yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #ifndef _ZTE_ROUTER_H_ |
| 2 | #define _ZTE_ROUTER_H_ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/stat.h> |
| 9 | #include <fcntl.h> |
| 10 | #include <netinet/in.h> |
| 11 | #include <unistd.h> |
| 12 | #include <sys/ipc.h> |
| 13 | #include <sys/msg.h> |
| 14 | #include <pthread.h> |
| 15 | #include <errno.h> |
| 16 | #include <signal.h> |
| 17 | #include <sys/socket.h> |
| 18 | #include <syslog.h> |
| 19 | #include <sys/klog.h> |
| 20 | #include <assert.h> |
| 21 | #include <ctype.h> |
| 22 | #include <sys/socket.h> |
| 23 | #include <netinet/in.h> |
| 24 | #include <arpa/inet.h> |
| 25 | #include "soft_timer.h" |
| 26 | #include "message.h" |
| 27 | #include "softap_api.h" |
| 28 | #include "cfg_nv_def.h" |
| 29 | |
| 30 | |
| 31 | /************************************************************************** |
| 32 | * Types * |
| 33 | **************************************************************************/ |
| 34 | |
| 35 | #define RULE_MAX 10 |
| 36 | #define ZTE_ROUTER_FW_PORT_LEN 6 |
| 37 | #define ZTE_ROUTER_FW_FLAG_LEN 4 |
| 38 | #define ZTE_ROUTER_WAN_IF_NAME_LEN 20 |
| 39 | #define ZTE_ROUTER_IP_ADDR_LEN 32 |
| 40 | #define ZTE_ROUTER_IPV6_ADDR_LEN 64 |
| 41 | |
| 42 | #define ZTE_FW_IP_ADDR_LEN_V6 45 |
| 43 | |
| 44 | #define ROUTER_DEFAULT_LEN 64 |
| 45 | #define ZTE_ROUTER_URL_FILTER_LEN 512 |
| 46 | #define MAX_OLD_URLS_COUNT 100 |
| 47 | #define NV_MACIP_LIST_MAX_LEN 500 //zte_mac_list_run |
| 48 | #define ROUTER_NV_ITEM_VALUE_MAX_LEN 256 |
| 49 | #define ROUTER_NV_FW_RULE_MAX_LEN 300 |
| 50 | #define IPPORT_FILTER_CHAIN "macipport_filter" |
| 51 | #define VPN_CHAIN "vpn_filter" |
| 52 | #define PORT_FORWARD_CHAIN "port_forward" |
| 53 | #define WEB_FILTER_CHAIN "web_filter" |
| 54 | #define DMZ_CHAIN "DMZ" |
| 55 | #define PORT_MAPPING_CHAIN "port_mapping" |
| 56 | |
| 57 | #define CLILDREN_MAC_CHAIN "children_filter" |
| 58 | #define CLILDREN_WEB_CHAIN "children_web_filter" |
| 59 | #define CLILDREN_WEB_PHONE_CHAIN "children_web_filter_phone" |
| 60 | |
| 61 | #define ACTION_DROP 0 |
| 62 | #define ACTION_ACCEPT 1 |
| 63 | |
| 64 | #define PROTO_UNKNOWN 0 |
| 65 | #define PROTO_TCP 1 |
| 66 | #define PROTO_UDP 2 |
| 67 | #define PROTO_TCP_UDP 3 |
| 68 | #define PROTO_ICMP 4 |
| 69 | #define PROTO_NONE 5 |
| 70 | |
| 71 | #define CONFIG_DEFAULT_LENGTH 64 |
| 72 | #define NV_QOS_LIST_MAX_LEN 500 |
| 73 | #define NV_STATIC_ROUTE_LIST_MAX_LEN 1500 |
| 74 | |
| 75 | #define ConnectWaitTime 180000 //1000=1s |
| 76 | #define StateTimerID 68 //timer ID |
| 77 | #define WaitTime 10000 //1000=1s |
| 78 | |
| 79 | #define FMT_ECHO_IPTABLES_CMD "1>/dev/null 2>&1" |
| 80 | |
| 81 | #define MAINCTRL_LOCK "mainctrl_lock" |
| 82 | |
| 83 | /************************************************************************** |
| 84 | * Global Struct * |
| 85 | **************************************************************************/ |
| 86 | typedef enum { |
| 87 | TIMER_MainCtrl_NvSaveID = 60, /*NvÖÜÆÚsave¶¨Ê±Æ÷ ID*/ |
| 88 | TIMER_MainCtrl_NetID = 66, /*Íø¿Ú¶¨Ê±Æ÷ID*/ |
| 89 | /*ºóÃæ²»ÄÜÔÙÌí¼Óеģ¬Ö»ÄÜÍùǰ¼Ó: ÒòÎªÍø¿Ú¶¨Ê±Æ÷IDÉè¼ÆÊÇ+devIdÖµ£¬Íùºó¼Ó»áÖØ¸´*/ |
| 90 | } T_emMainCtrl_SoftTimerId; |
| 91 | |
| 92 | struct url_list { |
| 93 | int count; |
| 94 | char url_list[MAX_OLD_URLS_COUNT][ZTE_ROUTER_URL_FILTER_LEN]; |
| 95 | }; |
| 96 | |
| 97 | /*struct mac_hostname{ |
| 98 | char mac[18]; |
| 99 | char hostname[500]; |
| 100 | };*/ |
| 101 | |
| 102 | struct mainctrl_notify_queue { |
| 103 | struct list_head list; |
| 104 | int notify_id; |
| 105 | }; |
| 106 | |
| 107 | extern char ps_wan[ZTE_ROUTER_WAN_IF_NAME_LEN]; |
| 108 | extern char usb_wan[ZTE_ROUTER_WAN_IF_NAME_LEN]; |
| 109 | extern char eth_wan[ZTE_ROUTER_WAN_IF_NAME_LEN]; |
| 110 | extern char wifi_wan[ZTE_ROUTER_WAN_IF_NAME_LEN]; |
| 111 | extern unsigned char ethwan_id; //ÓÃÓÚRJ45ÍâÍø¿ÚµÄ³¬Ê±´¦Àí |
| 112 | extern unsigned char wifiwan_id;//ÓÃÓÚwifiÍâÍø¿ÚµÄ³¬Ê±´¦Àí |
| 113 | |
| 114 | extern char g_router_nvconfig_buf[ROUTER_NV_ITEM_VALUE_MAX_LEN]; |
| 115 | extern char defwan_rel[ZTE_ROUTER_WAN_IF_NAME_LEN]; |
| 116 | |
| 117 | extern int g_mainctrl_factory_reset; |
| 118 | extern int g_mainctrl_reset_ext_cmd; |
| 119 | extern int g_mainctrl_poweroff_ext_cmd; |
| 120 | extern int g_mainctrl_restart_ext_cmd; |
| 121 | extern struct list_head g_mainctrl_reset_notify; |
| 122 | extern struct list_head g_mainctrl_poweroff_notify; |
| 123 | extern struct list_head g_mainctrl_restart_notify; |
| 124 | |
| 125 | /********************netdev_proc.c start********************************/ |
| 126 | extern int net_pdp_act_proc(struct pdp_active_info *actinfo); |
| 127 | extern int net_pdp_deact_proc(int c_id, unsigned char ip46flag); |
| 128 | extern int net_netdev_connect_internet(unsigned char netdev_id); |
| 129 | extern int net_netdev_disconnect_internet(unsigned char netdev_id); |
| 130 | extern int net_netdev_plugin_proc(unsigned char netdev_id); |
| 131 | extern int net_netdev_plugout_proc(unsigned char netdev_id); |
| 132 | extern int net_tc_control(struct tc_control_info *tcinfo,int src_id); |
| 133 | extern void proc_wan_change_v4(void); |
| 134 | extern void proc_wan_change_v6(void); |
| 135 | extern void out_of_time(unsigned char netdev_id); |
| 136 | extern void deletetimer(unsigned char netdev_id); |
| 137 | extern void creattimer(unsigned char* netdev_id); |
| 138 | extern int pdp_act_check(struct pdp_active_info *actinfo); |
| 139 | extern void set_pdp_mode(int c_id, unsigned char pdp_type); |
| 140 | extern void set_pdp_act_type(int c_id, unsigned char ip46flag); |
| 141 | extern int pdp_wan_config(struct pdp_active_info *actinfo); |
| 142 | extern int pdp_direct_config(struct pdp_active_info *actinfo); |
| 143 | extern int pdp_ppp_config(struct pdp_active_info *actinfo); |
| 144 | extern void reset_pdp_mode(int c_id); |
| 145 | extern void eth_connect(); |
| 146 | extern void wifi_connect(); |
| 147 | extern void vlan_config(unsigned int sw_type, char* act); |
| 148 | extern void ethwan_plugin(); |
| 149 | extern void ethlan_plugin(); |
| 150 | extern void ethwan_plugout(); |
| 151 | extern void ethlan_plugout(); |
| 152 | extern void wifi_plugin(); |
| 153 | extern void net_default_wan_proc(struct default_dev_info *dev); |
| 154 | /********************netdev_proc.c end********************************/ |
| 155 | |
| 156 | /********************net_xfrm.c start********************************/ |
| 157 | extern void zte_router_init(void); |
| 158 | extern int getNthValueSafe(int index, char *value, char delimit, char *result, int len); |
| 159 | extern void zte_iptables_Webs_Filter_Run(void); |
| 160 | extern void zte_iptables_port_map_all_run(void); |
| 161 | extern void zte_iptables_DMZ_Run(void); |
| 162 | extern void zte_iptables_sys_fw_run(void); |
| 163 | extern void zte_iptables_port_forward_run(void); |
| 164 | extern void zte_iptables_filter_run(void); |
| 165 | extern void zte_iptables_filter_run_v6(void); |
| 166 | extern void system_cmd_ex(char * cmd); |
| 167 | extern void zte_iptables_child_filter_run(); |
| 168 | extern void zte_router_ping_diagnostics(void); |
| 169 | |
| 170 | |
| 171 | /********************net_xfrm.c end********************************/ |
| 172 | |
| 173 | /********************net_other.c start********************************/ |
| 174 | extern void zte_router_MTU_set(void); |
| 175 | extern void zte_unpn_set(void); |
| 176 | extern void zte_router_dhcp_set_process(void); |
| 177 | extern void alg_control_fun(); |
| 178 | extern void zte_router_mtu_set_process(void); |
| 179 | |
| 180 | extern void get_mac_hostname_pro(struct mac_hostname_info *mac_hostname_); |
| 181 | extern void zte_macip_list_run(void); |
| 182 | extern void zte_bind_macip_list(void); |
| 183 | extern void zte_bind_macip_list_add(struct static_macip_info *static_macip); |
| 184 | extern void zte_bind_macip_list_del(char* mac); |
| 185 | extern void children_device_add(struct mac_hostname_info *mac_hostname); |
| 186 | extern void children_device_del(char* mac); |
| 187 | extern void white_site_add(struct white_site_info *white_site); |
| 188 | extern void white_site_remove(char* ids); |
| 189 | extern void zte_children_start_nonet(void); |
| 190 | extern void zte_children_stop_nonet(void); |
| 191 | extern void zte_router_dhcp_setting_req_process(dhcp_setting_req *pdhcp_setting_req); |
| 192 | /********************net_other.c end********************************/ |
| 193 | |
| 194 | int pppoe_encrypt_code(void); |
| 195 | int pppoe_decrypt_code(void); |
| 196 | int pppoe_aes_init(void); |
| 197 | |
| 198 | #endif |