Add msg_add_opt
[oweals/nmrpflash.git] / nmrpd.h
diff --git a/nmrpd.h b/nmrpd.h
index bcbe5228d5ef3054412d6e532c042593fb5be08d..28d3f0fd825a145cad0ca2a41f41292a306cc615 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
@@ -1,19 +1,19 @@
 /**
- * nmrp-flash - Netgear Unbrick Utility
+ * nmrpflash - Netgear Unbrick Utility
  * Copyright (C) 2016 Joseph Lehner <joseph.c.lehner@gmail.com>
  *
- * nmrp-flash is free software: you can redistribute it and/or modify
+ * nmrpflash is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * nmrp-flash is distributed in the hope that it will be useful,
+ * nmrpflash is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with nmrp-flash.  If not, see <http://www.gnu.org/licenses/>.
+ * along with nmrpflash.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
 
 #define NMRPFLASH_OSX
 #elif defined(__unix__)
 #define NMRPFLASH_UNIX
-#warning "nmrp-flash is not fully supported on your operating system"
+#warning "nmrpflash is not fully supported on your operating system"
 #endif
 
 #ifndef NMRPFLASH_WINDOWS
 #include <arpa/inet.h>
+#include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
 #include <net/if.h>
+#ifndef NMRPFLASH_LINUX
+#include <net/if_dl.h>
+#endif
 #else
 #include <winsock2.h>
 #include <iphlpapi.h>
 #include <windows.h>
 #endif
 
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
 enum nmrp_op {
        NMRP_UPLOAD_FW = 0,
        NMRP_UPLOAD_ST = 1,
@@ -54,17 +63,22 @@ struct nmrpd_args {
        unsigned rx_timeout;
        unsigned ul_timeout;
        const char *tftpcmd;
-       const char *filename;
+       const char *file_local;
+       const char *file_remote;
        const char *ipaddr;
        const char *ipmask;
        const char *intf;
        const char *mac;
        enum nmrp_op op;
        uint16_t port;
+       uint16_t region;
        int force_root;
 };
 
+const char *leafname(const char *path);
 int tftp_put(struct nmrpd_args *args);
+bool tftp_is_valid_filename(const char *filename);
+
 int nmrp_do(struct nmrpd_args *args);
 
 int select_fd(int fd, unsigned timeout);
@@ -89,4 +103,14 @@ int ethsock_set_timeout(struct ethsock *sock, unsigned msec);
 uint8_t *ethsock_get_hwaddr(struct ethsock *sock);
 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);
 #endif