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;