mUPnP for C
service.c File Reference
#include <mupnp/service.h>
#include <mupnp/device.h>
#include <mupnp/net/uri.h>
#include <mupnp/net/url.h>
#include <mupnp/ssdp/ssdp.h>
#include <mupnp/upnp.h>
#include <mupnp/upnp_function.h>
#include <mupnp/util/log.h>
#include <mupnp/util/string.h>

Functions

static void mupnp_service_initchildnodes (mUpnpService *service)
 
static void mupnp_service_initactionlist (mUpnpService *service)
 
static void mupnp_service_initservicestatetable (mUpnpService *service)
 
static mUpnpNetURLmupnp_service_mangleurl (mUpnpService *service, char *type)
 
mUpnpServicemupnp_service_new ()
 
void mupnp_service_delete (mUpnpService *service)
 
void mupnp_service_clear (mUpnpService *service)
 
bool mupnp_service_isscpdurl (mUpnpService *service, const char *url)
 
mUpnpNetURLmupnp_service_geteventsuburl (mUpnpService *service)
 
mUpnpNetURLmupnp_service_getcontrolurl (mUpnpService *service)
 
mUpnpNetURLmupnp_service_getscpdurl (mUpnpService *service)
 
bool mupnp_service_parsedescription (mUpnpService *service, const char *desciption, size_t descriptionLen)
 
bool mupnp_service_parsedescriptionurl (mUpnpService *service, mUpnpNetURL *url)
 
char * mupnp_service_getdescription (mUpnpService *service, mUpnpString *descStr)
 
const char * mupnp_servicetype_getidentifier (const char *serviceType)
 
const char * mupnp_servicetype_geturn (const char *serviceType)
 
const char * mupnp_servicetype_getservice (const char *serviceType)
 
const char * mupnp_servicetype_gettype (const char *serviceType)
 
char * mupnp_servicetype_getschematype (const char *serviceType)
 
const char * mupnp_servicetype_getversion (const char *serviceType)
 
char * mupnp_service_getnotifyservicetypent (mUpnpService *service, char *buf, int bufSize)
 
char * mupnp_service_getnotifyservicetypeusn (mUpnpService *service, char *buf, int bufSize)
 
bool mupnp_service_announcefrom (mUpnpService *service, const char *bindAddr)
 
bool mupnp_service_byebyefrom (mUpnpService *service, const char *bindAddr)
 
mUpnpActionmupnp_service_getactionbyname (mUpnpService *service, const char *name)
 
mUpnpStateVariablemupnp_service_getstatevariablebyname (mUpnpService *service, const char *name)
 
void mupnp_service_setactionlistener (mUpnpService *service, MUPNP_ACTION_LISTNER actionListener)
 
void mupnp_service_setquerylistener (mUpnpService *service, MUPNP_STATEVARIABLE_LISTNER queryListener)
 
mUpnpActionListmupnp_service_getactionlist (mUpnpService *service)
 
mUpnpActionmupnp_service_getactions (mUpnpService *service)
 
mUpnpServiceStateTablemupnp_service_getservicestatetable (mUpnpService *service)
 
mUpnpStateVariablemupnp_service_getstatevariables (mUpnpService *service)
 
bool mupnp_service_addsubscriber (mUpnpService *service, mUpnpSubscriber *sub)
 
bool mupnp_service_removesubscriber (mUpnpService *service, mUpnpSubscriber *sub)
 
mUpnpSubscribermupnp_service_getsubscriberbysid (mUpnpService *service, const char *sid)
 
mUpnpNetURLmupnp_service_mangleabsoluteurl (const char *serviceURLStr, const char *baseURLStr, const char *locationURLStr)
 

Function Documentation

◆ mupnp_service_addsubscriber()

bool mupnp_service_addsubscriber ( mUpnpService * service,
mUpnpSubscriber * sub )

Add a subscriber to the service

Parameters
serviceThe service in question
subThe subscriber

◆ mupnp_service_announcefrom()

bool mupnp_service_announcefrom ( mUpnpService * service,
const char * bindAddr )

Send a service announcement (advertisement) from the given address

Parameters
serviceThe service to advertise
bindAddrThe address to attach to the announcement

◆ mupnp_service_byebyefrom()

bool mupnp_service_byebyefrom ( mUpnpService * service,
const char * bindAddr )

Send a byebye announcement (i.e. a cancelling advertisement) from the given address

Parameters
serviceThe service to announce from
bindAddrThe address to attach to the announcement

◆ mupnp_service_clear()

void mupnp_service_clear ( mUpnpService * service)

Clear the contents of a UPnP service

Parameters
serviceThe service to clear

◆ mupnp_service_delete()

void mupnp_service_delete ( mUpnpService * service)

Destroy a UPnP service

Parameters
serviceThe service to destroy

◆ mupnp_service_getactionbyname()

mUpnpAction * mupnp_service_getactionbyname ( mUpnpService * service,
const char * name )

Get an action from the service by the action's name

Parameters
serviceThe service in question
nameThe name of the action to look for
Returns
mUpnpAction* or NULL

◆ mupnp_service_getactionlist()

mUpnpActionList * mupnp_service_getactionlist ( mUpnpService * service)

Get the service's list of actions (head of list)

Parameters
serviceThe service in question

◆ mupnp_service_getactions()

mUpnpAction * mupnp_service_getactions ( mUpnpService * service)

Get the first action in the service's list of actions. Use as the starting point in iteration loops.

Parameters
serviceThe service in question

◆ mupnp_service_getcontrolurl()

mUpnpNetURL * mupnp_service_getcontrolurl ( mUpnpService * service)

Get the service's control URL

Parameters
serviceThe service in question
Returns
char*

◆ mupnp_service_getdescription()

char * mupnp_service_getdescription ( mUpnpService * service,
mUpnpString * descStr )

Get the service's description XML nodes as a string

Parameters
serviceThe service in question
descStrThe description string

◆ mupnp_service_geteventsuburl()

mUpnpNetURL * mupnp_service_geteventsuburl ( mUpnpService * service)

Get the service's event subscription URL

Parameters
serviceThe service in question
Returns
char*

◆ mupnp_service_getnotifyservicetypent()

char * mupnp_service_getnotifyservicetypent ( mUpnpService * service,
char * buf,
int bufSize )

◆ mupnp_service_getnotifyservicetypeusn()

char * mupnp_service_getnotifyservicetypeusn ( mUpnpService * service,
char * buf,
int bufSize )

◆ mupnp_service_getscpdurl()

mUpnpNetURL * mupnp_service_getscpdurl ( mUpnpService * service)

Get the service's SCPD (service description) URL

Parameters
serviceThe service in question
Returns
mUpnpNetURL Pointer to URL/URI structure

◆ mupnp_service_getservicestatetable()

mUpnpServiceStateTable * mupnp_service_getservicestatetable ( mUpnpService * service)

Get the service's state table

Parameters
serviceThe service in question

◆ mupnp_service_getstatevariablebyname()

mUpnpStateVariable * mupnp_service_getstatevariablebyname ( mUpnpService * service,
const char * name )

Get a state variable from the service's state table by the variable's name

Parameters
serviceThe service in question
namethe name of the variable
Returns
mUpnpStateVariable* or NULL

◆ mupnp_service_getstatevariables()

mUpnpStateVariable * mupnp_service_getstatevariables ( mUpnpService * service)

Get the first state variable in the service's state table. Use as the starting point in iteration loops.

Parameters
serviceThe service in question

◆ mupnp_service_getsubscriberbysid()

mUpnpSubscriber * mupnp_service_getsubscriberbysid ( mUpnpService * service,
const char * sid )

Find a subscriber from the service's list of subscribers by its SID (Subscription ID)

Parameters
serviceThe service in question
sidThe SID

◆ mupnp_service_initactionlist()

static void mupnp_service_initactionlist ( mUpnpService * service)
static

◆ mupnp_service_initchildnodes()

static void mupnp_service_initchildnodes ( mUpnpService * service)
static

◆ mupnp_service_initservicestatetable()

static void mupnp_service_initservicestatetable ( mUpnpService * service)
static

◆ mupnp_service_isscpdurl()

bool mupnp_service_isscpdurl ( mUpnpService * service,
const char * url )

Compare the service's SCPD URL and the given location

Parameters
serviceThe service in question
urlThe URL (location) to compare
Returns
true if location is found from URL; otherwise false

◆ mupnp_service_mangleabsoluteurl()

mUpnpNetURL * mupnp_service_mangleabsoluteurl ( const char * serviceURLStr,
const char * baseURLStr,
const char * locationURLStr )

◆ mupnp_service_mangleurl()

static mUpnpNetURL * mupnp_service_mangleurl ( mUpnpService * service,
char * type )
static

◆ mupnp_service_new()

mUpnpService * mupnp_service_new ( void )

Create a new UPnP service

◆ mupnp_service_parsedescription()

bool mupnp_service_parsedescription ( mUpnpService * service,
const char * description,
size_t descriptionLen )

Create the service's contents from the given XML document

Parameters
serviceThe service to create
descriptionThe XML document to parse
descriptionLenThe length of the XML document

◆ mupnp_service_parsedescriptionurl()

bool mupnp_service_parsedescriptionurl ( mUpnpService * service,
mUpnpNetURL * url )

Create the service's contents from the given URL. Gets the XML document from the URL and passes it again to mupnp_service_parsedescription

Parameters
serviceThe service to create
urlThe URL of the document to parse

◆ mupnp_service_removesubscriber()

bool mupnp_service_removesubscriber ( mUpnpService * service,
mUpnpSubscriber * sub )

Remove a subscriber from the service

Parameters
serviceThe service in question
subThe subscriber to remove

◆ mupnp_service_setactionlistener()

void mupnp_service_setactionlistener ( mUpnpService * service,
MUPNP_ACTION_LISTNER actionListener )

Set an action listener to the service

Parameters
serviceThe service in question
actionListenerA callback function of type MUPNP_ACTION_LISTNER

◆ mupnp_service_setquerylistener()

void mupnp_service_setquerylistener ( mUpnpService * service,
MUPNP_STATEVARIABLE_LISTNER queryListener )

Set a query listener to the service

Parameters
serviceThe service in question
queryListenerA callback function of type MUPNP_STATEVARIABLE_LISTNER

◆ mupnp_servicetype_getidentifier()

const char * mupnp_servicetype_getidentifier ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL

◆ mupnp_servicetype_getschematype()

char * mupnp_servicetype_getschematype ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL

◆ mupnp_servicetype_getservice()

const char * mupnp_servicetype_getservice ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL

◆ mupnp_servicetype_gettype()

const char * mupnp_servicetype_gettype ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL

◆ mupnp_servicetype_geturn()

const char * mupnp_servicetype_geturn ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL

◆ mupnp_servicetype_getversion()

const char * mupnp_servicetype_getversion ( const char * serviceType)

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

Parameters
serviceTypeA service type string (usually the result from mupnp_service_getservicetype)
Returns
A newly-created char* if successful; otherwise NULL