[asterisk-commits] rizzo: trunk r76035 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 20 09:54:02 CDT 2007


Author: rizzo
Date: Fri Jul 20 09:54:01 2007
New Revision: 76035

URL: http://svn.digium.com/view/asterisk?view=rev&rev=76035
Log:
Extend the 'network settings' section with indication on the
localnet settings (requires the change in SVN 76034), and also
give an indication on whether/why/how the remapping of addresses
in SIP message is done or not.

I think this is especially useful for debugging the configuration,
as the address remapping depends on a combination of at least 3
parameters (localnet, externhost, externip) and successful DNS lookup.

An example of the output of this section is below:

	Network Settings:
	---------------------------
	  SIP address remapping:  Enabled using externhost
	  Externhost:             foo.dyndns.net
	  Externip:               80.64.128.23:0
	  Externrefresh:          10
	  Internal IP:            12.34.56.78:5060
	  Localnet:               192.168.0.0/255.255.0.0
				  10.0.0.0/255.0.0.0

I leave to the community the judgement if the above info is a
useful addition for 1.4. It is not a bugfix, but it is neither a
new feature, only a useful diagnostic tool.

Note that I would like to move there also the bindaddress/port
information, in the usual addr:port format e.g.

          Bindaddress:            0.0.0.0:5060

so that network information is all in one place.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=76035&r1=76034&r2=76035
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jul 20 09:54:01 2007
@@ -11139,6 +11139,7 @@
 	int realtimeusers;
 	int realtimeregs;
 	char codec_buf[BUFSIZ];
+	const char *msg;	/* temporary msg pointer */
 
 	realtimepeers = ast_check_realtime("sippeers");
 	realtimeusers = ast_check_realtime("sipusers");
@@ -11201,11 +11202,32 @@
 
 	ast_cli(fd, "\nNetwork Settings:\n");
 	ast_cli(fd, "---------------------------\n");
-	ast_cli(fd, "  Externhost:             %s\n", externhost);
+	/* determine if/how SIP address can be remapped */
+	if (localaddr == NULL)
+		msg = "Disabled, no localnet list";
+	else if (externip.sin_addr.s_addr == 0)
+		msg = "Disabled, externip is 0.0.0.0";
+	else if (externhost)
+		msg = "Enabled using externhost";
+	else
+		msg = "Enabled using externip";
+	ast_cli(fd, "  SIP address remapping:  %s\n", msg);
+	ast_cli(fd, "  Externhost:             %s\n", S_OR(externhost, "<none>"));
 	ast_cli(fd, "  Externip:               %s:%d\n", ast_inet_ntoa(externip.sin_addr), ntohs(externip.sin_port));
 	ast_cli(fd, "  Externrefresh:          %d\n", externrefresh);
 	ast_cli(fd, "  Internal IP:            %s:%d\n", ast_inet_ntoa(__ourip), ntohs(bindaddr.sin_port));
-
+	{
+		struct ast_ha *a;
+		const char *prefix = "Localnet:";
+		char buf[INET_ADDRSTRLEN]; /* need to print two addresses */
+
+		for (a = localaddr; a ; prefix = "", a = a->next) {
+			ast_cli(fd, "  %-24s%s/%s\n",
+			    prefix, ast_inet_ntoa(a->netaddr),
+			    inet_ntop(AF_INET, &a->netmask, buf, sizeof(buf)) );
+		}
+	}
+ 
 	ast_cli(fd, "\nGlobal Signalling Settings:\n");
 	ast_cli(fd, "---------------------------\n");
 	ast_cli(fd, "  Codecs:                 ");




More information about the asterisk-commits mailing list