1 /* $Id: upnphttp.h,v 1.42 2015/12/16 10:21:49 nanard Exp $ */
2 /* vim: tabstop=4 shiftwidth=4 noexpandtab */
4 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
5 * (c) 2006-2015 Thomas Bernard
6 * This software is subject to the conditions detailed
7 * in the LICENCE file provided within the distribution */
9 #ifndef UPNPHTTP_H_INCLUDED
10 #define UPNPHTTP_H_INCLUDED
12 #include <netinet/in.h>
13 #include <sys/queue.h>
18 #include <openssl/ssl.h>
19 #endif /* ENABLE_HTTPS */
21 #define UPNP_VERSION_STRING "UPnP/" UPNP_VERSION_MAJOR_STR "." UPNP_VERSION_MINOR_STR
23 /* server: HTTP header returned in all HTTP responses : */
24 #define MINIUPNPD_SERVER_STRING OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
28 0 - waiting for data to read
29 1 - waiting for HTTP Post Content.
31 >= 100 - to be deleted
34 EWaitingForHttpRequest
= 0,
35 EWaitingForHttpContent
,
51 struct in_addr clientaddr
; /* client address */
54 struct in6_addr clientaddr_v6
;
55 #endif /* ENABLE_IPV6 */
58 #endif /* ENABLE_HTTPS */
59 char clientaddr_str
[64]; /* used for syslog() output */
60 enum httpStates state
;
64 char accept_language
[8];
67 int req_contentoff
; /* header length */
68 enum httpCommands req_command
;
69 int req_soapActionOff
;
70 int req_soapActionLen
;
71 int req_HostOff
; /* Host: header */
74 int req_CallbackOff
; /* For SUBSCRIBE */
77 int req_SIDOff
; /* For UNSUBSCRIBE */
85 int respflags
; /* see FLAG_* constants below */
91 LIST_ENTRY(upnphttp
) entries
;
94 /* Include the "Timeout:" header in response */
95 #define FLAG_TIMEOUT 0x01
96 /* Include the "SID:" header in response */
99 /* If set, the POST request included a "Expect: 100-continue" header */
100 #define FLAG_CONTINUE 0x40
102 /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
103 #define FLAG_HTML 0x80
105 /* If set, the corresponding Allow: header is set */
106 #define FLAG_ALLOW_POST 0x100
107 #define FLAG_ALLOW_SUB_UNSUB 0x200
112 #endif /* ENABLE_HTTPS */
120 InitSSL_upnphttp(struct upnphttp
*);
121 #endif /* ENABLE_HTTPS */
123 /* CloseSocket_upnphttp() */
125 CloseSocket_upnphttp(struct upnphttp
*);
127 /* Delete_upnphttp() */
129 Delete_upnphttp(struct upnphttp
*);
131 /* Process_upnphttp() */
133 Process_upnphttp(struct upnphttp
*);
135 /* BuildHeader_upnphttp()
136 * build the header for the HTTP Response
137 * also allocate the buffer for body data
138 * return -1 on error */
140 BuildHeader_upnphttp(struct upnphttp
* h
, int respcode
,
141 const char * respmsg
,
144 /* BuildResp_upnphttp()
145 * fill the res_buf buffer with the complete
146 * HTTP 200 OK response from the body passed as argument */
148 BuildResp_upnphttp(struct upnphttp
*, const char *, int);
150 /* BuildResp2_upnphttp()
151 * same but with given response code/message */
153 BuildResp2_upnphttp(struct upnphttp
* h
, int respcode
,
154 const char * respmsg
,
155 const char * body
, int bodylen
);
158 SendResp_upnphttp(struct upnphttp
*);
160 /* SendRespAndClose_upnphttp() */
162 SendRespAndClose_upnphttp(struct upnphttp
*);