[Asterisk-cvs] asterisk/channels chan_sip.c,1.537,1.538

markster at lists.digium.com markster at lists.digium.com
Sat Oct 16 18:40:53 CDT 2004


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

Modified Files:
	chan_sip.c 
Log Message:
Improve peer stats (bug #2635)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.537
retrieving revision 1.538
diff -u -d -r1.537 -r1.538
--- chan_sip.c	16 Oct 2004 15:36:16 -0000	1.537
+++ chan_sip.c	16 Oct 2004 22:40:48 -0000	1.538
@@ -5611,27 +5611,34 @@
 				}
 				strncpy(status, "UNKNOWN", sizeof(status) - 1);
 			}
-		} else 
+		} else { 
 			strncpy(status, "Unmonitored", sizeof(status) - 1);
-			snprintf(srch, sizeof(srch), FORMAT, name,
-				peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
-				peer->dynamic ? " D " : "   ", 	/* Dynamic or not? */
-				(peer->nat & SIP_NAT_ROUTE) ? " N " : "   ",	/* NAT=yes? */
-				peer->ha ? " A " : "   ", 	/* permit/deny */
-				nm,
-				ntohs(peer->addr.sin_port), status);
+			/* Checking if port is 0 */
+		        if ( ntohs(peer->addr.sin_port) == 0 ) {
+				peers_offline++;
+			} else {
+				peers_online++;
+			}
+		}			
+		
+		snprintf(srch, sizeof(srch), FORMAT, name,
+			peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
+			peer->dynamic ? " D " : "   ", 	/* Dynamic or not? */
+			(peer->nat & SIP_NAT_ROUTE) ? " N " : "   ",	/* NAT=yes? */
+			peer->ha ? " A " : "   ", 	/* permit/deny */
+			nm, ntohs(peer->addr.sin_port), status);
 
-			if (argc == 5) {
-				if (!strcasecmp(argv[3],"include") && strstr(srch,argv[4])) {
-					print_line = -1;
-				} else if (!strcasecmp(argv[3],"exclude") && !strstr(srch,argv[4])) {
-					print_line = 1;
-				} else if (!strcasecmp(argv[3],"begin") && !strncasecmp(srch,argv[4],strlen(argv[4]))) {
-					print_line = -1;
-				} else {
-					print_line = 0;
-				}
+		if (argc == 5) {
+			if (!strcasecmp(argv[3],"include") && strstr(srch,argv[4])) {
+				print_line = -1;
+			} else if (!strcasecmp(argv[3],"exclude") && !strstr(srch,argv[4])) {
+				print_line = 1;
+			} else if (!strcasecmp(argv[3],"begin") && !strncasecmp(srch,argv[4],strlen(argv[4]))) {
+				print_line = -1;
+			} else {
+				print_line = 0;
 			}
+		}
 
 		if (print_line) {
 		    ast_cli(fd, FORMAT, name, 
@@ -5644,7 +5651,7 @@
 		}
 		total_peers++;
 	}
-	ast_cli(fd,"%d sip peers loaded [%d onlines , %d offlines]\n",total_peers,peers_online,peers_offline);
+	ast_cli(fd,"%d sip peers loaded [%d online , %d offline]\n",total_peers,peers_online,peers_offline);
 	ast_mutex_unlock(&peerl.lock);
 	return RESULT_SUCCESS;
 #undef FORMAT




More information about the svn-commits mailing list