43 #include <sys/socket.h> 44 #include <sys/ioctl.h> 49 #include <netinet/in.h> 50 #include <netinet/in_systm.h> 51 #include <netinet/ip.h> 52 #include <arpa/inet.h> 96 #define DEFAULT_EXPIRY 120 97 #define MAX_EXPIRY 3600 101 #define INADDR_NONE (in_addr_t)(-1) 110 .resync_threshold = 1000,
116 static const char tdesc[] =
"Media Gateway Control Protocol (MGCP)";
117 static const char config[] =
"mgcp.conf";
119 #define MGCP_DTMF_RFC2833 (1 << 0) 120 #define MGCP_DTMF_INBAND (1 << 1) 121 #define MGCP_DTMF_HYBRID (1 << 2) 123 #define DEFAULT_MGCP_GW_PORT 2427 124 #define DEFAULT_MGCP_CA_PORT 2727 125 #define MGCP_MAX_PACKET 1500 126 #define DEFAULT_RETRANS 1000 127 #define MAX_RETRANS 5 130 #define MGCP_CX_SENDONLY 0 131 #define MGCP_CX_RECVONLY 1 132 #define MGCP_CX_SENDRECV 2 133 #define MGCP_CX_CONF 3 134 #define MGCP_CX_CONFERENCE 3 135 #define MGCP_CX_MUTE 4 136 #define MGCP_CX_INACTIVE 4 181 }
qos = { 0, 0, 0, 0 };
250 #define MGCP_MAX_HEADERS 64 251 #define MGCP_MAX_LINES 64 281 #define RESPONSE_TIMEOUT 30 302 #define MGCP_SUBCHANNEL_MAGIC "!978!" 309 struct sockaddr_in tmpdest;
326 #define MGCP_ONHOOK 1 327 #define MGCP_OFFHOOK 2 403 struct sockaddr_in addr;
404 struct sockaddr_in defaddr;
405 struct in_addr ourip;
474 .description =
tdesc,
537 if (gw->
addr.sin_addr.s_addr)
538 res=sendto(
mgcpsock, data, len, 0, (
struct sockaddr *)&gw->
addr,
sizeof(
struct sockaddr_in));
540 res=sendto(
mgcpsock, data, len, 0, (
struct sockaddr *)&gw->
defaddr,
sizeof(
struct sockaddr_in));
575 for (prev =
NULL, cur = gw->
msgs; cur; prev = cur, cur = cur->
next) {
578 prev->next = cur->
next;
653 for (prev =
NULL, cur = gw->
msgs; cur; prev = cur, cur = cur->
next) {
656 ast_debug(1,
"Retransmitting #%d transaction %u on [%s]\n",
661 prev->next = cur->
next;
700 char *data,
int len,
unsigned int seqno)
707 if (!(msg =
ast_malloc(
sizeof(*msg) + len))) {
721 memcpy(msg->
buf, data, msg->
len);
724 for (cur = gw->
msgs; cur && cur->
next; cur = cur->
next);
800 memcpy(r, req,
sizeof(*r));
813 for (t = *queue; t && t->
next; t = t->
next);
842 snprintf(tone,
sizeof(tone),
"L/wt%s", distinctive_ring);
843 ast_debug(3,
"MGCP distinctive callwait %s\n", tone);
846 ast_debug(3,
"MGCP normal callwait %s\n", tone);
852 snprintf(tone,
sizeof(tone),
"L/r%s", distinctive_ring);
853 ast_debug(3,
"MGCP distinctive ring %s\n", tone);
909 ast_debug(1,
"Asked to hangup channel not connected\n");
913 ast_debug(1,
"Invalid magic. MGCP subchannel freed up already.\n");
1005 ast_debug(3,
"MGCP mgcp_hangup(%s) on %s@%s set vmwi(+)\n",
1009 ast_debug(3,
"MGCP mgcp_hangup(%s) on %s@%s set vmwi(-)\n",
1022 int hasendpoints = 0;
1027 e->
command =
"mgcp show endpoints";
1029 "Usage: mgcp show endpoints\n" 1030 " Lists all endpoints known to the MGCP (Media Gateway Control Protocol) subsystem.\n";
1052 if (!hasendpoints) {
1053 ast_cli(a->
fd,
" << No Endpoints Defined >> ");
1065 char *ename,*gname, *
c;
1069 e->
command =
"mgcp audit endpoint";
1071 "Usage: mgcp audit endpoint <endpointid>\n" 1072 " Lists the capabilities of an endpoint in the MGCP (Media Gateway Control Protocol) subsystem.\n" 1073 " mgcp debug MUST be on to see the results of this command.\n";
1086 for (gname = ename; *gname; gname++) {
1087 if (*gname ==
'@') {
1093 if (gname[0] ==
'[') {
1096 if ((c = strrchr(gname,
']'))) {
1101 if (!strcasecmp(mg->
name, gname)) {
1103 if (!strcasecmp(me->
name, ename)) {
1115 ast_cli(a->
fd,
" << Could not find endpoint >> ");
1125 e->
command =
"mgcp set debug {on|off}";
1127 "Usage: mgcp set debug {on|off}\n" 1128 " Enables/Disables dumping of MGCP packets for debugging purposes\n";
1137 if (!strncasecmp(a->
argv[e->
args - 1],
"on", 2)) {
1139 ast_cli(a->
fd,
"MGCP Debugging Enabled\n");
1140 }
else if (!strncasecmp(a->
argv[3],
"off", 3)) {
1142 ast_cli(a->
fd,
"MGCP Debugging Disabled\n");
1169 ast_verb(3,
"MGCP mgcp_answer(%s) on %s@%s-%d\n",
1256 ast_log(
LOG_WARNING,
"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
1268 ast_debug(1,
"GATE ALLOCATED, sending sdp\n");
1288 if (sub->
owner != oldchan) {
1306 ast_debug(1,
"Sending DTMF using inband/hybrid\n");
1309 ast_debug(1,
"Sending DTMF using RFC2833\n");
1328 ast_debug(1,
"Stopping DTMF using inband/hybrid\n");
1331 ast_debug(1,
"Stopping DTMF using RFC2833\n");
1364 char *
tmp, *endpt, *gw;
1368 if ((tmp = strchr(endpt,
'@'))) {
1376 if (strcasecmp(g->
name, gw) == 0) {
1385 for (; e; e = e->
next) {
1386 if (strcasecmp(e->
name, endpt) == 0) {
1409 return "Other end has hungup";
1411 return "Local ring";
1413 return "Remote end is ringing";
1415 return "Remote end has answered";
1417 return "Remote end is busy";
1419 return "Make it go off hook";
1421 return "Line is off hook";
1423 return "Congestion (circuits busy)";
1425 return "Flash hook";
1429 return "Set a low-level option";
1433 return "Un-Key Radio";
1443 ast_debug(3,
"MGCP asked to indicate %d '%s' condition on channel %s\n",
1448 #ifdef DLINK_BUGGY_FIRMWARE 1507 tmp =
ast_channel_alloc(1, state, i->
cid_num, i->
cid_name, i->
accountcode, i->
exten, i->
context, assignedids, requestor, i->
amaflags,
"MGCP/%s@%s-%d", i->
name, i->
parent->
name, sub->
id);
1546 ast_channel_language_set(tmp, i->
language);
1572 char valuebuf[1024];
1590 ast_verb(3,
"MGCP mgcp_new(%s) created in state: %s\n",
1598 if (strncasecmp(line, name, nameLen) == 0 && line[nameLen] ==
'=') {
1599 char *r = line + nameLen + 1;
1600 while (*r && (*r < 33)) ++r;
1609 int len = strlen(name);
1612 for (x = 0; x < req->
lines; x++) {
1614 if (r[0] !=
'\0')
return r;
1626 int len = strlen(name);
1628 while (*iterator < req->
lines) {
1630 if (r[0] !=
'\0')
return r;
1638 int len = strlen(name);
1640 for (x = *start; x < req->
headers; x++) {
1641 if (!strncasecmp(req->
header[x], name, len) &&
1642 (req->
header[x][len] ==
':')) {
1643 r = req->
header[x] + len + 1;
1644 while (*r && (*r < 33)) {
1666 *next =
NULL, *len = 0;
1667 if (!c)
return NULL;
1669 while (*c && (*c < 33 || *c ==
',')) {
1674 while (*c && (*c >= 33 && *c !=
',')) {
1695 ast_debug(1,
"*** find Realtime MGCPGW\n");
1724 for (gwv = mgcpgwconfig; gwv; gwv = gwv->
next) {
1725 if (!strcasecmp(gwv->
name,
"lines")) {
1731 for (gwv = gwv && gwv->
next ? gwv : mgcpgwconfig; gwv->
next; gwv = gwv->
next);
1738 for (i = 0; i <
args.argc; i++) {
1743 if (!strcasecmp(gwv->
next->
name,
"line")) {
1757 for (gwv = mgcpgwconfig; gwv; gwv = gwv->
next) {
1783 char *at =
NULL, *
c;
1787 at = strchr(tmp,
'@');
1795 if (at && (at[0] ==
'[')) {
1797 c = strrchr(at,
']');
1803 if ((!name || !strcasecmp(g->
name, at)) &&
1804 (sin || g->
addr.sin_addr.s_addr || g->
defaddr.sin_addr.s_addr)) {
1806 if (sin && g->
dynamic && name) {
1807 if ((g->
addr.sin_addr.s_addr != sin->sin_addr.s_addr) ||
1808 (g->
addr.sin_port != sin->sin_port)) {
1809 memcpy(&g->
addr, sin,
sizeof(g->
addr));
1812 struct sockaddr_in tmp3 = {0,};
1814 tmp3.sin_addr = g->
ourip;
1821 g->
ourip = tmp3.sin_addr;
1827 if (strcasecmp(g->
name, at)) {
1831 }
else if (!name && sin) {
1832 if ((g->
addr.sin_addr.s_addr != sin->sin_addr.s_addr) ||
1833 (g->
addr.sin_port != sin->sin_port)) {
1845 }
else if (name && !strcasecmp(p->
name, tmp)) {
1846 ast_debug(1,
"Coundn't determine subchannel, assuming current master %s@%s-%d\n",
1865 ast_log(
LOG_NOTICE,
"Gateway '%s' (and thus its endpoint '%s') does not exist\n", at, tmp);
1897 }
else if (*c ==
'\r') {
1920 req->
line[f] = c + 1;
1921 }
else if (*c ==
'\r') {
1933 while (*c && *c < 33) c++;
1936 while (*c && (*c > 32)) c++;
1940 while (*c && (*c < 33)) c++;
1942 while (*c && (*c > 32)) c++;
1946 while (*c && (*c < 33)) c++;
1948 while (*c && (*c > 32)) c++;
1952 while (*c && (*c < 33)) c++;
1954 while (*c && (*c > 32)) c++;
1955 while (*c && (*c < 33)) c++;
1956 while (*c && (*c > 32)) c++;
1962 ast_debug(1,
"Verb: '%s', Identifier: '%s', Endpoint: '%s', Version: '%s'\n",
1979 int peerNonCodecCapability;
1980 struct sockaddr_in sin;
1984 int codec, codec_count=0;
1995 ast_log(
LOG_WARNING,
"Insufficient information for SDP (m = '%s', c = '%s')\n", m, c);
1998 if (sscanf(c,
"IN IP4 %256s", host) != 1) {
2008 if (sscanf(m,
"audio %30d RTP/AVP %n", &portno, &len) != 1 || !len) {
2012 sin.sin_family = AF_INET;
2013 memcpy(&sin.sin_addr, hp->h_addr,
sizeof(sin.sin_addr));
2014 sin.sin_port = htons(portno);
2021 if (sscanf(codecs,
"%30d%n", &codec, &len) != 1) {
2038 if (sscanf(a,
"rtpmap: %30d %127[^/]/", &codec, mimeSubtype) != 2)
2050 ast_debug(1,
"Capabilities: us - %s, them - %s, combined - %s\n",
2056 ast_debug(1,
"Non-codec capabilities: us - %d, them - %d, combined - %d\n",
2067 if (req->
len >=
sizeof(req->
data) - 4) {
2089 if (req->
len >=
sizeof(req->
data) - 4) {
2154 memset(resp, 0,
sizeof(*resp));
2184 respprep(&resp, p, msg, req, msgrest);
2193 mgr->
buf[resp.
len] =
'\0';
2206 struct sockaddr_in sin;
2216 struct sockaddr_in dest = { 0, };
2232 if (sub->
tmpdest.sin_addr.s_addr) {
2233 dest.sin_addr = sub->
tmpdest.sin_addr;
2234 dest.sin_port = sub->
tmpdest.sin_port;
2239 dest.sin_port = sin.sin_port;
2244 snprintf(o,
sizeof(o),
"o=root %d %d IN IP4 %s\r\n", (
int)getpid(), (
int)getpid(),
ast_inet_ntoa(dest.sin_addr));
2246 snprintf(c,
sizeof(c),
"c=IN IP4 %s\r\n",
ast_inet_ntoa(dest.sin_addr));
2248 snprintf(m,
sizeof(m),
"m=audio %d RTP/AVP", ntohs(dest.sin_port));
2261 snprintf(costr,
sizeof(costr),
" %d", codec);
2262 strncat(m, costr,
sizeof(m) - strlen(m) - 1);
2264 strncat(a, costr,
sizeof(a) - strlen(a) - 1);
2272 ast_debug(1,
"Answering with non-codec capability %d\n", (
int) x);
2275 snprintf(costr,
sizeof(costr),
" %d", codec);
2276 strncat(m, costr,
sizeof(m) - strlen(m) - 1);
2278 strncat(a, costr,
sizeof(a) - strlen(a) - 1);
2282 snprintf(costr,
sizeof costr,
"a=fmtp:%d 0-16\r\n", codec);
2283 strncat(a, costr,
sizeof(a) - strlen(a) - 1);
2288 strncat(m,
"\r\n",
sizeof(m) - strlen(m) - 1);
2289 len = strlen(v) + strlen(s) + strlen(o) + strlen(c) + strlen(t) + strlen(m) + strlen(a);
2290 snprintf(costr,
sizeof(costr),
"%d", len);
2329 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2336 snprintf(tmp,
sizeof(tmp),
", dq-gi:%x", sub->
gate->
gateid);
2337 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2341 ast_debug(1,
"Waiting for opened gate...\n");
2348 oseq =
reqprep(&resp, p,
"MDCX");
2372 ast_debug(3,
"Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
2386 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2393 snprintf(tmp,
sizeof(tmp),
", dq-gi:%x", sub->
gate->
gateid);
2394 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2398 oseq =
reqprep(&resp, p,
"CRCX");
2478 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2483 ast_debug(3,
"Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
2486 oseq =
reqprep(&resp, p,
"CRCX");
2505 ast_debug(3,
"MGCP Asked to indicate tone: %s on %s@%s-%d in cxmode: %s\n",
2508 oseq =
reqprep(&resp, p,
"RQNT");
2548 snprintf(tone2,
sizeof(tone2),
"%s,L/ci(%02d/%02d/%02d/%02d,%s,%s)", tone,
2551 oseq =
reqprep(&resp, p,
"RQNT");
2564 ast_debug(3,
"MGCP Asked to indicate tone: %s on %s@%s-%d in cxmode: %s\n",
2587 ast_debug(3,
"Modified %s@%s-%d with new mode: %s on callid: %s\n",
2594 if (p->
ncs && !fc) {
2603 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2611 snprintf(tmp,
sizeof(tmp),
", dq-gi:%x", sub->
gate->
gateid);
2612 strncat(local, tmp,
sizeof(local) - strlen(local) - 1);
2620 oseq =
reqprep(&resp, p,
"MDCX");
2651 char tone_indicate_end = 0;
2656 if (p && (!strcasecmp(tone, (p->
ncs ?
"L/ro" :
"G/cg")))) {
2657 tone_indicate_end = 1;
2665 }
else if (!tone_indicate_end){
2666 add_header(resp,
"R", (p->
ncs ?
"L/hu(N),L/hf(N),L/[0-9#*](N)" :
"L/hu(N),L/hf(N),D/[0-9#*](N)"));
2668 ast_debug(1,
"We don't want more digits if we will end the call\n");
2680 oseq =
reqprep(&resp, p,
"AUEP");
2696 ast_debug(3,
"Delete connection %s %s@%s-%d with new mode: %s on callid: %s\n",
2698 oseq =
reqprep(&resp, p,
"DLCX");
2718 ast_debug(3,
"Delete connection %s %s@%s on callid: %s\n",
2719 cxident ? cxident :
"", p->
name, p->
parent->
name, callid ? callid :
"");
2720 oseq =
reqprep(&resp, p,
"DLCX");
2722 if (callid && *callid)
2725 if (cxident && *cxident)
2774 for (prev =
NULL, req = *queue; req; prev = req, req = req->
next) {
2775 if (req->trid == ident) {
2784 ast_debug(1,
"Posting Queued Request:\n%s to %s:%d\n", (*queue)->data,
2817 ast_verb(3,
"No command found on [%s] for transaction %u. Ignoring...\n",
2822 if (p && (result >= 400) && (result <= 599)) {
2880 if (strcasecmp(c, sub->
cxident)) {
2885 if (sub->
tmpdest.sin_addr.s_addr) {
2904 while ((v =
get_csv(c, &len, &n))) {
2909 char cxident[80] =
"";
2911 if (len > (
sizeof(cxident) - 1))
2912 len =
sizeof(cxident) - 1;
2914 ast_verb(3,
"Non existing connection id %s on %s@%s \n",
2926 if (strstr(c,
"hu")) {
2939 }
else if (strstr(c,
"hd")) {
2953 if (resp && resp->
lines) {
2955 if (sub && sub->
owner) {
3010 int loop_pause = 100;
3012 const char *pickupexten;
3019 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
3022 pickupexten =
ast_strdupa(pickup_cfg->pickupexten);
3029 while (strlen(p->
dtmf_buf) == len) {
3031 timeout -= loop_pause;
3055 ast_verb(3,
"Setting call forward to '%s' on channel %s\n",
3101 }
else if (res == 0) {
3102 ast_debug(1,
"not enough digits (and no ambiguous match)...\n");
3118 }
else if (!strcmp(p->
dtmf_buf, pickupexten)) {
3150 }
else if (!strcmp(p->
dtmf_buf,
"*78")) {
3159 }
else if (!strcmp(p->
dtmf_buf,
"*79")) {
3314 if (p->
sub != sub) {
3354 #ifdef DLINK_BUGGY_FIRMWARE 3386 ast_log(
LOG_WARNING,
"If we're onhook why are we here trying to handle a hd or hf?\n");
3412 if (!strcasecmp(req->
verb,
"RSIP")) {
3414 if (!strcasecmp(
get_header(req,
"RM"),
"X-keepalive")) {
3430 for (tmp_ep = g->
endpoints; tmp_ep; tmp_ep = tmp_ep->
next) {
3436 first_sub = tmp_ep->
sub;
3437 tmp_sub = tmp_ep->
sub;
3440 tmp_sub = tmp_sub->
next;
3441 if (tmp_sub == first_sub)
3446 }
else if (sub->
owner) {
3459 }
else if (!strcasecmp(req->
verb,
"NTFY")) {
3464 s = strchr(ev,
'/');
3468 if (strcasecmp(ev,
"hu") && strcasecmp(ev,
"hd") && strcasecmp(ev,
"ping")) {
3471 if (!strcasecmp(ev,
"hd")) {
3482 }
else if (!strcasecmp(ev,
"hf")) {
3514 ast_verb(3,
"MGCP Conferencing %d and %d on %s@%s\n",
3525 ast_verb(3,
"We didn't make one of the calls FLIPFLOP %d and %d on %s@%s\n",
3552 ast_log(
LOG_WARNING,
"Callwaiting, call transfer or threeway calling not enabled on endpoint %s@%s\n",
3555 }
else if (!strcasecmp(ev,
"hu")) {
3582 ast_verb(3,
"MGCP handle_request(%s@%s-%d) ast_channel already destroyed, resending DLCX.\n",
3604 }
else if ((strlen(ev) == 1) &&
3605 (((ev[0] >=
'0') && (ev[0] <=
'9')) ||
3606 ((ev[0] >=
'A') && (ev[0] <=
'D')) ||
3607 (ev[0] ==
'*') || (ev[0] ==
'#'))) {
3618 if (strstr(p->
curtone, (p->
ncs ?
"wt1" :
"wt")) && (ev[0] ==
'A')) {
3625 }
else if (!strcasecmp(ev,
"T")) {
3627 }
else if (!strcasecmp(ev,
"ping")) {
3645 if (sscanf(req->
identifier,
"%30d", &seqno) != 1) {
3657 if (seqno == cur->seqno)
3672 struct sockaddr_in sin;
3679 memset(&req, 0,
sizeof(req));
3680 res = recvfrom(
mgcpsock, req.
data,
sizeof(req.
data) - 1, 0, (
struct sockaddr *)&sin, &len);
3682 if (
errno != ECONNREFUSED)
3686 req.
data[res] =
'\0';
3699 if (sscanf(req.
verb,
"%30d", &result) && sscanf(req.
identifier,
"%30d", &ident)) {
3701 ast_debug(1,
"Ignoring provisional response on transaction %d\n", ident);
3712 for (prev =
NULL, cur = gw->
msgs; cur; prev = cur, cur = cur->
next) {
3713 if (cur->
seqno == ident) {
3714 ast_debug(1,
"Got response back on transaction %d\n", ident);
3735 ast_log(
LOG_NOTICE,
"Got response back on [%s] for transaction %d we aren't sending?\n",
3742 ast_log(
LOG_NOTICE,
"Message must have a verb, an idenitifier, version, and endpoint\n");
3779 for (i = 0; (i <
MAX_SUBS) && s; i++) {
3791 for (i = 0; (i <
MAX_SUBS) && sub; i++) {
3813 ast_debug(1,
"***** MGCP REALTIME PRUNE GW: %s\n", g->
name);
3861 lastpass = thispass;
3862 thispass = time(
NULL);
3865 if (thispass != lastpass) {
3870 if ((e->msgstate != res) && (e->hookstate ==
MGCP_ONHOOK) && (!e->rtp)){
3877 e->onhooktime = thispass;
3887 if(time(
NULL) > (lastrun + 60)) {
3912 lastrun = time(
NULL);
3918 pthread_testcancel();
3922 if ((res < 0) || (res > 1000)) {
3988 ast_verb(3,
"MGCP mgcp_request(%s)\n", tmp);
3989 ast_verb(3,
"MGCP cw: %d, dnd: %d, so: %d, sno: %d\n",
4031 if (!strcasecmp(cat, gw->
name)) {
4039 if (!gw && !(gw =
ast_calloc(1,
sizeof(*gw)))) {
4053 for (; v; v = v->
next) {
4054 if (!strcasecmp(v->
name,
"host")) {
4055 if (!strcasecmp(v->
value,
"dynamic")) {
4058 memset(&gw->
addr.sin_addr, 0, 4);
4059 if (gw->
addr.sin_port) {
4062 gw->
addr.sin_port = 0;
4082 }
else if (!strcasecmp(v->
name,
"defaultip")) {
4094 }
else if (!strcasecmp(v->
name,
"permit") ||
4095 !strcasecmp(v->
name,
"deny")) {
4099 ast_log(
LOG_ERROR,
"Invalid ACL '%s' specified for MGCP gateway '%s' on line %d. Not creating.\n",
4109 }
else if (!strcasecmp(v->
name,
"port")) {
4110 gw->
addr.sin_port = htons(atoi(v->
value));
4111 }
else if (!strcasecmp(v->
name,
"context")) {
4113 }
else if (!strcasecmp(v->
name,
"dtmfmode")) {
4114 if (!strcasecmp(v->
value,
"inband"))
4116 else if (!strcasecmp(v->
value,
"rfc2833"))
4118 else if (!strcasecmp(v->
value,
"hybrid"))
4120 else if (!strcasecmp(v->
value,
"none"))
4124 }
else if (!strcasecmp(v->
name,
"nat")) {
4126 }
else if (!strcasecmp(v->
name,
"ncs")) {
4128 }
else if (!strcasecmp(v->
name,
"hangupongateremove")) {
4130 }
else if (!strcasecmp(v->
name,
"pktcgatealloc")) {
4132 }
else if (!strcasecmp(v->
name,
"callerid")) {
4133 if (!strcasecmp(v->
value,
"asreceived")) {
4139 }
else if (!strcasecmp(v->
name,
"language")) {
4141 }
else if (!strcasecmp(v->
name,
"accountcode")) {
4143 }
else if (!strcasecmp(v->
name,
"amaflags")) {
4150 }
else if (!strcasecmp(v->
name,
"setvar")) {
4152 }
else if (!strcasecmp(v->
name,
"clearvars")) {
4157 }
else if (!strcasecmp(v->
name,
"musiconhold")) {
4159 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
4161 }
else if (!strcasecmp(v->
name,
"callgroup")) {
4163 }
else if (!strcasecmp(v->
name,
"pickupgroup")) {
4165 }
else if (!strcasecmp(v->
name,
"immediate")) {
4167 }
else if (!strcasecmp(v->
name,
"cancallforward")) {
4169 }
else if (!strcasecmp(v->
name,
"singlepath")) {
4171 }
else if (!strcasecmp(v->
name,
"directmedia") || !strcasecmp(v->
name,
"canreinvite")) {
4173 }
else if (!strcasecmp(v->
name,
"mailbox")) {
4175 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
4181 if (strchr(gw->
name,
'@')) {
4187 }
else if (!strcasecmp(v->
name,
"adsi")) {
4189 }
else if (!strcasecmp(v->
name,
"callreturn")) {
4191 }
else if (!strcasecmp(v->
name,
"callwaiting")) {
4193 }
else if (!strcasecmp(v->
name,
"slowsequence")) {
4195 }
else if (!strcasecmp(v->
name,
"transfer")) {
4197 }
else if (!strcasecmp(v->
name,
"threewaycalling")) {
4199 }
else if (!strcasecmp(v->
name,
"wcardep")) {
4250 if (!ep_reload && e->
sub && e->
sub->
rtp) {
4276 ast_verb(3,
"Allocating subchannel '%d' on %s@%s\n", i, e->
name, gw->
name);
4297 for (sub = e->
sub; sub && sub->
next; sub = sub->
next);
4305 }
else if (!strcasecmp(v->
name,
"trunk") ||
4306 !strcasecmp(v->
name,
"line")) {
4399 ast_verb(3,
"Allocating subchannel '%d' on %s@%s\n", i, e->
name, gw->
name);
4420 for (sub = e->
sub; sub && sub->
next; sub = sub->
next);
4428 }
else if (!strcasecmp(v->
name,
"name") || !strcasecmp(v->
name,
"lines")) {
4434 if (!ntohl(gw->
addr.sin_addr.s_addr) && !gw->
dynamic) {
4444 gw->
defaddr.sin_family = AF_INET;
4445 gw->
addr.sin_family = AF_INET;
4446 if (gw->
defaddr.sin_addr.s_addr && !ntohs(gw->
defaddr.sin_port)) {
4449 if (gw->
addr.sin_addr.s_addr && !ntohs(gw->
addr.sin_port)) {
4454 struct sockaddr_in tmp3 = {0,};
4456 tmp3.sin_addr = gw->
ourip;
4463 gw->
ourip = tmp3.sin_addr;
4472 return (gw_reload ?
NULL : gw);
4483 *instance = sub->
rtp;
4530 if (!strcasecmp(args,
"ncs")) {
4531 snprintf(buf, buflen,
"%s", sub->
parent->
ncs ?
"yes":
"no");
4574 for (i = 0; (i <
MAX_SUBS) && sub; i++) {
4656 if ((varval = strchr(varname,
'='))) {
4659 tmpvar->
next = list;
4673 for (v = src ; v ; v = v->
next) {
4724 if (!strcasecmp(v->
name,
"bindaddr")) {
4730 }
else if (!strcasecmp(v->
name,
"allow")) {
4732 }
else if (!strcasecmp(v->
name,
"disallow")) {
4734 }
else if (!strcasecmp(v->
name,
"tos")) {
4738 }
else if (!strcasecmp(v->
name,
"tos_audio")) {
4741 }
else if (!strcasecmp(v->
name,
"cos")) {
4744 }
else if (!strcasecmp(v->
name,
"cos_audio")) {
4747 }
else if (!strcasecmp(v->
name,
"port")) {
4753 }
else if (!strcasecmp(v->
name,
"firstdigittimeout")) {
4755 }
else if (!strcasecmp(v->
name,
"gendigittimeout")) {
4757 }
else if (!strcasecmp(v->
name,
"matchdigittimeout")) {
4773 if (strcasecmp(cat,
"general")) {
4793 if (ntohl(
bindaddr.sin_addr.s_addr)) {
4815 mgcpsock = socket(AF_INET, SOCK_DGRAM, 0);
4826 ast_verb(2,
"MGCP Listening on %s:%d\n",
4827 ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
4839 ast_verb(3,
"MGCP Auditing endpoint %s@%s for hookstate\n", e->
name, g->
name);
4862 ao2_ref(global_capability, -1);
4870 ao2_ref(global_capability, -1);
4878 ao2_ref(global_capability, -1);
4884 ao2_ref(global_capability, -1);
4894 ao2_ref(global_capability, -1);
4910 static int deprecated = 0;
4917 "Usage: mgcp reload\n" 4918 " 'mgcp reload' is deprecated. Please use 'reload chan_mgcp.so' instead.\n";
4925 if (!deprecated && a && a->
argc > 0) {
4926 ast_log(
LOG_WARNING,
"'mgcp reload' is deprecated. Please use 'reload chan_mgcp.so' instead.\n");
4932 ast_verbose(
"Previous mgcp reload not yet done\n");
5010 ao2_ref(global_capability, -1);
5011 global_capability =
NULL;
5024 .optional_modules =
"res_pktccops",
static int __mgcp_xmit(struct mgcp_gateway *gw, char *data, int len)
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static const char *const mgcp_cxmodes[]
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
static char musicclass[MAX_MUSICCLASS]
struct ast_variable * next
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
unsigned long long ast_group_t
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
static void start_rtp(struct mgcp_subchannel *sub)
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) ...
#define ast_channel_lock(chan)
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_party_dialed::@246 number
Dialed/Called number.
#define AST_CLI_DEFINE(fn, txt,...)
char * str
Subscriber phone number (Malloced)
static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, int result, unsigned int ident, struct mgcp_request *resp)
struct ast_mwi_subscriber * mwi_event_sub
static void mgcp_queue_frame(struct mgcp_subchannel *sub, struct ast_frame *f)
static ast_mutex_t gatelock
gatelock: mutex for gateway/endpoint lists
static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
char cid_num[AST_MAX_EXTENSION]
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
static ast_group_t cur_pickupgroup
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
static int firstdigittimeout
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
char * str
Subscriber phone number (Malloced)
char lastcallerid[AST_MAX_EXTENSION]
static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp)
static char parkinglot[AST_MAX_CONTEXT]
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
char cid_name[AST_MAX_EXTENSION]
static char * handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
static int restart_monitor(void)
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
struct mgcp_endpoint * owner_ep
struct mgcp_request * cx_queue
ast_mutex_t cmd_queue_lock
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
static struct mgcp_gateway * build_gateway(char *cat, struct ast_variable *v)
build_gateway: parse mgcp.conf and create gateway/endpoint structures
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
static unsigned int oseq_global
struct mgcp_subchannel * sub
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
#define ast_pthread_create_detached(a, b, c, d)
static int * mgcpsock_read_id
static int unalloc_sub(struct mgcp_subchannel *sub)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
struct cops_gate * ast_pktccops_gate_alloc(int cmd, struct cops_gate *gate, uint32_t mta, uint32_t actcount, float bitrate, uint32_t psize, uint32_t ssip, uint16_t ssport, int(*const got_dq_gi)(struct cops_gate *gate), int(*const gate_remove)(struct cops_gate *gate))
static void mgcp_set_owner(struct mgcp_subchannel *sub, struct ast_channel *chan)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static char * mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define DEFAULT_MGCP_GW_PORT
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
static struct ast_frame * mgcp_rtp_read(struct mgcp_subchannel *sub)
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
char musicclass[MAX_MUSICCLASS]
static char * get_csv(char *c, int *len, char **next)
get_csv: (SC:) get comma separated value
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Convenient Signal Processing routines.
static int mgcp_call(struct ast_channel *ast, const char *dest, int timeout)
#define MGCP_DTMF_RFC2833
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
static char * get_header(struct mgcp_request *req, char *name)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
static void destroy_gateway(struct mgcp_gateway *g)
#define DEADLOCK_AVOIDANCE(lock)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
descriptor for a cli entry.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
struct mgcp_request * next
static int attempt_transfer(struct mgcp_endpoint *p, struct mgcp_subchannel *sub)
Complete an attended transfer.
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
static struct ast_format_cap * global_capability
#define CONFIG_STATUS_FILEINVALID
char dtmf_buf[AST_MAX_EXTENSION]
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp)
static const char config[]
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
Structure for variables, used for configurations and for channel variables.
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
static int load_module(void)
Load the module.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
static void mgcp_queue_hangup(struct mgcp_subchannel *sub)
char call_forward[AST_MAX_EXTENSION]
static struct ast_frame * mgcp_read(struct ast_channel *ast)
static int send_response(struct mgcp_subchannel *sub, struct mgcp_request *req)
#define ast_rtp_glue_register(glue)
static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
static int reqprep(struct mgcp_request *req, struct mgcp_endpoint *p, char *verb)
static int unload_module(void)
static char ourhost[MAXHOSTNAMELEN]
int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
says digits of a string
Structure to pass both assignedid values to channel drivers.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
ast_channel_state
ast_channel states
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
static const struct adsi_event events[]
static void sdpLineNum_iterator_init(int *iterator)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername)
int ast_parking_blind_transfer_park(struct ast_bridge_channel *parker, const char *context, const char *exten, transfer_channel_cb parked_channel_cb, struct transfer_channel_data *parked_channel_data)
Perform a blind transfer to a parking extension.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct sockaddr_in tmpdest
#define ast_mutex_lock(a)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
static struct mgcp_request * find_command(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, struct mgcp_request **queue, ast_mutex_t *l, int ident)
find_command: (SC:) remove command transaction from queue
#define ast_str_alloca(init_len)
void ast_verbose(const char *fmt,...)
#define ast_strdup(str)
A wrapper for strdup()
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp_request *req, char *msgrest)
I/O Management (derived from Cheops-NG)
Common implementation-independent jitterbuffer stuff.
void ast_cli(int fd, const char *fmt,...)
struct mgcp_subchannel * next
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Socket address structure.
static char cid_num[AST_MAX_EXTENSION]
static struct ast_channel * mgcp_new(struct mgcp_subchannel *sub, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
#define ast_verb(level,...)
static int transmit_audit_endpoint(struct mgcp_endpoint *p)
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.
static void mgcp_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static int threewaycalling
struct ast_frame_subclass subclass
static void * do_monitor(void *data)
static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev)
static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
int args
This gets set in ast_cli_register()
#define AST_MAX_MAILBOX_UNIQUEID
static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_strlen_zero(foo)
static int transmit_connection_del_w_params(struct mgcp_endpoint *p, char *callid, char *cxident)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
static int cancallforward
#define ast_pthread_create_background(a, b, c, d)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
mgcp_message: MGCP message for queuing up
static void prune_gateways(void)
struct mgcp_response * responses
static char * handle_mgcp_show_endpoints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_MAX_ACCOUNT_CODE
#define DEFAULT_MGCP_CA_PORT
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
internal representation of ACL entries In principle user applications would have no need for this...
char language[MAX_LANGUAGE]
static void * mgcp_ss(void *data)
char parkinglot[AST_MAX_CONTEXT]
Configuration File Parser.
struct ast_format_cap * cap
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, const struct ast_format_cap *codecs)
static ast_mutex_t netlock
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
Get our local IP address when contacting a remote host.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
#define ast_config_load(filename, flags)
Load a config file.
struct ast_party_id ani
Automatic Number Identification (ANI)
static int mgcp_prune_realtime_gateway(struct mgcp_gateway *g)
General Asterisk PBX channel definitions.
void ast_channel_rings_set(struct ast_channel *chan, int value)
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
#define ast_mutex_trylock(a)
static struct sockaddr_in bindaddr
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code...
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define AST_PTHREADT_NULL
struct sockaddr_in defaddr
static int reload_config(int reload)
static void destroy_endpoint(struct mgcp_endpoint *e)
struct ast_variable * chanvars
Access Control of various sorts.
static struct ao2_container * codecs
Registered codecs.
Global IO variables are now in a struct in order to be made threadsafe.
static int mgcp_alloc_pktcgate(struct mgcp_subchannel *sub)
#define AST_MAX_EXTENSION
static int transmit_connect(struct mgcp_subchannel *sub)
Scheduler Routines (derived from cheops)
struct mgcp_gateway * next
#define ast_channel_cleanup(c)
Cleanup a channel reference.
#define ao2_ref(o, delta)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#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_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
struct ast_channel * owner
void ast_config_destroy(struct ast_config *config)
Destroys a config.
long int ast_random(void)
struct mgcp_request * rqnt_queue
static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct mgcp_message * msgs
static struct io_context * io
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *cap, int nat_active)
#define ast_malloc(len)
A wrapper for malloc()
static struct ast_channel_tech mgcp_tech
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
#define ast_variable_new(name, value, filename)
ast_group_t ast_get_group(const char *s)
static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, char *data, int len, unsigned int seqno)
static int transmit_connection_del(struct mgcp_subchannel *sub)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static int answer(void *data)
char context[AST_MAX_EXTENSION]
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record tx payload type information that was seen in an a=rtpmap: SDP line.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
char accountcode[AST_MAX_ACCOUNT_CODE]
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static int resend_response(struct mgcp_subchannel *sub, struct mgcp_response *resp)
#define CONFIG_STATUS_FILEUNCHANGED
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
static char language[MAX_LANGUAGE]
static int gendigittimeout
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
static pthread_t monitor_thread
struct mgcp_response * next
char exten[AST_MAX_EXTENSION]
static ast_mutex_t monlock
static struct ast_variable * add_var(const char *buf, struct ast_variable *list)
static int nonCodecCapability
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static int mgcp_devicestate(const char *data)
mgcp_devicestate: channel callback for device status monitoring
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_parking_is_exten_park(const char *context, const char *exten)
Determine if the context/exten is a "parking" extension.
static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp, char *tone)
ast_mutex_t cx_queue_lock
static enum ast_rtp_glue_result mgcp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct mgcp_gateway * parent
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
Set type of service.
static int init_req(struct mgcp_endpoint *p, struct mgcp_request *req, char *verb, unsigned int oseq)
static int mgcp_reloading
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
int(* gate_open)(struct cops_gate *gate)
const ast_string_field name
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
static char * get_sdp_by_line(char *line, char *name, int nameLen)
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
struct ast_format_cap * capabilities
int ast_parking_provider_registered(void)
Check whether a parking provider is registered.
static struct ast_jb_conf global_jbconf
#define ast_channel_unlock(chan)
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
static void parse(struct mgcp_request *req)
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
#define AST_CAUSE_UNREGISTERED
#define ast_calloc(num, len)
A wrapper for calloc()
ast_mutex_t rqnt_queue_lock
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
static char * handle_mgcp_audit_endpoint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
static ast_group_t cur_callergroup
Module has failed to load, may be in an inconsistent state.
int(* gate_remove)(struct cops_gate *gate)
struct mgcp_request * cmd_queue
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
static struct mgcp_gateway * gateways
static struct mgcp_subchannel * find_subchannel_and_lock(char *name, int msgid, struct sockaddr_in *sin)
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.
static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub)
dump_cmd_queues: (SC:) cleanup pending commands
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Structure used to handle boolean flags.
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
struct ast_rtp_instance * rtp
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
int ast_io_remove(struct io_context *ioc, int *id)
Removes an IO context.
static char cid_name[AST_MAX_EXTENSION]
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
static struct ast_channel * mgcp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *dest, int *cause)
static char accountcode[AST_MAX_ACCOUNT_CODE]
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
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...
struct mgcp_endpoint * parent
struct ast_frame ast_null_frame
static struct ast_variable * copy_vars(struct ast_variable *src)
duplicate a list of channel variables,
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
static char * __get_header(struct mgcp_request *req, char *name, int *start, char *def)
static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone)
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL
struct hostent * ast_gethostbyname(const char *host, struct ast_hostent *hp)
Thread-safe gethostbyname function to use in Asterisk.
Structure that contains information regarding a channel in a bridge.
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
static int hangupongateremove
static struct ast_cli_entry cli_mgcp[]
static int has_voicemail(struct mgcp_endpoint *p)
Standard Command Line Interface.
static int mgcp_answer(struct ast_channel *ast)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static ast_mutex_t mgcp_reload_lock
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
const char * ast_channel_name(const struct ast_channel *chan)
static int find_and_retrans(struct mgcp_subchannel *sub, struct mgcp_request *req)
static struct ast_rtp_glue mgcp_rtp_glue
static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, struct mgcp_request *req, unsigned int seqno)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
#define AST_PTHREADT_STOP
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
static char context[AST_MAX_EXTENSION]
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
char * line[MGCP_MAX_LINES]
struct stasis_forward * sub
Data structure associated with a single frame of data.
Internal Asterisk hangup causes.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
const char * ast_channel_language(const struct ast_channel *chan)
static void mgcp_queue_control(struct mgcp_subchannel *sub, int control)
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.
static int mgcp_pktcgate_open(struct cops_gate *gate)
char * header[MGCP_MAX_HEADERS]
static struct mgcp_gateway * find_realtime_gw(char *name, char *at, struct sockaddr_in *sin)
struct mgcp_message * next
static char * get_sdp_iterate(int *iterator, struct mgcp_request *req, char *name)
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.
static char * control2str(int ind)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
static int mgcp_pktcgate_remove(struct cops_gate *gate)
int error(const char *format,...)
static ast_mutex_t oseq_lock
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req, struct sockaddr_in *sin)
union ast_frame::@263 data
struct mgcp_endpoint * endpoints
enum ast_frame_type frametype
static int mgcp_hangup(struct ast_channel *ast)
static int add_line(struct mgcp_request *req, char *line)
#define DSP_DIGITMODE_NOQUELCH
#define ast_mutex_init(pmutex)
#define ast_channel_trylock(chan)
static int matchdigittimeout
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
#define ast_mutex_destroy(a)
struct mgcp_endpoint * next
static struct ast_sched_context * sched
struct ast_format * format
#define MGCP_SUBCHANNEL_MAGIC
static char * get_sdp(struct mgcp_request *req, char *name)
static struct in_addr __ourip
static const char tdesc[]
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
The structure that contains MWI state.
static struct ast_jb_conf default_jbconf
Say numbers and dates (maybe words one day too)
static int transmit_modify_request(struct mgcp_subchannel *sub)
#define ASTERISK_GPL_KEY
The text the key() function should return.
void ast_channel_priority_set(struct ast_channel *chan, int value)
Pluggable RTP Architecture.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
char mailbox[AST_MAX_EXTENSION]
Asterisk module definitions.
static int mgcpsock_read(int *id, int fd, short events, void *ignore)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
static struct hostent * hp
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
static snd_pcm_format_t format
char data[MGCP_MAX_PACKET]
Persistant data storage (akin to *doze registry)
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
unsigned char valid
TRUE if the number information is valid/present.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
General jitterbuffer configuration.
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record tx payload type information that was seen in an m= SDP line.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
static int init_resp(struct mgcp_request *req, char *resp, struct mgcp_request *orig, char *resprest)
static void dump_queue(struct mgcp_gateway *gw, struct mgcp_endpoint *p)
static int respprep(struct mgcp_request *resp, struct mgcp_endpoint *p, char *msg, struct mgcp_request *req, char *msgrest)
static int retrans_pkt(const void *data)
int(* got_dq_gi)(struct cops_gate *gate)
#define AST_MUTEX_DEFINE_STATIC(mutex)
Structure for mutex and tracking information.
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
#define ast_mutex_unlock(a)
static int add_header(struct mgcp_request *req, const char *var, const char *value)
Configuration relating to call pickup.
#define AST_APP_ARG(name)
Define an application argument.
Channels have this property if they can create jitter; i.e. most VoIP channels.
struct ast_party_number number
Subscriber phone number.
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
#define ast_module_ref(mod)
Hold a reference to the module.
struct mgcp_subchannel * owner_sub
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...