1 /*****************************************************************************
3 # Copyright 2004 Broadcom Corp. All Rights Reserved.
4 # This program is free software; you can distribute it and/or modify it
5 # under the terms of the GNU General Public License (Version 2) as
6 # published by the Free Software Foundation.
7 # This program is distributed in the hope it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 # You should have received a copy of the GNU General Public License along
12 # with this program; if not, write to the Free Software Foundation, Inc.,
13 # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
15 ******************************************************************************
17 // Filename: syscall.h
18 // Author: Peter T. Tran
19 // Creation Date: 12/26/01
21 ******************************************************************************
23 // Define the global constants, and functions for sysCall utility.
25 *****************************************************************************/
27 #ifndef __SYS_CALL_H__
28 #define __SYS_CALL_H__
29 #include <netinet/in.h>
31 /********************** Global Functions ************************************/
33 #define FILE_OPEN_OK 0
34 #define FILE_OPEN_ERR -1
37 #define MNTR_STS_ADSL_DOWN 1
38 #define MNTR_STS_PPP_AUTH_ERR 2
39 #define MNTR_STS_PPP_DOWN 3
40 #define MNTR_STS_OPEN_ERR 4
41 #define MNTR_STS_DHCPC_PROGRESS 5
42 #define MNTR_STS_DHCPC_FAIL 6
43 #define MNTR_STS_ADSL_TRAINING 7
44 #define MNTR_STS_BRIDGE 8
46 #define DHCPC_STS_FAIL 0
47 #define DHCPC_STS_SUCCESS 1
48 #define DHCPC_FAIL_MAX 15
50 // Values for network protocol
54 #define PROTO_BRIDGE 3
55 #define PROTO_PPPOE_RELAY 4
57 #define PROTO_IPOWAN 6
60 #define SYSTEM_APPID "SystemInfo"
61 #define SYS_USER_NAME_ID 1
62 #define SYS_PASSWORD_ID 2
63 #define SPT_USER_NAME_ID 3
64 #define SPT_PASSWORD_ID 4
65 #define USR_USER_NAME_ID 5
66 #define USR_PASSWORD_ID 6
67 #define SYS_DFT_GTWY_ID 7
70 #define SYS_SNMP_ID 10
71 #define SYS_FLAG_ID 11
72 #define SYS_TR69C_ID 12
73 #define SYS_MGMT_LOCK_ID 13
74 #define SYS_HOSTNAME_ID 14 //Andy add to support hostname
75 #define SYS_DOMAINNAME_ID 15 //Andy add to support domain name
76 #define SYS_DDNS_ID 16 //Andy add to suuport ddns status
78 #define SYS_ACTPPPCONN_ID 17 //Andy add to support active ppp connect
79 #define SYS_FIREWALL_ID_ODM 18 //Wilson add to support enable/disable firewall from web page.
80 #define SYS_REMOTE_SERVICE_ID 19 //Andy Add to support Remote Access Service
81 #define SYS_REMOTE_AUTHSER_ID 20 //Andy Add to support Remote Access Service
82 #define SYS_PRINTERSERVER_ID 21 //Wilson add to support print server
83 #define SYS_ODM_VOICE_QOS_ID 22
84 #ifdef BUILD_PPP_DOMAIN_SUFFIX
85 #define SYS_SUFFIX_ID 23
88 #define SYS_WEBLANG_ID 24
90 #if defined(SUPPORT_SYS_ALG)
91 #if defined(SUPPORT_SYS_VPN_ALG) || defined(SUPPORT_SYS_SIP_ALG)
95 #if defined(ODM_LANG_NETGEAR)
96 #define SYS_BLANKSTATE_ID 26
99 #if defined(SUPPORT_AUTO_DETECT_DEFAULT_PVC)
100 #define SYS_AUTO_DETECT_DEFAULT_PVC_ID 27
103 // Values that are used in syscall.c
104 #define SYS_CMD_LEN 256
106 #define IP_TBL_COL_NUM 0
107 #define IP_TBL_COL_PKTS 1
108 #define IP_TBL_COL_BYTES 2
109 #define IP_TBL_COL_TARGET 3
110 #define IP_TBL_COL_PROT 4
111 #define IP_TBL_COL_OPT 5
112 #define IP_TBL_COL_IN 6
113 #define IP_TBL_COL_OUT 7
114 #define IP_TBL_COL_SRC 8
115 #define IP_TBL_COL_DST 9
116 #define IP_TBL_COL_MAX 10
118 #define UPNP_IP_ADDRESS "239.255.255.250"
120 #if defined(INCLUDE_EMBHTTPD)
121 typedef struct expTime_s {
128 //Paul add, 8/29/2006
130 #define PRINTER_STR_LEN 40
132 char printername[PRINTER_STR_LEN];
133 char ethmacaddr[PRINTER_STR_LEN];
134 char ipaddr[PRINTER_STR_LEN];
136 char wssid[PRINTER_STR_LEN];
137 char networktype[PRINTER_STR_LEN];
139 char adsllinerate[PRINTER_STR_LEN];
140 char internet[PRINTER_STR_LEN];
141 char dfgateway[PRINTER_STR_LEN];
142 char pdnsserver[PRINTER_STR_LEN];
143 char sdnsserver[PRINTER_STR_LEN];
144 char swverion[PRINTER_STR_LEN];
145 } PRINTER_VAR, *PPRINTER_VAR;
149 //Paul porting from 2.21.5, 7/24/2006
150 #ifdef INCLUDE_PRINT_SERVER
152 #define PRINTER_STR_LEN 40
154 char printername[PRINTER_STR_LEN];
155 char ethmacaddr[PRINTER_STR_LEN];
156 char ipaddr[PRINTER_STR_LEN];
158 char wssid[PRINTER_STR_LEN];
159 char networktype[PRINTER_STR_LEN];
161 char adsllinerate[PRINTER_STR_LEN];
162 char internet[PRINTER_STR_LEN];
163 char dfgateway[PRINTER_STR_LEN];
164 char pdnsserver[PRINTER_STR_LEN];
165 char sdnsserver[PRINTER_STR_LEN];
166 char swverion[PRINTER_STR_LEN];
167 } PRINTER_VAR, *PPRINTER_VAR;
171 //Paul add, 8/10/2006
172 #define STATUS_PRINTING 0x80
173 #define STATUS_OK 0x0
174 #define STATUS_OUT_PAPER 0x1
175 #define STATUS_OFFLINE 0x2
176 #define STATUS_ONFIRE 0x3
177 #define STATUS_NOT_CONNECTED 0x4
178 #define STATUS_UNKNOWN 0x5
185 #if defined(__cplusplus)
188 #define bcmSystem(cmd) bcmSystemEx (cmd,1)
189 #define bcmSystemMute(cmd) bcmSystemEx (cmd,0)
190 int bcmSystemEx (char *command, int printFlag);
191 int bcmSystemNoHang (char *command);
192 int bcmGetPid (char *command);
193 int *bcmGetPidList(char * command);
194 int bcmCreateDhcpCfg(char *ipAddr, char *mask, char *addrStart, char *addrEnd,
195 char *dns1, char *dns2, int leasedTime, int isForever, int protocol,
196 int enblNat, int enblFirewall, char *domain);
197 int bcmCreateIpExtDhcpCfg(char *lanAddr, char *mask, char *wanAddr, char *domain);
198 int bcmCreateLocalDhcpCfg(char *addr, char *mask, char *domain, char *startIp);
199 int bcmCreateResolvCfg(char *dns1, char *dns2);
200 //int bcmCreateLoginCfg(char *cp_admin, char *cp_support, char *cp_user);
201 int bcmCreateLoginCfg(char *, char *, char *, char *, char *, char *);
202 int bcmGetAdslStatus(void);
203 int bcmGetVdslStatus(void);
204 int bcmGetXdslStatus(void);
205 int bcmGetPppStatus(char *str, int len, char *devName);
206 int bcmGetDhcpcStatus(char *str, int len);
207 int bcmGetSystemStatus(char *str, int len);
208 int bcmSetSystemStatus(int status);
209 int bcmSetIpExtension(int ipExt);
210 int bcmGetIpExtension(char *str, int len);
211 void bcmDisplayLed(int status);
212 void bcmGetDns(char *dns);
213 void bcmGetDns2(char *dns);
214 void bcmGetDnsSettings(int *mode, char *primary, char *secondary);
215 //void bcmRestartDnsProbe(void);
216 void bcmConfigDns(char *dns1, char *dns2, int dynamic);
217 void bcmRemoveDefaultGatewayByWanIf(char *wanIf);
218 void bcmGetDefaultGateway(char *gtwy, char *wanIf);
219 void wsnGetDefaultGateway(char *gtwy, char *wanIf);
220 int bcmIsDefaultGatewayExisted(char *gw, char *wanIf);
221 void bcmSetAutoDefaultGateway(char *errMsg, int runcmd);
222 void bcmSetStaticDefaultGateway(char *gw, char *wanIf, char *errMsg);
223 void bcmKillAllApps(void);
224 void disconnectPPP(void);
225 void setWanLinkStatus(int up);
226 int bcmCheckInterfaceUp(char *devname);
227 int bcmSetIpExtInfo(char *wan, char *gateway, char *dns);
228 void bcmGetIpExtInfo(char *buf, int type);
229 int bcmGetIfcIndexByName(char *ifcName);
230 int bcmIsValidIfcName(char *ifcName);
231 char *bcmGetIfcNameById(int ifcId, char *ifcName);
232 char *bcmGetIfcNameByIpAddr(unsigned long ipAddr, char *ifcName);
233 void getPppoeServiceName(char *service, char *ifName);
234 void bcmGetDefaultRouteInterfaceName(char *ifcName);
236 void bcmSetConnTrackMax(void);
237 void bcmResetConnTrackTable(void);
238 void bcmHandleConnTrack(void);
239 void bcmInsertModules(char *path);
240 void bcmInsertModule(char *modName);
241 int bcmIsModuleInserted(char *modName);
242 int bcmRemoveIpTableRule(char *device, char *table, char *chain);
243 void bcmRemoveAllIpTableRules(char *device);
245 void bcmRemoveTrafficControlRules(unsigned short vpi, unsigned short vci,
246 unsigned short conId, unsigned char protocol);
247 void bcmAddTrafficControlRules(unsigned short vpi, unsigned short vci,
248 unsigned short conId, unsigned char protocol);
250 int bcmRemoveRipIpTableRule(void);
251 int bcmRemoveUpnpIpTableRule(void);
252 void bcmInsertAllUpnpIpTableRules(void);
253 int bcmGetIntfNameSocket(int socketfd, char *intfname);
254 int bcmCheckEnable(char *appName, struct in_addr clntAddr);
256 int bcmRemoveEbTableRule(char *device, char *table, char *chain);
257 void bcmRemoveAllEbTableRules(char *device);
258 void bcmRemoveAllBrFilterRules(char *device);
259 int bcmRemoveAllEbTableFORWARDrule();
261 int getIfaceIpAddr(char *buff, char *ifaceName);
262 int ODMCreateDhcpMap(void);
263 int odmbase64Encode(const void *inp, int insize, char **outptr);
264 void odmbase64Decode(unsigned char *dest, char *src, int *rawLength);
266 int GetMASQIpTableRule(char *device, char *table, char *chain);
267 int GetTCPMSSIpTableRule(char *device, char *table, char *chain);
269 void parseStrInfo(char *info, char *var, char *val, int len);
270 void bcmConvertStrToShellStr(char *str, char *buf);
271 void bcmProcessMarkStrChars(char *str);
272 int bcmIsMarkStrChar(char c);
273 void bcmSetVdslSwVer(char *swVer);
274 void bcmGetSwVer(char *swVer, int size);
275 void bcmGetVdslSwVer(char *swVer, int size);
276 int isAccessFromLan(struct in_addr clntAddr);
277 int checkChipId(char *strTagChipId, char *sig2);
278 void bcmRemoveModules(int lanIf);
279 int bcmWaitIntfExists(char *ifName);
282 #ifdef SUPPORT_IPP //Paul add, 8/29/2006
283 int print_test_page();
286 //Paul porting from 2.21.5, 7/24/2006
288 #ifdef INCLUDE_PRINT_SERVER
289 int print_test_page();
290 int get_printer_status(char *status_str, char *lp_name);
293 int bcmMacStrToNum(char *macAddr, char *str);
294 int bcmMacNumToStr(char *macAddr, char *str);
296 int bcmWanEnetQuerySwitch(char *ifName);
298 #ifdef PORT_MIRRORING
299 int bcmConfigPortMirroring (void *pMirrorCfg) ;
301 void bcmStoreDeviceInfoToProcFile(void);
302 #ifdef BUILD_DOMAIN_LOCK
303 int wsnCheckStrTail(char *username, char *validDomain);
304 int wsnIsValidPppUser(char *pppUser);
308 int SysPstnVoipStatus(char *status);
311 void bcmGetDynamicDnsAddr(char *dns, int primary);
313 void getInterfaceMac(char *macstr, char *iface);
316 #define BCM_PPPOE_CLIENT_STATE_PADO 0 /* waiting for PADO */
317 #define BCM_PPPOE_CLIENT_STATE_PADS 1 /* got PADO, waiting for PADS */
318 #define BCM_PPPOE_CLIENT_STATE_CONFIRMED 2 /* got PADS, session ID confirmed */
319 #define BCM_PPPOE_CLIENT_STATE_DOWN 3 /* totally down */
320 #define BCM_PPPOE_CLIENT_STATE_UP 4 /* totally up */
321 #define BCM_PPPOE_SERVICE_AVAILABLE 5 /* ppp service is available on the remote */
323 #define BCM_PPPOE_AUTH_FAILED 7
324 #define WSN_PPPOE_STATE_DISCONNECTED -10//wilson add for Tr069 status
325 #define WSN_PPPOE_STATE_CONNECTING -11//wilson add for Tr069 status
327 #define BCM_PRIMARY_DNS 1
328 #define BCM_SECONDARY_DNS 0
330 #if defined(__cplusplus)