1 /* MiniDLNA media server
2 * Copyright (C) 2013-2017 NETGEAR
4 * This file is part of MiniDLNA.
6 * MiniDLNA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * MiniDLNA is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
24 #include "getifaddr.h"
27 struct client_type_s client_types
[] =
37 FLAG_MIME_AVI_AVI
| FLAG_MS_PFS
,
44 FLAG_DLNA
| FLAG_MIME_AVI_DIVX
,
51 FLAG_DLNA
| FLAG_MIME_AVI_DIVX
,
64 /* User-Agent: DLNADOC/1.50 SEC_HHP_[PC]LPC001/1.0 MS-DeviceCaps/1024 */
65 /* This is AllShare running on a PC. We don't want to respond with Samsung
66 * capabilities, or Windows (and AllShare) might get grumpy. */
75 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
| FLAG_CAPTION_RES
| FLAG_SKIP_DLNA_PN
,
81 /* Samsung Series [CDE] BDPs and TVs must be separated, or some of our
82 * advertised extra features trigger a folder browsing bug on BDPs. */
83 /* User-Agent: DLNADOC/1.50 SEC_HHP_BD-D5100/1.0 */
84 { ESamsungSeriesCDEBDP
,
85 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
,
86 "Samsung Series [CDEF] BDP",
91 /* Samsung Series [Q] TVs work with milliseconds for bookmarks */
92 /* User-Agent: DLNADOC/1.50 SEC_HHP_[TV] Samsung Q7 Series (49)/1.0 */
94 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
| FLAG_SAMSUNG_DCM10
| FLAG_CAPTION_RES
| FLAG_CONVERT_MS
,
96 "SEC_HHP_[TV] Samsung Q",
100 /* Samsung Series [QN] TVs work with milliseconds for bookmarks */
101 /* User-Agent: DLNADOC/1.50 SEC_HHP_Samsung QN90AA 50 TV/1.0 */
103 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
| FLAG_SAMSUNG_DCM10
| FLAG_CAPTION_RES
| FLAG_CONVERT_MS
,
104 "Samsung Series [QN]",
105 "SEC_HHP_Samsung QN",
109 /* User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UE40D7000/1.0 */
110 /* User-Agent: DLNADOC/1.50 SEC_HHP_ Family TV/1.0 */
111 /* USER-AGENT: DLNADOC/1.50 SEC_HHP_[TV] UE65JU7000/1.0 UPnP/1.0 */
113 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
| FLAG_SAMSUNG_DCM10
| FLAG_CAPTION_RES
,
114 "Samsung Series [CDEFJ]",
120 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
,
122 "SamsungWiselinkPro",
127 FLAG_SAMSUNG
| FLAG_DLNA
| FLAG_NO_RESIZE
,
133 /* User-Agent: Panasonic MIL DLNA CP UPnP/1.0 DLNADOC/1.50 */
135 FLAG_DLNA
| FLAG_FORCE_SORT
,
141 /* User-Agent: IPI/1.0 UPnP/1.0 DLNADOC/1.50 */
142 { ENetFrontLivingConnect
,
143 FLAG_DLNA
| FLAG_FORCE_SORT
| FLAG_CAPTION_RES
,
144 "NetFront Living Connect",
170 /* X-AV-Client-Info: av=5.0; cn="Sony Corporation"; mn="Blu-ray Disc Player"; mv="2.0" */
171 /* X-AV-Client-Info: av=5.0; cn="Sony Corporation"; mn="BLU-RAY HOME THEATRE SYSTEM"; mv="2.0"; */
172 /* Sony SMP-100 needs the same treatment as their BDP-S370 */
173 /* X-AV-Client-Info: av=5.0; cn="Sony Corporation"; mn="Media Player"; mv="2.0" */
181 /* USER-AGENT: Linux/2.6.35 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.6.0 */
183 FLAG_DLNA
| FLAG_CAPTION_RES
| FLAG_MIME_FLAC_FLAC
,
185 "LGE_DLNA_SDK/1.6.0",
189 /* User-Agent: Linux/2.6.31-1.0 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.5.0 */
191 FLAG_DLNA
| FLAG_CAPTION_RES
| FLAG_MIME_FLAC_FLAC
,
197 /* X-AV-Client-Info: av=5.0; cn="Sony Corporation"; mn="BRAVIA KDL-40EX503"; mv="1.7"; */
205 /* X-AV-Client-Info: av=5.0; hn=""; cn="Sony Corporation"; mn="INTERNET TV NSX-40GT 1"; mv="0.1"; */
214 FLAG_MS_PFS
| FLAG_RESIZE_THUMBS
,
230 "UPnP/1.0 DLNADOC/1.50 Intel_SDK_for_UPnP_devices/1.2",
242 FLAG_MS_PFS
| FLAG_AUDIO_ONLY
| FLAG_MIME_WAV_WAV
| FLAG_FORCE_SORT
,
249 FLAG_DLNA
| FLAG_MIME_WAV_WAV
,
258 "Microsoft-IPTV-Client",
270 FLAG_DLNA
| FLAG_MIME_AVI_AVI
| FLAG_CAPTION_RES
,
271 "Asus OPlay Mini/Mini+",
291 FLAG_DLNA
| FLAG_MIME_AVI_AVI
| FLAG_CAPTION_RES
,
298 FLAG_DLNA
| FLAG_MIME_AVI_AVI
,
312 FLAG_DLNA
| FLAG_MIME_AVI_AVI
,
328 struct client_cache_s clients
[CLIENT_CACHE_SLOTS
];
330 struct client_cache_s
*
331 SearchClientCache(struct in_addr addr
, int quiet
)
335 for (i
= 0; i
< CLIENT_CACHE_SLOTS
; i
++)
337 if (clients
[i
].addr
.s_addr
== addr
.s_addr
)
339 /* Invalidate this client cache if it's older than 1 hour */
340 if ((time(NULL
) - clients
[i
].age
) > 3600)
342 unsigned char mac
[6];
343 if (get_remote_mac(addr
, mac
) == 0 &&
344 memcmp(mac
, clients
[i
].mac
, 6) == 0)
346 /* Same MAC as last time when we were able to identify the client,
347 * so extend the timeout by another hour. */
348 clients
[i
].age
= time(NULL
);
352 memset(&clients
[i
], 0, sizeof(struct client_cache_s
));
357 DPRINTF(E_DEBUG
, L_HTTP
, "Client found in cache. [%s/entry %d]\n",
358 clients
[i
].type
->name
, i
);
366 struct client_cache_s
*
367 AddClientCache(struct in_addr addr
, int type
)
371 for (i
= 0; i
< CLIENT_CACHE_SLOTS
; i
++)
373 if (clients
[i
].addr
.s_addr
)
375 get_remote_mac(addr
, clients
[i
].mac
);
376 clients
[i
].addr
= addr
;
377 clients
[i
].type
= &client_types
[type
];
378 clients
[i
].age
= time(NULL
);
379 DPRINTF(E_DEBUG
, L_HTTP
, "Added client [%s/%s/%02X:%02X:%02X:%02X:%02X:%02X] to cache slot %d.\n",
380 client_types
[type
].name
, inet_ntoa(clients
[i
].addr
),
381 clients
[i
].mac
[0], clients
[i
].mac
[1], clients
[i
].mac
[2],
382 clients
[i
].mac
[3], clients
[i
].mac
[4], clients
[i
].mac
[5], i
);