[asterisk-commits] russell: branch 1.8 r353175 - /branches/1.8/main/netsock.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jan 28 20:43:02 CST 2012
Author: russell
Date: Sat Jan 28 20:42:59 2012
New Revision: 353175
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=353175
Log:
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().
Modified:
branches/1.8/main/netsock.c
Modified: branches/1.8/main/netsock.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/netsock.c?view=diff&rev=353175&r1=353174&r2=353175
==============================================================================
--- branches/1.8/main/netsock.c (original)
+++ branches/1.8/main/netsock.c Sat Jan 28 20:42:59 2012
@@ -238,17 +238,17 @@
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,7 +256,17 @@
}
if (i == ARRAY_LEN(prefixes)) {
- continue;
+ /* 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));
More information about the asterisk-commits
mailing list