diff options
author | Russell Bryant <russell@russellbryant.com> | 2006-11-04 21:44:48 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2006-11-04 21:44:48 +0000 |
commit | 4b5ad8fb983c1e6a1da86e58746eb22080233f85 (patch) | |
tree | 99c2bbceb1640688caa2b9a9cdd0e7737cbb7f69 | |
parent | 18b694d31864f49714f05cc9f71afd8a7c1c3e9d (diff) |
Do some minor cleanup to the section of code that sets the EID by getting the
mac address for an ethernet interface
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47204 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | pbx/pbx_dundi.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index e947e56f6..798beca16 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -392,26 +392,26 @@ static void dundi_reject(struct dundi_hdr *h, struct sockaddr_in *sin) static void reset_global_eid(void) { #if defined(SIOCGIFHWADDR) - int x,s; + int s, x = 0; char eid_str[20]; struct ifreq ifr; s = socket(AF_INET, SOCK_STREAM, 0); - if (s > 0) { - x = 0; - for(x=0;x<10;x++) { - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x); - if (!ioctl(s, SIOCGIFHWADDR, &ifr)) { - memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid)); - if (option_debug) - ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name); - close(s); - return; - } - } - close(s); + if (s < 0) + return; + for (x = 0; x < 10; x++) { + memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x); + if (ioctl(s, SIOCGIFHWADDR, &ifr)) + continue; + memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid)); + if (option_debug) { + ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", + dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name); + } + break; } + close(s); #else #if defined(ifa_broadaddr) && !defined(SOLARIS) char eid_str[20]; |