4 #include <tomato_profile.h>
6 #include <netinet/in.h>
10 #include <mntent.h> // !!TB
12 #define Y2K 946684800UL // seconds since 1970
14 #define ASIZE(array) (sizeof(array) / sizeof(array[0]))
17 extern const char *tomato_version
;
18 extern const char *tomato_buildtime
;
22 #define WP_DISABLED 0 // order must be synced with def in misc.c
31 ACT_TFTP_UPGRADE_UNUSED
,
33 ACT_WEBS_UPGRADE_UNUSED
,
44 struct in_addr dns
[3];
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
);
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
);
126 HW_BCM4704_BCM5325F_EWC
,
127 HW_BCM4705L_BCM5325E_EWC
,
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
);
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
);
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
);
175 #define LED_MYSTERY 7 // (unmarked LED between wireless and bridge on WHR-G54S)
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
);
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
199 extern const char *find_word(const char *buffer
, const char *word
);
200 extern int remove_word(char *buffer
, const char *word
);