Version 1.8.0.2 - CVE-2024-54661: Arbitrary file overwrite in readline.sh
[socat.git] / xio-socket.h
blob2064ed39572ddc2d38e5584de6d28f7f3f2bb7f4
1 /* source: xio-socket.h */
2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __xio_socket_h_included
6 #define __xio_socket_h_included 1
8 /* SO_PROTOTYPE is defined on Solaris, HP-UX
9 SO_PROTOCOL in Linux, is the better name, but came much later, now
10 standardised in POSIX 2024
11 illumos defines both, with SO_PROTOCOL as an alias of SO_PROTOTYPE */
12 #ifdef SO_PROTOCOL
13 # ifndef SO_PROTOTYPE
14 # define SO_PROTOTYPE SO_PROTOCOL
15 # endif
16 #else
17 # ifdef SO_PROTOTYPE
18 # define SO_PROTOCOL SO_PROTOTYPE
19 # else
20 /* Even when SO_PROTOCOL is not available for setsockopt() Socat uses it
21 internally as option for 3rd arg of socket() e.a. */
22 # define SO_PROTOCOL 0x9999
23 # define SO_PROTOTYPE SO_PROTOCOL
24 # endif
25 #endif
27 extern const struct addrdesc xioaddr_socket_connect;
28 extern const struct addrdesc xioaddr_socket_listen;
29 extern const struct addrdesc xioaddr_socket_sendto;
30 extern const struct addrdesc xioaddr_socket_datagram;
31 extern const struct addrdesc xioaddr_socket_recvfrom;
32 extern const struct addrdesc xioaddr_socket_recv;
34 extern const struct optdesc opt_connect_timeout;
35 extern const struct optdesc opt_so_debug;
36 extern const struct optdesc opt_so_acceptconn;
37 extern const struct optdesc opt_so_broadcast;
38 extern const struct optdesc opt_so_reuseaddr;
39 extern const struct optdesc opt_so_keepalive;
40 extern const struct optdesc opt_so_linger;
41 extern const struct optdesc opt_so_linger;
42 extern const struct optdesc opt_so_oobinline;
43 extern const struct optdesc opt_so_sndbuf;
44 extern const struct optdesc opt_so_sndbuf_late;
45 extern const struct optdesc opt_so_rcvbuf;
46 extern const struct optdesc opt_so_rcvbuf_late;
47 extern const struct optdesc opt_so_error;
48 extern const struct optdesc opt_so_type;
49 extern const struct optdesc opt_so_dontroute;
50 extern const struct optdesc opt_so_rcvlowat;
51 extern const struct optdesc opt_so_sndlowat;
52 extern const struct optdesc opt_so_rcvtimeo;
53 extern const struct optdesc opt_so_sndtimeo;
54 extern const struct optdesc opt_so_audit;
55 extern const struct optdesc opt_so_attach_filter;
56 extern const struct optdesc opt_so_detach_filter;
57 extern const struct optdesc opt_so_bindtodevice;
58 extern const struct optdesc opt_so_bsdcompat;
59 extern const struct optdesc opt_so_cksumrecv;
60 extern const struct optdesc opt_so_timestamp;
61 extern const struct optdesc opt_so_kernaccept;
62 extern const struct optdesc opt_so_no_check;
63 extern const struct optdesc opt_so_noreuseaddr;
64 extern const struct optdesc opt_so_passcred;
65 extern const struct optdesc opt_so_peercred;
66 extern const struct optdesc opt_so_priority;
67 extern const struct optdesc opt_so_reuseport;
68 extern const struct optdesc opt_so_security_authentication;
69 extern const struct optdesc opt_so_security_encryption_network;
70 extern const struct optdesc opt_so_security_encryption_transport;
71 extern const struct optdesc opt_so_use_ifbufs;
72 extern const struct optdesc opt_so_useloopback;
73 extern const struct optdesc opt_so_dgram_errind;
74 extern const struct optdesc opt_so_dontlinger;
75 extern const struct optdesc opt_so_prototype;
76 extern const struct optdesc opt_fiosetown;
77 extern const struct optdesc opt_siocspgrp;
78 extern const struct optdesc opt_bind;
79 extern const struct optdesc opt_protocol_family;
80 extern const struct optdesc opt_setsockopt;
81 extern const struct optdesc opt_setsockopt_int;
82 extern const struct optdesc opt_setsockopt_bin;
83 extern const struct optdesc opt_setsockopt_string;
84 extern const struct optdesc opt_setsockopt_listen;
85 extern const struct optdesc opt_null_eof;
88 extern
89 char *xiogetifname(int ind, char *val, int ins);
91 extern int retropt_socket_pf(struct opt *opts, int *pf);
92 extern int xiogetancillary(int fd, struct msghdr *msgh, int flags);
94 extern int xioopen_connect(struct single *fd,
95 union sockaddr_union *us, size_t uslen,
96 struct sockaddr *them, size_t themlen,
97 struct opt *opts,
98 int pf, int socktype, int protocol,
99 bool alt);
100 extern int _xioopen_connect(struct single *fd,
101 union sockaddr_union *us, size_t uslen,
102 struct sockaddr *them, size_t themlen,
103 struct opt *opts,
104 int pf, int socktype, int protocol,
105 bool alt, int level);
107 /* common to xioopen_udp_sendto, ..unix_sendto, ..rawip */
108 extern
109 int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
110 union sockaddr_union *us, socklen_t uslen,
111 struct opt *opts,
112 int xioflags, xiosingle_t *xfd, groups_t groups,
113 int pf, int socktype, int ipproto, bool alt);
114 extern
115 int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags,
116 struct sockaddr *us, socklen_t uslen,
117 struct opt *opts,
118 int pf, int socktype, int proto, int level);
119 extern
120 int _xioopen_dgram_recv(struct single *xfd, int xioflags,
121 struct sockaddr *us, socklen_t uslen,
122 struct opt *opts, int pf, int socktype, int proto,
123 int level);
124 extern int xiodopacketinfo(struct single *sfd, struct msghdr *msgh, bool withlog, bool withenv);
125 extern
126 int xiogetpacketsrc(int fd, struct msghdr *msgh, int flags);
127 extern
128 int xiocheckpeer(xiosingle_t *xfd,
129 union sockaddr_union *pa, union sockaddr_union *la);
130 extern
131 int xiosetsockaddrenv(const char *lr, union sockaddr_union *sau, socklen_t salen, int proto);
133 extern int xioparsenetwork(const char *rangename, int pf, struct xiorange *range, const int ai_flags[2]);
134 extern int xioparserange(const char *rangename, int pf, struct xiorange *range, const int ai_flags[2]);
136 extern int
137 xiosocket(struct opt *opts, int pf, int socktype, int proto, int level);
138 extern int
139 xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]);
140 extern int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts);
142 #endif /* !defined(__xio_socket_h_included) */