61#include <sys/socket.h>
62#include <netinet/in.h>
64#include <netinet/in_systm.h>
65#include <netinet/ip.h>
281#define SCHED_MULTITHREADED
285#define DEBUG_SCHED_MULTITHREAD
289static int nochecksums = 0;
292#define PTR_TO_CALLNO(a) ((unsigned short)(unsigned long)(a))
293#define CALLNO_TO_PTR(a) ((void *)(unsigned long)(a))
295#define DEFAULT_THREAD_COUNT 10
296#define DEFAULT_MAX_THREAD_COUNT 100
297#define DEFAULT_RETRY_TIME 1000
298#define MEMORY_SIZE 100
299#define DEFAULT_DROP 3
303#define MIN_REUSE_TIME 60
310static const char tdesc[] =
"Inter Asterisk eXchange Driver (Ver 2)";
315#define MAX_TRUNK_MTU 1240
320#define DEFAULT_CONTEXT "default"
340#define MAX_TRUNKDATA 640 * 200
373#define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF
375#define IAX_CAPABILITY_MEDBANDWIDTH (IAX_CAPABILITY_FULLBANDWIDTH & \
377 ~AST_FORMAT_SLIN16 & \
378 ~AST_FORMAT_SIREN7 & \
379 ~AST_FORMAT_SIREN14 & \
385#define IAX_CAPABILITY_LOWBANDWIDTH (IAX_CAPABILITY_MEDBANDWIDTH & \
387 ~AST_FORMAT_G726_AAL2 & \
390#define IAX_CAPABILITY_LOWFREE (IAX_CAPABILITY_LOWBANDWIDTH & \
394#define DEFAULT_MAXMS 2000
395#define DEFAULT_FREQ_OK 60 * 1000
396#define DEFAULT_FREQ_NOTOK 10 * 1000
407#define AUTH_METHOD_NAMES_BUFSIZE 19
422 pos += sprintf(pos,
"|RSA");
425 pos += sprintf(pos,
"|MD5");
428 pos += sprintf(pos,
"|plaintext");
440#define IAX_CALLENCRYPTED(pvt) \
441 (ast_test_flag64(pvt, IAX_ENCRYPTED) && ast_test_flag64(pvt, IAX_KEYPOPULATED))
443#define IAX_DEBUGDIGEST(msg, key) do { \
445 char digest[33] = ""; \
450 for (idx = 0; idx < 16; idx++) \
451 sprintf(digest + (idx << 1), "%02hhx", (unsigned char) key[idx]); \
453 ast_log(LOG_NOTICE, msg " IAX_COMMAND_RTKEY to rotate key to '%s'\n", digest); \
467static int test_late = 0;
468static int test_resync = 0;
469static int test_jit = 0;
470static int test_jitpct = 0;
498#define IAX_HASCALLERID (uint64_t)(1LLU << 0)
499#define IAX_DELME (uint64_t)(1LLU << 1)
500#define IAX_TEMPONLY (uint64_t)(1LLU << 2)
501#define IAX_TRUNK (uint64_t)(1LLU << 3)
502#define IAX_NOTRANSFER (uint64_t)(1LLU << 4)
503#define IAX_USEJITTERBUF (uint64_t)(1LLU << 5)
504#define IAX_DYNAMIC (uint64_t)(1LLU << 6)
505#define IAX_SENDANI (uint64_t)(1LLU << 7)
506#define IAX_RTSAVE_SYSNAME (uint64_t)(1LLU << 8)
507#define IAX_ALREADYGONE (uint64_t)(1LLU << 9)
508#define IAX_PROVISION (uint64_t)(1LLU << 10)
509#define IAX_QUELCH (uint64_t)(1LLU << 11)
510#define IAX_ENCRYPTED (uint64_t)(1LLU << 12)
511#define IAX_KEYPOPULATED (uint64_t)(1LLU << 13)
512#define IAX_CODEC_USER_FIRST (uint64_t)(1LLU << 14)
513#define IAX_CODEC_NOPREFS (uint64_t)(1LLU << 15)
514#define IAX_CODEC_NOCAP (uint64_t)(1LLU << 16)
515#define IAX_RTCACHEFRIENDS (uint64_t)(1LLU << 17)
516#define IAX_RTUPDATE (uint64_t)(1LLU << 18)
517#define IAX_RTAUTOCLEAR (uint64_t)(1LLU << 19)
518#define IAX_RTIGNOREREGEXPIRE (uint64_t)(1LLU << 21)
519#define IAX_TRUNKTIMESTAMPS (uint64_t)(1LLU << 22)
520#define IAX_TRANSFERMEDIA (uint64_t)(1LLU << 23)
521#define IAX_MAXAUTHREQ (uint64_t)(1LLU << 24)
522#define IAX_DELAYPBXSTART (uint64_t)(1LLU << 25)
523#define IAX_ALLOWFWDOWNLOAD (uint64_t)(1LLU << 26)
524#define IAX_IMMEDIATE (uint64_t)(1LLU << 27)
525#define IAX_SENDCONNECTEDLINE (uint64_t)(1LLU << 28)
526#define IAX_RECVCONNECTEDLINE (uint64_t)(1LLU << 29)
527#define IAX_FORCE_ENCRYPT (uint64_t)(1LLU << 30)
528#define IAX_SHRINKCALLERID (uint64_t)(1LLU << 31)
638#define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
704#define MIN_RETRY_TIME 100
705#define MAX_RETRY_TIME 10000
707#define MAX_JITTER_BUFFER 50
708#define MIN_JITTER_BUFFER 10
710#define DEFAULT_TRUNKDATA 640 * 10
712#define MAX_TIMESTAMP_SKEW 160
715#define TS_GAP_FOR_JB_RESYNC 5000
718#define MARK_IAX_SUBCLASS_TX 0x8000
950#define PTR_TO_CALLNO_ENTRY(a) ((uint16_t)(unsigned long)(a))
951#define CALLNO_ENTRY_TO_PTR(a) ((void *)(unsigned long)(a))
953#define CALLNO_ENTRY_SET_VALIDATED(a) ((a) |= 0x8000)
954#define CALLNO_ENTRY_IS_VALIDATED(a) ((a) & 0x8000)
955#define CALLNO_ENTRY_GET_CALLNO(a) ((a) & 0x7FFF)
996#define MAX_PEER_BUCKETS 17
998#define MAX_PEER_BUCKETS 563
1002#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
1112#ifdef SCHED_MULTITHREADED
1116#ifdef DEBUG_SCHED_MULTITHREAD
1222#define TRUNK_CALL_START (IAX_MAX_CALLS / 2)
1261 va_start(
args, fmt);
1273 va_start(
args, fmt);
1285 va_start(
args, fmt);
1318static int send_command_locked(
unsigned short callno,
char,
int,
unsigned int,
const unsigned char *,
int,
int);
1343 .description =
tdesc,
1384 if (!
iaxs[callno] || !
iaxs[callno]->owner) {
1415 if (subtype == -1) {
1552 ast_verb(1,
"IAX, got a network change message, renewing all IAX registrations.\n");
1570 .
type =
"IAX2_VARIABLE",
1698#ifdef SCHED_MULTITHREADED
1702 static time_t lasterror;
1707 thread->schedfunc = func;
1708 thread->scheddata = data;
1710#ifdef DEBUG_SCHED_MULTITHREAD
1717 if (t != lasterror) {
1719 ast_debug(1,
"Out of idle IAX2 threads for scheduling! (%s)\n", funcname);
1724#define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
1752 ast_debug(3,
"I wanted to lock callno %d, but it is dead or going to die.\n",
callno);
1768 ast_debug(3,
"Hangup initiated on call %d, aborting __send_ping\n",
callno);
1789#ifdef SCHED_MULTITHREADED
1816 if (!strcasecmp(s,
"aes128"))
1832 ast_debug(3,
"Hangup initiated on call %d, aborting __send_lagrq\n",
callno);
1853#ifdef SCHED_MULTITHREADED
1869 if (subclass & (1LL << x)) {
1901 uint64_t pref_bitfield;
1904 if (!pref_bitfield) {
1920 return found_format;
1923 ast_debug(4,
"Could not find preferred codec - Returning zero codec.\n");
2012 const char *
name = obj;
2022 struct iax2_peer *peer = obj, *peer2 = arg;
2023 const char *
name = arg;
2035 const char *
name = obj;
2046 const char *
name = arg;
2063 if (!peer && realtime) {
2188 ast_debug(1,
"Really destroying %d now...\n", callno);
2304 tmp->keyrotateid = -1;
2327 tmp->hold_signaling = 1;
2338 memcpy(
new, fr,
sizeof(*
new));
2449 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2459 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2468 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2478 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2518 struct peercnt *peercnt1 = obj, *peercnt2 = arg;
2547 const char *find =
S_OR(
name,
"guest");
2630 ast_debug(1,
"Reset limits for peercnts table\n");
2796 for (; v; v = v->
next) {
2804 ast_log(
LOG_ERROR,
"Call number limit for %s could not be added, Invalid address range\n.", v->
name);
2806 }
else if ((sscanf(v->
value,
"%d", &limit) != 1) || (limit < 0)) {
2892 e->
command =
"iax2 show callnumber usage";
2894 "Usage: iax2 show callnumber usage [IP address]\n"
2895 " Shows current IP addresses which are consuming iax2 call numbers\n";
2900 if (
a->argc < 4 ||
a->argc > 5)
2904 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2913 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2930 ast_cli(
a->fd,
"\nNon-CallToken Validation Callno Limit: %d\n"
2931 "Non-CallToken Validated Callno Used: %d\n",
2935 ast_cli(
a->fd,
"Total Available Callno: %zu\n"
2936 "Regular Callno Available: %zu\n"
2937 "Trunk Callno Available: %zu\n",
2938 pool_avail + trunk_pool_avail,
2941 }
else if (
a->argc == 5 && !found) {
2942 ast_cli(
a->fd,
"No call number table entries for %s found\n",
a->argv[4] );
2989 "NON-CallToken callnumber limit is reached. Current: %d Max: %d\n",
3043 "Attempted to decrement total non calltoken validated "
3044 "callnumbers below zero. Callno is: %d\n",
3161 int validated = (
new >
NEW_ALLOW) ? 1 : 0;
3170 .transfercallno =
callno,
3172 .frames_received = check_dcallno,
3178 if (return_locked) {
3187 memset(&tmp_pvt.
addr, 0,
sizeof(tmp_pvt.
addr));
3190 if (return_locked) {
3208 if (!res || !return_locked) {
3248 ast_debug(1,
"Creating new call structure %d\n", x);
3408 struct sockaddr_in *sin;
3411 struct sock_extended_err e;
3416 m.msg_controllen =
sizeof(e);
3418 res = recvmsg(
netsocket, &m, MSG_ERRQUEUE);
3422 if (m.msg_controllen) {
3423 sin = (
struct sockaddr_in *)SO_EE_OFFENDER(&e);
3512 if ((pvt =
iaxs[callno])) {
3529 ast_debug(3,
"Avoiding IAX destroy deadlock\n");
3615 }
else if (f->
final) {
3619 ast_log(
LOG_WARNING,
"Max retries exceeded to host %s on %s (type = %u, subclass = %d, ts=%u, seqno=%d)\n",
3633 if (
iaxs[callno] &&
iaxs[callno]->owner)
3636 if (
iaxs[callno]->reg) {
3637 memset(&
iaxs[callno]->reg->us, 0,
sizeof(
iaxs[callno]->
reg->
us));
3673 }
else if (callno) {
3680#ifdef SCHED_MULTITHREADED
3691 static const char *
const choices[] = {
"all",
NULL };
3696 e->
command =
"iax2 prune realtime";
3698 "Usage: iax2 prune realtime [<peername>|all]\n"
3699 " Prunes object(s) from the cache\n";
3712 if (!strcmp(
a->argv[3],
"all")) {
3715 ast_cli(
a->fd,
"Cache flushed successfully.\n");
3725 ast_cli(
a->fd,
"Peer %s was removed from the cache.\n",
a->argv[3]);
3727 ast_cli(
a->fd,
"Peer %s is not eligible for this operation.\n",
a->argv[3]);
3734 ast_cli(
a->fd,
"User %s was removed from the cache.\n",
a->argv[3]);
3736 ast_cli(
a->fd,
"User %s is not eligible for this operation.\n",
a->argv[3]);
3742 ast_cli(
a->fd,
"%s was not found in the cache.\n",
a->argv[3]);
3752 e->
command =
"iax2 test losspct";
3754 "Usage: iax2 test losspct <percentage>\n"
3755 " For testing, throws away <percentage> percent of incoming packets\n";
3773 e->
command =
"iax2 test late";
3775 "Usage: iax2 test late <ms>\n"
3776 " For testing, count the next frame as <ms> ms late\n";
3785 test_late = atoi(
a->argv[3]);
3794 e->
command =
"iax2 test resync";
3796 "Usage: iax2 test resync <ms>\n"
3797 " For testing, adjust all future frames by <ms> ms\n";
3806 test_resync = atoi(
a->argv[3]);
3815 e->
command =
"iax2 test jitter";
3817 "Usage: iax2 test jitter <ms> <pct>\n"
3818 " For testing, simulate maximum jitter of +/- <ms> on <pct>\n"
3819 " percentage of packets. If <pct> is not specified, adds\n"
3820 " jitter to all packets.\n";
3826 if (
a->argc < 4 ||
a->argc > 5)
3829 test_jit = atoi(
a->argv[3]);
3831 test_jitpct = atoi(
a->argv[4]);
3846 snprintf(
status, statuslen,
"LAGGED (%d ms)", peer->
lastms);
3848 }
else if (peer->
lastms) {
3849 snprintf(
status, statuslen,
"OK (%d ms)", peer->
lastms);
3869 int load_realtime = 0;
3873 e->
command =
"iax2 show peer";
3875 "Usage: iax2 show peer <name>\n"
3876 " Display details on specific IAX peer\n";
3887 load_realtime = (
a->argc == 5 && !strcmp(
a->argv[4],
"load")) ? 1 : 0;
3891 char *str_addr, *str_defaddr;
3892 char *str_port, *str_defport;
3915 ast_cli(
a->fd,
" Addr->IP : %s Port %s\n", str_addr ? str_addr :
"(Unspecified)", str_port);
3916 ast_cli(
a->fd,
" Defaddr->IP : %s Port %s\n", str_defaddr, str_defport);
3921 strcpy(cbuf,
"Error");
3923 ast_cli(
a->fd,
" Codec Order : %s\n", cbuf);
3931 ast_cli(
a->fd,
"Peer %s not found.\n",
a->argv[3]);
3943 int wordlen = strlen(
word);
3948 if (!strncasecmp(peer->
name,
word, wordlen) && ++which >
state
3964 int cnt = 0, dead = 0,
final = 0, i = 0;
3968 e->
command =
"iax2 show stats";
3970 "Usage: iax2 show stats\n"
3971 " Display statistics on IAX channel driver.\n";
3992 ast_cli(
a->fd,
" IAX Statistics\n");
3993 ast_cli(
a->fd,
"---------------------\n");
3997 ast_cli(
a->fd,
"Packets in transmit queue: %d dead, %d final, %d total\n\n", dead,
final, cnt);
4015 "Usage: iax2 set mtu <value>\n"
4016 " Set the system-wide IAX IP mtu to <value> bytes net or\n"
4017 " zero to disable. Disabling means that the operating system\n"
4018 " must handle fragmentation of UDP packets when the IAX2 trunk\n"
4019 " packet exceeds the UDP payload size. This is substantially\n"
4020 " below the IP mtu. Try 1240 on ethernets. Must be 172 or\n"
4021 " greater for G.711 samples.\n";
4029 if (strncasecmp(
a->argv[3],
"default", strlen(
a->argv[3])) == 0)
4032 mtuv = atoi(
a->argv[3]);
4039 if (mtuv < 172 || mtuv > 4000) {
4040 ast_cli(
a->fd,
"Trunk MTU must be between 172 and 4000\n");
4057 e->
command =
"iax2 show cache";
4059 "Usage: iax2 show cache\n"
4060 " Display currently cached IAX Dialplan results.\n";
4068 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8.8s %s\n",
"Peer/Context",
"Exten",
"Exp.",
"Wait.",
"Flags");
4071 s = dp->
expiry.tv_sec - now.tv_sec;
4074 strncat(
tmp,
"EXISTS|",
sizeof(
tmp) - strlen(
tmp) - 1);
4076 strncat(
tmp,
"NONEXISTENT|",
sizeof(
tmp) - strlen(
tmp) - 1);
4078 strncat(
tmp,
"CANEXIST|",
sizeof(
tmp) - strlen(
tmp) - 1);
4080 strncat(
tmp,
"PENDING|",
sizeof(
tmp) - strlen(
tmp) - 1);
4082 strncat(
tmp,
"TIMEOUT|",
sizeof(
tmp) - strlen(
tmp) - 1);
4084 strncat(
tmp,
"TRANSMITTED|",
sizeof(
tmp) - strlen(
tmp) - 1);
4086 strncat(
tmp,
"MATCHMORE|",
sizeof(
tmp) - strlen(
tmp) - 1);
4088 strncat(
tmp,
"UNKNOWN|",
sizeof(
tmp) - strlen(
tmp) - 1);
4091 tmp[strlen(
tmp) - 1] =
'\0';
4107 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9d %-8d %s\n", pc, dp->
exten, s, y,
tmp);
4109 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->
exten,
"(expired)", y,
tmp);
4125 const int lower_mask = (1 << ts_shift) - 1;
4126 const int upper_mask = ~lower_mask;
4129 if ( (fr->
ts & upper_mask) == last_upper ) {
4131 const int threshold = (ts_shift == 15) ? 25000 : 50000;
4138 fr->
ts = (last_upper + (1 << ts_shift)) | (fr->
ts & lower_mask);
4140 ast_debug(1,
"schedule_delivery: pushed forward timestamp\n");
4146 fr->
ts = (last_upper - (1 << ts_shift)) | (fr->
ts & lower_mask);
4148 ast_debug(1,
"schedule_delivery: pushed back timestamp\n");
4198 now.tv_usec += 1000;
4230 af.
src =
"IAX2 JB interpolation";
4263#ifdef SCHED_MULTITHREADED
4299 ast_debug(1,
"schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
4388 0, 0, (
unsigned char *)
text, strlen(
text) + 1, -1);
4422 time_t regseconds = 0, nowtime;
4424 char *str_addr, *str_port;
4439 if (!strcasecmp(
tmp->name,
"name"))
4440 peername =
tmp->value;
4444 if (!
var && peername) {
4454 if (!strcasecmp(
tmp->name,
"host")) {
4481 if (!strcasecmp(
tmp->name,
"type")) {
4482 if (strcasecmp(
tmp->value,
"friend") &&
4483 strcasecmp(
tmp->value,
"peer")) {
4488 }
else if (!strcasecmp(
tmp->name,
"regseconds")) {
4490 }
else if (!strcasecmp(
tmp->name,
"ipaddr")) {
4498 }
else if (!strcasecmp(
tmp->name,
"port")) {
4504 }
else if (!strcasecmp(
tmp->name,
"host")) {
4505 if (!strcasecmp(
tmp->value,
"dynamic"))
4535 memset(&peer->
addr, 0,
sizeof(peer->
addr));
4537 ast_debug(1,
"realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
4538 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4541 ast_debug(1,
"realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
4542 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4554 char *str_addr, *str_port;
4577 if (!strcasecmp(
tmp->name,
"host")) {
4598 if (!strcasecmp(
tmp->name,
"type")) {
4599 if (strcasecmp(
tmp->value,
"friend") &&
4600 strcasecmp(
tmp->value,
"user")) {
4626 char regseconds[20];
4628 char *syslabel =
NULL;
4634 syslabel =
"regserver";
4636 snprintf(regseconds,
sizeof(regseconds),
"%d", (
int)regtime);
4641 "regseconds", regseconds, syslabel, sysname,
SENTINEL);
4759 key = strchr(family,
'/');
4797#ifdef SCHED_MULTITHREADED
4831 struct ast_sockaddr *addr,
int command,
int ts,
unsigned char seqno,
4842 memcpy(&data.ied, ied->
buf, ied->
pos);
4845 data.f.scallno = htons(0x8000 | callno);
4847 data.f.ts = htonl(
ts);
4848 data.f.iseqno = seqno;
4855 return ast_sendto(sockfd, &data, size, 0, addr);
4861 if (pvt && ied && (2 < ((
int)
sizeof(ied->
buf) - ied->
pos))) {
4863 ied->
buf[ied->
pos++] = 0;
4900 (f->
datalen >
sizeof(data))) {
4920 data.ied.pos = ie_data_pos;
4993#define CALLTOKEN_HASH_FORMAT "%s%u%d"
4994#define CALLTOKEN_IE_FORMAT "%u?%s"
4996 time_t t = time(
NULL);
5019 char *rec_hash =
NULL;
5020 char *rec_ts =
NULL;
5021 unsigned int rec_time;
5031 if (!rec_hash || !rec_ts) {
5033 }
else if (sscanf(rec_ts,
"%u", &rec_time) != 1) {
5042 if (strcmp(hash, rec_hash)) {
5094 char *outkey =
NULL;
5109 if (strchr(pds->
peer,
'@')) {
5142 }
else if (outkey && (outkey[0] ==
'[')) {
5157 char *defaultrdest =
"s";
5163 const char* osp_token_ptr;
5164 unsigned int osp_token_length;
5165 unsigned char osp_block_index;
5166 unsigned int osp_block_length;
5167 unsigned char osp_buffer[256];
5168 char encoded_prefs[32];
5176 memset(&cai, 0,
sizeof(cai));
5180 memset(&pds, 0,
sizeof(pds));
5189 pds.
exten = defaultrdest;
5233 memset(&ied, 0,
sizeof(ied));
5318 if (
iaxs[callno]->maxtime) {
5331 osp_block_index = 0;
5332 while (osp_token_length > 0) {
5334 osp_buffer[0] = osp_block_index;
5335 memcpy(osp_buffer + 1, osp_token_ptr, osp_block_length);
5338 osp_token_ptr += osp_block_length;
5339 osp_token_length -= osp_block_length;
5344 ast_debug(1,
"OSP token is undefined\n");
5350 if (variablestore) {
5352 ast_debug(1,
"Found an IAX variable store on this channel\n");
5382 memset(&ied, 0,
sizeof(ied));
5384 if (callno &&
iaxs[callno]) {
5389 if (!
iaxs[callno]->
error && !alreadygone) {
5393 if (!
iaxs[callno]) {
5401 if (
iaxs[callno] && alreadygone) {
5404 }
else if (
iaxs[callno]) {
5406 ast_log(
LOG_ERROR,
"Unable to schedule iax2 callno %d destruction?!! Destroying immediately.\n", callno);
5427 unsigned short callno = pvt->
callno;
5463 if ((*(
int *)
data)) {
5495 if (!(h =
ast_malloc(datalen +
sizeof(*h)))) {
5500 h->option = htons(option);
5501 memcpy(h->
data, data, datalen);
5504 datalen +
sizeof(*h), -1);
5535 ast_debug(1,
"I should never be called!\n");
5552 snprintf(key,
sizeof(key),
"%lX", (
unsigned long)
ast_random());
5571#if defined(IAX2_NATIVE_BRIDGING)
5572static int iax2_start_transfer(
unsigned short callno0,
unsigned short callno1,
int mediaonly)
5577 unsigned int transferid = (
unsigned int)
ast_random();
5580 ast_debug(1,
"transfers are not supported for encrypted calls at this time\n");
5586 memset(&ied0, 0,
sizeof(ied0));
5591 memset(&ied1, 0,
sizeof(ied1));
5608#if defined(IAX2_NATIVE_BRIDGING)
5609static void lock_both(
unsigned short callno0,
unsigned short callno1)
5618#if defined(IAX2_NATIVE_BRIDGING)
5619static void unlock_both(
unsigned short callno0,
unsigned short callno1)
5626#if defined(IAX2_NATIVE_BRIDGING)
5633 int transferstarted=0;
5637 struct timeval waittimer = {0, 0};
5640 if (timeoutms > 0) {
5646 lock_both(callno0, callno1);
5647 if (!
iaxs[callno0] || !
iaxs[callno1]) {
5648 unlock_both(callno0, callno1);
5656 unlock_both(callno0, callno1);
5664 ast_verb(3,
"Can't masquerade, we're different...\n");
5682 ast_verb(3,
"Operating with different codecs [%s] [%s] , can't native bridge...\n",
5687 lock_both(callno0, callno1);
5692 unlock_both(callno0, callno1);
5701 transferstarted = 1;
5724 if (timeoutms > -1) {
5725 timeoutms -= (1000 - to);
5747 other = (who == c0) ? c1 : c0;
5779 if (flags & monitored_source) {
5794 lock_both(callno0, callno1);
5799 unlock_both(callno0, callno1);
5818 ast_debug(1,
"Indicating condition %d\n", condition);
5828 switch (condition) {
5845 ast_debug(2,
"Callno %d: Config blocked sending control frame %d.\n",
5908 const struct ast_channel *requestor,
unsigned int cachable)
5917 char *peer_name =
NULL;
5919 if (!(i =
iaxs[callno])) {
5967 if (i !=
iaxs[callno]) {
5985 if ((callid =
iaxs[callno]->callid)) {
6047 for (v = i->
vars ; v ; v = v->
next)
6054 ast_debug(1,
"Loading up the channel with IAXVARs\n");
6057 if (variablestore && varlist) {
6058 variablestore->
data = varlist;
6068 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
6078 if (variablestore) {
6107 unsigned long int mssincetx;
6134static unsigned int fix_peerts(
struct timeval *rxtrunktime,
int callno,
unsigned int ts)
6156 struct timeval *delivery =
NULL;
6219 else if (adjust > 0)
6239 ast_debug(1,
"predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
6244 int diff = ms % (f->
samples / rate);
6261 if ( (
unsigned int)ms < p->
lastsent )
6269 if (ms <= p->lastsent)
6296 ast_debug(1,
"calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %ums\n",
6301 ast_debug(1,
"calc_rxstamp: call=%d: works out as %d.%6.6d\n",
6309 if (!test_jitpct || ((100.0 *
ast_random() / (RAND_MAX + 1.0)) < test_jitpct)) {
6310 jit = (int)((
float)test_jit *
ast_random() / (RAND_MAX + 1.0));
6311 if ((
int)(2.0 *
ast_random() / (RAND_MAX + 1.0)))
6339 if ((tpeer =
ast_calloc(1,
sizeof(*tpeer)))) {
6348 setsockopt(tpeer->
sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums,
sizeof(nochecksums));
6397 mtm->
mini.
ts = htons(0xffff & fr->
ts);
6447 for (i = 0; i < 60; i++) {
6483 dst[x] = src[x] ^ 0xff;
6485 unsigned char lastblock[16] = { 0 };
6490 dst[x] ^= lastblock[x];
6491 memcpy(lastblock, src,
sizeof(lastblock));
6507 dst[x] = src[x] ^ 0xff;
6509 unsigned char curblock[16] = { 0 };
6513 curblock[x] ^= src[x];
6515 memcpy(curblock, dst,
sizeof(curblock));
6526 unsigned char *workspace;
6529 memset(f, 0,
sizeof(*f));
6537 padding = 16 + (workspace[15] & 0x0f);
6539 ast_debug(1,
"Decoding full frame with length %d (padding = %d) (15=%02hhx)\n", *datalen, padding, workspace[15]);
6543 *datalen -= padding;
6562 ast_debug(5,
"Decoding mini with length %d\n", *datalen);
6567 padding = 16 + (workspace[15] & 0x0f);
6570 *datalen -= padding;
6579 unsigned char *workspace;
6584 ast_debug(1,
"Encoding full frame %d/%d with length %d\n", fh->
type, fh->
csub, *datalen);
6586 padding = 16 + (padding & 0xf);
6587 memcpy(workspace, poo, padding);
6589 workspace[15] &= 0xf0;
6590 workspace[15] |= (padding & 0xf);
6592 ast_debug(1,
"Encoding full frame %d/%d with length %d + %d padding (15=%02hhx)\n", fh->
type, fh->
csub, *datalen, padding, workspace[15]);
6593 *datalen += padding;
6596 memcpy(poo, workspace + *datalen - 32, 32);
6600 ast_debug(5,
"Encoding mini frame with length %d\n", *datalen);
6602 padding = 16 + (padding & 0xf);
6603 memcpy(workspace, poo, padding);
6605 workspace[15] &= 0xf0;
6606 workspace[15] |= (padding & 0x0f);
6607 *datalen += padding;
6610 memcpy(poo, workspace + *datalen - 32, 32);
6621 unsigned char digest[16];
6622 char *tmppw, *stringp;
6626 while ((tmppw =
strsep(&stringp,
";"))) {
6629 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
6653 unsigned char buffer[4096];
6658 unsigned int lastsent;
6680 "f->frametype %c= AST_FRAME_VOICE, %sencrypted, %srotation scheduled...\n",
6691 (((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
6692 ((fts & 0xFFFF0000L) == ((lastsent + 0x10000) & 0xFFFF0000L))))
6710 if (((fts & 0xFFFF8000L) == (pvt->
lastvsent & 0xFFFF8000L)) &&
6755 fh->
ts = htonl(fr->
ts);
6839 mh->
ts = htons(fr->
ts & 0xFFFF);
6860 int havepattern = 0;
6862#define FORMAT "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n"
6863#define FORMAT2 "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n"
6872 e->
command =
"iax2 show users [like]";
6874 "Usage: iax2 show users [like <pattern>]\n"
6875 " Lists all known IAX2 users.\n"
6876 " Optional regular expression pattern is used to filter the user list.\n";
6884 if (!strcasecmp(
a->argv[3],
"like")) {
6885 if (regcomp(®exbuf,
a->argv[4], REG_EXTENDED | REG_NOSUB))
6896 ast_cli(
a->fd,
FORMAT,
"Username",
"Secret",
"Authen",
"Def.Context",
"A/C",
"Codec Pref");
6899 if (havepattern && regexec(®exbuf,
user->name, 0,
NULL, 0))
6905 snprintf(auth,
sizeof(auth),
"Key: %-15.15s ",
user->inkeys);
6942#define PEERS_FORMAT2 "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n"
6943#define PEERS_FORMAT "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n"
6947 char name[256] =
"";
6952 char *tmp_host, *tmp_mask, *tmp_port;
6966 if (retstatus > 0) {
6968 }
else if (!retstatus) {
6977 "Event: PeerEntry\r\n%s"
6978 "Channeltype: IAX\r\n",
6982 "ObjectName: %s\r\n"
6983 "ObjectUsername: %s\r\n",
6988 "ObjectName: %s\r\n",
6993 "Event: PeerEntry\r\n%s"
6994 "Channeltype: IAX2\r\n"
6995 "ObjectName: %s\r\n",
7000 "ChanObjectType: peer\r\n"
7001 "IPaddress: %s\r\n",
7017 "Encryption: %s\r\n"
7027 "Description: %s\r\n\r\n",
7051 .registeredonly = 0,
7058 .unmonitored_peers = 0,
7067 if (!strcasecmp(argv[3],
"registered"))
7071 if (!strcasecmp(argv[4],
"like")) {
7072 if (regcomp(&cont.
regexbuf, argv[5], REG_EXTENDED | REG_NOSUB))
7079 if (!strcasecmp(argv[3],
"like")) {
7080 if (regcomp(&cont.
regexbuf, argv[4], REG_EXTENDED | REG_NOSUB))
7087 if (!strcasecmp(argv[3],
"registered")) {
7101 ast_cli(fd,
PEERS_FORMAT2,
"Name/Username",
"Host",
" ",
"Mask",
"Port",
" ",
"Status",
"Description");
7120 ast_cli(fd,
"%d iax2 peers [%d online, %d offline, %d unmonitored]\n",
7142 int threadcount = 0, dynamiccount = 0;
7147 e->
command =
"iax2 show threads";
7149 "Usage: iax2 show threads\n"
7150 " Lists status of IAX helper threads\n";
7158 ast_cli(
a->fd,
"IAX2 Thread Information\n");
7163#ifdef DEBUG_SCHED_MULTITHREAD
7164 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7167 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7173 ast_cli(
a->fd,
"Active Threads:\n");
7180#ifdef DEBUG_SCHED_MULTITHREAD
7181 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d, func='%s'\n",
7184 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d\n",
7190 ast_cli(
a->fd,
"Dynamic Threads:\n");
7193#ifdef DEBUG_SCHED_MULTITHREAD
7194 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7197 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7203 ast_cli(
a->fd,
"%d of %d threads accounted for with %d dynamic threads\n", threadcount,
iaxthreadcount, dynamiccount);
7213 e->
command =
"iax2 unregister";
7215 "Usage: iax2 unregister <peername>\n"
7216 " Unregister (force expiration) an IAX2 peer from the registry.\n";
7234 ast_cli(
a->fd,
"Peer %s unregistered\n",
a->argv[2]);
7236 ast_cli(
a->fd,
"Peer %s not found\n",
a->argv[2]);
7239 ast_cli(
a->fd,
"Peer %s not registered\n",
a->argv[2]);
7243 ast_cli(
a->fd,
"Peer unknown: %s. Not unregistered\n",
a->argv[2]);
7253 int wordlen = strlen(
word);
7259 if (!strncasecmp(p->
name,
word, wordlen) &&
7277 e->
command =
"iax2 show peers";
7279 "Usage: iax2 show peers [registered] [like <pattern>]\n"
7280 " Lists all known IAX2 peers.\n"
7281 " Optional 'registered' argument lists only peers with known addresses.\n"
7282 " Optional regular expression pattern is used to filter the peer list.\n";
7308 int *fd = user_data;
7310 ast_cli(*fd,
"%-15.15s %-15d %-15d\n",
7313 (
int) ntohl(
header->datalen));
7322 e->
command =
"iax2 show firmware";
7324 "Usage: iax2 show firmware\n"
7325 " Lists all known IAX firmware images.\n";
7331 if (
a->argc != 3 &&
a->argc != 4)
7334 ast_cli(
a->fd,
"%-15.15s %-15.15s %-15.15s\n",
"Device",
"Version",
"Size");
7337 a->argc == 3 ?
NULL :
a->argv[3],
7347 static const char *
const a[] = {
"iax2",
"show",
"peers" };
7349 char idtext[256] =
"";
7353 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7372 .registeredonly = 0,
7379 .unmonitored_peers = 0,
7388 snprintf(cont.
idtext,
sizeof(cont.
idtext),
"ActionID: %s\r\n",
id);
7410 return "Unregistered";
7412 return "Request Sent";
7414 return "Auth. Sent";
7416 return "Registered";
7422 return "No Authentication";
7430#define FORMAT2 "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n"
7431#define FORMAT "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n"
7440 e->
command =
"iax2 show registry";
7442 "Usage: iax2 show registry\n"
7443 " Lists all registration requests and status.\n";
7450 ast_cli(
a->fd,
FORMAT2,
"Host",
"dnsmgr",
"Username",
"Perceived",
"Refresh",
"State");
7458 (reg->
dnsmgr) ?
"Y" :
"N",
7463 ast_cli(
a->fd,
"%d IAX2 registrations.\n", counter);
7473 char idtext[256] =
"";
7475 char perceived[80] =
"";
7479 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7490 "Event: RegistryEntry\r\n"
7493 "DNSmanager: %s\r\n"
7498 "\r\n", idtext, host, (reg->
dnsmgr) ?
"Y" :
"N", reg->
username, perceived,
7513#define FORMAT2 "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n"
7514#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"
7515#define FORMATB "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"
7518 char first_message[10] = { 0, };
7519 char last_message[10] = { 0, };
7523 e->
command =
"iax2 show channels";
7525 "Usage: iax2 show channels\n"
7526 " Lists all currently active IAX channels.\n";
7534 ast_cli(
a->fd,
FORMAT2,
"Channel",
"Peer",
"Username",
"ID (Lo/Rem)",
"Seq (Tx/Rx)",
"Lag",
"Jitter",
"JitBuf",
"Format",
"FirstMsg",
"LastMsg");
7538 int lag, jitter, localdelay;
7570 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7581 char first_message[10] = { 0, };
7582 char last_message[10] = { 0, };
7583#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"
7584#define ACN_FORMAT2 "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"
7588 int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
7595 localjitter = jbinfo.
jitter;
7598 locallosspct = jbinfo.
losspct/1000;
7619 iaxs[x]->frames_received/1000,
7620 iaxs[x]->remote_rr.jitter,
7641 iaxs[x]->frames_received/1000,
7642 iaxs[x]->remote_rr.jitter,
7667 e->
command =
"iax2 show netstats";
7669 "Usage: iax2 show netstats\n"
7670 " Lists network status for all currently active IAX channels.\n";
7677 ast_cli(
a->fd,
" -------- LOCAL --------------------- -------- REMOTE --------------------\n");
7678 ast_cli(
a->fd,
"Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts FirstMsg LastMsg\n");
7680 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7688 e->
command =
"iax2 set debug {on|off|peer}";
7690 "Usage: iax2 set debug {on|off|peer peername}\n"
7691 " Enables/Disables dumping of IAX packets for debugging purposes.\n";
7694 if (
a->pos == 4 && !strcasecmp(
a->argv[3],
"peer"))
7699 if (
a->argc < e->
args ||
a->argc > e->
args + 1)
7702 if (!strcasecmp(
a->argv[3],
"peer")) {
7705 if (
a->argc != e->
args + 1)
7711 ast_cli(
a->fd,
"IAX2 peer '%s' does not exist\n",
a->argv[e->
args-1]);
7720 }
else if (!strncasecmp(
a->argv[3],
"on", 2)) {
7722 ast_cli(
a->fd,
"IAX2 Debugging Enabled\n");
7726 ast_cli(
a->fd,
"IAX2 Debugging Disabled\n");
7735 e->
command =
"iax2 set debug trunk {on|off}";
7737 "Usage: iax2 set debug trunk {on|off}\n"
7738 " Enables/Disables debugging of IAX trunking\n";
7744 if (
a->argc != e->
args)
7747 if (!strncasecmp(
a->argv[e->
args - 1],
"on", 2)) {
7749 ast_cli(
a->fd,
"IAX2 Trunk Debugging Enabled\n");
7752 ast_cli(
a->fd,
"IAX2 Trunk Debugging Disabled\n");
7761 e->
command =
"iax2 set debug jb {on|off}";
7763 "Usage: iax2 set debug jb {on|off}\n"
7764 " Enables/Disables jitterbuffer debugging information\n";
7770 if (
a->argc != e->
args)
7773 if (!strncasecmp(
a->argv[e->
args -1],
"on", 2)) {
7775 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Enabled\n");
7778 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Disabled\n");
7821 f.
src = __FUNCTION__;
7835 ast_debug(2,
"Callno %d: Blocked sending control frame %d.\n",
7858 int call_num = i->
callno;
7861 if (!
iaxs[call_num])
7894 int gotcapability = 0;
7945 memset(&
iaxs[callno]->rprefs, 0,
sizeof(
iaxs[callno]->rprefs));
7949 if (!gotcapability) {
7961 !strcmp(
iaxs[callno]->username,
user->name))
7975 if (bestscore < 4) {
7984 if (bestscore < 3) {
7995 if (bestscore < 2) {
8004 if (bestscore < 1) {
8029 for (v =
user->vars ; v ; v = v->
next) {
8038 if (
user->maxauthreq > 0)
8087 char *family, *key=
NULL;
8090 key = strchr(family,
'/');
8133 return ast_sendto(sockfd, &fh,
sizeof(fh), 0, addr);
8160 int res = -1, authreq_restrict = 0;
8164 memset(&ied, 0,
sizeof(ied));
8172 if (
user->curauthreq ==
user->maxauthreq)
8173 authreq_restrict = 1;
8181 if (authreq_restrict) {
8210 char requeststr[256];
8211 char md5secret[256] =
"";
8213 char rsasecret[256] =
"";
8232 ast_log(
LOG_WARNING,
"Call Terminated, incoming call is unencrypted while force encrypt is enabled.\n");
8249 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8253 keyn =
strsep(&stringp,
":");
8261 ast_log(
LOG_WARNING,
"Requested inkey '%s' for RSA authentication does not exist\n", keyn);
8263 keyn =
strsep(&stringp,
":");
8271 unsigned char digest[16];
8272 char *tmppw, *stringp;
8275 while((tmppw =
strsep(&stringp,
";"))) {
8278 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8282 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8283 if (!strcasecmp(requeststr, md5secret)) {
8292 if (!strcmp(secret, p->
secret)) {
8305 char requeststr[256] =
"";
8306 char peer[256] =
"";
8307 char md5secret[256] =
"";
8308 char rsasecret[256] =
"";
8309 char secret[256] =
"";
8339 if (!p || !
iaxs[callno]) {
8383 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8387 keyn =
strsep(&stringp,
":");
8395 keyn =
strsep(&stringp,
":");
8405 ast_log(
LOG_NOTICE,
"Host '%s' trying to do RSA authentication, but we have no inkeys\n", peer);
8410 unsigned char digest[16];
8411 char *tmppw, *stringp;
8415 while((tmppw =
strsep(&stringp,
";"))) {
8418 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8421 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8422 if (!strcasecmp(requeststr, md5secret))
8434 if (strcmp(secret, p->
secret)) {
8454 if (expire && (expire <
iaxs[callno]->expiry)) {
8497 unsigned char digest[16];
8501 MD5Update(&
md5, (
unsigned char *) secret, strlen(secret));
8512 unsigned char digest[16];
8516 MD5Update(&
md5, (
unsigned char *)secret, strlen(secret));
8520 sprintf(digres + (x << 1),
"%02hhx", digest[x]);
8550 uint16_t callno = p->
callno;
8552 memset(&ied, 0,
sizeof(ied));
8604 if (!(p =
iaxs[callno])) {
8613 if (!(p =
iaxs[callno]))
8628 ast_log(
LOG_WARNING,
"Call terminated. Encryption requested by peer but no secret available locally\n");
8637 ast_log(
LOG_NOTICE,
"Call initiated without encryption while forceencryption=yes option is set\n");
8646 if (variablestore && varlist && p->
owner) {
8647 variablestore->
data = varlist;
8657 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8668 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8703#ifdef SCHED_MULTITHREADED
8716 memset(&ied, 0,
sizeof(ied));
8746 char exten[256] =
"";
8773 dp->
flags &= ~CACHE_FLAG_PENDING;
8780 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
8799 peercallno = ies->
callno;
8801 if (peercallno < 1) {
8862 char peer[256] =
"";
8865 char ourip[256] =
"<Unspecified>";
8906 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new and %d old messages waiting", reg->
messages & 0xff, reg->
messages >> 8);
8908 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new messages waiting", reg->
messages);
8910 ast_copy_string(msgstatus,
" with 1 new message waiting",
sizeof(msgstatus));
8912 ast_copy_string(msgstatus,
" with no messages waiting",
sizeof(msgstatus));
8925 const char *secret,
const char *porta)
8951 if (!porta && !reg->
port) {
8954 sscanf(porta,
"%5d", ®->
port);
8982 ast_log(
LOG_WARNING,
"Format for registration is user[:secret]@host[:port] at line %d\n", lineno);
8991 porta =
strsep(&stringp,
":");
8993 if (porta && !atoi(porta)) {
9005 char *stringp, *
ext;
9047 if (peer->
expire == -1) {
9054 ast_debug(1,
"Expiring registration for peer '%s'\n", peer->
name);
9059 "peer_status",
"Unregistered",
9060 "cause",
"Expired");
9083#ifdef SCHED_MULTITHREADED
9099 expiry = strrchr(data,
':');
9155 const char *peer_name;
9187 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9191 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9217 ast_verb(3,
"Registered IAX2 '%s' (%s) at %s\n",
9223 "peer_status",
"Registered",
9224 "address", str_addr,
9229 ast_verb(3,
"Unregistered IAX2 '%s' (%s)\n",
9234 "peer_status",
"Unregistered");
9301 msgcount = (old << 8) |
new;
9327 const char *peer_name;
9342 memset(&ied, 0,
sizeof(ied));
9375 char peer[256] =
"";
9378 int authmethods = 0;
9385 memset(&ied, 0,
sizeof(ied));
9400 if (reg->
secret[0] ==
'[') {
9403 tmpkey[strlen(tmpkey) - 1] =
'\0';
9427 int callno = (int)(
long)(nothing);
9431 memset(&ied, 0,
sizeof(ied));
9446 int callno = (int)(
long)(data);
9451#ifdef SCHED_MULTITHREADED
9476 int callno = (int)(
long)(nothing);
9480 memset(&ied, 0,
sizeof(ied));
9490 int callno = (int)(
long)(data);
9496#ifdef SCHED_MULTITHREADED
9509 memset(&ied, 0,
sizeof(ied));
9526 if (((
unsigned char) (f->
oseqno -
last) < 128) &&
9544#ifdef SCHED_MULTITHREADED
9581 calls = tpeer->
calls;
9597 if (now->tv_sec > tpeer->
trunkact.tv_sec + 5)
9636 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",
9639 (res != 1) ?
"s" :
"",
9656 if (drop->trunkdata) {
9658 drop->trunkdata =
NULL;
9666 ast_verbose(
"Ending trunk processing with %d peers and %d call chunks processed\n", processed,
totalcalls);
9680static void dp_lookup(
int callno,
const char *
context,
const char *callednum,
const char *callerid,
int skiplock)
9682 unsigned short dpstatus = 0;
9686 memset(&ied1, 0,
sizeof(ied1));
9725 pthread_t newthread;
9743 unsigned int ourver;
9745 snprintf(rsi,
sizeof(rsi),
"si-%s", si);
9748 ast_debug(1,
"Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
9759 memset(iep, 0,
sizeof(*iep));
9784 unsigned int length, offset = 0;
9795 memcpy(full_osptoken + offset, ies->
osptokenblock[i], length);
9802 *(full_osptoken + offset) =
'\0';
9803 if (strlen(full_osptoken) != offset) {
9805 *full_osptoken =
'\0';
9813 int localjitter = -1, localdelay = 0, locallost = -1, locallosspct = -1, localdropped = 0, localooo = -1, localpackets = -1;
9820 localjitter = jbinfo.
jitter;
9823 locallosspct = jbinfo.
losspct/1000;
9828 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",
9893 memcpy(pkt_buf->
buf, from_here->
buf, pkt_buf->
len);
9919 static time_t last_errtime = 0;
9924 if (t != last_errtime) {
9926 ast_debug(1,
"Out of idle IAX2 threads for I/O, pausing!\n");
9936 if (
thread->buf_len < 0) {
9937 if (
errno != ECONNREFUSED &&
errno != EAGAIN)
9985#ifdef DEBUG_SCHED_MULTITHREAD
9996 unsigned char metatype;
10003 struct timeval rxtrunktime;
10006 if (packet_len <
sizeof(*
meta)) {
10007 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a meta frame but is too short\n",
10015 if (packet_len < (
sizeof(*
meta) +
sizeof(*mth))) {
10016 ast_log(
LOG_WARNING,
"midget meta trunk packet received (%d of %d min)\n", packet_len,
10017 (
int) (
sizeof(*
meta) +
sizeof(*mth)));
10021 ts = ntohl(mth->
ts);
10022 metatype =
meta->cmddata;
10023 packet_len -= (
sizeof(*meta) +
sizeof(*mth));
10027 ast_log(
LOG_WARNING,
"Unable to accept trunked packet from '%s': No matching peer\n",
10036 while (packet_len >=
sizeof(*mte)) {
10038 unsigned short callno, trunked_ts,
len;
10042 ptr +=
sizeof(*mtm);
10043 packet_len -=
sizeof(*mtm);
10046 trunked_ts = ntohs(mtm->
mini.
ts);
10049 ptr +=
sizeof(*mte);
10050 packet_len -=
sizeof(*mte);
10059 if (
len > packet_len)
10068 memset(&f, 0,
sizeof(f));
10131 if (!variablestore) {
10135 varlist = variablestore->
data;
10139 if (strcmp(
var->name, data) == 0) {
10160 if (!variablestore) {
10162 if (!variablestore) {
10174 variablestore->
data = varlist;
10178 varlist = variablestore->
data;
10182 if (strcmp(
var->name, data) == 0) {
10207 if (
iaxs[callno] &&
iaxs[callno]->owner) {
10229 int updatehistory=1;
10232 char decrypted = 0;
10251 char host_pref_buf[128];
10252 char caller_pref_buf[128];
10254 char *using_prefs =
"mine";
10258 memset(fr, 0,
sizeof(*fr));
10266 if (res <
sizeof(*mh)) {
10267 ast_log(
LOG_WARNING,
"midget packet received (%d of %d min)\n", res, (
int)
sizeof(*mh));
10270 if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
10271 if (res <
sizeof(*vh)) {
10272 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a video frame but is too short\n",
10278 fr->
callno =
find_callno(ntohs(vh->callno) & ~0x8000, dcallno, &addr,
new, fd, 0);
10280 }
else if ((
meta->zeros == 0) && !(ntohs(
meta->metacmd) & 0x8000))
10283#ifdef DEBUG_SUPPORT
10284 if (res >=
sizeof(*fh))
10288 if (res <
sizeof(*fh)) {
10289 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a full frame but is too short\n",
10295 dcallno = ntohs(fh->
dcallno) & ~IAX_FLAG_RETRANS;
10322 if ((fh->
csub >> 6) & 0x1) {
10344 f.
datalen = res -
sizeof(*fh);
10356 memset(&ies, 0,
sizeof(ies));
10363 memset(&ies, 0,
sizeof(ies));
10387 memset(&ies, 0,
sizeof(ies));
10391 int check_dcallno = 0;
10457#ifdef DEBUG_SUPPORT
10469 int data_size =
sizeof(*cause_code);
10470 char subclass[40] =
"";
10486 data_size += strlen(subclass);
10489 memset(cause_code, 0, data_size);
10493 snprintf(cause_code->
code, data_size -
sizeof(*cause_code) + 1,
"IAX2 %s(%d)", subclass, ies.
causecode);
10514 unsigned short new_peercallno;
10516 new_peercallno = (
unsigned short) (ntohs(mh->callno) & ~IAX_FLAG_FULL);
10531 fr->
ts = ntohl(fh->
ts);
10534 ast_debug(1,
"Simulating frame ts resync, was %u now %u\n", fr->
ts, fr->
ts + test_resync);
10535 fr->
ts += test_resync;
10567 ast_debug(1,
"Packet arrived out of order (expecting %d, got %d) (frametype = %u, subclass = %d)\n",
10600 if (res < thread->buf_size)
10601 thread->buf[res++] =
'\0';
10603 thread->buf[res - 1] =
'\0';
10612 int call_to_destroy;
10624 ast_debug(1,
"Cancelling transmission of packet %d\n", x);
10625 call_to_destroy = 0;
10632 call_to_destroy = fr->
callno;
10635 if (call_to_destroy) {
10637 ast_debug(1,
"Really destroying %d, having been acked on final message\n", call_to_destroy);
10698 if (variablestore && varlist) {
10699 variablestore->
data = varlist;
10711 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10722 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10723 if (variablestore) {
10734 ast_debug(1,
"No channel, so populating IAXVARs to the pvt, as an intermediate step.\n");
10745 ast_debug(1,
"I have IAX variables, but they were not processed\n");
10775 ast_debug(1,
"Neat, somebody took away the channel at a magical time but i found it!\n");
10779 ast_debug(1,
"I can haz iaxvars, but they is no good. :-(\n");
10821 const char *moh_suggest;
10867 memset(&ied1, 0,
sizeof(ied1));
10889 fr->
callno = new_callno;
10898 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, who was trying to reach '%s@%s'\n",
10905 ast_log(
LOG_WARNING,
"Rejected connect attempt. No secret present while force encrypt enabled.\n");
10909 const char *
context, *exten, *cid_num;
10929 memset(&ied0, 0,
sizeof(ied0));
10937 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
10945 using_prefs =
"reqonly";
10947 using_prefs =
"disabled";
10950 memset(&pref, 0,
sizeof(pref));
10951 strcpy(caller_pref_buf,
"disabled");
10952 strcpy(host_pref_buf,
"disabled");
10955 using_prefs =
"mine";
10963 using_prefs =
"caller";
10978 memset(&ied0, 0,
sizeof(ied0));
10991 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
10996 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11011 memset(&pref, 0,
sizeof(pref));
11013 strcpy(caller_pref_buf,
"disabled");
11014 strcpy(host_pref_buf,
"disabled");
11017 using_prefs =
"mine";
11024 using_prefs =
"caller";
11037 memset(&ied0, 0,
sizeof(ied0));
11046 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11059 memset(&ied1, 0,
sizeof(ied1));
11065 ast_verb(3,
"Accepting UNAUTHENTICATED call from %s:\n"
11066 "%srequested format = %s,\n"
11067 "%srequested prefs = %s,\n"
11068 "%sactual format = %s,\n"
11069 "%shost prefs = %s,\n"
11070 "%spriority = %s\n",
11119 ast_debug(1,
"Immediately destroying %d, having received hangup\n", fr->
callno);
11146 ast_debug(1,
"Immediately destroying %d, having received reject\n",
11205 memset(&ied0, 0,
sizeof(ied0));
11216 ast_log(
LOG_NOTICE,
"Rejected call to %s, format %s incompatible with our capability %s.\n",
11283 "peer_status",
"Reachable",
11292 "peer_status",
"Lagged",
11346 ast_debug(1,
"Peer %s lag measured as %dms\n",
11360 "I don't know how to authenticate %s to %s\n",
11378 memset(&ied0, 0,
sizeof(ied0));
11389 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
11393 memset(&ied0, 0,
sizeof(ied0));
11404 using_prefs =
"reqonly";
11406 using_prefs =
"disabled";
11409 memset(&pref, 0,
sizeof(pref));
11410 strcpy(caller_pref_buf,
"disabled");
11411 strcpy(host_pref_buf,
"disabled");
11414 using_prefs =
"mine";
11420 using_prefs =
"caller";
11436 ast_debug(1,
"We don't do requested format %s, falling back to peer capability '%s'\n",
11444 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11449 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11456 memset(&ied0, 0,
sizeof(ied0));
11471 memset(&pref, 0,
sizeof(pref));
11475 strcpy(caller_pref_buf,
"disabled");
11476 strcpy(host_pref_buf,
"disabled");
11479 using_prefs =
"mine";
11486 using_prefs =
"caller";
11502 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11507 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11514 memset(&ied0, 0,
sizeof(ied0));
11526 memset(&ied1, 0,
sizeof(ied1));
11533 ast_verb(3,
"Accepting AUTHENTICATED call from %s:\n"
11534 "%srequested auth methods = (%s),\n"
11535 "%sactual auth method = %s,\n"
11536 "%sencrypted = %s,\n"
11537 "%srequested format = %s,\n"
11538 "%srequested prefs = %s,\n"
11539 "%sactual format = %s,\n"
11540 "%shost prefs = %s,\n"
11541 "%spriority = %s\n",
11565 }
else if (ies.
vars) {
11571 if (variablestore && varlist) {
11572 variablestore->
data = varlist;
11575 ast_debug(1,
"I can haz IAX vars? w00t\n");
11583 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11593 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11605 goto immediatedial;
11618 ast_log(
LOG_WARNING,
"Rejected dial attempt from %s, request '%s@%s' does not exist\n",
11622 memset(&ied0, 0,
sizeof(ied0));
11632 ast_verb(3,
"Accepting DIAL from %s, formats = %s\n",
11642 }
else if (ies.
vars) {
11648 ast_debug(1,
"I can haz IAX vars? w00t\n");
11649 if (variablestore && varlist) {
11650 variablestore->
data = varlist;
11660 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11670 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11682 ast_debug(1,
"Immediately destroying %d, having received INVAL\n", fr->
callno);
11687 ast_debug(1,
"Received VNAK: resending outstanding frames\n");
11753 memset(&ied0, 0,
sizeof(ied0));
11828 memset(&ied0, 0,
sizeof(ied0));
11829 memset(&ied1, 0,
sizeof(ied1));
11847 memset(&ied0, 0,
sizeof(ied0));
11848 memset(&ied1, 0,
sizeof(ied1));
11884 "we've been told to rotate our encryption key, "
11885 "but this isn't an encrypted call. bad things will happen.\n"
11906 memset(&ied0, 0,
sizeof(ied0));
11926 memset(&ied0, 0,
sizeof(ied0));
11933 ast_debug(1,
"I can haz IAX vars, but they is no good :-(\n");
11953 }
else if (minivid) {
11956 if (ntohs(vh->ts) & 0x8000LL) {
11972 f.
datalen = res -
sizeof(*vh);
11979 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | ((ntohs(vh->ts) + test_resync) & 0x7fff);
11982 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | (ntohs(vh->ts) & 0x7fff);
11994 ast_debug(1,
"Received mini frame before first full voice frame\n");
12013 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF0000L) | ((ntohs(mh->ts) + test_resync) & 0xffff);
12031 ast_debug(2,
"Callno %d: Blocked receiving control frame %d.\n",
12042 ast_debug(2,
"Callno %d: Config blocked receiving control frame %d.\n",
12164 struct timeval wait;
12165 struct timespec ts;
12166 int put_into_idle = 0;
12167 int first_time = 1;
12172 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
12191 if (put_into_idle) {
12199 ts.tv_sec = wait.tv_sec;
12200 ts.tv_nsec = wait.tv_usec * 1000;
12204 if (!put_into_idle ||
thread->stop) {
12224 ts.tv_sec = wait.tv_sec;
12225 ts.tv_nsec = wait.tv_usec * 1000;
12245 switch (
thread->iostate) {
12257#ifdef SCHED_MULTITHREADED
12275 time(&
thread->checktime);
12277#ifdef DEBUG_SCHED_MULTITHREAD
12278 thread->curfunc[0]=
'\0';
12297 pthread_detach(pthread_self());
12303 pthread_cleanup_pop(1);
12324 int callno = reg->
callno;
12332 ast_debug(1,
"Unable to send registration request for '%s' without IP address\n", reg->
username);
12344 ast_debug(3,
"Allocate call number\n");
12359 memset(&ied, 0,
sizeof(ied));
12379 memset(&cai, 0,
sizeof(cai));
12381 ast_debug(1,
"Provisioning '%s' from template '%s'\n", dest,
template);
12384 ast_debug(1,
"No provisioning found for template '%s'\n",
template);
12395 memset(&ied, 0,
sizeof(ied));
12402 if (
iaxs[callno]) {
12430 opts = strchr(sdata,
'|');
12443 ast_verb(3,
"Provisioned IAXY at '%s' with '%s'= %d\n",
12456 e->
command =
"iax2 provision";
12458 "Usage: iax2 provision <host> <template> [forced]\n"
12459 " Provisions the given peer or IP address using a template\n"
12460 " matching either 'template' or '*' if the template is not\n"
12461 " found. If 'forced' is specified, even empty provisioning\n"
12462 " fields will be provisioned as empty fields.\n";
12473 if (!strcasecmp(
a->argv[4],
"forced"))
12480 ast_cli(
a->fd,
"Unable to find peer/address '%s'\n",
a->argv[2]);
12482 ast_cli(
a->fd,
"No template (including wildcard) matching '%s'\n",
a->argv[3]);
12484 ast_cli(
a->fd,
"Provisioning '%s' with template '%s'%s\n",
a->argv[2],
a->argv[3], force ?
", forced" :
"");
12493 if (peer->
lastms > -1) {
12499 "peer_status",
"Unreachable",
12521#ifdef SCHED_MULTITHREADED
12640 memset(&pds, 0,
sizeof(pds));
12650 memset(&cai, 0,
sizeof(cai));
12678 if ((new_callno =
make_trunk(callno, 1)) != -1)
12679 callno = new_callno;
12691 requestor, cai.
found);
12732 ao2_ref(best_fmt_native, -1);
12755 pthread_testcancel();
12762 if (res < 0 &&
errno != -EINTR) {
12774 int threadcount = 0;
12780 thread->threadnum = ++threadcount;
12814 ast_verb(2,
"%d helper threads started\n", threadcount);
12831 if (strstr(
value,
"rsa"))
12833 if (strstr(
value,
"md5"))
12835 if (strstr(
value,
"plaintext"))
12850 sd = socket(addr->
ss.ss_family, SOCK_DGRAM, 0);
12883 port = atoi(portstr);
12921 if (nonlocal == 1) {
12923 "Non-local or unbound address specified (%s) in sourceaddress for '%s', reverting to default\n",
12927 }
else if (nonlocal == 2) {
12929 "Unable to bind to sourceaddress '%s' for '%s', reverting to default\n",
12934 ast_debug(1,
"Using sourceaddress %s for '%s'\n", srcaddr, peer->
name);
12974 int subscribe_acl_change = 0;
12985 oldacl = peer->
acl;
13035 if (!strcasecmp(v->
name,
"secret")) {
13037 }
else if (!strcasecmp(v->
name,
"mailbox")) {
13039 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
13045 if (strchr(
name,
'@')) {
13051 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13053 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13055 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13057 }
else if (!strcasecmp(v->
name,
"description")) {
13059 }
else if (!strcasecmp(v->
name,
"trunk")) {
13062 ast_log(
LOG_WARNING,
"Unable to support trunking on peer '%s' without a timing interface\n", peer->
name);
13065 }
else if (!strcasecmp(v->
name,
"auth")) {
13070 }
else if (!strcasecmp(v->
name,
"encryption")) {
13075 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13084 }
else if (!strcasecmp(v->
name,
"transfer")) {
13085 if (!strcasecmp(v->
value,
"mediaonly")) {
13091 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13093 }
else if (!strcasecmp(v->
name,
"host")) {
13094 if (!strcasecmp(v->
value,
"dynamic")) {
13122 }
else if (!strcasecmp(v->
name,
"defaultip")) {
13124 peer_defaddr_tmp.
ss.ss_family = AF_UNSPEC;
13130 }
else if (!strcasecmp(v->
name,
"sourceaddress")) {
13132 }
else if (!strcasecmp(v->
name,
"permit") ||
13133 !strcasecmp(v->
name,
"deny") ||
13134 !strcasecmp(v->
name,
"acl")) {
13136 }
else if (!strcasecmp(v->
name,
"mask")) {
13139 }
else if (!strcasecmp(v->
name,
"context")) {
13141 }
else if (!strcasecmp(v->
name,
"regexten")) {
13143 }
else if (!strcasecmp(v->
name,
"peercontext")) {
13145 }
else if (!strcasecmp(v->
name,
"port")) {
13155 }
else if (!strcasecmp(v->
name,
"username")) {
13157 }
else if (!strcasecmp(v->
name,
"allow")) {
13159 }
else if (!strcasecmp(v->
name,
"disallow")) {
13161 }
else if (!strcasecmp(v->
name,
"callerid")) {
13173 }
else if (!strcasecmp(v->
name,
"fullname")) {
13176 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13179 }
else if (!strcasecmp(v->
name,
"sendani")) {
13181 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13183 }
else if (!strcasecmp(v->
name,
"outkey")) {
13185 }
else if (!strcasecmp(v->
name,
"qualify")) {
13186 if (!strcasecmp(v->
value,
"no")) {
13188 }
else if (!strcasecmp(v->
value,
"yes")) {
13190 }
else if (sscanf(v->
value,
"%30d", &peer->
maxms) != 1) {
13191 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);
13194 }
else if (!strcasecmp(v->
name,
"qualifysmoothing")) {
13196 }
else if (!strcasecmp(v->
name,
"qualifyfreqok")) {
13198 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);
13200 }
else if (!strcasecmp(v->
name,
"qualifyfreqnotok")) {
13202 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);
13204 }
else if (!strcasecmp(v->
name,
"timezone")) {
13206 }
else if (!strcasecmp(v->
name,
"adsi")) {
13208 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13211 }
else if (!strcasecmp(v->
value,
"send")) {
13214 }
else if (!strcasecmp(v->
value,
"receive")) {
13220 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
13226 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13230 }
else if (!strcasecmp(v->
value,
"auto")) {
13271 if (subscribe_acl_change) {
13300 int oldcurauthreq = 0;
13301 int subscribe_acl_change = 0;
13302 char *varname =
NULL, *varval =
NULL;
13313 oldcurauthreq =
user->curauthreq;
13314 oldacl =
user->acl;
13315 oldcon =
user->contexts;
13334 user->curauthreq = oldcurauthreq;
13356 if (!strcasecmp(v->
name,
"context")) {
13362 user->contexts = con;
13365 }
else if (!strcasecmp(v->
name,
"permit") ||
13366 !strcasecmp(v->
name,
"deny") ||
13367 !strcasecmp(v->
name,
"acl")) {
13369 }
else if (!strcasecmp(v->
name,
"setvar")) {
13371 if ((varval = strchr(varname,
'='))) {
13377 user->vars = tmpvar;
13381 }
else if (!strcasecmp(v->
name,
"allow")) {
13383 }
else if (!strcasecmp(v->
name,
"disallow")) {
13385 }
else if (!strcasecmp(v->
name,
"trunk")) {
13388 ast_log(
LOG_WARNING,
"Unable to support trunking on user '%s' without a timing interface\n",
user->name);
13391 }
else if (!strcasecmp(v->
name,
"auth")) {
13396 }
else if (!strcasecmp(v->
name,
"encryption")) {
13398 if (!
user->encmethods) {
13401 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13406 if (
user->encmethods) {
13410 }
else if (!strcasecmp(v->
name,
"transfer")) {
13411 if (!strcasecmp(v->
value,
"mediaonly")) {
13417 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13418 if(!strcasecmp(v->
value,
"caller"))
13420 else if(!strcasecmp(v->
value,
"disabled"))
13422 else if(!strcasecmp(v->
value,
"reqonly")) {
13426 }
else if (!strcasecmp(v->
name,
"immediate")) {
13428 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13430 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13432 }
else if (!strcasecmp(v->
name,
"secret")) {
13439 }
else if (!strcasecmp(v->
name,
"callerid")) {
13452 }
else if (!strcasecmp(v->
name,
"fullname")) {
13461 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13470 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13472 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13474 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13476 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13478 }
else if (!strcasecmp(v->
name,
"language")) {
13480 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13485 user->amaflags = format;
13487 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13489 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13491 if (
user->maxauthreq < 0)
13492 user->maxauthreq = 0;
13493 }
else if (!strcasecmp(v->
name,
"adsi")) {
13495 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13498 }
else if (!strcasecmp(v->
value,
"send")) {
13501 }
else if (!strcasecmp(v->
value,
"receive")) {
13507 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13511 }
else if (!strcasecmp(v->
value,
"auto")) {
13526 if (!
user->authmethods) {
13547 if (subscribe_acl_change) {
13656 const char *tosval;
13661 int subscribe_network_change = 1;
13696 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
13748 if (!strcasecmp(v->
name,
"bindport")) {
13755 }
else if (!strcasecmp(v->
name,
"pingtime")){
13758 else if (!strcasecmp(v->
name,
"iaxthreadcount")) {
13772 }
else if (!strcasecmp(v->
name,
"iaxmaxthreadcount")) {
13787 }
else if (!strcasecmp(v->
name,
"nochecksums")) {
13795 ast_log(
LOG_WARNING,
"Disabling RTP checksums is not supported on this operating system!\n");
13798 else if (!strcasecmp(v->
name,
"maxjitterbuffer"))
13800 else if (!strcasecmp(v->
name,
"resyncthreshold"))
13802 else if (!strcasecmp(v->
name,
"maxjitterinterps"))
13804 else if (!strcasecmp(v->
name,
"jittertargetextra"))
13806 else if (!strcasecmp(v->
name,
"lagrqtime"))
13808 else if (!strcasecmp(v->
name,
"maxregexpire"))
13810 else if (!strcasecmp(v->
name,
"minregexpire"))
13812 else if (!strcasecmp(v->
name,
"bindaddr")) {
13840 }
else if (!strcasecmp(v->
name,
"auth")) {
13845 }
else if (!strcasecmp(v->
name,
"authdebug")) {
13847 }
else if (!strcasecmp(v->
name,
"encryption")) {
13852 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13861 }
else if (!strcasecmp(v->
name,
"transfer")) {
13862 if (!strcasecmp(v->
value,
"mediaonly")) {
13868 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13869 if(!strcasecmp(v->
value,
"caller"))
13871 else if(!strcasecmp(v->
value,
"disabled"))
13873 else if(!strcasecmp(v->
value,
"reqonly")) {
13877 }
else if (!strcasecmp(v->
name,
"jitterbuffer"))
13879 else if (!strcasecmp(v->
name,
"delayreject"))
13881 else if (!strcasecmp(v->
name,
"allowfwdownload"))
13883 else if (!strcasecmp(v->
name,
"rtcachefriends"))
13885 else if (!strcasecmp(v->
name,
"rtignoreregexpire"))
13887 else if (!strcasecmp(v->
name,
"rtupdate"))
13889 else if (!strcasecmp(v->
name,
"rtsavesysname"))
13891 else if (!strcasecmp(v->
name,
"trunktimestamps"))
13893 else if (!strcasecmp(v->
name,
"rtautoclear")) {
13894 int i = atoi(v->
value);
13900 }
else if (!strcasecmp(v->
name,
"trunkfreq")) {
13903 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 10ms instead.\n");
13906 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 1000ms instead.\n");
13912 }
else if (!strcasecmp(v->
name,
"trunkmtu")) {
13913 mtuv = atoi(v->
value);
13916 else if (mtuv >= 172 && mtuv < 4000)
13921 }
else if (!strcasecmp(v->
name,
"trunkmaxsize")) {
13925 }
else if (!strcasecmp(v->
name,
"autokill")) {
13926 if (sscanf(v->
value,
"%30d", &x) == 1) {
13936 }
else if (!strcasecmp(v->
name,
"bandwidth")) {
13937 if (!strcasecmp(v->
value,
"low")) {
13940 }
else if (!strcasecmp(v->
value,
"medium")) {
13943 }
else if (!strcasecmp(v->
value,
"high")) {
13949 }
else if (!strcasecmp(v->
name,
"allow")) {
13951 }
else if (!strcasecmp(v->
name,
"disallow")) {
13953 }
else if (!strcasecmp(v->
name,
"register")) {
13955 }
else if (!strcasecmp(v->
name,
"iaxcompat")) {
13957 }
else if (!strcasecmp(v->
name,
"regcontext")) {
13961 }
else if (!strcasecmp(v->
name,
"tos")) {
13964 }
else if (!strcasecmp(v->
name,
"cos")) {
13967 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13969 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13971 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13973 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13975 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13982 }
else if (!strcasecmp(v->
name,
"language")) {
13984 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13988 }
else if (!strcasecmp(v->
name,
"adsi")) {
13990 }
else if (!strcasecmp(v->
name,
"srvlookup")) {
13992 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13995 }
else if (!strcasecmp(v->
value,
"send")) {
13998 }
else if (!strcasecmp(v->
value,
"receive")) {
14004 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
14008 }
else if (!strcasecmp(v->
name,
"maxcallnumbers_nonvalidated")) {
14012 }
else if (!strcasecmp(v->
name,
"calltokenoptional")) {
14017 }
else if (!strcasecmp(v->
name,
"calltokenexpiration")) {
14019 sscanf(v->
value,
"%u", &temp);
14025 }
else if (!strcasecmp(v->
name,
"subscribe_network_change_event")) {
14027 subscribe_network_change = 1;
14029 subscribe_network_change = 0;
14033 }
else if (!strcasecmp(v->
name,
"shrinkcallerid")) {
14046 if (subscribe_network_change) {
14075 ast_log(
LOG_WARNING,
"Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
14085 int genregisteriax;
14086 const char *hasiax, *registeriax;
14093 if (strcasecmp(cat,
"general")) {
14096 if (
ast_true(hasiax) || (!hasiax && genhasiax)) {
14112 if (
ast_true(registeriax) || (!registeriax && genregisteriax)) {
14125 snprintf(
tmp,
sizeof(
tmp),
"%s:%s@%s", username, secret, host);
14127 snprintf(
tmp,
sizeof(
tmp),
"%s@%s", username, host);
14139 if (strcasecmp(cat,
"general")) {
14141 if (!strcasecmp(cat,
"callnumberlimits")) {
14143 }
else if (utype) {
14144 if (!strcasecmp(utype,
"user") || !strcasecmp(utype,
"friend")) {
14151 if (!strcasecmp(utype,
"peer") || !strcasecmp(utype,
"friend")) {
14159 }
else if (strcasecmp(utype,
"user")) {
14185 static const char config[] =
"iax.conf";
14220 "Usage: iax2 reload\n"
14221 " Reloads IAX configuration from iax.conf\n";
14251 if (
iaxs[x] && !strcasecmp(data,
iaxs[x]->dproot))
14259 memset(&cai, 0,
sizeof(cai));
14260 memset(&ied, 0,
sizeof(ied));
14261 memset(&pds, 0,
sizeof(pds));
14275 ast_debug(1,
"peer: %s, username: %s, password: %s, context: %s\n",
14314 int x, com[2], timeout, doabort, callno;
14387 pfd.events = POLLIN;
14394 }
else if (!pfd.revents) {
14415 dp->
flags &= ~CACHE_FLAG_PENDING;
14422 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
14440 ast_log(
LOG_NOTICE,
"iax2_exists: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14463 ast_log(
LOG_NOTICE,
"iax2_canmatch: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14486 ast_log(
LOG_NOTICE,
"iax2_matchmore: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n",
context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14512 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);
14530 ncontext = strchr(odata,
'/');
14534 snprintf(req,
sizeof(req),
"IAX2/%s/%s@%s", odata, exten, ncontext);
14536 snprintf(req,
sizeof(req),
"IAX2/%s/%s", odata, exten);
14538 ast_verb(3,
"Executing Dial('%s')\n", req);
14558 char *peername, *colname;
14563 if (!strcmp(peername,
"CURRENTCHANNEL")) {
14573 if ((colname = strchr(peername,
',')))
14581 if (!strcasecmp(colname,
"ip")) {
14583 }
else if (!strcasecmp(colname,
"status")) {
14585 }
else if (!strcasecmp(colname,
"mailbox")) {
14587 }
else if (!strcasecmp(colname,
"context")) {
14589 }
else if (!strcasecmp(colname,
"expire")) {
14591 }
else if (!strcasecmp(colname,
"dynamic")) {
14593 }
else if (!strcasecmp(colname,
"callerid_name")) {
14595 }
else if (!strcasecmp(colname,
"callerid_num")) {
14597 }
else if (!strcasecmp(colname,
"codecs")) {
14602 }
else if (!strncasecmp(colname,
"codec[", 6)) {
14603 char *codecnum, *ptr;
14607 codecnum = colname + 5;
14610 if ((ptr = strchr(codecnum,
']'))) {
14650 if (!strcasecmp(
args,
"osptoken")) {
14652 }
else if (!strcasecmp(
args,
"peerip")) {
14654 }
else if (!strcasecmp(
args,
"peername")) {
14656 }
else if (!strcasecmp(
args,
"secure_signaling") || !strcasecmp(
args,
"secure_media")) {
14675 memset(&pds, 0,
sizeof(pds));
14683 ast_debug(3,
"Checking device state for device %s\n", pds.
peer);
14691 ast_debug(3,
"Found peer. What's device state of %s? addr=%s, defaddr=%s maxms=%d, lastms=%d\n",
14711 .description =
"IAX Remote Dialplan Switch",
14740 AST_CLI_DEFINE(handle_cli_iax2_test_jitter,
"Simulates jitter for testing"),
14741 AST_CLI_DEFINE(handle_cli_iax2_test_late,
"Test the receipt of a late frame"),
14742 AST_CLI_DEFINE(handle_cli_iax2_test_resync,
"Test a resync in received timestamps"),
14749 struct iax2_thread_list *list_head = head;
14754 pthread_t thread_id =
thread->threadid;
14760 pthread_join(thread_id,
NULL);
14878 return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt,
14896 return match(&pvt2->transfer, pvt2->transfercallno, pvt2->callno, pvt,
14908 goto container_fail;
14914 goto container_fail;
14920 goto container_fail;
14926 goto container_fail;
14932 goto container_fail;
14938 goto container_fail;
14944 goto container_fail;
14948 goto container_fail;
14953 goto container_fail;
14995 static const char config[] =
"iax.conf";
15109 ast_verb(2,
"IAX Ready and Listening\n");
15124 ast_realtime_require_field(
"iaxpeers",
"name",
RQ_CHAR, 10,
"ipaddr",
RQ_CHAR, 15,
"port",
RQ_UINTEGER2, 5,
"regseconds",
RQ_UINTEGER2, 6,
SENTINEL);
15137 .
requires =
"dnsmgr",
15138 .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.
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)
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
#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)
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)
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.
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
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.
char * strsep(char **str, const char *delims)
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.
#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)
@ CONFIG_FLAG_FILEUNCHANGED
Asterisk internal frame definitions.
@ AST_FRFLAG_HAS_TIMING_INFO
#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
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[16], 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 @450 methods[]
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses
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.
struct ast_frame_subclass subclass
union ast_frame::@226 data
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::@208 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::@211 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.