gena.h
Go to the documentation of this file.
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef GENA_H
#define GENA_H
#include "config.h"
#include <time.h>
#include "UpnpString.h"
#include "httpparser.h"
#include "ithread.h"
#include "sock.h"
#include "upnp.h"
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else /* __cplusplus */
#ifndef EXTERN_C
#define EXTERN_C
#endif /* EXTERN_C */
#endif /* __cplusplus */
#define XML_VERSION "<?xml version='1.0' encoding='ISO-8859-1' ?>\n"
#define XML_PROPERTYSET_HEADER \
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n"
#define UNABLE_MEMORY "HTTP/1.1 500 Internal Server Error\r\n\r\n"
#define UNABLE_SERVICE_UNKNOWN "HTTP/1.1 404 Not Found\r\n\r\n"
#define UNABLE_SERVICE_NOT_ACCEPT "HTTP/1.1 503 Service Not Available\r\n\r\n"
#define NOT_IMPLEMENTED "HTTP/1.1 501 Not Implemented\r\n\r\n"
#define BAD_REQUEST "HTTP/1.1 400 Bad Request\r\n\r\n"
#define INVALID_NT BAD_CALLBACK
#define BAD_CALLBACK "HTTP/1.1 412 Precondition Failed\r\n\r\n"
#define HTTP_OK_CRLF "HTTP/1.1 200 OK\r\n\r\n"
#define HTTP_OK_STR "HTTP/1.1 200 OK\r\n"
#define INVALID_SID BAD_CALLBACK
#define MISSING_SID BAD_CALLBACK
#define MAX_CONTENT_LENGTH 20
#define MAX_SECONDS 10
#define MAX_EVENTS 20
#define MAX_PORT_SIZE 10
#define GENA_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
#define GENA_E_BAD_SERVICE UPNP_E_INVALID_SERVICE
#define GENA_E_SUBSCRIPTION_UNACCEPTED UPNP_E_SUBSCRIBE_UNACCEPTED
#define GENA_E_BAD_SID UPNP_E_INVALID_SID
#define GENA_E_UNSUBSCRIBE_UNACCEPTED UPNP_E_UNSUBSCRIBE_UNACCEPTED
#define GENA_E_NOTIFY_UNACCEPTED UPNP_E_NOTIFY_UNACCEPTED
#define GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB -9
#define GENA_E_BAD_HANDLE UPNP_E_INVALID_HANDLE
#define XML_ERROR -5
#define XML_SUCCESS UPNP_E_SUCCESS
#define GENA_SUCCESS UPNP_E_SUCCESS
#define CALLBACK_SUCCESS 0
#define DEFAULT_TIMEOUT 1801
extern ithread_mutex_t GlobalClientSubscribeMutex;
#define SubscribeLock() \
UpnpPrintf( \
UPNP_INFO, GENA, __FILE__, __LINE__, "Trying Subscribe Lock"); \
ithread_mutex_lock(&GlobalClientSubscribeMutex); \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "Subscribe Lock")
#define SubscribeUnlock() \
UpnpPrintf(UPNP_INFO, \
GENA, \
__FILE__, \
__LINE__, \
"Trying Subscribe UnLock"); \
ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "Subscribe UnLock")
typedef struct NOTIFY_THREAD_STRUCT
{
char *headers;
DOMString propertySet;
char *servId;
char *UDN;
Upnp_SID sid;
time_t ctime;
int *reference_count;
UpnpDevice_Handle device_handle;
} notify_thread_struct;
EXTERN_C void genaCallback(
http_parser_t *parser,
http_message_t *request,
SOCKINFO *info);
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaSubscribe(
UpnpClient_Handle client_handle,
const UpnpString *PublisherURL,
int *TimeOut,
UpnpString *out_sid);
#endif /* INCLUDE_CLIENT_APIS */
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaUnSubscribe(
UpnpClient_Handle client_handle,
const UpnpString *in_sid);
#endif /* INCLUDE_CLIENT_APIS */
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaUnregisterClient(
UpnpClient_Handle client_handle);
#endif /* INCLUDE_CLIENT_APIS */
/*
* DEVICE
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaUnregisterDevice(
UpnpDevice_Handle device_handle);
#endif /* INCLUDE_CLIENT_APIS */
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaRenewSubscription(
UpnpClient_Handle client_handle,
const UpnpString *in_sid,
int *TimeOut);
#endif /* INCLUDE_CLIENT_APIS */
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAll(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
char **VarNames,
char **VarValues,
int var_count);
#endif /* INCLUDE_DEVICE_APIS */
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAllExt(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
IXML_Document *PropSet);
#endif /* INCLUDE_DEVICE_APIS */
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotify(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
char **VarNames,
char **VarValues,
int var_count,
const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotifyExt(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
IXML_Document *PropSet,
const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
void error_respond(
SOCKINFO *info,
int error_code,
http_message_t *hmsg);
#endif /* GENA_H */
UpnpString.h
UpnpString object declaration.
notify_thread_struct
struct NOTIFY_THREAD_STRUCT notify_thread_struct
genaUnregisterClient
int genaUnregisterClient(UpnpClient_Handle client_handle)
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
Definition gena_ctrlpt.c:473
genaNotifyAll
int genaNotifyAll(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count)
Sends a notification to all the subscribed control points.
Definition gena_device.c:1004
genaUnregisterDevice
int genaUnregisterDevice(UpnpDevice_Handle device_handle)
Cleans the service table of the device.
Definition gena_device.c:61
genaUnSubscribe
int genaUnSubscribe(UpnpClient_Handle client_handle, const UpnpString *in_sid)
Unsubscribes a SID.
Definition gena_ctrlpt.c:518
genaCallback
void genaCallback(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
This is the callback function called by the miniserver to handle incoming GENA requests.
Definition gena_callback2.c:84
genaNotifyAllExt
int genaNotifyAllExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
Sends a notification to all the subscribed control points.
Definition gena_device.c:961
genaSubscribe
int genaSubscribe(UpnpClient_Handle client_handle, const UpnpString *PublisherURL, int *TimeOut, UpnpString *out_sid)
This function subscribes to a PublisherURL (also mentioned as EventURL in some places).
Definition gena_ctrlpt.c:567
genaInitNotifyExt
int genaInitNotifyExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet, const Upnp_SID sid)
Similar to the genaInitNofity. The only difference is that it takes the xml document for the state ta...
Definition gena_device.c:710
error_respond
void error_respond(SOCKINFO *info, int error_code, http_message_t *hmsg)
Sends an error message to the control point in the case of incorrect GENA requests.
Definition gena_callback2.c:58
genaRenewSubscription
int genaRenewSubscription(UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut)
Renews a SID.
Definition gena_ctrlpt.c:662
genaInitNotify
int genaInitNotify(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count, const Upnp_SID sid)
Sends the intial state table dump to newly subscribed control point.
Definition gena_device.c:659
Upnp_SID
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
UpnpClient_Handle
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition upnp.h:429
GlobalClientSubscribeMutex
ithread_mutex_t GlobalClientSubscribeMutex
Definition upnpapi.c:115
UpnpDevice_Handle
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition upnp.h:439
device_handle
UpnpDevice_Handle device_handle
Definition tv_device.c:78
UpnpString
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
Definition UpnpString.h:33
DOMString
#define DOMString
The type of DOM strings.
Definition ixml.h:48
httpparser.h
ithread.h
sock.h
NOTIFY_THREAD_STRUCT
Definition gena.h:125
SOCKINFO
Definition sock.h:60
_IXML_Document
Data structure representing the DOM Document.
Definition ixml.h:160
http_message_t
Definition httpparser.h:182
http_parser_t
Definition httpparser.h:217
upnp.h