[asterisk-commits] tilghman: trunk r227049 - in /trunk: ./ channels/ configs/ include/asterisk/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 2 16:29:27 CST 2009


Author: tilghman
Date: Mon Nov  2 16:29:19 2009
New Revision: 227049

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227049
Log:
Add PacketCable NCS 1.0 support for Docsis/Eurodocsis networks
(closes issue #12950)
 Reported by: alea-soluciones
 Patches: 
       ncs-pktccops-12950-r206803.patch uploaded by alea-soluciones (license 514)
 Tested by: alea-soluciones, adomjan, urtho, nahuelgreco

Added:
    trunk/configs/res_pktccops.conf.sample   (with props)
    trunk/include/asterisk/pktccops.h   (with props)
    trunk/res/res_pktccops.c   (with props)
Modified:
    trunk/CHANGES
    trunk/channels/chan_mgcp.c
    trunk/configs/mgcp.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=227049&r1=227048&r2=227049
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Nov  2 16:29:19 2009
@@ -67,6 +67,8 @@
  * Added ability to preset channel variables on indicated lines with the setvar
    configuration option.  Also, clearvars=all resets the list of variables back
    to none.
+ * PacketCable NCS 1.0 support has been added for Docsis/Eurodocsis Networks.
+   See configs/res_pktccops.conf for more information.
 
 Applications
 ------------

Modified: trunk/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=227049&r1=227048&r2=227049
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Mon Nov  2 16:29:19 2009
@@ -71,6 +71,7 @@
 #include "asterisk/abstract_jb.h"
 #include "asterisk/event.h"
 #include "asterisk/chanvars.h"
+#include "asterisk/pktccops.h"
 
 /*
  * Define to work around buggy dlink MGCP phone firmware which
@@ -150,6 +151,9 @@
 
 static int dtmfmode = 0;
 static int nat = 0;
+static int ncs = 0;
+static int pktcgatealloc = 0;
+static int hangupongateremove = 0;
 
 static ast_group_t cur_callergroup = 0;
 static ast_group_t cur_pickupgroup = 0;
@@ -296,6 +300,8 @@
 	int iseq;                      /*!< Not used? RTP? */
 	int outgoing;
 	int alreadygone;
+	int sdpsent;
+	struct cops_gate *gate;
 	struct mgcp_subchannel *next;  /*!< for out circular linked list */
 };
 
@@ -338,6 +344,9 @@
 	int hidecallerid;
 	int dtmfmode;
 	int amaflags;
+	int ncs;
+	int pktcgatealloc;
+	int hangupongateremove;
 	int type;
 	int slowsequence;			/*!< MS: Sequence the endpoint as a whole */
 	int group;
@@ -391,9 +400,10 @@
 	ast_mutex_t msgs_lock;     /*!< queue lock */  
 	int retransid;             /*!< retrans timer id */
 	int delme;                 /*!< needed for reload */
+	int realtime;
 	struct mgcp_response *responses;
 	struct mgcp_gateway *next;
-} *gateways;
+} *gateways = NULL;
 
 AST_MUTEX_DEFINE_STATIC(mgcp_reload_lock);
 static int mgcp_reloading = 0;
@@ -409,6 +419,7 @@
 static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp_request *req, char *msgrest);
 static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
 static int transmit_modify_request(struct mgcp_subchannel *sub);
+static int transmit_connect(struct mgcp_subchannel *sub);
 static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername);
 static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, int codecs);
 static int transmit_connection_del(struct mgcp_subchannel *sub);
@@ -431,14 +442,18 @@
 static int mgcp_senddigit_begin(struct ast_channel *ast, char digit);
 static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
 static int mgcp_devicestate(void *data);
-static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp);
+static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp, char *tone);
+static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp);
+static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v);
+static int mgcp_alloc_pktcgate(struct mgcp_subchannel *sub);
+static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
 static struct ast_variable *add_var(const char *buf, struct ast_variable *list);
 static struct ast_variable *copy_vars(struct ast_variable *src);
 
 static const struct ast_channel_tech mgcp_tech = {
 	.type = "MGCP",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_ULAW,
+	.capabilities = AST_FORMAT_ULAW | AST_FORMAT_ALAW,
 	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
 	.requester = mgcp_request,
 	.devicestate = mgcp_devicestate,
@@ -452,6 +467,7 @@
 	.send_digit_begin = mgcp_senddigit_begin,
 	.send_digit_end = mgcp_senddigit_end,
 	.bridge = ast_rtp_instance_bridge,
+ 	.func_channel_read = acf_channel_read,
 };
 
 static void mwi_event_cb(const struct ast_event *event, void *userdata)
@@ -778,12 +794,15 @@
 			ast_mutex_lock(l);
 			q = sub->cx_queue;
 			/* delete pending cx cmds */
-			while (q) {
-				r = q->next;
-				ast_free(q);
-				q = r;
-			}
-			*queue = NULL;
+			/* bugy sb5120 */
+			if(!sub->parent->ncs) {
+				while (q) {
+					r = q->next;
+					ast_free(q);
+					q = r;
+				}
+				*queue = NULL;
+			}
 			break;
 
 		case MGCP_CMD_CRCX:
@@ -875,7 +894,7 @@
 				ast_verb(3, "MGCP distinctive callwait %s\n", tone);
 			}
 		} else {
-			ast_copy_string(tone, "L/wt", sizeof(tone));
+			ast_copy_string(tone, (p->ncs ? "L/wt1" : "L/wt"), sizeof(tone));
 			if (mgcpdebug) {
 				ast_verb(3, "MGCP normal callwait %s\n", tone);
 			}
@@ -906,6 +925,7 @@
 	res = 0;
 	sub->outgoing = 1;
 	sub->cxmode = MGCP_CX_RECVONLY;
+	ast_setstate(ast, AST_STATE_RINGING);
 	if (p->type == TYPE_LINE) {
 		if (!sub->rtp) {
 			start_rtp(sub);
@@ -932,7 +952,6 @@
 		res = -1;
 	}
 	ast_mutex_unlock(&sub->lock);
-	ast_queue_control(ast, AST_CONTROL_RINGING);
 	return res;
 }
 
@@ -969,6 +988,21 @@
 	}
 
 	sub->owner = NULL;
+
+	/* for deleting gate */
+	if (p->pktcgatealloc && sub->gate) {
+		sub->gate->gate_open = NULL;
+		sub->gate->gate_remove = NULL;
+		sub->gate->got_dq_gi = NULL;
+		sub->gate->tech_pvt = NULL;
+		if (sub->gate->state == GATE_ALLOC_PROGRESS || sub->gate->state == GATE_ALLOCATED) {
+			ast_pktccops_gate_alloc(GATE_DEL, sub->gate, 0, 0, 0, 0, 0, 0, NULL, NULL);
+		} else {
+			sub->gate->deltimer = time(NULL) + 5;
+		}
+		sub->gate = NULL;
+	}
+
 	if (!ast_strlen_zero(sub->cxident)) {
 		transmit_connection_del(sub);
 	}
@@ -976,7 +1010,8 @@
 	if ((sub == p->sub) && sub->next->owner) {
 		if (p->hookstate == MGCP_OFFHOOK) {
 			if (sub->next->owner && ast_bridged_channel(sub->next->owner)) {
-				transmit_notify_request_with_callerid(p->sub, "L/wt", ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
+				// ncs fix!
+				transmit_notify_request_with_callerid(p->sub, (p->ncs ? "L/wt1" : "L/wt"), ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
 			}
 		} else {
 			/* set our other connection as the primary and swith over to it */
@@ -989,7 +1024,7 @@
 		}
 
 	} else if ((sub == p->sub->next) && p->hookstate == MGCP_OFFHOOK) {
-		transmit_notify_request(sub, "L/v");
+		transmit_notify_request(sub, p->ncs ? "" : "L/v");
 	} else if (p->hookstate == MGCP_OFFHOOK) {
 		transmit_notify_request(sub, "L/ro");
 	} else {
@@ -1062,7 +1097,7 @@
 	mg = gateways;
 	while(mg) {
 		me = mg->endpoints;
-		ast_cli(a->fd, "Gateway '%s' at %s (%s)\n", mg->name, mg->addr.sin_addr.s_addr ? ast_inet_ntoa(mg->addr.sin_addr) : ast_inet_ntoa(mg->defaddr.sin_addr), mg->dynamic ? "Dynamic" : "Static");
+		ast_cli(a->fd, "Gateway '%s' at %s (%s%s)\n", mg->name, mg->addr.sin_addr.s_addr ? ast_inet_ntoa(mg->addr.sin_addr) : ast_inet_ntoa(mg->defaddr.sin_addr), mg->realtime ? "Realtime, " : "", mg->dynamic ? "Dynamic" : "Static");
 		while(me) {
 			ast_cli(a->fd, "   -- '%s@%s in '%s' is %s\n", me->name, mg->name, me->context, me->sub->owner ? "active" : "idle");
 			if (me->chanvars) {
@@ -1264,11 +1299,17 @@
 		if (!(frame->subclass & ast->nativeformats)) {
 			ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
 				frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
-			return -1;
+			/* return -1; */
 		}
 	}
 	if (sub) {
 		ast_mutex_lock(&sub->lock);
+		if(!sub->sdpsent && sub->gate) {
+			if(sub->gate->state == GATE_ALLOCATED) {
+				ast_log(LOG_DEBUG, "GATE ALLOCATED, sending sdp\n");
+				transmit_modify_with_sdp(sub, NULL, 0);
+			}
+		}
 		if ((sub->parent->sub == sub) || !sub->parent->singlepath) {
 			if (sub->rtp) {
 				res =  ast_rtp_instance_write(sub->rtp, frame);
@@ -1328,12 +1369,18 @@
 		ast_log(LOG_DEBUG, "Stopping DTMF using inband/hybrid\n");
 		res = -1; /* Tell Asterisk to stop inband indications */
 	} else if (p->dtmfmode & MGCP_DTMF_RFC2833) {
-		ast_log(LOG_DEBUG, "Stopping DTMF using RFC2833\n");
-		tmp[0] = 'D';
-		tmp[1] = '/';
-		tmp[2] = digit;
-		tmp[3] = '\0';
-		transmit_notify_request(sub, tmp);
+
+  		ast_log(LOG_DEBUG, "Stopping DTMF using RFC2833\n");
+ 		if (sub->parent->ncs) {
+ 			tmp[0] = digit;
+ 			tmp[1] = '\0';
+ 		} else {
+ 			tmp[0] = 'D';
+ 			tmp[1] = '/';
+ 			tmp[2] = digit;
+ 			tmp[3] = '\0';
+ 		}
+  		transmit_notify_request(sub, tmp);
                 ast_rtp_instance_dtmf_end(sub->rtp, digit);
 	} else {
 		ast_log(LOG_ERROR, "Don't know about DTMF_MODE %d\n", p->dtmfmode);
@@ -1447,14 +1494,15 @@
 #ifdef DLINK_BUGGY_FIRMWARE	
 		transmit_notify_request(sub, "rt");
 #else
-		transmit_notify_request(sub, "G/rt");
+		if(!sub->sdpsent) /* will hide the inband progress!!! */
+			transmit_notify_request(sub, sub->parent->ncs ? "L/rt" : "G/rt");
 #endif		
 		break;
 	case AST_CONTROL_BUSY:
 		transmit_notify_request(sub, "L/bz");
 		break;
 	case AST_CONTROL_CONGESTION:
-		transmit_notify_request(sub, "G/cg");
+		transmit_notify_request(sub, sub->parent->ncs ? "L/cg" : "G/cg");
 		break;
 	case AST_CONTROL_HOLD:
 		ast_moh_start(ast, data, NULL);
@@ -1465,6 +1513,9 @@
 	case AST_CONTROL_SRCUPDATE:
 		ast_rtp_instance_new_source(sub->rtp);
 		break;
+	case AST_CONTROL_PROGRESS:
+	case AST_CONTROL_PROCEEDING:
+		transmit_modify_request(sub);
 	case -1:
 		transmit_notify_request(sub, "");
 		break;
@@ -1591,7 +1642,7 @@
 	return "";
 }
 
-static char *__get_header(struct mgcp_request *req, char *name, int *start)
+static char *__get_header(struct mgcp_request *req, char *name, int *start, char *def)
 {
 	int x;
 	int len = strlen(name);
@@ -1607,13 +1658,13 @@
 		}
 	}
 	/* Don't return NULL, so get_header is always a valid pointer */
-	return "";
+	return def;
 }
 
 static char *get_header(struct mgcp_request *req, char *name)
 {
 	int start = 0;
-	return __get_header(req, name, &start);
+	return __get_header(req, name, &start, "");
 }
 
 /*! \brief get_csv: (SC:) get comma separated value */
@@ -1636,6 +1687,100 @@
 		s = NULL, *next = NULL;
 
 	return s;
+}
+
+static struct mgcp_gateway *find_realtime_gw(char *name, char *at, struct sockaddr_in *sin)
+{
+	struct mgcp_gateway *g = NULL;
+	struct ast_variable *mgcpgwconfig = NULL;
+	struct ast_variable *mgcpepconfig = NULL;
+	struct ast_variable *gwv, *epname = NULL;
+	struct mgcp_endpoint *e;
+	char *c = NULL, *line;
+	char lines[256];
+	char tmp[4096];
+	int i, j;
+	if(mgcpdebug) ast_verbose ("*** find Realtime MGCPGW\n");
+
+	if (!(i = ast_check_realtime("mgcpgw")) || !(j = ast_check_realtime("mgcpep")))
+		return NULL;
+
+	if(!at || !strlen(at)) {
+		ast_log(LOG_DEBUG, "null gw name\n");
+		return NULL;
+	}
+
+	mgcpgwconfig = ast_load_realtime("mgcpgw", "name", at, NULL);
+	if(!mgcpgwconfig)
+		return NULL;
+
+	lines[0] = '\0';
+	gwv = mgcpgwconfig;
+	while (gwv) {
+		if(!strcasecmp(gwv->name, "lines")) {
+			strcpy(lines, gwv->value);
+			break;
+		}
+		gwv = gwv->next;
+	}
+	gwv = mgcpgwconfig;
+	while (gwv->next) {
+		gwv = gwv->next;
+	}
+	if (!ast_strlen_zero(lines)) {
+		c = lines;
+		line = tmp;
+		while(*c) {
+			*line = *c;
+			if(*c == ',') {
+					*(line) = 0;
+					mgcpepconfig = ast_load_realtime("mgcpep", "name", at, "line", tmp, NULL);
+					gwv->next = mgcpepconfig;
+
+					while(gwv->next) {
+						if(!strcasecmp(gwv->next->name, "line")) {
+							epname = gwv->next;
+							gwv->next = gwv->next->next;
+						} else {
+							gwv = gwv->next;
+						}
+					}
+						/* moving the line var to the end */
+					if(epname) {
+						gwv->next = epname;
+						epname->next = NULL;
+						gwv = gwv->next;
+					}
+					mgcpepconfig = NULL;
+					line = tmp;
+			} else {
+				line ++;
+			}
+			c++;
+		}
+	}
+	gwv = mgcpgwconfig;
+	while(gwv) {
+		ast_log(LOG_DEBUG, "MGCP Realtime var: %s => %s\n", gwv->name, gwv->value);
+		gwv = gwv->next;
+	}
+
+	if(mgcpgwconfig) { 
+		g = build_gateway(at, mgcpgwconfig);
+		ast_variables_destroy(mgcpgwconfig);
+	}
+	if(g) {
+		g->next = gateways;
+		g->realtime = 1;
+		gateways = g;
+		e = g->endpoints;
+		while(e) {
+			transmit_audit_endpoint(e);
+			e->needaudit = 0;
+			e = e->next;
+		}
+	}
+	return g;
 }
 
 static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, struct sockaddr_in *sin)
@@ -1663,6 +1808,8 @@
 			*c = '\0';
 	}
 	g = gateways;
+	if(!g)
+		g = find_realtime_gw(name, at, sin);
 	while(g) {
 		if ((!name || !strcasecmp(g->name, at)) && 
 		    (sin || g->addr.sin_addr.s_addr || g->defaddr.sin_addr.s_addr)) {
@@ -1687,11 +1834,17 @@
 			else if (!name && sin) {
  				if ((g->addr.sin_addr.s_addr != sin->sin_addr.s_addr) ||
 				    (g->addr.sin_port != sin->sin_port)) {
-					g = g->next;
+					if(!g->next)
+						g = find_realtime_gw(name, at, sin);
+					else
+						g = g->next;
 					continue;
 				}
 			} else {
-				g = g->next;
+				if(!g->next)
+					g = find_realtime_gw(name, at, sin);
+				else
+					g = g->next;
 				continue;
 			}
 			/* SC */
@@ -1736,7 +1889,10 @@
 				break;
 			}
 		}
-		g = g->next;
+		if(!g->next)
+			g = find_realtime_gw(name, at, sin);
+		else
+			g = g->next;
 	}
 	ast_mutex_unlock(&gatelock);
 	if (!sub) {
@@ -2009,9 +2165,9 @@
 	req->header[req->headers] = req->data + req->len;
 	/* check if we need brackets around the gw name */
 	if (p->parent->isnamedottedip)
-		snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %d %s@[%s] MGCP 1.0\r\n", verb, oseq, p->name, p->parent->name);
+		snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %d %s@[%s] MGCP 1.0%s\r\n", verb, oseq, p->name, p->parent->name, p->ncs ? " NCS 1.0" : "");
 	else
-		snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %d %s@%s MGCP 1.0\r\n", verb, oseq, p->name, p->parent->name);
++		snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %d %s@%s MGCP 1.0%s\r\n", verb, oseq, p->name, p->parent->name, p->ncs ? " NCS 1.0" : "");
 	req->len += strlen(req->header[req->headers]);
 	if (req->headers < MGCP_MAX_HEADERS)
 		req->headers++;
@@ -2043,6 +2199,9 @@
 	struct mgcp_request resp;
 	struct mgcp_endpoint *p = sub->parent;
 	struct mgcp_response *mgr;
+
+	if(!sub)
+		return -1;
 
 	respprep(&resp, p, msg, req, msgrest);
 	mgr = ast_calloc(1, sizeof(*mgr) + resp.len + 1);
@@ -2158,8 +2317,8 @@
 	struct mgcp_request resp;
 	char local[256];
 	char tmp[80];
+	struct mgcp_endpoint *p = sub->parent;
 	int x;
-	struct mgcp_endpoint *p = sub->parent;
 
 	if (ast_strlen_zero(sub->cxident) && rtp) {
 		/* We don't have a CXident yet, store the destination and
@@ -2167,13 +2326,28 @@
 		ast_rtp_instance_get_remote_address(rtp, &sub->tmpdest);
 		return 0;
 	}
-	ast_copy_string(local, "p:20", sizeof(local));
+ 	ast_copy_string(local, "e:on, s:off, p:20", sizeof(local));
 	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
 		if (p->capability & x) {
 			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
 			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
 		}
 	}
+ 
+ 	if (sub->gate) {
+ 		if(sub->gate->state == GATE_ALLOCATED || sub->gate->state == GATE_OPEN) {
+ 			snprintf(tmp, sizeof(tmp), ", dq-gi:%x", sub->gate->gateid);
+ 			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+ 			sub->sdpsent = 1;
+ 		} else {
+ 			/* oops wait */
+ 			ast_log(LOG_DEBUG, "Waiting for opened gate...\n");
+ 			sub->sdpsent = 0;
+ 			return 0;
+ 		}
+ 	}
+ 
+
 	reqprep(&resp, p, "MDCX");
 	add_header(&resp, "C", sub->callid);
 	add_header(&resp, "L", local);
@@ -2193,33 +2367,125 @@
 {
 	struct mgcp_request resp;
 	char local[256];
-	char tmp[80];
+	char tmp[80];	
 	int x;
 	struct mgcp_endpoint *p = sub->parent;
-
-	ast_copy_string(local, "p:20", sizeof(local));
+	
+ 	if (mgcpdebug) {
+ 		ast_verb(3, "Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
+			 p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
+ 	}
+ 
+ 	ast_copy_string(local, "e:on, s:off, p:20", sizeof(local));
+	
 	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
 		if (p->capability & x) {
 			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
 			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
 		}
 	}
-	if (mgcpdebug) {
-		ast_verb(3, "Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
-			p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
-	}
-	reqprep(&resp, p, "CRCX");
-	add_header(&resp, "C", sub->callid);
-	add_header(&resp, "L", local);
-	add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
-	/* X header should not be sent. kept for compatibility */
-	add_header(&resp, "X", sub->txident);
-	/*add_header(&resp, "S", "");*/
-	add_sdp(&resp, sub, rtp);
-	/* fill in new fields */
-	resp.cmd = MGCP_CMD_CRCX;
-	resp.trid = oseq;
-	return send_request(p, sub, &resp, oseq);  /* SC */
+	
+  	if (sub->gate) {
+  		if(sub->gate->state == GATE_ALLOCATED) {
+  			snprintf(tmp, sizeof(tmp), ", dq-gi:%x", sub->gate->gateid);
+  			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+  		}
+  	}
+ 	sub->sdpsent = 1;
+ 	reqprep(&resp, p, "CRCX");
+ 	add_header(&resp, "C", sub->callid);
+ 	add_header(&resp, "L", local);
+ 	add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
+ 	/* X header should not be sent. kept for compatibility */
+ 	add_header(&resp, "X", sub->txident);
+ 	/*add_header(&resp, "S", "");*/
+ 	add_sdp(&resp, sub, rtp);
+ 	/* fill in new fields */
+ 	resp.cmd = MGCP_CMD_CRCX;
+ 	resp.trid = oseq;
+ 	return send_request(p, sub, &resp, oseq);  /* SC */
+}
+
+
+ 
+static int mgcp_pktcgate_remove(struct cops_gate *gate)
+{
+ 	struct mgcp_subchannel *sub = gate->tech_pvt;
+ 	if(sub) {
+ 		ast_mutex_lock(&sub->lock);
+ 		ast_log(LOG_DEBUG, "Pktc: gate 0x%x deleted\n", gate->gateid);
+ 		if(sub->gate->state != GATE_CLOSED && sub->parent->hangupongateremove) {
+ 			sub->gate = NULL;
+ 			if(sub->owner) {
+ 				ast_softhangup(sub->owner, AST_CAUSE_REQUESTED_CHAN_UNAVAIL);
+ 				ast_channel_unlock(sub->owner);
+ 			}
+ 		} else {
+ 			sub->gate = NULL;
+ 		}
+ 		ast_mutex_unlock(&sub->lock);
+ 	}
+ 	return 1;
+}
+
+static int mgcp_pktcgate_open(struct cops_gate *gate)
+{
+ 	struct mgcp_subchannel *sub = gate->tech_pvt;
+ 	if(sub) {
+ 		ast_mutex_lock(&sub->lock);
+		ast_log(LOG_DEBUG, "Pktc: gate 0x%x open\n", gate->gateid);
+		if (!sub->sdpsent) transmit_modify_with_sdp(sub, NULL, 0);
+ 		ast_mutex_unlock(&sub->lock);
+ 	}
+ 	return 1;
+}
+
+static int mgcp_alloc_pktcgate(struct mgcp_subchannel *sub)
+{
+  	struct mgcp_endpoint *p = sub->parent;
+ 	sub->gate = ast_pktccops_gate_alloc(GATE_SET, NULL, ntohl(p->parent->addr.sin_addr.s_addr),
+					8, 128000, 232, 0, 0, NULL, &mgcp_pktcgate_remove);
+	
+ 	if(!sub->gate)
+ 		return 0;
+ 	sub->gate->tech_pvt = sub;
+ 	sub->gate->gate_open = &mgcp_pktcgate_open;
+ 	return 1;
+}
+ 
+static int transmit_connect(struct mgcp_subchannel *sub)
+{
+ 	struct mgcp_request resp;
+ 	char local[256];
+ 	char tmp[80];
+ 	int x;
+ 	struct mgcp_endpoint *p = sub->parent;
+	
+ 	ast_copy_string(local, "p:20, s:off, e:on", sizeof(local));
+	
+  	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+  		if (p->capability & x) {
+  			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
+  			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+  		}
+  	}
+	
+  	if (mgcpdebug) {
+ 		ast_verbose(VERBOSE_PREFIX_3 "Creating connection for %s@%s-%d in cxmode: %s callid: %s\n", 
+			    p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
+  	}
+ 	sub->sdpsent = 0;
+  	reqprep(&resp, p, "CRCX");
+  	add_header(&resp, "C", sub->callid);
+  	add_header(&resp, "L", local);
+ 	add_header(&resp, "M", "inactive");
+  	/* X header should not be sent. kept for compatibility */
+  	add_header(&resp, "X", sub->txident);
+  	/*add_header(&resp, "S", "");*/
+  	/* fill in new fields */
+  	resp.cmd = MGCP_CMD_CRCX;
+  	resp.trid = oseq;
+  	return send_request(p, sub, &resp, oseq);  /* SC */
 }
 
 static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone)
@@ -2239,7 +2505,7 @@
 		add_header(&resp, "R", "L/hd(N)");
 		break;
 	case MGCP_OFFHOOK:
-		add_header_offhook(sub, &resp);
+		add_header_offhook(sub, &resp, tone);
 		break;
 	}
 	if (!ast_strlen_zero(tone)) {
@@ -2281,7 +2547,7 @@
 		add_header(&resp, "R", "L/hd(N)");
 		break;
 	case MGCP_OFFHOOK:
-		add_header_offhook(sub, &resp);
+		add_header_offhook(sub, &resp, tone);
 		break;
 	}
 	if (!ast_strlen_zero(tone2)) {
@@ -2301,6 +2567,9 @@
 {
 	struct mgcp_request resp;
 	struct mgcp_endpoint *p = sub->parent;
+	int x, fc;
+	char local[256];
+	char tmp[80];
 
 	if (ast_strlen_zero(sub->cxident)) {
 		/* We don't have a CXident yet, store the destination and
@@ -2311,8 +2580,36 @@
 		ast_verb(3, "Modified %s@%s-%d with new mode: %s on callid: %s\n",
 			p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
 	}
+
+	ast_copy_string(local, "", sizeof(local));
+	for (x=1;x<= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+		if (p->capability & x) {
+			if(p->ncs && !fc) {
+				p->capability = x; /* sb5120e bug */
+				break;
+			} else {
+				fc = 0;
+				snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
+			}
+			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+		}
+	}
+
+	if(!sub->sdpsent) {
+		if (sub->gate) {
+			if(sub->gate->state == GATE_ALLOCATED || sub->gate->state == GATE_OPEN) {
+				snprintf(tmp, sizeof(tmp), ", dq-gi:%x", sub->gate->gateid);
+				strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+			} else {
+					/* we still dont have gateid wait */
+				return 0;
+			}
+		}
+	}
+
 	reqprep(&resp, p, "MDCX");
 	add_header(&resp, "C", sub->callid);
+	if(!sub->sdpsent) add_header(&resp, "L", local);
 	add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
 	/* X header should not be sent. kept for compatibility */
 	add_header(&resp, "X", sub->txident);
@@ -2322,8 +2619,12 @@
 		add_header(&resp, "R", "L/hd(N)");
 		break;
 	case MGCP_OFFHOOK:
-		add_header_offhook(sub, &resp);
+		add_header_offhook(sub, &resp, "");
 		break;
+	}
+	if(!sub->sdpsent) {
+		add_sdp(&resp, sub, NULL);
+		sub->sdpsent = 1;
 	}
 	/* fill in new fields */
 	resp.cmd = MGCP_CMD_MDCX;
@@ -2332,15 +2633,35 @@
 }
 
 
-static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp)
-{
-	struct mgcp_endpoint *p = sub->parent;
-
-	if (p && p->sub && p->sub->owner && p->sub->owner->_state >= AST_STATE_RINGING && (p->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)))
-		add_header(resp, "R", "L/hu(N),L/hf(N)");
-	else
-		add_header(resp, "R", "L/hu(N),L/hf(N),D/[0-9#*](N)");
-}
+static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp, char *tone)
+{
+        struct mgcp_endpoint *p = sub->parent;
+	char tone_indicate_end = 0;
+ 
+	/* We also should check the tone to indicate, because it have no sense
+	   to request notify D/[0-9#*] (dtmf keys) if we are sending congestion
+	   tone for example G/cg */
+	if (p && (!strcasecmp(tone, (p->ncs ? "L/ro" : "G/cg")))) {
+	  tone_indicate_end = 1;
+	}
+ 
+	if (p && p->sub && p->sub->owner &&
+	     p->sub->owner->_state >= AST_STATE_RINGING &&
+            (p->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID))) {
+	    add_header(resp, "R", "L/hu(N),L/hf(N)");
+
+        } else if (!tone_indicate_end){
+	    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)"));
+	} else {
+	    if (mgcpdebug) {
+	        ast_verbose("We don't want more digits if we will end the call\n");
+	    }
+        add_header(resp, "R", "L/hu(N),L/hf(N)");
+	}
+}
+
+
+
 
 static int transmit_audit_endpoint(struct mgcp_endpoint *p)
 {
@@ -2507,6 +2828,10 @@
 			break;
 		}
 		if (sub) {
+			if (!sub->cxident[0] && (req->cmd == MGCP_CMD_CRCX)) {
+			    ast_log(LOG_NOTICE, "DLCX for all connections on %s due to error %d\n", gw->name, result);
+			    transmit_connection_del(sub);
+			}
 			if (sub->owner) {
 				ast_log(LOG_NOTICE, "Terminating on result %d from %s@%s-%d\n", 
 					result, p->name, p->parent->name, sub ? sub->id:-1);
@@ -2530,6 +2855,15 @@
 	}
 
 	if (resp) {
+		/* responseAck: */
+		if (result == 200 && (req->cmd == MGCP_CMD_CRCX || req->cmd == MGCP_CMD_MDCX)) {
+				if (sub) { 
+					transmit_response(sub, "000", resp, "OK");
+					if (sub->owner && sub->owner->_state == AST_STATE_RINGING) {
+						ast_queue_control(sub->owner, AST_CONTROL_RINGING);
+					}
+				}
+		}
 		if (req->cmd == MGCP_CMD_CRCX) {
 			if ((c = get_header(resp, "I"))) {
 				if (!ast_strlen_zero(c) && sub) {
@@ -2642,7 +2976,14 @@
 	/* Make a call*ID */
         snprintf(sub->callid, sizeof(sub->callid), "%08lx%s", ast_random(), sub->txident);
 	/* Transmit the connection create */
-	transmit_connect_with_sdp(sub, NULL);
+	if(!sub->parent->pktcgatealloc) {
+		transmit_connect_with_sdp(sub, NULL);
+	} else {
+		transmit_connect(sub);
+		sub->gate = NULL;
+		if(!mgcp_alloc_pktcgate(sub))
+			mgcp_queue_hangup(sub);
+	}
 	ast_mutex_unlock(&sub->lock);
 }
 
@@ -2661,6 +3002,7 @@
 	len = strlen(p->dtmf_buf);
 
 	while(len < AST_MAX_EXTENSION-1) {
+		ast_log(LOG_DEBUG, "Dtmf buffer '%s' for '%s@%s'\n", p->dtmf_buf, p->name, p->parent->name);
 		res = 1;  /* Assume that we will get a digit */
 		while (strlen(p->dtmf_buf) == len){
 			ast_safe_sleep(chan, loop_pause);
@@ -2707,6 +3049,7 @@
 					/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 					ast_indicate(chan, -1);
 					ast_copy_string(chan->exten, p->dtmf_buf, sizeof(chan->exten));
+					chan->cid.cid_dnid = ast_strdup(p->dtmf_buf);
 					memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 					ast_set_callerid(chan,
 						p->hidecallerid ? "" : p->cid_num,
@@ -2723,7 +3066,7 @@
 						ast_log(LOG_WARNING, "PBX exited non-zero\n");
 						/*res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_CONGESTION);*/
 						/*transmit_notify_request(p, "nbz", 1);*/
-						transmit_notify_request(sub, "G/cg");
+						transmit_notify_request(sub, p->ncs ? "L/cg" : "G/cg");
 					}
 					return NULL;
 				}
@@ -2735,7 +3078,7 @@
 		} else if (res == 0) {
 			ast_debug(1, "not enough digits (and no ambiguous match)...\n");
 			/*res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_CONGESTION);*/
-			transmit_notify_request(sub, "G/cg");
+			transmit_notify_request(sub, p->ncs ? "L/cg" : "G/cg");
 			/*dahdi_wait_event(p->subs[index].zfd);*/
 			ast_hangup(chan);
 			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
@@ -2757,7 +3100,7 @@
 			if (ast_pickup_call(chan)) {
 				ast_log(LOG_WARNING, "No call pickup possible...\n");
 				/*res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_CONGESTION);*/
-				transmit_notify_request(sub, "G/cg");
+				transmit_notify_request(sub, p->ncs ? "L/cg" : "G/cg");
 			}
 			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			ast_hangup(chan);
@@ -2983,12 +3326,12 @@
 #ifdef DLINK_BUGGY_FIRMWARE	
 				transmit_notify_request(sub, "rt");
 #else
-				transmit_notify_request(sub, "G/rt");
+ 				transmit_notify_request(sub, p->ncs ? "L/rt" : "G/rt");
 #endif		
 				c = mgcp_new(sub, AST_STATE_RING, NULL);
 				if (!c) {
 					ast_log(LOG_WARNING, "Unable to start PBX on channel %s@%s\n", p->name, p->parent->name);
-					transmit_notify_request(sub, "G/cg");
++ 					transmit_notify_request(sub, p->ncs ? "L/cg" : "G/cg");
 					ast_hangup(c);
 				}
 			} else {
@@ -3105,6 +3448,13 @@
 		if (!strcasecmp(ev, "hd")) {
 			p->hookstate = MGCP_OFFHOOK;
 			sub->cxmode = MGCP_CX_SENDRECV;
+			
+			if (p) {
+			  /* When the endpoint have a Off hook transition we allways
+			     starts without any previous dtmfs */
+			  memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
+			}
+
 			handle_hd_hf(sub, ev);
 		} else if (!strcasecmp(ev, "hf")) {
 			/* We can assume we are offhook if we received a hookflash */
@@ -3250,7 +3600,7 @@
 				if (sub->next->owner)
 					mgcp_queue_frame(sub->next, &f);
 				ast_mutex_unlock(&sub->next->lock);
-				if (strstr(p->curtone, "wt") && (ev[0] == 'A')) {
+				if (strstr(p->curtone, (p->ncs ? "wt1" : "wt")) && (ev[0] == 'A')) {
 					memset(p->curtone, 0, sizeof(p->curtone));
 				}
 			} else {
@@ -3336,6 +3686,10 @@
 	}
 
 	if (sscanf(req.verb, "%30d", &result) && sscanf(req.identifier, "%30d", &ident)) {
+		if (result < 200) {
+			ast_debug(1, "Ignoring provisional response on transaction %d\n", ident);
+			return 1;
+		}
 		/* Try to find who this message is for, if it's important */
 		sub = find_subchannel_and_lock(NULL, ident, &sin);
 		if (sub) {
@@ -3392,13 +3746,76 @@
 
 static int *mgcpsock_read_id = NULL;
 
+static int mgcp_prune_realtime_gateway(struct mgcp_gateway *g){
+	struct mgcp_endpoint *enext, *e = g->endpoints;
+	struct mgcp_subchannel *s, *sub;
+	int i, prune = 1;
+
+	if (g->ha || !g->realtime || ast_mutex_trylock(&g->msgs_lock) || g->msgs) {
+		ast_mutex_unlock(&g->msgs_lock);
+		return 0;
+	}
+
+	while(e) {
+		ast_mutex_lock(&e->lock);
+		if(e->dsp || ast_mutex_trylock(&e->rqnt_queue_lock) || ast_mutex_trylock(&e->cmd_queue_lock)) {
+			prune = 0;
+		} else if( e->rqnt_queue || e->cmd_queue ) {
+			prune = 0;
+		}
+		s = e->sub;
+		for (i = 0; (i < MAX_SUBS) && s; i++) {
+			ast_mutex_lock(&s->lock);
+			if (!ast_strlen_zero(s->cxident) || s->rtp || ast_mutex_trylock(&s->cx_queue_lock) || s->gate) {
+				prune = 0;
+			} else if (s->cx_queue) {
+				prune = 0;
+			}
+			s = s->next;
+		}
+		e = e->next;
+	}
+
+	e = g->endpoints;
+
+	while(e) {
+		sub = e->sub;
+		enext = e->next; 
+		for (i = 0; (i < MAX_SUBS) && sub; i++) {
+			s = sub;
+			sub = sub->next;
+			ast_mutex_unlock(&s->lock);
+			ast_mutex_unlock(&s->cx_queue_lock);
+			if(prune) {
+				ast_mutex_destroy(&s->lock);
+				ast_mutex_destroy(&s->cx_queue_lock);
+				free(s);
+			}
+		}
+		ast_mutex_unlock(&e->lock);
+		ast_mutex_unlock(&e->rqnt_queue_lock);
+		ast_mutex_unlock(&e->cmd_queue_lock);
+		if(prune) {
+			ast_mutex_destroy(&e->lock);
+			ast_mutex_destroy(&e->rqnt_queue_lock);
+			ast_mutex_destroy(&e->cmd_queue_lock);
+			free(e);
+		}
+		e = enext;
+	}
+	if(prune) ast_log(LOG_DEBUG, "***** MGCP REALTIME PRUNE GW: %s\n", g->name);
+	return prune;
+}
+
 static void *do_monitor(void *data)
 {
 	int res;
 	int reloading;
+	struct mgcp_gateway *g, *gprev, *gnext;
 	/*struct mgcp_gateway *g;*/
 	/*struct mgcp_endpoint *e;*/
 	/*time_t thispass = 0, lastpass = 0;*/
+	time_t lastrun = 0;
 
 	/* Add an I/O event to our UDP socket */
 	if (mgcpsock > -1) 
@@ -3458,6 +3875,36 @@
 			g = g->next;
 		}
 #endif
+		/* pruning unused realtime gateways, running in every 60 seconds*/
+		if(time(NULL) > (lastrun + 60)) {
+			ast_mutex_lock(&gatelock);
+			g = gateways;
+			gprev = NULL;
+			while(g) {
+				gnext = g->next;
+				if(g->realtime) {
+					if(mgcp_prune_realtime_gateway(g)) {
+						if(gprev) {
+							gprev->next = gnext;
+							gprev = g;
+						} else {
+							gateways = g->next;
+						}
+						ast_mutex_unlock(&g->msgs_lock);
+						ast_mutex_destroy(&g->msgs_lock);
+						free(g);
+					} else {
+						ast_mutex_unlock(&g->msgs_lock);
+						gprev = g;
+					}
+				} else {
+					gprev = g;
+				}
+				g = gnext;
+			}
+			ast_mutex_unlock(&gatelock);
+			lastrun = time(NULL);
+		}
 		/* Okay, now that we know what to do, release the network lock */
 		ast_mutex_unlock(&netlock);
 		/* And from now on, we're okay to be killed, so release the monitor lock as well */
@@ -3519,7 +3966,7 @@
 	format &= capability;
 	if (!format) {
 		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
-		return NULL;
+		/*return NULL;*/
 	}
 	ast_copy_string(tmp, dest, sizeof(tmp));
 	if (ast_strlen_zero(tmp)) {
@@ -3592,6 +4039,7 @@
 	if (gw) {
 		if (!gw_reload) {
 			gw->expire = -1;
+			gw->realtime = 0;
 			gw->retransid = -1; /* SC */
 			ast_mutex_init(&gw->msgs_lock);
 			ast_copy_string(gw->name, cat, sizeof(gw->name));
@@ -3650,6 +4098,12 @@
 					ast_log(LOG_WARNING, "'%s' is not a valid DTMF mode at line %d\n", v->value, v->lineno);
 			} else if (!strcasecmp(v->name, "nat")) {
 				nat = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "ncs")) {
+				ncs = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "hangupongateremove")) {
+				hangupongateremove = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "pktcgatealloc")) {
+				pktcgatealloc = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "callerid")) {
 				if (!strcasecmp(v->value, "asreceived")) {
 					cid_num[0] = '\0';
@@ -3765,6 +4219,7 @@
 					e->amaflags = amaflags;
 					e->capability = capability;
 					e->parent = gw;
+					e->ncs = ncs;
 					e->dtmfmode = dtmfmode;
 					if (!ep_reload && e->sub && e->sub->rtp)
 						e->dtmfmode |= MGCP_DTMF_INBAND;
@@ -3800,6 +4255,8 @@
 								/*stnrcpy(sub->txident, txident, sizeof(sub->txident) - 1);*/
 								sub->cxmode = MGCP_CX_INACTIVE;
 								sub->nat = nat;
+								sub->gate = NULL;
+								sub->sdpsent = 0;
 								sub->next = e->sub;
 								e->sub = sub;
 							} else {
@@ -3869,6 +4326,9 @@
 					e->amaflags = amaflags;
 					e->capability = capability;
 					e->dtmfmode = dtmfmode;
+					e->ncs = ncs;
+					e->pktcgatealloc = pktcgatealloc;
+					e->hangupongateremove = hangupongateremove;
 					e->adsi = adsi;
 					if (!strcasecmp(v->name, "trunk"))
 						e->type = TYPE_TRUNK;
@@ -3948,6 +4408,8 @@
 						gw->endpoints = e;
 					}
 				}
+			} else if (!strcasecmp(v->name, "name") || !strcasecmp(v->name, "lines")) {
+				/* just eliminate realtime warnings */
 			} else
 				ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name, v->lineno);
 			v = v->next;
@@ -4010,11 +4472,40 @@
 	return -1;
 }
 
+static int mgcp_get_codec(struct ast_channel *chan)
+{
+	struct mgcp_subchannel *sub = chan->tech_pvt;
+	struct mgcp_endpoint *p = sub->parent;
+        return p->capability;
+}
+
 static struct ast_rtp_glue mgcp_rtp_glue = {
 	.type = "MGCP",
 	.get_rtp_info = mgcp_get_rtp_peer,
 	.update_peer = mgcp_set_rtp_peer,
+	.get_codec = mgcp_get_codec,
 };
+
+
+static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *args, char *buf, size_t buflen)
+{
+	struct mgcp_subchannel *sub = chan->tech_pvt;
+	int res = 0;
+
+	/* Sanity check */
+	if (!chan || chan->tech != &mgcp_tech) {
+		ast_log(LOG_ERROR, "This function requires a valid MGCP channel\n");
+		return -1;
+	}
+
+ 	if (!strcasecmp(args, "ncs")) { 
+	        snprintf(buf, buflen, "%s", sub->parent->ncs ?  "yes":"no");
+ 	} else { 
+	        res = -1; 
+ 	} 
+	return res;
+}
+
 
 static void destroy_endpoint(struct mgcp_endpoint *e)
 {
@@ -4033,6 +4524,12 @@
 		memset(sub->magic, 0, sizeof(sub->magic));
 		mgcp_queue_hangup(sub);
 		dump_cmd_queues(NULL, sub);
+		if(sub->gate) {
+			sub->gate->tech_pvt = NULL;
+			sub->gate->got_dq_gi = NULL;
+			sub->gate->gate_remove = NULL;
+			sub->gate->gate_open = NULL;
+		}
 		ast_mutex_unlock(&sub->lock);
 		sub = sub->next;
 	}
@@ -4088,7 +4585,7 @@
 	for (z = NULL, g = gateways; g;) {
 		/* prune endpoints */
 		for (p = NULL, e = g->endpoints; e; ) {
-			if (e->delme || g->delme) {
+			if (!g->realtime && (e->delme || g->delme)) {
 				t = e;
 				e = e->next;
 				if (!p)
@@ -4232,6 +4729,12 @@
 			} else {
 				ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", v->value, v->lineno, config);
 			}
+		} else if (!strcasecmp(v->name, "firstdigittimeout")) {
+			firstdigittimeout = atoi(v->value);
+		} else if (!strcasecmp(v->name, "gendigittimeout")) {
+			gendigittimeout = atoi(v->value);
+		} else if (!strcasecmp(v->name, "matchdigittimeout")) {
+			matchdigittimeout = atoi(v->value);
 		}
 		v = v->next;
 	}

Modified: trunk/configs/mgcp.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/mgcp.conf.sample?view=diff&rev=227049&r1=227048&r2=227049
==============================================================================
--- trunk/configs/mgcp.conf.sample (original)
+++ trunk/configs/mgcp.conf.sample Mon Nov  2 16:29:19 2009
@@ -10,6 +10,11 @@
 ;tos_audio=ef		; Sets TOS for RTP audio packets.
 ;cos=3			; Sets 802.1p priority for signaling packets.
 ;cos_audio=5		; Sets 802.1p priority for RTP audio packets.
+
+;---------------------- DIGIT TIMEOUTS ----------------------------
+firstdigittimeout = 30000 ; default 16000 = 16s
+gendigittimeout = 10000   ; default  8000 = 8s 
+matchdigittimeout = 5000  ; defaults 3000 = 3s
 
 ;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
 ; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of a
@@ -47,27 +52,27 @@
 
 ;; The MGCP channel supports the following service codes:
 ;; # - Transfer
-;; *67 - Calling Number Delivery Blocking
-;; *70 - Cancel Call Waiting
-;; *72 - Call Forwarding Activation
-;; *73 - Call Forwarding Deactivation
-;; *78 - Do Not Disturb Activation
-;; *79 - Do Not Disturb Deactivation
+;; *67 - Calling Number Delivery Blocking 
+;; *70 - Cancel Call Waiting 
+;; *72 - Call Forwarding Activation 
+;; *73 - Call Forwarding Deactivation 
+;; *78 - Do Not Disturb Activation 
+;; *79 - Do Not Disturb Deactivation 
 ;; *8 - Call pick-up
 ;
-; known to work with Swissvoice IP10s
-;[192.168.1.20]
-;context=local
-;host=192.168.1.20
-;callerid = "John Doe" <123>
+; known to work with Swissvoice IP10s 
+;[192.168.1.20] 
+;context=local 
+;host=192.168.1.20 
+;callerid = "John Doe" <123> 
 ;callgroup=0      ; in the range from 0 to 63
 ;pickupgroup=0    ; in the range from 0 to 63
-;nat=no
-;threewaycalling=yes
+;nat=no 
+;threewaycalling=yes 
 ;transfer=yes     ; transfer requires threewaycalling=yes. Use FLASH to transfer
 ;callwaiting=yes  ; this might be a cause of trouble for ip10s
-;cancallforward=yes
-;line => aaln/1
+;cancallforward=yes 
+;line => aaln/1 
 ;
 
 ;[dph100]
@@ -90,7 +95,7 @@
 				; 'documentation', or 'omit'
 ;context	= local
 ;host		= 192.168.1.20
-;wcardep	= aaln/*	; enables wildcard endpoint and sets it to 'aaln/*'
+;wcardep	= aaln/*	; enables wildcard endpoint and sets it to 'aaln/*' 
 				; another common format is '*'
 ;callerid 	= "Duane Cox" <123>	; now lets setup line 1 using per endpoint configuration...
 ;callwaiting	= no
@@ -111,3 +116,20 @@
 ;transfer	= no
 ;dtmfmode	= inband
 ;line => aaln/2			; now lets save this config to line2 aka aaln/2
+
+; PacketCable
+;[sbv5121e-mta.test.local]
+;host        = 10.0.1.3
+;callwaiting = 1
+;canreinvite = 1
+;dtmfmode    = rfc2833
+;amaflags    = BILLING
+;ncs         = yes ; Use NCS 1.0 signalling
+;pktcgatealloc = yes ; Allocate DQOS gate on CMTS
+;hangupongateremove = yes ; Hangup the channel if the CMTS close the gate
+;callerid    = 3622622225
+;accountcode = test-3622622225
+;line        = aaln/1
+;callerid    = 3622622226
+;accountcode = test-3622622226
+;line        = aaln/2

Added: trunk/configs/res_pktccops.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/res_pktccops.conf.sample?view=auto&rev=227049

[... 1652 lines stripped ...]



More information about the asterisk-commits mailing list