#include cleanup
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Wed, 3 Feb 2016 15:32:15 +0000 (17:32 +0200)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Wed, 3 Feb 2016 15:32:15 +0000 (17:32 +0200)
ethsock.c
nmrp.c
nmrpd.h

index 2eb8a427b923df1238c3c7b9324cd310f17f5ceb..b85b79e4040351b4bb03665fa2ce55538509aa33 100644 (file)
--- a/ethsock.c
+++ b/ethsock.c
@@ -7,10 +7,9 @@
 #include "nmrpd.h"
 
 #if defined(NMRPFLASH_WINDOWS)
-#define NMRPFLASH_ALIAS_PREFIX "net"
+#define NMRPFLASH_NETALIAS_PREFIX "net"
 #define WPCAP
 #include <pcap.h>
-#include <windows.h>
 #else
 #include <pcap.h>
 #include <ifaddrs.h>
@@ -151,7 +150,7 @@ static const char *intf_alias_to_wpcap(const char *intf)
 
        if (intf[0] == '\\') {
                return intf;
-       } else if (sscanf(intf, NMRPFLASH_ALIAS_PREFIX "%u", &dev_num) != 1) {
+       } else if (sscanf(intf, NMRPFLASH_NETALIAS_PREFIX "%u", &dev_num) != 1) {
                fprintf(stderr, "Invalid interface alias.\n");
                return NULL;
        }
@@ -162,7 +161,9 @@ static const char *intf_alias_to_wpcap(const char *intf)
 
        for (dev = devs; dev; dev = dev->next) {
                if (i == dev_num) {
-                       printf(NMRPFLASH_ALIAS_PREFIX "%u: %s\n", i, dev->name);
+                       if (verbosity) {
+                               printf("%s%u: %s\n", NMRPFLASH_NETALIAS_PREFIX, i, dev->name);
+                       }
                        strncpy(buf, dev->name, sizeof(buf) - 1);
                        buf[sizeof(buf) - 1] = '\0';
                        break;
@@ -332,7 +333,7 @@ ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len)
                if (ret == WAIT_TIMEOUT) {
                        return 0;
                } else if (ret != WAIT_OBJECT_0) {
-                       fprintf(stderr, "WaitForSingleObject: returned %d\n", (int)ret);
+                       win_perror("WaitForSingleObject", ret);
                        return -1;
                }
        }
diff --git a/nmrp.c b/nmrp.c
index bdbb6feb83a687cfae2b7ee4108f93ec6b13d640..288bbb79ad164e61fad10ad74fd4b77504c4f214 100644 (file)
--- a/nmrp.c
+++ b/nmrp.c
@@ -17,7 +17,6 @@
  *
  */
 
-#define _BSD_SOURCE
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include "ethsock.h"
 #include "nmrpd.h"
 
-#ifndef NMRPFLASH_WINDOWS
-#include <arpa/inet.h>
-#else
-#include <winsock2.h>
-#endif
-
 #define NMRP_HDR_LEN 6
 #define NMRP_OPT_LEN 4
 #define NMRP_MIN_PKT_LEN (sizeof(struct eth_hdr) +  NMRP_HDR_LEN)
diff --git a/nmrpd.h b/nmrpd.h
index 25d9e5fa9b3e34094bfb8c607d2fe77a9401b828..71d37c40041bc58c7008807b8f36a582efb9c7c1 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
@@ -34,7 +34,6 @@
 #endif
 
 #ifndef NMRPFLASH_WINDOWS
-#define _BSD_SOURCE
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <net/if.h>
@@ -42,6 +41,7 @@
 #include <winsock2.h>
 #include <iphlpapi.h>
 #include <ws2tcpip.h>
+#include <windows.h>
 #endif
 
 #define NMRPD_VERSION "0.9"