34 #include "XrdkCentralComRFCVar.h"
35 #include "hostIf_utils.h"
37 #define MAX_NUM_PARAMETERS 2048
38 #define DEVICE_REBOOT_PARAM "Device.X_CISCO_COM_DeviceControl.RebootDevice"
40 static DATA_TYPE getWdmpDataType(
char *dmParamDataType)
42 DATA_TYPE wdmpDataType = WDMP_NONE;
44 if(!strcmp(dmParamDataType,
"string"))
45 wdmpDataType = WDMP_STRING;
46 else if(!strcmp(dmParamDataType,
"boolean"))
47 wdmpDataType = WDMP_BOOLEAN;
48 else if(!strcmp(dmParamDataType,
"unsignedInt"))
49 wdmpDataType = WDMP_UINT;
50 else if(!strcmp(dmParamDataType,
"int"))
51 wdmpDataType = WDMP_INT;
52 else if(!strcmp(dmParamDataType,
"unsignedLong"))
53 wdmpDataType = WDMP_ULONG;
54 else if(!strcmp(dmParamDataType,
"dataTime"))
55 wdmpDataType = WDMP_DATETIME;
58 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Unknown data type identified...\n");
59 wdmpDataType = WDMP_NONE;
71 hostIfDataType = hostIf_StringType;
75 hostIfDataType = hostIf_IntegerType;
80 hostIfDataType = hostIf_UnsignedIntType;
84 hostIfDataType = hostIf_BooleanType;
88 hostIfDataType = hostIf_DateTimeType;
97 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"No matching hostif datatype - default to String\n");
100 return hostIfDataType;
103 static void convertAndAssignParamValue (
HOSTIF_MsgData_t *param,
char *value)
107 case hostIf_StringType:
108 case hostIf_DateTimeType:
109 snprintf(param->
paramValue,TR69HOSTIFMGR_MAX_PARAM_LEN,
"%s", value);
110 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> Type: String/Date, Value = %s\n", param->
paramValue);
112 case hostIf_IntegerType:
113 case hostIf_UnsignedIntType:
115 int ivalue = atoi(value);
118 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> Type: Integer/UnsignedInt, Value = %d\n", param->
paramValue);
121 case hostIf_UnsignedLongType:
123 long lvalue = atol(value);
126 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> Type: UnsignedLong, Value = %ul\n", param->
paramValue);
129 case hostIf_BooleanType:
132 *bptr = (0 == strncasecmp(value,
"TRUE", 4)|| (isdigit(value[0]) && value[0] !=
'0' ));
133 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> Type: Boolean, Value = %d\n", param->
paramValue);
137 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> This path should never be reached. param type is %d\n", param->
paramtype);
142 char tempValue[TR69HOSTIFMGR_MAX_PARAM_LEN] = {
'\0'};
145 case hostIf_StringType:
146 case hostIf_DateTimeType:
147 snprintf(tempValue,TR69HOSTIFMGR_MAX_PARAM_LEN,
"%s", value);
148 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> String value of String = %s\n", tempValue);
150 case hostIf_IntegerType:
151 case hostIf_UnsignedIntType:
153 snprintf(tempValue,TR69HOSTIFMGR_MAX_PARAM_LEN,
"%d", *((
int *)value));
154 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> String value of Integer/UnsignedInt = %s\n", tempValue);
157 case hostIf_UnsignedLongType:
159 snprintf(tempValue,TR69HOSTIFMGR_MAX_PARAM_LEN,
"%lu", *((
unsigned long *)value));
160 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> String value of UnsignedLong = %s\n", tempValue);
163 case hostIf_BooleanType:
165 if(*((
bool*)value) ==
true)
166 strncpy(tempValue,
"true", 4);
168 strncpy(tempValue,
"false", 5);
169 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> String value of Boolean = %s\n", tempValue);
173 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
">> This path should never be reached. param type is %d\n", paramType);
175 return strdup(tempValue);
184 case hostIf_StringType:
185 case hostIf_DateTimeType:
186 if(paramValue.length() > TR69HOSTIFMGR_MAX_PARAM_LEN)
188 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Parameter Value greater than allowed %d\n", TR69HOSTIFMGR_MAX_PARAM_LEN);
193 case hostIf_IntegerType:
194 if(isdigit(paramValue[0]) || (paramValue[0] ==
'-' && isdigit(paramValue[1])))
196 int value = stoi(paramValue, &index);
197 if(index != paramValue.length())
199 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Invalid Parameter Value for an Integer Type\n");
209 case hostIf_UnsignedIntType:
210 case hostIf_UnsignedLongType:
211 if(isdigit(paramValue[0]))
213 unsigned long value = stoul(paramValue, &index);
214 if(index != paramValue.length())
216 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Invalid Parameter Value for an UnsignedInt or UnsignedLong Type\n");
226 case hostIf_BooleanType:
227 if(!strcasecmp(paramValue.c_str(),
"true")
228 || !strcasecmp(paramValue.c_str(),
"false")
229 || !strcmp(paramValue.c_str(),
"1")
230 || !strcmp(paramValue.c_str(),
"0"))
232 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Valid Boolean Value\n");
236 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Invalid Parameter Value for a Boolean\n");
242 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"Unknown Data Type\n");
250 static void getHostIfParamStFromRequest(REQ_TYPE reqType, param_t *param,
HOSTIF_MsgData_t *hostIfParam)
252 strncpy(hostIfParam->
paramName, param->name, strlen(param->name));
253 hostIfParam->
paramName[strlen(param->name)] =
'\0';
255 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering %s\n", __FUNCTION__);
259 hostIfParam->
reqType = HOSTIF_GET;
260 hostIfParam->
paramtype = getHostIfParamType(param->type);
264 hostIfParam->
reqType = HOSTIF_SET;
265 hostIfParam->
paramtype = getHostIfParamType(param->type);
266 convertAndAssignParamValue(hostIfParam, param->value);
270 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s : Operation not handled : Shouldn't come here\n", __FUNCTION__);
274 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Leaving %s\n", __FUNCTION__);
277 static WDMP_STATUS handleRFCRequest(REQ_TYPE reqType, param_t *param)
279 WDMP_STATUS wdmpStatus = WDMP_SUCCESS;
281 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering %s\n", __FUNCTION__);
286 param->value = strdup(XRFCVarStore::getInstance()->getValue(param->name).c_str());
287 if(strlen(param->value) == 0)
288 wdmpStatus = WDMP_ERR_VALUE_IS_NULL;
292 if(!strcmp(param->name, XRFC_VAR_STORE_RELOADCACHE) && (!strcasecmp(param->value,
"true") || !strcmp(param->value,
"1")))
293 XRFCVarStore::getInstance()->reloadCache();
296 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"SET operation not supported\n");
297 wdmpStatus = WDMP_ERR_METHOD_NOT_SUPPORTED;
302 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s : Invalid operation - Not Supported\n", __FUNCTION__);
304 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Leaving %s\n", __FUNCTION__);
308 static WDMP_STATUS invokeHostIfAPI(REQ_TYPE reqType, param_t *param,
HostIf_Source_Type_t bsUpdate,
const char *pcCallerID)
310 WDMP_STATUS wdmpStatus = WDMP_SUCCESS;
314 if (strcmp(pcCallerID,
"rfc") == 0)
317 hostIfParam.
requestor = HOSTIF_SRC_WEBPA;
319 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering %s\n", __FUNCTION__);
321 getHostIfParamStFromRequest(reqType, param, &hostIfParam);
326 result = hostIf_GetMsgHandler(&hostIfParam);
330 if(!validateParamValue(param->value, getHostIfParamType(param->type)))
332 result = fcInvalidParameterValue;
333 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Invalid Parameter Value\n");
336 result = hostIf_SetMsgHandler(&hostIfParam);
340 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s : Invalid operation - Not Supported\n", __FUNCTION__);
348 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"The value for param: %s = %s\n", hostIfParam.
paramName, param->value);
352 param->value = strdup(
"");
353 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Error in HostIf : %d\n", hostIfParam.
faultCode);
354 wdmpStatus = WDMP_FAILURE;
359 param->value = strdup(
"");
360 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in hostIf_msgHandler, with return value: %d\n", result);
361 if(result == fcInvalidParameterValue)
362 wdmpStatus = WDMP_ERR_INVALID_PARAMETER_VALUE;
364 wdmpStatus = WDMP_ERR_INTERNAL_ERROR;
367 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Leaving %s\n", __FUNCTION__);
371 static WDMP_STATUS validateAgainstDataModel(REQ_TYPE reqType,
char* paramName,
const char* paramValue, DATA_TYPE *dataType,
char **defaultValue,
HostIf_Source_Type_t *bsUpdate)
374 WDMP_STATUS ret = WDMP_SUCCESS;
376 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering... %s\n", __FUNCTION__);
378 const char* dbParamName = paramName;
379 if(!getParamInfoFromDataModel(getDataModelHandle(), dbParamName, &dmParam))
381 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Invalid parameter name %s: doesn't exist in data-model\n", paramName);
382 return WDMP_ERR_INVALID_PARAMETER_NAME;
384 *bsUpdate = getBSUpdateEnum(dmParam.bsUpdate);
387 if(dmParam.dataType != NULL)
389 *dataType = getWdmpDataType(dmParam.dataType);
391 if(dmParam.defaultValue)
392 *defaultValue = strdup(dmParam.defaultValue);
394 else if(reqType == SET)
396 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Validating paramValue and dataType against data-model\n");
397 if(paramValue == NULL || *dataType >= WDMP_NONE)
399 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"ParameterValue is NULL or Unknown Datatype\n");
400 ret = WDMP_ERR_VALUE_IS_NULL;
402 else if(dmParam.access != NULL && !strcasecmp(dmParam.access,
"readOnly"))
404 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Parameter is readOnly\n");
405 ret = WDMP_ERR_NOT_WRITABLE;
407 else if (getWdmpDataType(dmParam.dataType) != *dataType)
409 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Datatype doesn't match\n");
410 ret = WDMP_ERR_INVALID_PARAMETER_TYPE;
415 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s : Invalid operation - Not Supported\n", __FUNCTION__);
419 if(dmParam.objectName)
420 free(dmParam.objectName);
421 if(dmParam.paramName)
422 free(dmParam.paramName);
424 free(dmParam.bsUpdate);
426 free(dmParam.access);
428 free(dmParam.dataType);
429 if(dmParam.defaultValue)
430 free(dmParam.defaultValue);
432 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Leaving... %s\n", __FUNCTION__);
436 static void freeParam(param_t *param)
446 static bool isAuthorized(
const char* pcCallerID,
const char* pcParamName)
448 if(!strcmp(pcParamName, DEVICE_REBOOT_PARAM))
450 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s : Invalid operation - Device Reboot Not Allowed Using tr181 command/RFC API\n", __FUNCTION__);
457 static bool allocate_res_struct_members(res_struct *respSt, req_struct *reqSt)
459 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering... %s\n", __FUNCTION__);
460 respSt->reqType = reqSt->reqType;
461 respSt->timeSpan = NULL;
462 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Allocating res_struct for reqType : ... %d\n", reqSt->reqType);
463 switch(reqSt->reqType)
466 if(reqSt->u.getReq->paramCnt == 0)
469 respSt->paramCnt = reqSt->u.getReq->paramCnt;
470 respSt->retStatus = (WDMP_STATUS *)calloc(respSt->paramCnt,
sizeof(WDMP_STATUS));
471 respSt->u.getRes = (get_res_t *)malloc(
sizeof(get_res_t));
472 if(respSt->u.getRes != NULL && respSt->retStatus != NULL)
474 memset(respSt->u.getRes, 0,
sizeof(get_res_t));
476 respSt->u.getRes->paramCnt = reqSt->u.getReq->paramCnt;
477 respSt->u.getRes->paramNames = (
char **)malloc(
sizeof(
char *) * (reqSt->u.getReq->paramCnt));
478 respSt->u.getRes->params = (param_t **)malloc(
sizeof(param_t *) * reqSt->u.getReq->paramCnt);
479 respSt->u.getRes->retParamCnt = (
size_t *)malloc(
sizeof(
size_t) * reqSt->u.getReq->paramCnt);
481 if(respSt->u.getRes->paramNames == NULL || respSt->u.getRes->params == NULL || respSt->u.getRes->retParamCnt == NULL)
483 if(respSt->u.getRes->paramNames) free(respSt->u.getRes->paramNames);
484 if(respSt->u.getRes->params) free(respSt->u.getRes->params);
485 if(respSt->u.getRes->retParamCnt) free(respSt->u.getRes->retParamCnt);
491 memset(respSt->u.getRes->paramNames, 0,
sizeof(
char *) * reqSt->u.getReq->paramCnt);
492 memset(respSt->u.getRes->params, 0,
sizeof(param_t *) * reqSt->u.getReq->paramCnt);
493 memset(respSt->u.getRes->retParamCnt, 0,
sizeof(
size_t) * reqSt->u.getReq->paramCnt);
504 if(reqSt->u.setReq->paramCnt == 0)
507 respSt->paramCnt = reqSt->u.setReq->paramCnt;
508 respSt->retStatus = (WDMP_STATUS *)calloc(respSt->paramCnt,
sizeof(WDMP_STATUS));
509 respSt->u.paramRes = (param_res_t *)malloc(
sizeof(param_res_t));
510 if(respSt->u.paramRes != NULL)
512 memset(respSt->u.paramRes, 0,
sizeof(param_res_t));
514 respSt->u.paramRes->params = (param_t *)malloc(
sizeof(param_t) * reqSt->u.setReq->paramCnt);
515 if(respSt->u.paramRes->params == NULL)
517 free(respSt->u.paramRes);
522 memset(respSt->u.paramRes->params, 0,
sizeof(param_t) * reqSt->u.setReq->paramCnt);
527 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"%s : Invalid Request Type\n", __FUNCTION__);
533 res_struct* handleRequest(
const char* pcCallerID, req_struct *reqSt)
535 unsigned int paramIndex = 0;
536 res_struct *respSt = NULL;
537 DATA_TYPE dataType = WDMP_NONE;
539 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Entering... %s\n", __FUNCTION__);
540 respSt = (res_struct *) malloc(
sizeof(res_struct));
543 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed to allocate respSt - returning\n");
546 memset(respSt, 0,
sizeof(res_struct));
547 if(!allocate_res_struct_members(respSt, reqSt))
549 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed to allocate respSt members\n");
550 wdmp_free_res_struct(respSt);
555 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"processing each paramName ... with reqType - %d\n", respSt->reqType);
557 switch(respSt->reqType)
560 for(paramIndex = 0; paramIndex < respSt->paramCnt; paramIndex++)
562 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Request:> paramNames[%d] = %s\n",paramIndex,reqSt->u.getReq->paramNames[paramIndex]);
563 respSt->u.getRes->paramNames[paramIndex] = strdup(reqSt->u.getReq->paramNames[paramIndex]);
565 if(strlen(respSt->u.getRes->paramNames[paramIndex]) > MAX_PARAMETERNAME_LEN)
567 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"paramName > MAX_PARAMETERNAME_LEN for : %s\n", reqSt->u.getReq->paramNames[paramIndex]);
568 respSt->u.getRes->retParamCnt[paramIndex] = 1;
569 respSt->u.getRes->params[paramIndex] = (param_t *)malloc(
sizeof(param_t) * respSt->u.getRes->retParamCnt[paramIndex]);
570 respSt->u.getRes->params[paramIndex][0].name = strdup(respSt->u.getRes->paramNames[paramIndex]);
571 respSt->u.getRes->params[paramIndex][0].value = NULL;
572 respSt->u.getRes->params[paramIndex][0].type = WDMP_NONE;
574 respSt->retStatus[paramIndex] = WDMP_ERR_INVALID_PARAMETER_NAME;
580 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"%s is a WildCardParam \n", respSt->u.getRes->paramNames[paramIndex]);
581 char **childParamNames = (
char**) calloc (MAX_NUM_PARAMETERS,
sizeof(
char*));
582 if (NULL == childParamNames)
584 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Error allocating memory\n");
585 wdmp_free_res_struct(respSt);
589 char **childParamDataTypes = (
char**) calloc (MAX_NUM_PARAMETERS,
sizeof(
char*));
590 if(NULL == childParamDataTypes)
592 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Error allocating memory\n");
593 free(childParamNames);
594 wdmp_free_res_struct(respSt);
598 param_t *childParams = NULL;
600 if(DB_SUCCESS == getChildParamNamesFromDataModel(getDataModelHandle(), respSt->u.getRes->paramNames[paramIndex], childParamNames, childParamDataTypes, (
int *)&respSt->u.getRes->retParamCnt[paramIndex]))
602 childParams = (param_t *)malloc(
sizeof(param_t) * (int) respSt->u.getRes->retParamCnt[paramIndex]);
603 respSt->retStatus[paramIndex] = WDMP_SUCCESS;
605 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"No of child params = %d\n", respSt->u.getRes->retParamCnt[paramIndex]);
606 for(
int childParamIndex = 0; childParamIndex < (int)respSt->u.getRes->retParamCnt[paramIndex]; childParamIndex++)
608 childParams[childParamIndex].name = childParamNames[childParamIndex];
609 childParams[childParamIndex].type = getWdmpDataType(childParamDataTypes[childParamIndex]);
610 childParams[childParamIndex].value = NULL;
613 if(WDMP_SUCCESS != invokeHostIfAPI(reqSt->reqType, childParams+childParamIndex, HOSTIF_NONE, pcCallerID) && respSt->retStatus[paramIndex] == WDMP_SUCCESS)
615 respSt->retStatus[paramIndex] = WDMP_ERR_VALUE_IS_EMPTY;
618 respSt->u.getRes->params[paramIndex] = childParams;
622 free(childParamDataTypes);
623 free(childParamNames);
625 respSt->u.getRes->retParamCnt[paramIndex] = 1;
626 respSt->u.getRes->params[paramIndex] = (param_t *)malloc(
sizeof(param_t) * respSt->u.getRes->retParamCnt[paramIndex]);
628 respSt->u.getRes->params[paramIndex][0].name = strdup(respSt->u.getRes->paramNames[paramIndex]);
629 respSt->u.getRes->params[paramIndex][0].value = strdup(
"");
630 respSt->u.getRes->params[paramIndex][0].type = WDMP_NONE;
631 respSt->retStatus[paramIndex] = WDMP_ERR_INVALID_PARAMETER_NAME;
636 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Not a wildcard param - validating against data model...\n");
637 char *defaultValue = NULL;
638 bool rfcParam =
false;
642 if(strncmp(respSt->u.getRes->paramNames[paramIndex],
"RFC_", 4) == 0 && strchr(respSt->u.getRes->paramNames[paramIndex],
'.') == NULL)
644 dataType = WDMP_STRING;
646 respSt->retStatus[paramIndex] = WDMP_SUCCESS;
650 respSt->retStatus[paramIndex] = validateAgainstDataModel(respSt->reqType, respSt->u.getRes->paramNames[paramIndex], NULL, &dataType, &defaultValue, &bsUpdate);
653 respSt->u.getRes->retParamCnt[paramIndex] = 1;
654 respSt->u.getRes->params[paramIndex] = (param_t *)malloc(
sizeof(param_t) * respSt->u.getRes->retParamCnt[paramIndex]);
656 respSt->u.getRes->params[paramIndex][0].name = strdup(respSt->u.getRes->paramNames[paramIndex]);
657 respSt->u.getRes->params[paramIndex][0].value = NULL;
658 respSt->u.getRes->params[paramIndex][0].type = dataType;
660 if(WDMP_SUCCESS == respSt->retStatus[paramIndex])
663 respSt->retStatus[paramIndex] = invokeHostIfAPI(reqSt->reqType, respSt->u.getRes->params[paramIndex], bsUpdate, pcCallerID);
665 respSt->retStatus[paramIndex] = handleRFCRequest(reqSt->reqType, respSt->u.getRes->params[paramIndex]);
667 if(respSt->retStatus[paramIndex] != WDMP_SUCCESS)
671 respSt->u.getRes->params[paramIndex][0].value = strdup(defaultValue);
672 respSt->retStatus[paramIndex] = WDMP_ERR_DEFAULT_VALUE;
673 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Setting Default Value : %s\n", respSt->u.getRes->params[paramIndex][0].value);
677 respSt->retStatus[paramIndex] = WDMP_ERR_VALUE_IS_EMPTY;
683 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Failed in data-model validation\n");
684 respSt->u.getRes->params[paramIndex][0].value = strdup(
"");
693 for(paramIndex = 0; paramIndex < respSt->paramCnt; paramIndex++)
695 bool rfcParam =
false;
697 respSt->u.paramRes->params[paramIndex].name = strdup(reqSt->u.setReq->param[paramIndex].name);
698 if(!isAuthorized(pcCallerID, reqSt->u.setReq->param[paramIndex].name))
700 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"CallerID : %s is not allowed to SET : %s\n", pcCallerID, reqSt->u.setReq->param[paramIndex].name);
701 respSt->retStatus[paramIndex] = WDMP_FAILURE;
706 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Wildcard SET/SET-ATTRIBUTES is not supported \n");
707 respSt->retStatus[paramIndex] = WDMP_ERR_WILDCARD_NOT_SUPPORTED;
710 else if(reqSt->u.setReq->param[paramIndex].value == NULL)
712 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Parameter value is null\n");
713 respSt->retStatus[paramIndex] = WDMP_ERR_VALUE_IS_NULL;
718 respSt->u.paramRes->params[paramIndex].value = strdup(reqSt->u.setReq->param[paramIndex].value);
722 if(strncmp(reqSt->u.setReq->param[paramIndex].name,
"RFC_", 4) == 0 && strchr(reqSt->u.setReq->param[paramIndex].name,
'.') == NULL)
724 dataType = WDMP_STRING;
726 respSt->retStatus[paramIndex] = handleRFCRequest(reqSt->reqType, reqSt->u.setReq->param + paramIndex);
731 respSt->retStatus[paramIndex] = validateAgainstDataModel(reqSt->reqType, reqSt->u.setReq->param[paramIndex].name, reqSt->u.setReq->param[paramIndex].value, &reqSt->u.setReq->param[paramIndex].type, NULL, &bsUpdate);
732 if(WDMP_SUCCESS != respSt->retStatus[paramIndex])
734 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Operation not permitted : %d\n", respSt->retStatus[paramIndex]);
737 respSt->retStatus[paramIndex] = invokeHostIfAPI(reqSt->reqType, reqSt->u.setReq->param + paramIndex, bsUpdate, pcCallerID);
743 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Invalid operation type : %d\n", reqSt->reqType);
744 wdmp_free_res_struct(respSt);
748 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"Leaving... %s\n", __FUNCTION__);