Electroneum
Toggle main menu visibility
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-2015 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
*/
33
enum
httpStates
{
34
EWaitingForHttpRequest
= 0,
35
EWaitingForHttpContent
,
36
ESendingContinue
,
37
ESendingAndClosing
,
38
EToDelete
= 100
39
};
40
41
enum
httpCommands
{
42
EUnknown
= 0,
43
EGet
,
44
EPost
,
45
ESubscribe
,
46
EUnSubscribe
47
};
48
49
struct
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 */
60
enum
httpStates
state
;
61
char
HttpVer
[16];
62
/* request */
63
char
*
req_buf
;
64
char
accept_language
[8];
65
int
req_buflen
;
66
int
req_contentlen
;
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 */
72
int
req_HostLen
;
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
;
88
int
res_buflen
;
89
int
res_sent
;
90
int
res_buf_alloclen
;
91
LIST_ENTRY
(
upnphttp
) entries;
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
110
int
init_ssl(
void
);
111
void
free_ssl(
void
);
112
#endif
/* ENABLE_HTTPS */
113
114
/* New_upnphttp() */
115
struct
upnphttp
*
116
New_upnphttp
(
int
);
117
118
#ifdef ENABLE_HTTPS
119
void
120
InitSSL_upnphttp(
struct
upnphttp
*);
121
#endif
/* ENABLE_HTTPS */
122
123
/* CloseSocket_upnphttp() */
124
void
125
CloseSocket_upnphttp
(
struct
upnphttp
*);
126
127
/* Delete_upnphttp() */
128
void
129
Delete_upnphttp
(
struct
upnphttp
*);
130
131
/* Process_upnphttp() */
132
void
133
Process_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 */
139
int
140
BuildHeader_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 */
147
void
148
BuildResp_upnphttp
(
struct
upnphttp
*,
const
char
*,
int
);
149
150
/* BuildResp2_upnphttp()
151
* same but with given response code/message */
152
void
153
BuildResp2_upnphttp
(
struct
upnphttp
* h,
int
respcode,
154
const
char
* respmsg,
155
const
char
* body,
int
bodylen);
156
157
int
158
SendResp_upnphttp
(
struct
upnphttp
*);
159
160
/* SendRespAndClose_upnphttp() */
161
void
162
SendRespAndClose_upnphttp
(
struct
upnphttp
*);
163
164
#endif
165
in6_addr
Definition
fake-rfc2553.h:68
upnphttp
Definition
upnphttp.h:49
upnphttp::req_soapActionLen
int req_soapActionLen
Definition
upnphttp.h:70
upnphttp::accept_language
char accept_language[8]
Definition
upnphttp.h:64
upnphttp::res_buflen
int res_buflen
Definition
upnphttp.h:88
upnphttp::res_buf
char * res_buf
Definition
upnphttp.h:87
upnphttp::res_buf_alloclen
int res_buf_alloclen
Definition
upnphttp.h:90
upnphttp::req_HostLen
int req_HostLen
Definition
upnphttp.h:72
upnphttp::req_contentoff
int req_contentoff
Definition
upnphttp.h:67
upnphttp::clientaddr
struct in_addr clientaddr
Definition
upnphttp.h:51
upnphttp::req_HostOff
int req_HostOff
Definition
upnphttp.h:71
upnphttp::req_buflen
int req_buflen
Definition
upnphttp.h:65
upnphttp::req_command
enum httpCommands req_command
Definition
upnphttp.h:68
upnphttp::state
enum httpStates state
Definition
upnphttp.h:60
upnphttp::req_soapActionOff
int req_soapActionOff
Definition
upnphttp.h:69
upnphttp::LIST_ENTRY
LIST_ENTRY(upnphttp) entries
upnphttp::socket
int socket
Definition
upnphttp.h:50
upnphttp::req_buf
char * req_buf
Definition
upnphttp.h:63
upnphttp::respflags
int respflags
Definition
upnphttp.h:85
upnphttp::HttpVer
char HttpVer[16]
Definition
upnphttp.h:61
upnphttp::res_sent
int res_sent
Definition
upnphttp.h:89
upnphttp::req_contentlen
int req_contentlen
Definition
upnphttp.h:66
upnphttp::clientaddr_str
char clientaddr_str[64]
Definition
upnphttp.h:59
httpStates
httpStates
Definition
upnphttp.h:33
EWaitingForHttpContent
@ EWaitingForHttpContent
Definition
upnphttp.h:35
EWaitingForHttpRequest
@ EWaitingForHttpRequest
Definition
upnphttp.h:34
ESendingContinue
@ ESendingContinue
Definition
upnphttp.h:36
ESendingAndClosing
@ ESendingAndClosing
Definition
upnphttp.h:37
EToDelete
@ EToDelete
Definition
upnphttp.h:38
Process_upnphttp
void Process_upnphttp(struct upnphttp *)
SendResp_upnphttp
int SendResp_upnphttp(struct upnphttp *)
BuildResp2_upnphttp
void BuildResp2_upnphttp(struct upnphttp *h, int respcode, const char *respmsg, const char *body, int bodylen)
New_upnphttp
struct upnphttp * New_upnphttp(int)
BuildHeader_upnphttp
int BuildHeader_upnphttp(struct upnphttp *h, int respcode, const char *respmsg, int bodylen)
BuildResp_upnphttp
void BuildResp_upnphttp(struct upnphttp *, const char *, int)
SendRespAndClose_upnphttp
void SendRespAndClose_upnphttp(struct upnphttp *)
httpCommands
httpCommands
Definition
upnphttp.h:41
EGet
@ EGet
Definition
upnphttp.h:43
ESubscribe
@ ESubscribe
Definition
upnphttp.h:45
EUnSubscribe
@ EUnSubscribe
Definition
upnphttp.h:46
EUnknown
@ EUnknown
Definition
upnphttp.h:42
EPost
@ EPost
Definition
upnphttp.h:44
Delete_upnphttp
void Delete_upnphttp(struct upnphttp *)
CloseSocket_upnphttp
void CloseSocket_upnphttp(struct upnphttp *)
external
miniupnp
miniupnpd
upnphttp.h
Generated on
for Electroneum by
1.17.0