http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / userapps / broadcom / cfm / inc / syscall.h
1 /*****************************************************************************
2 # <:copyright-gpl
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
10 # for more details.
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.
14 # :>
15 ******************************************************************************
16 //
17 //  Filename:       syscall.h
18 //  Author:         Peter T. Tran
19 //  Creation Date:  12/26/01
20 //
21 ******************************************************************************
22 //  Description:
23 //      Define the global constants, and functions for sysCall utility.
24 //
25 *****************************************************************************/
26
27 #ifndef __SYS_CALL_H__
28 #define __SYS_CALL_H__
29 #include <netinet/in.h>
30
31 /********************** Global Functions ************************************/
32
33 #define FILE_OPEN_OK                    0
34 #define FILE_OPEN_ERR                   -1
35
36 #define MNTR_STS_OK                     0
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
45
46 #define DHCPC_STS_FAIL                  0
47 #define DHCPC_STS_SUCCESS               1
48 #define DHCPC_FAIL_MAX                  15
49
50 // Values for network protocol
51 #define PROTO_PPPOE                     0
52 #define PROTO_PPPOA                     1
53 #define PROTO_MER                       2
54 #define PROTO_BRIDGE                    3
55 #define PROTO_PPPOE_RELAY               4
56 #define PROTO_IPOA                      5
57 #define PROTO_IPOWAN                    6
58 #define PROTO_NONE                      10
59
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
68 #define SYS_DNS_ID         8
69 #define SYS_LOG_ID         9
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
77
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
86 #endif
87 #ifdef ODM_MULTI_LANG
88 #define SYS_WEBLANG_ID   24
89 #endif
90 #if defined(SUPPORT_SYS_ALG)
91 #if defined(SUPPORT_SYS_VPN_ALG) || defined(SUPPORT_SYS_SIP_ALG)
92 #define SYS_ALG_ID       25
93 #endif
94 #endif
95 #if defined(ODM_LANG_NETGEAR)
96 #define SYS_BLANKSTATE_ID       26
97 #endif
98
99 #if defined(SUPPORT_AUTO_DETECT_DEFAULT_PVC)
100 #define SYS_AUTO_DETECT_DEFAULT_PVC_ID       27
101 #endif
102
103 // Values that are used in syscall.c
104 #define SYS_CMD_LEN        256
105
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
117
118 #define UPNP_IP_ADDRESS    "239.255.255.250"
119
120 #if defined(INCLUDE_EMBHTTPD)
121 typedef struct expTime_s {
122    int expNever;
123    int expTime;
124 }ExpTime_t;
125 #endif
126
127
128 //Paul add, 8/29/2006
129 #ifdef SUPPORT_IPP
130 #define PRINTER_STR_LEN    40
131 typedef struct {
132    char printername[PRINTER_STR_LEN];
133    char ethmacaddr[PRINTER_STR_LEN];
134    char ipaddr[PRINTER_STR_LEN];
135    int  dhcpsstatus;
136    char wssid[PRINTER_STR_LEN];
137    char networktype[PRINTER_STR_LEN];
138    int  wnetstatus;
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;
146 #endif
147 //Paul add end
148
149 //Paul porting from 2.21.5, 7/24/2006
150 #ifdef INCLUDE_PRINT_SERVER
151
152 #define PRINTER_STR_LEN    40
153 typedef struct {
154    char printername[PRINTER_STR_LEN];
155    char ethmacaddr[PRINTER_STR_LEN];
156    char ipaddr[PRINTER_STR_LEN];
157    int  dhcpsstatus;
158    char wssid[PRINTER_STR_LEN];
159    char networktype[PRINTER_STR_LEN];
160    int  wnetstatus;
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;
168 #endif
169 //Paul porting end
170
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
179
180 struct lpstate {
181         char    status;
182 };
183 //Paul add end
184
185 #if defined(__cplusplus)
186 extern "C" {
187 #endif
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);
235
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);
244 #if SUPPORT_TC
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);
249 #endif
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);
255
256 int bcmRemoveEbTableRule(char *device, char *table, char *chain);
257 void bcmRemoveAllEbTableRules(char *device);
258 void bcmRemoveAllBrFilterRules(char *device);
259 int bcmRemoveAllEbTableFORWARDrule();
260
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);
265
266 int GetMASQIpTableRule(char *device, char *table, char *chain);
267 int GetTCPMSSIpTableRule(char *device, char *table, char *chain);
268
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);
280
281
282 #ifdef SUPPORT_IPP //Paul add, 8/29/2006
283 int print_test_page();
284 #endif
285
286 //Paul porting from 2.21.5, 7/24/2006
287 //Charles 12/23/2003
288 #ifdef INCLUDE_PRINT_SERVER
289 int print_test_page();
290 int get_printer_status(char *status_str, char *lp_name);
291 #endif
292
293 int bcmMacStrToNum(char *macAddr, char *str);
294 int bcmMacNumToStr(char *macAddr, char *str);
295
296 int bcmWanEnetQuerySwitch(char *ifName);
297
298 #ifdef PORT_MIRRORING
299 int bcmConfigPortMirroring (void *pMirrorCfg) ;
300 #endif
301 void bcmStoreDeviceInfoToProcFile(void);
302 #ifdef BUILD_DOMAIN_LOCK
303 int wsnCheckStrTail(char *username, char *validDomain);
304 int wsnIsValidPppUser(char *pppUser);
305 #endif
306
307 #ifdef IP_MGCP
308 int SysPstnVoipStatus(char *status);
309 #endif
310
311 void bcmGetDynamicDnsAddr(char *dns, int primary);
312 #ifdef SUPPORT_TR69C
313 void getInterfaceMac(char *macstr, char *iface);
314 #endif
315
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 */
322
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
326
327 #define BCM_PRIMARY_DNS                      1
328 #define BCM_SECONDARY_DNS                    0
329
330 #if defined(__cplusplus)
331 }
332 #endif
333
334 #endif