Asterisk - The Open Source Telephony Project GIT-master-6144b6b
Loading...
Searching...
No Matches
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/acl.h"
29#include "asterisk/http.h"
30#include "asterisk/json.h"
31#include "asterisk/md5.h"
32#include "asterisk/sorcery.h"
35#include "ari_websockets.h"
36
37
38/*! @{ */
39
40/*!
41 * \brief Register CLI commands for ARI.
42 *
43 * \return 0 on success.
44 * \return Non-zero on error.
45 */
46int ari_cli_register(void);
47
48/*!
49 * \brief Unregister CLI commands for ARI.
50 */
51void ari_cli_unregister(void);
52
53/*! @} */
54
55/*! @{ */
56
57/*! \brief Global configuration options for ARI. */
61 /*! Allowed CORS origins */
63 /*! Authentication realm */
65 /*! Channel variables */
67 );
68 /*! Enabled by default, disabled if false. */
70 /*! Write timeout for websocket connections */
72 /*! Encoding format used during output (default compact). */
74};
75
76/*! \brief Password format */
78 /*! \brief Plaintext password */
80 /*! crypt(3) password */
82};
83
84/*! \brief Per-user configuration options */
88 /*! User's password. */
90 );
91 /*! Format for the password field */
93 /*! If true, user cannot execute change operations */
95 /*! ACL setting */
97};
98
99/*
100 * Using 1ULL is important as it forces the enum to be 64 bits to match
101 * the size of enum ast_ws_client_fields.
102 */
115
119 AST_STRING_FIELD(websocket_client_id); /*!< The ID of the websocket client to use */
120 AST_STRING_FIELD(apps); /*!< Stasis apps using this connection */
121 AST_STRING_FIELD(local_ari_user);/*!< The ARI user to act as */
122 AST_STRING_FIELD(local_ari_password); /*!< The password for the ARI user */
123 );
124 int invalid; /*!< Invalid configuration */
125 int subscribe_all; /*!< Subscribe to all events */
126 struct ast_websocket_client *websocket_client; /*!< The websocket client */
127};
128
129/*!
130 * \brief Detect changes between two outbound websocket configurations.
131 *
132 * \param old_owc The old outbound websocket configuration.
133 * \param new_owc The new outbound websocket configuration.
134 * \return A bitmask of changed fields.
135 */
137 struct ari_conf_outbound_websocket *old_owc,
138 struct ari_conf_outbound_websocket *new_owc);
139
140/*!
141 * \brief Get the outbound websocket configuration for a Stasis app.
142 *
143 * \param app_name The application name to search for.
144 * \param ws_type An OR'd list of ari_websocket_types or ARI_WS_TYPE_ANY.
145 *
146 * \retval ARI outbound websocket configuration object.
147 * \retval NULL if not found.
148 */
150 const char *app_name, unsigned int ws_type);
151
153 ARI_CONF_INIT = (1 << 0), /*!< Initialize sorcery */
154 ARI_CONF_RELOAD = (1 << 1), /*!< Reload sorcery */
155 ARI_CONF_LOAD_GENERAL = (1 << 2), /*!< Load general config */
156 ARI_CONF_LOAD_USER = (1 << 3), /*!< Load user config */
157 ARI_CONF_LOAD_OWC = (1 << 4), /*!< Load outbound websocket config */
158 ARI_CONF_LOAD_ALL = ( /*!< Load all configs */
162};
163
164/*!
165 * \brief (Re)load the ARI configuration
166 */
167int ari_conf_load(enum ari_conf_load_flags flags);
168
169/*!
170 * \brief Destroy the ARI configuration
171 */
172void ari_conf_destroy(void);
173
176struct ari_conf_user *ari_conf_get_user(const char *username);
177struct ao2_container *ari_conf_get_owcs(void);
178struct ari_conf_outbound_websocket *ari_conf_get_owc(const char *id);
181int ari_sorcery_observer_add(const char *object_type,
182 const struct ast_sorcery_observer *callbacks);
183int ari_sorcery_observer_remove(const char *object_type,
184 const struct ast_sorcery_observer *callbacks);
185
186/*!
187 * \brief Validated a user's credentials.
188 *
189 * \param username Name of the user.
190 * \param password User's password.
191 * \return User object.
192 * \retval NULL if username or password is invalid.
193 */
194struct ari_conf_user *ari_conf_validate_user(const char *username,
195 const char *password);
196
197/*! @} */
198
199#endif /* ARI_INTERNAL_H_ */
Access Control of various sorts.
Internal API's for websockets.
static const char type[]
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:152
@ ARI_CONF_LOAD_ALL
Definition internal.h:158
@ ARI_CONF_RELOAD
Definition internal.h:154
@ ARI_CONF_INIT
Definition internal.h:153
@ ARI_CONF_LOAD_OWC
Definition internal.h:157
@ ARI_CONF_LOAD_USER
Definition internal.h:156
@ ARI_CONF_LOAD_GENERAL
Definition internal.h:155
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:77
@ ARI_PASSWORD_FORMAT_CRYPT
Definition internal.h:81
@ ARI_PASSWORD_FORMAT_PLAIN
Plaintext password.
Definition internal.h:79
ari_conf_owc_fields
Definition internal.h:103
@ ARI_OWC_FIELD_APPS
Definition internal.h:106
@ ARI_OWC_FIELD_WEBSOCKET_CONNECTION_ID
Definition internal.h:105
@ ARI_OWC_NEEDS_REREGISTER
Definition internal.h:113
@ ARI_OWC_FIELD_LOCAL_ARI_PASSWORD
Definition internal.h:108
@ ARI_OWC_FIELD_NONE
Definition internal.h:104
@ ARI_OWC_FIELD_LOCAL_ARI_USER
Definition internal.h:107
@ ARI_OWC_FIELD_SUBSCRIBE_ALL
Definition internal.h:109
@ ARI_OWC_NEEDS_RECONNECT
Definition internal.h:110
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.
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.
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:475
struct @509 callbacks
Sorcery Data Access Layer API.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
Generic container type.
Registered applications container.
Definition pbx_app.c:69
Global configuration options for ARI.
Definition internal.h:58
SORCERY_OBJECT(details)
const ast_string_field channelvars
Definition internal.h:67
const ast_string_field allowed_origins
Definition internal.h:67
enum ast_json_encoding_format format
Definition internal.h:73
const ast_string_field auth_realm
Definition internal.h:67
const ast_string_field local_ari_password
Definition internal.h:123
struct ast_websocket_client * websocket_client
Definition internal.h:126
const ast_string_field local_ari_user
Definition internal.h:123
const ast_string_field websocket_client_id
Definition internal.h:123
Per-user configuration options.
Definition internal.h:85
SORCERY_OBJECT(details)
enum ari_user_password_format password_format
Definition internal.h:92
const ast_string_field password
Definition internal.h:90
struct ast_acl_list * acl
Definition internal.h:96
Wrapper for an ast_acl linked list.
Definition acl.h:76
Interface for a sorcery object type observer.
Definition sorcery.h:332
@ AST_WS_CLIENT_NEEDS_RECONNECT
#define AST_WS_CLIENT_FIELD_USER_START