Wed Oct 28 11:46:11 2009

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"

Include dependency graph for iax2-provision.c:

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 = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )


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 380 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, iax_template::name, and provlock.

Referenced by iax_provision_reload().

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

char* iax_prov_complete_template ( const char *  line,
const char *  word,
int  pos,
int  state 
)

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

00177 {
00178    struct iax_template *c;
00179    int which=0;
00180    char *ret = NULL;
00181    int wordlen = strlen(word);
00182 
00183    if (pos == 3) {
00184       ast_mutex_lock(&provlock);
00185       AST_LIST_TRAVERSE(&templates, c, list) {
00186          if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
00187             ret = ast_strdup(c->name);
00188             break;
00189          }
00190       }
00191       ast_mutex_unlock(&provlock);
00192    }
00193    return ret;
00194 }

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, and iax_template::name.

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 206 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().

00207 {
00208    struct iax_template *cur;
00209    unsigned int sig;
00210    char tmp[40];
00211    memset(provdata, 0, sizeof(*provdata));
00212    ast_mutex_lock(&provlock);
00213    cur = iax_template_find(template, 1);
00214    /* If no match, try searching for '*' */
00215    if (!cur)
00216       cur = iax_template_find("*", 1);
00217    if (cur) {
00218       /* found it -- add information elements as appropriate */
00219       if (force || strlen(cur->user))
00220          iax_ie_append_str(provdata, PROV_IE_USER, cur->user);
00221       if (force || strlen(cur->pass))
00222          iax_ie_append_str(provdata, PROV_IE_PASS, cur->pass);
00223       if (force || strlen(cur->lang))
00224          iax_ie_append_str(provdata, PROV_IE_LANG, cur->lang);
00225       if (force || cur->port)
00226          iax_ie_append_short(provdata, PROV_IE_PORTNO, cur->port);
00227       if (force || cur->server)
00228          iax_ie_append_int(provdata, PROV_IE_SERVERIP, cur->server);
00229       if (force || cur->serverport)
00230          iax_ie_append_short(provdata, PROV_IE_SERVERPORT, cur->serverport);
00231       if (force || cur->altserver)
00232          iax_ie_append_int(provdata, PROV_IE_ALTSERVER, cur->altserver);
00233       if (force || cur->flags)
00234          iax_ie_append_int(provdata, PROV_IE_FLAGS, cur->flags);
00235       if (force || cur->format)
00236          iax_ie_append_int(provdata, PROV_IE_FORMAT, cur->format);
00237       if (force || cur->tos)
00238          iax_ie_append_byte(provdata, PROV_IE_TOS, cur->tos);
00239       
00240       /* Calculate checksum of message so far */
00241       sig = prov_ver_calc(provdata);
00242       if (signature)
00243          *signature = sig;
00244       /* Store signature */
00245       iax_ie_append_int(provdata, PROV_IE_PROVVER, sig);
00246       /* Cache signature for later verification so we need not recalculate all this */
00247       snprintf(tmp, sizeof(tmp), "v0x%08x", sig);
00248       ast_db_put("iax/provisioning/cache", template, tmp);
00249    } else
00250       ast_db_put("iax/provisioning/cache", template, "u");
00251    ast_mutex_unlock(&provlock);
00252    return cur ? 0 : -1;
00253 }

static void iax_provision_free_templates ( int  dead  )  [static]

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

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

static int iax_provision_init ( void   )  [static]

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

References ast_cli_register_multiple(), and cli_iax2_provision.

Referenced by iax_provision_reload().

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

int iax_provision_reload ( int  reload  ) 

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

References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_db_deltree(), AST_LIST_TRAVERSE, ast_log(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, 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().

00523 {
00524    struct ast_config *cfg;
00525    struct iax_template *cur;
00526    char *cat;
00527    int found = 0;
00528    struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
00529    if (!provinit)
00530       iax_provision_init();
00531    
00532    cfg = ast_config_load("iaxprov.conf", config_flags);
00533    if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) {
00534       /* Mark all as dead.  No need for locking */
00535       AST_LIST_TRAVERSE(&templates, cur, list) {
00536          cur->dead = 1;
00537       }
00538 
00539       /* Load as appropriate */
00540       cat = ast_category_browse(cfg, NULL);
00541       while(cat) {
00542          if (strcasecmp(cat, "general")) {
00543             iax_process_template(cfg, cat, found ? "default" : NULL);
00544             found++;
00545             ast_verb(3, "Loaded provisioning template '%s'\n", cat);
00546          }
00547          cat = ast_category_browse(cfg, cat);
00548       }
00549       ast_config_destroy(cfg);
00550    } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
00551       return 0;
00552    else
00553       ast_log(LOG_NOTICE, "No IAX provisioning configuration found, IAX provisioning disabled.\n");
00554 
00555    iax_provision_free_templates(1 /* remove only marked as dead */);
00556 
00557    /* Purge cached signature DB entries */
00558    ast_db_deltree("iax/provisioning/cache", NULL);
00559    return 0;
00560 }

int iax_provision_unload ( void   ) 

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

References ast_cli_unregister_multiple(), cli_iax2_provision, and iax_provision_free_templates().

Referenced by __unload_module().

00514 {
00515    provinit = 0;
00516    ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
00517    iax_provision_free_templates(0 /* Remove all templates. */);
00518 
00519    return 0;
00520 }

int iax_provision_version ( unsigned int *  version,
const char *  template,
int  force 
)

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

00256 {
00257    char tmp[80] = "";
00258    struct iax_ie_data ied;
00259    int ret=0;
00260    memset(&ied, 0, sizeof(ied));
00261 
00262    ast_mutex_lock(&provlock);
00263    ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp));
00264    if (sscanf(tmp, "v%30x", version) != 1) {
00265       if (strcmp(tmp, "u")) {
00266          ret = iax_provision_build(&ied, version, template, force);
00267          if (ret)
00268             ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
00269       } else
00270          ret = -1;
00271    } else
00272       ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
00273    ast_mutex_unlock(&provlock);
00274    return ret;
00275 }

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

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

References ast_inet_ntoa().

Referenced by iax_show_provisioning().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by iax_show_provisioning().

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

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

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

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

Referenced by iax_provision_build().

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


Variable Documentation

struct ast_cli_entry cli_iax2_provision[] [static]

Initial value:

 {
   AST_CLI_DEFINE(iax_show_provisioning, "Display iax provisioning"),
}

Definition at line 486 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 = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]


Generated on Wed Oct 28 11:46:11 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6