cdevice.h File Reference

#include <cybergarage/typedef.h>
#include <cybergarage/xml/cxml.h>
#include <cybergarage/util/clist.h>
#include <cybergarage/util/cstring.h>
#include <cybergarage/util/cmutex.h>
#include <cybergarage/util/cthread.h>
#include <cybergarage/http/chttp.h>
#include <cybergarage/net/curl.h>
#include <cybergarage/net/cinterface.h>
#include <cybergarage/upnp/cservice.h>
#include <cybergarage/upnp/cicon.h>
#include <cybergarage/upnp/ssdp/cssdp_server.h>

Data Structures

struct  _CgUpnpDevice
 The generic UPnP device structure. More...

Defines

#define CG_UPNP_DEVICE_ELEM_NAME   "device"
#define CG_UPNP_DEVICELIST_ELEM_NAME   "deviceList"
#define CG_UPNP_DEVICE_UPNP_ROOTDEVICE   "upnp:rootdevice"
#define CG_UPNP_DEVICE_DEFAULT_STARTUP_WAIT_TIME   1000
#define CG_UPNP_DEVICE_DEFAULT_DISCOVERY_WAIT_TIME   500
#define CG_UPNP_DEVICE_DEFAULT_LEASE_TIME   (30 * 60)
#define CG_UPNP_DEVICE_HTTP_DEFAULT_PORT   38400
#define CG_UPNP_DEVICE_DEFAULT_DESCRIPTION_URI   "/description.xml"
#define CG_UPNP_DEVICE_URLBASE_MAXLEN   64
#define CG_UPNP_DEVICE_M_SEARCH_FILTER_INTERVAL   15
#define CG_UPNP_DEVICE_URLBASE_NAME   "URLBase"
#define CG_UPNP_DEVICE_DEVICE_TYPE   "deviceType"
#define CG_UPNP_DEVICE_FRIENDLY_NAME   "friendlyName"
#define CG_UPNP_DEVICE_MANUFACTURE   "manufacture"
#define CG_UPNP_DEVICE_MANUFACTURE_URL   "manufactureURL"
#define CG_UPNP_DEVICE_MODEL_DESCRIPTION   "modelDescription"
#define CG_UPNP_DEVICE_MODEL_NAME   "modelName"
#define CG_UPNP_DEVICE_MODEL_NUMBER   "modelNumber"
#define CG_UPNP_DEVICE_MODEL_URL   "modelURL"
#define CG_UPNP_DEVICE_SERIAL_NUMBER   "serialNumber"
#define CG_UPNP_DEVICE_UDN   "UDN"
#define CG_UPNP_DEVICE_UPC   "UPC"
#define CG_UPNP_DEVICE_PRESENTATION_URL   "presentationURL"
#define cg_upnp_device_next(dev)   (CgUpnpDevice *)cg_list_next((CgList *)dev)
#define cg_upnp_device_remove(dev)   cg_list_remove((CgList *)dev)
#define cg_upnp_device_isdevicenode(node)   cg_xml_node_isname(node, CG_UPNP_DEVICE_ELEM_NAME)
#define cg_upnp_device_getrootnode(dev)   cg_xml_nodelist_gets(dev->rootNodeList)
#define cg_upnp_device_getdevicenode(dev)   (dev->deviceNode)
#define cg_upnp_device_isrootdevice(dev)   ((dev->rootNodeList != NULL) ? TRUE : FALSE)
#define cg_upnp_device_setparentdevice(dev, pDev)   (dev->parentDevice = pDev)
#define cg_upnp_device_getparentdevice(dev)   (dev->parentDevice)
#define cg_upnp_device_setdevicetype(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_DEVICE_TYPE, value)
#define cg_upnp_device_getdevicetype(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_DEVICE_TYPE)
#define cg_upnp_device_isdevicetype(dev, value)   cg_streq(cg_upnp_device_getdevicetype(dev), value)
#define cg_upnp_device_setfriendlyname(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_FRIENDLY_NAME, value)
#define cg_upnp_device_getfriendlyname(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_FRIENDLY_NAME)
#define cg_upnp_device_setmanufacture(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE, value)
#define cg_upnp_device_getmanufacture(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE)
#define cg_upnp_device_setmanufactureurl(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE_URL, value)
#define cg_upnp_device_getmanufactureurl(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE_URL)
#define cg_upnp_device_setmodeldescription(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_DESCRIPTION, value)
#define cg_upnp_device_getmodeldescription(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_DESCRIPTION)
#define cg_upnp_device_setmodelname(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NAME, value)
#define cg_upnp_device_getmodelname(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NAME)
#define cg_upnp_device_setmodelnumber(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NUMBER, value)
#define cg_upnp_device_getmodelnumber(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NUMBER)
#define cg_upnp_device_setmodelurl(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_URL, value)
#define cg_upnp_device_getmodelurl(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_URL)
#define cg_upnp_device_setserialnumber(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_SERIAL_NUMBER, value)
#define cg_upnp_device_getserialnumber(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_SERIAL_NUMBER)
#define cg_upnp_device_setudn(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UDN, value)
#define cg_upnp_device_getudn(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UDN)
#define cg_upnp_device_hasudn(dev)   ((0 < cg_strlen(cg_upnp_device_getudn(dev))) ? TRUE : FALSE)
#define cg_upnp_device_setupc(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UPC, value)
#define cg_upnp_device_getupc(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UPC)
#define cg_upnp_device_setpresentationurl(dev, value)   cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_PRESENTATION_URL, value)
#define cg_upnp_device_getpresentationurl(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_PRESENTATION_URL)
#define cg_upnp_device_geturlbase(dev)   cg_xml_node_getchildnodevalue(cg_upnp_device_getrootnode(cg_upnp_device_getrootdevice(dev)), CG_UPNP_DEVICE_URLBASE_NAME)
#define cg_upnp_device_lock(dev)   cg_mutex_lock(dev->mutex)
#define cg_upnp_device_unlock(dev)   cg_mutex_unlock(dev->mutex)
#define cg_upnp_device_setuserdata(dev, value)   (dev->userData = value)
#define cg_upnp_device_getuserdata(dev)   (dev->userData)
#define cg_upnp_device_setdescriptionuri(dev, url)   cg_string_setvalue(dev->descriptionURI, url)
#define cg_upnp_device_getdescriptionuri(dev)   cg_string_getvalue(dev->descriptionURI)
#define cg_upnp_device_isdescriptionuri(dev, url)   cg_streq(cg_string_getvalue(dev->descriptionURI), url)
#define cg_upnp_device_setleasetime(dev, value)   (dev->leaseTime = value)
#define cg_upnp_device_getleasetime(dev)   (dev->leaseTime)
#define cg_upnp_device_getdevicelist(dev)   (dev->deviceList)
#define cg_upnp_device_getdevice(dev, idx)   ((CgUpnpDevice *)cg_list_get(dev->deviceList,idx))
#define cg_upnp_device_getdevices(dev)   ((CgUpnpDevice *)cg_list_gets((CgList *)dev->deviceList))
#define cg_upnp_device_getservicelist(dev)   (dev->serviceList)
#define cg_upnp_device_getservice(dev, idx)   ((CgUpnpService *)cg_list_get(dev->serviceList,idx))
#define cg_upnp_device_getservices(dev)   ((CgUpnpService *)cg_list_gets((CgList *)dev->serviceList))
#define cg_upnp_device_geticonlist(dev)   (dev->iconList)
#define cg_upnp_device_geticon(dev, idx)   ((CgUpnpIcon *)cg_list_get((CgList *)dev->iconList,idx))
#define cg_upnp_device_geticons(dev)   ((CgUpnpIcon *)cg_list_gets((CgList *)dev->iconList))
#define cg_upnp_devicelist_clear(devList)   cg_list_clear((CgList *)devList, (CG_LIST_DESTRUCTORFUNC)cg_upnp_device_delete)
#define cg_upnp_devicelist_size(devList)   cg_list_size((CgList *)devList)
#define cg_upnp_devicelist_gets(devList)   (CgUpnpDevice *)cg_list_next((CgList *)devList)
#define cg_upnp_devicelist_add(devList, dev)   cg_list_add((CgList *)devList, (CgList *)dev)
#define cg_upnp_service_getdevice(service)   ((CgUpnpDevice *)service->parentDevice)
#define cg_upnp_service_getrootdevice(service)   cg_upnp_device_getrootdevice((CgUpnpDevice *)service->parentDevice)
#define cg_upnp_device_sethttpport(dev, value)   (dev->httpPort = value)
#define cg_upnp_device_gethttpport(dev)   (dev->httpPort)
#define cg_upnp_device_sethttplistener(dev, func)   (dev->httpListener = func)
#define cg_upnp_device_gethttplistener(dev)   (dev->httpListener)
#define cg_upnp_device_getssdpserverlist(dev)   (dev->ssdpServerList)
#define cg_upnp_device_getssdppacket(dev)   (dev->ssdpPkt)
#define cg_upnp_device_setssdppacket(dev, srcSsdpPkt)   cg_upnp_ssdp_packet_copy(dev->ssdpPkt, srcSsdpPkt)
#define cg_upnp_device_getlocationfromssdppacket(dev)   cg_upnp_ssdp_packet_getlocation(dev->ssdpPkt)
#define cg_upnp_device_getinterfaceaddressfromssdppacket(dev)   cg_upnp_ssdp_packet_getlocaladdress(dev->ssdpPkt)
#define cg_upnp_device_getadvertiserthead(dev)   (dev->advertiser)

Typedefs

typedef _CgUpnpDevice CgUpnpDevice
 The generic UPnP device structure.
typedef _CgUpnpDevice CgUpnpDeviceList
 The generic UPnP device structure.

Functions

CgUpnpDevicecg_upnp_device_new ()
void cg_upnp_device_delete (CgUpnpDevice *dev)
void cg_upnp_device_clear (CgUpnpDevice *dev)
void cg_upnp_device_setdevicenode (CgUpnpDevice *dev, CgXmlNode *node)
CgUpnpDevicecg_upnp_device_getrootdevice (CgUpnpDevice *dev)
BOOL cg_upnp_device_parsedescription (CgUpnpDevice *dev, char *desciption, int descriptionLen)
BOOL cg_upnp_device_parsedescriptionurl (CgUpnpDevice *dev, CgNetURL *url)
BOOL cg_upnp_device_loaddescriptionfile (CgUpnpDevice *dev, char *fileName)
BOOL cg_upnp_device_updatefromssdppacket (CgUpnpDevice *dev, CgUpnpSSDPPacket *ssdpPkt)
char * cg_upnp_devicetype_getidentifier (char *deviceType)
char * cg_upnp_devicetype_geturn (char *deviceType)
char * cg_upnp_devicetype_getdevice (char *deviceType)
char * cg_upnp_devicetype_gettype (char *deviceType)
char * cg_upnp_devicetype_getschematype (char *deviceType)
char * cg_upnp_devicetype_getversion (char *deviceType)
void cg_upnp_device_seturlbase (CgUpnpDevice *dev, char *value)
BOOL cg_upnp_device_start (CgUpnpDevice *dev)
BOOL cg_upnp_device_stop (CgUpnpDevice *dev)
char * cg_upnp_device_getlocationurl (CgUpnpDevice *dev, char *host, char *buf, int bufSize)
void cg_upnp_device_announce (CgUpnpDevice *dev)
void cg_upnp_device_byebye (CgUpnpDevice *dev)
void cg_upnp_device_setactionlistener (CgUpnpDevice *dev, CG_UPNP_ACTION_LISTNER actionListner)
void cg_upnp_device_setquerylistener (CgUpnpDevice *dev, CG_UPNP_STATEVARIABLE_LISTNER queryListner)
CgUpnpDevicecg_upnp_device_getdevicebyexacttype (CgUpnpDevice *dev, char *exacttype)
CgUpnpDevicecg_upnp_device_getdevicebytype (CgUpnpDevice *dev, char *type)
CgUpnpDevicecg_upnp_device_getdevicebyudn (CgUpnpDevice *dev, char *udn)
CgUpnpDevicecg_upnp_device_getdevicebydescriptionuri (CgUpnpDevice *dev, char *url)
CgUpnpServicecg_upnp_device_getservicebyserviceid (CgUpnpDevice *dev, char *serviceId)
CgUpnpServicecg_upnp_device_getservicebyexacttype (CgUpnpDevice *dev, char *type)
CgUpnpServicecg_upnp_device_getservicebytype (CgUpnpDevice *dev, char *type)
CgUpnpServicecg_upnp_device_getservicebysid (CgUpnpDevice *dev, char *sid)
CgUpnpServicecg_upnp_device_getservicebyscpdurl (CgUpnpDevice *dev, char *url)
CgUpnpServicecg_upnp_device_getservicebycontrolurl (CgUpnpDevice *dev, char *url)
CgUpnpServicecg_upnp_device_getservicebyeventsuburl (CgUpnpDevice *dev, char *url)
CgUpnpActioncg_upnp_device_getactionbyname (CgUpnpDevice *dev, char *name)
CgUpnpStateVariablecg_upnp_device_getstatevariablebyname (CgUpnpDevice *dev, char *name)
CgUpnpDeviceListcg_upnp_devicelist_new ()
void cg_upnp_devicelist_delete (CgUpnpDeviceList *devList)
void cg_upnp_device_httprequestrecieved (CgHttpRequest *httpReq)
void cg_upnp_device_ssdplistener (CgUpnpSSDPPacket *ssdpPkt)
char * cg_upnp_device_getnotifydevicent (CgUpnpDevice *dev, char *buf, int bufSize)
char * cg_upnp_device_getnotifydeviceusn (CgUpnpDevice *dev, char *buf, int bufSize)
char * cg_upnp_device_getnotifydevicetypent (CgUpnpDevice *dev, char *buf, int bufSize)
char * cg_upnp_device_getnotifydevicetypeusn (CgUpnpDevice *dev, char *buf, int bufSize)
void cg_upnp_device_ssdpmessagereceived (CgUpnpDevice *dev, CgUpnpSSDPPacket *ssdpPkt, int filter)
BOOL cg_upnp_device_postsearchresponse (CgUpnpDevice *dev, CgUpnpSSDPPacket *ssdpPkt, char *st, char *usn)
BOOL cg_upnp_device_ipchanged (CgUpnpDevice *dev)
BOOL cg_upnp_device_advertiser_start (CgUpnpDevice *dev)
BOOL cg_upnp_device_advertiser_stop (CgUpnpDevice *dev)

Define Documentation

#define CG_UPNP_DEVICE_DEFAULT_DESCRIPTION_URI   "/description.xml"

Definition for default description file "location"

#define CG_UPNP_DEVICE_DEFAULT_DISCOVERY_WAIT_TIME   500

Definition for default device discovery wait time

#define CG_UPNP_DEVICE_DEFAULT_LEASE_TIME   (30 * 60)

Definition for default device lease time

#define CG_UPNP_DEVICE_DEFAULT_STARTUP_WAIT_TIME   1000

Definition for default device start up wait time

#define CG_UPNP_DEVICE_DEVICE_TYPE   "deviceType"

Definition for device type XML element name

#define CG_UPNP_DEVICE_ELEM_NAME   "device"

Definition for device XML element name

#define CG_UPNP_DEVICE_FRIENDLY_NAME   "friendlyName"

Definition for device friendly name XML element name

#define cg_upnp_device_getadvertiserthead ( dev   )     (dev->advertiser)

Get the advertiser thread from the device

Parameters:
dev The device in question

#define cg_upnp_device_getdescriptionuri ( dev   )     cg_string_getvalue(dev->descriptionURI)

Get the device's description URI

Parameters:
dev Device in question

#define cg_upnp_device_getdevice ( dev,
idx   )     ((CgUpnpDevice *)cg_list_get(dev->deviceList,idx))

Find a certain device from the given device list

Parameters:
dev Device in question
idx Device index number in list
Returns:
NULL if not found; otherwise the device pointer

#define cg_upnp_device_getdevicelist ( dev   )     (dev->deviceList)

Get the device's internal device list

Parameters:
dev Device in question

#define cg_upnp_device_getdevicenode ( dev   )     (dev->deviceNode)

Return the device XML description node

Parameters:
dev Device in question

#define cg_upnp_device_getdevices ( dev   )     ((CgUpnpDevice *)cg_list_gets((CgList *)dev->deviceList))

Todo:
Correct explanation...
Parameters:
dev Device in question

#define cg_upnp_device_getdevicetype ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_DEVICE_TYPE)

Return the device type

Parameters:
dev Device in question
Returns:
Device type

#define cg_upnp_device_getfriendlyname ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_FRIENDLY_NAME)

Return the device's friendly name.

Parameters:
dev Device in question
Returns:
The device's friendly name

#define cg_upnp_device_gethttplistener ( dev   )     (dev->httpListener)

Get the device's HTTP listener function

Parameters:
dev The device in question

#define cg_upnp_device_gethttpport ( dev   )     (dev->httpPort)

Get the device's HTTP port

Parameters:
dev The device in question

#define cg_upnp_device_geticon ( dev,
idx   )     ((CgUpnpIcon *)cg_list_get((CgList *)dev->iconList,idx))

Get an icon by its index from the device's list of icons

Parameters:
dev Device in question
idx Icon index number

#define cg_upnp_device_geticonlist ( dev   )     (dev->iconList)

Get the device's list of icons

Parameters:
dev Device in question

#define cg_upnp_device_geticons ( dev   )     ((CgUpnpIcon *)cg_list_gets((CgList *)dev->iconList))

Todo:
Correct explanation...
Parameters:
dev Device in question

#define cg_upnp_device_getinterfaceaddressfromssdppacket ( dev   )     cg_upnp_ssdp_packet_getlocaladdress(dev->ssdpPkt)

Extract the interface address from the device's SSDP packet

Parameters:
dev The device in question

#define cg_upnp_device_getleasetime ( dev   )     (dev->leaseTime)

Get the device's lease time. See cg_upnp_device_setleasetime.

Parameters:
dev Device in question

#define cg_upnp_device_getlocationfromssdppacket ( dev   )     cg_upnp_ssdp_packet_getlocation(dev->ssdpPkt)

Extract location information from the device's SSDP packet

Parameters:
dev The device in question

#define cg_upnp_device_getmanufacture ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE)

Get the device's manufacturer.

Parameters:
dev Device in question
Returns:
value The manufacturer's name

#define cg_upnp_device_getmanufactureurl ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE_URL)

Get the device's manufacturer URL

Parameters:
dev Device in question
Returns:
The manufacturer URL

#define cg_upnp_device_getmodeldescription ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_DESCRIPTION)

Get the device model description

Parameters:
dev Device in question
Returns:
The device model description

#define cg_upnp_device_getmodelname ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NAME)

Get the device's model name

Parameters:
dev Device in question
Returns:
The model name

#define cg_upnp_device_getmodelnumber ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NUMBER)

Get the device's model number

Parameters:
dev Device in question
Returns:
The model number

#define cg_upnp_device_getmodelurl ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_URL)

Get the device's model URL

Parameters:
dev Device in question
Returns:
The model URL

#define cg_upnp_device_getparentdevice ( dev   )     (dev->parentDevice)

Return the device's parent device

Parameters:
dev Device in question

#define cg_upnp_device_getpresentationurl ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_PRESENTATION_URL)

Get the device's presentation URL

Parameters:
dev Device in question
Returns:
The presentation URL

#define cg_upnp_device_getrootnode ( dev   )     cg_xml_nodelist_gets(dev->rootNodeList)

Return the device's root node

Todo:
Correct explanation...
Parameters:
dev Device in question

#define cg_upnp_device_getserialnumber ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_SERIAL_NUMBER)

Get the device's model number

Parameters:
dev Device in question
Returns:
The serial number

#define cg_upnp_device_getservice ( dev,
idx   )     ((CgUpnpService *)cg_list_get(dev->serviceList,idx))

Get a service from <idx> from the device

Parameters:
dev Device in question
idx Device index number

#define cg_upnp_device_getservicelist ( dev   )     (dev->serviceList)

Get the device's list of services

Parameters:
dev Device in question

#define cg_upnp_device_getservices ( dev   )     ((CgUpnpService *)cg_list_gets((CgList *)dev->serviceList))

Todo:
Correct explanation...
Parameters:
dev Device in question

#define cg_upnp_device_getssdppacket ( dev   )     (dev->ssdpPkt)

Get the device's SSDP packet

Parameters:
dev The device in question

#define cg_upnp_device_getssdpserverlist ( dev   )     (dev->ssdpServerList)

Get the device's list of SSDP servers

Parameters:
dev The device in question

#define cg_upnp_device_getudn ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UDN)

Get the device's Unique Device Name (UDN)

Parameters:
dev Device in question
Returns:
The Unique Device Name

#define cg_upnp_device_getupc ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UPC)

Get the device's Universal Product Code (UPC)

Parameters:
dev Device in question
Returns:
The Universal Product Code

#define cg_upnp_device_geturlbase ( dev   )     cg_xml_node_getchildnodevalue(cg_upnp_device_getrootnode(cg_upnp_device_getrootdevice(dev)), CG_UPNP_DEVICE_URLBASE_NAME)

Get the device's base URL. The base URL is the root for all relative URLs.

Parameters:
dev Device in question
Returns:
The URL base

#define cg_upnp_device_getuserdata ( dev   )     (dev->userData)

Get device's user data pointer

Parameters:
dev Device in question
Returns:
pointer to user data

#define cg_upnp_device_hasudn ( dev   )     ((0 < cg_strlen(cg_upnp_device_getudn(dev))) ? TRUE : FALSE)

Check whether the device has a Unique Device Name (UDN)

Parameters:
dev Device in question
Returns:
TRUE if the device has a UDN; otherwise FALSE

#define CG_UPNP_DEVICE_HTTP_DEFAULT_PORT   38400

Definition for default device HTTP port

#define cg_upnp_device_isdescriptionuri ( dev,
url   )     cg_streq(cg_string_getvalue(dev->descriptionURI), url)

Check, whether the given URL matches the device's description URI

Parameters:
dev Device in question
url Description URL to check

#define cg_upnp_device_isdevicenode ( node   )     cg_xml_node_isname(node, CG_UPNP_DEVICE_ELEM_NAME)

Check whether the given node is of type CG_UPNP_DEVICE_ELEM_NAME

Parameters:
node CgXmlAttribute

#define cg_upnp_device_isdevicetype ( dev,
value   )     cg_streq(cg_upnp_device_getdevicetype(dev), value)

Check, whether the device is of the exact specified type (including version)

Parameters:
dev Device in question
value Device type
Returns:
BOOL: TRUE if device matches given type; otherwise FALSE

#define cg_upnp_device_isrootdevice ( dev   )     ((dev->rootNodeList != NULL) ? TRUE : FALSE)

Check whether the given device contains a list of root nodes i.e. is it the root device

Parameters:
dev Device in question

#define cg_upnp_device_lock ( dev   )     cg_mutex_lock(dev->mutex)

Lock the device's mutex (grant exclusive access to the device) until cg_upnp_device_unlock is called.

Parameters:
dev Device in question

#define CG_UPNP_DEVICE_M_SEARCH_FILTER_INTERVAL   15

Definition for M-SEARCH filter interval

#define CG_UPNP_DEVICE_MANUFACTURE   "manufacture"

Definition for device manufacturer XML element name

#define CG_UPNP_DEVICE_MANUFACTURE_URL   "manufactureURL"

Definition for manufacturer URL XML element name

#define CG_UPNP_DEVICE_MODEL_DESCRIPTION   "modelDescription"

Definition for device model description XML element name

#define CG_UPNP_DEVICE_MODEL_NAME   "modelName"

Definition fo device model name XML element name

#define CG_UPNP_DEVICE_MODEL_NUMBER   "modelNumber"

Definition for device model number XML element name

#define CG_UPNP_DEVICE_MODEL_URL   "modelURL"

Definition for device model URL XML element name

#define cg_upnp_device_next ( dev   )     (CgUpnpDevice *)cg_list_next((CgList *)dev)

Get the next device in the device list. Use as an iterator.

Parameters:
dev Current device

#define CG_UPNP_DEVICE_PRESENTATION_URL   "presentationURL"

Definition for device presentation URL XML element name

#define cg_upnp_device_remove ( dev   )     cg_list_remove((CgList *)dev)

Remove the device from the device list.

Parameters:
dev Device in question

#define CG_UPNP_DEVICE_SERIAL_NUMBER   "serialNumber"

Definition for device serial number XML element name

#define cg_upnp_device_setdescriptionuri ( dev,
url   )     cg_string_setvalue(dev->descriptionURI, url)

Set the given URL as the device's description URI

Parameters:
dev Device in question
url Description URL

#define cg_upnp_device_setdevicetype ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_DEVICE_TYPE, value)

Modify the device type.

Parameters:
dev Device in question
value Type to set

#define cg_upnp_device_setfriendlyname ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_FRIENDLY_NAME, value)

Modify the device's friendly name.

Parameters:
dev Device in question
value The friendly name

#define cg_upnp_device_sethttplistener ( dev,
func   )     (dev->httpListener = func)

Set an HTTP listener function to the device

Parameters:
dev The device in question
func The listener function

#define cg_upnp_device_sethttpport ( dev,
value   )     (dev->httpPort = value)

Modify the port that the device's HTTP server is listening

Parameters:
dev The device in question
value Port number

#define cg_upnp_device_setleasetime ( dev,
value   )     (dev->leaseTime = value)

Set the device's lease time. The lease time is basically the maximum amount of time that can elapse before an advertisement is broadcast again. It does not set the exact advertisement interval, but rather a time window for each advertisement. Advertisement actually occurs at (more or less) random intervals inside this time window.

Parameters:
dev Device in question
value Lease time in seconds

#define cg_upnp_device_setmanufacture ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE, value)

Modify the device's manufacturer.

Parameters:
dev Device in question
value The manufacturer's name

#define cg_upnp_device_setmanufactureurl ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MANUFACTURE_URL, value)

Modify the device's manufacturer URL

Parameters:
dev Device in question
value The manufacturer URL

#define cg_upnp_device_setmodeldescription ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_DESCRIPTION, value)

Modify the device model description

Parameters:
dev Device in question
value The device model description

#define cg_upnp_device_setmodelname ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NAME, value)

Modify the device's model name

Parameters:
dev Device in question
value The model name

#define cg_upnp_device_setmodelnumber ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_NUMBER, value)

Modify the device's model number

Parameters:
dev Device in question
value The model number

#define cg_upnp_device_setmodelurl ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_MODEL_URL, value)

Modify the device's model URL

Parameters:
dev Device in question
value The model URL

#define cg_upnp_device_setparentdevice ( dev,
pDev   )     (dev->parentDevice = pDev)

Set a parent device for the given child device

Parameters:
dev Child device
pDev Parent device

#define cg_upnp_device_setpresentationurl ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_PRESENTATION_URL, value)

Modify the device's presentation URL

Parameters:
dev Device in question
value The presentation URL

#define cg_upnp_device_setserialnumber ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_SERIAL_NUMBER, value)

Modify the device's serial number

Parameters:
dev Device in question
value The serial number

#define cg_upnp_device_setssdppacket ( dev,
srcSsdpPkt   )     cg_upnp_ssdp_packet_copy(dev->ssdpPkt, srcSsdpPkt)

Modify the device's SSDP packet (creates a copy of the original)

Parameters:
dev The device in question
srcSsdpPkt The SSDP packet

#define cg_upnp_device_setudn ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UDN, value)

Modify the device's Unique Device Name (UDN)

Parameters:
dev Device in question
value The Unique Device Name

#define cg_upnp_device_setupc ( dev,
value   )     cg_xml_node_setchildnode(cg_upnp_device_getdevicenode(dev), CG_UPNP_DEVICE_UPC, value)

Modify the device's Universal Product Code (UPC)

Parameters:
dev Device in question
value The Universal Product Code

#define cg_upnp_device_setuserdata ( dev,
value   )     (dev->userData = value)

Set device's user data pointer

Parameters:
dev Device in question
value User data pointer

#define CG_UPNP_DEVICE_UDN   "UDN"

Definition for device UDN XML element name

#define cg_upnp_device_unlock ( dev   )     cg_mutex_unlock(dev->mutex)

Unlock the device's mutex (release exclusive access to the device) locked previously with cg_upnp_device_lock.

Parameters:
dev Device in question

#define CG_UPNP_DEVICE_UPC   "UPC"

Definition for device UPC XML element name

#define CG_UPNP_DEVICE_UPNP_ROOTDEVICE   "upnp:rootdevice"

Definition for UPnP rootdevice ID

#define CG_UPNP_DEVICE_URLBASE_MAXLEN   64

Definition for maximum URL base length

#define CG_UPNP_DEVICE_URLBASE_NAME   "URLBase"

Definition for urlbase XML element name

#define cg_upnp_devicelist_add ( devList,
dev   )     cg_list_add((CgList *)devList, (CgList *)dev)

Add a device to the device list

Parameters:
devList The device list
dev The device to add

#define cg_upnp_devicelist_clear ( devList   )     cg_list_clear((CgList *)devList, (CG_LIST_DESTRUCTORFUNC)cg_upnp_device_delete)

Clear the contents of a device list. Use cg_upnp_devicelist_delete instead of this function.

Parameters:
devList The device list to clear

#define CG_UPNP_DEVICELIST_ELEM_NAME   "deviceList"

Definition for device XML element list name

#define cg_upnp_devicelist_gets ( devList   )     (CgUpnpDevice *)cg_list_next((CgList *)devList)

Todo:
Correct description
Parameters:
devList The device list

#define cg_upnp_devicelist_size ( devList   )     cg_list_size((CgList *)devList)

Get the size of the device list

Parameters:
devList The device list

#define cg_upnp_service_getdevice ( service   )     ((CgUpnpDevice *)service->parentDevice)

Get the device associated to the given service

Parameters:
service The service in question

#define cg_upnp_service_getrootdevice ( service   )     cg_upnp_device_getrootdevice((CgUpnpDevice *)service->parentDevice)

Get the root device of the given service

Parameters:
service The service in question


Typedef Documentation

typedef struct _CgUpnpDevice CgUpnpDevice

The generic UPnP device structure.

Note:
This struct can also be cast to a CgList* and used as a node in a linked list with cg_list_* functions.

typedef struct _CgUpnpDevice CgUpnpDeviceList

The generic UPnP device structure.

Note:
This struct can also be cast to a CgList* and used as a node in a linked list with cg_list_* functions.


Function Documentation

BOOL cg_upnp_device_advertiser_start ( CgUpnpDevice dev  ) 

cg_upnp_device_advertiser_start

Start the advertiser thread for the given device

Parameters:
dev The device that is to be advertised

BOOL cg_upnp_device_advertiser_stop ( CgUpnpDevice dev  ) 

cg_upnp_device_advertiser_stop

Stop the advertiser thread for the given device

Parameters:
dev Device that is being advertised

void cg_upnp_device_announce ( CgUpnpDevice dev  ) 

Broadcast an SSDP:alive to notify control points that the device is available.

Parameters:
dev Device in question

void cg_upnp_device_byebye ( CgUpnpDevice dev  ) 

Broadcast an SSDP:byebye message to notify control points that the device is no longer available.

Parameters:
dev Device in question

void cg_upnp_device_clear ( CgUpnpDevice dev  ) 

Clear a UPnP device structure. This is an internal function and should not be called from outside.

Parameters:
dev Device in question

void cg_upnp_device_delete ( CgUpnpDevice dev  ) 

Delete a UPnP device

Parameters:
dev Device in question

CgUpnpAction* cg_upnp_device_getactionbyname ( CgUpnpDevice dev,
char *  name 
)

Find an action from a device by its name

Parameters:
dev Device in question
name Name of the action

CgUpnpDevice* cg_upnp_device_getdevicebydescriptionuri ( CgUpnpDevice dev,
char *  url 
)

Find a child device by its description URI.

Parameters:
dev Device in question
url Description URI

CgUpnpDevice* cg_upnp_device_getdevicebyexacttype ( CgUpnpDevice dev,
char *  exacttype 
)

Find a device from the device's children by the type of the device. This function searches for devices, whose *complete type string* matches the given string, including version number. For example: "urn:schemas-upnp-org:device:FooDevice:1". If you need to disregard the version number, use cg_upnp_device_getdevicebytype

Parameters:
dev Device in question
exacttype Type of the device

CgUpnpDevice* cg_upnp_device_getdevicebytype ( CgUpnpDevice dev,
char *  type 
)

Find a device from the device's children by the type of the device. This function searches for devices, whose *type part* (i.e. not including the version) of the device type string matches the given string. For example: "urn:schemas-upnp-org:device:FooDevice". If you need to know the version of a device, use cg_upnp_devicetype_getversion

Parameters:
dev Device in question
type Type of the device

CgUpnpDevice* cg_upnp_device_getdevicebyudn ( CgUpnpDevice dev,
char *  udn 
)

Find a device from the device's children by the UDN of the device.

Parameters:
dev Device in question
udn Type of the device

char* cg_upnp_device_getlocationurl ( CgUpnpDevice dev,
char *  host,
char *  buf,
int  bufSize 
)

Get device's location URL. Transforms the given <host> address to URL form: "http://<host>:<port>/description.xml". Port is usually 80 or 38400. If <host> is an IPv6 address, the address is "http://[<host>]:<port>/description.xml".

Parameters:
dev Device in question
host The device host
buf Buffer to store the resulting URL
bufSize Buffer length

char* cg_upnp_device_getnotifydevicent ( CgUpnpDevice dev,
char *  buf,
int  bufSize 
)

Get the device's Notification Type (NT). For the root device this is "upnp:rootdevice", otherwise the device's UDN (Unique Device Name).

Parameters:
dev The device in question
buf Buffer for the Notification Type
bufSize Buffer length

char* cg_upnp_device_getnotifydevicetypent ( CgUpnpDevice dev,
char *  buf,
int  bufSize 
)

Get the device type

Parameters:
dev The device in question
buf Buffer for the device type
bufSize Buffer length

char* cg_upnp_device_getnotifydevicetypeusn ( CgUpnpDevice dev,
char *  buf,
int  bufSize 
)

Get the device's USN (Unique Service Name). For the root device this is "<UDN>::upnp:rootdevice", otherwise the UDN (Unique Device Name).

Parameters:
dev The device in question
buf Buffer where USN is stored after call
bufSize Buffer size
Returns:
Pointer to buf

char* cg_upnp_device_getnotifydeviceusn ( CgUpnpDevice dev,
char *  buf,
int  bufSize 
)

TODO: cg_upnp_device_getnotifydeviceusn doc

CgUpnpDevice* cg_upnp_device_getrootdevice ( CgUpnpDevice dev  ) 

Return the root (i.e. the topmost) device in the device structure

Parameters:
dev Traverses the device tree upwards starting from this device

CgUpnpService* cg_upnp_device_getservicebycontrolurl ( CgUpnpDevice dev,
char *  url 
)

Find a service from a device by its control URL

Parameters:
dev Device in question
url Control URL

CgUpnpService* cg_upnp_device_getservicebyeventsuburl ( CgUpnpDevice dev,
char *  url 
)

Find a service from a device by its event subscription URL

Parameters:
dev Device in question
url Event Subscription URL

CgUpnpService* cg_upnp_device_getservicebyexacttype ( CgUpnpDevice dev,
char *  type 
)

Find a service from the device by the type of the service. This function searches for services, whose *complete type string* matches the given string, including version number. For example: "urn:schemas-upnp-org:service:ContentDirectory:1". If you need to know the version of a service, use cg_upnp_servicetype_getversion

Parameters:
dev Device in question
type Type of the service

CgUpnpService* cg_upnp_device_getservicebyscpdurl ( CgUpnpDevice dev,
char *  url 
)

Find a service from the device by the SCPD (Service Control Protocol Definition) URL of the service.

Parameters:
dev Device in question
url SCPD URL

CgUpnpService* cg_upnp_device_getservicebyserviceid ( CgUpnpDevice dev,
char *  serviceId 
)

Find service from the device by a given serviceId. This function searches recursively device and its subdevices for a service with a given serviceId

Parameters:
dev Device in question
serviceId serviceId of the service
Returns:
service matching the given serviceId

CgUpnpService* cg_upnp_device_getservicebysid ( CgUpnpDevice dev,
char *  sid 
)

Find a service from the device by the subscribtion ID

Parameters:
dev Device in question
sid Subscription ID of the service

CgUpnpService* cg_upnp_device_getservicebytype ( CgUpnpDevice dev,
char *  type 
)

Find a service from the device by the type of the service. This function searches for services, whose *type part* (i.e. not including the version) of the service type string matches the given string. For example: "urn:schemas-upnp-org:service:ContentDirectory". If you need to know the version of a service, use cg_upnp_servicetype_getversion

Parameters:
dev Device in question
type Type of the service

CgUpnpStateVariable* cg_upnp_device_getstatevariablebyname ( CgUpnpDevice dev,
char *  name 
)

Find a state variable from a device by its name

Parameters:
dev Device in question
name Name of the state variable

void cg_upnp_device_httprequestrecieved ( CgHttpRequest httpReq  ) 

Handler function for a received HTTP request. Delegates GET and POST requests to their respective handlers, or treats as a BAD REQUEST, when appropriate.

Parameters:
httpReq Received HTTP request

BOOL cg_upnp_device_ipchanged ( CgUpnpDevice dev  ) 

Notify device that IP address of the host has been changed.

Parameters:
dev dev The device in question
Returns:
success of changing used interfaces

BOOL cg_upnp_device_loaddescriptionfile ( CgUpnpDevice dev,
char *  fileName 
)

Load and parse the device description from an XML file. Not available for T-Engine, ITron and BTron platforms.

Parameters:
dev Device in question
fileName The file name containing the device description XML document
Returns:
TRUE, if the buffer was successfully parsed; otherwise FALSE

CgUpnpDevice* cg_upnp_device_new (  ) 

Create a new UPnP device

BOOL cg_upnp_device_parsedescription ( CgUpnpDevice dev,
char *  desciption,
int  descriptionLen 
)

Parse the device description XML document.

Parameters:
dev Device in question
desciption Buffer containing the device description in XML format
descriptionLen Buffer length
Returns:
TRUE, if the buffer was successfully parsed; otherwise FALSE

BOOL cg_upnp_device_parsedescriptionurl ( CgUpnpDevice dev,
CgNetURL url 
)

Fetch and parse the device description XML file, located in the given URL.

Parameters:
dev Device in question
url An internet resource
Returns:
TRUE, if the buffer was successfully parsed; otherwise FALSE

BOOL cg_upnp_device_postsearchresponse ( CgUpnpDevice dev,
CgUpnpSSDPPacket ssdpPkt,
char *  st,
char *  usn 
)

Post a response to an SSDP search message

Parameters:
dev The device in question
ssdpPkt Received SSDP packet
st Service Type (ST)
usn Unique Service Name (USN)

void cg_upnp_device_setactionlistener ( CgUpnpDevice dev,
CG_UPNP_ACTION_LISTNER  actionListner 
)

Set an action listener to the device. Actions are basically commands, that the device (service) responds to.

Parameters:
dev Device in question
actionListner The action listener

void cg_upnp_device_setdevicenode ( CgUpnpDevice dev,
CgXmlNode node 
)

Set the device description node and initialise its child nodes

Parameters:
dev Device in question
node The XML structure to be set as the device's description

void cg_upnp_device_setquerylistener ( CgUpnpDevice dev,
CG_UPNP_STATEVARIABLE_LISTNER  queryListner 
)

Set a query listener to the device. Queries are meant for state variables.

Parameters:
dev Device in question
queryListner The query listener

void cg_upnp_device_seturlbase ( CgUpnpDevice dev,
char *  value 
)

Modify the device's URL base The base URL is the root for all relative URLs.

Parameters:
dev Device in question
value The URL base

void cg_upnp_device_ssdplistener ( CgUpnpSSDPPacket ssdpPkt  ) 

The SSDP message handler function.

Parameters:
ssdpPkt SSDP Packet

void cg_upnp_device_ssdpmessagereceived ( CgUpnpDevice dev,
CgUpnpSSDPPacket ssdpPkt,
int  filter 
)

SSDP message handler

Parameters:
dev The device in question
ssdpPkt Received SSDP packet

BOOL cg_upnp_device_start ( CgUpnpDevice dev  ) 

Start the device. This essentially starts:

Parameters:
dev Device in question

BOOL cg_upnp_device_stop ( CgUpnpDevice dev  ) 

Stop the device. This concerns:

Parameters:
dev Device in question

BOOL cg_upnp_device_updatefromssdppacket ( CgUpnpDevice dev,
CgUpnpSSDPPacket ssdpPkt 
)

Update the device's contents from an SSDP packet if necessary.

Parameters:
dev The device to potentially update
ssdpPkt The SSDP packet to make decisions on
Returns:
TRUE if the device was updated; otherwise FALSE

void cg_upnp_devicelist_delete ( CgUpnpDeviceList devList  ) 

Delete a device list completely, freeing all devices and their contents.

Parameters:
devList The device list to delete

CgUpnpDeviceList* cg_upnp_devicelist_new (  ) 

Create a new device list

char* cg_upnp_devicetype_getdevice ( char *  deviceType  ) 

Get the device part of a device type string (usually just "device")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL

char* cg_upnp_devicetype_getidentifier ( char *  deviceType  ) 

Get the identifier-part of a device type string (usually "urn")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL

char* cg_upnp_devicetype_getschematype ( char *  deviceType  ) 

Get the schema type part of a device type string (without last colon) (ex. "urn:schemas-upnp-org:device:ContentDirectory")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL

char* cg_upnp_devicetype_gettype ( char *  deviceType  ) 

Get the type part of a device type string (ex. "ContentDirectory")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL

char* cg_upnp_devicetype_geturn ( char *  deviceType  ) 

Get the URN part of a device type string (usually "schemas-upnp-org")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL

char* cg_upnp_devicetype_getversion ( char *  deviceType  ) 

Get the version part of a device type string (ex. "1")

Parameters:
deviceType A device type string (usually the result from cg_upnp_device_getdevicetype)
Returns:
A newly-created char* if successful; otherwise NULL


Generated on Tue Aug 8 14:56:29 2006 for CyberLinkC by  doxygen 1.4.7