Wed Aug 7 17:16:06 2019

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

Functions

static AST_LIST_HEAD_NOLOCK_STATIC (templates, iax_template)
 AST_MUTEX_DEFINE_STATIC (provlock)
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

Detailed Description

IAX Provisioning Protocol.

Author:
Mark Spencer <markster@digium.com>

Definition in file iax2-provision.c.


Function Documentation

static AST_LIST_HEAD_NOLOCK_STATIC ( templates  ,
iax_template   
) [static]
AST_MUTEX_DEFINE_STATIC ( provlock   ) 
static int iax_process_template ( struct ast_config cfg,
char *  s,
char *  def 
) [static]

Definition at line 384 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(), LOG_WARNING, and iax_template::name.

Referenced by iax_provision_reload().

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

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

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(), 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 501 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, and iax_template::dead.

Referenced by iax_provision_reload(), and iax_provision_unload().

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

static int iax_provision_init ( void   )  [static]

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

References ast_cli_register_multiple(), and cli_iax2_provision.

Referenced by iax_provision_reload().

00495 {
00496    ast_cli_register_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
00497    provinit = 1;
00498    return 0;
00499 }

int iax_provision_reload ( int  reload  ) 

Definition at line 526 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(), and LOG_NOTICE.

Referenced by load_module(), and reload_config().

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

int iax_provision_unload ( void   ) 

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

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

Referenced by __unload_module().

00518 {
00519    provinit = 0;
00520    ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
00521    iax_provision_free_templates(0 /* Remove all templates. */);
00522 
00523    return 0;
00524 }

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(), and LOG_ERROR.

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/%s\n", template);
00267    }
00268    if (sscanf(tmp, "v%30x", version) != 1) {
00269       if (strcmp(tmp, "u")) {
00270          ret = iax_provision_build(&ied, version, template, force);
00271          if (ret)
00272             ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
00273       } else
00274          ret = -1;
00275    } else
00276       ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
00277    ast_mutex_unlock(&provlock);
00278    return ret;
00279 }

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

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

References ast_inet_ntoa().

Referenced by iax_show_provisioning().

00423 {
00424    struct in_addr ia;
00425    
00426    if (!addr)
00427       return "<unspecified>";
00428    
00429    ia.s_addr = htonl(addr);
00430 
00431    return ast_inet_ntoa(ia);
00432 }

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

Definition at line 435 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, ast_cli_args::n, iax_template::name, iax_template::pass, iax_template::port, ast_cli_args::pos, iax_template::server, iax_template::serverport, iax_template::src, iax_template::tos, ast_cli_entry::usage, iax_template::user, and ast_cli_args::word.

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

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, read]

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

References AST_LIST_TRAVERSE, iax_template::dead, 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 281 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, iax_template::server, iax_template::serverport, iax_template::src, iax_template::tos, iax_template::user, and ast_variable::value.

Referenced by iax_process_template().

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

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

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

Referenced by iax_show_provisioning().

00415 {
00416    if (strlen(s))
00417       return s;
00418    else
00419       return "<unspecified>";
00420 }

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


Variable Documentation

struct ast_cli_entry cli_iax2_provision[] [static]
Initial value:
 {
   AST_CLI_DEFINE(iax_show_provisioning, "Display iax provisioning"),
}

Definition at line 490 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 52 of file iax2-provision.c.


Generated on 7 Aug 2019 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1