Asterisk - The Open Source Telephony Project GIT-master-5963e62
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
internal.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * David M. Lee, II <dlee@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef ARI_INTERNAL_H_
20#define ARI_INTERNAL_H_
21
22/*! \file
23 *
24 * \brief Internal API's for res_ari.
25 * \author David M. Lee, II <dlee@digium.com>
26 */
27
28#include "asterisk/http.h"
29#include "asterisk/json.h"
30#include "asterisk/md5.h"
31#include "asterisk/sorcery.h"
34#include "ari_websockets.h"
35
36
37/*! @{ */
38
39/*!
40 * \brief Register CLI commands for ARI.
41 *
42 * \return 0 on success.
43 * \return Non-zero on error.
44 */
45int ari_cli_register(void);
46
47/*!
48 * \brief Unregister CLI commands for ARI.
49 */
50void ari_cli_unregister(void);
51
52/*! @} */
53
54/*! @{ */
55
56/*! \brief Global configuration options for ARI. */
60 /*! Allowed CORS origins */
62 /*! Authentication realm */
64 /*! Channel variables */
66 );
67 /*! Enabled by default, disabled if false. */
69 /*! Write timeout for websocket connections */
71 /*! Encoding format used during output (default compact). */
73};
74
75/*! \brief Password format */
77 /*! \brief Plaintext password */
79 /*! crypt(3) password */
81};
82
83/*! \brief Per-user configuration options */
87 /*! User's password. */
89 );
90 /*! Format for the password field */
92 /*! If true, user cannot execute change operations */
94};
95
107};
108
112 AST_STRING_FIELD(websocket_client_id); /*!< The ID of the websocket client to use */
113 AST_STRING_FIELD(apps); /*!< Stasis apps using this connection */
114 AST_STRING_FIELD(local_ari_user);/*!< The ARI user to act as */
115 AST_STRING_FIELD(local_ari_password); /*!< The password for the ARI user */
116 );
117 int invalid; /*!< Invalid configuration */
118 int subscribe_all; /*!< Subscribe to all events */
119 struct ast_websocket_client *websocket_client; /*!< The websocket client */
120};
121
122/*!
123 * \brief Detect changes between two outbound websocket configurations.
124 *
125 * \param old_owc The old outbound websocket configuration.
126 * \param new_owc The new outbound websocket configuration.
127 * \return A bitmask of changed fields.
128 */
130 struct ari_conf_outbound_websocket *old_owc,
131 struct ari_conf_outbound_websocket *new_owc);
132
133/*!
134 * \brief Get the outbound websocket configuration for a Stasis app.
135 *
136 * \param app_name The application name to search for.
137 * \param ws_type An OR'd list of ari_websocket_types or ARI_WS_TYPE_ANY.
138 *
139 * \retval ARI outbound websocket configuration object.
140 * \retval NULL if not found.
141 */
143 const char *app_name, unsigned int ws_type);
144
146 ARI_CONF_INIT = (1 << 0), /*!< Initialize sorcery */
147 ARI_CONF_RELOAD = (1 << 1), /*!< Reload sorcery */
148 ARI_CONF_LOAD_GENERAL = (1 << 2), /*!< Load general config */
149 ARI_CONF_LOAD_USER = (1 << 3), /*!< Load user config */
150 ARI_CONF_LOAD_OWC = (1 << 4), /*!< Load outbound websocket config */
151 ARI_CONF_LOAD_ALL = ( /*!< Load all configs */
155};
156
157/*!
158 * \brief (Re)load the ARI configuration
159 */
160int ari_conf_load(enum ari_conf_load_flags flags);
161
162/*!
163 * \brief Destroy the ARI configuration
164 */
165void ari_conf_destroy(void);
166
169struct ari_conf_user *ari_conf_get_user(const char *username);
170struct ao2_container *ari_conf_get_owcs(void);
171struct ari_conf_outbound_websocket *ari_conf_get_owc(const char *id);
174int ari_sorcery_observer_add(const char *object_type,
175 const struct ast_sorcery_observer *callbacks);
176int ari_sorcery_observer_remove(const char *object_type,
177 const struct ast_sorcery_observer *callbacks);
178
179/*!
180 * \brief Validated a user's credentials.
181 *
182 * \param username Name of the user.
183 * \param password User's password.
184 * \return User object.
185 * \retval NULL if username or password is invalid.
186 */
187struct ari_conf_user *ari_conf_validate_user(const char *username,
188 const char *password);
189
190/*! @} */
191
192#endif /* ARI_INTERNAL_H_ */
Internal API's for websockets.
static const char type[]
Definition: chan_ooh323.c:109
Support for Private Asterisk HTTP Servers.
ast_websocket_type
WebSocket connection/configuration types.
struct ari_conf_outbound_websocket * ari_conf_get_owc_for_app(const char *app_name, unsigned int ws_type)
Get the outbound websocket configuration for a Stasis app.
ari_conf_load_flags
Definition: internal.h:145
@ ARI_CONF_LOAD_ALL
Definition: internal.h:151
@ ARI_CONF_RELOAD
Definition: internal.h:147
@ ARI_CONF_INIT
Definition: internal.h:146
@ ARI_CONF_LOAD_OWC
Definition: internal.h:150
@ ARI_CONF_LOAD_USER
Definition: internal.h:149
@ ARI_CONF_LOAD_GENERAL
Definition: internal.h:148
int ari_sorcery_observer_remove(const char *object_type, const struct ast_sorcery_observer *callbacks)
enum ari_conf_owc_fields ari_conf_owc_get_invalid_fields(const char *id)
struct ao2_container * ari_conf_get_owcs(void)
struct ao2_container * ari_conf_get_users(void)
enum ari_conf_owc_fields ari_conf_owc_detect_changes(struct ari_conf_outbound_websocket *old_owc, struct ari_conf_outbound_websocket *new_owc)
Detect changes between two outbound websocket configurations.
int ari_conf_load(enum ari_conf_load_flags flags)
(Re)load the ARI configuration
ari_user_password_format
Password format.
Definition: internal.h:76
@ ARI_PASSWORD_FORMAT_CRYPT
Definition: internal.h:80
@ ARI_PASSWORD_FORMAT_PLAIN
Plaintext password.
Definition: internal.h:78
ari_conf_owc_fields
Definition: internal.h:96
@ ARI_OWC_FIELD_APPS
Definition: internal.h:99
@ ARI_OWC_FIELD_WEBSOCKET_CONNECTION_ID
Definition: internal.h:98
@ ARI_OWC_NEEDS_REREGISTER
Definition: internal.h:106
@ ARI_OWC_FIELD_LOCAL_ARI_PASSWORD
Definition: internal.h:101
@ ARI_OWC_FIELD_NONE
Definition: internal.h:97
@ ARI_OWC_FIELD_LOCAL_ARI_USER
Definition: internal.h:100
@ ARI_OWC_FIELD_SUBSCRIBE_ALL
Definition: internal.h:102
@ ARI_OWC_NEEDS_RECONNECT
Definition: internal.h:103
const char * ari_websocket_type_to_str(enum ast_websocket_type type)
int ari_sorcery_observer_add(const char *object_type, const struct ast_sorcery_observer *callbacks)
struct ari_conf_general * ari_conf_get_general(void)
void ari_cli_unregister(void)
Unregister CLI commands for ARI.
Definition: res/ari/cli.c:703
struct ari_conf_outbound_websocket * ari_conf_get_owc(const char *id)
struct ari_conf_user * ari_conf_get_user(const char *username)
int ari_cli_register(void)
Register CLI commands for ARI.
Definition: res/ari/cli.c:699
struct ari_conf_user * ari_conf_validate_user(const char *username, const char *password)
Validated a user's credentials.
void ari_conf_destroy(void)
Destroy the ARI configuration.
Asterisk JSON abstraction layer.
ast_json_encoding_format
Encoding format type.
Definition: json.h:791
MD5 digest functions.
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
struct @474 callbacks
Sorcery Data Access Layer API.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
Generic container type.
Registered applications container.
Definition: pbx_app.c:68
Global configuration options for ARI.
Definition: internal.h:57
SORCERY_OBJECT(details)
const ast_string_field channelvars
Definition: internal.h:66
const ast_string_field allowed_origins
Definition: internal.h:66
enum ast_json_encoding_format format
Definition: internal.h:72
const ast_string_field auth_realm
Definition: internal.h:66
const ast_string_field local_ari_password
Definition: internal.h:116
struct ast_websocket_client * websocket_client
Definition: internal.h:119
const ast_string_field local_ari_user
Definition: internal.h:116
const ast_string_field websocket_client_id
Definition: internal.h:116
Per-user configuration options.
Definition: internal.h:84
SORCERY_OBJECT(details)
enum ari_user_password_format password_format
Definition: internal.h:91
int read_only
Definition: internal.h:93
const ast_string_field password
Definition: internal.h:89
Interface for a sorcery object type observer.
Definition: sorcery.h:332
@ AST_WS_CLIENT_NEEDS_RECONNECT
#define AST_WS_CLIENT_FIELD_USER_START