Asterisk - The Open Source Telephony Project GIT-master-80b953f
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
111
115 AST_STRING_FIELD(websocket_client_id); /*!< The ID of the websocket client to use */
116 AST_STRING_FIELD(apps); /*!< Stasis apps using this connection */
117 AST_STRING_FIELD(local_ari_user);/*!< The ARI user to act as */
118 AST_STRING_FIELD(local_ari_password); /*!< The password for the ARI user */
119 );
120 int invalid; /*!< Invalid configuration */
121 int subscribe_all; /*!< Subscribe to all events */
122 struct ast_websocket_client *websocket_client; /*!< The websocket client */
123};
124
125/*!
126 * \brief Detect changes between two outbound websocket configurations.
127 *
128 * \param old_owc The old outbound websocket configuration.
129 * \param new_owc The new outbound websocket configuration.
130 * \return A bitmask of changed fields.
131 */
133 struct ari_conf_outbound_websocket *old_owc,
134 struct ari_conf_outbound_websocket *new_owc);
135
136/*!
137 * \brief Get the outbound websocket configuration for a Stasis app.
138 *
139 * \param app_name The application name to search for.
140 * \param ws_type An OR'd list of ari_websocket_types or ARI_WS_TYPE_ANY.
141 *
142 * \retval ARI outbound websocket configuration object.
143 * \retval NULL if not found.
144 */
146 const char *app_name, unsigned int ws_type);
147
149 ARI_CONF_INIT = (1 << 0), /*!< Initialize sorcery */
150 ARI_CONF_RELOAD = (1 << 1), /*!< Reload sorcery */
151 ARI_CONF_LOAD_GENERAL = (1 << 2), /*!< Load general config */
152 ARI_CONF_LOAD_USER = (1 << 3), /*!< Load user config */
153 ARI_CONF_LOAD_OWC = (1 << 4), /*!< Load outbound websocket config */
154 ARI_CONF_LOAD_ALL = ( /*!< Load all configs */
158};
159
160/*!
161 * \brief (Re)load the ARI configuration
162 */
163int ari_conf_load(enum ari_conf_load_flags flags);
164
165/*!
166 * \brief Destroy the ARI configuration
167 */
168void ari_conf_destroy(void);
169
172struct ari_conf_user *ari_conf_get_user(const char *username);
173struct ao2_container *ari_conf_get_owcs(void);
174struct ari_conf_outbound_websocket *ari_conf_get_owc(const char *id);
177int ari_sorcery_observer_add(const char *object_type,
178 const struct ast_sorcery_observer *callbacks);
179int ari_sorcery_observer_remove(const char *object_type,
180 const struct ast_sorcery_observer *callbacks);
181
182/*!
183 * \brief Validated a user's credentials.
184 *
185 * \param username Name of the user.
186 * \param password User's password.
187 * \return User object.
188 * \retval NULL if username or password is invalid.
189 */
190struct ari_conf_user *ari_conf_validate_user(const char *username,
191 const char *password);
192
193/*! @} */
194
195#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:148
@ ARI_CONF_LOAD_ALL
Definition internal.h:154
@ ARI_CONF_RELOAD
Definition internal.h:150
@ ARI_CONF_INIT
Definition internal.h:149
@ ARI_CONF_LOAD_OWC
Definition internal.h:153
@ ARI_CONF_LOAD_USER
Definition internal.h:152
@ ARI_CONF_LOAD_GENERAL
Definition internal.h:151
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:99
@ ARI_OWC_FIELD_APPS
Definition internal.h:102
@ ARI_OWC_FIELD_WEBSOCKET_CONNECTION_ID
Definition internal.h:101
@ ARI_OWC_NEEDS_REREGISTER
Definition internal.h:109
@ ARI_OWC_FIELD_LOCAL_ARI_PASSWORD
Definition internal.h:104
@ ARI_OWC_FIELD_NONE
Definition internal.h:100
@ ARI_OWC_FIELD_LOCAL_ARI_USER
Definition internal.h:103
@ ARI_OWC_FIELD_SUBSCRIBE_ALL
Definition internal.h:105
@ ARI_OWC_NEEDS_RECONNECT
Definition internal.h:106
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 @508 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:119
struct ast_websocket_client * websocket_client
Definition internal.h:122
const ast_string_field local_ari_user
Definition internal.h:119
const ast_string_field websocket_client_id
Definition internal.h:119
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