#include "iax2-parser.h"
Go to the source code of this file.
Defines | |
#define | PROV_FLAG_DEBUG (1 << 3) |
#define | PROV_FLAG_DIS_CALLERID (1 << 4) |
#define | PROV_FLAG_DIS_CALLWAIT (1 << 5) |
#define | PROV_FLAG_DIS_CIDCW (1 << 6) |
#define | PROV_FLAG_DIS_THREEWAY (1 << 7) |
#define | PROV_FLAG_HEARTBEAT (1 << 2) |
#define | PROV_FLAG_REGISTER (1 << 0) |
#define | PROV_FLAG_SECURE (1 << 1) |
#define | PROV_IE_AESKEY 14 |
#define | PROV_IE_ALTSERVER 19 |
#define | PROV_IE_FLAGS 12 |
#define | PROV_IE_FORMAT 13 |
#define | PROV_IE_GATEWAY 4 |
#define | PROV_IE_IPADDR 2 |
#define | PROV_IE_LANG 10 |
#define | PROV_IE_NEWAESKEY 17 |
#define | PROV_IE_PASS 7 |
#define | PROV_IE_PORTNO 5 |
#define | PROV_IE_PROVVER 18 |
#define | PROV_IE_SERVERIP 15 |
#define | PROV_IE_SERVERPASS 9 |
#define | PROV_IE_SERVERPORT 16 |
#define | PROV_IE_SERVERUSER 8 |
#define | PROV_IE_SUBNET 3 |
#define | PROV_IE_TOS 11 |
#define | PROV_IE_USEDHCP 1 |
#define | PROV_IE_USER 6 |
Functions | |
char * | iax_prov_complete_template (const char *line, const char *word, int pos, int state) |
char * | iax_provflags2str (char *buf, int buflen, unsigned int flags) |
int | iax_provision_build (struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force) |
int | iax_provision_reload (int reload) |
int | iax_provision_unload (void) |
int | iax_provision_version (unsigned int *signature, const char *template, int force) |
Definition in file iax2-provision.h.
#define PROV_FLAG_DEBUG (1 << 3) |
Definition at line 41 of file iax2-provision.h.
#define PROV_FLAG_DIS_CALLERID (1 << 4) |
Definition at line 43 of file iax2-provision.h.
#define PROV_FLAG_DIS_CALLWAIT (1 << 5) |
Definition at line 44 of file iax2-provision.h.
#define PROV_FLAG_DIS_CIDCW (1 << 6) |
Definition at line 45 of file iax2-provision.h.
#define PROV_FLAG_DIS_THREEWAY (1 << 7) |
Definition at line 46 of file iax2-provision.h.
#define PROV_FLAG_HEARTBEAT (1 << 2) |
Definition at line 40 of file iax2-provision.h.
#define PROV_FLAG_REGISTER (1 << 0) |
Definition at line 38 of file iax2-provision.h.
#define PROV_FLAG_SECURE (1 << 1) |
Definition at line 39 of file iax2-provision.h.
#define PROV_IE_AESKEY 14 |
Definition at line 31 of file iax2-provision.h.
#define PROV_IE_ALTSERVER 19 |
#define PROV_IE_FLAGS 12 |
#define PROV_IE_FORMAT 13 |
#define PROV_IE_GATEWAY 4 |
Definition at line 21 of file iax2-provision.h.
#define PROV_IE_IPADDR 2 |
Definition at line 19 of file iax2-provision.h.
#define PROV_IE_LANG 10 |
#define PROV_IE_NEWAESKEY 17 |
Definition at line 34 of file iax2-provision.h.
#define PROV_IE_PASS 7 |
#define PROV_IE_PORTNO 5 |
#define PROV_IE_PROVVER 18 |
#define PROV_IE_SERVERIP 15 |
#define PROV_IE_SERVERPASS 9 |
Definition at line 26 of file iax2-provision.h.
#define PROV_IE_SERVERPORT 16 |
#define PROV_IE_SERVERUSER 8 |
Definition at line 25 of file iax2-provision.h.
#define PROV_IE_SUBNET 3 |
Definition at line 20 of file iax2-provision.h.
#define PROV_IE_TOS 11 |
#define PROV_IE_USEDHCP 1 |
Definition at line 18 of file iax2-provision.h.
#define PROV_IE_USER 6 |
char* iax_prov_complete_template | ( | const char * | line, | |
const char * | word, | |||
int | pos, | |||
int | state | |||
) |
Definition at line 174 of file iax2-provision.c.
References AST_LIST_TRAVERSE, ast_mutex_lock, ast_mutex_unlock, ast_strdup, iax_template::list, iax_template::name, and provlock.
Referenced by handle_cli_iax2_provision(), and iax_show_provisioning().
00175 { 00176 struct iax_template *c; 00177 int which=0; 00178 char *ret = NULL; 00179 int wordlen = strlen(word); 00180 00181 if (pos == 3) { 00182 ast_mutex_lock(&provlock); 00183 AST_LIST_TRAVERSE(&templates, c, list) { 00184 if (!strncasecmp(word, c->name, wordlen) && ++which > state) { 00185 ret = ast_strdup(c->name); 00186 break; 00187 } 00188 } 00189 ast_mutex_unlock(&provlock); 00190 } 00191 return ret; 00192 }
char* iax_provflags2str | ( | char * | buf, | |
int | buflen, | |||
unsigned int | flags | |||
) |
Definition at line 85 of file iax2-provision.c.
References ARRAY_LEN, ast_strlen_zero(), iax_flags, iax_template::name, and value.
Referenced by dump_prov_flags(), and iax_show_provisioning().
00086 { 00087 int x; 00088 00089 if (!buf || buflen < 1) 00090 return NULL; 00091 00092 buf[0] = '\0'; 00093 00094 for (x = 0; x < ARRAY_LEN(iax_flags); x++) { 00095 if (flags & iax_flags[x].value){ 00096 strncat(buf, iax_flags[x].name, buflen - strlen(buf) - 1); 00097 strncat(buf, ",", buflen - strlen(buf) - 1); 00098 } 00099 } 00100 00101 if (!ast_strlen_zero(buf)) 00102 buf[strlen(buf) - 1] = '\0'; 00103 else 00104 strncpy(buf, "none", buflen - 1); 00105 00106 return buf; 00107 }
int iax_provision_build | ( | struct iax_ie_data * | provdata, | |
unsigned int * | signature, | |||
const char * | template, | |||
int | force | |||
) |
Definition at line 204 of file iax2-provision.c.
References iax_template::altserver, ast_db_put(), ast_mutex_lock, ast_mutex_unlock, iax_template::flags, iax_template::format, iax_ie_append_byte(), iax_ie_append_int(), iax_ie_append_short(), iax_ie_append_str(), iax_template_find(), iax_template::lang, iax_template::pass, iax_template::port, PROV_IE_ALTSERVER, PROV_IE_FLAGS, PROV_IE_FORMAT, PROV_IE_LANG, PROV_IE_PASS, PROV_IE_PORTNO, PROV_IE_PROVVER, PROV_IE_SERVERIP, PROV_IE_SERVERPORT, PROV_IE_TOS, PROV_IE_USER, prov_ver_calc(), provlock, iax_template::server, iax_template::serverport, iax_template::tos, and iax_template::user.
Referenced by iax2_provision(), and iax_provision_version().
00205 { 00206 struct iax_template *cur; 00207 unsigned int sig; 00208 char tmp[40]; 00209 memset(provdata, 0, sizeof(*provdata)); 00210 ast_mutex_lock(&provlock); 00211 cur = iax_template_find(template, 1); 00212 /* If no match, try searching for '*' */ 00213 if (!cur) 00214 cur = iax_template_find("*", 1); 00215 if (cur) { 00216 /* found it -- add information elements as appropriate */ 00217 if (force || strlen(cur->user)) 00218 iax_ie_append_str(provdata, PROV_IE_USER, cur->user); 00219 if (force || strlen(cur->pass)) 00220 iax_ie_append_str(provdata, PROV_IE_PASS, cur->pass); 00221 if (force || strlen(cur->lang)) 00222 iax_ie_append_str(provdata, PROV_IE_LANG, cur->lang); 00223 if (force || cur->port) 00224 iax_ie_append_short(provdata, PROV_IE_PORTNO, cur->port); 00225 if (force || cur->server) 00226 iax_ie_append_int(provdata, PROV_IE_SERVERIP, cur->server); 00227 if (force || cur->serverport) 00228 iax_ie_append_short(provdata, PROV_IE_SERVERPORT, cur->serverport); 00229 if (force || cur->altserver) 00230 iax_ie_append_int(provdata, PROV_IE_ALTSERVER, cur->altserver); 00231 if (force || cur->flags) 00232 iax_ie_append_int(provdata, PROV_IE_FLAGS, cur->flags); 00233 if (force || cur->format) 00234 iax_ie_append_int(provdata, PROV_IE_FORMAT, cur->format); 00235 if (force || cur->tos) 00236 iax_ie_append_byte(provdata, PROV_IE_TOS, cur->tos); 00237 00238 /* Calculate checksum of message so far */ 00239 sig = prov_ver_calc(provdata); 00240 if (signature) 00241 *signature = sig; 00242 /* Store signature */ 00243 iax_ie_append_int(provdata, PROV_IE_PROVVER, sig); 00244 /* Cache signature for later verification so we need not recalculate all this */ 00245 snprintf(tmp, sizeof(tmp), "v0x%08x", sig); 00246 ast_db_put("iax/provisioning/cache", template, tmp); 00247 } else 00248 ast_db_put("iax/provisioning/cache", template, "u"); 00249 ast_mutex_unlock(&provlock); 00250 return cur ? 0 : -1; 00251 }
int iax_provision_reload | ( | int | reload | ) |
Definition at line 520 of file iax2-provision.c.
References ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_db_deltree(), AST_LIST_TRAVERSE, ast_log(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, config_flags, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, iax_template::dead, iax_process_template(), iax_provision_free_templates(), iax_provision_init(), iax_template::list, and LOG_NOTICE.
Referenced by load_module(), and reload_config().
00521 { 00522 struct ast_config *cfg; 00523 struct iax_template *cur; 00524 char *cat; 00525 int found = 0; 00526 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 00527 if (!provinit) 00528 iax_provision_init(); 00529 00530 cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags); 00531 if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) { 00532 /* Mark all as dead. No need for locking */ 00533 AST_LIST_TRAVERSE(&templates, cur, list) { 00534 cur->dead = 1; 00535 } 00536 00537 /* Load as appropriate */ 00538 cat = ast_category_browse(cfg, NULL); 00539 while(cat) { 00540 if (strcasecmp(cat, "general")) { 00541 iax_process_template(cfg, cat, found ? "default" : NULL); 00542 found++; 00543 ast_verb(3, "Loaded provisioning template '%s'\n", cat); 00544 } 00545 cat = ast_category_browse(cfg, cat); 00546 } 00547 ast_config_destroy(cfg); 00548 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) 00549 return 0; 00550 else 00551 ast_log(LOG_NOTICE, "No IAX provisioning configuration found, IAX provisioning disabled.\n"); 00552 00553 iax_provision_free_templates(1 /* remove only marked as dead */); 00554 00555 /* Purge cached signature DB entries */ 00556 ast_db_deltree("iax/provisioning/cache", NULL); 00557 return 0; 00558 }
int iax_provision_unload | ( | void | ) |
Definition at line 511 of file iax2-provision.c.
References ast_cli_unregister_multiple(), cli_iax2_provision, and iax_provision_free_templates().
Referenced by __unload_module().
00512 { 00513 provinit = 0; 00514 ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry)); 00515 iax_provision_free_templates(0 /* Remove all templates. */); 00516 00517 return 0; 00518 }
int iax_provision_version | ( | unsigned int * | signature, | |
const char * | template, | |||
int | force | |||
) |
Definition at line 253 of file iax2-provision.c.
References ast_db_get(), ast_debug, ast_mutex_lock, ast_mutex_unlock, iax_provision_build(), and provlock.
Referenced by check_provisioning().
00254 { 00255 char tmp[80] = ""; 00256 struct iax_ie_data ied; 00257 int ret=0; 00258 memset(&ied, 0, sizeof(ied)); 00259 00260 ast_mutex_lock(&provlock); 00261 ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp)); 00262 if (sscanf(tmp, "v%30x", version) != 1) { 00263 if (strcmp(tmp, "u")) { 00264 ret = iax_provision_build(&ied, version, template, force); 00265 if (ret) 00266 ast_debug(1, "Unable to create provisioning packet for '%s'\n", template); 00267 } else 00268 ret = -1; 00269 } else 00270 ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version); 00271 ast_mutex_unlock(&provlock); 00272 return ret; 00273 }