avoid possible use of uninitialized intf_addr in nmrp_do()
[oweals/nmrpflash.git] / nmrpd.h
diff --git a/nmrpd.h b/nmrpd.h
index e061155b83dc1370bab3dc8cfbb9bd4d09c8a1fe..d65c8116003c339e8f614e835deb3dc5bb191248 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
 #ifndef NMRPD_H
 #define NMRPD_H
 #include <stdint.h>
+#include <signal.h>
 #include <stdbool.h>
 
 #if defined(_WIN32) || defined(_WIN64)
-#define NMRPFLASH_WINDOWS
-#elif defined(__linux__)
-#define NMRPFLASH_LINUX
+#      define NMRPFLASH_WINDOWS
 #elif defined(__APPLE__) && defined(__MACH__)
-#define NMRPFLASH_OSX
-#elif defined(__unix__)
-#define NMRPFLASH_UNIX
-#warning "nmrpflash is not fully supported on your operating system"
+#      define NMRPFLASH_UNIX
+#      define NMRPFLASH_OSX
+#      define NMRPFLASH_BSD
+#elif defined (__unix__)
+#      define NMRPFLASH_UNIX
+#      if defined(__linux__)
+#              define NMRPFLASH_LINUX
+#      elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#                      define NMRPFLASH_BSD
+#      else
+#              warning "nmrpflash is not fully supported on this platform"
+#      endif
+#else
+#      warning "nmrpflash is not supported on this platform"
 #endif
 
 #ifndef NMRPFLASH_WINDOWS
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #endif
 
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
 #ifndef PACKED
 #define PACKED __attribute__((packed))
 #endif
 
+#define NMRPFLASH_SET_REGION
+
 struct eth_hdr {
        uint8_t ether_dhost[6];
        uint8_t ether_shost[6];
@@ -81,6 +96,7 @@ struct nmrpd_args {
        const char *intf;
        const char *mac;
        enum nmrp_op op;
+       bool blind;
        uint16_t port;
        const char *region;
 };
@@ -98,7 +114,7 @@ const char *mac_to_str(uint8_t *mac);
 void win_perror2(const char *msg, DWORD err);
 void sock_perror(const char *msg);
 #else
-#define sock_perror(x) perror(x)
+#define sock_perror(x) xperror(x)
 #endif
 
 extern int verbosity;
@@ -133,4 +149,9 @@ int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo);
 
 time_t time_monotonic();
 char *lltostr(long long ll, int base);
+uint32_t bitcount(uint32_t n);
+uint32_t netmask(uint32_t count);
+void xperror(const char *msg);
+
+extern volatile sig_atomic_t g_interrupted;
 #endif