summaryrefslogtreecommitdiffstats
path: root/gl/sys_socket.in.h
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-02-11 06:20:24 (GMT)
committerAndreas Baumann <mail@andreasbaumann.cc>2023-02-11 06:20:24 (GMT)
commitf867d7b44080fa9716deeff4476275f9a489879f (patch)
treebc964662fc3300dc626fb6d833d8ed5c8f46eca7 /gl/sys_socket.in.h
parent9734c439cba0a02b087e50789e94ec9b07754608 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-f867d7b44080fa9716deeff4476275f9a489879f.tar.gz
Merge branch 'master' into curlfixes
Diffstat (limited to 'gl/sys_socket.in.h')
-rw-r--r--gl/sys_socket.in.h138
1 files changed, 91 insertions, 47 deletions
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index b4cf0c3..6705593 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,20 +1,20 @@
1/* Provide a sys/socket header file for systems lacking it (read: MinGW) 1/* Provide a sys/socket header file for systems lacking it (read: MinGW)
2 and for systems where it is incomplete. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2023 Free Software Foundation, Inc.
4 Written by Simon Josefsson. 4 Written by Simon Josefsson.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* This file is supposed to be used on platforms that lack <sys/socket.h>, 19/* This file is supposed to be used on platforms that lack <sys/socket.h>,
20 on platforms where <sys/socket.h> cannot be included standalone, and on 20 on platforms where <sys/socket.h> cannot be included standalone, and on
@@ -63,6 +63,9 @@
63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H 63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
64#define _@GUARD_PREFIX@_SYS_SOCKET_H 64#define _@GUARD_PREFIX@_SYS_SOCKET_H
65 65
66#ifndef _GL_INLINE_HEADER_BEGIN
67 #error "Please include config.h first."
68#endif
66_GL_INLINE_HEADER_BEGIN 69_GL_INLINE_HEADER_BEGIN
67#ifndef _GL_SYS_SOCKET_INLINE 70#ifndef _GL_SYS_SOCKET_INLINE
68# define _GL_SYS_SOCKET_INLINE _GL_INLINE 71# define _GL_SYS_SOCKET_INLINE _GL_INLINE
@@ -76,7 +79,12 @@ _GL_INLINE_HEADER_BEGIN
76 79
77#if !@HAVE_SA_FAMILY_T@ 80#if !@HAVE_SA_FAMILY_T@
78# if !GNULIB_defined_sa_family_t 81# if !GNULIB_defined_sa_family_t
82/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
83# if !defined __KLIBC__ || defined TCPV40HDRS
79typedef unsigned short sa_family_t; 84typedef unsigned short sa_family_t;
85# else
86typedef unsigned char sa_family_t;
87# endif
80# define GNULIB_defined_sa_family_t 1 88# define GNULIB_defined_sa_family_t 1
81# endif 89# endif
82#endif 90#endif
@@ -89,7 +97,6 @@ typedef unsigned short sa_family_t;
89# endif 97# endif
90# endif 98# endif
91#else 99#else
92# include <stdalign.h>
93/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 100/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
94 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ 101 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
95# define __ss_aligntype unsigned long int 102# define __ss_aligntype unsigned long int
@@ -133,6 +140,15 @@ struct sockaddr_storage
133# define SHUT_RDWR 2 140# define SHUT_RDWR 2
134# endif 141# endif
135 142
143# ifdef __VMS /* OpenVMS */
144# ifndef CMSG_SPACE
145# define CMSG_SPACE(length) _CMSG_SPACE(length)
146# endif
147# ifndef CMSG_LEN
148# define CMSG_LEN(length) _CMSG_LEN(length)
149# endif
150# endif
151
136#else 152#else
137 153
138# ifdef __CYGWIN__ 154# ifdef __CYGWIN__
@@ -152,7 +168,7 @@ struct sockaddr_storage
152 code may not run on older Windows releases then. My Windows 2000 168 code may not run on older Windows releases then. My Windows 2000
153 box was not able to run the code, for example. The situation is 169 box was not able to run the code, for example. The situation is
154 slightly confusing because 170 slightly confusing because
155 <http://msdn.microsoft.com/en-us/library/ms738520> 171 <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
156 suggests that getaddrinfo should be available on all Windows 172 suggests that getaddrinfo should be available on all Windows
157 releases. */ 173 releases. */
158 174
@@ -178,12 +194,7 @@ struct sockaddr_storage
178/* Include headers needed by the emulation code. */ 194/* Include headers needed by the emulation code. */
179# include <sys/types.h> 195# include <sys/types.h>
180# include <io.h> 196# include <io.h>
181 197/* If these headers don't define socklen_t, <config.h> does. */
182# if !GNULIB_defined_socklen_t
183typedef int socklen_t;
184# define GNULIB_defined_socklen_t 1
185# endif
186
187# endif 198# endif
188 199
189/* Rudimentary 'struct msghdr'; this works as long as you don't try to 200/* Rudimentary 'struct msghdr'; this works as long as you don't try to
@@ -198,6 +209,15 @@ struct msghdr {
198 209
199#endif 210#endif
200 211
212/* Ensure SO_REUSEPORT is defined. */
213/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
214 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
215 and https://lwn.net/Articles/542629/
216 */
217#ifndef SO_REUSEPORT
218# define SO_REUSEPORT SO_REUSEADDR
219#endif
220
201/* Fix some definitions from <winsock2.h>. */ 221/* Fix some definitions from <winsock2.h>. */
202 222
203#if @HAVE_WINSOCK2_H@ 223#if @HAVE_WINSOCK2_H@
@@ -235,7 +255,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
236# undef close 256# undef close
237# define close close_used_without_including_unistd_h 257# define close close_used_without_including_unistd_h
238# else 258# elif !defined __clang__
239 _GL_WARN_ON_USE (close, 259 _GL_WARN_ON_USE (close,
240 "close() used without including <unistd.h>"); 260 "close() used without including <unistd.h>");
241# endif 261# endif
@@ -320,14 +340,20 @@ _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
320# define accept rpl_accept 340# define accept rpl_accept
321# endif 341# endif
322_GL_FUNCDECL_RPL (accept, int, 342_GL_FUNCDECL_RPL (accept, int,
323 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 343 (int fd,
344 struct sockaddr *restrict addr,
345 socklen_t *restrict addrlen));
324_GL_CXXALIAS_RPL (accept, int, 346_GL_CXXALIAS_RPL (accept, int,
325 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 347 (int fd,
348 struct sockaddr *restrict addr,
349 socklen_t *restrict addrlen));
326# else 350# else
327/* Need to cast, because on Solaris 10 systems, the third parameter is 351/* Need to cast, because on Solaris 10 systems, the third parameter is
328 void *addrlen. */ 352 void *addrlen. */
329_GL_CXXALIAS_SYS_CAST (accept, int, 353_GL_CXXALIAS_SYS_CAST (accept, int,
330 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 354 (int fd,
355 struct sockaddr *restrict addr,
356 socklen_t *restrict addrlen));
331# endif 357# endif
332_GL_CXXALIASWARN (accept); 358_GL_CXXALIASWARN (accept);
333#elif @HAVE_WINSOCK2_H@ 359#elif @HAVE_WINSOCK2_H@
@@ -378,15 +404,18 @@ _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
378# define getpeername rpl_getpeername 404# define getpeername rpl_getpeername
379# endif 405# endif
380_GL_FUNCDECL_RPL (getpeername, int, 406_GL_FUNCDECL_RPL (getpeername, int,
381 (int fd, struct sockaddr *addr, socklen_t *addrlen) 407 (int fd, struct sockaddr *restrict addr,
408 socklen_t *restrict addrlen)
382 _GL_ARG_NONNULL ((2, 3))); 409 _GL_ARG_NONNULL ((2, 3)));
383_GL_CXXALIAS_RPL (getpeername, int, 410_GL_CXXALIAS_RPL (getpeername, int,
384 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 411 (int fd, struct sockaddr *restrict addr,
412 socklen_t *restrict addrlen));
385# else 413# else
386/* Need to cast, because on Solaris 10 systems, the third parameter is 414/* Need to cast, because on Solaris 10 systems, the third parameter is
387 void *addrlen. */ 415 void *addrlen. */
388_GL_CXXALIAS_SYS_CAST (getpeername, int, 416_GL_CXXALIAS_SYS_CAST (getpeername, int,
389 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 417 (int fd, struct sockaddr *restrict addr,
418 socklen_t *restrict addrlen));
390# endif 419# endif
391_GL_CXXALIASWARN (getpeername); 420_GL_CXXALIASWARN (getpeername);
392#elif @HAVE_WINSOCK2_H@ 421#elif @HAVE_WINSOCK2_H@
@@ -407,15 +436,18 @@ _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
407# define getsockname rpl_getsockname 436# define getsockname rpl_getsockname
408# endif 437# endif
409_GL_FUNCDECL_RPL (getsockname, int, 438_GL_FUNCDECL_RPL (getsockname, int,
410 (int fd, struct sockaddr *addr, socklen_t *addrlen) 439 (int fd, struct sockaddr *restrict addr,
440 socklen_t *restrict addrlen)
411 _GL_ARG_NONNULL ((2, 3))); 441 _GL_ARG_NONNULL ((2, 3)));
412_GL_CXXALIAS_RPL (getsockname, int, 442_GL_CXXALIAS_RPL (getsockname, int,
413 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 443 (int fd, struct sockaddr *restrict addr,
444 socklen_t *restrict addrlen));
414# else 445# else
415/* Need to cast, because on Solaris 10 systems, the third parameter is 446/* Need to cast, because on Solaris 10 systems, the third parameter is
416 void *addrlen. */ 447 void *addrlen. */
417_GL_CXXALIAS_SYS_CAST (getsockname, int, 448_GL_CXXALIAS_SYS_CAST (getsockname, int,
418 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 449 (int fd, struct sockaddr *restrict addr,
450 socklen_t *restrict addrlen));
419# endif 451# endif
420_GL_CXXALIASWARN (getsockname); 452_GL_CXXALIASWARN (getsockname);
421#elif @HAVE_WINSOCK2_H@ 453#elif @HAVE_WINSOCK2_H@
@@ -435,16 +467,19 @@ _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
435# undef getsockopt 467# undef getsockopt
436# define getsockopt rpl_getsockopt 468# define getsockopt rpl_getsockopt
437# endif 469# endif
438_GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname, 470_GL_FUNCDECL_RPL (getsockopt, int,
439 void *optval, socklen_t *optlen) 471 (int fd, int level, int optname,
440 _GL_ARG_NONNULL ((4, 5))); 472 void *restrict optval, socklen_t *restrict optlen)
441_GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname, 473 _GL_ARG_NONNULL ((4, 5)));
442 void *optval, socklen_t *optlen)); 474_GL_CXXALIAS_RPL (getsockopt, int,
475 (int fd, int level, int optname,
476 void *restrict optval, socklen_t *restrict optlen));
443# else 477# else
444/* Need to cast, because on Solaris 10 systems, the fifth parameter is 478/* Need to cast, because on Solaris 10 systems, the fifth parameter is
445 void *optlen. */ 479 void *optlen. */
446_GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname, 480_GL_CXXALIAS_SYS_CAST (getsockopt, int,
447 void *optval, socklen_t *optlen)); 481 (int fd, int level, int optname,
482 void *restrict optval, socklen_t *restrict optlen));
448# endif 483# endif
449_GL_CXXALIASWARN (getsockopt); 484_GL_CXXALIASWARN (getsockopt);
450#elif @HAVE_WINSOCK2_H@ 485#elif @HAVE_WINSOCK2_H@
@@ -491,7 +526,10 @@ _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
491 _GL_ARG_NONNULL ((2))); 526 _GL_ARG_NONNULL ((2)));
492_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 527_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
493# else 528# else
494_GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 529/* Need to cast, because on HP-UX 11.31 the return type may be
530 int,
531 depending on compiler options. */
532_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
495# endif 533# endif
496_GL_CXXALIASWARN (recv); 534_GL_CXXALIASWARN (recv);
497#elif @HAVE_WINSOCK2_H@ 535#elif @HAVE_WINSOCK2_H@
@@ -517,8 +555,11 @@ _GL_FUNCDECL_RPL (send, ssize_t,
517_GL_CXXALIAS_RPL (send, ssize_t, 555_GL_CXXALIAS_RPL (send, ssize_t,
518 (int fd, const void *buf, size_t len, int flags)); 556 (int fd, const void *buf, size_t len, int flags));
519# else 557# else
520_GL_CXXALIAS_SYS (send, ssize_t, 558/* Need to cast, because on HP-UX 11.31 the return type may be
521 (int fd, const void *buf, size_t len, int flags)); 559 int,
560 depending on compiler options. */
561_GL_CXXALIAS_SYS_CAST (send, ssize_t,
562 (int fd, const void *buf, size_t len, int flags));
522# endif 563# endif
523_GL_CXXALIASWARN (send); 564_GL_CXXALIASWARN (send);
524#elif @HAVE_WINSOCK2_H@ 565#elif @HAVE_WINSOCK2_H@
@@ -539,18 +580,21 @@ _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
539# define recvfrom rpl_recvfrom 580# define recvfrom rpl_recvfrom
540# endif 581# endif
541_GL_FUNCDECL_RPL (recvfrom, ssize_t, 582_GL_FUNCDECL_RPL (recvfrom, ssize_t,
542 (int fd, void *buf, size_t len, int flags, 583 (int fd, void *restrict buf, size_t len, int flags,
543 struct sockaddr *from, socklen_t *fromlen) 584 struct sockaddr *restrict from,
585 socklen_t *restrict fromlen)
544 _GL_ARG_NONNULL ((2))); 586 _GL_ARG_NONNULL ((2)));
545_GL_CXXALIAS_RPL (recvfrom, ssize_t, 587_GL_CXXALIAS_RPL (recvfrom, ssize_t,
546 (int fd, void *buf, size_t len, int flags, 588 (int fd, void *restrict buf, size_t len, int flags,
547 struct sockaddr *from, socklen_t *fromlen)); 589 struct sockaddr *restrict from,
590 socklen_t *restrict fromlen));
548# else 591# else
549/* Need to cast, because on Solaris 10 systems, the sixth parameter is 592/* Need to cast, because on Solaris 10 systems, the sixth parameter is
550 void *fromlen. */ 593 void *fromlen. */
551_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, 594_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
552 (int fd, void *buf, size_t len, int flags, 595 (int fd, void *restrict buf, size_t len, int flags,
553 struct sockaddr *from, socklen_t *fromlen)); 596 struct sockaddr *restrict from,
597 socklen_t *restrict fromlen));
554# endif 598# endif
555_GL_CXXALIASWARN (recvfrom); 599_GL_CXXALIASWARN (recvfrom);
556#elif @HAVE_WINSOCK2_H@ 600#elif @HAVE_WINSOCK2_H@
@@ -654,7 +698,7 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
654 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) 698 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
655 and O_TEXT, O_BINARY (defined in "binary-io.h"). 699 and O_TEXT, O_BINARY (defined in "binary-io.h").
656 See also the Linux man page at 700 See also the Linux man page at
657 <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */ 701 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
658# if @HAVE_ACCEPT4@ 702# if @HAVE_ACCEPT4@
659# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 703# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
660# define accept4 rpl_accept4 704# define accept4 rpl_accept4