MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / minidlna / upnphttp.h
blob4808c124580b003ec852bf9c0559da87bae71c8e
1 /* MiniUPnP project
2 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * Copyright (c) 2006, Thomas Bernard
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __UPNPHTTP_H__
30 #define __UPNPHTTP_H__
32 #include <netinet/in.h>
33 #include <sys/queue.h>
35 #include "minidlnatypes.h"
36 #include "config.h"
38 /* server: HTTP header returned in all HTTP responses : */
39 #define MINIDLNA_SERVER_STRING OS_VERSION " DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.0"
42 states :
43 0 - waiting for data to read
44 1 - waiting for HTTP Post Content.
45 ...
46 >= 100 - to be deleted
48 enum httpCommands {
49 EUnknown = 0,
50 EGet,
51 EPost,
52 EHead,
53 ESubscribe,
54 EUnSubscribe
57 struct upnphttp {
58 int socket;
59 struct in_addr clientaddr; /* client address */
60 int iface;
61 int state;
62 char HttpVer[16];
63 /* request */
64 char * req_buf;
65 int req_buflen;
66 int req_contentlen;
67 int req_contentoff; /* header length */
68 enum httpCommands req_command;
69 enum client_types req_client;
70 const char * req_soapAction;
71 int req_soapActionLen;
72 const char * req_Callback; /* For SUBSCRIBE */
73 int req_CallbackLen;
74 int req_Timeout;
75 const char * req_SID; /* For UNSUBSCRIBE */
76 int req_SIDLen;
77 off_t req_RangeStart;
78 off_t req_RangeEnd;
79 long int req_chunklen;
80 uint32_t reqflags;
81 /* response */
82 char * res_buf;
83 int res_buflen;
84 int res_buf_alloclen;
85 uint32_t respflags;
86 /*int res_contentlen;*/
87 /*int res_contentoff;*/ /* header length */
88 LIST_ENTRY(upnphttp) entries;
91 #define FLAG_TIMEOUT 0x00000001
92 #define FLAG_SID 0x00000002
93 #define FLAG_RANGE 0x00000004
94 #define FLAG_HOST 0x00000008
96 #define FLAG_HTML 0x00000080
97 #define FLAG_INVALID_REQ 0x00000010
99 #define FLAG_CHUNKED 0x00000100
100 #define FLAG_TIMESEEK 0x00000200
101 #define FLAG_REALTIMEINFO 0x00000400
102 #define FLAG_PLAYSPEED 0x00000800
103 #define FLAG_XFERSTREAMING 0x00001000
104 #define FLAG_XFERINTERACTIVE 0x00002000
105 #define FLAG_XFERBACKGROUND 0x00004000
106 #define FLAG_CAPTION 0x00008000
108 #define FLAG_DLNA 0x00100000
109 #define FLAG_MIME_AVI_DIVX 0x00200000
110 #define FLAG_MIME_AVI_AVI 0x00400000
111 #define FLAG_MIME_FLAC_FLAC 0x00800000
112 #define FLAG_NO_RESIZE 0x01000000
113 #define FLAG_MS_PFS 0x02000000 // Microsoft PlaysForSure client
114 #define FLAG_SAMSUNG 0x04000000
115 #define FLAG_AUDIO_ONLY 0x08000000
117 #define FLAG_FREE_OBJECT_ID 0x00000001
119 /* New_upnphttp() */
120 struct upnphttp *
121 New_upnphttp(int);
123 /* CloseSocket_upnphttp() */
124 void
125 CloseSocket_upnphttp(struct upnphttp *);
127 /* Delete_upnphttp() */
128 void
129 Delete_upnphttp(struct upnphttp *);
131 /* Process_upnphttp() */
132 void
133 Process_upnphttp(struct upnphttp *);
135 /* BuildHeader_upnphttp()
136 * build the header for the HTTP Response
137 * also allocate the buffer for body data */
138 void
139 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
140 const char * respmsg,
141 int bodylen);
143 /* BuildResp_upnphttp()
144 * fill the res_buf buffer with the complete
145 * HTTP 200 OK response from the body passed as argument */
146 void
147 BuildResp_upnphttp(struct upnphttp *, const char *, int);
149 /* BuildResp2_upnphttp()
150 * same but with given response code/message */
151 void
152 BuildResp2_upnphttp(struct upnphttp * h, int respcode,
153 const char * respmsg,
154 const char * body, int bodylen);
156 /* Error messages */
157 void
158 Send500(struct upnphttp *);
159 void
160 Send501(struct upnphttp *);
162 /* SendResp_upnphttp() */
163 void
164 SendResp_upnphttp(struct upnphttp *);
167 SearchClientCache(struct in_addr addr, int quiet);
169 void
170 SendResp_icon(struct upnphttp *, char * url);
171 void
172 SendResp_albumArt(struct upnphttp *, char * url);
173 void
174 SendResp_caption(struct upnphttp *, char * url);
175 void
176 SendResp_resizedimg(struct upnphttp *, char * url);
177 void
178 SendResp_thumbnail(struct upnphttp *, char * url);
179 /* SendResp_dlnafile()
180 * send the actual file data for a UPnP-A/V or DLNA request. */
181 void
182 SendResp_dlnafile(struct upnphttp *, char * url);
183 #endif