Add PPTP runtime and GUI
[tomato.git] / release / src / router / miniupnpd / upnphttp.h
blob96b3260f62df18b0fc836db56fb426e108c4f220
1 /* $Id: upnphttp.h,v 1.24 2011/06/27 11:06:00 nanard Exp $ */
2 /* MiniUPnP project
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2011 Thomas Bernard
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
8 #ifndef __UPNPHTTP_H__
9 #define __UPNPHTTP_H__
11 #include <netinet/in.h>
12 #include <sys/queue.h>
14 #include "config.h"
16 /* server: HTTP header returned in all HTTP responses : */
17 #define MINIUPNPD_SERVER_STRING OS_VERSION " UPnP/1.0 MiniUPnPd/" MINIUPNPD_VERSION
20 states :
21 0 - waiting for data to read
22 1 - waiting for HTTP Post Content.
23 ...
24 >= 100 - to be deleted
26 enum httpCommands {
27 EUnknown = 0,
28 EGet,
29 EPost,
30 ESubscribe,
31 EUnSubscribe
34 struct upnphttp {
35 int socket;
36 struct in_addr clientaddr; /* client address */
37 #ifdef ENABLE_IPV6
38 int ipv6;
39 struct in6_addr clientaddr_v6;
40 #endif
41 int state;
42 char HttpVer[16];
43 /* request */
44 char * req_buf;
45 int req_buflen;
46 int req_contentlen;
47 int req_contentoff; /* header length */
48 enum httpCommands req_command;
49 const char * req_soapAction;
50 int req_soapActionLen;
51 #ifdef ENABLE_EVENTS
52 const char * req_Callback; /* For SUBSCRIBE */
53 int req_CallbackLen;
54 int req_Timeout;
55 const char * req_SID; /* For UNSUBSCRIBE */
56 int req_SIDLen;
57 #endif
58 int respflags; /* see FLAG_* constants below */
59 /* response */
60 char * res_buf;
61 int res_buflen;
62 int res_buf_alloclen;
63 /*int res_contentlen;*/
64 /*int res_contentoff;*/ /* header length */
65 LIST_ENTRY(upnphttp) entries;
68 /* Include the "Timeout:" header in response */
69 #define FLAG_TIMEOUT 0x01
70 /* Include the "SID:" header in response */
71 #define FLAG_SID 0x02
73 /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
74 #define FLAG_HTML 0x80
76 /* New_upnphttp() */
77 struct upnphttp *
78 New_upnphttp(int);
80 /* CloseSocket_upnphttp() */
81 void
82 CloseSocket_upnphttp(struct upnphttp *);
84 /* Delete_upnphttp() */
85 void
86 Delete_upnphttp(struct upnphttp *);
88 /* Process_upnphttp() */
89 void
90 Process_upnphttp(struct upnphttp *);
92 /* BuildHeader_upnphttp()
93 * build the header for the HTTP Response
94 * also allocate the buffer for body data */
95 void
96 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
97 const char * respmsg,
98 int bodylen);
100 /* BuildResp_upnphttp()
101 * fill the res_buf buffer with the complete
102 * HTTP 200 OK response from the body passed as argument */
103 void
104 BuildResp_upnphttp(struct upnphttp *, const char *, int);
106 /* BuildResp2_upnphttp()
107 * same but with given response code/message */
108 void
109 BuildResp2_upnphttp(struct upnphttp * h, int respcode,
110 const char * respmsg,
111 const char * body, int bodylen);
113 /* SendResp_upnphttp() */
114 void
115 SendResp_upnphttp(struct upnphttp *);
117 #endif