#include "asterisk.h"
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/socket.h>
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/md5.h"
#include "asterisk/astdb.h"
#include "asterisk/utils.h"
#include "asterisk/acl.h"
#include "iax2.h"
#include "iax2-provision.h"
#include "iax2-parser.h"
Go to the source code of this file.
Data Structures | |
struct | iax_flag |
struct | iax_template |
struct | templates |
Functions | |
static int | iax_process_template (struct ast_config *cfg, char *s, char *def) |
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) |
static void | iax_provision_free_templates (int dead) |
static int | iax_provision_init (void) |
int | iax_provision_reload (int reload) |
int | iax_provision_unload (void) |
int | iax_provision_version (unsigned int *version, const char *template, int force) |
static const char * | iax_server (unsigned int addr) |
static char * | iax_show_provisioning (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static unsigned int | iax_str2flags (const char *buf) |
static void | iax_template_copy (struct iax_template *dst, struct iax_template *src) |
static struct iax_template * | iax_template_find (const char *s, int allowdead) |
static int | iax_template_parse (struct iax_template *cur, struct ast_config *cfg, const char *s, const char *def) |
static const char * | ifthere (const char *s) |
static unsigned int | prov_ver_calc (struct iax_ie_data *provdata) |
Variables | |
static struct ast_cli_entry | cli_iax2_provision [] |
static struct iax_flag | iax_flags [] |
static int | provinit = 0 |
static ast_mutex_t | provlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
Definition in file iax2-provision.c.
static int iax_process_template | ( | struct ast_config * | cfg, | |
char * | s, | |||
char * | def | |||
) | [static] |
Definition at line 386 of file iax2-provision.c.
References ast_calloc, AST_LIST_INSERT_HEAD, ast_log(), ast_mutex_lock, ast_mutex_unlock, iax_template::dead, iax_template_find(), iax_template_parse(), iax_template::list, LOG_WARNING, and provlock.
Referenced by iax_provision_reload().
00387 { 00388 /* Find an already existing one if there */ 00389 struct iax_template *cur; 00390 int mallocd = 0; 00391 00392 cur = iax_template_find(s, 1 /* allow dead */); 00393 if (!cur) { 00394 mallocd = 1; 00395 cur = ast_calloc(1, sizeof(*cur)); 00396 if (!cur) { 00397 ast_log(LOG_WARNING, "Out of memory!\n"); 00398 return -1; 00399 } 00400 /* Initialize entry */ 00401 strncpy(cur->name, s, sizeof(cur->name) - 1); 00402 cur->dead = 1; 00403 } 00404 if (!iax_template_parse(cur, cfg, s, def)) 00405 cur->dead = 0; 00406 00407 /* Link if we're mallocd */ 00408 if (mallocd) { 00409 ast_mutex_lock(&provlock); 00410 AST_LIST_INSERT_HEAD(&templates, cur, list); 00411 ast_mutex_unlock(&provlock); 00412 } 00413 return 0; 00414 }
char* iax_prov_complete_template | ( | const char * | line, | |
const char * | word, | |||
int | pos, | |||
int | state | |||
) |
Definition at line 178 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().
00179 { 00180 struct iax_template *c; 00181 int which=0; 00182 char *ret = NULL; 00183 int wordlen = strlen(word); 00184 00185 if (pos == 3) { 00186 ast_mutex_lock(&provlock); 00187 AST_LIST_TRAVERSE(&templates, c, list) { 00188 if (!strncasecmp(word, c->name, wordlen) && ++which > state) { 00189 ret = ast_strdup(c->name); 00190 break; 00191 } 00192 } 00193 ast_mutex_unlock(&provlock); 00194 } 00195 return ret; 00196 }
char* iax_provflags2str | ( | char * | buf, | |
int | buflen, | |||
unsigned int | flags | |||
) |
Definition at line 89 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().
00090 { 00091 int x; 00092 00093 if (!buf || buflen < 1) 00094 return NULL; 00095 00096 buf[0] = '\0'; 00097 00098 for (x = 0; x < ARRAY_LEN(iax_flags); x++) { 00099 if (flags & iax_flags[x].value){ 00100 strncat(buf, iax_flags[x].name, buflen - strlen(buf) - 1); 00101 strncat(buf, ",", buflen - strlen(buf) - 1); 00102 } 00103 } 00104 00105 if (!ast_strlen_zero(buf)) 00106 buf[strlen(buf) - 1] = '\0'; 00107 else 00108 strncpy(buf, "none", buflen - 1); 00109 00110 return buf; 00111 }
int iax_provision_build | ( | struct iax_ie_data * | provdata, | |
unsigned int * | signature, | |||
const char * | template, | |||
int | force | |||
) |
Definition at line 208 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().
00209 { 00210 struct iax_template *cur; 00211 unsigned int sig; 00212 char tmp[40]; 00213 memset(provdata, 0, sizeof(*provdata)); 00214 ast_mutex_lock(&provlock); 00215 cur = iax_template_find(template, 1); 00216 /* If no match, try searching for '*' */ 00217 if (!cur) 00218 cur = iax_template_find("*", 1); 00219 if (cur) { 00220 /* found it -- add information elements as appropriate */ 00221 if (force || strlen(cur->user)) 00222 iax_ie_append_str(provdata, PROV_IE_USER, cur->user); 00223 if (force || strlen(cur->pass)) 00224 iax_ie_append_str(provdata, PROV_IE_PASS, cur->pass); 00225 if (force || strlen(cur->lang)) 00226 iax_ie_append_str(provdata, PROV_IE_LANG, cur->lang); 00227 if (force || cur->port) 00228 iax_ie_append_short(provdata, PROV_IE_PORTNO, cur->port); 00229 if (force || cur->server) 00230 iax_ie_append_int(provdata, PROV_IE_SERVERIP, cur->server); 00231 if (force || cur->serverport) 00232 iax_ie_append_short(provdata, PROV_IE_SERVERPORT, cur->serverport); 00233 if (force || cur->altserver) 00234 iax_ie_append_int(provdata, PROV_IE_ALTSERVER, cur->altserver); 00235 if (force || cur->flags) 00236 iax_ie_append_int(provdata, PROV_IE_FLAGS, cur->flags); 00237 if (force || cur->format) 00238 iax_ie_append_int(provdata, PROV_IE_FORMAT, cur->format); 00239 if (force || cur->tos) 00240 iax_ie_append_byte(provdata, PROV_IE_TOS, cur->tos); 00241 00242 /* Calculate checksum of message so far */ 00243 sig = prov_ver_calc(provdata); 00244 if (signature) 00245 *signature = sig; 00246 /* Store signature */ 00247 iax_ie_append_int(provdata, PROV_IE_PROVVER, sig); 00248 /* Cache signature for later verification so we need not recalculate all this */ 00249 snprintf(tmp, sizeof(tmp), "v0x%08x", sig); 00250 ast_db_put("iax/provisioning/cache", template, tmp); 00251 } else 00252 ast_db_put("iax/provisioning/cache", template, "u"); 00253 ast_mutex_unlock(&provlock); 00254 return cur ? 0 : -1; 00255 }
static void iax_provision_free_templates | ( | int | dead | ) | [static] |
Definition at line 503 of file iax2-provision.c.
References ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_mutex_lock, ast_mutex_unlock, iax_template::dead, iax_template::list, and provlock.
Referenced by iax_provision_reload(), and iax_provision_unload().
00504 { 00505 struct iax_template *cur; 00506 00507 /* Drop dead or not (depending on dead) entries while locked */ 00508 ast_mutex_lock(&provlock); 00509 AST_LIST_TRAVERSE_SAFE_BEGIN(&templates, cur, list) { 00510 if ((dead && cur->dead) || !dead) { 00511 AST_LIST_REMOVE_CURRENT(list); 00512 ast_free(cur); 00513 } 00514 } 00515 AST_LIST_TRAVERSE_SAFE_END; 00516 ast_mutex_unlock(&provlock); 00517 }
static int iax_provision_init | ( | void | ) | [static] |
Definition at line 496 of file iax2-provision.c.
References ast_cli_register_multiple(), and cli_iax2_provision.
Referenced by iax_provision_reload().
00497 { 00498 ast_cli_register_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry)); 00499 provinit = 1; 00500 return 0; 00501 }
int iax_provision_reload | ( | int | reload | ) |
Definition at line 528 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_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().
00529 { 00530 struct ast_config *cfg; 00531 struct iax_template *cur; 00532 char *cat; 00533 int found = 0; 00534 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 00535 if (!provinit) 00536 iax_provision_init(); 00537 00538 cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags); 00539 if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) { 00540 /* Mark all as dead. No need for locking */ 00541 AST_LIST_TRAVERSE(&templates, cur, list) { 00542 cur->dead = 1; 00543 } 00544 00545 /* Load as appropriate */ 00546 cat = ast_category_browse(cfg, NULL); 00547 while(cat) { 00548 if (strcasecmp(cat, "general")) { 00549 iax_process_template(cfg, cat, found ? "default" : NULL); 00550 found++; 00551 ast_verb(3, "Loaded provisioning template '%s'\n", cat); 00552 } 00553 cat = ast_category_browse(cfg, cat); 00554 } 00555 ast_config_destroy(cfg); 00556 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) 00557 return 0; 00558 else 00559 ast_log(LOG_NOTICE, "No IAX provisioning configuration found, IAX provisioning disabled.\n"); 00560 00561 iax_provision_free_templates(1 /* remove only marked as dead */); 00562 00563 /* Purge cached signature DB entries */ 00564 ast_db_deltree("iax/provisioning/cache", NULL); 00565 return 0; 00566 }
int iax_provision_unload | ( | void | ) |
Definition at line 519 of file iax2-provision.c.
References ast_cli_unregister_multiple(), cli_iax2_provision, and iax_provision_free_templates().
Referenced by __unload_module().
00520 { 00521 provinit = 0; 00522 ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry)); 00523 iax_provision_free_templates(0 /* Remove all templates. */); 00524 00525 return 0; 00526 }
int iax_provision_version | ( | unsigned int * | version, | |
const char * | template, | |||
int | force | |||
) |
Definition at line 257 of file iax2-provision.c.
References ast_db_get(), ast_debug, ast_log(), ast_mutex_lock, ast_mutex_unlock, iax_provision_build(), LOG_ERROR, and provlock.
Referenced by check_provisioning().
00258 { 00259 char tmp[80] = ""; 00260 struct iax_ie_data ied; 00261 int ret=0; 00262 memset(&ied, 0, sizeof(ied)); 00263 00264 ast_mutex_lock(&provlock); 00265 if (!(ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp)))) { 00266 ast_log(LOG_ERROR, "ast_db_get failed to retrieve iax/provisioning/cache\n"); 00267 ast_mutex_unlock(&provlock); 00268 return -1; 00269 } 00270 if (sscanf(tmp, "v%30x", version) != 1) { 00271 if (strcmp(tmp, "u")) { 00272 ret = iax_provision_build(&ied, version, template, force); 00273 if (ret) 00274 ast_debug(1, "Unable to create provisioning packet for '%s'\n", template); 00275 } else 00276 ret = -1; 00277 } else 00278 ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version); 00279 ast_mutex_unlock(&provlock); 00280 return ret; 00281 }
static const char* iax_server | ( | unsigned int | addr | ) | [static] |
Definition at line 424 of file iax2-provision.c.
References ast_inet_ntoa().
Referenced by iax_show_provisioning().
00425 { 00426 struct in_addr ia; 00427 00428 if (!addr) 00429 return "<unspecified>"; 00430 00431 ia.s_addr = htonl(addr); 00432 00433 return ast_inet_ntoa(ia); 00434 }
static char* iax_show_provisioning | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 437 of file iax2-provision.c.
References iax_template::altserver, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_copy_string(), ast_getformatname(), AST_LIST_TRAVERSE, ast_mutex_lock, ast_mutex_unlock, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, iax_template::flags, iax_template::format, iax_prov_complete_template(), iax_provflags2str(), iax_server(), ifthere(), iax_template::lang, ast_cli_args::line, iax_template::list, ast_cli_args::n, iax_template::name, iax_template::pass, iax_template::port, ast_cli_args::pos, provlock, iax_template::server, iax_template::serverport, iax_template::src, iax_template::tos, ast_cli_entry::usage, iax_template::user, and ast_cli_args::word.
00438 { 00439 struct iax_template *cur; 00440 char server[INET_ADDRSTRLEN]; 00441 char alternate[INET_ADDRSTRLEN]; 00442 char flags[80]; /* Has to be big enough for 'flags' too */ 00443 int found = 0; 00444 00445 switch (cmd) { 00446 case CLI_INIT: 00447 e->command = "iax2 show provisioning"; 00448 e->usage = 00449 "Usage: iax2 show provisioning [template]\n" 00450 " Lists all known IAX provisioning templates or a\n" 00451 " specific one if specified.\n"; 00452 return NULL; 00453 case CLI_GENERATE: 00454 return iax_prov_complete_template(a->line, a->word, a->pos, a->n); 00455 } 00456 00457 if ((a->argc != 3) && (a->argc != 4)) 00458 return CLI_SHOWUSAGE; 00459 00460 ast_mutex_lock(&provlock); 00461 AST_LIST_TRAVERSE(&templates, cur, list) { 00462 if ((a->argc == 3) || (!strcasecmp(a->argv[3], cur->name))) { 00463 if (found) 00464 ast_cli(a->fd, "\n"); 00465 ast_copy_string(server, iax_server(cur->server), sizeof(server)); 00466 ast_copy_string(alternate, iax_server(cur->altserver), sizeof(alternate)); 00467 ast_cli(a->fd, "== %s ==\n", cur->name); 00468 ast_cli(a->fd, "Base Templ: %s\n", strlen(cur->src) ? cur->src : "<none>"); 00469 ast_cli(a->fd, "Username: %s\n", ifthere(cur->user)); 00470 ast_cli(a->fd, "Secret: %s\n", ifthere(cur->pass)); 00471 ast_cli(a->fd, "Language: %s\n", ifthere(cur->lang)); 00472 ast_cli(a->fd, "Bind Port: %d\n", cur->port); 00473 ast_cli(a->fd, "Server: %s\n", server); 00474 ast_cli(a->fd, "Server Port: %d\n", cur->serverport); 00475 ast_cli(a->fd, "Alternate: %s\n", alternate); 00476 ast_cli(a->fd, "Flags: %s\n", iax_provflags2str(flags, sizeof(flags), cur->flags)); 00477 ast_cli(a->fd, "Format: %s\n", ast_getformatname(cur->format)); 00478 ast_cli(a->fd, "TOS: 0x%x\n", cur->tos); 00479 found++; 00480 } 00481 } 00482 ast_mutex_unlock(&provlock); 00483 if (!found) { 00484 if (a->argc == 3) 00485 ast_cli(a->fd, "No provisioning templates found\n"); 00486 else 00487 ast_cli(a->fd, "No provisioning template matching '%s' found\n", a->argv[3]); 00488 } 00489 return CLI_SUCCESS; 00490 }
static unsigned int iax_str2flags | ( | const char * | buf | ) | [static] |
Definition at line 113 of file iax2-provision.c.
References ARRAY_LEN, iax_template::flags, iax_flags, len(), iax_template::name, and iax_flag::value.
Referenced by iax_template_parse().
00114 { 00115 int x; 00116 int len; 00117 unsigned int flags = 0; 00118 char *e; 00119 while(buf && *buf) { 00120 e = strchr(buf, ','); 00121 if (e) 00122 len = e - buf; 00123 else 00124 len = 0; 00125 for (x = 0; x < ARRAY_LEN(iax_flags); x++) { 00126 if ((len && !strncasecmp(iax_flags[x].name, buf, len)) || 00127 (!len && !strcasecmp(iax_flags[x].name, buf))) { 00128 flags |= iax_flags[x].value; 00129 break; 00130 } 00131 } 00132 if (e) { 00133 buf = e + 1; 00134 while(*buf && (*buf < 33)) 00135 buf++; 00136 } else 00137 break; 00138 } 00139 return flags; 00140 }
static void iax_template_copy | ( | struct iax_template * | dst, | |
struct iax_template * | src | |||
) | [static] |
Definition at line 142 of file iax2-provision.c.
References iax_template::altserver, ast_copy_string(), iax_template::dead, iax_template::flags, iax_template::format, iax_template::lang, iax_template::name, iax_template::pass, iax_template::port, iax_template::server, iax_template::src, iax_template::tos, and iax_template::user.
Referenced by iax_template_parse().
00143 { 00144 if (!dst || !src) { 00145 return; 00146 } 00147 00148 dst->dead = src->dead; 00149 ast_copy_string(dst->name, src->name, sizeof(dst->name)); 00150 ast_copy_string(dst->src, src->src, sizeof(dst->src)); 00151 ast_copy_string(dst->user, src->user, sizeof(dst->user)); 00152 ast_copy_string(dst->pass, src->pass, sizeof(dst->pass)); 00153 ast_copy_string(dst->lang, src->lang, sizeof(dst->lang)); 00154 dst->port = src->port; 00155 dst->server = src->server; 00156 dst->altserver = src->altserver; 00157 dst->flags = src->flags; 00158 dst->format = src->format; 00159 dst->tos = src->tos; 00160 }
static struct iax_template* iax_template_find | ( | const char * | s, | |
int | allowdead | |||
) | [static] |
Definition at line 162 of file iax2-provision.c.
References AST_LIST_TRAVERSE, iax_template::dead, iax_template::list, and iax_template::name.
Referenced by iax_process_template(), iax_provision_build(), and iax_template_parse().
00163 { 00164 struct iax_template *cur; 00165 00166 AST_LIST_TRAVERSE(&templates, cur, list) { 00167 if (!strcasecmp(s, cur->name)) { 00168 if (!allowdead && cur->dead) { 00169 cur = NULL; 00170 } 00171 break; 00172 } 00173 } 00174 00175 return cur; 00176 }
static int iax_template_parse | ( | struct iax_template * | cur, | |
struct ast_config * | cfg, | |||
const char * | s, | |||
const char * | def | |||
) | [static] |
Definition at line 283 of file iax2-provision.c.
References iax_template::altserver, ast_getformatbyname(), ast_gethostbyname(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_str2tos(), ast_variable_browse(), ast_variable_retrieve(), iax_template::dead, iax_template::flags, iax_template::format, hp, IAX_DEFAULT_PORTNO, iax_str2flags(), iax_template_copy(), iax_template_find(), iax_template::lang, ast_variable::lineno, LOG_WARNING, ast_variable::name, iax_template::name, ast_variable::next, iax_template::pass, iax_template::port, provlock, iax_template::server, iax_template::serverport, iax_template::src, iax_template::tos, iax_template::user, and ast_variable::value.
Referenced by iax_process_template().
00284 { 00285 struct ast_variable *v; 00286 int foundportno = 0; 00287 int foundserverportno = 0; 00288 int x; 00289 struct in_addr ia; 00290 struct hostent *hp; 00291 struct ast_hostent h; 00292 struct iax_template *src, tmp; 00293 const char *t; 00294 if (def) { 00295 t = ast_variable_retrieve(cfg, s ,"template"); 00296 src = NULL; 00297 if (t && strlen(t)) { 00298 src = iax_template_find(t, 0); 00299 if (!src) 00300 ast_log(LOG_WARNING, "Unable to find base template '%s' for creating '%s'. Trying '%s'\n", t, s, def); 00301 else 00302 def = t; 00303 } 00304 if (!src) { 00305 src = iax_template_find(def, 0); 00306 if (!src) 00307 ast_log(LOG_WARNING, "Unable to locate default base template '%s' for creating '%s', omitting.\n", def, s); 00308 } 00309 if (!src) 00310 return -1; 00311 ast_mutex_lock(&provlock); 00312 /* Backup old data */ 00313 iax_template_copy(&tmp, cur); 00314 /* Restore from src */ 00315 iax_template_copy(cur, src); 00316 /* Restore important headers */ 00317 memcpy(cur->name, tmp.name, sizeof(cur->name)); 00318 cur->dead = tmp.dead; 00319 ast_mutex_unlock(&provlock); 00320 } 00321 if (def) 00322 strncpy(cur->src, def, sizeof(cur->src) - 1); 00323 else 00324 cur->src[0] = '\0'; 00325 v = ast_variable_browse(cfg, s); 00326 while(v) { 00327 if (!strcasecmp(v->name, "port") || !strcasecmp(v->name, "serverport")) { 00328 if ((sscanf(v->value, "%5d", &x) == 1) && (x > 0) && (x < 65535)) { 00329 if (!strcasecmp(v->name, "port")) { 00330 cur->port = x; 00331 foundportno = 1; 00332 } else { 00333 cur->serverport = x; 00334 foundserverportno = 1; 00335 } 00336 } else 00337 ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno); 00338 } else if (!strcasecmp(v->name, "server") || !strcasecmp(v->name, "altserver")) { 00339 hp = ast_gethostbyname(v->value, &h); 00340 if (hp) { 00341 memcpy(&ia, hp->h_addr, sizeof(ia)); 00342 if (!strcasecmp(v->name, "server")) 00343 cur->server = ntohl(ia.s_addr); 00344 else 00345 cur->altserver = ntohl(ia.s_addr); 00346 } else 00347 ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno); 00348 } else if (!strcasecmp(v->name, "codec")) { 00349 if ((x = ast_getformatbyname(v->value)) > 0) { 00350 cur->format = x; 00351 } else 00352 ast_log(LOG_WARNING, "Ignoring invalid codec '%s' for '%s' at line %d\n", v->value, s, v->lineno); 00353 } else if (!strcasecmp(v->name, "tos")) { 00354 if (ast_str2tos(v->value, &cur->tos)) 00355 ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno); 00356 } else if (!strcasecmp(v->name, "user")) { 00357 strncpy(cur->user, v->value, sizeof(cur->user) - 1); 00358 if (strcmp(cur->user, v->value)) 00359 ast_log(LOG_WARNING, "Truncating username from '%s' to '%s' for '%s' at line %d\n", v->value, cur->user, s, v->lineno); 00360 } else if (!strcasecmp(v->name, "pass")) { 00361 strncpy(cur->pass, v->value, sizeof(cur->pass) - 1); 00362 if (strcmp(cur->pass, v->value)) 00363 ast_log(LOG_WARNING, "Truncating password from '%s' to '%s' for '%s' at line %d\n", v->value, cur->pass, s, v->lineno); 00364 } else if (!strcasecmp(v->name, "language")) { 00365 strncpy(cur->lang, v->value, sizeof(cur->lang) - 1); 00366 if (strcmp(cur->lang, v->value)) 00367 ast_log(LOG_WARNING, "Truncating language from '%s' to '%s' for '%s' at line %d\n", v->value, cur->lang, s, v->lineno); 00368 } else if (!strcasecmp(v->name, "flags")) { 00369 cur->flags = iax_str2flags(v->value); 00370 } else if (!strncasecmp(v->name, "flags", 5) && strchr(v->name, '+')) { 00371 cur->flags |= iax_str2flags(v->value); 00372 } else if (!strncasecmp(v->name, "flags", 5) && strchr(v->name, '-')) { 00373 cur->flags &= ~iax_str2flags(v->value); 00374 } else if (strcasecmp(v->name, "template")) { 00375 ast_log(LOG_WARNING, "Unknown keyword '%s' in definition of '%s' at line %d\n", v->name, s, v->lineno); 00376 } 00377 v = v->next; 00378 } 00379 if (!foundportno) 00380 cur->port = IAX_DEFAULT_PORTNO; 00381 if (!foundserverportno) 00382 cur->serverport = IAX_DEFAULT_PORTNO; 00383 return 0; 00384 }
static const char* ifthere | ( | const char * | s | ) | [static] |
static unsigned int prov_ver_calc | ( | struct iax_ie_data * | provdata | ) | [static] |
Definition at line 198 of file iax2-provision.c.
References iax_ie_data::buf, md5(), MD5Final(), MD5Init(), MD5Update(), and iax_ie_data::pos.
Referenced by iax_provision_build().
00199 { 00200 struct MD5Context md5; 00201 unsigned int tmp[4]; 00202 MD5Init(&md5); 00203 MD5Update(&md5, provdata->buf, provdata->pos); 00204 MD5Final((unsigned char *)tmp, &md5); 00205 return tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3]; 00206 }
struct ast_cli_entry cli_iax2_provision[] [static] |
Initial value:
{ { .handler = iax_show_provisioning , .summary = "Display iax provisioning" ,__VA_ARGS__ }, }
Definition at line 492 of file iax2-provision.c.
Referenced by iax_provision_init(), and iax_provision_unload().
Referenced by iax_provflags2str(), and iax_str2flags().
int provinit = 0 [static] |
Definition at line 52 of file iax2-provision.c.
ast_mutex_t provlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } [static] |
Definition at line 73 of file iax2-provision.c.
Referenced by iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_free_templates(), iax_provision_version(), iax_show_provisioning(), and iax_template_parse().