minidlna support now Samsung TV C550/C650 (thx amir909)
[tomato.git] / release / src / router / minidlna / upnphttp.h
blob95711cb30904d9c7e11a17c03532ac76804b3ce7
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
118 #define FLAG_ROOT_CONTAINER 0x00000002
120 /* New_upnphttp() */
121 struct upnphttp *
122 New_upnphttp(int);
124 /* CloseSocket_upnphttp() */
125 void
126 CloseSocket_upnphttp(struct upnphttp *);
128 /* Delete_upnphttp() */
129 void
130 Delete_upnphttp(struct upnphttp *);
132 /* Process_upnphttp() */
133 void
134 Process_upnphttp(struct upnphttp *);
136 /* BuildHeader_upnphttp()
137 * build the header for the HTTP Response
138 * also allocate the buffer for body data */
139 void
140 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
141 const char * respmsg,
142 int bodylen);
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);
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);
157 /* Error messages */
158 void
159 Send500(struct upnphttp *);
160 void
161 Send501(struct upnphttp *);
163 /* SendResp_upnphttp() */
164 void
165 SendResp_upnphttp(struct upnphttp *);
168 SearchClientCache(struct in_addr addr, int quiet);
170 void
171 SendResp_icon(struct upnphttp *, char * url);
172 void
173 SendResp_albumArt(struct upnphttp *, char * url);
174 void
175 SendResp_caption(struct upnphttp *, char * url);
176 void
177 SendResp_resizedimg(struct upnphttp *, char * url);
178 void
179 SendResp_thumbnail(struct upnphttp *, char * url);
180 /* SendResp_dlnafile()
181 * send the actual file data for a UPnP-A/V or DLNA request. */
182 void
183 SendResp_dlnafile(struct upnphttp *, char * url);
184 #endif