diff options
author | Mark Spencer <markster@digium.com> | 2005-02-09 03:22:42 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2005-02-09 03:22:42 +0000 |
commit | 97f589e6af67d8802167f0886ed4d6d90e6a817d (patch) | |
tree | e10408b6455f04f154abd2a2d43030d6a922007c /channels/chan_sip.c | |
parent | aeaa181d740ccfaccf6936275362763fdf220592 (diff) |
Handle DNS failures on startup more gracefully (bug #3086)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4989 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rwxr-xr-x | channels/chan_sip.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 24af559fe..fb00430a7 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -191,7 +191,6 @@ static int restart_monitor(void); static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263; static int noncodeccapability = AST_RTP_DTMF; -static char ourhost[256]; static struct in_addr __ourip; static struct sockaddr_in outboundproxyip; static int ourport; @@ -9059,10 +9058,6 @@ static int reload_config(void) char iabuf[INET_ADDRSTRLEN]; struct ast_flags dummy; - if (gethostname(ourhost, sizeof(ourhost))) { - ast_log(LOG_WARNING, "Unable to get hostname, SIP disabled\n"); - return 0; - } cfg = ast_config_load(config); /* We *must* have a config file otherwise stop immediately */ @@ -9297,20 +9292,9 @@ static int reload_config(void) } cat = ast_category_browse(cfg, cat); } - - /* Find our IP address */ - if (ntohl(bindaddr.sin_addr.s_addr)) { - memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip)); - } else { - 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_config_destroy(cfg); - return 0; - } - } else - memcpy(&__ourip, hp->h_addr, sizeof(__ourip)); + if (ast_find_ourip(&__ourip, bindaddr)) { + ast_log(LOG_WARNING, "Unable to get own IP address, SIP disabled\n"); + return 0; } if (!ntohs(bindaddr.sin_port)) bindaddr.sin_port = ntohs(DEFAULT_SIP_PORT); |