mUPnP for C
controlpoint.c File Reference

Functions

static void mupnp_controlpoint_ssdplistner (mUpnpSSDPPacket *ssdpPkt)
 
static void mupnp_controlpoint_ssdpresponselistner (mUpnpSSDPPacket *ssdpPkt)
 
const char * mupnp_controlpoint_geteventsubcallbackurl (mUpnpControlPoint *ctrlPoint, char *ifaddr, char *buf, size_t bufLen)
 
mUpnpControlPointmupnp_controlpoint_new ()
 
void mupnp_controlpoint_delete (mUpnpControlPoint *ctrlPoint)
 
bool mupnp_controlpoint_start (mUpnpControlPoint *ctrlPoint)
 
bool mupnp_controlpoint_stop (mUpnpControlPoint *ctrlPoint)
 
bool mupnp_controlpoint_isrunning (mUpnpControlPoint *ctrlPoint)
 
bool mupnp_controlpoint_lock (mUpnpControlPoint *ctrlPoint)
 
bool mupnp_controlpoint_unlock (mUpnpControlPoint *ctrlPoint)
 
mUpnpDevicemupnp_controlpoint_getdevicebyexacttype (mUpnpControlPoint *ctrlPoint, const char *exacttype)
 
mUpnpDevicemupnp_controlpoint_getdevicebytype (mUpnpControlPoint *ctrlPoint, const char *type)
 
mUpnpDevicemupnp_controlpoint_getdevicebyudn (mUpnpControlPoint *ctrlPoint, const char *udn)
 
bool mupnp_controlpoint_parsescservicescpd (mUpnpService *service)
 
bool mupnp_controlpoint_parseservicesfordevice (mUpnpDevice *dev, mUpnpSSDPPacket *ssdpPkt)
 
static mUpnpDevicemupnp_controlpoint_createdevicefromssdkpacket (mUpnpSSDPPacket *ssdpPkt)
 
void mupnp_controlpoint_adddevicebyssdppacket (mUpnpControlPoint *ctrlPoint, mUpnpSSDPPacket *ssdpPkt)
 
void mupnp_controlpoint_removedevicebyssdppacket (mUpnpControlPoint *ctrlPoint, mUpnpSSDPPacket *ssdpPkt)
 
bool mupnp_controlpoint_search (mUpnpControlPoint *ctrlPoint, const char *target)
 
bool mupnp_controlpoint_ipchanged (mUpnpControlPoint *ctrlPoint)
 

Function Documentation

◆ mupnp_controlpoint_adddevicebyssdppacket()

void mupnp_controlpoint_adddevicebyssdppacket ( mUpnpControlPoint * ctrlPoint,
mUpnpSSDPPacket * ssdpPkt )

Add a device on the basis of an SSDP packet. Do not call this from user applications.

Parameters
ctrlPointThe control point, whose device list to handle
ssdpPktThe received SSDP packet

◆ mupnp_controlpoint_createdevicefromssdkpacket()

static mUpnpDevice * mupnp_controlpoint_createdevicefromssdkpacket ( mUpnpSSDPPacket * ssdpPkt)
static

◆ mupnp_controlpoint_delete()

void mupnp_controlpoint_delete ( mUpnpControlPoint * ctrlPoint)

Destroy the given control point

Parameters
ctrlPointThe control point struct to destroy

◆ mupnp_controlpoint_getdevicebyexacttype()

mUpnpDevice * mupnp_controlpoint_getdevicebyexacttype ( mUpnpControlPoint * ctrlPoint,
const char * exacttype )

Find a device from the control point by the exact 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, use mupnp_controlpoint_getdevicebytype

Parameters
ctrlPointControlpoint in question
exacttypeType of the device

◆ mupnp_controlpoint_getdevicebytype()

mUpnpDevice * mupnp_controlpoint_getdevicebytype ( mUpnpControlPoint * ctrlPoint,
const char * type )

Find a device from the controlpoint 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 mupnp_devicetype_getversion

Parameters
ctrlPointControlpoint in question
typeType of the device

◆ mupnp_controlpoint_getdevicebyudn()

mUpnpDevice * mupnp_controlpoint_getdevicebyudn ( mUpnpControlPoint * ctrlPoint,
const char * udn )

Find a device from the controlpoint by the UDN of the device.

Parameters
ctrlPointControlpoint in question
udnType of the device

◆ mupnp_controlpoint_geteventsubcallbackurl()

const char * mupnp_controlpoint_geteventsubcallbackurl ( mUpnpControlPoint * ctrlPoint,
char * ifaddr,
char * buf,
size_t bufLen )

Get the event subscription callback URI

Parameters
ctrlPointThe control point in question
ifaddrInterface address
bufBuffer used to store callback url
bufLenBuffer length
Returns
Event callback url (pointer to buf)

◆ mupnp_controlpoint_ipchanged()

bool mupnp_controlpoint_ipchanged ( mUpnpControlPoint * ctrlpoint)

Notify the control point that any IP of the host has been changed.

Parameters
ctrlpointThe control point in use
Returns
success of changing used interfaces

◆ mupnp_controlpoint_isrunning()

bool mupnp_controlpoint_isrunning ( mUpnpControlPoint * ctrlPoint)

Check if the control point is activated.

Parameters
ctrlPointThe control point to stop
Returns
true if running; otherwise false

◆ mupnp_controlpoint_lock()

bool mupnp_controlpoint_lock ( mUpnpControlPoint * ctrlPoint)

Lock the control point's mutex. The control point should be ALWAYS locked, when a mUpnpDevice*, mUpnpService*, mUpnpAction* or other pointer has been taken into use from the stack. This effectively prevents devices/services from being updated/ removed or added while the control point is locked. You should release the lock as soon as possible with mupnp_controlpoint_unlock

Note
Do NOT save any mUpnp* pointers to user-space variables. Use them only as local variables (inside one function) after gaining a mutex lock. Release the lock as soon as you are done accessing the pointer, and then discard the pointer immediately.
Parameters
ctrlPointThe control point in question

◆ mupnp_controlpoint_new()

mUpnpControlPoint * mupnp_controlpoint_new ( void )

Create a new control point. Does not start any threads.

Returns
A newly-created mUpnpControlPoint

◆ mupnp_controlpoint_parsescservicescpd()

bool mupnp_controlpoint_parsescservicescpd ( mUpnpService * service)

Parse the service description from the service's SCPD URL. Do not call this from user applications.

Parameters
serviceThe service in question
Returns
true if successful; otherwise false

◆ mupnp_controlpoint_parseservicesfordevice()

bool mupnp_controlpoint_parseservicesfordevice ( mUpnpDevice * dev,
mUpnpSSDPPacket * ssdpPkt )

Parse the device's services using the received SSDP packet. Do not call this from user applications.

Parameters
devThe device in question
ssdpPktAn SSDP packet

◆ mupnp_controlpoint_removedevicebyssdppacket()

void mupnp_controlpoint_removedevicebyssdppacket ( mUpnpControlPoint * ctrlPoint,
mUpnpSSDPPacket * ssdpPkt )

Remove a device on the basis of an SSDP packet. Do not call this from user applications.

Parameters
ctrlPointThe control point, whose device list to handle
ssdpPktThe received SSDP packet

◆ mupnp_controlpoint_search()

bool mupnp_controlpoint_search ( mUpnpControlPoint * ctrlPoint,
const char * target )

Do an M-SEARCH to look for devices in the network.

Parameters
ctrlPointThe control point in question
targetThe Search Target parameter (ex. "ssdp:all")

◆ mupnp_controlpoint_ssdplistner()

static void mupnp_controlpoint_ssdplistner ( mUpnpSSDPPacket * ssdpPkt)
static

◆ mupnp_controlpoint_ssdpresponselistner()

static void mupnp_controlpoint_ssdpresponselistner ( mUpnpSSDPPacket * ssdpPkt)
static

◆ mupnp_controlpoint_start()

bool mupnp_controlpoint_start ( mUpnpControlPoint * ctrlPoint)

Activate the control point. Starts listening for SSDP messages etc. You must call this function before you can actually use a control point.

Parameters
ctrlPointThe control point to start
Returns
true if successful; otherwise false

◆ mupnp_controlpoint_stop()

bool mupnp_controlpoint_stop ( mUpnpControlPoint * ctrlPoint)

Stop the control point. Stops sending/receiveing/responding to any messages.

Parameters
ctrlPointThe control point to stop
Returns
true if successful; otherwise false

◆ mupnp_controlpoint_unlock()

bool mupnp_controlpoint_unlock ( mUpnpControlPoint * ctrlPoint)

Release a previously locked control point mutex. See mupnp_controlpoint_lock for a more detailed description on the control point locking mechanism.

Parameters
ctrlPointThe control point in question