Stealth Mode script
[tomato.git] / release / src / router / miniupnpd / upnphttp.h
blob5e2e523c98e59401e12a3839838ccf98d452cae5
1 /* $Id: upnphttp.h,v 1.35 2012/10/03 21:03:50 nanard Exp $ */
2 /* MiniUPnP project
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>
14 #include "config.h"
16 #if 0
17 /* according to "UPnP Device Architecture 1.0" */
18 #define UPNP_VERSION_STRING "UPnP/1.0"
19 #else
20 /* according to "UPnP Device Architecture 1.1" */
21 #define UPNP_VERSION_STRING "UPnP/1.1"
22 #endif
24 /* server: HTTP header returned in all HTTP responses : */
25 #define MINIUPNPD_SERVER_STRING OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
28 states :
29 0 - waiting for data to read
30 1 - waiting for HTTP Post Content.
31 ...
32 >= 100 - to be deleted
34 enum httpStates {
35 EWaitingForHttpRequest = 0,
36 EWaitingForHttpContent,
37 ESendingContinue,
38 ESendingAndClosing,
39 EToDelete = 100
42 enum httpCommands {
43 EUnknown = 0,
44 EGet,
45 EPost,
46 ESubscribe,
47 EUnSubscribe
50 struct upnphttp {
51 int socket;
52 struct in_addr clientaddr; /* client address */
53 #ifdef ENABLE_IPV6
54 int ipv6;
55 struct in6_addr clientaddr_v6;
56 #endif
57 enum httpStates state;
58 char HttpVer[16];
59 /* request */
60 char * req_buf;
61 char accept_language[8];
62 int req_buflen;
63 int req_contentlen;
64 int req_contentoff; /* header length */
65 enum httpCommands req_command;
66 int req_soapActionOff;
67 int req_soapActionLen;
68 #ifdef ENABLE_EVENTS
69 int req_CallbackOff; /* For SUBSCRIBE */
70 int req_CallbackLen;
71 int req_Timeout;
72 int req_SIDOff; /* For UNSUBSCRIBE */
73 int req_SIDLen;
74 const char * res_SID;
75 #ifdef UPNP_STRICT
76 int req_NTOff;
77 int req_NTLen;
78 #endif
79 #endif
80 int respflags; /* see FLAG_* constants below */
81 /* response */
82 char * res_buf;
83 int res_buflen;
84 int res_sent;
85 int res_buf_alloclen;
86 LIST_ENTRY(upnphttp) entries;
89 /* Include the "Timeout:" header in response */
90 #define FLAG_TIMEOUT 0x01
91 /* Include the "SID:" header in response */
92 #define FLAG_SID 0x02
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
105 /* New_upnphttp() */
106 struct upnphttp *
107 New_upnphttp(int);
109 /* CloseSocket_upnphttp() */
110 void
111 CloseSocket_upnphttp(struct upnphttp *);
113 /* Delete_upnphttp() */
114 void
115 Delete_upnphttp(struct upnphttp *);
117 /* Process_upnphttp() */
118 void
119 Process_upnphttp(struct upnphttp *);
121 /* BuildHeader_upnphttp()
122 * build the header for the HTTP Response
123 * also allocate the buffer for body data */
124 void
125 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
126 const char * respmsg,
127 int bodylen);
129 /* BuildResp_upnphttp()
130 * fill the res_buf buffer with the complete
131 * HTTP 200 OK response from the body passed as argument */
132 void
133 BuildResp_upnphttp(struct upnphttp *, const char *, int);
135 /* BuildResp2_upnphttp()
136 * same but with given response code/message */
137 void
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() */
146 void
147 SendRespAndClose_upnphttp(struct upnphttp *);
149 #endif