| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef ARI_INTERNAL_H_ |
| 20 |
#define ARI_INTERNAL_H_ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 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" |
| 33 |
#include "asterisk/stringfields.h" |
| 34 |
#include "asterisk/websocket_client.h" |
| 35 |
#include "ari_websockets.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
int ari_cli_register(void); |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
void ari_cli_unregister(void); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
struct ari_conf_general { |
| 59 |
SORCERY_OBJECT(details); |
| 60 |
AST_DECLARE_STRING_FIELDS( |
| 61 |
|
| 62 |
AST_STRING_FIELD(allowed_origins); |
| 63 |
|
| 64 |
AST_STRING_FIELD(auth_realm); |
| 65 |
|
| 66 |
AST_STRING_FIELD(channelvars); |
| 67 |
); |
| 68 |
|
| 69 |
int enabled; |
| 70 |
|
| 71 |
int write_timeout; |
| 72 |
|
| 73 |
enum ast_json_encoding_format format; |
| 74 |
}; |
| 75 |
|
| 76 |
|
| 77 |
enum ari_user_password_format { |
| 78 |
|
| 79 |
ARI_PASSWORD_FORMAT_PLAIN, |
| 80 |
|
| 81 |
ARI_PASSWORD_FORMAT_CRYPT, |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
struct ari_conf_user { |
| 86 |
SORCERY_OBJECT(details); |
| 87 |
AST_DECLARE_STRING_FIELDS( |
| 88 |
|
| 89 |
AST_STRING_FIELD(password); |
| 90 |
); |
| 91 |
|
| 92 |
enum ari_user_password_format password_format; |
| 93 |
|
| 94 |
int read_only; |
| 95 |
|
| 96 |
struct ast_acl_list *acl; |
| 97 |
}; |
| 98 |
|
| 99 |
enum ari_conf_owc_fields { |
| 100 |
ARI_OWC_FIELD_NONE = 0, |
| 101 |
ARI_OWC_FIELD_WEBSOCKET_CONNECTION_ID = (1 << AST_WS_CLIENT_FIELD_USER_START), |
| 102 |
ARI_OWC_FIELD_APPS = (1 << (AST_WS_CLIENT_FIELD_USER_START + 1)), |
| 103 |
ARI_OWC_FIELD_LOCAL_ARI_USER = (1 << (AST_WS_CLIENT_FIELD_USER_START + 2)), |
| 104 |
ARI_OWC_FIELD_LOCAL_ARI_PASSWORD = (1 << (AST_WS_CLIENT_FIELD_USER_START + 3)), |
| 105 |
ARI_OWC_FIELD_SUBSCRIBE_ALL = (1 << (AST_WS_CLIENT_FIELD_USER_START + 4)), |
| 106 |
ARI_OWC_NEEDS_RECONNECT = AST_WS_CLIENT_NEEDS_RECONNECT |
| 107 |
| ARI_OWC_FIELD_WEBSOCKET_CONNECTION_ID | ARI_OWC_FIELD_LOCAL_ARI_USER |
| 108 |
| ARI_OWC_FIELD_LOCAL_ARI_PASSWORD, |
| 109 |
ARI_OWC_NEEDS_REREGISTER = ARI_OWC_FIELD_APPS | ARI_OWC_FIELD_SUBSCRIBE_ALL, |
| 110 |
}; |
| 111 |
|
| 112 |
struct ari_conf_outbound_websocket { |
| 113 |
SORCERY_OBJECT(details); |
| 114 |
AST_DECLARE_STRING_FIELDS( |
| 115 |
AST_STRING_FIELD(websocket_client_id); |
| 116 |
AST_STRING_FIELD(apps); |
| 117 |
AST_STRING_FIELD(local_ari_user); |
| 118 |
AST_STRING_FIELD(local_ari_password); |
| 119 |
); |
| 120 |
int invalid; |
| 121 |
int subscribe_all; |
| 122 |
struct ast_websocket_client *websocket_client; |
| 123 |
}; |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
enum ari_conf_owc_fields ari_conf_owc_detect_changes( |
| 133 |
struct ari_conf_outbound_websocket *old_owc, |
| 134 |
struct ari_conf_outbound_websocket *new_owc); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
struct ari_conf_outbound_websocket *ari_conf_get_owc_for_app( |
| 146 |
const char *app_name, unsigned int ws_type); |
| 147 |
|
| 148 |
enum ari_conf_load_flags { |
| 149 |
ARI_CONF_INIT = (1 << 0), |
| 150 |
ARI_CONF_RELOAD = (1 << 1), |
| 151 |
ARI_CONF_LOAD_GENERAL = (1 << 2), |
| 152 |
ARI_CONF_LOAD_USER = (1 << 3), |
| 153 |
ARI_CONF_LOAD_OWC = (1 << 4), |
| 154 |
ARI_CONF_LOAD_ALL = ( |
| 155 |
ARI_CONF_LOAD_GENERAL |
| 156 |
| ARI_CONF_LOAD_USER |
| 157 |
| ARI_CONF_LOAD_OWC), |
| 158 |
}; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
int ari_conf_load(enum ari_conf_load_flags flags); |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
void ari_conf_destroy(void); |
| 169 |
|
| 170 |
struct ari_conf_general* ari_conf_get_general(void); |
| 171 |
struct ao2_container *ari_conf_get_users(void); |
| 172 |
struct ari_conf_user *ari_conf_get_user(const char *username); |
| 173 |
struct ao2_container *ari_conf_get_owcs(void); |
| 174 |
struct ari_conf_outbound_websocket *ari_conf_get_owc(const char *id); |
| 175 |
enum ari_conf_owc_fields ari_conf_owc_get_invalid_fields(const char *id); |
| 176 |
const char *ari_websocket_type_to_str(enum ast_websocket_type type); |
| 177 |
int ari_sorcery_observer_add(const char *object_type, |
| 178 |
const struct ast_sorcery_observer *callbacks); |
| 179 |
int ari_sorcery_observer_remove(const char *object_type, |
| 180 |
const struct ast_sorcery_observer *callbacks); |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
struct ari_conf_user *ari_conf_validate_user(const char *username, |
| 191 |
const char *password); |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
#endif |