[Asterisk-cvs] asterisk/channels chan_sip.c,1.485,1.486

markster at lists.digium.com markster at lists.digium.com
Tue Aug 31 12:45:55 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv32450/channels

Modified Files:
	chan_sip.c 
Log Message:
Use Contact for URI if supplied...


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.485
retrieving revision 1.486
diff -u -d -r1.485 -r1.486
--- chan_sip.c	31 Aug 2004 16:33:00 -0000	1.485
+++ chan_sip.c	31 Aug 2004 16:49:20 -0000	1.486
@@ -312,7 +312,7 @@
 	char callerid[256];			/* Caller*ID */
 	int restrictcid;			/* hide presentation from remote user */
 	char via[256];
-	char extraparams[80];		/* Extra parameters to go in the "To" header */
+	char fullcontact[80];		/* Extra parameters to go in the "To" header */
 	char accountcode[20];			/* Account code */
 	char our_contact[256];			/* Our contact header */
 	char realm[256];			/* Authorization realm */
@@ -424,7 +424,7 @@
 	char tohost[80];
 	char fromuser[80];
 	char fromdomain[80];
-	char extraparams[80];
+	char fullcontact[80];
 	char mailbox[AST_MAX_EXTENSION];
 	char language[MAX_LANGUAGE];
 	char musicclass[MAX_LANGUAGE];  /* Music on Hold class */
@@ -3674,7 +3674,10 @@
 	else
 		snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, p->tag);
 
-	if (!ast_strlen_zero(p->username)) {
+	if (!ast_strlen_zero(p->fullcontact)) {
+		/* If we have full contact, trust it */
+		strncpy(invite, p->fullcontact, sizeof(invite) - 1);
+	} else if (!ast_strlen_zero(p->username)) {
 		if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT) {
 			snprintf(invite, sizeof(invite), "sip:%s@%s:%d",p->username, p->tohost, ntohs(p->sa.sin_port));
 		} else {
@@ -3685,10 +3688,6 @@
 	} else {
 		snprintf(invite, sizeof(invite), "sip:%s", p->tohost);
 	}
-	if (!ast_strlen_zero(p->extraparams)) {
-		strncat(invite, ";", sizeof(invite) - strlen(invite));
-		strncat(invite, p->extraparams, sizeof(invite) - strlen(invite));
-	}
 	strncpy(p->uri, invite, sizeof(p->uri) - 1);
 	/* If there is a VXML URL append it to the SIP URL */
 	if (vxml_url)
@@ -4253,7 +4252,7 @@
 						if (e) {
 							*e = '\0';
 							e++;
-							strncpy(p->extraparams, e, sizeof(p->extraparams) - 1);
+							strncpy(p->fullcontact, e, sizeof(p->fullcontact) - 1);
 						}
 						strncpy(p->username, u, sizeof(p->username) - 1);
 						
@@ -4318,12 +4317,14 @@
 			ast_sched_del(sched, p->expire);
 		p->expire = -1;
 		ast_db_del("SIP/Registry", p->name);
+		p->fullcontact[0] = '\0';
 		p->useragent[0] = '\0';
 		p->lastms = 0;
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Unregistered SIP '%s'\n", p->name);
 		return 0;
 	}
+	strncpy(p->fullcontact, c, sizeof(p->fullcontact) - 1);
 	/* For the 200 OK, we should use the received contact */
 	snprintf(pvt->our_contact, sizeof(pvt->our_contact) - 1, "<%s>", c);
 	/* Make sure it's a SIP URL */
@@ -4335,10 +4336,7 @@
 	n = strchr(c, ';');
 	if (n) {
 		*n = '\0';
-		n++;
-		strncpy(p->extraparams, n, sizeof(p->extraparams) - 1);
-	} else
-		strncpy(p->extraparams, "", sizeof(p->extraparams) - 1);
+	}
 	/* Grab host */
 	n = strchr(c, '@');
 	if (!n) {
@@ -4382,7 +4380,7 @@
 	if (!p->temponly)
 		p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
 	pvt->expiry = expiry;
-	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->extraparams);
+	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
 	ast_db_put("SIP/Registry", p->name, data);
 	if (inaddrcmp(&p->addr, &oldsin)) {
 		sip_poke_peer(p);
@@ -5368,7 +5366,7 @@
 					strncpy(p->username, peer->username, sizeof(p->username) - 1);
 					strncpy(p->authname, peer->username, sizeof(p->authname) - 1);
 				}
-				strncpy(p->extraparams, peer->extraparams, sizeof(p->extraparams) - 1);
+				strncpy(p->fullcontact, peer->fullcontact, sizeof(p->fullcontact) - 1);
 				if (!ast_strlen_zero(peer->context))
 					strncpy(p->context, peer->context, sizeof(p->context) - 1);
 				strncpy(p->peersecret, peer->secret, sizeof(p->peersecret) - 1);
@@ -5728,7 +5726,7 @@
 			strncpy(status, "UNKNOWN", sizeof(status) - 1);
 		ast_cli(fd, "%s\n",status);
  		ast_cli(fd, "  Useragent    : %s\n", peer->useragent);
- 		ast_cli(fd, "  Extra Params : %s\n", peer->extraparams);
+ 		ast_cli(fd, "  Full Contact : %s\n", peer->fullcontact);
 		ast_cli(fd,"\n");
 	} else {
 		ast_cli(fd,"Peer %s not found.\n", argv[3]);




More information about the svn-commits mailing list