UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
ssdp_common.hpp
Go to the documentation of this file.
1#if defined(COMPA_HAVE_CTRLPT_SSDP) || defined(COMPA_HAVE_DEVICE_SSDP)
2
3#ifndef COMPA_SSDP_COMMON_HPP
4#define COMPA_SSDP_COMMON_HPP
5/**************************************************************************
6 *
7 * Copyright (c) 2000-2003 Intel Corporation
8 * All rights reserved.
9 * Copyright (C) 2011-2012 France Telecom All rights reserved.
10 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
11 * Redistribution only with this Copyright remark. Last modified: 2025-06-12
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 *
16 * - Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * - Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * - Neither name of Intel Corporation nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
33 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 **************************************************************************/
38// Last compare with ./pupnp source file on 2023-08-30, ver 1.14.18
45#include <miniserver.hpp>
46
47
49inline constexpr size_t ERROR_BUFFER_LEN{256};
50
54#define BUFSIZE (size_t)2500
56#define SSDP_IP "239.255.255.250"
58#define SSDP_IPV6_LINKLOCAL "FF02::C"
60#define SSDP_IPV6_SITELOCAL "FF05::C"
62#define SSDP_PORT 1900
64#define NUM_TRY 3
66#define THREAD_LIMIT 50
68#define COMMAND_LEN 300
70
73#define NO_ERROR_FOUND 0
75#define E_REQUEST_INVALID -3
77#define E_RES_EXPIRED -4
79#define E_MEM_ALLOC -5
81#define E_HTTP_SYNTEX -6
83#define E_SOCKET -7
85
87#define RQST_TIMEOUT 20
88
98
120
122typedef void (*SsdpFunPtr)(SsdpEvent*);
123
128 int Mx;
129 void* Cookie;
130 char* Data;
131 struct sockaddr_storage DestAddr;
133};
134
145
151
155 sockaddr_storage dest_addr;
156};
157
158/* globals */
159
162inline SOCKET gSsdpReqSocket4;
163#ifdef UPNP_ENABLE_IPV6
166inline SOCKET gSsdpReqSocket6;
167#endif /* UPNP_ENABLE_IPV6 */
168
170typedef int (*ParserFun)(char*, SsdpEvent*);
171
172
186 char* cmd,
188 SsdpEvent* Evt);
189
199 char* cmd);
200
211 char* cmd,
213 SsdpEvent* Evt);
214
224 SOCKET socket);
225
241
243
244#endif /* COMPA_SSDP_COMMON_HPP */
245#endif // defined(COMPA_HAVE_CTRLPT_SSDP) || defined(COMPA_HAVE_DEVICE_SSDP)
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice(),UpnpRegisterRootDevice2(),...
Definition API.hpp:425
#define LINE_SIZE
Definition API.hpp:45
Structure of an HTTP parser object.
int ssdp_request_type(char *cmd, SsdpEvent *Evt)
Starts filling the SSDP event structure based upon the request received.
int get_ssdp_sockets(MiniServerSockArray *out)
Creates the IPv4 and IPv6 ssdp sockets required by the control point and device operation.
SsdpSearchType ssdp_request_type1(char *cmd)
This function figures out the type of the SSDP search in the request.
int unique_service_name(char *cmd, SsdpEvent *Evt)
Fills the fields of the event structure like DeviceType, Device UDN and Service Type.
int readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Manage "Step 0: Addressing" of the UPnP+™ specification.
Provides sockets for all network communications.
struct sockaddr * DestAddr
Part of SSDP Event.
struct sockaddr_storage DestAddr
part of thread data
sockaddr_storage dest_addr
destination socket address
struct sockaddr_storage dest_addr
part of search reply
int MaxAge
Part of SSDP Event.
char UDN[LINE_SIZE]
Part of SSDP Event.
int Mx
Part of SSDP Event.
char Ext[LINE_SIZE]
Part of SSDP Event.
char HostAddr[LINE_SIZE]
Part of SSDP Event.
constexpr size_t ERROR_BUFFER_LEN
Size of the errorBuffer variable, passed to the strerror_r() function.
UpnpDevice_Handle handle
part of search reply
char ServiceType[LINE_SIZE]
Part of SSDP Event.
int Mx
part of thread data
int timeoutEventId
timeout event id
int ErrCode
Part of SSDP Event.
char DeviceType[LINE_SIZE]
Part of SSDP Event.
int(* ParserFun)(char *, SsdpEvent *)
Maybe a callback function?
int MaxAge
part of search reply
http_parser_t parser
parser
SOCKET gSsdpReqSocket6
If control point API is compiled in, this is the global IPv6 socket for it.
void(* SsdpFunPtr)(SsdpEvent *)
Maybe a callback function?
void * Cookie
part of thread data
char Os[LINE_SIZE]
Part of SSDP Event.
enum SsdpSearchType RequestType
Part of SSDP Event.
char Date[LINE_SIZE]
Part of SSDP Event.
char * Data
part of thread data
SsdpEvent event
part of search reply
SOCKET gSsdpReqSocket4
If control point API is compiled in, this is the global IPv4 socket for it.
void * Cookie
Part of SSDP Event.
char Location[LINE_SIZE]
Part of SSDP Event.
SsdpSearchType
Enumeration to define all different types of ssdp searches.
@ SSDP_SERROR
Unknown search command.
@ SSDP_DEVICEUDN
Part of SType.
@ SSDP_DEVICETYPE
Part of SType.
@ SSDP_ROOTDEVICE
Part of SType.
@ SSDP_SERVICE
Part of SType.
@ SSDP_ALL
Part of SType.
Structure to store the SSDP information.
SSDP search exp argument.
SSDP thread data.
thread data.
SSDP search reply.