mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-27 06:31:54 +00:00
Merge JS's Cisco MGCP fixes (Bug #693)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -11,6 +11,20 @@
|
|||||||
* the GNU General Public License
|
* the GNU General Public License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* JS: Changes
|
||||||
|
-- add support for the wildcard endpoint
|
||||||
|
-- seteable wildcard with wcardep on mgcp.conf
|
||||||
|
-- added package indicator on RQNT, i.e "dl" --> "L/dl"
|
||||||
|
-- removed MDCX just before DLCX, do we need this ?
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* JS: TODO
|
||||||
|
-- reload for wildcard endpoint probably buggy
|
||||||
|
-- when hf is notified we're sending CRCX after MDCX, without waiting for
|
||||||
|
OK on the MDCX which fails on Cisco IAD 24XX
|
||||||
|
-- honour codec order, by now the lowest codec number in "allow" is the prefered
|
||||||
|
*/
|
||||||
|
|
||||||
/* SC: Changes
|
/* SC: Changes
|
||||||
-- packet retransmit mechanism (simplistic)
|
-- packet retransmit mechanism (simplistic)
|
||||||
-- per endpoint/subchannel mgcp command sequencing.
|
-- per endpoint/subchannel mgcp command sequencing.
|
||||||
@@ -381,6 +395,8 @@ static struct mgcp_gateway {
|
|||||||
int lastout;
|
int lastout;
|
||||||
int messagepending;
|
int messagepending;
|
||||||
*/
|
*/
|
||||||
|
/* JS: Wildcard endpoint name */
|
||||||
|
char wcardep[30];
|
||||||
struct mgcp_message *msgs; /* SC: gw msg queue */
|
struct mgcp_message *msgs; /* SC: gw msg queue */
|
||||||
ast_mutex_t msgs_lock; /* SC: queue lock */
|
ast_mutex_t msgs_lock; /* SC: queue lock */
|
||||||
int retransid; /* SC: retrans timer id */
|
int retransid; /* SC: retrans timer id */
|
||||||
@@ -485,7 +501,7 @@ static void dump_queue(struct mgcp_gateway *gw, struct mgcp_endpoint *p)
|
|||||||
else
|
else
|
||||||
gw->msgs = cur->next;
|
gw->msgs = cur->next;
|
||||||
|
|
||||||
ast_log(LOG_NOTICE, "Removing message from %s tansaction %u\n",
|
ast_log(LOG_NOTICE, "Removing message from %s transaction %u\n",
|
||||||
gw->name, cur->seqno);
|
gw->name, cur->seqno);
|
||||||
|
|
||||||
w = cur;
|
w = cur;
|
||||||
@@ -844,9 +860,9 @@ static int mgcp_hangup(struct ast_channel *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if ((sub == p->sub->next) && p->hookstate == MGCP_OFFHOOK) {
|
} else if ((sub == p->sub->next) && p->hookstate == MGCP_OFFHOOK) {
|
||||||
transmit_notify_request(sub, "v");
|
transmit_notify_request(sub, "L/v");
|
||||||
} else if (p->hookstate == MGCP_OFFHOOK) {
|
} else if (p->hookstate == MGCP_OFFHOOK) {
|
||||||
transmit_notify_request(sub, "ro");
|
transmit_notify_request(sub, "L/ro");
|
||||||
} else {
|
} else {
|
||||||
transmit_notify_request(sub, "");
|
transmit_notify_request(sub, "");
|
||||||
}
|
}
|
||||||
@@ -875,12 +891,12 @@ static int mgcp_hangup(struct ast_channel *ast)
|
|||||||
if (mgcpdebug) {
|
if (mgcpdebug) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_hangup(%s) on %s@%s set vmwi(+)\n", ast->name, p->name, p->parent->name);
|
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_hangup(%s) on %s@%s set vmwi(+)\n", ast->name, p->name, p->parent->name);
|
||||||
}
|
}
|
||||||
transmit_notify_request(sub, "vmwi(+)");
|
transmit_notify_request(sub, "L/vmwi(+)");
|
||||||
} else {
|
} else {
|
||||||
if (mgcpdebug) {
|
if (mgcpdebug) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_hangup(%s) on %s@%s set vmwi(-)\n", ast->name, p->name, p->parent->name);
|
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_hangup(%s) on %s@%s set vmwi(-)\n", ast->name, p->name, p->parent->name);
|
||||||
}
|
}
|
||||||
transmit_notify_request(sub, "vmwi(-)");
|
transmit_notify_request(sub, "L/vmwi(-)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_mutex_unlock(&sub->lock);
|
ast_mutex_unlock(&sub->lock);
|
||||||
@@ -900,7 +916,9 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
|
|||||||
e = g->endpoints;
|
e = g->endpoints;
|
||||||
ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? inet_ntoa(g->addr.sin_addr) : inet_ntoa(g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
|
ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? inet_ntoa(g->addr.sin_addr) : inet_ntoa(g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
|
||||||
while(e) {
|
while(e) {
|
||||||
ast_cli(fd, " -- '%s@%s in '%s' is %s\n", e->name, g->name, e->context, e->sub->owner ? "active" : "idle");
|
// JS: Don't show wilcard endpoint
|
||||||
|
if (strcmp(e->name, g->wcardep) !=0)
|
||||||
|
ast_cli(fd, " -- '%s@%s in '%s' is %s\n", e->name, g->name, e->context, e->sub->owner ? "active" : "idle");
|
||||||
hasendpoints = 1;
|
hasendpoints = 1;
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
@@ -1133,13 +1151,13 @@ static int mgcp_indicate(struct ast_channel *ast, int ind)
|
|||||||
}
|
}
|
||||||
switch(ind) {
|
switch(ind) {
|
||||||
case AST_CONTROL_RINGING:
|
case AST_CONTROL_RINGING:
|
||||||
transmit_notify_request(sub, "rt");
|
transmit_notify_request(sub, "G/rt");
|
||||||
break;
|
break;
|
||||||
case AST_CONTROL_BUSY:
|
case AST_CONTROL_BUSY:
|
||||||
transmit_notify_request(sub, "bz");
|
transmit_notify_request(sub, "L/bz");
|
||||||
break;
|
break;
|
||||||
case AST_CONTROL_CONGESTION:
|
case AST_CONTROL_CONGESTION:
|
||||||
transmit_notify_request(sub, "cg");
|
transmit_notify_request(sub, "G/cg");
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
transmit_notify_request(sub, "");
|
transmit_notify_request(sub, "");
|
||||||
@@ -1929,10 +1947,10 @@ static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone)
|
|||||||
add_header(&resp, "X", p->rqnt_ident); /* SC */
|
add_header(&resp, "X", p->rqnt_ident); /* SC */
|
||||||
switch (p->hookstate) {
|
switch (p->hookstate) {
|
||||||
case MGCP_ONHOOK:
|
case MGCP_ONHOOK:
|
||||||
add_header(&resp, "R", "hd(N)");
|
add_header(&resp, "R", "L/hd(N)");
|
||||||
break;
|
break;
|
||||||
case MGCP_OFFHOOK:
|
case MGCP_OFFHOOK:
|
||||||
add_header(&resp, "R", "hu(N), hf(N), D/[0-9#*](N)");
|
add_header(&resp, "R", "L/hu(N), L/hf(N), D/[0-9#*](N)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strlen(tone)) {
|
if (strlen(tone)) {
|
||||||
@@ -2041,7 +2059,8 @@ static int transmit_audit_endpoint(struct mgcp_endpoint *p)
|
|||||||
struct mgcp_request resp;
|
struct mgcp_request resp;
|
||||||
reqprep(&resp, p, "AUEP");
|
reqprep(&resp, p, "AUEP");
|
||||||
/* SC: removed unknown param VS */
|
/* SC: removed unknown param VS */
|
||||||
add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,E,MD,M");
|
//add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,E,MD,M");
|
||||||
|
add_header(&resp, "F", "A");
|
||||||
/* SC: fill in new fields */
|
/* SC: fill in new fields */
|
||||||
resp.cmd = MGCP_CMD_AUEP;
|
resp.cmd = MGCP_CMD_AUEP;
|
||||||
resp.trid = oseq;
|
resp.trid = oseq;
|
||||||
@@ -2378,7 +2397,7 @@ static void *mgcp_ss(void *data)
|
|||||||
} else {
|
} else {
|
||||||
/* XXX Redundant? We should already be playing dialtone */
|
/* XXX Redundant? We should already be playing dialtone */
|
||||||
/*tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
|
/*tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
|
||||||
transmit_notify_request(sub, "dl");
|
transmit_notify_request(sub, "L/dl");
|
||||||
}
|
}
|
||||||
if (ast_exists_extension(chan, chan->context, exten, 1, p->callerid)) {
|
if (ast_exists_extension(chan, chan->context, exten, 1, p->callerid)) {
|
||||||
if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->callerid)) {
|
if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->callerid)) {
|
||||||
@@ -2390,7 +2409,7 @@ static void *mgcp_ss(void *data)
|
|||||||
p->call_forward, chan->name);
|
p->call_forward, chan->name);
|
||||||
}
|
}
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
if (res)
|
if (res)
|
||||||
break;
|
break;
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
@@ -2399,7 +2418,7 @@ static void *mgcp_ss(void *data)
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
|
||||||
transmit_notify_request(sub, "dl");
|
transmit_notify_request(sub, "L/dl");
|
||||||
len = 0;
|
len = 0;
|
||||||
getforward = 0;
|
getforward = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -2424,7 +2443,7 @@ static void *mgcp_ss(void *data)
|
|||||||
ast_log(LOG_WARNING, "PBX exited non-zero\n");
|
ast_log(LOG_WARNING, "PBX exited non-zero\n");
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
||||||
/*transmit_notify_request(p, "nbz", 1);*/
|
/*transmit_notify_request(p, "nbz", 1);*/
|
||||||
transmit_notify_request(sub, "cg");
|
transmit_notify_request(sub, "G/cg");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -2436,7 +2455,7 @@ static void *mgcp_ss(void *data)
|
|||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
|
ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
||||||
transmit_notify_request(sub, "cg");
|
transmit_notify_request(sub, "G/cg");
|
||||||
/*zt_wait_event(p->subs[index].zfd);*/
|
/*zt_wait_event(p->subs[index].zfd);*/
|
||||||
ast_hangup(chan);
|
ast_hangup(chan);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -2447,7 +2466,7 @@ static void *mgcp_ss(void *data)
|
|||||||
/* Disable call waiting if enabled */
|
/* Disable call waiting if enabled */
|
||||||
p->callwaiting = 0;
|
p->callwaiting = 0;
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
timeout = firstdigittimeout;
|
timeout = firstdigittimeout;
|
||||||
@@ -2460,7 +2479,7 @@ static void *mgcp_ss(void *data)
|
|||||||
if (ast_pickup_call(chan)) {
|
if (ast_pickup_call(chan)) {
|
||||||
ast_log(LOG_WARNING, "No call pickup possible...\n");
|
ast_log(LOG_WARNING, "No call pickup possible...\n");
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
|
||||||
transmit_notify_request(sub, "cg");
|
transmit_notify_request(sub, "G/cg");
|
||||||
}
|
}
|
||||||
ast_hangup(chan);
|
ast_hangup(chan);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -2475,7 +2494,7 @@ static void *mgcp_ss(void *data)
|
|||||||
free(chan->callerid);
|
free(chan->callerid);
|
||||||
chan->callerid = NULL;
|
chan->callerid = NULL;
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
timeout = firstdigittimeout;
|
timeout = firstdigittimeout;
|
||||||
@@ -2486,7 +2505,7 @@ static void *mgcp_ss(void *data)
|
|||||||
}
|
}
|
||||||
if (!res)
|
if (!res)
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
break;
|
break;
|
||||||
} else if (!strcmp(exten, "*78")) {
|
} else if (!strcmp(exten, "*78")) {
|
||||||
/* Do not disturb */
|
/* Do not disturb */
|
||||||
@@ -2494,7 +2513,7 @@ static void *mgcp_ss(void *data)
|
|||||||
ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %s\n", chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %s\n", chan->name);
|
||||||
}
|
}
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
p->dnd = 1;
|
p->dnd = 1;
|
||||||
getforward = 0;
|
getforward = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
@@ -2505,14 +2524,14 @@ static void *mgcp_ss(void *data)
|
|||||||
ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %s\n", chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %s\n", chan->name);
|
||||||
}
|
}
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
p->dnd = 0;
|
p->dnd = 0;
|
||||||
getforward = 0;
|
getforward = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
len = 0;
|
len = 0;
|
||||||
} else if (p->cancallforward && !strcmp(exten, "*72")) {
|
} else if (p->cancallforward && !strcmp(exten, "*72")) {
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
getforward = 1;
|
getforward = 1;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
len = 0;
|
len = 0;
|
||||||
@@ -2521,7 +2540,7 @@ static void *mgcp_ss(void *data)
|
|||||||
ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %s\n", chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %s\n", chan->name);
|
||||||
}
|
}
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
memset(p->call_forward, 0, sizeof(p->call_forward));
|
memset(p->call_forward, 0, sizeof(p->call_forward));
|
||||||
getforward = 0;
|
getforward = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
@@ -2543,7 +2562,7 @@ static void *mgcp_ss(void *data)
|
|||||||
res = ast_db_put("blacklist", p->lastcallerid, "1");
|
res = ast_db_put("blacklist", p->lastcallerid, "1");
|
||||||
if (!res) {
|
if (!res) {
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
@@ -2558,7 +2577,7 @@ static void *mgcp_ss(void *data)
|
|||||||
if (strlen(p->callerid))
|
if (strlen(p->callerid))
|
||||||
chan->callerid = strdup(p->callerid);
|
chan->callerid = strdup(p->callerid);
|
||||||
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(exten, 0, sizeof(exten));
|
memset(exten, 0, sizeof(exten));
|
||||||
timeout = firstdigittimeout;
|
timeout = firstdigittimeout;
|
||||||
@@ -2707,18 +2726,18 @@ static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev)
|
|||||||
}
|
}
|
||||||
if (p->immediate) {
|
if (p->immediate) {
|
||||||
/* The channel is immediately up. Start right away */
|
/* The channel is immediately up. Start right away */
|
||||||
transmit_notify_request(sub, "rt");
|
transmit_notify_request(sub, "G/rt");
|
||||||
c = mgcp_new(sub, AST_STATE_RING);
|
c = mgcp_new(sub, AST_STATE_RING);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
ast_log(LOG_WARNING, "Unable to start PBX on channel %s@%s\n", p->name, p->parent->name);
|
ast_log(LOG_WARNING, "Unable to start PBX on channel %s@%s\n", p->name, p->parent->name);
|
||||||
transmit_notify_request(sub, "cg");
|
transmit_notify_request(sub, "G/cg");
|
||||||
ast_hangup(c);
|
ast_hangup(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (has_voicemail(p)) {
|
if (has_voicemail(p)) {
|
||||||
transmit_notify_request(sub, "sl");
|
transmit_notify_request(sub, "L/sl");
|
||||||
} else {
|
} else {
|
||||||
transmit_notify_request(sub, "dl");
|
transmit_notify_request(sub, "L/dl");
|
||||||
}
|
}
|
||||||
c = mgcp_new(sub, AST_STATE_DOWN);
|
c = mgcp_new(sub, AST_STATE_DOWN);
|
||||||
if (c) {
|
if (c) {
|
||||||
@@ -2758,6 +2777,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
|
|||||||
char *ev, *s;
|
char *ev, *s;
|
||||||
struct ast_frame f = { 0, };
|
struct ast_frame f = { 0, };
|
||||||
struct mgcp_endpoint *p = sub->parent;
|
struct mgcp_endpoint *p = sub->parent;
|
||||||
|
struct mgcp_gateway *g = NULL;
|
||||||
int res;
|
int res;
|
||||||
if (mgcpdebug) {
|
if (mgcpdebug) {
|
||||||
ast_verbose("Handling request '%s' on %s@%s\n", req->verb, p->name, p->parent->name);
|
ast_verbose("Handling request '%s' on %s@%s\n", req->verb, p->name, p->parent->name);
|
||||||
@@ -2772,18 +2792,49 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
|
|||||||
} else {
|
} else {
|
||||||
dump_queue(p->parent, p);
|
dump_queue(p->parent, p);
|
||||||
dump_cmd_queues(p, NULL);
|
dump_cmd_queues(p, NULL);
|
||||||
if (option_verbose > 2) {
|
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Resetting interface %s@%s\n", p->name, p->parent->name);
|
if (option_verbose > 2 && (strcmp(p->name, p->parent->wcardep) != 0)) {
|
||||||
}
|
ast_verbose(VERBOSE_PREFIX_3 "Resetting interface %s@%s\n", p->name, p->parent->name);
|
||||||
if (sub->owner) {
|
}
|
||||||
|
// JS: For RSIP on wildcard we reset all endpoints
|
||||||
|
if (!strcmp(p->name, p->parent->wcardep)) {
|
||||||
|
/* Reset all endpoints */
|
||||||
|
struct mgcp_endpoint *tmp_ep;
|
||||||
|
|
||||||
|
g = p->parent;
|
||||||
|
tmp_ep = g->endpoints;
|
||||||
|
while (tmp_ep) {
|
||||||
|
//if ((strcmp(tmp_ep->name, "*") != 0) && (strcmp(tmp_ep->name, "aaln/*") != 0)) {
|
||||||
|
if (strcmp(tmp_ep->name, g->wcardep) != 0) {
|
||||||
|
struct mgcp_subchannel *tmp_sub, *first_sub;
|
||||||
|
if (option_verbose > 2) {
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Resetting interface %s@%s\n", tmp_ep->name, p->parent->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
first_sub = tmp_ep->sub;
|
||||||
|
tmp_sub = tmp_ep->sub;
|
||||||
|
while (tmp_sub) {
|
||||||
|
if (tmp_sub->owner)
|
||||||
|
ast_softhangup(sub->owner, AST_SOFTHANGUP_DEV);
|
||||||
|
tmp_sub = tmp_sub->next;
|
||||||
|
if (tmp_sub == first_sub)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmp_ep = tmp_ep->next;
|
||||||
|
}
|
||||||
|
} else if (sub->owner) {
|
||||||
ast_softhangup(sub->owner, AST_SOFTHANGUP_DEV);
|
ast_softhangup(sub->owner, AST_SOFTHANGUP_DEV);
|
||||||
}
|
}
|
||||||
transmit_response(sub, "200", req, "OK");
|
transmit_response(sub, "200", req, "OK");
|
||||||
transmit_notify_request(sub, "");
|
/* JS: We dont send NTFY or AUEP to wildcard ep */
|
||||||
/* SC: Audit endpoint.
|
if (strcmp(p->name, p->parent->wcardep) != 0) {
|
||||||
Idea is to prevent lost lines due to race conditions
|
transmit_notify_request(sub, "");
|
||||||
*/
|
/* SC: Audit endpoint.
|
||||||
transmit_audit_endpoint(p);
|
Idea is to prevent lost lines due to race conditions
|
||||||
|
*/
|
||||||
|
transmit_audit_endpoint(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(req->verb, "NTFY")) {
|
} else if (!strcasecmp(req->verb, "NTFY")) {
|
||||||
/* Acknowledge and be sure we keep looking for the same things */
|
/* Acknowledge and be sure we keep looking for the same things */
|
||||||
@@ -2905,9 +2956,11 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
|
|||||||
p->hookstate = MGCP_ONHOOK;
|
p->hookstate = MGCP_ONHOOK;
|
||||||
sub->cxmode = MGCP_CX_RECVONLY;
|
sub->cxmode = MGCP_CX_RECVONLY;
|
||||||
ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
|
ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
|
||||||
|
/* JS: Do we need to send MDCX before a DLCX ?
|
||||||
if (sub->rtp) {
|
if (sub->rtp) {
|
||||||
transmit_modify_request(sub);
|
transmit_modify_request(sub);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (p->transfer && (sub->owner && sub->next->owner) && ((!sub->outgoing) || (!sub->next->outgoing))) {
|
if (p->transfer && (sub->owner && sub->next->owner) && ((!sub->outgoing) || (!sub->next->outgoing))) {
|
||||||
/* We're allowed to transfer, we have two avtive calls and */
|
/* We're allowed to transfer, we have two avtive calls and */
|
||||||
/* we made at least one of the calls. Let's try and transfer */
|
/* we made at least one of the calls. Let's try and transfer */
|
||||||
@@ -2939,12 +2992,12 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
|
|||||||
if (option_verbose > 2) {
|
if (option_verbose > 2) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "MGCP handle_request(%s@%s) set vmwi(+)\n", p->name, p->parent->name);
|
ast_verbose(VERBOSE_PREFIX_3 "MGCP handle_request(%s@%s) set vmwi(+)\n", p->name, p->parent->name);
|
||||||
}
|
}
|
||||||
transmit_notify_request(sub, "vmwi(+)");
|
transmit_notify_request(sub, "L/vmwi(+)");
|
||||||
} else {
|
} else {
|
||||||
if (option_verbose > 2) {
|
if (option_verbose > 2) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "MGCP handle_request(%s@%s) set vmwi(-)\n", p->name, p->parent->name);
|
ast_verbose(VERBOSE_PREFIX_3 "MGCP handle_request(%s@%s) set vmwi(-)\n", p->name, p->parent->name);
|
||||||
}
|
}
|
||||||
transmit_notify_request(sub, "vmwi(-)");
|
transmit_notify_request(sub, "L/vmwi(-)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((strlen(ev) == 1) &&
|
} else if ((strlen(ev) == 1) &&
|
||||||
@@ -3112,9 +3165,9 @@ static void *do_monitor(void *data)
|
|||||||
res = has_voicemail(e);
|
res = has_voicemail(e);
|
||||||
if ((e->msgstate != res) && (e->hookstate == MGCP_ONHOOK) && (!e->rtp)){
|
if ((e->msgstate != res) && (e->hookstate == MGCP_ONHOOK) && (!e->rtp)){
|
||||||
if (res) {
|
if (res) {
|
||||||
transmit_notify_request(e, "vmwi(+)");
|
transmit_notify_request(e, "L/vmwi(+)");
|
||||||
} else {
|
} else {
|
||||||
transmit_notify_request(e, "vmwi(-)");
|
transmit_notify_request(e, "L/vmwi(-)");
|
||||||
}
|
}
|
||||||
e->msgstate = res;
|
e->msgstate = res;
|
||||||
e->onhooktime = thispass;
|
e->onhooktime = thispass;
|
||||||
@@ -3217,9 +3270,9 @@ static struct ast_channel *mgcp_request(char *type, int format, void *data)
|
|||||||
(sub->parent->dnd && (!strlen(sub->parent->call_forward)))) {
|
(sub->parent->dnd && (!strlen(sub->parent->call_forward)))) {
|
||||||
if (sub->parent->hookstate == MGCP_ONHOOK) {
|
if (sub->parent->hookstate == MGCP_ONHOOK) {
|
||||||
if (has_voicemail(sub->parent)) {
|
if (has_voicemail(sub->parent)) {
|
||||||
transmit_notify_request(sub,"vmwi(+)");
|
transmit_notify_request(sub,"L/vmwi(+)");
|
||||||
} else {
|
} else {
|
||||||
transmit_notify_request(sub,"vmwi(-)");
|
transmit_notify_request(sub,"L/vmwi(-)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3351,7 +3404,90 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
|||||||
transfer = ast_true(v->value);
|
transfer = ast_true(v->value);
|
||||||
} else if (!strcasecmp(v->name, "threewaycalling")) {
|
} else if (!strcasecmp(v->name, "threewaycalling")) {
|
||||||
threewaycalling = ast_true(v->value);
|
threewaycalling = ast_true(v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "wcardep")) {
|
||||||
|
/* SC: locate existing endpoint */
|
||||||
|
e = gw->endpoints;
|
||||||
|
while (e) {
|
||||||
|
if (!strcasecmp(v->value, e->name)) {
|
||||||
|
/* endpoint already exists */
|
||||||
|
e->delme = 0;
|
||||||
|
ep_reload = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e = e->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!e) {
|
||||||
|
e = malloc(sizeof(struct mgcp_endpoint));
|
||||||
|
ep_reload = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate wildcard endpoint */
|
||||||
|
e = malloc(sizeof(struct mgcp_endpoint));
|
||||||
|
if (e) {
|
||||||
|
if (!ep_reload) {
|
||||||
|
memset(e, 0, sizeof(struct mgcp_endpoint));
|
||||||
|
strncpy(e->name, v->value, sizeof(e->name) - 1);
|
||||||
|
e->needaudit = 1;
|
||||||
|
}
|
||||||
|
strncpy(gw->wcardep, v->value, sizeof(gw->wcardep)-1);
|
||||||
|
//strcpy(e->name, "aaln/*");
|
||||||
|
/* XXX Should we really check for uniqueness?? XXX */
|
||||||
|
strncpy(e->context, context, sizeof(e->context) - 1);
|
||||||
|
strncpy(e->callerid, callerid, sizeof(e->callerid) - 1);
|
||||||
|
strncpy(e->language, language, sizeof(e->language) - 1);
|
||||||
|
strncpy(e->musicclass, musicclass, sizeof(e->musicclass)-1);
|
||||||
|
strncpy(e->mailbox, mailbox, sizeof(e->mailbox)-1);
|
||||||
|
e->msgstate = -1;
|
||||||
|
e->capability = capability;
|
||||||
|
e->parent = gw;
|
||||||
|
e->dtmfinband = inbanddtmf;
|
||||||
|
e->adsi = adsi;
|
||||||
|
e->type = TYPE_LINE;
|
||||||
|
e->immediate = immediate;
|
||||||
|
e->callgroup=cur_callergroup;
|
||||||
|
e->pickupgroup=cur_pickupgroup;
|
||||||
|
e->callreturn = callreturn;
|
||||||
|
e->cancallforward = cancallforward;
|
||||||
|
e->canreinvite = canreinvite;
|
||||||
|
e->callwaiting = callwaiting;
|
||||||
|
e->transfer = transfer;
|
||||||
|
e->threewaycalling = threewaycalling;
|
||||||
|
e->onhooktime = time(NULL);
|
||||||
|
/* ASSUME we're onhook */
|
||||||
|
e->hookstate = MGCP_ONHOOK;
|
||||||
|
/*snprintf(txident, sizeof(txident), "%08x", rand());*/
|
||||||
|
for (i = 0; i < MAX_SUBS; i++) {
|
||||||
|
sub = malloc(sizeof(struct mgcp_subchannel));
|
||||||
|
if (sub) {
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Allocating subchannel '%d' on %s@%s\n", i, e->name, gw->name);
|
||||||
|
memset(sub, 0, sizeof(struct mgcp_subchannel));
|
||||||
|
sub->parent = e;
|
||||||
|
sub->id = i;
|
||||||
|
snprintf(sub->txident, sizeof(sub->txident), "%08x", rand());
|
||||||
|
/*strcpy(sub->txident, txident);*/
|
||||||
|
sub->cxmode = MGCP_CX_INACTIVE;
|
||||||
|
sub->nat = nat;
|
||||||
|
sub->next = e->sub;
|
||||||
|
e->sub = sub;
|
||||||
|
} else {
|
||||||
|
/* XXX Should find a way to clean up our memory */
|
||||||
|
ast_log(LOG_WARNING, "Out of memory allocating subchannel");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Make out subs a circular linked list so we can always sping through the whole bunch */
|
||||||
|
sub = e->sub;
|
||||||
|
/* find the end of the list */
|
||||||
|
while(sub->next){
|
||||||
|
sub = sub->next;
|
||||||
|
}
|
||||||
|
/* set the last sub->next to the first sub */
|
||||||
|
sub->next = e->sub;
|
||||||
|
|
||||||
|
e->next = gw->endpoints;
|
||||||
|
gw->endpoints = e;
|
||||||
|
}
|
||||||
} else if (!strcasecmp(v->name, "trunk") ||
|
} else if (!strcasecmp(v->name, "trunk") ||
|
||||||
!strcasecmp(v->name, "line")) {
|
!strcasecmp(v->name, "line")) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user