Basic USB Storage and Printing Support with GUI.
[tomato.git] / release / src / router / shared / shared.h
blob9fd40bc060a2b629fa0f2ac4abc941204e492955
1 #ifndef __SHARED_H__
2 #define __SHARED_H__
4 #include <tomato_profile.h>
6 #include <netinet/in.h>
7 #include <stdint.h>
8 #include <errno.h>
10 #include <mntent.h> // !!TB
12 #define Y2K 946684800UL // seconds since 1970
14 #define ASIZE(array) (sizeof(array) / sizeof(array[0]))
16 //version.c
17 extern const char *tomato_version;
18 extern const char *tomato_buildtime;
21 // misc.c
22 #define WP_DISABLED 0 // order must be synced with def in misc.c
23 #define WP_STATIC 1
24 #define WP_DHCP 2
25 #define WP_L2TP 3
26 #define WP_PPPOE 4
27 #define WP_PPTP 5
29 enum {
30 ACT_IDLE,
31 ACT_TFTP_UPGRADE_UNUSED,
32 ACT_WEB_UPGRADE,
33 ACT_WEBS_UPGRADE_UNUSED,
34 ACT_SW_RESTORE,
35 ACT_HW_RESTORE,
36 ACT_ERASE_NVRAM,
37 ACT_NVRAM_COMMIT,
38 ACT_REBOOT,
39 ACT_UNKNOWN
42 typedef struct {
43 int count;
44 struct in_addr dns[3];
45 } dns_list_t;
47 extern int get_wan_proto(void);
48 extern int using_dhcpc(void);
49 extern void notice_set(const char *path, const char *format, ...);
50 extern int check_wanup(void);
51 extern const dns_list_t *get_dns(void);
52 extern void set_action(int a);
53 extern int check_action(void);
54 extern int wait_action_idle(int n);
55 extern int wl_client(void);
56 extern const char *get_wanip(void);
57 extern long get_uptime(void);
58 extern int get_radio(void);
59 extern void set_radio(int on);
60 extern int nvram_get_int(const char *key);
61 // extern long nvram_xget_long(const char *name, long min, long max, long def);
62 extern int nvram_get_file(const char *key, const char *fname, int max);
63 extern int nvram_set_file(const char *key, const char *fname, int max);
64 extern int nvram_contains_word(const char *key, const char *word);
65 extern int connect_timeout(int fd, const struct sockaddr *addr, socklen_t len, int timeout);
66 //!!TB
67 extern struct mntent *findmntent(char *file);
69 // id.c
70 enum {
71 MODEL_UNKNOWN,
72 MODEL_WRT54G,
73 MODEL_WRTSL54GS,
74 MODEL_WHRG54S,
75 MODEL_WHRHPG54,
76 MODEL_WR850GV1,
77 MODEL_WR850GV2,
78 MODEL_WZRG54,
79 MODEL_WL500GP,
80 MODEL_WL500GPv2,
81 MODEL_WL500GE,
82 MODEL_WL520GU,
83 MODEL_WBRG54,
84 MODEL_WBR2G54,
85 MODEL_WX6615GT,
86 MODEL_WZRHPG54,
87 MODEL_WZRRSG54,
88 MODEL_WZRRSG54HP,
89 MODEL_WVRG54NF,
90 MODEL_WHR2A54G54,
91 MODEL_WHR3AG54,
92 MODEL_RT390W,
93 MODEL_MN700,
94 MODEL_WRH54G,
95 MODEL_WHRG125
97 #if TOMATO_N
99 MODEL_WZRG300N,
100 MODEL_WRT300N
101 #endif
104 enum {
105 HW_BCM4702,
106 HW_BCM4712,
107 HW_BCM5325E,
108 HW_BCM4704_BCM5325F,
109 HW_BCM5352E,
110 HW_BCM5354G,
111 HW_BCM4712_BCM5325E,
112 HW_BCM4704_BCM5325F_EWC,
113 HW_BCM4705L_BCM5325E_EWC,
114 HW_UNKNOWN
117 #define SUP_SES (1 << 0)
118 #define SUP_BRAU (1 << 1)
119 #define SUP_AOSS_LED (1 << 2)
120 #define SUP_WHAM_LED (1 << 3)
121 #define SUP_HPAMP (1 << 4)
122 #define SUP_NONVE (1 << 5)
123 #define SUP_80211N (1 << 6)
125 extern int check_hw_type(void);
126 // extern int get_hardware(void) __attribute__ ((weak, alias ("check_hw_type")));
127 extern int get_model(void);
128 extern int supports(unsigned long attr);
132 // process.c
133 extern char *psname(int pid, char *buffer, int maxlen);
134 extern int pidof(const char *name);
135 extern int killall(const char *name, int sig);
138 // files.c
139 #define FW_CREATE 0
140 #define FW_APPEND 1
141 #define FW_NEWLINE 2
143 extern unsigned long f_size(const char *path);
144 extern int f_exists(const char *file);
145 extern int f_read(const char *file, void *buffer, int max); // returns bytes read
146 extern int f_write(const char *file, const void *buffer, int len, unsigned flags, unsigned cmode); //
147 extern int f_read_string(const char *file, char *buffer, int max); // returns bytes read, not including term; max includes term
148 extern int f_write_string(const char *file, const char *buffer, unsigned flags, unsigned cmode); //
149 extern int f_read_alloc(const char *path, char **buffer, int max);
150 extern int f_read_alloc_string(const char *path, char **buffer, int max);
153 // led.c
154 #define LED_WLAN 0
155 #define LED_DIAG 1
156 #define LED_WHITE 2
157 #define LED_AMBER 3
158 #define LED_DMZ 4
159 #define LED_AOSS 5
160 #define LED_BRIDGE 6
161 #define LED_MYSTERY 7 // (unmarked LED between wireless and bridge on WHR-G54S)
162 #define LED_COUNT 8
164 #define LED_OFF 0
165 #define LED_ON 1
166 #define LED_BLINK 2
167 #define LED_PROBE 3
169 extern const char *led_names[];
171 extern void gpio_write(uint32_t bit, int en);
172 extern uint32_t gpio_read(void);
173 extern int nvget_gpio(const char *name, int *gpio, int *inv);
174 extern int led(int which, int mode);
177 // base64.c
178 extern int base64_encode(unsigned char *in, char *out, int inlen); // returns amount of out buffer used
179 extern int base64_decode(const char *in, unsigned char *out, int inlen); // returns amount of out buffer used
180 extern int base64_encoded_len(int len);
181 extern int base64_decoded_len(int len); // maximum possible, not actual
184 // strings.c
185 extern const char *find_word(const char *buffer, const char *word);
186 extern int remove_word(char *buffer, const char *word);
188 #endif