Update README.md
[oweals/nmrpflash.git] / nmrpd.h
diff --git a/nmrpd.h b/nmrpd.h
index 049b6479d15a720b61cc47bf0151d7a2ebb42cee..d54e4eb64535386aeef2cce5918515a21ed922b0 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
 #include <windows.h>
 #endif
 
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef PACKED
+#define PACKED __attribute__((packed))
+#endif
+
+struct eth_hdr {
+       uint8_t ether_dhost[6];
+       uint8_t ether_shost[6];
+       uint16_t ether_type;
+} PACKED;
+
 enum nmrp_op {
        NMRP_UPLOAD_FW = 0,
        NMRP_UPLOAD_ST = 1,
@@ -61,15 +75,17 @@ struct nmrpd_args {
        const char *tftpcmd;
        const char *file_local;
        const char *file_remote;
+       const char *ipaddr_intf;
        const char *ipaddr;
        const char *ipmask;
        const char *intf;
        const char *mac;
        enum nmrp_op op;
        uint16_t port;
-       int force_root;
+       const char *region;
 };
 
+const char *leafname(const char *path);
 int tftp_put(struct nmrpd_args *args);
 bool tftp_is_valid_filename(const char *filename);
 
@@ -88,6 +104,7 @@ void sock_perror(const char *msg);
 extern int verbosity;
 
 struct ethsock;
+struct ethsock_ip_undo;
 
 struct ethsock *ethsock_create(const char *intf, uint16_t protocol);
 int ethsock_close(struct ethsock *sock);
@@ -95,6 +112,21 @@ 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_arp_add(struct ethsock *sock, uint8_t *hwaddr, struct in_addr *ipaddr);
+int ethsock_arp_del(struct ethsock *sock, uint8_t *hwaddr, struct in_addr *ipaddr);
 int ethsock_list_all(void);
 
+struct ethsock_ip_callback_args
+{
+       struct in_addr *ipaddr;
+       struct in_addr *ipmask;
+       void *arg;
+};
+
+typedef int (*ethsock_ip_callback_t)(struct ethsock_ip_callback_args *args);
+int ethsock_for_each_ip(struct ethsock *sock, ethsock_ip_callback_t callback,
+               void *arg);
+
+int ethsock_ip_add(struct ethsock *sock, uint32_t ipaddr, uint32_t ipmask, struct ethsock_ip_undo **undo);
+int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo);
 #endif