61#include <sys/socket.h>
62#include <netinet/in.h>
64#include <netinet/in_systm.h>
65#include <netinet/ip.h>
305#define SCHED_MULTITHREADED
309#define DEBUG_SCHED_MULTITHREAD
313static int nochecksums = 0;
316#define PTR_TO_CALLNO(a) ((unsigned short)(unsigned long)(a))
317#define CALLNO_TO_PTR(a) ((void *)(unsigned long)(a))
319#define DEFAULT_THREAD_COUNT 10
320#define DEFAULT_MAX_THREAD_COUNT 100
321#define DEFAULT_RETRY_TIME 1000
322#define MEMORY_SIZE 100
323#define DEFAULT_DROP 3
327#define MIN_REUSE_TIME 60
334static const char tdesc[] =
"Inter Asterisk eXchange Driver (Ver 2)";
339#define MAX_TRUNK_MTU 1240
344#define DEFAULT_CONTEXT "default"
364#define MAX_TRUNKDATA 640 * 200
397#define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF
399#define IAX_CAPABILITY_MEDBANDWIDTH (IAX_CAPABILITY_FULLBANDWIDTH & \
401 ~AST_FORMAT_SLIN16 & \
402 ~AST_FORMAT_SIREN7 & \
403 ~AST_FORMAT_SIREN14 & \
409#define IAX_CAPABILITY_LOWBANDWIDTH (IAX_CAPABILITY_MEDBANDWIDTH & \
411 ~AST_FORMAT_G726_AAL2 & \
414#define IAX_CAPABILITY_LOWFREE (IAX_CAPABILITY_LOWBANDWIDTH & \
418#define DEFAULT_MAXMS 2000
419#define DEFAULT_FREQ_OK 60 * 1000
420#define DEFAULT_FREQ_NOTOK 10 * 1000
431#define AUTH_METHOD_NAMES_BUFSIZE 19
446 pos += sprintf(pos,
"|RSA");
449 pos += sprintf(pos,
"|MD5");
452 pos += sprintf(pos,
"|plaintext");
464#define IAX_CALLENCRYPTED(pvt) \
465 (ast_test_flag64(pvt, IAX_ENCRYPTED) && ast_test_flag64(pvt, IAX_KEYPOPULATED))
467#define IAX_DEBUGDIGEST(msg, key) do { \
469 char digest[33] = ""; \
474 for (idx = 0; idx < 16; idx++) \
475 sprintf(digest + (idx << 1), "%02hhx", (unsigned char) key[idx]); \
477 ast_log(LOG_NOTICE, msg " IAX_COMMAND_RTKEY to rotate key to '%s'\n", digest); \
491static int test_late = 0;
492static int test_resync = 0;
493static int test_jit = 0;
494static int test_jitpct = 0;
522#define IAX_HASCALLERID (uint64_t)(1LLU << 0)
523#define IAX_DELME (uint64_t)(1LLU << 1)
524#define IAX_TEMPONLY (uint64_t)(1LLU << 2)
525#define IAX_TRUNK (uint64_t)(1LLU << 3)
526#define IAX_NOTRANSFER (uint64_t)(1LLU << 4)
527#define IAX_USEJITTERBUF (uint64_t)(1LLU << 5)
528#define IAX_DYNAMIC (uint64_t)(1LLU << 6)
529#define IAX_SENDANI (uint64_t)(1LLU << 7)
530#define IAX_RTSAVE_SYSNAME (uint64_t)(1LLU << 8)
531#define IAX_ALREADYGONE (uint64_t)(1LLU << 9)
532#define IAX_PROVISION (uint64_t)(1LLU << 10)
533#define IAX_QUELCH (uint64_t)(1LLU << 11)
534#define IAX_ENCRYPTED (uint64_t)(1LLU << 12)
535#define IAX_KEYPOPULATED (uint64_t)(1LLU << 13)
536#define IAX_CODEC_USER_FIRST (uint64_t)(1LLU << 14)
537#define IAX_CODEC_NOPREFS (uint64_t)(1LLU << 15)
538#define IAX_CODEC_NOCAP (uint64_t)(1LLU << 16)
539#define IAX_RTCACHEFRIENDS (uint64_t)(1LLU << 17)
540#define IAX_RTUPDATE (uint64_t)(1LLU << 18)
541#define IAX_RTAUTOCLEAR (uint64_t)(1LLU << 19)
542#define IAX_RTIGNOREREGEXPIRE (uint64_t)(1LLU << 21)
543#define IAX_TRUNKTIMESTAMPS (uint64_t)(1LLU << 22)
544#define IAX_TRANSFERMEDIA (uint64_t)(1LLU << 23)
545#define IAX_MAXAUTHREQ (uint64_t)(1LLU << 24)
546#define IAX_DELAYPBXSTART (uint64_t)(1LLU << 25)
547#define IAX_ALLOWFWDOWNLOAD (uint64_t)(1LLU << 26)
548#define IAX_IMMEDIATE (uint64_t)(1LLU << 27)
549#define IAX_SENDCONNECTEDLINE (uint64_t)(1LLU << 28)
550#define IAX_RECVCONNECTEDLINE (uint64_t)(1LLU << 29)
551#define IAX_FORCE_ENCRYPT (uint64_t)(1LLU << 30)
552#define IAX_SHRINKCALLERID (uint64_t)(1LLU << 31)
662#define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
728#define MIN_RETRY_TIME 100
729#define MAX_RETRY_TIME 10000
731#define MAX_JITTER_BUFFER 50
732#define MIN_JITTER_BUFFER 10
734#define DEFAULT_TRUNKDATA 640 * 10
736#define MAX_TIMESTAMP_SKEW 160
739#define TS_GAP_FOR_JB_RESYNC 5000
742#define MARK_IAX_SUBCLASS_TX 0x8000
975#define PTR_TO_CALLNO_ENTRY(a) ((uint16_t)(unsigned long)(a))
976#define CALLNO_ENTRY_TO_PTR(a) ((void *)(unsigned long)(a))
978#define CALLNO_ENTRY_SET_VALIDATED(a) ((a) |= 0x8000)
979#define CALLNO_ENTRY_IS_VALIDATED(a) ((a) & 0x8000)
980#define CALLNO_ENTRY_GET_CALLNO(a) ((a) & 0x7FFF)
1021#define MAX_PEER_BUCKETS 17
1023#define MAX_PEER_BUCKETS 563
1027#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
1137#ifdef SCHED_MULTITHREADED
1141#ifdef DEBUG_SCHED_MULTITHREAD
1247#define TRUNK_CALL_START (IAX_MAX_CALLS / 2)
1286 va_start(
args, fmt);
1298 va_start(
args, fmt);
1310 va_start(
args, fmt);
1343static int send_command_locked(
unsigned short callno,
char,
int,
unsigned int,
const unsigned char *,
int,
int);
1368 .description =
tdesc,
1409 if (!
iaxs[callno] || !
iaxs[callno]->owner) {
1440 if (subtype == -1) {
1577 ast_verb(1,
"IAX, got a network change message, renewing all IAX registrations.\n");
1595 .
type =
"IAX2_VARIABLE",
1723#ifdef SCHED_MULTITHREADED
1727 static time_t lasterror;
1732 thread->schedfunc = func;
1733 thread->scheddata = data;
1735#ifdef DEBUG_SCHED_MULTITHREAD
1742 if (t != lasterror) {
1744 ast_debug(1,
"Out of idle IAX2 threads for scheduling! (%s)\n", funcname);
1749#define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
1777 ast_debug(3,
"I wanted to lock callno %d, but it is dead or going to die.\n",
callno);
1793 ast_debug(3,
"Hangup initiated on call %d, aborting __send_ping\n",
callno);
1814#ifdef SCHED_MULTITHREADED
1841 if (!strcasecmp(s,
"aes128"))
1857 ast_debug(3,
"Hangup initiated on call %d, aborting __send_lagrq\n",
callno);
1878#ifdef SCHED_MULTITHREADED
1894 if (subclass & (1LL << x)) {
1926 uint64_t pref_bitfield;
1929 if (!pref_bitfield) {
1945 return found_format;
1948 ast_debug(4,
"Could not find preferred codec - Returning zero codec.\n");
2037 const char *
name = obj;
2047 struct iax2_peer *peer = obj, *peer2 = arg;
2048 const char *
name = arg;
2060 const char *
name = obj;
2071 const char *
name = arg;
2088 if (!peer && realtime) {
2213 ast_debug(1,
"Really destroying %d now...\n", callno);
2363 memcpy(
new, fr,
sizeof(*
new));
2474 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2484 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2493 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2503 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2543 struct peercnt *peercnt1 = obj, *peercnt2 = arg;
2572 const char *find =
S_OR(
name,
"guest");
2655 ast_debug(1,
"Reset limits for peercnts table\n");
2821 for (; v; v = v->
next) {
2829 ast_log(
LOG_ERROR,
"Call number limit for %s could not be added, Invalid address range\n.", v->
name);
2831 }
else if ((sscanf(v->
value,
"%d", &limit) != 1) || (limit < 0)) {
2917 e->
command =
"iax2 show callnumber usage";
2919 "Usage: iax2 show callnumber usage [IP address]\n"
2920 " Shows current IP addresses which are consuming iax2 call numbers\n";
2925 if (
a->argc < 4 ||
a->argc > 5)
2929 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2938 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2955 ast_cli(
a->fd,
"\nNon-CallToken Validation Callno Limit: %d\n"
2956 "Non-CallToken Validated Callno Used: %d\n",
2960 ast_cli(
a->fd,
"Total Available Callno: %zu\n"
2961 "Regular Callno Available: %zu\n"
2962 "Trunk Callno Available: %zu\n",
2963 pool_avail + trunk_pool_avail,
2966 }
else if (
a->argc == 5 && !found) {
2967 ast_cli(
a->fd,
"No call number table entries for %s found\n",
a->argv[4] );
3014 "NON-CallToken callnumber limit is reached. Current: %d Max: %d\n",
3037 *entry = pool->
numbers[choice];
3068 "Attempted to decrement total non calltoken validated "
3069 "callnumbers below zero. Callno is: %d\n",
3186 int validated = (
new >
NEW_ALLOW) ? 1 : 0;
3195 .transfercallno =
callno,
3197 .frames_received = check_dcallno,
3203 if (return_locked) {
3212 memset(&tmp_pvt.
addr, 0,
sizeof(tmp_pvt.
addr));
3215 if (return_locked) {
3233 if (!res || !return_locked) {
3273 ast_debug(1,
"Creating new call structure %d\n", x);
3433 struct sockaddr_in *sin;
3436 struct sock_extended_err e;
3441 m.msg_controllen =
sizeof(e);
3443 res = recvmsg(
netsocket, &m, MSG_ERRQUEUE);
3447 if (m.msg_controllen) {
3448 sin = (
struct sockaddr_in *)SO_EE_OFFENDER(&e);
3537 if ((pvt =
iaxs[callno])) {
3554 ast_debug(3,
"Avoiding IAX destroy deadlock\n");
3640 }
else if (f->
final) {
3644 ast_log(
LOG_WARNING,
"Max retries exceeded to host %s on %s (type = %u, subclass = %d, ts=%u, seqno=%d)\n",
3658 if (
iaxs[callno] &&
iaxs[callno]->owner)
3661 if (
iaxs[callno]->reg) {
3662 memset(&
iaxs[callno]->reg->us, 0,
sizeof(
iaxs[callno]->
reg->
us));
3698 }
else if (callno) {
3705#ifdef SCHED_MULTITHREADED
3716 static const char *
const choices[] = {
"all",
NULL };
3721 e->
command =
"iax2 prune realtime";
3723 "Usage: iax2 prune realtime [<peername>|all]\n"
3724 " Prunes object(s) from the cache\n";
3737 if (!strcmp(
a->argv[3],
"all")) {
3740 ast_cli(
a->fd,
"Cache flushed successfully.\n");
3750 ast_cli(
a->fd,
"Peer %s was removed from the cache.\n",
a->argv[3]);
3752 ast_cli(
a->fd,
"Peer %s is not eligible for this operation.\n",
a->argv[3]);
3759 ast_cli(
a->fd,
"User %s was removed from the cache.\n",
a->argv[3]);
3761 ast_cli(
a->fd,
"User %s is not eligible for this operation.\n",
a->argv[3]);
3767 ast_cli(
a->fd,
"%s was not found in the cache.\n",
a->argv[3]);
3777 e->
command =
"iax2 test losspct";
3779 "Usage: iax2 test losspct <percentage>\n"
3780 " For testing, throws away <percentage> percent of incoming packets\n";
3798 e->
command =
"iax2 test late";
3800 "Usage: iax2 test late <ms>\n"
3801 " For testing, count the next frame as <ms> ms late\n";
3810 test_late = atoi(
a->argv[3]);
3819 e->
command =
"iax2 test resync";
3821 "Usage: iax2 test resync <ms>\n"
3822 " For testing, adjust all future frames by <ms> ms\n";
3831 test_resync = atoi(
a->argv[3]);
3840 e->
command =
"iax2 test jitter";
3842 "Usage: iax2 test jitter <ms> <pct>\n"
3843 " For testing, simulate maximum jitter of +/- <ms> on <pct>\n"
3844 " percentage of packets. If <pct> is not specified, adds\n"
3845 " jitter to all packets.\n";
3851 if (
a->argc < 4 ||
a->argc > 5)
3854 test_jit = atoi(
a->argv[3]);
3856 test_jitpct = atoi(
a->argv[4]);
3871 snprintf(
status, statuslen,
"LAGGED (%d ms)", peer->
lastms);
3873 }
else if (peer->
lastms) {
3874 snprintf(
status, statuslen,
"OK (%d ms)", peer->
lastms);
3894 int load_realtime = 0;
3898 e->
command =
"iax2 show peer";
3900 "Usage: iax2 show peer <name>\n"
3901 " Display details on specific IAX peer\n";
3912 load_realtime = (
a->argc == 5 && !strcmp(
a->argv[4],
"load")) ? 1 : 0;
3916 char *str_addr, *str_defaddr;
3917 char *str_port, *str_defport;
3940 ast_cli(
a->fd,
" Addr->IP : %s Port %s\n", str_addr ? str_addr :
"(Unspecified)", str_port);
3941 ast_cli(
a->fd,
" Defaddr->IP : %s Port %s\n", str_defaddr, str_defport);
3946 strcpy(cbuf,
"Error");
3948 ast_cli(
a->fd,
" Codec Order : %s\n", cbuf);
3956 ast_cli(
a->fd,
"Peer %s not found.\n",
a->argv[3]);
3968 int wordlen = strlen(
word);
3973 if (!strncasecmp(peer->
name,
word, wordlen) && ++which >
state
3989 int cnt = 0, dead = 0,
final = 0, i = 0;
3993 e->
command =
"iax2 show stats";
3995 "Usage: iax2 show stats\n"
3996 " Display statistics on IAX channel driver.\n";
4017 ast_cli(
a->fd,
" IAX Statistics\n");
4018 ast_cli(
a->fd,
"---------------------\n");
4022 ast_cli(
a->fd,
"Packets in transmit queue: %d dead, %d final, %d total\n\n", dead,
final, cnt);
4040 "Usage: iax2 set mtu <value>\n"
4041 " Set the system-wide IAX IP mtu to <value> bytes net or\n"
4042 " zero to disable. Disabling means that the operating system\n"
4043 " must handle fragmentation of UDP packets when the IAX2 trunk\n"
4044 " packet exceeds the UDP payload size. This is substantially\n"
4045 " below the IP mtu. Try 1240 on ethernets. Must be 172 or\n"
4046 " greater for G.711 samples.\n";
4054 if (strncasecmp(
a->argv[3],
"default", strlen(
a->argv[3])) == 0)
4057 mtuv = atoi(
a->argv[3]);
4064 if (mtuv < 172 || mtuv > 4000) {
4065 ast_cli(
a->fd,
"Trunk MTU must be between 172 and 4000\n");
4076 char tmp[1024], *pc =
NULL;
4082 e->
command =
"iax2 show cache";
4084 "Usage: iax2 show cache\n"
4085 " Display currently cached IAX Dialplan results.\n";
4093 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8.8s %s\n",
"Peer/Context",
"Exten",
"Exp.",
"Wait.",
"Flags");
4096 s = dp->
expiry.tv_sec - now.tv_sec;
4099 strncat(tmp,
"EXISTS|",
sizeof(tmp) - strlen(tmp) - 1);
4101 strncat(tmp,
"NONEXISTENT|",
sizeof(tmp) - strlen(tmp) - 1);
4103 strncat(tmp,
"CANEXIST|",
sizeof(tmp) - strlen(tmp) - 1);
4105 strncat(tmp,
"PENDING|",
sizeof(tmp) - strlen(tmp) - 1);
4107 strncat(tmp,
"TIMEOUT|",
sizeof(tmp) - strlen(tmp) - 1);
4109 strncat(tmp,
"TRANSMITTED|",
sizeof(tmp) - strlen(tmp) - 1);
4111 strncat(tmp,
"MATCHMORE|",
sizeof(tmp) - strlen(tmp) - 1);
4113 strncat(tmp,
"UNKNOWN|",
sizeof(tmp) - strlen(tmp) - 1);
4116 tmp[strlen(tmp) - 1] =
'\0';
4132 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9d %-8d %s\n", pc, dp->
exten, s, y, tmp);
4134 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->
exten,
"(expired)", y, tmp);
4150 const int lower_mask = (1 << ts_shift) - 1;
4151 const int upper_mask = ~lower_mask;
4154 if ( (fr->
ts & upper_mask) == last_upper ) {
4156 const int threshold = (ts_shift == 15) ? 25000 : 50000;
4163 fr->
ts = (last_upper + (1 << ts_shift)) | (fr->
ts & lower_mask);
4165 ast_debug(1,
"schedule_delivery: pushed forward timestamp\n");
4171 fr->
ts = (last_upper - (1 << ts_shift)) | (fr->
ts & lower_mask);
4173 ast_debug(1,
"schedule_delivery: pushed back timestamp\n");
4223 now.tv_usec += 1000;
4269 af.
src =
"IAX2 JB interpolation";
4302#ifdef SCHED_MULTITHREADED
4338 ast_debug(1,
"schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
4427 0, 0, (
unsigned char *)
text, strlen(
text) + 1, -1);
4461 time_t regseconds = 0, nowtime;
4463 char *str_addr, *str_port;
4477 for (tmp =
var; tmp; tmp = tmp->
next) {
4478 if (!strcasecmp(tmp->
name,
"name"))
4479 peername = tmp->
value;
4483 if (!
var && peername) {
4492 for (tmp =
var; tmp; tmp = tmp->
next) {
4493 if (!strcasecmp(tmp->
name,
"host")) {
4518 for (tmp =
var; tmp; tmp = tmp->
next) {
4520 if (!strcasecmp(tmp->
name,
"type")) {
4521 if (strcasecmp(tmp->
value,
"friend") &&
4522 strcasecmp(tmp->
value,
"peer")) {
4527 }
else if (!strcasecmp(tmp->
name,
"regseconds")) {
4529 }
else if (!strcasecmp(tmp->
name,
"ipaddr")) {
4537 }
else if (!strcasecmp(tmp->
name,
"port")) {
4543 }
else if (!strcasecmp(tmp->
name,
"host")) {
4544 if (!strcasecmp(tmp->
value,
"dynamic"))
4574 memset(&peer->
addr, 0,
sizeof(peer->
addr));
4576 ast_debug(1,
"realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
4577 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4580 ast_debug(1,
"realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
4581 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4593 char *str_addr, *str_port;
4615 for (tmp =
var; tmp; tmp = tmp->
next) {
4616 if (!strcasecmp(tmp->
name,
"host")) {
4637 if (!strcasecmp(tmp->
name,
"type")) {
4638 if (strcasecmp(tmp->
value,
"friend") &&
4639 strcasecmp(tmp->
value,
"user")) {
4665 char regseconds[20];
4667 char *syslabel =
NULL;
4673 syslabel =
"regserver";
4675 snprintf(regseconds,
sizeof(regseconds),
"%d", (
int)regtime);
4680 "regseconds", regseconds, syslabel, sysname,
SENTINEL);
4798 key = strchr(family,
'/');
4836#ifdef SCHED_MULTITHREADED
4849 tmp = (tm.
tm_sec >> 1) & 0x1f;
4850 tmp |= (tm.
tm_min & 0x3f) << 5;
4851 tmp |= (tm.
tm_hour & 0x1f) << 11;
4852 tmp |= (tm.
tm_mday & 0x1f) << 16;
4853 tmp |= ((tm.
tm_mon + 1) & 0xf) << 21;
4854 tmp |= ((tm.
tm_year - 100) & 0x7f) << 25;
4870 struct ast_sockaddr *addr,
int command,
int ts,
unsigned char seqno,
4881 memcpy(&data.ied, ied->
buf, ied->
pos);
4884 data.f.scallno = htons(0x8000 | callno);
4886 data.f.ts = htonl(
ts);
4887 data.f.iseqno = seqno;
4894 return ast_sendto(sockfd, &data, size, 0, addr);
4900 if (pvt && ied && (2 < ((
int)
sizeof(ied->
buf) - ied->
pos))) {
4902 ied->
buf[ied->
pos++] = 0;
4939 (f->
datalen >
sizeof(data))) {
4959 data.ied.pos = ie_data_pos;
5032#define CALLTOKEN_HASH_FORMAT "%s%u%d"
5033#define CALLTOKEN_IE_FORMAT "%u?%s"
5035 time_t t = time(
NULL);
5058 char *rec_hash =
NULL;
5059 char *rec_ts =
NULL;
5060 unsigned int rec_time;
5070 if (!rec_hash || !rec_ts) {
5072 }
else if (sscanf(rec_ts,
"%u", &rec_time) != 1) {
5081 if (strcmp(hash, rec_hash)) {
5133 char *outkey =
NULL;
5148 if (strchr(pds->
peer,
'@')) {
5181 }
else if (outkey && (outkey[0] ==
'[')) {
5196 char *defaultrdest =
"s";
5202 const char* osp_token_ptr;
5203 unsigned int osp_token_length;
5204 unsigned char osp_block_index;
5205 unsigned int osp_block_length;
5206 unsigned char osp_buffer[256];
5207 char encoded_prefs[32];
5215 memset(&cai, 0,
sizeof(cai));
5219 memset(&pds, 0,
sizeof(pds));
5228 pds.
exten = defaultrdest;
5272 memset(&ied, 0,
sizeof(ied));
5357 if (
iaxs[callno]->maxtime) {
5370 osp_block_index = 0;
5371 while (osp_token_length > 0) {
5373 osp_buffer[0] = osp_block_index;
5374 memcpy(osp_buffer + 1, osp_token_ptr, osp_block_length);
5377 osp_token_ptr += osp_block_length;
5378 osp_token_length -= osp_block_length;
5383 ast_debug(1,
"OSP token is undefined\n");
5389 if (variablestore) {
5391 ast_debug(1,
"Found an IAX variable store on this channel\n");
5421 memset(&ied, 0,
sizeof(ied));
5423 if (callno &&
iaxs[callno]) {
5428 if (!
iaxs[callno]->
error && !alreadygone) {
5432 if (!
iaxs[callno]) {
5440 if (
iaxs[callno] && alreadygone) {
5443 }
else if (
iaxs[callno]) {
5445 ast_log(
LOG_ERROR,
"Unable to schedule iax2 callno %d destruction?!! Destroying immediately.\n", callno);
5466 unsigned short callno = pvt->
callno;
5502 if ((*(
int *)
data)) {
5534 if (!(h =
ast_malloc(datalen +
sizeof(*h)))) {
5539 h->option = htons(option);
5540 memcpy(h->
data, data, datalen);
5543 datalen +
sizeof(*h), -1);
5574 ast_debug(1,
"I should never be called!\n");
5591 snprintf(key,
sizeof(key),
"%lX", (
unsigned long)
ast_random());
5610#if defined(IAX2_NATIVE_BRIDGING)
5611static int iax2_start_transfer(
unsigned short callno0,
unsigned short callno1,
int mediaonly)
5616 unsigned int transferid = (
unsigned int)
ast_random();
5619 ast_debug(1,
"transfers are not supported for encrypted calls at this time\n");
5625 memset(&ied0, 0,
sizeof(ied0));
5630 memset(&ied1, 0,
sizeof(ied1));
5647#if defined(IAX2_NATIVE_BRIDGING)
5648static void lock_both(
unsigned short callno0,
unsigned short callno1)
5657#if defined(IAX2_NATIVE_BRIDGING)
5658static void unlock_both(
unsigned short callno0,
unsigned short callno1)
5665#if defined(IAX2_NATIVE_BRIDGING)
5672 int transferstarted=0;
5676 struct timeval waittimer = {0, 0};
5679 if (timeoutms > 0) {
5685 lock_both(callno0, callno1);
5686 if (!
iaxs[callno0] || !
iaxs[callno1]) {
5687 unlock_both(callno0, callno1);
5695 unlock_both(callno0, callno1);
5703 ast_verb(3,
"Can't masquerade, we're different...\n");
5721 ast_verb(3,
"Operating with different codecs [%s] [%s] , can't native bridge...\n",
5726 lock_both(callno0, callno1);
5731 unlock_both(callno0, callno1);
5740 transferstarted = 1;
5763 if (timeoutms > -1) {
5764 timeoutms -= (1000 - to);
5786 other = (who == c0) ? c1 : c0;
5818 if (flags & monitored_source) {
5833 lock_both(callno0, callno1);
5838 unlock_both(callno0, callno1);
5857 ast_debug(1,
"Indicating condition %d\n", condition);
5867 switch (condition) {
5884 ast_debug(2,
"Callno %d: Config blocked sending control frame %d.\n",
5947 const struct ast_channel *requestor,
unsigned int cachable)
5956 char *peer_name =
NULL;
5958 if (!(i =
iaxs[callno])) {
6006 if (i !=
iaxs[callno]) {
6024 if ((callid =
iaxs[callno]->callid)) {
6045 ast_channel_parkinglot_set(tmp, i->
parkinglot);
6066 ast_channel_language_set(tmp, i->
language);
6086 for (v = i->
vars ; v ; v = v->
next)
6093 ast_debug(1,
"Loading up the channel with IAXVARs\n");
6096 if (variablestore && varlist) {
6097 variablestore->
data = varlist;
6107 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
6117 if (variablestore) {
6146 unsigned long int mssincetx;
6173static unsigned int fix_peerts(
struct timeval *rxtrunktime,
int callno,
unsigned int ts)
6195 struct timeval *delivery =
NULL;
6258 else if (adjust > 0)
6278 ast_debug(1,
"predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
6283 int diff = ms % (f->
samples / rate);
6300 if ( (
unsigned int)ms < p->
lastsent )
6308 if (ms <= p->lastsent)
6335 ast_debug(1,
"calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %ums\n",
6340 ast_debug(1,
"calc_rxstamp: call=%d: works out as %d.%6.6d\n",
6348 if (!test_jitpct || ((100.0 *
ast_random() / (RAND_MAX + 1.0)) < test_jitpct)) {
6349 jit = (int)((
float)test_jit *
ast_random() / (RAND_MAX + 1.0));
6350 if ((
int)(2.0 *
ast_random() / (RAND_MAX + 1.0)))
6378 if ((tpeer =
ast_calloc(1,
sizeof(*tpeer)))) {
6387 setsockopt(tpeer->
sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums,
sizeof(nochecksums));
6436 mtm->
mini.
ts = htons(0xffff & fr->
ts);
6476 memcpy(
buf, (
unsigned char *) &tmp, (
len >
sizeof(tmp)) ?
sizeof(tmp) :
len);
6486 for (i = 0; i < 60; i++) {
6522 dst[x] = src[x] ^ 0xff;
6524 unsigned char lastblock[16] = { 0 };
6529 dst[x] ^= lastblock[x];
6530 memcpy(lastblock, src,
sizeof(lastblock));
6546 dst[x] = src[x] ^ 0xff;
6548 unsigned char curblock[16] = { 0 };
6552 curblock[x] ^= src[x];
6554 memcpy(curblock, dst,
sizeof(curblock));
6565 unsigned char *workspace;
6568 memset(f, 0,
sizeof(*f));
6576 padding = 16 + (workspace[15] & 0x0f);
6578 ast_debug(1,
"Decoding full frame with length %d (padding = %d) (15=%02hhx)\n", *datalen, padding, workspace[15]);
6582 *datalen -= padding;
6601 ast_debug(5,
"Decoding mini with length %d\n", *datalen);
6606 padding = 16 + (workspace[15] & 0x0f);
6609 *datalen -= padding;
6618 unsigned char *workspace;
6623 ast_debug(1,
"Encoding full frame %d/%d with length %d\n", fh->
type, fh->
csub, *datalen);
6625 padding = 16 + (padding & 0xf);
6626 memcpy(workspace, poo, padding);
6628 workspace[15] &= 0xf0;
6629 workspace[15] |= (padding & 0xf);
6631 ast_debug(1,
"Encoding full frame %d/%d with length %d + %d padding (15=%02hhx)\n", fh->
type, fh->
csub, *datalen, padding, workspace[15]);
6632 *datalen += padding;
6635 memcpy(poo, workspace + *datalen - 32, 32);
6639 ast_debug(5,
"Encoding mini frame with length %d\n", *datalen);
6641 padding = 16 + (padding & 0xf);
6642 memcpy(workspace, poo, padding);
6644 workspace[15] &= 0xf0;
6645 workspace[15] |= (padding & 0x0f);
6646 *datalen += padding;
6649 memcpy(poo, workspace + *datalen - 32, 32);
6660 unsigned char digest[16];
6661 char *tmppw, *stringp;
6665 while ((tmppw =
strsep(&stringp,
";"))) {
6668 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
6692 unsigned char buffer[4096];
6697 unsigned int lastsent;
6719 "f->frametype %c= AST_FRAME_VOICE, %sencrypted, %srotation scheduled...\n",
6730 (((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
6731 ((fts & 0xFFFF0000L) == ((lastsent + 0x10000) & 0xFFFF0000L))))
6749 if (((fts & 0xFFFF8000L) == (pvt->
lastvsent & 0xFFFF8000L)) &&
6794 fh->
ts = htonl(fr->
ts);
6878 mh->
ts = htons(fr->
ts & 0xFFFF);
6899 int havepattern = 0;
6901#define FORMAT "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n"
6902#define FORMAT2 "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n"
6911 e->
command =
"iax2 show users [like]";
6913 "Usage: iax2 show users [like <pattern>]\n"
6914 " Lists all known IAX2 users.\n"
6915 " Optional regular expression pattern is used to filter the user list.\n";
6923 if (!strcasecmp(
a->argv[3],
"like")) {
6924 if (regcomp(®exbuf,
a->argv[4], REG_EXTENDED | REG_NOSUB))
6935 ast_cli(
a->fd,
FORMAT,
"Username",
"Secret",
"Authen",
"Def.Context",
"A/C",
"Codec Pref");
6938 if (havepattern && regexec(®exbuf,
user->name, 0,
NULL, 0))
6944 snprintf(auth,
sizeof(auth),
"Key: %-15.15s ",
user->inkeys);
6981#define PEERS_FORMAT2 "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n"
6982#define PEERS_FORMAT "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n"
6986 char name[256] =
"";
6991 char *tmp_host, *tmp_mask, *tmp_port;
7005 if (retstatus > 0) {
7007 }
else if (!retstatus) {
7016 "Event: PeerEntry\r\n%s"
7017 "Channeltype: IAX\r\n",
7021 "ObjectName: %s\r\n"
7022 "ObjectUsername: %s\r\n",
7027 "ObjectName: %s\r\n",
7032 "Event: PeerEntry\r\n%s"
7033 "Channeltype: IAX2\r\n"
7034 "ObjectName: %s\r\n",
7039 "ChanObjectType: peer\r\n"
7040 "IPaddress: %s\r\n",
7056 "Encryption: %s\r\n"
7066 "Description: %s\r\n\r\n",
7090 .registeredonly = 0,
7097 .unmonitored_peers = 0,
7106 if (!strcasecmp(argv[3],
"registered"))
7110 if (!strcasecmp(argv[4],
"like")) {
7111 if (regcomp(&cont.
regexbuf, argv[5], REG_EXTENDED | REG_NOSUB))
7118 if (!strcasecmp(argv[3],
"like")) {
7119 if (regcomp(&cont.
regexbuf, argv[4], REG_EXTENDED | REG_NOSUB))
7126 if (!strcasecmp(argv[3],
"registered")) {
7140 ast_cli(fd,
PEERS_FORMAT2,
"Name/Username",
"Host",
" ",
"Mask",
"Port",
" ",
"Status",
"Description");
7159 ast_cli(fd,
"%d iax2 peers [%d online, %d offline, %d unmonitored]\n",
7181 int threadcount = 0, dynamiccount = 0;
7186 e->
command =
"iax2 show threads";
7188 "Usage: iax2 show threads\n"
7189 " Lists status of IAX helper threads\n";
7197 ast_cli(
a->fd,
"IAX2 Thread Information\n");
7202#ifdef DEBUG_SCHED_MULTITHREAD
7203 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7206 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7212 ast_cli(
a->fd,
"Active Threads:\n");
7219#ifdef DEBUG_SCHED_MULTITHREAD
7220 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d, func='%s'\n",
7223 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d\n",
7229 ast_cli(
a->fd,
"Dynamic Threads:\n");
7232#ifdef DEBUG_SCHED_MULTITHREAD
7233 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7236 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7242 ast_cli(
a->fd,
"%d of %d threads accounted for with %d dynamic threads\n", threadcount,
iaxthreadcount, dynamiccount);
7252 e->
command =
"iax2 unregister";
7254 "Usage: iax2 unregister <peername>\n"
7255 " Unregister (force expiration) an IAX2 peer from the registry.\n";
7273 ast_cli(
a->fd,
"Peer %s unregistered\n",
a->argv[2]);
7275 ast_cli(
a->fd,
"Peer %s not found\n",
a->argv[2]);
7278 ast_cli(
a->fd,
"Peer %s not registered\n",
a->argv[2]);
7282 ast_cli(
a->fd,
"Peer unknown: %s. Not unregistered\n",
a->argv[2]);
7292 int wordlen = strlen(
word);
7298 if (!strncasecmp(p->
name,
word, wordlen) &&
7316 e->
command =
"iax2 show peers";
7318 "Usage: iax2 show peers [registered] [like <pattern>]\n"
7319 " Lists all known IAX2 peers.\n"
7320 " Optional 'registered' argument lists only peers with known addresses.\n"
7321 " Optional regular expression pattern is used to filter the peer list.\n";
7347 int *fd = user_data;
7349 ast_cli(*fd,
"%-15.15s %-15d %-15d\n",
7352 (
int) ntohl(
header->datalen));
7361 e->
command =
"iax2 show firmware";
7363 "Usage: iax2 show firmware\n"
7364 " Lists all known IAX firmware images.\n";
7370 if (
a->argc != 3 &&
a->argc != 4)
7373 ast_cli(
a->fd,
"%-15.15s %-15.15s %-15.15s\n",
"Device",
"Version",
"Size");
7376 a->argc == 3 ?
NULL :
a->argv[3],
7386 static const char *
const a[] = {
"iax2",
"show",
"peers" };
7388 char idtext[256] =
"";
7392 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7411 .registeredonly = 0,
7418 .unmonitored_peers = 0,
7427 snprintf(cont.
idtext,
sizeof(cont.
idtext),
"ActionID: %s\r\n",
id);
7449 return "Unregistered";
7451 return "Request Sent";
7453 return "Auth. Sent";
7455 return "Registered";
7461 return "No Authentication";
7469#define FORMAT2 "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n"
7470#define FORMAT "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n"
7479 e->
command =
"iax2 show registry";
7481 "Usage: iax2 show registry\n"
7482 " Lists all registration requests and status.\n";
7489 ast_cli(
a->fd,
FORMAT2,
"Host",
"dnsmgr",
"Username",
"Perceived",
"Refresh",
"State");
7497 (reg->
dnsmgr) ?
"Y" :
"N",
7502 ast_cli(
a->fd,
"%d IAX2 registrations.\n", counter);
7512 char idtext[256] =
"";
7514 char perceived[80] =
"";
7518 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7529 "Event: RegistryEntry\r\n"
7532 "DNSmanager: %s\r\n"
7537 "\r\n", idtext, host, (reg->
dnsmgr) ?
"Y" :
"N", reg->
username, perceived,
7552#define FORMAT2 "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n"
7553#define FORMAT "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %-4.4dms %-6.6s %s%s %3s%s\n"
7554#define FORMATB "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"
7557 char first_message[10] = { 0, };
7558 char last_message[10] = { 0, };
7562 e->
command =
"iax2 show channels";
7564 "Usage: iax2 show channels\n"
7565 " Lists all currently active IAX channels.\n";
7573 ast_cli(
a->fd,
FORMAT2,
"Channel",
"Peer",
"Username",
"ID (Lo/Rem)",
"Seq (Tx/Rx)",
"Lag",
"Jitter",
"JitBuf",
"Format",
"FirstMsg",
"LastMsg");
7577 int lag, jitter, localdelay;
7609 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7620 char first_message[10] = { 0, };
7621 char last_message[10] = { 0, };
7622#define ACN_FORMAT1 "%-24.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n"
7623#define ACN_FORMAT2 "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"
7627 int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
7634 localjitter = jbinfo.
jitter;
7637 locallosspct = jbinfo.
losspct/1000;
7658 iaxs[x]->frames_received/1000,
7659 iaxs[x]->remote_rr.jitter,
7680 iaxs[x]->frames_received/1000,
7681 iaxs[x]->remote_rr.jitter,
7706 e->
command =
"iax2 show netstats";
7708 "Usage: iax2 show netstats\n"
7709 " Lists network status for all currently active IAX channels.\n";
7716 ast_cli(
a->fd,
" -------- LOCAL --------------------- -------- REMOTE --------------------\n");
7717 ast_cli(
a->fd,
"Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts FirstMsg LastMsg\n");
7719 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7727 e->
command =
"iax2 set debug {on|off|peer}";
7729 "Usage: iax2 set debug {on|off|peer peername}\n"
7730 " Enables/Disables dumping of IAX packets for debugging purposes.\n";
7733 if (
a->pos == 4 && !strcasecmp(
a->argv[3],
"peer"))
7738 if (
a->argc < e->
args ||
a->argc > e->
args + 1)
7741 if (!strcasecmp(
a->argv[3],
"peer")) {
7744 if (
a->argc != e->
args + 1)
7750 ast_cli(
a->fd,
"IAX2 peer '%s' does not exist\n",
a->argv[e->
args-1]);
7759 }
else if (!strncasecmp(
a->argv[3],
"on", 2)) {
7761 ast_cli(
a->fd,
"IAX2 Debugging Enabled\n");
7765 ast_cli(
a->fd,
"IAX2 Debugging Disabled\n");
7774 e->
command =
"iax2 set debug trunk {on|off}";
7776 "Usage: iax2 set debug trunk {on|off}\n"
7777 " Enables/Disables debugging of IAX trunking\n";
7783 if (
a->argc != e->
args)
7786 if (!strncasecmp(
a->argv[e->
args - 1],
"on", 2)) {
7788 ast_cli(
a->fd,
"IAX2 Trunk Debugging Enabled\n");
7791 ast_cli(
a->fd,
"IAX2 Trunk Debugging Disabled\n");
7800 e->
command =
"iax2 set debug jb {on|off}";
7802 "Usage: iax2 set debug jb {on|off}\n"
7803 " Enables/Disables jitterbuffer debugging information\n";
7809 if (
a->argc != e->
args)
7812 if (!strncasecmp(
a->argv[e->
args -1],
"on", 2)) {
7814 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Enabled\n");
7817 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Disabled\n");
7860 f.
src = __FUNCTION__;
7874 ast_debug(2,
"Callno %d: Blocked sending control frame %d.\n",
7897 int call_num = i->
callno;
7900 if (!
iaxs[call_num])
7933 int gotcapability = 0;
7984 memset(&
iaxs[callno]->rprefs, 0,
sizeof(
iaxs[callno]->rprefs));
7988 if (!gotcapability) {
8000 !strcmp(
iaxs[callno]->username,
user->name))
8014 if (bestscore < 4) {
8023 if (bestscore < 3) {
8034 if (bestscore < 2) {
8043 if (bestscore < 1) {
8068 for (v =
user->vars ; v ; v = v->
next) {
8077 if (
user->maxauthreq > 0)
8126 char *family, *key=
NULL;
8129 key = strchr(family,
'/');
8172 return ast_sendto(sockfd, &fh,
sizeof(fh), 0, addr);
8199 int res = -1, authreq_restrict = 0;
8203 memset(&ied, 0,
sizeof(ied));
8211 if (
user->curauthreq ==
user->maxauthreq)
8212 authreq_restrict = 1;
8220 if (authreq_restrict) {
8249 char requeststr[256];
8250 char md5secret[256] =
"";
8252 char rsasecret[256] =
"";
8271 ast_log(
LOG_WARNING,
"Call Terminated, incoming call is unencrypted while force encrypt is enabled.\n");
8288 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8292 keyn =
strsep(&stringp,
":");
8300 ast_log(
LOG_WARNING,
"Requested inkey '%s' for RSA authentication does not exist\n", keyn);
8302 keyn =
strsep(&stringp,
":");
8310 unsigned char digest[16];
8311 char *tmppw, *stringp;
8314 while((tmppw =
strsep(&stringp,
";"))) {
8317 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8321 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8322 if (!strcasecmp(requeststr, md5secret)) {
8331 if (!strcmp(secret, p->
secret)) {
8344 char requeststr[256] =
"";
8345 char peer[256] =
"";
8346 char md5secret[256] =
"";
8347 char rsasecret[256] =
"";
8348 char secret[256] =
"";
8378 if (!p || !
iaxs[callno]) {
8422 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8426 keyn =
strsep(&stringp,
":");
8434 keyn =
strsep(&stringp,
":");
8444 ast_log(
LOG_NOTICE,
"Host '%s' trying to do RSA authentication, but we have no inkeys\n", peer);
8449 unsigned char digest[16];
8450 char *tmppw, *stringp;
8454 while((tmppw =
strsep(&stringp,
";"))) {
8457 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8460 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8461 if (!strcasecmp(requeststr, md5secret))
8473 if (strcmp(secret, p->
secret)) {
8493 if (expire && (expire <
iaxs[callno]->expiry)) {
8536 unsigned char digest[16];
8540 MD5Update(&
md5, (
unsigned char *) secret, strlen(secret));
8551 unsigned char digest[16];
8555 MD5Update(&
md5, (
unsigned char *)secret, strlen(secret));
8559 sprintf(digres + (x << 1),
"%02hhx", digest[x]);
8589 uint16_t callno = p->
callno;
8591 memset(&ied, 0,
sizeof(ied));
8643 if (!(p =
iaxs[callno])) {
8652 if (!(p =
iaxs[callno]))
8667 ast_log(
LOG_WARNING,
"Call terminated. Encryption requested by peer but no secret available locally\n");
8676 ast_log(
LOG_NOTICE,
"Call initiated without encryption while forceencryption=yes option is set\n");
8685 if (variablestore && varlist && p->
owner) {
8686 variablestore->
data = varlist;
8696 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8707 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8742#ifdef SCHED_MULTITHREADED
8755 memset(&ied, 0,
sizeof(ied));
8785 char exten[256] =
"";
8812 dp->
flags &= ~CACHE_FLAG_PENDING;
8819 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
8838 peercallno = ies->
callno;
8840 if (peercallno < 1) {
8901 char peer[256] =
"";
8904 char ourip[256] =
"<Unspecified>";
8945 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new and %d old messages waiting", reg->
messages & 0xff, reg->
messages >> 8);
8947 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new messages waiting", reg->
messages);
8949 ast_copy_string(msgstatus,
" with 1 new message waiting",
sizeof(msgstatus));
8951 ast_copy_string(msgstatus,
" with no messages waiting",
sizeof(msgstatus));
8964 const char *secret,
const char *porta)
8990 if (!porta && !reg->
port) {
8993 sscanf(porta,
"%5d", ®->
port);
9021 ast_log(
LOG_WARNING,
"Format for registration is user[:secret]@host[:port] at line %d\n", lineno);
9030 porta =
strsep(&stringp,
":");
9032 if (porta && !atoi(porta)) {
9044 char *stringp, *
ext;
9086 if (peer->
expire == -1) {
9093 ast_debug(1,
"Expiring registration for peer '%s'\n", peer->
name);
9098 "peer_status",
"Unregistered",
9099 "cause",
"Expired");
9122#ifdef SCHED_MULTITHREADED
9138 expiry = strrchr(data,
':');
9194 const char *peer_name;
9226 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9230 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9256 ast_verb(3,
"Registered IAX2 '%s' (%s) at %s\n",
9262 "peer_status",
"Registered",
9263 "address", str_addr,
9268 ast_verb(3,
"Unregistered IAX2 '%s' (%s)\n",
9273 "peer_status",
"Unregistered");
9340 msgcount = (old << 8) |
new;
9366 const char *peer_name;
9381 memset(&ied, 0,
sizeof(ied));
9414 char peer[256] =
"";
9417 int authmethods = 0;
9424 memset(&ied, 0,
sizeof(ied));
9439 if (reg->
secret[0] ==
'[') {
9442 tmpkey[strlen(tmpkey) - 1] =
'\0';
9466 int callno = (int)(
long)(nothing);
9470 memset(&ied, 0,
sizeof(ied));
9485 int callno = (int)(
long)(data);
9490#ifdef SCHED_MULTITHREADED
9515 int callno = (int)(
long)(nothing);
9519 memset(&ied, 0,
sizeof(ied));
9529 int callno = (int)(
long)(data);
9535#ifdef SCHED_MULTITHREADED
9548 memset(&ied, 0,
sizeof(ied));
9565 if (((
unsigned char) (f->
oseqno -
last) < 128) &&
9583#ifdef SCHED_MULTITHREADED
9620 calls = tpeer->
calls;
9636 if (now->tv_sec > tpeer->
trunkact.tv_sec + 5)
9675 ast_verbose(
" - Trunk peer (%s) has %d call chunk%s in transit, %u bytes backlogged and has hit a high water mark of %u bytes\n",
9678 (res != 1) ?
"s" :
"",
9695 if (drop->trunkdata) {
9697 drop->trunkdata =
NULL;
9705 ast_verbose(
"Ending trunk processing with %d peers and %d call chunks processed\n", processed,
totalcalls);
9719static void dp_lookup(
int callno,
const char *
context,
const char *callednum,
const char *callerid,
int skiplock)
9721 unsigned short dpstatus = 0;
9725 memset(&ied1, 0,
sizeof(ied1));
9764 pthread_t newthread;
9782 unsigned int ourver;
9784 snprintf(rsi,
sizeof(rsi),
"si-%s", si);
9787 ast_debug(1,
"Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
9798 memset(iep, 0,
sizeof(*iep));
9823 unsigned int length, offset = 0;
9834 memcpy(full_osptoken + offset, ies->
osptokenblock[i], length);
9841 *(full_osptoken + offset) =
'\0';
9842 if (strlen(full_osptoken) != offset) {
9844 *full_osptoken =
'\0';
9852 int localjitter = -1, localdelay = 0, locallost = -1, locallosspct = -1, localdropped = 0, localooo = -1, localpackets = -1;
9859 localjitter = jbinfo.
jitter;
9862 locallosspct = jbinfo.
losspct/1000;
9867 ast_debug(3,
"JB STATS:%s ping=%u ljitterms=%d ljbdelayms=%d ltotlost=%d lrecentlosspct=%d ldropped=%d looo=%d lrecvd=%d rjitterms=%d rjbdelayms=%d rtotlost=%d rrecentlosspct=%d rdropped=%d rooo=%d rrecvd=%d\n",
9932 memcpy(pkt_buf->
buf, from_here->
buf, pkt_buf->
len);
9958 static time_t last_errtime = 0;
9963 if (t != last_errtime) {
9965 ast_debug(1,
"Out of idle IAX2 threads for I/O, pausing!\n");
9975 if (
thread->buf_len < 0) {
9976 if (
errno != ECONNREFUSED &&
errno != EAGAIN)
10024#ifdef DEBUG_SCHED_MULTITHREAD
10035 unsigned char metatype;
10042 struct timeval rxtrunktime;
10045 if (packet_len <
sizeof(*
meta)) {
10046 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a meta frame but is too short\n",
10054 if (packet_len < (
sizeof(*
meta) +
sizeof(*mth))) {
10055 ast_log(
LOG_WARNING,
"midget meta trunk packet received (%d of %d min)\n", packet_len,
10056 (
int) (
sizeof(*
meta) +
sizeof(*mth)));
10060 ts = ntohl(mth->
ts);
10061 metatype =
meta->cmddata;
10062 packet_len -= (
sizeof(*meta) +
sizeof(*mth));
10066 ast_log(
LOG_WARNING,
"Unable to accept trunked packet from '%s': No matching peer\n",
10075 while (packet_len >=
sizeof(*mte)) {
10077 unsigned short callno, trunked_ts,
len;
10081 ptr +=
sizeof(*mtm);
10082 packet_len -=
sizeof(*mtm);
10085 trunked_ts = ntohs(mtm->
mini.
ts);
10088 ptr +=
sizeof(*mte);
10089 packet_len -=
sizeof(*mte);
10098 if (
len > packet_len)
10107 memset(&f, 0,
sizeof(f));
10170 if (!variablestore) {
10174 varlist = variablestore->
data;
10178 if (strcmp(
var->name, data) == 0) {
10199 if (!variablestore) {
10201 if (!variablestore) {
10213 variablestore->
data = varlist;
10217 varlist = variablestore->
data;
10221 if (strcmp(
var->name, data) == 0) {
10246 if (
iaxs[callno] &&
iaxs[callno]->owner) {
10268 int updatehistory=1;
10271 char decrypted = 0;
10290 char host_pref_buf[128];
10291 char caller_pref_buf[128];
10293 char *using_prefs =
"mine";
10297 memset(fr, 0,
sizeof(*fr));
10305 if (res <
sizeof(*mh)) {
10306 ast_log(
LOG_WARNING,
"midget packet received (%d of %d min)\n", res, (
int)
sizeof(*mh));
10309 if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
10310 if (res <
sizeof(*vh)) {
10311 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a video frame but is too short\n",
10317 fr->
callno =
find_callno(ntohs(vh->callno) & ~0x8000, dcallno, &addr,
new, fd, 0);
10319 }
else if ((
meta->zeros == 0) && !(ntohs(
meta->metacmd) & 0x8000))
10322#ifdef DEBUG_SUPPORT
10323 if (res >=
sizeof(*fh))
10327 if (res <
sizeof(*fh)) {
10328 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a full frame but is too short\n",
10334 dcallno = ntohs(fh->
dcallno) & ~IAX_FLAG_RETRANS;
10361 if ((fh->
csub >> 6) & 0x1) {
10383 f.
datalen = res -
sizeof(*fh);
10397 memset(&ies, 0,
sizeof(ies));
10404 memset(&ies, 0,
sizeof(ies));
10428 memset(&ies, 0,
sizeof(ies));
10432 int check_dcallno = 0;
10498#ifdef DEBUG_SUPPORT
10510 int data_size =
sizeof(*cause_code);
10511 char subclass[40] =
"";
10527 data_size += strlen(subclass);
10530 memset(cause_code, 0, data_size);
10534 snprintf(cause_code->
code, data_size -
sizeof(*cause_code) + 1,
"IAX2 %s(%d)", subclass, ies.
causecode);
10555 unsigned short new_peercallno;
10557 new_peercallno = (
unsigned short) (ntohs(mh->callno) & ~IAX_FLAG_FULL);
10572 fr->
ts = ntohl(fh->
ts);
10575 ast_debug(1,
"Simulating frame ts resync, was %u now %u\n", fr->
ts, fr->
ts + test_resync);
10576 fr->
ts += test_resync;
10608 ast_debug(1,
"Packet arrived out of order (expecting %d, got %d) (frametype = %u, subclass = %d)\n",
10641 if (res < thread->buf_size)
10642 thread->buf[res++] =
'\0';
10644 thread->buf[res - 1] =
'\0';
10653 int call_to_destroy;
10665 ast_debug(1,
"Cancelling transmission of packet %d\n", x);
10666 call_to_destroy = 0;
10673 call_to_destroy = fr->
callno;
10676 if (call_to_destroy) {
10678 ast_debug(1,
"Really destroying %d, having been acked on final message\n", call_to_destroy);
10739 if (variablestore && varlist) {
10740 variablestore->
data = varlist;
10752 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10763 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10764 if (variablestore) {
10775 ast_debug(1,
"No channel, so populating IAXVARs to the pvt, as an intermediate step.\n");
10786 ast_debug(1,
"I have IAX variables, but they were not processed\n");
10816 ast_debug(1,
"Neat, somebody took away the channel at a magical time but i found it!\n");
10820 ast_debug(1,
"I can haz iaxvars, but they is no good. :-(\n");
10862 const char *moh_suggest;
10908 memset(&ied1, 0,
sizeof(ied1));
10930 fr->
callno = new_callno;
10939 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, who was trying to reach '%s@%s'\n",
10946 ast_log(
LOG_WARNING,
"Rejected connect attempt. No secret present while force encrypt enabled.\n");
10950 const char *
context, *exten, *cid_num;
10970 memset(&ied0, 0,
sizeof(ied0));
10978 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
10986 using_prefs =
"reqonly";
10988 using_prefs =
"disabled";
10991 memset(&pref, 0,
sizeof(pref));
10992 strcpy(caller_pref_buf,
"disabled");
10993 strcpy(host_pref_buf,
"disabled");
10996 using_prefs =
"mine";
11004 using_prefs =
"caller";
11019 memset(&ied0, 0,
sizeof(ied0));
11032 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11037 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11052 memset(&pref, 0,
sizeof(pref));
11054 strcpy(caller_pref_buf,
"disabled");
11055 strcpy(host_pref_buf,
"disabled");
11058 using_prefs =
"mine";
11065 using_prefs =
"caller";
11078 memset(&ied0, 0,
sizeof(ied0));
11087 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11100 memset(&ied1, 0,
sizeof(ied1));
11106 ast_verb(3,
"Accepting UNAUTHENTICATED call from %s:\n"
11107 "%srequested format = %s,\n"
11108 "%srequested prefs = %s,\n"
11109 "%sactual format = %s,\n"
11110 "%shost prefs = %s,\n"
11111 "%spriority = %s\n",
11160 ast_debug(1,
"Immediately destroying %d, having received hangup\n", fr->
callno);
11187 ast_debug(1,
"Immediately destroying %d, having received reject\n",
11246 memset(&ied0, 0,
sizeof(ied0));
11257 ast_log(
LOG_NOTICE,
"Rejected call to %s, format %s incompatible with our capability %s.\n",
11324 "peer_status",
"Reachable",
11333 "peer_status",
"Lagged",
11387 ast_debug(1,
"Peer %s lag measured as %dms\n",
11401 "I don't know how to authenticate %s to %s\n",
11419 memset(&ied0, 0,
sizeof(ied0));
11430 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
11434 memset(&ied0, 0,
sizeof(ied0));
11445 using_prefs =
"reqonly";
11447 using_prefs =
"disabled";
11450 memset(&pref, 0,
sizeof(pref));
11451 strcpy(caller_pref_buf,
"disabled");
11452 strcpy(host_pref_buf,
"disabled");
11455 using_prefs =
"mine";
11461 using_prefs =
"caller";
11477 ast_debug(1,
"We don't do requested format %s, falling back to peer capability '%s'\n",
11485 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11490 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11497 memset(&ied0, 0,
sizeof(ied0));
11512 memset(&pref, 0,
sizeof(pref));
11516 strcpy(caller_pref_buf,
"disabled");
11517 strcpy(host_pref_buf,
"disabled");
11520 using_prefs =
"mine";
11527 using_prefs =
"caller";
11543 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11548 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11555 memset(&ied0, 0,
sizeof(ied0));
11567 memset(&ied1, 0,
sizeof(ied1));
11574 ast_verb(3,
"Accepting AUTHENTICATED call from %s:\n"
11575 "%srequested auth methods = (%s),\n"
11576 "%sactual auth method = %s,\n"
11577 "%sencrypted = %s,\n"
11578 "%srequested format = %s,\n"
11579 "%srequested prefs = %s,\n"
11580 "%sactual format = %s,\n"
11581 "%shost prefs = %s,\n"
11582 "%spriority = %s\n",
11611 }
else if (ies.
vars) {
11617 if (variablestore && varlist) {
11618 variablestore->
data = varlist;
11621 ast_debug(1,
"I can haz IAX vars? w00t\n");
11629 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11639 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11651 goto immediatedial;
11664 ast_log(
LOG_WARNING,
"Rejected dial attempt from %s, request '%s@%s' does not exist\n",
11668 memset(&ied0, 0,
sizeof(ied0));
11678 ast_verb(3,
"Accepting DIAL from %s, formats = %s\n",
11688 }
else if (ies.
vars) {
11694 ast_debug(1,
"I can haz IAX vars? w00t\n");
11695 if (variablestore && varlist) {
11696 variablestore->
data = varlist;
11706 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11716 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11728 ast_debug(1,
"Immediately destroying %d, having received INVAL\n", fr->
callno);
11733 ast_debug(1,
"Received VNAK: resending outstanding frames\n");
11799 memset(&ied0, 0,
sizeof(ied0));
11874 memset(&ied0, 0,
sizeof(ied0));
11875 memset(&ied1, 0,
sizeof(ied1));
11893 memset(&ied0, 0,
sizeof(ied0));
11894 memset(&ied1, 0,
sizeof(ied1));
11930 "we've been told to rotate our encryption key, "
11931 "but this isn't an encrypted call. bad things will happen.\n"
11952 memset(&ied0, 0,
sizeof(ied0));
11972 memset(&ied0, 0,
sizeof(ied0));
11979 ast_debug(1,
"I can haz IAX vars, but they is no good :-(\n");
11999 }
else if (minivid) {
12002 if (ntohs(vh->ts) & 0x8000LL) {
12018 f.
datalen = res -
sizeof(*vh);
12025 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | ((ntohs(vh->ts) + test_resync) & 0x7fff);
12028 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | (ntohs(vh->ts) & 0x7fff);
12040 ast_debug(1,
"Received mini frame before first full voice frame\n");
12059 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF0000L) | ((ntohs(mh->ts) + test_resync) & 0xffff);
12077 ast_debug(2,
"Callno %d: Blocked receiving control frame %d.\n",
12088 ast_debug(2,
"Callno %d: Config blocked receiving control frame %d.\n",
12210 struct timeval wait;
12211 struct timespec ts;
12212 int put_into_idle = 0;
12213 int first_time = 1;
12218 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
12237 if (put_into_idle) {
12245 ts.tv_sec = wait.tv_sec;
12246 ts.tv_nsec = wait.tv_usec * 1000;
12250 if (!put_into_idle ||
thread->stop) {
12270 ts.tv_sec = wait.tv_sec;
12271 ts.tv_nsec = wait.tv_usec * 1000;
12291 switch (
thread->iostate) {
12303#ifdef SCHED_MULTITHREADED
12321 time(&
thread->checktime);
12323#ifdef DEBUG_SCHED_MULTITHREAD
12324 thread->curfunc[0]=
'\0';
12343 pthread_detach(pthread_self());
12349 pthread_cleanup_pop(1);
12370 int callno = reg->
callno;
12378 ast_debug(1,
"Unable to send registration request for '%s' without IP address\n", reg->
username);
12390 ast_debug(3,
"Allocate call number\n");
12405 memset(&ied, 0,
sizeof(ied));
12425 memset(&cai, 0,
sizeof(cai));
12427 ast_debug(1,
"Provisioning '%s' from template '%s'\n", dest,
template);
12430 ast_debug(1,
"No provisioning found for template '%s'\n",
template);
12441 memset(&ied, 0,
sizeof(ied));
12448 if (
iaxs[callno]) {
12476 opts = strchr(sdata,
'|');
12489 ast_verb(3,
"Provisioned IAXY at '%s' with '%s'= %d\n",
12502 e->
command =
"iax2 provision";
12504 "Usage: iax2 provision <host> <template> [forced]\n"
12505 " Provisions the given peer or IP address using a template\n"
12506 " matching either 'template' or '*' if the template is not\n"
12507 " found. If 'forced' is specified, even empty provisioning\n"
12508 " fields will be provisioned as empty fields.\n";
12519 if (!strcasecmp(
a->argv[4],
"forced"))
12526 ast_cli(
a->fd,
"Unable to find peer/address '%s'\n",
a->argv[2]);
12528 ast_cli(
a->fd,
"No template (including wildcard) matching '%s'\n",
a->argv[3]);
12530 ast_cli(
a->fd,
"Provisioning '%s' with template '%s'%s\n",
a->argv[2],
a->argv[3], force ?
", forced" :
"");
12539 if (peer->
lastms > -1) {
12545 "peer_status",
"Unreachable",
12567#ifdef SCHED_MULTITHREADED
12686 memset(&pds, 0,
sizeof(pds));
12696 memset(&cai, 0,
sizeof(cai));
12724 if ((new_callno =
make_trunk(callno, 1)) != -1)
12725 callno = new_callno;
12737 requestor, cai.
found);
12778 ao2_ref(best_fmt_native, -1);
12801 pthread_testcancel();
12808 if (res < 0 &&
errno != -EINTR) {
12820 int threadcount = 0;
12826 thread->threadnum = ++threadcount;
12860 ast_verb(2,
"%d helper threads started\n", threadcount);
12877 if (strstr(
value,
"rsa"))
12879 if (strstr(
value,
"md5"))
12881 if (strstr(
value,
"plaintext"))
12896 sd = socket(addr->
ss.ss_family, SOCK_DGRAM, 0);
12929 port = atoi(portstr);
12967 if (nonlocal == 1) {
12969 "Non-local or unbound address specified (%s) in sourceaddress for '%s', reverting to default\n",
12973 }
else if (nonlocal == 2) {
12975 "Unable to bind to sourceaddress '%s' for '%s', reverting to default\n",
12980 ast_debug(1,
"Using sourceaddress %s for '%s'\n", srcaddr, peer->
name);
13020 int subscribe_acl_change = 0;
13031 oldacl = peer->
acl;
13081 if (!strcasecmp(v->
name,
"secret")) {
13083 }
else if (!strcasecmp(v->
name,
"mailbox")) {
13085 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
13091 if (strchr(
name,
'@')) {
13097 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13099 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13101 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13103 }
else if (!strcasecmp(v->
name,
"description")) {
13105 }
else if (!strcasecmp(v->
name,
"trunk")) {
13108 ast_log(
LOG_WARNING,
"Unable to support trunking on peer '%s' without a timing interface\n", peer->
name);
13111 }
else if (!strcasecmp(v->
name,
"auth")) {
13116 }
else if (!strcasecmp(v->
name,
"encryption")) {
13121 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13130 }
else if (!strcasecmp(v->
name,
"transfer")) {
13131 if (!strcasecmp(v->
value,
"mediaonly")) {
13137 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13139 }
else if (!strcasecmp(v->
name,
"host")) {
13140 if (!strcasecmp(v->
value,
"dynamic")) {
13168 }
else if (!strcasecmp(v->
name,
"defaultip")) {
13170 peer_defaddr_tmp.
ss.ss_family = AF_UNSPEC;
13176 }
else if (!strcasecmp(v->
name,
"sourceaddress")) {
13178 }
else if (!strcasecmp(v->
name,
"permit") ||
13179 !strcasecmp(v->
name,
"deny") ||
13180 !strcasecmp(v->
name,
"acl")) {
13182 }
else if (!strcasecmp(v->
name,
"mask")) {
13185 }
else if (!strcasecmp(v->
name,
"context")) {
13187 }
else if (!strcasecmp(v->
name,
"regexten")) {
13189 }
else if (!strcasecmp(v->
name,
"peercontext")) {
13191 }
else if (!strcasecmp(v->
name,
"port")) {
13201 }
else if (!strcasecmp(v->
name,
"username")) {
13203 }
else if (!strcasecmp(v->
name,
"allow")) {
13205 }
else if (!strcasecmp(v->
name,
"disallow")) {
13207 }
else if (!strcasecmp(v->
name,
"callerid")) {
13219 }
else if (!strcasecmp(v->
name,
"fullname")) {
13222 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13225 }
else if (!strcasecmp(v->
name,
"sendani")) {
13227 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13229 }
else if (!strcasecmp(v->
name,
"outkey")) {
13231 }
else if (!strcasecmp(v->
name,
"qualify")) {
13232 if (!strcasecmp(v->
value,
"no")) {
13234 }
else if (!strcasecmp(v->
value,
"yes")) {
13236 }
else if (sscanf(v->
value,
"%30d", &peer->
maxms) != 1) {
13237 ast_log(
LOG_WARNING,
"Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of iax.conf\n", peer->
name, v->
lineno);
13240 }
else if (!strcasecmp(v->
name,
"qualifysmoothing")) {
13242 }
else if (!strcasecmp(v->
name,
"qualifyfreqok")) {
13244 ast_log(
LOG_WARNING,
"Qualification testing frequency of peer '%s' when OK should a number of milliseconds at line %d of iax.conf\n", peer->
name, v->
lineno);
13246 }
else if (!strcasecmp(v->
name,
"qualifyfreqnotok")) {
13248 ast_log(
LOG_WARNING,
"Qualification testing frequency of peer '%s' when NOT OK should be a number of milliseconds at line %d of iax.conf\n", peer->
name, v->
lineno);
13250 }
else if (!strcasecmp(v->
name,
"timezone")) {
13252 }
else if (!strcasecmp(v->
name,
"adsi")) {
13254 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13257 }
else if (!strcasecmp(v->
value,
"send")) {
13260 }
else if (!strcasecmp(v->
value,
"receive")) {
13266 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
13272 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13276 }
else if (!strcasecmp(v->
value,
"auto")) {
13317 if (subscribe_acl_change) {
13346 int oldcurauthreq = 0;
13347 int subscribe_acl_change = 0;
13348 char *varname =
NULL, *varval =
NULL;
13359 oldcurauthreq =
user->curauthreq;
13360 oldacl =
user->acl;
13361 oldcon =
user->contexts;
13380 user->curauthreq = oldcurauthreq;
13402 if (!strcasecmp(v->
name,
"context")) {
13408 user->contexts = con;
13411 }
else if (!strcasecmp(v->
name,
"permit") ||
13412 !strcasecmp(v->
name,
"deny") ||
13413 !strcasecmp(v->
name,
"acl")) {
13415 }
else if (!strcasecmp(v->
name,
"setvar")) {
13417 if ((varval = strchr(varname,
'='))) {
13423 user->vars = tmpvar;
13427 }
else if (!strcasecmp(v->
name,
"allow")) {
13429 }
else if (!strcasecmp(v->
name,
"disallow")) {
13431 }
else if (!strcasecmp(v->
name,
"trunk")) {
13434 ast_log(
LOG_WARNING,
"Unable to support trunking on user '%s' without a timing interface\n",
user->name);
13437 }
else if (!strcasecmp(v->
name,
"auth")) {
13442 }
else if (!strcasecmp(v->
name,
"encryption")) {
13444 if (!
user->encmethods) {
13447 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13452 if (
user->encmethods) {
13456 }
else if (!strcasecmp(v->
name,
"transfer")) {
13457 if (!strcasecmp(v->
value,
"mediaonly")) {
13463 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13464 if(!strcasecmp(v->
value,
"caller"))
13466 else if(!strcasecmp(v->
value,
"disabled"))
13468 else if(!strcasecmp(v->
value,
"reqonly")) {
13472 }
else if (!strcasecmp(v->
name,
"immediate")) {
13474 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13476 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13478 }
else if (!strcasecmp(v->
name,
"secret")) {
13485 }
else if (!strcasecmp(v->
name,
"callerid")) {
13498 }
else if (!strcasecmp(v->
name,
"fullname")) {
13507 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13516 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13518 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13520 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13522 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13524 }
else if (!strcasecmp(v->
name,
"language")) {
13526 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13531 user->amaflags = format;
13533 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13535 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13537 if (
user->maxauthreq < 0)
13538 user->maxauthreq = 0;
13539 }
else if (!strcasecmp(v->
name,
"adsi")) {
13541 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13544 }
else if (!strcasecmp(v->
value,
"send")) {
13547 }
else if (!strcasecmp(v->
value,
"receive")) {
13553 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13557 }
else if (!strcasecmp(v->
value,
"auto")) {
13572 if (!
user->authmethods) {
13593 if (subscribe_acl_change) {
13702 const char *tosval;
13707 int subscribe_network_change = 1;
13742 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
13794 if (!strcasecmp(v->
name,
"bindport")) {
13801 }
else if (!strcasecmp(v->
name,
"pingtime")){
13804 else if (!strcasecmp(v->
name,
"iaxthreadcount")) {
13818 }
else if (!strcasecmp(v->
name,
"iaxmaxthreadcount")) {
13833 }
else if (!strcasecmp(v->
name,
"nochecksums")) {
13841 ast_log(
LOG_WARNING,
"Disabling RTP checksums is not supported on this operating system!\n");
13844 else if (!strcasecmp(v->
name,
"maxjitterbuffer"))
13846 else if (!strcasecmp(v->
name,
"resyncthreshold"))
13848 else if (!strcasecmp(v->
name,
"maxjitterinterps"))
13850 else if (!strcasecmp(v->
name,
"jittertargetextra"))
13852 else if (!strcasecmp(v->
name,
"lagrqtime"))
13854 else if (!strcasecmp(v->
name,
"maxregexpire"))
13856 else if (!strcasecmp(v->
name,
"minregexpire"))
13858 else if (!strcasecmp(v->
name,
"bindaddr")) {
13886 }
else if (!strcasecmp(v->
name,
"auth")) {
13891 }
else if (!strcasecmp(v->
name,
"authdebug")) {
13893 }
else if (!strcasecmp(v->
name,
"encryption")) {
13898 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13907 }
else if (!strcasecmp(v->
name,
"transfer")) {
13908 if (!strcasecmp(v->
value,
"mediaonly")) {
13914 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13915 if(!strcasecmp(v->
value,
"caller"))
13917 else if(!strcasecmp(v->
value,
"disabled"))
13919 else if(!strcasecmp(v->
value,
"reqonly")) {
13923 }
else if (!strcasecmp(v->
name,
"jitterbuffer"))
13925 else if (!strcasecmp(v->
name,
"delayreject"))
13927 else if (!strcasecmp(v->
name,
"allowfwdownload"))
13929 else if (!strcasecmp(v->
name,
"rtcachefriends"))
13931 else if (!strcasecmp(v->
name,
"rtignoreregexpire"))
13933 else if (!strcasecmp(v->
name,
"rtupdate"))
13935 else if (!strcasecmp(v->
name,
"rtsavesysname"))
13937 else if (!strcasecmp(v->
name,
"trunktimestamps"))
13939 else if (!strcasecmp(v->
name,
"rtautoclear")) {
13940 int i = atoi(v->
value);
13946 }
else if (!strcasecmp(v->
name,
"trunkfreq")) {
13949 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 10ms instead.\n");
13952 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 1000ms instead.\n");
13958 }
else if (!strcasecmp(v->
name,
"trunkmtu")) {
13959 mtuv = atoi(v->
value);
13962 else if (mtuv >= 172 && mtuv < 4000)
13967 }
else if (!strcasecmp(v->
name,
"trunkmaxsize")) {
13971 }
else if (!strcasecmp(v->
name,
"autokill")) {
13972 if (sscanf(v->
value,
"%30d", &x) == 1) {
13982 }
else if (!strcasecmp(v->
name,
"bandwidth")) {
13983 if (!strcasecmp(v->
value,
"low")) {
13986 }
else if (!strcasecmp(v->
value,
"medium")) {
13989 }
else if (!strcasecmp(v->
value,
"high")) {
13995 }
else if (!strcasecmp(v->
name,
"allow")) {
13997 }
else if (!strcasecmp(v->
name,
"disallow")) {
13999 }
else if (!strcasecmp(v->
name,
"register")) {
14001 }
else if (!strcasecmp(v->
name,
"iaxcompat")) {
14003 }
else if (!strcasecmp(v->
name,
"regcontext")) {
14007 }
else if (!strcasecmp(v->
name,
"tos")) {
14010 }
else if (!strcasecmp(v->
name,
"cos")) {
14013 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
14015 }
else if (!strcasecmp(v->
name,
"accountcode")) {
14017 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
14019 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
14021 }
else if (!strcasecmp(v->
name,
"amaflags")) {
14028 }
else if (!strcasecmp(v->
name,
"language")) {
14030 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
14034 }
else if (!strcasecmp(v->
name,
"adsi")) {
14036 }
else if (!strcasecmp(v->
name,
"srvlookup")) {
14038 }
else if (!strcasecmp(v->
name,
"connectedline")) {
14041 }
else if (!strcasecmp(v->
value,
"send")) {
14044 }
else if (!strcasecmp(v->
value,
"receive")) {
14050 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
14054 }
else if (!strcasecmp(v->
name,
"maxcallnumbers_nonvalidated")) {
14058 }
else if (!strcasecmp(v->
name,
"calltokenoptional")) {
14063 }
else if (!strcasecmp(v->
name,
"calltokenexpiration")) {
14065 sscanf(v->
value,
"%u", &temp);
14071 }
else if (!strcasecmp(v->
name,
"subscribe_network_change_event")) {
14073 subscribe_network_change = 1;
14075 subscribe_network_change = 0;
14079 }
else if (!strcasecmp(v->
name,
"shrinkcallerid")) {
14092 if (subscribe_network_change) {
14121 ast_log(
LOG_WARNING,
"Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
14131 int genregisteriax;
14132 const char *hasiax, *registeriax;
14139 if (strcasecmp(cat,
"general")) {
14142 if (
ast_true(hasiax) || (!hasiax && genhasiax)) {
14158 if (
ast_true(registeriax) || (!registeriax && genregisteriax)) {
14171 snprintf(tmp,
sizeof(tmp),
"%s:%s@%s", username, secret, host);
14173 snprintf(tmp,
sizeof(tmp),
"%s@%s", username, host);
14185 if (strcasecmp(cat,
"general")) {
14187 if (!strcasecmp(cat,
"callnumberlimits")) {
14189 }
else if (utype) {
14190 if (!strcasecmp(utype,
"user") || !strcasecmp(utype,
"friend")) {
14197 if (!strcasecmp(utype,
"peer") || !strcasecmp(utype,
"friend")) {
14205 }
else if (strcasecmp(utype,
"user")) {
14231 static const char config[] =
"iax.conf";
14266 "Usage: iax2 reload\n"
14267 " Reloads IAX configuration from iax.conf\n";
14297 if (
iaxs[x] && !strcasecmp(data,
iaxs[x]->dproot))
14305 memset(&cai, 0,
sizeof(cai));
14306 memset(&ied, 0,
sizeof(ied));
14307 memset(&pds, 0,
sizeof(pds));
14321 ast_debug(1,
"peer: %s, username: %s, password: %s, context: %s\n",
14360 int x, com[2], timeout, doabort, callno;
14433 pfd.events = POLLIN;
14440 }
else if (!pfd.revents) {
14461 dp->
flags &= ~CACHE_FLAG_PENDING;
14468 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
14486 ast_log(
LOG_NOTICE,
"iax2_exists: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14509 ast_log(
LOG_NOTICE,
"iax2_canmatch: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14532 ast_log(
LOG_NOTICE,
"iax2_matchmore: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14558 ast_log(
LOG_NOTICE,
"iax2_exec: con: %s, exten: %s, pri: %d, cid: %s, data: %s, newstack: %d\n",
context, exten,
priority, callerid ? callerid :
"<unknown>", data, newstack);
14576 ncontext = strchr(odata,
'/');
14580 snprintf(req,
sizeof(req),
"IAX2/%s/%s@%s", odata, exten, ncontext);
14582 snprintf(req,
sizeof(req),
"IAX2/%s/%s", odata, exten);
14584 ast_verb(3,
"Executing Dial('%s')\n", req);
14604 char *peername, *colname;
14609 if (!strcmp(peername,
"CURRENTCHANNEL")) {
14619 if ((colname = strchr(peername,
',')))
14627 if (!strcasecmp(colname,
"ip")) {
14629 }
else if (!strcasecmp(colname,
"status")) {
14631 }
else if (!strcasecmp(colname,
"mailbox")) {
14633 }
else if (!strcasecmp(colname,
"context")) {
14635 }
else if (!strcasecmp(colname,
"expire")) {
14637 }
else if (!strcasecmp(colname,
"dynamic")) {
14639 }
else if (!strcasecmp(colname,
"callerid_name")) {
14641 }
else if (!strcasecmp(colname,
"callerid_num")) {
14643 }
else if (!strcasecmp(colname,
"codecs")) {
14648 }
else if (!strncasecmp(colname,
"codec[", 6)) {
14649 char *codecnum, *ptr;
14653 codecnum = colname + 5;
14656 if ((ptr = strchr(codecnum,
']'))) {
14696 if (!strcasecmp(
args,
"osptoken")) {
14698 }
else if (!strcasecmp(
args,
"peerip")) {
14700 }
else if (!strcasecmp(
args,
"peername")) {
14702 }
else if (!strcasecmp(
args,
"secure_signaling") || !strcasecmp(
args,
"secure_media")) {
14721 memset(&pds, 0,
sizeof(pds));
14729 ast_debug(3,
"Checking device state for device %s\n", pds.
peer);
14737 ast_debug(3,
"Found peer. What's device state of %s? addr=%s, defaddr=%s maxms=%d, lastms=%d\n",
14757 .description =
"IAX Remote Dialplan Switch",
14786 AST_CLI_DEFINE(handle_cli_iax2_test_jitter,
"Simulates jitter for testing"),
14787 AST_CLI_DEFINE(handle_cli_iax2_test_late,
"Test the receipt of a late frame"),
14788 AST_CLI_DEFINE(handle_cli_iax2_test_resync,
"Test a resync in received timestamps"),
14795 struct iax2_thread_list *list_head = head;
14800 pthread_t thread_id =
thread->threadid;
14806 pthread_join(thread_id,
NULL);
14924 return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt,
14942 return match(&pvt2->transfer, pvt2->transfercallno, pvt2->callno, pvt,
14954 goto container_fail;
14960 goto container_fail;
14966 goto container_fail;
14972 goto container_fail;
14978 goto container_fail;
14984 goto container_fail;
14990 goto container_fail;
14994 goto container_fail;
14999 goto container_fail;
15041 static const char config[] =
"iax.conf";
15155 ast_verb(2,
"IAX Ready and Listening\n");
15170 ast_realtime_require_field(
"iaxpeers",
"name",
RQ_CHAR, 10,
"ipaddr",
RQ_CHAR, 15,
"port",
RQ_UINTEGER2, 5,
"regseconds",
RQ_UINTEGER2, 6,
SENTINEL);
15183 .
requires =
"dnsmgr",
15184 .optional_modules =
"res_crypto",
Access Control of various sorts.
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to)
Copy the contents of one HA to another.
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *hostname, const char *service)
Get the IP address given a hostname and optional service.
static const struct adsi_event events[]
static struct ast_generator gen
static int copy(char *infile, char *outfile)
Utility function to copy a file.
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_del(const char *family, const char *key)
Delete entry in astdb.
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
@ AST_BRIDGE_TRANSFER_SUCCESS
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
#define AST_PRES_NUMBER_NOT_AVAILABLE
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Internal Asterisk hangup causes.
#define AST_CAUSE_CONGESTION
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
#define AST_CAUSE_NO_USER_RESPONSE
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED
#define AST_CAUSE_CALL_REJECTED
#define AST_CAUSE_FACILITY_REJECTED
#define AST_CAUSE_NO_ROUTE_DESTINATION
#define AST_CAUSE_UNREGISTERED
static const char config_file[]
static int timing_read(int *id, int fd, short events, void *cbdata)
#define IAX_TRUNKTIMESTAMPS
static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
static void set_peercnt_limit(struct peercnt *peercnt)
static int check_access(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
static int iaxthreadcount
static int send_ping(const void *data)
static int iax2_trunk_expired(struct iax2_trunk_peer *tpeer, struct timeval *now)
static int manager_iax2_show_peers(struct mansession *s, const struct message *m)
callback to display iax peers in manager
static struct ao2_container * peercnts
static struct iax2_context * build_context(const char *context)
static void save_rr(struct iax_frame *fr, struct iax_ies *ies)
static int update_registry(struct ast_sockaddr *addr, int callno, char *devtype, int fd, unsigned short refresh)
static int iax2_write(struct ast_channel *c, struct ast_frame *f)
#define AUTH_METHOD_NAMES_BUFSIZE
static struct iax2_peer * realtime_peer(const char *peername, struct ast_sockaddr *addr)
static int socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, struct ast_sockaddr *addr, int sockfd, struct iax_frame *fr)
static struct iax2_user * user_unref(struct iax2_user *user)
static int apply_context(struct iax2_context *con, const char *context)
static struct ast_channel_tech iax2_tech
static void __auto_hangup(const void *nothing)
static int iax2_poke_peer_cb(void *obj, void *arg, int flags)
static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
static char * complete_iax2_peers(const char *line, const char *word, int pos, int state, uint64_t flags)
static int randomcalltokendata
static int iaxdynamicthreadcount
static void iax2_lock_owner(int callno)
static int iax2_queue_hold(int callno, const char *musicclass)
Queue a hold frame on the ast_channel owner.
#define MAX_TIMESTAMP_SKEW
static void acl_change_stasis_subscribe(void)
static void store_by_transfercallno(struct chan_iax2_pvt *pvt)
static struct ast_channel * ast_iax2_new(int callno, int state, iax2_format capability, struct iax2_codec_pref *prefs, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, unsigned int cachable)
Create new call, interface with the PBX core.
static void jb_error_output(const char *fmt,...)
static int peer_hash_cb(const void *obj, const int flags)
@ NEW_ALLOW_CALLTOKEN_VALIDATED
static void iax2_publish_registry(const char *username, const char *domain, const char *status, const char *cause)
static int replace_callno(const void *obj)
#define CALLNO_ENTRY_IS_VALIDATED(a)
static int auto_congest(const void *data)
static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, struct timeval *now)
static void __iax2_poke_noanswer(const void *data)
static int iax2_predestroy(int callno)
static int update_packet(struct iax_frame *f)
static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
static char * handle_cli_iax2_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int peercnt_hash_cb(const void *obj, const int flags)
static int check_provisioning(struct ast_sockaddr *addr, int sockfd, char *si, unsigned int ver)
static int iax2_setoption(struct ast_channel *c, int option, void *data, int datalen)
static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int)
static void unwrap_timestamp(struct iax_frame *fr)
static int wait_for_peercallno(struct chan_iax2_pvt *pvt)
static int iax2_hangup(struct ast_channel *c)
static int queue_signalling(struct chan_iax2_pvt *pvt, struct ast_frame *f)
All frames other than that of type AST_FRAME_IAX must be held until we have received a destination ca...
static int __schedule_action(void(*func)(const void *data), const void *data, const char *funcname)
static int addr_range_match_address_cb(void *obj, void *arg, int flags)
static int maxjitterbuffer
static int auth_fail(int callno, int failcode)
static char * handle_cli_iax2_test_losspct(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_queue_hangup(int callno)
Queue a hangup frame on the ast_channel owner.
static int peercnt_remove_cb(const void *obj)
static unsigned int fix_peerts(struct timeval *rxtrunktime, int callno, unsigned int ts)
static unsigned char compress_subclass(iax2_format subclass)
static int handle_error(void)
static const char * auth_method_labels[]
Name of effective auth method.
static int peer_cmp_cb(void *obj, void *arg, int flags)
static void resend_with_token(int callno, struct iax_frame *f, const char *newtoken)
static int get_auth_methods(const char *value)
static int handle_call_token(struct ast_iax2_full_hdr *fh, struct iax_ies *ies, struct ast_sockaddr *addr, int fd)
static struct chan_iax2_pvt * new_iax(struct ast_sockaddr *addr, const char *host)
static char default_parkinglot[AST_MAX_CONTEXT]
static struct iax2_trunk_peer * find_tpeer(struct ast_sockaddr *addr, int fd)
static void iax_error_output(const char *data)
static void vnak_retransmit(int callno, int last)
static int user_delme_cb(void *obj, void *arg, int flags)
static int send_command_immediate(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
static struct ast_custom_function iaxvar_function
#define IAX_SHRINKCALLERID
static void defer_full_frame(struct iax2_thread *from_here, struct iax2_thread *to_here)
Queue the last read full frame for processing by a certain thread.
static int iax2_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Execute IAX2 dialplan switch.
static int __unload_module(void)
static char * handle_cli_iax2_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct stasis_subscription * acl_change_sub
static int iax2_poke_peer(struct iax2_peer *peer, int heldcall)
static iax2_format iax2_capability
#define DEFAULT_MAX_THREAD_COUNT
static ast_mutex_t iaxsl[ARRAY_LEN(iaxs)]
chan_iax2_pvt structure locks
static int iax2_digit_end(struct ast_channel *c, char digit, unsigned int duration)
static uint16_t DEFAULT_MAXCALLNO_LIMIT_NONVAL
static struct ast_sched_context * sched
static void * dp_lookup_thread(void *data)
static uint16_t DEFAULT_MAXCALLNO_LIMIT
static void peercnt_modify(unsigned char reg, uint16_t limit, struct ast_sockaddr *sockaddr)
static int transmit_trunk(struct iax_frame *f, struct ast_sockaddr *addr, int sockfd)
static int registry_rerequest(struct iax_ies *ies, int callno, struct ast_sockaddr *addr)
static int send_command(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static void encmethods_to_str(int e, struct ast_str **buf)
static void construct_rr(struct chan_iax2_pvt *pvt, struct iax_ie_data *iep)
static struct ast_custom_function iaxpeer_function
static int load_objects(void)
static int complete_transfer(int callno, struct iax_ies *ies)
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan)
static struct ast_format * codec_choose_from_prefs(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
static int prune_addr_range_cb(void *obj, void *arg, int flags)
static void iax_debug_output(const char *data)
#define IAX_CALLENCRYPTED(pvt)
static char * handle_cli_iax2_provision(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static uint16_t global_maxcallno_nonval
static int maxjitterinterps
static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
static void jb_debug_output(const char *fmt,...)
static void iax_pvt_callid_new(int callno)
static char * regstate2str(int regstate)
static int last_authmethod
static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int argc, const char *const argv[])
static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
static char * handle_cli_iax2_set_mtu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Set trunk MTU from CLI.
static void pvt_destructor(void *obj)
static int addr_range_hash_cb(const void *obj, const int flags)
static int pvt_hash_cb(const void *obj, const int flags)
static int iax2_queue_unhold(int callno)
Queue an unhold frame on the ast_channel owner.
#define MAX_TRUNK_MTU
Maximum transmission unit for the UDP packet in the trunk not to be fragmented. This is based on 1516...
static int iax2_getpeername(struct ast_sockaddr addr, char *host, int len)
static struct iax2_peer * build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create peer structure based on configuration.
static int find_callno_locked(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
static void * iax2_process_thread(void *data)
static int iax2_digit_begin(struct ast_channel *c, char digit)
static struct iax2_user * build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create in-memory user structure from configuration.
static char regcontext[AST_MAX_CONTEXT]
static int socket_process_helper(struct iax2_thread *thread)
#define IAX_CAPABILITY_FULLBANDWIDTH
static struct ao2_container * peers
static int set_config(const char *config_file, int reload, int forced)
Load configuration.
static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers_context *cont, struct iax2_peer *peer)
static void __auto_congest(const void *nothing)
static void free_signaling_queue_entry(struct signaling_queue_entry *s)
static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno, int now, int transfer, int final)
#define MARK_IAX_SUBCLASS_TX
static int iax2_key_rotate(const void *vpvt)
#define schedule_action(func, data)
static int invalid_key(ast_aes_decrypt_key *ecx)
static int user_cmp_cb(void *obj, void *arg, int flags)
static void __expire_registry(const void *data)
static void reg_source_db(struct iax2_peer *p)
static int scheduled_destroy(const void *vid)
static void prune_peers(void)
static time_t max_calltoken_delay
static struct ao2_container * callno_limits
static int calltoken_required(struct ast_sockaddr *addr, const char *name, int subclass)
static struct ast_frame * iax2_read(struct ast_channel *c)
static struct ast_netsock_list * netsock
static int min_reg_expire
static int add_calltoken_ignore(const char *addr)
static int authenticate_reply(struct chan_iax2_pvt *p, struct ast_sockaddr *addr, struct iax_ies *ies, const char *override, const char *okey)
static char * handle_cli_iax2_show_firmware(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_transfer(struct ast_channel *c, const char *dest)
static int iax2_transmit(struct iax_frame *fr)
static void __auth_reject(const void *nothing)
static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt)
@ IAX_THREAD_TYPE_DYNAMIC
#define CALLNO_ENTRY_GET_CALLNO(a)
static int iax2_getpeertrunk(struct ast_sockaddr addr)
static int attempt_transmit(const void *data)
static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen)
static struct ast_netsock_list * outsock
static void prune_users(void)
static void user_destructor(void *obj)
static struct ao2_container * iax_transfercallno_pvts
Another container of iax2_pvt structures.
static struct iax2_user * find_user(const char *name)
static int resyncthreshold
#define IAX_RECVCONNECTEDLINE
static void register_peer_exten(struct iax2_peer *peer, int onoff)
static int transfercallno_pvt_cmp_cb(void *obj, void *arg, int flags)
static int iaxdynamicthreadnum
static ast_mutex_t callno_pool_lock
static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static void free_context(struct iax2_context *con)
static char * handle_cli_iax2_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define CALLNO_ENTRY_SET_VALIDATED(a)
static uint16_t total_nonval_callno_used
static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
#define IAX_DEBUGDIGEST(msg, key)
static const char tdesc[]
static void parse_dial_string(char *data, struct parsed_dial_string *pds)
Parses an IAX dial string into its component parts.
static int global_rtautoclear
static void iax2_destroy(int callno)
static int manager_iax2_show_netstats(struct mansession *s, const struct message *m)
static void spawn_dp_lookup(int callno, const char *context, const char *callednum, const char *callerid)
static struct iax_frame * iaxfrdup2(struct iax_frame *fr)
static int transmit_frame(void *data)
static int acf_iaxvar_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int iax2_answer(struct ast_channel *c)
static int iax2_authmethods
static const char * iax2_getformatname_multiple(iax2_format format, struct ast_str **codec_buf)
static void set_hangup_source_and_cause(int callno, unsigned char causecode)
static int iax2_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
part of the IAX2 dial plan switch interface
static void __send_ping(const void *data)
static struct iax2_peer * find_peer(const char *name, int realtime)
static char * handle_cli_iax2_show_netstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iaxactivethreadcount
static int check_srcaddr(struct ast_sockaddr *addr)
Check if address can be used as packet source.
static void insert_idle_thread(struct iax2_thread *thread)
static void acl_change_stasis_unsubscribe(void)
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static int pvt_cmp_cb(void *obj, void *arg, int flags)
static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct ast_sockaddr *addr, struct chan_iax2_pvt *pvt)
static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int iaxdefaulttimeout
static struct ao2_container * users
static int auth_reject(const void *data)
static int create_callno_pools(void)
static void send_signaling(struct chan_iax2_pvt *pvt)
This function must be called once we are sure the other side has given us a call number....
#define CALLTOKEN_IE_FORMAT
static char * handle_cli_iax2_show_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define IAX_FORCE_ENCRYPT
static char * handle_cli_iax2_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void network_change_stasis_subscribe(void)
static struct ast_switch iax2_switch
static void poke_all_peers(void)
#define IAX_SENDCONNECTEDLINE
static int(* iax2_regfunk)(const char *username, int onoff)
static int network_change_sched_cb(const void *data)
static int find_callno(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
static int __do_deliver(void *data)
#define IAX_RTCACHEFRIENDS
#define IAX_RTIGNOREREGEXPIRE
static int socket_process(struct iax2_thread *thread)
static int manager_iax2_show_registry(struct mansession *s, const struct message *m)
static void dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, int skiplock)
static int iax2_poke_noanswer(const void *data)
static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry)
static char * handle_cli_iax2_show_callno_limits(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_iax2_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_taskprocessor * transmit_processor
static int iaxdefaultdpcache
static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct @117 frame_queue[IAX_MAX_CALLS]
a list of frames that may need to be retransmitted
static int send_lagrq(const void *data)
static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
Parse the "sourceaddress" value, lookup in netsock list and set peer's sockfd. Defaults to defaultsoc...
static int reload_config(int forced_reload)
static int peercnt_add(struct ast_sockaddr *addr)
static int iax2_do_register(struct iax2_registry *reg)
static int iax2_register(const char *value, int lineno)
static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img)
static struct ast_timer * timer
static void __send_lagrq(const void *data)
static void unlink_peer(struct iax2_peer *peer)
static int authenticate_request(int call_num)
static struct iax2_peer * peer_unref(struct iax2_peer *peer)
static int iax2_append_register(const char *hostname, const char *username, const char *secret, const char *porta)
static int firmware_show_callback(struct ast_iax2_firmware_header *header, void *user_data)
static int get_from_jb(const void *p)
static void save_osptoken(struct iax_frame *fr, struct iax_ies *ies)
static int max_reg_expire
static int iax2_queryoption(struct ast_channel *c, int option, void *data, int *datalen)
static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, struct ast_frame *f)
#define DEFAULT_RETRY_TIME
static int peer_status(struct iax2_peer *peer, char *status, int statuslen)
peer_status: Report Peer status in character string
static void set_config_destroy(void)
static int attribute_pure iax2_allow_new(int frametype, int subclass, int inbound)
#define IAX_RTSAVE_SYSNAME
static iax2_format iax2_codec_choose(struct iax2_codec_pref *pref, iax2_format formats)
static int iax2_delete_from_sched(const void *data)
static char * handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define DEFAULT_FREQ_NOTOK
static void update_jbsched(struct chan_iax2_pvt *pvt)
static void store_by_peercallno(struct chan_iax2_pvt *pvt)
static int set_peercnt_limit_all_cb(void *obj, void *arg, int flags)
static void handle_deferred_full_frames(struct iax2_thread *thread)
Handle any deferred full frames for this thread.
static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
static int transfercallno_pvt_hash_cb(const void *obj, const int flags)
static int decrypt_frame(int callno, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
static void iax_pvt_callid_set(int callno, ast_callid callid)
static void __get_from_jb(const void *p)
static int iax2_encryption
static int peercnt_remove_by_addr(struct ast_sockaddr *addr)
static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
static struct call_number_pool callno_pool
static pthread_t netthreadid
#define CALLNO_ENTRY_TO_PTR(a)
static void build_rand_pad(unsigned char *buf, ssize_t len)
static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
static char * handle_cli_iax2_set_debug_trunk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_iax2_show_registry(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_sched_add(struct ast_sched_context *sched, int when, ast_sched_cb callback, const void *data)
static int socket_read(int *id, int fd, short events, void *cbdata)
static int peer_delme_cb(void *obj, void *arg, int flags)
static int create_addr(const char *peername, struct ast_channel *c, struct ast_sockaddr *addr, struct create_addr_info *cai)
static char * auth_method_names(int authmethods, char *restrict buf)
Get names of all auth methods.
static int user_hash_cb(const void *obj, const int flags)
static void peer_destructor(void *obj)
static void __iax2_do_register_s(const void *data)
static int send_apathetic_reply(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int command, int ts, unsigned char seqno, int sockfd, struct iax_ie_data *ied)
static void jb_warning_output(const char *fmt,...)
static int iax2_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Part of the IAX2 switch interface.
calltoken_peer_enum
Call token validation settings.
@ CALLTOKEN_DEFAULT
Default calltoken required unless the ip is in the ignorelist.
@ CALLTOKEN_AUTO
Require call token validation after a successful registration using call token validation occurs.
@ CALLTOKEN_NO
Do not require call token validation.
@ CALLTOKEN_YES
Require call token validation.
static int get_encrypt_methods(const char *s)
static int jittertargetextra
static int iax2_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Part of the IAX2 Switch interface.
static struct ast_flags64 globalflags
static struct iax2_dpcache * find_cache(struct ast_channel *chan, const char *data, const char *context, const char *exten, int priority)
static iax2_format uncompress_subclass(unsigned char csub)
static void * network_thread(void *ignore)
static char * handle_cli_iax2_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_is_control_frame_allowed(int subtype)
static void network_change_stasis_unsubscribe(void)
static void realtime_update_peer(const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
static struct io_context * io
static char * complete_iax2_unregister(const char *line, const char *word, int pos, int state)
static struct stasis_subscription * network_change_sub
static int raw_hangup(struct ast_sockaddr *addr, unsigned short src, unsigned short dst, int sockfd)
#define PTR_TO_CALLNO_ENTRY(a)
static struct ao2_container * calltoken_ignores
static void * iax2_dup_variable_datastore(void *)
static struct iax2_codec_pref prefs_global
@ IAX_STATE_AUTHENTICATED
static struct iax2_user * realtime_user(const char *username, struct ast_sockaddr *addr)
#define IAX2_TRUNK_PREFACE
static int iax2_ack_registry(struct iax_ies *ies, struct ast_sockaddr *addr, int callno)
Acknowledgment received for OUR registration.
static void __iax2_poke_peer_s(const void *data)
static int load_module(void)
Load the module.
static int iax2_vnak(int callno)
#define IAX_CAPABILITY_MEDBANDWIDTH
static int iax2_parse_allow_disallow(struct iax2_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
#define DEFAULT_TRUNKDATA
static char * handle_cli_iax2_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show one peer in detail.
static void iax2_process_thread_cleanup(void *data)
#define IAX_TRANSFERMEDIA
static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen)
static int addr_range_cmp_cb(void *obj, void *arg, int flags)
static int registry_authrequest(int callno)
static int iax2_provision(struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
const char * iax2_getformatname(iax2_format format)
iax2 wrapper function for ast_getformatname
#define DEFAULT_THREAD_COUNT
static int acf_iaxvar_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static void iax2_free_variable_datastore(void *)
static int iax2_poke_peer_s(const void *data)
static int addr_range_delme_cb(void *obj, void *arg, int flags)
static struct iax2_thread * find_idle_thread(void)
static struct ast_channel * iax2_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
static void add_empty_calltoken_ie(struct chan_iax2_pvt *pvt, struct iax_ie_data *ied)
static void delete_users(void)
#define IAX_DELAYPBXSTART
static int cache_get_callno_locked(const char *data)
static void iax_outputframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
static int unload_module(void)
static void remove_by_transfercallno(struct chan_iax2_pvt *pvt)
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
static int peer_set_sock_cb(void *obj, void *arg, int flags)
static void stop_stuff(int callno)
static char * handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
static void log_jitterstats(unsigned short callno)
static struct iax2_peer * peer_ref(struct iax2_peer *peer)
static ast_callid iax_pvt_callid_get(int callno)
#define IAX_CAPABILITY_LOWBANDWIDTH
static void cleanup_thread_list(void *head)
static int manager_iax2_show_peer_list(struct mansession *s, const struct message *m)
callback to display iax peers in manager format
static int iax2_queue_frame(int callno, struct ast_frame *f)
Queue a frame to a call's owning asterisk channel.
static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
static int iax2_sendtext(struct ast_channel *c, const char *text)
static struct ast_sockaddr debugaddr
static int send_packet(struct iax_frame *f)
static char language[MAX_LANGUAGE]
static char accountcode[AST_MAX_ACCOUNT_CODE]
static void merge_encryption(struct chan_iax2_pvt *p, unsigned int enc)
static void memcpy_decrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_decrypt_key *dcx)
static char * handle_cli_iax2_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define IAX_ALLOWFWDOWNLOAD
#define IAX_CODEC_USER_FIRST
static int iax2_lock_callno_unless_destroyed(int callno)
Acquire the iaxsl[callno] if call exists and not having ongoing hangup.
static struct call_number_pool callno_pool_trunk
static uint16_t global_maxcallno
static void remove_by_peercallno(struct chan_iax2_pvt *pvt)
#define CALLTOKEN_HASH_FORMAT
static int start_network_thread(void)
static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
static int iax2_sched_replace(int id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
static char mohsuggest[MAX_MUSICCLASS]
static int __find_callno(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int return_locked, int check_dcallno)
static void build_encryption_keys(const unsigned char *digest, struct chan_iax2_pvt *pvt)
static void build_callno_limits(struct ast_variable *v)
static void __attempt_transmit(const void *data)
static struct ast_cli_entry cli_iax2[]
static unsigned int iax2_datetime(const char *tz)
static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final)
#define IAX_CODEC_NOPREFS
static int auto_hangup(const void *data)
static char * handle_cli_iax2_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static char mohinterpret[MAX_MUSICCLASS]
static const struct ast_datastore_info iax2_variable_datastore_info
static void sched_delay_remove(struct ast_sockaddr *addr, callno_entry entry)
static int iax2_do_register_s(const void *data)
static int iax2_devicestate(const char *data)
Part of the device state notification system —.
static void peercnt_remove(struct peercnt *peercnt)
static int network_change_sched_id
static int expire_registry(const void *data)
static void iax2_frame_free(struct iax_frame *fr)
static void memcpy_encrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_encrypt_key *ecx)
static void requirecalltoken_mark_auto(const char *name, int subclass)
static int iaxmaxthreadcount
static int peercnt_cmp_cb(void *obj, void *arg, int flags)
static struct ao2_container * iax_peercallno_pvts
Another container of iax2_pvt structures.
static int send_command_locked(unsigned short callno, char, int, unsigned int, const unsigned char *, int, int)
static int make_trunk(unsigned short callno, int locked)
static int register_verify(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
Verify inbound registration.
static int global_max_trunk_mtu
static void iax2_dprequest(struct iax2_dpcache *dp, int callno)
struct ast_sockaddr bindaddr
static char version[AST_MAX_EXTENSION]
static const char config[]
static int transfer(void *data)
General Asterisk PBX channel definitions.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint,...)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define AST_BRIDGE_DTMF_CHANNEL_0
Report DTMF on channel 0.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
#define DATASTORE_INHERIT_FOREVER
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
#define ast_channel_ref(c)
Increase channel reference count.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_context(const struct ast_channel *chan)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
#define AST_BRIDGE_DTMF_CHANNEL_1
Report DTMF on channel 1.
#define ast_channel_trylock(chan)
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
#define AST_MAX_ACCOUNT_CODE
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
@ AST_BRIDGE_FAILED_NOWARN
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
const char * ast_channel_language(const struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
const char * ast_var_name(const struct ast_var_t *var)
#define ast_var_assign(name, value)
const char * ast_var_value(const struct ast_var_t *var)
void ast_var_delete(struct ast_var_t *var)
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,...)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
unsigned int ast_codec_samples_count(struct ast_frame *frame)
Get the number of samples contained within a frame.
int iax2_codec_pref_string(struct iax2_codec_pref *pref, char *buf, size_t size)
Dump audio codec preference list into a string.
void iax2_codec_pref_prepend(struct iax2_codec_pref *pref, struct ast_format *format, unsigned int framing, int only_if_existing)
Prepend an audio codec to a preference list, removing it first if it was already there.
uint64_t iax2_codec_pref_order_value_to_format_bitfield(int order_value)
Convert an iax2_codec_pref order value into a format bitfield.
uint64_t iax2_codec_pref_from_bitfield(struct iax2_codec_pref *pref, uint64_t bitfield)
Create codec preference list from the given bitfield formats.
struct ast_format * iax2_codec_pref_index(struct iax2_codec_pref *pref, int idx, struct ast_format **result)
Codec located at a particular place in the preference index.
void iax2_codec_pref_convert(struct iax2_codec_pref *pref, char *buf, size_t size, int right)
Shift an audio codec preference list up or down 65 bytes so that it becomes an ASCII string.
void iax2_codec_pref_remove_missing(struct iax2_codec_pref *pref, uint64_t bitfield)
Removes format from the pref list that aren't in the bitfield.
void iax2_codec_pref_append(struct iax2_codec_pref *pref, struct ast_format *format, unsigned int framing)
Append a audio codec to a preference list, removing it first if it was already there.
int iax2_codec_pref_to_cap(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
Convert a preference structure to a capabilities structure.
int iax2_codec_pref_best_bitfield2cap(uint64_t bitfield, struct iax2_codec_pref *prefs, struct ast_format_cap *cap)
Convert a bitfield to a format capabilities structure in the "best" order.
Media Format Bitfield Compatibility API.
Provide cryptographic signature routines.
int ast_aes_set_encrypt_key(const unsigned char *key, ast_aes_encrypt_key *ctx)
Set an encryption key.
struct ast_key * ast_key_get(const char *kname, int ktype)
Retrieve a key.
int ast_aes_set_decrypt_key(const unsigned char *key, ast_aes_decrypt_key *ctx)
Set a decryption key.
int ast_aes_encrypt(const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *key)
AES encrypt data.
int ast_aes_decrypt(const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *key)
AES decrypt data.
int ast_sign(struct ast_key *key, char *msg, char *sig)
Sign a message signature using a given private key.
int ast_check_signature(struct ast_key *key, const char *msg, const char *sig)
Check the authenticity of a message signature using a given public key.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Background DNS update manager.
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry)
Check is see if a dnsmgr entry has changed.
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
void ast_verbose(const char *fmt,...)
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
int iax_firmware_get_version(const char *dev, uint16_t *version)
void iax_firmware_reload(void)
void iax_firmware_unload(void)
int iax_firmware_append(struct iax_ie_data *ied, const char *dev, unsigned int desc)
void iax_firmware_traverse(const char *filter, int(*callback)(struct ast_iax2_firmware_header *header, void *data), void *data)
IAX Firmware Support header file.
static int exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
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)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
void astman_append(struct mansession *s, const char *fmt,...)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
static int iax2_prov_app(struct ast_channel *chan, const char *data)
Implementation of Inter-Asterisk eXchange, version 2 parser.c parser.h chan_iax2.c.
#define IAX_LINGER_TIMEOUT
#define IAX_DPSTATUS_CANEXIST
#define IAX_MAX_OSPBLOCK_SIZE
#define IAX_IE_CALLINGANI2
#define IAX_IE_CALLING_NUMBER
#define IAX_IE_TRANSFERID
#define IAX_IE_CALLING_ANI
#define IAX_DEFAULT_PORTNO
#define IAX_IE_CALLINGTNS
#define IAX_IE_RSA_RESULT
#define IAX_META_TRUNK_SUPERMINI
#define IAX_IE_IAX_UNKNOWN
#define IAX_DPSTATUS_NONEXISTENT
#define IAX_DPSTATUS_IGNOREPAT
#define IAX_IE_CAPABILITY2
#define IAX_IE_CALLING_NAME
#define IAX_DEFAULT_REG_EXPIRE
#define IAX_MAX_OSPTOKEN_SIZE
#define IAX_IE_RR_DROPPED
#define IAX_IE_ENCRYPTION
#define IAX_ENCRYPT_AES128
#define IAX_MAX_OSPBUFF_SIZE
#define IAX_IE_FIRMWAREVER
#define IAX_IE_CODEC_PREFS
#define IAX_IE_CALLED_NUMBER
#define IAX_IE_CAPABILITY
#define IAX_DPSTATUS_MATCHMORE
#define IAX_IE_PROVISIONING
#define IAX_IE_MD5_RESULT
#define IAX_PROTO_VERSION
#define IAX_IE_AUTOANSWER
#define IAX_ENCRYPT_KEYROTATE
#define IAX_IE_APPARENT_ADDR
#define IAX_AUTH_PLAINTEXT
#define IAX_MAX_OSPBLOCK_NUM
#define IAX_META_TRUNK_MINI
#define IAX_IE_CALLINGPRES
#define IAX_IE_AUTHMETHODS
#define IAX_IE_CALLED_CONTEXT
#define IAX_IE_CALLINGTON
#define IAX_DPSTATUS_EXISTS
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
@ CONFIG_FLAG_FILEUNCHANGED
#define ast_variable_new(name, value, filename)
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Asterisk internal frame definitions.
#define ast_frame_byteswap_be(fr)
#define AST_OPTION_RELAXDTMF
#define AST_OPTION_TONE_VERIFY
#define AST_OPTION_RXGAIN
#define AST_OPTION_DIGIT_DETECT
#define AST_OPTION_OPRMODE
#define AST_OPTION_SECURE_MEDIA
#define AST_OPTION_FLAG_REQUEST
#define AST_OPTION_FAX_DETECT
#define AST_OPTION_TXGAIN
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define AST_OPTION_SECURE_SIGNALING
ast_control_frame_type
Internal control frame subtype field values.
@ AST_CONTROL_RECORD_CANCEL
@ AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_RADIO_UNKEY
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_TAKEOFFHOOK
@ AST_CONTROL_T38_PARAMETERS
@ AST_CONTROL_READ_ACTION
@ AST_CONTROL_RECORD_STOP
@ AST_CONTROL_RECORD_MUTE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_STREAM_FORWARD
@ AST_CONTROL_RECORD_SUSPEND
@ AST_CONTROL_MASQUERADE_NOTIFY
@ AST_CONTROL_PVT_CAUSE_CODE
@ AST_CONTROL_UPDATE_RTP_PEER
#define AST_OPTION_AUDIO_MODE
struct ast_frame ast_null_frame
@ AST_FRFLAG_HAS_TIMING_INFO
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
#define ast_debug(level,...)
Log a DEBUG message.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
#define AST_CALLID_BUFFER_LENGTH
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
#define ast_verb(level,...)
I/O Management (derived from Cheops-NG)
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
jitterbuf: an application-independent jitterbuffer jitterbuf.c
void jb_destroy(jitterbuf *jb)
destroy jitterbuf
void jb_reset(jitterbuf *jb)
reset jitterbuf
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl)
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame!...
jitterbuf * jb_new(void)
new jitterbuf
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
queue a frame
long jb_next(jitterbuf *jb)
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are adde...
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
unconditionally get frames from jitterbuf until empty
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
A set of macros to manage forward-linked lists.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list entry before the current entry during a traversal.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from 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.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
Custom localtime functions for multiple timezones.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define AST_PTHREADT_NULL
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define DEADLOCK_AVOIDANCE(lock)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_trylock(a)
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
int ast_atomic_dec_and_test(volatile int *p)
decrement *p by 1 and return true if the variable has reached 0.
#define ast_cond_signal(cond)
static char hostname[MAXHOSTNAMELEN]
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_REPORTING
#define EVENT_FLAG_SYSTEM
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
void MD5Init(struct MD5Context *context)
void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], struct MD5Context *context)
Asterisk module definitions.
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_module_ref(mod)
Hold a reference to the module.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DRIVER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
meta
below block is needed for mssql
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
int ast_sockaddr_apply_netmask(const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask, struct ast_sockaddr *result)
Apply a netmask to an address and store the result in a separate structure.
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
Wrapper around sendto(2) that uses ast_sockaddr.
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr)
Wrapper around recvfrom(2) that uses struct ast_sockaddr.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
Determine if this is an IPv4-mapped IPv6 address.
int ast_sockaddr_hash(const struct ast_sockaddr *addr)
Computes a hash value from the address. The port is ignored.
int ast_netsock_release(struct ast_netsock_list *list)
struct ast_netsock_list * ast_netsock_list_alloc(void)
struct ast_netsock * ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data)
void ast_netsock_unref(struct ast_netsock *ns)
int ast_netsock_sockfd(const struct ast_netsock *ns)
struct ast_netsock * ast_netsock_find(struct ast_netsock_list *list, struct ast_sockaddr *addr)
int ast_netsock_init(struct ast_netsock_list *list)
struct ast_netsock * ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct ast_sockaddr *bindaddr, int tos, int cos, ast_io_cb callback, void *data)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Implementation of the IAX2 protocol.
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
int iax_get_iframes(void)
#define DIRECTION_OUTGRESS
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr)
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len)
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
void iax_frame_free(struct iax_frame *fr)
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
struct iax_frame * iax_frame_new(int direction, int datalen, unsigned int cacheable)
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
void iax_set_output(void(*output)(const char *data))
int iax_get_oframes(void)
#define DIRECTION_INGRESS
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
void iax_set_error(void(*output)(const char *data))
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_SYSTEM_NAME
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
static int matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static void * cleanup(void *unused)
#define ast_poll(a, b, c)
IAX2 Provisioning protocol.
int iax_provision_reload(int reload)
int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force)
int iax_provision_unload(void)
char * iax_prov_complete_template(const char *line, const char *word, int pos, int state)
int iax_provision_version(unsigned int *signature, const char *template, int force)
struct stasis_forward * sub
static struct @453 methods[]
static void challenge(const char *endpoint_id, struct ast_sip_auth *auth, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale, const pjsip_auth_algorithm *algorithm)
Send a WWW-Authenticate challenge.
Scheduler Routines (derived from cheops)
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb)
Clean all scheduled events with matching callback.
int ast_sched_replace(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
replace a scheduler entry
int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
int(* ast_sched_cb)(const void *data)
scheduler callback
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Security Event Reporting API.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
#define stasis_subscribe(topic, callback, data)
void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause)
Publish a channel driver outgoing registration message.
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes.
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
Parse a time (integer) string.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
#define ast_str_alloca(init_len)
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
unsigned char raw[AST_CRYPTO_AES_BLOCKSIZE/8]
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Wrapper for an ast_acl linked list.
ast_app: A registered application
Structure to pass both assignedid values to channel drivers.
Structure to describe a channel "technology", ie a channel driver See for examples:
struct ast_format_cap * capabilities
Main Channel structure associated with a channel.
descriptor for a cli entry.
int args
This gets set in ast_cli_register()
char chan_name[AST_CHANNEL_NAME]
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Structure used to handle a large number of boolean flags == used only in app_dial?
Structure used to handle boolean flags.
unsigned int frame_ending
struct ast_format * format
Data structure associated with a single frame of data.
union ast_frame::@228 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
internal representation of ACL entries In principle user applications would have no need for this,...
struct ast_sockaddr netmask
Abstract JSON element (object, array, string, int, ...).
Structure for mutex and tracking information.
The structure that contains MWI state.
struct ast_party_id id
Caller party ID.
int ani2
Automatic Number Identification 2 (Info Digits)
struct ast_party_id ani
Automatic Number Identification (ANI)
Connected Line/Party information.
struct ast_party_id id
Connected party ID.
struct ast_party_dialed::@210 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
int transit_network_select
Transit Network Select.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
int presentation
Q.931 encoded presentation-indicator encoded field.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Socket address structure.
struct sockaddr_storage ss
Support for dynamic strings.
A ast_taskprocessor structure is a singleton by name.
struct ast_var_t::@213 entries
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
callno_entry numbers[IAX_MAX_CALLS/2+1]
unsigned char semirand[32]
const ast_string_field mohinterpret
struct ast_variable * vars
const ast_string_field language
const ast_string_field cid_num
struct chan_iax2_pvt::signaling_queue signaling_queue
const ast_string_field inkeys
const ast_string_field outkey
struct chan_iax2_pvt::@122 dpentries
const ast_string_field dproot
const ast_string_field mohsuggest
unsigned short bridgecallno
const ast_string_field accountcode
const ast_string_field username
iax2_format peercapability
struct ast_variable * iaxvars
struct ast_sockaddr transfer
const ast_string_field context
unsigned short peercallno
struct iax2_codec_pref prefs
unsigned char calltoken_ie_len
const ast_string_field parkinglot
const ast_string_field host
callno_entry callno_entry
unsigned short transfercallno
struct ast_channel * owner
const ast_string_field rdnis
const ast_string_field challenge
const ast_string_field exten
const ast_string_field ani
struct iax2_codec_pref rprefs
struct iax2_registry * reg
ast_aes_decrypt_key mydcx
const ast_string_field cid_name
enum iax_transfer_state transferring
const ast_string_field secret
const ast_string_field dnid
const ast_string_field osptoken
struct iax2_peer * peerpoke
const ast_string_field peer
struct iax2_codec_pref prefs
char context[AST_MAX_CONTEXT]
char peercontext[AST_MAX_CONTEXT]
char mohsuggest[MAX_MUSICCLASS]
char mohinterpret[MAX_MUSICCLASS]
char context[AST_MAX_EXTENSION]
char callednum[AST_MAX_EXTENSION]
char order[IAX2_CODEC_PREF_SIZE]
char context[AST_MAX_CONTEXT]
struct iax2_context * next
struct iax2_dpcache::@125 peer_list
char exten[AST_MAX_EXTENSION]
struct iax2_dpcache::@124 cache_list
char peercontext[AST_MAX_CONTEXT]
const ast_string_field peercontext
const ast_string_field mohinterpret
struct ast_dnsmgr_entry * dnsmgr
const ast_string_field cid_num
const ast_string_field inkeys
const ast_string_field outkey
struct ast_mwi_subscriber * mwi_event_sub
enum calltoken_peer_enum calltoken_required
const ast_string_field regexten
const ast_string_field mohsuggest
const ast_string_field username
const ast_string_field zonetag
struct ast_sockaddr defaddr
const ast_string_field description
const ast_string_field context
struct iax2_codec_pref prefs
const ast_string_field parkinglot
const ast_string_field dbsecret
struct ast_endpoint * endpoint
struct ast_acl_list * acl
const ast_string_field name
const ast_string_field cid_name
const ast_string_field secret
const ast_string_field mailbox
struct iax2_pkt_buf::@126 entry
struct ast_dnsmgr_entry * dnsmgr
enum iax_reg_state regstate
struct iax2_registry::@121 entry
unsigned char readbuf[4096]
struct iax2_thread::@128 ffinfo
struct ast_sockaddr ioaddr
struct iax2_thread::@127 list
enum iax2_thread_iostate iostate
enum iax2_thread_type type
void(* schedfunc)(const void *)
struct iax2_thread::@129 full_frames
struct timeval lasttxtime
struct timeval rxtrunktime
struct iax2_trunk_peer::@120 list
unsigned int trunkdataalloc
unsigned int trunkdatalen
unsigned char * trunkdata
struct timeval txtrunktime
const ast_string_field mohinterpret
struct ast_variable * vars
const ast_string_field language
const ast_string_field cid_num
const ast_string_field inkeys
struct iax2_context * contexts
enum calltoken_peer_enum calltoken_required
const ast_string_field mohsuggest
const ast_string_field accountcode
struct iax2_codec_pref prefs
const ast_string_field parkinglot
const ast_string_field dbsecret
struct ast_acl_list * acl
const ast_string_field name
const ast_string_field cid_name
const ast_string_field secret
unsigned char semirand[32]
struct iax_frame::@139 list
ast_aes_decrypt_key mydcx
struct ast_sockaddr apparent_addr
unsigned char * calltokendata
struct ast_variable * vars
unsigned char iax_unknown
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM]
char * osptokenblock[IAX_MAX_OSPBLOCK_NUM]
Global IO variables are now in a struct in order to be made threadsafe.
In case you didn't read that giant block of text above the mansession_session struct,...
struct signaling_queue_entry * next
structure to hold users read from users.conf
list of users found in the config file
An API for managing task processing threads that can be shared across modules.
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
@ TPS_REF_DEFAULT
return a reference to a taskprocessor, create one if it does not exist
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller,...
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Timing source management.
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
struct ast_timer * ast_timer_open(void)
Open a timer.
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
Support for translation of data formats. translate.c.
int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
Chooses the best translation path.
int error(const char *format,...)
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_set2_flag64(p, value, flag)
#define ast_test_flag64(p, flag)
#define ast_set_flags_to64(p, flag, value)
#define ast_clear_flag64(p, flag)
#define ast_pthread_create_background(a, b, c, d)
#define ast_assert_return(a,...)
#define ast_clear_flag(p, flag)
long int ast_random(void)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_copy_flags64(dest, src, flagz)
#define ast_set_flag64(p, flag)
#define ast_set_flag(p, flag)
void ast_sha1_hash(char *output, const char *input)
Produces SHA1 hash based on input string.