19 #include <libgupnp/gupnp.h>
26 #include <libxml/tree.h>
27 #include <libxml/parser.h>
30 #include "secure_wrapper.h"
32 #ifdef INCLUDE_BREAKPAD
33 #include "breakpad_wrapper.h"
36 #ifdef ENABLE_SD_NOTIFY
37 #include <systemd/sd-daemon.h>
39 #include "rdk_safeclib.h"
41 #define DEVICE_XML_PATH "/etc/xupnp/"
42 #define DEVICE_XML_FILE "BasicDevice.xml"
43 #define CLIENT_DEVICE_XML_FILE "X1Renderer.xml"
44 #define GW_DEVICE_XML_FILE "X1VideoGateway.xml"
45 #define BROADBAND_DEVICE_XML_FILE "X1BroadbandGateway.xml"
46 #define LOG_FILE "/opt/logs/xdevice.log"
47 #define DEVICE_PROTECTION_CONTEXT_PORT 50757
50 #define RUIURLSIZE 2048
53 #define BOOL unsigned char
58 static GMainLoop *main_loop;
60 char devBcastIf[MAXSIZE],serial_Num[MAXSIZE], cvpInterface[MAXSIZE], cvPXmlFile[MAXSIZE],playBackUrl[URLSIZE],devXMlPath[MAXSIZE],uUid[MAXSIZE],ruiUrl[RUIURLSIZE];
61 char devXMlFile [MAXSIZE],devBcastIf[MAXSIZE],serial_Num[MAXSIZE],cvpInterface[MAXSIZE],cvPXmlFile[MAXSIZE],ipv6preFix[MAXSIZE],trmUrl[MAXSIZE],urL[MAXSIZE];
63 char gwyIp[MAXSIZE],gwyIpv6[MAXSIZE],gwystbIp[MAXSIZE],hostMacaddress[MAXSIZE],bcastMacaddress[MAXSIZE],recvdevType[MAXSIZE],deviceType[MAXSIZE],modelclass[MAXSIZE],modelNumber[MAXSIZE],deviceid[MAXSIZE],hardwarerevision[MAXSIZE],softwarerevision[MAXSIZE],managementurl[MAXSIZE],Make[MAXSIZE],accountId[MAXSIZE],clientIp[MAXSIZE];
64 char buildVersion[MAXSIZE],dnsConfig[MAXSIZE],systemIds[MAXSIZE],dataGatewayIPAddress[MAXSIZE],dsgtimeZone[MAXSIZE],deviceName[MAXSIZE],etcHosts[RUIURLSIZE],receiverId[MAXSIZE],ipsubnet[MAXSIZE];
65 char devPXmlFile[MAXSIZE], devCertFile[MAXSIZE], devCertPath[MAXSIZE], devKeyFile[MAXSIZE], devKeyPath[MAXSIZE];
66 gint rawoffset, dstoffset, dstsavings, devBcastPort, cvpPort;
67 gboolean usedaylightsavings,allowgwy,requiresTrm;
68 char *caFile=
"/tmp/UPnP_CA";
70 static int rfc_enabled;
71 #ifdef SAFEC_DUMMY_API
73 errno_t strcmp_s(
const char * d,
int max ,
const char * src,
int *r)
80 static xmlNode * get_node_by_name(xmlNode * node,
const char *node_name)
84 xmlNode * cur_node = NULL;
87 for (cur_node = node ; cur_node ; cur_node = cur_node->next)
89 rc = strcmp_s(cur_node->name, strlen(cur_node->name), node_name, &ind);
91 if ((ind ==0) && (rc == EOK))
95 ret = get_node_by_name(cur_node->children, node_name);
113 int set_content(xmlDoc* doc,
const char * node_name,
const char * new_value)
115 xmlNode * root_element = NULL;
116 xmlNode * target_node = NULL;
118 root_element = xmlDocGetRootElement(doc);
119 target_node = get_node_by_name(root_element, node_name);
121 if (target_node==NULL)
123 g_printerr(
"Couldn't locate the Target node\n");
127 xmlNodeSetContent(target_node,new_value);
146 BOOL
updatexmldata(
const char* xmlfilename,
const char* struuid,
const char* serialno,
const char* friendlyName)
154 g_printerr (
"Error reading the Device XML file\n");
161 g_printerr (
"Error setting the upc in conf xml\n");
164 g_message(
"Added UPC value to %s",xmlfilename);
170 g_printerr (
"Error setting the upc in conf xml\n");
173 g_message(
"Updated UPC value as empty string in %s",xmlfilename);
177 g_printerr (
"Error setting the unique device id in conf xml\n");
182 g_printerr (
"Error setting the serial number in conf xml\n");
185 if(NULL != friendlyName)
187 if (
set_content(doc,
"friendlyName", friendlyName)!=0)
189 g_printerr (
"Error setting the friendlyName number in conf xml\n");
195 g_printerr (
"friendlyName is NULL\n");
198 FILE *fp = fopen(xmlfilename,
"w");
202 g_printerr (
"Error opening the conf xml file for writing\n");
205 else if (xmlDocFormatDump(fp, doc, 1) == -1)
207 g_printerr (
"Could not write the conf to xml file\n");
232 if ((service_ready==FALSE) )
234 g_warning(
"Received notificaton before start of Service");
239 GValue value = G_VALUE_INIT;
240 g_value_init(&value, G_TYPE_STRING);
241 g_value_set_static_string(&value, strvalue);
242 g_message(
"Sending value change notification Name %s - Value: %s", varname, strvalue);
243 gupnp_service_notify_value((GUPnPService *)upnpService, varname, &value);
261 ret = xmlReadFile(file_name, NULL, 0);
282 get_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
288 gupnp_service_action_set (action,
"BaseUrl", G_TYPE_STRING, urL, NULL);
289 gupnp_service_action_return (action);
303 get_trm_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
307 gupnp_service_action_set (action,
"BaseTrmUrl", G_TYPE_STRING, trmUrl, NULL);
308 gupnp_service_action_return (action);
321 get_playback_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
327 getPlaybackUrl(playBackUrl);
328 gupnp_service_action_set (action,
"PlaybackUrl", G_TYPE_STRING, playBackUrl ,NULL);
333 gupnp_service_action_set (action,
"PlaybackUrl", G_TYPE_STRING,
"NULL", NULL);
335 gupnp_service_action_return (action);
349 get_gwyip_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
353 gupnp_service_action_set (action,
"GatewayIP", G_TYPE_STRING, gwyIp, NULL);
354 gupnp_service_action_return (action);
367 get_gwyipv6_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
371 gupnp_service_action_set (action,
"GatewayIPv6", G_TYPE_STRING, gwyIpv6, NULL);
372 gupnp_service_action_return (action);
386 get_gwystbip_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
390 gupnp_service_action_set (action,
"GatewayStbIP", G_TYPE_STRING, gwystbIp, NULL);
391 gupnp_service_action_return (action);
406 get_ipv6prefix_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
410 gupnp_service_action_set (action,
"Ipv6Prefix", G_TYPE_STRING, ipv6preFix, NULL);
411 gupnp_service_action_return (action);
428 getHostMacAddress(hostMacaddress);
429 gupnp_service_action_set (action,
"HostMacAddress", G_TYPE_STRING, hostMacaddress, NULL);
430 gupnp_service_action_return (action);
447 gupnp_service_action_set (action,
"BcastMacAddress", G_TYPE_STRING, bcastMacaddress, NULL);
448 gupnp_service_action_return (action);
461 get_recvdevtype_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
465 gupnp_service_action_set (action,
"RecvDevType", G_TYPE_STRING, recvdevType, NULL);
466 gupnp_service_action_return (action);
470 get_devicetype_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
474 gupnp_service_action_set (action,
"DeviceType", G_TYPE_STRING, deviceType, NULL);
475 gupnp_service_action_return (action);
489 get_buildversion_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
492 getBuildVersion(buildVersion);
493 gupnp_service_action_set (action,
"BuildVersion", G_TYPE_STRING, buildVersion, NULL);
494 gupnp_service_action_return (action);
508 get_dnsconfig_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
510 getDnsConfig(dnsConfig);
511 gupnp_service_action_set (action,
"DnsConfig", G_TYPE_STRING, dnsConfig, NULL);
512 gupnp_service_action_return (action);
526 get_systemids_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
529 getSystemsIds(systemIds);
530 gupnp_service_action_set (action,
"SystemIds", G_TYPE_STRING, systemIds, NULL);
531 gupnp_service_action_return (action);
552 getRouteDataGateway(dataGatewayIPAddress);
554 gupnp_service_action_set (action,
"DataGatewayIPaddress", G_TYPE_STRING, dataGatewayIPAddress, NULL);
555 gupnp_service_action_return (action);
569 get_ipsubnet_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
571 getIpSubnet(ipsubnet);
572 gupnp_service_action_set (action,
"IPSubNet", G_TYPE_STRING, ipsubnet, NULL);
573 gupnp_service_action_return (action);
587 get_timezone_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
590 if(getIsuseGliDiagEnabled()) {
591 getTimeZone(dsgtimeZone);
593 gupnp_service_action_set (action,
"TimeZone", G_TYPE_STRING, dsgtimeZone, NULL);
594 gupnp_service_action_return (action);
607 get_rawoffset_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
609 getRawOffSet(&rawoffset);
610 gupnp_service_action_set (action,
"RawOffSet", G_TYPE_INT, rawoffset, NULL);
611 gupnp_service_action_return (action);
624 get_dstsavings_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
626 getDstSavings(&dstsavings);
627 gupnp_service_action_set (action,
"DSTSavings", G_TYPE_INT, dstsavings, NULL);
628 gupnp_service_action_return (action);
643 getUsesDayLightTime((
unsigned char *)&usedaylightsavings);
644 gupnp_service_action_set (action,
"UsesDaylightTime", G_TYPE_BOOLEAN, usedaylightsavings, NULL);
645 gupnp_service_action_return (action);
658 get_devicename_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
661 gupnp_service_action_set (action,
"DeviceName", G_TYPE_STRING, deviceName, NULL);
662 gupnp_service_action_return (action);
675 get_dstoffset_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
677 getDstOffset(&dstoffset);
678 gupnp_service_action_set (action,
"DSTOffset", G_TYPE_INT, dstoffset, NULL);
679 gupnp_service_action_return (action);
692 get_hosts_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
696 gupnp_service_action_set (action,
"Hosts", G_TYPE_STRING, etcHosts, NULL);
697 gupnp_service_action_return (action);
710 get_isgateway_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
713 gchar *clientMacAddr=NULL;
714 gchar *clientIpAddr=NULL;
715 gboolean deviceProtectionEnabled=
TRUE;
718 if(gupnp_service_action_get_argument_count(action))
720 gupnp_service_action_get (action,
"deviceProtection", G_TYPE_BOOLEAN,&deviceProtectionEnabled, NULL);
721 if(!deviceProtectionEnabled)
723 gupnp_service_action_get (action,
"macAddr", G_TYPE_STRING, &clientMacAddr, NULL);
724 gupnp_service_action_get (action,
"ipAddr", G_TYPE_STRING, &clientIpAddr, NULL);
725 if((clientMacAddr) && (clientIpAddr))
726 g_warning(
"Device Protection Disabled Device : %s,%s",clientMacAddr,clientIpAddr);
728 g_warning(
"Device Protection Disabled Device without details");
732 g_warning(
"Device Protection Not supported legacy Device");
734 getIsGateway((
unsigned char *)&allowgwy);
735 gupnp_service_action_set (action,
"IsGateway", G_TYPE_BOOLEAN, allowgwy, NULL);
736 gupnp_service_action_return (action);
749 get_requirestrm_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
751 getRequiresTRM((
unsigned char *)&requiresTrm);
752 gupnp_service_action_set (action,
"RequiresTRM", G_TYPE_BOOLEAN, requiresTrm, NULL);
753 gupnp_service_action_return (action);
766 get_rui_url_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
770 if(!getRUIUrl(ruiUrl)){
771 g_print(
"Error in initializing RUI url value\n");
774 gupnp_service_action_get (action,
"InputDeviceProfile", G_TYPE_STRING, inDevProfile->str, NULL);
775 gupnp_service_action_get (action,
"UIFilter", G_TYPE_STRING, uiFilter->str,NULL);
776 gupnp_service_action_set (action,
"UIListing", G_TYPE_STRING, ruiUrl, NULL);
777 gupnp_service_action_return (action);
781 get_modelclass_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
785 gupnp_service_action_set (action,
"ModelClass", G_TYPE_STRING, modelclass, NULL);
786 gupnp_service_action_return (action);
789 get_modelnumber_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
792 getModelNumber(modelNumber);
793 gupnp_service_action_set (action,
"ModelNumber", G_TYPE_STRING, modelNumber, NULL);
794 gupnp_service_action_return (action);
797 get_deviceid_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
800 gupnp_service_action_set (action,
"DeviceId", G_TYPE_STRING, deviceid, NULL);
801 gupnp_service_action_return (action);
804 get_hardwarerevision_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
807 gupnp_service_action_set (action,
"HardwareRevision", G_TYPE_STRING, hardwarerevision, NULL);
808 gupnp_service_action_return (action);
811 get_softwarerevision_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
814 gupnp_service_action_set (action,
"SoftwareRevision", G_TYPE_STRING, softwarerevision, NULL);
815 gupnp_service_action_return (action);
818 get_managementurl_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
821 gupnp_service_action_set (action,
"ManagementURL", G_TYPE_STRING, managementurl, NULL);
822 gupnp_service_action_return (action);
825 get_make_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
829 gupnp_service_action_set (action,
"Make", G_TYPE_STRING, Make, NULL);
830 gupnp_service_action_return (action);
833 get_recev_id_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
836 gupnp_service_action_set (action,
"ReceiverId", G_TYPE_STRING, receiverId, NULL);
837 gupnp_service_action_return (action);
840 get_account_id_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data)
842 gchar *clientAccountId=NULL;
844 gchar *clientMacAddr=NULL;
845 gchar *clientIpAddr=NULL;
850 gupnp_service_action_get (action,
"SAccountId", G_TYPE_STRING, &clientAccountId, NULL);
851 gupnp_service_action_set (action,
"GAccountId", G_TYPE_STRING, accountId, NULL);
852 gupnp_service_action_get (action,
"macAddr", G_TYPE_STRING, &clientMacAddr, NULL);
853 gupnp_service_action_get (action,
"ipAddr", G_TYPE_STRING, &clientIpAddr, NULL);
854 if ((clientAccountId) && (!strcmp(clientAccountId, accountId)))
856 g_warning(
"Client connection account ID same : %s,%s,%s,%s" , accountId,clientAccountId,clientMacAddr,clientIpAddr);
859 g_warning(
"/usr/ccsp/moca/moca_whitelist_ctl.sh add %s",clientIpAddr);
860 ret = v_secure_system(
"/usr/ccsp/moca/moca_whitelist_ctl.sh add %s", clientIpAddr);
862 g_warning(
"Failure in executing command via v_secure_system. ret:[%d] ;\n", ret);
865 gupnp_service_action_return (action);
872 g_warning(
"Client connection account ID mismatch found : %s,%s,%s,%s" , accountId,clientAccountId,clientMacAddr,clientIpAddr);
874 g_warning(
"/usr/ccsp/moca/moca_whitelist_ctl.sh del %s", clientIpAddr);
875 ret = v_secure_system(
"/usr/ccsp/moca/moca_whitelist_ctl.sh del %s", clientIpAddr);
877 g_warning(
"Failure in executing command via v_secure_system. ret:[%d] ;\n", ret);
881 gupnp_service_action_return (action);
904 gupnp_service_action_set (action,
"ClientIP", G_TYPE_STRING, clientIp, NULL);
905 gupnp_service_action_return (action);
923 query_url_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
925 g_value_init (value, G_TYPE_STRING);
926 g_value_set_string (value, urL);
940 query_trm_url_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
942 g_value_init (value, G_TYPE_STRING);
943 g_value_set_string (value, trmUrl);
962 g_value_init (value, G_TYPE_STRING);
963 g_value_set_string (value, playBackUrl);
968 g_value_init (value, G_TYPE_STRING);
969 g_value_set_string (value,
"NULL");
987 g_value_init (value, G_TYPE_STRING);
988 g_value_set_string (value, dataGatewayIPAddress);
1001 G_MODULE_EXPORT
void
1002 query_devicename_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1004 g_value_init (value, G_TYPE_STRING);
1005 g_value_set_string (value, deviceName);
1018 G_MODULE_EXPORT
void
1019 query_gwyip_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1021 g_value_init (value, G_TYPE_STRING);
1022 g_value_set_string (value, gwyIp);
1035 G_MODULE_EXPORT
void
1036 query_gwyipv6_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1038 g_value_init (value, G_TYPE_STRING);
1039 g_value_set_string (value, gwyIpv6);
1052 G_MODULE_EXPORT
void
1053 query_gwystbip_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1055 g_value_init (value, G_TYPE_STRING);
1056 g_value_set_string (value, gwystbIp);
1070 G_MODULE_EXPORT
void
1071 query_ipv6prefix_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1073 g_value_init (value, G_TYPE_STRING);
1074 g_value_set_string (value, ipv6preFix);
1088 G_MODULE_EXPORT
void
1091 g_value_init (value, G_TYPE_STRING);
1092 g_value_set_string (value, hostMacaddress);
1105 G_MODULE_EXPORT
void
1108 g_value_init (value, G_TYPE_STRING);
1109 g_value_set_string (value, bcastMacaddress);
1122 G_MODULE_EXPORT
void
1123 query_recvdevtype_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1125 g_value_init (value, G_TYPE_STRING);
1126 g_value_set_string (value, recvdevType);
1129 G_MODULE_EXPORT
void
1130 query_devicetype_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1132 g_value_init (value, G_TYPE_STRING);
1133 g_value_set_string (value, deviceType);
1146 G_MODULE_EXPORT
void
1149 g_value_init (value, G_TYPE_STRING);
1150 g_value_set_string (value, buildVersion);
1164 G_MODULE_EXPORT
void
1165 query_dnsconfig_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1167 g_value_init (value, G_TYPE_STRING);
1168 g_value_set_string (value, dnsConfig);
1182 G_MODULE_EXPORT
void
1183 query_systemids_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1185 g_value_init (value, G_TYPE_STRING);
1186 g_value_set_string (value, systemIds);
1199 G_MODULE_EXPORT
void
1202 getIpSubnet(ipsubnet);
1203 g_value_init (value, G_TYPE_STRING);
1204 g_value_set_string (value, ipsubnet);
1218 G_MODULE_EXPORT
void
1219 query_timezone_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1221 if (getIsuseGliDiagEnabled() == FALSE){
1222 getTimeZone(dsgtimeZone);
1224 g_value_init (value, G_TYPE_STRING);
1225 g_value_set_string (value, dsgtimeZone);
1238 G_MODULE_EXPORT
void
1239 query_hosts_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1241 g_value_init (value, G_TYPE_STRING);
1242 g_value_set_string (value, etcHosts);
1255 G_MODULE_EXPORT
void
1256 query_isgateway_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1258 g_value_init (value, G_TYPE_BOOLEAN);
1259 g_value_set_boolean (value, allowgwy);
1272 G_MODULE_EXPORT
void
1273 query_requirestrm_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1275 g_value_init (value, G_TYPE_BOOLEAN);
1276 g_value_set_boolean (value, requiresTrm);
1289 G_MODULE_EXPORT
void
1290 query_rui_url_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1292 g_value_init (value, G_TYPE_STRING);
1293 g_value_set_string (value, ruiUrl);
1306 G_MODULE_EXPORT
void
1307 query_rawoffset_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1309 g_value_init (value, G_TYPE_INT);
1310 g_value_set_int (value, rawoffset);
1323 G_MODULE_EXPORT
void
1324 query_dstoffset_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1326 g_value_init (value, G_TYPE_INT);
1327 g_value_set_int (value, dstoffset);
1340 G_MODULE_EXPORT
void
1341 query_dstsavings_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1343 g_value_init (value, G_TYPE_INT);
1344 g_value_set_int (value, dstsavings);
1358 G_MODULE_EXPORT
void
1361 g_value_init (value, G_TYPE_STRING);
1362 g_value_set_string (value, clientIp);
1376 G_MODULE_EXPORT
void
1379 g_value_init (value, G_TYPE_BOOLEAN);
1380 g_value_set_boolean (value, usedaylightsavings);
1383 G_MODULE_EXPORT
void
1384 query_modelclass_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1386 g_value_init (value, G_TYPE_STRING);
1387 g_value_set_string (value, modelclass);
1389 G_MODULE_EXPORT
void
1390 query_modelnumber_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1392 g_value_init (value, G_TYPE_STRING);
1393 g_value_set_string (value, modelNumber);
1395 G_MODULE_EXPORT
void
1396 query_deviceid_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1398 g_value_init (value, G_TYPE_STRING);
1399 g_value_set_string (value, deviceid);
1401 G_MODULE_EXPORT
void
1402 query_hardwarerevision_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1404 g_value_init (value, G_TYPE_STRING);
1405 g_value_set_string (value, hardwarerevision);
1407 G_MODULE_EXPORT
void
1408 query_softwarerevision_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1410 g_value_init (value, G_TYPE_STRING);
1411 g_value_set_string (value, softwarerevision);
1413 G_MODULE_EXPORT
void
1414 query_managementurl_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1416 g_value_init (value, G_TYPE_STRING);
1417 g_value_set_string (value, managementurl);
1419 G_MODULE_EXPORT
void
1420 query_make_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1422 g_value_init (value, G_TYPE_STRING);
1423 g_value_set_string (value, Make);
1425 G_MODULE_EXPORT
void
1426 query_recev_id_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1428 g_value_init (value, G_TYPE_STRING);
1429 g_value_set_string (value, receiverId);
1431 G_MODULE_EXPORT
void
1432 query_account_id_cb (GUPnPService *service,
char *variable, GValue *value, gpointer user_data)
1434 g_value_init (value, G_TYPE_STRING);
1435 g_value_set_string (value, accountId);
1438 int registerIdentityConfigurationService(GUPnPServiceInfo *upnpIdService)
1440 g_signal_connect (upnpIdService,
"action-invoked::GetRecvDevType", G_CALLBACK (
get_recvdevtype_cb), NULL);
1441 g_signal_connect (upnpIdService,
"action-invoked::GetDeviceType", G_CALLBACK (get_devicetype_cb), NULL);
1442 g_signal_connect (upnpIdService,
"action-invoked::GetBuildVersion", G_CALLBACK (
get_buildversion_cb), NULL);
1443 g_signal_connect (upnpIdService,
"action-invoked::GetDeviceName", G_CALLBACK (
get_devicename_cb), NULL);
1444 g_signal_connect (upnpIdService,
"action-invoked::GetModelClass", G_CALLBACK (get_modelclass_cb), NULL);
1445 g_signal_connect (upnpIdService,
"action-invoked::GetModelNumber", G_CALLBACK (get_modelnumber_cb), NULL);
1446 g_signal_connect (upnpIdService,
"action-invoked::GetDeviceId", G_CALLBACK (get_deviceid_cb), NULL);
1447 g_signal_connect (upnpIdService,
"action-invoked::GetHardwareRevision", G_CALLBACK (get_hardwarerevision_cb), NULL);
1448 g_signal_connect (upnpIdService,
"action-invoked::GetSoftwareRevision", G_CALLBACK (get_softwarerevision_cb), NULL);
1449 g_signal_connect (upnpIdService,
"action-invoked::GetManagementUrl", G_CALLBACK (get_managementurl_cb), NULL);
1450 g_signal_connect (upnpIdService,
"action-invoked::GetMake", G_CALLBACK (get_make_cb), NULL);
1451 g_signal_connect (upnpIdService,
"action-invoked::GetReceiverId", G_CALLBACK (get_recev_id_cb), NULL);
1452 g_signal_connect (upnpIdService,
"action-invoked::GetAccountId", G_CALLBACK (get_account_id_cb), NULL);
1453 g_signal_connect (upnpIdService,
"action-invoked::GetClientIP", G_CALLBACK (
get_client_ip_cb), NULL);
1454 g_signal_connect (upnpIdService,
"action-invoked::GetBcastMacAddress", G_CALLBACK (
get_bcastmacaddress_cb), NULL);
1455 g_signal_connect (upnpIdService,
"query-variable::RecvDevType", G_CALLBACK (
query_recvdevtype_cb), NULL);
1456 g_signal_connect (upnpIdService,
"query-variable::DeviceType", G_CALLBACK (query_devicetype_cb), NULL);
1457 g_signal_connect (upnpIdService,
"query-variable::BuildVersion", G_CALLBACK (
query_buildversion_cb), NULL);
1458 g_signal_connect (upnpIdService,
"query-variable::DeviceName", G_CALLBACK (
query_devicename_cb), NULL);
1459 g_signal_connect (upnpIdService,
"query-variable::ModelClass", G_CALLBACK (query_modelclass_cb), NULL);
1460 g_signal_connect (upnpIdService,
"query-variable::ModelNumber", G_CALLBACK (query_modelnumber_cb), NULL);
1461 g_signal_connect (upnpIdService,
"query-variable::DeviceId", G_CALLBACK (query_deviceid_cb), NULL);
1462 g_signal_connect (upnpIdService,
"query-variable::HardwareRevision", G_CALLBACK (query_hardwarerevision_cb), NULL);
1463 g_signal_connect (upnpIdService,
"query-variable::SoftwareRevision", G_CALLBACK (query_softwarerevision_cb), NULL);
1464 g_signal_connect (upnpIdService,
"query-variable::ManagementUrl", G_CALLBACK (query_managementurl_cb), NULL);
1465 g_signal_connect (upnpIdService,
"query-variable::Make", G_CALLBACK (query_make_cb), NULL);
1466 g_signal_connect (upnpIdService,
"query-variable::ReceiverId", G_CALLBACK (query_recev_id_cb), NULL);
1467 g_signal_connect (upnpIdService,
"query-variable::AccountId", G_CALLBACK (query_account_id_cb), NULL);
1469 g_signal_connect (upnpIdService,
"query-variable::ClientIP", G_CALLBACK (
query_client_ip_cb), NULL);
1472 int registerMediaConfigurationService(GUPnPServiceInfo *upnpMediaConfService)
1474 g_signal_connect (upnpMediaConfService,
"action-invoked::GetBaseUrl", G_CALLBACK (
get_url_cb), NULL);
1475 g_signal_connect (upnpMediaConfService,
"action-invoked::GetPlaybackUrl", G_CALLBACK (
get_playback_url_cb), NULL);
1478 g_signal_connect (upnpMediaConfService,
"query-variable::Url", G_CALLBACK (
query_url_cb), NULL);
1479 g_signal_connect (upnpMediaConfService,
"query-variable::PlaybackUrl", G_CALLBACK (
query_playback_url_cb), NULL);
1484 int registerGatewayConfigurationService(GUPnPServiceInfo *upnpGatewayConf)
1486 g_signal_connect (upnpGatewayConf,
"action-invoked::GetGatewayIP", G_CALLBACK (
get_gwyip_cb), NULL);
1487 g_signal_connect (upnpGatewayConf,
"action-invoked::GetGatewayIPv6", G_CALLBACK (
get_gwyipv6_cb), NULL);
1489 g_signal_connect (upnpGatewayConf,
"action-invoked::GetIpv6Prefix", G_CALLBACK (
get_ipv6prefix_cb), NULL);
1490 g_signal_connect (upnpGatewayConf,
"action-invoked::GetDnsConfig", G_CALLBACK (
get_dnsconfig_cb), NULL);
1492 g_signal_connect (upnpGatewayConf,
"action-invoked::GetGatewayStbIP", G_CALLBACK (
get_gwystbip_cb), NULL);
1493 g_signal_connect (upnpGatewayConf,
"action-invoked::GetHosts", G_CALLBACK (
get_hosts_cb), NULL);
1494 g_signal_connect (upnpGatewayConf,
"action-invoked::GetHostMacAddress", G_CALLBACK (
get_hostmacaddress_cb), NULL);
1496 g_signal_connect (upnpGatewayConf,
"action-invoked::GetIsGateway", G_CALLBACK (
get_isgateway_cb), NULL);
1497 g_signal_connect (upnpGatewayConf,
"action-invoked::GetIPSubNet", G_CALLBACK (
get_ipsubnet_cb), NULL);
1498 g_signal_connect (upnpGatewayConf,
"query-variable::GatewayIP", G_CALLBACK (
query_gwyip_cb), NULL);
1499 g_signal_connect (upnpGatewayConf,
"query-variable::GatewayIPv6", G_CALLBACK (
query_gwyipv6_cb), NULL);
1501 g_signal_connect (upnpGatewayConf,
"query-variable::Ipv6Prefix", G_CALLBACK (
query_ipv6prefix_cb), NULL);
1502 g_signal_connect (upnpGatewayConf,
"query-variable::DnsConfig", G_CALLBACK (
query_dnsconfig_cb), NULL);
1504 g_signal_connect (upnpGatewayConf,
"query-variable::GatewayStbIP", G_CALLBACK (
query_gwystbip_cb), NULL);
1505 g_signal_connect (upnpGatewayConf,
"query-variable::Hosts", G_CALLBACK (
query_hosts_cb), NULL);
1506 g_signal_connect (upnpGatewayConf,
"query-variable::HostMacAddress", G_CALLBACK (
query_hostmacaddress_cb), NULL);
1508 g_signal_connect (upnpGatewayConf,
"query-variable::IsGateway", G_CALLBACK (
query_isgateway_cb), NULL);
1509 g_signal_connect (upnpGatewayConf,
"query-variable::IPSubNet", G_CALLBACK (
query_ipsubnet_cb), NULL);
1512 int registerQamConfigurationService(GUPnPServiceInfo *upnpQamConf)
1514 g_signal_connect (upnpQamConf,
"action-invoked::GetBaseTrmUrl", G_CALLBACK (
get_trm_url_cb), NULL);
1515 g_signal_connect (upnpQamConf,
"action-invoked::GetSystemIds", G_CALLBACK (
get_systemids_cb), NULL);
1516 g_signal_connect (upnpQamConf,
"action-invoked::GetRequiresTRM", G_CALLBACK (
get_requirestrm_cb), NULL);
1517 g_signal_connect (upnpQamConf,
"query-variable::TrmUrl", G_CALLBACK (
query_trm_url_cb), NULL);
1518 g_signal_connect (upnpQamConf,
"query-variable::SystemIds", G_CALLBACK (
query_systemids_cb), NULL);
1519 g_signal_connect (upnpQamConf,
"query-variable::RequiresTRM", G_CALLBACK (
query_requirestrm_cb), NULL);
1522 int registerTimeConfigurationService(GUPnPServiceInfo *upnpTimeConf)
1524 g_signal_connect (upnpTimeConf,
"action-invoked::GetTimeZone", G_CALLBACK (
get_timezone_cb), NULL);
1525 g_signal_connect (upnpTimeConf,
"action-invoked::GetRawOffSet", G_CALLBACK (
get_rawoffset_cb), NULL);
1526 g_signal_connect (upnpTimeConf,
"action-invoked::GetDSTOffset", G_CALLBACK (
get_dstoffset_cb), NULL);
1527 g_signal_connect (upnpTimeConf,
"action-invoked::GetDSTSavings", G_CALLBACK (
get_dstsavings_cb), NULL);
1528 g_signal_connect (upnpTimeConf,
"action-invoked::GetUsesDaylightTime", G_CALLBACK (
get_usesdaylighttime_cb), NULL);
1529 g_signal_connect (upnpTimeConf,
"query-variable::TimeZone", G_CALLBACK (
query_timezone_cb), NULL);
1530 g_signal_connect (upnpTimeConf,
"query-variable::RawOffSet", G_CALLBACK (
query_rawoffset_cb), NULL);
1531 g_signal_connect (upnpTimeConf,
"query-variable::DSTOffset", G_CALLBACK (
query_dstoffset_cb), NULL);
1532 g_signal_connect (upnpTimeConf,
"query-variable::DSTSavings", G_CALLBACK (
query_dstsavings_cb), NULL);
1539 main (
int argc,
char **argv)
1541 GError *error = NULL;
1542 g_thread_init (NULL);
1543 char devConfFile[] =
"/etc/xdevice.conf";
1544 char *certFile=NULL, *keyFile=NULL;
1547 g_message(
"Starting XCAL-DEVICE ");
1549 xdeviceInit(devConfFile,NULL);
1551 rfc_enabled = check_rfc();
1554 g_message(
"Running Older Xcal Device");
1556 if(!(getDevXmlPath(devXMlPath)&& getDevXmlFile(devXMlFile,0) && getUUID(uUid) && getBcastPort(&devBcastPort) && getSerialNum(serial_Num) && getBcastIf(devBcastIf)))
1558 g_message(
"Failed to update the required gupnp xcal-device variables");
1561 g_message(
"xmlfilename=%s struuid=%s serial_Num=%s",devXMlFile,uUid,serial_Num);
1562 g_message(
"devBcastIf=%sdevBcastPort=%d",devBcastIf,devBcastPort);
1563 #ifdef INCLUDE_BREAKPAD
1564 breakpad_ExceptionHandler();
1566 char* xmlfilename = devXMlFile;
1567 const char* struuid = uUid;
1568 int result =
updatexmldata(xmlfilename, struuid, serial_Num,
"XFINITY");
1571 fprintf(stderr,
"Failed to open the device xml file %s\n", xmlfilename);
1576 g_message(
"Updated the device xml file:%s uuid: %s", xmlfilename,struuid);
1580 g_message(
"Unable to get bcastMacaddress");
1584 upnpContext = gupnp_context_new (NULL, devBcastIf, devBcastPort, &error);
1586 upnpContext = gupnp_context_new (devBcastIf, devBcastPort, &error);
1589 g_message(
"Error creating the Broadcast context: %s",
1592 g_clear_error(&error);
1593 return EXIT_FAILURE;
1595 gupnp_context_set_subscription_timeout(upnpContext, 0);
1597 baseDev = gupnp_root_device_new (upnpContext, devXMlFile, devXMlPath);
1599 baseDev = gupnp_root_device_new (upnpContext, devXMlFile, devXMlPath, &error);
1601 #ifndef CLIENT_XCAL_SERVER
1602 if(!getDisableTuneReadyStatus())
1606 g_message(
"Xupnp: Tune ready status is false");
1610 gupnp_root_device_set_available (baseDev,
TRUE);
1612 upnpService = gupnp_device_info_get_service
1613 (GUPNP_DEVICE_INFO (baseDev),
"urn:schemas-upnp-org:service:DiscoverFriendlies:1");
1616 g_printerr (
"Cannot get DiscoverFriendlies service\n");
1617 return EXIT_FAILURE;
1621 char devXMlFile_new[MAXSIZE];
1623 if(!getDevXmlFile(devXMlFile_new, 1))
1625 g_message(
"Unable to get new device xml file");
1627 char *xmlfilename_new = devXMlFile_new;
1630 if(getAccountId(accountId))
1632 g_message(
"Account Id of the device is %s", accountId);
1636 g_message(
"Failed to get the Account Id");
1638 if(strlen(bcastMacaddress) != 0)
1641 if (snprintf(uuid_new,
sizeof(uuid_new),
"uuid:%s",bcastMacaddress) > (
int)
sizeof(uuid_new)) {
1642 g_message(
"truncation while copying bcastMacaddress to uuid_new \n");
1646 if(xPKI_check_rfc() == 1)
1648 certFile= g_strdup(
"/tmp/xpki_cert");
1649 keyFile= g_strdup(
"/tmp/xpki_key");
1650 g_message(
"Using xPKI certs for handshaking");
1655 if ((getDevCertFile(devCertFile)) && (getDevCertPath(devCertPath)) && (getDevKeyFile(devKeyFile)) && (getDevKeyPath(devKeyPath)))
1657 if (g_path_is_absolute (devCertFile))
1659 certFile = g_strdup (devCertFile);
1663 certFile = g_build_filename (devCertPath, devCertFile, NULL);
1665 g_message(
"certFile loaded");
1667 if (g_path_is_absolute (devKeyFile))
1669 keyFile = g_strdup (devKeyFile);
1673 keyFile = g_build_filename (devKeyPath, devKeyFile, NULL);
1675 g_message(
"keyFile loaded ");
1680 if ( (certFile != NULL) && (keyFile != NULL) && (g_file_test(certFile, G_FILE_TEST_EXISTS)) && (g_file_test(keyFile, G_FILE_TEST_EXISTS))
1681 && (g_file_test(caFile, G_FILE_TEST_EXISTS)))
1683 result =
updatexmldata(xmlfilename_new, uuid_new, serial_Num,
"XFINITY");
1686 g_message(
"Failed to open the device xml file %s\n", xmlfilename_new);
1691 g_message(
"RFC enabled Updated the device xml file:%s uuid: %s", xmlfilename_new,uuid_new);
1696 upnpContextDeviceProtect = gupnp_context_new_s (NULL, devBcastIf, DEVICE_PROTECTION_CONTEXT_PORT, certFile, keyFile, &error);
1698 upnpContextDeviceProtect = gupnp_context_new_s ( devBcastIf, DEVICE_PROTECTION_CONTEXT_PORT, certFile, keyFile, &error);
1702 g_message(
"Error creating the Device Protection Broadcast context: %s",
1705 g_clear_error(&error);
1709 gupnp_context_set_subscription_timeout(upnpContextDeviceProtect, 0);
1711 gupnp_context_set_tls_params(upnpContextDeviceProtect,caFile,keyFile, NULL);
1713 dev = gupnp_root_device_new (upnpContextDeviceProtect, devXMlFile_new, devXMlPath);
1715 dev = gupnp_root_device_new (upnpContextDeviceProtect, devXMlFile_new, devXMlPath, &error);
1717 gupnp_root_device_set_available (dev,
TRUE);
1719 upnpIdService = gupnp_device_info_get_service
1720 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1Identity:1");
1723 g_message(
"Cannot get X1Identity service\n");
1727 g_message(
"XUPNP Identity service successfully created");
1729 if (strstr(devXMlFile_new,BROADBAND_DEVICE_XML_FILE) || strstr(devXMlFile_new,GW_DEVICE_XML_FILE))
1731 g_message(
"Broadband OR Gateway Device Configuration File");
1732 upnpTimeConf = gupnp_device_info_get_service
1733 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1Time:1");
1736 g_message(
"Cannot get XfinityTimeConfiguration service\n");
1740 g_message(
"XUPNP XfinityTimeConfiguration service successfully created");
1742 upnpGatewayConf = gupnp_device_info_get_service
1743 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1GatewayConfiguration:1");
1744 if (!upnpGatewayConf)
1746 g_message(
"Cannot get XfinityGatewayConfiguration service\n");
1750 g_message(
"XUPNP XfinityGatewayConfiguration service successfully created");
1755 g_message(
"Client Device configuration file");
1756 upnpMediaConfService = gupnp_device_info_get_service
1757 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1MediaConfiguration:1");
1758 if (!upnpMediaConfService)
1760 g_message(
"Cannot get XfinityMediaConfiguration service\n");
1764 g_message(
"XUPNP Media Configuration service successfully created");
1767 if (strstr(devXMlFile_new,GW_DEVICE_XML_FILE))
1769 g_message(
"Gateway Device Configuration file");
1770 upnpMediaConfService = gupnp_device_info_get_service
1771 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1MediaConfiguration:1");
1772 if (!upnpMediaConfService)
1774 g_message(
"Cannot get XfinityMediaConfiguration service\n");
1778 g_message(
"XUPNP Media Configuration service successfully created");
1780 upnpQamConf = gupnp_device_info_get_service
1781 (GUPNP_DEVICE_INFO (dev),
"urn:schemas-upnp-org:service:X1QamConfiguration:1");
1784 g_message(
"Cannot get XfinityQamConfiguration service\n");
1788 g_message(
"XUPNP XfinityQamConfiguration service successfully created");
1792 if (!getReceiverId(receiverId))
1794 g_message(
"Unable to get receiver id");
1800 g_message(
"DeviceProtection Error: Cert file, Key file not available, continuing with older xcal");
1802 result =
updatexmldata(xmlfilename, struuid, serial_Num,
"XFINITY");
1805 fprintf(stderr,
"Failed to open the device xml file %s\n", xmlfilename);
1810 g_message(
"Updated the device xml file:%s uuid: %s", xmlfilename,struuid);
1818 #ifdef ENABLE_SD_NOTIFY
1819 sd_notifyf(0,
"READY=1\n"
1820 "STATUS=xcal-device is Successfully Initialized\n"
1822 (
unsigned long) getpid());
1835 g_signal_connect (upnpService,
"action-invoked::GetBaseUrl", G_CALLBACK (
get_url_cb), NULL);
1836 g_signal_connect (upnpService,
"action-invoked::GetBaseTrmUrl", G_CALLBACK (
get_trm_url_cb), NULL);
1837 g_signal_connect (upnpService,
"action-invoked::GetGatewayIP", G_CALLBACK (
get_gwyip_cb), NULL);
1838 g_signal_connect (upnpService,
"action-invoked::GetGatewayIPv6", G_CALLBACK (
get_gwyipv6_cb), NULL);
1840 g_signal_connect (upnpService,
"action-invoked::GetIpv6Prefix", G_CALLBACK (
get_ipv6prefix_cb), NULL);
1841 g_signal_connect (upnpService,
"action-invoked::GetDnsConfig", G_CALLBACK (
get_dnsconfig_cb), NULL);
1843 g_signal_connect (upnpService,
"action-invoked::GetGatewayStbIP", G_CALLBACK (
get_gwystbip_cb), NULL);
1844 g_signal_connect (upnpService,
"action-invoked::GetSystemIds", G_CALLBACK (
get_systemids_cb), NULL);
1845 g_signal_connect (upnpService,
"action-invoked::GetTimeZone", G_CALLBACK (
get_timezone_cb), NULL);
1846 g_signal_connect (upnpService,
"action-invoked::GetHosts", G_CALLBACK (
get_hosts_cb), NULL);
1847 g_signal_connect (upnpService,
"action-invoked::GetRequiresTRM", G_CALLBACK (
get_requirestrm_cb), NULL);
1848 g_signal_connect (upnpService,
"action-invoked::GetHostMacAddress", G_CALLBACK (
get_hostmacaddress_cb), NULL);
1849 g_signal_connect (upnpService,
"action-invoked::GetRawOffSet", G_CALLBACK (
get_rawoffset_cb), NULL);
1850 g_signal_connect (upnpService,
"action-invoked::GetDSTOffset", G_CALLBACK (
get_dstoffset_cb), NULL);
1851 g_signal_connect (upnpService,
"action-invoked::GetDSTSavings", G_CALLBACK (
get_dstsavings_cb), NULL);
1852 g_signal_connect (upnpService,
"action-invoked::GetUsesDaylightTime", G_CALLBACK (
get_usesdaylighttime_cb), NULL);
1853 g_signal_connect (upnpService,
"action-invoked::GetPlaybackUrl", G_CALLBACK (
get_playback_url_cb), NULL);
1855 g_signal_connect (upnpService,
"action-invoked::GetDeviceName", G_CALLBACK (
get_devicename_cb), NULL);
1856 g_signal_connect (upnpService,
"action-invoked::GetIsGateway", G_CALLBACK (
get_isgateway_cb), NULL);
1857 g_signal_connect (upnpService,
"action-invoked::GetBcastMacAddress", G_CALLBACK (
get_bcastmacaddress_cb), NULL);
1858 g_signal_connect (upnpService,
"action-invoked::GetRecvDevType", G_CALLBACK (
get_recvdevtype_cb), NULL);
1859 g_signal_connect (upnpService,
"action-invoked::GetDeviceType", G_CALLBACK (get_devicetype_cb), NULL);
1860 g_signal_connect (upnpService,
"action-invoked::GetBuildVersion", G_CALLBACK (
get_buildversion_cb), NULL);
1861 g_signal_connect (upnpService,
"action-invoked::GetClientIP", G_CALLBACK (
get_client_ip_cb), NULL);
1862 g_signal_connect (upnpService,
"query-variable::Url", G_CALLBACK (
query_url_cb), NULL);
1863 g_signal_connect (upnpService,
"query-variable::TrmUrl", G_CALLBACK (
query_trm_url_cb), NULL);
1864 g_signal_connect (upnpService,
"query-variable::GatewayIP", G_CALLBACK (
query_gwyip_cb), NULL);
1865 g_signal_connect (upnpService,
"query-variable::GatewayIPv6", G_CALLBACK (
query_gwyipv6_cb), NULL);
1867 g_signal_connect (upnpService,
"query-variable::Ipv6Prefix", G_CALLBACK (
query_ipv6prefix_cb), NULL);
1868 g_signal_connect (upnpService,
"query-variable::DnsConfig", G_CALLBACK (
query_dnsconfig_cb), NULL);
1870 g_signal_connect (upnpService,
"query-variable::GatewayStbIP", G_CALLBACK (
query_gwystbip_cb), NULL);
1871 g_signal_connect (upnpService,
"query-variable::SystemIds", G_CALLBACK (
query_systemids_cb), NULL);
1872 g_signal_connect (upnpService,
"query-variable::TimeZone", G_CALLBACK (
query_timezone_cb), NULL);
1873 g_signal_connect (upnpService,
"query-variable::Hosts", G_CALLBACK (
query_hosts_cb), NULL);
1874 g_signal_connect (upnpService,
"query-variable::RequiresTRM", G_CALLBACK (
query_requirestrm_cb), NULL);
1876 g_signal_connect (upnpService,
"query-variable::RawOffSet", G_CALLBACK (
query_rawoffset_cb), NULL);
1877 g_signal_connect (upnpService,
"query-variable::DSTOffset", G_CALLBACK (
query_dstoffset_cb), NULL);
1878 g_signal_connect (upnpService,
"query-variable::DSTSavings", G_CALLBACK (
query_dstsavings_cb), NULL);
1880 g_signal_connect (upnpService,
"query-variable::PlaybackUrl", G_CALLBACK (
query_playback_url_cb), NULL);
1882 g_signal_connect (upnpService,
"query-variable::DeviceName", G_CALLBACK (
query_devicename_cb), NULL);
1883 g_signal_connect (upnpService,
"query-variable::IsGateway", G_CALLBACK (
query_isgateway_cb), NULL);
1885 g_signal_connect (upnpService,
"query-variable::RecvDevType", G_CALLBACK (
query_recvdevtype_cb), NULL);
1886 g_signal_connect (upnpService,
"query-variable::DeviceType", G_CALLBACK (query_devicetype_cb), NULL);
1887 g_signal_connect (upnpService,
"query-variable::BuildVersion", G_CALLBACK (
query_buildversion_cb), NULL);
1888 g_signal_connect (upnpService,
"query-variable::ClientIP", G_CALLBACK (
query_client_ip_cb), NULL);
1894 registerGatewayConfigurationService(upnpGatewayConf);
1895 registerTimeConfigurationService(upnpTimeConf);
1897 #ifndef CLIENT_XCAL_SERVER
1899 registerQamConfigurationService(upnpQamConf);
1900 registerGatewayConfigurationService(upnpGatewayConf);
1901 registerTimeConfigurationService(upnpTimeConf);
1902 registerMediaConfigurationService(upnpMediaConfService);
1905 registerMediaConfigurationService(upnpMediaConfService);
1908 registerIdentityConfigurationService(upnpIdService);
1909 g_message(
"Successfully registered all services");
1913 #ifndef CLIENT_XCAL_SERVER
1915 if (checkCVP2Enabled())
1917 if(!(getCVPIf(cvpInterface) && getCVPXmlFile(cvPXmlFile) && getCVPPort(&cvpPort)))
1919 g_message(
"Failed to update the CVP variables for xcal-device");
1921 char* cvpxmlfilename = g_strconcat(g_strstrip(devXMlPath),
"/", g_strstrip(cvPXmlFile),NULL);
1922 g_print(
"Starting CVP2 Service with %s\n", cvpxmlfilename);
1923 char * struuidcvp = NULL;
1927 struuidcvp = g_strconcat(
"uuid:AA5859B7-EFF4-42FD-BB92-", mac->str, NULL);
1928 g_string_free(mac,
TRUE);
1931 g_print(
"RemoteUIServerDevice UDN value: %s\n",struuidcvp);
1934 result =
updatexmldata(cvpxmlfilename, struuidcvp, serial_Num,
"XFINITY");
1939 g_free( cvpxmlfilename);
1943 g_printerr(
"Failed to open the RemoteUIServerDevice xml file\n");
1947 g_print(
"Updated the RemoteUIServerDevice xml file\n");
1949 cvpcontext = gupnp_context_new (NULL, cvpInterface, cvpPort, &error);
1951 cvpcontext = gupnp_context_new (cvpInterface, cvpPort, &error);
1954 g_printerr (
"Error creating the CVP context: %s\n", error->message);
1956 g_clear_error(&error);
1957 return EXIT_FAILURE;
1959 gupnp_context_set_subscription_timeout(cvpcontext, 0);
1961 cvpdev = gupnp_root_device_new (cvpcontext, cvPXmlFile, devXMlPath);
1963 cvpdev = gupnp_root_device_new (cvpcontext, cvPXmlFile, devXMlPath, &error);
1966 gupnp_root_device_set_available (cvpdev,
TRUE);
1967 cvpservice = gupnp_device_info_get_service
1968 (GUPNP_DEVICE_INFO (cvpdev),
"urn:schemas-upnp-org:service:RemoteUIServer:1");
1970 g_printerr (
"Cannot get RemoteUI service\n");
1971 return EXIT_FAILURE;
1973 g_signal_connect (cvpservice,
"action-invoked::GetCompatibleUIs", G_CALLBACK (
get_rui_url_cb), NULL);
1974 fprintf(stderr,
"exiting if dev-cvp\n");
1985 main_loop = g_main_loop_new (NULL, FALSE);
1986 g_main_loop_run (main_loop);
1988 g_main_loop_unref (main_loop);
1989 g_object_unref (upnpService);
1990 g_object_unref (baseDev);
1991 g_object_unref (upnpContext);
1994 g_object_unref (upnpIdService);
1995 if(upnpMediaConfService)
1997 g_object_unref (upnpMediaConfService);
2001 g_object_unref (upnpTimeConf);
2005 g_object_unref (upnpGatewayConf);
2009 g_object_unref (upnpQamConf);
2011 g_object_unref (dev);
2012 g_object_unref (upnpContextDeviceProtect);
2014 return EXIT_SUCCESS;