Mon Mar 19 11:30:48 2012

Asterisk developer's documentation


iax2-provision.c File Reference

IAX Provisioning Protocol. More...

#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_templateiax_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 }


Detailed Description

IAX Provisioning Protocol.

Author:
Mark Spencer <markster@digium.com>

Definition in file iax2-provision.c.


Function Documentation

static int iax_process_template ( struct ast_config cfg,
char *  s,
char *  def 
) [static]

Definition at line 378 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().

00379 {
00380    /* Find an already existing one if there */
00381    struct iax_template *cur;
00382    int mallocd = 0;
00383 
00384    cur = iax_template_find(s, 1 /* allow dead */);
00385    if (!cur) {
00386       mallocd = 1;
00387       cur = ast_calloc(1, sizeof(*cur));
00388       if (!cur) {
00389          ast_log(LOG_WARNING, "Out of memory!\n");
00390          return -1;
00391       }
00392       /* Initialize entry */
00393       strncpy(cur->name, s, sizeof(cur->name) - 1);
00394       cur->dead = 1;
00395    }
00396    if (!iax_template_parse(cur, cfg, s, def))
00397       cur->dead = 0;
00398 
00399    /* Link if we're mallocd */
00400    if (mallocd) {
00401       ast_mutex_lock(&provlock);
00402       AST_LIST_INSERT_HEAD(&templates, cur, list);
00403       ast_mutex_unlock(&provlock);
00404    }
00405    return 0;
00406 }

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 }

static void iax_provision_free_templates ( int  dead  )  [static]

Definition at line 495 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().

00496 {
00497    struct iax_template *cur;
00498 
00499    /* Drop dead or not (depending on dead) entries while locked */
00500    ast_mutex_lock(&provlock);
00501    AST_LIST_TRAVERSE_SAFE_BEGIN(&templates, cur, list) {
00502       if ((dead && cur->dead) || !dead) {
00503          AST_LIST_REMOVE_CURRENT(list);
00504          ast_free(cur);
00505       }
00506    }
00507    AST_LIST_TRAVERSE_SAFE_END;
00508    ast_mutex_unlock(&provlock);
00509 }

static int iax_provision_init ( void   )  [static]

Definition at line 488 of file iax2-provision.c.

References ast_cli_register_multiple(), and cli_iax2_provision.

Referenced by iax_provision_reload().

00489 {
00490    ast_cli_register_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
00491    provinit = 1;
00492    return 0;
00493 }

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 *  version,
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 }

static const char* iax_server ( unsigned int  addr  )  [static]

Definition at line 416 of file iax2-provision.c.

References ast_inet_ntoa().

Referenced by iax_show_provisioning().

00417 {
00418    struct in_addr ia;
00419    
00420    if (!addr)
00421       return "<unspecified>";
00422    
00423    ia.s_addr = htonl(addr);
00424 
00425    return ast_inet_ntoa(ia);
00426 }

static char* iax_show_provisioning ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 429 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.

00430 {
00431    struct iax_template *cur;
00432    char server[INET_ADDRSTRLEN];
00433    char alternate[INET_ADDRSTRLEN];
00434    char flags[80];   /* Has to be big enough for 'flags' too */
00435    int found = 0;
00436 
00437    switch (cmd) {
00438    case CLI_INIT:
00439       e->command = "iax2 show provisioning";
00440       e->usage =
00441          "Usage: iax2 show provisioning [template]\n"
00442          "       Lists all known IAX provisioning templates or a\n"
00443          "       specific one if specified.\n";
00444       return NULL;
00445    case CLI_GENERATE:
00446       return iax_prov_complete_template(a->line, a->word, a->pos, a->n);
00447    }
00448 
00449    if ((a->argc != 3) && (a->argc != 4))
00450       return CLI_SHOWUSAGE;
00451 
00452    ast_mutex_lock(&provlock);
00453    AST_LIST_TRAVERSE(&templates, cur, list) {
00454       if ((a->argc == 3) || (!strcasecmp(a->argv[3], cur->name)))  {
00455          if (found) 
00456             ast_cli(a->fd, "\n");
00457          ast_copy_string(server, iax_server(cur->server), sizeof(server));
00458          ast_copy_string(alternate, iax_server(cur->altserver), sizeof(alternate));
00459          ast_cli(a->fd, "== %s ==\n", cur->name);
00460          ast_cli(a->fd, "Base Templ:   %s\n", strlen(cur->src) ? cur->src : "<none>");
00461          ast_cli(a->fd, "Username:     %s\n", ifthere(cur->user));
00462          ast_cli(a->fd, "Secret:       %s\n", ifthere(cur->pass));
00463          ast_cli(a->fd, "Language:     %s\n", ifthere(cur->lang));
00464          ast_cli(a->fd, "Bind Port:    %d\n", cur->port);
00465          ast_cli(a->fd, "Server:       %s\n", server);
00466          ast_cli(a->fd, "Server Port:  %d\n", cur->serverport);
00467          ast_cli(a->fd, "Alternate:    %s\n", alternate);
00468          ast_cli(a->fd, "Flags:        %s\n", iax_provflags2str(flags, sizeof(flags), cur->flags));
00469          ast_cli(a->fd, "Format:       %s\n", ast_getformatname(cur->format));
00470          ast_cli(a->fd, "TOS:          0x%x\n", cur->tos);
00471          found++;
00472       }
00473    }
00474    ast_mutex_unlock(&provlock);
00475    if (!found) {
00476       if (a->argc == 3)
00477          ast_cli(a->fd, "No provisioning templates found\n");
00478       else
00479          ast_cli(a->fd, "No provisioning template matching '%s' found\n", a->argv[3]);
00480    }
00481    return CLI_SUCCESS;
00482 }

static unsigned int iax_str2flags ( const char *  buf  )  [static]

Definition at line 109 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().

00110 {
00111    int x;
00112    int len;
00113    unsigned int flags = 0;
00114    char *e;
00115    while(buf && *buf) {
00116       e = strchr(buf, ',');
00117       if (e)
00118          len = e - buf;
00119       else
00120          len = 0;
00121       for (x = 0; x < ARRAY_LEN(iax_flags); x++) {
00122          if ((len && !strncasecmp(iax_flags[x].name, buf, len)) ||
00123              (!len && !strcasecmp(iax_flags[x].name, buf))) {
00124             flags |= iax_flags[x].value;
00125             break;
00126          }
00127       }
00128       if (e) {
00129          buf = e + 1;
00130          while(*buf && (*buf < 33))
00131             buf++;
00132       } else
00133          break;
00134    }
00135    return flags;
00136 }

static void iax_template_copy ( struct iax_template dst,
struct iax_template src 
) [static]

Definition at line 138 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().

00139 {
00140    if (!dst || !src) {
00141       return;
00142    }
00143 
00144    dst->dead = src->dead;
00145    ast_copy_string(dst->name, src->name, sizeof(dst->name));
00146    ast_copy_string(dst->src, src->src, sizeof(dst->src));
00147    ast_copy_string(dst->user, src->user, sizeof(dst->user));
00148    ast_copy_string(dst->pass, src->pass, sizeof(dst->pass));
00149    ast_copy_string(dst->lang, src->lang, sizeof(dst->lang));
00150    dst->port = src->port;
00151    dst->server = src->server;
00152    dst->altserver = src->altserver;
00153    dst->flags = src->flags;
00154    dst->format = src->format;
00155    dst->tos = src->tos;
00156 }

static struct iax_template* iax_template_find ( const char *  s,
int  allowdead 
) [static]

Definition at line 158 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().

00159 {
00160    struct iax_template *cur;
00161 
00162    AST_LIST_TRAVERSE(&templates, cur, list) {
00163       if (!strcasecmp(s, cur->name)) {
00164          if (!allowdead && cur->dead) {
00165             cur = NULL;
00166          }
00167          break;
00168       }
00169    }
00170 
00171    return cur;
00172 }

static int iax_template_parse ( struct iax_template cur,
struct ast_config cfg,
const char *  s,
const char *  def 
) [static]

Definition at line 275 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().

00276 {
00277    struct ast_variable *v;
00278    int foundportno = 0;
00279    int foundserverportno = 0;
00280    int x;
00281    struct in_addr ia;
00282    struct hostent *hp;
00283    struct ast_hostent h;
00284    struct iax_template *src, tmp;
00285    const char *t;
00286    if (def) {
00287       t = ast_variable_retrieve(cfg, s ,"template");
00288       src = NULL;
00289       if (t && strlen(t)) {
00290          src = iax_template_find(t, 0);
00291          if (!src)
00292             ast_log(LOG_WARNING, "Unable to find base template '%s' for creating '%s'.  Trying '%s'\n", t, s, def);
00293          else
00294             def = t;
00295       } 
00296       if (!src) {
00297          src = iax_template_find(def, 0);
00298          if (!src)
00299             ast_log(LOG_WARNING, "Unable to locate default base template '%s' for creating '%s', omitting.\n", def, s);
00300       }
00301       if (!src)
00302          return -1;
00303       ast_mutex_lock(&provlock);
00304       /* Backup old data */
00305       iax_template_copy(&tmp, cur);
00306       /* Restore from src */
00307       iax_template_copy(cur, src);
00308       /* Restore important headers */
00309       memcpy(cur->name, tmp.name, sizeof(cur->name));
00310       cur->dead = tmp.dead;
00311       ast_mutex_unlock(&provlock);
00312    }
00313    if (def)
00314       strncpy(cur->src, def, sizeof(cur->src) - 1);
00315    else
00316       cur->src[0] = '\0';
00317    v = ast_variable_browse(cfg, s);
00318    while(v) {
00319       if (!strcasecmp(v->name, "port") || !strcasecmp(v->name, "serverport")) {
00320          if ((sscanf(v->value, "%5d", &x) == 1) && (x > 0) && (x < 65535)) {
00321             if (!strcasecmp(v->name, "port")) {
00322                cur->port = x;
00323                foundportno = 1;
00324             } else {
00325                cur->serverport = x;
00326                foundserverportno = 1;
00327             }
00328          } else
00329             ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
00330       } else if (!strcasecmp(v->name, "server") || !strcasecmp(v->name, "altserver")) {
00331          hp = ast_gethostbyname(v->value, &h);
00332          if (hp) {
00333             memcpy(&ia, hp->h_addr, sizeof(ia));
00334             if (!strcasecmp(v->name, "server"))
00335                cur->server = ntohl(ia.s_addr);
00336             else
00337                cur->altserver = ntohl(ia.s_addr);
00338          } else 
00339             ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
00340       } else if (!strcasecmp(v->name, "codec")) {
00341          if ((x = ast_getformatbyname(v->value)) > 0) {
00342             cur->format = x;
00343          } else
00344             ast_log(LOG_WARNING, "Ignoring invalid codec '%s' for '%s' at line %d\n", v->value, s, v->lineno);
00345       } else if (!strcasecmp(v->name, "tos")) {
00346          if (ast_str2tos(v->value, &cur->tos))
00347             ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
00348       } else if (!strcasecmp(v->name, "user")) {
00349          strncpy(cur->user, v->value, sizeof(cur->user) - 1);
00350          if (strcmp(cur->user, v->value))
00351             ast_log(LOG_WARNING, "Truncating username from '%s' to '%s' for '%s' at line %d\n", v->value, cur->user, s, v->lineno);
00352       } else if (!strcasecmp(v->name, "pass")) {
00353          strncpy(cur->pass, v->value, sizeof(cur->pass) - 1);
00354          if (strcmp(cur->pass, v->value))
00355             ast_log(LOG_WARNING, "Truncating password from '%s' to '%s' for '%s' at line %d\n", v->value, cur->pass, s, v->lineno);
00356       } else if (!strcasecmp(v->name, "language")) {
00357          strncpy(cur->lang, v->value, sizeof(cur->lang) - 1);
00358          if (strcmp(cur->lang, v->value))
00359             ast_log(LOG_WARNING, "Truncating language from '%s' to '%s' for '%s' at line %d\n", v->value, cur->lang, s, v->lineno);
00360       } else if (!strcasecmp(v->name, "flags")) {
00361          cur->flags = iax_str2flags(v->value);
00362       } else if (!strncasecmp(v->name, "flags", 5) && strchr(v->name, '+')) {
00363          cur->flags |= iax_str2flags(v->value);
00364       } else if (!strncasecmp(v->name, "flags", 5) && strchr(v->name, '-')) {
00365          cur->flags &= ~iax_str2flags(v->value);
00366       } else if (strcasecmp(v->name, "template")) {
00367          ast_log(LOG_WARNING, "Unknown keyword '%s' in definition of '%s' at line %d\n", v->name, s, v->lineno);
00368       }
00369       v = v->next;
00370    }
00371    if (!foundportno)
00372       cur->port = IAX_DEFAULT_PORTNO;
00373    if (!foundserverportno)
00374       cur->serverport = IAX_DEFAULT_PORTNO;
00375    return 0;
00376 }

static const char* ifthere ( const char *  s  )  [static]

Definition at line 408 of file iax2-provision.c.

Referenced by iax_show_provisioning().

00409 {
00410    if (strlen(s))
00411       return s;
00412    else
00413       return "<unspecified>";
00414 }

static unsigned int prov_ver_calc ( struct iax_ie_data provdata  )  [static]

Definition at line 194 of file iax2-provision.c.

References iax_ie_data::buf, md5(), MD5Final(), MD5Init(), MD5Update(), and iax_ie_data::pos.

Referenced by iax_provision_build().

00195 {
00196    struct MD5Context md5;
00197    unsigned int tmp[4];
00198    MD5Init(&md5);
00199    MD5Update(&md5, provdata->buf, provdata->pos);
00200    MD5Final((unsigned char *)tmp, &md5);
00201    return tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3];
00202 }


Variable Documentation

struct ast_cli_entry cli_iax2_provision[] [static]

Initial value:

 {
   { .handler =  iax_show_provisioning , .summary =  "Display iax provisioning" ,__VA_ARGS__ },
}

Definition at line 484 of file iax2-provision.c.

Referenced by iax_provision_init(), and iax_provision_unload().

struct iax_flag iax_flags[] [static]

Referenced by iax_provflags2str(), and iax_str2flags().

int provinit = 0 [static]

Definition at line 48 of file iax2-provision.c.

ast_mutex_t provlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } [static]

Definition at line 69 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().


Generated on Mon Mar 19 11:30:48 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7