Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef GENA_H
00034 #define GENA_H
00035
00036
00042 #include "config.h"
00043
00044
00045 #include <string.h>
00046 #include <time.h>
00047
00048
00049 #include "client_table.h"
00050 #include "httpparser.h"
00051 #include "miniserver.h"
00052 #include "service_table.h"
00053 #include "sock.h"
00054 #include "ThreadPool.h"
00055 #include "upnp.h"
00056 #include "UpnpString.h"
00057 #include "uri.h"
00058
00059
00060 #ifdef __cplusplus
00061 #define EXTERN_C extern "C"
00062 #else
00063 #ifndef EXTERN_C
00064 #define EXTERN_C
00065 #endif
00066 #endif
00067
00068
00073 #define XML_VERSION "<?xml version='1.0' encoding='ISO-8859-1' ?>\n"
00074 #define XML_PROPERTYSET_HEADER \
00075 "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n"
00076
00077
00078 #define UNABLE_MEMORY "HTTP/1.1 500 Internal Server Error\r\n\r\n"
00079 #define UNABLE_SERVICE_UNKNOWN "HTTP/1.1 404 Not Found\r\n\r\n"
00080 #define UNABLE_SERVICE_NOT_ACCEPT "HTTP/1.1 503 Service Not Available\r\n\r\n"
00081
00082
00083 #define NOT_IMPLEMENTED "HTTP/1.1 501 Not Implemented\r\n\r\n"
00084 #define BAD_REQUEST "HTTP/1.1 400 Bad Request\r\n\r\n"
00085 #define INVALID_NT BAD_CALLBACK
00086 #define BAD_CALLBACK "HTTP/1.1 412 Precondition Failed\r\n\r\n"
00087 #define HTTP_OK_CRLF "HTTP/1.1 200 OK\r\n\r\n"
00088 #define HTTP_OK_STR "HTTP/1.1 200 OK\r\n"
00089 #define INVALID_SID BAD_CALLBACK
00090 #define MISSING_SID BAD_CALLBACK
00091 #define MAX_CONTENT_LENGTH 20
00092 #define MAX_SECONDS 10
00093 #define MAX_EVENTS 20
00094 #define MAX_PORT_SIZE 10
00095
00096
00097 #define GENA_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
00098 #define GENA_E_BAD_SERVICE UPNP_E_INVALID_SERVICE
00099 #define GENA_E_SUBSCRIPTION_UNACCEPTED UPNP_E_SUBSCRIBE_UNACCEPTED
00100 #define GENA_E_BAD_SID UPNP_E_INVALID_SID
00101 #define GENA_E_UNSUBSCRIBE_UNACCEPTED UPNP_E_UNSUBSCRIBE_UNACCEPTED
00102 #define GENA_E_NOTIFY_UNACCEPTED UPNP_E_NOTIFY_UNACCEPTED
00103 #define GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB -9
00104 #define GENA_E_BAD_HANDLE UPNP_E_INVALID_HANDLE
00105
00106
00107 #define XML_ERROR -5
00108 #define XML_SUCCESS UPNP_E_SUCCESS
00109 #define GENA_SUCCESS UPNP_E_SUCCESS
00110
00111
00112 #define CALLBACK_SUCCESS 0
00113 #define DEFAULT_TIMEOUT 1801
00114
00115
00116 extern ithread_mutex_t GlobalClientSubscribeMutex;
00117
00118
00122 #define SubscribeLock() \
00123 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
00124 "Trying Subscribe Lock\n"); \
00125 ithread_mutex_lock(&GlobalClientSubscribeMutex); \
00126 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
00127 "Subscribe Lock\n");
00128
00129
00133 #define SubscribeUnlock() \
00134 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
00135 "Trying Subscribe UnLock\n"); \
00136 ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
00137 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
00138 "Subscribe UnLock\n");
00139
00140
00144 typedef struct NOTIFY_THREAD_STRUCT {
00145 char *headers;
00146 DOMString propertySet;
00147 char *servId;
00148 char *UDN;
00149 Upnp_SID sid;
00150 int eventKey;
00151 int *reference_count;
00152 UpnpDevice_Handle device_handle;
00153 } notify_thread_struct;
00154
00155
00162 EXTERN_C void genaCallback(
00164 http_parser_t *parser,
00166 http_message_t* request,
00168 SOCKINFO *info);
00169
00170
00181 #ifdef INCLUDE_CLIENT_APIS
00182 EXTERN_C int genaSubscribe(
00184 UpnpClient_Handle client_handle,
00186 const UpnpString *PublisherURL,
00191 int *TimeOut,
00193 UpnpString *out_sid);
00194 #endif
00195
00196
00207 #ifdef INCLUDE_CLIENT_APIS
00208 EXTERN_C int genaUnSubscribe(
00210 UpnpClient_Handle client_handle,
00212 const UpnpString *in_sid);
00213 #endif
00214
00215
00225 #ifdef INCLUDE_CLIENT_APIS
00226 EXTERN_C int genaUnregisterClient(
00228 UpnpClient_Handle client_handle);
00229 #endif
00230
00231
00232
00233
00234
00235
00236
00242 #ifdef INCLUDE_DEVICE_APIS
00243 EXTERN_C int genaUnregisterDevice(
00245 UpnpDevice_Handle device_handle);
00246 #endif
00247
00248
00259 #ifdef INCLUDE_CLIENT_APIS
00260 EXTERN_C int genaRenewSubscription(
00262 UpnpClient_Handle client_handle,
00264 const UpnpString *in_sid,
00267 int *TimeOut);
00268 #endif
00269
00270
00279 #ifdef INCLUDE_DEVICE_APIS
00280 EXTERN_C int genaNotifyAll(
00282 UpnpDevice_Handle device_handle,
00284 char *UDN,
00286 char *servId,
00288 char **VarNames,
00290 char **VarValues,
00292 int var_count);
00293 #endif
00294
00295
00304 #ifdef INCLUDE_DEVICE_APIS
00305 EXTERN_C int genaNotifyAllExt(
00307 UpnpDevice_Handle device_handle,
00309 char *UDN,
00311 char *servId,
00313 IXML_Document *PropSet);
00314 #endif
00315
00316
00325 #ifdef INCLUDE_DEVICE_APIS
00326 EXTERN_C int genaInitNotify(
00328 UpnpDevice_Handle device_handle,
00330 char *UDN,
00332 char *servId,
00334 char **VarNames,
00336 char **VarValues,
00338 int var_count,
00340 const Upnp_SID sid);
00341 #endif
00342
00343
00354 #ifdef INCLUDE_DEVICE_APIS
00355 EXTERN_C int genaInitNotifyExt(
00357 UpnpDevice_Handle device_handle,
00359 char *UDN,
00361 char *servId,
00363 IXML_Document *PropSet,
00365 const Upnp_SID sid);
00366 #endif
00367
00368
00375 void error_respond(
00377 SOCKINFO *info,
00379 int error_code,
00381 http_message_t* hmsg);
00382
00383
00384 #endif
00385