22 #include <xdevice_library.h>
23 #include <xdevice_library_private.h>
25 #include <libsoup/soup.h>
28 #include <sys/types.h>
30 #include <netinet/in.h>
31 #include <sys/ioctl.h>
34 #include <arpa/inet.h>
37 #include <libxml/tree.h>
38 #include <libxml/parser.h>
39 #include <glib/gstdio.h>
44 #ifdef CLIENT_XCAL_SERVER
47 #if defined(USE_XUPNP_IARM_BUS)
49 #include "libIARMCore.h"
51 #include "libIBusDaemon.h"
52 IARM_Bus_Daemon_SysMode_t sysModeParam;
54 #include "rdk_safeclib.h"
55 #include "secure_wrapper.h"
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"
70 #define DEVICE_PROPERTY_FILE "/etc/device.properties"
71 #define DEVICE_NAME_FILE "/opt/hn_service_settings.conf"
73 #define RUIURLSIZE 2048
74 #define MAX_OUTVALUE 256
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};
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)
94 #define COMCAST_PARTNET_KEY "comcast"
95 #define COX_PARTNET_KEY "cox"
96 #define ARRAY_COUNT(array) (sizeof(array)/sizeof(array[0]))
98 {COMCAST_PARTNET_KEY,
"comcast"},
99 {COX_PARTNET_KEY ,
"cox"},
104 {COMCAST_PARTNET_KEY,
"XFINITY"},
105 {COX_PARTNET_KEY ,
"Contour"},
110 {COMCAST_PARTNET_KEY,
"xfinity"},
111 {COX_PARTNET_KEY ,
"contour"},
114 {COMCAST_PARTNET_KEY,
"Comcast XFINITY Guide"},
115 {COX_PARTNET_KEY ,
"Cox Contour Guide"},
118 {COMCAST_PARTNET_KEY,
"Comcast XFINITY Guide application"},
119 {COX_PARTNET_KEY ,
"Cox Contour Guide application"},
122 {COMCAST_PARTNET_KEY,
"Comcast Gateway"},
123 {COX_PARTNET_KEY ,
"Cox Gateway"},
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}
148 xupnpEventCallback eventCallback;
150 static GString *get_uri_value();
152 void xupnpEventCallback_register(xupnpEventCallback callback_func)
154 eventCallback=callback_func;
157 void mapTimeZoneToJavaFormat(
char* payload)
160 int len =
sizeof(tzStruct)/
sizeof(
struct TZStruct );
162 for (; i < len; i++ )
164 if (g_strcmp0(tzStruct[i].inputTZ, payload) == 0)
167 g_string_assign(dsgtimezone, tzStruct[i].javaTZ);
172 rawOffset = tzStruct[i].rawOffset;
173 usesDaylightTime= tzStruct[i].usesDST;
185 if ((g_strcmp0(g_strstrip(dsgtimezone->str),
"US/Mountain") == 0) && (dstOffset == 0))
187 g_string_assign(dsgtimezone,
"US/Arizona");
188 g_message(
"XUPnP: changing timezone timezone= %s dst offset = %d \n",dsgtimezone->str,dstOffset);
190 else if ((g_strcmp0(g_strstrip(dsgtimezone->str),
"US/Central") == 0) && (dstOffset == 0))
192 g_string_assign(dsgtimezone,
"Canada/Saskatchewan");
193 g_message(
"XUPnP: changing timezone timezone= %s dst offset = %d \n",dsgtimezone->str,dstOffset);
200 (*eventCallback)(
"TimeZone", dsgtimezone->str);
205 #ifndef CLIENT_XCAL_SERVER
207 gboolean result = FALSE;
208 gchar* udhcpcvendorfile = NULL;
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);
218 gchar **tokens = g_strsplit_set(udhcpcvendorfile,
" \n\t\b\0", -1);
219 guint toklength = g_strv_length(tokens);
221 for (loopvar=0; loopvar<toklength; loopvar++)
224 if (g_strrstr(g_strstrip(tokens[loopvar]),
"SUBOPTION4"))
226 if ((loopvar+1) < toklength )
228 g_string_assign(serial_num, g_strstrip(tokens[loopvar+2]));
241 g_clear_error(&error);
248 IARM_Result_t iarmRet = IARM_RESULT_IPCCORE_FAIL;
250 rc = memset_s(¶m,
sizeof(param), 0,
sizeof(param));
252 param.
type = mfrSERIALIZED_TYPE_SERIALNUMBER;
254 if(iarmRet == IARM_RESULT_SUCCESS)
258 g_message(
" serialized data %s \n",param.
buffer );
259 g_string_assign(serial_num,param.
buffer);
264 g_message(
" serialized data is empty \n" );
271 g_message(
"IARM CALL failed for mfrtype \n");
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;
296 return map[0].pszValue;
310 gboolean result = FALSE;
311 gchar* devfilebuffer = NULL;
314 if (deviceFile == NULL)
316 g_message(
"device properties file not found");
320 result = g_file_get_contents (deviceFile, &devfilebuffer, NULL, &error);
323 g_message(
"No contents in device properties");
329 gchar **tokens = g_strsplit_set(devfilebuffer,
",='\n'", -1);
330 guint toklength = g_strv_length(tokens);
332 for (loopvar=0; loopvar<toklength; loopvar++)
334 if (g_strrstr(g_strstrip(tokens[loopvar]),
"DEVICE_TYPE"))
336 if ((loopvar+1) < toklength )
339 g_string_assign(recvdevtype, g_strstrip(tokens[loopvar+1]));
347 else if(g_strrstr(g_strstrip(tokens[loopvar]),
"BUILD_VERSION"))
349 if ((loopvar+1) < toklength )
352 g_string_assign(buildversion, g_strstrip(tokens[loopvar+1]));
360 else if(g_strrstr(g_strstrip(tokens[loopvar]),
"BOX_TYPE"))
362 if ((loopvar+1) < toklength )
365 g_string_assign(devicetype, g_strstrip(tokens[loopvar+1]));
373 if (g_strrstr(g_strstrip(tokens[loopvar]),
"MOCA_INTERFACE"))
375 if ((loopvar+1) < toklength )
378 g_string_assign(mocaIface, g_strstrip(tokens[loopvar+1]));
386 if (g_strrstr(g_strstrip(tokens[loopvar]),
"WIFI_INTERFACE"))
388 if ((loopvar+1) < toklength )
391 g_string_assign(wifiIface, g_strstrip(tokens[loopvar+1]));
399 if (g_strrstr(g_strstrip(tokens[loopvar]),
"MODEL_NUM"))
401 if ((loopvar+1) < toklength )
404 g_string_assign(modelnumber, g_strstrip(tokens[loopvar+1]));
412 if (g_strrstr(g_strstrip(tokens[loopvar]),
"MFG_NAME"))
414 if ((loopvar+1) < toklength )
417 g_string_assign(make, g_strstrip(tokens[loopvar+1]));
432 g_message(
"RECEIVER_DEVICETYPE and BUILD_VERSION not found in %s",deviceFile);
438 g_clear_error(&error);
448 RFC_ParamData_t param = {0};
451 WDMP_STATUS status = getRFCParameter(
"XUPNP",
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.UPnPxPKI.Enable",¶m);
453 if (status == WDMP_SUCCESS)
455 rc = strcmp_s(param.value,
sizeof(param.value),
"true",&ind);
456 if ((ind == 0) && (rc == EOK))
458 g_message(
"New Device xPKI rfc_enabled and xcal is running with new certs");
463 g_message(
"Running xcal-device with old certs");
468 g_message(
"getRFCParameter Failed : %s\n", getRFCErrorString(status));
471 g_message(
"Not built with RFC support.");
479 RFC_ParamData_t param = {0};
481 WDMP_STATUS status = getRFCParameter(
"XUPNP",
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.UPnP.Refactor.Enable",¶m);
483 if (status == WDMP_SUCCESS)
485 if (!strncmp(param.value,
"true", strlen(
"true")))
487 g_message(
"New Device Refactoring rfc_enabled");
492 g_message(
"Running older xcal");
497 g_message(
"getRFCParameter Failed : %s\n", getRFCErrorString(status));
500 g_message(
"Not built with RFC support.");
505 static GString *get_compatible_uis_icon(
int nSize,
int nDepth,
const char * pszImageType,
const char * pszImageExt)
507 GString * icon = g_string_new(NULL);
508 g_string_printf(icon,
510 "<mimetype>image/%s</mimetype>"
512 "<height>%d</height>"
513 "<depth>%d</depth> <url>http://syndeo.xcal.tv/app/x2rui/dlna/%s/%s_%d.%s</url>"
528 static GString *get_compatible_uis_icon_list()
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");
535 GString * iconList = g_string_new(NULL);
536 g_string_printf(iconList,
549 g_string_free(icon1,
TRUE);
550 g_string_free(icon2,
TRUE);
551 g_string_free(icon3,
TRUE);
552 g_string_free(icon4,
TRUE);
565 gboolean
is_num(
const gchar *str)
569 gboolean isnum =
TRUE;
570 for (i = 0; i < strlen(str); i++) {
571 if (!g_ascii_isdigit(str[i])) {
579 #if defined(USE_XUPNP_IARM_BUS)
590 BOOL getRouteData(
void)
593 IARM_Result_t iarmRet = IARM_RESULT_IPCCORE_FAIL;
595 param.status =
false;
596 rc = memset_s(¶m,
sizeof(param), 0,
sizeof(param));
599 IARM_BUS_ROUTE_MGR_API_getCurrentRouteData, ¶m,
sizeof(param));
600 if (iarmRet == IARM_RESULT_SUCCESS )
603 g_string_assign(dataGatewayIPaddress, param.route.routeIp);
604 g_message(
"getRouteData: route IP for the device %s ",
605 dataGatewayIPaddress->str);
608 g_message(
"route data not available");
614 g_message(
"IARM failure in getting route data");
631 void getSystemValues(
void)
635 ¶m,
sizeof(param));
639 channelmap_id = strtoul(param.
channel_map.payload, NULL, 10);
640 g_message(
"Channel map id available. Value %lu", channelmap_id);
643 if (param.dac_id.state == 2) {
644 if (strlen(param.dac_id.payload) > 0
646 dac_id = strtoul(param.dac_id.payload, NULL, 10);
647 g_message(
"dac id available. Value %lu", dac_id);
650 if (param.plant_id.state == 2) {
651 if (strlen(param.plant_id.payload) > 0
653 plant_id = strtoul(param.plant_id.payload, NULL, 10);
654 g_message(
"plant id available. Value %lu", plant_id);
657 if (param.vod_ad.state == 2) {
658 if (strlen(param.vod_ad.payload) > 0
660 vodserver_id = strtoul(param.vod_ad.payload, NULL, 10);
661 g_message(
"vod ad available. Value %lu", vodserver_id);
664 if (param.time_zone_available.state == 2) {
665 if (strlen(param.time_zone_available.payload) > 0
667 g_message(
"Timezone is available. Value %s",
668 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);
675 if (param.dst_offset.state == 2) {
676 if (strlen(param.dst_offset.payload) > 0) {
677 dstOffset = atoi(param.dst_offset.payload);
679 dstSavings = (dstOffset * 60000);
680 g_message(
"dstSavings: %d", dstSavings);
681 if (g_strcmp0(g_strstrip(dsgtimezone->str), NULL) != 0) {
685 if (tune_ready != param.TuneReadyStatus.state) {
686 tune_ready = param.TuneReadyStatus.state;
688 (*eventCallback)(
"PlaybackUrl", playbackurl->str);
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);
695 g_message(
"Serial no is NULL\n");
712 #if defined(USE_XUPNP_IARM_BUS)
723 static void _sysEventHandler(
const char *owner, IARM_EventId_t eventId,
724 void *data,
size_t len)
736 if ((eventId != IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE)
737 || (ind != 0) || (rc != EOK))
743 IARM_Bus_SYSMgr_SystemState_t stateId =
744 sysEventData->data.systemStates.stateId;
746 case IARM_BUS_SYSMGR_SYSSTATE_TUNEREADY:
747 if ( sysEventData != NULL)
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) {
754 g_message(
" Start publishing %d ", tune_ready);
755 if (devConf->useGliDiag == FALSE) {
757 (*eventCallback)(
"SystemIds", systemids->str);
759 (*eventCallback)(
"PlaybackUrl", playbackurl->str);
762 g_message(
" Stop publishing %d ", tune_ready);
765 if (devConf->useGliDiag == FALSE) {
767 (*eventCallback)(
"SystemIds", systemids->str);
769 (*eventCallback)(
"PlaybackUrl", playbackurl->str);
771 g_message(
"Tune Ready Update Received: %d", tune_ready);
775 case IARM_BUS_SYSMGR_SYSSTATE_STB_SERIAL_NO:
776 if(sysEventData != NULL)
778 g_string_assign(serial_num, sysEventData->data.systemStates.payload);
779 g_message(
"Serial Number Update Received: %s", serial_num->str);
782 case IARM_BUS_SYSMGR_SYSSTATE_CHANNELMAP:
783 if(sysEventData != NULL)
785 g_message(
"Received channel map update");
786 if (sysEventData->data.systemStates.error) {
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);
795 g_message(
"Received channel map id: %lu", channelmap_id);
797 (*eventCallback)(
"SystemIds", systemids->str);
802 case IARM_BUS_SYSMGR_SYSSTATE_DAC_ID:
803 g_message(
"Received controller id update");
804 if(sysEventData != NULL)
806 if (sysEventData->data.systemStates.error) {
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);
815 g_message(
"Received controller id: %lu", dac_id);
817 (*eventCallback)(
"SystemIds", systemids->str);
822 case IARM_BUS_SYSMGR_SYSSTATE_PLANT_ID:
823 if( sysEventData != NULL)
825 g_message(
"Received plant id update");
826 if (sysEventData->data.systemStates.error) {
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);
835 g_message(
"Received plant id: %lu", plant_id);
837 (*eventCallback)(
"SystemIds", systemids->str);
842 case IARM_BUS_SYSMGR_SYSSTATE_VOD_AD:
843 if(sysEventData != NULL)
845 g_message(
"Received vod server id update");
846 if (sysEventData->data.systemStates.error) {
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);
855 g_message(
"Received vod server id: %lu", vodserver_id);
857 (*eventCallback)(
"SystemIds", systemids->str);
862 case IARM_BUS_SYSMGR_SYSSTATE_TIME_ZONE:
863 if(sysEventData != NULL)
865 g_message(
"Received timezone update");
866 if (sysEventData->data.systemStates.error) {
868 g_message(
"Time zone error");
869 }
else if (sysEventData->data.systemStates.state == 2) {
870 if ((strlen(sysEventData->data.systemStates.payload) > 1))
874 mapTimeZoneToJavaFormat ((
char *)sysEventData->data.systemStates.payload);
876 g_message(
"Received dsgtimezone: %s", dsgtimezone->str);
877 g_message(
"Received rawOffset: %d", rawOffset);
882 case IARM_BUS_SYSMGR_SYSSTATE_DST_OFFSET :
883 if( sysEventData != NULL)
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) {
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;
932 static void _routesysEventHandler(
const char *owner, IARM_EventId_t eventId,
933 void *data,
size_t len)
937 rc = strcmp_s(IARM_BUS_NM_SRV_MGR_NAME,strlen(IARM_BUS_NM_SRV_MGR_NAME),owner,&ind);
939 if ((!ind) && (rc == EOK))
942 case IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_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);
950 g_message(
"same route is send %s %s ", param->routeIp,
951 dataGatewayIPaddress->str);
953 g_message(
" route ip is empty");
968 BOOL XUPnP_IARM_Init(
void)
970 g_message(
"<<<<< Iniializing IARM XUPnP >>>>>>>>");
972 g_message(
"<<<<<<<%s - Failed in IARM Bus IARM_Bus_Init>>>>>>>>",
976 g_message(
"<<<<<<<%s Failed in IARM_Bus_Connect>>>>>>>>", __FUNCTION__);
980 IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE, _sysEventHandler);
982 IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA, _routesysEventHandler);
983 g_message(
"<<<<<<<%s - Registered the SYSMGR BUS Events >>>>>>>>",
986 g_message(
"<<<<<<<%s - Registering Callback for Warehouse Mode Check >>>>>>>>",
1012 BOOL check_null(
char *str)
1031 BOOL result = FALSE;
1033 if ((!check_null(gwyip->str)) || (!check_null(outValue)) || (!check_null(recv_id->str))) {
1034 g_message(
"getBaseUrl : NULL string !");
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);
1053 BOOL getPlaybackUrl(
char *outValue)
1055 BOOL result = FALSE;
1057 if (!check_null(playbackurl->str)){
1058 g_message(
"getPlaybackUrl: NULL string !");
1063 rc = strcpy_s(outValue,URLSIZE, playbackurl->str);
1080 BOOL getDisableTuneReadyStatus()
1082 return devConf->disableTuneReady;
1096 BOOL result = FALSE;
1098 if (!check_null(outValue)) {
1099 g_message(
"getIpv6Prefix : NULL string !");
1102 if ((
parseipv6prefix()) || ((ipv6prefix->str != NULL) && (ipv6prefix->str[0] ==
'\0'))) {
1103 rc = strcpy_s(outValue,MAX_OUTVALUE,ipv6prefix->str);
1113 g_message(
"getIpv6Prefix : No ipv6 prefix !");
1118 BOOL getIpSubnet(
char *outValue)
1120 BOOL result = FALSE;
1122 if (!check_null(outValue)) {
1123 g_message(
"getIpSubnet : NULL string !");
1126 rc = strcpy_s(outValue,MAX_OUTVALUE,
"");
1151 BOOL result = FALSE;
1153 if (!check_null(outValue)) {
1154 g_message(
"getDeviceName : NULL string !");
1158 rc = strcpy_s(outValue,MAX_OUTVALUE,devicename->str);
1168 g_message(
"getDeviceName : No Device Name !");
1184 BOOL result = FALSE;
1186 if ((!check_null(devicetype->str)) || (!check_null(outValue))) {
1187 g_message(
"getDeviceType : NULL string !");
1191 rc = strcpy_s(outValue,MAX_OUTVALUE,devicetype->str);
1201 g_message(
"getDeviceType : No device type availabel\n");
1217 BOOL result = FALSE;
1219 if (!check_null(outValue)) {
1220 g_message(
"getBcastMacAddress : NULL string !");
1223 if (devConf->bcastIf != NULL ) {
1224 const gchar *bcastmac = (gchar *)
getmacaddress(devConf->bcastIf);
1226 g_message(
"Broadcast MAC address in interface: %s %s \n", devConf->bcastIf,
1229 g_message(
"failed to retrieve macaddress on interface %s ", devConf->bcastIf);
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);
1244 g_message(
"getBcastMacAddress : Could not get BcastMacaddress\n");
1261 BOOL result = FALSE;
1263 if ((!check_null(gwystbip->str)) || (!check_null(outValue))) {
1264 g_message(
"getGatewayStbIp : NULL string !");
1267 #ifndef CLIENT_XCAL_SERVER
1269 rc = strcpy_s(outValue,MAX_OUTVALUE,gwystbip->str);
1279 g_message(
"getGatewayStbIp : Could not get gatewayStbIp\n");
1296 BOOL result = FALSE;
1298 if ((!check_null(gwyipv6->str)) || (!check_null(outValue))) {
1299 g_message(
"getGatewayIpv6 : NULL string !");
1302 #ifndef CLIENT_XCAL_SERVER
1304 rc = strcpy_s(outValue,MAX_OUTVALUE,gwyipv6->str);
1314 g_message(
"getGatewayIpv6 : Could not get GatewayIpv6\n");
1331 BOOL result = FALSE;
1333 if ((!check_null(gwyip->str)) || (!check_null(outValue))) {
1334 g_message(
"getGatewayIp : NULL string !");
1338 rc = strcpy_s(outValue,MAX_OUTVALUE,gwyip->str);
1348 g_message(
"getGatewayIp : Could not get gatewayIp\n");
1364 BOOL result = FALSE;
1366 if ((!check_null(recvdevtype->str)) || (!check_null(outValue))) {
1367 g_message(
"getRecvDevType : NULL string !");
1372 rc = strcpy_s(outValue,MAX_OUTVALUE,recvdevtype->str);
1382 g_message(
"getRecvDevType : Could not get receiver DeciveType\n");
1386 BOOL getBuildVersion(
char *outValue)
1388 BOOL result = FALSE;
1390 if ((!check_null(buildversion->str)) || (!check_null(outValue))) {
1391 g_message(
"getBuildVersion : NULL string !");
1395 rc = strcpy_s(outValue,MAX_OUTVALUE,buildversion->str);
1405 g_message(
"getBuildVersion : Could not get Build Version\n");
1409 BOOL getHostMacAddress(
char *outValue)
1411 BOOL result = FALSE;
1413 if (!(check_null(hostmacaddress->str)) || (!check_null(outValue))) {
1414 g_message(
"getHostMacAddress : NULL string !");
1417 #ifndef CLIENT_XCAL_SERVER
1418 if (devConf->hostMacIf != NULL) {
1419 const gchar *hostmac = (gchar *)
getmacaddress(devConf->hostMacIf);
1421 g_message(
"MAC address in interface: %s %s \n", devConf->hostMacIf, hostmac);
1423 g_message(
"failed to retrieve macaddress on interface %s ",
1424 devConf->hostMacIf);
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);
1438 g_message(
"getHostMacAddress : Could not get host mac address\n");
1443 BOOL getDnsConfig(
char *outValue)
1445 BOOL result = FALSE;
1447 if (!check_null(outValue)) {
1448 g_message(
"getDnsConfig : NULL string !");
1452 rc = strcpy_s(outValue,MAX_OUTVALUE,dnsconfig->str);
1462 g_message(
"getDnsConfig : no dns config !");
1466 BOOL getSystemsIds(
char *outValue)
1469 BOOL result = FALSE;
1470 if ((!check_null(systemids->str)) || (!check_null(outValue))) {
1471 g_message(
"getSystemsIds : NULL string !");
1476 rc = strcpy_s(outValue,MAX_OUTVALUE, systemids->str);
1491 g_message(
"getSystemsIds : No systemIds \n");
1498 gboolean result = FALSE;
1499 gchar* dsgproxyfile = NULL;
1501 if (devConf->dsgFile == NULL)
1503 g_warning(
"dsg file name not found in config");
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);
1514 gchar **tokens = g_strsplit_set(dsgproxyfile,
",=", -1);
1515 guint toklength = g_strv_length(tokens);
1517 for (loopvar=0; loopvar<toklength; loopvar++)
1520 if (g_strrstr(g_strstrip(tokens[loopvar]),
"DSGPROXY_HOST_TIME_ZONE"))
1522 if ((loopvar+1) < toklength )
1524 g_string_assign(dsgtimezone, g_strstrip(tokens[loopvar+1]));
1538 g_clear_error(&error);
1544 BOOL getTimeZone(
char *outValue)
1546 BOOL result = FALSE;
1548 if ((!check_null(dsgtimezone->str)) || (!check_null(outValue))) {
1549 g_message(
"getTimeZone : NULL string !");
1553 rc = strcpy_s(outValue,MAX_OUTVALUE,dsgtimezone->str);
1563 g_message(
"getTimeZone : No Timezone data\n");
1567 BOOL getRawOffSet(
int *outValue)
1569 *outValue = rawOffset;
1572 BOOL getDstOffset(
int *outValue)
1574 *outValue = dstOffset;
1577 BOOL getDstSavings(
int *outValue)
1579 *outValue = dstSavings;
1582 BOOL getUsesDayLightTime(BOOL *outValue)
1584 *outValue = usesDaylightTime;
1587 BOOL getIsGateway(BOOL *outValue)
1589 *outValue = devConf->allowGwy;
1592 BOOL getHosts(
char *outValue)
1594 BOOL result = FALSE;
1596 if (!check_null(outValue)) {
1597 g_message(
"getHosts : NULL string !");
1601 rc = strcpy_s(outValue,RUIURLSIZE,etchosts->str);
1611 g_message(
"getHosts : No Hosts Data available !");
1615 BOOL getRequiresTRM(BOOL *outValue)
1617 *outValue = requirestrm;
1620 BOOL getBcastPort(
int *outValue)
1622 *outValue = devConf->bcastPort;
1625 BOOL getBcastIp(
char *outValue)
1627 BOOL result = FALSE;
1629 if ((!check_null(gwyip->str)) || (!check_null(outValue))) {
1630 g_message(
"getBcastIp : NULL string !");
1634 rc = strcpy_s(outValue,MAX_OUTVALUE,gwyip->str);
1644 g_message(
"getBcastIp : No BcastIp found\n");
1648 BOOL getBcastIf(
char *outValue)
1651 BOOL result = FALSE;
1652 if (!check_null(outValue)) {
1653 g_message(
"getBcastIf : NULL string !");
1656 if(check_null(devConf->bcastIf)) {
1657 rc = strcpy_s(outValue,MAX_OUTVALUE,devConf->bcastIf);
1668 g_message(
"getBcastIf : No Bcast Interface found !");
1671 BOOL getRUIUrl(
char *outValue)
1674 if (!check_null(outValue)) {
1675 g_message(
"getPartnerId : NULL string !");
1678 if ( ruiurl->str != NULL ) {
1679 g_string_free( ruiurl,
TRUE);
1681 if (devConf->ruiPath != NULL) {
1682 g_print(
"getruiurl using xdevice.conf RuiPath=value\n");
1683 ruiurl = g_string_new(g_strconcat(devConf->ruiPath, NULL));
1685 GString *urivalue = get_uri_value();
1686 GString *iconlist = get_compatible_uis_icon_list();
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\">"
1694 "<uiID>1234-9876-1265-8758</uiID>"
1696 "<description>%s</description>"
1699 "<lifetime>-1</lifetime>"
1700 "<protocol shortName=\"DLNA-HTML5-1.0\">"
1708 getServiceDescription(),
1712 g_string_free(urivalue,
TRUE);
1713 g_string_free(iconlist,
TRUE);
1715 rc = strcpy_s(outValue,RUIURLSIZE,ruiurl->str);
1716 g_print(
"ruiurl string from getruiurl(): = %s\n",ruiurl->str);
1727 BOOL getSerialNum(
char *outValue)
1730 BOOL result = FALSE;
1731 if (!check_null(outValue)) {
1732 g_message(
"getSerialNum : NULL string !");
1736 rc = strcpy_s(outValue,MAX_OUTVALUE,serial_num->str);
1746 g_message(
"getSerialNum : No Serial Number Available !");
1750 BOOL getPartnerId(
char *outValue)
1752 BOOL result = FALSE;
1754 if (!check_null(outValue)) {
1755 g_message(
"getPartnerId : NULL string !");
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);
1770 g_message(
"getPartnerId : No partner Id found\n");
1775 BOOL getUUID(
char *outValue)
1777 BOOL result = FALSE;
1778 if (!check_null(outValue)) {
1779 g_message(
"getUUID : NULL string !");
1783 sprintf(outValue,
"uuid:%s", recv_id->str);
1788 g_message(
"getUUID : No recv_id for uuid available\n");
1792 BOOL getReceiverId(
char *outValue)
1794 BOOL result = FALSE;
1796 if (!check_null(outValue)) {
1797 g_message(
"getReceiverId : NULL string !");
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);
1812 g_message(
"getReceiverId : No recveiverId found\n");
1816 BOOL getTrmUrl(
char *outValue)
1818 BOOL result = FALSE;
1820 if (!check_null(outValue)) {
1821 g_message(
"getTrmUrl : NULL string !");
1825 rc =strcpy_s(outValue,MAX_OUTVALUE,trmurl->str);
1835 g_message(
"getTrmUrl : No trmurl found\n");
1839 BOOL getIsuseGliDiagEnabled()
1841 return devConf->useGliDiag;
1843 #ifndef CLIENT_XCAL_SERVER
1844 BOOL getCVPIp(
char *outValue)
1847 if (!check_null(outValue)) {
1848 g_message(
"getCVPIp : NULL string !");
1851 ipAddressBuffer[0] =
'\0';
1852 int result =
getipaddress(devConf->cvpIf, ipAddressBuffer, FALSE);
1854 fprintf(stderr,
"Could not locate the ipaddress of CVP2 interface %s\n",
1858 g_message(
"ipaddress of the CVP2 interface %s\n", ipAddressBuffer);
1859 rc = strcpy_s(outValue,MAX_OUTVALUE,ipAddressBuffer);
1871 BOOL getCVPIf(
char *outValue)
1873 BOOL result = FALSE;
1875 if (!check_null(outValue)) {
1876 g_message(
"getCVPIf : NULL string !");
1880 rc =strcpy_s(outValue,MAX_OUTVALUE,devConf->cvpIf);
1892 g_message(
"getCVPIf : Failed to get the CVP Interface\n");
1896 BOOL getCVPPort(
int *outValue)
1898 BOOL result = FALSE;
1899 if (!check_null((
char *)outValue)) {
1900 g_message(
"getCVPPort : NULL string !");
1905 *outValue = devConf->cvpPort;
1910 BOOL getCVPXmlFile(
char *outValue)
1913 BOOL result = FALSE;
1914 if (!check_null(outValue)) {
1915 g_message(
"getCVPXmlFile : NULL string !");
1919 rc = strcpy_s(outValue,MAX_OUTVALUE,devConf->cvpXmlFile);
1931 g_message(
"getCVPXmlFile : Failed to get the CVP XmlFile\n");
1936 BOOL getRouteDataGateway(
char *outValue)
1938 BOOL result = FALSE;
1940 if (!check_null(outValue)) {
1941 g_message(
"getRouteDataGateway : NULL string !");
1944 if (getRouteData()) {
1945 rc =strcpy_s(outValue,MAX_OUTVALUE,dataGatewayIPaddress->str);
1955 g_message(
"getRouteDataGateway : error getting route data!");
1958 BOOL getLogFile(
char *outValue)
1960 BOOL result = FALSE;
1962 if (!check_null(outValue)) {
1963 g_message(
"getLogFile : NULL string !");
1967 rc = strcpy_s(outValue,MAX_OUTVALUE,devConf->logFile);
1977 g_message(
"getLogFile : Config doesnt have a log file !");
1980 BOOL getEstbMacAddr(
char *outValue)
1982 BOOL result = FALSE;
1984 #ifndef CLIENT_XCAL_SERVER
1985 if ((!check_null(devConf->hostMacIf)) || (!check_null(outValue))) {
1986 g_message(
"getEstbMacAddr : NULL string !");
1990 const gchar *hostmac = (gchar *)
getmacaddress(devConf->hostMacIf);
1992 g_message(
"MAC address in interface: %s %s \n", devConf->hostMacIf, hostmac);
1993 g_string_assign(hostmacaddress, hostmac);
1996 g_message(
"failed to retrieve macaddress on interface %s ",
1997 devConf->hostMacIf);
2001 rc = strcpy_s(outValue,MAX_OUTVALUE, hostmacaddress->str);
2010 g_message(
"Host mac address is %s", hostmacaddress->str);
2014 BOOL getDevXmlPath(
char *outValue)
2016 BOOL result = FALSE;
2018 if ((!check_null(devConf->devXmlPath)) || (!check_null(outValue))) {
2019 g_message(
"getDevXmlPath : NULL string !");
2022 if (check_null(devConf->devXmlPath)) {
2023 rc = strcpy_s(outValue,MAX_OUTVALUE,devConf->devXmlPath);
2033 g_message(
"getDevXmlPath : config has empty xml path !");
2037 BOOL getDevXmlFile(
char *outValue,
int refactor)
2039 BOOL result = FALSE;
2040 if ((!check_null(devConf->devXmlFile)) || (!check_null(outValue))) {
2041 g_message(
"getDevXmlFile : NULL string !");
2047 sprintf(outValue,
"%s/%s", devConf->devXmlPath, devConf->devXmlFile);
2050 g_message(
"getDevXmlFile : config has empty xml file !");
2054 #ifndef CLIENT_XCAL_SERVER
2055 sprintf(outValue,
"%s/%s", devConf->devXmlPath,GW_DEVICE_XML_FILE);
2057 sprintf(outValue,
"%s/%s", devConf->devXmlPath,CLIENT_DEVICE_XML_FILE);
2060 g_message(
"getDevXmlFile : refactor path=%s",outValue);
2065 BOOL getDevKeyPath(
char *outValue)
2067 BOOL result = FALSE;
2068 if ((!check_null(devConf->devKeyPath)) || (!check_null(outValue))) {
2069 g_message(
"getDevKeyPath: NULL string !");
2073 strncpy(outValue,devConf->devKeyPath, MAX_FILE_LENGTH);
2076 g_message(
"getDevKeyPath : config has empty key path !");
2080 BOOL getDevKeyFile(
char *outValue)
2082 BOOL result = FALSE;
2083 if ((!check_null(devConf->devKeyFile)) || (!check_null(outValue))) {
2084 g_message(
"getDevKeyFile : NULL string !");
2088 strncpy(outValue,devConf->devKeyFile, MAX_FILE_LENGTH);
2091 g_message(
"getDevKeyFile : config has empty key file !");
2095 BOOL getDevCertPath(
char *outValue)
2097 BOOL result = FALSE;
2098 if ((!check_null(devConf->devCertPath)) || (!check_null(outValue))) {
2099 g_message(
"getDevCertPath: NULL string !");
2103 strncpy(outValue,devConf->devCertPath, MAX_FILE_LENGTH);
2106 g_message(
"getDevCertPath: config has empty path!");
2111 BOOL getDevCertFile(
char *outValue)
2113 BOOL result = FALSE;
2114 if ((!check_null(devConf->devCertFile)) || (!check_null(outValue))) {
2115 g_message(
"getDevCertFile: NULL string !");
2119 strncpy(outValue,devConf->devCertFile,MAX_FILE_LENGTH);
2122 g_message(
"getDevCertFile: config has empty file !");
2126 BOOL getModelNumber(
char *outValue)
2128 BOOL result = FALSE;
2130 if ((!check_null(modelnumber->str)) || (!check_null(outValue))) {
2131 g_message(
"getModelNumber : NULL string !");
2135 rc = strcpy_s(outValue,MAX_OUTVALUE,modelnumber->str);
2144 g_message(
"getModelNumber : %s",modelnumber->str);
2147 g_message(
"getModelNumber : config has empty modelnumber file !");
2151 BOOL getMake(
char *outValue)
2153 BOOL result = FALSE;
2155 if ((!check_null(make->str)) || (!check_null(outValue))) {
2156 g_message(
"getMake : NULL string !");
2160 rc = strcpy_s(outValue,MAX_OUTVALUE,make->str);
2170 g_message(
"getMake : config has empty device make file !");
2173 BOOL getAccountId(
char *outValue)
2175 BOOL result = FALSE;
2179 RFC_ParamData_t param = {0};
2181 WDMP_STATUS status = getRFCParameter(
"XUPNP",
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID",¶m);
2183 if (status == WDMP_SUCCESS)
2185 if ((!check_null(param.value)))
2187 g_message(
"getAccountId : NULL string !");
2192 rc = strcpy_s(outValue,MAX_OUTVALUE,param.value);
2205 g_message(
"getAccountId: getRFCParameter Failed : %s\n", getRFCErrorString(status));
2208 g_message(
"Not built with RFC support.");
2213 BOOL checkCVP2Enabled()
2215 return devConf->enableCVP2;
2230 gboolean isalphanum =
TRUE;
2231 for (i = 0; i < strlen(str); i++) {
2232 if (!g_ascii_isalnum(str[i])) {
2249 gboolean result = FALSE;
2250 gchar* prefixfile = NULL;
2252 guint prefixloopvar=0;
2253 gboolean ifacematch = FALSE;
2254 gboolean prefixmatch = FALSE;
2255 gchar **prefixtokens;
2256 if (devConf->ipv6PrefixFile == NULL)
2258 g_warning(
"ipv6PrefixFile file name not found in config");
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);
2267 gchar **tokens = g_strsplit_set(prefixfile,
"'\n''\0'", -1);
2268 guint toklength = g_strv_length(tokens);
2270 while(loopvar < toklength)
2272 if(ifacematch==FALSE)
2274 if ((g_strrstr(g_strstrip(tokens[loopvar]),
"ifacename")) && (g_strrstr(g_strstrip(tokens[loopvar]), devConf->hostMacIf)))
2281 if(g_strrstr(g_strstrip(tokens[loopvar]),
"AddrPrefix"))
2283 prefixtokens = g_strsplit_set(tokens[loopvar],
"'<''>''='", -1);
2284 guint prefixtoklength = g_strv_length(prefixtokens);
2285 while(prefixloopvar<prefixtoklength)
2287 if(g_strrstr(g_strstrip(prefixtokens[prefixloopvar]),
"/AddrPrefix"))
2292 g_string_printf(ipv6prefix,
"%s",prefixtokens[prefixloopvar-1]);
2293 g_message(
"ipv6 prefix format in the file %s",prefixtokens[prefixloopvar-1]);
2298 g_strfreev(prefixtokens);
2300 if(prefixmatch ==
TRUE)
2307 if(prefixmatch == FALSE)
2310 g_message(
"No Matching ipv6 prefix in file %s",prefixfile);
2316 g_clear_error(&error);
2322 BOOL xdeviceInit(
char *devConfFile,
char *devLogFile)
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;
2342 service_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);
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");
2370 #ifndef CLIENT_XCAL_SERVER
2373 g_message(
"Unable to find xdevice config, giving up\n");
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;
2406 if (check_null(devLogFile)) {
2407 logoutfile = g_fopen (devLogFile,
"a");
2409 #ifdef ENABLE_LOGFILE
2410 else if (devConf->logFile) {
2411 logoutfile = g_fopen (devConf->logFile,
"a");
2415 g_message(
"xupnp not handling the logging");
2417 if (devConf->devPropertyFile != NULL) {
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,
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,
2430 int loop,result,assigned=0;
2431 for(loop=0;loop<10;loop++)
2433 #ifndef CLIENT_XCAL_SERVER
2434 if ( access(devConf->ipv6FileLocation, F_OK ) != -1 ){
2440 "In Ipv6 Could not locate the link local ipv6 address of the broadcast interface %s\n",
2442 g_critical(
"In Ipv6 Could not locate the link local ipv6 address of the broadcast interface %s\n",
2447 g_message(
"ipaddress of the interface %s", ipAddressBuffer);
2449 g_string_assign(gwyipv6, ipAddressBuffer);
2450 ipAddressBuffer[0] =
'\0';
2451 result =
getipaddress(devConf->bcastIf, ipAddressBuffer, FALSE);
2454 "Could not locate the link local v4 ipaddress of the broadcast interface %s\n",
2456 g_critical(
"Could not locate the link local v4 ipaddress of the broadcast interface %s\n",
2460 g_message(
"ipaddress of the interface %s", ipAddressBuffer);
2464 ipAddressBuffer[0] =
'\0';
2465 result =
getipaddress(mocaIface->str, ipAddressBuffer, FALSE);
2467 g_message(
"Could not locate the ipaddress of the broadcast moca isolation interface %s",
2469 result =
getipaddress(wifiIface->str, ipAddressBuffer, FALSE);
2471 g_message(
"Could not locate the ipaddress of the wifi broadcast interface %s",
2473 g_critical(
"Could not locate the link local v4 ipaddress of the broadcast interface %s\n",
2476 devConf->bcastIf = g_strdup(wifiIface->str);
2477 g_message(
"ipaddress of the interface %s", ipAddressBuffer);
2482 devConf->bcastIf = g_strdup(mocaIface->str);
2483 g_message(
"ipaddress of the interface %s", ipAddressBuffer);
2491 g_message(
"Starting xdevice service on interface %s ipAddressBuffer= %s", devConf->bcastIf,ipAddressBuffer);
2494 g_message(
"waited 10 seconds for interface to come up so giving up");
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);
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
2511 g_critical(
"XUPNP IARM init failed");
2513 #endif //#if defined(USE_XUPNP_IARM_BUS)
2515 #ifndef CLIENT_XCAL_SERVER
2516 if (devConf->hostMacIf != NULL) {
2517 const gchar *hostmac = (gchar *)
getmacaddress(devConf->hostMacIf);
2519 g_message(
"MAC address in interface: %s %s \n", devConf->hostMacIf, hostmac);
2521 g_message(
"failed to retrieve macaddress on interface %s ",
2522 devConf->hostMacIf);
2524 g_string_assign(hostmacaddress, hostmac);
2525 g_message(
"Host mac address is %s", hostmacaddress->str);
2528 if (devConf->bcastIf != NULL ) {
2529 const gchar *bcastmac = (gchar *)
getmacaddress(devConf->bcastIf);
2531 g_message(
"Broadcast MAC address in interface: %s %s \n", devConf->bcastIf,
2534 g_message(
"failed to retrieve macaddress on interface %s ", devConf->bcastIf);
2536 g_string_assign(bcastmacaddress, bcastmac);
2537 g_message(
"bcast mac address is %s", bcastmacaddress->str);
2539 if (devConf->deviceNameFile != NULL) {
2541 g_message(
"Device Name : %s ", devicename->str);
2543 g_message(
" ERROR in getting Device Name ");
2548 g_message(
"getting the receiver id from %s", GET_DEVICEID_SCRIPT);
2549 recv_id =
getID(RECEIVER_ID);
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);
2560 g_string_printf(trmurl,
"ws://%s:9988", ipAddressBuffer);
2563 if (devConf->allowGwy == FALSE) {
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);
2571 g_print(
"Contents of dnsconfig is %s\n", dnsconfig->str);
2574 g_message(
"System ids are %s\n", systemids->str);
2576 g_warning(
"Error in finding system ids\n");
2578 #if defined(USE_XUPNP_IARM_BUS)
2579 if ((strlen(g_strstrip(serial_num->str)) < 6)
2581 g_message(
"Serial Number not yet received.\n");
2583 g_message(
"Received Serial Number:%s", serial_num->str);
2586 g_print(
"Serial Number is %s\n", serial_num->str);
2591 g_print(
"Serial Number is %s\n", serial_num->str);
2594 #ifndef CLIENT_XCAL_SERVER
2596 g_print(
"EtcHosts Content is \n%s\n", etchosts->str);
2598 g_print(
"Error in getting etc hosts\n");
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");
2610 g_message(
"Tune Ready check is disabled - Setting tune_ready to TRUE");
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);
2620 g_message(
" V6 prefix is not yet updated in file %s ",
2621 devConf->ipv6PrefixFile);
2624 g_message(
"IPv6 prefix : %s ", ipv6prefix->str);
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);
2629 if (devConf->hostMacIf != NULL) {
2630 result =
getipaddress(devConf->hostMacIf, stbipAddressBuffer, ipv6Enabled);
2632 g_message(
"Could not locate the ipaddress of the host mac interface %s\n",
2633 devConf->hostMacIf);
2635 g_message(
"ipaddress of the interface %s\n", stbipAddressBuffer);
2636 g_string_assign(gwystbip, stbipAddressBuffer);
2654 GString *
getID(
const gchar *
id )
2656 BOOL isDevIdPresent = FALSE;
2659 GString *jsonData = g_string_new(NULL);
2660 GString *value = g_string_new(NULL);
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,
2671 g_string_free(jsonData,
TRUE);
2674 #endif //#if defined(USE_XUPNP_IARM_BUS)
2677 if((fp = v_secure_popen(
"r", GET_DEVICEID_SCRIPT)))
2679 char response[1024] = {0};
2680 fread(response, 1,
sizeof(response)-1, fp);
2681 int ret = v_secure_pclose(fp);
2683 g_message(
"Error in closing pipe ! : %d \n", ret);
2685 if ((response[0] ==
'\0') && (counter < MAX_DEBUG_MESSAGE)) {
2687 g_message(
"No Json string found in Auth url %s \n" ,
2690 g_string_assign(jsonData, response);
2691 gchar **tokens = g_strsplit_set(jsonData->str,
"{}:,\"", -1);
2692 guint tokLength = g_strv_length(tokens);
2694 for (loopvar = 0; loopvar < tokLength; loopvar++) {
2695 if (g_strrstr(g_strstrip(tokens[loopvar]),
id)) {
2697 if ((loopvar + 3) < tokLength ) {
2698 g_string_assign(value, g_strstrip(tokens[loopvar + 3]));
2699 if (value->str[0] !=
'\0') {
2700 isDevIdPresent =
TRUE;
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);
2711 if (counter < MAX_DEBUG_MESSAGE ) {
2713 g_message(
"%s not found in Json string in Auth url %s \n ",
id, jsonData->str);
2716 g_message(
"Successfully fetched %s %s \n ",
id, value->str);
2717 g_string_free(jsonData,
TRUE);
2725 g_message(
"The deviceId script %s can't be executed\n", GET_DEVICEID_SCRIPT);
2731 g_string_free(jsonData,
TRUE);
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);
2750 gchar *diagfile = NULL;
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");
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");
2764 g_string_printf(systemids,
"channelMapId:%lu;", diagid);
2766 g_string_append_printf(systemids,
"controllerId:%lu;", diagid);
2768 g_string_append_printf(systemids,
"plantId:%lu;", diagid);
2770 g_string_append_printf(systemids,
"vodServerId:%lu", diagid);
2774 g_clear_error(&error);
2788 GError *error = NULL;
2789 BOOL result = FALSE;
2790 gchar *devicenamefile = NULL;
2792 BOOL devicenamematch = FALSE;
2793 if (devConf->deviceNameFile == NULL) {
2794 g_warning(
"device name file name not found in config");
2798 result = g_file_get_contents (devConf->deviceNameFile, &devicenamefile, NULL,
2800 if (result == FALSE && error != NULL) {
2801 g_warning(
"Problem in reading /devicename/devicename file %s", error->message);
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")) {
2808 g_string_printf(devicename,
"%s", g_strstrip(tokens[loopvar + 1]));
2810 devicenamematch =
TRUE;
2816 if (devicenamematch == FALSE) {
2817 g_message(
"No Matching devicename in file %s", devicenamefile);
2821 if(strstr(devicename->str,
"\"")||strstr(devicename->str,
"\\"))
2824 ptr = g_strescape(devicename->str,
"\b\n");
2827 g_string_printf(devicename,
"%s",ptr);
2831 g_message(
"device name = %s",devicename->str);
2836 g_clear_error(&error);
2838 g_free(devicenamefile);
2850 GError *error = NULL;
2851 BOOL result = FALSE;
2852 gchar *prefixfile = NULL;
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");
2862 result = g_file_get_contents (devConf->ipv6PrefixFile, &prefixfile, NULL,
2864 if (result == FALSE && error != NULL) {
2865 g_warning(
"Problem in reading /prefix/prefix file %s", error->message);
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))) {
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")) {
2883 g_string_printf(ipv6prefix,
"%s", prefixtokens[prefixloopvar - 1]);
2884 g_message(
"ipv6 prefix format in the file %s",
2885 prefixtokens[prefixloopvar - 1]);
2890 g_strfreev(prefixtokens);
2892 if (prefixmatch ==
TRUE)
2898 if (prefixmatch == FALSE) {
2900 g_message(
"No Matching ipv6 prefix in file %s", prefixfile);
2905 g_clear_error(&error);
2915 #define VIDIPATH_FLAG "/opt/vidiPathEnabled"
2916 static int isVidiPathEnabled()
2918 if (access(VIDIPATH_FLAG, F_OK) == 0)
2932 GKeyFile *keyfile = NULL;
2933 GKeyFileFlags flags;
2934 GError *error = NULL;
2936 keyfile = g_key_file_new ();
2937 flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
2939 if (!g_key_file_load_from_file (keyfile, configfile, flags, &error)) {
2941 g_message (error->message);
2943 g_clear_error(&error);
2946 g_key_file_free(keyfile);
2966 devConf->bcastIf = g_key_file_get_string (keyfile,
"Network",
2968 devConf->bcastPort = g_key_file_get_integer (keyfile,
"Network",
2970 #ifndef CLIENT_XCAL_SERVER
2971 devConf->streamIf = g_key_file_get_string (keyfile,
"Network",
2973 devConf->trmIf = g_key_file_get_string (keyfile,
"Network",
2975 devConf->gwIf = g_key_file_get_string (keyfile,
"Network",
"GwIf",
2977 devConf->cvpIf = g_key_file_get_string (keyfile,
"Network",
2979 devConf->cvpPort = g_key_file_get_integer (keyfile,
"Network",
2981 devConf->hostMacIf = g_key_file_get_string (keyfile,
"Network",
3002 #ifndef CLIENT_XCAL_SERVER
3003 devConf->oemFile = g_key_file_get_string (keyfile,
"DataFiles",
3005 devConf->dnsFile = g_key_file_get_string (keyfile,
"DataFiles",
3007 devConf->dsgFile = g_key_file_get_string (keyfile,
"DataFiles",
3009 devConf->diagFile = g_key_file_get_string (keyfile,
"DataFiles",
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",
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);
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);
3049 devConf->useIARM = g_key_file_get_boolean (keyfile,
"Flags",
3051 devConf->allowGwy = g_key_file_get_boolean (keyfile,
"Flags",
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 ) {
3057 devConf->uriOverride = g_key_file_get_string (keyfile,
"Rui",
"uriOverride",
3060 devConf->uriOverride = NULL;
3062 devConf->enableTRM = g_key_file_get_boolean (keyfile,
"Flags",
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);
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");
3090 static void xmlescape(gchar *instr, GString *outstr)
3092 for (; *instr; instr++)
3097 g_string_append_printf(outstr,
"%s",
"&");
3100 g_string_append_printf(outstr,
"%s",
"&guot;");
3103 g_string_append_printf(outstr,
"%s",
"'");
3106 g_string_append_printf(outstr,
"%s",
"<");
3109 g_string_append_printf(outstr,
"%s",
">");
3112 g_string_append_printf(outstr,
"%c",*instr);
3122 static void uriescape(
unsigned char *instr, GString *outstr)
3125 char unreserved[256] = {0};
3127 for (i = 0; i < 256; ++i)
3129 unreserved[i] = isalnum(i) || i ==
'-' || i ==
'_' || i ==
'.' || i ==
'!' || i ==
'~'
3130 || i ==
'*' || i ==
'\'' || i ==
'(' || i ==
')'
3134 for (; *instr; instr++)
3136 if (unreserved[*instr])
3137 g_string_append_printf(outstr,
"%c",*instr);
3139 g_string_append_printf(outstr,
"%%%02X",*instr);
3158 if (hostmacaddress != NULL && hostmacaddress->len == 17)
3160 GString* addr = g_string_new(NULL);
3163 for (i = 0; i < hostmacaddress->len; ++i)
3165 if (i != 2 && i != 5 && i != 8 && i != 11 && i != 14 )
3167 addr = g_string_append_c(addr,(hostmacaddress->str)[i]);
3170 return g_string_ascii_up(addr);
3178 static void initIpAddressBufferCVP2(
char *ipAddressBufferCVP2)
3180 int result =
getipaddress(devConf->cvpIf, ipAddressBufferCVP2, FALSE);
3184 fprintf(stderr,
"Could not locate the ipaddress of CVP2 interface %s\n", devConf->cvpIf);
3187 g_message(
"ipaddress of the CVP2 interface %s\n", ipAddressBufferCVP2);
3188 g_string_assign(gwyipCVP2, ipAddressBufferCVP2);
3195 static GString *get_uri_value()
3201 g_get_current_time(&timeval);
3202 double t = timeval.tv_sec + (timeval.tv_usec /
3205 snprintf(udnvalue, 25,
"%s%f",
"CVP-", t);
3207 char ipAddressBufferCVP2[INET6_ADDRSTRLEN];
3208 initIpAddressBufferCVP2(ipAddressBufferCVP2);
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);
3216 if (devConf->uriOverride != NULL)
3217 urilink = devConf->uriOverride;
3219 urilink =
"http://syndeo.xcal.tv/app/x2rui/rui.html";
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);
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);
3243 if (controllerId == NULL)
3244 controllerId = g_string_new(
"0");
3245 GString *plantId = NULL;
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);
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);
3263 if (vodServerId == NULL)
3264 vodServerId = g_string_new(
"0");
3266 if (eSTBMAC == NULL) {
3267 eSTBMAC = g_string_new(
"UNKNOWN");
3269 gchar *gw_value = g_strconcat(
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,
"\""
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);
3291 GString *gwescapededstr = g_string_sized_new(strlen(gw_value) *
3293 uriescape(gw_value, gwescapededstr);
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) *
3301 xmlescape(uri, xmlescapedstr);
3304 return xmlescapedstr;
3315 GError *error = NULL;
3316 BOOL result = FALSE;
3317 gchar *etchostsfile = NULL;
3319 if ( ipv6Enabled ==
TRUE )
3320 hostsFile = g_strdup(
"//etc//xi-xconf-hosts.list");
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);
3327 gchar **tokens = g_strsplit_set(etchostsfile,
"\n\0", -1);
3329 guint toklength = g_strv_length(tokens);
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]));
3337 g_string_assign(etchosts,
"");
3339 for (loopvar = 1; loopvar < toklength; loopvar++) {
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]));
3357 g_clear_error(&error);
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);
3383 gchar **tokens = g_strsplit_set(udhcpcvendorfile,
" \n\t\b\0", -1);
3384 guint toklength = g_strv_length(tokens);
3386 for (loopvar = 0; loopvar < toklength; 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]));
3401 g_clear_error(&error);
3407 IARM_Result_t iarmRet = IARM_RESULT_IPCCORE_FAIL;
3409 rc = memset_s(¶m,
sizeof(param), 0,
sizeof(param));
3411 param.
type = mfrSERIALIZED_TYPE_SERIALNUMBER;
3414 if (iarmRet == IARM_RESULT_SUCCESS) {
3416 g_message(
" serialized data %s \n", param.
buffer );
3417 g_string_assign(serial_num, param.
buffer);
3420 g_message(
" serialized data is empty \n" );
3425 g_message(
"IARM CALL failed for mfrtype \n");
3441 const gchar *diagfilecontents)
3443 unsigned long diagid = 0;
3444 gchar **tokens = g_strsplit_set(diagfilecontents,
":,{}", -1);
3445 guint toklength = g_strv_length(tokens);
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);
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");
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);
3477 gchar **tokens = g_strsplit_set(dnsconfigfile,
"\n\0", -1);
3479 guint toklength = g_strv_length(tokens);
3481 BOOL firsttok =
TRUE;
3482 for (loopvar = 0; loopvar < toklength; loopvar++) {
3483 if ((strlen(g_strstrip(tokens[loopvar])) > 0)) {
3485 if (firsttok == FALSE) {
3486 g_string_append_printf(strdnsconfig,
"%s;", g_strstrip(tokens[loopvar]));
3488 g_string_printf(strdnsconfig,
"%s;", g_strstrip(tokens[loopvar]));
3493 g_string_assign(dnsconfig, strdnsconfig->str);
3494 g_string_free(strdnsconfig,
TRUE);
3495 g_message(
"DNS Config is %s", dnsconfig->str);
3500 g_clear_error(&error);
3518 GString *data = g_string_new(
"00:00:00:00:00:00");
3520 fd = socket(AF_INET, SOCK_DGRAM, 0);
3524 ifr.ifr_addr.sa_family = AF_INET;
3525 rc = strcpy_s(ifr.ifr_name ,IFNAMSIZ - 1,ifname);
3527 ioctl(fd, SIOCGIFHWADDR, &ifr);
3529 mac = (
unsigned char *)ifr.ifr_hwaddr.sa_data;
3532 g_string_printf(data,
"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0], mac[1], mac[2],
3533 mac[3], mac[4], mac[5]);
3547 int getipaddress(
const char *ifname,
char *ipAddressBuffer,gboolean ipv6Enabled)
3549 struct ifaddrs *ifAddrStruct = NULL;
3550 struct ifaddrs *ifa = NULL;
3551 void *tmpAddrPtr = NULL;
3552 getifaddrs(&ifAddrStruct);
3557 for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
3558 if (ifa->ifa_addr == NULL)
continue;
3559 if (ipv6Enabled ==
TRUE) {
3562 rc = strcmp_s(ifa->ifa_name,strlen(ifa->ifa_name),ifname,&ind);
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);
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))) {
3578 if (ifa ->ifa_addr->sa_family == AF_INET) {
3580 tmpAddrPtr = &((
struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
3581 inet_ntop(AF_INET, tmpAddrPtr, ipAddressBuffer, INET_ADDRSTRLEN);
3583 rc = strcmp_s(ifa->ifa_name,strlen(ifa->ifa_name),ifname,&ind);
3585 if((!ind) && (rc == EOK)) {
3592 if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct);
3596 static char * getPartnerName()
3598 getPartnerId(partner_id->str);
3599 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(partnerNameMap), partnerNameMap);
3603 static char * getFriendlyName()
3605 getPartnerId(partner_id->str);
3606 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(friendlyNameMap), friendlyNameMap);
3610 static char * getProductName()
3612 getPartnerId(partner_id->str);
3613 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(productNameMap), productNameMap);
3615 static char * getServiceName()
3617 getPartnerId(partner_id->str);
3618 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(serviceNameMap), serviceNameMap);
3620 static char * getServiceDescription()
3622 getPartnerId(partner_id->str);
3623 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(serviceDescriptionMap), serviceDescriptionMap);
3625 static char * getGatewayName()
3627 getPartnerId(partner_id->str);
3628 return getStrValueFromMap(partner_id->str, ARRAY_COUNT(gatewayNameMap), gatewayNameMap);