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