#include "clidefs.h"
#include "cliapi.h"
#include "adslctlapi.h"
+#if defined(SUPPORT_VDSL)
+#include "vdslctlapi.h"
+#endif
#include "secapi.h"
#include "dbapi.h"
#include "dbobject.h"
#include <atm.h>
#include "portMirror.h"
#include "atmapidrv.h"
-#endif
-#endif
+#endif /* PORT_MIRRORING */
+#include "bcmcfm.h"
+#endif /* USE_ALL */
+#include "bcmxdsl.h"
#include "syscall.h"
#include "board_api.h"
#include "bcmTag.h"
#include "busybox.h"
#endif
+#ifndef USE_ALL
+#define IFC_LARGE_LEN 264
+#endif
+
extern char **environ;
extern char *getIfName(void);
+extern char glbErrMsg[IFC_LARGE_LEN];
#define READ_BUF_SIZE 128
#define CONNTRACK_MUX 2000
case -1: // error occurs then return -1
return -1;
case 0: // child does not exited yet
- sleep(1);
- if ( ++counter > 19 ) {
+ usleep(20);
+ if ( ++counter > 20000 ) {
#ifdef BRCM_DEBUG
printf("app: child process cannot exits while executing command - %s\n", command);
#endif
// global ADSL info variable is declared here (in syscall.c)
// and is used in syscall.c, sysdiag.c, cgimain.c, and cgists.c
ADSL_CONNECTION_INFO glbAdslInfo;
+#if defined(SUPPORT_VDSL)
+XDSL_CONNECTION_INFO glbVdslInfo;
+#endif
+
+/***************************************************************************
+// Function Name: bcmGetXdslStatus().
+// Description : get ADSL or VDSL status, depending on which link is up
+// Parameters : none
+// Returns : Link satus as in BCMXDSL_STATUS
+****************************************************************************/
+int bcmGetXdslStatus()
+{
+ BCMXDSL_STATUS ret = BCM_XDSL_LINK_DOWN;
+ BCMADSL_STATUS sts;
+
+ sts = BcmAdslCtl_GetConnectionInfo(&glbAdslInfo);
+ if( sts == BCMADSL_STATUS_SUCCESS )
+ ret = glbAdslInfo.LinkState;
+
+#if defined(SUPPORT_VDSL)
+ if((sts == BCMADSL_STATUS_ERROR) || ( glbAdslInfo.LinkState == BCM_XDSL_LINK_DOWN))
+ {
+ sts = BcmVdslCtl_GetConnectionInfo(&glbVdslInfo, glbErrMsg);
+ if( sts == BCMADSL_STATUS_SUCCESS )
+ ret = glbVdslInfo.LinkState;
+ }
+#endif
+
+ return((int)ret);
+}
/***************************************************************************
// Function Name: bcmGetAdslStatus().
if (BcmAdslCtl_GetConnectionInfo(&glbAdslInfo) != BCMADSL_STATUS_ERROR) {
ret = glbAdslInfo.LinkState;
-// if ( glbAdslInfo.LinkState == BCM_ADSL_LINK_UP )
-// ret = ADSL_LINK_UP;
-// else
-// ret = ADSL_LINK_DOWN;
} else
ret = BCMADSL_STATUS_ERROR;
return ret;
}
+#if defined(SUPPORT_VDSL)
+/***************************************************************************
+// Function Name: bcmGetVdslStatus().
+// Description : get VDSL status.
+// Parameters : none
+// Returns : 0 - VDSL link Up (OK)
+// 1 - VDSL link Down
+// 2 - Other error
+****************************************************************************/
+int bcmGetVdslStatus() {
+ return((BcmVdslCtl_GetConnectionInfo(&glbVdslInfo, glbErrMsg) != BCMADSL_STATUS_ERROR) ?
+ glbVdslInfo.LinkState : BCMADSL_STATUS_ERROR);
+}
+#endif
+
/***************************************************************************
// Function Name: bcmGetPppStatus().
// Description : get PPP status.
/* this means ADSL is UP, but not PPP */
//sysLedCtrl(kLedPPP, kLedStateFail);
sysLedCtrl(kLedPPP, kLedStateOff); // USR9108
+ /* TR68 - no change unless authentication error. */
+ /* sysLedCtrl(kLedPPP, kLedStateFail); */
break;
case MNTR_STS_OK:
/* this means ADSL and PPP are up */
****************************************************************************/
void bcmGetDns(char *dns) {
IFC_DNS_INFO dnsInfo;
+ int sts = BcmDb_getDnsInfo(&dnsInfo);
dns[0] = '\0';
- if ( ((BcmDb_getDnsInfo(&dnsInfo) == DB_GET_OK) && (dnsInfo.dynamic)) ||
- (BcmDb_getDnsInfo(&dnsInfo) != DB_GET_OK) ) {
- if (dnsInfo.dynamic) {
+ if ( sts == DB_GET_OK ) {
+ if ( dnsInfo.dynamic == TRUE )
bcmGetDynamicDnsAddr(dns,BCM_PRIMARY_DNS);
- }
- }
- else {
- /* static */
- if ( dnsInfo.preferredDns.s_addr != INADDR_NONE )
- strcpy(dns, inet_ntoa(dnsInfo.preferredDns));
- }
+ else {
+ if ( dnsInfo.preferredDns.s_addr != INADDR_NONE )
+ strcpy(dns, inet_ntoa(dnsInfo.preferredDns));
+ }
+ } else
+ // in bcmGetDynamicDnsAddr, if cannot find primary dns info then
+ // assign default value which is router IP address
+ bcmGetDynamicDnsAddr(dns,BCM_PRIMARY_DNS);
}
/***************************************************************************
****************************************************************************/
void bcmGetDns2(char *dns) {
IFC_DNS_INFO dnsInfo;
+ int sts = BcmDb_getDnsInfo(&dnsInfo);
dns[0] = '\0';
- if ( ((BcmDb_getDnsInfo(&dnsInfo) == DB_GET_OK) && (dnsInfo.dynamic)) ||
- (BcmDb_getDnsInfo(&dnsInfo) != DB_GET_OK) ) {
- if (dnsInfo.dynamic) {
- bcmGetDynamicDnsAddr(dns, BCM_SECONDARY_DNS);
- }
- }
- else {
- /* static */
- if ( dnsInfo.alternateDns.s_addr != INADDR_NONE )
- strcpy(dns, inet_ntoa(dnsInfo.alternateDns));
- }
+ if ( sts == DB_GET_OK ) {
+ if ( dnsInfo.dynamic == TRUE )
+ bcmGetDynamicDnsAddr(dns,BCM_SECONDARY_DNS);
+ else {
+ if ( dnsInfo.alternateDns.s_addr != INADDR_NONE )
+ strcpy(dns, inet_ntoa(dnsInfo.alternateDns));
+ }
+ } else
+ // in bcmGetDynamicDnsAddr, if cannot find primary dns info then
+ // assign default value which is router IP address
+ bcmGetDynamicDnsAddr(dns,BCM_SECONDARY_DNS);
}
void bcmGetDnsSettings(int *mode, char *primary, char *secondary)
void bcmConfigDns(char *dns1, char *dns2, int dynamic) {
char cmd[CLI_MAX_BUF_SZ], addr[CLI_MAX_BUF_SZ], buf[CLI_MAX_BUF_SZ];
IFC_DNS_INFO dnsInfo;
+ // need to call getDnsInfo before setDnsInfo to retrieve domain name
+ int sts = BcmDb_getDnsInfo(&dnsInfo);
// get local ip address
bcmGetIfDestAddr("br0", addr);
// if user changes from static to auto assgined dns
if (dynamic) {
- if ( BcmDb_getDnsInfo(&dnsInfo) == DB_GET_OK &&
+ if ( sts == DB_GET_OK &&
bcmIsModuleInserted("iptable_nat") == TRUE ) {
strcpy(buf, inet_ntoa(dnsInfo.preferredDns));
// del the old rule
} /* dynamic to static */
dnsInfo.dynamic = dynamic;
BcmDb_setDnsInfo(&dnsInfo);
- BcmPsi_flush();
}
/***************************************************************************
char cmd[IFC_LARGE_LEN];
FILE *fs = NULL;
IFC_DEF_GW_INFO defgw;
+
+// USR9109/9113 Just in case if something was wrong.
+ errMsg[0] = '\0';
// remove static default gateway
if ( BcmDb_getDefaultGatewayInfo(&defgw) == DB_GET_OK ) {
if ( ifcId >= IFC_ENET_ID && ifcId < IFC_USB_ID )
sprintf(ifcName, "eth%d", ifcId - IFC_ENET_ID);
else if ( ifcId >= IFC_USB_ID && ifcId < IFC_HPNA_ID )
-// strcpy(ifcName, "eth1");
sprintf(ifcName, "usb%d", ifcId - IFC_USB_ID);
else if ( ifcId >= IFC_HPNA_ID && ifcId < IFC_WIRELESS_ID )
sprintf(ifcName, "il%d", ifcId - IFC_HPNA_ID);
sprintf(ifcName, "wl0.%d", num);
}
}
+ else if (ifcId >= IFC_ENET0_VNET_ID && ifcId < IFC_ENET0_VNET_ID + IFC_LAN_MAX + 2)
+ sprintf(ifcName, "eth0.%d", ifcId - IFC_ENET0_VNET_ID);
+ else if (ifcId >= IFC_ENET1_VNET_ID && ifcId < IFC_ENET1_VNET_ID + IFC_LAN_MAX + 2)
+ sprintf(ifcName, "eth1.%d", ifcId - IFC_ENET1_VNET_ID);
return ifcName;
}
// execute iptables command to create iptable file
sprintf(line, "iptables -t %s -L %s -v --line-numbers > /var/iptable",
table, chain);
- bcmSystemMute(line);
+ bcmSystemNoHang(line);
fs = fopen("/var/iptable", "r");
if ( fs != NULL ) {
strcmp(col[IP_TBL_COL_OUT], device) == 0 ) {
sprintf(line, "iptables -t %s -D %s %s 2>/dev/null",
table, chain, col[IP_TBL_COL_NUM]);
- bcmSystemMute(line);
+ bcmSystemNoHang(line);
ret = TRUE;
break;
}
return ret;
}
+#if defined(SUPPORT_VDSL)
+static char glbVdslSwVer[SYS_CMD_LEN];
+//**************************************************************************
+//**************************************************************************
+// Function Name: bcmSetSwVer
+// Description : store software version to global variable
+// Parameters : swVer - the software version that needs to be set.
+// Returns : none.
+//**************************************************************************
+void bcmSetVdslSwVer(char *swVer)
+{
+ if ( swVer == NULL ) return;
+
+ if ( strlen(swVer) < SYS_CMD_LEN - 1 )
+ strcpy(glbVdslSwVer, swVer);
+ else {
+ strncpy(glbVdslSwVer, swVer, SYS_CMD_LEN - 2);
+ glbVdslSwVer[SYS_CMD_LEN - 1] = '\0';
+ }
+}
+#endif
+
//**************************************************************************
// Function Name: bcmGetSwVer
// Description : retrieve software version from global variable
// create software version
sprintf(version, "%s%s", SOFTWARE_VERSION, adslPhyVersion);
strncpy(swVer, version, size);
- swVer[size-1] = '\0';
}
// USR9108
#endif
}
+#if defined(SUPPORT_VDSL)
+//**************************************************************************
+// Function Name: bcmGetVdslSwVer
+// Description : retrieve software version from global variable
+// Parameters : swVer - buffer to get the software version.
+// size - size of buffer.
+// Returns : none.
+//**************************************************************************
+void bcmGetVdslSwVer(char *swVer, int size) {
+ if ( swVer == NULL ) return;
+
+ if ( strlen(glbVdslSwVer) < size - 1 )
+ strcpy(swVer, glbVdslSwVer);
+ else {
+ strncpy(swVer, glbVdslSwVer, size - 2);
+ swVer[size - 1] = '\0';
+ }
+}
+#endif
+
//**************************************************************************
// Function Name: bcmcheck_enable
// Description : check the appName with ip address against the psi
int checkChipId(char *strTagChipId, char *sig2)
{
int tagChipId = 0;
- unsigned int chipId = (int) sysGetChipId();
- int result = 0;
-
- if (strstr(sig2, "Firmware"))
- return result; // skip the pre 2_14L02 release, where the signiture_2 is "Firmware version 1.0"
-
- tagChipId = atoi(strTagChipId);
+ unsigned int chipId = (int) sysGetChipId();
+ int result;
- switch (chipId)
- {
- case 0x6338:
- if (!(tagChipId == 6338))
- result = -1;
- break;
- case 0x6345:
- if (!(tagChipId == 6345 || tagChipId == 6335))
- result = -1;
- break;
- case 0x6348:
- if (tagChipId != 6348)
- result = -1;
- break;
- default:
- printf("Chip id %04x not supported.\n", chipId);
- result = -1;
- break;
- }
+ tagChipId = strtol(strTagChipId, NULL, 16);
- if (result == -1)
- printf("Chip Id error. Image Chip Id = %d, Board Chip Id = %04x.\n", tagChipId, chipId);
+ if (tagChipId == chipId)
+ result = 0;
+ else {
+ printf("Chip Id error. Image Chip Id = %04x, Board Chip Id = %04x.\n", tagChipId, chipId);
+ result = -1;
+ }
return result;
}
FILE* fs;
int count = 0;
+ if (bcmIsModuleInserted("iptable_nat") == FALSE)
+ return FALSE;
+
bcmSystem("iptables -t nat -L > /var/nat_redirect");
fs = fopen("/var/nat_redirect", "r");
{
char *modList[]=
{
- "bcm_usb",
-#ifndef SUPPORT_ETHWAN
"bcm_enet",
-#endif
+ "bcm_usb",
"ipt_state",
"ipt_mark",
"ipt_limit",
if (lanIf == 0) // if lan, do not kill bcm_usb and bcm_enet
i = 2;
+ else // if in ipow mode, leave bcm_enet out
+ {
+ FILE *fs = fopen("/proc/var/fyi/wan/eth0/pid", "r");
+ if (fs != NULL)
+ {
+ i = 1;
+ fclose(fs);
+ }
+ }
saveNat = bcmCheckForRedirect();
-
if (bcmIsModuleInserted("iptable_filter") == TRUE)
{
strncpy(cmd, "iptables -t filter -F", SYS_CMD_LEN-1);
// Before we do anythng, lets add an ebtable rule at the bottom, that
// marks the packets with low priority mark as default 0x0001.
sprintf(cmd, "ebtables -t broute -A BROUTING -j mark --set-mark 0x0001 -p IPv4");
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
// Create the root. This also creates the classes 1:1, 1:2 and 1:3
// automatically
sprintf(cmd, "tc qdisc add dev %s root handle 1: htb default 1", ifc);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc class add dev %s parent 1: classid 1:1 htb rate %lukbit",
ifc, adslInfo.ulInterleavedUpStreamRate);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc qdisc add dev %s parent 1:1 handle 10: prio bands 3 "
"priomap 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", ifc);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
// Create the htb's under each class.
sprintf(cmd, "tc qdisc add dev %s parent 10:1 handle 100: pfifo limit 10", ifc);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc qdisc add dev %s parent 10:2 handle 200: pfifo limit 10", ifc);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc qdisc add dev %s parent 10:3 handle 300: pfifo limit 10", ifc);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
// Now add the filters for each sfq using the default handles.
sprintf(cmd, "tc filter add dev %s protocol ip parent 10:0 prio 1 handle %d fw classid 10:1",
ifc, PRIORITY_HIGH);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc filter add dev %s protocol ip parent 10:0 prio 1 handle %d fw classid 10:2",
ifc, PRIORITY_MEDIUM);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
sprintf(cmd, "tc filter add dev %s protocol ip parent 10:0 prio 1 handle %d fw classid 10:3",
ifc, PRIORITY_LOW);
- bcmSystem(cmd);
+ bcmSystemNoHang(cmd);
}
+
+/* this function stores device into procfs file for other processes to access */
+void bcmStoreDeviceInfoToProcFile(void)
+{
+ FILE* fs;
+ void *info=NULL;
+ PBcmCfm_DevInfoCfg_t pDevInfo = NULL;
+
+ bcmSystemMute("mkdir -p /var/fyi/sys");
+ bcmSystemMute("echo > /var/fyi/sys/info");
+ fs = fopen("/var/fyi/sys/info", "w+");
+
+ /* OUI %s */
+ /* SerialNumber %s */
+ /* ProductClass %s */
+ if ( fs != NULL ) {
+ if (BcmCfm_objGet(BCMCFM_OBJ_SYS_DEVICE_INFO, &info, 0) == BcmCfm_Ok) {
+ pDevInfo = (PBcmCfm_DevInfoCfg_t)info;
+ if (pDevInfo != NULL) {
+ fprintf(fs,"OUI %s\n",pDevInfo->manufacturerOui);
+ fprintf(fs,"SerialNumber %s\n",pDevInfo->serialNumber);
+ fprintf(fs,"ProductClass %s\n",pDevInfo->productClass);
+ BcmCfm_objFree(BCMCFM_OBJ_SYS_DEVICE_INFO, info);
+ }
+ }
+ fclose(fs);
+ } /* fs != NULL */
+}
+
#endif