IAX2 Provisioning protocol. More...
#include "iax2-parser.h"

Go to the source code of this file.
Defines | |
| #define | PROV_FLAG_DEBUG (1 << 3) |
| #define | PROV_FLAG_DIS_CALLERID (1 << 4) /* Caller-ID Disabled */ |
| #define | PROV_FLAG_DIS_CALLWAIT (1 << 5) /* Caller-ID / Call Waiting Disable */ |
| #define | PROV_FLAG_DIS_CIDCW (1 << 6) /* CID/CW Disabled */ |
| #define | PROV_FLAG_DIS_THREEWAY (1 << 7) /* Three-way calling, transfer disabled */ |
| #define | PROV_FLAG_HEARTBEAT (1 << 2) |
| #define | PROV_FLAG_REGISTER (1 << 0) |
| #define | PROV_FLAG_SECURE (1 << 1) |
| #define | PROV_IE_AESKEY 14 /* 128-bits */ |
| #define | PROV_IE_ALTSERVER 19 /* 32-bits */ |
| #define | PROV_IE_FLAGS 12 /* 32-bits */ |
| #define | PROV_IE_FORMAT 13 /* 32-bits */ |
| #define | PROV_IE_GATEWAY 4 /* 32-bit */ |
| #define | PROV_IE_IPADDR 2 /* 32-bit */ |
| #define | PROV_IE_LANG 10 /* < 10 bytes */ |
| #define | PROV_IE_NEWAESKEY 17 /* 128-bits */ |
| #define | PROV_IE_PASS 7 /* < 20 bytes */ |
| #define | PROV_IE_PORTNO 5 /* 16-bit */ |
| #define | PROV_IE_PROVVER 18 /* 32-bits */ |
| #define | PROV_IE_SERVERIP 15 /* 32-bits */ |
| #define | PROV_IE_SERVERPASS 9 /* < 20 bytes */ |
| #define | PROV_IE_SERVERPORT 16 /* 16-bits */ |
| #define | PROV_IE_SERVERUSER 8 /* < 20 bytes */ |
| #define | PROV_IE_SUBNET 3 /* 32-bit */ |
| #define | PROV_IE_TOS 11 /* 8-bits */ |
| #define | PROV_IE_USEDHCP 1 /* Presense only */ |
| #define | PROV_IE_USER 6 /* < 20 bytes */ |
Functions | |
| char * | iax_prov_complete_template (const char *line, const char *word, int pos, int state) |
| char * | iax_provflags2str (char *buf, int buflen, unsigned int flags) |
| int | iax_provision_build (struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force) |
| int | iax_provision_reload (int reload) |
| int | iax_provision_unload (void) |
| int | iax_provision_version (unsigned int *signature, const char *template, int force) |
IAX2 Provisioning protocol.
Definition in file iax2-provision.h.
| #define PROV_FLAG_DEBUG (1 << 3) |
Definition at line 41 of file iax2-provision.h.
| #define PROV_FLAG_DIS_CALLERID (1 << 4) /* Caller-ID Disabled */ |
Definition at line 43 of file iax2-provision.h.
| #define PROV_FLAG_DIS_CALLWAIT (1 << 5) /* Caller-ID / Call Waiting Disable */ |
Definition at line 44 of file iax2-provision.h.
| #define PROV_FLAG_DIS_CIDCW (1 << 6) /* CID/CW Disabled */ |
Definition at line 45 of file iax2-provision.h.
| #define PROV_FLAG_DIS_THREEWAY (1 << 7) /* Three-way calling, transfer disabled */ |
Definition at line 46 of file iax2-provision.h.
| #define PROV_FLAG_HEARTBEAT (1 << 2) |
Definition at line 40 of file iax2-provision.h.
| #define PROV_FLAG_REGISTER (1 << 0) |
Definition at line 38 of file iax2-provision.h.
| #define PROV_FLAG_SECURE (1 << 1) |
Definition at line 39 of file iax2-provision.h.
| #define PROV_IE_AESKEY 14 /* 128-bits */ |
Definition at line 31 of file iax2-provision.h.
| #define PROV_IE_ALTSERVER 19 /* 32-bits */ |
Definition at line 36 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_FLAGS 12 /* 32-bits */ |
Definition at line 29 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_FORMAT 13 /* 32-bits */ |
Definition at line 30 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_GATEWAY 4 /* 32-bit */ |
Definition at line 21 of file iax2-provision.h.
| #define PROV_IE_IPADDR 2 /* 32-bit */ |
Definition at line 19 of file iax2-provision.h.
| #define PROV_IE_LANG 10 /* < 10 bytes */ |
Definition at line 27 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_NEWAESKEY 17 /* 128-bits */ |
Definition at line 34 of file iax2-provision.h.
| #define PROV_IE_PASS 7 /* < 20 bytes */ |
Definition at line 24 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_PORTNO 5 /* 16-bit */ |
Definition at line 22 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_PROVVER 18 /* 32-bits */ |
Definition at line 35 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_SERVERIP 15 /* 32-bits */ |
Definition at line 32 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_SERVERPASS 9 /* < 20 bytes */ |
Definition at line 26 of file iax2-provision.h.
| #define PROV_IE_SERVERPORT 16 /* 16-bits */ |
Definition at line 33 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_SERVERUSER 8 /* < 20 bytes */ |
Definition at line 25 of file iax2-provision.h.
| #define PROV_IE_SUBNET 3 /* 32-bit */ |
Definition at line 20 of file iax2-provision.h.
| #define PROV_IE_TOS 11 /* 8-bits */ |
Definition at line 28 of file iax2-provision.h.
Referenced by iax_provision_build().
| #define PROV_IE_USEDHCP 1 /* Presense only */ |
Definition at line 18 of file iax2-provision.h.
| #define PROV_IE_USER 6 /* < 20 bytes */ |
Definition at line 23 of file iax2-provision.h.
Referenced by iax_provision_build().
| 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().
{
struct iax_template *c;
int which=0;
char *ret = NULL;
int wordlen = strlen(word);
if (pos == 3) {
ast_mutex_lock(&provlock);
AST_LIST_TRAVERSE(&templates, c, list) {
if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
ret = ast_strdup(c->name);
break;
}
}
ast_mutex_unlock(&provlock);
}
return ret;
}
| 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().
{
int x;
if (!buf || buflen < 1)
return NULL;
buf[0] = '\0';
for (x = 0; x < ARRAY_LEN(iax_flags); x++) {
if (flags & iax_flags[x].value){
strncat(buf, iax_flags[x].name, buflen - strlen(buf) - 1);
strncat(buf, ",", buflen - strlen(buf) - 1);
}
}
if (!ast_strlen_zero(buf))
buf[strlen(buf) - 1] = '\0';
else
strncpy(buf, "none", buflen - 1);
return buf;
}
| 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().
{
struct iax_template *cur;
unsigned int sig;
char tmp[40];
memset(provdata, 0, sizeof(*provdata));
ast_mutex_lock(&provlock);
cur = iax_template_find(template, 1);
/* If no match, try searching for '*' */
if (!cur)
cur = iax_template_find("*", 1);
if (cur) {
/* found it -- add information elements as appropriate */
if (force || strlen(cur->user))
iax_ie_append_str(provdata, PROV_IE_USER, cur->user);
if (force || strlen(cur->pass))
iax_ie_append_str(provdata, PROV_IE_PASS, cur->pass);
if (force || strlen(cur->lang))
iax_ie_append_str(provdata, PROV_IE_LANG, cur->lang);
if (force || cur->port)
iax_ie_append_short(provdata, PROV_IE_PORTNO, cur->port);
if (force || cur->server)
iax_ie_append_int(provdata, PROV_IE_SERVERIP, cur->server);
if (force || cur->serverport)
iax_ie_append_short(provdata, PROV_IE_SERVERPORT, cur->serverport);
if (force || cur->altserver)
iax_ie_append_int(provdata, PROV_IE_ALTSERVER, cur->altserver);
if (force || cur->flags)
iax_ie_append_int(provdata, PROV_IE_FLAGS, cur->flags);
if (force || cur->format)
iax_ie_append_int(provdata, PROV_IE_FORMAT, cur->format);
if (force || cur->tos)
iax_ie_append_byte(provdata, PROV_IE_TOS, cur->tos);
/* Calculate checksum of message so far */
sig = prov_ver_calc(provdata);
if (signature)
*signature = sig;
/* Store signature */
iax_ie_append_int(provdata, PROV_IE_PROVVER, sig);
/* Cache signature for later verification so we need not recalculate all this */
snprintf(tmp, sizeof(tmp), "v0x%08x", sig);
ast_db_put("iax/provisioning/cache", template, tmp);
} else
ast_db_put("iax/provisioning/cache", template, "u");
ast_mutex_unlock(&provlock);
return cur ? 0 : -1;
}
| int iax_provision_reload | ( | int | reload | ) |
Definition at line 527 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().
{
struct ast_config *cfg;
struct iax_template *cur;
char *cat;
int found = 0;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if (!provinit)
iax_provision_init();
cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags);
if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) {
/* Mark all as dead. No need for locking */
AST_LIST_TRAVERSE(&templates, cur, list) {
cur->dead = 1;
}
/* Load as appropriate */
cat = ast_category_browse(cfg, NULL);
while(cat) {
if (strcasecmp(cat, "general")) {
iax_process_template(cfg, cat, found ? "default" : NULL);
found++;
ast_verb(3, "Loaded provisioning template '%s'\n", cat);
}
cat = ast_category_browse(cfg, cat);
}
ast_config_destroy(cfg);
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
return 0;
else
ast_log(LOG_NOTICE, "No IAX provisioning configuration found, IAX provisioning disabled.\n");
iax_provision_free_templates(1 /* remove only marked as dead */);
/* Purge cached signature DB entries */
ast_db_deltree("iax/provisioning/cache", NULL);
return 0;
}
| int iax_provision_unload | ( | void | ) |
Definition at line 518 of file iax2-provision.c.
References ast_cli_unregister_multiple(), cli_iax2_provision, and iax_provision_free_templates().
Referenced by __unload_module().
{
provinit = 0;
ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
iax_provision_free_templates(0 /* Remove all templates. */);
return 0;
}
| int iax_provision_version | ( | unsigned int * | signature, |
| 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().
{
char tmp[80] = "";
struct iax_ie_data ied;
int ret=0;
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&provlock);
if (ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp))) {
ast_log(LOG_ERROR, "ast_db_get failed to retrieve iax/provisioning/cache/%s\n", template);
}
if (sscanf(tmp, "v%30x", version) != 1) {
if (strcmp(tmp, "u")) {
ret = iax_provision_build(&ied, version, template, force);
if (ret)
ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
} else
ret = -1;
} else
ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
ast_mutex_unlock(&provlock);
return ret;
}