21 #ifdef USE_WIFI_PROFILE
49 #include "wifi_client_hal.h"
50 #include "wifiSrvMgrIarmIf.h"
55 GHashTable* WiFiDevice::devHash = NULL;
56 GHashTable* hostIf_WiFi::ifHash = NULL;
58 WiFiDevice::WiFiDevice(
int dev_id):dev_id(dev_id)
64 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Error! Unable to connect to WiFi Device instance %d\n",dev_id);
69 WiFiDevice* WiFiDevice::getInstance(
int dev_id)
71 WiFiDevice* pRet = NULL;
75 pRet = (WiFiDevice *)g_hash_table_lookup(devHash, (gpointer) dev_id);
79 devHash = g_hash_table_new(NULL,NULL);
85 pRet =
new WiFiDevice(dev_id);
88 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create WiFi device instance..\n");
90 g_hash_table_insert(devHash,(gpointer)dev_id, pRet);
94 void* WiFiDevice::getContext()
99 void WiFiDevice::closeInstance(WiFiDevice *pDev)
103 g_hash_table_remove(devHash, (gconstpointer)pDev->dev_id);
112 void WiFiDevice::closeAllInstances()
116 GList* tmp_list = g_hash_table_get_values (devHash);
120 WiFiDevice* pDev = (WiFiDevice *)tmp_list->data;
121 tmp_list = tmp_list->next;
131 int WiFiDevice::init()
147 void WiFiDevice::shutdown()
153 hostIf_WiFi::hostIf_WiFi(
int dev_id):
155 uiRadioNumberOfEntries(0),
156 uiSSIDNumberOfEntries(0),
157 uiAccessPointNumberOfEntries(0),
158 uiEndPointNumberOfEntries(0)
164 hostIf_WiFi* hostIf_WiFi::getInstance(
int dev_id)
166 hostIf_WiFi* pRet = NULL;
170 pRet = (hostIf_WiFi *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
174 ifHash = g_hash_table_new(NULL,NULL);
180 pRet =
new hostIf_WiFi(dev_id);
183 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create Wifi Interface instance..\n");
185 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
191 GList* hostIf_WiFi::getAllIntefaces()
194 return g_hash_table_get_keys(ifHash);
198 void hostIf_WiFi::closeInstance(hostIf_WiFi *pDev)
202 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
207 void hostIf_WiFi::closeAllInstances()
211 GList* tmp_list = g_hash_table_get_values (ifHash);
215 hostIf_WiFi* pDev = (hostIf_WiFi *)tmp_list->data;
216 tmp_list = tmp_list->next;
226 int hostIf_WiFi::get_Device_WiFi_RadioNumberOfEntries(
HOSTIF_MsgData_t *stMsgData)
228 ULONG radioNumOfEntries = 0;
229 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
233 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
235 param.numEntry=IARM_BUS_WIFI_MGR_RadioEntry;
239 if (IARM_RESULT_SUCCESS != retVal)
241 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal);
244 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] param.data.radioNumberOfEntries returned %d radioNumOfEntries:%lu\n",
245 __FUNCTION__, __FILE__, ret, param.data.radioNumberOfEntries);
246 radioNumOfEntries=param.data.radioNumberOfEntries;
248 stMsgData->
paramtype = hostIf_UnsignedIntType;
249 stMsgData->
paramLen =
sizeof(radioNumOfEntries);
251 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
256 int hostIf_WiFi::get_Device_WiFi_SSIDNumberOfEntries(
HOSTIF_MsgData_t *stMsgData)
258 ULONG ssidNumOfEntries = 0;
259 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
263 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
264 param.numEntry=IARM_BUS_WIFI_MGR_SSIDEntry;
267 if (IARM_RESULT_SUCCESS != retVal)
269 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal);
272 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering.. param.data.ssidNumberOfEntries %d \n", __FUNCTION__, __FILE__,param.data.ssidNumberOfEntries);
273 ssidNumOfEntries=param.data.ssidNumberOfEntries;
275 stMsgData->
paramtype = hostIf_UnsignedIntType;
278 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
283 int hostIf_WiFi::get_Device_WiFi_AccessPointNumberOfEntries(
HOSTIF_MsgData_t *stMsgData)
285 unsigned int accessPointNumOfEntries = 1;
287 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
291 stMsgData->
paramtype = hostIf_UnsignedIntType;
292 stMsgData->
paramLen =
sizeof (
unsigned int);
294 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
299 int hostIf_WiFi::get_Device_WiFi_EndPointNumberOfEntries(
HOSTIF_MsgData_t *stMsgData)
303 unsigned int endPointNumOfEntries = 1;
305 stMsgData->
paramtype = hostIf_UnsignedIntType;
306 stMsgData->
paramLen =
sizeof (
unsigned int);
316 snprintf (param.setInterface, INTERFACE_SIZE,
"WIFI");
317 IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_isInterfaceEnabled, (
void*)¶m,
sizeof(param));
319 stMsgData->
paramtype = hostIf_BooleanType;
328 if (stMsgData->
paramtype != hostIf_BooleanType)
330 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, stMsgData->
paramName);
331 stMsgData->
faultCode = fcInvalidParameterType;
336 snprintf (iarmData.setInterface, INTERFACE_SIZE,
"WIFI");
337 iarmData.isInterfaceEnabled = get_boolean(stMsgData->
paramValue);
338 iarmData.persist =
true;
340 if (IARM_RESULT_SUCCESS ==
IARM_Bus_Call (IARM_BUS_NM_SRV_MGR_NAME,
341 IARM_BUS_NETSRVMGR_API_setInterfaceEnabled,
342 (
void*)&iarmData,
sizeof(iarmData)))
344 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
345 "[%s] IARM call succeeded %s %s (interface = %s enabled = %d persist = %d)\n",
346 __FUNCTION__, IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_setInterfaceEnabled,
347 iarmData.setInterface, iarmData.isInterfaceEnabled, iarmData.persist);
352 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
353 "[%s] IARM call failed %s %s (interface = %s enabled = %d persist = %d)\n",
354 __FUNCTION__, IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_setInterfaceEnabled,
355 iarmData.setInterface, iarmData.isInterfaceEnabled, iarmData.persist);