| 1 | #include <cy_conf.h>
|
|---|
| 2 |
|
|---|
| 3 | extern int diag_led(int type, int act);
|
|---|
| 4 | extern int C_led(int i);
|
|---|
| 5 | extern int get_single_ip(char *ipaddr, int which);
|
|---|
| 6 | extern char *get_mac_from_ip(char *ip);
|
|---|
| 7 | extern struct dns_lists *get_dns_list(int no);
|
|---|
| 8 | extern int dns_to_resolv(void);
|
|---|
| 9 | extern char *get_wan_face(void);
|
|---|
| 10 | extern int check_wan_link(int num);
|
|---|
| 11 | extern char *get_complete_lan_ip(char *ip);
|
|---|
| 12 | extern int get_int_len(int num);
|
|---|
| 13 | extern int file_to_buf(char *path, char *buf, int len);
|
|---|
| 14 | extern int buf_to_file(char *path, char *buf);
|
|---|
| 15 | extern pid_t* find_pid_by_name( char* pidName);
|
|---|
| 16 | extern int find_pid_by_ps(char* pidName);
|
|---|
| 17 | extern int *find_all_pid_by_ps(char* pidName);
|
|---|
| 18 | extern char *find_name_by_proc(int pid);
|
|---|
| 19 | extern int get_ppp_pid(char *file);
|
|---|
| 20 | extern long convert_ver(char *ver);
|
|---|
| 21 | extern int check_flash(void);
|
|---|
| 22 | extern int check_action(void);
|
|---|
| 23 | extern int check_now_boot(void);
|
|---|
| 24 | extern int check_hw_type(void);
|
|---|
| 25 | extern int is_exist(char *filename);
|
|---|
| 26 | extern void set_ip_forward(char c);
|
|---|
| 27 | struct mtu_lists *get_mtu(char *proto);
|
|---|
| 28 | extern void set_host_domain_name(void);
|
|---|
| 29 |
|
|---|
| 30 | extern void encode(char *buf, int len);
|
|---|
| 31 | extern void decode(char *buf, int len);
|
|---|
| 32 |
|
|---|
| 33 | extern int sys_netdev_ioctl(int family, int socket, char *if_name, int cmd, struct ifreq *ifr);
|
|---|
| 34 |
|
|---|
| 35 | int ct_openlog(const char *ident, int option, int facility, char *log_name);
|
|---|
| 36 | void ct_syslog(int level, int enable, const char *fmt,...);
|
|---|
| 37 | void ct_logger(int level, const char *fmt,...);
|
|---|
| 38 | struct wl_assoc_mac * get_wl_assoc_mac(int *c);
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | enum { DMZ, SESSION, DIAG , WL};
|
|---|
| 43 |
|
|---|
| 44 | enum { START_LED, STOP_LED };
|
|---|
| 45 |
|
|---|
| 46 | typedef enum { ACT_IDLE,
|
|---|
| 47 | ACT_TFTP_UPGRADE,
|
|---|
| 48 | ACT_WEB_UPGRADE,
|
|---|
| 49 | ACT_WEBS_UPGRADE,
|
|---|
| 50 | ACT_SW_RESTORE,
|
|---|
| 51 | ACT_HW_RESTORE } ACTION;
|
|---|
| 52 |
|
|---|
| 53 | enum { UNKNOWN_BOOT = -1, PMON_BOOT, CFE_BOOT };
|
|---|
| 54 |
|
|---|
| 55 | enum { BCM4702_CHIP, BCM4712_CHIP, BCM5325E_CHIP };
|
|---|
| 56 |
|
|---|
| 57 | enum { FIRST, SECOND };
|
|---|
| 58 |
|
|---|
| 59 | enum { SYSLOG_LOG=1, SYSLOG_DEBUG, CONSOLE_ONLY, LOG_CONSOLE, DEBUG_CONSOLE };
|
|---|
| 60 |
|
|---|
| 61 | #define ACTION(cmd) buf_to_file(ACTION_FILE, cmd)
|
|---|
| 62 |
|
|---|
| 63 | struct dns_lists {
|
|---|
| 64 | int num_servers;
|
|---|
| 65 | char dns_server[4][16];
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | #define NOT_USING 0
|
|---|
| 69 | #define USING 1
|
|---|
| 70 |
|
|---|
| 71 | struct wl_assoc_mac
|
|---|
| 72 | {
|
|---|
| 73 | char mac[18];
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | struct mtu_lists {
|
|---|
| 77 | char *proto; /* protocol */
|
|---|
| 78 | char *min; /* min mtu */
|
|---|
| 79 | char *max; /* max mtu */
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | #define PPP_PSEUDO_IP "10.64.64.64"
|
|---|
| 84 | #define PPP_PSEUDO_NM "255.255.255.255"
|
|---|
| 85 | #define PPP_PSEUDO_GW "10.112.112.112"
|
|---|
| 86 |
|
|---|
| 87 | #define PING_TMP "/tmp/ping.log"
|
|---|
| 88 | #define TRACEROUTE_TMP "/tmp/traceroute.log"
|
|---|
| 89 | #define MAX_BUF_LEN 254
|
|---|
| 90 |
|
|---|
| 91 | #define RESOLV_FILE "/tmp/resolv.conf"
|
|---|
| 92 | #define HOSTS_FILE "/tmp/hosts"
|
|---|
| 93 |
|
|---|
| 94 | #define LOG_FILE "/var/log/mess"
|
|---|
| 95 |
|
|---|
| 96 | #define ACTION_FILE "/tmp/action"
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | #define split(word, wordlist, next, delim) \
|
|---|
| 100 | for (next = wordlist, \
|
|---|
| 101 | strncpy(word, next, sizeof(word)), \
|
|---|
| 102 | word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
|
|---|
| 103 | next = next ? next + sizeof(delim) - 1 : NULL ; \
|
|---|
| 104 | strlen(word); \
|
|---|
| 105 | next = next ? : "", \
|
|---|
| 106 | strncpy(word, next, sizeof(word)), \
|
|---|
| 107 | word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
|
|---|
| 108 | next = next ? next + sizeof(delim) - 1 : NULL)
|
|---|
| 109 |
|
|---|
| 110 | #define STRUCT_LEN(name) sizeof(name)/sizeof(name[0])
|
|---|
| 111 |
|
|---|
| 112 | #define printHEX(str,len) { \
|
|---|
| 113 | int i; \
|
|---|
| 114 | for (i=0 ; i<len ; i++) { \
|
|---|
| 115 | printf("%02X ", (unsigned char)*(str+i)); \
|
|---|
| 116 | if(((i+1)%16) == 0) printf("- "); \
|
|---|
| 117 | if(((i+1)%32) == 0) printf("\n"); \
|
|---|
| 118 | } \
|
|---|
| 119 | printf("\n\n"); \
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 | #define printASC(str,len) { \
|
|---|
| 124 | int i; \
|
|---|
| 125 | for (i=0 ; i<len ; i++) { \
|
|---|
| 126 | printf("%c", (unsigned char)*(str+i)); \
|
|---|
| 127 | if(((i+1)%16) == 0) printf("- "); \
|
|---|
| 128 | if(((i+1)%32) == 0) printf("\n"); \
|
|---|
| 129 | } \
|
|---|
| 130 | printf("\n\n"); \
|
|---|
| 131 | }
|
|---|