Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / minidlna / upnphttp.h
blob5a460bdf25cfc5dc2fcf86a446d0d21678faec5e
1 /* MiniDLNA project
3 * http://sourceforge.net/projects/minidlna/
5 * MiniDLNA media server
6 * Copyright (C) 2008-2012 Justin Maggard
8 * This file is part of MiniDLNA.
10 * MiniDLNA is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * MiniDLNA is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
22 * Portions of the code from the MiniUPnP project:
24 * Copyright (c) 2006-2007, Thomas Bernard
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions are met:
29 * * Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * * Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * * The name of the author may not be used to endorse or promote products
35 * derived from this software without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
41 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 * POSSIBILITY OF SUCH DAMAGE.
49 #ifndef __UPNPHTTP_H__
50 #define __UPNPHTTP_H__
52 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include "minidlnatypes.h"
56 #include "config.h"
58 /* server: HTTP header returned in all HTTP responses : */
59 #define MINIDLNA_SERVER_STRING OS_VERSION " DLNADOC/1.50 UPnP/1.0 " SERVER_NAME "/" MINIDLNA_VERSION
62 states :
63 0 - waiting for data to read
64 1 - waiting for HTTP Post Content.
65 ...
66 >= 100 - to be deleted
68 enum httpCommands {
69 EUnknown = 0,
70 EGet,
71 EPost,
72 EHead,
73 ESubscribe,
74 EUnSubscribe
77 struct upnphttp {
78 int socket;
79 struct in_addr clientaddr; /* client address */
80 int iface;
81 int state;
82 char HttpVer[16];
83 /* request */
84 char * req_buf;
85 int req_buflen;
86 int req_contentlen;
87 int req_contentoff; /* header length */
88 enum httpCommands req_command;
89 enum client_types req_client;
90 const char * req_soapAction;
91 int req_soapActionLen;
92 const char * req_Callback; /* For SUBSCRIBE */
93 int req_CallbackLen;
94 const char * req_NT;
95 int req_NTLen;
96 int req_Timeout;
97 const char * req_SID; /* For UNSUBSCRIBE */
98 int req_SIDLen;
99 off_t req_RangeStart;
100 off_t req_RangeEnd;
101 long int req_chunklen;
102 uint32_t reqflags;
103 /* response */
104 char * res_buf;
105 int res_buflen;
106 int res_buf_alloclen;
107 uint32_t respflags;
108 /*int res_contentlen;*/
109 /*int res_contentoff;*/ /* header length */
110 LIST_ENTRY(upnphttp) entries;
113 #define FLAG_TIMEOUT 0x00000001
114 #define FLAG_SID 0x00000002
115 #define FLAG_RANGE 0x00000004
116 #define FLAG_HOST 0x00000008
117 #define FLAG_LANGUAGE 0x00000010
119 #define FLAG_INVALID_REQ 0x00000040
120 #define FLAG_HTML 0x00000080
122 #define FLAG_CHUNKED 0x00000100
123 #define FLAG_TIMESEEK 0x00000200
124 #define FLAG_REALTIMEINFO 0x00000400
125 #define FLAG_PLAYSPEED 0x00000800
126 #define FLAG_XFERSTREAMING 0x00001000
127 #define FLAG_XFERINTERACTIVE 0x00002000
128 #define FLAG_XFERBACKGROUND 0x00004000
129 #define FLAG_CAPTION 0x00008000
131 #define FLAG_DLNA 0x00100000
132 #define FLAG_MIME_AVI_DIVX 0x00200000
133 #define FLAG_MIME_AVI_AVI 0x00400000
134 #define FLAG_MIME_FLAC_FLAC 0x00800000
135 #define FLAG_MIME_WAV_WAV 0x01000000
136 #define FLAG_NO_RESIZE 0x02000000
137 #define FLAG_MS_PFS 0x04000000 // Microsoft PlaysForSure client
138 #define FLAG_SAMSUNG 0x08000000
139 #define FLAG_SAMSUNG_TV 0x10000000
140 #define FLAG_AUDIO_ONLY 0x20000000
142 #define FLAG_FREE_OBJECT_ID 0x00000001
143 #define FLAG_ROOT_CONTAINER 0x00000002
145 /* New_upnphttp() */
146 struct upnphttp *
147 New_upnphttp(int);
149 /* CloseSocket_upnphttp() */
150 void
151 CloseSocket_upnphttp(struct upnphttp *);
153 /* Delete_upnphttp() */
154 void
155 Delete_upnphttp(struct upnphttp *);
157 /* Process_upnphttp() */
158 void
159 Process_upnphttp(struct upnphttp *);
161 /* BuildHeader_upnphttp()
162 * build the header for the HTTP Response
163 * also allocate the buffer for body data */
164 void
165 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
166 const char * respmsg,
167 int bodylen);
169 /* BuildResp_upnphttp()
170 * fill the res_buf buffer with the complete
171 * HTTP 200 OK response from the body passed as argument */
172 void
173 BuildResp_upnphttp(struct upnphttp *, const char *, int);
175 /* BuildResp2_upnphttp()
176 * same but with given response code/message */
177 void
178 BuildResp2_upnphttp(struct upnphttp * h, int respcode,
179 const char * respmsg,
180 const char * body, int bodylen);
182 /* Error messages */
183 void
184 Send500(struct upnphttp *);
185 void
186 Send501(struct upnphttp *);
188 /* SendResp_upnphttp() */
189 void
190 SendResp_upnphttp(struct upnphttp *);
193 SearchClientCache(struct in_addr addr, int quiet);
195 void
196 SendResp_icon(struct upnphttp *, char * url);
197 void
198 SendResp_albumArt(struct upnphttp *, char * url);
199 void
200 SendResp_caption(struct upnphttp *, char * url);
201 void
202 SendResp_resizedimg(struct upnphttp *, char * url);
203 void
204 SendResp_thumbnail(struct upnphttp *, char * url);
205 /* SendResp_dlnafile()
206 * send the actual file data for a UPnP-A/V or DLNA request. */
207 void
208 SendResp_dlnafile(struct upnphttp *, char * url);
209 #endif