479 { \
480 int idx; \
481 char digest[33] = ""; \
482 \
484 break; \
485 \
486 for (idx = 0; idx < 16; idx++) \
487 sprintf(digest + (idx << 1), "%02hhx", (unsigned char) key[idx]); \
488 \
489 ast_log(
LOG_NOTICE, msg
" IAX_COMMAND_RTKEY to rotate key to '%s'\n", digest); \
490 } while(0)
491
494
496
498
500
502#ifdef IAXTESTS
503static int test_late = 0;
504static int test_resync = 0;
505static int test_jit = 0;
506static int test_jitpct = 0;
507#endif
508
517
519
521
526};
527
531};
532
533
534#define IAX_HASCALLERID (uint64_t)(1LLU << 0)
535#define IAX_DELME (uint64_t)(1LLU << 1)
536#define IAX_TEMPONLY (uint64_t)(1LLU << 2)
537#define IAX_TRUNK (uint64_t)(1LLU << 3)
538#define IAX_NOTRANSFER (uint64_t)(1LLU << 4)
539#define IAX_USEJITTERBUF (uint64_t)(1LLU << 5)
540#define IAX_DYNAMIC (uint64_t)(1LLU << 6)
541#define IAX_SENDANI (uint64_t)(1LLU << 7)
542#define IAX_RTSAVE_SYSNAME (uint64_t)(1LLU << 8)
543#define IAX_ALREADYGONE (uint64_t)(1LLU << 9)
544#define IAX_PROVISION (uint64_t)(1LLU << 10)
545#define IAX_QUELCH (uint64_t)(1LLU << 11)
546#define IAX_ENCRYPTED (uint64_t)(1LLU << 12)
547#define IAX_KEYPOPULATED (uint64_t)(1LLU << 13)
548#define IAX_CODEC_USER_FIRST (uint64_t)(1LLU << 14)
549#define IAX_CODEC_NOPREFS (uint64_t)(1LLU << 15)
550#define IAX_CODEC_NOCAP (uint64_t)(1LLU << 16)
551#define IAX_RTCACHEFRIENDS (uint64_t)(1LLU << 17)
552#define IAX_RTUPDATE (uint64_t)(1LLU << 18)
553#define IAX_RTAUTOCLEAR (uint64_t)(1LLU << 19)
554#define IAX_RTIGNOREREGEXPIRE (uint64_t)(1LLU << 21)
555#define IAX_TRUNKTIMESTAMPS (uint64_t)(1LLU << 22)
556#define IAX_TRANSFERMEDIA (uint64_t)(1LLU << 23)
557#define IAX_MAXAUTHREQ (uint64_t)(1LLU << 24)
558#define IAX_DELAYPBXSTART (uint64_t)(1LLU << 25)
559#define IAX_ALLOWFWDOWNLOAD (uint64_t)(1LLU << 26)
560#define IAX_IMMEDIATE (uint64_t)(1LLU << 27)
561#define IAX_SENDCONNECTEDLINE (uint64_t)(1LLU << 28)
562#define IAX_RECVCONNECTEDLINE (uint64_t)(1LLU << 29)
563#define IAX_FORCE_ENCRYPT (uint64_t)(1LLU << 30)
564#define IAX_SHRINKCALLERID (uint64_t)(1LLU << 31)
566
568
569
570
571
573
575
577
578
580
582};
583
597 );
598
612};
613
622
630
635 );
644
645
649
653
654
659
665
667
670
672};
673
674#define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
675
685
693};
694
696
705};
706
719};
720
735};
736
738
739
740#define MIN_RETRY_TIME 100
741#define MAX_RETRY_TIME 10000
742
743#define MAX_JITTER_BUFFER 50
744#define MIN_JITTER_BUFFER 10
745
746#define DEFAULT_TRUNKDATA 640 * 10
747
748#define MAX_TIMESTAMP_SKEW 160
749
750
751#define TS_GAP_FOR_JB_RESYNC 5000
752
753
754#define MARK_IAX_SUBCLASS_TX 0x8000
755
761
770};
771
772struct iax2_pvt_ref;
773
774
775
777
779
781
783
785
787
789
791
793
795
797
799
801
803
805
807
809
811
813
815
817
819
821
823
824
825
826
828
830
832
834
836
838
840
842
844
846
848
850
852
854
856
858
860
862
864
867
869
871
873
875
877
879
881
883
885
887
889
894
896
898 );
899
901
903
905
907
909
911
913
914
916
918
920
922
925
926
928
930
932
934
936
937
939
940
942
955
957
959
961
963
965
967
969
971
973
975};
976
980};
981
985};
986
987#define PTR_TO_CALLNO_ENTRY(a) ((uint16_t)(unsigned long)(a))
988#define CALLNO_ENTRY_TO_PTR(a) ((void *)(unsigned long)(a))
989
990#define CALLNO_ENTRY_SET_VALIDATED(a) ((a) |= 0x8000)
991#define CALLNO_ENTRY_IS_VALIDATED(a) ((a) & 0x8000)
992#define CALLNO_ENTRY_GET_CALLNO(a) ((a) & 0x7FFF)
993
998};
999
1001
1002
1004
1005
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1018
1020
1022
1024
1025
1026
1027
1028
1029
1030
1031
1032#ifdef LOW_MEMORY
1033#define MAX_PEER_BUCKETS 17
1034#else
1035#define MAX_PEER_BUCKETS 563
1036#endif
1038
1039#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
1041
1042
1044
1045
1047
1048
1050
1052
1054
1056
1057
1059
1061
1062
1063
1065
1067
1069
1071
1072
1074};
1075
1076
1078
1080
1082
1083 unsigned char delme;
1084};
1085
1086enum {
1087
1089
1091
1093
1095
1097
1099
1101
1103};
1104
1108 struct timeval
orig;
1115};
1116
1118
1122
1126
1132};
1133
1137};
1138
1142 unsigned char buf[1];
1143};
1144
1149#ifdef SCHED_MULTITHREADED
1152#endif
1153#ifdef DEBUG_SCHED_MULTITHREAD
1155#endif
1170
1171
1172
1173
1174 struct {
1175 unsigned short callno;
1178 unsigned char csub;
1180
1181
1182
1185};
1186
1187
1191
1194
1196{
1200}
1201
1202
1203
1204
1205
1206
1207
1208
1209
1211
1213{
1215}
1216
1218{
1220}
1221
1223{
1228}
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1240
1241
1242
1243
1244
1245
1246
1247
1249
1250
1251
1252
1253
1254
1256
1257
1258
1259#define TRUNK_CALL_START (IAX_MAX_CALLS / 2)
1260
1261
1263
1265{
1271
1274 } else {
1278 }
1279 }
1280}
1281
1283{
1286}
1287
1289{
1291}
1292
1293static void __attribute__((format(printf, 1, 2)))
jb_error_output(const
char *fmt, ...)
1294{
1297
1298 va_start(
args, fmt);
1301
1303}
1304
1305static void __attribute__((format(printf, 1, 2)))
jb_warning_output(const
char *fmt, ...)
1306{
1309
1310 va_start(
args, fmt);
1313
1315}
1316
1317static void __attribute__((format(printf, 1, 2)))
jb_debug_output(const
char *fmt, ...)
1318{
1321
1322 va_start(
args, fmt);
1325
1327}
1328
1350
1355static int send_command_locked(
unsigned short callno,
char,
int,
unsigned int,
const unsigned char *,
int,
int);
1366
1377
1380 .description =
tdesc,
1401};
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1419{
1420 for (;;) {
1421 if (!
iaxs[callno] || !
iaxs[callno]->owner) {
1422
1423 break;
1424 }
1426
1427 break;
1428 }
1429
1431 }
1432}
1433
1434
1435
1436
1437
1438
1439
1440
1441
1443{
1445 int is_allowed;
1446
1447
1448
1449
1450
1451
1452 if (subtype == -1) {
1453 return -1;
1454 }
1455
1456
1457 is_allowed = 0;
1458
1459
1460
1461
1462
1463 switch (control) {
1464
1465
1466
1491 is_allowed = -1;
1492 break;
1493
1494
1495
1496
1498
1500
1502
1504
1506
1508
1510
1512
1514
1516
1518
1520
1528
1533
1534 break;
1535 }
1536 return is_allowed;
1537}
1538
1540{
1546 }
1547}
1548
1550{
1552}
1553
1555{
1561 }
1562}
1563
1565{
1567}
1568
1570{
1576 }
1578
1579 return 0;
1580}
1581
1584{
1585
1587 return;
1588 }
1589
1590 ast_verb(1,
"IAX, got a network change message, renewing all IAX registrations.\n");
1593 }
1594}
1595
1598{
1600 return;
1601 }
1602
1605}
1606
1608 .
type =
"IAX2_VARIABLE",
1611};
1612
1614{
1617
1619 if (!newlist) {
1622 }
1623
1628 if (newvar)
1630 else
1632 }
1634 return newlist;
1635}
1636
1638{
1641
1645 }
1649}
1650
1651
1652
1653
1654
1656{
1661 } else {
1665 }
1666
1667 return;
1668}
1669
1671{
1673
1674
1678
1679
1683 }
1684
1685
1689
1690
1694 }
1695
1696
1699
1700
1704
1705
1711
1712
1721 }
1722
1723
1724
1726
1727
1729
1730
1732
1734}
1735
1736#ifdef SCHED_MULTITHREADED
1737static int __schedule_action(
void (*func)(
const void *data),
const void *data,
const char *funcname)
1738{
1740 static time_t lasterror;
1741 time_t t;
1742
1745 thread->schedfunc = func;
1746 thread->scheddata = data;
1748#ifdef DEBUG_SCHED_MULTITHREAD
1750#endif
1752 return 0;
1753 }
1754 time(&t);
1755 if (t != lasterror) {
1756 lasterror = t;
1757 ast_debug(1,
"Out of idle IAX2 threads for scheduling! (%s)\n", funcname);
1758 }
1759
1760 return -1;
1761}
1762#define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
1763#endif
1764
1767{
1769}
1770
1773{
1775}
1776
1777
1778
1779
1780
1781
1782
1784{
1786
1787
1788
1790 ast_debug(3,
"I wanted to lock callno %d, but it is dead or going to die.\n",
callno);
1792 return 0;
1793 }
1794
1795
1796 return 1;
1797}
1798
1800
1802{
1804
1806 ast_debug(3,
"Hangup initiated on call %d, aborting __send_ping\n",
callno);
1807 return;
1808 }
1809
1810
1812
1813
1815
1817
1818
1820 }
1821
1823}
1824
1826{
1827#ifdef SCHED_MULTITHREADED
1829#endif
1831
1832 return 0;
1833}
1834
1836{
1840 }
1843 }
1846 } else {
1848 }
1849}
1850
1852{
1853 int e;
1854 if (!strcasecmp(s, "aes128"))
1858 else
1859 e = 0;
1860 return e;
1861}
1862
1864
1866{
1868
1870 ast_debug(3,
"Hangup initiated on call %d, aborting __send_lagrq\n",
callno);
1871 return;
1872 }
1873
1874
1876
1877
1879
1881
1882
1884 }
1885
1887}
1888
1890{
1891#ifdef SCHED_MULTITHREADED
1893#endif
1895 return 0;
1896}
1897
1899{
1900 int x;
1901 int power=-1;
1902
1904 return subclass;
1905
1907 if (subclass & (1LL << x)) {
1908 if (power > -1) {
1910 return 0;
1911 } else
1912 power = x;
1913 }
1914 }
1916}
1917
1919{
1920
1922
1924 return -1;
1925 else
1927 }
1928 else
1930}
1931
1933{
1934 int x;
1936
1939 uint64_t pref_bitfield;
1940
1942 if (!pref_bitfield) {
1943 break;
1944 }
1945
1947 if (!pref_format) {
1948
1949 continue;
1950 }
1952 if (found_format) {
1953 break;
1954 }
1955 }
1956
1958 return found_format;
1959 }
1960
1961 ast_debug(4,
"Could not find preferred codec - Returning zero codec.\n");
1964}
1965
1967{
1971
1975 if (!tmpfmt) {
1977 return 0;
1978 }
1979
1983 }
1984
1985 return format;
1986}
1987
1989{
1991
1993 if (!tmpfmt) {
1994 return "Unknown";
1995 }
1996
1998}
1999
2001{
2003
2004 if (!cap) {
2005 return "(Nothing)";
2006 }
2010
2012}
2013
2015{
2016 int res, i;
2018
2019
2023 return 1;
2024 }
2025
2027
2028
2031
2034
2037 }
2038
2040
2041 return res;
2042}
2043
2044
2045
2046
2047static int peer_hash_cb(
const void *obj,
const int flags)
2048{
2050 const char *
name = obj;
2051
2053}
2054
2055
2056
2057
2059{
2060 struct iax2_peer *peer = obj, *peer2 = arg;
2061 const char *
name = arg;
2062
2065}
2066
2067
2068
2069
2071{
2073 const char *
name = obj;
2074
2076}
2077
2078
2079
2080
2082{
2084 const char *
name = arg;
2085
2088}
2089
2090
2091
2092
2093
2095{
2097
2099
2100
2101 if (!peer && realtime) {
2103 }
2104 return peer;
2105}
2106
2108{
2110 return peer;
2111}
2112
2114{
2117}
2118
2120{
2122}
2123
2125{
2128}
2129
2131{
2133 int res = 0;
2135
2138
2142 res = 1;
2143 break;
2144 }
2146 }
2148
2149 if (!peer) {
2151 if (peer) {
2154 res = 1;
2155 }
2156 }
2157
2158 return res;
2159}
2160
2161
2163{
2165
2167
2168 return 0;
2169}
2170
2171
2172
2174{
2175
2178
2183 }
2184
2186 }
2187
2188
2189
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2204
2207
2213}
2214
2216{
2219}
2220
2222{
2226 ast_debug(1,
"Really destroying %d now...\n", callno);
2228 }
2230 return 0;
2231}
2232
2234{
2237 }
2239}
2240
2241
2242
2244{
2246
2250 }
2252}
2253
2254
2255
2257{
2259
2261 return 1;
2263 return -1;
2264 }
2265
2266
2269
2272 return -1;
2273 }
2275 }
2277
2278 return 0;
2279}
2280
2282{
2286
2288
2290
2293
2294
2296
2298
2300 }
2301
2303
2306 }
2307
2310 }
2311
2317 }
2318
2321 }
2322
2325 }
2326}
2327
2329{
2332
2335 }
2336
2344
2349 }
2350
2352
2355
2362
2364
2367
2368 return tmp;
2369}
2370
2372{
2374 if (new) {
2376 memcpy(new, fr, sizeof(*new));
2380 new->datalen = 0;
2382 new->retrans = -1;
2383 }
2384 return new;
2385}
2386
2387
2388enum {
2389
2391
2393
2395
2396
2398};
2399
2401{
2403
2406
2407 return 1;
2408 }
2409 }
2411
2413 return 1;
2414 }
2415 return 0;
2416}
2417
2419{
2420 int x;
2421 int res= 0;
2425 return -1;
2426 }
2429 return -1;
2430 }
2431
2435 &entry)) {
2437 return -1;
2438 }
2439
2442
2443
2444
2445
2446
2452
2453
2454
2461
2462 }
2464
2466
2471
2472 if (locked)
2474 res = x;
2475 if (!locked)
2477
2478
2480
2481 return res;
2482}
2483
2485{
2487 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2488 return;
2489 }
2490
2492}
2493
2495{
2497 ast_log(
LOG_ERROR,
"This should not be called without a transfer call number.\n");
2498 return;
2499 }
2500
2502}
2504{
2506 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2507 return;
2508 }
2509
2511}
2512
2514{
2516 ast_log(
LOG_ERROR,
"This should not be called without a peer call number.\n");
2517 return;
2518 }
2519
2521}
2522
2524{
2527 return 0;
2528}
2529
2531{
2534}
2535
2537{
2542}
2543
2545{
2547
2549 return 0;
2550 }
2552}
2553
2555{
2556 struct peercnt *peercnt1 = obj, *peercnt2 = arg;
2558}
2559
2561{
2565
2567
2570 }
2571 return 0;
2572}
2573
2574
2575
2576
2577
2578
2580{
2584
2585 const char *find =
S_OR(
name,
"guest");
2586 int res = 1;
2587 int optional = 0;
2589
2590
2591
2592
2593
2594
2595
2598 optional = 1;
2599 }
2600
2601
2610 }
2611
2612 if (peer) {
2614 }
2617 }
2618
2622 res = 0;
2623 }
2624
2625 return res;
2626}
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2639{
2643
2645
2647 return;
2648 }
2649
2654 }
2655
2657}
2658
2659
2660
2661
2662
2664{
2666
2668 ast_debug(1,
"Reset limits for peercnts table\n");
2669
2670 return 0;
2671}
2672
2673
2674
2675
2676
2678{
2680
2682}
2683
2684
2685
2686
2687
2689{
2690
2693
2695
2700 } else {
2702 }
2705 }
2706}
2707
2708
2709
2710
2711
2712
2713
2714
2715
2717{
2719 int res = 0;
2721
2723
2724
2725
2726
2727
2728
2729
2735
2738
2739
2741 } else {
2743 return -1;
2744 }
2745
2746
2750 } else {
2752 res = -1;
2753 }
2754
2755
2759
2760 return res;
2761}
2762
2763
2764
2765
2766
2768{
2770
2772
2773
2774
2775
2776
2777
2778
2782
2785 }
2787}
2788
2789
2790
2791
2792
2794{
2796
2799
2800 return 0;
2801}
2802
2803
2804
2805
2806
2808{
2811
2813
2817 }
2818 return 0;
2819}
2820
2821
2822
2823
2824
2826{
2830 int limit;
2832 int found;
2833
2834 for (; v; v = v->
next) {
2835 limit = -1;
2837 found = 0;
2839
2840
2841 if (error) {
2842 ast_log(
LOG_ERROR,
"Call number limit for %s could not be added, Invalid address range\n.", v->
name);
2843 continue;
2844 }
else if ((sscanf(v->
value,
"%d", &limit) != 1) || (limit < 0)) {
2847 continue;
2848 }
2849
2851
2854 found = 1;
2857 return;
2858 }
2859
2860
2865
2866
2867 if (found) {
2869 } else {
2871 }
2873 }
2874}
2875
2876
2877
2878
2879
2881{
2886
2889 return -1;
2890 }
2891
2893
2894
2895 if (error) {
2897 return -1;
2898 }
2899
2901
2907
2910 } else {
2912 return -1;
2913 }
2914
2917
2918 return 0;
2919}
2920
2922{
2926 int found = 0;
2927
2928 switch (cmd) {
2930 e->
command =
"iax2 show callnumber usage";
2932 "Usage: iax2 show callnumber usage [IP address]\n"
2933 " Shows current IP addresses which are consuming iax2 call numbers\n";
2938 if (
a->argc < 4 ||
a->argc > 5)
2940
2942 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2943 }
2944
2948
2951 ast_cli(
a->fd,
"%-45s %-12s %-12s\n",
"Address",
"Callno Usage",
"Callno Limit");
2954 found = 1;
2955 break;
2956 }
2957 } else {
2959 }
2961 }
2963
2967
2968 ast_cli(
a->fd,
"\nNon-CallToken Validation Callno Limit: %d\n"
2969 "Non-CallToken Validated Callno Used: %d\n",
2972
2973 ast_cli(
a->fd,
"Total Available Callno: %zu\n"
2974 "Regular Callno Available: %zu\n"
2975 "Trunk Callno Available: %zu\n",
2976 pool_avail + trunk_pool_avail,
2977 pool_avail,
2978 trunk_pool_avail);
2979 }
else if (
a->argc == 5 && !found) {
2980 ast_cli(
a->fd,
"No call number table entries for %s found\n",
a->argv[4] );
2981 }
2982
2983
2985 default:
2987 }
2988}
2989
2991{
2994 size_t choice;
2995
2999 break;
3002 break;
3003 default:
3005 break;
3006 }
3007
3008
3009 *entry = 0;
3010
3011
3012
3014
3015
3019 return 1;
3020 }
3021
3022
3023
3024
3027 "NON-CallToken callnumber limit is reached. Current: %d Max: %d\n",
3031 return 1;
3032 }
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3049
3050 *entry = pool->
numbers[choice];
3052
3055
3056 if (validated) {
3058 } else {
3060 }
3061
3063
3064 return 0;
3065}
3066
3068{
3071
3072
3073
3075
3079 } else {
3081 "Attempted to decrement total non calltoken validated "
3082 "callnumbers below zero. Callno is: %d\n",
3084 }
3085 }
3086
3089 } else {
3091 }
3092
3094
3095
3097
3100
3102
3103 return 0;
3104}
3105
3107{
3108 uint16_t i;
3109
3111
3112
3116 }
3117
3121 }
3122
3125
3127
3128 return 0;
3129}
3130
3131
3132
3133
3134
3135
3136
3137
3138
3140{
3141 int i;
3144
3146
3148
3151 if (i == -1) {
3153 }
3154 }
3155
3161}
3162
3163
3164
3165
3166
3167
3168
3169
3171{
3173 return 0;
3174 }
3175 switch (subclass) {
3180 return 1;
3182 if (!inbound) {
3183 return 1;
3184 }
3185 break;
3186 }
3187 return 0;
3188}
3189
3190
3191
3192
3193static int __find_callno(
unsigned short callno,
unsigned short dcallno,
struct ast_sockaddr *
addr,
int new,
int sockfd,
int return_locked,
int check_dcallno)
3194{
3195 int res = 0;
3196 int x;
3197
3198
3199 int validated = (
new >
NEW_ALLOW) ? 1 : 0;
3200 char host[80];
3201
3203 if (callno) {
3208 .transfercallno =
callno,
3209
3210 .frames_received = check_dcallno,
3211 };
3212
3214
3216 if (return_locked) {
3218 }
3222 return res;
3223 }
3224
3225 memset(&tmp_pvt.
addr, 0,
sizeof(tmp_pvt.
addr));
3228 if (return_locked) {
3230 }
3234 return res;
3235 }
3236 }
3237
3238
3239 if (dcallno) {
3241 }
3244 res = dcallno;
3246 if (!res || !return_locked) {
3248 }
3249 return res;
3250 }
3251 if (dcallno) {
3253 }
3254 }
3257
3258
3259
3260
3261
3262
3263
3266
3268
3269
3270 return 0;
3271 }
3272
3274
3275
3278 return 0;
3279 }
3282
3286 ast_debug(1,
"Creating new call structure %d\n", x);
3302
3305 }
3306 } else {
3310 return 0;
3311 }
3312 if (!return_locked)
3314 res = x;
3315 }
3316 return res;
3317}
3318
3321}
3322
3324
3326}
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3339{
3344 }
3345 return 0;
3346}
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3362{
3367 }
3368 return 0;
3369}
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3385{
3390 }
3391 return 0;
3392}
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3408{
3413 }
3414 return 0;
3415}
3416
3417
3418
3419
3420
3421
3422
3423
3424
3426{
3427
3428
3434
3436
3437 return 0;
3438}
3439
3441{
3442
3443
3444
3445#if 0
3446 struct sockaddr_in *sin;
3447 int res;
3448 struct msghdr m;
3449 struct sock_extended_err e;
3451 m.msg_namelen = 0;
3453 m.msg_control = &e;
3454 m.msg_controllen = sizeof(e);
3455 m.msg_flags = 0;
3456 res = recvmsg(
netsocket, &m, MSG_ERRQUEUE);
3457 if (res < 0)
3459 else {
3460 if (m.msg_controllen) {
3461 sin = (struct sockaddr_in *)SO_EE_OFFENDER(&e);
3462 if (sin)
3464 else
3466 } else {
3468 }
3469 }
3470#endif
3471 return 0;
3472}
3473
3475{
3476 int res;
3478
3479 if (res < 0) {
3482 } else
3483 res = 0;
3484 return res;
3485}
3486
3488{
3489 int res;
3491
3492
3493 if (!callno || !
iaxs[callno] ||
iaxs[callno]->error)
3494 return -1;
3495
3496
3499 }
3503 } else {
3506 }
3507 if (res < 0) {
3511 } else
3512 res = 0;
3513
3514 return res;
3515}
3516
3517
3518
3519
3520
3522{
3525
3526 if (!pvt)
3527 return -1;
3528
3532 }
3533
3539 }
3540
3541 return 0;
3542}
3543
3545{
3548
3549retry:
3550 if ((pvt =
iaxs[callno])) {
3551#if 0
3552
3553
3554
3555
3556
3557
3558
3560#endif
3561 }
3562
3564
3565 if (owner) {
3567 ast_debug(3,
"Avoiding IAX destroy deadlock\n");
3569 goto retry;
3570 }
3571 }
3572
3573 if (!owner) {
3575 }
3576
3577 if (pvt) {
3578 if (!owner) {
3580 } else {
3581
3582
3583
3585 }
3586
3589 }
3590
3593 }
3594
3595 if (!owner) {
3598 }
3599 }
3600
3601 if (owner) {
3603 }
3604}
3605
3607{
3608
3611
3612
3615 }
3616
3618
3621
3622
3624
3625
3628 }
3629 return 0;
3630}
3631
3634{
3635
3636
3638 int freeme = 0;
3640
3641
3646
3647 freeme = 1;
3649
3651
3653 }
else if (f->
final) {
3655 } else {
3657 ast_log(
LOG_WARNING,
"Max retries exceeded to host %s on %s (type = %u, subclass = %d, ts=%u, seqno=%d)\n",
3664 }
3668
3670
3671 if (
iaxs[callno] &&
iaxs[callno]->owner)
3673 } else {
3674 if (
iaxs[callno]->reg) {
3675 memset(&
iaxs[callno]->reg->us, 0,
sizeof(
iaxs[callno]->
reg->
us));
3678 }
3680 }
3681 }
3682 freeme = 1;
3683 } else {
3684
3686
3689
3693
3697 }
3698 } else {
3699
3701 freeme = 1;
3702 }
3703
3704 if (freeme) {
3705
3709
3711 } else if (callno) {
3713 }
3714}
3715
3717{
3718#ifdef SCHED_MULTITHREADED
3720#endif
3722 return 0;
3723}
3724
3726{
3729 static const char *
const choices[] = {
"all",
NULL };
3730 char *cmplt;
3731
3732 switch (cmd) {
3734 e->
command =
"iax2 prune realtime";
3736 "Usage: iax2 prune realtime [<peername>|all]\n"
3737 " Prunes object(s) from the cache\n";
3742 if (!cmplt)
3744 return cmplt;
3745 }
3747 }
3750 if (!strcmp(
a->argv[3],
"all")) {
3753 ast_cli(
a->fd,
"Cache flushed successfully.\n");
3755 }
3759 if (peer) {
3763 ast_cli(
a->fd,
"Peer %s was removed from the cache.\n",
a->argv[3]);
3764 } else {
3765 ast_cli(
a->fd,
"Peer %s is not eligible for this operation.\n",
a->argv[3]);
3766 }
3768 }
3772 ast_cli(
a->fd,
"User %s was removed from the cache.\n",
a->argv[3]);
3773 } else {
3774 ast_cli(
a->fd,
"User %s is not eligible for this operation.\n",
a->argv[3]);
3775 }
3778 }
3779 } else {
3780 ast_cli(
a->fd,
"%s was not found in the cache.\n",
a->argv[3]);
3781 }
3782
3784}
3785
3787{
3788 switch (cmd) {
3790 e->
command =
"iax2 test losspct";
3792 "Usage: iax2 test losspct <percentage>\n"
3793 " For testing, throws away <percentage> percent of incoming packets\n";
3797 }
3800
3802
3804}
3805
3806#ifdef IAXTESTS
3808{
3809 switch (cmd) {
3811 e->
command =
"iax2 test late";
3813 "Usage: iax2 test late <ms>\n"
3814 " For testing, count the next frame as <ms> ms late\n";
3818 }
3819
3822
3823 test_late = atoi(
a->argv[3]);
3824
3826}
3827
3829{
3830 switch (cmd) {
3832 e->
command =
"iax2 test resync";
3834 "Usage: iax2 test resync <ms>\n"
3835 " For testing, adjust all future frames by <ms> ms\n";
3839 }
3840
3843
3844 test_resync = atoi(
a->argv[3]);
3845
3847}
3848
3850{
3851 switch (cmd) {
3853 e->
command =
"iax2 test jitter";
3855 "Usage: iax2 test jitter <ms> <pct>\n"
3856 " For testing, simulate maximum jitter of +/- <ms> on <pct>\n"
3857 " percentage of packets. If <pct> is not specified, adds\n"
3858 " jitter to all packets.\n";
3862 }
3863
3864 if (
a->argc < 4 ||
a->argc > 5)
3866
3867 test_jit = atoi(
a->argv[3]);
3869 test_jitpct = atoi(
a->argv[4]);
3870
3872}
3873#endif
3874
3875
3876
3878{
3879 int res = 0;
3884 snprintf(
status, statuslen,
"LAGGED (%d ms)", peer->
lastms);
3885 res = 1;
3886 }
else if (peer->
lastms) {
3887 snprintf(
status, statuslen,
"OK (%d ms)", peer->
lastms);
3888 res = 1;
3889 } else {
3891 }
3892 } else {
3894 res = -1;
3895 }
3896 return res;
3897}
3898
3899
3901{
3903 char cbuf[256];
3907 int load_realtime = 0;
3908
3909 switch (cmd) {
3911 e->
command =
"iax2 show peer";
3913 "Usage: iax2 show peer <name>\n"
3914 " Display details on specific IAX peer\n";
3920 }
3921
3924
3925 load_realtime = (
a->argc == 5 && !strcmp(
a->argv[4],
"load")) ? 1 : 0;
3926
3928 if (peer) {
3929 char *str_addr, *str_defaddr;
3930 char *str_port, *str_defport;
3931
3936
3953 ast_cli(
a->fd,
" Addr->IP : %s Port %s\n", str_addr ? str_addr :
"(Unspecified)", str_port);
3954 ast_cli(
a->fd,
" Defaddr->IP : %s Port %s\n", str_defaddr, str_defport);
3957
3959 strcpy(cbuf, "Error");
3960 }
3961 ast_cli(
a->fd,
" Codec Order : %s\n", cbuf);
3962
3968 } else {
3969 ast_cli(
a->fd,
"Peer %s not found.\n",
a->argv[3]);
3971 }
3972
3974}
3975
3977{
3978 int which = 0;
3981 int wordlen = strlen(
word);
3983
3986 if (!strncasecmp(peer->
name,
word, wordlen) && ++which >
state
3990 break;
3991 }
3993 }
3995
3996 return res;
3997}
3998
4000{
4002 int cnt = 0, dead = 0, final = 0, i = 0;
4003
4004 switch (cmd) {
4006 e->
command =
"iax2 show stats";
4008 "Usage: iax2 show stats\n"
4009 " Display statistics on IAX channel driver.\n";
4013 }
4014
4017
4022 dead++;
4024 final++;
4025 cnt++;
4026 }
4028 }
4029
4030 ast_cli(
a->fd,
" IAX Statistics\n");
4031 ast_cli(
a->fd,
"---------------------\n");
4035 ast_cli(
a->fd,
"Packets in transmit queue: %d dead, %d final, %d total\n\n", dead,
final, cnt);
4036
4040
4042}
4043
4044
4046{
4047 int mtuv;
4048
4049 switch (cmd) {
4053 "Usage: iax2 set mtu <value>\n"
4054 " Set the system-wide IAX IP mtu to <value> bytes net or\n"
4055 " zero to disable. Disabling means that the operating system\n"
4056 " must handle fragmentation of UDP packets when the IAX2 trunk\n"
4057 " packet exceeds the UDP payload size. This is substantially\n"
4058 " below the IP mtu. Try 1240 on ethernets. Must be 172 or\n"
4059 " greater for G.711 samples.\n";
4063 }
4064
4067 if (strncasecmp(
a->argv[3],
"default", strlen(
a->argv[3])) == 0)
4069 else
4070 mtuv = atoi(
a->argv[3]);
4071
4072 if (mtuv == 0) {
4076 }
4077 if (mtuv < 172 || mtuv > 4000) {
4078 ast_cli(
a->fd,
"Trunk MTU must be between 172 and 4000\n");
4080 }
4084}
4085
4087{
4089 char tmp[1024], *pc =
NULL;
4090 int s, x, y;
4092
4093 switch (cmd) {
4095 e->
command =
"iax2 show cache";
4097 "Usage: iax2 show cache\n"
4098 " Display currently cached IAX Dialplan results.\n";
4102 }
4103
4105
4106 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8.8s %s\n",
"Peer/Context",
"Exten",
"Exp.",
"Wait.",
"Flags");
4107
4109 s = dp->
expiry.tv_sec - now.tv_sec;
4110 tmp[0] = '\0';
4112 strncat(tmp, "EXISTS|", sizeof(tmp) - strlen(tmp) - 1);
4114 strncat(tmp, "NONEXISTENT|", sizeof(tmp) - strlen(tmp) - 1);
4116 strncat(tmp, "CANEXIST|", sizeof(tmp) - strlen(tmp) - 1);
4118 strncat(tmp, "PENDING|", sizeof(tmp) - strlen(tmp) - 1);
4120 strncat(tmp, "TIMEOUT|", sizeof(tmp) - strlen(tmp) - 1);
4122 strncat(tmp, "TRANSMITTED|", sizeof(tmp) - strlen(tmp) - 1);
4124 strncat(tmp, "MATCHMORE|", sizeof(tmp) - strlen(tmp) - 1);
4126 strncat(tmp, "UNKNOWN|", sizeof(tmp) - strlen(tmp) - 1);
4127
4129 tmp[strlen(tmp) - 1] = '\0';
4130 } else {
4132 }
4133 y = 0;
4135 if (!pc) {
4137 } else {
4138 pc++;
4139 }
4142 y++;
4143 }
4144 if (s > 0) {
4145 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9d %-8d %s\n", pc, dp->
exten, s, y, tmp);
4146 } else {
4147 ast_cli(
a->fd,
"%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->
exten,
"(expired)", y, tmp);
4148 }
4149 }
4150
4152
4154}
4155
4157
4159{
4160
4161
4163 const int lower_mask = (1 << ts_shift) - 1;
4164 const int upper_mask = ~lower_mask;
4166
4167 if ( (fr->
ts & upper_mask) == last_upper ) {
4169 const int threshold = (ts_shift == 15) ? 25000 : 50000;
4170
4172
4173
4174
4175
4176 fr->
ts = (last_upper + (1 << ts_shift)) | (fr->
ts & lower_mask);
4178 ast_debug(1,
"schedule_delivery: pushed forward timestamp\n");
4180
4181
4182
4183
4184 fr->
ts = (last_upper - (1 << ts_shift)) | (fr->
ts & lower_mask);
4186 ast_debug(1,
"schedule_delivery: pushed back timestamp\n");
4187 }
4188 }
4189}
4190
4192
4194{
4195 int when;
4196
4198
4200
4201 if (when <= 0) {
4202
4203 when = 1;
4204 }
4205
4208}
4209
4211{
4216 int ret;
4217 long ms;
4221
4222
4225 if (!pvt) {
4226
4228 return;
4229 }
4230
4232
4233
4234
4235
4236 now.tv_usec += 1000;
4237
4241 if (!voicefmt) {
4242
4243
4244
4246 if (!voicefmt) {
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4259 }
4260 }
4261 if (!voicefmt) {
4262
4265 }
4267 switch(ret) {
4271
4273 break;
4275 {
4277
4278
4282 af.
src =
"IAX2 JB interpolation";
4285
4286
4287
4290
4292 }
4293 }
4294 break;
4297 break;
4300
4301 break;
4302 default:
4303
4304 break;
4305 }
4306 }
4308 if (pvt)
4311}
4312
4314{
4315#ifdef SCHED_MULTITHREADED
4317#endif
4319 return 0;
4320}
4321
4322
4323
4324
4325
4326
4327
4329{
4331 int ret;
4332 int needfree = 0;
4333
4334
4335
4336
4337
4338
4341 }
4342
4343
4345
4346
4349 else {
4350#if 0
4351 ast_debug(1,
"schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
4352#endif
4354 }
4355
4358
4364 }
4365
4367 if (tsout)
4370 return -1;
4371 }
4372
4373
4374
4378 needfree++;
4381 }
4382 if (tsout)
4384 if (needfree) {
4385
4387 return -1;
4388 }
4389 return 0;
4390}
4391
4393{
4395
4397
4399
4402 }
4403
4406
4408 } else {
4409
4414 }
4415
4416 return 0;
4417}
4418
4420{
4422
4424}
4425
4427{
4429}
4430
4432{
4434}
4435
4437{
4438
4440 0, 0, (unsigned char *)text, strlen(text) + 1, -1);
4441}
4442
4444{
4446}
4447
4449{
4451}
4452
4454{
4459 else
4462 return 0;
4463}
4464
4465
4466
4467
4468
4470{
4474 time_t regseconds = 0, nowtime;
4475 int dynamic=0;
4476 char *str_addr, *str_port;
4477
4480
4481 if (peername) {
4485 }
4489
4490 for (tmp =
var; tmp; tmp = tmp->
next) {
4491 if (!strcasecmp(tmp->
name,
"name"))
4492 peername = tmp->
value;
4493 }
4494 }
4495 }
4496 if (!
var && peername) {
4498
4499
4500
4501
4502
4503
4505 for (tmp =
var; tmp; tmp = tmp->
next) {
4506 if (!strcasecmp(tmp->
name,
"host")) {
4508
4511
4514 }
4516 break;
4517 }
4518 }
4519 }
4520 }
4523
4525
4526 if (!peer) {
4529 }
4530
4531 for (tmp =
var; tmp; tmp = tmp->
next) {
4532
4533 if (!strcasecmp(tmp->
name,
"type")) {
4534 if (strcasecmp(tmp->
value,
"friend") &&
4535 strcasecmp(tmp->
value,
"peer")) {
4536
4538 break;
4539 }
4540 }
else if (!strcasecmp(tmp->
name,
"regseconds")) {
4542 }
else if (!strcasecmp(tmp->
name,
"ipaddr")) {
4546 } else {
4548 }
4550 }
else if (!strcasecmp(tmp->
name,
"port")) {
4551 int bindport;
4554 }
4556 }
else if (!strcasecmp(tmp->
name,
"host")) {
4557 if (!strcasecmp(tmp->
value,
"dynamic"))
4558 dynamic = 1;
4559 }
4560 }
4561
4563
4571 }
4572 }
4576 }
4580 } else {
4582 }
4583
4585 time(&nowtime);
4587 memset(&peer->
addr, 0,
sizeof(peer->
addr));
4589 ast_debug(1,
"realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
4590 peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
4591 }
4592 else {
4593 ast_debug(1,
"realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
4594 peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
4595 }
4596 }
4597
4598 return peer;
4599}
4600
4602{
4606 char *str_addr, *str_port;
4607
4610
4618 }
4621
4622
4623
4624
4625
4626
4628 for (tmp =
var; tmp; tmp = tmp->
next) {
4629 if (!strcasecmp(tmp->
name,
"host")) {
4631
4634
4637 }
4639 break;
4640 }
4641 }
4642 }
4643 }
4646
4648 while(tmp) {
4649
4650 if (!strcasecmp(tmp->
name,
"type")) {
4651 if (strcasecmp(tmp->
value,
"friend") &&
4652 strcasecmp(tmp->
value,
"user")) {
4654 }
4655 }
4657 }
4658
4660
4662
4665
4669 } else {
4671 }
4672
4674}
4675
4677{
4678 char regseconds[20];
4680 char *syslabel =
NULL;
4681 char *port;
4682
4686 syslabel = "regserver";
4687
4688 snprintf(regseconds, sizeof(regseconds), "%d", (int)regtime);
4693 "regseconds", regseconds, syslabel, sysname,
SENTINEL);
4694}
4695
4716};
4717
4719{
4721 int res = -1;
4722
4726
4729
4734 return -1;
4735 }
4736
4739 }
4740
4742
4743
4744
4745
4746
4749 int i;
4750
4756 1);
4758 }
4759 }
4760 return 0;
4761 }
4762
4764
4765
4767 goto return_unref;
4768 }
4769
4770
4772 goto return_unref;
4773
4782
4784 int i;
4785
4791 1);
4793 }
4794 }
4806 } else {
4807 char *family;
4809
4811 key = strchr(family, '/');
4812 if (key)
4813 *key++ = '\0';
4816 goto return_unref;
4817 }
4818 }
4819
4822 } else {
4824 }
4825
4826 res = 0;
4827
4828return_unref:
4830
4831 return res;
4832}
4833
4835{
4843 }
4845}
4846
4848{
4849#ifdef SCHED_MULTITHREADED
4851#endif
4853 return 0;
4854}
4855
4857{
4860 unsigned int tmp;
4862 tmp = (tm.tm_sec >> 1) & 0x1f;
4863 tmp |= (tm.tm_min & 0x3f) << 5;
4864 tmp |= (tm.tm_hour & 0x1f) << 11;
4865 tmp |= (tm.tm_mday & 0x1f) << 16;
4866 tmp |= ((tm.tm_mon + 1) & 0xf) << 21;
4867 tmp |= ((tm.tm_year - 100) & 0x7f) << 25;
4868 return tmp;
4869}
4870
4880};
4881
4883 struct ast_sockaddr *addr,
int command,
int ts,
unsigned char seqno,
4885{
4886 struct {
4889 } data;
4891
4892 if (ied) {
4894 memcpy(&data.ied, ied->
buf, ied->
pos);
4895 }
4896
4897 data.f.scallno = htons(0x8000 | callno);
4899 data.f.ts = htonl(
ts);
4900 data.f.iseqno = seqno;
4901 data.f.oseqno = 0;
4904
4906
4907 return ast_sendto(sockfd, &data, size, 0, addr);
4908}
4909
4911{
4912
4913 if (pvt && ied && (2 < ((
int)
sizeof(ied->
buf) - ied->
pos))) {
4915 ied->
buf[ied->
pos++] = 0;
4917 }
4918}
4919
4921{
4925 struct {
4928 } data = {
4930 .ied.pos = 0,
4931 };
4932
4934
4935 if (!pvt) {
4936 return;
4937 }
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4952 (f->
datalen >
sizeof(data))) {
4953
4954 return;
4955 }
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4972 data.ied.pos = ie_data_pos;
4973
4974
4975
4978
4979
4981
4982
4984
4985
4987
4988
4996 }
4997
4998
5000}
5001
5003{
5006
5008 return;
5009 }
5010
5015 }
5016
5017 if (peer) {
5019 }
5022 }
5023}
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5044{
5045#define CALLTOKEN_HASH_FORMAT "%s%u%d"
5046#define CALLTOKEN_IE_FORMAT "%u?%s"
5048 time_t t = time(
NULL);
5049 char hash[41];
5051
5052
5056 .pos = 0,
5057 };
5058
5059
5062
5066
5067 return 1;
5068
5069
5071 char *rec_hash =
NULL;
5072 char *rec_ts =
NULL;
5073 unsigned int rec_time;
5074
5075
5077 if (rec_hash) {
5078 *rec_hash++ = '\0';
5080 }
5081
5082
5083 if (!rec_hash || !rec_ts) {
5084 goto reject;
5085 } else if (sscanf(rec_ts, "%u", &rec_time) != 1) {
5086 goto reject;
5087 }
5088
5089
5092
5093
5094 if (strcmp(hash, rec_hash)) {
5096 goto reject;
5099 goto reject;
5100 }
5101
5102
5103
5105 return 0;
5106
5107
5108 } else {
5111 goto reject;
5112 }
5113 return 0;
5114 }
5115
5116reject:
5117
5120 } else {
5122 }
5123
5124 return 1;
5125}
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5145{
5146 char *outkey =
NULL;
5147
5149 return;
5150
5154
5159 }
5160
5161 if (strchr(pds->
peer,
'@')) {
5165 }
5166
5171 outkey = data;
5172 }
5173
5177
5178
5179
5180
5181
5182
5183
5184
5190 } else {
5193 }
5194 } else if (outkey && (outkey[0] == '[')) {
5198 } else {
5200 }
5201 }
5202}
5203
5205{
5209 char *defaultrdest = "s";
5215 const char* osp_token_ptr;
5216 unsigned int osp_token_length;
5217 unsigned char osp_block_index;
5218 unsigned int osp_block_length;
5219 unsigned char osp_buffer[256];
5220 char encoded_prefs[32];
5222
5225 return -1;
5226 }
5227
5228 memset(&cai, 0, sizeof(cai));
5231
5232 memset(&pds, 0, sizeof(pds));
5235
5238 return -1;
5239 }
5241 pds.
exten = defaultrdest;
5242 }
5245 return -1;
5246 }
5247
5253 return -1;
5254 }
5258 return -1;
5259 }
5260 }
5261
5270
5271
5273
5275 int bindport;
5278 }
5279 }
5280
5283
5284
5285 memset(&ied, 0, sizeof(ied));
5286
5287
5291
5293 }
5294
5295
5298
5299 if (l) {
5303 } else if (n) {
5306 } else {
5308 }
5309
5313
5314 if (n)
5320 }
5321
5326 }
5330 }
5331
5334
5337
5340
5342
5345
5348
5350
5352
5355
5360
5364
5369
5370 if (
iaxs[callno]->maxtime) {
5371
5377 }
5378
5379
5383 osp_block_index = 0;
5384 while (osp_token_length > 0) {
5386 osp_buffer[0] = osp_block_index;
5387 memcpy(osp_buffer + 1, osp_token_ptr, osp_block_length);
5389 osp_block_index++;
5390 osp_token_ptr += osp_block_length;
5391 osp_token_length -= osp_block_length;
5392 }
5393 } else
5396 ast_debug(1,
"OSP token is undefined\n");
5397
5398
5400
5401
5402 if (variablestore) {
5404 ast_debug(1,
"Found an IAX variable store on this channel\n");
5407 char tmp[256];
5408 int i;
5410
5414 }
5415 }
5417 }
5418
5419
5422
5425
5426 return 0;
5427}
5428
5430{
5433 int alreadygone;
5434 memset(&ied, 0, sizeof(ied));
5436 if (callno &&
iaxs[callno]) {
5439
5441 if (!
iaxs[callno]->error && !alreadygone) {
5444 }
5445 if (!
iaxs[callno]) {
5447 return 0;
5448 }
5449 }
5450
5452
5453 if (
iaxs[callno] && alreadygone) {
5456 }
else if (
iaxs[callno]) {
5458 ast_log(
LOG_ERROR,
"Unable to schedule iax2 callno %d destruction?!! Destroying immediately.\n", callno);
5460 }
5461 }
5463
5464
5465
5466
5468 }
5471 return 0;
5472}
5473
5474
5475
5476
5478{
5479 unsigned short callno = pvt->
callno;
5480
5482
5483 int count = 10;
5487 }
5489 return -1;
5490 }
5491 }
5492
5493 return 0;
5494}
5495
5497{
5499 int res;
5500
5504
5506 return -1;
5509 return -1;
5512 {
5515 if ((*(
int *)
data)) {
5517 } else {
5519 }
5521 return 0;
5522 }
5523
5524
5525
5526
5533 {
5536
5539
5542 return -1;
5543 }
5544
5546
5547 if (!(h =
ast_malloc(datalen +
sizeof(*h)))) {
5548 return -1;
5549 }
5550
5552 h->
option = htons(option);
5553 memcpy(h->
data, data, datalen);
5556 datalen + sizeof(*h), -1);
5558 return res;
5559 }
5560 default:
5561 return -1;
5562 }
5563
5564
5565 return -1;
5566}
5567
5569{
5570 switch (option) {
5573 {
5578 return 0;
5579 }
5580 default:
5581 return -1;
5582 }
5583}
5584
5586{
5587 ast_debug(1,
"I should never be called!\n");
5589}
5590
5592{
5593 int res = 0;
5596 char key[17] = "";
5599 };
5600
5603
5604 snprintf(key,
sizeof(key),
"%lX", (
unsigned long)
ast_random());
5605
5609
5611
5613
5615
5617
5619
5620 return res;
5621}
5622
5623#if defined(IAX2_NATIVE_BRIDGING)
5624static int iax2_start_transfer(unsigned short callno0, unsigned short callno1, int mediaonly)
5625{
5626 int res;
5629 unsigned int transferid = (
unsigned int)
ast_random();
5630
5632 ast_debug(1,
"transfers are not supported for encrypted calls at this time\n");
5635 return 0;
5636 }
5637
5638 memset(&ied0, 0, sizeof(ied0));
5642
5643 memset(&ied1, 0, sizeof(ied1));
5647
5649 if (res)
5650 return -1;
5652 if (res)
5653 return -1;
5656 return 0;
5657}
5658#endif
5659
5660#if defined(IAX2_NATIVE_BRIDGING)
5661static void lock_both(unsigned short callno0, unsigned short callno1)
5662{
5666 }
5667}
5668#endif
5669
5670#if defined(IAX2_NATIVE_BRIDGING)
5671static void unlock_both(unsigned short callno0, unsigned short callno1)
5672{
5675}
5676#endif
5677
5678#if defined(IAX2_NATIVE_BRIDGING)
5680{
5683 int to = -1;
5684 int res = -1;
5685 int transferstarted=0;
5689 struct timeval waittimer = {0, 0};
5690
5691
5692 if (timeoutms > 0) {
5694 }
5695
5696 timeoutms = -1;
5697
5698 lock_both(callno0, callno1);
5699 if (!
iaxs[callno0] || !
iaxs[callno1]) {
5700 unlock_both(callno0, callno1);
5702 }
5703
5707 }
5708 unlock_both(callno0, callno1);
5709
5710
5711 cs[0] = c0;
5712 cs[1] = c1;
5713 for (;;) {
5714
5716 ast_verb(3,
"Can't masquerade, we're different...\n");
5717
5722 }
5727 }
5729 }
5733
5734 ast_verb(3,
"Operating with different codecs [%s] [%s] , can't native bridge...\n",
5737
5738
5739 lock_both(callno0, callno1);
5744 unlock_both(callno0, callno1);
5746 }
5747
5749
5753 transferstarted = 1;
5754 }
5756
5759 waittimer = now;
5764 *rc = c0;
5766 break;
5767 }
5768 }
5769 to = 1000;
5771
5772
5773
5774
5775
5776 if (timeoutms > -1) {
5777 timeoutms -= (1000 - to);
5778 if (timeoutms < 0)
5779 timeoutms = 0;
5780 }
5781 if (!who) {
5782 if (!timeoutms) {
5784 break;
5785 }
5788 break;
5789 }
5790 continue;
5791 }
5793 if (!f) {
5795 *rc = who;
5797 break;
5798 }
5799 other = (who == c0) ? c1 : c0;
5807 break;
5810 break;
5811 default:
5812 *fo = f;
5813 *rc = who;
5815 break;
5816 }
5818 break;
5819 }
5826
5827
5828
5830
5831 if (flags & monitored_source) {
5832 *rc = who;
5833 *fo = f;
5835
5836 break;
5837 }
5839 }
5841
5842 cs[2] = cs[0];
5843 cs[0] = cs[1];
5844 cs[1] = cs[2];
5845 }
5846 lock_both(callno0, callno1);
5851 unlock_both(callno0, callno1);
5852 return res;
5853}
5854#endif
5855
5857{
5861}
5862
5864{
5867 int res = 0;
5868
5870 ast_debug(1,
"Indicating condition %d\n", condition);
5871
5874
5876 res = -1;
5878 }
5879
5880 switch (condition) {
5885 }
5886 break;
5891 }
5892 break;
5896
5897 ast_debug(2,
"Callno %d: Config blocked sending control frame %d.\n",
5900 }
5901 break;
5904 res = -1;
5906 }
5907
5909
5912
5913 return res;
5914}
5915
5917{
5924 if (context) {
5927 }
5929 if (context)
5934}
5935
5937{
5939 int res = 0;
5941
5944
5948 break;
5949 }
5951 }
5953
5954 return res;
5955}
5956
5957
5960 const struct ast_channel *requestor,
unsigned int cachable)
5961{
5969 char *peer_name =
NULL;
5970
5971 if (!(i =
iaxs[callno])) {
5974 }
5975
5976 if (!capability) {
5980 }
5982 if (!native) {
5984 }
5991 }
5992
5997 }
5998
5999
6001
6008 }
6010 }
6011
6012 if (!tmp) {
6016 }
6017
6019 if (i !=
iaxs[callno]) {
6020 if (tmp) {
6021
6026 }
6029 }
6030 if (!tmp) {
6033 }
6034
6036
6037 if ((callid =
iaxs[callno]->callid)) {
6039 }
6040
6042
6043
6046
6051
6054
6056
6058 ast_channel_parkinglot_set(tmp, i->
parkinglot);
6059
6060
6067 }
6072 }
6079 ast_channel_language_set(tmp, i->
language);
6088 else
6092
6093 if (!cachable) {
6095 }
6096
6097
6099 for (v = i->
vars ; v ; v = v->
next)
6101 }
6106 ast_debug(1,
"Loading up the channel with IAXVARs\n");
6109 if (variablestore && varlist) {
6110 variablestore->
data = varlist;
6115 if (prev)
6118 if (!newvar) {
6119
6120 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
6121 } else {
6123 }
6124 }
6125 if (prev)
6129 } else {
6130 if (variablestore) {
6132 }
6133 if (varlist) {
6135 }
6136 }
6137 }
6138
6141
6145
6150 }
6151 }
6152
6154 return tmp;
6155}
6156
6158{
6159 unsigned long int mssincetx;
6160 long int ms, pred;
6161
6165
6168 }
6169
6171
6172
6174
6177 ms = pred;
6178
6179
6183 return ms;
6184}
6185
6186static unsigned int fix_peerts(
struct timeval *rxtrunktime,
int callno,
unsigned int ts)
6187{
6188 long ms;
6190
6192
6194 }
6195
6197
6198 return ms + ts;
6199}
6200
6202{
6203 int ms;
6204 int voice = 0;
6205 int genuine = 0;
6206 int adjust;
6207 int rate = 0;
6208 struct timeval *delivery =
NULL;
6209
6210
6211
6212
6213
6214
6215
6216
6218 voice = 1;
6222 genuine = 1;
6225 }
6226
6229
6231 }
6232
6233 if (ts)
6234 return ts;
6235
6238 if (ms < 0) {
6239 ms = 0;
6240 }
6243 } else {
6245 if (ms < 0)
6246 ms = 0;
6247 if (voice) {
6248
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269 if (adjust < 0)
6271 else if (adjust > 0)
6273
6278 }
6280 } else {
6281
6282
6283
6284
6285
6286
6287
6288
6289
6291 ast_debug(1,
"predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
6293
6295 {
6296 int diff = ms % (f->
samples / rate);
6297 if (diff)
6299 }
6300
6303 }
6305
6306
6307
6308
6309
6310
6311
6312
6313 if ( (
unsigned int)ms < p->
lastsent )
6315 } else {
6316
6317
6319 if (genuine) {
6320
6321 if (ms <= p->lastsent)
6324
6326 }
6327 }
6328 }
6330 if (voice) {
6332 }
6333 return ms;
6334}
6335
6337{
6338
6339
6340 int ms;
6341#ifdef IAXTESTS
6342 int jit;
6343#endif
6344
6348 ast_debug(1,
"calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %ums\n",
6351#if 1
6353 ast_debug(1,
"calc_rxstamp: call=%d: works out as %d.%6.6d\n",
6355#endif
6356 }
6357
6359#ifdef IAXTESTS
6360 if (test_jit) {
6361 if (!test_jitpct || ((100.0 *
ast_random() / (RAND_MAX + 1.0)) < test_jitpct)) {
6362 jit = (int)((
float)test_jit *
ast_random() / (RAND_MAX + 1.0));
6363 if ((
int)(2.0 *
ast_random() / (RAND_MAX + 1.0)))
6364 jit = -jit;
6365 ms += jit;
6366 }
6367 }
6368 if (test_late) {
6369 ms += test_late;
6370 test_late = 0;
6371 }
6372#endif
6373 return ms;
6374}
6375
6377{
6379
6380
6382
6386 break;
6387 }
6388 }
6389
6390 if (!tpeer) {
6391 if ((tpeer =
ast_calloc(1,
sizeof(*tpeer)))) {
6398
6399#ifdef SO_NO_CHECK
6400 setsockopt(tpeer->
sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums,
sizeof(nochecksums));
6401#endif
6404 }
6405 }
6406
6408
6409 return tpeer;
6410}
6411
6413{
6416 void *tmp, *ptr;
6417 struct timeval now;
6420
6423 if (tpeer) {
6424
6426
6430 return -1;
6431 }
6432
6436 } else {
6439 return -1;
6440 }
6441 }
6442
6443
6449 mtm->
mini.
ts = htons(0xffff & fr->
ts);
6452 } else {
6454
6457
6460 }
6461
6464
6466
6467
6470
6471
6476 }
6477
6479 }
6480 return 0;
6481}
6482
6483
6484
6486{
6487 long tmp;
6489 memcpy(
buf, (
unsigned char *) &tmp, (
len >
sizeof(tmp)) ?
sizeof(tmp) :
len);
6492 }
6493}
6494
6496{
6497#ifdef HAVE_OPENSSL
6498 int i;
6499 for (i = 0; i < 60; i++) {
6501 return 0;
6502 }
6503 }
6504
6505 return -1;
6506#else
6507 return 0;
6508#endif
6509}
6510
6512{
6515}
6516
6518{
6519
6520
6521
6525}
6526
6528{
6529#if 0
6530
6531 int x;
6535 dst[x] = src[x] ^ 0xff;
6536#else
6537 unsigned char lastblock[16] = { 0 };
6538 int x;
6541 for (x=0;x<16;x++)
6542 dst[x] ^= lastblock[x];
6543 memcpy(lastblock, src, sizeof(lastblock));
6544 dst += 16;
6545 src += 16;
6547 }
6548#endif
6549}
6550
6552{
6553#if 0
6554
6555 int x;
6559 dst[x] = src[x] ^ 0xff;
6560#else
6561 unsigned char curblock[16] = { 0 };
6562 int x;
6564 for (x=0;x<16;x++)
6565 curblock[x] ^= src[x];
6567 memcpy(curblock, dst, sizeof(curblock));
6568 dst += 16;
6569 src += 16;
6571 }
6572#endif
6573}
6574
6576{
6577 int padding;
6578 unsigned char *workspace;
6579
6581 memset(f, 0, sizeof(*f));
6585 return -1;
6586
6588
6589 padding = 16 + (workspace[15] & 0x0f);
6591 ast_debug(1,
"Decoding full frame with length %d (padding = %d) (15=%02hhx)\n", *datalen, padding, workspace[15]);
6593 return -1;
6594
6595 *datalen -= padding;
6602 }
6607 }
6608 } else {
6610 }
6611 } else {
6614 ast_debug(5,
"Decoding mini with length %d\n", *datalen);
6616 return -1;
6617
6619 padding = 16 + (workspace[15] & 0x0f);
6621 return -1;
6622 *datalen -= padding;
6624 }
6625 return 0;
6626}
6627
6629{
6630 int padding;
6631 unsigned char *workspace;
6636 ast_debug(1,
"Encoding full frame %d/%d with length %d\n", fh->
type, fh->
csub, *datalen);
6638 padding = 16 + (padding & 0xf);
6639 memcpy(workspace, poo, padding);
6641 workspace[15] &= 0xf0;
6642 workspace[15] |= (padding & 0xf);
6644 ast_debug(1,
"Encoding full frame %d/%d with length %d + %d padding (15=%02hhx)\n", fh->
type, fh->
csub, *datalen, padding, workspace[15]);
6645 *datalen += padding;
6648 memcpy(poo, workspace + *datalen - 32, 32);
6649 } else {
6652 ast_debug(5,
"Encoding mini frame with length %d\n", *datalen);
6654 padding = 16 + (padding & 0xf);
6655 memcpy(workspace, poo, padding);
6657 workspace[15] &= 0xf0;
6658 workspace[15] |= (padding & 0x0f);
6659 *datalen += padding;
6662 memcpy(poo, workspace + *datalen - 32, 32);
6663 }
6664 return 0;
6665}
6666
6668{
6669 int res=-1;
6671
6673 unsigned char digest[16];
6674 char *tmppw, *stringp;
6675
6677 stringp = tmppw;
6678 while ((tmppw =
strsep(&stringp,
";"))) {
6681 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
6685 if (!res) {
6687 break;
6688 }
6689 }
6690 } else
6692 return res;
6693}
6694
6696{
6697
6698
6699
6703 struct {
6705 unsigned char buffer[4096];
6706 } frb;
6708 int res;
6709 int sendmini=0;
6710 unsigned int lastsent;
6711 unsigned int fts;
6712
6714
6715 if (!pvt) {
6717 return -1;
6718 }
6719
6721
6722
6724
6725
6726
6727
6729 return 0;
6730#if 0
6732 "f->frametype %c= AST_FRAME_VOICE, %sencrypted, %srotation scheduled...\n",
6735 pvt->keyrotateid != -1 ? "" : "no "
6736 );
6737#endif
6740 }
6741
6743 (((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
6744 ((fts & 0xFFFF0000L) == ((lastsent + 0x10000) & 0xFFFF0000L))))
6745 &&
6747 &&
6750 ) {
6751
6752 now = 1;
6753
6754 sendmini = 1;
6755 }
6757
6758
6759
6760
6761
6762 if (((fts & 0xFFFF8000L) == (pvt->
lastvsent & 0xFFFF8000L)) &&
6765 ) {
6766 now = 1;
6767 sendmini = 1;
6768 } else {
6769 now = 0;
6770 sendmini = 0;
6771 }
6773 }
6775
6779 }
6780 }
6781
6782 if (now) {
6783 fr = &frb.fr2;
6784 } else
6786 if (!fr) {
6788 return -1;
6789 }
6790
6792
6798 if (!sendmini) {
6799
6800 if (seqno > -1)
6802 else
6807 fh->
ts = htonl(fr->
ts);
6811 } else
6813
6817
6824 } else {
6826 }
6827
6830 } else
6836
6842
6853 else
6860 } else
6862 }
6863
6864 if (now) {
6866 } else
6868 } else {
6871 res = 0;
6873
6884 } else {
6885
6888
6891 mh->
ts = htons(fr->
ts & 0xFFFF);
6900 } else
6902 }
6904 }
6905 }
6906 return res;
6907}
6908
6910{
6911 regex_t regexbuf;
6912 int havepattern = 0;
6913
6914#define FORMAT "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n"
6915#define FORMAT2 "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n"
6916
6918 char auth[90];
6919 char *pstr = "";
6921
6922 switch (cmd) {
6924 e->
command =
"iax2 show users [like]";
6926 "Usage: iax2 show users [like <pattern>]\n"
6927 " Lists all known IAX2 users.\n"
6928 " Optional regular expression pattern is used to filter the user list.\n";
6932 }
6933
6935 case 5:
6936 if (!strcasecmp(
a->argv[3],
"like")) {
6937 if (regcomp(®exbuf,
a->argv[4], REG_EXTENDED | REG_NOSUB))
6939 havepattern = 1;
6940 } else
6942 case 3:
6943 break;
6944 default:
6946 }
6947
6948 ast_cli(
a->fd,
FORMAT,
"Username",
"Secret",
"Authen",
"Def.Context",
"A/C",
"Codec Pref");
6951 if (havepattern && regexec(®exbuf,
user->name, 0,
NULL, 0))
6952 continue;
6953
6957 snprintf(auth,
sizeof(auth),
"Key: %-15.15s ",
user->inkeys);
6958 } else
6960
6962 pstr = "REQ Only";
6964 pstr = "Disabled";
6965 else
6967
6971 }
6973
6974 if (havepattern)
6975 regfree(®exbuf);
6976
6978#undef FORMAT
6979#undef FORMAT2
6980}
6981
6992};
6993
6994#define PEERS_FORMAT2 "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n"
6995#define PEERS_FORMAT "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n"
6996
6998{
6999 char name[256] =
"";
7001 int retstatus;
7003
7004 char *tmp_host, *tmp_mask, *tmp_port;
7005
7009
7012 } else {
7014 }
7015
7018 if (retstatus > 0) {
7020 } else if (!retstatus) {
7022 } else {
7024 }
7025
7026 if (s) {
7029 "Event: PeerEntry\r\n%s"
7030 "Channeltype: IAX\r\n",
7034 "ObjectName: %s\r\n"
7035 "ObjectUsername: %s\r\n",
7038 } else {
7040 "ObjectName: %s\r\n",
7042 }
7043 } else {
7045 "Event: PeerEntry\r\n%s"
7046 "Channeltype: IAX2\r\n"
7047 "ObjectName: %s\r\n",
7050 }
7052 "ChanObjectType: peer\r\n"
7053 "IPaddress: %s\r\n",
7054 tmp_host);
7057 "Mask: %s\r\n"
7058 "Port: %s\r\n",
7059 tmp_mask,
7060 tmp_port);
7061 } else {
7063 "IPport: %s\r\n",
7064 tmp_port);
7065 }
7067 "Dynamic: %s\r\n"
7068 "Trunk: %s\r\n"
7069 "Encryption: %s\r\n"
7070 "Status: %s\r\n",
7077 } else {
7079 "Description: %s\r\n\r\n",
7081 }
7082 } else {
7085 tmp_host,
7087 tmp_mask,
7088 tmp_port,
7090 peer->encmethods ? "(E)" : " ",
7092 peer->description);
7093 }
7094
7096}
7097
7099{
7102 .idtext = "",
7103 .registeredonly = 0,
7104
7105 .peerlist = 0,
7106
7107 .total_peers = 0,
7108 .online_peers = 0,
7109 .offline_peers = 0,
7110 .unmonitored_peers = 0,
7111 };
7112
7114
7116
7117 switch (argc) {
7118 case 6:
7119 if (!strcasecmp(argv[3], "registered"))
7121 else
7123 if (!strcasecmp(argv[4], "like")) {
7124 if (regcomp(&cont.
regexbuf, argv[5], REG_EXTENDED | REG_NOSUB))
7127 } else
7129 break;
7130 case 5:
7131 if (!strcasecmp(argv[3], "like")) {
7132 if (regcomp(&cont.
regexbuf, argv[4], REG_EXTENDED | REG_NOSUB))
7135 } else
7137 break;
7138 case 4:
7139 if (!strcasecmp(argv[3], "registered")) {
7141 } else {
7143 }
7144 break;
7145 case 3:
7146 break;
7147 default:
7149 }
7150
7151
7152 if (!s) {
7153 ast_cli(fd,
PEERS_FORMAT2,
"Name/Username",
"Host",
" ",
"Mask",
"Port",
" ",
"Status",
"Description");
7154 }
7155
7158
7160 continue;
7161 }
7163 continue;
7164 }
7165
7167
7168 }
7170
7171 if (!s) {
7172 ast_cli(fd,
"%d iax2 peers [%d online, %d offline, %d unmonitored]\n",
7174 }
7175
7178 }
7179
7182 }
7183
7185
7186}
7187#undef PEERS_FORMAT2
7188#undef PEERS_FORMAT
7189
7191{
7193 time_t t;
7194 int threadcount = 0, dynamiccount = 0;
7196
7197 switch (cmd) {
7199 e->
command =
"iax2 show threads";
7201 "Usage: iax2 show threads\n"
7202 " Lists status of IAX helper threads\n";
7206 }
7209
7210 ast_cli(
a->fd,
"IAX2 Thread Information\n");
7211 time(&t);
7215#ifdef DEBUG_SCHED_MULTITHREAD
7216 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7218#else
7219 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7221#endif
7222 threadcount++;
7223 }
7225 ast_cli(
a->fd,
"Active Threads:\n");
7230 else
7232#ifdef DEBUG_SCHED_MULTITHREAD
7233 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d, func='%s'\n",
7235#else
7236 ast_cli(
a->fd,
"Thread %c%d: state=%u, update=%d, actions=%d\n",
7238#endif
7239 threadcount++;
7240 }
7242 ast_cli(
a->fd,
"Dynamic Threads:\n");
7245#ifdef DEBUG_SCHED_MULTITHREAD
7246 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d, func='%s'\n",
7248#else
7249 ast_cli(
a->fd,
"Thread %d: state=%u, update=%d, actions=%d\n",
7251#endif
7252 dynamiccount++;
7253 }
7255 ast_cli(
a->fd,
"%d of %d threads accounted for with %d dynamic threads\n", threadcount,
iaxthreadcount, dynamiccount);
7257}
7258
7260{
7262
7263 switch (cmd) {
7265 e->
command =
"iax2 unregister";
7267 "Usage: iax2 unregister <peername>\n"
7268 " Unregister (force expiration) an IAX2 peer from the registry.\n";
7272 }
7273
7276
7278 if (p) {
7281
7283 if (peer) {
7286 ast_cli(
a->fd,
"Peer %s unregistered\n",
a->argv[2]);
7287 } else {
7288 ast_cli(
a->fd,
"Peer %s not found\n",
a->argv[2]);
7289 }
7290 } else {
7291 ast_cli(
a->fd,
"Peer %s not registered\n",
a->argv[2]);
7292 }
7294 } else {
7295 ast_cli(
a->fd,
"Peer unknown: %s. Not unregistered\n",
a->argv[2]);
7296 }
7298}
7299
7301{
7302 int which = 0;
7305 int wordlen = strlen(
word);
7306
7307
7308 if (pos == 2) {
7311 if (!strncasecmp(p->
name,
word, wordlen) &&
7315 break;
7316 }
7318 }
7320 }
7321
7322 return res;
7323}
7324
7326{
7327 switch (cmd) {
7329 e->
command =
"iax2 show peers";
7331 "Usage: iax2 show peers [registered] [like <pattern>]\n"
7332 " Lists all known IAX2 peers.\n"
7333 " Optional 'registered' argument lists only peers with known addresses.\n"
7334 " Optional regular expression pattern is used to filter the peer list.\n";
7338 }
7339
7345 default:
7347 }
7348}
7349
7351{
7355}
7356
7358 void *user_data)
7359{
7360 int *fd = user_data;
7361
7362 ast_cli(*fd,
"%-15.15s %-15d %-15d\n",
7365 (
int) ntohl(
header->datalen));
7366
7367 return 0;
7368}
7369
7371{
7372 switch (cmd) {
7374 e->
command =
"iax2 show firmware";
7376 "Usage: iax2 show firmware\n"
7377 " Lists all known IAX firmware images.\n";
7381 }
7382
7383 if (
a->argc != 3 &&
a->argc != 4)
7385
7386 ast_cli(
a->fd,
"%-15.15s %-15.15s %-15.15s\n",
"Device",
"Version",
"Size");
7387
7389 a->argc == 3 ?
NULL :
a->argv[3],
7392
7394}
7395
7396
7398{
7399 static const char *
const a[] = {
"iax2",
"show",
"peers" };
7401 char idtext[256] = "";
7403
7405 snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
7406
7408
7409
7411
7412
7415 return 0;
7416}
7417
7418
7420{
7423 .idtext = "",
7424 .registeredonly = 0,
7425
7426 .peerlist = 1,
7427
7428 .total_peers = 0,
7429 .online_peers = 0,
7430 .offline_peers = 0,
7431 .unmonitored_peers = 0,
7432 };
7433
7436
7438
7440 snprintf(cont.
idtext,
sizeof(cont.
idtext),
"ActionID: %s\r\n",
id);
7441 }
7442
7444
7448 }
7450
7453
7455}
7456
7457
7459{
7460 switch(regstate) {
7462 return "Unregistered";
7464 return "Request Sent";
7466 return "Auth. Sent";
7468 return "Registered";
7470 return "Rejected";
7472 return "Timeout";
7474 return "No Authentication";
7475 default:
7476 return "Unknown";
7477 }
7478}
7479
7481{
7482#define FORMAT2 "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n"
7483#define FORMAT "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n"
7484
7486 char host[80];
7487 char perceived[80];
7488 int counter = 0;
7489
7490 switch (cmd) {
7492 e->
command =
"iax2 show registry";
7494 "Usage: iax2 show registry\n"
7495 " Lists all registration requests and status.\n";
7499 }
7502 ast_cli(
a->fd,
FORMAT2,
"Host",
"dnsmgr",
"Username",
"Perceived",
"Refresh",
"State");
7506
7508
7510 (reg->
dnsmgr) ?
"Y" :
"N",
7512 counter++;
7513 }
7515 ast_cli(
a->fd,
"%d IAX2 registrations.\n", counter);
7517#undef FORMAT
7518#undef FORMAT2
7519}
7520
7522{
7525 char idtext[256] = "";
7526 char host[80] = "";
7527 char perceived[80] = "";
7529
7531 snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
7532
7534
7538
7540
7542 "Event: RegistryEntry\r\n"
7543 "%s"
7544 "Host: %s\r\n"
7545 "DNSmanager: %s\r\n"
7546 "Username: %s\r\n"
7547 "Perceived: %s\r\n"
7548 "Refresh: %d\r\n"
7549 "State: %s\r\n"
7550 "\r\n", idtext, host, (reg->
dnsmgr) ?
"Y" :
"N", reg->
username, perceived,
7552
7554 }
7556
7559
7560 return 0;
7561}
7562
7564{
7565#define FORMAT2 "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n"
7566#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"
7567#define FORMATB "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"
7568 int x;
7569 int numchans = 0;
7570 char first_message[10] = { 0, };
7571 char last_message[10] = { 0, };
7572
7573 switch (cmd) {
7575 e->
command =
"iax2 show channels";
7577 "Usage: iax2 show channels\n"
7578 " Lists all currently active IAX channels.\n";
7582 }
7583
7586 ast_cli(
a->fd,
FORMAT2,
"Channel",
"Peer",
"Username",
"ID (Lo/Rem)",
"Seq (Tx/Rx)",
"Lag",
"Jitter",
"JitBuf",
"Format",
"FirstMsg",
"LastMsg");
7590 int lag, jitter, localdelay;
7596 } else {
7597 jitter = -1;
7598 localdelay = 0;
7599 }
7600
7610 lag,
7611 jitter,
7612 localdelay,
7615 first_message,
7617 last_message);
7618 numchans++;
7619 }
7621 }
7622 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7624#undef FORMAT
7625#undef FORMAT2
7626#undef FORMATB
7627}
7628
7630{
7631 int x;
7632 int numchans = 0;
7633 char first_message[10] = { 0, };
7634 char last_message[10] = { 0, };
7635#define ACN_FORMAT1 "%-24.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n"
7636#define ACN_FORMAT2 "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"
7640 int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
7644
7647 localjitter = jbinfo.
jitter;
7650 locallosspct = jbinfo.
losspct/1000;
7653 } else {
7654 localjitter = -1;
7655 localdelay = 0;
7656 locallost = -1;
7657 locallosspct = -1;
7658 localdropped = 0;
7659 localooo = -1;
7660 }
7661 if (s)
7665 localjitter,
7666 localdelay,
7667 locallost,
7668 locallosspct,
7669 localdropped,
7670 localooo,
7671 iaxs[x]->frames_received/1000,
7672 iaxs[x]->remote_rr.jitter,
7673 iaxs[x]->remote_rr.delay,
7674 iaxs[x]->remote_rr.losscnt,
7675 iaxs[x]->remote_rr.losspct,
7676 iaxs[x]->remote_rr.dropped,
7677 iaxs[x]->remote_rr.ooo,
7678 iaxs[x]->remote_rr.packets/1000,
7680 first_message,
7682 last_message);
7683 else
7687 localjitter,
7688 localdelay,
7689 locallost,
7690 locallosspct,
7691 localdropped,
7692 localooo,
7693 iaxs[x]->frames_received/1000,
7694 iaxs[x]->remote_rr.jitter,
7695 iaxs[x]->remote_rr.delay,
7696 iaxs[x]->remote_rr.losscnt,
7697 iaxs[x]->remote_rr.losspct,
7698 iaxs[x]->remote_rr.dropped,
7699 iaxs[x]->remote_rr.ooo,
7700 iaxs[x]->remote_rr.packets/1000,
7702 first_message,
7704 last_message);
7705 numchans++;
7706 }
7708 }
7709
7710 return numchans;
7711}
7712
7714{
7715 int numchans = 0;
7716
7717 switch (cmd) {
7719 e->
command =
"iax2 show netstats";
7721 "Usage: iax2 show netstats\n"
7722 " Lists network status for all currently active IAX channels.\n";
7726 }
7729 ast_cli(
a->fd,
" -------- LOCAL --------------------- -------- REMOTE --------------------\n");
7730 ast_cli(
a->fd,
"Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts FirstMsg LastMsg\n");
7732 ast_cli(
a->fd,
"%d active IAX channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
7734}
7735
7737{
7738 switch (cmd) {
7740 e->
command =
"iax2 set debug {on|off|peer}";
7742 "Usage: iax2 set debug {on|off|peer peername}\n"
7743 " Enables/Disables dumping of IAX packets for debugging purposes.\n";
7746 if (
a->pos == 4 && !strcasecmp(
a->argv[3],
"peer"))
7749 }
7750
7751 if (
a->argc < e->
args ||
a->argc > e->
args + 1)
7753
7754 if (!strcasecmp(
a->argv[3],
"peer")) {
7756
7757 if (
a->argc != e->
args + 1)
7759
7761
7762 if (!peer) {
7763 ast_cli(
a->fd,
"IAX2 peer '%s' does not exist\n",
a->argv[e->
args-1]);
7765 }
7766
7768
7770
7772 }
else if (!strncasecmp(
a->argv[3],
"on", 2)) {
7774 ast_cli(
a->fd,
"IAX2 Debugging Enabled\n");
7775 } else {
7778 ast_cli(
a->fd,
"IAX2 Debugging Disabled\n");
7779 }
7781}
7782
7784{
7785 switch (cmd) {
7787 e->
command =
"iax2 set debug trunk {on|off}";
7789 "Usage: iax2 set debug trunk {on|off}\n"
7790 " Enables/Disables debugging of IAX trunking\n";
7794 }
7795
7796 if (
a->argc != e->
args)
7798
7799 if (!strncasecmp(
a->argv[e->
args - 1],
"on", 2)) {
7801 ast_cli(
a->fd,
"IAX2 Trunk Debugging Enabled\n");
7802 } else {
7804 ast_cli(
a->fd,
"IAX2 Trunk Debugging Disabled\n");
7805 }
7807}
7808
7810{
7811 switch (cmd) {
7813 e->
command =
"iax2 set debug jb {on|off}";
7815 "Usage: iax2 set debug jb {on|off}\n"
7816 " Enables/Disables jitterbuffer debugging information\n";
7820 }
7821
7822 if (
a->argc != e->
args)
7824
7825 if (!strncasecmp(
a->argv[e->
args -1],
"on", 2)) {
7827 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Enabled\n");
7828 } else {
7830 ast_cli(
a->fd,
"IAX2 Jitterbuffer Debugging Disabled\n");
7831 }
7833}
7834
7836{
7838 int res = -1;
7841
7844 res = 0;
7845
7847 res = 0;
7849 res = 0;
7851 res = 0;
7852 else
7853
7855 } else {
7857 }
7858 }
7859
7861 return res;
7862}
7863
7866{
7868 int res = 0;
7869
7873 f.
src = __FUNCTION__;
7875
7877 return res;
7878 }
7879
7881}
7882
7884{
7886
7887 ast_debug(2,
"Callno %d: Blocked sending control frame %d.\n",
7889 return 0;
7890 }
7892}
7893
7895{
7896 int res;
7900 return res;
7901}
7902
7903
7904
7905
7906
7907
7909{
7910 int call_num = i->
callno;
7911
7913 if (!
iaxs[call_num])
7914 return -1;
7916}
7917
7919{
7921}
7922
7924{
7926}
7927
7929{
7930 while(con) {
7931 if (!strcmp(con->
context, context) || !strcmp(con->
context,
"*"))
7932 return -1;
7934 }
7935 return 0;
7936}
7937
7938
7940{
7941
7942 int res = -1;
7945 int bestscore = 0;
7946 int gotcapability = 0;
7949
7951 return res;
7957 }
7959 }
7987 gotcapability = 1;
7989 }
7992
7993
7996 } else {
7997 memset(&
iaxs[callno]->rprefs, 0,
sizeof(
iaxs[callno]->rprefs));
7998 }
8000
8001 if (!gotcapability) {
8003 }
8007 return res;
8008 }
8009
8013 !strcmp(
iaxs[callno]->username,
user->name))
8018
8019 if (best)
8022 break;
8024
8026
8027 if (bestscore < 4) {
8028 bestscore = 4;
8029 if (best)
8032 continue;
8033 }
8034 } else {
8035
8036 if (bestscore < 3) {
8037 bestscore = 3;
8038 if (best)
8041 continue;
8042 }
8043 }
8044 } else {
8046
8047 if (bestscore < 2) {
8048 bestscore = 2;
8049 if (best)
8052 continue;
8053 }
8054 } else {
8055
8056 if (bestscore < 1) {
8057 bestscore = 1;
8058 if (best)
8061 continue;
8062 }
8063 }
8064 }
8065 }
8067 }
8076 }
8077 }
8079
8080
8081 for (v =
user->vars ; v ; v = v->
next) {
8086 }
8087 }
8088 }
8089
8090 if (
user->maxauthreq > 0)
8095
8098
8101
8105 else
8107 }
8108
8110
8113
8123 }
8137
8139 char *family, *key=
NULL;
8142 key = strchr(family, '/');
8143 if (key) {
8144 *key = '\0';
8145 key++;
8146 }
8149 else
8151 } else
8153 res = 0;
8155 } else {
8156
8157
8158
8159
8164
8165 res = 0;
8166 }
8167 }
8169 return res;
8170}
8171
8173{
8183
8185 return ast_sendto(sockfd, &fh,
sizeof(fh), 0, addr);
8186}
8187
8189{
8190
8195 }
8198 else
8200 }
8201}
8202
8203
8204
8205
8206
8207
8208
8210{
8212 int res = -1, authreq_restrict = 0;
8215
8216 memset(&ied, 0, sizeof(ied));
8217
8218
8221
8224 if (
user->curauthreq ==
user->maxauthreq)
8225 authreq_restrict = 1;
8226 else
8229 }
8230 }
8231
8232
8233 if (authreq_restrict) {
8237 return 0;
8238 }
8239
8244
8246 }
8249
8251
8253
8256
8257 return res;
8258}
8259
8261{
8262 char requeststr[256];
8263 char md5secret[256] = "";
8265 char rsasecret[256] = "";
8266 int res = -1;
8267 int x;
8269
8271 return res;
8272 }
8273
8279 }
8282 }
8284 ast_log(
LOG_WARNING,
"Call Terminated, incoming call is unencrypted while force encrypt is enabled.\n");
8285 return res;
8286 }
8288 return res;
8297 char *keyn;
8298 char *tmpkey;
8301 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8302 return res;
8303 }
8304 stringp = tmpkey;
8305 keyn =
strsep(&stringp,
":");
8306 while(keyn) {
8309 res = 0;
8311 break;
8312 } else if (!key) {
8313 ast_log(
LOG_WARNING,
"Requested inkey '%s' for RSA authentication does not exist\n", keyn);
8314 }
8315 keyn =
strsep(&stringp,
":");
8316 }
8320 }
8323 unsigned char digest[16];
8324 char *tmppw, *stringp;
8326 stringp = tmppw;
8327 while((tmppw =
strsep(&stringp,
";"))) {
8330 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8332
8333 for (x=0;x<16;x++)
8334 sprintf(requeststr + (x << 1), "%02hhx", digest[x]);
8335 if (!strcasecmp(requeststr, md5secret)) {
8336 res = 0;
8338 break;
8341 }
8342 }
8344 if (!strcmp(secret, p->
secret)) {
8345 res = 0;
8349 }
8350 }
8351 return res;
8352}
8353
8354
8356{
8357 char requeststr[256] = "";
8358 char peer[256] = "";
8359 char md5secret[256] = "";
8360 char rsasecret[256] = "";
8361 char secret[256] = "";
8364 char *keyn;
8365 int x;
8366 int expire = 0;
8367 int res = -1;
8368
8370
8381
8384 return -1;
8385 }
8386
8387
8391 if (!p || !
iaxs[callno]) {
8394
8396
8397
8398
8399
8400
8401
8402
8403
8404
8407
8408 res = 0;
8409 }
8410 }
8413 goto return_unref;
8414 }
8415
8419 goto return_unref;
8420 }
8421
8425 goto return_unref;
8426 }
8429
8432 char *tmpkey;
8435 ast_log(
LOG_ERROR,
"Unable to create a temporary string for parsing stored 'inkeys'\n");
8436 goto return_unref;
8437 }
8438 stringp = tmpkey;
8439 keyn =
strsep(&stringp,
":");
8440 while(keyn) {
8444 break;
8445 } else if (!key)
8447 keyn =
strsep(&stringp,
":");
8448 }
8450 if (!keyn) {
8453 goto return_unref;
8454 }
8455 } else {
8457 ast_log(
LOG_NOTICE,
"Host '%s' trying to do RSA authentication, but we have no inkeys\n", peer);
8458 goto return_unref;
8459 }
8462 unsigned char digest[16];
8463 char *tmppw, *stringp;
8464
8466 stringp = tmppw;
8467 while((tmppw =
strsep(&stringp,
";"))) {
8470 MD5Update(&
md5, (
unsigned char *)tmppw, strlen(tmppw));
8472 for (x=0;x<16;x++)
8473 sprintf(requeststr + (x << 1), "%02hhx", digest[x]);
8474 if (!strcasecmp(requeststr, md5secret))
8475 break;
8476 }
8477 if (tmppw) {
8479 } else {
8482 goto return_unref;
8483 }
8485
8486 if (strcmp(secret, p->
secret)) {
8489 goto return_unref;
8490 } else
8493
8494 goto return_unref;
8495 }
8497
8498
8499 res = 0;
8500
8501return_unref:
8504
8505
8506 if (expire && (expire <
iaxs[callno]->expiry)) {
8508 }
8509 }
8510
8511 if (p) {
8513 }
8514 return res;
8515}
8516
8518{
8519 int res = -1;
8520 int x;
8525 }
8528 } else {
8529 char sig[256];
8532 if (!key) {
8534 } else {
8537 res = -1;
8538 } else {
8540 if (pvt) {
8542 }
8543 res = 0;
8544 }
8545 }
8546
8549 unsigned char digest[16];
8550
8553 MD5Update(&
md5, (
unsigned char *) secret, strlen(secret));
8555
8557 }
8558 }
8559 }
8560
8564 unsigned char digest[16];
8565 char digres[128];
8568 MD5Update(&
md5, (
unsigned char *)secret, strlen(secret));
8570
8571 for (x=0;x<16;x++)
8572 sprintf(digres + (x << 1), "%02hhx", digest[x]);
8573 if (pvt) {
8576 }
8578 res = 0;
8581 if (pvt) {
8583 }
8584 res = 0;
8585 } else
8587 }
8588 return res;
8589}
8590
8591
8592
8593
8594
8596{
8598
8599 int res = -1;
8602 uint16_t callno = p->
callno;
8603
8604 memset(&ied, 0, sizeof(ied));
8605
8614 else
8616
8617
8619
8621 } else {
8627
8629
8632
8634
8636
8638
8639 ) {
8641 if (!res) {
8643 break;
8644 }
8645 }
8647 }
8649 if (!peer) {
8650
8651
8656 if (!(p =
iaxs[callno])) {
8658 return -1;
8659 }
8662 }
8663 if (!peer) {
8665 if (!(p =
iaxs[callno]))
8666 return -1;
8667 }
8668 }
8669 }
8670
8672
8674 return -1;
8675 }
8676
8680 ast_log(
LOG_WARNING,
"Call terminated. Encryption requested by peer but no secret available locally\n");
8681 return -1;
8682 }
8683
8684
8689 ast_log(
LOG_NOTICE,
"Call initiated without encryption while forceencryption=yes option is set\n");
8690 return -1;
8691 }
8692 if (!res) {
8698 if (variablestore && varlist && p->
owner) {
8699 variablestore->
data = varlist;
8704 if (prev)
8707 if (!newvar) {
8708
8709 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8710 } else {
8712 }
8713 }
8714 if (prev)
8718 } else {
8720 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
8721 if (variablestore)
8723 if (varlist)
8725 }
8726 }
8727
8728 if (!res)
8730 return res;
8731}
8732
8734
8736{
8738
8744 } else {
8746 }
8747 }
8748
8751}
8752
8754{
8755#ifdef SCHED_MULTITHREADED
8757#endif
8759 return 0;
8760}
8761
8763{
8764 int newcall = 0;
8767
8768 memset(&ied, 0, sizeof(ied));
8771 }
8774 }
8777 return -1;
8778 }
8782
8783
8786 }
8788
8791 }
8793 return 0;
8794}
8795
8797{
8798 char exten[256] = "";
8801
8804
8811
8816
8820 continue;
8825 dp->
flags &= ~CACHE_FLAG_PENDING;
8828 }
8829
8832 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
8833 }
8834 }
8835 }
8836 }
8839
8840 return 0;
8841}
8842
8844{
8845 int peercallno = 0;
8849
8851 peercallno = ies->
callno;
8852
8853 if (peercallno < 1) {
8855 return -1;
8856 }
8858
8859
8860
8863
8866
8871
8874 }
8876
8886
8896
8897
8898
8900 }
8901 return 0;
8902}
8903
8905{
8907}
8908
8909
8911{
8913
8914 char peer[256] = "";
8915 char msgstatus[60];
8917 char ourip[256] = "<Unspecified>";
8920 int oldmsgs;
8921
8924 }
8927 }
8930 }
8932
8933 }
8935 if (!reg) {
8937 return -1;
8938 }
8943 return -1;
8944 }
8948 }
8949
8950
8951
8956
8958 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new and %d old messages waiting", reg->
messages & 0xff, reg->
messages >> 8);
8960 snprintf(msgstatus,
sizeof(msgstatus),
" with %d new messages waiting", reg->
messages);
8962 ast_copy_string(msgstatus,
" with 1 new message waiting",
sizeof(msgstatus));
8963 } else {
8964 ast_copy_string(msgstatus,
" with no messages waiting",
sizeof(msgstatus));
8965 }
8966
8968
8971 }
8973 return 0;
8974}
8975
8977 const char *secret, const char *porta)
8978{
8980
8982 return -1;
8983 }
8984
8988 return -1;
8989 }
8990
8993
8996 }
8997
9000
9002
9003 if (!porta && !reg->
port) {
9005 } else if (porta) {
9006 sscanf(porta,
"%5d", ®->
port);
9007 }
9008
9010
9014
9015 return 0;
9016}
9017
9019{
9022 char *porta;
9024
9026 return -1;
9027
9032
9034 ast_log(
LOG_WARNING,
"Format for registration is user[:secret]@host[:port] at line %d\n", lineno);
9035 return -1;
9036 }
9037
9043 porta =
strsep(&stringp,
":");
9044
9045 if (porta && !atoi(porta)) {
9047 return -1;
9048 }
9049
9051}
9052
9053
9055{
9056 char multi[256];
9057 char *stringp, *
ext;
9060 stringp = multi;
9062 if (onoff) {
9066 } else
9068 }
9069 }
9070}
9072
9074{
9079 }
9080 }
9081
9086 }
9087 }
9088
9090}
9091
9093{
9096
9097 if (!peer)
9098 return;
9099 if (peer->
expire == -1) {
9100
9101 return;
9102 }
9103
9105
9106 ast_debug(1,
"Expiring registration for peer '%s'\n", peer->
name);
9111 "peer_status", "Unregistered",
9112 "cause", "Expired");
9114
9116
9118
9126
9129
9131}
9132
9134{
9135#ifdef SCHED_MULTITHREADED
9137#endif
9139 return 0;
9140}
9141
9143{
9144 char data[80];
9146
9148 return;
9149 }
9150
9151 expiry = strrchr(data,
':');
9154 return;
9155 }
9157
9160 return;
9161 }
9162
9164
9167
9173 }
9174 }
9175
9177
9181 }
9182
9185 }
9186
9188}
9189
9190
9191
9192
9193
9194
9195
9197{
9198
9199
9202 };
9204 int msgcount;
9205 char data[80];
9207 const char *peer_name;
9208 int res = -1;
9209 char *str_addr;
9210
9212
9213
9218 return -1;
9219 }
9222 goto return_unref;
9223
9226 time_t nowtime;
9227 time(&nowtime);
9229 } else {
9231 }
9232 }
9233
9234
9237 }
9239 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9243 ast_log(
LOG_NOTICE,
"Restricting registration for peer '%s' to %d seconds (requested %d)\n",
9246 } else {
9248 }
9249
9252
9255 }
9256
9257
9259
9260
9262
9264
9266
9269 ast_verb(3,
"Registered IAX2 '%s' (%s) at %s\n",
9275 "peer_status", "Registered",
9276 "address", str_addr,
9281 ast_verb(3,
"Unregistered IAX2 '%s' (%s)\n",
9286 "peer_status", "Unregistered");
9290 }
9291
9293
9294
9295
9297 }
9298
9299
9302 }
9303
9304
9306 res = -1;
9307 goto return_unref;
9308 }
9309
9310
9312
9317 }
9318 }
9319
9324 }
9329
9331
9335 int new, old;
9337
9339 if (msg) {
9343 } else {
9345 }
9346
9347 if (new > 255) {
9348 new = 255;
9349 }
9350 if (old > 255) {
9351 old = 255;
9352 }
9353 msgcount = (old << 8) | new;
9354
9356 }
9360 }
9361 }
9364 }
9365
9366 res = 0;
9367
9368return_unref:
9370
9372}
9373
9375{
9379 const char *peer_name;
9380 int sentauthmethod;
9381
9383
9384
9388 }
9389
9392 goto return_unref;
9393
9394 memset(&ied, 0, sizeof(ied));
9395
9396
9397
9398
9399
9400
9402 if (!p) {
9404 }
9407
9411 }
9413
9414return_unref:
9415 if (p) {
9417 }
9418
9420}
9421
9423{
9425
9427 char peer[256] = "";
9429 int res;
9430 int authmethods = 0;
9437 memset(&ied, 0, sizeof(ied));
9439 if (reg) {
9440
9443 return -1;
9444 }
9448 return -1;
9449 }
9452 if (reg->
secret[0] ==
'[') {
9453 char tmpkey[256];
9455 tmpkey[strlen(tmpkey) - 1] = '\0';
9457 } else
9459 if (!res) {
9463 } else
9464 return -1;
9466 } else
9468 return -1;
9469}
9470
9472{
9474}
9475
9477{
9478
9479 int callno = (int)(long)(nothing);
9483 memset(&ied, 0, sizeof(ied));
9490 }
9492 }
9494}
9495
9497{
9498 int callno = (int)(long)(data);
9503#ifdef SCHED_MULTITHREADED
9505#endif
9507 return 0;
9508}
9509
9510static int auth_fail(
int callno,
int failcode)
9511{
9512
9513
9519 } else
9521 }
9522 return 0;
9523}
9524
9526{
9527
9528 int callno = (int)(long)(nothing);
9532 memset(&ied, 0, sizeof(ied));
9536 }
9538}
9539
9541{
9542 int callno = (int)(long)(data);
9546 }
9548#ifdef SCHED_MULTITHREADED
9550#endif
9552 return 0;
9553}
9554
9556{
9558
9561 memset(&ied, 0, sizeof(ied));
9565}
9566
9568{
9570}
9571
9573{
9575
9577
9578 if (((
unsigned char) (f->
oseqno -
last) < 128) &&
9581 }
9582 }
9583}
9584
9586{
9590}
9591
9593{
9596#ifdef SCHED_MULTITHREADED
9598#endif
9600 return 0;
9601}
9602
9604{
9605 int res = 0;
9609 int calls = 0;
9610
9611
9613
9617
9622 else
9625
9629
9633 calls = tpeer->
calls;
9634#if 0
9636#endif
9637
9640 }
9641 if (res < 0)
9642 return res;
9643 return calls;
9644}
9645
9647{
9648
9649 if (now->tv_sec > tpeer->
trunkact.tv_sec + 5)
9650 return 1;
9651 return 0;
9652}
9653
9655{
9659
9662 }
9663
9667 return 0;
9668 }
9669 }
9670
9671
9674 processed++;
9675 res = 0;
9677
9678
9680
9681
9683 drop = tpeer;
9684 } else {
9688 ast_verbose(
" - Trunk peer (%s) has %d call chunk%s in transit, %u bytes backlogged and has hit a high water mark of %u bytes\n",
9690 res,
9691 (res != 1) ? "s" : "",
9692 tpeer->trunkdatalen,
9693 tpeer->trunkdataalloc);
9694 }
9695 }
9697 res = 0;
9699 }
9702
9703 if (drop) {
9705
9706
9708 if (drop->trunkdata) {
9710 drop->trunkdata =
NULL;
9711 }
9715 }
9716
9718 ast_verbose(
"Ending trunk processing with %d peers and %d call chunks processed\n", processed,
totalcalls);
9719 }
9721
9722 return 1;
9723}
9724
9730};
9731
9732static void dp_lookup(
int callno,
const char *context,
const char *callednum,
const char *callerid,
int skiplock)
9733{
9734 unsigned short dpstatus = 0;
9736 int mm;
9737
9738 memset(&ied1, 0, sizeof(ied1));
9740
9745 } else {
9747 }
9750 if (mm)
9752 if (!skiplock)
9759 }
9760 if (!skiplock)
9762}
9763
9765{
9766
9773}
9774
9776{
9777 pthread_t newthread;
9779
9781 return;
9782
9790 }
9791}
9792
9794{
9795 unsigned int ourver;
9796 char rsi[80];
9797 snprintf(rsi, sizeof(rsi), "si-%s", si);
9799 return 0;
9800 ast_debug(1,
"Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
9801 if (ourver != ver)
9803 return 0;
9804}
9805
9807{
9810
9811 memset(iep, 0, sizeof(*iep));
9812
9820}
9821
9823{
9831}
9832
9834{
9835 int i;
9836 unsigned int length, offset = 0;
9838
9841 if (length != 0) {
9843
9844 offset = 0;
9845 break;
9846 } else {
9847 memcpy(full_osptoken + offset, ies->
osptokenblock[i], length);
9848 offset += length;
9849 }
9850 } else {
9851 break;
9852 }
9853 }
9854 *(full_osptoken + offset) = '\0';
9855 if (strlen(full_osptoken) != offset) {
9856
9857 *full_osptoken = '\0';
9858 }
9859
9861}
9862
9864{
9865 int localjitter = -1, localdelay = 0, locallost = -1, locallosspct = -1, localdropped = 0, localooo = -1, localpackets = -1;
9867
9872 localjitter = jbinfo.
jitter;
9875 locallosspct = jbinfo.
losspct/1000;
9879 }
9880 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",
9883 localjitter,
9884 localdelay,
9885 locallost,
9886 locallosspct,
9887 localdropped,
9888 localooo,
9889 localpackets,
9897 }
9899}
9900
9902
9903
9904
9905
9907{
9909
9911
9914
9918
9920
9923
9925 }
9926
9928}
9929
9930
9931
9932
9933
9934
9935
9937{
9940
9942 return;
9943
9945 memcpy(pkt_buf->
buf, from_here->
buf, pkt_buf->
len);
9946
9953 break;
9954 }
9955 }
9957
9958 if (!cur_pkt_buf)
9960
9963
9965}
9966
9968{
9970 time_t t;
9971 static time_t last_errtime = 0;
9973
9975 time(&t);
9976 if (t != last_errtime) {
9977 last_errtime = t;
9978 ast_debug(1,
"Out of idle IAX2 threads for I/O, pausing!\n");
9979 }
9980 usleep(1);
9981 return 1;
9982 }
9983
9988 if (
thread->buf_len < 0) {
9989 if (
errno != ECONNREFUSED &&
errno != EAGAIN)
9994 return 1;
9995 }
9999 return 1;
10000 }
10001
10002
10003
10004
10009
10014 break;
10015 }
10016 if (cur) {
10017
10018
10023 return 1;
10024 } else {
10025
10031 }
10033 }
10034
10035
10037#ifdef DEBUG_SCHED_MULTITHREAD
10039#endif
10041
10042 return 1;
10043}
10044
10047{
10048 unsigned char metatype;
10053 unsigned int ts;
10054 void *ptr;
10055 struct timeval rxtrunktime;
10057
10058 if (packet_len < sizeof(*meta)) {
10059 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a meta frame but is too short\n",
10061 return 1;
10062 }
10063
10065 return 1;
10066
10067 if (packet_len < (sizeof(*meta) + sizeof(*mth))) {
10068 ast_log(
LOG_WARNING,
"midget meta trunk packet received (%d of %d min)\n", packet_len,
10069 (int) (sizeof(*meta) + sizeof(*mth)));
10070 return 1;
10071 }
10073 ts = ntohl(mth->
ts);
10074 metatype =
meta->cmddata;
10075 packet_len -= (sizeof(*meta) + sizeof(*mth));
10078 if (!tpeer) {
10079 ast_log(
LOG_WARNING,
"Unable to accept trunked packet from '%s': No matching peer\n",
10081 return 1;
10082 }
10088 while (packet_len >= sizeof(*mte)) {
10089
10090 unsigned short callno, trunked_ts,
len;
10091
10094 ptr += sizeof(*mtm);
10095 packet_len -= sizeof(*mtm);
10098 trunked_ts = ntohs(mtm->
mini.
ts);
10101 ptr += sizeof(*mte);
10102 packet_len -= sizeof(*mte);
10105 trunked_ts = 0;
10106 } else {
10108 break;
10109 }
10110
10111 if (
len > packet_len)
10112 break;
10115 continue;
10116
10117
10118
10119
10120 memset(&f, 0, sizeof(f));
10123
10133 else
10135 if (trunked_ts)
10137 else
10139
10142
10143
10149 else
10154 if (duped_fr)
10158 }
10159 } else {
10161 }
10162 }
10166 }
10167
10168 return 1;
10169}
10170
10172{
10176
10177 if (!chan) {
10179 return -1;
10180 }
10181
10183 if (!variablestore) {
10185 return 0;
10186 }
10187 varlist = variablestore->
data;
10188
10191 if (strcmp(
var->name, data) == 0) {
10193 break;
10194 }
10195 }
10197 return 0;
10198}
10199
10201{
10205
10206 if (!chan) {
10208 return -1;
10209 }
10210
10212 if (!variablestore) {
10214 if (!variablestore) {
10216 return -1;
10217 }
10219 if (!varlist) {
10222 return -1;
10223 }
10224
10226 variablestore->
data = varlist;
10229 } else
10230 varlist = variablestore->
data;
10231
10234 if (strcmp(
var->name, data) == 0) {
10237 break;
10238 }
10239 }
10244 else
10247 return 0;
10248}
10249
10254};
10255
10257{
10259 if (
iaxs[callno] &&
iaxs[callno]->owner) {
10262
10264 if (causecode) {
10266 }
10274 }
10275}
10276
10278{
10280 int res;
10281 int updatehistory=1;
10283 int dcallno = 0;
10284 char decrypted = 0;
10298 int fd;
10300 int minivid = 0;
10301 char empty[32]="";
10303 char host_pref_buf[128];
10304 char caller_pref_buf[128];
10306 char *using_prefs = "mine";
10307
10308
10310 memset(fr, 0, sizeof(*fr));
10312
10313
10317
10318 if (res < sizeof(*mh)) {
10319 ast_log(
LOG_WARNING,
"midget packet received (%d of %d min)\n", res, (
int)
sizeof(*mh));
10320 return 1;
10321 }
10322 if ((vh->
zeros == 0) && (ntohs(vh->
callno) & 0x8000)) {
10323 if (res < sizeof(*vh)) {
10324 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a video frame but is too short\n",
10326 return 1;
10327 }
10328
10329
10331 minivid = 1;
10332 }
else if ((
meta->zeros == 0) && !(ntohs(
meta->metacmd) & 0x8000))
10334
10335#ifdef DEBUG_SUPPORT
10336 if (res >= sizeof(*fh))
10338#endif
10340 if (res < sizeof(*fh)) {
10341 ast_log(
LOG_WARNING,
"Rejecting packet from '%s' that is flagged as a full frame but is too short\n",
10343 return 1;
10344 }
10345
10346
10347 dcallno = ntohs(fh->
dcallno) & ~IAX_FLAG_RETRANS;
10348
10349
10350
10351
10352
10353
10360 return 1;
10361 }
10362 decrypted = 1;
10363 }
10365 }
10366
10367
10372 return 1;
10373 }
10374 if ((fh->
csub >> 6) & 0x1) {
10376 }
10380 return 1;
10381 }
10382 } else {
10384 }
10385
10386
10388
10390 return 1;
10392
10393 return 1;
10394 }
10395
10396 f.
datalen = res -
sizeof(*fh);
10400 char subclass[40];
10404 return 1;
10405 }
10408 } else {
10410 memset(&ies, 0, sizeof(ies));
10411 }
10412 } else {
10415 else
10417 memset(&ies, 0, sizeof(ies));
10418 }
10419
10421
10424 return 1;
10425 }
10426
10428
10429
10430
10431
10433 } else {
10435 }
10436 }
10437 } else {
10438
10441 memset(&ies, 0, sizeof(ies));
10442 }
10443
10445 int check_dcallno = 0;
10446
10447
10448
10449
10450
10451
10452
10453
10454
10456 check_dcallno = 1;
10457 }
10458
10465 } else {
10467 }
10469 return 1;
10470 }
10471 }
10472
10477
10479 }
10480 }
10481
10483
10484
10486
10493 fd);
10494 }
10497 }
10499 return 1;
10500 }
10506 return 1;
10507 }
10508 decrypted = 1;
10509 }
10510
10511#ifdef DEBUG_SUPPORT
10512 if (decrypted) {
10514 }
10515#endif
10516
10523 int data_size = sizeof(*cause_code);
10524 char subclass[40] = "";
10525
10526
10528
10529
10530 data_size += 5;
10531
10532 data_size += 3;
10534 data_size++;
10535 }
10537 data_size++;
10538 }
10539
10540 data_size += strlen(subclass);
10541
10543 memset(cause_code, 0, data_size);
10545
10547 snprintf(cause_code->
code, data_size -
sizeof(*cause_code) + 1,
"IAX2 %s(%d)", subclass, ies.
causecode);
10548
10554 }
10558 return 1;
10559 }
10560 }
10561
10562
10564
10568 unsigned short new_peercallno;
10569
10570 new_peercallno = (
unsigned short) (ntohs(mh->
callno) & ~IAX_FLAG_FULL);
10574 }
10577 }
10578 }
10582
10583 fr->
oseqno = fh->oseqno;
10584 fr->
iseqno = fh->iseqno;
10585 fr->
ts = ntohl(fh->ts);
10586#ifdef IAXTESTS
10587 if (test_resync) {
10588 ast_debug(1,
"Simulating frame ts resync, was %u now %u\n", fr->
ts, fr->
ts + test_resync);
10589 fr->
ts += test_resync;
10590 }
10591#endif
10592#if 0
10599#endif
10601 updatehistory = 0;
10610 if (
10620
10621 ast_debug(1,
"Packet arrived out of order (expecting %d, got %d) (frametype = %u, subclass = %d)\n",
10623
10624
10626
10630
10631
10633 }
10634 } else {
10635
10637 }
10640 return 1;
10641 }
10642 } else {
10643
10651 }
10652
10654 if (res < thread->buf_size)
10655 thread->buf[res++] =
'\0';
10656 else
10657 thread->buf[res - 1] =
'\0';
10658 }
10659
10660
10661
10665 unsigned char x;
10666 int call_to_destroy;
10667
10670 else
10673
10674
10676
10678 ast_debug(1,
"Cancelling transmission of packet %d\n", x);
10679 call_to_destroy = 0;
10681
10684
10686 call_to_destroy = fr->
callno;
10687 }
10688 }
10689 if (call_to_destroy) {
10691 ast_debug(1,
"Really destroying %d, having been acked on final message\n", call_to_destroy);
10695 }
10696 }
10697
10700 else {
10701
10704 return 1;
10705 }
10706 } else {
10708 }
10709 }
10714
10717 return 1;
10718 }
10719
10720
10721
10722
10733 return 1;
10734 }
10735 }
10736
10741
10746 return 1;
10747 }
10751
10752 if (variablestore && varlist) {
10753 variablestore->
data = varlist;
10759 if (prev) {
10761 }
10763 if (!newvar) {
10764
10765 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10766 } else {
10768 }
10769 }
10770 if (prev) {
10772 }
10775 } else {
10776 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
10777 if (variablestore) {
10779 }
10780 if (varlist) {
10782 }
10783 }
10785 } else {
10786
10787
10788 ast_debug(1,
"No channel, so populating IAXVARs to the pvt, as an intermediate step.\n");
10794 }
10795 }
10796 }
10797
10799 ast_debug(1,
"I have IAX variables, but they were not processed\n");
10800 }
10801 }
10802
10803
10804
10807 }
10808
10818 if (native) {
10823 }
10825 }
10827 }
10828 } else {
10829 ast_debug(1,
"Neat, somebody took away the channel at a magical time but i found it!\n");
10830
10833 ast_debug(1,
"I can haz iaxvars, but they is no good. :-(\n");
10835 }
10837 return 1;
10838 }
10839 }
10840 }
10841 }
10846 }
10847 }
10850
10853
10854
10862 }
10866 }
10869
10870 break;
10875 const char *moh_suggest;
10876
10879 break;
10880 }
10881
10882
10883
10884
10885
10889 }
10890 }
10891 break;
10896 break;
10897 }
10898
10901 break;
10902 }
10903
10904
10905
10906
10907
10910 }
10911 break;
10914
10916
10919 }
10920 }
10921 memset(&ied1, 0, sizeof(ied1));
10925 }
10926 break;
10928
10930 break;
10936 break;
10937 }
10938 }
10939
10941 int new_callno;
10943 fr->
callno = new_callno;
10944 }
10945
10949
10952 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, who was trying to reach '%s@%s'\n",
10954 }
10955 break;
10956 }
10959 ast_log(
LOG_WARNING,
"Rejected connect attempt. No secret present while force encrypt enabled.\n");
10960 break;
10961 }
10963 const char *
context, *exten, *cid_num;
10964
10968
10969
10973
10975 break;
10976 }
10977 } else
10979
10983 memset(&ied0, 0, sizeof(ied0));
10988 break;
10989 }
10991 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
10993 }
10994 } else {
10995
10996
10999 using_prefs = "reqonly";
11000 } else {
11001 using_prefs = "disabled";
11002 }
11004 memset(&pref, 0, sizeof(pref));
11005 strcpy(caller_pref_buf, "disabled");
11006 strcpy(host_pref_buf, "disabled");
11007 } else {
11009 using_prefs = "mine";
11010
11014
11017 using_prefs = "caller";
11018 } else {
11020 }
11021 } else
11023
11027 }
11028 if (!format) {
11031 if (!format) {
11032 memset(&ied0, 0, sizeof(ied0));
11037 break;
11038 }
11043
11045 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11049 } else {
11050 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11055 }
11056 }
11057 } else {
11058
11061 format = 0;
11062 } else {
11065 memset(&pref, 0, sizeof(pref));
11067 strcpy(caller_pref_buf,"disabled");
11068 strcpy(host_pref_buf,"disabled");
11069 } else {
11071 using_prefs = "mine";
11073
11076 } else {
11078 using_prefs = "caller";
11079 }
11081 } else
11083 }
11084 }
11085
11086 if (!format) {
11090
11091 memset(&ied0, 0, sizeof(ied0));
11097 break;
11098 }
11100 ast_log(
LOG_NOTICE,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11105 }
11107 break;
11108 }
11109 }
11110 }
11111 if (format) {
11112
11113 memset(&ied1, 0, sizeof(ied1));
11119 ast_verb(3,
"Accepting UNAUTHENTICATED call from %s:\n"
11120 "%srequested format = %s,\n"
11121 "%srequested prefs = %s,\n"
11122 "%sactual format = %s,\n"
11123 "%shost prefs = %s,\n"
11124 "%spriority = %s\n",
11129 caller_pref_buf,
11133 host_pref_buf,
11135 using_prefs);
11136
11138
11139
11142 } else {
11144
11146 }
11147 }
11148 }
11149 break;
11150 }
11153 else
11157 break;
11159
11163
11165 } else {
11166
11168 }
11169 }
11170 break;
11173 ast_debug(1,
"Immediately destroying %d, having received hangup\n", fr->
callno);
11174
11178 break;
11179 }
11180 }
11181
11182
11185 break;
11187
11191 break;
11192 }
11193 }
11194
11200 ast_debug(1,
"Immediately destroying %d, having received reject\n",
11202 }
11203
11209 break;
11211 {
11214
11215 break;
11216 }
11220
11224
11230 }
11231
11234 }
11235
11236 break;
11237 }
11239
11241 break;
11243
11246 break;
11247 }
11250 } else {
11253 else
11255 }
11259 memset(&ied0, 0, sizeof(ied0));
11264 break;
11265 }
11269
11270 ast_log(
LOG_NOTICE,
"Rejected call to %s, format %s incompatible with our capability %s.\n",
11274 }
11275 } else {
11277
11282
11283
11286 native);
11289
11290
11296 }
11297
11299 }
11306 }
11307 break;
11309
11311 break;
11313 {
11316
11318 }
11319 break;
11321
11323
11325
11326
11328
11337 "peer_status", "Reachable",
11340 }
11346 "peer_status", "Lagged",
11349 }
11350 }
11357 else
11359
11360
11365 }
11366 }
11367
11370 else
11374
11376
11380 }
11381 break;
11390
11393 } else {
11394
11395 unsigned int ts;
11396
11400 ast_debug(1,
"Peer %s lag measured as %dms\n",
11402 }
11403 break;
11407 break;
11408 }
11412 };
11414 "I don't know how to authenticate %s to %s\n",
11417 }
11418 break;
11420
11423
11426 break;
11427 }
11432 memset(&ied0, 0, sizeof(ied0));
11434 break;
11435 }
11437
11439 } else
11443 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, request '%s@%s' does not exist\n",
11447 memset(&ied0, 0, sizeof(ied0));
11452 break;
11453 }
11454 } else {
11455
11458 using_prefs = "reqonly";
11459 } else {
11460 using_prefs = "disabled";
11461 }
11463 memset(&pref, 0, sizeof(pref));
11464 strcpy(caller_pref_buf, "disabled");
11465 strcpy(host_pref_buf, "disabled");
11466 } else {
11468 using_prefs = "mine";
11474 using_prefs = "caller";
11475 } else {
11477 }
11478 } else
11483 }
11484 if (!format) {
11488
11490 ast_debug(1,
"We don't do requested format %s, falling back to peer capability '%s'\n",
11494 }
11495 if (!format) {
11498 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11502 } else {
11503 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11508 }
11509 }
11510 memset(&ied0, 0, sizeof(ied0));
11515 break;
11516 }
11517 } else {
11518
11521 format = 0;
11522 } else {
11525 memset(&pref, 0, sizeof(pref));
11529 strcpy(caller_pref_buf,"disabled");
11530 strcpy(host_pref_buf,"disabled");
11531 } else {
11533 using_prefs = "mine";
11535
11538 } else {
11540 using_prefs = "caller";
11541 }
11543 } else
11545 }
11546 }
11547 if (!format) {
11551
11556 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
11560 } else {
11561 ast_log(
LOG_WARNING,
"Rejected connect attempt from %s, requested/capability '%s'/'%s' incompatible with our capability '%s'.\n",
11566 }
11567 }
11568 memset(&ied0, 0, sizeof(ied0));
11573 break;
11574 }
11575 }
11576 }
11577 }
11578 if (format) {
11579
11580 memset(&ied1, 0, sizeof(ied1));
11587 ast_verb(3,
"Accepting AUTHENTICATED call from %s:\n"
11588 "%srequested auth methods = (%s),\n"
11589 "%sactual auth method = %s,\n"
11590 "%sencrypted = %s,\n"
11591 "%srequested format = %s,\n"
11592 "%srequested prefs = %s,\n"
11593 "%sactual format = %s,\n"
11594 "%shost prefs = %s,\n"
11595 "%spriority = %s\n",
11606 caller_pref_buf,
11610 host_pref_buf,
11612 using_prefs);
11613
11614
11615
11616
11618
11624 }
else if (ies.
vars) {
11630 if (variablestore && varlist) {
11631 variablestore->
data = varlist;
11634 ast_debug(1,
"I can haz IAX vars? w00t\n");
11637 if (prev)
11640 if (!newvar) {
11641
11642 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11643 } else {
11645 }
11646 }
11647 if (prev)
11651 } else {
11652 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11653 if (variablestore)
11655 if (varlist)
11657 }
11658 }
11659 } else {
11661
11664 goto immediatedial;
11665 }
11666 }
11667 }
11668 }
11669 break;
11671immediatedial:
11677 ast_log(
LOG_WARNING,
"Rejected dial attempt from %s, request '%s@%s' does not exist\n",
11681 memset(&ied0, 0, sizeof(ied0));
11686 break;
11687 }
11688 } else {
11691 ast_verb(3,
"Accepting DIAL from %s, formats = %s\n",
11701 }
else if (ies.
vars) {
11707 ast_debug(1,
"I can haz IAX vars? w00t\n");
11708 if (variablestore && varlist) {
11709 variablestore->
data = varlist;
11714 if (prev)
11717 if (!newvar) {
11718
11719 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11720 } else {
11722 }
11723 }
11724 if (prev)
11728 } else {
11729 ast_log(
LOG_ERROR,
"Memory allocation error while processing IAX2 variables\n");
11730 if (variablestore)
11732 if (varlist)
11734 }
11735 }
11736 }
11737 }
11738 break;
11741 ast_debug(1,
"Immediately destroying %d, having received INVAL\n", fr->
callno);
11744 break;
11746 ast_debug(1,
"Received VNAK: resending outstanding frames\n");
11747
11749 break;
11752
11757 break;
11758 }
11759
11761 break;
11762 }
11764 break;
11765 }
11768
11771 }
11774 }
11776 break;
11777 }
11782 }
11783 break;
11784 }
11786 break;
11790 }
11791
11794 break;
11801 }
11804 }
11805
11808 break;
11810
11812 memset(&ied0, 0, sizeof(ied0));
11816 }
11817 break;
11823 }
11825 break;
11826 }
11827
11831
11833 break;
11834 }
11835
11840 }
11842 break;
11848 }
11850 break;
11851 }
11852
11857 } else {
11860 }
11861 break;
11862 }
11864
11866 break;
11867 }
11868
11873 break;
11874 }
11875
11876
11877
11878
11879
11883
11886
11887 memset(&ied0, 0, sizeof(ied0));
11888 memset(&ied1, 0, sizeof(ied1));
11893 } else {
11896
11901
11902
11905
11906 memset(&ied0, 0, sizeof(ied0));
11907 memset(&ied1, 0, sizeof(ied1));
11912 }
11914 break;
11917 break;
11921 break;
11923
11927 break;
11931
11934 }
11935 }
11936
11938 }
11939 break;
11943 "we've been told to rotate our encryption key, "
11944 "but this isn't an encrypted call. bad things will happen.\n"
11945 );
11946 break;
11947 }
11948
11950
11952 break;
11955 break;
11958 break;
11960
11963 break;
11964 }
11965 memset(&ied0, 0, sizeof(ied0));
11967 if (res < 0)
11969 else if (res > 0)
11971 else
11973 break;
11975 {
11977
11980 }
11981 break;
11982 }
11983 default:
11985 memset(&ied0, 0, sizeof(ied0));
11988 }
11989
11992 ast_debug(1,
"I can haz IAX vars, but they is no good :-(\n");
11994 }
11995
11996
12004 }
12005 }
12007 return 1;
12008 }
12009
12012 } else if (minivid) {
12015 if (ntohs(vh->
ts) & 0x8000LL) {
12017 }
12022 return 1;
12023 }
12024 } else {
12029 return 1;
12030 }
12031 f.
datalen = res -
sizeof(*vh);
12036 return 1;
12037 }
12040 else
12042#ifdef IAXTESTS
12043 if (test_resync) {
12044 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | ((ntohs(vh->ts) + test_resync) & 0x7fff);
12045 } else
12046#endif
12047 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF8000L) | (ntohs(vh->ts) & 0x7fff);
12048 } else {
12049
12056 return 1;
12057 }
12058 } else {
12059 ast_debug(1,
"Received mini frame before first full voice frame\n");
12063 return 1;
12064 }
12070 return 1;
12071 }
12074 else
12076#ifdef IAXTESTS
12077 if (test_resync) {
12078 fr->
ts = (
iaxs[fr->
callno]->
last & 0xFFFF0000L) | ((ntohs(mh->
ts) + test_resync) & 0xffff);
12079 } else
12080#endif
12082
12083 }
12084
12085
12090 return 1;
12091 }
12092
12095
12096 ast_debug(2,
"Callno %d: Blocked receiving control frame %d.\n",
12100 return 1;
12101 }
12106
12107 ast_debug(2,
"Callno %d: Config blocked receiving control frame %d.\n",
12111 return 1;
12112 }
12113 }
12114
12121 }
12123 }
12124 }
12125
12130
12131
12132
12133
12134
12135
12139
12144
12154 }
12155 }
12157 }
12158
12159
12166
12169 } else
12171
12176 return 1;
12177 }
12178
12180
12181
12183
12185 } else {
12188 }
12190 }
12194 if (duped_fr) {
12196 }
12197 }
12200#if 1
12203#endif
12204 }
12205
12206
12209 return 1;
12210}
12211
12213{
12217 }
12218 return res;
12219}
12220
12221
12223{
12230
12232}
12233
12235{
12237 struct timeval wait;
12238 struct timespec ts;
12239 int put_into_idle = 0;
12240 int first_time = 1;
12241 int old_state;
12242
12244
12245 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
12247
12248 for (;;) {
12249
12251
12254 break;
12255 }
12256
12257
12258 if (first_time) {
12260 first_time = 0;
12261 }
12262
12263
12264 if (put_into_idle) {
12266 }
12267
12270
12272 ts.tv_sec = wait.tv_sec;
12273 ts.tv_nsec = wait.tv_usec * 1000;
12275
12276
12277 if (!put_into_idle ||
thread->stop) {
12279 break;
12280 }
12282
12286 if (t) {
12287
12288
12289
12291 break;
12292 }
12293
12294
12295
12297 ts.tv_sec = wait.tv_sec;
12298 ts.tv_nsec = wait.tv_usec * 1000;
12301 break;
12302 }
12303 }
12304 } else {
12306 }
12307
12308
12309 put_into_idle = 1;
12310
12312
12314 break;
12315 }
12316
12317
12318 switch (
thread->iostate) {
12320 continue;
12326 break;
12330#ifdef SCHED_MULTITHREADED
12332#endif
12333 break;
12334 default:
12335 break;
12336 }
12337
12338
12339
12340
12344
12345
12347
12348 time(&
thread->checktime);
12350#ifdef DEBUG_SCHED_MULTITHREAD
12351 thread->curfunc[0]=
'\0';
12352#endif
12353 }
12354
12355
12356
12357
12358
12359
12363
12367
12369
12370 pthread_detach(pthread_self());
12371 }
12372
12373
12374
12375
12376 pthread_cleanup_pop(1);
12378}
12379
12381{
12385
12388
12390 }
12391
12392
12393
12394
12395
12397 int callno = reg->
callno;
12402 }
12405 ast_debug(1,
"Unable to send registration request for '%s' without IP address\n", reg->
username);
12406
12409 return -1;
12410 }
12413 }
12414
12416
12417 ast_debug(3,
"Allocate call number\n");
12418
12422 return -1;
12423 } else
12427 }
12428
12431
12432 memset(&ied, 0, sizeof(ied));
12438 return 0;
12439}
12440
12442{
12443
12444
12447 unsigned int sig;
12449 int callno;
12451
12452 memset(&cai, 0, sizeof(cai));
12453
12454 ast_debug(1,
"Provisioning '%s' from template '%s'\n", dest,
template);
12455
12457 ast_debug(1,
"No provisioning found for template '%s'\n",
template);
12458 return 0;
12459 }
12460
12465 return -1;
12466
12467
12468 memset(&ied, 0, sizeof(ied));
12470
12472 if (!callno)
12473 return -1;
12474
12475 if (
iaxs[callno]) {
12476
12480
12482 }
12484
12485 return 1;
12486}
12487
12488static char *
papp =
"IAX2Provision";
12489
12490
12491
12492
12494{
12495 int res;
12496 char *sdata;
12497 char *opts;
12498 int force =0;
12501 data = "default";
12503 opts = strchr(sdata, '|');
12504 if (opts)
12505 *opts='\0';
12506
12509 return -1;
12510 }
12513 return -1;
12514 }
12516 ast_verb(3,
"Provisioned IAXY at '%s' with '%s'= %d\n",
12518 sdata, res);
12519 return res;
12520}
12521
12523{
12524 int force = 0;
12525 int res;
12526
12527 switch (cmd) {
12529 e->
command =
"iax2 provision";
12531 "Usage: iax2 provision <host> <template> [forced]\n"
12532 " Provisions the given peer or IP address using a template\n"
12533 " matching either 'template' or '*' if the template is not\n"
12534 " found. If 'forced' is specified, even empty provisioning\n"
12535 " fields will be provisioned as empty fields.\n";
12541 }
12542
12546 if (!strcasecmp(
a->argv[4],
"forced"))
12547 force = 1;
12548 else
12550 }
12552 if (res < 0)
12553 ast_cli(
a->fd,
"Unable to find peer/address '%s'\n",
a->argv[2]);
12554 else if (res < 1)
12555 ast_cli(
a->fd,
"No template (including wildcard) matching '%s'\n",
a->argv[3]);
12556 else
12557 ast_cli(
a->fd,
"Provisioning '%s' with template '%s'%s\n",
a->argv[2],
a->argv[3], force ?
", forced" :
"");
12559}
12560
12562{
12565
12566 if (peer->
lastms > -1) {
12568
12572 "peer_status", "Unreachable",
12576 }
12581 }
12584
12588}
12589
12591{
12594#ifdef SCHED_MULTITHREADED
12596#endif
12599 return 0;
12600}
12601
12603{
12605
12607
12608 return 0;
12609}
12610
12612{
12614 int poke_timeout;
12615
12617
12618
12623 return 0;
12624 }
12625
12626
12632 }
12633 if (heldcall)
12636 if (heldcall)
12640 return -1;
12641 }
12642
12647 }
12648 }
12649
12651
12652
12653
12654
12655
12657 } else {
12658
12659
12660
12661
12662
12664 }
12665
12666
12668
12671
12672
12677 .pos = 0,
12678 };
12679
12680
12683
12686 }
12688
12689 return 0;
12690}
12691
12693{
12695 while(con) {
12696 conl = con;
12699 }
12700}
12701
12703{
12704 int callno;
12705 int res;
12710 char *tmpstr;
12712
12713 memset(&pds, 0, sizeof(pds));
12716
12718
12722 }
12723 memset(&cai, 0, sizeof(cai));
12725
12727
12728
12732 }
12733
12735 int bindport;
12738 }
12739
12741 if (callno < 1) {
12745 }
12746
12747
12750 int new_callno;
12751 if ((new_callno =
make_trunk(callno, 1)) != -1)
12752 callno = new_callno;
12753 }
12755 if (callid) {
12757 }
12758
12761 }
12762
12764 requestor, cai.
found);
12765
12767
12771 if (callid) {
12775 }
12776
12778 if (!joint) {
12781 }
12782
12784
12785
12789
12791 if (res < 0) {
12794
12802 }
12805 ao2_ref(best_fmt_native, -1);
12806 }
12811
12814 }
12815
12817}
12818
12820{
12821 int res;
12822
12825 }
12826
12827 for (;;) {
12828 pthread_testcancel();
12829
12830
12831
12833
12834
12835 if (res < 0 &&
errno != -EINTR) {
12837 break;
12838 }
12839 }
12840
12842}
12843
12845{
12847 int threadcount = 0;
12848 int x;
12853 thread->threadnum = ++threadcount;
12858
12860
12870 continue;
12871 }
12872
12874
12875
12877
12881 }
12882 }
12885 return -1;
12886 }
12887 ast_verb(2,
"%d helper threads started\n", threadcount);
12888 return 0;
12889}
12890
12892{
12894
12897
12898 return con;
12899}
12900
12902{
12904 if (strstr(
value,
"rsa"))
12906 if (strstr(
value,
"md5"))
12908 if (strstr(
value,
"plaintext"))
12911}
12912
12913
12914
12915
12916
12917
12918
12920{
12921 int sd;
12922
12923 sd = socket(addr->
ss.ss_family, SOCK_DGRAM, 0);
12924 if (sd < 0) {
12926 return -1;
12927 }
12928
12931 close(sd);
12932 return 1;
12933 }
12934
12935 close(sd);
12936 return 0;
12937}
12938
12939
12940
12941
12943{
12945 int nonlocal = 1;
12948 char *tmp;
12949 char *host;
12950 char *portstr;
12951
12954
12955 if (portstr) {
12956 port = atoi(portstr);
12957 if (port < 1)
12959 }
12960
12964
12966
12968
12971 if (sock) {
12973 nonlocal = 0;
12974 } else {
12975
12980 if (sock) {
12983 nonlocal = 0;
12984 } else {
12985 nonlocal = 2;
12986 }
12987 }
12988 }
12989 }
12990 }
12991
12993
12994 if (nonlocal == 1) {
12996 "Non-local or unbound address specified (%s) in sourceaddress for '%s', reverting to default\n",
12997 srcaddr,
12999 return -1;
13000 } else if (nonlocal == 2) {
13002 "Unable to bind to sourceaddress '%s' for '%s', reverting to default\n",
13003 srcaddr,
13005 return -1;
13006 } else {
13007 ast_debug(1,
"Using sourceaddress %s for '%s'\n", srcaddr, peer->
name);
13008 return 0;
13009 }
13010}
13011
13013{
13016
13018
13023 }
13024
13026
13029
13032 }
13033
13035
13037}
13038
13039
13041{
13044 int maskfound = 0;
13045 int found = 0;
13046 int firstpass = 1;
13047 int subscribe_acl_change = 0;
13048
13049 if (!temponly) {
13052 firstpass = 0;
13053 }
13054
13055 if (peer) {
13056 found++;
13057 if (firstpass) {
13058 oldacl = peer->
acl;
13060 }
13070 }
13071 }
13072
13073 if (peer) {
13074 if (firstpass) {
13080 if (!found) {
13085 }
13101 }
13102
13103 if (!v) {
13104 v = alt;
13106 }
13107 while(v) {
13108 if (!strcasecmp(v->
name,
"secret")) {
13110 }
else if (!strcasecmp(v->
name,
"mailbox")) {
13112 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13114 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13116 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13118 }
else if (!strcasecmp(v->
name,
"description")) {
13120 }
else if (!strcasecmp(v->
name,
"trunk")) {
13123 ast_log(
LOG_WARNING,
"Unable to support trunking on peer '%s' without a timing interface\n", peer->
name);
13125 }
13126 }
else if (!strcasecmp(v->
name,
"auth")) {
13130 }
13131 }
else if (!strcasecmp(v->
name,
"encryption")) {
13135 }
13136 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13139 } else {
13143 }
13144 }
13145 }
else if (!strcasecmp(v->
name,
"transfer")) {
13146 if (!strcasecmp(v->
value,
"mediaonly")) {
13150 } else
13152 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13154 }
else if (!strcasecmp(v->
name,
"host")) {
13155 if (!strcasecmp(v->
value,
"dynamic")) {
13156
13158 if (!found) {
13160 if (peer_port) {
13162 }
13164 }
13165 } else {
13166
13170
13172 } else {
13173
13175 }
13178 }
13181 }
13182 }
13183 }
else if (!strcasecmp(v->
name,
"defaultip")) {
13185 peer_defaddr_tmp.
ss.ss_family = AF_UNSPEC;
13188 }
13191 }
else if (!strcasecmp(v->
name,
"sourceaddress")) {
13193 }
else if (!strcasecmp(v->
name,
"permit") ||
13194 !strcasecmp(v->
name,
"deny") ||
13195 !strcasecmp(v->
name,
"acl")) {
13197 }
else if (!strcasecmp(v->
name,
"mask")) {
13198 maskfound++;
13200 }
else if (!strcasecmp(v->
name,
"context")) {
13202 }
else if (!strcasecmp(v->
name,
"regexten")) {
13204 }
else if (!strcasecmp(v->
name,
"peercontext")) {
13206 }
else if (!strcasecmp(v->
name,
"port")) {
13207 int bindport;
13210 }
13213 } else {
13215 }
13216 }
else if (!strcasecmp(v->
name,
"username")) {
13218 }
else if (!strcasecmp(v->
name,
"allow")) {
13220 }
else if (!strcasecmp(v->
name,
"disallow")) {
13222 }
else if (!strcasecmp(v->
name,
"callerid")) {
13224 char name2[80];
13225 char num2[80];
13229 } else {
13232 }
13234 }
else if (!strcasecmp(v->
name,
"fullname")) {
13237 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13240 }
else if (!strcasecmp(v->
name,
"sendani")) {
13242 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13244 }
else if (!strcasecmp(v->
name,
"outkey")) {
13246 }
else if (!strcasecmp(v->
name,
"qualify")) {
13247 if (!strcasecmp(v->
value,
"no")) {
13249 }
else if (!strcasecmp(v->
value,
"yes")) {
13251 }
else if (sscanf(v->
value,
"%30d", &peer->
maxms) != 1) {
13252 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);
13254 }
13255 }
else if (!strcasecmp(v->
name,
"qualifysmoothing")) {
13257 }
else if (!strcasecmp(v->
name,
"qualifyfreqok")) {
13259 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);
13260 }
13261 }
else if (!strcasecmp(v->
name,
"qualifyfreqnotok")) {
13263 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);
13264 }
13265 }
else if (!strcasecmp(v->
name,
"timezone")) {
13267 }
else if (!strcasecmp(v->
name,
"adsi")) {
13269 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13272 }
else if (!strcasecmp(v->
value,
"send")) {
13275 }
else if (!strcasecmp(v->
value,
"receive")) {
13278 } else {
13280 }
13281 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
13284 } else {
13286 }
13287 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13288
13291 }
else if (!strcasecmp(v->
value,
"auto")) {
13295 } else {
13297 }
13298 }
13299
13301 if (!v) {
13302 v = alt;
13304 }
13305 }
13309 }
13310
13316 } else {
13318 }
13319 }
13320
13321 if (oldacl) {
13323 }
13324
13326
13327
13328
13330 }
13331
13332 if (subscribe_acl_change) {
13334 }
13335
13336 return peer;
13337}
13338
13340{
13342
13348 }
13350}
13351
13352
13354{
13359 int format;
13360 int firstpass=1;
13361 int oldcurauthreq = 0;
13362 int subscribe_acl_change = 0;
13363 char *varname =
NULL, *varval =
NULL;
13365
13366 if (!temponly) {
13369 firstpass = 0;
13370 }
13371
13373 if (firstpass) {
13374 oldcurauthreq =
user->curauthreq;
13375 oldacl =
user->acl;
13376 oldcon =
user->contexts;
13379 }
13380
13382 } else {
13384 }
13385
13387 if (firstpass) {
13393 }
13395 user->curauthreq = oldcurauthreq;
13411 }
13412 if (!v) {
13413 v = alt;
13415 }
13416 while(v) {
13417 if (!strcasecmp(v->
name,
"context")) {
13419 if (con) {
13420 if (conl)
13422 else
13423 user->contexts = con;
13424 conl = con;
13425 }
13426 }
else if (!strcasecmp(v->
name,
"permit") ||
13427 !strcasecmp(v->
name,
"deny") ||
13428 !strcasecmp(v->
name,
"acl")) {
13430 }
else if (!strcasecmp(v->
name,
"setvar")) {
13432 if ((varval = strchr(varname, '='))) {
13433 *varval = '\0';
13434 varval++;
13438 user->vars = tmpvar;
13439 }
13440 }
13441 }
13442 }
else if (!strcasecmp(v->
name,
"allow")) {
13444 }
else if (!strcasecmp(v->
name,
"disallow")) {
13446 }
else if (!strcasecmp(v->
name,
"trunk")) {
13449 ast_log(
LOG_WARNING,
"Unable to support trunking on user '%s' without a timing interface\n",
user->name);
13451 }
13452 }
else if (!strcasecmp(v->
name,
"auth")) {
13456 }
13457 }
else if (!strcasecmp(v->
name,
"encryption")) {
13459 if (!
user->encmethods) {
13461 }
13462 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13465 } else {
13467 if (
user->encmethods) {
13469 }
13470 }
13471 }
else if (!strcasecmp(v->
name,
"transfer")) {
13472 if (!strcasecmp(v->
value,
"mediaonly")) {
13476 } else
13478 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13479 if(!strcasecmp(v->
value,
"caller"))
13481 else if(!strcasecmp(v->
value,
"disabled"))
13483 else if(!strcasecmp(v->
value,
"reqonly")) {
13486 }
13487 }
else if (!strcasecmp(v->
name,
"immediate")) {
13489 }
else if (!strcasecmp(v->
name,
"jitterbuffer")) {
13491 }
else if (!strcasecmp(v->
name,
"dbsecret")) {
13493 }
else if (!strcasecmp(v->
name,
"secret")) {
13496
13498 } else
13500 }
else if (!strcasecmp(v->
name,
"callerid")) {
13502 char name2[80];
13503 char num2[80];
13508 } else {
13512 }
13513 }
else if (!strcasecmp(v->
name,
"fullname")) {
13517 } else {
13521 }
13522 }
else if (!strcasecmp(v->
name,
"cid_number")) {
13526 } else {
13530 }
13531 }
else if (!strcasecmp(v->
name,
"accountcode")) {
13533 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
13535 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
13537 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
13539 }
else if (!strcasecmp(v->
name,
"language")) {
13541 }
else if (!strcasecmp(v->
name,
"amaflags")) {
13543 if (format < 0) {
13545 } else {
13546 user->amaflags = format;
13547 }
13548 }
else if (!strcasecmp(v->
name,
"inkeys")) {
13550 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
13552 if (
user->maxauthreq < 0)
13553 user->maxauthreq = 0;
13554 }
else if (!strcasecmp(v->
name,
"adsi")) {
13556 }
else if (!strcasecmp(v->
name,
"connectedline")) {
13559 }
else if (!strcasecmp(v->
value,
"send")) {
13562 }
else if (!strcasecmp(v->
value,
"receive")) {
13565 } else {
13567 }
13568 }
else if (!strcasecmp(v->
name,
"requirecalltoken")) {
13569
13572 }
else if (!strcasecmp(v->
value,
"auto")) {
13576 } else {
13578 }
13579 }
13580
13582 if (!v) {
13583 v = alt;
13585 }
13586 }
13587 if (!
user->authmethods) {
13594 } else {
13596 }
13597 }
13599 }
13601 if (oldacl) {
13603 }
13604 if (oldcon) {
13606 }
13607
13608 if (subscribe_acl_change) {
13610 }
13611
13613}
13614
13616{
13618
13620
13621 return 0;
13622}
13623
13625{
13627
13629
13630 return 0;
13631}
13632
13634{
13636
13638
13643 }
13650 }
13652 }
13656 }
13658
13660}
13661
13663{
13666
13671 }
13673 }
13675}
13676
13677
13679{
13682
13687 }
13689 }
13691}
13692
13694{
13707}
13708
13709
13711{
13715 char *cat;
13716 const char *utype;
13717 const char *tosval;
13718 int format;
13720 int x;
13721 int mtuv;
13722 int subscribe_network_change = 1;
13729
13731
13732 if (!cfg) {
13734 return -1;
13739 return 0;
13740 }
13741 if (!cfg) {
13742
13744 return -1;
13745 }
13748 return 0;
13749 } else {
13751 }
13752
13755 }
13756
13758
13759
13761
13762
13766
13767#ifdef SO_NO_CHECK
13768 nochecksums = 0;
13769#endif
13770
13772
13778
13780
13783
13785
13786
13788 if (tosval) {
13791 }
13792
13794 if (tosval) {
13797 }
13798 while(v) {
13799 if (!strcasecmp(v->
name,
"bindport")) {
13802 }
13805 }
13806 }
else if (!strcasecmp(v->
name,
"pingtime")){
13808 }
13809 else if (!strcasecmp(v->
name,
"iaxthreadcount")) {
13813 } else {
13821 }
13822 }
13823 }
else if (!strcasecmp(v->
name,
"iaxmaxthreadcount")) {
13828 } else {
13836 }
13837 }
13838 }
else if (!strcasecmp(v->
name,
"nochecksums")) {
13839#ifdef SO_NO_CHECK
13841 nochecksums = 1;
13842 else
13843 nochecksums = 0;
13844#else
13846 ast_log(
LOG_WARNING,
"Disabling RTP checksums is not supported on this operating system!\n");
13847#endif
13848 }
13849 else if (!strcasecmp(v->
name,
"maxjitterbuffer"))
13851 else if (!strcasecmp(v->
name,
"resyncthreshold"))
13853 else if (!strcasecmp(v->
name,
"maxjitterinterps"))
13855 else if (!strcasecmp(v->
name,
"jittertargetextra"))
13857 else if (!strcasecmp(v->
name,
"lagrqtime"))
13859 else if (!strcasecmp(v->
name,
"maxregexpire"))
13861 else if (!strcasecmp(v->
name,
"minregexpire"))
13863 else if (!strcasecmp(v->
name,
"bindaddr")) {
13866 } else {
13867
13869
13871
13874 }
13875
13878 } else {
13880
13883 }
13885 }
13886
13887 } else {
13889 }
13890 }
13891 }
else if (!strcasecmp(v->
name,
"auth")) {
13895 }
13896 }
else if (!strcasecmp(v->
name,
"authdebug")) {
13898 }
else if (!strcasecmp(v->
name,
"encryption")) {
13902 }
13903 }
else if (!strcasecmp(v->
name,
"forceencryption")) {
13906 } else {
13910 }
13911 }
13912 }
else if (!strcasecmp(v->
name,
"transfer")) {
13913 if (!strcasecmp(v->
value,
"mediaonly")) {
13917 } else
13919 }
else if (!strcasecmp(v->
name,
"codecpriority")) {
13920 if(!strcasecmp(v->
value,
"caller"))
13922 else if(!strcasecmp(v->
value,
"disabled"))
13924 else if(!strcasecmp(v->
value,
"reqonly")) {
13927 }
13928 }
else if (!strcasecmp(v->
name,
"jitterbuffer"))
13930 else if (!strcasecmp(v->
name,
"delayreject"))
13932 else if (!strcasecmp(v->
name,
"allowfwdownload"))
13934 else if (!strcasecmp(v->
name,
"rtcachefriends"))
13936 else if (!strcasecmp(v->
name,
"rtignoreregexpire"))
13938 else if (!strcasecmp(v->
name,
"rtupdate"))
13940 else if (!strcasecmp(v->
name,
"rtsavesysname"))
13942 else if (!strcasecmp(v->
name,
"trunktimestamps"))
13944 else if (!strcasecmp(v->
name,
"rtautoclear")) {
13945 int i = atoi(v->
value);
13946 if(i > 0)
13948 else
13949 i = 0;
13951 }
else if (!strcasecmp(v->
name,
"trunkfreq")) {
13954 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 10ms instead.\n");
13957 ast_log(
LOG_NOTICE,
"trunkfreq must be between 10ms and 1000ms, using 1000ms instead.\n");
13959 }
13962 }
13963 }
else if (!strcasecmp(v->
name,
"trunkmtu")) {
13964 mtuv = atoi(v->
value);
13965 if (mtuv == 0 )
13967 else if (mtuv >= 172 && mtuv < 4000)
13969 else
13972 }
else if (!strcasecmp(v->
name,
"trunkmaxsize")) {
13976 }
else if (!strcasecmp(v->
name,
"autokill")) {
13977 if (sscanf(v->
value,
"%30d", &x) == 1) {
13978 if (x >= 0)
13980 else
13984 } else {
13986 }
13987 }
else if (!strcasecmp(v->
name,
"bandwidth")) {
13988 if (!strcasecmp(v->
value,
"low")) {
13991 }
else if (!strcasecmp(v->
value,
"medium")) {
13994 }
else if (!strcasecmp(v->
value,
"high")) {
13997 } else {
13999 }
14000 }
else if (!strcasecmp(v->
name,
"allow")) {
14002 }
else if (!strcasecmp(v->
name,
"disallow")) {
14004 }
else if (!strcasecmp(v->
name,
"register")) {
14006 }
else if (!strcasecmp(v->
name,
"iaxcompat")) {
14008 }
else if (!strcasecmp(v->
name,
"regcontext")) {
14010
14012 }
else if (!strcasecmp(v->
name,
"tos")) {
14015 }
else if (!strcasecmp(v->
name,
"cos")) {
14018 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
14020 }
else if (!strcasecmp(v->
name,
"accountcode")) {
14022 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
14024 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
14026 }
else if (!strcasecmp(v->
name,
"amaflags")) {
14028 if (format < 0) {
14030 } else {
14032 }
14033 }
else if (!strcasecmp(v->
name,
"language")) {
14035 }
else if (!strcasecmp(v->
name,
"maxauthreq")) {
14039 }
else if (!strcasecmp(v->
name,
"adsi")) {
14041 }
else if (!strcasecmp(v->
name,
"srvlookup")) {
14043 }
else if (!strcasecmp(v->
name,
"connectedline")) {
14046 }
else if (!strcasecmp(v->
value,
"send")) {
14049 }
else if (!strcasecmp(v->
value,
"receive")) {
14052 } else {
14054 }
14055 }
else if (!strcasecmp(v->
name,
"maxcallnumbers")) {
14058 }
14059 }
else if (!strcasecmp(v->
name,
"maxcallnumbers_nonvalidated")) {
14062 }
14063 }
else if (!strcasecmp(v->
name,
"calltokenoptional")) {
14066 return -1;
14067 }
14068 }
else if (!strcasecmp(v->
name,
"calltokenexpiration")) {
14069 int temp = -1;
14070 sscanf(v->
value,
"%u", &temp);
14071 if( temp <= 0 ){
14073 } else {
14075 }
14076 }
else if (!strcasecmp(v->
name,
"subscribe_network_change_event")) {
14078 subscribe_network_change = 1;
14080 subscribe_network_change = 0;
14081 } else {
14083 }
14084 }
else if (!strcasecmp(v->
name,
"shrinkcallerid")) {
14089 } else {
14091 }
14092 }
14093
14095 }
14096
14097 if (subscribe_network_change) {
14099 } else {
14101 }
14102
14104
14106
14109 } else {
14113 }
14114 }
14120 return -1;
14121 }
14123 }
14124
14126 ast_log(
LOG_WARNING,
"Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
14129 }
14132
14134 while(cat) {
14135 if (strcasecmp(cat, "general")) {
14137 if (!strcasecmp(cat, "callnumberlimits")) {
14139 } else if (utype) {
14140 if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
14145 }
14146 }
14147 if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
14149 if (peer) {
14154 }
14155 } else if (strcasecmp(utype, "user")) {
14157 }
14158 } else
14160 }
14162 }
14164 return 1;
14165}
14166
14168{
14171
14176 }
14178}
14180{
14181 static const char config[] =
"iax.conf";
14183
14193
14198
14199
14201 }
14202
14206
14207 return 0;
14208}
14209
14211{
14212 switch (cmd) {
14216 "Usage: iax2 reload\n"
14217 " Reloads IAX configuration from iax.conf\n";
14221 }
14222
14224
14226}
14227
14229{
14231}
14232
14234{
14236 int x;
14237 int callno;
14241 char *tmpstr;
14242
14244
14245
14247 if (
iaxs[x] && !strcasecmp(data,
iaxs[x]->dproot))
14248 return x;
14250 }
14251 }
14252
14253
14254
14255 memset(&cai, 0, sizeof(cai));
14256 memset(&ied, 0, sizeof(ied));
14257 memset(&pds, 0, sizeof(pds));
14258
14261
14264 return -1;
14265 }
14266
14267
14269 return -1;
14270
14271 ast_debug(1,
"peer: %s, username: %s, password: %s, context: %s\n",
14273
14275 if (callno < 1) {
14277 return -1;
14278 }
14279
14282
14285
14286
14287
14294
14299
14302
14303 return callno;
14304}
14305
14307{
14310 int x, com[2], timeout, doabort, callno;
14311
14317 else
14319 continue;
14320 }
14322 break;
14323 }
14325
14326 if (!dp) {
14327
14328
14332 }
14336 }
14341
14346
14349
14353 }
14354
14355
14357 int res;
14358 struct pollfd pfd;
14359
14360
14362
14364 break;
14365 }
14369 }
14370 if (pipe(com)) {
14373 }
14375
14377
14379 doabort = 0;
14380
14381
14382 pfd.fd = com[0];
14383 pfd.events = POLLIN;
14384 pfd.revents = 0;
14385
14387 if (res < 0) {
14390 } else if (!pfd.revents) {
14392 }
14393
14395 doabort = 1;
14396 }
14397
14400 close(com[1]);
14401 close(com[0]);
14402 if (doabort) {
14403
14405 }
14407
14409
14410
14411 dp->
flags &= ~CACHE_FLAG_PENDING;
14413
14414
14418 if (write(dp->
waiters[x],
"asdf", 4) < 0) {
14420 }
14421 }
14422 }
14423 }
14424 }
14425
14426 }
14427 return dp;
14428}
14429
14430
14432{
14433 int res = 0;
14435#if 0
14436 ast_log(
LOG_NOTICE,
"iax2_exists: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14437#endif
14439 return 0;
14440
14444 res = 1;
14445 } else {
14447 }
14449
14450 return res;
14451}
14452
14453
14455{
14456 int res = 0;
14458#if 0
14459 ast_log(
LOG_NOTICE,
"iax2_canmatch: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14460#endif
14462 return 0;
14463
14467 res = 1;
14468 } else {
14470 }
14472
14473 return res;
14474}
14475
14476
14478{
14479 int res = 0;
14481#if 0
14482 ast_log(
LOG_NOTICE,
"iax2_matchmore: con: %s, exten: %s, pri: %d, cid: %s, data: %s\n", context,
exten,
priority, callerid ? callerid :
"<unknown>", data);
14483#endif
14485 return 0;
14486
14490 res = 1;
14491 } else {
14493 }
14495
14496 return res;
14497}
14498
14499
14501{
14502 char odata[256];
14504 char *ncontext;
14507#if 0
14508 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);
14509#endif
14511
14513 if (dialstatus) {
14515 if (dial)
14517 }
14518 return -1;
14520 return -1;
14521
14526 ncontext = strchr(odata, '/');
14527 if (ncontext) {
14528 *ncontext = '\0';
14529 ncontext++;
14530 snprintf(req, sizeof(req), "IAX2/%s/%s@%s", odata, exten, ncontext);
14531 } else {
14532 snprintf(req, sizeof(req), "IAX2/%s/%s", odata, exten);
14533 }
14534 ast_verb(3,
"Executing Dial('%s')\n", req);
14535 } else {
14537 ast_log(
LOG_WARNING,
"Can't execute nonexistent extension '%s[@%s]' in data '%s'\n", exten, context, data);
14538 return -1;
14539 }
14540 }
14542
14545 else
14547
14548 return -1;
14549}
14550
14552{
14554 char *peername, *colname;
14555
14557
14558
14559 if (!strcmp(peername,"CURRENTCHANNEL")) {
14562 return -1;
14563 }
14566 return 0;
14567 }
14568
14569 if ((colname = strchr(peername, ',')))
14570 *colname++ = '\0';
14571 else
14572 colname = "ip";
14573
14575 return -1;
14576
14577 if (!strcasecmp(colname, "ip")) {
14579 } else if (!strcasecmp(colname, "status")) {
14581 } else if (!strcasecmp(colname, "mailbox")) {
14583 } else if (!strcasecmp(colname, "context")) {
14585 } else if (!strcasecmp(colname, "expire")) {
14587 } else if (!strcasecmp(colname, "dynamic")) {
14589 } else if (!strcasecmp(colname, "callerid_name")) {
14591 } else if (!strcasecmp(colname, "callerid_num")) {
14593 } else if (!strcasecmp(colname, "codecs")) {
14595
14598 } else if (!strncasecmp(colname, "codec[", 6)) {
14599 char *codecnum, *ptr;
14601
14602
14603 codecnum = colname + 5;
14604 *codecnum = '\0';
14605 codecnum++;
14606 if ((ptr = strchr(codecnum, ']'))) {
14607 *ptr = '\0';
14608 }
14611 } else {
14613 }
14614 } else {
14616 }
14617
14619
14620 return 0;
14621}
14622
14626};
14627
14629{
14632 int res = 0;
14633
14636 return -1;
14637 }
14638
14643 return -1;
14644 }
14645
14646 if (!strcasecmp(
args,
"osptoken")) {
14648 }
else if (!strcasecmp(
args,
"peerip")) {
14650 }
else if (!strcasecmp(
args,
"peername")) {
14652 }
else if (!strcasecmp(
args,
"auth_method")) {
14654 }
else if (!strcasecmp(
args,
"secure_signaling") || !strcasecmp(
args,
"secure_media")) {
14656 } else {
14657 res = -1;
14658 }
14659
14661
14662 return res;
14663}
14664
14665
14667{
14672
14673 memset(&pds, 0, sizeof(pds));
14675
14678 return res;
14679 }
14680
14681 ast_debug(3,
"Checking device state for device %s\n", pds.
peer);
14682
14683
14685 return res;
14686
14688
14689 ast_debug(3,
"Found peer. What's device state of %s? addr=%s, defaddr=%s maxms=%d, lastms=%d\n",
14691
14694
14695
14697
14699 }
14700
14702
14703 return res;
14704}
14705
14707{
14709 .description = "IAX Remote Dialplan Switch",
14714};
14715
14737#ifdef IAXTESTS
14738 AST_CLI_DEFINE(handle_cli_iax2_test_jitter,
"Simulates jitter for testing"),
14739 AST_CLI_DEFINE(handle_cli_iax2_test_late,
"Test the receipt of a late frame"),
14740 AST_CLI_DEFINE(handle_cli_iax2_test_resync,
"Test a resync in received timestamps"),
14741#endif
14742};
14743
14745{
14747 struct iax2_thread_list *list_head = head;
14749
14752 pthread_t thread_id =
thread->threadid;
14753
14756
14758 pthread_join(thread_id,
NULL);
14760 }
14762}
14763
14765{
14766 int x;
14767
14770
14779
14784 }
14785
14789 }
14790 }
14791
14792
14796
14802 }
14803 }
14815
14818 }
14819
14829 }
14831
14836
14839
14842 return 0;
14843}
14844
14846{
14850}
14851
14853{
14855
14858
14859 return 0;
14860}
14861
14863{
14865
14867}
14868
14870{
14872
14873
14874
14875
14876 return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt,
14878}
14879
14881{
14883
14885}
14886
14888{
14890
14891
14892
14893
14894 return match(&pvt2->transfer, pvt2->transfercallno, pvt2->callno, pvt,
14896}
14897
14899{
14902
14906 goto container_fail;
14907 }
14908
14912 goto container_fail;
14913 }
14914
14918 goto container_fail;
14919 }
14920
14924 goto container_fail;
14925 }
14926
14930 goto container_fail;
14931 }
14932
14936 goto container_fail;
14937 }
14938
14942 goto container_fail;
14943 }
14944
14946 goto container_fail;
14947 }
14948
14951 goto container_fail;
14952 }
14953
14954 return 0;
14955
14956container_fail:
14959 }
14962 }
14965 }
14968 }
14971 }
14974 }
14977 }
14978 return -1;
14979}
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14992{
14993 static const char config[] =
"iax.conf";
14994 int x = 0;
14996
14999 }
15001
15006 }
15007
15009
15012 }
15013
15019 }
15020
15027 }
15028
15036 }
15037
15046 }
15048
15058 }
15060
15062
15066
15069 }
15070
15075 }
15078 }
15079
15081
15083
15086
15091
15096 }
15097
15100 }
15101
15106 } else {
15107 ast_verb(2,
"IAX Ready and Listening\n");
15108 }
15109
15114
15117
15118
15121
15122 ast_realtime_require_field(
"iaxpeers",
"name",
RQ_CHAR, 10,
"ipaddr",
RQ_CHAR, 15,
"port",
RQ_UINTEGER2, 5,
"regseconds",
RQ_UINTEGER2, 6,
SENTINEL);
15123
15125
15127}
15128
15135 .requires = "dnsmgr",
15136 .optional_modules = "res_crypto",
15137);
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to)
Copy the contents of one HA to another.
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *hostname, const char *service)
Get the IP address given a hostname and optional service.
void ast_cli_unregister_multiple(void)
static const struct adsi_event events[]
static int copy(char *infile, char *outfile)
Utility function to copy a file.
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
char * strsep(char **str, const char *delims)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
@ AST_BRIDGE_TRANSFER_SUCCESS
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
#define AST_PRES_NUMBER_NOT_AVAILABLE
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
#define AST_CAUSE_CONGESTION
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
#define AST_CAUSE_NO_USER_RESPONSE
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED
#define AST_CAUSE_CALL_REJECTED
#define AST_CAUSE_FACILITY_REJECTED
#define AST_CAUSE_NO_ROUTE_DESTINATION
#define AST_CAUSE_UNREGISTERED
static const char config_file[]
static int timing_read(int *id, int fd, short events, void *cbdata)
#define IAX_TRUNKTIMESTAMPS
static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
static void set_peercnt_limit(struct peercnt *peercnt)
static int check_access(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
static int iaxthreadcount
static int send_ping(const void *data)
static int iax2_trunk_expired(struct iax2_trunk_peer *tpeer, struct timeval *now)
static int manager_iax2_show_peers(struct mansession *s, const struct message *m)
callback to display iax peers in manager
static struct ao2_container * peercnts
static struct iax2_context * build_context(const char *context)
static void save_rr(struct iax_frame *fr, struct iax_ies *ies)
static int update_registry(struct ast_sockaddr *addr, int callno, char *devtype, int fd, unsigned short refresh)
static int iax2_write(struct ast_channel *c, struct ast_frame *f)
#define AUTH_METHOD_NAMES_BUFSIZE
static struct iax2_peer * realtime_peer(const char *peername, struct ast_sockaddr *addr)
static int socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, struct ast_sockaddr *addr, int sockfd, struct iax_frame *fr)
static struct iax2_user * user_unref(struct iax2_user *user)
static int apply_context(struct iax2_context *con, const char *context)
static struct ast_channel_tech iax2_tech
static void __auto_hangup(const void *nothing)
static int iax2_poke_peer_cb(void *obj, void *arg, int flags)
static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
static char * complete_iax2_peers(const char *line, const char *word, int pos, int state, uint64_t flags)
static int randomcalltokendata
static int iaxdynamicthreadcount
static void iax2_lock_owner(int callno)
static int iax2_queue_hold(int callno, const char *musicclass)
Queue a hold frame on the ast_channel owner.
#define MAX_TIMESTAMP_SKEW
static void acl_change_stasis_subscribe(void)
static void store_by_transfercallno(struct chan_iax2_pvt *pvt)
static struct ast_channel * ast_iax2_new(int callno, int state, iax2_format capability, struct iax2_codec_pref *prefs, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, unsigned int cachable)
Create new call, interface with the PBX core.
static void jb_error_output(const char *fmt,...)
static int peer_hash_cb(const void *obj, const int flags)
static void iax2_publish_registry(const char *username, const char *domain, const char *status, const char *cause)
static int replace_callno(const void *obj)
#define CALLNO_ENTRY_IS_VALIDATED(a)
static int auto_congest(const void *data)
static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, struct timeval *now)
static void __iax2_poke_noanswer(const void *data)
static int iax2_predestroy(int callno)
static int update_packet(struct iax_frame *f)
static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
static char * handle_cli_iax2_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int peercnt_hash_cb(const void *obj, const int flags)
static int check_provisioning(struct ast_sockaddr *addr, int sockfd, char *si, unsigned int ver)
static int iax2_setoption(struct ast_channel *c, int option, void *data, int datalen)
static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int)
static void unwrap_timestamp(struct iax_frame *fr)
static int wait_for_peercallno(struct chan_iax2_pvt *pvt)
static int iax2_hangup(struct ast_channel *c)
static int queue_signalling(struct chan_iax2_pvt *pvt, struct ast_frame *f)
All frames other than that of type AST_FRAME_IAX must be held until we have received a destination ca...
static int __schedule_action(void(*func)(const void *data), const void *data, const char *funcname)
static int addr_range_match_address_cb(void *obj, void *arg, int flags)
static int maxjitterbuffer
static int auth_fail(int callno, int failcode)
static char * handle_cli_iax2_test_losspct(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_queue_hangup(int callno)
Queue a hangup frame on the ast_channel owner.
static int peercnt_remove_cb(const void *obj)
static unsigned int fix_peerts(struct timeval *rxtrunktime, int callno, unsigned int ts)
static unsigned char compress_subclass(iax2_format subclass)
static int handle_error(void)
static const char * auth_method_labels[]
Name of effective auth method.
static int peer_cmp_cb(void *obj, void *arg, int flags)
static void resend_with_token(int callno, struct iax_frame *f, const char *newtoken)
static int get_auth_methods(const char *value)
static int handle_call_token(struct ast_iax2_full_hdr *fh, struct iax_ies *ies, struct ast_sockaddr *addr, int fd)
static struct chan_iax2_pvt * new_iax(struct ast_sockaddr *addr, const char *host)
static char default_parkinglot[AST_MAX_CONTEXT]
static struct iax2_trunk_peer * find_tpeer(struct ast_sockaddr *addr, int fd)
static void iax_error_output(const char *data)
static void vnak_retransmit(int callno, int last)
static int user_delme_cb(void *obj, void *arg, int flags)
static int send_command_immediate(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
static struct ast_custom_function iaxvar_function
#define IAX_SHRINKCALLERID
static void defer_full_frame(struct iax2_thread *from_here, struct iax2_thread *to_here)
Queue the last read full frame for processing by a certain thread.
static int iax2_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Execute IAX2 dialplan switch.
static int __unload_module(void)
static char * handle_cli_iax2_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct stasis_subscription * acl_change_sub
static int iax2_poke_peer(struct iax2_peer *peer, int heldcall)
static iax2_format iax2_capability
#define DEFAULT_MAX_THREAD_COUNT
static ast_mutex_t iaxsl[ARRAY_LEN(iaxs)]
chan_iax2_pvt structure locks
static int iax2_digit_end(struct ast_channel *c, char digit, unsigned int duration)
static uint16_t DEFAULT_MAXCALLNO_LIMIT_NONVAL
static struct ast_sched_context * sched
static void * dp_lookup_thread(void *data)
static uint16_t DEFAULT_MAXCALLNO_LIMIT
static void peercnt_modify(unsigned char reg, uint16_t limit, struct ast_sockaddr *sockaddr)
static int transmit_trunk(struct iax_frame *f, struct ast_sockaddr *addr, int sockfd)
static int registry_rerequest(struct iax_ies *ies, int callno, struct ast_sockaddr *addr)
static int send_command(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static void encmethods_to_str(int e, struct ast_str **buf)
static void construct_rr(struct chan_iax2_pvt *pvt, struct iax_ie_data *iep)
static struct ast_custom_function iaxpeer_function
static int load_objects(void)
static int complete_transfer(int callno, struct iax_ies *ies)
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan)
static struct ast_format * codec_choose_from_prefs(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
static int prune_addr_range_cb(void *obj, void *arg, int flags)
static void iax_debug_output(const char *data)
#define IAX_CALLENCRYPTED(pvt)
static char * handle_cli_iax2_provision(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static uint16_t global_maxcallno_nonval
static int maxjitterinterps
static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
static void jb_debug_output(const char *fmt,...)
static void iax_pvt_callid_new(int callno)
static char * regstate2str(int regstate)
static int last_authmethod
static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int argc, const char *const argv[])
static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
static char * handle_cli_iax2_set_mtu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Set trunk MTU from CLI.
static void pvt_destructor(void *obj)
static int addr_range_hash_cb(const void *obj, const int flags)
static int pvt_hash_cb(const void *obj, const int flags)
static int iax2_queue_unhold(int callno)
Queue an unhold frame on the ast_channel owner.
#define MAX_TRUNK_MTU
Maximum transmission unit for the UDP packet in the trunk not to be fragmented. This is based on 1516...
static int iax2_getpeername(struct ast_sockaddr addr, char *host, int len)
static struct iax2_peer * build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create peer structure based on configuration.
static int find_callno_locked(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
static void * iax2_process_thread(void *data)
static struct @119 frame_queue[IAX_MAX_CALLS]
a list of frames that may need to be retransmitted
static int iax2_digit_begin(struct ast_channel *c, char digit)
static struct iax2_user * build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create in-memory user structure from configuration.
static char regcontext[AST_MAX_CONTEXT]
static int socket_process_helper(struct iax2_thread *thread)
#define IAX_CAPABILITY_FULLBANDWIDTH
static struct ao2_container * peers
static int set_config(const char *config_file, int reload, int forced)
Load configuration.
static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers_context *cont, struct iax2_peer *peer)
static void __auto_congest(const void *nothing)
static void free_signaling_queue_entry(struct signaling_queue_entry *s)
static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno, int now, int transfer, int final)
#define MARK_IAX_SUBCLASS_TX
static int iax2_key_rotate(const void *vpvt)
#define schedule_action(func, data)
static int invalid_key(ast_aes_decrypt_key *ecx)
static int user_cmp_cb(void *obj, void *arg, int flags)
static void __expire_registry(const void *data)
static void reg_source_db(struct iax2_peer *p)
static int scheduled_destroy(const void *vid)
static void prune_peers(void)
static time_t max_calltoken_delay
static struct ao2_container * callno_limits
static int calltoken_required(struct ast_sockaddr *addr, const char *name, int subclass)
static struct ast_frame * iax2_read(struct ast_channel *c)
static struct ast_netsock_list * netsock
static int min_reg_expire
static int add_calltoken_ignore(const char *addr)
static int authenticate_reply(struct chan_iax2_pvt *p, struct ast_sockaddr *addr, struct iax_ies *ies, const char *override, const char *okey)
static char * handle_cli_iax2_show_firmware(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_transfer(struct ast_channel *c, const char *dest)
static int iax2_transmit(struct iax_frame *fr)
static void __auth_reject(const void *nothing)
static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt)
@ IAX_THREAD_TYPE_DYNAMIC
#define CALLNO_ENTRY_GET_CALLNO(a)
static int iax2_getpeertrunk(struct ast_sockaddr addr)
static int attempt_transmit(const void *data)
static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen)
static struct ast_netsock_list * outsock
static void prune_users(void)
static void user_destructor(void *obj)
static struct ao2_container * iax_transfercallno_pvts
Another container of iax2_pvt structures.
static struct iax2_user * find_user(const char *name)
static int resyncthreshold
#define IAX_RECVCONNECTEDLINE
static void register_peer_exten(struct iax2_peer *peer, int onoff)
static int transfercallno_pvt_cmp_cb(void *obj, void *arg, int flags)
static int iaxdynamicthreadnum
static ast_mutex_t callno_pool_lock
static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
static void free_context(struct iax2_context *con)
static char * handle_cli_iax2_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define CALLNO_ENTRY_SET_VALIDATED(a)
static uint16_t total_nonval_callno_used
static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
#define IAX_DEBUGDIGEST(msg, key)
static const char tdesc[]
static void parse_dial_string(char *data, struct parsed_dial_string *pds)
Parses an IAX dial string into its component parts.
static int global_rtautoclear
static void iax2_destroy(int callno)
static int manager_iax2_show_netstats(struct mansession *s, const struct message *m)
static void spawn_dp_lookup(int callno, const char *context, const char *callednum, const char *callerid)
static struct iax_frame * iaxfrdup2(struct iax_frame *fr)
static int transmit_frame(void *data)
static int acf_iaxvar_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int iax2_answer(struct ast_channel *c)
static int iax2_authmethods
static const char * iax2_getformatname_multiple(iax2_format format, struct ast_str **codec_buf)
static void set_hangup_source_and_cause(int callno, unsigned char causecode)
static int iax2_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
part of the IAX2 dial plan switch interface
static void __send_ping(const void *data)
static struct iax2_peer * find_peer(const char *name, int realtime)
static char * handle_cli_iax2_show_netstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iaxactivethreadcount
static int check_srcaddr(struct ast_sockaddr *addr)
Check if address can be used as packet source.
static void insert_idle_thread(struct iax2_thread *thread)
static void acl_change_stasis_unsubscribe(void)
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static int pvt_cmp_cb(void *obj, void *arg, int flags)
static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct ast_sockaddr *addr, struct chan_iax2_pvt *pvt)
static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int iaxdefaulttimeout
static struct ao2_container * users
static int auth_reject(const void *data)
static int create_callno_pools(void)
static void send_signaling(struct chan_iax2_pvt *pvt)
This function must be called once we are sure the other side has given us a call number....
#define CALLTOKEN_IE_FORMAT
static char * handle_cli_iax2_show_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define IAX_FORCE_ENCRYPT
static char * handle_cli_iax2_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void network_change_stasis_subscribe(void)
static struct ast_switch iax2_switch
static void poke_all_peers(void)
#define IAX_SENDCONNECTEDLINE
static int(* iax2_regfunk)(const char *username, int onoff)
static int network_change_sched_cb(const void *data)
static int find_callno(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
static int __do_deliver(void *data)
#define IAX_RTCACHEFRIENDS
#define IAX_RTIGNOREREGEXPIRE
static int socket_process(struct iax2_thread *thread)
static int manager_iax2_show_registry(struct mansession *s, const struct message *m)
static void dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, int skiplock)
static int iax2_poke_noanswer(const void *data)
static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry)
static char * handle_cli_iax2_show_callno_limits(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_iax2_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_taskprocessor * transmit_processor
static int iaxdefaultdpcache
static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int send_lagrq(const void *data)
static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
Parse the "sourceaddress" value, lookup in netsock list and set peer's sockfd. Defaults to defaultsoc...
static int peercnt_add(struct ast_sockaddr *addr)
static int iax2_do_register(struct iax2_registry *reg)
static int iax2_register(const char *value, int lineno)
static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img)
static struct ast_timer * timer
static void __send_lagrq(const void *data)
static void unlink_peer(struct iax2_peer *peer)
static int authenticate_request(int call_num)
static struct iax2_peer * peer_unref(struct iax2_peer *peer)
static int iax2_append_register(const char *hostname, const char *username, const char *secret, const char *porta)
static int firmware_show_callback(struct ast_iax2_firmware_header *header, void *user_data)
static int get_from_jb(const void *p)
static void save_osptoken(struct iax_frame *fr, struct iax_ies *ies)
static int max_reg_expire
static int iax2_queryoption(struct ast_channel *c, int option, void *data, int *datalen)
static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, struct ast_frame *f)
#define DEFAULT_RETRY_TIME
static int peer_status(struct iax2_peer *peer, char *status, int statuslen)
peer_status: Report Peer status in character string
static void set_config_destroy(void)
static int attribute_pure iax2_allow_new(int frametype, int subclass, int inbound)
#define IAX_RTSAVE_SYSNAME
static iax2_format iax2_codec_choose(struct iax2_codec_pref *pref, iax2_format formats)
static int iax2_delete_from_sched(const void *data)
static char * handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define DEFAULT_FREQ_NOTOK
static void update_jbsched(struct chan_iax2_pvt *pvt)
static void store_by_peercallno(struct chan_iax2_pvt *pvt)
static int set_peercnt_limit_all_cb(void *obj, void *arg, int flags)
@ NEW_ALLOW_CALLTOKEN_VALIDATED
static void handle_deferred_full_frames(struct iax2_thread *thread)
Handle any deferred full frames for this thread.
static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
static int transfercallno_pvt_hash_cb(const void *obj, const int flags)
static int decrypt_frame(int callno, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
static void iax_pvt_callid_set(int callno, ast_callid callid)
static void __get_from_jb(const void *p)
static int iax2_encryption
static int peercnt_remove_by_addr(struct ast_sockaddr *addr)
static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
static struct call_number_pool callno_pool
static pthread_t netthreadid
#define CALLNO_ENTRY_TO_PTR(a)
static void build_rand_pad(unsigned char *buf, ssize_t len)
static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
static char * handle_cli_iax2_set_debug_trunk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_iax2_show_registry(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_sched_add(struct ast_sched_context *sched, int when, ast_sched_cb callback, const void *data)
static int socket_read(int *id, int fd, short events, void *cbdata)
static int peer_delme_cb(void *obj, void *arg, int flags)
static int create_addr(const char *peername, struct ast_channel *c, struct ast_sockaddr *addr, struct create_addr_info *cai)
static char * auth_method_names(int authmethods, char *restrict buf)
Get names of all auth methods.
static int user_hash_cb(const void *obj, const int flags)
static void peer_destructor(void *obj)
static void __iax2_do_register_s(const void *data)
static int send_apathetic_reply(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int command, int ts, unsigned char seqno, int sockfd, struct iax_ie_data *ied)
static void jb_warning_output(const char *fmt,...)
static int iax2_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Part of the IAX2 switch interface.
calltoken_peer_enum
Call token validation settings.
@ CALLTOKEN_DEFAULT
Default calltoken required unless the ip is in the ignorelist.
@ CALLTOKEN_AUTO
Require call token validation after a successful registration using call token validation occurs.
@ CALLTOKEN_NO
Do not require call token validation.
@ CALLTOKEN_YES
Require call token validation.
static int get_encrypt_methods(const char *s)
static int jittertargetextra
static int iax2_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Part of the IAX2 Switch interface.
static struct ast_flags64 globalflags
static struct iax2_dpcache * find_cache(struct ast_channel *chan, const char *data, const char *context, const char *exten, int priority)
static iax2_format uncompress_subclass(unsigned char csub)
static void * network_thread(void *ignore)
static char * handle_cli_iax2_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int iax2_is_control_frame_allowed(int subtype)
static void network_change_stasis_unsubscribe(void)
static void realtime_update_peer(const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
static struct io_context * io
static char * complete_iax2_unregister(const char *line, const char *word, int pos, int state)
static struct stasis_subscription * network_change_sub
static int raw_hangup(struct ast_sockaddr *addr, unsigned short src, unsigned short dst, int sockfd)
#define PTR_TO_CALLNO_ENTRY(a)
static struct ao2_container * calltoken_ignores
static void * iax2_dup_variable_datastore(void *)
static struct iax2_codec_pref prefs_global
@ IAX_STATE_AUTHENTICATED
static struct iax2_user * realtime_user(const char *username, struct ast_sockaddr *addr)
#define IAX2_TRUNK_PREFACE
static int iax2_ack_registry(struct iax_ies *ies, struct ast_sockaddr *addr, int callno)
Acknowledgment received for OUR registration.
static void __iax2_poke_peer_s(const void *data)
static int load_module(void)
Load the module.
static int iax2_vnak(int callno)
#define IAX_CAPABILITY_MEDBANDWIDTH
static int iax2_parse_allow_disallow(struct iax2_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
#define DEFAULT_TRUNKDATA
static char * handle_cli_iax2_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show one peer in detail.
static void iax2_process_thread_cleanup(void *data)
#define IAX_TRANSFERMEDIA
static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen)
static int addr_range_cmp_cb(void *obj, void *arg, int flags)
static int registry_authrequest(int callno)
static int iax2_provision(struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
const char * iax2_getformatname(iax2_format format)
iax2 wrapper function for ast_getformatname
#define DEFAULT_THREAD_COUNT
static int acf_iaxvar_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static void iax2_free_variable_datastore(void *)
static int iax2_poke_peer_s(const void *data)
static int addr_range_delme_cb(void *obj, void *arg, int flags)
static struct iax2_thread * find_idle_thread(void)
static struct ast_channel * iax2_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
static void add_empty_calltoken_ie(struct chan_iax2_pvt *pvt, struct iax_ie_data *ied)
static void delete_users(void)
#define IAX_DELAYPBXSTART
static int cache_get_callno_locked(const char *data)
static void iax_outputframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
static int unload_module(void)
static void remove_by_transfercallno(struct chan_iax2_pvt *pvt)
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
static int peer_set_sock_cb(void *obj, void *arg, int flags)
static void stop_stuff(int callno)
static char * handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
static void log_jitterstats(unsigned short callno)
static struct iax2_peer * peer_ref(struct iax2_peer *peer)
static ast_callid iax_pvt_callid_get(int callno)
#define IAX_CAPABILITY_LOWBANDWIDTH
static void cleanup_thread_list(void *head)
static int manager_iax2_show_peer_list(struct mansession *s, const struct message *m)
callback to display iax peers in manager format
static int iax2_queue_frame(int callno, struct ast_frame *f)
Queue a frame to a call's owning asterisk channel.
static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
static int iax2_sendtext(struct ast_channel *c, const char *text)
static struct ast_sockaddr debugaddr
static int send_packet(struct iax_frame *f)
static char language[MAX_LANGUAGE]
static char accountcode[AST_MAX_ACCOUNT_CODE]
static void merge_encryption(struct chan_iax2_pvt *p, unsigned int enc)
static void memcpy_decrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_decrypt_key *dcx)
static char * handle_cli_iax2_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define IAX_ALLOWFWDOWNLOAD
#define IAX_CODEC_USER_FIRST
static int iax2_lock_callno_unless_destroyed(int callno)
Acquire the iaxsl[callno] if call exists and not having ongoing hangup.
static struct call_number_pool callno_pool_trunk
static uint16_t global_maxcallno
static void remove_by_peercallno(struct chan_iax2_pvt *pvt)
#define CALLTOKEN_HASH_FORMAT
static int start_network_thread(void)
static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
static int iax2_sched_replace(int id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
static char mohsuggest[MAX_MUSICCLASS]
static int __find_callno(unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int return_locked, int check_dcallno)
static void build_encryption_keys(const unsigned char *digest, struct chan_iax2_pvt *pvt)
static void build_callno_limits(struct ast_variable *v)
static void __attempt_transmit(const void *data)
static struct ast_cli_entry cli_iax2[]
static unsigned int iax2_datetime(const char *tz)
static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final)
#define IAX_CODEC_NOPREFS
static int auto_hangup(const void *data)
static char * handle_cli_iax2_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static char mohinterpret[MAX_MUSICCLASS]
static const struct ast_datastore_info iax2_variable_datastore_info
static void sched_delay_remove(struct ast_sockaddr *addr, callno_entry entry)
static int iax2_do_register_s(const void *data)
static int iax2_devicestate(const char *data)
Part of the device state notification system —.
static void peercnt_remove(struct peercnt *peercnt)
static int network_change_sched_id
static int expire_registry(const void *data)
static void iax2_frame_free(struct iax_frame *fr)
static void memcpy_encrypt(unsigned char *dst, const unsigned char *src, int len, ast_aes_encrypt_key *ecx)
static void requirecalltoken_mark_auto(const char *name, int subclass)
static int iaxmaxthreadcount
static int peercnt_cmp_cb(void *obj, void *arg, int flags)
static struct ao2_container * iax_peercallno_pvts
Another container of iax2_pvt structures.
static int send_command_locked(unsigned short callno, char, int, unsigned int, const unsigned char *, int, int)
static int make_trunk(unsigned short callno, int locked)
static int register_verify(int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
Verify inbound registration.
static int global_max_trunk_mtu
static void iax2_dprequest(struct iax2_dpcache *dp, int callno)
struct ast_sockaddr bindaddr
static char version[AST_MAX_EXTENSION]
static const char config[]
static int transfer(void *data)
static int reload_config(void)
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint,...)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define AST_BRIDGE_DTMF_CHANNEL_0
Report DTMF on channel 0.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
#define DATASTORE_INHERIT_FOREVER
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
#define ast_channel_ref(c)
Increase channel reference count.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_context(const struct ast_channel *chan)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
#define AST_BRIDGE_DTMF_CHANNEL_1
Report DTMF on channel 1.
#define ast_channel_trylock(chan)
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
#define AST_MAX_ACCOUNT_CODE
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
@ AST_BRIDGE_FAILED_NOWARN
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
const char * ast_channel_language(const struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags, int rdlock)
const char * ast_var_name(const struct ast_var_t *var)
#define ast_var_assign(name, value)
const char * ast_var_value(const struct ast_var_t *var)
void ast_var_delete(struct ast_var_t *var)
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
unsigned int ast_codec_samples_count(struct ast_frame *frame)
Get the number of samples contained within a frame.
int iax2_codec_pref_string(struct iax2_codec_pref *pref, char *buf, size_t size)
Dump audio codec preference list into a string.
void iax2_codec_pref_prepend(struct iax2_codec_pref *pref, struct ast_format *format, unsigned int framing, int only_if_existing)
Prepend an audio codec to a preference list, removing it first if it was already there.
uint64_t iax2_codec_pref_order_value_to_format_bitfield(int order_value)
Convert an iax2_codec_pref order value into a format bitfield.
uint64_t iax2_codec_pref_from_bitfield(struct iax2_codec_pref *pref, uint64_t bitfield)
Create codec preference list from the given bitfield formats.
struct ast_format * iax2_codec_pref_index(struct iax2_codec_pref *pref, int idx, struct ast_format **result)
Codec located at a particular place in the preference index.
void iax2_codec_pref_convert(struct iax2_codec_pref *pref, char *buf, size_t size, int right)
Shift an audio codec preference list up or down 65 bytes so that it becomes an ASCII string.
void iax2_codec_pref_remove_missing(struct iax2_codec_pref *pref, uint64_t bitfield)
Removes format from the pref list that aren't in the bitfield.
void iax2_codec_pref_append(struct iax2_codec_pref *pref, struct ast_format *format, unsigned int framing)
Append a audio codec to a preference list, removing it first if it was already there.
int iax2_codec_pref_to_cap(struct iax2_codec_pref *pref, struct ast_format_cap *cap)
Convert a preference structure to a capabilities structure.
int iax2_codec_pref_best_bitfield2cap(uint64_t bitfield, struct iax2_codec_pref *prefs, struct ast_format_cap *cap)
Convert a bitfield to a format capabilities structure in the "best" order.
int AST_OPTIONAL_API_NAME() ast_check_signature(struct ast_key *key, const char *msg, const char *sig)
Check the authenticity of a message signature using a given public key.
int AST_OPTIONAL_API_NAME() ast_aes_set_encrypt_key(const unsigned char *key, ast_aes_encrypt_key *ctx)
Set an encryption key.
int AST_OPTIONAL_API_NAME() ast_sign(struct ast_key *key, char *msg, char *sig)
Sign a message signature using a given private key.
int AST_OPTIONAL_API_NAME() ast_aes_decrypt(const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *key)
AES decrypt data.
struct ast_key *AST_OPTIONAL_API_NAME() ast_key_get(const char *kname, int ktype)
Retrieve a key.
int AST_OPTIONAL_API_NAME() ast_aes_set_decrypt_key(const unsigned char *key, ast_aes_decrypt_key *ctx)
Set a decryption key.
int AST_OPTIONAL_API_NAME() ast_aes_encrypt(const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *key)
AES encrypt data.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry)
Check is see if a dnsmgr entry has changed.
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
int iax_firmware_get_version(const char *dev, uint16_t *version)
void iax_firmware_reload(void)
void iax_firmware_unload(void)
int iax_firmware_append(struct iax_ie_data *ied, const char *dev, unsigned int desc)
void iax_firmware_traverse(const char *filter, int(*callback)(struct ast_iax2_firmware_header *header, void *data), void *data)
static int exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
void astman_append(struct mansession *s, const char *fmt,...)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
static int iax2_prov_app(struct ast_channel *chan, const char *data)
#define IAX_LINGER_TIMEOUT
#define IAX_DPSTATUS_CANEXIST
#define IAX_MAX_OSPBLOCK_SIZE
#define IAX_IE_CALLINGANI2
#define IAX_IE_CALLING_NUMBER
#define IAX_IE_TRANSFERID
#define IAX_IE_CALLING_ANI
#define IAX_DEFAULT_PORTNO
#define IAX_IE_CALLINGTNS
#define IAX_IE_RSA_RESULT
#define IAX_META_TRUNK_SUPERMINI
#define IAX_IE_IAX_UNKNOWN
#define IAX_DPSTATUS_NONEXISTENT
#define IAX_DPSTATUS_IGNOREPAT
#define IAX_IE_CAPABILITY2
#define IAX_IE_CALLING_NAME
#define IAX_DEFAULT_REG_EXPIRE
#define IAX_MAX_OSPTOKEN_SIZE
#define IAX_IE_RR_DROPPED
#define IAX_IE_ENCRYPTION
#define IAX_ENCRYPT_AES128
#define IAX_MAX_OSPBUFF_SIZE
#define IAX_IE_FIRMWAREVER
#define IAX_IE_CODEC_PREFS
#define IAX_IE_CALLED_NUMBER
#define IAX_IE_CAPABILITY
#define IAX_DPSTATUS_MATCHMORE
#define IAX_IE_PROVISIONING
#define IAX_IE_MD5_RESULT
#define IAX_PROTO_VERSION
#define IAX_IE_AUTOANSWER
#define IAX_ENCRYPT_KEYROTATE
#define IAX_IE_APPARENT_ADDR
#define IAX_AUTH_PLAINTEXT
#define IAX_MAX_OSPBLOCK_NUM
#define IAX_META_TRUNK_MINI
#define IAX_IE_CALLINGPRES
#define IAX_IE_AUTHMETHODS
#define IAX_IE_CALLED_CONTEXT
#define IAX_IE_CALLINGTON
#define IAX_DPSTATUS_EXISTS
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
#define ast_config_load(filename, flags)
Load a config file.
@ CONFIG_FLAG_FILEUNCHANGED
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
#define ast_variable_new(name, value, filename)
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
#define ast_frame_byteswap_be(fr)
#define AST_OPTION_RELAXDTMF
#define AST_OPTION_TONE_VERIFY
#define AST_OPTION_RXGAIN
#define AST_OPTION_DIGIT_DETECT
#define AST_OPTION_OPRMODE
@ AST_FRFLAG_HAS_TIMING_INFO
#define AST_OPTION_SECURE_MEDIA
#define AST_OPTION_FLAG_REQUEST
#define AST_OPTION_FAX_DETECT
#define AST_OPTION_TXGAIN
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define AST_OPTION_SECURE_SIGNALING
ast_control_frame_type
Internal control frame subtype field values.
@ AST_CONTROL_RECORD_CANCEL
@ AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_RADIO_UNKEY
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_TAKEOFFHOOK
@ AST_CONTROL_T38_PARAMETERS
@ AST_CONTROL_READ_ACTION
@ AST_CONTROL_RECORD_STOP
@ AST_CONTROL_PLAYBACK_BEGIN
@ AST_CONTROL_RECORD_MUTE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_STREAM_FORWARD
@ AST_CONTROL_RECORD_SUSPEND
@ AST_CONTROL_MASQUERADE_NOTIFY
@ AST_CONTROL_PVT_CAUSE_CODE
@ AST_CONTROL_UPDATE_RTP_PEER
#define AST_OPTION_AUDIO_MODE
struct ast_frame ast_null_frame
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
#define ast_debug(level,...)
Log a DEBUG message.
ast_callid ast_read_threadstorage_callid(void)
extracts the callid from the thread
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
#define AST_CALLID_BUFFER_LENGTH
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
#define ast_verb(level,...)
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
void jb_destroy(jitterbuf *jb)
destroy jitterbuf
void jb_reset(jitterbuf *jb)
reset jitterbuf
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl)
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame!...
jitterbuf * jb_new(void)
new jitterbuf
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
queue a frame
long jb_next(jitterbuf *jb)
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are adde...
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
unconditionally get frames from jitterbuf until empty
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list entry before the current entry during a traversal.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
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 ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define AST_PTHREADT_NULL
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define DEADLOCK_AVOIDANCE(lock)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_trylock(a)
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
int ast_atomic_dec_and_test(volatile int *p)
decrement *p by 1 and return true if the variable has reached 0.
#define ast_cond_signal(cond)
static char hostname[MAXHOSTNAMELEN]
#define EVENT_FLAG_REPORTING
#define EVENT_FLAG_SYSTEM
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
void MD5Init(struct MD5Context *context)
void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], struct MD5Context *context)
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_module_ref(mod)
Hold a reference to the module.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DRIVER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
meta
below block is needed for mssql
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
int ast_sockaddr_apply_netmask(const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask, struct ast_sockaddr *result)
Apply a netmask to an address and store the result in a separate structure.
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
Wrapper around sendto(2) that uses ast_sockaddr.
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr)
Wrapper around recvfrom(2) that uses struct ast_sockaddr.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
Determine if this is an IPv4-mapped IPv6 address.
int ast_sockaddr_hash(const struct ast_sockaddr *addr)
Computes a hash value from the address. The port is ignored.
int ast_netsock_release(struct ast_netsock_list *list)
struct ast_netsock_list * ast_netsock_list_alloc(void)
struct ast_netsock * ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data)
void ast_netsock_unref(struct ast_netsock *ns)
int ast_netsock_sockfd(const struct ast_netsock *ns)
struct ast_netsock * ast_netsock_find(struct ast_netsock_list *list, struct ast_sockaddr *addr)
int ast_netsock_init(struct ast_netsock_list *list)
struct ast_netsock * ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct ast_sockaddr *bindaddr, int tos, int cos, ast_io_cb callback, void *data)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
int iax_get_iframes(void)
#define DIRECTION_OUTGRESS
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr)
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len)
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
void iax_frame_free(struct iax_frame *fr)
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
struct iax_frame * iax_frame_new(int direction, int datalen, unsigned int cacheable)
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
void iax_set_output(void(*output)(const char *data))
int iax_get_oframes(void)
#define DIRECTION_INGRESS
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
void iax_set_error(void(*output)(const char *data))
const char * ast_config_AST_SYSTEM_NAME
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
static int matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
#define ast_poll(a, b, c)
int iax_provision_reload(int reload)
int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force)
int iax_provision_unload(void)
char * iax_prov_complete_template(const char *line, const char *word, int pos, int state)
int iax_provision_version(unsigned int *signature, const char *template, int force)
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.
static struct @487 methods[]
static void challenge(const char *endpoint_id, struct ast_sip_auth *auth, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale, const pjsip_auth_algorithm *algorithm)
Send a WWW-Authenticate challenge.
static void cleanup(void)
Clean up any old apps that we don't need any more.
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb)
Clean all scheduled events with matching callback.
int ast_sched_replace(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
replace a scheduler entry
int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
int(* ast_sched_cb)(const void *data)
scheduler callback
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
#define stasis_subscribe(topic, callback, data)
void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause)
Publish a channel driver outgoing registration message.
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes.
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
Parse a time (integer) string.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
#define ast_str_alloca(init_len)
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
unsigned char raw[AST_CRYPTO_AES_BLOCKSIZE/8]
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Wrapper for an ast_acl linked list.
ast_app: A registered application
Structure to pass both assignedid values to channel drivers.
Structure to describe a channel "technology", ie a channel driver See for examples:
struct ast_format_cap * capabilities
Main Channel structure associated with a channel.
char context[AST_MAX_CONTEXT]
descriptor for a cli entry.
int args
This gets set in ast_cli_register()
char chan_name[AST_CHANNEL_NAME]
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Structure used to handle a large number of boolean flags == used only in app_dial?
Structure used to handle boolean flags.
unsigned int frame_ending
struct ast_format * format
Data structure associated with a single frame of data.
union ast_frame::@236 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
internal representation of ACL entries In principle user applications would have no need for this,...
struct ast_sockaddr netmask
Abstract JSON element (object, array, string, int, ...).
Structure for mutex and tracking information.
The structure that contains MWI state.
struct ast_party_id id
Caller party ID.
int ani2
Automatic Number Identification 2 (Info Digits)
struct ast_party_id ani
Automatic Number Identification (ANI)
Connected Line/Party information.
struct ast_party_id id
Connected party ID.
struct ast_party_dialed::@218 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
int transit_network_select
Transit Network Select.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
int presentation
Q.931 encoded presentation-indicator encoded field.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Socket address structure.
struct sockaddr_storage ss
Support for dynamic strings.
A ast_taskprocessor structure is a singleton by name.
struct ast_var_t::@221 entries
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
callno_entry numbers[IAX_MAX_CALLS/2+1]
unsigned char semirand[32]
const ast_string_field mohinterpret
struct ast_variable * vars
const ast_string_field language
const ast_string_field cid_num
struct chan_iax2_pvt::signaling_queue signaling_queue
const ast_string_field inkeys
const ast_string_field outkey
const ast_string_field dproot
const ast_string_field mohsuggest
unsigned short bridgecallno
const ast_string_field accountcode
const ast_string_field username
iax2_format peercapability
struct ast_variable * iaxvars
struct ast_sockaddr transfer
const ast_string_field context
unsigned short peercallno
struct iax2_codec_pref prefs
unsigned char calltoken_ie_len
const ast_string_field parkinglot
const ast_string_field host
callno_entry callno_entry
unsigned short transfercallno
struct ast_channel * owner
const ast_string_field rdnis
const ast_string_field challenge
const ast_string_field exten
const ast_string_field ani
struct iax2_codec_pref rprefs
struct iax2_registry * reg
ast_aes_decrypt_key mydcx
const ast_string_field cid_name
enum iax_transfer_state transferring
const ast_string_field secret
const ast_string_field dnid
const ast_string_field osptoken
struct iax2_peer * peerpoke
const ast_string_field peer
struct chan_iax2_pvt::@124 dpentries
struct iax2_codec_pref prefs
char context[AST_MAX_CONTEXT]
char peercontext[AST_MAX_CONTEXT]
char mohsuggest[MAX_MUSICCLASS]
char mohinterpret[MAX_MUSICCLASS]
char context[AST_MAX_EXTENSION]
char callednum[AST_MAX_EXTENSION]
char order[IAX2_CODEC_PREF_SIZE]
char context[AST_MAX_CONTEXT]
struct iax2_context * next
struct iax2_dpcache::@127 peer_list
char exten[AST_MAX_EXTENSION]
struct iax2_dpcache::@126 cache_list
char peercontext[AST_MAX_CONTEXT]
const ast_string_field peercontext
const ast_string_field mohinterpret
struct ast_dnsmgr_entry * dnsmgr
const ast_string_field cid_num
const ast_string_field inkeys
const ast_string_field outkey
struct ast_mwi_subscriber * mwi_event_sub
enum calltoken_peer_enum calltoken_required
const ast_string_field regexten
const ast_string_field mohsuggest
const ast_string_field username
const ast_string_field zonetag
struct ast_sockaddr defaddr
const ast_string_field description
const ast_string_field context
struct iax2_codec_pref prefs
const ast_string_field parkinglot
const ast_string_field dbsecret
struct ast_endpoint * endpoint
struct ast_acl_list * acl
const ast_string_field name
const ast_string_field cid_name
const ast_string_field secret
const ast_string_field mailbox
struct iax2_pkt_buf::@128 entry
struct ast_dnsmgr_entry * dnsmgr
enum iax_reg_state regstate
struct iax2_registry::@123 entry
unsigned char readbuf[4096]
struct iax2_thread::@130 ffinfo
struct ast_sockaddr ioaddr
struct iax2_thread::@129 list
struct iax2_thread::@131 full_frames
enum iax2_thread_iostate iostate
enum iax2_thread_type type
void(* schedfunc)(const void *)
struct timeval lasttxtime
struct timeval rxtrunktime
struct iax2_trunk_peer::@122 list
unsigned int trunkdataalloc
unsigned int trunkdatalen
unsigned char * trunkdata
struct timeval txtrunktime
const ast_string_field mohinterpret
struct ast_variable * vars
const ast_string_field language
const ast_string_field cid_num
const ast_string_field inkeys
struct iax2_context * contexts
enum calltoken_peer_enum calltoken_required
const ast_string_field mohsuggest
const ast_string_field accountcode
struct iax2_codec_pref prefs
const ast_string_field parkinglot
const ast_string_field dbsecret
struct ast_acl_list * acl
const ast_string_field name
const ast_string_field cid_name
const ast_string_field secret
unsigned char semirand[32]
struct iax_frame::@144 list
ast_aes_decrypt_key mydcx
struct ast_sockaddr apparent_addr
unsigned char * calltokendata
struct ast_variable * vars
unsigned char iax_unknown
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM]
char * osptokenblock[IAX_MAX_OSPBLOCK_NUM]
Global IO variables are now in a struct in order to be made threadsafe.
In case you didn't read that giant block of text above the mansession_session struct,...
struct signaling_queue_entry * next
structure to hold users read from phoneprov_users.conf
list of users found in the config file
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
@ TPS_REF_DEFAULT
return a reference to a taskprocessor, create one if it does not exist
#define ast_taskprocessor_push(tps, task_exe, datap)
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller,...
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
struct ast_timer * ast_timer_open(void)
Open a timer.
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
Chooses the best translation path.
int error(const char *format,...)
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_set2_flag64(p, value, flag)
#define ast_test_flag64(p, flag)
#define ast_set_flags_to64(p, flag, value)
#define ast_clear_flag64(p, flag)
#define ast_pthread_create_background(a, b, c, d)
#define ast_assert_return(a,...)
#define ast_clear_flag(p, flag)
long int ast_random(void)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_copy_flags64(dest, src, flagz)
#define ast_set_flag64(p, flag)
#define ast_set_flag(p, flag)
void ast_sha1_hash(char *output, const char *input)
Produces SHA1 hash based on input string.