diff --git a/main/netsock.c b/main/netsock.c index 5cab1c19a488f9004e81460e4dc7155ea279ba8e..2effc4a10669bd190f3bdad7ab3f8bbeb1d25ab8 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);