[Asterisk-Dev] MGCP dirty fixes

alex at pilosoft.com alex at pilosoft.com
Fri Mar 28 05:51:33 MST 2003


In case someone finds them useful to get started with MGCP phones with *:

(Mark, please do not apply, the patches are wrong, and need to be redone 
correctly).

Issues "covered up": 

a) "hook flash"
b) "timeouts" for MGCP 
c) absence of "hbz" tone on dlink 

Index: channels/chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.4
diff --unified -r1.4 chan_mgcp.c
--- channels/chan_mgcp.c	24 Mar 2003 22:20:28 -0000	1.4
+++ channels/chan_mgcp.c	28 Mar 2003 12:55:54 -0000
@@ -140,6 +140,7 @@
 	int iseq;
 	int nat;
 	int lastout;
+	time_t lastouttime;
 	int alreadygone;
 	int needdestroy;
 	int capability;
@@ -220,8 +221,14 @@
 {
 	struct mgcp_message *msg = malloc(sizeof(struct mgcp_message) + len);
 	struct mgcp_message *cur;
+	time_t t;
 	if (!msg)
 		return -1;
+	time(&t);
+	if (p->messagepending && (p->lastouttime + 20 < t)) {
+		ast_log(LOG_NOTICE, "UNDEFERRING based on %d/%d\n", p->lastouttime,t);
+		dump_queue(p);
+	}
 	msg->seqno = seqno;
 	msg->next = NULL;
 	msg ->len = len;
@@ -236,6 +243,7 @@
 	if (!p->messagepending) {
 		p->messagepending = 1;
 		p->lastout = seqno;
+		p->lastouttime = t;
 		__mgcp_xmit(p, msg->buf, msg->len);
 		/* XXX Should schedule retransmission XXX */
 	} else
@@ -540,16 +548,20 @@
 static int mgcp_indicate(struct ast_channel *ast, int ind)
 {
 	struct mgcp_endpoint *p = ast->pvt->pvt;
+/*	ast_log(LOG_DEBUG, "Indicating condition %d\n", ind); */
 	switch(ind) {
 	case AST_CONTROL_RINGING:
 		transmit_notify_request(p, "rt", 1);
 		break;
+	case AST_CONTROL_CONGESTION:
 	case AST_CONTROL_BUSY:
 		transmit_notify_request(p, "bz", 1);
 		break;
+		/*
 	case AST_CONTROL_CONGESTION:
 		transmit_notify_request(p, "nbz", 1);
 		break;
+		*/
 	case -1:
 		transmit_notify_request(p, "", 1);
 		break;		
@@ -1267,6 +1279,7 @@
 static void handle_response(struct mgcp_endpoint *p, int result, int ident)
 {
 	struct mgcp_message *cur;
+	time_t t;
 	if (p->msgs && (p->msgs->seqno == ident)) {
 		ast_log(LOG_DEBUG, "Got response back on tansaction %d\n", ident);
 		cur = p->msgs;
@@ -1276,6 +1289,8 @@
 			/* Send next pending message if appropriate */
 			p->messagepending = 1;
 			p->lastout = p->msgs->seqno;
+			time(&t);
+			p->lastouttime = t;
 			__mgcp_xmit(p, p->msgs->buf, p->msgs->len);
 			/* XXX Should schedule retransmission XXX */
 		} else
@@ -1381,6 +1396,16 @@
 		/* Keep looking for events unless this was a hangup */
 		if (strcasecmp(ev, "hu") && strcasecmp(ev, "hd"))
 			transmit_notify_request(p, p->curtone, 1);
+		if (!strcasecmp(ev, "hf")) {
+                        ast_log(LOG_DEBUG, "Alex: HookeFlashe\n");
+                        if (p->owner) {
+                                p->alreadygone = 1;
+                                ast_queue_hangup(p->owner, 1);
+                        }
+                        transmit_notify_request(p, "", 0);
+                        ev="hd";
+                }
+
 		if (!strcasecmp(ev, "hd")) {
 			/* Off hook / answer */
 			if (p->outgoing) {
@@ -1405,6 +1430,7 @@
 					ast_log(LOG_WARNING, "Off hook, but alreaedy have owner on %s@%s\n", p->name, p->parent->name);
 				}
 			}
+/* alex */
 		} else if (!strcasecmp(ev, "hu")) {
 			ast_log(LOG_DEBUG, "Went on hook\n");
 			if (p->owner) {




More information about the asterisk-dev mailing list