Windows fixes
[oweals/nmrpflash.git] / ethsock.c
index 024d77df6147402ba2f6b2c21303df0f3b2de590..75e166867047e8d9026fb06a688b05a655f45221 100644 (file)
--- a/ethsock.c
+++ b/ethsock.c
@@ -40,7 +40,7 @@ struct ethsock
 
 struct ethsock_ip_undo
 {
-#ifndef NRMPFLASH_WINDOWS
+#ifndef NMRPFLASH_WINDOWS
        uint32_t ip[2];
 #else
        ULONG context;
@@ -152,7 +152,7 @@ static bool get_intf_info(const char *intf, uint8_t *hwaddr, DWORD *index)
 
        if ((ret = GetAdaptersInfo(adapters, &bufLen) == NO_ERROR)) {
                for (adapter = adapters; adapter; adapter = adapter->Next) {
-                       if (adapter->Type != MIB_IF_TYPE_ETHERNET) {
+                       if (adapter->Type != MIB_IF_TYPE_ETHERNET && adapter->Type != IF_TYPE_IEEE80211) {
                                continue;
                        }
 
@@ -751,8 +751,10 @@ out:
 #else // NMRPFLASH_WINDOWS
        ULONG instance;
 
-       DWORD ret = AddIPAddress(ipaddr, ipmask, sock->index, &undo->context, &instance);
-       if (ret != NO_ERROR) {
+       (*undo)->context = 0;
+
+       DWORD ret = AddIPAddress(ipaddr, ipmask, sock->index, &(*undo)->context, &instance);
+       if (ret != NO_ERROR && ret != ERROR_DUP_DOMAINNAME && ret != ERROR_OBJECT_ALREADY_EXISTS) {
                win_perror2("AddIPAddress", ret);
                return -1;
        }
@@ -776,13 +778,8 @@ int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo)
                ret = 0;
        }
 #else
-       DWORD err = DeleteIPAddress((*undo)->context);
-       if (err != NO_ERROR) {
-               win_perror2("DeleteIPAddress", ret);
-               ret = -1;
-       } else {
-               ret = 0;
-       }
+       DeleteIPAddress((*undo)->context);
+       ret = 0;
 #endif
 
        free(*undo);