summaryrefslogtreecommitdiff
path: root/main/netsock.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2012-01-28 04:31:07 +0000
committerRussell Bryant <russell@russellbryant.com>2012-01-28 04:31:07 +0000
commit3b785264b038583e4d7d2f0226cfe6204c5e1562 (patch)
treeef8327bce74733a759511a3609403f5a016e0572 /main/netsock.c
parent2e04182efcd9adc90e03ee7d25353c0c6695246b (diff)
Update ast_set_default_eid() to find more network interfaces.
As of Fedora 15, ethN is not the name of ethernet interfaces. The names are emN or pciN. Update some code that searched for interfaces named ethN to look for the new names, as well. For more information about why this change was made, see this page: http://domsch.com/blog/?p=455 ........ Merged revisions 353077 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 353078 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/netsock.c')
-rw-r--r--main/netsock.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/main/netsock.c b/main/netsock.c
index 5cab1c19a..2effc4a10 100644
--- a/main/netsock.c
+++ b/main/netsock.c
@@ -245,10 +245,22 @@ void ast_set_default_eid(struct ast_eid *eid)
if (s < 0)
return;
for (x = 0; x < 10; x++) {
+ static const char *prefixes[] = { "eth", "em", "pci" };
+ unsigned int i;
+
memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x);
- if (ioctl(s, SIOCGIFHWADDR, &ifr))
+
+ for (i = 0; i < ARRAY_LEN(prefixes); i++) {
+ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", prefixes[i], x);
+ if (!ioctl(s, SIOCGIFHWADDR, &ifr)) {
+ break;
+ }
+ }
+
+ if (i == ARRAY_LEN(prefixes)) {
continue;
+ }
+
memcpy(eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(*eid));
ast_debug(1, "Seeding global EID '%s' from '%s' using 'siocgifhwaddr'\n", ast_eid_to_str(eid_str, sizeof(eid_str), eid), ifr.ifr_name);
close(s);