Extend the 'network settings' section with indication on the
authorLuigi Rizzo <rizzo@icir.org>
Fri, 20 Jul 2007 14:54:01 +0000 (14:54 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Fri, 20 Jul 2007 14:54:01 +0000 (14:54 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76035 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index b0b7bda..04e03c7 100644 (file)
@@ -11139,6 +11139,7 @@ static int sip_show_settings(int fd, int argc, char *argv[])
        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 @@ static int sip_show_settings(int fd, int argc, char *argv[])
 
        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:                 ");