64 #include <sys/socket.h> 65 #include <netinet/in.h> 66 #include <arpa/inet.h> 67 #include <netinet/in_systm.h> 68 #include <netinet/ip.h> 277 #define SCHED_MULTITHREADED 281 #define DEBUG_SCHED_MULTITHREAD 285 static int nochecksums = 0;
288 #define PTR_TO_CALLNO(a) ((unsigned short)(unsigned long)(a)) 289 #define CALLNO_TO_PTR(a) ((void *)(unsigned long)(a)) 291 #define DEFAULT_THREAD_COUNT 10 292 #define DEFAULT_MAX_THREAD_COUNT 100 293 #define DEFAULT_RETRY_TIME 1000 294 #define MEMORY_SIZE 100 295 #define DEFAULT_DROP 3 297 #define DEBUG_SUPPORT 299 #define MIN_REUSE_TIME 60 306 static const char tdesc[] =
"Inter Asterisk eXchange Driver (Ver 2)";
311 #define MAX_TRUNK_MTU 1240 316 #define DEFAULT_CONTEXT "default" 336 #define MAX_TRUNKDATA 640 * 200 369 #define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF 371 #define IAX_CAPABILITY_MEDBANDWIDTH (IAX_CAPABILITY_FULLBANDWIDTH & \ 373 ~AST_FORMAT_SLIN16 & \ 374 ~AST_FORMAT_SIREN7 & \ 375 ~AST_FORMAT_SIREN14 & \ 381 #define IAX_CAPABILITY_LOWBANDWIDTH (IAX_CAPABILITY_MEDBANDWIDTH & \ 383 ~AST_FORMAT_G726_AAL2 & \ 386 #define IAX_CAPABILITY_LOWFREE (IAX_CAPABILITY_LOWBANDWIDTH & \ 390 #define DEFAULT_MAXMS 2000 391 #define DEFAULT_FREQ_OK 60 * 1000 392 #define DEFAULT_FREQ_NOTOK 10 * 1000 395 #define IAX_CALLENCRYPTED(pvt) \ 396 (ast_test_flag64(pvt, IAX_ENCRYPTED) && ast_test_flag64(pvt, IAX_KEYPOPULATED)) 398 #define IAX_DEBUGDIGEST(msg, key) do { \ 400 char digest[33] = ""; \ 405 for (idx = 0; idx < 16; idx++) \ 406 sprintf(digest + (idx << 1), "%02hhx", (unsigned char) key[idx]); \ 408 ast_log(LOG_NOTICE, msg " IAX_COMMAND_RTKEY to rotate key to '%s'\n", digest); \ 422 static int test_late = 0;
423 static int test_resync = 0;
424 static int test_jit = 0;
425 static int test_jitpct = 0;
453 #define IAX_HASCALLERID (uint64_t)(1LLU << 0) 454 #define IAX_DELME (uint64_t)(1LLU << 1) 455 #define IAX_TEMPONLY (uint64_t)(1LLU << 2) 456 #define IAX_TRUNK (uint64_t)(1LLU << 3) 457 #define IAX_NOTRANSFER (uint64_t)(1LLU << 4) 458 #define IAX_USEJITTERBUF (uint64_t)(1LLU << 5) 459 #define IAX_DYNAMIC (uint64_t)(1LLU << 6) 460 #define IAX_SENDANI (uint64_t)(1LLU << 7) 461 #define IAX_RTSAVE_SYSNAME (uint64_t)(1LLU << 8) 462 #define IAX_ALREADYGONE (uint64_t)(1LLU << 9) 463 #define IAX_PROVISION (uint64_t)(1LLU << 10) 464 #define IAX_QUELCH (uint64_t)(1LLU << 11) 465 #define IAX_ENCRYPTED (uint64_t)(1LLU << 12) 466 #define IAX_KEYPOPULATED (uint64_t)(1LLU << 13) 467 #define IAX_CODEC_USER_FIRST (uint64_t)(1LLU << 14) 468 #define IAX_CODEC_NOPREFS (uint64_t)(1LLU << 15) 469 #define IAX_CODEC_NOCAP (uint64_t)(1LLU << 16) 470 #define IAX_RTCACHEFRIENDS (uint64_t)(1LLU << 17) 471 #define IAX_RTUPDATE (uint64_t)(1LLU << 18) 472 #define IAX_RTAUTOCLEAR (uint64_t)(1LLU << 19) 473 #define IAX_RTIGNOREREGEXPIRE (uint64_t)(1LLU << 21) 474 #define IAX_TRUNKTIMESTAMPS (uint64_t)(1LLU << 22) 475 #define IAX_TRANSFERMEDIA (uint64_t)(1LLU << 23) 476 #define IAX_MAXAUTHREQ (uint64_t)(1LLU << 24) 477 #define IAX_DELAYPBXSTART (uint64_t)(1LLU << 25) 478 #define IAX_ALLOWFWDOWNLOAD (uint64_t)(1LLU << 26) 479 #define IAX_IMMEDIATE (uint64_t)(1LLU << 27) 480 #define IAX_SENDCONNECTEDLINE (uint64_t)(1LLU << 28) 481 #define IAX_RECVCONNECTEDLINE (uint64_t)(1LLU << 29) 482 #define IAX_FORCE_ENCRYPT (uint64_t)(1LLU << 30) 483 #define IAX_SHRINKCALLERID (uint64_t)(1LLU << 31) 593 #define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr)) 599 struct timeval txtrunktime;
600 struct timeval rxtrunktime;
601 struct timeval lasttxtime;
602 struct timeval trunkact;
659 #define MIN_RETRY_TIME 100 660 #define MAX_RETRY_TIME 10000 662 #define MAX_JITTER_BUFFER 50 663 #define MIN_JITTER_BUFFER 10 665 #define DEFAULT_TRUNKDATA 640 * 10 667 #define MAX_TIMESTAMP_SKEW 160 670 #define TS_GAP_FOR_JB_RESYNC 5000 673 #define MARK_IAX_SUBCLASS_TX 0x8000 751 struct timeval offset;
753 struct timeval rxcore;
833 unsigned char semirand[32];
902 #define PTR_TO_CALLNO_ENTRY(a) ((uint16_t)(unsigned long)(a)) 903 #define CALLNO_ENTRY_TO_PTR(a) ((void *)(unsigned long)(a)) 905 #define CALLNO_ENTRY_SET_VALIDATED(a) ((a) |= 0x8000) 906 #define CALLNO_ENTRY_IS_VALIDATED(a) ((a) & 0x8000) 907 #define CALLNO_ENTRY_GET_CALLNO(a) ((a) & 0x7FFF) 948 #define MAX_PEER_BUCKETS 17 950 #define MAX_PEER_BUCKETS 563 954 #define MAX_USER_BUCKETS MAX_PEER_BUCKETS 1023 struct timeval orig;
1024 struct timeval expiry;
1064 #ifdef SCHED_MULTITHREADED 1065 void (*schedfunc)(
const void *);
1068 #ifdef DEBUG_SCHED_MULTITHREAD 1075 unsigned char readbuf[4096];
1174 #define TRUNK_CALL_START (IAX_MAX_CALLS / 2) 1213 va_start(args, fmt);
1214 vsnprintf(buf,
sizeof(buf), fmt, args);
1225 va_start(args, fmt);
1226 vsnprintf(buf,
sizeof(buf), fmt, args);
1237 va_start(args, fmt);
1238 vsnprintf(buf,
sizeof(buf), fmt, args);
1270 static int send_command_locked(
unsigned short callno,
char,
int,
unsigned int,
const unsigned char *,
int,
int);
1295 .description =
tdesc,
1338 if (!iaxs[callno] || !iaxs[callno]->owner) {
1369 if (subtype == -1) {
1457 if (!network_change_sub) {
1459 network_change_stasis_cb,
NULL);
1472 if (!acl_change_sub) {
1474 acl_change_stasis_cb,
NULL);
1506 ast_verb(1,
"IAX, got a network change message, renewing all IAX registrations.\n");
1524 .
type =
"IAX2_VARIABLE",
1613 if (iaxdynamicthreadcount >= iaxmaxthreadcount || !(thread =
ast_calloc(1,
sizeof(*thread))))
1652 #ifdef SCHED_MULTITHREADED 1653 static int __schedule_action(
void (*func)(
const void *data),
const void *data,
const char *funcname)
1656 static time_t lasterror;
1660 if (thread !=
NULL) {
1664 #ifdef DEBUG_SCHED_MULTITHREAD 1671 if (t != lasterror) {
1673 ast_debug(1,
"Out of idle IAX2 threads for scheduling! (%s)\n", funcname);
1678 #define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__) 1704 if (!iaxs[callno] || iaxs[callno]->destroy_initiated) {
1705 ast_debug(3,
"I wanted to lock callno %d, but it is dead or going to die.\n", callno);
1721 ast_debug(3,
"Hangup initiated on call %d, aborting __send_ping\n", callno);
1729 if (iaxs[callno]->peercallno) {
1742 #ifdef SCHED_MULTITHREADED 1769 if (!strcasecmp(s,
"aes128"))
1785 ast_debug(3,
"Hangup initiated on call %d, aborting __send_lagrq\n", callno);
1793 if (iaxs[callno]->peercallno) {
1806 #ifdef SCHED_MULTITHREADED 1822 if (subclass & (1LL << x)) {
1854 uint64_t pref_bitfield;
1857 if (!pref_bitfield) {
1873 return found_format;
1876 ast_debug(4,
"Could not find preferred codec - Returning zero codec.\n");
1965 const char *name = obj;
1975 struct iax2_peer *peer = obj, *peer2 = arg;
1976 const char *name = arg;
1978 return !strcmp(peer->
name, flags &
OBJ_KEY ? name : peer2->name) ?
1988 const char *name = obj;
1999 const char *name = arg;
2001 return !strcmp(user->
name, flags &
OBJ_KEY ? name : user2->name) ?
2016 if (!peer && realtime) {
2141 ast_debug(1,
"Really destroying %d now...\n", callno);
2291 memcpy(
new, fr,
sizeof(*
new));
2320 (check_dcallno ? dcallno == cur->
callno : 1) ) {
2338 if (iaxs[callno]->oseqno) {
2370 if (iaxs[x]->callno_entry) {
2383 ping_time * 1000, send_ping, (
void *)(
long)x);
2385 lagrq_time * 1000, send_lagrq, (
void *)(
long)x);
2394 ast_debug(1,
"Made call %d into trunk call %d\n", callno, x);
2402 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2406 ao2_link(iax_transfercallno_pvts, pvt);
2412 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2421 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2425 ao2_link(iax_peercallno_pvts, pvt);
2431 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2471 struct peercnt *peercnt1 = obj, *peercnt2 = arg;
2500 const char *find =
S_OR(name,
"guest");
2534 ast_debug(1,
"Determining if address %s with username %s requires calltoken validation. Optional = %d calltoken_required = %u \n",
ast_sockaddr_stringify_addr(addr), name, optional, calltoken_required);
2561 if (peercnt->
reg && peercnt->
limit) {
2566 limit = addr_range->
limit;
2571 peercnt->
limit = limit;
2583 ast_debug(1,
"Reset limits for peercnts table\n");
2662 if (peercnt->
limit > peercnt->
cur) {
2698 if (peercnt->
cur == 0) {
2743 struct addr_range tmp;
2749 for (; v; v = v->
next) {
2757 ast_log(
LOG_ERROR,
"Call number limit for %s could not be added, Invalid address range\n.", v->
name);
2759 }
else if ((sscanf(v->
value,
"%d", &limit) != 1) || (limit < 0)) {
2770 }
else if (!(addr_range =
ao2_alloc(
sizeof(*addr_range),
NULL))) {
2778 addr_range->
limit = limit;
2779 addr_range->
delme = 0;
2785 ao2_link(callno_limits, addr_range);
2819 addr_range->
delme = 0;
2821 }
else if ((addr_range =
ao2_alloc(
sizeof(*addr_range),
NULL))) {
2824 ao2_link(calltoken_ignores, addr_range);
2845 e->
command =
"iax2 show callnumber usage";
2847 "Usage: iax2 show callnumber usage [IP address]\n" 2848 " Shows current IP addresses which are consuming iax2 call numbers\n";
2857 ast_cli(a->
fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2866 ast_cli(a->
fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2883 ast_cli(a->
fd,
"\nNon-CallToken Validation Callno Limit: %d\n" 2884 "Non-CallToken Validated Callno Used: %d\n",
2885 global_maxcallno_nonval,
2886 total_nonval_callno_used);
2888 ast_cli(a->
fd,
"Total Available Callno: %zu\n" 2889 "Regular Callno Available: %zu\n" 2890 "Trunk Callno Available: %zu\n",
2891 pool_avail + trunk_pool_avail,
2894 }
else if (a->
argc == 5 && !found) {
2895 ast_cli(a->
fd,
"No call number table entries for %s found\n", a->
argv[4] );
2940 if (!validated && total_nonval_callno_used >= global_maxcallno_nonval) {
2942 "NON-CallToken callnumber limit is reached. Current: %d Max: %d\n",
2943 total_nonval_callno_used,
2944 global_maxcallno_nonval);
2965 *entry = pool->
numbers[choice];
2974 total_nonval_callno_used++;
2992 if (total_nonval_callno_used) {
2993 total_nonval_callno_used--;
2996 "Attempted to decrement total non calltoken validated " 2997 "callnumbers below zero. Callno is: %d\n",
3108 static int __find_callno(
unsigned short callno,
unsigned short dcallno,
struct ast_sockaddr *addr,
int new,
int sockfd,
int return_locked,
int check_dcallno)
3114 int validated = (
new >
NEW_ALLOW) ? 1 : 0;
3123 .transfercallno =
callno,
3125 .frames_received = check_dcallno,
3131 if (return_locked) {
3140 memset(&tmp_pvt.
addr, 0,
sizeof(tmp_pvt.
addr));
3143 if (return_locked) {
3157 if (callno && dcallno && iaxs[dcallno] && !iaxs[dcallno]->peercallno &&
match(addr, callno, dcallno, iaxs[dcallno], check_dcallno)) {
3161 if (!res || !return_locked) {
3198 iaxs[x] =
new_iax(addr, host);
3201 ast_debug(1,
"Creating new call structure %d\n", x);
3218 if (iaxs[x]->peercallno) {
3234 static int find_callno(
unsigned short callno,
unsigned short dcallno,
struct ast_sockaddr *addr,
int new,
int sockfd,
int full_frame) {
3235 return __find_callno(callno, dcallno, addr,
new, sockfd, 0, full_frame);
3240 return __find_callno(callno, dcallno, addr,
new, sockfd, 1, full_frame);
3256 if (iaxs[callno] && iaxs[callno]->owner) {
3279 if (iaxs[callno] && iaxs[callno]->owner) {
3302 if (iaxs[callno] && iaxs[callno]->owner) {
3325 if (iaxs[callno] && iaxs[callno]->owner) {
3361 struct sockaddr_in *sin;
3364 struct sock_extended_err e;
3369 m.msg_controllen =
sizeof(e);
3371 res = recvmsg(
netsocket, &m, MSG_ERRQUEUE);
3375 if (m.msg_controllen) {
3376 sin = (
struct sockaddr_in *)SO_EE_OFFENDER(&e);
3408 if (!callno || !iaxs[callno] || iaxs[callno]->error)
3449 if ((c = pvt->
owner)) {
3465 if ((pvt = iaxs[callno])) {
3482 ast_debug(3,
"Avoiding IAX destroy deadlock\n");
3489 iaxs[callno] =
NULL;
3559 if (callno && iaxs[callno]) {
3568 }
else if (f->
final) {
3571 if (iaxs[callno]->owner) {
3572 ast_log(
LOG_WARNING,
"Max retries exceeded to host %s on %s (type = %u, subclass = %d, ts=%u, seqno=%d)\n",
3581 if (iaxs[callno]->owner) {
3586 if (iaxs[callno] && iaxs[callno]->owner)
3589 if (iaxs[callno]->reg) {
3590 memset(&iaxs[callno]->reg->
us, 0,
sizeof(iaxs[callno]->
reg->
us));
3626 }
else if (callno) {
3633 #ifdef SCHED_MULTITHREADED 3644 static const char *
const choices[] = {
"all",
NULL };
3649 e->
command =
"iax2 prune realtime";
3651 "Usage: iax2 prune realtime [<peername>|all]\n" 3652 " Prunes object(s) from the cache\n";
3665 if (!strcmp(a->
argv[3],
"all")) {
3668 ast_cli(a->
fd,
"Cache flushed successfully.\n");
3678 ast_cli(a->
fd,
"Peer %s was removed from the cache.\n", a->
argv[3]);
3680 ast_cli(a->
fd,
"Peer %s is not eligible for this operation.\n", a->
argv[3]);
3687 ast_cli(a->
fd,
"User %s was removed from the cache.\n", a->
argv[3]);
3689 ast_cli(a->
fd,
"User %s is not eligible for this operation.\n", a->
argv[3]);
3695 ast_cli(a->
fd,
"%s was not found in the cache.\n", a->
argv[3]);
3705 e->
command =
"iax2 test losspct";
3707 "Usage: iax2 test losspct <percentage>\n" 3708 " For testing, throws away <percentage> percent of incoming packets\n";
3726 e->
command =
"iax2 test late";
3728 "Usage: iax2 test late <ms>\n" 3729 " For testing, count the next frame as <ms> ms late\n";
3738 test_late = atoi(a->
argv[3]);
3747 e->
command =
"iax2 test resync";
3749 "Usage: iax2 test resync <ms>\n" 3750 " For testing, adjust all future frames by <ms> ms\n";
3759 test_resync = atoi(a->
argv[3]);
3768 e->
command =
"iax2 test jitter";
3770 "Usage: iax2 test jitter <ms> <pct>\n" 3771 " For testing, simulate maximum jitter of +/- <ms> on <pct>\n" 3772 " percentage of packets. If <pct> is not specified, adds\n" 3773 " jitter to all packets.\n";
3782 test_jit = atoi(a->
argv[3]);
3784 test_jitpct = atoi(a->
argv[4]);
3799 snprintf(status, statuslen,
"LAGGED (%d ms)", peer->
lastms);
3801 }
else if (peer->
lastms) {
3802 snprintf(status, statuslen,
"OK (%d ms)", peer->
lastms);
3822 int load_realtime = 0;
3826 e->
command =
"iax2 show peer";
3828 "Usage: iax2 show peer <name>\n" 3829 " Display details on specific IAX peer\n";
3840 load_realtime = (a->
argc == 5 && !strcmp(a->
argv[4],
"load")) ? 1 : 0;
3844 char *str_addr, *str_defaddr;
3845 char *str_port, *str_defport;
3868 ast_cli(a->
fd,
" Addr->IP : %s Port %s\n", str_addr ? str_addr :
"(Unspecified)", str_port);
3869 ast_cli(a->
fd,
" Defaddr->IP : %s Port %s\n", str_defaddr, str_defport);
3874 strcpy(cbuf,
"Error");
3876 ast_cli(a->
fd,
" Codec Order : %s\n", cbuf);
3879 ast_cli(a->
fd,
" Status : %s\n", status);
3896 int wordlen = strlen(word);
3901 if (!strncasecmp(peer->
name, word, wordlen) && ++which > state
3917 int cnt = 0, dead = 0,
final = 0, i = 0;
3921 e->
command =
"iax2 show stats";
3923 "Usage: iax2 show stats\n" 3924 " Display statistics on IAX channel driver.\n";
3946 ast_cli(a->
fd,
"---------------------\n");
3950 ast_cli(a->
fd,
"Packets in transmit queue: %d dead, %d final, %d total\n\n", dead,
final, cnt);
3968 "Usage: iax2 set mtu <value>\n" 3969 " Set the system-wide IAX IP mtu to <value> bytes net or\n" 3970 " zero to disable. Disabling means that the operating system\n" 3971 " must handle fragmentation of UDP packets when the IAX2 trunk\n" 3972 " packet exceeds the UDP payload size. This is substantially\n" 3973 " below the IP mtu. Try 1240 on ethernets. Must be 172 or\n" 3974 " greater for G.711 samples.\n";
3982 if (strncasecmp(a->
argv[3],
"default", strlen(a->
argv[3])) == 0)
3985 mtuv = atoi(a->
argv[3]);
3992 if (mtuv < 172 || mtuv > 4000) {
3993 ast_cli(a->
fd,
"Trunk MTU must be between 172 and 4000\n");
4010 e->
command =
"iax2 show cache";
4012 "Usage: iax2 show cache\n" 4013 " Display currently cached IAX Dialplan results.\n";
4021 ast_cli(a->
fd,
"%-20.20s %-12.12s %-9.9s %-8.8s %s\n",
"Peer/Context",
"Exten",
"Exp.",
"Wait.",
"Flags");
4024 s = dp->
expiry.tv_sec - now.tv_sec;
4027 strncat(tmp,
"EXISTS|",
sizeof(tmp) - strlen(tmp) - 1);
4029 strncat(tmp,
"NONEXISTENT|",
sizeof(tmp) - strlen(tmp) - 1);
4031 strncat(tmp,
"CANEXIST|",
sizeof(tmp) - strlen(tmp) - 1);
4033 strncat(tmp,
"PENDING|",
sizeof(tmp) - strlen(tmp) - 1);
4035 strncat(tmp,
"TIMEOUT|",
sizeof(tmp) - strlen(tmp) - 1);
4037 strncat(tmp,
"TRANSMITTED|",
sizeof(tmp) - strlen(tmp) - 1);
4039 strncat(tmp,
"MATCHMORE|",
sizeof(tmp) - strlen(tmp) - 1);
4041 strncat(tmp,
"UNKNOWN|",
sizeof(tmp) - strlen(tmp) - 1);
4044 tmp[strlen(tmp) - 1] =
'\0';
4060 ast_cli(a->
fd,
"%-20.20s %-12.12s %-9d %-8d %s\n", pc, dp->
exten, s, y, tmp);
4062 ast_cli(a->
fd,
"%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->
exten,
"(expired)", y, tmp);
4078 const int lower_mask = (1 << ts_shift) - 1;
4079 const int upper_mask = ~lower_mask;
4080 const int last_upper = iaxs[fr->
callno]->
last & upper_mask;
4082 if ( (fr->
ts & upper_mask) == last_upper ) {
4084 const int threshold = (ts_shift == 15) ? 25000 : 50000;
4086 if (x < -threshold) {
4091 fr->
ts = (last_upper + (1 << ts_shift)) | (fr->
ts & lower_mask);
4093 ast_debug(1,
"schedule_delivery: pushed forward timestamp\n");
4094 }
else if (x > threshold) {
4099 fr->
ts = (last_upper - (1 << ts_shift)) | (fr->
ts & lower_mask);
4101 ast_debug(1,
"schedule_delivery: pushed back timestamp\n");
4150 now.tv_usec += 1000;
4173 af.
src =
"IAX2 JB interpolation";
4205 #ifdef SCHED_MULTITHREADED 4241 ast_debug(1,
"schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
4266 calc_rxstamp(iaxs[fr->
callno],fr->
ts));
4330 0, 0, (
unsigned char *)text, strlen(text) + 1, -1);
4364 time_t regseconds = 0, nowtime;
4366 char *str_addr, *str_port;
4380 for (tmp = var;
tmp; tmp = tmp->
next) {
4381 if (!strcasecmp(tmp->
name,
"name"))
4382 peername = tmp->
value;
4386 if (!var && peername) {
4395 for (tmp = var;
tmp; tmp = tmp->
next) {
4396 if (!strcasecmp(tmp->
name,
"host")) {
4421 for (tmp = var;
tmp; tmp = tmp->
next) {
4423 if (!strcasecmp(tmp->
name,
"type")) {
4424 if (strcasecmp(tmp->
value,
"friend") &&
4425 strcasecmp(tmp->
value,
"peer")) {
4430 }
else if (!strcasecmp(tmp->
name,
"regseconds")) {
4432 }
else if (!strcasecmp(tmp->
name,
"ipaddr")) {
4440 }
else if (!strcasecmp(tmp->
name,
"port")) {
4446 }
else if (!strcasecmp(tmp->
name,
"host")) {
4447 if (!strcasecmp(tmp->
value,
"dynamic"))
4477 memset(&peer->
addr, 0,
sizeof(peer->
addr));
4479 ast_debug(1,
"realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
4480 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4483 ast_debug(1,
"realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
4484 peername, (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
4496 char *str_addr, *str_port;
4518 for (tmp = var;
tmp; tmp = tmp->
next) {
4519 if (!strcasecmp(tmp->
name,
"host")) {
4540 if (!strcasecmp(tmp->
name,
"type")) {
4541 if (strcasecmp(tmp->
value,
"friend") &&
4542 strcasecmp(tmp->
value,
"user")) {
4568 char regseconds[20];
4570 char *syslabel =
NULL;
4576 syslabel =
"regserver";
4578 snprintf(regseconds,
sizeof(regseconds),
"%d", (
int)regtime);
4583 "regseconds", regseconds, syslabel, sysname,
SENTINEL);
4701 key = strchr(family,
'/');
4730 iaxs[callno]->
initid = -1;
4739 #ifdef SCHED_MULTITHREADED 4752 tmp = (tm.
tm_sec >> 1) & 0x1f;
4753 tmp |= (tm.
tm_min & 0x3f) << 5;
4754 tmp |= (tm.
tm_hour & 0x1f) << 11;
4755 tmp |= (tm.
tm_mday & 0x1f) << 16;
4756 tmp |= ((tm.
tm_mon + 1) & 0xf) << 21;
4757 tmp |= ((tm.
tm_year - 100) & 0x7f) << 25;
4773 struct ast_sockaddr *addr,
int command,
int ts,
unsigned char seqno,
4784 memcpy(&data.ied, ied->
buf, ied->
pos);
4787 data.f.scallno = htons(0x8000 | callno);
4789 data.f.ts = htonl(ts);
4790 data.f.iseqno = seqno;
4797 return ast_sendto(sockfd, &data, size, 0, addr);
4803 if (pvt && ied && (2 < ((
int)
sizeof(ied->
buf) - ied->
pos))) {
4805 ied->
buf[ied->
pos++] = 0;
4842 (f->
datalen >
sizeof(data))) {
4862 data.ied.pos = ie_data_pos;
4935 #define CALLTOKEN_HASH_FORMAT "%s%u%d" 4936 #define CALLTOKEN_IE_FORMAT "%u?%s" 4938 time_t t = time(
NULL);
4961 char *rec_hash =
NULL;
4962 char *rec_ts =
NULL;
4963 unsigned int rec_time;
4973 if (!rec_hash || !rec_ts) {
4975 }
else if (sscanf(rec_ts,
"%u", &rec_time) != 1) {
4984 if (strcmp(hash, rec_hash)) {
4987 }
else if ((t < rec_time) || ((t - rec_time) >= max_calltoken_delay)) {
5050 if (strchr(pds->
peer,
'@')) {
5081 char *defaultrdest =
"s";
5087 const char* osp_token_ptr;
5088 unsigned int osp_token_length;
5089 unsigned char osp_block_index;
5090 unsigned int osp_block_length;
5091 unsigned char osp_buffer[256];
5092 char encoded_prefs[32];
5100 memset(&cai, 0,
sizeof(cai));
5104 memset(&pds, 0,
sizeof(pds));
5113 pds.
exten = defaultrdest;
5157 memset(&ied, 0,
sizeof(ied));
5241 if (iaxs[callno]->maxtime) {
5254 osp_block_index = 0;
5255 while (osp_token_length > 0) {
5257 osp_buffer[0] = osp_block_index;
5258 memcpy(osp_buffer + 1, osp_token_ptr, osp_block_length);
5261 osp_token_ptr += osp_block_length;
5262 osp_token_length -= osp_block_length;
5267 ast_debug(1,
"OSP token is undefined\n");
5273 if (variablestore) {
5275 ast_debug(1,
"Found an IAX variable store on this channel\n");
5305 memset(&ied, 0,
sizeof(ied));
5307 if (callno && iaxs[callno]) {
5312 if (!iaxs[callno]->error && !alreadygone) {
5316 if (!iaxs[callno]) {
5324 if (iaxs[callno] && alreadygone) {
5327 }
else if (iaxs[callno]) {
5329 ast_log(
LOG_ERROR,
"Unable to schedule iax2 callno %d destruction?!! Destroying immediately.\n", callno);
5350 unsigned short callno = pvt->
callno;
5386 if ((*(
int *) data)) {
5418 if (!(h =
ast_malloc(datalen +
sizeof(*h)))) {
5423 h->option = htons(option);
5424 memcpy(h->
data, data, datalen);
5427 datalen +
sizeof(*h), -1);
5458 ast_debug(1,
"I should never be called!\n");
5475 snprintf(key,
sizeof(key),
"%lX", (
unsigned long)
ast_random());
5478 MD5Update(&md5, (
unsigned char *) key, strlen(key));
5479 MD5Final((
unsigned char *) key, &md5);
5494 #if defined(IAX2_NATIVE_BRIDGING) 5495 static int iax2_start_transfer(
unsigned short callno0,
unsigned short callno1,
int mediaonly)
5500 unsigned int transferid = (
unsigned int)
ast_random();
5503 ast_debug(1,
"transfers are not supported for encrypted calls at this time\n");
5509 memset(&ied0, 0,
sizeof(ied0));
5514 memset(&ied1, 0,
sizeof(ied1));
5531 #if defined(IAX2_NATIVE_BRIDGING) 5532 static void lock_both(
unsigned short callno0,
unsigned short callno1)
5541 #if defined(IAX2_NATIVE_BRIDGING) 5542 static void unlock_both(
unsigned short callno0,
unsigned short callno1)
5549 #if defined(IAX2_NATIVE_BRIDGING) 5556 int transferstarted=0;
5560 struct timeval waittimer = {0, 0};
5563 if (timeoutms > 0) {
5569 lock_both(callno0, callno1);
5570 if (!iaxs[callno0] || !iaxs[callno1]) {
5571 unlock_both(callno0, callno1);
5579 unlock_both(callno0, callno1);
5587 ast_verb(3,
"Can't masquerade, we're different...\n");
5605 ast_verb(3,
"Operating with different codecs [%s] [%s] , can't native bridge...\n",
5610 lock_both(callno0, callno1);
5615 unlock_both(callno0, callno1);
5624 transferstarted = 1;
5647 if (timeoutms > -1) {
5648 timeoutms -= (1000 - to);
5670 other = (who == c0) ? c1 : c0;
5702 if (flags & monitored_source) {
5717 lock_both(callno0, callno1);
5722 unlock_both(callno0, callno1);
5741 ast_debug(1,
"Indicating condition %d\n", condition);
5751 switch (condition) {
5768 ast_debug(2,
"Callno %d: Config blocked sending control frame %d.\n",
5794 context = strchr(tmp,
'@');
5831 const struct ast_channel *requestor,
unsigned int cachable)
5840 char *peer_name =
NULL;
5842 if (!(i = iaxs[callno])) {
5890 if (i != iaxs[callno]) {
5908 if ((callid = iaxs[callno]->callid)) {
5929 ast_channel_parkinglot_set(tmp, i->
parkinglot);
5949 ast_channel_language_set(tmp, i->
language);
5969 for (v = i->
vars ; v ; v = v->
next)
5976 ast_debug(1,
"Loading up the channel with IAXVARs\n");
5979 if (variablestore && varlist) {
5980 variablestore->
data = varlist;
5990 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
6000 if (variablestore) {
6029 unsigned long int mssincetx;
6056 static unsigned int fix_peerts(
struct timeval *rxtrunktime,
int callno,
unsigned int ts)
6063 iaxs[callno]->
rxcore.tv_usec -= iaxs[callno]->
rxcore.tv_usec % 20000;
6078 struct timeval *delivery =
NULL;
6141 else if (adjust > 0)
6161 ast_debug(1,
"predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
6166 int diff = ms % (f->
samples / rate);
6183 if ( (
unsigned int)ms < p->
lastsent )
6191 if (ms <= p->lastsent)
6218 ast_debug(1,
"calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %ums\n",
6223 ast_debug(1,
"calc_rxstamp: call=%d: works out as %d.%6.6d\n",
6231 if (!test_jitpct || ((100.0 *
ast_random() / (RAND_MAX + 1.0)) < test_jitpct)) {
6232 jit = (int)((
float)test_jit *
ast_random() / (RAND_MAX + 1.0));
6233 if ((
int)(2.0 *
ast_random() / (RAND_MAX + 1.0)))
6261 if ((tpeer =
ast_calloc(1,
sizeof(*tpeer)))) {
6270 setsockopt(tpeer->
sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums,
sizeof(nochecksums));
6319 mtm->
mini.
ts = htons(0xffff & fr->
ts);
6359 memcpy(buf, (
unsigned char *) &tmp, (len >
sizeof(tmp)) ?
sizeof(tmp) : len);
6389 dst[x] = src[x] ^ 0xff;
6391 unsigned char lastblock[16] = { 0 };
6396 dst[x] ^= lastblock[x];
6397 memcpy(lastblock, src,
sizeof(lastblock));
6413 dst[x] = src[x] ^ 0xff;
6415 unsigned char curblock[16] = { 0 };
6419 curblock[x] ^= src[x];
6421 memcpy(curblock, dst,
sizeof(curblock));
6432 unsigned char *workspace;
6435 memset(f, 0,
sizeof(*f));
6443 padding = 16 + (workspace[15] & 0x0f);
6445 ast_debug(1,
"Decoding full frame with length %d (padding = %d) (15=%02hhx)\n", *datalen, padding, workspace[15]);
6449 *datalen -= padding;
6462 ast_debug(1,
"Decoding mini with length %d\n", *datalen);
6467 padding = 16 + (workspace[15] & 0x0f);
6470 *datalen -= padding;
6479 unsigned char *workspace;
6484 ast_debug(1,
"Encoding full frame %d/%d with length %d\n", fh->
type, fh->
csub, *datalen);
6486 padding = 16 + (padding & 0xf);
6487 memcpy(workspace, poo, padding);
6489 workspace[15] &= 0xf0;
6490 workspace[15] |= (padding & 0xf);
6492 ast_debug(1,
"Encoding full frame %d/%d with length %d + %d padding (15=%02hhx)\n", fh->
type, fh->
csub, *datalen, padding, workspace[15]);
6493 *datalen += padding;
6496 memcpy(poo, workspace + *datalen - 32, 32);
6500 ast_debug(1,
"Encoding mini frame with length %d\n", *datalen);
6502 padding = 16 + (padding & 0xf);
6503 memcpy(workspace, poo, padding);
6505 workspace[15] &= 0xf0;
6506 workspace[15] |= (padding & 0x0f);
6507 *datalen += padding;
6510 memcpy(poo, workspace + *datalen - 32, 32);
6521 unsigned char digest[16];
6522 char *tmppw, *stringp;
6526 while ((tmppw =
strsep(&stringp,
";"))) {
6529 MD5Update(&md5, (
unsigned char *)tmppw, strlen(tmppw));
6532 res =
decode_frame(&iaxs[callno]->dcx, fh, f, datalen);
6539 res =
decode_frame(&iaxs[callno]->dcx, fh, f, datalen);
6553 unsigned char buffer[4096];
6558 unsigned int lastsent;
6580 "f->frametype %c= AST_FRAME_VOICE, %sencrypted, %srotation scheduled...\n",
6591 (((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
6592 ((fts & 0xFFFF0000L) == ((lastsent + 0x10000) & 0xFFFF0000L))))
6610 if (((fts & 0xFFFF8000L) == (pvt->
lastvsent & 0xFFFF8000L)) &&
6655 fh->
ts = htonl(fr->
ts);
6739 mh->
ts = htons(fr->
ts & 0xFFFF);
6760 int havepattern = 0;
6762 #define FORMAT "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n" 6763 #define FORMAT2 "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n" 6772 e->
command =
"iax2 show users [like]";
6774 "Usage: iax2 show users [like <pattern>]\n" 6775 " Lists all known IAX2 users.\n" 6776 " Optional regular expression pattern is used to filter the user list.\n";
6784 if (!strcasecmp(a->
argv[3],
"like")) {
6785 if (regcomp(®exbuf, a->
argv[4], REG_EXTENDED | REG_NOSUB))
6796 ast_cli(a->
fd,
FORMAT,
"Username",
"Secret",
"Authen",
"Def.Context",
"A/C",
"Codec Pref");
6799 if (havepattern && regexec(®exbuf, user->
name, 0,
NULL, 0))
6805 snprintf(auth,
sizeof(auth),
"Key: %-15.15s ", user->
inkeys);
6842 #define PEERS_FORMAT2 "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n" 6843 #define PEERS_FORMAT "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n" 6847 char name[256] =
"";
6852 char *tmp_host, *tmp_mask, *tmp_port;
6859 snprintf(name,
sizeof(name),
"%s/%s", peer->
name, peer->
username);
6865 retstatus =
peer_status(peer, status,
sizeof(status));
6866 if (retstatus > 0) {
6868 }
else if (!retstatus) {
6877 "Event: PeerEntry\r\n%s" 6878 "Channeltype: IAX\r\n",
6882 "ObjectName: %s\r\n" 6883 "ObjectUsername: %s\r\n",
6888 "ObjectName: %s\r\n",
6893 "Event: PeerEntry\r\n%s" 6894 "Channeltype: IAX2\r\n" 6895 "ObjectName: %s\r\n",
6900 "ChanObjectType: peer\r\n" 6901 "IPaddress: %s\r\n",
6917 "Encryption: %s\r\n" 6927 "Description: %s\r\n\r\n",
6951 .registeredonly = 0,
6958 .unmonitored_peers = 0,
6967 if (!strcasecmp(argv[3],
"registered"))
6971 if (!strcasecmp(argv[4],
"like")) {
6972 if (regcomp(&cont.
regexbuf, argv[5], REG_EXTENDED | REG_NOSUB))
6979 if (!strcasecmp(argv[3],
"like")) {
6980 if (regcomp(&cont.
regexbuf, argv[4], REG_EXTENDED | REG_NOSUB))
6987 if (!strcasecmp(argv[3],
"registered")) {
7001 ast_cli(fd,
PEERS_FORMAT2,
"Name/Username",
"Host",
" ",
"Mask",
"Port",
" ",
"Status",
"Description");
7020 ast_cli(fd,
"%d iax2 peers [%d online, %d offline, %d unmonitored]\n",
7035 #undef PEERS_FORMAT2 7042 int threadcount = 0, dynamiccount = 0;
7047 e->
command =
"iax2 show threads";
7049 "Usage: iax2 show threads\n" 7050 " Lists status of IAX helper threads\n";
7058 ast_cli(a->
fd,
"IAX2 Thread Information\n");
7063 #ifdef DEBUG_SCHED_MULTITHREAD 7064 ast_cli(a->
fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7067 ast_cli(a->
fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7080 #ifdef DEBUG_SCHED_MULTITHREAD 7081 ast_cli(a->
fd,
"Thread %c%d: state=%u, update=%d, actions=%d, func='%s'\n",
7084 ast_cli(a->
fd,
"Thread %c%d: state=%u, update=%d, actions=%d\n",
7093 #ifdef DEBUG_SCHED_MULTITHREAD 7094 ast_cli(a->
fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7097 ast_cli(a->
fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7103 ast_cli(a->
fd,
"%d of %d threads accounted for with %d dynamic threads\n", threadcount, iaxthreadcount, dynamiccount);
7113 e->
command =
"iax2 unregister";
7115 "Usage: iax2 unregister <peername>\n" 7116 " Unregister (force expiration) an IAX2 peer from the registry.\n";
7143 ast_cli(a->
fd,
"Peer unknown: %s. Not unregistered\n", a->
argv[2]);
7153 int wordlen = strlen(word);
7159 if (!strncasecmp(p->
name, word, wordlen) &&
7160 ++which > state && p->
expire > -1) {
7177 e->
command =
"iax2 show peers";
7179 "Usage: iax2 show peers [registered] [like <pattern>]\n" 7180 " Lists all known IAX2 peers.\n" 7181 " Optional 'registered' argument lists only peers with known addresses.\n" 7182 " Optional regular expression pattern is used to filter the peer list.\n";
7208 int *fd = user_data;
7210 ast_cli(*fd,
"%-15.15s %-15d %-15d\n",
7213 (
int) ntohl(header->
datalen));
7222 e->
command =
"iax2 show firmware";
7224 "Usage: iax2 show firmware\n" 7225 " Lists all known IAX firmware images.\n";
7234 ast_cli(a->
fd,
"%-15.15s %-15.15s %-15.15s\n",
"Device",
"Version",
"Size");
7247 static const char *
const a[] = {
"iax2",
"show",
"peers" };
7249 char idtext[256] =
"";
7253 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7272 .registeredonly = 0,
7279 .unmonitored_peers = 0,
7288 snprintf(cont.
idtext,
sizeof(cont.
idtext),
"ActionID: %s\r\n",
id);
7310 return "Unregistered";
7312 return "Request Sent";
7314 return "Auth. Sent";
7316 return "Registered";
7322 return "No Authentication";
7330 #define FORMAT2 "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n" 7331 #define FORMAT "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n" 7340 e->
command =
"iax2 show registry";
7342 "Usage: iax2 show registry\n" 7343 " Lists all registration requests and status.\n";
7350 ast_cli(a->
fd,
FORMAT2,
"Host",
"dnsmgr",
"Username",
"Perceived",
"Refresh",
"State");
7358 (reg->
dnsmgr) ?
"Y" :
"N",
7363 ast_cli(a->
fd,
"%d IAX2 registrations.\n", counter);
7373 char idtext[256] =
"";
7375 char perceived[80] =
"";
7379 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7390 "Event: RegistryEntry\r\n" 7393 "DNSmanager: %s\r\n" 7398 "\r\n", idtext, host, (reg->
dnsmgr) ?
"Y" :
"N", reg->
username, perceived,
7413 #define FORMAT2 "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n" 7414 #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" 7415 #define FORMATB "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n" 7418 char first_message[10] = { 0, };
7419 char last_message[10] = { 0, };
7423 e->
command =
"iax2 show channels";
7425 "Usage: iax2 show channels\n" 7426 " Lists all currently active IAX channels.\n";
7434 ast_cli(a->
fd,
FORMAT2,
"Channel",
"Peer",
"Username",
"ID (Lo/Rem)",
"Seq (Tx/Rx)",
"Lag",
"Jitter",
"JitBuf",
"Format",
"FirstMsg",
"LastMsg");
7438 int lag, jitter, localdelay;
7456 iaxs[x]->callno, iaxs[x]->peercallno,
7457 iaxs[x]->oseqno, iaxs[x]->iseqno,
7464 (iaxs[x]->last_iax_message & MARK_IAX_SUBCLASS_TX) ?
"Tx:" :
"Rx:",
7470 ast_cli(a->
fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7481 char first_message[10] = { 0, };
7482 char last_message[10] = { 0, };
7483 #define ACN_FORMAT1 "%-20.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n" 7484 #define ACN_FORMAT2 "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n" 7488 int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
7495 localjitter = jbinfo.
jitter;
7498 locallosspct = jbinfo.
losspct/1000;
7519 iaxs[x]->frames_received/1000,
7520 iaxs[x]->remote_rr.jitter,
7541 iaxs[x]->frames_received/1000,
7542 iaxs[x]->remote_rr.jitter,
7567 e->
command =
"iax2 show netstats";
7569 "Usage: iax2 show netstats\n" 7570 " Lists network status for all currently active IAX channels.\n";
7577 ast_cli(a->
fd,
" -------- LOCAL --------------------- -------- REMOTE --------------------\n");
7578 ast_cli(a->
fd,
"Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts FirstMsg LastMsg\n");
7580 ast_cli(a->
fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7588 e->
command =
"iax2 set debug {on|off|peer}";
7590 "Usage: iax2 set debug {on|off|peer peername}\n" 7591 " Enables/Disables dumping of IAX packets for debugging purposes.\n";
7594 if (a->
pos == 4 && !strcasecmp(a->
argv[3],
"peer"))
7602 if (!strcasecmp(a->
argv[3],
"peer")) {
7620 }
else if (!strncasecmp(a->
argv[3],
"on", 2)) {
7622 ast_cli(a->
fd,
"IAX2 Debugging Enabled\n");
7626 ast_cli(a->
fd,
"IAX2 Debugging Disabled\n");
7635 e->
command =
"iax2 set debug trunk {on|off}";
7637 "Usage: iax2 set debug trunk {on|off}\n" 7638 " Enables/Disables debugging of IAX trunking\n";
7647 if (!strncasecmp(a->
argv[e->
args - 1],
"on", 2)) {
7649 ast_cli(a->
fd,
"IAX2 Trunk Debugging Enabled\n");
7652 ast_cli(a->
fd,
"IAX2 Trunk Debugging Disabled\n");
7661 e->
command =
"iax2 set debug jb {on|off}";
7663 "Usage: iax2 set debug jb {on|off}\n" 7664 " Enables/Disables jitterbuffer debugging information\n";
7673 if (!strncasecmp(a->
argv[e->
args -1],
"on", 2)) {
7675 ast_cli(a->
fd,
"IAX2 Jitterbuffer Debugging Enabled\n");
7678 ast_cli(a->
fd,
"IAX2 Jitterbuffer Debugging Disabled\n");
7690 if (!iaxs[callno]->error) {
7702 res =
iax2_send(iaxs[callno], f, 0, -1, 0, 0, 0);
7713 int now,
int transfer,
int final)
7721 f.
src = __FUNCTION__;
7728 return iax2_send(i, &f, ts, seqno, now, transfer,
final);
7731 static int send_command(
struct chan_iax2_pvt *i,
char type,
int command,
unsigned int ts,
const unsigned char *data,
int datalen,
int seqno)
7735 ast_debug(2,
"Callno %d: Blocked sending control frame %d.\n",
7739 return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 0);
7742 static int send_command_locked(
unsigned short callno,
char type,
int command,
unsigned int ts,
const unsigned char *data,
int datalen,
int seqno)
7746 res =
send_command(iaxs[callno], type, command, ts, data, datalen, seqno);
7758 int call_num = i->
callno;
7761 if (!iaxs[call_num])
7763 return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 1);
7768 return __send_command(i, type, command, ts, data, datalen, seqno, 1, 0, 0);
7773 return __send_command(i, type, command, ts, data, datalen, 0, 0, 1, 0);
7779 if (!strcmp(con->
context, context) || !strcmp(con->
context,
"*"))
7794 int gotcapability = 0;
7843 memset(&iaxs[callno]->rprefs, 0,
sizeof(iaxs[callno]->rprefs));
7847 if (!gotcapability) {
7859 !strcmp(iaxs[callno]->username, user->
name))
7873 if (bestscore < 4) {
7882 if (bestscore < 3) {
7893 if (bestscore < 2) {
7902 if (bestscore < 1) {
7927 for (v = user->
vars ; v ; v = v->
next) {
7930 tmpvar->next = iaxs[callno]->
vars;
7931 iaxs[callno]->
vars = tmpvar;
7985 char *family, *key=
NULL;
7988 key = strchr(family,
'/');
7993 if (!key ||
ast_db_get(family, key, buf,
sizeof(buf)))
8031 return ast_sendto(sockfd, &fh,
sizeof(fh), 0, addr);
8058 int res = -1, authreq_restrict = 0;
8062 memset(&ied, 0,
sizeof(ied));
8071 authreq_restrict = 1;
8079 if (authreq_restrict) {
8088 snprintf(challenge,
sizeof(challenge),
"%d", (
int)
ast_random());
8108 char requeststr[256];
8109 char md5secret[256] =
"";
8111 char rsasecret[256] =
"";
8130 ast_log(
LOG_NOTICE,
"Call Terminated, Incoming call is unencrypted while force encrypt is enabled.\n");
8147 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8151 keyn =
strsep(&stringp,
":");
8158 ast_log(
LOG_WARNING,
"requested inkey '%s' for RSA authentication does not exist\n", keyn);
8159 keyn =
strsep(&stringp,
":");
8164 unsigned char digest[16];
8165 char *tmppw, *stringp;
8168 while((tmppw =
strsep(&stringp,
";"))) {
8171 MD5Update(&md5, (
unsigned char *)tmppw, strlen(tmppw));
8175 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8176 if (!strcasecmp(requeststr, md5secret)) {
8182 if (!strcmp(secret, p->
secret))
8191 char requeststr[256] =
"";
8192 char peer[256] =
"";
8193 char md5secret[256] =
"";
8194 char rsasecret[256] =
"";
8195 char secret[256] =
"";
8225 if (!p || !iaxs[callno]) {
8269 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8273 keyn =
strsep(&stringp,
":");
8281 keyn =
strsep(&stringp,
":");
8291 ast_log(
LOG_NOTICE,
"Host '%s' trying to do RSA authentication, but we have no inkeys\n", peer);
8296 unsigned char digest[16];
8297 char *tmppw, *stringp;
8301 while((tmppw =
strsep(&stringp,
";"))) {
8304 MD5Update(&md5, (
unsigned char *)tmppw, strlen(tmppw));
8307 sprintf(requeststr + (x << 1),
"%02hhx", digest[x]);
8308 if (!strcasecmp(requeststr, md5secret))
8320 if (strcmp(secret, p->
secret)) {
8340 if (expire && (expire < iaxs[callno]->expiry)) {
8341 iaxs[callno]->
expiry = expire;
8369 if (
ast_sign(key, (
char*)challenge, sig)) {
8384 unsigned char digest[16];
8387 MD5Update(&md5, (
unsigned char *)challenge, strlen(challenge));
8388 MD5Update(&md5, (
unsigned char *)secret, strlen(secret));
8392 sprintf(digres + (x << 1),
"%02hhx", digest[x]);
8418 uint16_t callno = p->
callno;
8420 memset(&ied, 0,
sizeof(ied));
8472 if (!(p = iaxs[callno])) {
8481 if (!(p = iaxs[callno]))
8490 ast_log(
LOG_WARNING,
"Call terminated. Encryption requested by peer but no secret available locally\n");
8495 ast_log(
LOG_NOTICE,
"Call initiated without encryption while forceencryption=yes option is set\n");
8504 if (variablestore && varlist && p->
owner) {
8505 variablestore->
data = varlist;
8508 for (var = ies->
vars; var; var = var->
next) {
8515 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8526 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8561 #ifdef SCHED_MULTITHREADED 8574 memset(&ied, 0,
sizeof(ied));
8604 char exten[256] =
"";
8625 if (strcmp(dp->
exten, exten))
8638 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
8657 peercallno = ies->
callno;
8659 if (peercallno < 1) {
8720 char peer[256] =
"";
8723 char ourip[256] =
"<Unspecified>";
8740 reg = iaxs[callno]->
reg;
8764 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new and %d old messages waiting", reg->
messages & 0xff, reg->
messages >> 8);
8766 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new messages waiting", reg->
messages);
8768 ast_copy_string(msgstatus,
" with 1 new message waiting",
sizeof(msgstatus));
8770 ast_copy_string(msgstatus,
" with no messages waiting",
sizeof(msgstatus));
8783 const char *secret,
const char *porta)
8787 if (!(reg =
ast_calloc(1,
sizeof(*reg) + strlen(hostname) + 1))) {
8809 if (!porta && !reg->
port) {
8812 sscanf(porta,
"%5d", ®->
port);
8836 username =
strsep(&stringp,
"@");
8837 hostname =
strsep(&stringp,
"@");
8840 ast_log(
LOG_WARNING,
"Format for registration is user[:secret]@host[:port] at line %d\n", lineno);
8845 username =
strsep(&stringp,
":");
8846 secret =
strsep(&stringp,
":");
8848 hostname =
strsep(&stringp,
":");
8849 porta =
strsep(&stringp,
":");
8851 if (porta && !atoi(porta)) {
8863 char *stringp, *
ext;
8867 while((ext =
strsep(&stringp,
"&"))) {
8905 if (peer->
expire == -1) {
8912 ast_debug(1,
"Expiring registration for peer '%s'\n", peer->
name);
8917 "peer_status",
"Unregistered",
8918 "cause",
"Expired");
8941 #ifdef SCHED_MULTITHREADED 8957 expiry = strrchr(data,
':');
8969 p->
expiry = atoi(expiry);
9013 const char *peer_name;
9045 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9049 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9075 ast_verb(3,
"Registered IAX2 '%s' (%s) at %s\n",
9081 "peer_status",
"Registered",
9082 "address", str_addr,
9087 ast_verb(3,
"Unregistered IAX2 '%s' (%s)\n",
9092 "peer_status",
"Unregistered");
9111 if (!iaxs[callno]) {
9159 msgcount = (old << 8) |
new;
9185 const char *peer_name;
9200 memset(&ied, 0,
sizeof(ied));
9214 snprintf(challenge,
sizeof(challenge),
"%d", (
int)
ast_random());
9233 char peer[256] =
"";
9236 int authmethods = 0;
9243 memset(&ied, 0,
sizeof(ied));
9244 reg = iaxs[callno]->
reg;
9258 if (reg->
secret[0] ==
'[') {
9261 tmpkey[strlen(tmpkey) - 1] =
'\0';
9285 int callno = (int)(
long)(nothing);
9289 memset(&ied, 0,
sizeof(ied));
9304 int callno = (int)(
long)(
data);
9307 iaxs[callno]->
authid = -1;
9309 #ifdef SCHED_MULTITHREADED 9334 int callno = (int)(
long)(nothing);
9338 memset(&ied, 0,
sizeof(ied));
9348 int callno = (int)(
long)(
data);
9351 iaxs[callno]->
autoid = -1;
9354 #ifdef SCHED_MULTITHREADED 9367 memset(&ied, 0,
sizeof(ied));
9384 if (((
unsigned char) (f->
oseqno - last) < 128) &&
9402 #ifdef SCHED_MULTITHREADED 9439 calls = tpeer->
calls;
9455 if (now->tv_sec > tpeer->
trunkact.tv_sec + 5)
9494 ast_verbose(
" - Trunk peer (%s) has %d call chunk%s in transit, %u bytes backloged and has hit a high water mark of %u bytes\n",
9497 (res != 1) ?
"s" :
"",
9514 if (drop->trunkdata) {
9516 drop->trunkdata =
NULL;
9524 ast_verbose(
"Ending trunk processing with %d peers and %d call chunks processed\n", processed,
totalcalls);
9538 static void dp_lookup(
int callno,
const char *
context,
const char *callednum,
const char *callerid,
int skiplock)
9540 unsigned short dpstatus = 0;
9544 memset(&ied1, 0,
sizeof(ied1));
9583 pthread_t newthread;
9601 unsigned int ourver;
9603 snprintf(rsi,
sizeof(rsi),
"si-%s", si);
9606 ast_debug(1,
"Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
9617 memset(iep, 0,
sizeof(*iep));
9642 unsigned int length, offset = 0;
9653 memcpy(full_osptoken + offset, ies->
osptokenblock[i], length);
9660 *(full_osptoken + offset) =
'\0';
9661 if (strlen(full_osptoken) != offset) {
9663 *full_osptoken =
'\0';
9671 int localjitter = -1, localdelay = 0, locallost = -1, locallosspct = -1, localdropped = 0, localooo = -1, localpackets = -1;
9675 if (iaxs[callno] && iaxs[callno]->owner &&
ast_channel_name(iaxs[callno]->owner)) {
9678 localjitter = jbinfo.
jitter;
9681 locallosspct = jbinfo.
losspct/1000;
9686 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",
9688 iaxs[callno]->pingtime,
9696 iaxs[callno]->remote_rr.jitter,
9721 thread->
buf = pkt_buf->
buf;
9751 memcpy(pkt_buf->
buf, from_here->
buf, pkt_buf->
len);
9777 static time_t last_errtime = 0;
9782 if (t != last_errtime) {
9784 ast_debug(1,
"Out of idle IAX2 threads for I/O, pausing!\n");
9795 if (
errno != ECONNREFUSED &&
errno != EAGAIN)
9843 #ifdef DEBUG_SCHED_MULTITHREAD 9854 unsigned char metatype;
9861 struct timeval rxtrunktime;
9864 if (packet_len <
sizeof(*meta)) {
9865 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a meta frame but is too short\n",
9873 if (packet_len < (
sizeof(*meta) +
sizeof(*mth))) {
9874 ast_log(
LOG_WARNING,
"midget meta trunk packet received (%d of %d min)\n", packet_len,
9875 (
int) (
sizeof(*meta) +
sizeof(*mth)));
9879 ts = ntohl(mth->
ts);
9881 packet_len -= (
sizeof(*meta) +
sizeof(*mth));
9885 ast_log(
LOG_WARNING,
"Unable to accept trunked packet from '%s': No matching peer\n",
9894 while (packet_len >=
sizeof(*mte)) {
9896 unsigned short callno, trunked_ts,
len;
9900 ptr +=
sizeof(*mtm);
9901 packet_len -=
sizeof(*mtm);
9902 len = ntohs(mtm->
len);
9904 trunked_ts = ntohs(mtm->
mini.
ts);
9907 ptr +=
sizeof(*mte);
9908 packet_len -=
sizeof(*mte);
9909 len = ntohs(mte->
len);
9910 callno = ntohs(mte->
callno);
9917 if (len > packet_len)
9926 memset(&f, 0,
sizeof(f));
9942 fr->
ts = (iaxs[fr->
callno]->
last & 0xFFFF0000L) | (trunked_ts & 0xffff);
9989 if (!variablestore) {
9993 varlist = variablestore->
data;
9997 if (strcmp(var->
name, data) == 0) {
10018 if (!variablestore) {
10020 if (!variablestore) {
10032 variablestore->
data = varlist;
10036 varlist = variablestore->
data;
10040 if (strcmp(var->
name, data) == 0) {
10065 if (iaxs[callno] && iaxs[callno]->owner) {
10069 owner = iaxs[callno]->
owner;
10087 int updatehistory=1;
10090 char decrypted = 0;
10109 char host_pref_buf[128];
10110 char caller_pref_buf[128];
10112 char *using_prefs =
"mine";
10116 memset(fr, 0,
sizeof(*fr));
10124 if (res <
sizeof(*mh)) {
10125 ast_log(
LOG_WARNING,
"midget packet received (%d of %d min)\n", res, (
int)
sizeof(*mh));
10128 if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
10129 if (res <
sizeof(*vh)) {
10130 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a video frame but is too short\n",
10136 fr->
callno =
find_callno(ntohs(vh->callno) & ~0x8000, dcallno, &addr,
new, fd, 0);
10138 }
else if ((meta->
zeros == 0) && !(ntohs(meta->
metacmd) & 0x8000))
10141 #ifdef DEBUG_SUPPORT 10142 if (res >=
sizeof(*fh))
10146 if (res <
sizeof(*fh)) {
10147 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a full frame but is too short\n",
10177 if ((fh->
csub >> 6) & 0x1) {
10196 f.
datalen = res -
sizeof(*fh);
10208 memset(&ies, 0,
sizeof(ies));
10215 memset(&ies, 0,
sizeof(ies));
10239 memset(&ies, 0,
sizeof(ies));
10243 int check_dcallno = 0;
10306 #ifdef DEBUG_SUPPORT 10318 int data_size =
sizeof(*cause_code);
10319 char subclass[40] =
"";
10335 data_size += strlen(subclass);
10338 memset(cause_code, 0, data_size);
10342 snprintf(cause_code->
code, data_size -
sizeof(*cause_code) + 1,
"IAX2 %s(%d)", subclass, ies.
causecode);
10350 if (!iaxs[fr->
callno]) {
10363 unsigned short new_peercallno;
10365 new_peercallno = (
unsigned short) (ntohs(mh->callno) & ~
IAX_FLAG_FULL);
10380 fr->
ts = ntohl(fh->
ts);
10383 ast_debug(1,
"Simulating frame ts resync, was %u now %u\n", fr->
ts, fr->
ts + test_resync);
10384 fr->
ts += test_resync;
10416 ast_debug(1,
"Packet arrived out of order (expecting %d, got %d) (frametype = %u, subclass = %d)\n",
10449 if (res < thread->buf_size)
10450 thread->
buf[res++] =
'\0';
10452 thread->
buf[res - 1] =
'\0';
10461 int call_to_destroy;
10473 ast_debug(1,
"Cancelling transmission of packet %d\n", x);
10474 call_to_destroy = 0;
10481 call_to_destroy = fr->
callno;
10484 if (call_to_destroy) {
10486 ast_debug(1,
"Really destroying %d, having been acked on final message\n", call_to_destroy);
10538 if (!iaxs[fr->
callno]) {
10547 if (variablestore && varlist) {
10548 variablestore->
data = varlist;
10552 for (var = ies.
vars; var; var = var->
next) {
10560 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10571 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10572 if (variablestore) {
10583 ast_debug(1,
"No channel, so populating IAXVARs to the pvt, as an intermediate step.\n");
10584 for (var = ies.
vars; var && var->
next; var = var->
next);
10594 ast_debug(1,
"I have IAX variables, but they were not processed\n");
10624 ast_debug(1,
"Neat, somebody took away the channel at a magical time but i found it!\n");
10628 ast_debug(1,
"I can haz iaxvars, but they is no good. :-(\n");
10670 const char *moh_suggest;
10690 if (!iaxs[fr->
callno]) {
10716 memset(&ied1, 0,
sizeof(ied1));
10730 if (!iaxs[fr->
callno]) {
10738 fr->
callno = new_callno;
10747 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, who was trying to reach '%s@%s'\n",
10754 ast_log(
LOG_WARNING,
"Rejected connect attempt. No secret present while force encrypt enabled.\n");
10757 if (strcasecmp(iaxs[fr->
callno]->
exten,
"TBD")) {
10769 if (!iaxs[fr->
callno]) {
10777 if (strcmp(iaxs[fr->
callno]->
exten,
"TBD") && !exists) {
10778 memset(&ied0, 0,
sizeof(ied0));
10782 if (!iaxs[fr->
callno]) {
10786 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
10794 using_prefs =
"reqonly";
10796 using_prefs =
"disabled";
10799 memset(&pref, 0,
sizeof(pref));
10800 strcpy(caller_pref_buf,
"disabled");
10801 strcpy(host_pref_buf,
"disabled");
10804 using_prefs =
"mine";
10812 using_prefs =
"caller";
10827 memset(&ied0, 0,
sizeof(ied0));
10831 if (!iaxs[fr->
callno]) {
10840 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
10845 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
10860 memset(&pref, 0,
sizeof(pref));
10862 strcpy(caller_pref_buf,
"disabled");
10863 strcpy(host_pref_buf,
"disabled");
10866 using_prefs =
"mine";
10873 using_prefs =
"caller";
10886 memset(&ied0, 0,
sizeof(ied0));
10891 if (!iaxs[fr->
callno]) {
10895 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
10908 memset(&ied1, 0,
sizeof(ied1));
10914 ast_verb(3,
"Accepting UNAUTHENTICATED call from %s:\n" 10915 "%srequested format = %s,\n" 10916 "%srequested prefs = %s,\n" 10917 "%sactual format = %s,\n" 10918 "%shost prefs = %s,\n" 10919 "%spriority = %s\n",
10968 ast_debug(1,
"Immediately destroying %d, having received hangup\n", fr->
callno);
10972 if (!iaxs[fr->
callno]) {
10985 if (!iaxs[fr->
callno]) {
10995 ast_debug(1,
"Immediately destroying %d, having received reject\n",
11008 if (!iaxs[fr->
callno]) {
11054 memset(&ied0, 0,
sizeof(ied0));
11058 if (!iaxs[fr->
callno]) {
11065 ast_log(
LOG_NOTICE,
"Rejected call to %s, format %s incompatible with our capability %s.\n",
11075 if (iaxs[fr->
callno] && iaxs[fr->
callno]->owner && native) {
11080 iaxs[fr->
callno]->peerformat, &iaxs[fr->
callno]->rprefs,
11124 if (iaxs[fr->
callno]->peerpoke) {
11126 peer = iaxs[fr->
callno]->peerpoke;
11132 "peer_status",
"Reachable",
11141 "peer_status",
"Lagged",
11193 iaxs[fr->
callno]->lag = ts - fr->
ts;
11195 ast_debug(1,
"Peer %s lag measured as %dms\n",
11209 "I don't know how to authenticate %s to %s\n",
11226 iaxs[fr->
callno]->username);
11227 memset(&ied0, 0,
sizeof(ied0));
11231 if (strcasecmp(iaxs[fr->
callno]->exten,
"TBD")) {
11236 if (strcmp(iaxs[fr->
callno]->exten,
"TBD") && !exists) {
11238 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
11240 iaxs[fr->
callno]->exten,
11241 iaxs[fr->
callno]->context);
11242 memset(&ied0, 0,
sizeof(ied0));
11246 if (!iaxs[fr->
callno]) {
11253 using_prefs =
"reqonly";
11255 using_prefs =
"disabled";
11257 format = iaxs[fr->
callno]->peerformat & iaxs[fr->
callno]->capability;
11258 memset(&pref, 0,
sizeof(pref));
11259 strcpy(caller_pref_buf,
"disabled");
11260 strcpy(host_pref_buf,
"disabled");
11263 using_prefs =
"mine";
11268 pref = iaxs[fr->
callno]->rprefs;
11269 using_prefs =
"caller";
11271 pref = iaxs[fr->
callno]->prefs;
11274 pref = iaxs[fr->
callno]->prefs;
11285 ast_debug(1,
"We don't do requested format %s, falling back to peer capability '%s'\n",
11288 format = iaxs[fr->
callno]->peercapability & iaxs[fr->
callno]->capability;
11293 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11298 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11305 memset(&ied0, 0,
sizeof(ied0));
11309 if (!iaxs[fr->
callno]) {
11315 if(!(iaxs[fr->
callno]->peerformat & iaxs[fr->
callno]->capability))
11320 memset(&pref, 0,
sizeof(pref));
11322 ? iaxs[fr->
callno]->peerformat
11324 strcpy(caller_pref_buf,
"disabled");
11325 strcpy(host_pref_buf,
"disabled");
11328 using_prefs =
"mine";
11332 pref = iaxs[fr->
callno]->prefs;
11334 pref = iaxs[fr->
callno]->rprefs;
11335 using_prefs =
"caller";
11351 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11356 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11363 memset(&ied0, 0,
sizeof(ied0));
11367 if (!iaxs[fr->
callno]) {
11375 memset(&ied1, 0,
sizeof(ied1));
11379 if (strcmp(iaxs[fr->
callno]->exten,
"TBD")) {
11381 ast_verb(3,
"Accepting AUTHENTICATED call from %s:\n" 11382 "%srequested format = %s,\n" 11383 "%srequested prefs = %s,\n" 11384 "%sactual format = %s,\n" 11385 "%shost prefs = %s,\n" 11386 "%spriority = %s\n",
11404 }
else if (ies.
vars) {
11410 if (variablestore && varlist) {
11411 variablestore->
data = varlist;
11414 ast_debug(1,
"I can haz IAX vars? w00t\n");
11415 for (var = ies.
vars; var; var = var->
next) {
11422 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11432 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11444 goto immediatedial;
11457 ast_log(
LOG_NOTICE,
"Rejected dial attempt from %s, request '%s@%s' does not exist\n",
11459 iaxs[fr->
callno]->exten,
11460 iaxs[fr->
callno]->context);
11461 memset(&ied0, 0,
sizeof(ied0));
11465 if (!iaxs[fr->
callno]) {
11471 ast_verb(3,
"Accepting DIAL from %s, formats = %s\n",
11477 iaxs[fr->
callno]->peerformat, &iaxs[fr->
callno]->rprefs,
11481 }
else if (ies.
vars) {
11487 ast_debug(1,
"I can haz IAX vars? w00t\n");
11488 if (variablestore && varlist) {
11489 variablestore->
data = varlist;
11492 for (var = ies.
vars; var; var = var->
next) {
11499 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11509 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11520 iaxs[fr->
callno]->error = ENOTCONN;
11521 ast_debug(1,
"Immediately destroying %d, having received INVAL\n", fr->
callno);
11526 ast_debug(1,
"Received VNAK: resending outstanding frames\n");
11536 if (!iaxs[fr->
callno]) {
11543 if (!iaxs[fr->
callno]) {
11555 if (!iaxs[fr->
callno]) {
11576 if (iaxs[fr->
callno]->reg) {
11592 memset(&ied0, 0,
sizeof(ied0));
11600 && iaxs[fr->
callno]->bridgecallno
11604 if (!iaxs[fr->
callno]) {
11610 memset(&iaxs[fr->
callno]->transfer, 0,
sizeof(iaxs[fr->
callno]->transfer));
11612 if (!iaxs[fr->
callno]->bridgecallno) {
11616 if (iaxs[iaxs[fr->
callno]->bridgecallno]
11617 && iaxs[iaxs[fr->
callno]->bridgecallno]->transferring) {
11625 && iaxs[fr->
callno]->bridgecallno
11629 if (!iaxs[fr->
callno]) {
11638 if (iaxs[fr->
callno]->bridgecallno) {
11645 if (!iaxs[fr->
callno]->bridgecallno) {
11649 if (!iaxs[iaxs[fr->
callno]->bridgecallno]
11667 memset(&ied0, 0,
sizeof(ied0));
11668 memset(&ied1, 0,
sizeof(ied1));
11686 memset(&ied0, 0,
sizeof(ied0));
11687 memset(&ied1, 0,
sizeof(ied1));
11699 if (iaxs[fr->
callno]->transferring)
11723 "we've been told to rotate our encryption key, " 11724 "but this isn't an encrypted call. bad things will happen.\n" 11745 memset(&ied0, 0,
sizeof(ied0));
11765 memset(&ied0, 0,
sizeof(ied0));
11772 ast_debug(1,
"I can haz IAX vars, but they is no good :-(\n");
11792 }
else if (minivid) {
11795 if (ntohs(vh->ts) & 0x8000LL) {
11806 f.
datalen = res -
sizeof(*vh);
11813 fr->
ts = (iaxs[fr->
callno]->
last & 0xFFFF8000L) | ((ntohs(vh->ts) + test_resync) & 0x7fff);
11816 fr->
ts = (iaxs[fr->
callno]->
last & 0xFFFF8000L) | (ntohs(vh->ts) & 0x7fff);
11823 ast_debug(1,
"Received mini frame before first full voice frame\n");
11842 fr->
ts = (iaxs[fr->
callno]->
last & 0xFFFF0000L) | ((ntohs(mh->ts) + test_resync) & 0xffff);
11845 fr->
ts = (iaxs[fr->
callno]->
last & 0xFFFF0000L) | ntohs(mh->ts);
11860 ast_debug(2,
"Callno %d: Blocked receiving control frame %d.\n",
11871 ast_debug(2,
"Callno %d: Config blocked receiving control frame %d.\n",
11993 struct timeval wait;
11994 struct timespec ts;
11995 int put_into_idle = 0;
11996 int first_time = 1;
12001 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
12008 if (thread->
stop) {
12020 if (put_into_idle) {
12028 ts.tv_sec = wait.tv_sec;
12029 ts.tv_nsec = wait.tv_usec * 1000;
12033 if (!put_into_idle || thread->
stop) {
12053 ts.tv_sec = wait.tv_sec;
12054 ts.tv_nsec = wait.tv_usec * 1000;
12069 if (thread->
stop) {
12086 #ifdef SCHED_MULTITHREADED 12106 #ifdef DEBUG_SCHED_MULTITHREAD 12124 if (!thread->
stop) {
12126 pthread_detach(pthread_self());
12132 pthread_cleanup_pop(1);
12153 int callno = reg->
callno;
12161 ast_debug(1,
"Unable to send registration request for '%s' without IP address\n", reg->
username);
12173 ast_debug(3,
"Allocate call number\n");
12188 memset(&ied, 0,
sizeof(ied));
12208 memset(&cai, 0,
sizeof(cai));
12210 ast_debug(1,
"Provisioning '%s' from template '%s'\n", dest,
template);
12213 ast_debug(1,
"No provisioning found for template '%s'\n",
template);
12224 memset(&ied, 0,
sizeof(ied));
12231 if (iaxs[callno]) {
12234 sched, 15000,
auto_hangup, (
void *)(
long)callno);
12259 opts = strchr(sdata,
'|');
12271 res =
iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd,
NULL, sdata, force);
12272 ast_verb(3,
"Provisioned IAXY at '%s' with '%s'= %d\n",
12285 e->
command =
"iax2 provision";
12287 "Usage: iax2 provision <host> <template> [forced]\n" 12288 " Provisions the given peer or IP address using a template\n" 12289 " matching either 'template' or '*' if the template is not\n" 12290 " found. If 'forced' is specified, even empty provisioning\n" 12291 " fields will be provisioned as empty fields.\n";
12302 if (!strcasecmp(a->
argv[4],
"forced"))
12309 ast_cli(a->
fd,
"Unable to find peer/address '%s'\n", a->
argv[2]);
12311 ast_cli(a->
fd,
"No template (including wildcard) matching '%s'\n", a->
argv[3]);
12313 ast_cli(a->
fd,
"Provisioning '%s' with template '%s'%s\n", a->
argv[2], a->
argv[3], force ?
", forced" :
"");
12322 if (peer->
lastms > -1) {
12328 "peer_status",
"Unreachable",
12333 if ((callno = peer->
callno) > 0) {
12350 #ifdef SCHED_MULTITHREADED 12383 if ((callno = peer->
callno) > 0) {
12430 if (iaxs[callno]) {
12469 memset(&pds, 0,
sizeof(pds));
12479 memset(&cai, 0,
sizeof(cai));
12507 if ((new_callno =
make_trunk(callno, 1)) != -1)
12508 callno = new_callno;
12520 requestor, cai.
found);
12561 ao2_ref(best_fmt_native, -1);
12584 pthread_testcancel();
12591 if (res < 0 &&
errno != -EINTR) {
12603 int threadcount = 0;
12643 ast_verb(2,
"%d helper threads started\n", threadcount);
12660 if (strstr(value,
"rsa"))
12662 if (strstr(value,
"md5"))
12664 if (strstr(value,
"plaintext"))
12677 sd = socket(addr->
ss.ss_family, SOCK_DGRAM, 0);
12710 port = atoi(portstr);
12748 if (nonlocal == 1) {
12750 "Non-local or unbound address specified (%s) in sourceaddress for '%s', reverting to default\n",
12754 }
else if (nonlocal == 2) {
12756 "Unable to bind to sourceaddress '%s' for '%s', reverting to default\n",
12761 ast_debug(1,
"Using sourceaddress %s for '%s'\n", srcaddr, peer->
name);
12769 int callno = peer->
callno;
12801 int subscribe_acl_change = 0;
12812 oldacl = peer->
acl;
12862 if (!strcasecmp(v->
name,
"secret")) {
12864 }
else if (!strcasecmp(v->
name,
"mailbox")) {
12866 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
12872 if (strchr(name,
'@')) {
12878 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
12880 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
12882 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
12884 }
else if (!strcasecmp(v->
name,
"description")) {
12886 }
else if (!strcasecmp(v->
name,
"trunk")) {
12889 ast_log(
LOG_WARNING,
"Unable to support trunking on peer '%s' without a timing interface\n", peer->
name);
12892 }
else if (!strcasecmp(v->
name,
"auth")) {
12897 }
else if (!strcasecmp(v->
name,
"encryption")) {
12902 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
12911 }
else if (!strcasecmp(v->
name,
"transfer")) {
12912 if (!strcasecmp(v->
value,
"mediaonly")) {
12918 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
12920 }
else if (!strcasecmp(v->
name,
"host")) {
12921 if (!strcasecmp(v->
value,
"dynamic")) {
12949 }
else if (!strcasecmp(v->
name,
"defaultip")) {
12951 peer_defaddr_tmp.
ss.ss_family = AF_UNSPEC;
12957 }
else if (!strcasecmp(v->
name,
"sourceaddress")) {
12959 }
else if (!strcasecmp(v->
name,
"permit") ||
12960 !strcasecmp(v->
name,
"deny") ||
12961 !strcasecmp(v->
name,
"acl")) {
12963 }
else if (!strcasecmp(v->
name,
"mask")) {
12966 }
else if (!strcasecmp(v->
name,
"context")) {
12968 }
else if (!strcasecmp(v->
name,
"regexten")) {
12970 }
else if (!strcasecmp(v->
name,
"peercontext")) {
12972 }
else if (!strcasecmp(v->
name,
"port")) {
12982 }
else if (!strcasecmp(v->
name,
"username")) {
12984 }
else if (!strcasecmp(v->
name,
"allow")) {
12986 }
else if (!strcasecmp(v->
name,
"disallow")) {
12988 }
else if (!strcasecmp(v->
name,
"callerid")) {
13000 }
else if (!strcasecmp(v->
name,
"fullname")) {
13003 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13006 }
else if (!strcasecmp(v->
name,
"sendani")) {
13008 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13010 }
else if (!strcasecmp(v->
name,
"outkey")) {
13012 }
else if (!strcasecmp(v->
name,
"qualify")) {
13013 if (!strcasecmp(v->
value,
"no")) {
13015 }
else if (!strcasecmp(v->
value,
"yes")) {
13017 }
else if (sscanf(v->
value,
"%30d", &peer->
maxms) != 1) {
13018 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);
13021 }
else if (!strcasecmp(v->
name,
"qualifysmoothing")) {
13023 }
else if (!strcasecmp(v->
name,
"qualifyfreqok")) {
13025 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);
13027 }
else if (!strcasecmp(v->
name,
"qualifyfreqnotok")) {
13029 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);
13031 }
else if (!strcasecmp(v->
name,
"timezone")) {
13033 }
else if (!strcasecmp(v->
name,
"adsi")) {
13035 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13038 }
else if (!strcasecmp(v->
value,
"send")) {
13041 }
else if (!strcasecmp(v->
value,
"receive")) {
13047 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
13053 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13057 }
else if (!strcasecmp(v->
value,
"auto")) {
13098 if (subscribe_acl_change) {
13127 int oldcurauthreq = 0;
13128 int subscribe_acl_change = 0;
13129 char *varname =
NULL, *varval =
NULL;
13141 oldacl = user->
acl;
13155 memset(user, 0,
sizeof(
struct iax2_user));
13183 if (!strcasecmp(v->
name,
"context")) {
13192 }
else if (!strcasecmp(v->
name,
"permit") ||
13193 !strcasecmp(v->
name,
"deny") ||
13194 !strcasecmp(v->
name,
"acl")) {
13196 }
else if (!strcasecmp(v->
name,
"setvar")) {
13198 if ((varval = strchr(varname,
'='))) {
13204 user->
vars = tmpvar;
13208 }
else if (!strcasecmp(v->
name,
"allow")) {
13210 }
else if (!strcasecmp(v->
name,
"disallow")) {
13212 }
else if (!strcasecmp(v->
name,
"trunk")) {
13215 ast_log(
LOG_WARNING,
"Unable to support trunking on user '%s' without a timing interface\n", user->
name);
13218 }
else if (!strcasecmp(v->
name,
"auth")) {
13223 }
else if (!strcasecmp(v->
name,
"encryption")) {
13228 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13237 }
else if (!strcasecmp(v->
name,
"transfer")) {
13238 if (!strcasecmp(v->
value,
"mediaonly")) {
13244 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13245 if(!strcasecmp(v->
value,
"caller"))
13247 else if(!strcasecmp(v->
value,
"disabled"))
13249 else if(!strcasecmp(v->
value,
"reqonly")) {
13253 }
else if (!strcasecmp(v->
name,
"immediate")) {
13255 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13257 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13259 }
else if (!strcasecmp(v->
name,
"secret")) {
13266 }
else if (!strcasecmp(v->
name,
"callerid")) {
13279 }
else if (!strcasecmp(v->
name,
"fullname")) {
13288 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13297 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13299 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13301 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13303 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13305 }
else if (!strcasecmp(v->
name,
"language")) {
13307 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13314 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13316 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13320 }
else if (!strcasecmp(v->
name,
"adsi")) {
13322 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13325 }
else if (!strcasecmp(v->
value,
"send")) {
13328 }
else if (!strcasecmp(v->
value,
"receive")) {
13334 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13338 }
else if (!strcasecmp(v->
value,
"auto")) {
13374 if (subscribe_acl_change) {
13411 int callno = reg->
callno;
13413 if (iaxs[callno]) {
13483 const char *tosval;
13488 int subscribe_network_change = 1;
13508 ast_log(
LOG_ERROR,
"Config file %s is in an invalid format. Aborting.\n", config_file);
13518 ast_log(
LOG_ERROR,
"Config file %s is in an invalid format. Aborting.\n", config_file);
13523 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
13539 memset(&globalflags, 0,
sizeof(globalflags));
13575 if (!strcasecmp(v->
name,
"bindport")) {
13582 }
else if (!strcasecmp(v->
name,
"pingtime")){
13585 else if (!strcasecmp(v->
name,
"iaxthreadcount")) {
13587 if (atoi(v->
value) != iaxthreadcount)
13590 iaxthreadcount = atoi(v->
value);
13591 if (iaxthreadcount < 1) {
13593 iaxthreadcount = 1;
13594 }
else if (iaxthreadcount > 256) {
13596 iaxthreadcount = 256;
13599 }
else if (!strcasecmp(v->
name,
"iaxmaxthreadcount")) {
13602 iaxmaxthreadcount = atoi(v->
value);
13605 iaxmaxthreadcount = atoi(v->
value);
13606 if (iaxmaxthreadcount < 0) {
13608 iaxmaxthreadcount = 0;
13609 }
else if (iaxmaxthreadcount > 256) {
13611 iaxmaxthreadcount = 256;
13614 }
else if (!strcasecmp(v->
name,
"nochecksums")) {
13622 ast_log(
LOG_WARNING,
"Disabling RTP checksums is not supported on this operating system!\n");
13625 else if (!strcasecmp(v->
name,
"maxjitterbuffer"))
13627 else if (!strcasecmp(v->
name,
"resyncthreshold"))
13629 else if (!strcasecmp(v->
name,
"maxjitterinterps"))
13631 else if (!strcasecmp(v->
name,
"jittertargetextra"))
13633 else if (!strcasecmp(v->
name,
"lagrqtime"))
13635 else if (!strcasecmp(v->
name,
"maxregexpire"))
13637 else if (!strcasecmp(v->
name,
"minregexpire"))
13639 else if (!strcasecmp(v->
name,
"bindaddr")) {
13667 }
else if (!strcasecmp(v->
name,
"auth")) {
13672 }
else if (!strcasecmp(v->
name,
"authdebug")) {
13674 }
else if (!strcasecmp(v->
name,
"encryption")) {
13679 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13688 }
else if (!strcasecmp(v->
name,
"transfer")) {
13689 if (!strcasecmp(v->
value,
"mediaonly")) {
13695 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13696 if(!strcasecmp(v->
value,
"caller"))
13698 else if(!strcasecmp(v->
value,
"disabled"))
13700 else if(!strcasecmp(v->
value,
"reqonly")) {
13704 }
else if (!strcasecmp(v->
name,
"jitterbuffer"))
13706 else if (!strcasecmp(v->
name,
"delayreject"))
13708 else if (!strcasecmp(v->
name,
"allowfwdownload"))
13710 else if (!strcasecmp(v->
name,
"rtcachefriends"))
13712 else if (!strcasecmp(v->
name,
"rtignoreregexpire"))
13714 else if (!strcasecmp(v->
name,
"rtupdate"))
13716 else if (!strcasecmp(v->
name,
"rtsavesysname"))
13718 else if (!strcasecmp(v->
name,
"trunktimestamps"))
13720 else if (!strcasecmp(v->
name,
"rtautoclear")) {
13721 int i = atoi(v->
value);
13723 global_rtautoclear = i;
13727 }
else if (!strcasecmp(v->
name,
"trunkfreq")) {
13730 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 10ms instead.\n");
13733 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 1000ms instead.\n");
13739 }
else if (!strcasecmp(v->
name,
"trunkmtu")) {
13740 mtuv = atoi(v->
value);
13743 else if (mtuv >= 172 && mtuv < 4000)
13748 }
else if (!strcasecmp(v->
name,
"trunkmaxsize")) {
13752 }
else if (!strcasecmp(v->
name,
"autokill")) {
13753 if (sscanf(v->
value,
"%30d", &x) == 1) {
13763 }
else if (!strcasecmp(v->
name,
"bandwidth")) {
13764 if (!strcasecmp(v->
value,
"low")) {
13767 }
else if (!strcasecmp(v->
value,
"medium")) {
13770 }
else if (!strcasecmp(v->
value,
"high")) {
13776 }
else if (!strcasecmp(v->
name,
"allow")) {
13778 }
else if (!strcasecmp(v->
name,
"disallow")) {
13780 }
else if (!strcasecmp(v->
name,
"register")) {
13782 }
else if (!strcasecmp(v->
name,
"iaxcompat")) {
13784 }
else if (!strcasecmp(v->
name,
"regcontext")) {
13788 }
else if (!strcasecmp(v->
name,
"tos")) {
13791 }
else if (!strcasecmp(v->
name,
"cos")) {
13794 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13796 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13798 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13800 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13802 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13809 }
else if (!strcasecmp(v->
name,
"language")) {
13811 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13815 }
else if (!strcasecmp(v->
name,
"adsi")) {
13817 }
else if (!strcasecmp(v->
name,
"srvlookup")) {
13819 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13822 }
else if (!strcasecmp(v->
value,
"send")) {
13825 }
else if (!strcasecmp(v->
value,
"receive")) {
13831 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
13832 if (sscanf(v->
value,
"%10hu", &global_maxcallno) != 1) {
13835 }
else if (!strcasecmp(v->
name,
"maxcallnumbers_nonvalidated")) {
13836 if (sscanf(v->
value,
"%10hu", &global_maxcallno_nonval) != 1) {
13839 }
else if (!strcasecmp(v->
name,
"calltokenoptional")) {
13844 }
else if (!strcasecmp(v->
name,
"calltokenexpiration")) {
13846 sscanf(v->
value,
"%u", &temp);
13850 max_calltoken_delay = temp;
13852 }
else if (!strcasecmp(v->
name,
"subscribe_network_change_event")) {
13854 subscribe_network_change = 1;
13856 subscribe_network_change = 0;
13860 }
else if (!strcasecmp(v->
name,
"shrinkcallerid")) {
13873 if (subscribe_network_change) {
13902 ast_log(
LOG_WARNING,
"Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
13912 int genregisteriax;
13913 const char *hasiax, *registeriax;
13920 if (strcasecmp(cat,
"general")) {
13923 if (
ast_true(hasiax) || (!hasiax && genhasiax)) {
13939 if (
ast_true(registeriax) || (!registeriax && genregisteriax)) {
13952 snprintf(tmp,
sizeof(tmp),
"%s:%s@%s", username, secret, host);
13954 snprintf(tmp,
sizeof(tmp),
"%s@%s", username, host);
13966 if (strcasecmp(cat,
"general")) {
13968 if (!strcasecmp(cat,
"callnumberlimits")) {
13970 }
else if (utype) {
13971 if (!strcasecmp(utype,
"user") || !strcasecmp(utype,
"friend")) {
13978 if (!strcasecmp(utype,
"peer") || !strcasecmp(utype,
"friend")) {
13986 }
else if (strcasecmp(utype,
"user")) {
13987 ast_log(
LOG_WARNING,
"Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
14012 static const char config[] =
"iax.conf";
14015 if (
set_config(config, 1, forced_reload) > 0) {
14047 "Usage: iax2 reload\n" 14048 " Reloads IAX configuration from iax.conf\n";
14074 for (x = 0; x <
ARRAY_LEN(iaxs); x++) {
14078 if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot))
14086 memset(&cai, 0,
sizeof(cai));
14087 memset(&ied, 0,
sizeof(ied));
14088 memset(&pds, 0,
sizeof(pds));
14102 ast_debug(1,
"peer: %s, username: %s, password: %s, context: %s\n",
14141 int x, com[2],
timeout, old = 0, outfd, doabort, callno;
14190 struct timeval start;
14255 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
14275 ast_log(
LOG_NOTICE,
"iax2_exists: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context, exten, priority, callerid ? callerid :
"<unknown>", data);
14277 if ((priority != 1) && (priority != 2))
14281 if ((dp =
find_cache(chan, data, context, exten, priority))) {
14298 ast_log(
LOG_NOTICE,
"iax2_canmatch: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context, exten, priority, callerid ? callerid :
"<unknown>", data);
14300 if ((priority != 1) && (priority != 2))
14304 if ((dp =
find_cache(chan, data, context, exten, priority))) {
14321 ast_log(
LOG_NOTICE,
"iax2_matchmore: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context, exten, priority, callerid ? callerid :
"<unknown>", data);
14323 if ((priority != 1) && (priority != 2))
14327 if ((dp =
find_cache(chan, data, context, exten, priority))) {
14347 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);
14349 if (priority == 2) {
14358 }
else if (priority != 1)
14362 if ((dp =
find_cache(chan, data, context, exten, priority))) {
14365 ncontext = strchr(odata,
'/');
14369 snprintf(req,
sizeof(req),
"IAX2/%s/%s@%s", odata, exten, ncontext);
14371 snprintf(req,
sizeof(req),
"IAX2/%s/%s", odata, exten);
14373 ast_verb(3,
"Executing Dial('%s')\n", req);
14376 ast_log(
LOG_WARNING,
"Can't execute nonexistent extension '%s[@%s]' in data '%s'\n", exten, context, data);
14393 char *peername, *colname;
14398 if (!strcmp(peername,
"CURRENTCHANNEL")) {
14408 if ((colname = strchr(peername,
',')))
14416 if (!strcasecmp(colname,
"ip")) {
14418 }
else if (!strcasecmp(colname,
"status")) {
14420 }
else if (!strcasecmp(colname,
"mailbox")) {
14422 }
else if (!strcasecmp(colname,
"context")) {
14424 }
else if (!strcasecmp(colname,
"expire")) {
14425 snprintf(buf, len,
"%d", peer->
expire);
14426 }
else if (!strcasecmp(colname,
"dynamic")) {
14428 }
else if (!strcasecmp(colname,
"callerid_name")) {
14430 }
else if (!strcasecmp(colname,
"callerid_num")) {
14432 }
else if (!strcasecmp(colname,
"codecs")) {
14437 }
else if (!strncasecmp(colname,
"codec[", 6)) {
14438 char *codecnum, *ptr;
14442 codecnum = colname + 5;
14445 if ((ptr = strchr(codecnum,
']'))) {
14480 if (!(pvt = iaxs[callno])) {
14485 if (!strcasecmp(args,
"osptoken")) {
14487 }
else if (!strcasecmp(args,
"peerip")) {
14489 }
else if (!strcasecmp(args,
"peername")) {
14491 }
else if (!strcasecmp(args,
"secure_signaling") || !strcasecmp(args,
"secure_media")) {
14510 memset(&pds, 0,
sizeof(pds));
14518 ast_debug(3,
"Checking device state for device %s\n", pds.
peer);
14526 ast_debug(3,
"Found peer. What's device state of %s? addr=%s, defaddr=%s maxms=%d, lastms=%d\n",
14546 .description =
"IAX Remote Dialplan Switch",
14575 AST_CLI_DEFINE(handle_cli_iax2_test_jitter,
"Simulates jitter for testing"),
14576 AST_CLI_DEFINE(handle_cli_iax2_test_late,
"Test the receipt of a late frame"),
14577 AST_CLI_DEFINE(handle_cli_iax2_test_resync,
"Test a resync in received timestamps"),
14584 struct iax2_thread_list *list_head = head;
14589 pthread_t thread_id = thread->
threadid;
14595 pthread_join(thread_id,
NULL);
14623 for (x = 0; x <
ARRAY_LEN(iaxs); x++) {
14636 for (x = 0; x <
ARRAY_LEN(iaxs); x++) {
14653 for (x = 0; x <
ARRAY_LEN(iaxsl); x++) {
14659 ao2_ref(iax_peercallno_pvts, -1);
14660 ao2_ref(iax_transfercallno_pvts, -1);
14662 ao2_ref(calltoken_ignores, -1);
14713 return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt,
14731 return match(&pvt2->transfer, pvt2->transfercallno, pvt2->callno, pvt,
14737 peers = users = iax_peercallno_pvts = iax_transfercallno_pvts =
NULL;
14738 peercnts = callno_limits = calltoken_ignores =
NULL;
14743 goto container_fail;
14749 goto container_fail;
14754 if (!iax_peercallno_pvts) {
14755 goto container_fail;
14760 if (!iax_transfercallno_pvts) {
14761 goto container_fail;
14767 goto container_fail;
14772 if (!callno_limits) {
14773 goto container_fail;
14778 if (!calltoken_ignores) {
14779 goto container_fail;
14783 goto container_fail;
14787 if (!transmit_processor) {
14788 goto container_fail;
14800 if (iax_peercallno_pvts) {
14801 ao2_ref(iax_peercallno_pvts, -1);
14803 if (iax_transfercallno_pvts) {
14804 ao2_ref(iax_transfercallno_pvts, -1);
14809 if (callno_limits) {
14812 if (calltoken_ignores) {
14813 ao2_ref(calltoken_ignores, -1);
14830 static const char config[] =
"iax.conf";
14845 memset(iaxs, 0,
sizeof(iaxs));
14847 for (x = 0; x <
ARRAY_LEN(iaxsl); x++) {
14944 ast_verb(2,
"IAX Ready and Listening\n");
14959 ast_realtime_require_field(
"iaxpeers",
"name",
RQ_CHAR, 10,
"ipaddr",
RQ_CHAR, 15,
"port",
RQ_UINTEGER2, 5,
"regseconds",
RQ_UINTEGER2, 6,
SENTINEL);
14972 .requires =
"dnsmgr",
14973 .optional_modules =
"res_crypto",
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
static ast_mutex_t iaxsl[ARRAY_LEN(iaxs)]
chan_iax2_pvt structure locks
static int iaxdefaultdpcache
static int iax2_delete_from_sched(const void *data)
static void requirecalltoken_mark_auto(const char *name, int subclass)
static struct iax_frame * iaxfrdup2(struct iax_frame *fr)
static int acf_iaxvar_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
char mohsuggest[MAX_MUSICCLASS]
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
static char musicclass[MAX_MUSICCLASS]
struct ast_variable * next
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...
Require call token validation after a successful registration using call token validation occurs...
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
void iax_set_error(void(*output)(const char *data))
static char * handle_cli_iax2_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct sockaddr_storage ss
static int load_module(void)
Load the module.
static int manager_iax2_show_registry(struct mansession *s, const struct message *m)
static uint16_t global_maxcallno_nonval
static void jb_error_output(const char *fmt,...)
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
static char accountcode[AST_MAX_ACCOUNT_CODE]
int presentation
Q.931 encoded presentation-indicator encoded field.
static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen)
unsigned int trunkdatalen
static int socket_process(struct iax2_thread *thread)
static char * complete_iax2_peers(const char *line, const char *word, int pos, int state, uint64_t flags)
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.
static int handle_error(void)
#define IAX_IE_IAX_UNKNOWN
static void iax_outputframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
#define ast_channel_lock(chan)
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) ...
static char * handle_cli_iax2_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const ast_string_field secret
const ast_string_field rdnis
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_party_dialed::@246 number
Dialed/Called number.
struct timeval lasttxtime
static int iax2_ack_registry(struct iax_ies *ies, struct ast_sockaddr *addr, int callno)
Acknowledgment received for OUR registration.
static uint16_t DEFAULT_MAXCALLNO_LIMIT_NONVAL
static void build_rand_pad(unsigned char *buf, ssize_t len)
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.
#define AST_CLI_DEFINE(fn, txt,...)
void iax_firmware_reload(void)
#define IAX_RTSAVE_SYSNAME
static struct ast_format * codec_choose_from_prefs(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
char * str
Subscriber phone number (Malloced)
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan)
#define IAX_TRUNKTIMESTAMPS
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.
#define IAX_IE_CAPABILITY2
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
#define IAX_CALLENCRYPTED(pvt)
#define AST_LIST_LOCK(head)
Locks a list.
static void free_context(struct iax2_context *con)
Asterisk locking-related definitions:
void astman_append(struct mansession *s, const char *fmt,...)
static int make_trunk(unsigned short callno, int locked)
#define IAX_IE_CALLINGTNS
const ast_string_field osptoken
Asterisk main include file. File version handling, generic pbx functions.
static const char config_file[]
static char language[MAX_LANGUAGE]
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
#define ast_realloc(p, len)
A wrapper for realloc()
static void free_signaling_queue_entry(struct signaling_queue_entry *s)
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
const ast_string_field cid_num
char * str
Subscriber phone number (Malloced)
char chan_name[AST_CHANNEL_NAME]
static int jittertargetextra
#define ast_copy_flags64(dest, src, flagz)
static struct iax2_peer * find_peer(const char *name, int realtime)
static char parkinglot[AST_MAX_CONTEXT]
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len)
static int prune_addr_range_cb(void *obj, void *arg, int flags)
static char * handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const ast_string_field exten
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Security Event Reporting API.
static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
static int iax2_predestroy(int callno)
#define AST_OPTION_TXGAIN
unsigned char calltoken_ie_len
static char * complete_iax2_unregister(const char *line, const char *word, int pos, int state)
static uint16_t DEFAULT_MAXCALLNO_LIMIT
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint,...)
void iax_set_output(void(*output)(const char *data))
static void __auth_reject(const void *nothing)
static pthread_t netthreadid
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
const ast_string_field dnid
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
static void network_change_stasis_subscribe(void)
static void handle_deferred_full_frames(struct iax2_thread *thread)
Handle any deferred full frames for this thread.
static void realtime_update_peer(const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static struct iax2_peer * realtime_peer(const char *peername, struct ast_sockaddr *addr)
static struct iax2_peer * peer_unref(struct iax2_peer *peer)
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)
#define CALLTOKEN_HASH_FORMAT
static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
#define ast_pthread_create_detached(a, b, c, d)
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int network_change_sched_cb(const void *data)
struct ast_party_id id
Connected party ID.
static struct ao2_container * iax_peercallno_pvts
Another container of iax2_pvt structures.
static int iax2_write(struct ast_channel *c, struct ast_frame *f)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static void __attempt_transmit(const void *data)
#define ast_channel_unref(c)
Decrease channel reference count.
static int transfercallno_pvt_hash_cb(const void *obj, const int flags)
struct iax2_registry * reg
static int send_command_locked(unsigned short callno, char, int, unsigned int, const unsigned char *, int, int)
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
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 int send_lagrq(const void *data)
#define ast_test_flag(p, flag)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static int addr_range_delme_cb(void *obj, void *arg, int flags)
static int exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
int ast_netsock_sockfd(const struct ast_netsock *ns)
const ast_string_field description
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Support for translation of data formats. translate.c.
#define IAX_SHRINKCALLERID
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
const char * ast_var_value(const struct ast_var_t *var)
static void iax_pvt_callid_new(int callno)
static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt)
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_party_name name
Subscriber name.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
int iax_firmware_get_version(const char *dev, uint16_t *version)
const ast_string_field name
struct iax2_thread::@124 full_frames
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
static void __iax2_do_register_s(const void *data)
#define IAX_META_TRUNK_MINI
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
#define schedule_action(func, data)
static char * handle_cli_iax2_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_variable * vars
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 void unlink_peer(struct iax2_peer *peer)
static const char * iax2_getformatname_multiple(iax2_format format, struct ast_str **codec_buf)
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
iax2_format peercapability
static time_t max_calltoken_delay
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
const char * ast_var_name(const struct ast_var_t *var)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
int ast_netsock_release(struct ast_netsock_list *list)
#define ast_set_flag(p, flag)
const char * iax2_getformatname(iax2_format format)
iax2 wrapper function for ast_getformatname
static int send_ping(const void *data)
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
struct iax2_context * next
static int peercnt_hash_cb(const void *obj, const int flags)
static int max_reg_expire
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static int iax2_poke_peer(struct iax2_peer *peer, int heldcall)
#define DEADLOCK_AVOIDANCE(lock)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
static struct ast_netsock_list * netsock
descriptor for a cli entry.
#define AST_OPTION_OPRMODE
static int update_packet(struct iax_frame *f)
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
const ast_string_field dbsecret
static int iax2_queue_frame(int callno, struct ast_frame *f)
Queue a frame to a call's owning asterisk channel.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
static int iax2_getpeername(struct ast_sockaddr addr, char *host, int len)
static char * handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
#define MARK_IAX_SUBCLASS_TX
enum iax_transfer_state transferring
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
char * iax_prov_complete_template(const char *line, const char *word, int pos, int state)
#define ao2_callback(c, flags, cb_fn, arg)
static int iax2_queryoption(struct ast_channel *c, int option, void *data, int *datalen)
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...
Provide cryptographic signature routines.
static void __get_from_jb(const void *p)
static struct chan_iax2_pvt * new_iax(struct ast_sockaddr *addr, const char *host)
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEINVALID
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)
unsigned char semirand[32]
#define IAX_ENCRYPT_KEYROTATE
enum iax_reg_state regstate
static int iax2_transmit(struct iax_frame *fr)
static int iax2_authmethods
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
static int iaxmaxthreadcount
const ast_string_field language
static int auto_congest(const void *data)
struct iax2_codec_pref rprefs
#define IAX_FORCE_ENCRYPT
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
static unsigned int iax2_datetime(const char *tz)
const ast_string_field inkeys
static void register_peer_exten(struct iax2_peer *peer, int onoff)
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define IAX_DEFAULT_REG_EXPIRE
#define IAX_DELAYPBXSTART
#define IAX_LINGER_TIMEOUT
#define AST_CAUSE_FACILITY_REJECTED
static int network_change_sched_id
#define DEFAULT_MAX_THREAD_COUNT
static int load_objects(void)
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.
Structure for variables, used for configurations and for channel variables.
static pj_pool_t * pool
Global memory pool for configuration and timers.
static void unwrap_timestamp(struct iax_frame *fr)
static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, struct ast_frame *f)
#define IAX_IE_MD5_RESULT
static int iax2_parse_allow_disallow(struct iax2_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
const ast_string_field challenge
static void iax_debug_output(const char *data)
void MD5Final(unsigned char digest[16], struct MD5Context *context)
#define MAX_TIMESTAMP_SKEW
unsigned short bridgecallno
struct ast_variable * iaxvars
#define IAX_DPSTATUS_MATCHMORE
#define IAX_DEFAULT_PORTNO
#define IAX_IE_FIRMWAREVER
static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
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
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
return a reference to a taskprocessor, create one if it does not exist
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int iax_get_oframes(void)
static struct stasis_subscription * network_change_sub
const ast_string_field name
const ast_string_field language
static struct iax2_thread * find_idle_thread(void)
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
static char * handle_cli_iax2_provision(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
Structure to pass both assignedid values to channel drivers.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
static void jb_debug_output(const char *fmt,...)
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
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 ...
int iax_provision_unload(void)
Structure for a data store type.
ast_channel_state
ast_channel states
static char * handle_cli_iax2_show_netstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_timer * ast_timer_open(void)
Open a timer.
static int wait_for_peercallno(struct chan_iax2_pvt *pvt)
unsigned char semirand[32]
uint64_t iax2_codec_pref_from_bitfield(struct iax2_codec_pref *pref, uint64_t bitfield)
Create codec preference list from the given bitfield formats.
char * str
Subscriber name (Malloced)
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
static int registry_authrequest(int callno)
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
static const struct adsi_event events[]
static void build_encryption_keys(const unsigned char *digest, struct chan_iax2_pvt *pvt)
Used in the sip_show_peers functions to pass parameters.
#define ast_cond_wait(cond, mutex)
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.
#define IAX_CODEC_NOPREFS
Background DNS update manager.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cond_init(cond, attr)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static char * handle_cli_iax2_test_losspct(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_netsock_list * ast_netsock_list_alloc(void)
#define IAX_CAPABILITY_FULLBANDWIDTH
static int matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
unsigned short transfercallno
static int auto_hangup(const void *data)
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.
ast_control_frame_type
Internal control frame subtype field values.
static int copy(char *infile, char *outfile)
Utility function to copy a file.
#define IAX_IE_AUTOANSWER
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
struct ast_dnsmgr_entry * dnsmgr
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
static struct @481 methods[]
#define ast_set_flag64(p, flag)
Wrapper for an ast_acl linked list.
#define IAX_CODEC_USER_FIRST
#define ast_mutex_lock(a)
#define CALLNO_ENTRY_IS_VALIDATED(a)
static void add_empty_calltoken_ie(struct chan_iax2_pvt *pvt, struct iax_ie_data *ied)
#define IAX_MAX_OSPTOKEN_SIZE
#define IAX_DPSTATUS_IGNOREPAT
#define AST_OPTION_SECURE_MEDIA
static void user_destructor(void *obj)
static void set_hangup_source_and_cause(int callno, unsigned char causecode)
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 ...
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
#define ast_str_alloca(init_len)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
void ast_verbose(const char *fmt,...)
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
static char * handle_cli_iax2_show_registry(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int socket_read(int *id, int fd, short events, void *cbdata)
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
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.
#define IAX_DEBUGDIGEST(msg, key)
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
static int iax2_devicestate(const char *data)
Part of the device state notification system —.
struct iax_frame * iax_frame_new(int direction, int datalen, unsigned int cacheable)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
static void log_jitterstats(unsigned short callno)
static int peercnt_add(struct ast_sockaddr *addr)
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
calltoken_peer_enum
Call token validation settings.
#define AST_CAUSE_NO_USER_RESPONSE
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! JB_DROP: H...
I/O Management (derived from Cheops-NG)
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. All signaling is held here until that point.
static int acf_iaxvar_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
#define CALLNO_ENTRY_GET_CALLNO(a)
callno_entry callno_entry
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
static int manager_iax2_show_netstats(struct mansession *s, const struct message *m)
void ast_cli(int fd, const char *fmt,...)
static int handle_call_token(struct ast_iax2_full_hdr *fh, struct iax_ies *ies, struct ast_sockaddr *addr, int fd)
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
static char mohinterpret[MAX_MUSICCLASS]
static char * handle_cli_iax2_set_debug_trunk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
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.
#define PTR_TO_CALLNO_ENTRY(a)
Structure used to handle a large number of boolean flags == used only in app_dial?
static int iax2_digit_end(struct ast_channel *c, char digit, unsigned int duration)
int ast_unregister_application(const char *app)
Unregister an application.
static char default_parkinglot[AST_MAX_CONTEXT]
static int update_registry(struct ast_sockaddr *addr, int callno, char *devtype, int fd, unsigned short refresh)
static void set_config_destroy(void)
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
void ast_free_ptr(void *ptr)
free() wrapper
Socket address 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.
static char cid_num[AST_MAX_EXTENSION]
#define ast_cond_signal(cond)
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
static int iaxactivethreadcount
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
#define ast_verb(level,...)
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
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)
static void pvt_destructor(void *obj)
static int manager_iax2_show_peer_list(struct mansession *s, const struct message *m)
callback to display iax peers in manager format
void MD5Init(struct MD5Context *context)
struct iax_frame::@156 list
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
const ast_string_field inkeys
static struct iax2_trunk_peer * find_tpeer(struct ast_sockaddr *addr, int fd)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
#define IAX_IE_CALLING_NUMBER
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.
ast_aes_decrypt_key mydcx
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.
static char * handle_cli_iax2_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Implementation of the IAX2 protocol.
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static struct ast_custom_function iaxpeer_function
struct ast_frame_subclass subclass
const ast_string_field parkinglot
static struct iax2_context * build_context(const char *context)
static struct ao2_container * iax_transfercallno_pvts
Another container of iax2_pvt structures.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
#define IAX_IE_CALLING_ANI
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
static iax2_format uncompress_subclass(unsigned char csub)
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
#define IAX_META_TRUNK_SUPERMINI
int args
This gets set in ast_cli_register()
int AST_OPTIONAL_API_NAME() ast_check_signature(struct ast_key *key, const char *msg, const char *sig)
base64 decode then sent to __ast_check_signature_bin
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int)
#define IAX_CAPABILITY_LOWBANDWIDTH
#define CALLNO_ENTRY_SET_VALIDATED(a)
static char * handle_cli_iax2_show_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_module_unref(mod)
Release a reference to the module.
pthread_cond_t ast_cond_t
#define ast_strlen_zero(foo)
struct chan_iax2_pvt::signaling_queue signaling_queue
static int resyncthreshold
static int check_provisioning(struct ast_sockaddr *addr, int sockfd, char *si, unsigned int ver)
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
static int iax2_sched_replace(int id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
#define ast_pthread_create_background(a, b, c, d)
const char * ast_config_AST_SYSTEM_NAME
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
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.
#define IAX_IE_ENCRYPTION
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
#define AST_MAX_ACCOUNT_CODE
static int register_verify(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
Verify inbound registration.
jitterbuf * jb_new(void)
new jitterbuf
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
Custom localtime functions for multiple timezones.
uint64_t iax2_codec_pref_order_value_to_format_bitfield(int order_value)
Convert an iax2_codec_pref order value into a format bitfield.
internal representation of ACL entries In principle user applications would have no need for this...
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
meta
below block is needed for mssql
static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
struct ast_party_id id
Caller party ID.
static int __unload_module(void)
static void iax2_dprequest(struct iax2_dpcache *dp, int callno)
static struct ast_sockaddr debugaddr
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
Configuration File Parser.
AES_KEY ast_aes_encrypt_key
struct iax2_context * contexts
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
get values from config variables.
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
static int global_max_trunk_mtu
#define EVENT_FLAG_SYSTEM
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 socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, struct ast_sockaddr *addr, int sockfd, struct iax_frame *fr)
#define ast_debug(level,...)
Log a DEBUG message.
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...
#define MAX_TRUNK_MTU
Maximum transmission unit for the UDP packet in the trunk not to be fragmented. This is based on 1516...
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
static void * iax2_process_thread(void *data)
#define IAX_MAX_OSPBLOCK_NUM
#define ast_config_load(filename, flags)
Load a config file.
void ast_netsock_unref(struct ast_netsock *ns)
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.
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
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.
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
static int scheduled_destroy(const void *vid)
struct ast_party_id ani
Automatic Number Identification (ANI)
static void __send_lagrq(const void *data)
unsigned char * calltokendata
General Asterisk PBX channel definitions.
static void * iax2_dup_variable_datastore(void *)
static void memcpy_decrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_decrypt_key *dcx)
static int iax2_transfer(struct ast_channel *c, const char *dest)
static void resend_with_token(int callno, struct iax_frame *f, const char *newtoken)
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
static void iax2_destroy(int callno)
struct timeval txtrunktime
static struct ao2_container * users
static void * dp_lookup_thread(void *data)
#define DEFAULT_RETRY_TIME
#define DEFAULT_THREAD_COUNT
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
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.
Asterisk file paths, configured in asterisk.conf.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
static struct ao2_container * peers
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
#define DIRECTION_OUTGRESS
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
#define ast_mutex_trylock(a)
struct ast_sockaddr netmask
#define DIRECTION_INGRESS
char exten[AST_MAX_EXTENSION]
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static int iax2_lock_callno_unless_destroyed(int callno)
#define AST_OPTION_RELAXDTMF
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
static struct ast_generator gen
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
static int peer_hash_cb(const void *obj, const int flags)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
static void acl_change_stasis_subscribe(void)
#define AST_PTHREADT_NULL
int iax2_codec_pref_to_cap(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
Convert a preference structure to a capabilities structure.
static struct call_number_pool callno_pool_trunk
enum iax2_thread_type type
unsigned char iax_unknown
Data structure associated with a custom dialplan function.
Access Control of various sorts.
IAX Firmware Support header file.
static void iax2_publish_registry(const char *username, const char *domain, const char *status, const char *cause)
Global IO variables are now in a struct in order to be made threadsafe.
#define IAX_RTCACHEFRIENDS
static char mohsuggest[MAX_MUSICCLASS]
#define AST_MAX_EXTENSION
unsigned short peercallno
Scheduler Routines (derived from cheops)
enum iax2_thread_iostate iostate
const ast_string_field zonetag
const ast_string_field mohinterpret
static iax2_format iax2_codec_choose(struct iax2_codec_pref *pref, iax2_format formats)
#define AST_STRING_FIELD(name)
Declare a string field.
char * osptokenblock[IAX_MAX_OSPBLOCK_NUM]
static char * handle_cli_iax2_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
#define IAX_DPSTATUS_NONEXISTENT
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
static int complete_transfer(int callno, struct iax_ies *ies)
Asterisk internal frame definitions.
static int find_callno(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
#define ao2_ref(o, delta)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
static struct @112 frame_queue[IAX_MAX_CALLS]
a list of frames that may need to be retransmitted
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
#define IAX_IE_CALLING_NAME
void ast_config_destroy(struct ast_config *config)
Destroys a config.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
const ast_string_field regexten
long int ast_random(void)
const ast_string_field username
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 ...
static uint16_t total_nonval_callno_used
#define IAX_IE_PROVISIONING
static void __auto_hangup(const void *nothing)
static void iax_pvt_callid_set(int callno, ast_callid callid)
Require call token validation.
#define ast_strdupa(s)
duplicate a string in memory from the stack
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)
static void sched_delay_remove(struct ast_sockaddr *addr, callno_entry entry)
#define AST_BRIDGE_DTMF_CHANNEL_1
Report DTMF on channel 1.
static struct ao2_container * calltoken_ignores
static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
int ast_atomic_dec_and_test(volatile int *p)
decrement *p by 1 and return true if the variable has reached 0.
void AST_OPTIONAL_API_NAME() ast_aes_encrypt(const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *ctx)
int AST_OPTIONAL_API_NAME() ast_sign(struct ast_key *key, char *msg, char *sig)
wrapper for __ast_sign_bin then base64 encode it
unsigned int ast_codec_samples_count(struct ast_frame *frame)
Get the number of samples contained within a frame.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
Default calltoken required unless the ip is in the ignorelist.
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
A set of macros to manage forward-linked lists.
#define ast_malloc(len)
A wrapper for malloc()
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
static void __send_ping(const void *data)
#define ast_variable_new(name, value, filename)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
static void delete_users(void)
static void dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, int skiplock)
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
callno_entry numbers[IAX_MAX_CALLS/2+1]
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static int iax2_queue_unhold(int callno)
Queue an unhold frame on the ast_channel owner.
static int authenticate_reply(struct chan_iax2_pvt *p, struct ast_sockaddr *addr, struct iax_ies *ies, const char *override, const char *okey)
static int unload_module(void)
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
#define IAX2_TRUNK_PREFACE
static void iax2_free_variable_datastore(void *)
static int timing_read(int *id, int fd, short events, void *cbdata)
const ast_string_field accountcode
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.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
int ast_sockaddr_hash(const struct ast_sockaddr *addr)
Computes a hash value from the address. The port is ignored.
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
static int peercnt_remove_cb(const void *obj)
Core PBX routines and definitions.
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.
static int user_delme_cb(void *obj, void *arg, int flags)
static void acl_change_stasis_unsubscribe(void)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static ast_callid iax_pvt_callid_get(int callno)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
static int firmware_show_callback(struct ast_iax2_firmware_header *header, void *user_data)
static int __do_deliver(void *data)
static void poke_all_peers(void)
#define IAX_RECVCONNECTEDLINE
enum calltoken_peer_enum calltoken_required
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
static void store_by_peercallno(struct chan_iax2_pvt *pvt)
#define CONFIG_STATUS_FILEUNCHANGED
static int peer_status(struct iax2_peer *peer, char *status, int statuslen)
peer_status: Report Peer status in character string
#define stasis_subscribe(topic, callback, data)
char peercontext[AST_MAX_CONTEXT]
struct iax2_codec_pref prefs
void ast_sha1_hash(char *output, const char *input)
Produces SHA1 hash based on input string.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
static int maxjitterbuffer
jitterbuf: an application-independent jitterbuffer jitterbuf.c
static int iax2_answer(struct ast_channel *c)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static int(* iax2_regfunk)(const char *username, int onoff)
static struct iax2_codec_pref prefs_global
static int iax2_queue_hangup(int callno)
Queue a hangup frame on the ast_channel owner.
static int attribute_pure iax2_allow_new(int frametype, int subclass, int inbound)
static int iax2_register(const char *value, int lineno)
static int replace_callno(const void *obj)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
static struct ast_taskprocessor * transmit_processor
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
ast_aes_decrypt_key mydcx
#define IAX_IE_CALLED_NUMBER
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
static int iax2_setoption(struct ast_channel *c, int option, void *data, int datalen)
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.
const ast_string_field outkey
static int iaxdynamicthreadcount
IAX2 Provisioning protocol.
#define AST_OPTION_DIGIT_DETECT
static int iax2_poke_peer_s(const void *data)
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED
static void iax2_frame_free(struct iax_frame *fr)
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
static void set_peercnt_limit(struct peercnt *peercnt)
#define IAX_MAX_OSPBLOCK_SIZE
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
const ast_string_field accountcode
Implementation of Inter-Asterisk eXchange, version 2 iax2-parser::c iax2-parser.h chan_iax2...
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
static int iax2_vnak(int callno)
struct ast_taskprocessor * mailbox
const ast_string_field mohinterpret
#define AST_OPTION_RXGAIN
static int calltoken_required(struct ast_sockaddr *addr, const char *name, int subclass)
const ast_string_field parkinglot
#define ao2_unlink(container, obj)
const ast_string_field peer
int iax2_codec_pref_string(struct iax2_codec_pref *pref, char *buf, size_t size)
Dump audio codec preference list into a string.
void iax_firmware_unload(void)
static unsigned int fix_peerts(struct timeval *rxtrunktime, int callno, unsigned int ts)
static int peer_set_sock_cb(void *obj, void *arg, int flags)
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
struct iax2_codec_pref prefs
static int reload_config(int forced_reload)
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
static void iax2_process_thread_cleanup(void *data)
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
static void iax_error_output(const char *data)
static char * handle_cli_iax2_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show one peer in detail.
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
static struct ast_frame * iax2_read(struct ast_channel *c)
const ast_string_field mohsuggest
static struct ast_netsock_list * outsock
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
#define IAX_IE_AUTHMETHODS
static int iax2_provision(struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
static void __iax2_poke_peer_s(const void *data)
struct iax2_peer * peerpoke
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
void ast_var_delete(struct ast_var_t *var)
struct ast_mwi_subscriber * mwi_event_sub
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
static struct iax2_user * user_unref(struct iax2_user *user)
int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
char mohinterpret[MAX_MUSICCLASS]
const ast_string_field inkeys
const ast_string_field mohinterpret
static int iax2_sendtext(struct ast_channel *c, const char *text)
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Connected Line/Party information.
static void peercnt_modify(unsigned char reg, uint16_t limit, struct ast_sockaddr *sockaddr)
static int set_peercnt_limit_all_cb(void *obj, void *arg, int flags)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
static int min_reg_expire
int iax_get_iframes(void)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img)
static struct ast_channel_tech iax2_tech
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
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.
static int send_command_immediate(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static int transmit_frame(void *data)
const ast_string_field mohsuggest
static void save_osptoken(struct iax_frame *fr, struct iax_ies *ies)
Do not require call token validation.
static int iax2_poke_peer_cb(void *obj, void *arg, int flags)
#define ao2_iterator_next(iter)
#define ast_cond_destroy(cond)
static int iaxdynamicthreadnum
#define ao2_alloc(data_size, destructor_fn)
#define AST_PRES_NUMBER_NOT_AVAILABLE
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
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.
static const struct ast_datastore_info iax2_variable_datastore_info
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
const ast_string_field username
#define CALLNO_ENTRY_TO_PTR(a)
#define IAX_ALLOWFWDOWNLOAD
static int registry_rerequest(struct iax_ies *ies, int callno, struct ast_sockaddr *addr)
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes. ...
static int pvt_cmp_cb(void *obj, void *arg, int flags)
struct ast_format_cap * capabilities
const ast_string_field ani
static int maxjitterinterps
static struct ast_sched_context * sched
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
static struct ast_flags64 globalflags
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static int create_addr(const char *peername, struct ast_channel *c, struct ast_sockaddr *addr, struct create_addr_info *cai)
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
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 decrypt_frame(int callno, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
const ast_string_field host
static int iax2_encryption
static const char tdesc[]
static int manager_iax2_show_peers(struct mansession *s, const struct message *m)
callback to display iax peers in manager
static void vnak_retransmit(int callno, int last)
static int find_callno_locked(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
#define ast_channel_unlock(chan)
int iax_provision_reload(int reload)
#define IAX_TRANSFERMEDIA
static char version[AST_MAX_EXTENSION]
char context[AST_MAX_CONTEXT]
static int addr_range_hash_cb(const void *obj, const int flags)
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
static void parse_dial_string(char *data, struct parsed_dial_string *pds)
Parses an IAX dial string into its component parts.
static void __iax2_poke_noanswer(const void *data)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
static int iax2_sched_add(struct ast_sched_context *sched, int when, ast_sched_cb callback, const void *data)
#define AST_CAUSE_UNREGISTERED
struct iax2_trunk_peer::@115 list
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define ast_calloc(num, len)
A wrapper for calloc()
static unsigned char compress_subclass(iax2_format subclass)
int iax_firmware_append(struct iax_ie_data *ied, const char *dev, unsigned int desc)
AES_KEY ast_aes_decrypt_key
#define AST_OPTION_SECURE_SIGNALING
static int user_hash_cb(const void *obj, const int flags)
struct ast_var_t::@249 entries
static void cleanup_thread_list(void *head)
struct ast_endpoint * endpoint
#define AST_OPTION_AUDIO_MODE
#define ast_var_assign(name, value)
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
#define IAX_IE_CODEC_PREFS
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
static int set_config(const char *config_file, int reload, int forced)
Load configuration.
unsigned int frame_ending
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static int randomcalltokendata
unsigned char * trunkdata
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 int socket_process_helper(struct iax2_thread *thread)
static void insert_idle_thread(struct iax2_thread *thread)
#define IAX_RTIGNOREREGEXPIRE
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
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.
static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Module has failed to load, may be in an inconsistent state.
char callednum[AST_MAX_EXTENSION]
static int cache_get_callno_locked(const char *data)
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
Determine if this is an IPv4-mapped IPv6 address.
static int get_auth_methods(const char *value)
struct ast_variable * vars
#define DATASTORE_INHERIT_FOREVER
static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry)
char context[AST_MAX_EXTENSION]
#define ao2_find(container, arg, flags)
const ast_string_field cid_num
An API for managing task processing threads that can be shared across modules.
void(* schedfunc)(const void *)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
static int iaxthreadcount
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
static int iax2_trunk_expired(struct iax2_trunk_peer *tpeer, struct timeval *now)
static int iax2_getpeertrunk(struct ast_sockaddr addr)
static struct iax2_dpcache * find_cache(struct ast_channel *chan, const char *data, const char *context, const char *exten, int priority)
int(* ast_sched_cb)(const void *data)
scheduler callback
static void __auto_congest(const void *nothing)
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.
#define ast_set2_flag64(p, value, flag)
structure to hold users read from users.conf
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
static void * cleanup(void *unused)
static void reg_source_db(struct iax2_peer *p)
Structure used to handle boolean flags.
static void * network_thread(void *ignore)
static int iax2_poke_noanswer(const void *data)
static int create_callno_pools(void)
static char * handle_cli_iax2_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_clear_flag64(p, flag)
struct chan_iax2_pvt::@117 dpentries
#define IAX_DPSTATUS_CANEXIST
#define ast_clear_flag(p, flag)
#define IAX_CAPABILITY_MEDBANDWIDTH
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
static char cid_name[AST_MAX_EXTENSION]
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static char * regstate2str(int regstate)
static int check_access(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
static struct ast_cli_entry cli_iax2[]
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
char peercontext[AST_MAX_CONTEXT]
static void iax2_lock_owner(int callno)
static int user_cmp_cb(void *obj, void *arg, int flags)
static int expire_registry(const void *data)
const ast_string_field context
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
static int send_packet(struct iax_frame *f)
static void network_change_stasis_unsubscribe(void)
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
static struct iax2_user * find_user(const char *name)
stasis_subscription_cb callback
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 int start_network_thread(void)
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...
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.
struct ast_frame ast_null_frame
static char * handle_cli_iax2_set_mtu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Set trunk MTU from CLI.
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
#define IAX_IE_CALLINGTON
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN
unsigned char readbuf[4096]
#define EVENT_FLAG_REPORTING
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
static void remove_by_transfercallno(struct chan_iax2_pvt *pvt)
const ast_string_field secret
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
static int get_from_jb(const void *p)
char order[IAX2_CODEC_PREF_SIZE]
static ast_mutex_t callno_pool_lock
static void save_rr(struct iax_frame *fr, struct iax_ies *ies)
int transit_network_select
Transit Network Select.
struct ast_netsock * ast_netsock_find(struct ast_netsock_list *list, struct ast_sockaddr *addr)
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen)
struct iax2_thread::@123 ffinfo
const ast_string_field mohsuggest
static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
char * strsep(char **str, const char *delims)
struct ast_variable * vars
A ast_taskprocessor structure is a singleton by name.
#define AST_CAUSE_NO_ROUTE_DESTINATION
#define IAX_IE_CALLINGPRES
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.
#define AST_OPTION_FAX_DETECT
static struct stasis_subscription * acl_change_sub
struct iax2_dpcache::@120 peer_list
#define ast_channel_ref(c)
Increase channel reference count.
void iax_firmware_traverse(const char *filter, int(*callback)(struct ast_iax2_firmware_header *header, void *data), void *data)
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.
#define IAX_PROTO_VERSION
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
static struct io_context * io
static void merge_encryption(struct chan_iax2_pvt *p, unsigned int enc)
int ast_netsock_init(struct ast_netsock_list *list)
Standard Command Line Interface.
struct ast_acl_list * acl
static void update_jbsched(struct chan_iax2_pvt *pvt)
int ast_channel_hangupcause(const struct ast_channel *chan)
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_db_del(const char *family, const char *key)
Delete entry in astdb.
void ast_channel_context_set(struct ast_channel *chan, const char *value)
struct signaling_queue_entry * next
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int iaxdefaulttimeout
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_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
ast_app: A registered application
static void prune_peers(void)
const char * ast_channel_name(const struct ast_channel *chan)
static int transmit_trunk(struct iax_frame *f, struct ast_sockaddr *addr, int sockfd)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
#define IAX_IE_RR_DROPPED
static char * handle_cli_iax2_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int iax_provision_version(unsigned int *signature, const char *template, int force)
static void store_by_transfercallno(struct chan_iax2_pvt *pvt)
int AST_OPTIONAL_API_NAME() ast_aes_set_encrypt_key(const unsigned char *key, ast_aes_encrypt_key *ctx)
static void remove_by_peercallno(struct chan_iax2_pvt *pvt)
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
struct ast_channel * owner
static struct iax2_peer * peer_ref(struct iax2_peer *peer)
#define AST_CALLID_BUFFER_LENGTH
const ast_string_field mailbox
struct ast_sockaddr apparent_addr
static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int argc, const char *const argv[])
const ast_string_field cid_name
static int check_srcaddr(struct ast_sockaddr *addr)
Check if address can be used as packet source.
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr)
static int send_command(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
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.
static int apply_context(struct iax2_context *con, const char *context)
static void prune_users(void)
#define DEFAULT_TRUNKDATA
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.
struct ast_dnsmgr_entry * dnsmgr
#define AST_OPTION_FLAG_REQUEST
struct stasis_forward * sub
static char * handle_cli_iax2_show_callno_limits(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Data structure associated with a single frame of data.
static void jb_warning_output(const char *fmt,...)
struct iax2_codec_pref prefs
Internal Asterisk hangup causes.
static char regcontext[AST_MAX_CONTEXT]
static int authenticate_request(int call_num)
static int auth_reject(const void *data)
static struct ast_str * hostname
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
const char * ast_channel_language(const struct ast_channel *chan)
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 IAX_IE_RSA_RESULT
Abstract JSON element (object, array, string, int, ...).
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM]
static void encmethods_to_str(int e, struct ast_str **buf)
static int addr_range_cmp_cb(void *obj, void *arg, int flags)
static uint16_t global_maxcallno
struct ast_key *AST_OPTIONAL_API_NAME() ast_key_get(const char *kname, int ktype)
return the ast_key structure for name
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 iax2_do_register_s(const void *data)
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)
#define AST_OPTION_TONE_VERIFY
int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry)
Check is see if a dnsmgr entry has changed.
const ast_string_field cid_name
static void stop_stuff(int callno)
static int iax2_digit_begin(struct ast_channel *c, char digit)
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.
const char * ast_channel_context(const struct ast_channel *chan)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
int error(const char *format,...)
#define ast_frame_byteswap_be(fr)
#define IAX_IE_CALLED_CONTEXT
static int iax2_append_register(const char *hostname, const char *username, const char *secret, const char *porta)
#define IAX_AUTH_PLAINTEXT
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
#define ast_datastore_alloc(info, uid)
#define ast_set_flags_to64(p, flag, value)
union ast_frame::@263 data
static int pvt_hash_cb(const void *obj, const int flags)
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
#define IAX_ENCRYPT_AES128
static int __schedule_action(void(*func)(const void *data), const void *data, const char *funcname)
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.
#define IAX_IE_APPARENT_ADDR
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.
char context[AST_MAX_CONTEXT]
void iax_frame_free(struct iax_frame *fr)
static int iax2_hangup(struct ast_channel *c)
#define ast_mutex_init(pmutex)
const ast_string_field parkinglot
#define ast_channel_trylock(chan)
static struct call_number_pool callno_pool
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 int get_encrypt_methods(const char *s)
unsigned char valid
TRUE if the name information is valid/present.
static int attempt_transmit(const void *data)
void jb_destroy(jitterbuf *jb)
destroy jitterbuf
static char context[AST_MAX_CONTEXT]
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
Media Format Bitfield Compatibility API.
const ast_string_field dbsecret
#define ast_mutex_destroy(a)
static int last_authmethod
#define IAX_SENDCONNECTEDLINE
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.
const ast_string_field cid_name
#define AST_LIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list entry before the current entry during a traversal.
struct ast_format * format
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.
static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, struct timeval *now)
static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
static int iax2_prov_app(struct ast_channel *chan, const char *data)
static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers_context *cont, struct iax2_peer *peer)
const ast_string_field context
static int peer_delme_cb(void *obj, void *arg, int flags)
#define IAX_IE_TRANSFERID
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
struct timeval rxtrunktime
The structure that contains MWI state.
static int iax2_key_rotate(const void *vpvt)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define AST_CAUSE_CALL_REJECTED
static void spawn_dp_lookup(int callno, const char *context, const char *callednum, const char *callerid)
const ast_string_field secret
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...
static struct ast_timer * timer
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
static struct iax2_user * realtime_user(const char *username, struct ast_sockaddr *addr)
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Asterisk module definitions.
const ast_string_field cid_num
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
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.
static int iax2_queue_hold(int callno, const char *musicclass)
Queue a hold frame on the ast_channel owner.
static void peercnt_remove(struct peercnt *peercnt)
int AST_OPTIONAL_API_NAME() ast_aes_set_decrypt_key(const unsigned char *key, ast_aes_decrypt_key *ctx)
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
unconditionally get frames from jitterbuf until empty
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.
static snd_pcm_format_t format
static int global_rtautoclear
enum calltoken_peer_enum calltoken_required
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Persistant data storage (akin to *doze registry)
static void construct_rr(struct chan_iax2_pvt *pvt, struct iax_ie_data *iep)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static struct ao2_container * callno_limits
static char * handle_cli_iax2_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define IAX_MAX_OSPBUFF_SIZE
static struct ast_switch iax2_switch
unsigned char valid
TRUE if the number information is valid/present.
static int peer_cmp_cb(void *obj, void *arg, int flags)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
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. ...
struct ast_sockaddr transfer
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ast_cond_timedwait(cond, mutex, time)
static struct ast_custom_function iaxvar_function
static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
static int peercnt_cmp_cb(void *obj, void *arg, int flags)
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
#define ast_custom_function_register(acf)
Register a custom function.
static int iax2_do_register(struct iax2_registry *reg)
#define AST_CAUSE_CONGESTION
void AST_OPTIONAL_API_NAME() ast_aes_decrypt(const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *ctx)
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
static void build_callno_limits(struct ast_variable *v)
#define IAX_IE_CAPABILITY
#define AST_BRIDGE_DTMF_CHANNEL_0
Report DTMF on channel 0.
struct iax2_thread::@122 list
Timing source management.
#define AST_MUTEX_DEFINE_STATIC(mutex)
static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
struct ast_sockaddr ioaddr
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
const ast_string_field peercontext
Structure for mutex and tracking information.
static int peercnt_remove_by_addr(struct ast_sockaddr *addr)
static int iax2_is_control_frame_allowed(int subtype)
static void memcpy_encrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_encrypt_key *ecx)
static int addr_range_match_address_cb(void *obj, void *arg, int flags)
#define CALLTOKEN_IE_FORMAT
unsigned int trunkdataalloc
static iax2_format iax2_capability
static int add_calltoken_ignore(const char *addr)
static int transfercallno_pvt_cmp_cb(void *obj, void *arg, int flags)
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
#define ast_mutex_unlock(a)
struct iax2_codec_pref prefs
struct ast_acl_list * acl
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.
struct ast_sockaddr defaddr
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to)
Copy the contents of one HA to another.
static void peer_destructor(void *obj)
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static void __expire_registry(const void *data)
#define IAX_DPSTATUS_EXISTS
void jb_reset(jitterbuf *jb)
reset jitterbuf
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
static struct ao2_container * peercnts
#define DEFAULT_FREQ_NOTOK
static int raw_hangup(struct ast_sockaddr *addr, unsigned short src, unsigned short dst, int sockfd)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
static char * handle_cli_iax2_show_firmware(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_party_number number
Subscriber phone number.
static int auth_fail(int callno, int failcode)
#define ast_test_flag64(p, flag)
#define ast_module_ref(mod)
Hold a reference to the module.
#define ao2_link(container, obj)
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...