dynamic interafaces names list
This commit is contained in:
parent
90008346be
commit
bab88d61a1
2
dhcp.c
2
dhcp.c
@ -520,7 +520,7 @@ enum return_type perform_dhcp(struct interface_info * intf)
|
|||||||
int num_options;
|
int num_options;
|
||||||
char requested_options[50];
|
char requested_options[50];
|
||||||
|
|
||||||
if (strncmp(intf->device, "eth", 3)) {
|
if (strncmp(intf->device, "en", 2) & strncmp(intf->device, "eth", 3)) {
|
||||||
stg1_info_message("DHCP available only for Ethernet networking.");
|
stg1_info_message("DHCP available only for Ethernet networking.");
|
||||||
return RETURN_ERROR;
|
return RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
25
probing.c
25
probing.c
@ -285,24 +285,19 @@ static int net_device_available(char * device)
|
|||||||
|
|
||||||
char ** get_net_devices(void)
|
char ** get_net_devices(void)
|
||||||
{
|
{
|
||||||
char * devices[] = {
|
DIR * sys_net;
|
||||||
"eth0", "eth1", "eth2", "eth3", "eth4", "eth5",
|
|
||||||
"ib0", "ib1",
|
|
||||||
"tr0",
|
|
||||||
"fddi0",
|
|
||||||
#ifdef ENABLE_USBNET
|
|
||||||
"usb0", "usb1", "usb2", "usb3",
|
|
||||||
#endif
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
char ** ptr = devices;
|
|
||||||
char * tmp[50];
|
char * tmp[50];
|
||||||
|
struct dirent * ent;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
sys_net = opendir("/sys/class/net");
|
||||||
|
if (sys_net == NULL) return(strdup("\0"));
|
||||||
|
|
||||||
while (ptr && *ptr) {
|
while ( ent = readdir(sys_net)){
|
||||||
if (net_device_available(*ptr))
|
if( !strcmp("lo", ent->d_name))continue;
|
||||||
tmp[i++] = strdup(*ptr);
|
if (net_device_available(ent->d_name)){
|
||||||
ptr++;
|
tmp[i++] = strdup(ent->d_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tmp[i++] = NULL;
|
tmp[i++] = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user