1 /*****************************************************************************
3 // Copyright (c) 2000-2001 Broadcom Corporation
5 // No portions of this material may be reproduced in any form without the
6 // written permission of:
7 // Broadcom Corporation
9 // Irvine, California 92619
10 // All information contained in this document is Broadcom Corporation
11 // company private, proprietary, and trade secret.
13 ******************************************************************************
15 // Filename: syscall.h
16 // Author: Peter T. Tran
17 // Creation Date: 12/26/01
19 ******************************************************************************
21 // Define the global constants, and functions for sysCall utility.
23 *****************************************************************************/
25 #ifndef __SYS_CALL_H__
26 #define __SYS_CALL_H__
27 #include <netinet/in.h>
29 /********************** Global Functions ************************************/
31 #define FILE_OPEN_OK 0
32 #define FILE_OPEN_ERR -1
35 #define MNTR_STS_ADSL_DOWN 1
36 #define MNTR_STS_PPP_AUTH_ERR 2
37 #define MNTR_STS_PPP_DOWN 3
38 #define MNTR_STS_OPEN_ERR 4
39 #define MNTR_STS_DHCPC_PROGRESS 5
40 #define MNTR_STS_DHCPC_FAIL 6
41 #define MNTR_STS_ADSL_TRAINING 7
42 #define MNTR_STS_BRIDGE 8
44 #define DHCPC_STS_FAIL 0
45 #define DHCPC_STS_SUCCESS 1
46 #define DHCPC_FAIL_MAX 15
48 // Values for network protocol
52 #define PROTO_BRIDGE 3
53 #define PROTO_PPPOE_RELAY 4
55 #define PROTO_IPOWAN 6
58 #define SYSTEM_APPID "SystemInfo"
59 #define SYS_USER_NAME_ID 1
60 #define SYS_PASSWORD_ID 2
61 #define SPT_USER_NAME_ID 3
62 #define SPT_PASSWORD_ID 4
63 #define USR_USER_NAME_ID 5
64 #define USR_PASSWORD_ID 6
65 #define SYS_DFT_GTWY_ID 7
68 #define SYS_SNMP_ID 10
69 #define SYS_FLAG_ID 11
70 #define SYS_TR69C_ID 12
71 #define SYS_MGMT_LOCK_ID 13
73 // Values that are used in syscall.c
74 #define SYS_CMD_LEN 256
76 #define IP_TBL_COL_NUM 0
77 #define IP_TBL_COL_PKTS 1
78 #define IP_TBL_COL_BYTES 2
79 #define IP_TBL_COL_TARGET 3
80 #define IP_TBL_COL_PROT 4
81 #define IP_TBL_COL_OPT 5
82 #define IP_TBL_COL_IN 6
83 #define IP_TBL_COL_OUT 7
84 #define IP_TBL_COL_SRC 8
85 #define IP_TBL_COL_DST 9
86 #define IP_TBL_COL_MAX 10
88 #define UPNP_IP_ADDRESS "239.255.255.250"
90 #if defined(__cplusplus)
93 #define bcmSystem(cmd) bcmSystemEx (cmd,1)
94 #define bcmSystemMute(cmd) bcmSystemEx (cmd,0)
95 int bcmSystemEx (char *command, int printFlag);
96 int bcmSystemNoHang (char *command);
97 int bcmGetPid (char *command);
98 int *bcmGetPidList(char * command);
99 int bcmCreateDhcpCfg(char *ipAddr, char *mask, char *addrStart, char *addrEnd,
100 char *dns1, char *dns2, int leasedTime, int protocol,
101 int enblNat, int enblFirewall);
102 int bcmCreateIpExtDhcpCfg(char *lanAddr, char *mask, char *wanAddr);
103 int bcmCreateLocalDhcpCfg(char *addr, char *mask);
104 int bcmCreateResolvCfg(char *dns1, char *dns2);
105 int bcmCreateLoginCfg(char *cp_admin, char *cp_support, char *cp_user);
106 int bcmGetAdslStatus(void);
107 int bcmGetVdslStatus(void);
108 int bcmGetXdslStatus(void);
109 int bcmGetPppStatus(char *str, int len, char *devName);
110 int bcmGetDhcpcStatus(char *str, int len);
111 int bcmGetSystemStatus(char *str, int len);
112 int bcmSetSystemStatus(int status);
113 int bcmSetIpExtension(int ipExt);
114 int bcmGetIpExtension(char *str, int len);
115 void bcmDisplayLed(int status);
116 void bcmGetDns(char *dns);
117 void bcmGetDns2(char *dns);
118 void bcmGetDnsSettings(int *mode, char *primary, char *secondary);
119 void bcmRestartDnsProbe(void);
120 void bcmConfigDns(char *dns1, char *dns2, int dynamic);
121 void bcmRemoveDefaultGatewayByWanIf(char *wanIf);
122 void bcmGetDefaultGateway(char *gtwy, char *wanIf);
123 int bcmIsDefaultGatewayExisted(char *gw, char *wanIf);
124 void bcmSetAutoDefaultGateway(char *errMsg);
125 void bcmSetStaticDefaultGateway(char *gw, char *wanIf, char *errMsg);
126 void bcmKillAllApps(void);
127 void disconnectPPP(void);
128 void setWanLinkStatus(int up);
129 int bcmCheckInterfaceUp(char *devname);
130 int bcmSetIpExtInfo(char *wan, char *gateway, char *dns);
131 void bcmGetIpExtInfo(char *buf, int type);
132 int bcmGetIfcIndexByName(char *ifcName);
133 int bcmIsValidIfcName(char *ifcName);
134 char *bcmGetIfcNameById(int ifcId, char *ifcName);
135 char *bcmGetIfcNameByIpAddr(unsigned long ipAddr, char *ifcName);
136 void getPppoeServiceName(char *service, char *ifName);
137 void bcmGetDefaultRouteInterfaceName(char *ifcName);
139 void bcmSetConnTrackMax(void);
140 void bcmResetConnTrackTable(void);
141 void bcmHandleConnTrack(void);
142 void bcmInsertModules(char *path);
143 void bcmInsertModule(char *modName);
144 int bcmIsModuleInserted(char *modName);
145 int bcmRemoveIpTableRule(char *device, char *table, char *chain);
146 void bcmRemoveAllIpTableRules(char *device);
148 void bcmRemoveTrafficControlRules(unsigned short vpi, unsigned short vci,
149 unsigned short conId, unsigned char protocol);
150 void bcmAddTrafficControlRules(unsigned short vpi, unsigned short vci,
151 unsigned short conId, unsigned char protocol);
153 int bcmRemoveRipIpTableRule(void);
154 int bcmRemoveUpnpIpTableRule(void);
155 void bcmInsertAllUpnpIpTableRules(void);
156 int bcmGetIntfNameSocket(int socketfd, char *intfname);
157 int bcmCheckEnable(char *appName, struct in_addr clntAddr);
159 int bcmRemoveEbTableRule(char *device, char *table, char *chain);
160 void bcmRemoveAllEbTableRules(char *device);
162 void parseStrInfo(char *info, char *var, char *val, int len);
163 void bcmConvertStrToShellStr(char *str, char *buf);
164 void bcmProcessMarkStrChars(char *str);
165 int bcmIsMarkStrChar(char c);
166 void bcmSetVdslSwVer(char *swVer);
167 void bcmGetSwVer(char *swVer, int size);
168 void bcmGetBuildVer(char *swVer, int size); // USR9108
169 void bcmGetVdslSwVer(char *swVer, int size);
170 int isAccessFromLan(struct in_addr clntAddr);
171 int checkChipId(char *strTagChipId, char *sig2);
172 void bcmRemoveModules(int lanIf);
173 int bcmWaitIntfExists(char *ifName);
175 int bcmMacStrToNum(char *macAddr, char *str);
176 int bcmMacNumToStr(char *macAddr, char *str);
178 int bcmWanEnetQuerySwitch(char *ifName);
180 int bcmConfigPortMirroring (void *pMirrorCfg) ;
181 void bcmStoreDeviceInfoToProcFile(void);
183 #define BCM_PPPOE_CLIENT_STATE_PADO 0 /* waiting for PADO */
184 #define BCM_PPPOE_CLIENT_STATE_PADS 1 /* got PADO, waiting for PADS */
185 #define BCM_PPPOE_CLIENT_STATE_CONFIRMED 2 /* got PADS, session ID confirmed */
186 #define BCM_PPPOE_CLIENT_STATE_DOWN 3 /* totally down */
187 #define BCM_PPPOE_CLIENT_STATE_UP 4 /* totally up */
188 #define BCM_PPPOE_SERVICE_AVAILABLE 5 /* ppp service is available on the remote */
190 #define BCM_PPPOE_AUTH_FAILED 7
192 #define BCM_PRIMARY_DNS 1
193 #define BCM_SECONDARY_DNS 0
195 #if defined(__cplusplus)