UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
sock.hpp
Go to the documentation of this file.
1#ifndef COMPA_SOCK_HPP
2#define COMPA_SOCK_HPP
3/**************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * All rights reserved.
7 * Copyright (c) 2012 France Telecom All rights reserved.
8 * Copyright (C) 2021+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
9 * Redistribution only with this Copyright remark. Last modified: 2024-11-05
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither name of Intel Corporation nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
31 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 **************************************************************************/
36// Last compare with ./pupnp source file on 2023-09-13, ver 1.14.18
37//
38// Unused interface header file deleted. It's available until commit
39// a01e0186bc0dcb8dc243f6d313ca8527535648fd:compa/inc/compa/sock.hpp
46#include <UPnPsdk/port_sock.hpp> /* for SOCKET, netinet/in */
47#include <umock/unistd.hpp>
48
49#ifdef UPnPsdk_HAVE_OPENSSL
50#include <openssl/ssl.h>
51#endif
52
53/* The following are not defined under winsock.h */
57#ifndef SD_RECEIVE
58#define SD_RECEIVE 0x00
59#define SD_SEND 0x01
60#define SD_BOTH 0x02
61#endif
63
65struct SOCKINFO {
67 SOCKET socket;
69 sockaddr_storage foreign_sockaddr;
70#ifdef UPnPsdk_HAVE_OPENSSL
72 SSL* ssl;
73#else
75 void* ssl;
76#endif
77};
78
84// Don't export function symbol; only used library intern.
85inline int sock_close(
87 SOCKET sock) {
88 if (sock == INVALID_SOCKET)
89 return -1;
90 return umock::unistd_h.CLOSE_SOCKET_P(sock);
91}
92
102// Don't export function symbol; only used library intern.
103int sock_init(
105 SOCKINFO* info,
107 SOCKET sockfd);
108
118// Don't export function symbol; only used library intern.
121 SOCKINFO* info,
123 SOCKET sockfd,
125 struct sockaddr* foreign_sockaddr);
126
135// Don't export function symbol; only used library intern.
136#ifdef UPnPsdk_HAVE_OPENSSL
139 SOCKINFO* info);
140#endif
141
153// Don't export function symbol; only used library intern.
154int sock_destroy(
156 SOCKINFO* info,
158 int ShutdownMethod);
159
168// Don't export function symbol; only used library intern.
169int sock_read(
171 SOCKINFO* info,
173 char* buffer,
175 size_t bufsize,
177 int* timeoutSecs);
178
187// Don't export function symbol; only used library intern.
188int sock_write(
190 SOCKINFO* info,
192 const char* buffer,
194 size_t bufsize,
196 int* timeoutSecs);
197
202// Don't export function symbol; only used library intern.
204 /* [in] socket. */
205 SOCKET sock);
206
211// Don't export function symbol; only used library intern.
213 /* [in] socket. */
214 SOCKET sock);
215
216#endif /* COMPA_SOCK_HPP */
Specifications to be portable with sockets between different platforms.
SOCKET socket
Handle/descriptor to a socket.
Definition sock.hpp:67
int sock_make_blocking(SOCKET sock)
Make socket blocking.
Definition sock.cpp:557
int sock_ssl_connect(SOCKINFO *info)
Associates an SSL object with the socket and begins the client-side SSL/TLS handshake.
Definition sock.cpp:469
SSL * ssl
Information about an ssl connection only filled in incoming requests.
Definition sock.hpp:72
void * ssl
Alternative unused member if OpenSSL isn't compiled in.
Definition sock.hpp:75
int sock_init_with_ip(SOCKINFO *info, SOCKET sockfd, struct sockaddr *foreign_sockaddr)
Calls the sock_init function and assigns the passed in IP address and port to the IP address and port...
Definition sock.cpp:451
sockaddr_storage foreign_sockaddr
Socket address of the remote node only filled in incoming requests.
Definition sock.hpp:69
int sock_close(SOCKET sock)
Closes the socket if it is different from -1.
Definition sock.hpp:85
int sock_make_no_blocking(SOCKET sock)
Make socket non-blocking.
Definition sock.cpp:573
int sock_destroy(SOCKINFO *info, int ShutdownMethod)
Shutsdown the socket using the ShutdownMethod to indicate whether sends and receives on the socket wi...
Definition sock.cpp:489
int sock_read(SOCKINFO *info, char *buffer, size_t bufsize, int *timeoutSecs)
Reads data on socket in sockinfo.
Definition sock.cpp:525
int sock_write(SOCKINFO *info, const char *buffer, size_t bufsize, int *timeoutSecs)
Writes data on the socket in sockinfo.
Definition sock.cpp:541
int sock_init(SOCKINFO *info, SOCKET sockfd)
Assign the passed in socket descriptor to socket descriptor in the SOCKINFO structure.
Definition sock.cpp:440
Additional socket information for connections and ssl.
Definition sock.hpp:65