static int
GrePsmSet(const char *param, const char *value)
{
    if (PSM_Set_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent),
                (char *)param, ccsp_string, (char *)value) != CCSP_SUCCESS)
        return -1;
    return 0;
}
Example #2
0
// Function: process_setdetail
// Example: ./psmcli setdetail string COM.CISCO.CCSP.ETH0.IPv4_ADDR 192.168.100.2
unsigned int process_setdetail(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_setdetail";

    if ((cmd_cnt % 3) != 0) {
    	CcspTraceWarning(("<%s>[%s]: arg count = %d is not a multiple of 3, returning %d CCSP_ERR_INVALID_ARGUMENTS\n", 
                        prog_name, func_name, cmd_cnt, CCSP_ERR_INVALID_ARGUMENTS));
    	return CCSP_ERR_INVALID_ARGUMENTS;
    }
    
    // setdetail shall override the current object type and set the new specified type
    cmd_cnt = cmd_cnt/3;
    while(cmd_cnt--) {
        
    	get_type_info(&psmType, (char**)&argVars[cmd_index], TYPE_FORMAT_STRING);
    	if(psmType != ccsp_none) {
            
            ret = 0;
            ret = PSM_Set_Record_Value2((void*)busHandle,
        	            		subsys_prefix, //	PSMCLI_SUBSYSTEM_PREFIX,
                                        argVars[cmd_index+1],
                                        psmType,
                                        argVars[cmd_index+2]);
            
            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+1], argVars[cmd_index+2], ret));
                func_ret = ret;
                //                break;  // to accommondate more cmd
            }
        } else {
            CcspTraceWarning(("<%s>[%s]: unsupported datatype '%s', return set to %d = CCSP_CR_ERR_UNSUPPORTED_DATATYPE\n", 
                            prog_name, func_name, argVars[cmd_index], CCSP_CR_ERR_UNSUPPORTED_DATATYPE));
            func_ret = CCSP_CR_ERR_UNSUPPORTED_DATATYPE;
            //                break;  // to accommondate more cmd
        }

        cmd_index+=3;
    }

    //    CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret));

    return func_ret;
}
ANSC_STATUS
CosaDmlSetCaptivePortalEnable
    (
        BOOL value
    )
{
	char buf[10];
	char cmd[50];
	memset(buf,0,sizeof(buf));
	memset(cmd,0,sizeof(cmd));
	if (value)
	{
		strcpy(buf,"true");
		CcspTraceWarning(("CaptivePortal: Enabling Captive Portal switch ...\n"));		
	}
	else
	{
		CcspTraceWarning(("CaptivePortal: Disabling Captive Portal switch ...\n"));		
		strcpy(buf,"false");
	}
	PSM_Set_Record_Value2(bus_handle,g_Subsystem,"Device.DeviceInfo.X_RDKCENTRAL-COM_CaptivePortalEnable", ccsp_string,buf);

	return ANSC_STATUS_SUCCESS;
}
Example #4
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;
}