Display partition types for unmounted partitions.
[tomato.git] / release / src / router / shared / shared.h
blob3b3768130f7e309ed3c8ac9ce2fa29c04695abe9
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 char *detect_fs_type(char *device);
68 extern struct mntent *findmntent(char *file);
69 extern int find_label(char *mnt_dev, char *the_label);
71 #define DEV_DISCS_ROOT "/dev/discs"
73 /* Flags used in exec_for_host calls
75 #define EFH_1ST_HOST 0x00000001 /* func is called for the 1st time for this host */
76 #define EFH_1ST_DISC 0x00000002 /* func is called for the 1st time for this disc */
77 #define EFH_HUNKNOWN 0x00000004 /* host is unknown */
78 #define EFH_USER 0x00000008 /* process is user-initiated - either via Web GUI or a script */
80 typedef int (*host_exec)(char *dev_name, int host_num, int disc_num, int part_num, uint flags);
81 extern int exec_for_host(int host, int when_to_update, uint flags, host_exec func);
83 // id.c
84 enum {
85 MODEL_UNKNOWN,
86 MODEL_WRT54G,
87 MODEL_WRTSL54GS,
88 MODEL_WHRG54S,
89 MODEL_WHRHPG54,
90 MODEL_WR850GV1,
91 MODEL_WR850GV2,
92 MODEL_WZRG54,
93 MODEL_WL500GP,
94 MODEL_WL500GPv2,
95 MODEL_WL500GE,
96 MODEL_WL520GU,
97 MODEL_WBRG54,
98 MODEL_WBR2G54,
99 MODEL_WX6615GT,
100 MODEL_WZRHPG54,
101 MODEL_WZRRSG54,
102 MODEL_WZRRSG54HP,
103 MODEL_WVRG54NF,
104 MODEL_WHR2A54G54,
105 MODEL_WHR3AG54,
106 MODEL_RT390W,
107 MODEL_MN700,
108 MODEL_WRH54G,
109 MODEL_WHRG125
111 #if TOMATO_N
113 MODEL_WZRG300N,
114 MODEL_WRT300N
115 #endif
118 enum {
119 HW_BCM4702,
120 HW_BCM4712,
121 HW_BCM5325E,
122 HW_BCM4704_BCM5325F,
123 HW_BCM5352E,
124 HW_BCM5354G,
125 HW_BCM4712_BCM5325E,
126 HW_BCM4704_BCM5325F_EWC,
127 HW_BCM4705L_BCM5325E_EWC,
128 HW_UNKNOWN
131 #define SUP_SES (1 << 0)
132 #define SUP_BRAU (1 << 1)
133 #define SUP_AOSS_LED (1 << 2)
134 #define SUP_WHAM_LED (1 << 3)
135 #define SUP_HPAMP (1 << 4)
136 #define SUP_NONVE (1 << 5)
137 #define SUP_80211N (1 << 6)
139 extern int check_hw_type(void);
140 // extern int get_hardware(void) __attribute__ ((weak, alias ("check_hw_type")));
141 extern int get_model(void);
142 extern int supports(unsigned long attr);
146 // process.c
147 extern char *psname(int pid, char *buffer, int maxlen);
148 extern int pidof(const char *name);
149 extern int killall(const char *name, int sig);
152 // files.c
153 #define FW_CREATE 0
154 #define FW_APPEND 1
155 #define FW_NEWLINE 2
157 extern unsigned long f_size(const char *path);
158 extern int f_exists(const char *file);
159 extern int f_read(const char *file, void *buffer, int max); // returns bytes read
160 extern int f_write(const char *file, const void *buffer, int len, unsigned flags, unsigned cmode); //
161 extern int f_read_string(const char *file, char *buffer, int max); // returns bytes read, not including term; max includes term
162 extern int f_write_string(const char *file, const char *buffer, unsigned flags, unsigned cmode); //
163 extern int f_read_alloc(const char *path, char **buffer, int max);
164 extern int f_read_alloc_string(const char *path, char **buffer, int max);
167 // led.c
168 #define LED_WLAN 0
169 #define LED_DIAG 1
170 #define LED_WHITE 2
171 #define LED_AMBER 3
172 #define LED_DMZ 4
173 #define LED_AOSS 5
174 #define LED_BRIDGE 6
175 #define LED_MYSTERY 7 // (unmarked LED between wireless and bridge on WHR-G54S)
176 #define LED_COUNT 8
178 #define LED_OFF 0
179 #define LED_ON 1
180 #define LED_BLINK 2
181 #define LED_PROBE 3
183 extern const char *led_names[];
185 extern void gpio_write(uint32_t bit, int en);
186 extern uint32_t gpio_read(void);
187 extern int nvget_gpio(const char *name, int *gpio, int *inv);
188 extern int led(int which, int mode);
191 // base64.c
192 extern int base64_encode(unsigned char *in, char *out, int inlen); // returns amount of out buffer used
193 extern int base64_decode(const char *in, unsigned char *out, int inlen); // returns amount of out buffer used
194 extern int base64_encoded_len(int len);
195 extern int base64_decoded_len(int len); // maximum possible, not actual
198 // strings.c
199 extern const char *find_word(const char *buffer, const char *word);
200 extern int remove_word(char *buffer, const char *word);
202 #endif