]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Update ast_set_default_eid() to find more network interfaces.
authorRussell Bryant <russell@russellbryant.com>
Sat, 28 Jan 2012 04:25:25 +0000 (04:25 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sat, 28 Jan 2012 04:25:25 +0000 (04:25 +0000)
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

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

main/netsock.c

index 02a143b641de7835e8c13356d3143fc024ef0fc2..e20e03b0c87411f9d3eba67c730888e91eba91a4 100644 (file)
@@ -243,10 +243,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);