1
0
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:
Daniel Collins 2012-07-22 18:57:06 +00:00
parent f000b16d03
commit 999500b865
2 changed files with 21 additions and 7 deletions

View File

@ -54,7 +54,6 @@ struct ipx_interface *get_interfaces(int ifnum) {
struct ipx_interface *nics = NULL, *enic = NULL;
IP_ADAPTER_INFO *ifptr = ifroot;
int this_ifnum = 0;
while(ifptr) {
struct reg_value rv;
@ -73,11 +72,6 @@ struct ipx_interface *get_interfaces(int ifnum) {
continue;
}
if(ifnum >= 0 && this_ifnum++ != ifnum) {
ifptr = ifptr->Next;
continue;
}
struct ipx_interface *nnic = malloc(sizeof(struct ipx_interface));
if(!nnic) {
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);
/* 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;
}

View File

@ -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) {
int nic = ComboBox_GetCurSel(windows.primary);
int this_nic = 1;
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);
}
}