X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=nmrpd.h;h=841b4f3758ef82d78d0b1e1a3d4e69e6c03e0559;hb=54114efc39ab39087c6093065ca704ee1475e87c;hp=befa93234c3e58d6cd93c2aaba91accf4fa4cfdf;hpb=486a3a2e6973947706fa19ae809a41782fd400b2;p=oweals%2Fnmrpflash.git diff --git a/nmrpd.h b/nmrpd.h index befa932..841b4f3 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -1,19 +1,19 @@ /** - * nmrp-flash - Netgear Unbrick Utility + * nmrpflash - Netgear Unbrick Utility * Copyright (C) 2016 Joseph Lehner * - * 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 . + * along with nmrpflash. If not, see . * */ @@ -30,13 +30,18 @@ #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 +#include #include +#include #include +#ifndef NMRPFLASH_LINUX +#include +#endif #else #include #include @@ -44,7 +49,9 @@ #include #endif -#define NMRPD_VERSION "0.9" +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif enum nmrp_op { NMRP_UPLOAD_FW = 0, @@ -56,19 +63,53 @@ 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; - 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); + 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); + +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