RDK Documentation (Open Sourced RDK Components)
hostIf_XrdkCentralT2_ReqHandler.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2020 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file hostIf_XrdkCentralT2_ReqHandler.cpp
22  * @brief The header file provides HostIf Telemetry 2.0 service request handler information.
23  */
24 #include "hostIf_main.h"
25 #include "hostIf_utils.h"
27 #include "hostIf_XrdkCentralT2_ReqHandler.h"
28 
29 #define T2_REPORT_PROFILE_PARAM "Device.X_RDKCENTRAL-COM_T2.ReportProfiles"
30 
31 
32 XRdkCentralT2* XRdkCentralT2::pInstance = NULL;
33 
34 msgHandler* XRdkCentralT2::getInstance()
35 {
36  if(!pInstance)
37  {
38  pInstance = new XRdkCentralT2();
39  }
40 
41  return pInstance;
42 }
43 
44 /**
45  * @brief This function is use to initialize. Currently not implemented.
46  *
47  * @return Returns the status of the operation.
48  *
49  * @retval true if initialization is successfully .
50  * @retval false if initialization is not successful.
51  * @ingroup TR-069HOSTIF_TELEMETRY_REQHANDLER_CLASSES
52  */
54 {
55  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] IN \n", __FUNCTION__, __FILE__);
56  return true;
57 }
58 
59 /**
60  * @brief This function is used to close all the instances of telemetry service.
61  *
62  * @return Returns the status of the operation.
63  *
64  * @retval true if it is successfully close all the instances.
65  * @retval false if not able to close all the instances.
66  * @ingroup TR-069HOSTIF_TELEMETRY_REQHANDLER_CLASSES
67  */
69 {
70  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] XRdkCentralT2 un-initialization ...\n", __FUNCTION__);
71  return true;
72 }
73 
74 /**
75  * @brief This function use to handle the set message request of telemetry multiprofile .
76  * This will be a pass through request to actual module having implementation registered
77  * with rbus .
78  *
79  * @param[out] stMsgData TR-069 Host interface message request.
80  *
81  * @return Returns the status of the operation.
82  *
83  * @retval OK if it is successfully.
84  * @retval ERR_INTERNAL_ERROR if not able to set the data to the device.
85  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
86  */
88 {
89  int ret = NOT_HANDLED;
90 
91  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] Found string as %s.\n", __FUNCTION__, __FILE__, stMsgData->paramName);
92  if(strcasecmp(stMsgData->paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfiles") == 0) {
93  if(stMsgData->paramValue) {
94  if (stMsgData->isLengthyParam && NULL != stMsgData->paramValueLong) {
95  char* paramValueGetVal = NULL;
96  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] Assigning long value to rbus%s.\n", __FUNCTION__, __FILE__, stMsgData->paramValueLong);
97  setRbusStringParam(T2_REPORT_PROFILE_PARAM, stMsgData->paramValueLong);
98 
99  /*Cross check*/
100  if(OK == getRbusStringParam(T2_REPORT_PROFILE_PARAM, &paramValueGetVal)) {
101  //Check length
102  int iIpLen = strlen (stMsgData->paramValueLong);
103  int iOpLen = strlen (paramValueGetVal);
104  RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%s] ReportProfiles written data size:%d data size read:%d\n", __FUNCTION__, __FILE__, iIpLen, iOpLen);
105  }
106  else {
107  RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%s] Device.X_RDKCENTRAL-COM_T2.ReportProfiles cross check get failed\n", __FUNCTION__, __FILE__);
108  }
109  free (stMsgData->paramValueLong);
110  stMsgData->paramValueLong = NULL;
111  }
112  else {
113  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] Found parameter value as %s.\n", __FUNCTION__, __FILE__, stMsgData->paramValue);
114  setRbusStringParam(T2_REPORT_PROFILE_PARAM, stMsgData->paramValue);
115  }
116  }
117  ret = OK ;
118 
119  }
120  else if(strcasecmp(stMsgData->paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack") == 0) {
121  if(stMsgData->paramValue) {
122  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] Found parameter value as %s.\n", __FUNCTION__, __FILE__, stMsgData->paramValue);
123  setRbusStringParam("Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack", stMsgData->paramValue);
124  }
125  ret = OK ;
126 
127  }
128  else {
129  stMsgData->faultCode = fcInvalidParameterName;
130  ret = NOT_HANDLED;
131  }
132  return ret;
133 }
134 
135 /**
136  * @brief This function use to handle the get message request of telemetry multiprofile .
137  * This will be a pass through request to actual module having implementation registered
138  * with rbus .
139  *
140  * @param[out] stMsgData TR-069 Host interface message request.
141  *
142  * @return Returns the status of the operation.
143  *
144  * @retval OK if it is successfully.
145  * @retval ERR_INTERNAL_ERROR if not able to get data from the device.
146  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
147  */
149 {
150  int ret = NOT_HANDLED;
151  //const char *pSetting = NULL;
152  int instanceNumber = 0;
153  //char lcParam[TR69HOSTIFMGR_MAX_PARAM_LEN] = {'\0'};
154  char* paramValue = NULL;
155 
156  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
157  if(strcasecmp(stMsgData->paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfiles") == 0)
158  {
159  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Pass through function to be called over RBUS for %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
160  stMsgData->isLengthyParam = true;
161  if(OK == getRbusStringParam(T2_REPORT_PROFILE_PARAM, &paramValue)) {
162  if (stMsgData->isLengthyParam) {
163  int iParamLen = strlen (paramValue);
164  stMsgData->paramValueLong = (char*) malloc (iParamLen+1);
165  if (NULL == stMsgData->paramValueLong) {
166  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] [%d] memory allocation failed.\n", __FUNCTION__, __LINE__);
167  ret = NOK;
168  return ret;
169  }
170  else {
171  memset (stMsgData->paramValueLong, '\0', iParamLen+1);
172  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d] read data size: %d\n", __FILE__, __FUNCTION__, __LINE__, iParamLen);
173  strncpy(stMsgData->paramValueLong, paramValue, iParamLen);
174  }
175  }
176  else {
177  strncpy(stMsgData->paramValue, paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN-1);
178  stMsgData->paramValue[TR69HOSTIFMGR_MAX_PARAM_LEN-1] = '\0';
179  }
180  ret = OK ;
181  }
182 
183  }
184  else if(strcasecmp(stMsgData->paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack") == 0)
185  {
186  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Pass through function to be called over RBUS for %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
187  if(OK == getRbusStringParam("Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack", &paramValue)) {
188  strncpy(stMsgData->paramValue, paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN-1);
189  stMsgData->paramValue[TR69HOSTIFMGR_MAX_PARAM_LEN-1] = '\0';
190  ret = OK ;
191  }
192 
193  }
194  else
195  {
196  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Invalid parameter.\n", __FUNCTION__);
197  ret = NOK;
198  }
199  return ret;
200 }
201 
202 int XRdkCentralT2::handleGetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
203 {
204  return NOT_HANDLED;
205 }
206 
207 int XRdkCentralT2::handleSetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
208 {
209  return NOT_HANDLED;
210 }
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
XRdkCentralT2::handleSetMsg
virtual int handleSetMsg(HOSTIF_MsgData_t *stMsgData)
This function use to handle the set message request of telemetry multiprofile . This will be a pass t...
Definition: hostIf_XrdkCentralT2_ReqHandler.cpp:87
XRdkCentralT2::unInit
virtual bool unInit()
This function is used to close all the instances of telemetry service.
Definition: hostIf_XrdkCentralT2_ReqHandler.cpp:68
hostIf_main.h
hostIf_main API.
hostIf_rbus_Dml_Provider.h
The header file provides HostIf message handler information APIs.
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
_HostIf_MsgData_t::faultCode
faultCode_t faultCode
Definition: hostIf_tr69ReqHandler.h:179
_HostIf_MsgData_t::paramName
char paramName[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:171
XRdkCentralT2::handleGetMsg
virtual int handleGetMsg(HOSTIF_MsgData_t *stMsgData)
This function use to handle the get message request of telemetry multiprofile . This will be a pass t...
Definition: hostIf_XrdkCentralT2_ReqHandler.cpp:148
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
msgHandler
Definition: hostIf_msgHandler.h:103
XRdkCentralT2::init
virtual bool init()
This function is use to initialize. Currently not implemented.
Definition: hostIf_XrdkCentralT2_ReqHandler.cpp:53
XRdkCentralT2
This class provides the interface for getting Telemetry DML request handler information.
Definition: hostIf_XrdkCentralT2_ReqHandler.h:49