Move OS defines to nmrpd.h
[oweals/nmrpflash.git] / nmrpd.h
1 /**
2  * nmrp-flash - Netgear Unbrick Utility
3  * Copyright (C) 2016 Joseph Lehner <joseph.c.lehner@gmail.com>
4  *
5  * nmrp-flash is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * nmrp-flash is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with nmrp-flash.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19
20 #ifndef NMRPD_H
21 #define NMRPD_H
22 #include <stdint.h>
23 #include <stdbool.h>
24
25 #if defined(_WIN32) || defined(_WIN64)
26 #define NMRPFLASH_WINDOWS
27 #elif defined(__linux__)
28 #define NMRPFLASH_LINUX
29 #elif defined(__APPLE__) && defined(__MACH__)
30 #define NMRPFLASH_OSX
31 #elif defined(__unix__)
32 #define NMRPFLASH_UNIX
33 #warning "nmrp-flash is not fully supported on your operating system"
34 #endif
35
36 #define NMRPD_VERSION "0.9"
37
38 enum nmrp_op {
39         NMRP_UPLOAD_FW = 0,
40         NMRP_UPLOAD_ST = 1,
41         NMRP_SET_REGION = 2,
42 };
43
44 struct nmrpd_args {
45         unsigned rx_timeout;
46         unsigned ul_timeout;
47         const char *tftpcmd;
48         const char *filename;
49         const char *ipaddr;
50         const char *ipmask;
51         const char *intf;
52         const char *mac;
53         enum nmrp_op op;
54         uint16_t port;
55         int force_root;
56 };
57
58 int sock_set_rx_timeout(int sock, unsigned msec);
59 int tftp_put(struct nmrpd_args *args);
60 int nmrp_do(struct nmrpd_args *args);
61
62
63 #endif