ULONG CosaDmlBlkURL_GetNumberOfEntries(void) { char *param_value = NULL; PSM_Get_Record_Value2(bus_handle,g_Subsystem, "dmsb.X_Comcast_com_ParentalControl.ManagedSites.InstanceNumber", NULL, ¶m_value); if(param_value!=NULL){ g_NrBlkURL = atoi(param_value); } else{ g_NrBlkURL = 0;//RDKB-EMULATOR } return g_NrBlkURL; }
ULONG CosaDmlMSServ_GetNumberOfEntries(void) { //RDKB-EMULATOR char *param_value = NULL; PSM_Get_Record_Value2(bus_handle,g_Subsystem, "dmsb.X_Comcast_com_ParentalControl.ManagedServices.InstanceNumber", NULL, ¶m_value); if(param_value!=NULL){ g_NrMSServs = atoi(param_value); } else{ g_NrMSServs = 0; } return g_NrMSServs; }
ANSC_STATUS CosaDmlGetCaptivePortalEnable ( BOOL *pValue ) { char *param_value = NULL; PSM_Get_Record_Value2(bus_handle,g_Subsystem, "Device.DeviceInfo.X_RDKCENTRAL-COM_CaptivePortalEnable", NULL, ¶m_value); if(strcmp(param_value,"true") == 0) *pValue = true; else *pValue = false; return ANSC_STATUS_SUCCESS; }
static int GrePsmGet(const char *param, char *value, int size) { char *val; CCSP_MESSAGE_BUS_INFO *businfo; if (PSM_Get_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent), (char *)param, NULL, &val) != CCSP_SUCCESS) return -1; snprintf(value, size, "%s", val); businfo = g_MessageBusHandle; businfo->freefunc(val); return 0; }
static int PsmGet(const char *param, char *value, int size) { char *val = NULL; if (PSM_Get_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent), (char *)param, NULL, &val) != CCSP_SUCCESS) return -1; if(val) { snprintf(value, size, "%s", val); ((CCSP_MESSAGE_BUS_INFO *)g_MessageBusHandle)->freefunc(val); } else return -1; return 0; }
// Function: process_set // Example: ./psmcli set COM.CISCO.CCSP.ETH0.IPv4_ADDR 192.168.100.2 unsigned int process_set(int const argCnt, char const * const argVars[], char const * const busHandle) { //printf("Command Arguments = %s\n", argVars[1]); int cmd_index = 2; int cmd_cnt = argCnt - 2; unsigned int ret = 0; unsigned int func_ret = CCSP_SUCCESS; char *psmValue = NULL; unsigned int psmType = ccsp_string; char *typeStr = NULL; char const func_name[] = "process_set"; if ((cmd_cnt % 2) != 0) { CcspTraceWarning(("<%s>[%s]: arg count = %d is not even, returning %d CCSP_ERR_INVALID_ARGUMENTS\n", prog_name, func_name, cmd_cnt, CCSP_ERR_INVALID_ARGUMENTS)); return CCSP_ERR_INVALID_ARGUMENTS; } /* Use the same type as the object's current type or use string in case of new object name */ cmd_cnt = cmd_cnt/2; while(cmd_cnt--) { ret = 0; ret = PSM_Get_Record_Value2((void*)busHandle, subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index], &psmType, &psmValue); if (ret == CCSP_SUCCESS && psmValue != NULL) { ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; // Set the new value, Reuse type info ret = 0; ret = PSM_Set_Record_Value2((void*)busHandle, subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index], psmType, argVars[cmd_index+1]); // Comment below if (ret == CCSP_SUCCESS) { printf("%d\n", CCSP_SUCCESS); } else { CcspTraceWarning(("<%s>[%s]: processing setting '%s' to '%s' unsuccessful, return set to %d\n", prog_name, func_name, argVars[cmd_index], argVars[cmd_index+1], ret)); func_ret = ret; // break; // to accommondate more cmd } } else { // New object name, use default type = ccsp_string // Set the new value psmType = ccsp_string; ret = 0; ret = PSM_Set_Record_Value2((void*)busHandle, subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index], psmType, argVars[cmd_index+1]); if (ret == CCSP_SUCCESS) { printf("%d\n", CCSP_SUCCESS); } else { CcspTraceWarning(("<%s>[%s]: processing setting '%s' to '%s' unsuccessful, return set to %d\n", prog_name, func_name, argVars[cmd_index], argVars[cmd_index+1], ret)); func_ret = ret; // break; // to accommondate more cmd } } cmd_index+=2; } if(psmValue != NULL) ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); // CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret)); return func_ret; }
// Function: process_getdetail_e // Example: ./psmcli getdetail -e ETH0_IPV4ADDR COM.CISCO.CCSP.ETH0.IPv4_ADDR unsigned int process_getdetail_e(int const argCnt, char const * const argVars[], char const * const busHandle) { //printf("Command Arguments = %s\t%s\n", argVars[1], argVars[2]); // Check if arguments are in pairs int cmd_index = 3; int cmd_cnt = argCnt - 3; unsigned int ret = 0; unsigned int iter = 0; unsigned int func_ret = CCSP_SUCCESS; char *psmValue = NULL; unsigned int psmType = ccsp_string; char *typeStr = NULL; char *typeStrEnv = NULL; char const func_name[] = "process_getdetail_e"; if ((cmd_cnt % 2) != 0) { CcspTraceWarning(("<%s>[%s]: arg count = %d is not even, returning %d CCSP_ERR_INVALID_ARGUMENTS\n", prog_name, func_name, cmd_cnt, CCSP_ERR_INVALID_ARGUMENTS)); return CCSP_ERR_INVALID_ARGUMENTS; } cmd_cnt = cmd_cnt/2; // Loop over the commands and extract the values while(cmd_cnt--) { ret = 0; iter = 0; do { ret = PSM_Get_Record_Value2((void*)busHandle, subsys_prefix, //PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index+1], &psmType, &psmValue); iter++; } while (( psmValue == NULL ) && ( iter < 3 ) ); if (ret == CCSP_SUCCESS) { if (psmValue != NULL) { get_type_info(&psmType, &typeStr, TYPE_FORMAT_CCSP); typeStrEnv = AnscAllocateMemory(strlen(argVars[cmd_index]) + strlen("_TYPE") + 1); strncpy(typeStrEnv, argVars[cmd_index], strlen(argVars[cmd_index])+1); strcat(typeStrEnv, "_TYPE"); printf("%s=\"%s\"\n",typeStrEnv, typeStr); printf("%s=\"%s\"\n",argVars[cmd_index], psmValue); AnscFreeMemory(typeStrEnv); AnscFreeMemory(typeStr); ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); typeStrEnv = typeStr = psmValue = NULL; } else { CcspTraceWarning(("<%s>[%s]: '%s'-> psmValue is NULL, return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; } } else if (ret == CCSP_CR_ERR_INVALID_PARAM) { CcspTraceWarning(("<%s>[%s]: invalid paramter '%s', return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; if(psmValue != NULL) { ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate more cmd } else { // Can choose to stop further procesing - use break // CcspTraceDebug(("<%s>[%s]: processing '%s' unsuccessful, return set to %d\n", // prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; if(psmValue != NULL) { ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate more cmd } cmd_index += 2; } if (psmValue != NULL) ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); // CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret)); return func_ret; }
// Function: process_get_e // Example: ./psmcli get -e ETH0_IPV4ADDR COM.CISCO.CCSP.ETH0.IPv4_ADDR unsigned int process_get_e(int const argCnt, char const * const argVars[], char const * const busHandle) { //printf("Command Arguments = %s\t%s\n", argVars[1], argVars[2]); // Check if arguments are in pairs int cmd_index = 3; int cmd_cnt = argCnt - 3; unsigned int ret = 0; unsigned int iter = 0; unsigned int func_ret = CCSP_SUCCESS; char *psmValue = NULL; unsigned int psmType = ccsp_string; char const func_name[] = "process_get_e"; if ((cmd_cnt % 2) != 0) { CcspTraceWarning(("<%s>[%s]: arg count = %d is not even, returning %d CCSP_ERR_INVALID_ARGUMENTS\n", prog_name, func_name, cmd_cnt, CCSP_ERR_INVALID_ARGUMENTS)); return CCSP_ERR_INVALID_ARGUMENTS; } cmd_cnt = cmd_cnt/2; #ifdef PSMCLI_TESTING_LOCAL if (psmcli_debug_print >= PSMCLI_DEBUG_PRINT_SUBROUTINE) { int i=0; CcspTraceDebug(("<%s>[%s]: cmd_cnt=%d, '", prog_name, func_name, cmd_cnt)); for(i=0; i<(cmd_cnt-1); i++) { CcspTraceDebug(("%s %s ", argVars[cmd_index+i*2], argVars[cmd_index+i*2+1])); } CcspTraceDebug(("%s %s\'\n", argVars[cmd_index+(cmd_cnt-1)*2], argVars[cmd_index+(cmd_cnt-1)*2+1])); } #endif // Loop over the commands and extract the values while(cmd_cnt--) { // CcspTraceDebug(("<%s>[%s]: PSM_Get2 query='%s'\n", prog_name, func_name, argVars[cmd_index+1])); ret = 0; iter = 0; do { ret = PSM_Get_Record_Value2((void*)busHandle, subsys_prefix, //PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index+1], &psmType, &psmValue); iter++; } while (( psmValue == NULL ) && ( iter < 3 ) ); #ifdef PSMCLI_TESTING_LOCAL CcspTraceDebug(("<%s>[%s]: ret=%d", prog_name, func_name, ret)); if (psmValue!=NULL) { CcspTraceDebug((", psmValue='%s'\n", psmValue)); } else { CcspTraceDebug((", psmValue = NULL\n")); } #endif if (ret == CCSP_SUCCESS) { if(psmValue != NULL) { printf("%s=\"%s\"\n",argVars[cmd_index], psmValue); // CcspTraceDebug(("<%s>[%s]: freeing psmValue at address 0x%x\n", prog_name, func_name, (unsigned int)psmValue)); ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } else { CcspTraceWarning(("<%s>[%s]: '%s'-> psmValue is NULL, return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; } } else if (ret == CCSP_CR_ERR_INVALID_PARAM) { CcspTraceWarning(("<%s>[%s]: invalid paramter '%s', return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; if(psmValue != NULL) { // CcspTraceDebug(("<%s>[%s]: freeing psmValue at address 0x%x\n", prog_name, func_name, (unsigned int)psmValue)); ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate more cmd } else { // Can choose to stop further procesing - use break // CcspTraceDebug(("<%s>[%s]: processing '%s' unsuccessful, returning %d\n", // prog_name, func_name, argVars[cmd_index+1], ret)); func_ret = ret; if(psmValue != NULL) { // CcspTraceDebug(("<%s>[%s]: freeing psmValue at address 0x%x\n", prog_name, func_name, (unsigned int)psmValue)); ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate more cmd } cmd_index += 2; } if (psmValue != NULL) { // CcspTraceDebug(("<%s>[%s]: freeing psmValue at address 0x%x\n", prog_name, func_name, (unsigned int)psmValue)); ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); } // CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret)); return func_ret; }
// Function: process_getdetail // Example: ./psmcli getdetail COM.CISCO.CCSP.ETH0.IPv4_ADDR unsigned int process_getdetail(int const argCnt, char const * const argVars[], char const * const busHandle) { int cmd_index = 2; int cmd_cnt = argCnt - 2; unsigned int ret = 0; unsigned int iter = 0; unsigned int func_ret = CCSP_SUCCESS; char *psmValue = NULL; unsigned int psmType = ccsp_string; char *typeStr = NULL; char const func_name[] = "process_getdetail"; // Loop over the commands and extract the values while(cmd_cnt--) { ret = 0; iter = 0; do { ret = PSM_Get_Record_Value2((void*)busHandle, subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, argVars[cmd_index], &psmType, &psmValue); iter++; } while (( psmValue == NULL ) && ( iter < 3 ) ); if (ret == CCSP_SUCCESS) { if (psmValue != NULL) { get_type_info(&psmType, &typeStr, TYPE_FORMAT_CCSP); if(typeStr != NULL) { printf("%s\n%s\n", typeStr, psmValue); AnscFreeMemory(typeStr); } ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); typeStr = psmValue = NULL; } else { CcspTraceWarning(("<%s>[%s]: '%s'-> psmValue is NULL, return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index], ret)); func_ret = ret; } } else if (ret == CCSP_CR_ERR_INVALID_PARAM) { CcspTraceWarning(("<%s>[%s]: invalid paramter '%s', return set to %d = CCSP_CR_ERR_INVALID_PARAM\n", prog_name, func_name, argVars[cmd_index], ret)); func_ret = ret; if(psmValue != NULL) { ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate cmd_cnt > 1 } else { // Can choose to stop further processing - use break CcspTraceWarning(("<%s>[%s]: processing '%s' unsuccessful, returning %d\n", prog_name, func_name, argVars[cmd_index], ret)); func_ret = ret; if(psmValue != NULL) { ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); psmValue = NULL; } // break; // to accommondate cmd_cnt > 1 } cmd_index++; } if(psmValue != NULL) ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(psmValue); // CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret)); return func_ret; }
/********************************************************************** caller: owner of this object prototype: BOOL DeviceInfo_GetParamBoolValue_Custom ( ANSC_HANDLE hInsContext, char* ParamName, BOOL* pBool ); description: This function is called to retrieve Boolean parameter value; argument: ANSC_HANDLE hInsContext, The instance handle; char* ParamName, The parameter name; BOOL* pBool The buffer of returned boolean value; return: TRUE if succeeded. **********************************************************************/ BOOL DeviceInfo_GetParamBoolValue_Custom ( ANSC_HANDLE hInsContext, char* ParamName, BOOL* pBool ) { PCOSA_DATAMODEL_DEVICEINFO pMyObject = (PCOSA_DATAMODEL_DEVICEINFO)g_pCosaBEManager->hDeviceInfo; char *param_value = NULL; #ifdef CONFIG_INTERNET2P0 if (AnscEqualString(ParamName, "X_RDKCENTRAL-COM_ConfigureWiFi", TRUE)) { PSM_Get_Record_Value2(bus_handle,g_Subsystem, "Device.DeviceInfo.X_RDKCENTRAL-COM_ConfigureWiFi", NULL, ¶m_value); if(strcmp(param_value,"true") == 0) pMyObject->bWiFiConfigued = TRUE; else pMyObject->bWiFiConfigued = FALSE; *pBool = pMyObject->bWiFiConfigued; return TRUE; } if (AnscEqualString(ParamName, "X_RDKCENTRAL-COM_WiFiNeedsPersonalization",TRUE)) { char buf[5]; syscfg_get( NULL, "redirection_flag", buf, sizeof(buf)); if( buf != NULL ) { if (strcmp(buf,"true") == 0) *pBool = TRUE; else *pBool = FALSE; } return TRUE; } if (AnscEqualString(ParamName, "X_RDKCENTRAL-COM_CaptivePortalEnable", TRUE)) { // *pBool = pMyObject->bCaptivePortalEnable; if (CosaDmlGetCaptivePortalEnable(&pMyObject->bCaptivePortalEnable) != ANSC_STATUS_SUCCESS) return FALSE; *pBool = pMyObject->bCaptivePortalEnable; return TRUE; } if (AnscEqualString(ParamName, "X_RDKCENTRAL-COM_CloudUICapable", TRUE)) { *pBool = pMyObject->bCloudCapable; return TRUE; } if (AnscEqualString(ParamName, "X_RDKCENTRAL-COM_CloudUIEnable", TRUE)) { *pBool = pMyObject->bCloudEnable; char buf[5]; syscfg_get( NULL, "cloud_enable_flag", buf, sizeof(buf)); if( buf != NULL ) { if (strcmp(buf,"1") == 0) pMyObject->bCloudEnable = TRUE; else pMyObject->bCloudEnable = FALSE; } *pBool = pMyObject->bCloudEnable; return TRUE; } #endif #ifdef CONFIG_CISCO_HOTSPOT /* check the parameter name and return the corresponding value */ if (AnscEqualString(ParamName, "X_COMCAST-COM_xfinitywifiCapableCPE", TRUE)) { if (CosaDmlDiGetXfinityWiFiCapable(pBool) != ANSC_STATUS_SUCCESS) return FALSE; return TRUE; } if (AnscEqualString(ParamName, "X_COMCAST_COM_xfinitywifiEnable", TRUE)) { if (CosaDmlDiGetXfinityWiFiEnable(pBool) != ANSC_STATUS_SUCCESS) return FALSE; // printf("%s : bxfinitywifiEnable value is : %d\n",__FUNCTION__,pMyObject->bxfinitywifiEnable); //*pBool = pMyObject->bxfinitywifiEnable; return TRUE; } #endif if (AnscEqualString(ParamName, "X_COMCAST-COM_rdkbPlatformCapable", TRUE)) { *pBool = TRUE; return TRUE; } /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ return FALSE; }