usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / shared / utils.h
blobdb20e3bac897357a70ad1c36515223cc8790f127
1 #ifndef __SHUTILS_H__
2 #define __SHUTILS_H__
5 #define PPP_PSEUDO_IP "10.64.64.64"
6 #define PPP_PSEUDO_NM "255.255.255.255"
7 #define PPP_PSEUDO_GW "10.112.112.112"
10 // extern int diag_led(int type, int act);
11 // extern int C_led(int i);
12 // extern int get_single_ip(char *ipaddr, int which);
13 // extern char *get_mac_from_ip(char *ip);
14 // extern struct dns_lists *get_dns_list(int no);
15 // extern char *get_wan_face(void);
16 // extern int check_wan_link(int num);
17 // extern char *get_complete_lan_ip(char *ip);
18 // extern int get_int_len(int num);
19 // extern int file_to_buf(char *path, char *buf, int len);
20 // int buf_to_file(char *path, char *buf);
21 // extern pid_t* find_pid_by_name( char* pidName);
22 // extern int find_pid_by_ps(char* pidName);
23 // extern int *find_all_pid_by_ps(char* pidName);
25 // extern long convert_ver(char *ver);
26 // extern int check_flash(void);
27 // extern int check_now_boot(void);
28 // extern int check_hw_type(void);
29 // extern int is_exist(char *filename);
31 // extern void encode(char *buf, int len);
32 // extern void decode(char *buf, int len);
34 // extern int set_register_value(unsigned short port_addr, unsigned short option_content);
35 // extern unsigned long get_register_value(unsigned short id, unsigned short num);
37 // struct wl_assoc_mac * get_wl_assoc_mac(int *c);
40 enum {
41 WL = 0,
42 DIAG = 1,
43 SES_LED1 = 2,
44 SES_LED2 = 3,
45 SES_BUTTON = 4,
46 DMZ = 7
49 enum {
50 START_LED,
51 STOP_LED,
52 MALFUNCTION_LED
56 // enum { UNKNOWN_BOOT = -1, PMON_BOOT, CFE_BOOT };
58 // enum { BCM4702_CHIP, BCM4712_CHIP, BCM5325E_CHIP, BCM4704_BCM5325F_CHIP, BCM5352E_CHIP, NO_DEFINE_CHIP };
60 // enum { FIRST, SECOND };
62 // enum { SYSLOG_LOG=1, SYSLOG_DEBUG, CONSOLE_ONLY, LOG_CONSOLE, DEBUG_CONSOLE };
65 typedef enum {
66 ACT_IDLE,
67 ACT_TFTP_UPGRADE,
68 ACT_WEB_UPGRADE,
69 ACT_WEBS_UPGRADE,
70 ACT_SW_RESTORE,
71 ACT_HW_RESTORE,
72 ACT_ERASE_NVRAM,
73 ACT_NVRAM_COMMIT,
74 ACT_UPGRADE_DONE
75 } ACTION;
76 #define ACTION_FILE "/tmp/action"
77 #define ACTION(cmd) buf_to_file(ACTION_FILE, cmd)
78 extern int check_action(void);
82 struct dns_lists {
83 int num_servers;
84 char dns_server[4][16];
87 struct wl_assoc_mac {
88 char mac[18];
91 #define PROTO_DHCP 0
92 #define PROTO_STATIC 1
93 #define PROTO_PPPOE 2
94 #define PROTO_PPTP 3
95 #define PROTO_L2TP 4
96 #define PROTO_HB 5
97 #define PROTO_EARTHLINK 6
98 #define PROTO_ERROR -1
103 #define split(word, wordlist, next, delim) \
104 for (next = wordlist, \
105 strncpy(word, next, sizeof(word)), \
106 word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
107 next = next ? next + sizeof(delim) - 1 : NULL ; \
108 strlen(word); \
109 next = next ? : "", \
110 strncpy(word, next, sizeof(word)), \
111 word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
112 next = next ? next + sizeof(delim) - 1 : NULL)
114 #define STRUCT_LEN(name) sizeof(name)/sizeof(name[0])
116 #endif