[Asterisk-cvs] asterisk/channels chan_sip.c,1.687,1.688

markster at lists.digium.com markster at lists.digium.com
Tue Mar 22 13:15:13 CST 2005


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

Modified Files:
	chan_sip.c 
Log Message:
Fix SIP realtime bug (somehow didn't get committed yesterday)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.687
retrieving revision 1.688
diff -u -d -r1.687 -r1.688
--- chan_sip.c	21 Mar 2005 15:09:10 -0000	1.687
+++ chan_sip.c	22 Mar 2005 19:09:47 -0000	1.688
@@ -1257,13 +1257,13 @@
 	struct sip_peer *peer=NULL;
 	struct ast_variable *var;
 	struct ast_variable *tmp;
+	char *newpeername = (char *) peername;
+	char iabuf[80] = "";
 
 	/* First check on peer name */
-	if (peername) 
+	if (newpeername) 
 		var = ast_load_realtime("sippeers", "name", peername, NULL);
 	else if (sin) {	/* Then check on IP address */
-		char iabuf[80];
-
 		ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
 		var = ast_load_realtime("sippeers", "ipaddr", iabuf, NULL);
 	} else
@@ -1279,23 +1279,30 @@
 		    !strcasecmp(tmp->value, "user")) {
 			ast_variables_destroy(var);
 			return NULL;
+		} else if(!newpeername && !strcasecmp(tmp->name, "name")) {
+			newpeername = tmp->value;
 		}
 		tmp = tmp->next;
 	}
+	
+	if (newpeername) {
+		peer = build_peer(newpeername, var, ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS) ? 0 : 1);
 
-	peer = build_peer(peername, var, ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS) ? 0 : 1);
-
-	if (peer) {
-		if(ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS)) {
-			ast_copy_flags((&peer->flags_page2),(&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
-			if(ast_test_flag((&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
-				peer->expire = ast_sched_add(sched, (global_rtautoclear) * 1000, expire_register, (void *)peer);
+		if (peer) {
+			if(ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS)) {
+				ast_copy_flags((&peer->flags_page2),(&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
+				if(ast_test_flag((&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
+					peer->expire = ast_sched_add(sched, (global_rtautoclear) * 1000, expire_register, (void *)peer);
+				}
+				ASTOBJ_CONTAINER_LINK(&peerl,peer);
+			} else {
+				ast_set_flag(peer, SIP_REALTIME);
 			}
-			ASTOBJ_CONTAINER_LINK(&peerl,peer);
-		} else {
-			ast_set_flag(peer, SIP_REALTIME);
 		}
+	} else {
+		ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", iabuf);
 	}
+	
 	ast_variables_destroy(var);
 	return peer;
 }




More information about the svn-commits mailing list