1 /* $Id: upnphttp.h,v 1.40 2014/12/09 16:41:21 nanard Exp $ */
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2014 Thomas Bernard
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
8 #ifndef UPNPHTTP_H_INCLUDED
9 #define UPNPHTTP_H_INCLUDED
11 #include <netinet/in.h>
12 #include <sys/queue.h>
17 #include <openssl/ssl.h>
18 #endif /* ENABLE_HTTPS */
21 /* according to "UPnP Device Architecture 1.0" */
22 #define UPNP_VERSION_STRING "UPnP/1.0"
24 /* according to "UPnP Device Architecture 1.1" */
25 #define UPNP_VERSION_STRING "UPnP/1.1"
28 /* server: HTTP header returned in all HTTP responses : */
29 #define MINIUPNPD_SERVER_STRING OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
33 0 - waiting for data to read
34 1 - waiting for HTTP Post Content.
36 >= 100 - to be deleted
39 EWaitingForHttpRequest
= 0,
40 EWaitingForHttpContent
,
56 struct in_addr clientaddr
; /* client address */
59 struct in6_addr clientaddr_v6
;
60 #endif /* ENABLE_IPV6 */
63 #endif /* ENABLE_HTTPS */
64 enum httpStates state
;
68 char accept_language
[8];
71 int req_contentoff
; /* header length */
72 enum httpCommands req_command
;
73 int req_soapActionOff
;
74 int req_soapActionLen
;
75 int req_HostOff
; /* Host: header */
78 int req_CallbackOff
; /* For SUBSCRIBE */
81 int req_SIDOff
; /* For UNSUBSCRIBE */
89 int respflags
; /* see FLAG_* constants below */
95 LIST_ENTRY(upnphttp
) entries
;
98 /* Include the "Timeout:" header in response */
99 #define FLAG_TIMEOUT 0x01
100 /* Include the "SID:" header in response */
101 #define FLAG_SID 0x02
103 /* If set, the POST request included a "Expect: 100-continue" header */
104 #define FLAG_CONTINUE 0x40
106 /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
107 #define FLAG_HTML 0x80
109 /* If set, the corresponding Allow: header is set */
110 #define FLAG_ALLOW_POST 0x100
111 #define FLAG_ALLOW_SUB_UNSUB 0x200
116 #endif /* ENABLE_HTTPS */
124 InitSSL_upnphttp(struct upnphttp
*);
125 #endif /* ENABLE_HTTPS */
127 /* CloseSocket_upnphttp() */
129 CloseSocket_upnphttp(struct upnphttp
*);
131 /* Delete_upnphttp() */
133 Delete_upnphttp(struct upnphttp
*);
135 /* Process_upnphttp() */
137 Process_upnphttp(struct upnphttp
*);
139 /* BuildHeader_upnphttp()
140 * build the header for the HTTP Response
141 * also allocate the buffer for body data
142 * return -1 on error */
144 BuildHeader_upnphttp(struct upnphttp
* h
, int respcode
,
145 const char * respmsg
,
148 /* BuildResp_upnphttp()
149 * fill the res_buf buffer with the complete
150 * HTTP 200 OK response from the body passed as argument */
152 BuildResp_upnphttp(struct upnphttp
*, const char *, int);
154 /* BuildResp2_upnphttp()
155 * same but with given response code/message */
157 BuildResp2_upnphttp(struct upnphttp
* h
, int respcode
,
158 const char * respmsg
,
159 const char * body
, int bodylen
);
162 SendResp_upnphttp(struct upnphttp
*);
164 /* SendRespAndClose_upnphttp() */
166 SendRespAndClose_upnphttp(struct upnphttp
*);