[Asterisk-Dev] how does asterisk choose which network interfacetobind with?

Race Vanderdecken asterisk at vanderdecken.com
Mon Mar 7 18:34:45 MST 2005


Good to hear that you are progressing with your interface problems.

I hope you will have Asterisk working soon.

My server is down while I build another one. I should be back up by
Friday.


Race Vanderdecken

-----Original Message-----
From: asterisk-dev-bounces at lists.digium.com
[mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Liang Huang
Sent: Monday, March 07, 2005 8:02 PM
To: asterisk at vanderdecken.com; Asterisk Developers Mailing List
Subject: Re: [Asterisk-Dev] how does asterisk choose which network
interfacetobind with?

Race Vanderdecken wrote:

>Liang,
>
>Here is the offending code that is causing the "reload" error. In
>channels/chan_sip.c
>
>if (gethostname(ourhost, sizeof(ourhost))) {
>                ast_log(LOG_WARNING, "Unable to get hostname, SIP
>disabled\n");
>                return 0;
>        }
>...
>...
>...
>hp = ast_gethostbyname(ourhost, &ahp);
>                if (!hp) {
>                        ast_log(LOG_WARNING, "Unable to get IP address
>for %s, SIP disabled\n", ourhost);
>                        if (!__ourip.s_addr) {
>                                ast_destroy(cfg);
>                                return 0;
>                        }
>                } else
>                        memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
>
>A good explanation of gethostname is here. (IBM has excellent resource
>pages.)
>
>http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.i
b
>m.aix.doc/libs/commtrf2/gethostname.htm
>
>Since is passing the first gethostname() call it means that something
>was copied into the ourhost variable.
>
>Later the ast_gethostbyname() call then fails because it can't find the
>host "(none)" that was returned by gethostname(). At least that is what
>I am seeing from the code without running your code on your server.
>
>Did you set the host name for the computer? This is where my knowledge
>
I checked the hostname of the server, it was set to "(none)".....I have 
to manully set it to its IP "192.168.1.153".
Well, SIP module can be bind to all available addresses now instead of 
an specified IP "192.168.1.153", but it still can't get any SIP messages

from clients.

>ends because I don't know how the host name gets set or where it is
>stored. But gethostname found the words "(none)" when it was called.
>
>Does anyone else know more about gethostbyname()?
>
>Utils.c shows:
>struct hostent *ast_gethostbyname(const char *host, struct ast_hostent
>*hp)
>{
>        int res;
>        int herrno;
>        const char *s;
>        struct hostent *result = NULL;
>        /* Although it is perfectly legitimate to lookup a pure
integer,
>for
>           the sake of the sanity of people who like to name their
peers
>as
>           integers, we break with tradition and refuse to look up a
>           pure integer */
>        s = host;
>        while(s && *s) {
>                if (!isdigit(*s))
>                        break;
>                s++;
>        }
>        if (!s || !*s)
>                return NULL;
>        res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf),
>&result, &herrno);
>
>        if (res || !result || !hp->hp.h_addr_list ||
>!hp->hp.h_addr_list[0])
>                return NULL;
>        return &hp->hp;
>}
>As above ast_gethostbyname() does not check errorno for what went
wrong,
>it it just returns null. (Bad programmer, bad, bad, sit.)
>
>Try to discover why you are getting (none) in your gethostname call.
>
>Plan B:
>
>If you are not seeing SIP messages with sip debug turned on then the
>messages are not getting to Asterisk.
>
>So let's work on that problem.
>
>>From the Asterisk server box:
>
>1.
>
>#> ping (ipaddress of phone)
>Can asterisk see the phone?
>  
>
Yes, ICMP service is provided by the server on which my SIP client is 
running

>
>2. Can you http with a browser to the phone?
>	Http://ip.adress.of.phone
>
Yes, httpd service is provided by the server on which my SIP client is 
running.
And no firewall is set on both server side and client side.

>
>3.
>Have you run tcpdump?
>
>#> tcpdump -X -s0 host (ipaddress of phone )
>  
>
Nope, I will try this one later today.

>
>This will give you the low level conversation between the phone and
>asterisk. 
>
Thanks a lot!!!

>
>Race "The Tyrant" Vanderdecken
>
>
>
>_______________________________________________
>Asterisk-Dev mailing list
>Asterisk-Dev at lists.digium.com
>http://lists.digium.com/mailman/listinfo/asterisk-dev
>To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-dev
>  
>
Best Regards,

Liang

_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Spam detection software, running on the system "zeus.avanzada7.com", has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
the administrator of that system for details.

Content preview:  Race Vanderdecken wrote: >Liang, > >Here is the 
  offending code that is causing the "reload" error. In 
  >channels/chan_sip.c > >if (gethostname(ourhost, sizeof(ourhost))) { >

  ast_log(LOG_WARNING, "Unable to get hostname, SIP >disabled\n"); > 
  return 0; > } >... >... >... >hp = ast_gethostbyname(ourhost, &ahp); >

  if (!hp) { > ast_log(LOG_WARNING, "Unable to get IP address >for %s, 
  SIP disabled\n", ourhost); > if (!__ourip.s_addr) { > 
  ast_destroy(cfg); > return 0; > } > } else > memcpy(&__ourip, 
  hp->h_addr, sizeof(__ourip)); > >A good explanation of gethostname is 
  here. (IBM has excellent resource >pages.) > 
  
 
>http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.i
b 
  >m.aix.doc/libs/commtrf2/gethostname.htm > >Since is passing the first

  gethostname() call it means that something >was copied into the 
  ourhost variable. > >Later the ast_gethostbyname() call then fails 
  because it can't find the >host "(none)" that was returned by 
  gethostname(). At least that is what >I am seeing from the code 
  without running your code on your server. > >Did you set the host name

  for the computer? This is where my knowledge > I checked the hostname 
  of the server, it was set to "(none)".....I have to manully set it to 
  its IP "192.168.1.153". Well, SIP module can be bind to all available 
  addresses now instead of an specified IP "192.168.1.153", but it still

  can't get any SIP messages from clients. [...] 

Content analysis details:   (3.7 points, 5.0 required)

 pts rule name              description
---- ----------------------
--------------------------------------------------
 0.1 FORGED_RCVD_HELO       Received: contains a forged HELO
 2.8 RCVD_IN_DSBL           RBL: Received via a relay in list.dsbl.org
                            [<http://dsbl.org/listing?219.238.107.100>]
 0.9 RCVD_IN_NJABL_RELAY    RBL: NJABL: sender is confirmed open relay
                            [219.238.107.100 listed in
combined.njabl.org]






More information about the asterisk-dev mailing list