RDK Documentation (Open Sourced RDK Components)
xdiscovery.c File Reference

This source file contains functions that will run as task for maintaining the device list. More...

#include <libgupnp/gupnp-control-point.h>
#include <string.h>
#include <unistd.h>
#include <libgssdp/gssdp.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include "xdiscovery.h"
#include "xdiscovery_private.h"
#include "secure_wrapper.h"
#include <glib/gprintf.h>
#include <glib/gstdio.h>
#include "rdk_safeclib.h"
#include <libsoup/soup.h>
Include dependency graph for xdiscovery.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define OUTPLAYURL_SIZE   180
 
#define DEVICE_PROTECTION_CONTEXT_PORT   50760
 
#define ACCOUNTID_SIZE   30
 
#define MILESTONE_LOG_FILENAME   "/opt/logs/rdk_milestones.log"
 
#define RESTART_XDISCOVERY_FILE   "/tmp/restartedXdiscovery"
 
#define WAIT_TIME_SEC   5
 
#define PNAME   "/tmp/xpki_cert"
 
#define PID   21699
 
#define SHM_EXISTS   17
 

Typedefs

typedef GTlsInteraction XupnpTlsInteraction
 
typedef GTlsInteractionClass XupnpTlsInteractionClass
 

Functions

int getSoupStatusFromUrl (char *url)
 
static void xupnp_tls_interaction_init (XupnpTlsInteraction *interaction)
 
static void xupnp_tls_interaction_class_init (XupnpTlsInteractionClass *xupnpClass)
 
static gboolean getAccountId (char *outValue)
 
static gboolean update_gwylist (GwyDeviceData *gwydata)
 Check for any addition or deletion of gateway from the list. If any update occurs, this routine will validate and add/delete the entry to/from the gateway list and the updated list will be published to others. More...
 
GType xupnp_tls_interaction_get_type (void)
 
 G_DEFINE_TYPE (XupnpTlsInteraction, xupnp_tls_interaction, G_TYPE_TLS_INTERACTION)
 
static void addRouteToMocaBridge (char *subnetip)
 
static GTlsInteractionResult xupnp_tls_interaction_request_certificate (GTlsInteraction *interaction, GTlsConnection *connection, GTlsCertificateRequestFlags flags, GCancellable *cancellable, GError **error)
 
int xPKI_check_rfc ()
 
int check_rfc ()
 
void xupnp_logger (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
 This function is used to log the messages of XUPnP applications. Each Log message will be written to a file along with the timestamp formated in ISO8601 format. More...
 
static gint g_list_find_sno (GwyDeviceData *gwData, gconstpointer *sno)
 
static gint g_list_find_udn (GwyDeviceData *gwData, gconstpointer *udn)
 
static gint g_list_compare_sno (GwyDeviceData *gwData1, GwyDeviceData *gwData2, gpointer user_data)
 
gboolean checkDeviceExists (const char *sno, char *outPlayUrl)
 This will Scan through the device list to check whether a particular device entry exists. More...
 
static void device_proxy_unavailable_cb (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_unavailable_cb_client (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_unavailable_cb_gw (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_available_cb (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_available_cb_client (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_available_cb_gw (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_unavailable_cb_bgw (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
static void device_proxy_available_cb_bgw (GUPnPControlPoint *cp, GUPnPDeviceProxy *dproxy)
 
int main (int argc, char *argv[])
 
gboolean processBooleanRequest (const GUPnPServiceProxy *sproxy, const char *requestFn, const char *responseFn, gboolean *result, gboolean isInCriticalPath)
 This function is used to retrieve a boolean parameter from discovered data. Use this function only when there are no parameters passed to the action call. More...
 
gboolean processStringRequest (const GUPnPServiceProxy *sproxy, const char *requestFn, const char *responseFn, gchar **result, gboolean isInCriticalPath)
 This function is used to retrieve a string parameter from discovered data. Use this function only when there are no parameters passed to the action call. More...
 
gboolean processIntRequest (const GUPnPServiceProxy *sproxy, const char *requestFn, const char *responseFn, guint *result, gboolean isInCriticalPath)
 This function is used to retrieve a int parameter from discovered data. Use this function only when there are no parameters passed to the action call. More...
 
gboolean process_gw_services (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 This function is used to get attributes of different Gateway services using GUPnP Service Proxy. More...
 
gboolean process_gw_services_identity (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 
gboolean process_gw_services_media_config (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 
gboolean process_gw_services_gateway_config (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 
gboolean process_gw_services_time_config (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 
gboolean process_gw_services_qam_config (GUPnPServiceProxy *sproxy, GwyDeviceData *gwData)
 
gboolean replace_hn_with_local (GwyDeviceData *gwyData)
 Replace IP Address part of the Gateway URL attributes from home networking IP with the local host IP. It Replaces the URL attribute of playbackurl, baseurl, basetrmurl. More...
 
gboolean init_gwydata (GwyDeviceData *gwydata)
 Initializes gateway attributes such as serial number, IP details , MAC details, URL details etc. More...
 
gboolean free_gwydata (GwyDeviceData *gwydata)
 Uninitialize gateway data attributes by resetting them to default value. More...
 
gboolean delete_gwyitem (const char *serial_num)
 Deletes a gateway entry from the list of Gateway devices if it matches with the serial number supplied as input. More...
 
gboolean sendDiscoveryResult (const char *outfilename)
 This will store the updated device discovery results in local storage as JSON formatted data. More...
 
void * verify_devices ()
 Verify and update the gateway list according to the availability of the gateway devices connected to the network. New devices will be added to the list and dead devices will be deleted from the list.
 
void delOldItemsFromList (gboolean bDeleteAll)
 Delete all the devices from the device list or delete devices marked as "Not Found" from device list. More...
 
static void on_last_change (GUPnPServiceProxy *sproxy, const char *variable_name, GValue *value, gpointer user_data)
 
gboolean readconffile (const char *configfile)
 This will parse and load the configuration file in a key/value pair format as specified in GLib encoding. The configuration file contain attributes which are categorized into following: More...
 
gboolean getserialnum (GString *ownSerialNo)
 Get the serial number of the device from Vendor specific UDHCPC config file. More...
 
char * replace_string (char *src_string, char *sub_string, char *replace_string)
 Replace all occurrences of a sub-string in the given string to value the specified. More...
 
int getipaddress (const char *ifname, char *ipAddressBuffer, gboolean ipv6Enabled)
 This function gets the IP address for the given interface. The IP Address will be formatted to IPv6 or IPv4 address depending upon the configuration. More...
 
gboolean replace_local_device_ip (GwyDeviceData *gwydata)
 When the discovered device is the own device then MOcA IP is replaced. More...
 
gboolean checkvalidip (char *ipAddress)
 This will check whether the input IP Address is a valid IPv4 or IPv6 address. More...
 
gboolean checkvalidhostname (char *hostname)
 This function will check whether a Host name is valid by validating all the associated IP addresses. More...
 
gchar * getmacaddress (const gchar *ifname)
 This function is used to get the mac address of the target device. More...
 

Variables

int gatewayDetected =0
 
gboolean partialDiscovery =FALSE
 
const char * localHostIP ="127.0.0.1"
 
static int rfc_enabled
 
static GMainLoop * main_loop
 
gboolean checkDevAddInProgress =FALSE
 
guint deviceAddNo =0
 
char * cert_File =NULL
 
char * key_File =NULL
 
char * ca_File ="/tmp/UPnP_CA"
 
char accountId [30] ={'\0',}
 
gboolean selfDeviceDiscovered =FALSE
 
gboolean bSerialNum =FALSE
 

yes

This source file contains functions that will run as task for maintaining the device list.

Definition in file xdiscovery.c.