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 <string.h>
#include <time.h>
#include "client_table.h"
#include "httpparser.h"
#include "miniserver.h"
#include "service_table.h"
#include "sock.h"
#include "ThreadPool.h"
#include "upnp.h"
#include "UpnpString.h"
#include "uri.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\n"); \
ithread_mutex_lock(&GlobalClientSubscribeMutex); \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Subscribe Lock\n");
#define SubscribeUnlock() \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Trying Subscribe UnLock\n"); \
ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Subscribe UnLock\n");
typedef struct NOTIFY_THREAD_STRUCT {
char *headers;
DOMString propertySet;
char *servId;
char *UDN;
Upnp_SID sid;
int eventKey;
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 */