33#include <netinet/in.h>
34#include <netinet/in_systm.h>
35#include <netinet/ip.h>
36#include <sys/socket.h>
94 if (!
buf || buflen < 1)
102 strncat(
buf,
",", buflen - strlen(
buf) - 1);
107 buf[strlen(
buf) - 1] =
'\0';
109 strncpy(
buf,
"none", buflen - 1);
118 unsigned int flags = 0;
121 e = strchr(
buf,
',');
135 while(*
buf && (*
buf < 33))
168 if (!strcasecmp(s, cur->
name)) {
169 if (!allowdead && cur->
dead) {
184 int wordlen = strlen(
word);
214 memset(provdata, 0,
sizeof(*provdata));
222 if (force || strlen(cur->
user))
224 if (force || strlen(cur->
pass))
226 if (force || strlen(cur->
lang))
228 if (force || cur->
port)
236 if (force || cur->
flags)
240 if (force || cur->
tos)
250 snprintf(
tmp,
sizeof(
tmp),
"v0x%08x", sig);
253 ast_db_put(
"iax/provisioning/cache",
template,
"u");
263 memset(&ied, 0,
sizeof(ied));
267 ast_log(
LOG_ERROR,
"ast_db_get failed to retrieve iax/provisioning/cache/%s\n",
template);
270 if (strcmp(
tmp,
"u")) {
273 ast_debug(1,
"Unable to create provisioning packet for '%s'\n",
template);
286 int foundserverportno = 0;
293 if (t && strlen(t)) {
296 ast_log(
LOG_WARNING,
"Unable to find base template '%s' for creating '%s'. Trying '%s'\n", t, s, def);
303 ast_log(
LOG_WARNING,
"Unable to locate default base template '%s' for creating '%s', omitting.\n", def, s);
323 if (!strcasecmp(v->
name,
"port") || !strcasecmp(v->
name,
"serverport")) {
324 if ((sscanf(v->
value,
"%5d", &x) == 1) && (x > 0) && (x < 65535)) {
325 if (!strcasecmp(v->
name,
"port")) {
330 foundserverportno = 1;
334 }
else if (!strcasecmp(v->
name,
"server") || !strcasecmp(v->
name,
"altserver")) {
339 if (!strcasecmp(v->
name,
"server"))
344 }
else if (!strcasecmp(v->
name,
"codec")) {
351 }
else if (!strcasecmp(v->
name,
"tos")) {
354 }
else if (!strcasecmp(v->
name,
"user")) {
358 }
else if (!strcasecmp(v->
name,
"pass")) {
362 }
else if (!strcasecmp(v->
name,
"language")) {
366 }
else if (!strcasecmp(v->
name,
"flags")) {
368 }
else if (!strncasecmp(v->
name,
"flags", 5) && strchr(v->
name,
'+')) {
370 }
else if (!strncasecmp(v->
name,
"flags", 5) && strchr(v->
name,
'-')) {
372 }
else if (strcasecmp(v->
name,
"template")) {
379 if (!foundserverportno)
419 return "<unspecified>";
427 return "<unspecified>";
429 ia.s_addr = htonl(addr);
438 char server[INET_ADDRSTRLEN];
439 char alternate[INET_ADDRSTRLEN];
445 e->
command =
"iax2 show provisioning";
447 "Usage: iax2 show provisioning [template]\n"
448 " Lists all known IAX provisioning templates or a\n"
449 " specific one if specified.\n";
455 if ((
a->argc != 3) && (
a->argc != 4))
460 if ((
a->argc == 3) || (!strcasecmp(
a->argv[3], cur->
name))) {
466 ast_cli(
a->fd,
"Base Templ: %s\n", strlen(cur->
src) ? cur->
src :
"<none>");
473 ast_cli(
a->fd,
"Alternate: %s\n", alternate);
483 ast_cli(
a->fd,
"No provisioning templates found\n");
485 ast_cli(
a->fd,
"No provisioning template matching '%s' found\n",
a->argv[3]);
546 if (strcasecmp(cat,
"general")) {
549 ast_verb(3,
"Loaded provisioning template '%s'\n", cat);
557 ast_log(
LOG_NOTICE,
"No IAX provisioning configuration found, IAX provisioning disabled.\n");
Access Control of various sorts.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
Persistent data storage (akin to *doze registry)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int ast_db_deltree(const char *family, const char *keytree)
Delete one or more entries in astdb.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * iax2_getformatname(iax2_format format)
iax2 wrapper function for ast_getformatname
static char version[AST_MAX_EXTENSION]
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Implementation of Inter-Asterisk eXchange, version 2 parser.c parser.h chan_iax2.c.
#define IAX_DEFAULT_PORTNO
Configuration File Parser.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
@ CONFIG_FLAG_FILEUNCHANGED
Asterisk internal frame definitions.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Asterisk locking-related definitions:
#define ast_mutex_unlock(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
void MD5Init(struct MD5Context *context)
void MD5Final(unsigned char digest[16], struct MD5Context *context)
int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr, const char *name, int flag, int family)
Return the first entry from ast_sockaddr_resolve filtered by address family.
uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr)
Get an IPv4 address of an ast_sockaddr.
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Implementation of the IAX2 protocol.
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
int iax_provision_reload(int reload)
static int iax_process_template(struct ast_config *cfg, char *s, char *def)
static unsigned int prov_ver_calc(struct iax_ie_data *provdata)
static ast_mutex_t provlock
static unsigned int iax_str2flags(const char *buf)
static int iax_provision_init(void)
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)
int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force)
char * iax_provflags2str(char *buf, int buflen, unsigned int flags)
static struct iax_flag iax_flags[]
int iax_provision_unload(void)
static const char * iax_server(unsigned int addr)
char * iax_prov_complete_template(const char *line, const char *word, int pos, int state)
int iax_provision_version(unsigned int *version, const char *template, int force)
static void iax_provision_free_templates(int dead)
static char * iax_show_provisioning(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_cli_entry cli_iax2_provision[]
static struct iax_template * iax_template_find(const char *s, int allowdead)
static void iax_template_copy(struct iax_template *dst, struct iax_template *src)
IAX2 Provisioning protocol.
#define PROV_FLAG_HEARTBEAT
#define PROV_FLAG_DIS_THREEWAY
#define PROV_FLAG_DIS_CIDCW
#define PROV_IE_SERVERPORT
#define PROV_FLAG_DIS_CALLWAIT
#define PROV_FLAG_REGISTER
#define PROV_IE_ALTSERVER
#define PROV_FLAG_DIS_CALLERID
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
descriptor for a cli entry.
Structure used to handle boolean flags.
Socket address structure.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct iax_template::@140 list
unsigned short serverport
structure to hold users read from users.conf