Monero
Loading...
Searching...
No Matches
upnphttp.h
Go to the documentation of this file.
1/* $Id: upnphttp.h,v 1.42 2015/12/16 10:21:49 nanard Exp $ */
2/* vim: tabstop=4 shiftwidth=4 noexpandtab
3 * MiniUPnP project
4 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
5 * (c) 2006-2020 Thomas Bernard
6 * This software is subject to the conditions detailed
7 * in the LICENCE file provided within the distribution */
8
9#ifndef UPNPHTTP_H_INCLUDED
10#define UPNPHTTP_H_INCLUDED
11
12#include <netinet/in.h>
13#include <sys/queue.h>
14
15#include "config.h"
16
17#ifdef ENABLE_HTTPS
18#include <openssl/ssl.h>
19#endif /* ENABLE_HTTPS */
20
21#define UPNP_VERSION_STRING "UPnP/" UPNP_VERSION_MAJOR_STR "." UPNP_VERSION_MINOR_STR
22
23/* server: HTTP header returned in all HTTP responses : */
24#define MINIUPNPD_SERVER_STRING OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
25
26/*
27 states :
28 0 - waiting for data to read
29 1 - waiting for HTTP Post Content.
30 ...
31 >= 100 - to be deleted
32*/
40
48
49struct upnphttp {
50 int socket;
51 struct in_addr clientaddr; /* client address */
52#ifdef ENABLE_IPV6
53 int ipv6;
54 struct in6_addr clientaddr_v6;
55#endif /* ENABLE_IPV6 */
56#ifdef ENABLE_HTTPS
57 SSL * ssl;
58#endif /* ENABLE_HTTPS */
59 char clientaddr_str[64]; /* used for syslog() output */
61 char HttpVer[16];
62 /* request */
63 char * req_buf;
67 int req_contentoff; /* header length */
71 int req_HostOff; /* Host: header */
73#ifdef ENABLE_EVENTS
74 int req_CallbackOff; /* For SUBSCRIBE */
75 int req_CallbackLen;
76 int req_Timeout;
77 int req_SIDOff; /* For UNSUBSCRIBE */
78 int req_SIDLen;
79 const char * res_SID;
80#ifdef UPNP_STRICT
81 int req_NTOff;
82 int req_NTLen;
83#endif
84#endif
85 int respflags; /* see FLAG_* constants below */
86 /* response */
87 char * res_buf;
92};
93
94/* Include the "Timeout:" header in response */
95#define FLAG_TIMEOUT 0x01
96/* Include the "SID:" header in response */
97#define FLAG_SID 0x02
98
99/* If set, the POST request included a "Expect: 100-continue" header */
100#define FLAG_CONTINUE 0x40
101
102/* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
103#define FLAG_HTML 0x80
104
105/* If set, the corresponding Allow: header is set */
106#define FLAG_ALLOW_POST 0x100
107#define FLAG_ALLOW_SUB_UNSUB 0x200
108
109#ifdef ENABLE_HTTPS
110int init_ssl(void);
111void free_ssl(void);
112#endif /* ENABLE_HTTPS */
113
114/* New_upnphttp() */
115struct upnphttp *
116New_upnphttp(int);
117
118#ifdef ENABLE_HTTPS
119void
120InitSSL_upnphttp(struct upnphttp *);
121#endif /* ENABLE_HTTPS */
122
123/* CloseSocket_upnphttp() */
124void
126
127/* Delete_upnphttp() */
128void
129Delete_upnphttp(struct upnphttp *);
130
131/* Process_upnphttp() */
132void
133Process_upnphttp(struct upnphttp *);
134
135/* BuildHeader_upnphttp()
136 * build the header for the HTTP Response
137 * also allocate the buffer for body data
138 * return -1 on error */
139int
140BuildHeader_upnphttp(struct upnphttp * h, int respcode,
141 const char * respmsg,
142 int bodylen);
143
144/* BuildResp_upnphttp()
145 * fill the res_buf buffer with the complete
146 * HTTP 200 OK response from the body passed as argument */
147void
148BuildResp_upnphttp(struct upnphttp *, const char *, int);
149
150/* BuildResp2_upnphttp()
151 * same but with given response code/message */
152void
153BuildResp2_upnphttp(struct upnphttp * h, int respcode,
154 const char * respmsg,
155 const char * body, int bodylen);
156
157int
159
160/* SendRespAndClose_upnphttp() */
161void
163
164#endif
165
static uint64_t h
Definition blockchain_stats.cpp:55
Definition upnphttp.h:49
int req_soapActionLen
Definition upnphttp.h:70
char accept_language[8]
Definition upnphttp.h:64
int res_buflen
Definition upnphttp.h:88
char * res_buf
Definition upnphttp.h:87
int res_buf_alloclen
Definition upnphttp.h:90
int req_HostLen
Definition upnphttp.h:72
int req_contentoff
Definition upnphttp.h:67
struct in_addr clientaddr
Definition upnphttp.h:51
int req_HostOff
Definition upnphttp.h:71
int req_buflen
Definition upnphttp.h:65
enum httpCommands req_command
Definition upnphttp.h:68
enum httpStates state
Definition upnphttp.h:60
int req_soapActionOff
Definition upnphttp.h:69
LIST_ENTRY(upnphttp) entries
int socket
Definition upnphttp.h:50
char * req_buf
Definition upnphttp.h:63
int respflags
Definition upnphttp.h:85
char HttpVer[16]
Definition upnphttp.h:61
int res_sent
Definition upnphttp.h:89
int req_contentlen
Definition upnphttp.h:66
char clientaddr_str[64]
Definition upnphttp.h:59
httpStates
Definition upnphttp.h:33
@ EWaitingForHttpContent
Definition upnphttp.h:35
@ EWaitingForHttpRequest
Definition upnphttp.h:34
@ ESendingContinue
Definition upnphttp.h:36
@ ESendingAndClosing
Definition upnphttp.h:37
@ EToDelete
Definition upnphttp.h:38
void Process_upnphttp(struct upnphttp *)
Definition upnphttp.c:904
int SendResp_upnphttp(struct upnphttp *)
Definition upnphttp.c:1221
void BuildResp2_upnphttp(struct upnphttp *h, int respcode, const char *respmsg, const char *body, int bodylen)
Definition upnphttp.c:1201
struct upnphttp * New_upnphttp(int)
Definition upnphttp.c:136
int BuildHeader_upnphttp(struct upnphttp *h, int respcode, const char *respmsg, int bodylen)
Definition upnphttp.c:1102
void BuildResp_upnphttp(struct upnphttp *, const char *, int)
Definition upnphttp.c:1214
void SendRespAndClose_upnphttp(struct upnphttp *)
Definition upnphttp.c:1282
httpCommands
Definition upnphttp.h:41
@ EGet
Definition upnphttp.h:43
@ ESubscribe
Definition upnphttp.h:45
@ EUnSubscribe
Definition upnphttp.h:46
@ EUnknown
Definition upnphttp.h:42
@ EPost
Definition upnphttp.h:44
void Delete_upnphttp(struct upnphttp *)
Definition upnphttp.c:194
void CloseSocket_upnphttp(struct upnphttp *)
Definition upnphttp.c:182