[asterisk-commits] tilghman: branch 1.4 r118251 - /branches/1.4/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun May 25 11:02:06 CDT 2008


Author: tilghman
Date: Sun May 25 11:02:04 2008
New Revision: 118251

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118251
Log:
Realtime flag affects construction in multiple ways, so consulting whether
rtcachefriends was set was done too soon (needed to be done inside build_peer,
not just as a flag to build_peer).
Also, fullcontact needed to be reconstructed, because realtime separates the
embedded ';' into multiple fields.
(closes issue #12722)
 Reported by: barthpbx
 Patches: 
       20080525__bug12722.diff.txt uploaded by Corydon76 (license 14)
 Tested by: barthpbx
 (Much of the discussion happened on #asterisk-dev for diagnosing this issue)

Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=118251&r1=118250&r2=118251
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Sun May 25 11:02:04 2008
@@ -2614,7 +2614,7 @@
 	}
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+	peer = build_peer(newpeername, var, NULL, 1);
 	if (!peer) {
 		if(peerlist)
 			ast_config_destroy(peerlist);
@@ -16648,9 +16648,9 @@
 	struct ast_variable *tmpvar = NULL;
 	struct ast_flags peerflags[2] = {{(0)}};
 	struct ast_flags mask[2] = {{(0)}};
-
-
-	if (!realtime)
+	char fullcontact[sizeof(peer->fullcontact)] = "";
+
+	if (!realtime || ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS))
 		/* Note we do NOT use find_peer here, to avoid realtime recursion */
 		/* We also use a case-sensitive comparison (unlike find_peer) so
 		   that case changes made to the peer name will be properly handled
@@ -16667,7 +16667,7 @@
 		if (!(peer = ast_calloc(1, sizeof(*peer))))
 			return NULL;
 
-		if (realtime)
+		if (realtime && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS))
 			rpeerobjs++;
 		else
 			speerobjs++;
@@ -16704,8 +16704,14 @@
 		} else if (realtime && !strcasecmp(v->name, "name"))
 			ast_copy_string(peer->name, v->value, sizeof(peer->name));
 		else if (realtime && !strcasecmp(v->name, "fullcontact")) {
-			ast_copy_string(peer->fullcontact, v->value, sizeof(peer->fullcontact));
-			ast_set_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT);
+			/* Reconstruct field, because realtime separates our value at the ';' */
+			if (!ast_strlen_zero(fullcontact)) {
+				strncat(fullcontact, ";", sizeof(fullcontact) - strlen(fullcontact) - 1);
+				strncat(fullcontact, v->value, sizeof(fullcontact) - strlen(fullcontact) - 1);
+			} else {
+				ast_copy_string(fullcontact, v->value, sizeof(fullcontact));
+				ast_set_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT);
+			}
 		} else if (!strcasecmp(v->name, "secret")) 
 			ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
 		else if (!strcasecmp(v->name, "md5secret")) 
@@ -16865,6 +16871,10 @@
 				peer->maxcallbitrate = default_maxcallbitrate;
 		}
 	}
+	if (!ast_strlen_zero(fullcontact)) {
+		ast_copy_string(peer->fullcontact, fullcontact, sizeof(peer->fullcontact));
+	}
+
 	if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && realtime) {
 		time_t nowtime = time(NULL);
 




More information about the asterisk-commits mailing list