1 /* $Id: upnphttp.h,v 1.35 2012/10/03 21:03:50 nanard Exp $ */
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2012 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 /* according to "UPnP Device Architecture 1.0" */
18 #define UPNP_VERSION_STRING "UPnP/1.0"
20 /* according to "UPnP Device Architecture 1.1" */
21 #define UPNP_VERSION_STRING "UPnP/1.1"
24 /* server: HTTP header returned in all HTTP responses : */
25 #define MINIUPNPD_SERVER_STRING OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
29 0 - waiting for data to read
30 1 - waiting for HTTP Post Content.
32 >= 100 - to be deleted
35 EWaitingForHttpRequest
= 0,
36 EWaitingForHttpContent
,
52 struct in_addr clientaddr
; /* client address */
55 struct in6_addr clientaddr_v6
;
57 enum httpStates state
;
61 char accept_language
[8];
64 int req_contentoff
; /* header length */
65 enum httpCommands req_command
;
66 int req_soapActionOff
;
67 int req_soapActionLen
;
69 int req_CallbackOff
; /* For SUBSCRIBE */
72 int req_SIDOff
; /* For UNSUBSCRIBE */
80 int respflags
; /* see FLAG_* constants below */
86 LIST_ENTRY(upnphttp
) entries
;
89 /* Include the "Timeout:" header in response */
90 #define FLAG_TIMEOUT 0x01
91 /* Include the "SID:" header in response */
94 /* If set, the POST request included a "Expect: 100-continue" header */
95 #define FLAG_CONTINUE 0x40
97 /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
98 #define FLAG_HTML 0x80
100 /* If set, the corresponding Allow: header is set */
101 #define FLAG_ALLOW_POST 0x100
102 #define FLAG_ALLOW_SUB_UNSUB 0x200
109 /* CloseSocket_upnphttp() */
111 CloseSocket_upnphttp(struct upnphttp
*);
113 /* Delete_upnphttp() */
115 Delete_upnphttp(struct upnphttp
*);
117 /* Process_upnphttp() */
119 Process_upnphttp(struct upnphttp
*);
121 /* BuildHeader_upnphttp()
122 * build the header for the HTTP Response
123 * also allocate the buffer for body data */
125 BuildHeader_upnphttp(struct upnphttp
* h
, int respcode
,
126 const char * respmsg
,
129 /* BuildResp_upnphttp()
130 * fill the res_buf buffer with the complete
131 * HTTP 200 OK response from the body passed as argument */
133 BuildResp_upnphttp(struct upnphttp
*, const char *, int);
135 /* BuildResp2_upnphttp()
136 * same but with given response code/message */
138 BuildResp2_upnphttp(struct upnphttp
* h
, int respcode
,
139 const char * respmsg
,
140 const char * body
, int bodylen
);
143 SendResp_upnphttp(struct upnphttp
*);
145 /* SendRespAndClose_upnphttp() */
147 SendRespAndClose_upnphttp(struct upnphttp
*);