RDK Documentation (Open Sourced RDK Components)
hostIf_StorageService_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 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 Storage Service Request Handler Interface
21  *
22  * @author karsomas@cisco.com
23  */
24 
25 /**
26  * @file hostIf_StorageService_ReqHandler.cpp
27  * @brief The header file provides HostIf IP Storage service request handler information APIs.
28  */
29 #include "hostIf_main.h"
30 #include "hostIf_utils.h"
31 #include "Service_Storage.h"
33 
34 
35 StorageSrvcReqHandler* StorageSrvcReqHandler::pInstance = NULL;
36 
37 msgHandler* StorageSrvcReqHandler::getInstance()
38 {
39  hostIf_StorageSrvc::getLock();
40  if(!pInstance)
41  {
42  pInstance = new StorageSrvcReqHandler();
43  }
44  hostIf_StorageSrvc::releaseLock();
45 
46  return pInstance;
47 }
48 
49 /**
50  * @brief This function is use to initialize. Currently not implemented.
51  *
52  * @return Returns the status of the operation.
53  *
54  * @retval true if initialization is successfully .
55  * @retval false if initialization is not successful.
56  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
57  */
59 {
60  return true;
61 }
62 
63 /**
64  * @brief This function is used to close all the instances of storage service.
65  *
66  * @return Returns the status of the operation.
67  *
68  * @retval true if it is successfully close all the instances.
69  * @retval false if not able to close all the instances.
70  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
71  */
73 {
74  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] Storage Service manager DeInitializing\n", __FUNCTION__);
75  hostIf_StorageSrvc::closeAllInstances();
76 
77  return true;
78 }
79 
80 /**
81  * @brief This function use to handle the set message request of storage service.
82  * Currently not implemented.
83  *
84  * @param[out] stMsgData TR-069 Host interface message request.
85  *
86  * @return Returns the status of the operation.
87  *
88  * @retval OK if it is successfully.
89  * @retval ERR_INTERNAL_ERROR if not able to set the data to the device.
90  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
91  */
93 {
94  int ret = NOT_HANDLED;
95 
96  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Found string as %s. Set command not supported.\n",
97  __FUNCTION__, __FILE__, stMsgData->paramName);
98  stMsgData->faultCode = fcInvalidParameterName;
99  return ret;
100 }
101 
102 /**
103  * @brief This function use to handle the get message request of storage service.
104  *
105  * @param[out] stMsgData TR-069 Host interface message request.
106  *
107  * @return Returns the status of the operation.
108  *
109  * @retval OK if it is successfully.
110  * @retval ERR_INTERNAL_ERROR if not able to get data from the device.
111  * @ingroup TR-069HOSTIF_STORAGESERVICE_REQHANDLER_CLASSES
112  */
114 {
115  int ret = NOT_HANDLED;
116  const char *pSetting = NULL;
117  int instanceNumber = 0;
118  char lcParam[TR69HOSTIFMGR_MAX_PARAM_LEN]={'\0'};
119  hostIf_StorageSrvc::getLock();
120 
121  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName);
122  if(strcasecmp(stMsgData->paramName, "Device.services.StorageServiceNumberOfEntries") == 0)
123  {
124  ret = hostIf_StorageSrvc::get_Device_StorageSrvc_ClientNumberOfEntries(stMsgData);
125  }
126  else if(matchComponent(stMsgData->paramName,"Device.services.StorageService",&pSetting,instanceNumber))
127  {
128  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"psettings:%s %d\n",pSetting, instanceNumber);
129  hostIf_StorageSrvc *pStorageSrvc = hostIf_StorageSrvc::getInstance(instanceNumber);
130  if(pStorageSrvc)
131  {
132  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Getting response from StorageService object\n");
133  ret = pStorageSrvc->handleGetMsg(stMsgData);
134  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"After Getting response from StorageService object\n");
135  }
136  else
137  {
138  ret = NOK;
139  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d] hostIf_StorageSrvc::getInstance returned NULL for instance %d,\n",
140  __FUNCTION__, __FILE__, __LINE__, instanceNumber);
141  }
142  }
143  else
144  {
145  stMsgData->faultCode = fcInvalidParameterName;
146  ret = NOK;
147  }
148  hostIf_StorageSrvc::releaseLock();
149  return ret;
150 }
151 
152 int StorageSrvcReqHandler::handleGetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
153 {
154  int ret = NOT_HANDLED;
155  hostIf_StorageSrvc::getLock();
156  // TODO: Retrieve notification value from DeviceInfo structure for given parameter
157  hostIf_StorageSrvc::releaseLock();
158  return ret;
159 }
160 
161 int StorageSrvcReqHandler::handleSetAttributesMsg(HOSTIF_MsgData_t *stMsgData)
162 {
163  int ret = NOT_HANDLED;
164  hostIf_StorageSrvc::getLock();
165  // TODO: Set notification value from DeviceInfo structure for given parameter
166  hostIf_StorageSrvc::releaseLock();
167  return ret;
168 }
Service_Storage.h
The header file provides storage service information APIs.
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_StorageSrvc_ReqHandler.h
The header file provides HostIf Storage service request handler information APIs.
hostIf_StorageSrvc::handleGetMsg
int handleGetMsg(HOSTIF_MsgData_t *stMsgData)
This function get the hostIf storage service interface such as total number physical medium entries,...
Definition: Service_Storage.cpp:158
StorageSrvcReqHandler::handleSetMsg
virtual int handleSetMsg(HOSTIF_MsgData_t *stMsgData)
This function use to handle the set message request of storage service. Currently not implemented.
Definition: hostIf_StorageService_ReqHandler.cpp:92
hostIf_main.h
hostIf_main API.
StorageSrvcReqHandler
This class provides the interface for getting StorageService request handler information.
Definition: hostIf_StorageSrvc_ReqHandler.h:59
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
_HostIf_MsgData_t::faultCode
faultCode_t faultCode
Definition: hostIf_tr69ReqHandler.h:179
StorageSrvcReqHandler::init
virtual bool init()
This function is use to initialize. Currently not implemented.
Definition: hostIf_StorageService_ReqHandler.cpp:58
_HostIf_MsgData_t::paramName
char paramName[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:171
hostIf_StorageSrvc
This class provides the TR-069 storage service information.
Definition: Service_Storage.h:99
msgHandler
Definition: hostIf_msgHandler.h:103
StorageSrvcReqHandler::unInit
virtual bool unInit()
This function is used to close all the instances of storage service.
Definition: hostIf_StorageService_ReqHandler.cpp:72
StorageSrvcReqHandler::handleGetMsg
virtual int handleGetMsg(HOSTIF_MsgData_t *stMsgData)
This function use to handle the get message request of storage service.
Definition: hostIf_StorageService_ReqHandler.cpp:113