static int check_ethernet_wan_status() { int ret = -1, size =0, val_size =0; char compName[MAX_PARAMETERNAME_LEN/2] = { '\0' }; char dbusPath[MAX_PARAMETERNAME_LEN/2] = { '\0' }; parameterValStruct_t **parameterval = NULL; char *getList[] = {ETH_WAN_STATUS_PARAM}; componentStruct_t ** ppComponents = NULL; char dst_pathname_cr[256] = {0}; char isEthEnabled[64]={'\0'}; if(0 == syscfg_init()) { if( 0 == syscfg_get( NULL, "eth_wan_enabled", isEthEnabled, sizeof(isEthEnabled)) && (isEthEnabled[0] != '\0' && strncmp(isEthEnabled, "true", strlen("true")) == 0)) { CcspTraceInfo(("Ethernet WAN is enabled\n")); ret = CCSP_SUCCESS; } } else { waitForEthAgentComponentReady(); sprintf(dst_pathname_cr, "%s%s", "eRT.", CCSP_DBUS_INTERFACE_CR); ret = CcspBaseIf_discComponentSupportingNamespace(bus_handle, dst_pathname_cr, ETH_WAN_STATUS_PARAM, "", &ppComponents, &size); if ( ret == CCSP_SUCCESS && size >= 1) { strncpy(compName, ppComponents[0]->componentName, sizeof(compName)-1); strncpy(dbusPath, ppComponents[0]->dbusPath, sizeof(compName)-1); } else { CcspTraceError(("Failed to get component for %s ret: %d\n",ETH_WAN_STATUS_PARAM,ret)); } free_componentStruct_t(bus_handle, size, ppComponents); if(strlen(compName) != 0 && strlen(dbusPath) != 0) { ret = CcspBaseIf_getParameterValues(bus_handle, compName, dbusPath, getList, 1, &val_size, ¶meterval); if(ret == CCSP_SUCCESS && val_size > 0) { if(parameterval[0]->parameterValue != NULL && strncmp(parameterval[0]->parameterValue, "true", strlen("true")) == 0) { CcspTraceInfo(("Ethernet WAN is enabled\n")); ret = CCSP_SUCCESS; } else { CcspTraceInfo(("Ethernet WAN is disabled\n")); ret = CCSP_FAILURE; } } else { CcspTraceError(("Failed to get values for %s ret: %d\n",getList[0],ret)); } free_parameterValStruct_t(bus_handle, val_size, parameterval); } } return ret; }
/* GetParameterValues */ BOOL Cosa_GetParamValues ( char* pDestComp, char* pDestPath, char** pParamArray, int uParamSize, int* puValueSize, parameterValStruct_t*** pppValueArray ) { CcspTraceInfo(("RDKB_SNMP : SNMP GET called for param '%s'\n",*pParamArray)); int iStatus = 0; iStatus = CcspBaseIf_getParameterValues ( bus_handle, pDestComp, pDestPath, pParamArray, uParamSize, puValueSize, pppValueArray ); if(iStatus != CCSP_SUCCESS && *pParamArray) { CcspTraceWarning(("RDKB_SNMP : Failed to get parameter value for '%s'\n",*pParamArray)); } else { CcspTraceInfo(("RDKB_SNMP : SNMP GET SUCCESS for param '%s'\n",*pParamArray)); } return iStatus == CCSP_SUCCESS; }
static void waitForEthAgentComponentReady() { char status[32] = {'\0'}; int count = 0; int ret = -1; while(1) { checkComponentHealthStatus(RDKB_ETHAGENT_COMPONENT_NAME, RDKB_ETHAGENT_DBUS_PATH, status,&ret); if(ret == CCSP_SUCCESS && (strcmp(status, "Green") == 0)) { CcspTraceInfo(("%s component health is %s, continue\n", RDKB_ETHAGENT_COMPONENT_NAME, status)); break; } else { count++; if(count > 60) { CcspTraceError(("%s component Health check failed (ret:%d), continue\n",RDKB_ETHAGENT_COMPONENT_NAME, ret)); break; } if(count%5 == 0) { CcspTraceError(("%s component Health, ret:%d, waiting\n", RDKB_ETHAGENT_COMPONENT_NAME, ret)); } sleep(5); } } }
/* SetParameterValues */ BOOL Cosa_SetParamValuesNoCommit ( char* pDestComp, char* pDestPath, parameterValStruct_t *val, int size ) { int iStatus = 0; char *faultParam = NULL; CCSP_MESSAGE_BUS_INFO *bus_info = (CCSP_MESSAGE_BUS_INFO *)bus_handle; /*Removing Logging of Password values due to Security Requirement*/ if(NULL != strstr(val->parameterName,".Security.X_COMCAST-COM_KeyPassphrase")) { CcspTraceInfo(("RDKB_SNMP : SNMP SET called for param '%s'\n",val->parameterName)); } else { CcspTraceInfo(("RDKB_SNMP : SNMP SET called for param '%s' with value '%s'\n",val->parameterName,val->parameterValue)); } iStatus = CcspBaseIf_setParameterValues ( bus_handle, pDestComp, pDestPath, 0, CCSP_COMPONENT_ID_SNMP, /* session id and write id */ val, size, FALSE, /* no commit */ &faultParam ); if (iStatus != CCSP_SUCCESS && faultParam) { AnscTraceError(("Error:Failed to SetValue for param '%s'\n", faultParam)); CcspTraceWarning(("RDKB_SNMP : Failed to set parameter value for '%s'\n",faultParam)); bus_info->freefunc(faultParam); } else { CcspTraceInfo(("RDKB_SNMP : SNMP SET SUCCESS for param '%s'\n",val->parameterName)); } return iStatus == CCSP_SUCCESS; }
static void daemonize(void) { int fd; switch (fork()) { case 0: break; case -1: // Error CcspTraceInfo(("Error daemonizing (fork)! %d - %s\n", errno, strerror( errno))); exit(0); break; default: _exit(0); } if (setsid() < 0) { CcspTraceInfo(("Error demonizing (setsid)! %d - %s\n", errno, strerror(errno))); exit(0); } /* * What is the point to change current directory? * chdir("/"); */ #ifndef _DEBUG fd = open("/dev/null", O_RDONLY); if (fd != 0) { dup2(fd, 0); close(fd); } fd = open("/dev/null", O_WRONLY); if (fd != 1) { dup2(fd, 1); close(fd); } fd = open("/dev/null", O_WRONLY); if (fd != 2) { dup2(fd, 2); close(fd); } #endif }
/* Description: The API initiates a DHCP client renewal. Arguments: pAlias The entry is identified through Alias. */ ANSC_STATUS CosaDmlDhcpv6cRenew ( ANSC_HANDLE hContext, ULONG ulInstanceNumber ) { CcspTraceInfo((" CosaDmlDhcpv6cRenew -- ulInstanceNumber:%d.\n", ulInstanceNumber)); return ANSC_STATUS_SUCCESS; }
void sig_handler(int sig) { if ( sig == SIGINT ) { signal(SIGINT, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGINT received!\n")); exit(0); } else if ( sig == SIGUSR1 ) { signal(SIGUSR1, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGUSR1 received!\n")); } else if ( sig == SIGUSR2 ) { CcspTraceInfo(("SIGUSR2 received!\n")); } else if ( sig == SIGCHLD ) { signal(SIGCHLD, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGCHLD received!\n")); } else if ( sig == SIGPIPE ) { signal(SIGPIPE, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGPIPE received!\n")); } else if ( sig == SIGALRM ) { signal(SIGALRM, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGALRM received!\n")); gChannelSwitchingCount = 0; } else if ( sig == SIGTERM ) { CcspTraceInfo(("SIGTERM received!\n")); exit(0); } else if ( sig == SIGKILL ) { CcspTraceInfo(("SIGKILL received!\n")); exit(0); } else { /* get stack trace first */ _print_stack_backtrace(); CcspTraceInfo(("Signal %d received, exiting!\n", sig)); exit(0); } }
ANSC_HANDLE PsmFloGetSysIraIf ( ANSC_HANDLE hThisObject ) { //CcspTraceInfo(("PsmFloGetSysIraIf begins\n")); ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PPSM_FILE_LOADER_OBJECT pMyObject = (PPSM_FILE_LOADER_OBJECT)hThisObject; CcspTraceInfo(("retrieved System Ira Interface\n")); //CcspTraceInfo(("PsmFloGetSysIraIf ends \n")); return pMyObject->hSysIraIf; }
ANSC_STATUS PsmFloReset ( ANSC_HANDLE hThisObject ) { //CcspTraceInfo(("PsmFloReset begins\n")); ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PPSM_FILE_LOADER_OBJECT pMyObject = (PPSM_FILE_LOADER_OBJECT )hThisObject; PPSM_FILE_LOADER_PROPERTY pProperty = (PPSM_FILE_LOADER_PROPERTY)&pMyObject->Property; CcspTraceInfo(("Object states are Reset\n")); //CcspTraceInfo(("PsmFloReset ends\n")); return ANSC_STATUS_SUCCESS; }
ANSC_STATUS PsmFloResetProperty ( ANSC_HANDLE hThisObject ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PPSM_FILE_LOADER_OBJECT pMyObject = (PPSM_FILE_LOADER_OBJECT )hThisObject; PPSM_FILE_LOADER_PROPERTY pProperty = (PPSM_FILE_LOADER_PROPERTY)&pMyObject->Property; AnscZeroMemory(pProperty, sizeof(PSM_FILE_LOADER_PROPERTY)); CcspTraceInfo(("Object Property is Reset\n")); return ANSC_STATUS_SUCCESS; }
ANSC_HANDLE PsmCreateFileLoader ( ANSC_HANDLE hContainerContext, ANSC_HANDLE hOwnerContext, ANSC_HANDLE hAnscReserved ) { //CcspTraceInfo(("PsmCreateFileLoader begins '\n")); ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; CcspTraceInfo(("PsmCreateFileLoader-New File LoaderObject is created \n")); // CcspTraceInfo(("PsmCreateFileLoader ends '\n")); return PsmFloCreate(hContainerContext, hOwnerContext, hAnscReserved); }
void WriteWiFiLog(char *msg) { char LogMsg_arr[512] = {0}; char *LogMsg = LogMsg_arr; char LogLevel[512] = {0}; strcpy (LogLevel, msg); strtok_r (LogLevel, ",",&LogMsg); if( AnscEqualString(LogLevel, "RDK_LOG_ERROR", TRUE)) { CcspTraceError((LogMsg)); } else if( AnscEqualString(LogLevel, "RDK_LOG_WARN", TRUE)) { CcspTraceWarning((LogMsg)); } else if( AnscEqualString(LogLevel, "RDK_LOG_NOTICE", TRUE)) { CcspTraceNotice((LogMsg)); } else if( AnscEqualString(LogLevel, "RDK_LOG_INFO", TRUE)) { CcspTraceInfo((LogMsg)); } else if( AnscEqualString(LogLevel, "RDK_LOG_DEBUG", TRUE)) { CcspTraceDebug((LogMsg)); } else if( AnscEqualString(LogLevel, "RDK_LOG_FATAL", TRUE)) { CcspTraceCritical((LogMsg)); } else { CcspTraceInfo((LogMsg)); } }
ANSC_STATUS PsmFloSetSysIraIf ( ANSC_HANDLE hThisObject, ANSC_HANDLE hInterface ) { // CcspTraceInfo(("PsmFloSetSysIraIf begins \n")); ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PPSM_FILE_LOADER_OBJECT pMyObject = (PPSM_FILE_LOADER_OBJECT)hThisObject; pMyObject->hSysIraIf = hInterface; CcspTraceInfo(("System Ira Interface is set\n")); // CcspTraceInfo(("PsmFloSetSysIraIf ends \n")); return ANSC_STATUS_SUCCESS; }
void sig_handler(int sig) { #ifndef _COSA_INTEL_USG_ATOM_ CcspBaseIf_deadlock_detection_log_print(sig); #endif if ( sig == SIGINT ) { signal(SIGINT, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGINT received!\n")); exit(0); } else if ( sig == SIGUSR1 ) { signal(SIGUSR1, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGUSR1 received!\n")); } else if ( sig == SIGUSR2 ) { CcspTraceInfo(("SIGUSR2 received!\n")); } else if ( sig == SIGCHLD ) { signal(SIGCHLD, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGCHLD received!\n")); } else if ( sig == SIGPIPE ) { signal(SIGPIPE, sig_handler); /* reset it to this function */ CcspTraceInfo(("SIGPIPE received!\n")); } else if ( sig == SIGTERM ) { CcspTraceInfo(("SIGTERM received!\n")); exit(0); } else if ( sig == SIGKILL ) { CcspTraceInfo(("SIGKILL received!\n")); exit(0); } else { /* get stack trace first */ _print_stack_backtrace(); CcspTraceInfo(("Signal %d received, exiting!\n", sig)); exit(0); } }
ANSC_STATUS PsmFloSetProperty ( ANSC_HANDLE hThisObject, ANSC_HANDLE hProperty ) { //CcspTraceInfo(("PsmFloSetProperty begins \n")); ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PPSM_FILE_LOADER_OBJECT pMyObject = (PPSM_FILE_LOADER_OBJECT )hThisObject; PPSM_FILE_LOADER_PROPERTY pProperty = (PPSM_FILE_LOADER_PROPERTY)&pMyObject->Property; *pProperty = *(PPSM_FILE_LOADER_PROPERTY)hProperty; CcspTraceInfo(("Object Property is Configured\n")); //CcspTraceInfo(("PsmFloSetProperty ends \n")); return ANSC_STATUS_SUCCESS; }
int WebpaInterface_DiscoverComponent(char** pcomponentName, char** pcomponentPath ) { char CrName[256] = {0}; int ret = 0; CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s ENTER\n", __FUNCTION__ )); CrName[0] = 0; strcpy(CrName, "eRT."); strcat(CrName, CCSP_DBUS_INTERFACE_CR); componentStruct_t **components = NULL; int compNum = 0; int res = CcspBaseIf_discComponentSupportingNamespace ( bus_handle, CrName, #ifndef _XF3_PRODUCT_REQ_ "Device.X_CISCO_COM_CableModem.MACAddress", #else "Device.DPoE.Mac_address", #endif "", &components, &compNum); if(res != CCSP_SUCCESS || compNum < 1){ CcspTraceError(("WebpaInterface_DiscoverComponent find eRT PAM component error %d\n", res)); ret = -1; } else{ *pcomponentName = LanManager_CloneString(components[0]->componentName); *pcomponentPath = LanManager_CloneString(components[0]->dbusPath); CcspTraceInfo(("WebpaInterface_DiscoverComponent find eRT PAM component %s--%s\n", *pcomponentName, *pcomponentPath)); } free_componentStruct_t(bus_handle, compNum, components); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s EXIT\n", __FUNCTION__ )); return ret; }
ANSC_STATUS Pam_GetFirstIpInterfaceObjectName ( BOOL bUpstream, char* pIfObjName, PULONG pulObjNameSize ) { ANSC_STATUS returnStatus = ANSC_STATUS_CANT_FIND; int iReturnValue = 0; ULONG ulTotal = 0; ULONG ulIndex = 0; ULONG ulInstNum = 0; ULONG ulLen = 0; char pObjName[256] = {0}; char Buffer[128] = {0}; ULONG BufferSize = 0; char LowerLayers[256] = {0}; ULONG LowerLayersSize = 0; BOOL bLowerLayerUpstream = FALSE; char* EnvIndex = NULL; ULONG ulEnvIndex = PAM_MAX_IP_INTERFACE_NUM; CcspTraceInfo(("[%s] -- Enter \n", __FUNCTION__)); #ifdef _COSA_SIM_ // Hard coded, RTian 09/20/2013 { if(bUpstream) { pulObjNameSize = sprintf(pIfObjName, "Device.IP.Interface.1.") + 1; // else pulObjNameSize = sprintf(pIfObjName, "Device.IP.Interface.4.") + 1; CcspTraceInfo(("[%s] -- Exit, defined _COSA_SIM_ pulObjNameSize: %d from \n", __FUNCTION__, pulObjNameSize)); return ANSC_STATUS_SUCCESS; } } #endif ulTotal = CosaGetParamValueUlong("Device.IP.InterfaceNumberOfEntries"); EnvIndex = getenv(PAM_FIRST_IP_INTERFACE); if(EnvIndex != NULL) { ulEnvIndex = atol(EnvIndex); } for ( ulIndex = 0; ulIndex < ulTotal; ulIndex++ ) { if(EnvIndex != NULL && ulEnvIndex < PAM_MAX_IP_INTERFACE_NUM) { ulInstNum = CosaGetInstanceNumberByIndex("Device.IP.Interface.", ulEnvIndex); if( 0 == ulInstNum) { EnvIndex = NULL; ulEnvIndex = PAM_MAX_IP_INTERFACE_NUM; } else { ulIndex = EnvIndex; } } ulInstNum = CosaGetInstanceNumberByIndex("Device.IP.Interface.", ulIndex); if ( 0 == ulInstNum ) { CcspTraceWarning(("Pam_GetFirstIpInterfaceObjectName -- invalid Device.IP.Interface instance number!\n")); returnStatus = ANSC_STATUS_FAILURE; break; } else { _ansc_sprintf(pObjName, "Device.IP.Interface.%d.LowerLayers", ulInstNum); /*CcspTraceInfo(("Checking %s...\n", pObjName));*/ LowerLayersSize = sizeof(LowerLayers); iReturnValue = CosaGetParamValueString(pObjName, LowerLayers, &LowerLayersSize); if ( iReturnValue != 0 ) { returnStatus = ANSC_STATUS_FAILURE; break; } else if ( LowerLayersSize == 0 ) { continue; } do { /* * We have to check whether LowerLayers is a partial object name (without '.' at the end) or not * Assuming only one lower layer value for now * Look for the LowerLayer with a empty LowerLayers parameter */ ulLen = _ansc_strlen(LowerLayers); if ( LowerLayers[ulLen - 1] == '.' ) { LowerLayers[ulLen - 1] = '\0'; } _ansc_strcpy (pObjName, LowerLayers); _ansc_sprintf(Buffer, "%s.LowerLayers", LowerLayers); CcspTraceDebug(("Checking %s...\n", Buffer)); LowerLayersSize = sizeof(LowerLayers); iReturnValue = CosaGetParamValueString(Buffer, LowerLayers, &LowerLayersSize); if ( iReturnValue != 0 ) { break; } else if ( LowerLayersSize == 0 ) { break; } } while (TRUE); /* * Check the Upstream parameter. * Note, not all error cases are covered well here, which happened to help to pass the test * on DRG -- LowerLayers parameter of IP.Interface on top of Bridge.1 is not actually correct. */ _ansc_sprintf(Buffer, "%s.Upstream", pObjName); bLowerLayerUpstream = CosaGetParamValueBool(Buffer); if ( bUpstream == bLowerLayerUpstream ) { CcspTraceDebug (( "Found the lowest %s layer %s for IP interface Device.IP.Interface.%d.\n", bUpstream ? "upstream" : "downstream", LowerLayers, ulInstNum )); _ansc_sprintf(Buffer, "Device.IP.Interface.%d.", ulInstNum); BufferSize = _ansc_strlen(Buffer); if ( BufferSize < *pulObjNameSize ) { AnscCopyString(pIfObjName, Buffer); *pulObjNameSize = BufferSize; returnStatus = ANSC_STATUS_SUCCESS; } else { *pulObjNameSize = BufferSize; returnStatus = ANSC_STATUS_MORE_DATA; } break; } } } CcspTraceInfo(("[%s] -- Exit returnStatus: %d\n", __FUNCTION__, returnStatus)); return returnStatus; }
ANSC_STATUS AnscDstoEngage ( ANSC_HANDLE hThisObject ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PANSC_DAEMON_SERVER_TCP_OBJECT pMyObject = (PANSC_DAEMON_SERVER_TCP_OBJECT)hThisObject; PANSC_DSTO_WORKER_OBJECT pWorker = (PANSC_DSTO_WORKER_OBJECT )pMyObject->hWorker; int s_result = 0; #ifdef _ANSC_IPV6_COMPATIBLE_ ansc_addrinfo ansc_hints = {0}; ansc_addrinfo* pansc_local_addrinfo = NULL; xskt_addrinfo xskt_hints = {0}; xskt_addrinfo* pxskt_local_addrinfo = NULL; USHORT usPort = 0; char port[6] = {0}; #else /*RDKB-6151, CID-24487,24794; initializing variable before use*/ ansc_socket_addr_in local_addr1 = {0}; xskt_socket_addr_in local_addr2 = {0}; #endif if ( pMyObject->bActive ) { return ANSC_STATUS_SUCCESS; } else if ( !pWorker ) { return ANSC_STATUS_UNAPPLICABLE; } else { pWorker->Init(pWorker->hWorkerContext); pMyObject->StartTime = AnscGetTickInSecondsAbs(); pMyObject->bActive = TRUE; } /* * The underlying socket wrapper may require an explicit startup() call, such is the case on * Microsoft windows platforms. The wrapper initialization has to done for each task. On most * real-time operating systems, this call is not required. */ if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { AnscStartupXsocketWrapper((ANSC_HANDLE)pMyObject); } else { AnscStartupSocketWrapper((ANSC_HANDLE)pMyObject); } #ifdef _ANSC_IPV6_COMPATIBLE_ if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { xskt_hints.ai_family = AF_UNSPEC; xskt_hints.ai_socktype = XSKT_SOCKET_STREAM; xskt_hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; usPort = pMyObject->GetHostPort((ANSC_HANDLE)pMyObject); _ansc_sprintf(port, "%d", usPort); CcspTraceInfo(("!!! Host Name: %s, Host Port: %s !!!\n", pMyObject->HostName, port)); if ( _xskt_getaddrinfo ( pMyObject->HostName[0] ? pMyObject->HostName : "::", port, &xskt_hints, &pxskt_local_addrinfo ) ) { CcspTraceError(("!!! error 1 !!!\n")); returnStatus = ANSC_STATUS_FAILURE; goto EXIT1; } pMyObject->pHostAddr2 = pxskt_local_addrinfo; } else { ansc_hints.ai_family = AF_UNSPEC; ansc_hints.ai_socktype = ANSC_SOCKET_STREAM; ansc_hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; usPort = pMyObject->GetHostPort((ANSC_HANDLE)pMyObject); _ansc_sprintf(port, "%d", usPort); CcspTraceInfo(("!!! Host Name: %s, Host Port: %s !!!\n", pMyObject->HostName, port)); if ( _ansc_getaddrinfo ( pMyObject->HostName[0] ? pMyObject->HostName : "::", port, &ansc_hints, &pansc_local_addrinfo ) ) { returnStatus = ANSC_STATUS_FAILURE; goto EXIT1; } pMyObject->pHostAddr1 = pansc_local_addrinfo; } #endif /* * To engage the Tcp Daemon, we need to perform following acts in the respective order: * * (1) create the os-dependent socket * (2) manufacture and start all the engines objects * (3) manufacture the global socket object pool * (4) bind to the socket and listen on it */ if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { #ifdef _ANSC_IPV6_COMPATIBLE_ pMyObject->Socket = _xskt_socket(pxskt_local_addrinfo->ai_family, pxskt_local_addrinfo->ai_socktype, 0); #else pMyObject->Socket = _xskt_socket(XSKT_SOCKET_AF_INET, XSKT_SOCKET_STREAM, 0); #endif } else { #ifdef _ANSC_IPV6_COMPATIBLE_ pMyObject->Socket = _ansc_socket(pansc_local_addrinfo->ai_family, pansc_local_addrinfo->ai_socktype, 0); #else pMyObject->Socket = _ansc_socket(ANSC_SOCKET_AF_INET, ANSC_SOCKET_STREAM, 0); #endif } if ( ((pMyObject->Socket == XSKT_SOCKET_INVALID_SOCKET) && (pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET)) || ((pMyObject->Socket == ANSC_SOCKET_INVALID_SOCKET) && !(pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET)) ) { returnStatus = ANSC_STATUS_FAILURE; goto EXIT1; } _ansc_en_reuseaddr(pMyObject->Socket); #ifndef _ANSC_IPV6_COMPATIBLE_ if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { local_addr2.sin_family = XSKT_SOCKET_AF_INET; local_addr2.sin_port = _xskt_htons(pMyObject->HostPort); if ( pMyObject->HostAddress.Value == 0 ) { ((pansc_socket_addr_in)&local_addr2)->sin_addr.s_addr = XSKT_SOCKET_ANY_ADDRESS; } else { ((pansc_socket_addr_in)&local_addr2)->sin_addr.s_addr = pMyObject->HostAddress.Value; } } else { local_addr1.sin_family = ANSC_SOCKET_AF_INET; local_addr1.sin_port = _ansc_htons(pMyObject->HostPort); if ( pMyObject->HostAddress.Value == 0 ) { local_addr1.sin_addr.s_addr = ANSC_SOCKET_ANY_ADDRESS; } else { local_addr1.sin_addr.s_addr = pMyObject->HostAddress.Value; } } #endif #if !defined(_ANSC_KERNEL) || !defined(_ANSC_LINUX) if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { #ifdef _ANSC_IPV6_COMPATIBLE_ s_result = _xskt_bind(pMyObject->Socket, pxskt_local_addrinfo->ai_addr, pxskt_local_addrinfo->ai_addrlen); #else AnscTrace("AnscDstoEngage -- the address is 0x%lX:%d, familty %d.\n", _ansc_ntohl(local_addr2.sin_addr.s_addr), _ansc_ntohs(local_addr2.sin_port), local_addr2.sin_family); s_result = _xskt_bind(pMyObject->Socket, (xskt_socket_addr*)&local_addr2, sizeof(local_addr2)); #endif } else { #ifdef _ANSC_IPV6_COMPATIBLE_ s_result = _ansc_bind(pMyObject->Socket, pansc_local_addrinfo->ai_addr, pansc_local_addrinfo->ai_addrlen); #else s_result = _ansc_bind(pMyObject->Socket, (ansc_socket_addr*)&local_addr1, sizeof(local_addr1)); #endif } #else if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { while ( _xskt_bind(pMyObject->Socket, (ansc_socket_addr*)&local_addr2, sizeof(local_addr2)) != 0 ) { AnscTrace ( "AnscDstoEngage -- failure to bind try again !socket %d family %d port %d address %X \n", pMyObject->Socket, local_addr2.sin_family, local_addr2.sin_port, ((pansc_socket_addr_in)&local_addr2)->sin_addr.s_addr ); AnscSleep(10); } } else { while ( _ansc_bind(pMyObject->Socket, (ansc_socket_addr*)&local_addr1, sizeof(local_addr1)) != 0 ) { AnscTrace ( "AnscDstoEngage -- failure to bind try again !socket %d family %d port %d address %X \n", pMyObject->Socket, local_addr1.sin_family, local_addr1.sin_port, local_addr1.sin_addr.s_addr ); AnscSleep(10); } } #endif if ( s_result != 0 ) { AnscTrace ( "AnscDstoEngage -- failed to bind to the socket, error code is %d!!!\n", (pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET) ? _xskt_get_last_error() : _ansc_get_last_error() ); returnStatus = ANSC_STATUS_FAILURE; goto EXIT2; } pMyObject->ManufactureEnginePool((ANSC_HANDLE)pMyObject); pMyObject->ManufactureSocketPool((ANSC_HANDLE)pMyObject); pMyObject->StartEngines ((ANSC_HANDLE)pMyObject); if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { s_result = _xskt_listen(pMyObject->Socket, ANSC_SOCKET_BACKLOG_VALUE); } else { s_result = _ansc_listen(pMyObject->Socket, ANSC_SOCKET_BACKLOG_VALUE); } if ( s_result != 0 ) { AnscTrace("AnscDstoEngage -- failed to listen on the socket!\n"); returnStatus = ANSC_STATUS_FAILURE; goto EXIT2; } /* * If the compilation option '_ANSC_SOCKET_TLS_LAYER_' is enabled, we can simply let the ANSC * socket layer to perform the SSL/TLS functionality; otherwise, we need to prepare for doing * SSL/TLS internally. */ if ( pMyObject->Mode & ANSC_DSTO_MODE_TLS_ENABLED ) { #ifdef _ANSC_USE_OPENSSL_ pMyObject->bTlsEnabled = TRUE; if ( !openssl_init(SSL_SERVER_CALLS) ) { AnscTrace("AnscSctoEngage - openssl_init() failed!\n"); returnStatus = ANSC_STATUS_FAILURE; goto EXIT2; } #else #ifdef _ANSC_SOCKET_TLS_LAYER_ { _ansc_en_usetls(pMyObject->Socket); pMyObject->bTlsEnabled = FALSE; } #else { pMyObject->hTlsScsIf = (pMyObject->hTlsScsIf != NULL)? pMyObject->hTlsScsIf : AnscSocketTlsGetScsIf(); pMyObject->bTlsEnabled = TRUE; pMyObject->bTlsReqCert = (pMyObject->Mode & ANSC_DSTO_MODE_TLS_REQ_CERT); } #endif #endif } AnscResetEvent(&pMyObject->AcceptEvent); returnStatus = pMyObject->SpawnTask3 ( (ANSC_HANDLE)pMyObject, (void* )pMyObject->AcceptTask, (ANSC_HANDLE)pMyObject, ANSC_DSTO_ACCEPT_TASK_NAME, USER_DEFAULT_TASK_PRIORITY, 2*USER_DEFAULT_TASK_STACK_SIZE ); return ANSC_STATUS_SUCCESS; /****************************************************************** GRACEFUL ROLLBACK PROCEDURES AND EXIT DOORS ******************************************************************/ EXIT2: if ( pMyObject->Mode & ANSC_DSTO_MODE_XSOCKET ) { _xskt_closesocket(pMyObject->Socket); } else { _ansc_closesocket(pMyObject->Socket); } EXIT1: if ( returnStatus != ANSC_STATUS_SUCCESS ) { pMyObject->bActive = FALSE; } return returnStatus; }
char * getDeviceMac() { CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s ENTER\n", __FUNCTION__ )); #if defined(_PLATFORM_RASPBERRYPI_) || defined(_PLATFORM_IPQ_) // Return without performing any operation as RPi Platform don't have Cable Modem and execution // of this function on RPI puts calling thread in infinite wait. return deviceMAC; #endif while(!strlen(deviceMAC)) { pthread_mutex_lock(&device_mac_mutex); int ret = -1, val_size =0,cnt =0, fd = 0; char *pcomponentName = NULL, *pcomponentPath = NULL; parameterValStruct_t **parameterval = NULL; token_t token; char isEthEnabled[64]={'\0'}; char deviceMACValue[32] = { '\0' }; #ifndef _XF3_PRODUCT_REQ_ char *getList[] = {"Device.X_CISCO_COM_CableModem.MACAddress"}; #else char *getList[] = {"Device.DPoE.Mac_address"}; #endif if (strlen(deviceMAC)) { pthread_mutex_unlock(&device_mac_mutex); break; } fd = s_sysevent_connect(&token); if(CCSP_SUCCESS == check_ethernet_wan_status() && sysevent_get(fd, token, "eth_wan_mac", deviceMACValue, sizeof(deviceMACValue)) == 0 && deviceMACValue[0] != '\0') { strcpy(fullDeviceMAC, deviceMACValue); macToLower(deviceMACValue); CcspTraceInfo(("deviceMAC is %s\n", deviceMAC)); } else { CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Before WebpaInterface_DiscoverComponent ret: %d\n",ret)); if(pcomponentPath == NULL || pcomponentName == NULL) { if(-1 == WebpaInterface_DiscoverComponent(&pcomponentName, &pcomponentPath)){ CcspTraceError(("%s ComponentPath or pcomponentName is NULL\n", __FUNCTION__)); pthread_mutex_unlock(&device_mac_mutex); return NULL; } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, WebpaInterface_DiscoverComponent ret: %d ComponentPath %s ComponentName %s \n",ret, pcomponentPath, pcomponentName)); } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Before GPV ret: %d\n",ret)); ret = CcspBaseIf_getParameterValues(bus_handle, pcomponentName, pcomponentPath, getList, 1, &val_size, ¶meterval); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, After GPV ret: %d\n",ret)); if(ret == CCSP_SUCCESS) { CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, val_size : %d\n",val_size)); for (cnt = 0; cnt < val_size; cnt++) { CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, parameterval[%d]->parameterName : %s\n",cnt,parameterval[cnt]->parameterName)); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, parameterval[%d]->parameterValue : %s\n",cnt,parameterval[cnt]->parameterValue)); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, parameterval[%d]->type :%d\n",cnt,parameterval[cnt]->type)); } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Calling macToLower to get deviceMacId\n")); strcpy(fullDeviceMAC, parameterval[0]->parameterValue); macToLower(parameterval[0]->parameterValue); if(pcomponentName) { AnscFreeMemory(pcomponentName); } if(pcomponentPath) { AnscFreeMemory(pcomponentPath); } } else { CcspLMLiteTrace(("RDK_LOG_ERROR, Failed to get values for %s ret: %d\n",getList[0],ret)); CcspTraceError(("RDK_LOG_ERROR, Failed to get values for %s ret: %d\n",getList[0],ret)); sleep(10); } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Before free_parameterValStruct_t...\n")); free_parameterValStruct_t(bus_handle, val_size, parameterval); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, After free_parameterValStruct_t...\n")); } pthread_mutex_unlock(&device_mac_mutex); } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s EXIT\n", __FUNCTION__ )); return deviceMAC; }
ULONG Pam_GetParamStringValue ( ANSC_HANDLE hInsContext, char* ParamName, char* pValue, ULONG* pulSize ) { int iReturnValue = 0; PCOSA_CONTEXT_LINK_OBJECT pCosaContext = (PCOSA_CONTEXT_LINK_OBJECT)hInsContext; char IpIfObjName[128] = {0}; ULONG IpIfObjNameSize = 0; ULONG ulInstNum = 0; char Buffer[128] = {0}; ULONG BufferSize = 0; CcspTraceInfo(("[%s] -- '%s', pValue addr: 0x%x, pulSize addr: 0x%x \n", __FUNCTION__, ParamName, pValue, pulSize)); IpIfObjNameSize = sizeof(IpIfObjName) - 1; /* check the parameter name and return the corresponding value */ if( AnscEqualString(ParamName, "FirstUpstreamIpInterface", TRUE)) { /* We hardcode the value here temporarily. In the future, if LowerLayers mechanism works well, we can change back*/ /* AnscCopyString(pValue, "Device.IP.Interface.1."); *pulSize = _ansc_strlen("Device.IP.Interface.1."); return 0; */ if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { if ( IpIfObjNameSize < *pulSize ) { AnscCopyString(pValue, IpIfObjName); *pulSize = IpIfObjNameSize; return 0; } else { *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpInterface", TRUE)) { /* We hardcode the value here temporarily. In the future, if LowerLayers mechanism works well, we can change back*/ /* AnscCopyString(pValue, "Device.IP.Interface.4."); *pulSize = _ansc_strlen("Device.IP.Interface.4."); return 0; */ // CcspTraceInfo(("Pam_GetParamStringValue -- FirstDownstreamIpInterface case\n")); if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { // CcspTraceInfo(("Pam_GetParamStringValue -- '%s' Pam_GetFirstIpInterfaceObjectName ret success\n", ParamName)); CcspTraceInfo(("[%s] -- '%s' IpIfObjNameSize: %d, pulSize: %d\n", __FUNCTION__, ParamName, IpIfObjNameSize, *pulSize)); if ( IpIfObjNameSize < *pulSize ) { AnscCopyString(pValue, IpIfObjName); CcspTraceInfo(("[%s] -- pValue: %s\n", __FUNCTION__, pValue)); *pulSize = IpIfObjNameSize; return 0; } else { *pulSize = IpIfObjNameSize; return 1; } } else { CcspTraceInfo(("[%s] -- '%s' Pam_GetFirstIpInterfaceObjectName ret failed\n", __FUNCTION__, ParamName)); return -1; } } else if( AnscEqualString(ParamName, "FirstUpstreamIpv4Address", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "IPAddress"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve IP address, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstUpstreamIpv4SubnetMask", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "SubnetMask"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve subnet mask, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpv4Address", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "IPAddress"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve IP address, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpv4SubnetMask", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "SubnetMask"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve subnet mask, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ return -1; }
void sendWebpaMsg(char *serviceName, char *dest, char *trans_id, char *contentType, char *payload, unsigned int payload_len) { pthread_mutex_lock(&webpa_mutex); #ifdef PARODUS_ENABLE wrp_msg_t *wrp_msg ; int retry_count = 0, backoffRetryTime = 0, c = 2; int sendStatus = -1; char source[MAX_PARAMETERNAME_LEN/2] = {'\0'}; #else char* faultParam = NULL; int ret = -1; parameterValStruct_t val = {0}; char * packedMsg = NULL; CCSP_MESSAGE_BUS_INFO *bus_info = (CCSP_MESSAGE_BUS_INFO *)bus_handle; #endif CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s ENTER\n", __FUNCTION__ )); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, <======== Start of sendWebpaMsg =======>\n")); #ifdef PARODUS_ENABLE CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, deviceMAC *********:%s\n",deviceMAC)); if(serviceName!= NULL){ CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, serviceName :%s\n",serviceName)); snprintf(source, sizeof(source), "mac:%s/%s", deviceMAC, serviceName); } if(dest!= NULL){ CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, dest :%s\n",dest)); } if(trans_id!= NULL){ CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, transaction_id :%s\n",trans_id)); } if(contentType!= NULL){ CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, contentType :%s\n",contentType)); } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, payload_len :%d\n",payload_len)); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Received DeviceMac from Atom side: %s\n",deviceMAC)); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Source derived is %s\n", source)); wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); if(wrp_msg != NULL) { memset(wrp_msg, 0, sizeof(wrp_msg_t)); wrp_msg->msg_type = WRP_MSG_TYPE__EVENT; wrp_msg->u.event.payload = (void *)payload; wrp_msg->u.event.payload_size = payload_len; wrp_msg->u.event.source = source; wrp_msg->u.event.dest = dest; wrp_msg->u.event.content_type = contentType; CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->msg_type :%d\n",wrp_msg->msg_type)); if(wrp_msg->u.event.payload!=NULL) CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->u.event.payload :%s\n",(char *)(wrp_msg->u.event.payload))); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->u.event.payload_size :%d\n",wrp_msg->u.event.payload_size)); if(wrp_msg->u.event.source != NULL) CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->u.event.source :%s\n",wrp_msg->u.event.source)); if(wrp_msg->u.event.dest!=NULL) CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->u.event.dest :%s\n",wrp_msg->u.event.dest)); if(wrp_msg->u.event.content_type!=NULL) CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, wrp_msg->u.event.content_type :%s\n",wrp_msg->u.event.content_type)); while(retry_count<=5) { backoffRetryTime = (int) pow(2, c) -1; CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, retry_count : %d\n",retry_count)); sendStatus = libparodus_send(client_instance, wrp_msg); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, sendStatus is %d\n",sendStatus)); if(sendStatus == 0) { retry_count = 0; CcspTraceInfo(("Sent message successfully to parodus\n")); break; } else { CcspTraceError(("Failed to send message: '%s', retrying ....\n",libparodus_strerror(sendStatus))); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, backoffRetryTime %d seconds\n", backoffRetryTime)); sleep(backoffRetryTime); c++; retry_count++; } } CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, Before freeing wrp_msg\n")); free(wrp_msg); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, After freeing wrp_msg\n")); } #else // Pack the message using msgpck WRP notification format and then using base64 packedMsg = packStructure(serviceName, dest, trans_id, payload, contentType,payload_len); /* if(consoleDebugEnable) { fprintf(stderr, "RDK_LOG_DEBUG, base64 encoded msgpack packed data containing %d bytes is : %s\n",strlen(packedMsg),packedMsg); }*/ // set this packed message as value of WebPA Post parameter val.parameterValue = packedMsg; val.type = ccsp_base64; val.parameterName = WEBPA_PARAMETER_NAME; CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, val.parameterName %s, val.type %d\n",val.parameterName,val.type)); ret = CcspBaseIf_setParameterValues(bus_handle, WEBPA_COMPONENT_NAME, WEBPA_DBUS_PATH, 0, 0x0000000C, /* session id and write id */ &val, 1, TRUE, /* no commit */ &faultParam); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, CcspBaseIf_setParameterValues ret %d\n",ret)); if (ret != CCSP_SUCCESS) { CcspLMLiteTrace(("RDK_LOG_ERROR, ~~~~ Error:Failed to SetValue - ret : %d\n", ret)); if(faultParam) { CcspLMLiteTrace(("RDK_LOG_ERROR, ~~~~ Error:Failed to SetValue for param : '%s'\n", faultParam)); bus_info->freefunc(faultParam); } } if(packedMsg != NULL) { free(packedMsg); packedMsg = NULL; } #endif CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, <======== End of sendWebpaMsg =======>\n")); CcspLMLiteConsoleTrace(("RDK_LOG_DEBUG, LMLite %s EXIT\n", __FUNCTION__ )); pthread_mutex_unlock(&webpa_mutex); }
ANSC_STATUS BbhmDiageoResultQueryTask ( ANSC_HANDLE hThisObject ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PBBHM_DIAG_EXEC_OBJECT pMyObject = (PBBHM_DIAG_EXEC_OBJECT )hThisObject; PDSLH_DIAG_INFO_BASE pDiagInfo = NULL; BOOLEAN bQueryDone = FALSE; AnscTraceFlow(("BbhmDiageoResultQueryTask ...\n")); do { returnStatus = pMyObject->RetrieveResult((ANSC_HANDLE)pMyObject); if ( returnStatus == ANSC_STATUS_SUCCESS ) { pDiagInfo = (PDSLH_DIAG_INFO_BASE)pMyObject->hDslhDiagInfo; bQueryDone = TRUE; if ( (pDiagInfo->DiagnosticState != DSLH_DIAG_STATE_TYPE_Inprogress) && (pDiagInfo->DiagnosticState != DSLH_DIAG_STATE_TYPE_Requested) ) { pMyObject->ResultTimestamp = AnscGetTickInSeconds(); break; } } else { /* internal error occurs, quit immediatelly */ break; } AnscWaitEvent(&pMyObject->ResultQueryEvent, 1000); } while ( pMyObject->bResultQueryRunning ); if ( TRUE/*pDiagInfo->RequestType == DSLH_DIAGNOSTIC_REQUEST_TYPE_Acs*/ ) { /* Always notify the initiator */ CcspTraceInfo(("BbhmDiageoResultQueryTask -- notify initiator.....\n")); /* send out the notification */ if ( ANSC_STATUS_SUCCESS != CosaSendDiagCompleteSignal() ) { AnscTraceWarning(("Failed to send event for diagnostics completion.\n")); } } AnscAcquireLock(&pMyObject->AccessLock); AnscTraceFlow(("BbhmDiageoResultQueryTask -- quiting...\n")); /* * stop the diagnostic process */ pMyObject->bResultQueryRunning = FALSE; if ( !bQueryDone ) { pMyObject->StopDiag((ANSC_HANDLE)pMyObject); } AnscSetEvent(&pMyObject->ResultQueryExitEvent); AnscReleaseLock(&pMyObject->AccessLock); AnscTraceFlow(("BbhmDiageoStartDiag -- exit...\n")); return ANSC_STATUS_SUCCESS; }
int cmd_dispatch(int command) { ULONG ulInsNumber = 0; parameterValStruct_t val[3] = {0}; char* pParamNames[] = {"Device.X_CISCO_COM_DDNS."}; parameterValStruct_t** ppReturnVal = NULL; parameterInfoStruct_t** ppReturnValNames = NULL; parameterAttributeStruct_t** ppReturnvalAttr = NULL; ULONG ulReturnValCount = 0; ULONG i = 0; switch ( command ) { case 'e' : #ifdef _ANSC_LINUX CcspTraceInfo(("Connect to bus daemon...\n")); { char CName[256]; if ( g_Subsystem[0] != 0 ) { _ansc_sprintf(CName, "%s%s", g_Subsystem, gpPnmStartCfg->ComponentId); } else { _ansc_sprintf(CName, "%s", gpPnmStartCfg->ComponentId); } ssp_PnmMbi_MessageBusEngage ( CName, CCSP_MSG_BUS_CFG, gpPnmStartCfg->DbusPath ); } #endif ssp_create_pnm(gpPnmStartCfg); ssp_engage_pnm(gpPnmStartCfg); g_bActive = TRUE; CcspTraceInfo(("Provision & Management Module loaded successfully...\n")); break; case 'r' : CcspCcMbi_GetParameterValues ( DSLH_MPA_ACCESS_CONTROL_ACS, pParamNames, 1, &ulReturnValCount, &ppReturnVal, NULL ); for ( i = 0; i < ulReturnValCount; i++ ) { CcspTraceWarning(("Parameter %d name: %s value: %s \n", i+1, ppReturnVal[i]->parameterName, ppReturnVal[i]->parameterValue)); } /* CcspCcMbi_GetParameterNames ( "Device.DeviceInfo.", 0, &ulReturnValCount, &ppReturnValNames ); for ( i = 0; i < ulReturnValCount; i++ ) { CcspTraceWarning(("Parameter %d name: %s bWritable: %d \n", i+1, ppReturnValNames[i]->parameterName, ppReturnValNames[i]->writable)); } */ /* CcspCcMbi_GetParameterAttributes ( pParamNames, 1, &ulReturnValCount, &ppReturnvalAttr ); */ /* CcspCcMbi_DeleteTblRow ( 123, "Device.X_CISCO_COM_SWDownload.SWDownload.1." ); */ break; case 'm': AnscPrintComponentMemoryTable(pComponentName); break; case 't': AnscTraceMemoryTable(); break; case 'c': ssp_cancel_pnm(gpPnmStartCfg); break; default: break; } return 0; }