Asterisk - The Open Source Telephony Project GIT-master-7e7a603
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"
31
32/*! @{ */
33
34/*!
35 * \brief Register CLI commands for ARI.
36 *
37 * \return 0 on success.
38 * \return Non-zero on error.
39 */
40int ast_ari_cli_register(void);
41
42/*!
43 * \brief Unregister CLI commands for ARI.
44 */
45void ast_ari_cli_unregister(void);
46
47/*! @} */
48
49/*! @{ */
50
52
53/*! \brief All configuration options for ARI. */
55 /*! The general section configuration options. */
57 /*! Configured users */
59};
60
61/*! Max length for auth_realm field */
62#define ARI_AUTH_REALM_LEN 256
63
64/*! \brief Global configuration options for ARI. */
66 /*! Enabled by default, disabled if false. */
68 /*! Write timeout for websocket connections */
70 /*! Encoding format used during output (default compact). */
72 /*! Authentication realm */
74
77 );
78};
79
80/*! \brief Password format */
82 /*! \brief Plaintext password */
84 /*! crypt(3) password */
86};
87
88/*!
89 * \brief User's password mx length.
90 *
91 * If 256 seems like a lot, a crypt SHA-512 has over 106 characters.
92 */
93#define ARI_PASSWORD_LEN 256
94
95/*! \brief Per-user configuration options */
97 /*! Username for authentication */
98 char *username;
99 /*! User's password. */
101 /*! Format for the password field */
103 /*! If true, user cannot execute change operations */
105};
106
107/*!
108 * \brief Initialize the ARI configuration
109 */
110int ast_ari_config_init(void);
111
112/*!
113 * \brief Reload the ARI configuration
114 */
115int ast_ari_config_reload(void);
116
117/*!
118 * \brief Destroy the ARI configuration
119 */
120void ast_ari_config_destroy(void);
121
122/*!
123 * \brief Get the current ARI configuration.
124 *
125 * This is an immutable object, so don't modify it. It is AO2 managed, so
126 * ao2_cleanup() when you're done with it.
127 *
128 * \return ARI configuration object.
129 * \retval NULL on error.
130 */
131struct ast_ari_conf *ast_ari_config_get(void);
132
133/*!
134 * \brief Validated a user's credentials.
135 *
136 * \param username Name of the user.
137 * \param password User's password.
138 * \return User object.
139 * \retval NULL if username or password is invalid.
140 */
142 const char *password);
143
144/*! @} */
145
146/* Forward-declare websocket structs. This avoids including http_websocket.h,
147 * which causes optional_api stuff to happen, which makes optional_api more
148 * difficult to debug. */
149
151
152/*!
153 * \brief Wrapper for invoking the websocket code for an incoming connection.
154 *
155 * \param ws_server WebSocket server to invoke.
156 * \param ser HTTP session.
157 * \param uri Requested URI.
158 * \param method Requested HTTP method.
159 * \param get_params Parsed query parameters.
160 * \param headers Parsed HTTP headers.
161 */
162void ari_handle_websocket(struct ast_websocket_server *ws_server,
163 struct ast_tcptls_session_instance *ser, const char *uri,
164 enum ast_http_method method, struct ast_variable *get_params,
165 struct ast_variable *headers);
166
167#endif /* ARI_INTERNAL_H_ */
Support for Private Asterisk HTTP Servers.
ast_http_method
HTTP Request methods known by Asterisk.
Definition: http.h:58
struct ast_ari_conf * ast_ari_config_get(void)
Get the current ARI configuration.
int ast_ari_config_reload(void)
Reload the ARI configuration.
void ari_handle_websocket(struct ast_websocket_server *ws_server, struct ast_tcptls_session_instance *ser, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
Wrapper for invoking the websocket code for an incoming connection.
#define ARI_PASSWORD_LEN
User's password mx length.
Definition: internal.h:93
int ast_ari_cli_register(void)
Register CLI commands for ARI.
Definition: res/ari/cli.c:431
int ast_ari_config_init(void)
Initialize the ARI configuration.
void ast_ari_cli_unregister(void)
Unregister CLI commands for ARI.
Definition: res/ari/cli.c:435
#define ARI_AUTH_REALM_LEN
Definition: internal.h:62
struct ast_ari_conf_user * ast_ari_config_validate_user(const char *username, const char *password)
Validated a user's credentials.
void ast_ari_config_destroy(void)
Destroy the ARI configuration.
ast_ari_password_format
Password format.
Definition: internal.h:81
@ ARI_PASSWORD_FORMAT_CRYPT
Definition: internal.h:85
@ ARI_PASSWORD_FORMAT_PLAIN
Plaintext password.
Definition: internal.h:83
Asterisk JSON abstraction layer.
ast_json_encoding_format
Encoding format type.
Definition: json.h:791
const char * method
Definition: res_pjsip.c:1279
#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.
Global configuration options for ARI.
Definition: internal.h:65
char auth_realm[ARI_AUTH_REALM_LEN]
Definition: internal.h:73
const ast_string_field allowed_origins
Definition: internal.h:77
enum ast_json_encoding_format format
Definition: internal.h:71
Per-user configuration options.
Definition: internal.h:96
char password[ARI_PASSWORD_LEN]
Definition: internal.h:100
enum ast_ari_password_format password_format
Definition: internal.h:102
char * username
Definition: internal.h:98
All configuration options for ARI.
Definition: internal.h:54
struct ao2_container * users
Definition: internal.h:58
struct ast_ari_conf_general * general
Definition: internal.h:56
describes a server instance
Definition: tcptls.h:150
Structure for variables, used for configurations and for channel variables.
Structure for a WebSocket server.