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"
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
63 0 - waiting for data to read
64 1 - waiting for HTTP Post Content.
66 >= 100 - to be deleted
79 struct in_addr clientaddr
; /* client address */
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 */
97 const char * req_SID
; /* For UNSUBSCRIBE */
101 long int req_chunklen
;
106 int res_buf_alloclen
;
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
149 /* CloseSocket_upnphttp() */
151 CloseSocket_upnphttp(struct upnphttp
*);
153 /* Delete_upnphttp() */
155 Delete_upnphttp(struct upnphttp
*);
157 /* Process_upnphttp() */
159 Process_upnphttp(struct upnphttp
*);
161 /* BuildHeader_upnphttp()
162 * build the header for the HTTP Response
163 * also allocate the buffer for body data */
165 BuildHeader_upnphttp(struct upnphttp
* h
, int respcode
,
166 const char * respmsg
,
169 /* BuildResp_upnphttp()
170 * fill the res_buf buffer with the complete
171 * HTTP 200 OK response from the body passed as argument */
173 BuildResp_upnphttp(struct upnphttp
*, const char *, int);
175 /* BuildResp2_upnphttp()
176 * same but with given response code/message */
178 BuildResp2_upnphttp(struct upnphttp
* h
, int respcode
,
179 const char * respmsg
,
180 const char * body
, int bodylen
);
184 Send500(struct upnphttp
*);
186 Send501(struct upnphttp
*);
188 /* SendResp_upnphttp() */
190 SendResp_upnphttp(struct upnphttp
*);
193 SearchClientCache(struct in_addr addr
, int quiet
);
196 SendResp_icon(struct upnphttp
*, char * url
);
198 SendResp_albumArt(struct upnphttp
*, char * url
);
200 SendResp_caption(struct upnphttp
*, char * url
);
202 SendResp_resizedimg(struct upnphttp
*, char * url
);
204 SendResp_thumbnail(struct upnphttp
*, char * url
);
205 /* SendResp_dlnafile()
206 * send the actual file data for a UPnP-A/V or DLNA request. */
208 SendResp_dlnafile(struct upnphttp
*, char * url
);