Set ackblock to -1 on timeout
[oweals/nmrpflash.git] / nmrpd.h
diff --git a/nmrpd.h b/nmrpd.h
index b6287dc8be19c36ebda4e44bc4fa14a09f98d82b..0f9e6ac949ffb5ab481606cd1a6de478b6710ec3 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
 #include <stdint.h>
 #include <stdbool.h>
 
+#if defined(_WIN32) || defined(_WIN64)
+#define NMRPFLASH_WINDOWS
+#elif defined(__linux__)
+#define NMRPFLASH_LINUX
+#elif defined(__APPLE__) && defined(__MACH__)
+#define NMRPFLASH_OSX
+#elif defined(__unix__)
+#define NMRPFLASH_UNIX
+#warning "nmrp-flash is not fully supported on your operating system"
+#endif
+
+#ifndef NMRPFLASH_WINDOWS
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#else
+#include <winsock2.h>
+#include <iphlpapi.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
+
 #define NMRPD_VERSION "0.9"
 
 enum nmrp_op {
@@ -44,9 +66,29 @@ struct nmrpd_args {
        int force_root;
 };
 
-int sock_set_rx_timeout(int sock, unsigned msec);
 int tftp_put(struct nmrpd_args *args);
 int nmrp_do(struct nmrpd_args *args);
 
+int select_fd(int fd, unsigned timeout);
+const char *mac_to_str(uint8_t *mac);
+
+#ifdef NMRPFLASH_WINDOWS
+void win_perror2(const char *msg, DWORD err);
+void sock_perror(const char *msg);
+#else
+#define sock_perror(x) perror(x)
+#endif
+
+extern int verbosity;
+
+struct ethsock;
+
+struct ethsock *ethsock_create(const char *intf, uint16_t protocol);
+int ethsock_close(struct ethsock *sock);
+int ethsock_send(struct ethsock *sock, void *buf, size_t len);
+ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len);
+int ethsock_set_timeout(struct ethsock *sock, unsigned msec);
+uint8_t *ethsock_get_hwaddr(struct ethsock *sock);
+int ethsock_list_all(void);
 
 #endif