mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Fixed a couple of interface ordering bugs.
This commit is contained in:
parent
f000b16d03
commit
999500b865
@ -54,7 +54,6 @@ struct ipx_interface *get_interfaces(int ifnum) {
|
|||||||
struct ipx_interface *nics = NULL, *enic = NULL;
|
struct ipx_interface *nics = NULL, *enic = NULL;
|
||||||
|
|
||||||
IP_ADAPTER_INFO *ifptr = ifroot;
|
IP_ADAPTER_INFO *ifptr = ifroot;
|
||||||
int this_ifnum = 0;
|
|
||||||
|
|
||||||
while(ifptr) {
|
while(ifptr) {
|
||||||
struct reg_value rv;
|
struct reg_value rv;
|
||||||
@ -73,11 +72,6 @@ struct ipx_interface *get_interfaces(int ifnum) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ifnum >= 0 && this_ifnum++ != ifnum) {
|
|
||||||
ifptr = ifptr->Next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ipx_interface *nnic = malloc(sizeof(struct ipx_interface));
|
struct ipx_interface *nnic = malloc(sizeof(struct ipx_interface));
|
||||||
if(!nnic) {
|
if(!nnic) {
|
||||||
log_printf(LOG_ERROR, "Out of memory! (Tried to allocate %u bytes)", (unsigned int)sizeof(struct ipx_interface));
|
log_printf(LOG_ERROR, "Out of memory! (Tried to allocate %u bytes)", (unsigned int)sizeof(struct ipx_interface));
|
||||||
@ -135,6 +129,25 @@ struct ipx_interface *get_interfaces(int ifnum) {
|
|||||||
|
|
||||||
free(ifroot);
|
free(ifroot);
|
||||||
|
|
||||||
|
/* Delete every entry in the NIC list except the requested one */
|
||||||
|
if(ifnum >= 0) {
|
||||||
|
int this_ifnum = 0;
|
||||||
|
|
||||||
|
while(nics && this_ifnum++ < ifnum) {
|
||||||
|
struct ipx_interface *dnic = nics;
|
||||||
|
nics = nics->next;
|
||||||
|
|
||||||
|
free(dnic);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(nics && nics->next) {
|
||||||
|
struct ipx_interface *dnic = nics->next;
|
||||||
|
nics->next = nics->next->next;
|
||||||
|
|
||||||
|
free(dnic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nics;
|
return nics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +192,10 @@ static LRESULT CALLBACK main_wproc(HWND window, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
}
|
}
|
||||||
}else if(HIWORD(wp) == CBN_SELCHANGE && LOWORD(wp) == ID_PRI_LIST) {
|
}else if(HIWORD(wp) == CBN_SELCHANGE && LOWORD(wp) == ID_PRI_LIST) {
|
||||||
int nic = ComboBox_GetCurSel(windows.primary);
|
int nic = ComboBox_GetCurSel(windows.primary);
|
||||||
|
int this_nic = 1;
|
||||||
|
|
||||||
for(iface_list::iterator i = nics.begin(); i != nics.end(); i++) {
|
for(iface_list::iterator i = nics.begin(); i != nics.end(); i++) {
|
||||||
i->primary = (nic > 0 && i - nics.begin() == nic - 1);
|
i->primary = (i->enabled && this_nic++ == nic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user