RDK Documentation (Open Sourced RDK Components)
x_rdk_req_handler.cpp
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 2016 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 * @brief Provides implementation for DHCPv4 Client Request Handler Interface
21 *
22 * @author vejuturu@cisco.com
23 */
24 
25 /**
26  * @file hostIf_Device_X_RDK_ReqHandler..cpp
27  * @brief The header file provides HostIf X_RDK_ReqHandler. client request handler information APIs.
28  */
29 //#define HAVE_VALUE_CHANGE_EVENT
30 #include "hostIf_main.h"
31 #include "hostIf_utils.h"
32 #include "x_rdk_req_handler.h"
33 #include "safec_lib.h"
34 
35 X_rdk_req_hdlr* X_rdk_req_hdlr::pInstance = NULL;
36 std::mutex X_rdk_req_hdlr::m;
37 
38 
39 msgHandler* X_rdk_req_hdlr::getInstance()
40 {
41  if(!pInstance)
42  pInstance = new X_rdk_req_hdlr();
43  return pInstance;
44 }
45 
46 
47 /**
48  * @brief This function is used to initialize. Currently not implemented.
49  *
50  * @return Returns the status of the operation.
51  *
52  * @retval true if initialization is successful.
53  * @retval false if initialization is not successful.
54  * @ingroup TR-069X_rdk_req_hdlrCLIENT_REQHANDLER_CLASSES
55  */
57 {
58  return true;
59 }
60 
61 /**
62  * @brief This function is used to close all the instances of interface stack.
63  *
64  * @return Returns the status of the operation.
65  *
66  * @retval true if it successfully close all the instances.
67  * @retval false if not able to close all the instances.
68  * @ingroup TR-069X_rdk_req_hdlrCLIENT_REQHANDLER_CLASSES
69  */
71 {
72  return true;
73 }
74 
75 
76 /**
77  * @brief This function is used to handle the set message request of InterfaceStack Client.
78  * Currently not implemented.
79  *
80  * @param[out] stMsgData TR-069 Host interface message request.
81  *
82  * @return Returns the status of the operation.
83  *
84  * @retval OK if successful.
85  * @retval ERR_INTERNAL_ERROR if not able to set the data to the device.
86  * @ingroup TR-069X_rdk_req_hdlrCLIENT_REQHANDLER_CLASSES
87  */
89 {
90  int ret = NOT_HANDLED;
91  std::lock_guard<std::mutex> lg(m);
92 
93  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
94 
95  if(strncasecmp(stMsgData->paramName, X_RDK_PREFIX_STR, strlen(X_RDK_PREFIX_STR)) == 0)
96  {
97  X_rdk_profile *pIface = X_rdk_profile::getInstance();
98  ret = pIface->handleSetMsg(stMsgData);
99  }
100  else {
101  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Found string as %s. Set command not supported.\n",
102  __FUNCTION__, __FILE__, stMsgData->paramName);
103  stMsgData->faultCode = fcAttemptToSetaNonWritableParameter;
104  }
105  return ret;
106 }
107 
108 /**
109  * @brief This function is used to handle the get message request of InterfaceStack Client.
110  * Gets the total number of active interface stack entries or get the attributes of
111  * interface stack such as "HigherLayer" and "LowerLayer".
112  *
113  * @param[out] stMsgData TR-069 Host interface message request.
114  *
115  * @return Returns the status of the operation.
116  *
117  * @retval OK if successful.
118  * @retval ERR_INTERNAL_ERROR if not able to set the data to the device.
119  * @ingroup TR-069X_rdk_req_hdlrCLIENT_REQHANDLER_CLASSES
120  */
122 {
123  int ret = OK;
124  std::lock_guard<std::mutex> lg(m);
125 
126  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
127 
128  if(strncasecmp(stMsgData->paramName, X_RDK_PREFIX_STR, strlen(X_RDK_PREFIX_STR)) == 0)
129  {
130  X_rdk_profile *pIface = X_rdk_profile::getInstance();
131  ret = pIface->handleGetMsg(stMsgData);
132  }
133  else
134  {
135  ret = NOK;
136  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s:%d] Wrong Parameter.\n",
137  __FUNCTION__, __FILE__, __LINE__);
138  }
139  return ret;
140 }
141 int X_rdk_req_hdlr::handleGetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
142 {
143  int ret = NOT_HANDLED;
144  return ret;
145 }
146 
147 int X_rdk_req_hdlr::handleSetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
148 {
149  int ret = NOT_HANDLED;
150  return ret;
151 }
152 
X_rdk_req_hdlr::handleGetMsg
virtual int handleGetMsg(HOSTIF_MsgData_t *stMsgData)
This function is used to handle the get message request of InterfaceStack Client. Gets the total numb...
Definition: x_rdk_req_handler.cpp:121
X_rdk_req_hdlr::unInit
virtual bool unInit()
This function is used to close all the instances of interface stack.
Definition: x_rdk_req_handler.cpp:70
X_rdk_req_hdlr::init
virtual bool init()
This function is used to initialize. Currently not implemented.
Definition: x_rdk_req_handler.cpp:56
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_main.h
hostIf_main API.
X_rdk_profile::handleSetMsg
int handleSetMsg(HOSTIF_MsgData_t *)
This function set the bluetooth profile attributes.
Definition: x_rdk_profile.cpp:97
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
x_rdk_req_handler.h
The header file provides Device.X_RDK_<Parameter> client request handler information APIs.
X_rdk_profile
This class provides the TR-069 components Bluetooth devices information.
Definition: x_rdk_profile.h:59
X_rdk_profile::handleGetMsg
int handleGetMsg(HOSTIF_MsgData_t *)
This function get the bluetooth attributes such as name, profile, count and others for paired and con...
Definition: x_rdk_profile.cpp:147
X_rdk_req_hdlr::handleSetMsg
virtual int handleSetMsg(HOSTIF_MsgData_t *stMsgData)
This function is used to handle the set message request of InterfaceStack Client. Currently not imple...
Definition: x_rdk_req_handler.cpp:88
X_rdk_req_hdlr
This class provides the interface for getting Device.X_RDK_<Parameter> client request handler informa...
Definition: x_rdk_req_handler.h:59
msgHandler
Definition: hostIf_msgHandler.h:103