RDK Documentation (Open Sourced RDK Components)
Device_WiFi_EndPoint_Security.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 2018 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 /**
22  * @file Device_WiFi_EndPoint_Stats.cpp
23  *
24  * @brief Device_WiFi_EndPoint_Stats API Implementation.
25  *
26  * This is the implementation of the WiFi API.
27  *
28  * @par Document
29  */
30 /** @addtogroup TR-069 WiFi Implementation
31  * This is the implementation of the Device Public API.
32  * @{
33  */
34 
35 /*****************************************************************************
36  * STANDARD INCLUDE FILES
37  *****************************************************************************/
38 #ifdef USE_WIFI_PROFILE
39 #include "Device_WiFi_EndPoint_Security.h"
40 
41 extern "C" {
42 #include "wifiSrvMgrIarmIf.h"
43 };
44 
45 GHashTable* hostIf_WiFi_EndPoint_Security::ifHash = NULL;
46 
47 hostIf_WiFi_EndPoint_Security* hostIf_WiFi_EndPoint_Security::getInstance(int dev_id)
48 {
49  hostIf_WiFi_EndPoint_Security* pRet = NULL;
50 
51  if(ifHash)
52  {
53  pRet = (hostIf_WiFi_EndPoint_Security *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
54  }
55  else
56  {
57  ifHash = g_hash_table_new(NULL,NULL);
58  }
59 
60  if(!pRet)
61  {
62  try {
63  pRet = new hostIf_WiFi_EndPoint_Security(dev_id);
64  } catch(int e)
65  {
66  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create hostIf_WiFi_EndPoint_Security instance..\n");
67  }
68  g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
69  }
70  return pRet;
71 }
72 
73 
74 GList* hostIf_WiFi_EndPoint_Security::getAllInstances()
75 {
76  if(ifHash)
77  return g_hash_table_get_keys(ifHash);
78  return NULL;
79 }
80 
81 
82 void hostIf_WiFi_EndPoint_Security::closeInstance(hostIf_WiFi_EndPoint_Security *pDev)
83 {
84  if(pDev)
85  {
86  g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
87  delete pDev;
88  }
89 }
90 
91 void hostIf_WiFi_EndPoint_Security::closeAllInstances()
92 {
93  if(ifHash)
94  {
95  GList* tmp_list = g_hash_table_get_values (ifHash);
96 
97  while(tmp_list)
98  {
100  tmp_list = tmp_list->next;
101  closeInstance(pDev);
102  }
103  }
104 }
105 
106 
107 hostIf_WiFi_EndPoint_Security::hostIf_WiFi_EndPoint_Security(int dev_id)
108 {
109  memset(ModesSupported, 0, 64);
110 }
111 
113 {
114  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering.. \n", __FUNCTION__, __FILE__);
115 
116  IARM_Result_t retVal = IARM_RESULT_IPCCORE_FAIL;
118 
119  if(NULL == stMsgData)
120  {
121  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] Input arg stMsgData is NULL\n", __FILE__, __FUNCTION__);
122  return retVal;
123  }
124 
125  memset(&param, 0, sizeof(param));
126  retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getPairedSSIDInfo, (void *)&param, sizeof(param));
127 
128  if(retVal != IARM_RESULT_SUCCESS) {
129  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal);
130  return retVal;
131  }else{
132  strncpy(stMsgData->paramValue,param.data.getPairedSSIDInfo.security,sizeof(stMsgData->paramValue));
133  stMsgData->paramtype = hostIf_StringType;
134  stMsgData->paramLen = strlen(stMsgData->paramValue);
135  retVal = IARM_RESULT_SUCCESS;
136  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] WiFi Security Mode : %s\n",__FUNCTION__,stMsgData->paramValue);
137  }
138  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
139  return retVal;
140 }
142 {
143  return 0;
144 }
145 
146 #endif /* #ifdef USE_WIFI_PROFILE */
147 
148 
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_WiFi_EndPoint_Security
Definition: Device_WiFi_EndPoint_Security.h:42
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_ModesSupported
int get_hostIf_WiFi_EndPoint_ModesSupported(HOSTIF_MsgData_t *stMsgData)
This function provides the comma-separated list of strings contains which security modes the wireless...
IARM_BUS_WIFI_MGR_API_getPairedSSIDInfo
#define IARM_BUS_WIFI_MGR_API_getPairedSSIDInfo
Definition: wifiSrvMgrIarmIf.h:78
_IARM_Bus_WiFiSrvMgr_Param_t
Definition: wifiSrvMgrIarmIf.h:258
hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnabled
int get_hostIf_WiFi_EndPoint_Security_ModesEnabled(HOSTIF_MsgData_t *stMsgData)
Get the security mode enabled for wifi device. The value must be a member of the list reported by the...
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175