mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-01 11:32:25 +00:00
Find even more network interfaces.
The previous change made the code look for emN and pciN in addition to what it did originally, which was search for ethN. However, it needed to be looking for pciN#N, so that's what it does now. This also moves the memset() to be before every ioctl(). git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@353175 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -238,17 +238,17 @@ void ast_set_default_eid(struct ast_eid *eid)
|
||||
int s, x = 0;
|
||||
char eid_str[20];
|
||||
struct ifreq ifr;
|
||||
static const unsigned int MAXIF = 10;
|
||||
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0)
|
||||
return;
|
||||
for (x = 0; x < 10; x++) {
|
||||
static const char *prefixes[] = { "eth", "em", "pci" };
|
||||
for (x = 0; x < MAXIF; x++) {
|
||||
static const char *prefixes[] = { "eth", "em" };
|
||||
unsigned int i;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
|
||||
for (i = 0; i < ARRAY_LEN(prefixes); i++) {
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", prefixes[i], x);
|
||||
if (!ioctl(s, SIOCGIFHWADDR, &ifr)) {
|
||||
break;
|
||||
@@ -256,8 +256,18 @@ void ast_set_default_eid(struct ast_eid *eid)
|
||||
}
|
||||
|
||||
if (i == ARRAY_LEN(prefixes)) {
|
||||
/* Try pciX#[1..N] */
|
||||
for (i = 0; i < MAXIF; i++) {
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "pci%u#%u", x, i);
|
||||
if (!ioctl(s, SIOCGIFHWADDR, &ifr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == MAXIF) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user