RDK Documentation (Open Sourced RDK Components)
XUPnP XCal-Discovery Functions

Description

Describe the details about XUPnP XCal-Discovery specifications.

Functions

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...
 
gboolean checkDeviceExists (const char *sno, char *outPlayUrl)
 This will Scan through the device list to check whether a particular device entry exists. More...
 
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 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...
 
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...
 
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...
 
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...
 

Function Documentation

◆ xupnp_logger()

void xupnp_logger ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
)

This function is used to log the messages of XUPnP applications. Each Log message will be written to a file along with the timestamp formated in ISO8601 format.

Parameters
[in]log_domainDefines the log domain. For applications, this is typically left as the default NULL domain. Libraries should define this so that any messages that they log can be differentiated from messages from other libraries/applications.
[in]log_levelLog level used to categorize messages of type warning, error, info, debug etc.
[in]messageThe Message to be logged represented in string format.
[in]user_dataContains the Log file name.

Definition at line 859 of file xdiscovery.c.

◆ checkDeviceExists()

gboolean checkDeviceExists ( const char *  sno,
char *  outPlayUrl 
)

This will Scan through the device list to check whether a particular device entry exists.

It will Match the device serial number in the list to find the desired device entry.

Parameters
[in]snoSerial number of the device represented in string format.
Returns
Returns TRUE if serial number is present in the device list else returns FALSE.

Definition at line 919 of file xdiscovery.c.

◆ processBooleanRequest()

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.

Parameters
[in]sproxyThe Service proxy object
[in]requestFnThe required parameter to be retrieved
[in]responseFnThe function to retrieve requried function
[out]resultthe result to be stored.
[in]isInCriticalPathif true, a log message will be printed for telemetry
Returns
Returns TRUE if the gateway service requests processed successfully else returns FALSE.

Definition at line 2005 of file xdiscovery.c.

◆ processStringRequest()

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.

Parameters
[in]sproxyThe Service proxy object
[in]requestFnThe required parameter to be retrieved
[in]responseFnThe function to retrieve requried function
[out]resultthe result to be stored.
[in]isInCriticalPathif true, a log message will be printed for telemetry
Returns
Returns TRUE if the gateway service requests processed successfully else returns FALSE.

Definition at line 2050 of file xdiscovery.c.

◆ processIntRequest()

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.

Parameters
[in]sproxyThe Service proxy object
[in]requestFnThe required parameter to be retrieved
[in]responseFnThe function to retrieve requried function
[out]resultthe result to be stored.
[in]isInCriticalPathif true, a log message will be printed for telemetry
Returns
Returns TRUE if the gateway service requests processed successfully else returns FALSE.

Definition at line 2095 of file xdiscovery.c.

◆ process_gw_services()

gboolean process_gw_services ( GUPnPServiceProxy *  sproxy,
GwyDeviceData gwData 
)

This function is used to get attributes of different Gateway services using GUPnP Service Proxy.

GUPnP Service Proxy sends commands to a remote UPnP service and handles incoming event notifications. It will request the proxy to get services and attributes such as:

  • Base TRM URL.
  • Playback URL.
  • Gateway IP.
  • DNS Configuration.
  • Device Type.
  • Time Zone.
  • DST (Daylight Saving Time).
  • MAC Address.
  • System ID and so on.
Parameters
[in]sproxyAddress of the GUPnP Service Proxy instance.
[in]gwDataAddress of the Structure holding gateway service attributes.
Returns
Returns TRUE if the gateway service requests processed successfully else returns FALSE.

Definition at line 2149 of file xdiscovery.c.

◆ replace_hn_with_local()

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.

Parameters
[in]gwyDataAddress of the structure holding Gateway attributes.
Returns
Returns TRUE indicating the call has finished.

Definition at line 2709 of file xdiscovery.c.

◆ init_gwydata()

gboolean init_gwydata ( GwyDeviceData gwydata)

Initializes gateway attributes such as serial number, IP details , MAC details, URL details etc.

Parameters
[in]gwyDataAddress of the structure holding gateway attributes.
Returns
Returns TRUE indicating the call has finished.

Definition at line 2744 of file xdiscovery.c.

◆ free_gwydata()

gboolean free_gwydata ( GwyDeviceData gwydata)

Uninitialize gateway data attributes by resetting them to default value.

Parameters
[in]gwyDataAddress of the structure variable holding Gateway attributes.
Returns
Returns a boolean value indicating success/failure of the call.

Definition at line 2803 of file xdiscovery.c.

◆ update_gwylist()

gboolean update_gwylist ( GwyDeviceData gwydata)
static

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.

Parameters
[in]gwyDataAddress of the structure holding Gateway attributes.
Returns
Returns TRUE if successfully updated the gateway list else returns FALSE.

Definition at line 2870 of file xdiscovery.c.

◆ delete_gwyitem()

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.

Parameters
[in]serial_numSerial number of the gateway device represented in string format.
Returns
Returns TRUE if successfully deleted an item from the Gateway device list else returns FALSE.

Definition at line 2999 of file xdiscovery.c.

◆ sendDiscoveryResult()

gboolean sendDiscoveryResult ( const char *  outfilename)

This will store the updated device discovery results in local storage as JSON formatted data.

Whenever there's add/delete of gateway list it will create a json file, and all service variables will be added to output.json. It will notify to all the listeners that listen for change of xupnp data.

Parameters
[in]outfilenameName of the output file to store JSON data.
Returns
Returns TRUE when successfully stored the device discovery result else returns FALSE.

Definition at line 3087 of file xdiscovery.c.

◆ delOldItemsFromList()

void delOldItemsFromList ( gboolean  bDeleteAll)

Delete all the devices from the device list or delete devices marked as "Not Found" from device list.

Parameters
[in]bDeleteAllBoolean variable indicating whether to delete all entries.

Definition at line 3637 of file xdiscovery.c.

◆ readconffile()

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:

This function is used to retrieve the data from the device configuration file.

  • Network : Contains parameters such as interface name, IP etc.
  • Datafiles : Contains Name of Script and Log files.
Parameters
[in]configfileName of the configuration file.
Returns
Returns TRUE if successfully loaded the configuration file in GKey file structure else returns FALSE.

Definition at line 3812 of file xdiscovery.c.

◆ getserialnum()

gboolean getserialnum ( GString *  ownSerialNo)

Get the serial number of the device from Vendor specific UDHCPC config file.

This function is used to get the serial number of the device from the vendor specific file.

Parameters
[out]ownSerialNoAddress of the string to return the Serial number.
Returns
Returns TRUE if successfully get the own serial number else returns FALSE.

Definition at line 3907 of file xdiscovery.c.

◆ replace_string()

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.

Parameters
[in]src_stringSource String.
[in]sub_stringSub string which has to be searched and replaced.
[in]replace_stringNew sub string that will be replaced.
Returns
Returns TRUE if successfully replaced the sub string with replace string else returns FALSE.

Definition at line 4009 of file xdiscovery.c.

◆ getipaddress()

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.

This function is used to get the IP address based on IPv6 or IPv4 is enabled.

Parameters
[in]ifnameName of the network interface.
[out]ipAddressBufferString which will store the result IP Address.
[in]ipv6EnabledBoolean value indicating whether IPv6 is enabled.
Returns
Returns an Integer value.
Return values
1If an IP address is found.
0If No IP address found on specified interface.

Definition at line 4063 of file xdiscovery.c.

◆ replace_local_device_ip()

gboolean replace_local_device_ip ( GwyDeviceData gwydata)

When the discovered device is the own device then MOcA IP is replaced.

Parameters
[in]gwyDataAddress of structure holding the Gateway device attributes.
Returns
Returns TRUE if successfully replaced the IP else returns FALSE.

Definition at line 4130 of file xdiscovery.c.

◆ checkvalidip()

gboolean checkvalidip ( char *  ipAddress)

This will check whether the input IP Address is a valid IPv4 or IPv6 address.

Parameters
[in]ipAddressIP Address in string format.
Returns
Returns TRUE if IP address is valid else returns FALSE.

Definition at line 4153 of file xdiscovery.c.

◆ checkvalidhostname()

gboolean checkvalidhostname ( char *  hostname)

This function will check whether a Host name is valid by validating all the associated IP addresses.

Parameters
[in]hostnameHost name represented as a string.
Returns
Returns TRUE if host name is valid else returns FALSE.

Definition at line 4184 of file xdiscovery.c.