29 #include "hostIf_utils.h"
30 #include "hostIf_tr69ReqHandler.h"
31 #include "safec_lib.h"
33 using namespace tinyxml2;
34 #define MAX_PARAMETER_LENGTH 512
35 #define MAX_DATATYPE_LENGTH 48
36 #define MAX_NUM_PARAMETERS 2048
37 #define INSTANCE_NUMBER_INDICATOR "{i}."
38 #define INSTANCE_CHAR_INDICATOR ".{i}."
39 #define MAX_PARAM_LENGTH TR69HOSTIFMGR_MAX_PARAM_LEN
40 #define BLUETOOTH_DISCOVERED_DEVICE_COUNT_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.DiscoveredDeviceCnt"
41 #define BLUETOOTH_PAIRED_DEVICE_COUNT_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.PairedDeviceCnt"
42 #define BLUETOOTH_CONNECTED_DEVICE_COUNT_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.ConnectedDeviceCnt"
43 #define DEVAPPS_COUNT_PARAM "Device.X_COMCAST-COM_Xcalibur.DevApp.devAppNumAps"
48 GHashTable *instanceNumParamHash = NULL;
52 static XMLNode* getList(XMLNode *pParent,
char *paramName,
char* currentParam,
char **ptrParamList,
char **pParamDataTypeList,
int *paramCount);
53 static void removeUnnecessaryAttributes(XMLDocument *pParent);
54 void checkforParameterMatch(XMLNode *pParent,
char *paramName,
int *pMatch,
DataModelParam *dmParam);
55 void appendNextObject(
char* currentParam,
const char* pAttparam);
56 int isParamEndsWithInstance(
const char* paramName);
57 void replaceWithInstanceNumber(
char *paramName,
int instanceNumber);
58 int checkMatchingParameter(
const char* attrValue,
char* paramName,
int* ret);
59 void appendNextObject(
char* currentParam,
const char* pAttparam);
60 int getNumberofInstances(
const char* paramName);
63 #define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml"
64 static void *g_dbhandle = NULL;
65 std::mutex g_db_mutex;
73 DB_STATUS loadDataModel(
void)
75 DB_STATUS dbRet = DB_FAILURE;
76 XMLDocument *doc = NULL;
81 const std::lock_guard<std::mutex> lock(g_db_mutex);
84 doc =
new XMLDocument();
87 doc->LoadFile(WEBPA_DATA_MODEL_FILE);
88 if( doc->ErrorID() == 0 )
90 removeUnnecessaryAttributes(doc);
91 g_dbhandle = (
void *)doc;
93 initNumEntityParamList();
103 static void removeUnnecessaryAttributes(XMLDocument *pParent)
106 if( pParent->ToElement() == NULL )
108 for ( pChild = pParent->FirstChild(); pChild != 0; )
110 if( pChild->ToElement() == NULL )
112 pChild = pChild->NextSibling();
116 if( !strcmp (pChild->Value(),
"object") )
118 pChild = pChild->FirstChild();
128 XMLElement* pElement = pChild->ToElement();
129 const XMLAttribute* pAttrib = pElement->FirstAttribute();
130 if(!strcmp(pChild->Value(),
"object"))
132 pElement->DeleteAttribute(
"minEntries");
133 pElement->DeleteAttribute(
"addObjIdx");
134 pElement->DeleteAttribute(
"delObjIdx");
135 XMLNode* param = pChild->FirstChild();
136 if(param != NULL && !strcmp(param->Value(),
"parameter"))
140 param->ToElement()->DeleteAttribute(
"notification");
141 param->ToElement()->DeleteAttribute(
"maxNotification");
142 param->ToElement()->DeleteAttribute(
"rebootIdx");
143 param->ToElement()->DeleteAttribute(
"initIdx");
144 param->ToElement()->DeleteAttribute(
"setIdx");
145 param=param->NextSibling();
149 pChild = pChild->NextSibling();
153 void* getDataModelHandle()
158 DB_STATUS checkDataModelStatus()
160 return (g_dbhandle != NULL)?DB_SUCCESS:DB_FAILURE;
167 void initNumEntityParamList()
169 instanceNumParamHash = g_hash_table_new(g_str_hash, g_str_equal);
170 if(NULL != instanceNumParamHash)
172 g_hash_table_insert(instanceNumParamHash, (gpointer)
"Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.DiscoveredDevice", (gpointer)BLUETOOTH_DISCOVERED_DEVICE_COUNT_PARAM);
173 g_hash_table_insert(instanceNumParamHash,(gpointer)
"Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.PairedDevice",(gpointer) BLUETOOTH_PAIRED_DEVICE_COUNT_PARAM);
174 g_hash_table_insert(instanceNumParamHash, (gpointer)
"Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.ConnectedDevice", (gpointer)BLUETOOTH_CONNECTED_DEVICE_COUNT_PARAM);
175 g_hash_table_insert(instanceNumParamHash, (gpointer)
"Device.X_COMCAST-COM_Xcalibur.DevApp.devAppTable", (gpointer)DEVAPPS_COUNT_PARAM);
185 int getNumberofInstances(
const char* paramName)
187 int instanceCount = 0;
188 errno_t safec_rc = -1;
189 if(NULL != paramName)
191 char *position = NULL;
192 char numberOfEntitiesParam[MAX_PARAMETER_LENGTH] =
"\0";
193 char parameter[MAX_PARAMETER_LENGTH] =
"\0";
194 strncpy(numberOfEntitiesParam,paramName,
sizeof(numberOfEntitiesParam) -1);
195 numberOfEntitiesParam[
sizeof(numberOfEntitiesParam) -1] =
'\0';
196 if(NULL != (position = strstr(numberOfEntitiesParam, INSTANCE_NUMBER_INDICATOR)))
199 strncpy(parameter,numberOfEntitiesParam,strlen(numberOfEntitiesParam)-5);
200 const char* paramValue = (
const char *) g_hash_table_lookup(instanceNumParamHash,parameter);
201 if(NULL != paramValue)
203 safec_rc=strcpy_s(numberOfEntitiesParam,
sizeof(numberOfEntitiesParam),paramValue);
211 safec_rc=strcpy_s(position-1,MAX_PARAMETER_LENGTH-((
char *)position - (
char*)numberOfEntitiesParam),
"NumberOfEntries");
219 size_t *retCount = 0;
220 char *getParamList[1];
221 getParamList[0] = (
char*) calloc(1,MAX_PARAMETER_LENGTH);
222 strncpy(getParamList[0],numberOfEntitiesParam,MAX_PARAMETER_LENGTH);
223 param_t **parametervalArr = (param_t **) malloc(
sizeof(param_t **));
226 *parametervalArr = NULL;
228 ret = (WDMP_STATUS *) malloc(
sizeof(WDMP_STATUS));
229 retCount = (
size_t *) malloc(
sizeof(
size_t));
232 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"ret is null\n");
233 return instanceCount;
237 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"ret is null\n");
239 return instanceCount;
241 getValues(
const_cast<const char**
>(getParamList), 1, ¶metervalArr, &retCount,&ret);
242 if( *retCount > 0 && (NULL != parametervalArr) && NULL != (*parametervalArr)[0].value )
244 instanceCount = strtol(
const_cast<const char*
>((*parametervalArr)[0].value),NULL,10);
248 free(getParamList[0]);
249 if(NULL != parametervalArr && NULL != *parametervalArr)
251 if((*parametervalArr)[0].value)
252 free((*parametervalArr)[0].value);
253 if((*parametervalArr)[0].name)
254 free((*parametervalArr)[0].name);
255 free(*parametervalArr);
257 if(NULL != parametervalArr) {
258 free(parametervalArr);
264 return instanceCount;
272 int isParamEndsWithInstance(
const char* paramName)
275 if(NULL != paramName)
277 retValue = strcmp(paramName+strlen(paramName)-4,INSTANCE_NUMBER_INDICATOR);
291 if(NULL != paramName)
293 if(!strcmp(paramName+strlen(paramName)-1,
"."))
306 void replaceWithInstanceNumber(
char *paramName,
int instanceNumber)
312 if(!(position = strstr(paramName, INSTANCE_NUMBER_INDICATOR)))
314 sprintf(number,
"%d.",instanceNumber);
318 safec_rc=strcpy_s(paramName+(strlen(paramName)-4),MAX_PARAMETER_LENGTH,number);
324 strcpy(paramName+(strlen(paramName)-4),number);
336 int checkMatchingParameter(
const char* attrValue,
char* paramName,
int* ret)
343 if(!(*attrValue && *paramName && (*attrValue == *paramName)))
346 if(*attrValue ==
'{' && *paramName >= 48 && *paramName<=56)
349 while(*paramName && *paramName !=
'.')
351 *ret = *ret*i + (*paramName-48);
361 if(!*attrValue && (*(attrValue-2) ==
'}'))
382 void appendNextObject(
char* currentParam,
const char* pAttparam)
384 errno_t safec_rc = -1;
387 if(!(*currentParam == *pAttparam) )
390 if(*pAttparam ==
'{')
395 currentParam = strstr(currentParam,
".");
403 if(!*currentParam && !*pAttparam )
break;
410 strcpy(currentParam, pAttparam);
419 static XMLNode* getList(XMLNode *pParent,
char *paramName,
char* currentParam,
char **ptrParamList,
char **pParamDataTypeList,
int *paramCount)
421 errno_t safec_rc = -1;
423 const char* maxEntries;
424 int isReccursiveCall = 0;
425 char zeroInstance[MAX_PARAMETER_LENGTH] =
"\0";
432 if(!strcmp(currentParam,
""))
434 isReccursiveCall = 0;
438 isReccursiveCall = 1;
442 if( pParent->ToElement() == NULL )
444 for ( pChild = pParent->FirstChild(); pChild != 0; )
446 if( pChild->ToElement() == NULL )
448 pChild = pChild->NextSibling();
452 if( !strcmp (pChild->Value(),
"object") )
454 pChild = pChild->FirstChild();
465 XMLElement* pElement = pChild->ToElement();
466 const XMLAttribute* pAttrib = pElement->FirstAttribute();
472 if(!strcmp(pChild->Value(),
"object"))
475 if(strstr(pAttrib->Value(),paramName) || (status = checkMatchingParameter(pAttrib->Value(),paramName,&inst)))
478 if (*zeroInstance && strstr(pAttrib->Value(),zeroInstance))
480 pChild = pChild->NextSibling();
483 else if(*zeroInstance)
485 zeroInstance[0] =
'\0';
488 if( status && !isReccursiveCall)
491 strcpy(currentParam, paramName);
494 appendNextObject(currentParam, pAttrib->Value());
495 XMLNode* bChild,*sChild;
498 pChild = pChild->FirstChild();
503 pChild = bChild->NextSibling();
505 maxEntries = pElement->Attribute(
"maxEntries");
507 if(maxEntries && ((!strcmp(maxEntries,
"unbounded")) || (strtol(maxEntries,&endPtr, 10) > 1)))
510 if(isParamEndsWithInstance(pAttrib->Value()) == 0 )
512 int instanceNumber = 0;
515 int actualInstance = getNumberofInstances(pAttrib->Value());
519 if(actualInstance >= inst)
520 i = instanceNumber = inst;
526 instanceNumber = actualInstance;
530 char tparaName[MAX_PARAMETER_LENGTH];
531 while(i<=instanceNumber && inst==0)
533 memset(tparaName, 0,MAX_PARAMETER_LENGTH);
534 int len=strlen(currentParam)-4;
535 safec_rc=strcpy_s(tparaName, MAX_PARAMETER_LENGTH, pChild->Parent()->ToElement()->FirstAttribute()->Value());
541 replaceWithInstanceNumber(currentParam,i);
542 sChild = getList(pChild,tparaName,currentParam,ptrParamList,pParamDataTypeList,paramCount);
544 strcpy(currentParam+len, INSTANCE_NUMBER_INDICATOR);
551 safec_rc=strcpy_s(zeroInstance,MAX_PARAMETER_LENGTH, pAttrib->Value());
556 pChild = pChild->Parent();
561 else if(isReccursiveCall)
567 pChild = pChild->NextSibling();
571 else if(!strcmp(pChild->Value(),
"parameter"))
575 for(bChild = pChild ; pChild ; pChild=pChild->NextSibling() )
577 if(*paramCount < MAX_NUM_PARAMETERS)
579 if(strlen(currentParam) > 0)
581 ptrParamList[*paramCount] = (
char *) malloc(MAX_PARAMETER_LENGTH *
sizeof(
char));
582 pParamDataTypeList[*paramCount] = (
char *) malloc(MAX_DATATYPE_LENGTH *
sizeof(
char));
583 snprintf(ptrParamList[*paramCount],MAX_PARAMETER_LENGTH,
"%s%s",currentParam,pChild->ToElement()->FirstAttribute()->Value());
584 strncpy(pParamDataTypeList[*paramCount],pChild->FirstChild()->FirstChild()->Value(),MAX_DATATYPE_LENGTH-1);
590 pChild = bChild->Parent();
591 pChild = pChild->NextSibling();
606 DB_STATUS getChildParamNamesFromDataModel(
void *dbhandle,
char *paramName,
char **ParamList,
char **ParamDataTypeList,
int *paramCount)
608 char parameterName[MAX_PARAMETER_LENGTH];
609 char currentParam[MAX_PARAMETER_LENGTH] =
"\0";
610 strncpy(parameterName,paramName,MAX_PARAMETER_LENGTH-1);
617 XMLDocument *doc = (XMLDocument *) dbhandle;
618 getList(doc,parameterName,currentParam,ParamList,ParamDataTypeList,paramCount);
621 return DB_ERR_INVALID_PARAMETER;
626 return DB_ERR_WILDCARD_NOT_SUPPORTED;
631 void checkforParameterNameMatch(XMLNode *pParent,
const char *ObjectName,
const char *paramName,
int *pMatch,
DataModelParam *dmParam)
635 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"pParent Node is NULL.. returning form checkforAttributeMatch\n");
639 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"checkforAttributeMatch : pParent->Value() : %s\n", pParent->Value());
640 if(pParent->ToElement() != NULL)
642 XMLElement* pElement = pParent->ToElement();
643 const XMLAttribute* pAttrib = pElement->FirstAttribute();
644 if(!strcmp(pParent->Value(),
"parameter") && pAttrib)
646 char *ParameterName = (
char *) malloc(
sizeof(
char) * MAX_PARAMETER_LENGTH);
647 strncpy(ParameterName,ObjectName,MAX_PARAMETER_LENGTH-1);
648 strncat(ParameterName,pAttrib->Value(),MAX_PARAMETER_LENGTH-1);
649 ParameterName[MAX_PARAMETER_LENGTH-1] =
'\0';
650 bool match = !strcmp(ParameterName,paramName);
654 XMLNode *pSyntaxNode = NULL;
655 XMLNode *pSyntaxChildNode = NULL;
656 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"Match found : Extracting parameter attributes\n");
657 dmParam->objectName = strdup(paramName);
658 if(pElement->Attribute(
"base") != NULL)
659 dmParam->paramName = strdup(pElement->Attribute(
"base"));
660 if(pElement->Attribute(
"bsUpdate") != NULL)
661 dmParam->bsUpdate = strdup(pElement->Attribute(
"bsUpdate"));
662 if(pElement->Attribute(
"access") != NULL)
663 dmParam->access = strdup(pElement->Attribute(
"access"));
665 pSyntaxNode = pElement->FirstChildElement(
"syntax");
666 for(pSyntaxChildNode = pSyntaxNode->FirstChild(); pSyntaxChildNode != NULL; pSyntaxChildNode = pSyntaxChildNode->NextSibling())
668 if(!strcmp(
"default", pSyntaxChildNode->Value()))
670 XMLElement *pDefaultElement = pSyntaxChildNode->ToElement();
671 dmParam->defaultValue = strdup(pDefaultElement->Attribute(
"value"));
672 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"Default Value : %s\n", dmParam->defaultValue);
676 dmParam->dataType = strdup(pSyntaxChildNode->Value());
686 void checkforObjectMatch(XMLNode *pParent,
const char *objectName,
int *pMatch,
DataModelParam *dmParam)
690 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"pParent Node is NULL.. returning form checkforParameterMatch\n");
694 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"checkforObjectMatch : pParent->Value() : %s\n", pParent->Value());
695 if(pParent->ToElement() != NULL)
697 XMLElement* pElement = pParent->ToElement();
698 const XMLAttribute* pAttrib = pElement->FirstAttribute();
699 if(!strcmp(pParent->Value(),
"object") && pAttrib)
701 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"Comparing with object : %s\n", pAttrib->Value());
703 if(!strcmp(pAttrib->Value(),objectName))
712 void checkforParameterMatch(XMLNode *pParent,
const char *paramName,
int *pMatch,
DataModelParam *dmParam)
714 XMLNode *pChild = NULL;
715 XMLNode *pParam = NULL;
718 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"pParent is Null - returning\n");
723 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"paramName is Null - returning\n");
727 std::string *str1 =
new std::string(paramName);
728 std::size_t found = str1->find_last_of(
".");
731 char *paramObject = (
char *) malloc(
sizeof(
char) * MAX_PARAMETER_LENGTH);
734 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"paramObject Malloc is Null - returning\n");
737 if(found != std::string::npos)
739 strncpy(paramObject,paramName,found);
740 paramObject[found]=
'.';
741 paramObject[found+1]=
'\0';
745 strncpy(paramObject,paramName,MAX_PARAMETER_LENGTH-1);
746 paramObject[MAX_PARAMETER_LENGTH-1] =
'\0';
749 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"Looking for object : %s\n", paramObject);
750 for(pChild = pParent->FirstChildElement(
"dm:document")->FirstChildElement(
"model")->FirstChildElement(
"object"); pChild != NULL; pChild = pChild->NextSibling())
752 if(pChild->ToElement() == NULL)
756 checkforObjectMatch(pChild,paramObject,pMatch,dmParam);
760 for(pParam = pChild->FirstChild(); pParam != NULL; pParam = pParam->NextSibling())
762 checkforParameterNameMatch(pParam, paramObject, paramName, pMatch, dmParam);
774 int getNumberOfDigitsInInstanceNumber(
const char* paramName,
int position)
781 len = strlen(paramName);
782 while((position < len) && isdigit(paramName[position]))
797 int getParamInfoFromDataModel(
void *dbhandle,
const char *paramName,
DataModelParam *dmParam)
801 char *newparamName = NULL;
802 XMLDocument *doc = NULL;
804 const std::lock_guard<std::mutex> lock(g_db_mutex);
806 doc = (XMLDocument *) dbhandle;
810 std::string str(paramName);
811 std::size_t found = str.find_first_of(
"0123456789");
812 if(found != std::string::npos)
815 checkforParameterMatch(doc,paramName,&Match,dmParam);
818 int numOfDigits = getNumberOfDigitsInInstanceNumber(paramName,found);
820 newparamName =(
char *) malloc(
sizeof(
char) * MAX_PARAMETER_LENGTH);
821 char splitParam[MAX_PARAMETER_LENGTH] =
"{i}";
822 if(paramName[found+numOfDigits] ==
'.' && paramName[found-1] ==
'.')
824 strncpy(newparamName,paramName,found);
825 newparamName[found]=
'\0';
826 strncat(splitParam,str.substr(found+numOfDigits).data(),MAX_PARAMETER_LENGTH-1);
827 splitParam[MAX_PARAMETER_LENGTH-1]=
'\0';
829 strncat(newparamName,splitParam,MAX_PARAMETER_LENGTH-1);
830 newparamName[MAX_PARAMETER_LENGTH-1]=
'\0';
831 checkforParameterMatch(doc,(
const char*)newparamName,&Match,dmParam);
837 strncpy(newparamName,paramName,found+1);
838 newparamName[found+1]=
'\0';
839 strncpy(splitParam,paramName+found+1,MAX_PARAMETER_LENGTH);
840 splitParam[MAX_PARAMETER_LENGTH-1]=
'\0';
844 std::string str(splitParam);
845 std::size_t found = str.find_first_of(
"0123456789");
846 if(found != std::string::npos)
848 strncpy(newparamName,paramName,first_i);
849 newparamName[first_i] =
'\0';
850 numOfDigits = getNumberOfDigitsInInstanceNumber(splitParam,found);
852 if(splitParam[found+numOfDigits] ==
'.' && splitParam[found-1] ==
'.')
854 splitParam[found]=
'\0';
855 strcat(splitParam,
"{i}");
856 strncat(splitParam,str.substr(found+numOfDigits).data(),MAX_PARAMETER_LENGTH-1);
857 splitParam[MAX_PARAMETER_LENGTH-1]=
'\0';
859 strncat(newparamName,splitParam+3,MAX_PARAMETER_LENGTH-1);
860 newparamName[MAX_PARAMETER_LENGTH-1]=
'\0';
861 checkforParameterMatch(doc,(
const char*)newparamName,&Match,dmParam);
868 int first_num = found;
869 std::string str(splitParam+first_num+1);
870 std::size_t found = str.find_first_of(
"0123456789");
871 if(found != std::string::npos)
873 splitParam[found+first_num]=
'\0';
874 strcat(splitParam,
".{i}");
875 strncat(splitParam,str.substr(found+1).data(),MAX_PARAMETER_LENGTH-1);
876 splitParam[MAX_PARAMETER_LENGTH-1]=
'\0';
878 strncat(newparamName,splitParam+3,MAX_PARAMETER_LENGTH-1);
879 newparamName[MAX_PARAMETER_LENGTH-1]=
'\0';
880 checkforParameterMatch(doc,(
const char*)newparamName,&Match,dmParam);
888 newparamName[first_i-1]=
'\0';
889 strncat(newparamName,splitParam,MAX_PARAMETER_LENGTH-1);
890 newparamName[MAX_PARAMETER_LENGTH-1]=
'\0';
891 checkforParameterMatch(doc,(
const char *)newparamName,&Match,dmParam);
895 checkforParameterMatch(doc, paramName, &Match, dmParam);
911 static DB_STATUS get_complete_parameter_list_from_dml_xml (
912 XMLNode *pInParentXmlNode,
913 char **pOutParamNameList,
916 int params_count = 0;
917 XMLNode* pChild = NULL;
919 char currentParam[MAX_PARAMETER_LENGTH] =
"\0";
920 const char *top_node_name =
"Device.";
923 if(!pInParentXmlNode) {
928 if( pInParentXmlNode->ToElement() == NULL )
930 for ( pChild = pInParentXmlNode->FirstChild(); pChild != 0; )
932 if( pChild->ToElement() == NULL )
934 pChild = pChild->NextSibling();
938 if( !strcmp (pChild->Value(),
"object") )
940 pChild = pChild->FirstChild();
946 pChild = pInParentXmlNode;
952 XMLElement* pElement = pChild->ToElement();
953 const XMLAttribute* pAttrib = pElement->FirstAttribute();
956 if(!strcmp(pChild->Value(),
"object"))
959 if(strstr(pAttrib->Value(),top_node_name))
961 appendNextObject(currentParam, pAttrib->Value());
962 std::string str = pAttrib->Value();
964 if (str.compare(str.size()-5,5,
".{i}.") == 0) {
965 if(params_count < MAX_NUM_PARAMETERS)
967 pOutParamNameList[params_count] = (
char *) calloc(MAX_PARAMETER_LENGTH,
sizeof(
char));
968 snprintf(pOutParamNameList[params_count], MAX_PARAMETER_LENGTH,
"%s",pAttrib->Value());
975 pChild = pChild->FirstChild();
980 pChild = bChild->NextSibling();
985 pChild = pChild->NextSibling();
989 else if(!strcmp(pChild->Value(),
"parameter"))
993 for(bChild = pChild ; pChild ; pChild=pChild->NextSibling() )
995 if(params_count < MAX_NUM_PARAMETERS)
997 if(strlen(currentParam) > 0)
999 pOutParamNameList[params_count] = (
char *) calloc(MAX_PARAMETER_LENGTH,
sizeof(
char));
1000 snprintf(pOutParamNameList[params_count],MAX_PARAMETER_LENGTH,
"%s%s",currentParam,pChild->ToElement()->FirstAttribute()->Value());
1006 pChild = bChild->Parent();
1007 pChild = pChild->NextSibling();
1010 *num_of_params = params_count;
1020 DB_STATUS get_complete_param_list (
char **out_param_list,
int *out_param_count)
1022 DB_STATUS status = DB_SUCCESS;
1024 XMLDocument *in_xml_doc = (XMLDocument *)getDataModelHandle();
1026 if(in_xml_doc == NULL)
1030 get_complete_parameter_list_from_dml_xml(in_xml_doc, out_param_list, out_param_count);
1032 if(out_param_count == 0)
1034 return status = DB_FAILURE;
1042 if(dmParam.objectName)
1043 free(dmParam.objectName);
1044 if(dmParam.paramName)
1045 free(dmParam.paramName);
1047 free(dmParam.access);
1048 if(dmParam.dataType)
1049 free(dmParam.dataType);
1050 if(dmParam.defaultValue)
1051 free(dmParam.defaultValue);
1052 if(dmParam.bsUpdate)
1053 free(dmParam.bsUpdate);
1059 void test_get_complete_param_list()
1062 char **pParam_name_list;
1064 pParam_name_list = (
char**) calloc (MAX_NUM_PARAMETERS,
sizeof(
char*));
1065 int num_of_params = 0;
1067 if(DB_SUCCESS != loadDataModel())
1069 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Failed to load data-model.xml file\n" );
1072 if(DB_SUCCESS != get_complete_param_list (pParam_name_list, &num_of_params))
1074 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Failed to get complete parameter list.\n");
1077 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Count = %d \n", num_of_params);
1079 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"======================================================================\n");
1080 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Iteration:1 => Starts\n ");
1081 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"======================================================================\n");
1082 for(i=0; i< num_of_params; i++)
1084 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
" [%d] Parameter : [(%s)]\n", i +1, pParam_name_list[i]);
1085 free(pParam_name_list[i]);
1087 free(pParam_name_list);
1088 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"======================================================================\n");
1089 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Iteration:1 => Ends\n ");
1090 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"======================================================================\n");
1093 const char *pParameterName =
"Device.WiFi.EndPoint.1.Profile.1.Status";
1095 if (getParamInfoFromDataModel(g_dbhandle, pParameterName, &dmParam))
1097 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Found Parameter...!!! [%s (%s)]\n ", pParameterName, dmParam.dataType);
1100 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"Invalid Parameter : [%s] \n ", pParameterName);
1103 ((XMLDocument *)g_dbhandle)->Clear();