RDK Documentation (Open Sourced RDK Components)
xcal-device.c
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 /**
21  * @file xcal-device.c
22  * @brief This source file contains the APIs for xcal device initializer.
23  */
24 #include <libgupnp/gupnp.h>
25 //#include <libgssdp/gssdp.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <gmodule.h>
29 #include <stdbool.h>
30 
31 #include <sys/types.h>
32 #include <ifaddrs.h>
33 #include <netinet/in.h>
34 #include <sys/ioctl.h>
35 #include <net/if.h>
36 #include <string.h>
37 #include <arpa/inet.h>
38 #include <unistd.h>
39 
40 #include <memory.h>
41 
42 #include <libxml/tree.h>
43 #include <libxml/parser.h>
44 
45 #include "xdevice.h"
46 #include "rdk_safeclib.h"
47 #ifdef CLIENT_XCAL_SERVER
48 #include "mfrMgr.h"
49 #endif
50 #ifdef ENABLE_BREAKPAD
51 #include "breakpadWrapper.h"
52 #endif
53 
54 #ifdef ENABLE_SD_NOTIFY
55 #include <systemd/sd-daemon.h>
56 #endif
57 
58 
59 #if defined(USE_XUPNP_IARM_BUS)
60 #include "libIBus.h"
61 #include "libIARMCore.h"
62 #include "sysMgr.h"
63 #include "libIBusDaemon.h"
64 
65 #define G_VALUE_INIT {0,{{0}}}
66 
67 #define RECEIVER_ID "deviceId"
68 #define PARTNER_ID "partnerId"
69 #define SLEEP_INTERVAL 7000000
70 
71 #define BCAST_PORT 50755
72 #define DEVICE_PROPERTY_FILE "/etc/device.properties"
73 #define GET_DEVICEID_SCRIPT "/lib/rdk/getDeviceId.sh"
74 #define DEVICE_NAME_FILE "/opt/hn_service_settings.conf"
75 #define LOG_FILE "/opt/logs/xdevice.log"
76 #define DEVICE_XML_PATH "/etc/xupnp/"
77 #define DEVICE_XML_FILE "BasicDevice.xml"
78 static GMainLoop *main_loop;
79 
80 IARM_Bus_Daemon_SysMode_t sysModeParam;
81 //Event Handler for SYSMGR Events
82 
83 //Raw offset is fixed for a timezone
84 //in case of 1.3.x this read from java TimeZone object
85 #define HST_RAWOFFSET (-11 * 60 * 60 * 1000)
86 #define AKST_RAWOFFSET (-9 * 60 * 60 * 1000)
87 #define PST_RAWOFFSET (-8 * 60 * 60 * 1000)
88 #define MST_RAWOFFSET (-7 * 60 * 60 * 1000)
89 #define CST_RAWOFFSET (-6 * 60 * 60 * 1000)
90 #define EST_RAWOFFSET (-5 * 60 * 60 * 1000)
91 gboolean ipv6Enabled=FALSE;
92 
93 #ifdef SAFEC_DUMMY_API
94 //adding strcmp_s defination
95 errno_t strcmp_s(const char * d,int max ,const char * src,int *r)
96 {
97  *r= strcmp(d,src);
98  return EOK;
99 }
100 #endif
101 
102 
103 static struct TZStruct
104 {
105  char* inputTZ;
106  char* javaTZ;
107  int rawOffset;
108  gboolean usesDST;
109 } tzStruct[] =
110 {
111  {"HST11", "US/Hawaii", HST_RAWOFFSET, 1},
112  {"HST11HDT,M3.2.0,M11.1.0", "US/Hawaii", HST_RAWOFFSET, 1},
113  {"AKST", "US/Alaska", AKST_RAWOFFSET, 1},
114  {"AKST09AKDT", "US/Alaska", AKST_RAWOFFSET, 1},
115  {"PST08", "US/Pacific", PST_RAWOFFSET, 1},
116  {"PST08PDT,M3.2.0,M11.1.0", "US/Pacific", PST_RAWOFFSET, 1},
117  {"MST07","US/Mountain", MST_RAWOFFSET, 1},
118  {"MST07MDT,M3.2.0,M11.1.0","US/Mountain", MST_RAWOFFSET, 1},
119  {"CST06", "US/Central", CST_RAWOFFSET, 1},
120  {"CST06CDT,M3.2.0,M11.1.0", "US/Central", CST_RAWOFFSET, 1},
121  {"EST05", "US/Eastern", EST_RAWOFFSET, 1},
122  {"EST05EDT,M3.2.0,M11.1.0", "US/Eastern", EST_RAWOFFSET, 1}
123 };
124 
125 static void mapTimeZoneToJavaFormat(char* payload)
126 {
127  int i = 0;
128  int len = sizeof(tzStruct)/sizeof( struct TZStruct );
129 // dstOffset = 3600000;
130  for (; i < len; i++ )
131  {
132  if (g_strcmp0(tzStruct[i].inputTZ, payload) == 0)
133  {
134 
135  g_string_assign(dsgtimezone, tzStruct[i].javaTZ);
136  if(dstOffset != 1)
137  {
138  notify_timezone();
139  }
140  rawOffset = tzStruct[i].rawOffset;
141  usesDaylightTime= tzStruct[i].usesDST;
142  break;
143  }
144  }
145 }
146 
147 #define COMCAST_PARTNET_KEY "comcast"
148 #define COX_PARTNET_KEY "cox"
149 
150 typedef struct _STRING_MAP
151 {
152  char * pszKey;
153  char * pszValue;
154 } STRING_MAP;
155 
156 #define ARRAY_COUNT(array) (sizeof(array)/sizeof(array[0]))
157 
158 static STRING_MAP partnerNameMap[] = {
159  {COMCAST_PARTNET_KEY, "comcast"},
160  {COX_PARTNET_KEY , "cox"},
161 };
162 
163 static STRING_MAP friendlyNameMap[] = {
164  {COMCAST_PARTNET_KEY, "XFINITY"},
165  {COX_PARTNET_KEY , "Contour"},
166 };
167 
168 static STRING_MAP productNameMap[] = {
169  {COMCAST_PARTNET_KEY, "xfinity"},
170  {COX_PARTNET_KEY , "contour"},
171 };
172 
173 static STRING_MAP serviceNameMap[] = {
174  {COMCAST_PARTNET_KEY, "Comcast XFINITY Guide"},
175  {COX_PARTNET_KEY , "Cox Contour Guide"},
176 };
177 
178 static STRING_MAP serviceDescriptionMap[] = {
179  {COMCAST_PARTNET_KEY, "Comcast XFINITY Guide application"},
180  {COX_PARTNET_KEY , "Cox Contour Guide application"},
181 };
182 
183 static STRING_MAP gatewayNameMap[] = {
184  {COMCAST_PARTNET_KEY, "Comcast Gateway"},
185  {COX_PARTNET_KEY , "Cox Gateway"},
186 };
187 
188 static char * getStrValueFromMap(char * pszKey, int nPairs, STRING_MAP map[])
189 {
190  int i = 0;
191  for(i = 0; i < nPairs; i++)
192  {
193  int nKeyLen = strlen(map[i].pszKey);
194  if(0==strncasecmp(map[i].pszKey, pszKey, nKeyLen)) return map[i].pszValue;
195  }
196 
197  // By default return value in entry 0;
198  return map[0].pszValue;
199 }
200 
201 static char * getPartnerID()
202 {
203  return partner_id->str;
204 }
205 
206 static char * getPartnerName()
207 {
208  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(partnerNameMap), partnerNameMap);
209 }
210 
211 static char * getFriendlyName()
212 {
213  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(friendlyNameMap), friendlyNameMap);
214 }
215 
216 static char * getProductName()
217 {
218  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(productNameMap), productNameMap);
219 }
220 
221 static char * getServiceName()
222 {
223  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(serviceNameMap), serviceNameMap);
224 }
225 
226 static char * getServiceDescription()
227 {
228  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(serviceDescriptionMap), serviceDescriptionMap);
229 }
230 
231 static char * getGatewayName()
232 {
233  return getStrValueFromMap(getPartnerID(), ARRAY_COUNT(gatewayNameMap), gatewayNameMap);
234 }
235 
236 static void _sysEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
237 {
238  errno_t rc = -1;
239  int ind = -1;
240  /* Only handle state events */
241  rc = strcmp_s(owner, strlen(owner), IARM_BUS_SYSMGR_NAME , &ind);
242  ERR_CHK(rc);
243  if ((eventId != IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE) || (ind != 0) || (rc != EOK))
244 
245  return;
246 
248  IARM_Bus_SYSMgr_SystemState_t stateId = sysEventData->data.systemStates.stateId;
249  int state = sysEventData->data.systemStates.state;
250 
251 
252  switch(stateId) {
253  case IARM_BUS_SYSMGR_SYSSTATE_TUNEREADY:
254  if (tune_ready != sysEventData->data.systemStates.state)
255  {
256  tune_ready = sysEventData->data.systemStates.state;
257  if (devConf->rmfCrshSupp == TRUE)
258  {
259  if (tune_ready == TRUE)
260  {
261  gupnp_root_device_set_available (dev,TRUE);
262  g_message(" Start publishing %d ",tune_ready);
263  if (devConf->useGliDiag == FALSE)
264  {
265  updatesystemids();
266  notify_value_change("SystemIds", systemids->str);
267  }
268  notify_value_change("PlaybackUrl", playbackurl->str);
269  }
270  else
271  {
272  gupnp_root_device_set_available (dev,FALSE);
273  g_message(" Stop publishing %d ",tune_ready);
274  }
275  }
276  else
277  {
278  if (devConf->useGliDiag == FALSE)
279  {
280  updatesystemids();
281  notify_value_change("SystemIds", systemids->str);
282  }
283  notify_value_change("PlaybackUrl", playbackurl->str);
284  }
285  g_message("Tune Ready Update Received: %d", tune_ready);
286  }
287  break;
288  case IARM_BUS_SYSMGR_SYSSTATE_STB_SERIAL_NO:
289  g_string_assign(serial_num, sysEventData->data.systemStates.payload);
290  g_message("Serial Number Update Received: %s", serial_num->str);
291  break;
292  case IARM_BUS_SYSMGR_SYSSTATE_CHANNELMAP:
293  g_message("Received channel map update");
294  if (sysEventData->data.systemStates.error)
295  {
296  channelmap_id=0;
297  //g_string_assign(channelmap_id, NULL);
298  }
299  else if (sysEventData->data.systemStates.state == 2)
300  {
301  if ((strlen(sysEventData->data.systemStates.payload) > 0) &&
302  is_num(sysEventData->data.systemStates.payload) == TRUE)
303  {
304  channelmap_id=strtoul(sysEventData->data.systemStates.payload, NULL, 10);
305  //g_string_assign(channelmap_id, sysEventData->data.systemStates.payload);
306  //g_message("Received channel map id: %s", channelmap_id->str);
307  g_message("Received channel map id: %lu", channelmap_id);
308  updatesystemids();
309  notify_value_change("SystemIds", systemids->str);
310  }
311 
312  }
313  break;
314  case IARM_BUS_SYSMGR_SYSSTATE_DAC_ID:
315  g_message("Received controller id update");
316  if (sysEventData->data.systemStates.error)
317  {
318  dac_id=0;
319  //g_string_assign(dac_id, NULL);
320  }
321  else if (sysEventData->data.systemStates.state == 2)
322  {
323  if ((strlen(sysEventData->data.systemStates.payload) > 0) &&
324  (is_num(sysEventData->data.systemStates.payload) == TRUE))
325  {
326  dac_id=strtoul(sysEventData->data.systemStates.payload, NULL, 10);
327  //g_string_assign(dac_id, sysEventData->data.systemStates.payload);
328  //g_message("Received controller id: %s", dac_id->str);
329  g_message("Received controller id: %lu", dac_id);
330  updatesystemids();
331  notify_value_change("SystemIds", systemids->str);
332  }
333  }
334  break;
335  case IARM_BUS_SYSMGR_SYSSTATE_PLANT_ID:
336  g_message("Received plant id update");
337  if (sysEventData->data.systemStates.error)
338  {
339  plant_id=0;
340  //g_string_assign(plant_id, NULL);
341  }
342  else if (sysEventData->data.systemStates.state == 2)
343  {
344  if ((strlen(sysEventData->data.systemStates.payload) > 0) &&
345  is_num(sysEventData->data.systemStates.payload) == TRUE)
346  {
347  plant_id=strtoul(sysEventData->data.systemStates.payload, NULL, 10);
348  //g_string_assign(plant_id, sysEventData->data.systemStates.payload);
349  //g_message("Received plant id: %s", plant_id->str);
350  g_message("Received plant id: %lu", plant_id);
351  updatesystemids();
352  notify_value_change("SystemIds", systemids->str);
353  }
354  }
355  break;
356  case IARM_BUS_SYSMGR_SYSSTATE_VOD_AD:
357  g_message("Received vod server id update");
358  if (sysEventData->data.systemStates.error)
359  {
360  vodserver_id=0;
361  //g_string_assign(vodserver_id, NULL);
362  }
363  else if (sysEventData->data.systemStates.state == 2)
364  {
365  if ((strlen(sysEventData->data.systemStates.payload) > 0) &&
366  is_num(sysEventData->data.systemStates.payload) == TRUE)
367  {
368  vodserver_id=strtoul(sysEventData->data.systemStates.payload, NULL, 10);
369  //g_string_assign(vodserver_id, sysEventData->data.systemStates.payload);
370  //g_message("Received vod server id: %s", vodserver_id->str);
371  g_message("Received vod server id: %lu", vodserver_id);
372  updatesystemids();
373  notify_value_change("SystemIds", systemids->str);
374  }
375  }
376  break;
377 
378  case IARM_BUS_SYSMGR_SYSSTATE_TIME_ZONE:
379  g_message("Received timezone update");
380  if (sysEventData->data.systemStates.error)
381  {
382 // g_string_assign(dsgtimezone, "null");
383  g_message("Time zone error");
384  }
385  else if (sysEventData->data.systemStates.state == 2)
386  {
387  if ((strlen(sysEventData->data.systemStates.payload) > 1)) /*&&
388  is_alphanum(sysEventData->data.systemStates.payload) == TRUE)*/
389  {
390  //If in DST then the TZ string will contain , and . so is alpha num checking will fail
391  mapTimeZoneToJavaFormat ((char*)sysEventData->data.systemStates.payload);
392 
393  //g_string_assign(dsgtimezone, sysEventData->data.systemStates.payload);
394  g_message("Received dsgtimezone: %s", dsgtimezone->str);
395  g_message("Received rawOffset: %d", rawOffset);
396 
397  }
398  }
399  break;
400  case IARM_BUS_SYSMGR_SYSSTATE_DST_OFFSET :
401  if (sysEventData->data.systemStates.error)
402  {
403  g_message("dst offset error ");
404  }
405  else if (sysEventData->data.systemStates.state == 2)
406  {
407  dstOffset= atoi(sysEventData->data.systemStates.payload);
408  dstSavings=(dstOffset*60000);
409  g_message("Received dstSavings: %d", dstSavings);
410  if (g_strcmp0(g_strstrip(dsgtimezone->str),"null") != 0)
411  {
412 
413  notify_timezone();
414  }
415  }
416  break;
417  /* case IARM_BUS_SYSMGR_SYSSTATE_LAN_IP:
418  if (sysEventData->data.systemStates.error)
419  {
420  g_string_assign(lan_ip, NULL);
421  }
422  else if (sysEventData->data.systemStates.state == 1)
423  {
424  g_string_assign(lan_ip, sysEventData->data.systemStates.payload);
425  }
426  break;
427  case IARM_BUS_SYSMGR_SYSSTATE_MOCA:
428  setPropertyFunc(SYSTEM_MOCA, state, sysEventData->data.systemStates.error);
429  break;*/
430  default:
431  break;
432  }
433 }
434 
435 /**
436  * @brief This function is used to get the system modes (EAS, NORMAL and WAREHOUSE)
437  *
438  * @param[in] arg Pointer variable of void.
439  *
440  * @retval IARM_RESULT_SUCCESS By default it return success.
441  * @ingroup XUPNP_XCALDEV_FUNC
442  */
443 IARM_Result_t _SysModeChange(void *arg)
444 {
445  IARM_Bus_CommonAPI_SysModeChange_Param_t *param = (IARM_Bus_CommonAPI_SysModeChange_Param_t *)arg;
446  g_message("Sys Mode Change::New mode --> %d, Old mode --> %d\n",param->newMode,param->oldMode);
447  sysModeParam=param->newMode;
448  return IARM_RESULT_SUCCESS;
449 }
450 
451 static void _routesysEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
452 {
453  errno_t rc = -1;
454  int ind = -1;
455  rc = strcmp_s(owner, strlen(owner), IARM_BUS_NM_SRV_MGR_NAME, &ind );
456  ERR_CHK(rc);
457  if((ind == 0) && (rc == EOK))
458  {
459  switch (eventId) {
460  case IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA:
461  {
462  routeEventData_t *param = (routeEventData_t *)data;
463  if(param->routeIp)
464  {
465  if(g_strcmp0(g_strstrip(param->routeIp),dataGatewayIPaddress->str) != 0)
466  {
467  g_string_assign(dataGatewayIPaddress,param->routeIp);
468  g_message("route IP for the device %s ",dataGatewayIPaddress->str);
469  notify_value_change("DataGatewayIPaddress", dataGatewayIPaddress->str);
470  }
471  else
472  g_message("same route is send %s %s ",param->routeIp,dataGatewayIPaddress->str);
473  }
474  else
475  g_message(" route ip is empty");
476  }
477  break;
478  default:
479  break;
480  }
481  }
482 }
483 
484 /**
485  * @brief Initialize the IARM Bus from UPnP, connecting to the IARM Bus, registering system events,
486  * listing system event states and registering system mode changes.
487  *
488  * @return TRUE if the IARM initializer is successful else returns FALSE.
489  * @ingroup XUPNP_XCALDEV_FUNC
490  */
491 gboolean XUPnP_IARM_Init(void)
492 {
493  g_message("<<<<< Iniializing IARM XUPnP >>>>>>>>");
494 
495 
496  if(IARM_RESULT_SUCCESS != IARM_Bus_Init(_IARM_XDEVICE_NAME))
497  {
498  g_message("<<<<<<<%s - Failed in IARM Bus IARM_Bus_Init>>>>>>>>",__FUNCTION__);
499  return FALSE;
500  }
501  else if (IARM_RESULT_SUCCESS != IARM_Bus_Connect())
502  {
503  g_message("<<<<<<<%s - Failed in IARM_Bus_Connect>>>>>>>>",__FUNCTION__);
504  return FALSE;
505  }
506  else
507  {
508  IARM_Bus_RegisterEventHandler(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE, _sysEventHandler);
509  IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA, _routesysEventHandler);
510  g_message("<<<<<<<%s - Registered the SYSMGR BUS Events >>>>>>>>",__FUNCTION__);
511  IARM_Bus_RegisterCall(IARM_BUS_COMMON_API_SysModeChange,_SysModeChange);
512  g_message("<<<<<<<%s - Registering Callback for Warehouse Mode Check >>>>>>>>",__FUNCTION__);
513  return TRUE;
514  }
515 }
516 
517 void getRouteData(void)
518 {
520  IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_ROUTE_MGR_API_getCurrentRouteData, &param, sizeof(param));
521  if (param.status)
522  {
523  g_string_assign(dataGatewayIPaddress,param.route.routeIp);
524  g_message("getRouteData: route IP for the device %s ",dataGatewayIPaddress->str);
525  }
526  else
527  {
528  g_message("route data not available");
529  }
530 }
531 
532 /**
533  * @brief This fuction is used to query the existing system values from IARM System manager.
534  *
535  * The system values could be,
536  * - Channel Map Id
537  * - Plant Id
538  * - DAC Id
539  * - VOD server Id
540  * - Time Zone
541  * - Serial number of tuner, and so on.
542  * @ingroup XUPNP_XCALDEV_FUNC
543  */
544 void getSystemValues(void)
545 {
548 
549 
550  if (param.channel_map.state == 2)
551  {
552  if (strlen(param.channel_map.payload) > 0
553  && is_num(param.channel_map.payload) == TRUE)
554  {
555  channelmap_id=strtoul(param.channel_map.payload, NULL, 10);
556  g_message("Channel map id available. Value %lu", channelmap_id);
557  }
558  }
559  if (param.dac_id.state == 2)
560  {
561  if (strlen(param.dac_id.payload) > 0
562  && is_num(param.dac_id.payload) == TRUE)
563  {
564  dac_id=strtoul(param.dac_id.payload, NULL, 10);
565  g_message("dac id available. Value %lu", dac_id);
566  }
567  }
568 
569  if (param.plant_id.state == 2)
570  {
571  if (strlen(param.plant_id.payload) > 0
572  && is_num(param.plant_id.payload) == TRUE)
573  {
574  plant_id=strtoul(param.plant_id.payload, NULL, 10);
575  g_message("plant id available. Value %lu", plant_id);
576  }
577  }
578 
579  if (param.vod_ad.state == 2)
580  {
581  if (strlen(param.vod_ad.payload) > 0
582  && is_num(param.vod_ad.payload) == TRUE)
583  {
584  vodserver_id=strtoul(param.vod_ad.payload, NULL, 10);
585  g_message("vod ad available. Value %lu", vodserver_id);
586  }
587  }
588 
589  if (param.time_zone_available.state == 2)
590  {
591  if (strlen(param.time_zone_available.payload) > 0
592  /*&& is_alphanum(param.time_zone_available.payload) == TRUE*/)
593  {
594  g_message("Timezone is available. Value %s",param.time_zone_available.payload);
595  //g_string_assign(dsgtimezone, param.time_zone_available.payload);
596  mapTimeZoneToJavaFormat ((char*)param.time_zone_available.payload);
597  g_message("dsgtimezone: %s", dsgtimezone->str);
598  g_message("rawOffset: %d", rawOffset);
599  }
600  }
601 
602  if (param.dst_offset.state == 2)
603  {
604  if (strlen(param.dst_offset.payload) > 0)
605  {
606  dstOffset= atoi(param.dst_offset.payload);
607  }
608  dstSavings=(dstOffset*60000);
609  g_message("dstSavings: %d", dstSavings);
610  if (g_strcmp0(g_strstrip(dsgtimezone->str),"null") != 0)
611  {
612  notify_timezone();
613  }
614 
615  }
616  if (tune_ready != param.TuneReadyStatus.state)
617  {
618  tune_ready = param.TuneReadyStatus.state;
619  notify_value_change("PlaybackUrl", playbackurl->str);
620  }
621 
622  g_message("Tune Ready: %d\n", tune_ready);
623  if (param.stb_serial_no.payload != NULL)
624  {
625  g_string_assign(serial_num, param.stb_serial_no.payload);
626  g_message("Serial no: %s\n", serial_num->str);
627  }
628  else
629  g_message("Serial no is NULL\n");
630  /* if (param.lan_ip.state == 1)
631  g_string_assign(lan_ip, param.lan_ip.payload);
632 
633  if (param.time_zone_available.state == 1)
634  {
635  g_string_assign(dsgtimezone, param.time_zone_available.payload);
636  }
637  */
638  /* else if(propertyNames.at(i) == SYSTEM_MOCA) {
639  property["value"] = param.moca.state;
640  property["error"] = param.moca.error;
641  }
642  */
643  return;
644 }
645 
646 #endif //#if defined(USE_XUPNP_IARM_BUS)
647 
648 /**
649  * @brief This function is used to log the messages of XUPnP applications. Each Log message
650  * will be written to a file along with the timestamp formated in ISO8601 format.
651  *
652  * @param[in] log_domain Character pointer variable for domain name.
653  * @param[in] log_level Variable of glib log level enum.
654  * @param[in] message Character pointer for the log message string.
655  * @param[in] user_data Void pointer variable.
656  *
657  * @ingroup XUPNP_XCALDEV_FUNC
658  */
659 void xupnp_logger (const gchar *log_domain, GLogLevelFlags log_level,
660  const gchar *message, gpointer user_data)
661 {
662 
663  GTimeVal timeval;
664  g_get_current_time(&timeval);
665  if (logoutfile == NULL)
666  {
667  // Fall back to console output if unable to open file
668  g_print ("%s: g_time_val_to_iso8601(&timeval): %s\n", message);
669  return;
670  }
671 
672  g_fprintf (logoutfile, "%s : %s\n", g_time_val_to_iso8601(&timeval), message);
673  fflush(logoutfile);
674 
675 }
676 
677 /**
678  * @brief Callback function which is invoked when getBaseURL action is invoked and this sets the
679  * state variable for base url.
680  *
681  * @param[in] service Name of the service.
682  * @param[out] action Action to be invoked.
683  * @param[in] user_data Usually null will be passed.
684  *
685  * @ingroup XUPNP_XCALDEV_FUNC
686  */
687 /* GetBaseUrl */
688 G_MODULE_EXPORT void
689 get_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
690 {
691  //static int counter=0;
692  //counter++;
693  //g_print ("Got a call back for url %d\n", counter);
694  gupnp_service_action_set (action, "BaseUrl", G_TYPE_STRING, url->str, NULL);
695  gupnp_service_action_return (action);
696 }
697 
698 /**
699  * @brief Callback function which is invoked when getBaseTrmUrl action is invoked and this sets the state
700  * variable for base TRM Url.
701  *
702  * @param[in] service Name of the service.
703  * @param[out] action Action to be invoked.
704  * @param[in] user_data Usually null will be passed.
705  *
706  * @ingroup XUPNP_XCALDEV_FUNC
707  */
708 /* GetBaseTrmUrl */
709 G_MODULE_EXPORT void
710 get_trm_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
711 {
712  //g_print ("Got a call back for trm url, value is %s\n", trmurl->str);
713  gupnp_service_action_set (action, "BaseTrmUrl", G_TYPE_STRING, trmurl->str, NULL);
714  gupnp_service_action_return (action);
715 }
716 
717 /**
718  * @brief Callback function which is invoked when getPlaybackUrl action is invoked and this sets
719  * the state variable for Playback Url.
720  *
721  * @param[in] service Name of the service.
722  * @param[out] action Action to be invoked.
723  * @param[in] user_data Usually null will be passed.
724  * @ingroup XUPNP_XCALDEV_FUNC
725  */
726 /* GetPlayBackUrl */
727 G_MODULE_EXPORT void
728 get_playback_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
729 {
730  //g_message ("Got a call back for playback url, value is %s\n", playbackurl->str);
731  if (tune_ready == TRUE)
732  {
733  //g_message ("Got a call back for playback url, value is %s\n", playbackurl->str);
734  gupnp_service_action_set (action, "PlaybackUrl", G_TYPE_STRING, playbackurl->str, NULL);
735  }
736 
737  else
738  {
739  //g_message ("Got a call back for playback url, Sending NULL\n", playbackurl->str);
740  gupnp_service_action_set (action, "PlaybackUrl", G_TYPE_STRING, "NULL", NULL);
741  }
742  gupnp_service_action_return (action);
743 }
744 
745 /**
746  * @brief Callback function which is invoked when getGatewayIP action is invoked and this sets
747  * the state variable for Gateway IP.
748  *
749  * @param[in] service Name of the service.
750  * @param[out] action Action to be invoked.
751  * @param[in] user_data Usually null will be passed.
752  * @ingroup XUPNP_XCALDEV_FUNC
753  */
754 /* GetGatewayIP */
755 G_MODULE_EXPORT void
756 get_gwyip_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
757 {
758  //g_print ("Got a call back\n");
759  gupnp_service_action_set (action, "GatewayIP", G_TYPE_STRING, gwyip->str, NULL);
760  gupnp_service_action_return (action);
761 }
762 
763 /**
764  * @brief Callback function which is invoked when getGatewayIPv6 action is invoked and this sets
765  * the state variable for Gateway IPv6.
766  *
767  * @param[in] service Name of the service.
768  * @param[out] action Action to be invoked.
769  * @param[in] user_data Usually null will be passed.
770  * @ingroup XUPNP_XCALDEV_FUNC
771  */
772 /* GetGatewayIPv6 */
773 G_MODULE_EXPORT void
774 get_gwyipv6_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
775 {
776  //g_print ("Got a call back\n");
777  gupnp_service_action_set (action, "GatewayIPv6", G_TYPE_STRING, gwyipv6->str, NULL);
778  gupnp_service_action_return (action);
779 }
780 
781 /**
782  * @brief Callback function which is invoked when getGatewayStbIP action is invoked and this sets
783  * the state variable for Gateway STB IP.
784  *
785  * @param[in] service Name of the service.
786  * @param[out] action Action to be invoked.
787  * @param[in] user_data Usually null will be passed.
788  *
789  * @ingroup XUPNP_XCALDEV_FUNC
790  */
791 /* GetGatewayIP */
792 G_MODULE_EXPORT void
793 get_gwystbip_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
794 {
795  //g_print ("Got a call back\n");
796  gupnp_service_action_set (action, "GatewayStbIP", G_TYPE_STRING, gwystbip->str, NULL);
797  gupnp_service_action_return (action);
798 }
799 
800 /**
801  * @brief Callback function which is invoked when getIpv6Prefix action is invoked and this sets
802  * the state variable for IPv6 Prefix.
803  *
804  * @param[in] service Name of the service.
805  * @param[out] action Action to be invoked.
806  * @param[in] user_data Usually null will be passed.
807  *
808  * @ingroup XUPNP_XCALDEV_FUNC
809  */
810 /* GetIpv6Prefix */
811 G_MODULE_EXPORT void
812 get_ipv6prefix_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
813 {
814  //g_print ("Got a call back\n");
815  gupnp_service_action_set (action, "Ipv6Prefix", G_TYPE_STRING, ipv6prefix->str, NULL);
816  gupnp_service_action_return (action);
817 }
818 
819 /**
820  * @brief Callback function which is invoked when getHostMacAddress action is invoked and this sets
821  * the state variable for Host MAC Address.
822  *
823  * @param[in] service Name of the service.
824  * @param[out] action Action to be invoked.
825  * @param[in] user_data Usually null will be passed.
826  * @ingroup XUPNP_XCALDEV_FUNC
827  */
828 /* GetHostMacAddress */
829 G_MODULE_EXPORT void
830 get_hostmacaddress_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
831 {
832  //g_print ("Got a call back\n");
833  gupnp_service_action_set (action, "HostMacAddress", G_TYPE_STRING, hostmacaddress->str, NULL);
834  gupnp_service_action_return (action);
835 }
836 
837 /**
838  * @brief Callback function which is invoked when getBcastMacAddress action is invoked and this sets
839  * the state variable for Broadcast MAC Address.
840  *
841  * @param[in] service Name of the service.
842  * @param[out] action Action to be invoked.
843  * @param[in] user_data Usually null will be passed.
844  * @ingroup XUPNP_XCALDEV_FUNC
845  */
846 /* GetBcastMacAddress */
847 G_MODULE_EXPORT void
848 get_bcastmacaddress_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
849 {
850  //g_print ("Got a call back\n");
851  gupnp_service_action_set (action, "BcastMacAddress", G_TYPE_STRING, bcastmacaddress->str, NULL);
852  gupnp_service_action_return (action);
853 }
854 
855 /**
856  * @brief Callback function which is invoked when getRecvDevType action is invoked and this sets
857  * the state variable for Receive Device Type.
858  *
859  * @param[in] service Name of the service.
860  * @param[out] action Action to be invoked.
861  * @param[in] user_data Usually null will be passed.
862  * @ingroup XUPNP_XCALDEV_FUNC
863  */
864 /* GetRecvDevType */
865 G_MODULE_EXPORT void
866 get_recvdevtype_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
867 {
868  //g_print ("Got a call back\n");
869  gupnp_service_action_set (action, "RecvDevType", G_TYPE_STRING, recvdevtype->str, NULL);
870  gupnp_service_action_return (action);
871 }
872 
873 /* GetDeviceType */
874 G_MODULE_EXPORT void
875 get_devicetype_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
876 {
877  //g_print ("Got a call back\n");
878  gupnp_service_action_set (action, "DeviceType", G_TYPE_STRING, devicetype->str, NULL);
879  gupnp_service_action_return (action);
880 }
881 /**
882  * @brief Callback function which is invoked when getBuildVersion action is invoked and this sets
883  * the state variable for Build Version.
884  *
885  * @param[in] service Name of the service.
886  * @param[out] action Action to be invoked.
887  * @param[in] user_data Usually null will be passed.
888  * @ingroup XUPNP_XCALDEV_FUNC
889  */
890 /* GetBuildVersion */
891 G_MODULE_EXPORT void
892 get_buildversion_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
893 {
894  //g_print ("Got a call back\n");
895  gupnp_service_action_set (action, "BuildVersion", G_TYPE_STRING, buildversion->str, NULL);
896  gupnp_service_action_return (action);
897 }
898 
899 /**
900  * @brief Callback function which is invoked when getDnsConfig action is invoked and this sets
901  * the state variable for DNS Config.
902  *
903  * @param[in] service Name of the service.
904  * @param[out] action Action to be invoked.
905  * @param[in] user_data Usually null will be passed.
906  * @ingroup XUPNP_XCALDEV_FUNC
907  */
908 /* GetDnsConfig */
909 G_MODULE_EXPORT void
910 get_dnsconfig_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
911 {
912  getdnsconfig();
913  gupnp_service_action_set (action, "DnsConfig", G_TYPE_STRING, dnsconfig->str, NULL);
914  gupnp_service_action_return (action);
915 }
916 
917 /**
918  * @brief Callback function which is invoked when getSystemIds action is invoked and this sets
919  * the state variable for System Id.
920  *
921  * @param[in] service Name of the service.
922  * @param[out] action Action to be invoked.
923  * @param[in] user_data Usually null will be passed.
924  * @ingroup XUPNP_XCALDEV_FUNC
925  */
926 /* GetSystemsIds */
927 G_MODULE_EXPORT void
928 get_systemids_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
929 {
930  //g_print ("Got a call back\n");
931  updatesystemids();
932  gupnp_service_action_set (action, "SystemIds", G_TYPE_STRING, systemids->str, NULL);
933  gupnp_service_action_return (action);
934 }
935 
936 /**
937  * @brief Callback function which is invoked when getdataGatewayIPaddress action is invoked and this sets
938  * the state variable for DataGatewayIPaddress.
939  *
940  * @param[in] service Name of the service.
941  * @param[out] action Action to be invoked.
942  * @param[in] user_data Usually null will be passed.
943  * @ingroup XUPNP_XCALDEV_FUNC
944  */
945 /* GetDataGatewayIPaddress */
946 G_MODULE_EXPORT void
947 get_dataGatewayIPaddress_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
948 {
949  gupnp_service_action_set (action, "DataGatewayIPaddress", G_TYPE_STRING, dataGatewayIPaddress->str, NULL);
950  gupnp_service_action_return (action);
951 }
952 
953 /**
954  * @brief Callback function which is invoked when TimeZone action is invoked and this sets
955  * the state variable for Time Zone.
956  *
957  * @param[in] service Name of the service.
958  * @param[out] action Action to be invoked.
959  * @param[in] user_data Usually null will be passed.
960  * @ingroup XUPNP_XCALDEV_FUNC
961  */
962 /* GetTimeZone */
963 G_MODULE_EXPORT void
964 get_timezone_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
965 {
966  //g_print ("Got a call back\n");
967  if (devConf->useGliDiag == FALSE)
968  gettimezone();
969  gupnp_service_action_set (action, "TimeZone", G_TYPE_STRING, dsgtimezone->str, NULL);
970  gupnp_service_action_return (action);
971 }
972 
973 /**
974  * @brief Callback function which is invoked when getRawOffSet action is invoked and this sets
975  * the state variable for Raw Offset.
976  *
977  * @param[in] service Name of the service.
978  * @param[out] action Action to be invoked.
979  * @param[in] user_data Usually null will be passed.
980  * @ingroup XUPNP_XCALDEV_FUNC
981  */
982 /* GetRawOffSet */
983 G_MODULE_EXPORT void
984 get_rawoffset_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
985 {
986  gupnp_service_action_set (action,"RawOffSet", G_TYPE_INT, rawOffset, NULL);
987  gupnp_service_action_return (action);
988 }
989 
990 /**
991  * @brief Callback function which is invoked when getDSTSavings action is invoked and this sets
992  * the state variable for DST Savings.
993  *
994  * @param[in] service Name of the service.
995  * @param[out] action Action to be invoked.
996  * @param[in] user_data Usually null will be passed.
997  * @ingroup XUPNP_XCALDEV_FUNC
998  */
999 /* GetDSTSavings */
1000 G_MODULE_EXPORT void
1001 get_dstsavings_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1002 {
1003  gupnp_service_action_set (action,"DSTSavings", G_TYPE_INT, dstSavings, NULL);
1004  gupnp_service_action_return (action);
1005 }
1006 
1007 /**
1008  * @brief Callback function which is invoked when getUsesDaylightTime action is invoked and this sets
1009  * the state variable for Uses Daylight Time.
1010  *
1011  * @param[in] service Name of the service.
1012  * @param[out] action Action to be invoked.
1013  * @param[in] user_data Usually null will be passed.
1014  * @ingroup XUPNP_XCALDEV_FUNC
1015  */
1016 /* GetUsesDaylightTime */
1017 G_MODULE_EXPORT void
1018 get_usesdaylighttime_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1019 {
1020  gupnp_service_action_set (action,"UsesDaylightTime", G_TYPE_BOOLEAN, usesDaylightTime, NULL);
1021  gupnp_service_action_return (action);
1022 }
1023 
1024 /**
1025  * @brief Callback function which is invoked when getDeviceName action is invoked and this sets
1026  * the state variable for Uses Service Name.
1027  *
1028  * @param[in] service Name of the service.
1029  * @param[out] action Action to be invoked.
1030  * @param[in] user_data Usually null will be passed.
1031  * @ingroup XUPNP_XCALDEV_FUNC
1032  */
1033 /* GetDeviceName */
1034 G_MODULE_EXPORT void
1035 get_devicename_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1036 {
1037  getdevicename();
1038  gupnp_service_action_set (action,"DeviceName", G_TYPE_STRING, devicename->str, NULL);
1039  gupnp_service_action_return (action);
1040 }
1041 
1042 /**
1043  * @brief Callback function which is invoked when getDSTOffset action is invoked and this sets
1044  * the state variable for DST Offset.
1045  *
1046  * @param[in] service Name of the service.
1047  * @param[out] action Action to be invoked.
1048  * @param[in] user_data Usually null will be passed.
1049  * @ingroup XUPNP_XCALDEV_FUNC
1050  */
1051 /* GetDSTOffset */
1052 G_MODULE_EXPORT void
1053 get_dstoffset_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1054 {
1055  gupnp_service_action_set (action,"DSTOffset", G_TYPE_INT, dstOffset, NULL);
1056  gupnp_service_action_return (action);
1057 }
1058 
1059 /**
1060  * @brief Callback function which is invoked when getHosts action is invoked and this sets
1061  * the state variable for Hosts.
1062  *
1063  * @param[in] service Name of the service.
1064  * @param[out] action Action to be invoked.
1065  * @param[in] user_data Usually null will be passed.
1066  * @ingroup XUPNP_XCALDEV_FUNC
1067  */
1068 /* GetEtcHosts */
1069 G_MODULE_EXPORT void
1070 get_hosts_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1071 {
1072  //g_print ("Got a call back\n");
1073  getetchosts();
1074  gupnp_service_action_set (action, "Hosts", G_TYPE_STRING, etchosts->str, NULL);
1075  gupnp_service_action_return (action);
1076 }
1077 
1078 /**
1079  * @brief Callback function which is invoked when getIsGateway action is invoked and this sets
1080  * the state variable for Gatway is active or not.
1081  *
1082  * @param[in] service Name of the service.
1083  * @param[out] action Action to be invoked.
1084  * @param[in] user_data Usually null will be passed.
1085  * @ingroup XUPNP_XCALDEV_FUNC
1086  */
1087 /* GetIsGateway */
1088 G_MODULE_EXPORT void
1089 get_isgateway_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1090 {
1091  //g_print ("Got a call back\n");
1092  gupnp_service_action_set (action, "IsGateway", G_TYPE_BOOLEAN, isgateway, NULL);
1093  gupnp_service_action_return (action);
1094 }
1095 
1096 /**
1097  * @brief Callback function which is invoked when getRequiresTRM action is invoked and this sets
1098  * the state variable for Requiring TRM.
1099  *
1100  * @param[in] service Name of the service.
1101  * @param[out] action Action to be invoked.
1102  * @param[in] user_data Usually null will be passed.
1103  * @ingroup XUPNP_XCALDEV_FUNC
1104  */
1105 /* IsTrmRequired */
1106 G_MODULE_EXPORT void
1107 get_requirestrm_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1108 {
1109  gupnp_service_action_set (action, "RequiresTRM", G_TYPE_BOOLEAN, requirestrm, NULL);
1110  gupnp_service_action_return (action);
1111 }
1112 
1113 /**
1114  * @brief Callback function which is invoked when GetCompatibleUIs action is invoked and this sets
1115  * the state variable for InputDeviceProfile, UIFilter and UIListing.
1116  *
1117  * @param[in] service Name of the service.
1118  * @param[out] action Action to be invoked.
1119  * @param[in] user_data Usually null will be passed.
1120  * @ingroup XUPNP_XCALDEV_FUNC
1121  */
1122 /* GetRuiBaseUrl */
1123 G_MODULE_EXPORT void
1124 get_rui_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
1125 {
1126  if (getruiurl()!=TRUE) //initializes ruirul->str
1127  //must init every callback because it generates a unique
1128  //device number for each return value.
1129  g_print("Error in initializing RUI url value\n");
1130 
1131  //g_print ("Got a call back for Ruiurl, value is %s\n", ruiurl->str);
1132  gupnp_service_action_get (action,"InputDeviceProfile", G_TYPE_STRING, inDevProfile->str, NULL);
1133  gupnp_service_action_get (action,"UIFilter", G_TYPE_STRING, uiFilter->str,NULL);
1134  gupnp_service_action_set (action, "UIListing", G_TYPE_STRING, ruiurl->str, NULL);
1135  gupnp_service_action_return (action);
1136 }
1137 
1138 
1139 /*
1140  * State Variable query handlers
1141  */
1142 
1143 /**
1144  * @brief Callback function which is invoked when getUrl action is invoked.
1145  *
1146  * @param[in] service Name of the service.
1147  * @param[in] variable State(Query)variable.
1148  * @param[in] value New value to be assigned.
1149  * @param[in] user_data Usually null will be passed.
1150  * @ingroup XUPNP_XCALDEV_FUNC
1151  */
1152 /* BaseUrl */
1153 G_MODULE_EXPORT void
1154 query_url_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1155 {
1156  g_value_init (value, G_TYPE_STRING);
1157  g_value_set_string (value, url->str);
1158 }
1159 
1160 /**
1161  * @brief Callback function which is invoked when TrmUrl action is invoked and this sets
1162  * the state variable with a new TRM Url value.
1163  *
1164  * @param[in] service Name of the service.
1165  * @param[in] variable State(Query) variable.
1166  * @param[in] value New value to be assigned.
1167  * @param[in] user_data Usually null will be passed.
1168  * @ingroup XUPNP_XCALDEV_FUNC
1169  */
1170 /* BaseTrmUrl */
1171 G_MODULE_EXPORT void
1172 query_trm_url_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1173 {
1174  g_value_init (value, G_TYPE_STRING);
1175  g_value_set_string (value, trmurl->str);
1176 }
1177 
1178 /**
1179  * @brief Callback function which is invoked when PlaybackUrl action is invoked and this sets
1180  * the state variable with a new playback url.
1181  *
1182  * @param[in] service Name of the service.
1183  * @param[in] variable State(Query) variable.
1184  * @param[in] value New value to be assigned.
1185  * @param[in] user_data Usually null will be passed.
1186  * @ingroup XUPNP_XCALDEV_FUNC
1187  */
1188 /* PlaybackUrl */
1189 G_MODULE_EXPORT void
1190 query_playback_url_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1191 {
1192  if (tune_ready == TRUE)
1193  {
1194  //g_message ("Got a query for playback url, sending %s\n", playbackurl->str);
1195  g_value_init (value, G_TYPE_STRING);
1196  g_value_set_string (value, playbackurl->str);
1197  }
1198  else
1199  {
1200  //g_message ("Got a query for playback url, sending NULL");
1201  g_value_init (value, G_TYPE_STRING);
1202  g_value_set_string (value, "NULL");
1203 
1204  }
1205 }
1206 
1207 /**
1208  * @brief Callback function which is invoked when DataGatewayIPaddress action is invoked and this sets
1209  * the state variable with a new DataGatewayIPaddress.
1210  *
1211  * @param[in] service Name of the service.
1212  * @param[in] variable State(Query) variable.
1213  * @param[in] value New value to be assigned.
1214  * @param[in] user_data Usually null will be passed.
1215  * @ingroup XUPNP_XCALDEV_FUNC
1216  */
1217 /* DataGatewayIPaddress */
1218 G_MODULE_EXPORT void
1219 query_dataGatewayIPaddress_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1220 {
1221  g_value_init (value, G_TYPE_STRING);
1222  g_value_set_string (value, dataGatewayIPaddress->str);
1223 }
1224 
1225 
1226 
1227 /**
1228  * @brief Callback function which is invoked when DeviceName action is invoked and this sets
1229  * the state variable with a new device name.
1230  *
1231  * @param[in] service Name of the service.
1232  * @param[in] variable State(Query) variable.
1233  * @param[in] value New value to be assigned.
1234  * @param[in] user_data Usually null will be passed.
1235  * @ingroup XUPNP_XCALDEV_FUNC
1236  */
1237 /* DeviceName */
1238 G_MODULE_EXPORT void
1239 query_devicename_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1240 {
1241  g_value_init (value, G_TYPE_STRING);
1242  g_value_set_string (value, devicename->str);
1243 }
1244 
1245 /**
1246  * @brief Callback function which is invoked when GatewayIP action is invoked and this sets
1247  * the state variable with a new Gateway IP.
1248  *
1249  * @param[in] service Name of the service.
1250  * @param[in] variable State(Query) variable.
1251  * @param[in] value New value to be assigned.
1252  * @param[in] user_data Usually null will be passed.
1253  * @ingroup XUPNP_XCALDEV_FUNC
1254  */
1255 /* GatewayIP */
1256 G_MODULE_EXPORT void
1257 query_gwyip_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1258 {
1259  g_value_init (value, G_TYPE_STRING);
1260  g_value_set_string (value, gwyip->str);
1261 }
1262 
1263 /**
1264  * @brief Callback function which is invoked when Ipv6Prefix action is invoked and this sets
1265  * the state variable with a new value.
1266  *
1267  * @param[in] service Name of the service.
1268  * @param[in] variable State(Query) variable.
1269  * @param[in] value New value to be assigned.
1270  * @param[in] user_data Usually null will be passed.
1271  * @ingroup XUPNP_XCALDEV_FUNC
1272  */
1273 /* GatewayIPv6 */
1274 G_MODULE_EXPORT void
1275 query_gwyipv6_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1276 {
1277  g_value_init (value, G_TYPE_STRING);
1278  g_value_set_string (value, gwyipv6->str);
1279 }
1280 
1281 /**
1282  * @brief Callback function which is invoked when GatewayStbIP action is invoked and this sets
1283  * the state variable with a new value.
1284  *
1285  * @param[in] service Name of the service.
1286  * @param[in] variable State(Query) variable.
1287  * @param[in] value New value to be assigned.
1288  * @param[in] user_data Usually null will be passed.
1289  * @ingroup XUPNP_XCALDEV_FUNC
1290  */
1291 /* GatewayStbIP */
1292 G_MODULE_EXPORT void
1293 query_gwystbip_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1294 {
1295  g_value_init (value, G_TYPE_STRING);
1296  g_value_set_string (value, gwystbip->str);
1297 }
1298 
1299 /**
1300  * @brief Callback function which is invoked when Ipv6Prefix action is invoked and this sets
1301  * the state variable with a new value.
1302  *
1303  * @param[in] service Name of the service.
1304  * @param[in] variable State(Query) variable.
1305  * @param[in] value New value to be assigned.
1306  * @param[in] user_data Usually null will be passed.
1307  * @ingroup XUPNP_XCALDEV_FUNC
1308  */
1309 /* Ipv6Prefix */
1310 G_MODULE_EXPORT void
1311 query_ipv6prefix_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1312 {
1313  g_value_init (value, G_TYPE_STRING);
1314  g_value_set_string (value, ipv6prefix->str);
1315 }
1316 
1317 /**
1318  * @brief Callback function which is invoked when HostMacAddress action is invoked and this sets
1319  * the state variable with a new value.
1320  *
1321  * @param[in] service Name of the service.
1322  * @param[in] variable State(Query) variable.
1323  * @param[in] value New value to be assigned.
1324  * @param[in] user_data Usually null will be passed.
1325  * @ingroup XUPNP_XCALDEV_FUNC
1326  */
1327 /* HostMacAddress */
1328 G_MODULE_EXPORT void
1329 query_hostmacaddress_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1330 {
1331  g_value_init (value, G_TYPE_STRING);
1332  g_value_set_string (value, hostmacaddress->str);
1333 }
1334 
1335 /**
1336  * @brief Callback function which is invoked when BcastMacAddress action is invoked and this sets
1337  * the state variable with a new value.
1338  *
1339  * @param[in] service Name of the service.
1340  * @param[in] variable State(Query) variable.
1341  * @param[in] value New value to be assigned.
1342  * @param[in] user_data Usually null will be passed.
1343  * @ingroup XUPNP_XCALDEV_FUNC
1344  */
1345 /* BcastMacAddress */
1346 G_MODULE_EXPORT void
1347 query_bcastmacaddress_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1348 {
1349  g_value_init (value, G_TYPE_STRING);
1350  g_value_set_string (value, bcastmacaddress->str);
1351 }
1352 
1353 /**
1354  * @brief Callback function which is invoked when RecvDevType action is invoked and this sets
1355  * the state variable with a new value.
1356  *
1357  * @param[in] service Name of the service.
1358  * @param[in] variable State(Query) variable.
1359  * @param[in] value New value to be assigned.
1360  * @param[in] user_data Usually null will be passed.
1361  * @ingroup XUPNP_XCALDEV_FUNC
1362  */
1363 /* RecvDevType */
1364 G_MODULE_EXPORT void
1365 query_recvdevtype_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1366 {
1367  g_value_init (value, G_TYPE_STRING);
1368  g_value_set_string (value, recvdevtype->str);
1369 }
1370 
1371 /* DeviceType */
1372 G_MODULE_EXPORT void
1373 query_devicetype_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1374 {
1375  g_value_init (value, G_TYPE_STRING);
1376  g_value_set_string (value, devicetype->str);
1377 }
1378 
1379 /**
1380  * @brief Callback function which is invoked when BuildVersion action is invoked and this sets
1381  * the state variable with a new value.
1382  *
1383  * @param[in] service Name of the service.
1384  * @param[in] variable State(Query) variable.
1385  * @param[in] value New value to be assigned.
1386  * @param[in] user_data Usually null will be passed.
1387  * @ingroup XUPNP_XCALDEV_FUNC
1388  */
1389 /* BuildVersion */
1390 G_MODULE_EXPORT void
1391 query_buildversion_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1392 {
1393  g_value_init (value, G_TYPE_STRING);
1394  g_value_set_string (value, buildversion->str);
1395 }
1396 
1397 /**
1398  * @brief Callback function which is invoked when DnsConfig action is invoked and this sets
1399  * the state variable with a new value.
1400  *
1401  * @param[in] service Name of the service.
1402  * @param[in] variable State(Query) variable.
1403  * @param[in] value New value to be assigned.
1404  * @param[in] user_data Usually null will be passed.
1405  * @ingroup XUPNP_XCALDEV_FUNC
1406  */
1407 /* DnsConfig */
1408 G_MODULE_EXPORT void
1409 query_dnsconfig_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1410 {
1411  g_value_init (value, G_TYPE_STRING);
1412  g_value_set_string (value, dnsconfig->str);
1413 }
1414 
1415 /**
1416  * @brief Callback function which is invoked when SystemIds action is invoked and this sets
1417  * the state variable with a new value.
1418  *
1419  * @param[in] service Name of the service.
1420  * @param[in] variable State(Query) variable.
1421  * @param[in] value New value to be assigned.
1422  * @param[in] user_data Usually null will be passed.
1423  * @ingroup XUPNP_XCALDEV_FUNC
1424  */
1425 /* SystemIds */
1426 G_MODULE_EXPORT void
1427 query_systemids_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1428 {
1429 
1430  g_value_init (value, G_TYPE_STRING);
1431  g_value_set_string (value, systemids->str);
1432 }
1433 
1434 /**
1435  * @brief Callback function which is invoked when TimeZone action is invoked and this sets
1436  * the state variable with a new value.
1437  *
1438  * @param[in] service Name of the service.
1439  * @param[in] variable State(Query) variable.
1440  * @param[in] value New value to be assigned.
1441  * @param[in] user_data Usually null will be passed.
1442  * @ingroup XUPNP_XCALDEV_FUNC
1443  */
1444 /* TimeZone */
1445 G_MODULE_EXPORT void
1446 query_timezone_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1447 {
1448  if (devConf->useGliDiag == FALSE)
1449  gettimezone();
1450  g_value_init (value, G_TYPE_STRING);
1451  g_value_set_string (value, dsgtimezone->str);
1452 }
1453 
1454 /**
1455  * @brief Callback function which is invoked when Hosts action is invoked and this sets
1456  * the state variable with a new value.
1457  *
1458  * @param[in] service Name of the service.
1459  * @param[in] variable State(Query) variable.
1460  * @param[in] value New value to be assigned.
1461  * @param[in] user_data Usually null will be passed.
1462  * @ingroup XUPNP_XCALDEV_FUNC
1463  */
1464 /* EtcHosts */
1465 G_MODULE_EXPORT void
1466 query_hosts_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1467 {
1468 
1469  g_value_init (value, G_TYPE_STRING);
1470  g_value_set_string (value, etchosts->str);
1471 }
1472 
1473 /**
1474  * @brief Callback function which is invoked when IsGateway action is invoked and this sets
1475  * the state variable with a new value.
1476  *
1477  * @param[in] service Name of the service.
1478  * @param[in] variable State(Query) variable.
1479  * @param[in] value New value to be assigned.
1480  * @param[in] user_data Usually null will be passed.
1481  * @ingroup XUPNP_XCALDEV_FUNC
1482  */
1483 /* IsGateway */
1484 G_MODULE_EXPORT void
1485 query_isgateway_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1486 {
1487 
1488  g_value_init (value, G_TYPE_BOOLEAN);
1489  g_value_set_boolean (value, isgateway);
1490 }
1491 
1492 /**
1493  * @brief Callback function which is invoked when RequiresTRM action is invoked and this sets
1494  * the state variable with a new value.
1495  *
1496  * @param[in] service Name of the service.
1497  * @param[in] variable State(Query) variable.
1498  * @param[in] value New value to be assigned.
1499  * @param[in] user_data Usually null will be passed.
1500  * @ingroup XUPNP_XCALDEV_FUNC
1501  */
1502 /* RequiresTRM */
1503 G_MODULE_EXPORT void
1504 query_requirestrm_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1505 {
1506 
1507  g_value_init (value, G_TYPE_BOOLEAN);
1508  g_value_set_boolean (value, requirestrm);
1509 }
1510 
1511 /**
1512  * @brief Callback function which is invoked when RuiUrl action is invoked and this sets
1513  * the state variable with a new value.
1514  *
1515  * @param[in] service Name of the service.
1516  * @param[in] variable State(Query) variable.
1517  * @param[in] value New value to be assigned.
1518  * @param[in] user_data Usually null will be passed.
1519  * @ingroup XUPNP_XCALDEV_FUNC
1520  */
1521 /* RuiUrl */
1522 G_MODULE_EXPORT void
1523 query_rui_url_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1524 {
1525  g_value_init (value, G_TYPE_STRING);
1526  g_value_set_string (value, ruiurl->str);
1527 }
1528 
1529 /**
1530  * @brief Callback function which is invoked when RawOffSet action is invoked and this sets
1531  * the state variable with a new value.
1532  *
1533  * @param[in] service Name of the service.
1534  * @param[in] variable State(Query) variable.
1535  * @param[in] value New value to be assigned.
1536  * @param[in] user_data Usually null will be passed.
1537  * @ingroup XUPNP_XCALDEV_FUNC
1538  */
1539 /* RawOffSet */
1540 G_MODULE_EXPORT void
1541 query_rawoffset_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1542 {
1543  g_value_init (value, G_TYPE_INT);
1544  g_value_set_int (value, rawOffset);
1545 }
1546 
1547 /**
1548  * @brief Callback function which is invoked when DSTOffset action is invoked and this sets
1549  * the state variable with a new value.
1550  *
1551  * @param[in] service Name of the service.
1552  * @param[in] variable State(Query) variable.
1553  * @param[in] value New value to be assigned.
1554  * @param[in] user_data Usually null will be passed.
1555  * @ingroup XUPNP_XCALDEV_FUNC
1556  */
1557 /* DSTOffset */
1558 G_MODULE_EXPORT void
1559 query_dstoffset_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1560 {
1561  g_value_init (value, G_TYPE_INT);
1562  g_value_set_int (value, dstOffset);
1563 }
1564 
1565 /**
1566  * @brief Callback function which is invoked when DSTSavings action is invoked and this sets
1567  * the state variable with a new value.
1568  *
1569  * @param[in] service Name of the service.
1570  * @param[in] variable State(Query) variable.
1571  * @param[in] value New value to be assigned.
1572  * @param[in] user_data Usually null will be passed.
1573  * @ingroup XUPNP_XCALDEV_FUNC
1574  */
1575 /* DSTSavings */
1576 G_MODULE_EXPORT void
1577 query_dstsavings_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1578 {
1579  g_value_init (value, G_TYPE_INT);
1580  g_value_set_int (value, dstSavings);
1581 }
1582 
1583 /**
1584  * @brief Callback function which is invoked when UsesDaylightTime action is invoked and this sets
1585  * the state variable with a new value.
1586  *
1587  * @param[in] service Name of the service.
1588  * @param[in] variable State(Query) variable.
1589  * @param[in] value New value to be assigned.
1590  * @param[in] user_data Usually null will be passed.
1591  * @ingroup XUPNP_XCALDEV_FUNC
1592  */
1593 /* UsesDaylightTime */
1594 G_MODULE_EXPORT void
1595 query_usesdaylighttime_cb (GUPnPService *service, char *variable, GValue *value, gpointer user_data)
1596 {
1597  g_value_init (value, G_TYPE_BOOLEAN);
1598  g_value_set_boolean (value, usesDaylightTime);
1599 }
1600 
1601 void* checkMainLoopRunning()
1602 {
1603  guint checkMainLoopCounter=0;
1604  while(true)
1605  {
1606  if (! g_main_loop_is_running(main_loop))
1607  {
1608  if(checkMainLoopCounter < 7)
1609  g_message("TELEMETRY_XUPNP_DEVICE_MAIN_LOOP_NOT_RUNNING");
1610  checkMainLoopCounter++;
1611  }
1612  usleep(SLEEP_INTERVAL);
1613  }
1614 }
1615 
1616 int
1617 main (int argc, char **argv)
1618 {
1619 
1620  GThread *thread;
1621 
1622  GError *error = NULL;
1623  url = g_string_new("null");
1624  trmurl = g_string_new("null");
1625  trmurlCVP2 = g_string_new("null");
1626  playbackurl = g_string_new("null");
1627  playbackurlCVP2 = g_string_new("null");
1628  gwyip = g_string_new("null");
1629  gwyipv6 = g_string_new("null");
1630  gwystbip = g_string_new("null");
1631  ipv6prefix = g_string_new("null");
1632  gwyipCVP2 = g_string_new("null");
1633  dnsconfig = g_string_new("null");
1634  systemids = g_string_new("null");
1635  dsgtimezone = g_string_new("null");
1636  etchosts = g_string_new("null");
1637  serial_num = g_string_new("null");
1638  channelmap_id = dac_id = plant_id = vodserver_id = 0;
1639  isgateway=TRUE;
1640  requirestrm=TRUE;
1641  service_ready=FALSE;
1642  tune_ready=FALSE;
1643  ruiurl = g_string_new("null");
1644  inDevProfile = g_string_new("null");
1645  uiFilter = g_string_new("null");
1646  recv_id = g_string_new("null");
1647  partner_id = g_string_new("null");
1648  hostmacaddress = g_string_new("null");
1649  bcastmacaddress = g_string_new("null");
1650  devicename = g_string_new("null");
1651  buildversion = g_string_new("null");
1652  recvdevtype = g_string_new("null");
1653  devicetype = g_string_new("null");
1654  mocaIface = g_string_new("null");
1655  wifiIface = g_string_new("null");
1656  dataGatewayIPaddress = g_string_new("null");
1657 
1658 
1659  char ipAddressBuffer[INET6_ADDRSTRLEN];
1660  char stbipAddressBuffer[INET6_ADDRSTRLEN];
1661 
1662  g_thread_init (NULL);
1663  g_type_init ();
1664 
1665  dstOffset=1; //dstoffset can be only 0 or 60 so intializing with 1
1666 
1667 #ifdef ENABLE_BREAKPAD
1668  installExceptionHandler();
1669 #endif
1670  if (argc < 2)
1671  {
1672  fprintf(stderr, "Error in arguments\nUsage: %s config file name (eg: %s /etc/xdevice.conf)\n", argv[0], argv[0]);
1673 #ifndef CLIENT_XCAL_SERVER
1674  exit(1);
1675 #else
1676  devConf = g_new(ConfSettings,1);
1677 #endif
1678  }
1679  else
1680  {
1681 
1682  const char* configfilename = argv[1];
1683 
1684  if (readconffile(configfilename)==FALSE)
1685  {
1686  g_print("Unable to find xdevice config, giving up\n");
1687 #ifndef CLIENT_XCAL_SERVER
1688  exit(1);
1689 #endif
1690  }
1691  }
1692 #ifdef CLIENT_XCAL_SERVER
1693  if(! (devConf->bcastPort))
1694  devConf->bcastPort=BCAST_PORT;
1695  if(! (devConf->devPropertyFile))
1696  devConf->devPropertyFile=g_strdup(DEVICE_PROPERTY_FILE);
1697  if(! (devConf->deviceNameFile))
1698  devConf->deviceNameFile=g_strdup(DEVICE_NAME_FILE);
1699  if(! (devConf->logFile))
1700  devConf->logFile=g_strdup(LOG_FILE);
1701  if(! (devConf->devXmlPath))
1702  devConf->devXmlPath=g_strdup(DEVICE_XML_PATH);
1703  if(! (devConf->devXmlFile))
1704  devConf->devXmlFile=g_strdup(DEVICE_XML_FILE);
1705  devConf->allowGwy=FALSE;
1706  devConf->useIARM=TRUE;
1707  devConf->useGliDiag=TRUE;
1708 #endif
1709 
1710  char* logfilename = argv[2];
1711  if(logfilename)
1712  {
1713  logoutfile = g_fopen (logfilename, "a");
1714  }
1715  else
1716  {
1717  g_message("xupnp not handling the logging");
1718  }
1719  if(logoutfile)
1720  {
1721  g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE | \
1722  G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR, xupnp_logger, NULL);
1723  }
1724  g_message("Starting xdevice service on interface %s", devConf->bcastIf);
1725  g_print("Starting xdevice service on interface %s\n", devConf->bcastIf);
1726 
1727  //const char* ifname = devConf->bcastIf;
1728  char* xmlfilename = g_strconcat(devConf->devXmlPath, "/", devConf->devXmlFile, NULL);
1729  const guint host_port = devConf->bcastPort;
1730  if (devConf->devPropertyFile != NULL)
1731  {
1732  if (readDevFile(devConf->devPropertyFile)==TRUE)
1733  {
1734  g_message("Receiver Type : %s Build Version : %s Device Type: %s moca %s wifi %s \n", recvdevtype->str,buildversion->str,devicetype->str,mocaIface->str,wifiIface->str);
1735  }
1736  else
1737  {
1738  g_message(" ERROR in getting Receiver Type : %s Build Version : %s \n", recvdevtype->str,buildversion->str);
1739  g_message("Receiver Type : %s Build Version : %s Device Type: %s moca %s wifi %s \n", recvdevtype->str,buildversion->str,devicetype->str,mocaIface->str,wifiIface->str);
1740  }
1741  }
1742 
1743 // int result = getipaddress(devConf->bcastIf, ipAddressBuffer);
1744 #ifndef CLIENT_XCAL_SERVER
1745  if( access(devConf->ipv6FileLocation, F_OK ) != -1 )
1746  ipv6Enabled=TRUE;
1747  int result = getipaddress(devConf->bcastIf,ipAddressBuffer,TRUE);
1748  if (!result)
1749  {
1750  fprintf(stderr,"In Ipv6 Could not locate the link local ipv6 address of the broadcast interface %s\n", devConf->bcastIf);
1751  g_critical("In Ipv6 Could not locate the link local ipv6 address of the broadcast interface %s\n", devConf->bcastIf);
1752  exit(1);
1753  }
1754  g_string_assign(gwyipv6, ipAddressBuffer);
1755  result = getipaddress(devConf->bcastIf,ipAddressBuffer,FALSE);
1756 
1757  if (!result)
1758  {
1759  fprintf(stderr,"Could not locate the link local v4 ipaddress of the broadcast interface %s\n", devConf->bcastIf);
1760  g_critical("Could not locate the link local v4 ipaddress of the broadcast interface %s\n", devConf->bcastIf);
1761  exit(1);
1762  }
1763  else
1764  g_message("ipaddress of the interface %s\n", ipAddressBuffer);
1765 #else
1766  int result = getipaddress(mocaIface->str,ipAddressBuffer,FALSE);
1767  if (!result)
1768  {
1769  g_message("Could not locate the ipaddress of the broadcast interface %s",mocaIface->str);
1770  result = getipaddress(wifiIface->str,ipAddressBuffer,FALSE);
1771  if (!result)
1772  {
1773  g_message("Could not locate the ipaddress of the wifi broadcast interface %s",wifiIface->str);
1774  g_critical("Could not locate the link local v4 ipaddress of the broadcast interface %s\n", devConf->bcastIf);
1775  exit(1);
1776  }
1777  else
1778  {
1779  devConf->bcastIf=g_strdup(wifiIface->str);
1780  }
1781  }
1782  else
1783  {
1784  devConf->bcastIf=g_strdup(mocaIface->str);
1785  }
1786  g_message("Starting xdevice service on interface %s", devConf->bcastIf);
1787 
1788 #endif
1789 
1790 
1791 
1792  //readconffile();
1793  g_message("Broadcast Network interface: %s\n", devConf->bcastIf);
1794  g_message("Dev XML File Name: %s\n", devConf->devXmlFile);
1795  g_message("Use IARM value is: %u\n", devConf->useIARM);
1796 
1797  g_string_assign(gwyip, ipAddressBuffer);
1798 
1799  //Init IARM Events
1800 #if defined(USE_XUPNP_IARM_BUS)
1801  gboolean iarminit = XUPnP_IARM_Init();
1802  if (iarminit==true)
1803  {
1804  //g_print("IARM init success");
1805  g_message("XUPNP IARM init success");
1806 #ifndef CLIENT_XCAL_SERVER
1807  getSystemValues();
1808 #endif
1809  }
1810  else
1811  {
1812  //g_print("IARM init failure");
1813  g_critical("XUPNP IARM init failed");
1814  }
1815 #endif //#if defined(USE_XUPNP_IARM_BUS)
1816 
1817 #ifndef CLIENT_XCAL_SERVER
1818  if(devConf->hostMacIf != NULL)
1819  {
1820  const gchar* hostmac=(gchar*)getmacaddress(devConf->hostMacIf);
1821  if(hostmac)
1822  {
1823  g_message("MAC address in interface: %s %s \n", devConf->hostMacIf,hostmac);
1824  }
1825  else
1826  {
1827  g_message("failed to retrieve macaddress on interface %s ", devConf->hostMacIf);
1828  }
1829  g_string_assign(hostmacaddress,hostmac);
1830  g_message("Host mac address is %s",hostmacaddress->str);
1831  }
1832 #endif
1833  if (devConf->bcastIf != NULL )
1834  {
1835  const gchar* bcastmac=(gchar*)getmacaddress(devConf->bcastIf);
1836  if(bcastmac)
1837  {
1838  g_message("Broadcast MAC address in interface: %s %s \n", devConf->bcastIf,bcastmac);
1839  }
1840  else
1841  {
1842  g_message("failed to retrieve macaddress on interface %s ", devConf->bcastIf);
1843  }
1844  g_string_assign(bcastmacaddress,bcastmac);
1845  g_message("bcast mac address is %s",bcastmacaddress->str);
1846  }
1847  if (devConf->deviceNameFile != NULL)
1848  {
1849  if (getdevicename() == TRUE)
1850  {
1851  g_message("Device Name : %s ", devicename->str);
1852  }
1853  else
1854  {
1855  g_message(" ERROR in getting Device Name ");
1856  }
1857  }
1858  //status = FALSE;
1859  //g_string_assign(recv_id, argv[2]);
1860  g_message("getting the receiver id from %s", GET_DEVICEID_SCRIPT);
1861  recv_id=getID(RECEIVER_ID);
1862 
1863  g_string_printf(url, "http://%s:8080/videoStreamInit?recorderId=%s", ipAddressBuffer, recv_id->str);
1864  g_print ("The url is now %s.\n", url->str);
1865 
1866 #ifndef CLIENT_XCAL_SERVER
1867  if (devConf->enableTRM == FALSE)
1868  {
1869  requirestrm=FALSE;
1870  g_string_printf(trmurl, "NULL");
1871  }
1872  else
1873  {
1874  requirestrm=TRUE;
1875  g_string_printf(trmurl, "ws://%s:9988", ipAddressBuffer);
1876  }
1877 #endif
1878  if(devConf->allowGwy == FALSE)
1879  {
1880  isgateway=FALSE;
1881  }
1882 
1883 
1884 #ifndef CLIENT_XCAL_SERVER
1885  g_string_printf(playbackurl, "http://%s:8080/hnStreamStart?deviceId=%s&DTCP1HOST=%s&DTCP1PORT=5000", ipAddressBuffer, recv_id->str, ipAddressBuffer);
1886 
1887  if (getdnsconfig()==TRUE)
1888  {
1889  g_print("Contents of dnsconfig is %s\n", dnsconfig->str);
1890 
1891  }
1892  if (updatesystemids()==TRUE)
1893  {
1894  g_message("System ids are %s\n", systemids->str);
1895  }
1896  else
1897  {
1898  g_warning("Error in finding system ids\n");
1899  }
1900 
1901 
1902 #if defined(USE_XUPNP_IARM_BUS)
1903  while ((strlen(g_strstrip(serial_num->str)) < 6) || (is_alphanum(serial_num->str) == FALSE))
1904  {
1905  g_message("XUPnP: Waiting for Serial Number\n");
1906  usleep(5000000);
1907  }
1908  g_message("Received Serial Number:%s", serial_num->str);
1909 #else
1910  if (getserialnum(serial_num)==TRUE)
1911  {
1912  g_print("Serial Number is %s\n", serial_num->str);
1913  }
1914 #endif
1915 #else
1916  if (getserialnum(serial_num)==TRUE)
1917  {
1918  g_print("Serial Number is %s\n", serial_num->str);
1919  }
1920 
1921 #endif
1922 
1923 #ifndef CLIENT_XCAL_SERVER
1924  if (getetchosts()==TRUE)
1925  {
1926  g_print("EtcHosts Content is \n%s\n", etchosts->str);
1927  }
1928  else
1929  {
1930  g_print("Error in getting etc hosts\n");
1931  }
1932 #else
1933  getRouteData();
1934 #endif
1935  const char* struuid = g_strconcat("uuid:", g_strstrip(recv_id->str),NULL);
1936  result = updatexmldata(xmlfilename, struuid, serial_num->str, "XFINITY"); // BasicDevice.xml currently does not need multi-tenancy support per RDK-8190. (May come in as part of some other ticket, in which case replace "XFINITY" with getFriendlyName().)
1937 
1938  if (!result)
1939  {
1940  fprintf(stderr,"Failed to open the device xml file %s\n", xmlfilename);
1941  exit(1);
1942  }
1943  else
1944  fprintf(stderr,"Updated the device xml file %s\n", xmlfilename);
1945 
1946 #ifndef GUPNP_1_2
1947  upnpContext = gupnp_context_new (NULL, devConf->bcastIf, devConf->bcastPort, &error);
1948 #else
1949  upnpContext = gupnp_context_new (devConf->bcastIf, devConf->bcastPort, &error);
1950 #endif
1951  if (error) {
1952  g_printerr ("Error creating the Broadcast context: %s\n",
1953  error->message);
1954  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
1955  g_clear_error(&error);
1956  return EXIT_FAILURE;
1957  }
1958 
1959 
1960  gupnp_context_set_subscription_timeout(upnpContext, 0);
1961 #ifndef GUPNP_1_2
1962  dev = gupnp_root_device_new (upnpContext, devConf->devXmlFile, devConf->devXmlPath);
1963 #else
1964  dev = gupnp_root_device_new (upnpContext, devConf->devXmlFile, devConf->devXmlPath, &error);
1965 #endif
1966 
1967 #ifndef CLIENT_XCAL_SERVER
1968  if (devConf->disableTuneReady == FALSE)
1969  {
1970  while (FALSE == tune_ready)
1971  {
1972  g_message("XUPnP: Waiting for Tune Ready\n");
1973  usleep(5000000);
1974  }
1975  //g_message("Received Tune Ready:%u", tune_ready);
1976  }
1977  else
1978  {
1979  g_message("Tune Ready check is disabled - Setting tune_ready to TRUE");
1980  tune_ready=TRUE;
1981  }
1982  if((devConf->allowGwy == TRUE) && (ipv6Enabled==TRUE) && (devConf->ipv6PrefixFile != NULL))
1983  {
1984  while(access(devConf->ipv6PrefixFile, F_OK ) == -1 )
1985  {
1986 
1987  g_message(" Waiting to get IPv6 prefix file ");
1988  usleep(5000000);
1989  }
1990  while (getipv6prefix() == FALSE)
1991  {
1992 
1993  g_message(" V6 prefix is not yet updated in file %s ",devConf->ipv6PrefixFile);
1994  usleep(2000000);
1995  }
1996  g_message("IPv6 prefix : %s ", ipv6prefix->str);
1997  }
1998  else
1999  {
2000  g_message("Box is in IPV4 or ipv6 prefix is empty or Not a gateway ipv6enabled = %d ipv6PrefixFile = %s allowGwy = %d ",ipv6Enabled,devConf->ipv6PrefixFile,devConf->allowGwy);
2001  }
2002  if(devConf->hostMacIf != NULL)
2003  {
2004  result = getipaddress(devConf->hostMacIf,stbipAddressBuffer,ipv6Enabled);
2005 
2006  if (!result)
2007  {
2008  g_message("Could not locate the ipaddress of the host mac interface %s\n", devConf->hostMacIf);
2009  }
2010  else
2011  g_message("ipaddress of the interface %s\n", stbipAddressBuffer);
2012 
2013  g_string_assign(gwystbip, stbipAddressBuffer);
2014  }
2015 #endif
2016  gupnp_root_device_set_available (dev, TRUE);
2017  upnpService = gupnp_device_info_get_service
2018  (GUPNP_DEVICE_INFO (dev), "urn:schemas-upnp-org:service:DiscoverFriendlies:1");
2019  if (!upnpService) {
2020  g_printerr ("Cannot get DiscoverFriendlies service\n");
2021 
2022  return EXIT_FAILURE;
2023  }
2024 
2025 #ifdef ENABLE_SD_NOTIFY
2026  sd_notifyf(0, "READY=1\n"
2027  "STATUS=xcal-device is Successfully Initialized\n"
2028  "MAINPID=%lu",
2029  (unsigned long) getpid());
2030 #endif
2031 
2032 
2033  g_signal_connect (upnpService, "action-invoked::GetBaseUrl", G_CALLBACK (get_url_cb), NULL);
2034  g_signal_connect (upnpService, "action-invoked::GetBaseTrmUrl", G_CALLBACK (get_trm_url_cb), NULL);
2035  g_signal_connect (upnpService, "action-invoked::GetGatewayIP", G_CALLBACK (get_gwyip_cb), NULL);
2036  g_signal_connect (upnpService, "action-invoked::GetGatewayIPv6", G_CALLBACK (get_gwyipv6_cb), NULL);
2037  g_signal_connect (upnpService, "action-invoked::GetIpv6Prefix", G_CALLBACK (get_ipv6prefix_cb), NULL);
2038  g_signal_connect (upnpService, "action-invoked::GetGatewayStbIP", G_CALLBACK (get_gwystbip_cb), NULL);
2039  g_signal_connect (upnpService, "action-invoked::GetDnsConfig", G_CALLBACK (get_dnsconfig_cb), NULL);
2040  g_signal_connect (upnpService, "action-invoked::GetSystemIds", G_CALLBACK (get_systemids_cb), NULL);
2041  g_signal_connect (upnpService, "action-invoked::GetTimeZone", G_CALLBACK (get_timezone_cb), NULL);
2042  g_signal_connect (upnpService, "action-invoked::GetHosts", G_CALLBACK (get_hosts_cb), NULL);
2043  g_signal_connect (upnpService, "action-invoked::GetRequiresTRM", G_CALLBACK (get_requirestrm_cb), NULL);
2044  g_signal_connect (upnpService, "action-invoked::GetHostMacAddress", G_CALLBACK (get_hostmacaddress_cb), NULL);
2045  g_signal_connect (upnpService, "action-invoked::GetRawOffSet", G_CALLBACK (get_rawoffset_cb), NULL);
2046  g_signal_connect (upnpService, "action-invoked::GetDSTOffset", G_CALLBACK (get_dstoffset_cb), NULL);
2047  g_signal_connect (upnpService, "action-invoked::GetDSTSavings", G_CALLBACK (get_dstsavings_cb), NULL);
2048  g_signal_connect (upnpService, "action-invoked::GetUsesDaylightTime", G_CALLBACK (get_usesdaylighttime_cb), NULL);
2049  g_signal_connect (upnpService, "action-invoked::GetPlaybackUrl", G_CALLBACK (get_playback_url_cb), NULL);
2050  g_signal_connect (upnpService, "action-invoked::GetDataGatewayIPaddress", G_CALLBACK (get_dataGatewayIPaddress_cb), NULL);
2051  g_signal_connect (upnpService, "action-invoked::GetDeviceName", G_CALLBACK (get_devicename_cb), NULL);
2052  g_signal_connect (upnpService, "action-invoked::GetIsGateway", G_CALLBACK (get_isgateway_cb), NULL);
2053  g_signal_connect (upnpService, "action-invoked::GetBcastMacAddress", G_CALLBACK (get_bcastmacaddress_cb), NULL);
2054  g_signal_connect (upnpService, "action-invoked::GetRecvDevType", G_CALLBACK (get_recvdevtype_cb), NULL);
2055  g_signal_connect (upnpService, "action-invoked::GetDeviceType", G_CALLBACK (get_devicetype_cb), NULL);
2056  g_signal_connect (upnpService, "action-invoked::GetBuildVersion", G_CALLBACK (get_buildversion_cb), NULL);
2057 
2058  g_signal_connect (upnpService, "query-variable::Url", G_CALLBACK (query_url_cb), NULL);
2059  g_signal_connect (upnpService, "query-variable::TrmUrl", G_CALLBACK (query_trm_url_cb), NULL);
2060  g_signal_connect (upnpService, "query-variable::GatewayIP", G_CALLBACK (query_gwyip_cb), NULL);
2061  g_signal_connect (upnpService, "query-variable::GatewayIPv6", G_CALLBACK (query_gwyipv6_cb), NULL);
2062  g_signal_connect (upnpService, "query-variable::Ipv6Prefix", G_CALLBACK (query_ipv6prefix_cb), NULL);
2063  g_signal_connect (upnpService, "query-variable::GatewayStbIP", G_CALLBACK (query_gwystbip_cb), NULL);
2064  g_signal_connect (upnpService, "query-variable::DnsConfig", G_CALLBACK (query_dnsconfig_cb), NULL);
2065  g_signal_connect (upnpService, "query-variable::SystemIds", G_CALLBACK (query_systemids_cb), NULL);
2066  g_signal_connect (upnpService, "query-variable::TimeZone", G_CALLBACK (query_timezone_cb), NULL);
2067  g_signal_connect (upnpService, "query-variable::Hosts", G_CALLBACK (query_hosts_cb), NULL);
2068  g_signal_connect (upnpService, "query-variable::RequiresTRM", G_CALLBACK (query_requirestrm_cb), NULL);
2069  g_signal_connect (upnpService, "query-variable::HostMacAddress", G_CALLBACK (query_hostmacaddress_cb), NULL);
2070  g_signal_connect (upnpService, "query-variable::RawOffSet", G_CALLBACK (query_rawoffset_cb), NULL);
2071  g_signal_connect (upnpService, "query-variable::DSTOffset", G_CALLBACK (query_dstoffset_cb), NULL);
2072  g_signal_connect (upnpService, "query-variable::DSTSavings", G_CALLBACK (query_dstsavings_cb), NULL);
2073  g_signal_connect (upnpService, "query-variable::UsesDaylightTime", G_CALLBACK (query_usesdaylighttime_cb), NULL);
2074  g_signal_connect (upnpService, "query-variable::PlaybackUrl", G_CALLBACK (query_playback_url_cb), NULL);
2075  g_signal_connect (upnpService, "query-variable::DataGatewayIPaddress", G_CALLBACK (query_dataGatewayIPaddress_cb), NULL);
2076  g_signal_connect (upnpService, "query-variable::DeviceName", G_CALLBACK (query_devicename_cb), NULL);
2077  g_signal_connect (upnpService, "query-variable::IsGateway", G_CALLBACK (query_isgateway_cb), NULL);
2078  g_signal_connect (upnpService, "query-variable::BcastMacAddress", G_CALLBACK (query_bcastmacaddress_cb), NULL);
2079  g_signal_connect (upnpService, "query-variable::RecvDevType", G_CALLBACK (query_recvdevtype_cb), NULL);
2080  g_signal_connect (upnpService, "query-variable::DeviceType", G_CALLBACK (query_devicetype_cb), NULL);
2081  g_signal_connect (upnpService, "query-variable::BuildVersion", G_CALLBACK (query_buildversion_cb), NULL);
2082 
2083  service_ready=TRUE;
2084 
2085 #ifndef CLIENT_XCAL_SERVER
2086  /*Code to handle RUI publishing*/
2087  if (devConf->enableCVP2)
2088  {
2089  char* cvpxmlfilename = g_strconcat(g_strstrip(devConf->devXmlPath), "/", g_strstrip(devConf->cvpXmlFile), NULL);
2090  g_print("Starting CVP2 Service with %s\n", cvpxmlfilename);
2091 
2092  char * struuidcvp = NULL;
2093  GString* mac = get_eSTBMAC();
2094  if(mac)
2095  {
2096  struuidcvp = g_strconcat("uuid:AA5859B7-EFF4-42FD-BB92-", mac->str, NULL);
2097  g_string_free(mac,TRUE);
2098  mac = NULL;
2099  }
2100 
2101  g_print("RemoteUIServerDevice UDN value: %s\n",struuidcvp);
2102  partner_id=getID(PARTNER_ID);
2103 
2104  if(struuidcvp)
2105  {
2106  result = updatexmldata(cvpxmlfilename, struuidcvp, serial_num->str, getFriendlyName());
2107  g_free(struuidcvp);
2108  }
2109 
2110  if(cvpxmlfilename)
2111  {
2112  g_free( cvpxmlfilename);
2113  }
2114 
2115  if (!result)
2116  {
2117  g_printerr("Failed to open the RemoteUIServerDevice xml file\n");
2118  exit(1);
2119  }
2120  else
2121  g_print("Updated the RemoteUIServerDevice xml file\n");
2122 
2123 #ifndef GUPNP_1_2
2124  cvpcontext = gupnp_context_new (NULL, devConf->cvpIf, devConf->cvpPort, &error);
2125 #else
2126  cvpcontext = gupnp_context_new (devConf->cvpIf, devConf->cvpPort, &error);
2127 #endif
2128  if (error) {
2129  g_printerr ("Error creating the CVP context: %s\n", error->message);
2130  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2131  g_clear_error(&error);
2132  return EXIT_FAILURE;
2133  }
2134 
2135 
2136  gupnp_context_set_subscription_timeout(cvpcontext, 0);
2137 #ifndef GUPNP_1_2
2138  cvpdev = gupnp_root_device_new (cvpcontext, devConf->cvpXmlFile, devConf->devXmlPath);
2139 #else
2140  cvpdev = gupnp_root_device_new (cvpcontext, devConf->cvpXmlFile, devConf->devXmlPath, &error);
2141 #endif
2142  gupnp_root_device_set_available (cvpdev, TRUE);
2143 
2144  /* Get the CVP service from the root device */
2145  cvpservice = gupnp_device_info_get_service
2146  (GUPNP_DEVICE_INFO (cvpdev), "urn:schemas-upnp-org:service:RemoteUIServer:1");
2147  if (!cvpservice) {
2148  g_printerr ("Cannot get RemoteUI service\n");
2149 
2150  return EXIT_FAILURE;
2151  }
2152  g_signal_connect (cvpservice, "action-invoked::GetCompatibleUIs", G_CALLBACK (get_rui_url_cb), NULL);
2153  }
2154 
2155 #endif
2156  //control the announcement frequency and life time
2157  /*
2158  GSSDPResourceGroup *ssdpgrp = gupnp_root_device_get_ssdp_resource_group(dev);
2159  guint msgdelay = gssdp_resource_group_get_message_delay(ssdpgrp);
2160  guint msgage = gssdp_resource_group_get_max_age(ssdpgrp);
2161  g_print("Message delay is %u, Message max age is %u", msgdelay, msgage);
2162  * /
2163 
2164  /* Run the main loop */
2165  main_loop = g_main_loop_new (NULL, FALSE);
2166  thread = g_thread_create(checkMainLoopRunning, NULL,FALSE, NULL);
2167  g_main_loop_run (main_loop);
2168 
2169  /* Cleanup */
2170  g_main_loop_unref (main_loop);
2171  g_object_unref (upnpService);
2172  g_object_unref (dev);
2173  g_object_unref (upnpContext);
2174 
2175  return EXIT_SUCCESS;
2176 }
2177 
2178 /**
2179  * @brief This function is used to get the IP address based on IPv6 or IPv4 is enabled.
2180  *
2181  * @param[in] ifname Name of the network interface.
2182  * @param[out] ipAddressBuffer Character buffer to hold the IP address.
2183  * @param[in] ipv6Enabled Flag to check whether IPV6 is enabled
2184  *
2185  * @return Returns an integer value '1' if successfully gets the IP address else returns '0'.
2186  * @ingroup XUPNP_XCALDEV_FUNC
2187  */
2188 int getipaddress(const char* ifname, char* ipAddressBuffer, gboolean ipv6Enabled)
2189 {
2190  struct ifaddrs * ifAddrStruct=NULL;
2191  struct ifaddrs * ifa=NULL;
2192  void * tmpAddrPtr=NULL;
2193  errno_t rc = -1;
2194  int ind = -1;
2195  getifaddrs(&ifAddrStruct);
2196  //char addressBuffer[INET_ADDRSTRLEN] = NULL;
2197  int found=0;
2198  for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
2199  if (ifa->ifa_addr == NULL) continue;
2200  if (ipv6Enabled == TRUE)
2201  { // check it is IP6
2202  // is a valid IP6 Address
2203  rc = strcmp_s(ifa->ifa_name, strlen(ifa->ifa_name), ifname, &ind);
2204  ERR_CHK(rc);
2205  if (((ind == 0) && (rc == EOK)) && (ifa ->ifa_addr->sa_family==AF_INET6))
2206  {
2207  tmpAddrPtr=&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
2208 
2209  inet_ntop(AF_INET6, tmpAddrPtr, ipAddressBuffer, INET6_ADDRSTRLEN);
2210 
2211  //if (strcmp(ifa->ifa_name,"eth0")==0trcmp0(g_strstrip(devConf->mocaMacIf),ifname) == 0)
2212  if ((g_strcmp0(g_strstrip(devConf->bcastIf),ifname) == 0) && (IN6_IS_ADDR_LINKLOCAL(tmpAddrPtr)) || ((!(IN6_IS_ADDR_LINKLOCAL(tmpAddrPtr))) && (g_strcmp0(g_strstrip(devConf->hostMacIf),ifname) == 0)))
2213  {
2214  found = 1;
2215  break;
2216  }
2217  }
2218  }
2219 
2220  else {
2221 
2222  if (ifa ->ifa_addr->sa_family==AF_INET) { // check it is IP4
2223  // is a valid IP4 Address
2224  tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
2225 
2226  inet_ntop(AF_INET, tmpAddrPtr, ipAddressBuffer, INET_ADDRSTRLEN);
2227 
2228  //if (strcmp(ifa->ifa_name,"eth0")==0)
2229  rc = strcmp_s(ifa->ifa_name, strlen(ifa->ifa_name), ifname, &ind);
2230  ERR_CHK(rc);
2231  if((ind == 0) && (rc == EOK))
2232  {
2233  found = 1;
2234  break;
2235  }
2236  }
2237  }
2238  }
2239 
2240  if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
2241  return found;
2242 
2243 }
2244 
2245 /**
2246  * @brief This function is used to get the mac address of the target device.
2247  *
2248  * @param[in] ifname Name of the network interface.
2249  *
2250  * @return Returns the mac address of the interface given.
2251  * @ingroup XUPNP_XCALDEV_FUNC
2252  */
2253 gchar* getmacaddress(const gchar* ifname)
2254 {
2255  errno_t rc = -1;
2256  int fd;
2257  struct ifreq ifr;
2258  unsigned char *mac;
2259  GString *data=g_string_new(NULL);
2260 
2261  fd = socket(AF_INET, SOCK_DGRAM, 0);
2262 
2263  ifr.ifr_addr.sa_family = AF_INET;
2264  rc = strcpy_s(ifr.ifr_name , IFNAMSIZ-1, ifname);
2265  ERR_CHK(rc);
2266  if(rc == EOK)
2267  {
2268  ioctl(fd, SIOCGIFHWADDR, &ifr);
2269 
2270  close(fd);
2271 
2272  mac = (unsigned char *)ifr.ifr_hwaddr.sa_data;
2273 
2274  //display mac address
2275  //g_print("Mac : %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n" , mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
2276  g_string_printf(data,"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
2277  }
2278  return data->str;
2279 }
2280 
2281 /**
2282  * @brief This function is used to get the DNS value from DNS mask configuration file.
2283  *
2284  * @return Returns TRUE if successfully gets the DNS configuration, else returns FALSE.
2285  * @ingroup XUPNP_XCALDEV_FUNC
2286  */
2287 gboolean getdnsconfig(void)
2288 {
2289  GError *error=NULL;
2290  gboolean result = FALSE;
2291  gchar* dnsconfigfile = NULL;
2292  GString* strdnsconfig = g_string_new(NULL);
2293 
2294  if (devConf->dnsFile == NULL)
2295  {
2296  g_warning("dnsconfig file name not found in config");
2297  return result;
2298  }
2299  result = g_file_get_contents (devConf->dnsFile, &dnsconfigfile, NULL, &error);
2300  if (result == FALSE)
2301  {
2302  g_warning("Problem in reading dnsconfig file %s", error->message);
2303  }
2304  else
2305  {
2306  gchar **tokens = g_strsplit_set(dnsconfigfile,"\n\0", -1);
2307  //etchosts->str = g_strjoinv(";", tokens);
2308  guint toklength = g_strv_length(tokens);
2309  guint loopvar=0;
2310  gboolean firsttok = TRUE;
2311 
2312  for (loopvar=0; loopvar<toklength; loopvar++)
2313  {
2314  if ((strlen(g_strstrip(tokens[loopvar])) > 0))
2315  {
2316  // g_message("Token is %s\n",g_strstrip(tokens[loopvar]));
2317  if (firsttok == FALSE)
2318  {
2319  g_string_append_printf(strdnsconfig,"%s;",g_strstrip(tokens[loopvar]));
2320  }
2321  else
2322  {
2323  g_string_printf(strdnsconfig,"%s;",g_strstrip(tokens[loopvar]));
2324  firsttok = FALSE;
2325  }
2326  }
2327  }
2328 
2329  g_string_assign(dnsconfig, strdnsconfig->str);
2330  g_string_free(strdnsconfig, TRUE);
2331  g_message("DNS Config is %s",dnsconfig->str);
2332  g_strfreev(tokens);
2333  }
2334 
2335  if(error)
2336  {
2337  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2338  g_clear_error(&error);
2339  }
2340 
2341  return result;
2342 }
2343 
2344 /**
2345  * @brief This function is used to update the system Ids such as channelMapId, controllerId, plantId
2346  * and vodServerId.
2347  *
2348  * @return Returns TRUE if successfully updates the system ids, else returns FALSE.
2349  * @ingroup XUPNP_XCALDEV_FUNC
2350  */
2351 gboolean updatesystemids(void)
2352 {
2353  if (devConf->useGliDiag == TRUE)
2354  {
2355  g_string_printf(systemids, "channelMapId:%lu;controllerId:%lu;plantId:%lu;vodServerId:%lu",
2356  channelmap_id,dac_id,plant_id,vodserver_id);
2357  return TRUE;
2358  }
2359  else
2360  {
2361  gchar* diagfile;
2362  unsigned long diagid=0;
2363  gboolean result = FALSE;
2364  GError *error=NULL;
2365 
2366  if (devConf->diagFile == NULL)
2367  {
2368  g_warning("diag file name not found in config");
2369  return result;
2370  }
2371  result = g_file_get_contents (devConf->diagFile, &diagfile, NULL, &error);
2372  if (result == FALSE) {
2373  g_string_assign(systemids, "channelMapId:0;controllerId:0;plantId:0;vodServerId:0");
2374  }
2375  else
2376  {
2377  diagid = getidfromdiagfile("channelMapId", diagfile);
2378  g_string_printf(systemids, "channelMapId:%lu;", diagid);
2379  diagid = getidfromdiagfile("controllerId", diagfile);
2380  g_string_append_printf(systemids, "controllerId:%lu;", diagid);
2381  diagid = getidfromdiagfile("plantId", diagfile);
2382  g_string_append_printf(systemids, "plantId:%lu;", diagid);
2383  diagid = getidfromdiagfile("vodServerId", diagfile);
2384  g_string_append_printf(systemids, "vodServerId:%lu", diagid);
2385  }
2386 
2387 
2388  if(error)
2389  {
2390  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2391  g_clear_error(&error);
2392  }
2393 
2394  return result;
2395  }
2396 }
2397 
2398 
2399 /**
2400  * @brief This function is used to get the system Id information from the diagnostic file.
2401  *
2402  * @param[in] diagparam Parameter for which value(system Id) need to be retrieved from the diagnostic file.
2403  * @param[in] diagfilecontents The diagnostic filename
2404  *
2405  * @return Returns value of the system Id.
2406  * @ingroup XUPNP_XCALDEV_FUNC
2407  */
2408 unsigned long getidfromdiagfile(const gchar *diagparam, const gchar* diagfilecontents)
2409 {
2410 
2411  unsigned long diagid=0;
2412  gchar **tokens = g_strsplit_set(diagfilecontents,":,{}", -1);
2413  guint toklength = g_strv_length(tokens);
2414  guint loopvar=0;
2415 
2416  for (loopvar=0; loopvar<toklength; loopvar++)
2417  {
2418  if (g_strrstr(g_strstrip(tokens[loopvar]), diagparam))
2419  {
2420  if ((loopvar+1) < toklength )
2421  diagid=strtoul(tokens[loopvar+1], NULL, 10);
2422  }
2423  }
2424  g_strfreev(tokens);
2425  return diagid;
2426 
2427 }
2428 
2429 /**
2430  * @brief This function is used to get the time zone. It gets the time zone information
2431  * from the device configuration.
2432  *
2433  * @return Returns TRUE if successfully gets the time zone value else, returns FALSE.
2434  * @ingroup XUPNP_XCALDEV_FUNC
2435  */
2436 gboolean gettimezone(void)
2437 {
2438  GError *error=NULL;
2439  gboolean result = FALSE;
2440  gchar* dsgproxyfile = NULL;
2441 
2442  if (devConf->dsgFile == NULL)
2443  {
2444  g_warning("dsg file name not found in config");
2445  return result;
2446  }
2447  result = g_file_get_contents (devConf->dsgFile, &dsgproxyfile, NULL, &error);
2448  if (result == FALSE) {
2449  g_warning("Problem in reading dsgproxyfile file %s", error->message);
2450  }
2451  else
2452  {
2453  /* reset result = FALSE to identify timezone from dsgproxyfile contents */
2454  result = FALSE;
2455  gchar **tokens = g_strsplit_set(dsgproxyfile,",=", -1);
2456  guint toklength = g_strv_length(tokens);
2457  guint loopvar=0;
2458  for (loopvar=0; loopvar<toklength; loopvar++)
2459  {
2460  //g_print("Token is %s\n",g_strstrip(tokens[loopvar]));
2461  if (g_strrstr(g_strstrip(tokens[loopvar]), "DSGPROXY_HOST_TIME_ZONE"))
2462  {
2463  if ((loopvar+1) < toklength )
2464  {
2465  g_string_assign(dsgtimezone, g_strstrip(tokens[loopvar+1]));
2466  }
2467  result = TRUE;
2468  break;
2469  }
2470  }
2471  g_strfreev(tokens);
2472  }
2473 
2474  //diagid=1000;
2475 
2476  if(error)
2477  {
2478  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2479  g_clear_error(&error);
2480  }
2481 
2482  return result;
2483 }
2484 
2485 /**
2486  * @brief This function is used to get the serial number of the device from the vendor specific file.
2487  *
2488  * @param[out] serial_num Manufacturer serial number
2489  *
2490  * @return Returns TRUE if successfully gets the serial number else, returns FALSE.
2491  * @ingroup XUPNP_XCALDEV_FUNC
2492  */
2493 gboolean getserialnum(GString* serial_num)
2494 {
2495 #ifndef CLIENT_XCAL_SERVER
2496  GError *error=NULL;
2497  gboolean result = FALSE;
2498  gchar* udhcpcvendorfile = NULL;
2499 
2500  result = g_file_get_contents ("//etc//udhcpc.vendor_specific", &udhcpcvendorfile, NULL, &error);
2501  if (result == FALSE) {
2502  g_warning("Problem in reading /etc/udhcpcvendorfile file %s", error->message);
2503  }
2504  else
2505  {
2506  /* reset result = FALSE to identify serial number from udhcpcvendorfile contents */
2507  result = FALSE;
2508  gchar **tokens = g_strsplit_set(udhcpcvendorfile," \n\t\b\0", -1);
2509  guint toklength = g_strv_length(tokens);
2510  guint loopvar=0;
2511  for (loopvar=0; loopvar<toklength; loopvar++)
2512  {
2513  //g_print("Token is %s\n",g_strstrip(tokens[loopvar]));
2514  if (g_strrstr(g_strstrip(tokens[loopvar]), "SUBOPTION4"))
2515  {
2516  if ((loopvar+1) < toklength )
2517  {
2518  g_string_assign(serial_num, g_strstrip(tokens[loopvar+2]));
2519  }
2520  result = TRUE;
2521  break;
2522  }
2523  }
2524  g_strfreev(tokens);
2525  }
2526  //diagid=1000;
2527 
2528  if(error)
2529  {
2530  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2531  g_clear_error(&error);
2532  }
2533 
2534  return result;
2535 #else
2536  bool bRet;
2537  errno_t rc = -1;
2539  IARM_Result_t iarmRet = IARM_RESULT_IPCCORE_FAIL;
2540  rc = memset_s(&param, sizeof(param), 0, sizeof(param));
2541  ERR_CHK(rc);
2542  param.type = mfrSERIALIZED_TYPE_SERIALNUMBER;
2544  if(iarmRet == IARM_RESULT_SUCCESS)
2545  {
2546  if(param.buffer && param.bufLen)
2547  {
2548  g_message( " serialized data %s \n",param.buffer );
2549  g_string_assign(serial_num,param.buffer);
2550  bRet = true;
2551  }
2552  else
2553  {
2554  g_message( " serialized data is empty \n" );
2555  bRet = false;
2556  }
2557  }
2558  else
2559  {
2560  bRet = false;
2561  g_message( "IARM CALL failed for mfrtype \n");
2562  }
2563  return bRet;
2564 #endif
2565 }
2566 
2567 /**
2568  * @brief This function is used to get the hosts IP information from hosts configuration file "/etc/hosts".
2569  *
2570  * @return Returns TRUE if successfully gets the hosts else returns FALSE.
2571  * @ingroup XUPNP_XCALDEV_FUNC
2572  */
2573 gboolean getetchosts(void)
2574 {
2575  GError *error=NULL;
2576  gboolean result = FALSE;
2577  gchar* etchostsfile = NULL;
2578  gchar* hostsFile;
2579 
2580  if( ipv6Enabled == TRUE )
2581  hostsFile=g_strdup("//etc//xi-xconf-hosts.list");
2582  else
2583  hostsFile=g_strdup("//etc//hosts");
2584  result = g_file_get_contents (hostsFile, &etchostsfile, NULL, &error);
2585  if (result == FALSE) {
2586  g_warning("Problem in reading %s file %s", hostsFile,error->message);
2587  }
2588  else
2589  {
2590  gchar **tokens = g_strsplit_set(etchostsfile,"\n\0", -1);
2591  //etchosts->str = g_strjoinv(";", tokens);
2592  guint toklength = g_strv_length(tokens);
2593  guint loopvar=0;
2594  if ((toklength > 0) && (strlen(g_strstrip(tokens[0])) > 0) &&
2595  (g_strrstr(g_strstrip(tokens[0]), "127.0.0.1") == NULL))
2596  {
2597  g_string_printf(etchosts, "%s",gwyip->str);
2598  g_string_append_printf(etchosts,"%s"," ");
2599  g_string_append_printf(etchosts,"%s;", g_strstrip(tokens[0]));
2600  }
2601  else
2602  {
2603  g_string_assign(etchosts,"");
2604  }
2605 
2606  for (loopvar=1; loopvar<toklength; loopvar++)
2607  {
2608  //g_print("Token is %s\n",g_strstrip(tokens[loopvar]));
2609  //Do not send localhost 127.0.0.1 mapping
2610  if (g_strrstr(g_strstrip(tokens[loopvar]), "127.0.0.1") == NULL)
2611  {
2612  if (strlen(g_strstrip(tokens[loopvar])) > 0)
2613  {
2614  g_string_append_printf(etchosts, "%s",gwyip->str);
2615  g_string_append_printf(etchosts,"%s"," ");
2616  g_string_append_printf(etchosts,"%s;",g_strstrip(tokens[loopvar]));
2617  }
2618  }
2619  }
2620  g_strfreev(tokens);
2621  }
2622  //diagid=1000;
2623  //g_print("Etc Hosts contents are %s", etchosts->str);
2624  g_free(hostsFile);
2625 
2626  if(error)
2627  {
2628  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
2629  g_clear_error(&error);
2630  }
2631 
2632  return result;
2633 }
2634 /*-----------------------------
2635 * Creates a URI escaped string from input using RFC 2396 reserved chars
2636 * The output matches what javascript encodeURIComponent() generates
2637 */
2638 static void uriescape(unsigned char *instr, GString *outstr)
2639 {
2640  int i;
2641  char unreserved[256] = {0}; //array of unreserved chars or 0 flag
2642 
2643  for (i = 0; i < 256; ++i) //init unreserved chars
2644  {
2645  unreserved[i] = isalnum(i) || i == '-' || i == '_' || i == '.' || i == '!' || i == '~'
2646  || i == '*' || i == '\'' || i == '(' || i == ')'
2647  ? i : 0;
2648  }
2649 
2650  for (; *instr; instr++) //escape the input string to the output string
2651  {
2652  if (unreserved[*instr]) //if defined as unreserved
2653  g_string_append_printf(outstr,"%c",*instr);
2654  else
2655  g_string_append_printf(outstr,"%%%02X",*instr);
2656  }
2657 }
2658 
2659 /*-----------------------------
2660 * Creates a XML escaped string from input
2661 */
2662 static void xmlescape(gchar *instr, GString *outstr)
2663 {
2664  for (; *instr; instr++)
2665  {
2666  switch (*instr)
2667  {
2668  case '&':
2669  g_string_append_printf(outstr,"%s","&amp;");
2670  break;
2671  case '\"':
2672  g_string_append_printf(outstr,"%s","&guot;");
2673  break;
2674  case '\'':
2675  g_string_append_printf(outstr,"%s","&apos;");
2676  break;
2677  case '<':
2678  g_string_append_printf(outstr,"%s","&lt;");
2679  break;
2680  case '>':
2681  g_string_append_printf(outstr,"%s","&gt;");
2682  break;
2683  default:
2684  g_string_append_printf(outstr,"%c",*instr);
2685  break;
2686  }
2687  }
2688 }
2689 
2690 /*-----------------------------
2691 * Returns pointer to string of eSTBMAC without ':' chars
2692 * Uses global hostmacaddress GString for address value
2693 * Returned string must be g_string_free() if not NULL
2694 */
2695 
2696 /**
2697  * @brief This function is used to get the MAC address of the eSTB. It uses global hostmacaddress
2698  * GString to get the address value.
2699  *
2700  * @return Returned string must be g_string_free() if not NULL.
2701  * @ingroup XUPNP_XCALDEV_FUNC
2702  */
2703 GString* get_eSTBMAC(void)
2704 {
2705  if (hostmacaddress != NULL && hostmacaddress->len == 17)//length of address with ':' chars
2706  {
2707  GString* addr = g_string_new(NULL);
2708 
2709  int i = 0;
2710  for (i = 0; i < hostmacaddress->len; ++i)
2711  {
2712  if (i != 2 && i != 5 && i != 8 && i != 11 && i != 14 )//positions of ':' char
2713  {
2714  addr = g_string_append_c(addr,(hostmacaddress->str)[i]);
2715  }
2716  }
2717  return g_string_ascii_up(addr);
2718  }
2719  return NULL;
2720 }
2721 
2722 /*-----------------------------
2723 * Initialize ipAddressBufferCVP2 with ip address at devConf->cvp2If
2724 */
2725 static void initIpAddressBufferCVP2( char *ipAddressBufferCVP2)
2726 {
2727  int result = getipaddress(devConf->cvpIf, ipAddressBufferCVP2, FALSE);
2728 
2729  if (!result)
2730  {
2731  fprintf(stderr,"Could not locate the ipaddress of CVP2 interface %s\n", devConf->cvpIf);
2732  }
2733 
2734  g_message("ipaddress of the CVP2 interface %s\n", ipAddressBufferCVP2);
2735  g_string_assign(gwyipCVP2, ipAddressBufferCVP2);
2736 }
2737 
2738 
2739 static GString *get_compatible_uis_icon(int nSize, int nDepth, const char * pszImageType, const char * pszImageExt)
2740 {
2741  GString * icon = g_string_new(NULL);
2742  g_string_printf(icon,
2743  "<icon>"
2744  "<mimetype>image/%s</mimetype>"
2745  "<width>%d</width>"
2746  "<height>%d</height>"
2747  "<depth>%d</depth> <url>http://syndeo.xcal.tv/app/x2rui/dlna/%s/%s_%d.%s</url>"
2748  "</icon>",
2749  pszImageType,
2750  nSize,
2751  nSize,
2752  nDepth,
2753  getPartnerName(),
2754  getProductName(),
2755  nSize,
2756  pszImageExt
2757  );
2758 
2759  return icon;
2760 }
2761 
2762 static GString *get_compatible_uis_icon_list()
2763 {
2764  GString * icon1 = get_compatible_uis_icon( 48, 32, "png", "png");
2765  GString * icon2 = get_compatible_uis_icon(120, 32, "png", "png");
2766  GString * icon3 = get_compatible_uis_icon( 48, 32, "jpeg", "jpg");
2767  GString * icon4 = get_compatible_uis_icon(120, 32, "jpeg", "jpg");
2768 
2769  GString * iconList = g_string_new(NULL);
2770  g_string_printf(iconList,
2771  "<iconList>"
2772  "%s"
2773  "%s"
2774  "%s"
2775  "%s"
2776  "</iconList>",
2777  icon1->str,
2778  icon2->str,
2779  icon3->str,
2780  icon4->str
2781  );
2782 
2783  g_string_free(icon1, TRUE);
2784  g_string_free(icon2, TRUE);
2785  g_string_free(icon3, TRUE);
2786  g_string_free(icon4, TRUE);
2787 
2788  return iconList;
2789 }
2790 
2791 /*-----------------------------
2792 * Creates the escaped rui <uri> element value
2793 */
2794 static GString *get_uri_value()
2795 {
2796  //create a unique udn value
2797  //struct timeval now;
2798  //int rc = gettimeofday(&now,NULL);
2799  GTimeVal timeval;
2800  g_get_current_time(&timeval);
2801 
2802  double t = timeval.tv_sec + (timeval.tv_usec/1000000.0); //number of seconds and microsecs since epoch
2803  char udnvalue[25];
2804  snprintf(udnvalue,25,"%s%f","CVP-",t);
2805 
2806  //get current ip address for CVP2
2807  char ipAddressBufferCVP2[INET6_ADDRSTRLEN];
2808  initIpAddressBufferCVP2(ipAddressBufferCVP2);
2809 
2810  //init uri parameters with current ip address
2811  g_string_printf(trmurlCVP2, "ws://%s:9988", ipAddressBufferCVP2);
2812  g_string_printf(playbackurlCVP2, "http://%s:8080/hnStreamStart?deviceId=%s&DTCP1HOST=%s&DTCP1PORT=5000", ipAddressBufferCVP2, recv_id->str, ipAddressBufferCVP2);
2813 
2814 
2815  //initialize urivalue from xdevice.conf if present
2816  gchar *urilink;
2817  if (devConf->uriOverride != NULL)
2818  urilink = devConf->uriOverride;
2819  else
2820  urilink = "http://syndeo.xcal.tv/app/x2rui/rui.html";
2821 
2822  //g_print("before g_strconcat urilink: %s\n",urilink);
2823 
2824  //parse the systemids
2825  //systemids-str must have the following format
2826  //channelMapId:%lu;controllerId:%lu;plantId:%lu;vodServerId:%lu
2827  g_print("systemids->str: %s\n", systemids->str);
2828  GString *channelMapId = NULL;
2829  char * pId = "channelMapId:";
2830  char *pChannelMapId = strstr(systemids->str,pId);
2831  if (pChannelMapId != NULL)
2832  {
2833  pChannelMapId += strlen(pId);
2834  size_t len = strcspn(pChannelMapId, ";");
2835  channelMapId = g_string_new_len(pChannelMapId, len);
2836  }
2837  if (channelMapId == NULL)
2838  channelMapId = g_string_new("0");
2839 
2840  GString *controllerId = NULL;
2841  pId = "controllerId:";
2842  char *pControllerId = strstr(systemids->str,pId);
2843  if (pControllerId != NULL)
2844  {
2845  pControllerId += strlen(pId);
2846  size_t len = strcspn(pControllerId, ";");
2847  controllerId = g_string_new_len(pControllerId, len);
2848  }
2849  if (controllerId == NULL)
2850  controllerId = g_string_new("0");
2851 
2852  GString *plantId = NULL;
2853  pId = "plantId:";
2854  char *pPlantId = strstr(systemids->str,pId);
2855  if (pPlantId != NULL)
2856  {
2857  pPlantId += strlen(pId);
2858  size_t len = strcspn(pPlantId, ";");
2859  plantId = g_string_new_len(pPlantId, len);
2860  }
2861  if (plantId == NULL)
2862  plantId = g_string_new("0");
2863 
2864  GString *vodServerId = NULL;
2865  pId = "vodServerId:";
2866  char *pVodServerId = strstr(systemids->str,pId);
2867  if (pVodServerId != NULL)
2868  {
2869  pVodServerId += strlen(pId);
2870  size_t len = strcspn(pVodServerId, ";");
2871  vodServerId = g_string_new_len(pVodServerId, len);
2872  }
2873  if (vodServerId == NULL)
2874  vodServerId = g_string_new("0");
2875 
2876  GString* eSTBMAC = get_eSTBMAC();
2877  if (eSTBMAC == NULL)
2878  {
2879  eSTBMAC = g_string_new("UNKNOWN");
2880  }
2881 
2882 
2883  gchar* gw_value= g_strconcat(
2884  "{"
2885  "\"deviceType\":\"DMS\","
2886  "\"friendlyName\":\"" ,getGatewayName(), "\","
2887  "\"receiverID\":\"" ,recv_id->str, "\","
2888  "\"udn\":\"" ,udnvalue, "\","
2889  "\"gatewayIP\":\"" ,gwyipCVP2->str, "\","
2890  "\"baseURL\":\"" ,playbackurlCVP2->str, "\","
2891  "\"trmURL\":\"" ,trmurlCVP2->str, "\","
2892  "\"channelMapId\":\"" ,channelMapId->str, "\","
2893  "\"controllerId\":\"" ,controllerId->str, "\","
2894  "\"plantId\":\"" ,plantId->str, "\","
2895  "\"vodServerId\":\"" ,vodServerId->str, "\","
2896  "\"eSTBMAC\":\"" ,eSTBMAC->str, "\""
2897  "}", NULL );
2898 
2899  g_string_free(eSTBMAC, TRUE);
2900  g_string_free(channelMapId,TRUE);
2901  g_string_free(controllerId,TRUE);
2902  g_string_free(plantId,TRUE);
2903  g_string_free(vodServerId,TRUE);
2904 
2905  //gchar *gw_value = "a&b\"c\'d<e>f;g/h?i:j@k&l=m+n$o,p{}q'r_s-t.u!v~x*y(z)"; //test string with reserved chars
2906  //g_print("gw_value string before escape = %s\n",gw_value);
2907 
2908  GString *gwescapededstr = g_string_sized_new(strlen(gw_value) * 3);//x3, big enough for all of the chars to be escaped
2909 
2910  uriescape(gw_value,gwescapededstr);
2911 
2912  g_free(gw_value);
2913 
2914  //g_print("gw_value string after URI escape = %s\n",gwescapededstr->str);
2915 
2916  gchar* uri = g_strconcat( urilink,"?partner=", getPartnerID(),"&gw=", gwescapededstr->str, NULL );
2917 
2918  g_string_free(gwescapededstr, TRUE);
2919 
2920  GString *xmlescapedstr = g_string_sized_new(strlen(uri) * 2);//x2 should be big enough
2921 
2922  xmlescape(uri, xmlescapedstr);
2923 
2924  g_free(uri);
2925 
2926  //g_print("uri string after XML escape = %s\n",xmlescapedstr->str);
2927 
2928  return xmlescapedstr;
2929 }
2930 
2931 /*----------------------------
2932 * Init ruiurl var with the RUI GetCompatibleUIs return value
2933 */
2934 
2935 /**
2936  * @brief This function is used to get the RUI(Remote user interface) Url. It uses xdevice.conf
2937  * file to get the RUI Url. If the xdevice.conf file is not present then create the the RUI url string.
2938  *
2939  * @return Returns TRUE if successfully gets the RUI url.
2940  * @ingroup XUPNP_XCALDEV_FUNC
2941  */
2942 gboolean getruiurl()
2943 {
2944 
2945  if ( ruiurl->str != NULL ) //previous string needs to be freed
2946  {
2947  g_string_free( ruiurl, TRUE);//TRUE means free str allocation too
2948  }
2949 
2950  if (devConf->ruiPath != NULL) //use config file string if present
2951  {
2952  g_print("getruiurl using xdevice.conf RuiPath=value\n");
2953  ruiurl = g_string_new(g_strconcat(devConf->ruiPath, NULL));
2954  }
2955  else //otherwise, create with actual values
2956  {
2957 
2958  GString *urivalue = get_uri_value();
2959  GString *iconlist = get_compatible_uis_icon_list();
2960 
2961  //create rui url string, needs to be freed with g_free()
2962  ruiurl = g_string_new(NULL);
2963  g_string_printf(ruiurl,
2964  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2965  "<uilist xmlns=\"urn:schemas-upnp-org:remoteui:uilist-1-0\" "
2966  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:schemas-upnp-org:remoteui:uilist-1-0 CompatibleUIs.xsd\">"
2967  "<ui>"
2968  "<uiID>1234-9876-1265-8758</uiID>"
2969  "<name>%s</name>" //"<name>Comcast XFINITY Guide</name>"
2970  "<description>%s</description>" //"<description>Comcast XFINITY Guide application</description>"
2971  "%s"
2972  "<fork>true</fork>"
2973  "<lifetime>-1</lifetime>"
2974  "<protocol shortName=\"DLNA-HTML5-1.0\">"
2975  "<uri>"
2976  "%s"
2977  "</uri>"
2978  "</protocol>"
2979  "</ui>"
2980  "</uilist>",
2981  getServiceName(),
2982  getServiceDescription(),
2983  iconlist->str,
2984  urivalue->str
2985  );
2986 
2987  g_string_free(urivalue, TRUE);
2988  g_string_free(iconlist, TRUE);
2989  }
2990  //g_print("ruiurl string from getruiurl(): = %s\n",ruiurl->str);
2991  return TRUE;
2992 }
2993 
2994 static xmlNode * get_node_by_name(xmlNode * node, const char *node_name)
2995 {
2996  xmlNode * cur_node = NULL;
2997  xmlNode * ret = NULL;
2998  errno_t rc = -1;
2999  int ind = -1;
3000 
3001  for (cur_node = node ; cur_node ; cur_node = cur_node->next)
3002  {
3003  rc = strcmp_s(cur_node->name, strlen(cur_node->name), node_name, &ind);
3004  ERR_CHK(rc);
3005  if ((ind == 0) && (rc == EOK))
3006  {
3007  return cur_node;
3008  }
3009  ret = get_node_by_name(cur_node->children, node_name);
3010  if ( ret != NULL )
3011  break;
3012  }
3013  return ret;
3014 }
3015 
3016 /**
3017  * @brief This function is used to set new value to the given node from the xml file.
3018  *
3019  * @param[in] doc Xml document.
3020  * @param[in] node_name The name of the node to be updated.
3021  * @param[in] new_value New value to be set for the node.
3022  *
3023  * @return Returns Integer value '0' if successfully sets the new node value else returns '1'.
3024  * @ingroup XUPNP_XCALDEV_FUNC
3025  */
3026 int set_content(xmlDoc* doc, const char * node_name, const char * new_value)
3027 {
3028  xmlNode * root_element = NULL;
3029  xmlNode * target_node = NULL;
3030 
3031  root_element = xmlDocGetRootElement(doc);
3032  target_node = get_node_by_name(root_element, node_name);
3033 
3034  if (target_node==NULL)
3035  {
3036  g_printerr("Couldn't locate the Target node\n");
3037  return 1;
3038  }
3039 
3040  xmlNodeSetContent(target_node,new_value);
3041 
3042  return 0;
3043 }
3044 
3045 /**
3046  * @brief This function is used to get the value of the node from the xml file.
3047  *
3048  * @param[in] doc Xml document.
3049  * @param[in] node_name Name of the node for which value has to be retrieved.
3050  *
3051  * @return Returns the Node value string else returns NULL.
3052  * @ingroup XUPNP_XCALDEV_FUNC
3053  */
3054 char * get_content(xmlDoc* doc, const char * node_name)
3055 {
3056  xmlNode * root_element = xmlDocGetRootElement(doc);
3057  xmlNode * xml_node = get_node_by_name(root_element, node_name);
3058 
3059  if (xml_node==NULL)
3060  {
3061  g_printerr("Couldn't locate the %s node\n", node_name);
3062  return NULL;
3063  }
3064 
3065  return xmlNodeGetContent(xml_node);
3066 }
3067 
3068 /**
3069  * @brief Supporting function for reading the XML file
3070  *
3071  * @param[in] file_name Name of the xml file
3072  *
3073  * @return Returns the resulting document tree.
3074  * @ingroup XUPNP_XCALDEV_FUNC
3075  */
3076 xmlDoc * open_document(const char * file_name)
3077 {
3078  xmlDoc * ret;
3079 
3080  ret = xmlReadFile(file_name, NULL, 0);
3081  if (ret == NULL)
3082  {
3083  //g_printerr("Failed to parse %s\n", file_name);
3084  return NULL;
3085  }
3086  return ret;
3087 }
3088 
3089 /*
3090 * isVidiPathEnabled()
3091 * If /opt/vidiPathEnabled does not exist, indicates VidiPath is NOT enabled.
3092 * If /opt/vidiPathEnabled exists, VidiPath is enabled.
3093 */
3094 #define VIDIPATH_FLAG "/opt/vidiPathEnabled"
3095 
3096 static int isVidiPathEnabled()
3097 {
3098  if (access(VIDIPATH_FLAG,F_OK) == 0)
3099  return 1; //vidipath enabled
3100  return 0; //vidipath not enabled
3101 }
3102 
3103 /**
3104  * @brief This function is used to retrieve the data from the device configuration file
3105  *
3106  * @param[in] configfile Device configuration file name.
3107  *
3108  * @return Returns TRUE if successfully reads the configuration else returns FALSE.
3109  * @ingroup XUPNP_XCALDEV_FUNC
3110  */
3111 gboolean readconffile(const char* configfile)
3112 {
3113 
3114  GKeyFile *keyfile = NULL;
3115  GKeyFileFlags flags;
3116  GError *error = NULL;
3117  gsize length;
3118 
3119  /* Create a new GKeyFile object and a bitwise list of flags. */
3120  keyfile = g_key_file_new ();
3121  flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
3122 
3123  /* Load the GKeyFile from keyfile.conf or return. */
3124  if (!g_key_file_load_from_file (keyfile, configfile, flags, &error))
3125  {
3126  if(error)
3127  {
3128  g_error ("%s\n", error->message);
3129 
3130  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
3131  g_clear_error(&error);
3132  }
3133  if(keyfile)
3134  {
3135  g_key_file_free(keyfile);
3136  }
3137  return FALSE;
3138  }
3139  g_message("Starting with Settings %s\n", g_key_file_to_data(keyfile, NULL, NULL));
3140 
3141  devConf = g_new(ConfSettings,1);
3142  /*
3143  # Names of all network interfaces used for publishing
3144  [Network]
3145  BCastIf=eth1
3146  BCastPort=50755
3147  StreamIf=eth1
3148  TrmIf=eth1
3149  GwIf=eth1
3150  CvpIf=eth1
3151  CvpPort=50753
3152  HostMacIf=wan
3153  */
3154 
3155  /* Read in data from the key file from the group "Network". */
3156 
3157  devConf->bcastIf = g_key_file_get_string (keyfile, "Network","BCastIf", NULL);
3158  devConf->bcastPort = g_key_file_get_integer (keyfile, "Network","BCastPort", NULL);
3159 #ifndef CLIENT_XCAL_SERVER
3160  devConf->streamIf = g_key_file_get_string (keyfile, "Network","StreamIf", NULL);
3161  devConf->trmIf = g_key_file_get_string (keyfile, "Network","TrmIf", NULL);
3162  devConf->gwIf = g_key_file_get_string (keyfile, "Network","GwIf", NULL);
3163  devConf->cvpIf = g_key_file_get_string (keyfile, "Network","CvpIf", NULL);
3164  devConf->cvpPort = g_key_file_get_integer (keyfile, "Network","CvpPort", NULL);
3165  devConf->hostMacIf = g_key_file_get_string (keyfile, "Network","HostMacIf", NULL);
3166 #endif
3167  /*
3168  # Paths and names of all input data files
3169  [DataFiles]
3170  OemFile=//etc//udhcpc.vendor_specific
3171  DnsFile=//etc//resolv.dnsmasq
3172  DsgFile=//tmp//dsgproxy_slp_attributes.txt
3173  DiagFile=//tmp//mnt/diska3//persistent//usr//1112//703e//diagnostics.json
3174  HostsFile=//etc//hosts
3175  DevXmlPath=/opt/xupnp/
3176  DevXmlFile=BasicDevice.xml
3177  LogFile=/opt/logs/xdevice.log
3178  AuthServerUrl=http://localhost:50050/device/generateAuthToken
3179  DevPropertyFile=/etc/device.properties
3180  Ipv6FileLocation=/tmp/stb_ipv6
3181  Ipv6PrefixFile=/tmp/stb_ipv6
3182  DeviceNameFile=/opt/hn_service_settings.conf
3183  */
3184  /* Read in data from the key file from the group "DataFiles". */
3185 #ifndef CLIENT_XCAL_SERVER
3186  devConf->oemFile = g_key_file_get_string (keyfile, "DataFiles","OemFile", NULL);
3187  devConf->dnsFile = g_key_file_get_string (keyfile, "DataFiles","DnsFile", NULL);
3188  devConf->dsgFile = g_key_file_get_string (keyfile, "DataFiles","DsgFile", NULL);
3189  devConf->diagFile = g_key_file_get_string (keyfile, "DataFiles","DiagFile", NULL);
3190  devConf->devXmlPath = g_key_file_get_string (keyfile, "DataFiles","DevXmlPath", NULL);
3191  devConf->devXmlFile = g_key_file_get_string (keyfile, "DataFiles","DevXmlFile", NULL);
3192  devConf->cvpXmlFile = g_key_file_get_string (keyfile, "DataFiles","CvpXmlFile", NULL);
3193  devConf->logFile = g_key_file_get_string (keyfile, "DataFiles","LogFile", NULL);
3194  devConf->ipv6FileLocation = g_key_file_get_string (keyfile, "DataFiles","Ipv6FileLocation", NULL);
3195  devConf->ipv6PrefixFile = g_key_file_get_string (keyfile, "DataFiles","Ipv6PrefixFile", NULL);
3196  devConf->enableCVP2 = isVidiPathEnabled();
3197 #endif
3198  devConf->deviceNameFile = g_key_file_get_string (keyfile, "DataFiles","DeviceNameFile", NULL);
3199  devConf->devPropertyFile = g_key_file_get_string (keyfile, "DataFiles","DevPropertyFile", NULL);
3200  /*
3201  # Enable/Disable feature flags
3202  [Flags]
3203  EnableCVP2=false
3204  UseIARM=true
3205  AllowGwy=true
3206  EnableTRM=true
3207  UseGliDiag=true
3208  DisableTuneReady=true
3209  enableHostMacPblsh=true
3210  wareHouseMode=true
3211  rmfCrshSupp=false
3212  */
3213  devConf->useIARM = g_key_file_get_boolean (keyfile, "Flags","UseIARM", NULL);
3214  devConf->allowGwy = g_key_file_get_boolean (keyfile, "Flags","AllowGwy", NULL);
3215 #ifndef CLIENT_XCAL_SERVER
3216  devConf->enableCVP2 = isVidiPathEnabled();
3217 
3218  devConf->ruiPath = g_key_file_get_string (keyfile,"Rui", "RuiPath" , NULL);
3219 
3220  if (devConf->ruiPath == NULL ) //only use overrides if ruiPath is not present
3221  {
3222  devConf->uriOverride = g_key_file_get_string (keyfile, "Rui", "uriOverride", NULL);
3223  }
3224  else
3225  {
3226  devConf->uriOverride = NULL;
3227  }
3228  devConf->enableTRM = g_key_file_get_boolean (keyfile, "Flags","EnableTRM", NULL);
3229  devConf->useGliDiag = g_key_file_get_boolean (keyfile, "Flags","UseGliDiag", NULL);
3230  devConf->disableTuneReady = g_key_file_get_boolean (keyfile, "Flags","DisableTuneReady", NULL);
3231  devConf->enableHostMacPblsh = g_key_file_get_boolean (keyfile, "Flags","EnableHostMacPblsh", NULL);
3232  devConf->rmfCrshSupp = g_key_file_get_boolean (keyfile, "Flags","rmfCrshSupp", NULL);
3233  devConf->wareHouseMode = g_key_file_get_boolean (keyfile, "Flags","wareHouseMode", NULL);
3234 #endif
3235 
3236  g_key_file_free(keyfile);
3237 #ifndef CLIENT_XCAL_SERVER
3238  if ((devConf->bcastIf == NULL)|| (devConf->bcastPort == 0) || (devConf->devXmlPath == NULL) ||
3239  (devConf->devXmlFile == NULL))
3240  {
3241  g_warning("Invalid or no values found for mandatory parameters\n");
3242  return FALSE;
3243  }
3244 #endif
3245  return TRUE;
3246 
3247 }
3248 
3249 /**
3250  * @brief This function is used to update the xml node values UDN, serialNumber and friendlyName.
3251  *
3252  * @param[in] xmlfilename Name of the XML file.
3253  * @param[in] struuid Unique device Id .
3254  * @param[in] serialno Serial number.
3255  * @param[in] friendlyName Friendly name.
3256  *
3257  * @return Returns TRUE if successfully updated the xml data else returns FALSE.
3258  * @ingroup XUPNP_XCALDEV_FUNC
3259  */
3260 gboolean updatexmldata(const char* xmlfilename, const char* struuid, const char* serialno, const char* friendlyName)
3261 {
3262  LIBXML_TEST_VERSION
3263 
3264  xmlDoc * doc = open_document(xmlfilename);
3265 
3266  if (doc == NULL)
3267  {
3268  g_printerr ("Error reading the Device XML file\n");
3269  return FALSE;
3270  }
3271 
3272  if (set_content(doc, "UDN", struuid)!=0)
3273  {
3274  g_printerr ("Error setting the unique device id in conf xml\n");
3275  return FALSE;
3276  }
3277  if (set_content(doc, "serialNumber", serialno)!=0)
3278  {
3279  g_printerr ("Error setting the serial number in conf xml\n");
3280  return FALSE;
3281  }
3282 
3283  if(NULL != friendlyName)
3284  {
3285  if (set_content(doc, "friendlyName", friendlyName)!=0)
3286  {
3287  g_printerr ("Error setting the friendlyName number in conf xml\n");
3288  return FALSE;
3289  }
3290  }
3291  else
3292  {
3293  g_printerr ("friendlyName is NULL\n");
3294  }
3295 
3296  FILE *fp = fopen(xmlfilename, "w");
3297 
3298  if (fp==NULL)
3299  {
3300  g_printerr ("Error opening the conf xml file for writing\n");
3301  return FALSE;
3302  }
3303  else if (xmlDocFormatDump(fp, doc, 1) == -1)
3304  {
3305  g_printerr ("Could not write the conf to xml file\n");
3306  return FALSE;
3307  }
3308 
3309  fclose(fp);
3310 
3311  xmlFreeDoc(doc);
3312  xmlCleanupParser();
3313  return TRUE;
3314 }
3315 
3316 /**
3317  * @brief A generic function to notify all the clients whenever there is a change found in the
3318  * service variable values.
3319  *
3320  * @param[in] varname Node name to be notified.
3321  * @param[in] strvalue New value to be notified.
3322  * @ingroup XUPNP_XCALDEV_FUNC
3323  */
3324 void notify_value_change(const char* varname, const char* strvalue)
3325 {
3326  if ((service_ready==FALSE) || (!upnpService))
3327  {
3328  g_warning("Received notificaton before start of Service");
3329  }
3330  else
3331  {
3332 // GValue value = {0};
3333  GValue value = G_VALUE_INIT;
3334  g_value_init(&value, G_TYPE_STRING);
3335  g_value_set_static_string(&value, strvalue);
3336  g_message("Sending value change notification Name %s - Value: %s", varname, strvalue);
3337  gupnp_service_notify_value(upnpService, varname, &value);
3338  //g_value_unset(&value);
3339  }
3340  return;
3341 }
3342 
3343 /**
3344  * @brief Generic function to notify the change in the node value which are of integers type
3345  * from the XML service file.
3346  *
3347  * @param[in] varname Node name to be notified.
3348  * @param[in] strvalue New value to be notified.
3349  * @ingroup XUPNP_XCALDEV_FUNC
3350  */
3351 void notify_value_change_int(const char* varname, int intvalue)
3352 {
3353  if ((service_ready==FALSE) || (!upnpService))
3354  {
3355  g_warning("Received notificaton before start of Service");
3356  }
3357  else
3358  {
3359  GValue value = G_VALUE_INIT;
3360  g_value_init(&value, G_TYPE_INT);
3361  g_value_set_int(&value, intvalue);
3362  g_message("Sending value change notification Name %s - Value: %d", varname, intvalue);
3363  gupnp_service_notify_value(upnpService, varname, &value);
3364  //g_value_unset(&value);
3365  }
3366  return;
3367 }
3368 
3369 /**
3370  * @brief Supporting function for checking the given string is alphanumeric.
3371  *
3372  * @param[in] str String to be verified.
3373  *
3374  * @return Returns TRUE if successfully checks the string is alphanumeric else returns FALSE.
3375  * @ingroup XUPNP_XCALDEV_FUNC
3376  */
3377 gboolean is_alphanum(const gchar *str)
3378 {
3379 
3380  unsigned int i=0;
3381  gboolean isalphanum = TRUE;
3382  for (i = 0; i < strlen(str); i++) {
3383  if (!g_ascii_isalnum(str[i])) {
3384  isalphanum = FALSE;
3385  break;
3386  }
3387  }
3388  return isalphanum;
3389 }
3390 
3391 /**
3392  * @brief Supporting function for checking the content of given string is numeric or not.
3393  *
3394  * @param[in] str String for which the contents need to be verified.
3395  *
3396  * @return Returns TRUE if successfully checks the string is numeric else returns FALSE.
3397  * @ingroup XUPNP_XCALDEV_FUNC
3398  */
3399 gboolean is_num(const gchar *str)
3400 {
3401 
3402  unsigned int i=0;
3403  gboolean isnum = TRUE;
3404  for (i = 0; i < strlen(str); i++) {
3405  if (!g_ascii_isdigit(str[i])) {
3406  isnum = FALSE;
3407  break;
3408  }
3409  }
3410  return isnum;
3411 }
3412 
3413 /**
3414  * @brief This function is used to get the Receiver Id & Partner Id.
3415  *
3416  * When box in warehouse mode, the box does not have the receiver Id so the box need to be put the
3417  * broadcast MAC address as receiver Id.
3418  *
3419  * @param[in] id The Device ID node for which the value need to be retrieved. It is also used for
3420  * getting Partner Id.
3421  *
3422  * @return Returns Value of the Device Id on success else NULL.
3423  * @ingroup XUPNP_XCALDEV_FUNC
3424  */
3425 GString* getID( const gchar *id )
3426 {
3427  gboolean isDevIdPresent=FALSE;
3428  gshort counter=0; // to limit the logging if the user doesnt activate for long time
3429 
3430  GString* jsonData=g_string_new(NULL);
3431  GString* value=g_string_new(NULL);
3432  while(TRUE)
3433  {
3434 // if (IARM_BUS_SYS_MODE_WAREHOUSE == sysModeParam)
3435 #if defined(USE_XUPNP_IARM_BUS)
3436  if(( devConf->wareHouseMode == TRUE ) || (IARM_BUS_SYS_MODE_WAREHOUSE == sysModeParam))
3437  {
3438  const gchar* bcastmac=(gchar*)getmacaddress(devConf->bcastIf);
3439  g_string_assign(value, bcastmac);
3440  g_message("In WareHouse Mode recvid %s bcastmac %s \n ",recv_id->str,bcastmac);
3441  break;
3442  }
3443 #endif //#if defined(USE_XUPNP_IARM_BUS)
3444 
3445  FILE *fp = NULL;
3446  if((fp = v_secure_popen("r", GET_DEVICEID_SCRIPT)))
3447  {
3448  char response[1024] = {0};
3449  fread(response, 1, sizeof(response)-1, fp);
3450  int ret = v_secure_pclose(fp);
3451  if(ret != 0)
3452  g_message("Error in closing pipe ! : %d \n", ret);
3453 
3454  if ((response[0] == '\0') && (counter < MAX_DEBUG_MESSAGE))
3455  {
3456  counter ++;
3457  g_message("No Json string found in Auth url %s \n" ,response);
3458  }
3459  else
3460  {
3461  g_string_assign(jsonData,response);
3462  gchar **tokens = g_strsplit_set(jsonData->str,"{}:,\"", -1);
3463  guint tokLength = g_strv_length(tokens);
3464  guint loopvar=0;
3465  for (loopvar=0; loopvar<tokLength; loopvar++)
3466  {
3467  if (g_strrstr(g_strstrip(tokens[loopvar]), id))
3468  {
3469  //"deviceId": "T00xxxxxxx" so omit 3 tokens ":" fromDeviceId
3470  if ((loopvar+3) < tokLength )
3471  {
3472  g_string_assign(value, g_strstrip(tokens[loopvar+3]));
3473  if(value->str[0] != '\0')
3474  {
3475  isDevIdPresent=TRUE;
3476  break;
3477  }
3478  }
3479  }
3480  }
3481  if(!isDevIdPresent)
3482  {
3483  if (g_strrstr(id,PARTNER_ID))
3484  {
3485  g_message("%s not found in Json string in Auth url %s \n ",id,jsonData->str);
3486  return value;
3487  }
3488  if (counter < MAX_DEBUG_MESSAGE )
3489  {
3490  counter++;
3491  g_message("%s not found in Json string in Auth url %s \n ",id,jsonData->str);
3492 
3493  }
3494  }
3495  else
3496  {
3497  g_message("Successfully fetched %s %s \n ",id,value->str);
3498  //g_free(tokens);
3499  break;
3500  }
3501  g_strfreev(tokens);
3502  }
3503  }
3504  else
3505  {
3506  g_message("The deviceId script %s can't be executed\n", GET_DEVICEID_SCRIPT);
3507  }
3508 
3509  sleep(5);
3510  }
3511  g_string_free(jsonData,TRUE);
3512  return value;
3513 }
3514 
3515 
3516 /**
3517  * @brief This function is used to retrieve the information from the device file.
3518  *
3519  * @param[in] deviceFile Name of the device configuration file.
3520  *
3521  * @return Returns TRUE if successfully reads the device file else returns FALSE.
3522  * @ingroup XUPNP_XCALDEV_FUNC
3523  */
3524 gboolean readDevFile(const char *deviceFile)
3525 {
3526  GError *error=NULL;
3527  gboolean result = FALSE;
3528  gchar* devfilebuffer = NULL;
3529  gchar counter=0;
3530 
3531  if (deviceFile == NULL)
3532  {
3533  g_message("device properties file not found");
3534  return result;
3535  }
3536 
3537  result = g_file_get_contents (deviceFile, &devfilebuffer, NULL, &error);
3538  if (result == FALSE)
3539  {
3540  g_message("No contents in device properties");
3541  }
3542  else
3543  {
3544  /* reset result = FALSE to identify device properties from devicefile contents */
3545  result = FALSE;
3546  gchar **tokens = g_strsplit_set(devfilebuffer,",='\n'", -1);
3547  guint toklength = g_strv_length(tokens);
3548  guint loopvar=0;
3549  for (loopvar=0; loopvar<toklength; loopvar++)
3550  {
3551  if (g_strrstr(g_strstrip(tokens[loopvar]), "RECEIVER_DEVICETYPE"))
3552  {
3553  if ((loopvar+1) < toklength )
3554  {
3555  counter++;
3556  g_string_assign(recvdevtype, g_strstrip(tokens[loopvar+1]));
3557  }
3558  if (counter == 5)
3559  {
3560  result = TRUE;
3561  break;
3562  }
3563  }
3564  else if(g_strrstr(g_strstrip(tokens[loopvar]), "BUILD_VERSION"))
3565  {
3566  if ((loopvar+1) < toklength )
3567  {
3568  counter++;
3569  g_string_assign(buildversion, g_strstrip(tokens[loopvar+1]));
3570  }
3571  if (counter == 5)
3572  {
3573  result = TRUE;
3574  break;
3575  }
3576  }
3577  else if(g_strrstr(g_strstrip(tokens[loopvar]), "BOX_TYPE"))
3578  {
3579  if ((loopvar+1) < toklength )
3580  {
3581  counter++;
3582  g_string_assign(devicetype, g_strstrip(tokens[loopvar+1]));
3583  }
3584  if (counter == 5)
3585  {
3586  result = TRUE;
3587  break;
3588  }
3589  }
3590  if (g_strrstr(g_strstrip(tokens[loopvar]), "MOCA_INTERFACE"))
3591  {
3592  if ((loopvar+1) < toklength )
3593  {
3594  counter++;
3595  g_string_assign(mocaIface, g_strstrip(tokens[loopvar+1]));
3596  }
3597  if (counter == 5)
3598  {
3599  result = TRUE;
3600  break;
3601  }
3602  }
3603  if (g_strrstr(g_strstrip(tokens[loopvar]), "WIFI_INTERFACE"))
3604  {
3605  if ((loopvar+1) < toklength )
3606  {
3607  counter++;
3608  g_string_assign(wifiIface, g_strstrip(tokens[loopvar+1]));
3609  }
3610  if (counter == 5)
3611  {
3612  result = TRUE;
3613  break;
3614  }
3615  }
3616 
3617  }
3618  g_strfreev(tokens);
3619  }
3620 
3621  if(result == FALSE)
3622  {
3623  g_message("RECEIVER_DEVICETYPE and BUILD_VERSION not found in %s",deviceFile);
3624  }
3625 
3626  if(error)
3627  {
3628  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
3629  g_clear_error(&error);
3630  }
3631 
3632  //diagid=1000;
3633  return result;
3634 }
3635 
3636 /**
3637  * @brief Generic function to notify the change in the time zone.
3638  * @ingroup XUPNP_XCALDEV_FUNC
3639  */
3641 {
3642  if ((g_strcmp0(g_strstrip(dsgtimezone->str),"US/Mountain") == 0) && (dstOffset == 0))
3643  {
3644  g_string_assign(dsgtimezone,"US/Arizona");
3645  g_message("XUPnP: changing timezone timezone= %s dst offset = %d \n",dsgtimezone->str,dstOffset);
3646  }
3647  else if ((g_strcmp0(g_strstrip(dsgtimezone->str),"US/Central") == 0) && (dstOffset == 0))
3648  {
3649  g_string_assign(dsgtimezone,"Canada/Saskatchewan");
3650  g_message("XUPnP: changing timezone timezone= %s dst offset = %d \n",dsgtimezone->str,dstOffset);
3651  }
3652 // else if ((g_strcmp0(g_strstrip(dsgtimezone->str),"US/Hawaii") == 0) && (dstOffset == 60)) //we wont get dstoffset as 60 for hawaii but just to be safe.
3653  // {
3654  // g_message("XUPnP: changing dstoffset timezone= %s dst offset = %d \n",dsgtimezone->str,dstOffset);
3655  // dstOffset=0;
3656  // }
3657  notify_value_change("TimeZone", dsgtimezone->str);
3658 }
3659 
3660 /**
3661  * @brief This function is used to retrieve the IPv6 prefix information from dibblers file.
3662  *
3663  * @return Returns TRUE if successfully gets the ipv6 prefix value else returns FALSE.
3664  * @ingroup XUPNP_XCALDEV_FUNC
3665  */
3666 gboolean getipv6prefix(void)
3667 {
3668  GError *error=NULL;
3669  gboolean result = FALSE;
3670  gchar* prefixfile = NULL;
3671  guint loopvar=0;
3672  guint prefixloopvar=0;
3673  gboolean ifacematch = FALSE;
3674  gboolean prefixmatch = FALSE;
3675  gchar **prefixtokens;
3676  if (devConf->ipv6PrefixFile == NULL)
3677  {
3678  g_warning("ipv6PrefixFile file name not found in config");
3679  return result;
3680  }
3681  result = g_file_get_contents (devConf->ipv6PrefixFile, &prefixfile, NULL, &error);
3682  if (result == FALSE) {
3683  g_warning("Problem in reading /prefix/prefix file %s", error->message);
3684  }
3685  else
3686  {
3687  gchar **tokens = g_strsplit_set(prefixfile,"'\n''\0'", -1);
3688  guint toklength = g_strv_length(tokens);
3689 
3690  while(loopvar < toklength)
3691  {
3692  if(ifacematch==FALSE)
3693  {
3694  if ((g_strrstr(g_strstrip(tokens[loopvar]), "ifacename")) && (g_strrstr(g_strstrip(tokens[loopvar]), devConf->hostMacIf)))
3695  {
3696  ifacematch=TRUE;
3697  }
3698  }
3699  else
3700  {
3701  if(g_strrstr(g_strstrip(tokens[loopvar]), "AddrPrefix"))
3702  {
3703  prefixtokens = g_strsplit_set(tokens[loopvar],"'<''>''='", -1);
3704  guint prefixtoklength = g_strv_length(prefixtokens);
3705  while(prefixloopvar<prefixtoklength)
3706  {
3707  if(g_strrstr(g_strstrip(prefixtokens[prefixloopvar]), "/AddrPrefix"))
3708  {
3709 
3710  prefixmatch=TRUE;
3711  result=TRUE;
3712  g_string_printf(ipv6prefix,"%s",prefixtokens[prefixloopvar-1]);
3713  g_message("ipv6 prefix format in the file %s",prefixtokens[prefixloopvar-1]);
3714  break;
3715  }
3716  prefixloopvar++;
3717  }
3718  g_strfreev(prefixtokens);
3719  }
3720  if(prefixmatch == TRUE)
3721  break;
3722  }
3723  loopvar++;
3724 
3725  }
3726  g_strfreev(tokens);
3727  if(prefixmatch == FALSE)
3728  {
3729  result=FALSE;
3730  g_message("No Matching ipv6 prefix in file %s",prefixfile);
3731  }
3732  }
3733  if(error)
3734  {
3735  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
3736  g_clear_error(&error);
3737  }
3738  g_free(prefixfile);
3739  return result;
3740 }
3741 
3742 /**
3743  * @brief This function is used to get the device name from /devicename/devicename file.
3744  *
3745  * @return Returns TRUE if successfully gets the device name string else returns FALSE.
3746  * @ingroup XUPNP_XCALDEV_FUNC
3747  */
3748 gboolean getdevicename(void)
3749 {
3750  GError *error=NULL;
3751  gboolean result = FALSE;
3752  gchar* devicenamefile = NULL;
3753  guint loopvar=0;
3754  gboolean devicenamematch = FALSE;
3755  if (devConf->deviceNameFile == NULL)
3756  {
3757  g_warning("device name file name not found in config");
3758  return result;
3759  }
3760  result = g_file_get_contents (devConf->deviceNameFile, &devicenamefile, NULL, &error);
3761  if (result == FALSE) {
3762  g_warning("Problem in reading /devicename/devicename file %s", error->message);
3763  }
3764  else
3765  {
3766  gchar **tokens = g_strsplit_set(devicenamefile,"'=''\n''\0'", -1);
3767  guint toklength = g_strv_length(tokens);
3768 
3769  while(loopvar < toklength)
3770  {
3771  if (g_strrstr(g_strstrip(tokens[loopvar]), "deviceName"))
3772  {
3773  result=TRUE;
3774  g_string_printf(devicename,"%s",g_strstrip(tokens[loopvar+1]));
3775  g_message("device name = %s",devicename->str);
3776  devicenamematch=TRUE;
3777 
3778  break;
3779  }
3780  loopvar++;
3781  }
3782  g_strfreev(tokens);
3783  if(devicenamematch == FALSE)
3784  {
3785  g_message("No Matching devicename in file %s",devicenamefile);
3786  }
3787  }
3788  if(error)
3789  {
3790  /* g_clear_error() frees the GError *error memory and reset pointer if set in above operation */
3791  g_clear_error(&error);
3792  }
3793  g_free(devicenamefile);
3794  return result;
3795 }
gettimezone
gboolean gettimezone(void)
This function is used to get the time zone. It gets the time zone information from the device configu...
Definition: xcal-device.c:2436
get_requirestrm_cb
G_MODULE_EXPORT void get_requirestrm_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getRequiresTRM action is invoked and this sets the state vari...
Definition: xcal-device.c:1107
query_usesdaylighttime_cb
G_MODULE_EXPORT void query_usesdaylighttime_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when UsesDaylightTime action is invoked and this sets the state va...
Definition: xcal-device.c:1595
get_hosts_cb
G_MODULE_EXPORT void get_hosts_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getHosts action is invoked and this sets the state variable f...
Definition: xcal-device.c:1070
get_devicename_cb
G_MODULE_EXPORT void get_devicename_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getDeviceName action is invoked and this sets the state varia...
Definition: xcal-device.c:1035
query_systemids_cb
G_MODULE_EXPORT void query_systemids_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when SystemIds action is invoked and this sets the state variable ...
Definition: xcal-device.c:1427
get_gwyipv6_cb
G_MODULE_EXPORT void get_gwyipv6_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getGatewayIPv6 action is invoked and this sets the state vari...
Definition: xcal-device.c:774
query_rui_url_cb
G_MODULE_EXPORT void query_rui_url_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when RuiUrl action is invoked and this sets the state variable wit...
Definition: xcal-device.c:1523
_IARM_Bus_SYSMgr_GetSystemStates_Param_t::channel_map
state_property channel_map
Definition: sysMgr.h:300
get_trm_url_cb
G_MODULE_EXPORT void get_trm_url_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getBaseTrmUrl action is invoked and this sets the state varia...
Definition: xcal-device.c:710
sysMgr.h
IARM-Bus Sys Manager Public API.
notify_value_change
void notify_value_change(const char *varname, const char *strvalue)
A generic function to notify all the clients whenever there is a change found in the service variable...
Definition: xcal-device.c:3324
getdevicename
gboolean getdevicename(void)
This function is used to get the device name from /devicename/devicename file.
Definition: xcal-device.c:3748
get_rui_url_cb
G_MODULE_EXPORT void get_rui_url_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when GetCompatibleUIs action is invoked and this sets the state va...
Definition: xcal-device.c:1124
query_hostmacaddress_cb
G_MODULE_EXPORT void query_hostmacaddress_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when HostMacAddress action is invoked and this sets the state vari...
Definition: xcal-device.c:1329
getetchosts
gboolean getetchosts(void)
This function is used to get the hosts IP information from hosts configuration file "/etc/hosts".
Definition: xcal-device.c:2573
IARM_BUS_SYSMGR_NAME
#define IARM_BUS_SYSMGR_NAME
Definition: sysMgr.h:110
_IARM_Bus_MFRLib_GetSerializedData_Param_t::buffer
char buffer[(1280)]
Definition: mfrMgr.h:120
query_hosts_cb
G_MODULE_EXPORT void query_hosts_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when Hosts action is invoked and this sets the state variable with...
Definition: xcal-device.c:1466
query_playback_url_cb
G_MODULE_EXPORT void query_playback_url_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when PlaybackUrl action is invoked and this sets the state variabl...
Definition: xcal-device.c:1190
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
getdnsconfig
gboolean getdnsconfig(void)
This function is used to get the DNS value from DNS mask configuration file.
Definition: xcal-device.c:2287
query_gwyip_cb
G_MODULE_EXPORT void query_gwyip_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when GatewayIP action is invoked and this sets the state variable ...
Definition: xcal-device.c:1257
get_eSTBMAC
GString * get_eSTBMAC(void)
This function is used to get the MAC address of the eSTB. It uses global hostmacaddress GString to ge...
Definition: xcal-device-library.c:2519
readconffile
gboolean readconffile(const char *configfile)
This function is used to retrieve the data from the device configuration file.
Definition: xcal-device.c:3111
query_url_cb
G_MODULE_EXPORT void query_url_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when getUrl action is invoked.
Definition: xcal-device.c:1154
query_dataGatewayIPaddress_cb
G_MODULE_EXPORT void query_dataGatewayIPaddress_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when DataGatewayIPaddress action is invoked and this sets the stat...
Definition: xcal-device.c:1219
_IARM_Bus_MFRLib_GetSerializedData_Param_t::bufLen
int bufLen
Definition: mfrMgr.h:121
notify_value_change_int
void notify_value_change_int(const char *varname, int intvalue)
Generic function to notify the change in the node value which are of integers type from the XML servi...
Definition: xcal-device.c:3351
get_playback_url_cb
G_MODULE_EXPORT void get_playback_url_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getPlaybackUrl action is invoked and this sets the state vari...
Definition: xcal-device.c:728
query_bcastmacaddress_cb
G_MODULE_EXPORT void query_bcastmacaddress_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when BcastMacAddress action is invoked and this sets the state var...
Definition: xcal-device.c:1347
IARM_Bus_RegisterEventHandler
IARM_Result_t IARM_Bus_RegisterEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler)
This API register to listen to event and provide the callback function for event notification....
Definition: iarmMgrMocks.cpp:43
query_devicename_cb
G_MODULE_EXPORT void query_devicename_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when DeviceName action is invoked and this sets the state variable...
Definition: xcal-device.c:1239
_STRING_MAP
Definition: xdevice-library-private.h:47
_IARM_Bus_SYSMgr_GetSystemStates_Param_t
Definition: sysMgr.h:299
readDevFile
gboolean readDevFile(const char *deviceFile)
This function is used to get partner ID.
Definition: xcal-device-library.c:385
IARM_Bus_RegisterCall
IARM_Result_t IARM_Bus_RegisterCall(const char *methodName, IARM_BusCall_t handler)
This API is used to register an RPC method that can be invoked by other applications.
getserialnum
gboolean getserialnum(GString *serial_num)
This function is used to get the serial number of the device from the vendor specific file.
Definition: xcal-device.c:2493
notify_timezone
void notify_timezone(void)
Generic function to notify the change in the time zone.
Definition: xcal-device.c:3640
get_gwystbip_cb
G_MODULE_EXPORT void get_gwystbip_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getGatewayStbIP action is invoked and this sets the state var...
Definition: xcal-device.c:793
get_usesdaylighttime_cb
G_MODULE_EXPORT void get_usesdaylighttime_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getUsesDaylightTime action is invoked and this sets the state...
Definition: xcal-device.c:1018
xdevice.h
The header file provides xcal devices APIs.
query_gwystbip_cb
G_MODULE_EXPORT void query_gwystbip_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when GatewayStbIP action is invoked and this sets the state variab...
Definition: xcal-device.c:1293
query_rawoffset_cb
G_MODULE_EXPORT void query_rawoffset_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when RawOffSet action is invoked and this sets the state variable ...
Definition: xcal-device.c:1541
_IARM_XDEVICE_NAME
#define _IARM_XDEVICE_NAME
Definition: xdevice.h:41
query_dnsconfig_cb
G_MODULE_EXPORT void query_dnsconfig_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when DnsConfig action is invoked and this sets the state variable ...
Definition: xcal-device.c:1409
getStrValueFromMap
static char * getStrValueFromMap(char *pszKey, int nPairs, STRING_MAP map[])
This function is used to get the IP address based on IPv6 or IPv4 is enabled.
Definition: xcal_device_library.c:288
open_document
xmlDoc * open_document(const char *file_name)
Supporting function for reading the XML file.
Definition: xcal-device.c:3076
query_ipv6prefix_cb
G_MODULE_EXPORT void query_ipv6prefix_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when Ipv6Prefix action is invoked and this sets the state variable...
Definition: xcal-device.c:1311
ConfSettings
Definition: xdevice-library-private.h:27
_IARM_BUS_SYSMgr_EventData_t
Definition: sysMgr.h:229
get_hostmacaddress_cb
G_MODULE_EXPORT void get_hostmacaddress_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getHostMacAddress action is invoked and this sets the state v...
Definition: xcal-device.c:830
is_num
gboolean is_num(const gchar *str)
Supporting function for checking the content of given string is numeric or not.
Definition: xcal-device-library.c:522
getmacaddress
gchar * getmacaddress(const gchar *ifname)
This function is used to get the mac address of the target device.
Definition: xcal-device.c:2253
_IARM_Bus_RouteSrvMgr_RouteData_Param_t
Definition: xdevice-library.h:127
get_url_cb
G_MODULE_EXPORT void get_url_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getBaseURL action is invoked and this sets the state variable...
Definition: xcal-device.c:689
updatexmldata
gboolean updatexmldata(const char *xmlfilename, const char *struuid, const char *serialno, const char *friendlyName)
This function is used to update the xml node values UDN, serialNumber and friendlyName.
Definition: xcal-device.c:3260
libIBus.h
RDK IARM-Bus API Declarations.
get_ipv6prefix_cb
G_MODULE_EXPORT void get_ipv6prefix_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getIpv6Prefix action is invoked and this sets the state varia...
Definition: xcal-device.c:812
query_recvdevtype_cb
G_MODULE_EXPORT void query_recvdevtype_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when RecvDevType action is invoked and this sets the state variabl...
Definition: xcal-device.c:1365
get_timezone_cb
G_MODULE_EXPORT void get_timezone_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when TimeZone action is invoked and this sets the state variable f...
Definition: xcal-device.c:964
updatesystemids
gboolean updatesystemids(void)
This function is used to update the system Ids such as channelMapId, controllerId,...
Definition: xcal-device.c:2351
query_buildversion_cb
G_MODULE_EXPORT void query_buildversion_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when BuildVersion action is invoked and this sets the state variab...
Definition: xcal-device.c:1391
query_dstsavings_cb
G_MODULE_EXPORT void query_dstsavings_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when DSTSavings action is invoked and this sets the state variable...
Definition: xcal-device.c:1577
query_gwyipv6_cb
G_MODULE_EXPORT void query_gwyipv6_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when Ipv6Prefix action is invoked and this sets the state variable...
Definition: xcal-device.c:1275
query_dstoffset_cb
G_MODULE_EXPORT void query_dstoffset_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when DSTOffset action is invoked and this sets the state variable ...
Definition: xcal-device.c:1559
getipaddress
int getipaddress(const char *ifname, char *ipAddressBuffer, gboolean ipv6Enabled)
This function is used to get the IP address based on IPv6 or IPv4 is enabled.
Definition: xcal-device.c:2188
IARM_BUS_MFRLIB_API_GetSerializedData
#define IARM_BUS_MFRLIB_API_GetSerializedData
Definition: mfrMgr.h:100
getidfromdiagfile
unsigned long getidfromdiagfile(const gchar *diagparam, const gchar *diagfilecontents)
This function is used to get the system Id information from the diagnostic file.
Definition: xcal-device.c:2408
get_buildversion_cb
G_MODULE_EXPORT void get_buildversion_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getBuildVersion action is invoked and this sets the state var...
Definition: xcal-device.c:892
get_systemids_cb
G_MODULE_EXPORT void get_systemids_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getSystemIds action is invoked and this sets the state variab...
Definition: xcal-device.c:928
IARM_BUS_MFRLIB_NAME
#define IARM_BUS_MFRLIB_NAME
Definition: mfrMgr.h:98
query_isgateway_cb
G_MODULE_EXPORT void query_isgateway_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when IsGateway action is invoked and this sets the state variable ...
Definition: xcal-device.c:1485
getID
GString * getID(const gchar *id)
This function is used to get the Receiver Id & Partner Id.
Definition: xcal-device.c:3425
getruiurl
gboolean getruiurl()
This function is used to get the RUI(Remote user interface) Url. It uses xdevice.conf file to get the...
Definition: xcal-device.c:2942
_IARM_Bus_MFRLib_GetSerializedData_Param_t
Definition: mfrMgr.h:118
set_content
int set_content(xmlDoc *doc, const char *node_name, const char *new_value)
This function is used to set new value to the given node from the xml file.
Definition: xcal-device.c:3026
query_trm_url_cb
G_MODULE_EXPORT void query_trm_url_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when TrmUrl action is invoked and this sets the state variable wit...
Definition: xcal-device.c:1172
TZStruct
Definition: xcal_device_library.c:126
get_dataGatewayIPaddress_cb
G_MODULE_EXPORT void get_dataGatewayIPaddress_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getdataGatewayIPaddress action is invoked and this sets the s...
Definition: xcal-device.c:947
_IARM_Bus_MFRLib_GetSerializedData_Param_t::type
mfrSerializedType_t type
Definition: mfrMgr.h:119
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
get_content
char * get_content(xmlDoc *doc, const char *node_name)
This function is used to get the value of the node from the xml file.
Definition: xcal-device.c:3054
xupnp_logger
void xupnp_logger(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
This function is used to log the messages of XUPnP applications. Each Log message will be written to ...
Definition: xcal-device.c:659
get_gwyip_cb
G_MODULE_EXPORT void get_gwyip_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getGatewayIP action is invoked and this sets the state variab...
Definition: xcal-device.c:756
is_alphanum
gboolean is_alphanum(const gchar *str)
Supporting function for checking the given string is alphanumeric.
Definition: xcal-device-library.c:1177
getipv6prefix
gboolean getipv6prefix(void)
This function is used to retrieve the IPv6 prefix information from dibblers file.
Definition: xcal-device.c:3666
get_dstsavings_cb
G_MODULE_EXPORT void get_dstsavings_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getDSTSavings action is invoked and this sets the state varia...
Definition: xcal-device.c:1001
_SysModeChange
static IARM_Result_t _SysModeChange(void *arg)
This function is a event handler which returns current system mode using IARM. It returns mode as "NO...
Definition: dsMgr.c:272
get_recvdevtype_cb
G_MODULE_EXPORT void get_recvdevtype_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getRecvDevType action is invoked and this sets the state vari...
Definition: xcal-device.c:866
get_rawoffset_cb
G_MODULE_EXPORT void get_rawoffset_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getRawOffSet action is invoked and this sets the state variab...
Definition: xcal-device.c:984
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38
get_bcastmacaddress_cb
G_MODULE_EXPORT void get_bcastmacaddress_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getBcastMacAddress action is invoked and this sets the state ...
Definition: xcal-device.c:848
TRUE
#define TRUE
Defines for TRUE/FALSE/ENABLE flags.
Definition: wifi_common_hal.h:199
_routeEventData_t
Definition: xdevice-library.h:121
get_dstoffset_cb
G_MODULE_EXPORT void get_dstoffset_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getDSTOffset action is invoked and this sets the state variab...
Definition: xcal-device.c:1053
query_requirestrm_cb
G_MODULE_EXPORT void query_requirestrm_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when RequiresTRM action is invoked and this sets the state variabl...
Definition: xcal-device.c:1504
get_isgateway_cb
G_MODULE_EXPORT void get_isgateway_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getIsGateway action is invoked and this sets the state variab...
Definition: xcal-device.c:1089
get_dnsconfig_cb
G_MODULE_EXPORT void get_dnsconfig_cb(GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
Callback function which is invoked when getDnsConfig action is invoked and this sets the state variab...
Definition: xcal-device.c:910
query_timezone_cb
G_MODULE_EXPORT void query_timezone_cb(GUPnPService *service, char *variable, GValue *value, gpointer user_data)
Callback function which is invoked when TimeZone action is invoked and this sets the state variable w...
Definition: xcal-device.c:1446
IARM_BUS_SYSMGR_API_GetSystemStates
#define IARM_BUS_SYSMGR_API_GetSystemStates
Definition: sysMgr.h:284