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 */
4 
5 #ifndef __xio_socket_h_included
6 #define __xio_socket_h_included 1
7 
8 /* SO_PROTOTYPE is defined on Solaris, HP-UX
9    SO_PROTOCOL in Linux, is the better name, but came much later */
10 #ifdef SO_PROTOCOL
11 #  undef SO_PROTOTYPE
12 #    define SO_PROTOTYPE SO_PROTOCOL
13 #else
14 #  ifdef SO_PROTOTYPE
15 #    define SO_PROTOCOL SO_PROTOTYPE
16 #  else
17 #    define SO_PROTOCOL 0x9999
18 #    define SO_PROTOTYPE SO_PROTOCOL
19 #  endif
20 #endif
21 
22 extern const struct addrdesc xioaddr_socket_connect;
23 extern const struct addrdesc xioaddr_socket_listen;
24 extern const struct addrdesc xioaddr_socket_sendto;
25 extern const struct addrdesc xioaddr_socket_datagram;
26 extern const struct addrdesc xioaddr_socket_recvfrom;
27 extern const struct addrdesc xioaddr_socket_recv;
28 
29 extern const struct optdesc opt_connect_timeout;
30 extern const struct optdesc opt_so_debug;
31 extern const struct optdesc opt_so_acceptconn;
32 extern const struct optdesc opt_so_broadcast;
33 extern const struct optdesc opt_so_reuseaddr;
34 extern const struct optdesc opt_so_keepalive;
35 extern const struct optdesc opt_so_linger;
36 extern const struct optdesc opt_so_linger;
37 extern const struct optdesc opt_so_oobinline;
38 extern const struct optdesc opt_so_sndbuf;
39 extern const struct optdesc opt_so_sndbuf_late;
40 extern const struct optdesc opt_so_rcvbuf;
41 extern const struct optdesc opt_so_rcvbuf_late;
42 extern const struct optdesc opt_so_error;
43 extern const struct optdesc opt_so_type;
44 extern const struct optdesc opt_so_dontroute;
45 extern const struct optdesc opt_so_rcvlowat;
46 extern const struct optdesc opt_so_sndlowat;
47 extern const struct optdesc opt_so_audit;
48 extern const struct optdesc opt_so_attach_filter;
49 extern const struct optdesc opt_so_detach_filter;
50 extern const struct optdesc opt_so_bindtodevice;
51 extern const struct optdesc opt_so_bsdcompat;
52 extern const struct optdesc opt_so_cksumrecv;
53 extern const struct optdesc opt_so_timestamp;
54 extern const struct optdesc opt_so_kernaccept;
55 extern const struct optdesc opt_so_no_check;
56 extern const struct optdesc opt_so_noreuseaddr;
57 extern const struct optdesc opt_so_passcred;
58 extern const struct optdesc opt_so_peercred;
59 extern const struct optdesc opt_so_priority;
60 extern const struct optdesc opt_so_reuseport;
61 extern const struct optdesc opt_so_security_authentication;
62 extern const struct optdesc opt_so_security_encryption_network;
63 extern const struct optdesc opt_so_security_encryption_transport;
64 extern const struct optdesc opt_so_use_ifbufs;
65 extern const struct optdesc opt_so_useloopback;
66 extern const struct optdesc opt_so_dgram_errind;
67 extern const struct optdesc opt_so_dontlinger;
68 extern const struct optdesc opt_so_prototype;
69 extern const struct optdesc opt_fiosetown;
70 extern const struct optdesc opt_siocspgrp;
71 extern const struct optdesc opt_bind;
72 extern const struct optdesc opt_protocol_family;
73 extern const struct optdesc opt_setsockopt;
74 extern const struct optdesc opt_setsockopt_int;
75 extern const struct optdesc opt_setsockopt_bin;
76 extern const struct optdesc opt_setsockopt_string;
77 extern const struct optdesc opt_setsockopt_listen;
78 extern const struct optdesc opt_null_eof;
79 
80 
81 extern
82 char *xiogetifname(int ind, char *val, int ins);
83 
84 extern int retropt_socket_pf(struct opt *opts, int *pf);
85 
86 extern int xioopen_connect(struct single *fd,
87 			    union sockaddr_union *us, size_t uslen,
88 			    struct sockaddr *them, size_t themlen,
89 			    struct opt *opts,
90 			   int pf, int socktype, int protocol,
91 			    bool alt);
92 extern int _xioopen_connect(struct single *fd,
93 			    union sockaddr_union *us, size_t uslen,
94 			    struct sockaddr *them, size_t themlen,
95 			    struct opt *opts,
96 			    int pf, int socktype, int protocol,
97 			    bool alt, int level);
98 
99 /* common to xioopen_udp_sendto, ..unix_sendto, ..rawip */
100 extern
101 int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
102 			union sockaddr_union *us, socklen_t uslen,
103 			struct opt *opts,
104 			int xioflags, xiosingle_t *xfd, unsigned groups,
105 			int pf, int socktype, int ipproto);
106 extern
107 int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags,
108 			    struct sockaddr *us, socklen_t uslen,
109 			    struct opt *opts,
110 			    int pf, int socktype, int proto, int level);
111 extern
112 int _xioopen_dgram_recv(struct single *xfd, int xioflags,
113 			struct sockaddr *us, socklen_t uslen,
114 			struct opt *opts, int pf, int socktype, int proto,
115 			int level);
116 extern
117 int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv);
118 extern
119 int xiogetpacketsrc(int fd, struct msghdr *msgh, int flags);
120 extern
121 int xiocheckpeer(xiosingle_t *xfd,
122 		 union sockaddr_union *pa, union sockaddr_union *la);
123 extern
124 int xiosetsockaddrenv(const char *lr, union sockaddr_union *sau, socklen_t salen, int proto);
125 
126 extern
127 int xioparsenetwork(const char *rangename, int pf,
128 		    struct xiorange *range);
129 extern
130 int xioparserange(const char *rangename, int pf, struct xiorange *range);
131 
132 extern int
133 xiosocket(struct opt *opts, int pf, int socktype, int proto, int level);
134 extern int
135 xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]);
136 
137 #endif /* !defined(__xio_socket_h_included) */
138