mUPnP for C
|
#include <mupnp/util/string.h>
#include <mupnp/util/mutex.h>
#include <mupnp/util/cond.h>
#include <mupnp/xml/xml.h>
#include <mupnp/net/interface.h>
#include <mupnp/device.h>
#include <mupnp/argument.h>
#include <mupnp/upnp_status.h>
#include <mupnp/ssdp/ssdp_server.h>
#include <mupnp/event/event.h>
#include <mupnp/event/notify.h>
Data Structures | |
struct | _mUpnpControlPoint |
Typedefs | |
typedef enum _mUpnpDeviceStatus | mUpnpDeviceStatus |
typedef struct _mUpnpControlPoint | mUpnpControlPoint |
typedef void(* | MUPNP_DEVICE_LISTENER) (mUpnpControlPoint *ctrlPoint, const char *udn, mUpnpDeviceStatus status) |
Enumerations | |
enum | _mUpnpDeviceStatus { mUpnpDeviceStatusAdded = 0 , mUpnpDeviceStatusUpdated , mUpnpDeviceStatusInvalid , mUpnpDeviceStatusRemoved } |
#define mupnp_controlpoint_adddevice | ( | ctrlPoint, | |
dev ) |
Add a device to the control point's list of devices. Do not call this from user applications.
ctrlPoint | The control point in use |
dev | The device to add |
#define mupnp_controlpoint_addeventlistener | ( | ctrlPoint, | |
listener ) |
Set an event listener for the control point. Use this function to get event notifications to user-space applications.
ctrlPoint | The control point in question |
listener | A callback function that is of type MUPNP_EVENT_LISTENER |
#define mupnp_controlpoint_getdevice | ( | ctrlPoint, | |
index ) |
Get the head of the control point's list of devices (use for iteration)
ctrlPoint | The control point in use |
index | The index of the device to get |
#define mupnp_controlpoint_getdevicelistener | ( | ctrlPoint | ) |
Get the device listener for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getdevices | ( | ctrlPoint | ) |
Get the head of the control point's list of devices (use for iteration)
ctrlPoint | The control point in use |
#define mupnp_controlpoint_geteventlistener | ( | ctrlPoint | ) |
Get the single event listener for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_geteventlisteners | ( | ctrlPoint | ) |
Get the list of event listeners for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_geteventport | ( | ctrlPoint | ) |
Get the IP port number for the control point's event reception
ctrlPoint | The control point in question |
#define mupnp_controlpoint_geteventsuburi | ( | ctrlPoint | ) |
Get the URI used for the control point's event subscription notifications
ctrlPoint | The control point in question |
#define mupnp_controlpoint_gethttplistener | ( | ctrlPoint | ) |
Get the HTTP listener function for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_gethttpserverlist | ( | ctrlPoint | ) |
Get the list of HTTP servers associated to the control point
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getndevices | ( | ctrlPoint | ) |
Get the number of devices known by the control point
ctrlPoint | The control point in use |
#define mupnp_controlpoint_getssdplistener | ( | ctrlPoint | ) |
Get the SSDP message listener for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getssdpresponselistener | ( | ctrlPoint | ) |
Get the SSDP response listener for the control point.
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getssdpresponseport | ( | ctrlPoint | ) |
Get the IP port number used for the control point's SSDP responses
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getssdpresponseserverlist | ( | ctrlPoint | ) |
Get the list of SSDP response servers associated to the control point
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getssdpsearchmx | ( | ctrlPoint | ) |
Get the MX-parameter used for SSDP searches
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getssdpserverlist | ( | ctrlPoint | ) |
Get the list of SSDP servers associated to the control point
ctrlPoint | The control point in question |
#define mupnp_controlpoint_getuserdata | ( | ctrlPoint | ) |
Get the user data pointer (arbitrary user data) from the control point.
dev | The control point in question |
#define MUPNP_CONTROLPOINT_HTTP_EVENT_DEFAULT_PORT 39500 |
Definition for HTTP event default port
#define MUPNP_CONTROLPOINT_HTTP_EVENTSUB_URI "/eventSub" |
Definition for default controlpoint event callback "location"
#define mupnp_controlpoint_removeeventlistener | ( | ctrlPoint, | |
listener ) |
Remove an event listener from the control point.
ctrlPoint | The control point in question |
listener | The callback function to remove, that is of type MUPNP_EVENT_LISTENER |
#define mupnp_controlpoint_setdevicelistener | ( | ctrlPoint, | |
func ) |
Set device listener for the control point.
ctrlPoint | The control point |
func | A callback function that is type MUPNP_DEVICE_LISTENER or NULL |
#define mupnp_controlpoint_seteventport | ( | ctrlPoint, | |
port ) |
Set the IP port number for the control point's event reception
ctrlPoint | The control point in question |
port | The IP port number |
#define mupnp_controlpoint_seteventsuburi | ( | ctrlPoint, | |
uri ) |
Set the URI used for the control point's event subscription notifications
ctrlPoint | The control point in question |
uri | The URI to set |
#define mupnp_controlpoint_sethttplistener | ( | ctrlPoint, | |
func ) |
Set an HTTP listener function to the control point. Use this function to get HTTP requests to user-space applications.
ctrlPoint | The control point in question |
func | The listener function, that is of type MUPNP_HTTP_LISTENER |
#define mupnp_controlpoint_setssdplistener | ( | ctrlPoint, | |
func ) |
Set an SSDP message listener for the control point. Use this function to get SSDP messages to user-space applications.
ctrlPoint | The control point in question |
func | A callback function that is of type MUPNP_SSDP_LISTNER |
#define mupnp_controlpoint_setssdpresponselistener | ( | ctrlPoint, | |
func ) |
Set an SSDP response listener for the control point. Use this function to get SSDP responses to user-space applications.
ctrlPoint | The control point in question |
func | A callback function that is of type MUPNP_SSDP_RESPONSE_LISTNER |
#define mupnp_controlpoint_setssdpresponseport | ( | ctrlPoint, | |
port ) |
Set the IP port number used for the control point's SSDP responses
ctrlPoint | The control point in question |
port | The IP port number |
#define mupnp_controlpoint_setssdpsearchmx | ( | ctrlPoint, | |
value ) |
Set the MX-parameter used for SSDP searches i.e. Set the time to wait (in seconds) for device responses to an M-SEARCH
ctrlPoint | The control point in question |
value | MX; Time to wait |
#define mupnp_controlpoint_setuserdata | ( | ctrlPoint, | |
value ) |
Set the user data pointer (arbitrary user data) to the control point.
ctrlPoint | The control point in question |
value | Arbitrary user data |
#define MUPNP_CONTROLPOINT_SSDP_DEFAULT_SEARCH_MX 3 |
Definition for SSDP default search MX
#define MUPNP_CONTROLPOINT_SSDP_MIN_DELAY 20 |
Definition for control point SSDP minimum delay
#define MUPNP_CONTROLPOINT_SSDP_RESPONSE_DEFAULT_PORT 39400 |
Definition for control point default response port
#define MUPNP_CONTROLPOINT_SSDP_RESPONSE_PORT_MAX_TRIES_INDEX 80 |
Definition for numeric constant to specify the max tries to open a SSDP Response Port (rosfran.borges)
typedef void(* MUPNP_DEVICE_LISTENER) (mUpnpControlPoint *ctrlPoint, const char *udn, mUpnpDeviceStatus status) |
typedef struct _mUpnpControlPoint mUpnpControlPoint |
Prototype for control point's device listener callback.
udn | The UDN of the device, that the status update concerns |
status | The new status |
typedef enum _mUpnpDeviceStatus mUpnpDeviceStatus |
Device listener status parameters.
mUpnpDeviceStatusAdded means a device has been added to local cache. mUpnpDeviceStatusUpdated means a device description has been updated because its IP address or description has changed. The user should renew any active subscriptions if this has been received.
mUpnpDeviceStatusInvalid is basically the same as mUpnpDeviceStatusRemoved, but mUpnpDeviceStatusRemoved is sent only when a device leaves the network in a proper way (i.e. with UPnP ByeBye messages). The user should immediately cease using the device, because it will be removed in both cases.
enum _mUpnpDeviceStatus |
Device listener status parameters.
mUpnpDeviceStatusAdded means a device has been added to local cache. mUpnpDeviceStatusUpdated means a device description has been updated because its IP address or description has changed. The user should renew any active subscriptions if this has been received.
mUpnpDeviceStatusInvalid is basically the same as mUpnpDeviceStatusRemoved, but mUpnpDeviceStatusRemoved is sent only when a device leaves the network in a proper way (i.e. with UPnP ByeBye messages). The user should immediately cease using the device, because it will be removed in both cases.
Enumerator | |
---|---|
mUpnpDeviceStatusAdded | |
mUpnpDeviceStatusUpdated | |
mUpnpDeviceStatusInvalid | |
mUpnpDeviceStatusRemoved |
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.
ctrlPoint | The control point, whose device list to handle |
ssdpPkt | The received SSDP packet |
void mupnp_controlpoint_delete | ( | mUpnpControlPoint * | ctrlPoint | ) |
Destroy the given control point
ctrlPoint | The control point struct to destroy |
void mupnp_controlpoint_expirationhandler | ( | mUpnpThread * | thread | ) |
Worker thread for handling expirations.
thread | the thread in question |
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
ctrlPoint | Controlpoint in question |
exacttype | Type of the device |
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
ctrlPoint | Controlpoint in question |
exacttype | Type of the device |
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
ctrlPoint | Controlpoint in question |
type | Type of the device |
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
ctrlPoint | Controlpoint in question |
type | Type of the device |
mUpnpDevice * mupnp_controlpoint_getdevicebyudn | ( | mUpnpControlPoint * | ctrlPoint, |
const char * | udn ) |
Find a device from the controlpoint by the UDN of the device.
ctrlPoint | Controlpoint in question |
type | Type of the device |
Find a device from the controlpoint by the UDN of the device.
ctrlPoint | Controlpoint in question |
udn | Type of the device |
const char * mupnp_controlpoint_geteventsubcallbackurl | ( | mUpnpControlPoint * | ctrlPoint, |
char * | ifaddr, | ||
char * | buf, | ||
size_t | bufLen ) |
Get the event subscription callback URI
ctrlPoint | The control point in question |
Get the event subscription callback URI
ctrlPoint | The control point in question |
ifaddr | Interface address |
buf | Buffer used to store callback url |
bufLen | Buffer length |
void mupnp_controlpoint_httprequestreceived | ( | mUpnpHttpRequest * | httpReq | ) |
The function that calls all HTTP listener callback functions. Do not call this from applications.
httpReq | The received HTTP request |
bool mupnp_controlpoint_ipchanged | ( | mUpnpControlPoint * | ctrlpoint | ) |
Notify the control point that any IP of the host has been changed.
ctrlpoint | The control point in use |
bool mupnp_controlpoint_isrunning | ( | mUpnpControlPoint * | ctrlPoint | ) |
Check if the control point is activated.
ctrlPoint | The control point to stop |
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
ctrlPoint | The control point in question |
mUpnpControlPoint * mupnp_controlpoint_new | ( | void | ) |
Create a new control point. Does not start any threads.
bool mupnp_controlpoint_parsescservicescpd | ( | mUpnpService * | service | ) |
Parse the service description from the service's SCPD URL. Do not call this from user applications.
service | The service in question |
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.
dev | The device in question |
ssdpPkt | An SSDP packet |
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.
ctrlPoint | The control point, whose device list to handle |
ssdpPkt | The received SSDP packet |
bool mupnp_controlpoint_resubscribe | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpService * | service, | ||
long | timeout ) |
Re-subscribe to a service's events (i.e. renew subscription)
ctrlPoint | The control point in use |
service | The service to subscribe to |
timeout | Timeout for subscription expiration/renewal |
bool mupnp_controlpoint_resubscribeall | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpDevice * | dev, | ||
long | timeout ) |
Re-subscribe to all of the device's services' events (i.e. renew subscription)
ctrlPoint | The control point in use |
dev | The device to subscribe to |
timeout | Timeout for subscription expiration/renewal |
bool mupnp_controlpoint_search | ( | mUpnpControlPoint * | ctrlPoint, |
const char * | target ) |
Do an M-SEARCH to look for devices in the network.
ctrlPoint | The control point in question |
target | The Search Target parameter (ex. "ssdp:all") |
bool mupnp_controlpoint_seteventlistener | ( | mUpnpControlPoint * | ctrlPoint, |
MUPNP_EVENT_LISTENER | evlistener ) |
Set a single event listener for the control point. Use this function to get event notifications to user-space applications if you need only one listener.
ctrlPoint | The control point in question |
evlistener | The callback function to set, that is of type MUPNP_EVENT_LISTENER, or NULL |
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.
ctrlPoint | The control point to start |
bool mupnp_controlpoint_stop | ( | mUpnpControlPoint * | ctrlPoint | ) |
Stop the control point. Stops sending/receiveing/responding to any messages.
ctrlPoint | The control point to stop |
bool mupnp_controlpoint_subscribe | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpService * | service, | ||
long | timeout ) |
Subscribe to a service's events
ctrlPoint | The control point in use |
service | The service to subscribe to |
timeout | Timeout for subscription expiration/renewal |
bool mupnp_controlpoint_subscribeall | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpDevice * | dev, | ||
long | timeout ) |
Subscribe to all of the device's services' events
ctrlPoint | The control point in use |
dev | The device to subscribe to |
timeout | Timeout for subscription expiration/renewal |
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.
ctrlPoint | The control point in question |
bool mupnp_controlpoint_unsubscribe | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpService * | service ) |
Unsubscribe to a service's events (i.e. cancel subscription)
ctrlPoint | The control point in use |
service | The service to unsubscribe to |
bool mupnp_controlpoint_unsubscribeall | ( | mUpnpControlPoint * | ctrlPoint, |
mUpnpDevice * | dev ) |
Unsubscribe to all of the device's services' events (i.e. cancel subscription)
ctrlPoint | The control point in use |
dev | The device to unsubscribe to |
void mupnp_controlpoint_updatestatetablefromproperty | ( | mUpnpService * | service, |
mUpnpProperty * | prop ) |
When an event is received, update also the associated service's state table to include the evented state variable.
service | The service, whose state table to update |
prop | The evented property from which to update |