version 1.7.3.0
[socat.git] / xioopts.h
blobebcf3153bcfd296bde563b541a1f9bb4801ddf4e
1 /* source: xioopts.h */
2 /* Copyright Gerhard Rieger */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __xioopts_h_included
6 #define __xioopts_h_included 1
8 #define ODESC_END ((void *)0) /* indicates end of actual option array */
9 #define ODESC_DONE ((void *)-1) /* indicates that option has been applied */
10 #define ODESC_ERROR ODESC_DONE /* maybe later */
12 #define XIO_OFFSETOF(x) ((size_t)&((xiosingle_t *)0)->x)
13 #define XIO_SIZEOF(x) (sizeof(((struct single *)0)->x))
15 /* atomic structure for use in the option search table; keep compatible with
16 struct wordent! */
17 struct optname {
18 const char *name;
19 const struct optdesc *desc;
20 } ;
22 /* keep consistent with xiohelp.c:optiontypenames[] ! */
23 enum e_types {
24 TYPE_CONST, /* keyword means a fix value - implies int type */
25 TYPE_BIN, /* raw binary data, length determined by data */
26 TYPE_BOOL, /* value is 0 or 1 (no-value is interpreted as 1) */
27 TYPE_BYTE, /* unsigned char */
29 TYPE_INT, /* int */
30 TYPE_LONG, /* long */
31 TYPE_STRING, /* char * */
32 TYPE_NAME = TYPE_STRING,
33 TYPE_FILENAME = TYPE_STRING,
34 TYPE_PTRDIFF, /* ptrdiff_t */
36 TYPE_SHORT, /* short */
37 TYPE_SIZE_T, /* size_t */
38 TYPE_SOCKADDR, /* struct sockaddr * */
39 TYPE_UINT, /* unsigned int */
41 TYPE_ULONG, /* unsigned long */
42 TYPE_USHORT, /* unsigned short */
43 TYPE_2BYTE = TYPE_USHORT,
44 TYPE_MODET, /* representation of mode_t */
45 TYPE_GIDT, /* representation of gid_t */
47 TYPE_UIDT, /* representation of uid_t */
48 /*TYPE_FLAG,*/
49 TYPE_INT3, /* int[3] */
50 TYPE_TIMEVAL, /* struct timeval: {long;long;}, seconds and microsec. */
51 TYPE_TIMESPEC, /* struct timespec: {time_t;long;}, seconds and nanosec. */
53 TYPE_DOUBLE, /* double */
54 TYPE_STRING_NULL, /* char *; string or NULL */
55 TYPE_LONGLONG, /* long long */
56 TYPE_OFF32, /* off_t */
58 TYPE_OFF64, /* off64_t */
59 TYPE_INT_INT, /* 2 parameters: first is int, second is int */
60 TYPE_INT_INTP, /* 2 parameters: first is int, second is int* */
61 TYPE_INT_BIN, /* 2 parameters: first is int, second is binary */
63 TYPE_INT_STRING, /* 2 parameters: first is int, second is req string */
64 TYPE_INT_INT_INT, /* 3 params: first and second are int, 3rd is int */
65 TYPE_INT_INT_BIN, /* 3 params: first and second are int, 3rd is binary */
66 TYPE_INT_INT_STRING, /* 3 params: first and second are int, 3rd is string */
68 TYPE_IP4NAME, /* IPv4 hostname or address */
69 #if HAVE_STRUCT_LINGER
70 TYPE_LINGER, /* struct linger */
71 #endif /* HAVE_STRUCT_LINGER */
72 #if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IP_MREQN
73 TYPE_IP_MREQN, /* for struct ip_mreq or struct ip_mreqn */
74 #endif
75 } ;
77 enum e_func {
78 OFUNC_NONE, /* no function - should not occur */
79 OFUNC_FLAG, /* no function, but bitposition, only with bool; arg1 is mask */
80 OFUNC_FLAG_PATTERN, /* no function, but bitpattern: arg1 is pattern, arg2 is mask */
81 OFUNC_SEEK32, /* lseek(): arg1 is whence (SEEK_SET etc.) */
82 OFUNC_SEEK64, /* lseek64(): arg1 is whence (SEEK_SET etc.) */
83 OFUNC_FCNTL, /* fcntl(, ): arg1 is cmd */
84 OFUNC_IOCTL, /* ioctl(): arg1 of option description is request, arg2
85 is int setrequest */
86 OFUNC_IOCTL_MASK_LONG, /* arg1 is getrequest, arg2 is setrequest:
87 ioctl(arg1, ); |= arg3; ioctl(arg2, ); */
88 OFUNC_IOCTL_GENERIC, /* generic ioctl() (request on cmdline) */
89 OFUNC_SOCKOPT, /* setsockopt() */
90 OFUNC_SOCKOPT_APPEND,/* getsockopt(), append data, setsockopt() */
91 OFUNC_SOCKOPT_GENERIC,/* generic setsockopt() (level, optname on cmdline) */
92 OFUNC_FLOCK, /* flock() */
93 OFUNC_TERMIO, /* termio() ? */
94 OFUNC_SPEC, /* special, i.e. no generalizable function call */
95 OFUNC_OFFSET, /* put a value into xiofile struct; major is offset */
96 OFUNC_OFFSET_MASKS, /* !!! */
97 /*OFUNC_APPL,*/ /* special, i.e. application must know which f. */
98 OFUNC_EXT, /* with extended file descriptors only */
99 OFUNC_TERMIOS_FLAG, /* a flag in struct termios: major..tcflag, minor..bit
101 OFUNC_TERMIOS_PATTERN, /* a multibit: major..tcflag, minor..pattern,
102 arg3..mask */
103 OFUNC_TERMIOS_VALUE, /* a variable value: major..tcflag, minor..mask, arg3..shift */
104 OFUNC_TERMIOS_CHAR, /* a termios functional character: major..c_cc index */
105 OFUNC_TERMIOS_SPEED, /* termios c_ispeed etc on FreeBSD */
106 OFUNC_TERMIOS_SPEC, /* termios combined modes */
107 OFUNC_SIGNAL, /* a signal that should be passed to child process */
108 OFUNC_RESOLVER, /* a bit position used on _res.options */
109 OFUNC_IFFLAG, /* interface flag: locical-or a 1bit mask */
110 # define ENABLE_OFUNC
111 # include "xio-streams.h" /* push a POSIX STREAMS module */
112 # undef ENABLE_OFUNC
115 /* for simpler handling of option-to-connection-type relations we define
116 groups. to keep the search for options simple, we allow each option to
117 belong to at most one group only. (we have a dummy GROUP_NONE for those
118 that don't want to belong to any...)
119 The caller of parseopts() specifies per bitpatter a set of groups where it
120 accepts options from.
123 /*- the group bits are:
124 - 000ooooo 00000000 000000uf 0000ssss
125 - ooooo: more detailed description to ssss (e.g., socket family)
126 - ssss: the type of stream, as in stat.h: S_IF...
127 - f: has a named entry in the file system
128 - u: has user and group
130 /* keep consistent with xiohelp.c:addressgroupnames[] ! */
131 /* a dummy group */
132 #define GROUP_NONE 0x00000000
134 #define GROUP_FD 0x00000001 /* everything applyable to a fd */
135 #define GROUP_FIFO 0x00000002
136 #define GROUP_CHR 0x00000004
137 #define GROUP_BLK 0x00000008
138 #define GROUP_REG 0x00000010
139 #define GROUP_FILE GROUP_REG
140 #define GROUP_SOCKET 0x00000020
141 #define GROUP_READLINE 0x00000040
143 #define GROUP_NAMED 0x00000100 /* file system entry */
144 #define GROUP_OPEN 0x00000200 /* flags for open() */
145 #define GROUP_EXEC 0x00000400 /* program or script execution */
146 #define GROUP_FORK 0x00000800 /* communication with forked process */
148 #define GROUP_LISTEN 0x00001000 /* socket in listening mode */
149 /* 0x00002000 */
150 #define GROUP_CHILD 0x00004000 /* autonom child process */
151 #define GROUP_RETRY 0x00008000 /* when open/connect etc. fails */
152 #define GROUP_TERMIOS 0x00010000
153 #define GROUP_RANGE 0x00020000 /* differs from GROUP_LISTEN */
154 #define GROUP_PTY 0x00040000 /* address pty or exec...,pty */
155 #define GROUP_PARENT 0x00080000 /* for parent of communicating child */
157 #define GROUP_SOCK_UNIX 0x00100000
158 #define GROUP_SOCK_IP4 0x00200000
159 #define GROUP_SOCK_IP6 0x00400000
160 #define GROUP_SOCK_IP (GROUP_SOCK_IP4|GROUP_SOCK_IP6)
161 #define GROUP_INTERFACE 0x00800000
162 #define GROUP_TUN GROUP_INTERFACE
164 #define GROUP_IP_UDP 0x01000000
165 #define GROUP_IP_TCP 0x02000000
166 #define GROUP_IPAPP (GROUP_IP_UDP|GROUP_IP_TCP|GROUP_IP_SCTP) /* true: indicates one of UDP, TCP, SCTP */
167 #define GROUP_IP_SOCKS4 0x04000000
168 #define GROUP_OPENSSL 0x08000000
170 #define GROUP_PROCESS 0x10000000 /* a process related option */
171 #define GROUP_APPL 0x20000000 /* option handled by data loop */
172 #define GROUP_HTTP 0x40000000 /* any HTTP client */
173 #define GROUP_IP_SCTP 0x80000000
175 #define GROUP_ANY (GROUP_PROCESS|GROUP_APPL)
176 #define GROUP_ALL 0xffffffff
179 /* no IP multicasts, no error queue yet */
180 /* the only reason for keeping this enum sorted is to help detecting name
181 conflicts. */
182 /* optcode's */
183 enum e_optcode {
184 OPT_ADDRESS_FAMILY = 1,
185 /* these are not alphabetically, I know... */
186 OPT_B0, /* termios.c_cflag */
187 OPT_B50, /* termios.c_cflag */
188 OPT_B75, /* termios.c_cflag */
189 OPT_B110, /* termios.c_cflag */
190 OPT_B134, /* termios.c_cflag */
191 OPT_B150, /* termios.c_cflag */
192 OPT_B200, /* termios.c_cflag */
193 OPT_B300, /* termios.c_cflag */
194 OPT_B600, /* termios.c_cflag */
195 OPT_B900, /* termios.c_cflag - HP-UX */
196 OPT_B1200, /* termios.c_cflag */
197 OPT_B1800, /* termios.c_cflag */
198 OPT_B2400, /* termios.c_cflag */
199 OPT_B3600, /* termios.c_cflag - HP-UX */
200 OPT_B4800, /* termios.c_cflag */
201 OPT_B7200, /* termios.c_cflag - HP-UX */
202 OPT_B9600, /* termios.c_cflag */
203 OPT_B19200, /* termios.c_cflag */
204 OPT_B38400, /* termios.c_cflag */
205 OPT_B57600, /* termios.c_cflag */
206 OPT_B115200, /* termios.c_cflag */
207 OPT_B230400, /* termios.c_cflag */
208 OPT_B460800, /* termios.c_cflag */
209 OPT_B500000, /* termios.c_cflag */
210 OPT_B576000, /* termios.c_cflag */
211 OPT_B921600, /* termios.c_cflag */
212 OPT_B1000000, /* termios.c_cflag */
213 OPT_B1152000, /* termios.c_cflag */
214 OPT_B1500000, /* termios.c_cflag */
215 OPT_B2000000, /* termios.c_cflag */
216 OPT_B2500000, /* termios.c_cflag */
217 OPT_B3000000, /* termios.c_cflag */
218 OPT_B3500000, /* termios.c_cflag */
219 OPT_B4000000, /* termios.c_cflag */
220 OPT_BACKLOG,
221 OPT_BIND, /* a socket address as character string */
222 OPT_BRKINT, /* termios.c_iflag */
223 #ifdef BSDLY
224 # ifdef BS0
225 OPT_BS0, /* termios.c_oflag */
226 # endif
227 # ifdef BS1
228 OPT_BS1, /* termios.c_oflag */
229 # endif
230 OPT_BSDLY, /* termios.c_oflag */
231 #endif
232 OPT_CHROOT, /* chroot() past file system access */
233 OPT_CHROOT_EARLY, /* chroot() before file system access */
234 /*OPT_CIBAUD,*/ /* termios.c_cflag */
235 OPT_CLOCAL, /* termios.c_cflag */
236 OPT_CLOEXEC,
237 OPT_CONNECT_TIMEOUT, /* socket connect */
238 OPT_COOL_WRITE,
239 OPT_CR, /* customized */
240 #ifdef CR0
241 OPT_CR0, /* termios.c_oflag */
242 #endif
243 #ifdef CR1
244 OPT_CR1, /* termios.c_oflag */
245 #endif
246 #ifdef CR2
247 OPT_CR2, /* termios.c_oflag */
248 #endif
249 #ifdef CR3
250 OPT_CR3, /* termios.c_oflag */
251 #endif
252 #ifdef CRDLY
253 OPT_CRDLY, /* termios.c_oflag */
254 #endif
255 OPT_CREAD, /* termios.c_cflag */
256 OPT_CRNL, /* customized */
257 #ifdef CRTSCTS
258 OPT_CRTSCTS, /* termios.c_cflag */
259 #endif
260 OPT_CS5, /* termios.c_cflag */
261 OPT_CS6, /* termios.c_cflag */
262 OPT_CS7, /* termios.c_cflag */
263 OPT_CS8, /* termios.c_cflag */
264 OPT_CSIZE, /* termios.c_cflag */
265 OPT_CSTOPB, /* termios.c_cflag */
266 OPT_DASH, /* exec() */
267 OPT_ECHO, /* termios.c_lflag */
268 OPT_ECHOCTL, /* termios.c_lflag */
269 OPT_ECHOE, /* termios.c_lflag */
270 OPT_ECHOK, /* termios.c_lflag */
271 OPT_ECHOKE, /* termios.c_lflag */
272 OPT_ECHONL, /* termios.c_lflag */
273 #ifdef ECHOPRT
274 OPT_ECHOPRT, /* termios.c_lflag */
275 #endif
276 OPT_END_CLOSE, /* xfd.stream.howtoend = END_CLOSE */
277 OPT_ESCAPE,
278 OPT_EXT2_SECRM,
279 OPT_EXT2_UNRM,
280 OPT_EXT2_COMPR,
281 OPT_EXT2_SYNC,
282 OPT_EXT2_IMMUTABLE,
283 OPT_EXT2_APPEND,
284 OPT_EXT2_NODUMP,
285 OPT_EXT2_NOATIME,
286 OPT_EXT2_JOURNAL_DATA,
287 OPT_EXT2_NOTAIL,
288 OPT_EXT2_DIRSYNC,
289 OPT_EXT2_TOPDIR,
290 OPT_FDIN,
291 OPT_FDOUT,
292 #ifdef FFDLY
293 # ifdef FF0
294 OPT_FF0, /* termios.c_oflag */
295 # endif
296 # ifdef FF1
297 OPT_FF1, /* termios.c_oflag */
298 # endif
299 OPT_FFDLY, /* termios.c_oflag */
300 #endif
301 #ifdef FIOSETOWN
302 OPT_FIOSETOWN, /* asm/sockios.h */
303 #endif
304 OPT_FLOCK_EX, /* flock(fd, LOCK_EX) */
305 OPT_FLOCK_EX_NB, /* flock(fd, LOCK_EX|LOCK_NB) */
306 OPT_FLOCK_SH, /* flock(fd, LOCK_SH) */
307 OPT_FLOCK_SH_NB, /* flock(fd, LOCK_SH|LOCK_NB) */
308 OPT_FLUSHO, /* termios.c_lflag */
309 /*0 OPT_FORCE,*/
310 OPT_FOREVER,
311 OPT_FORK,
312 OPT_FTRUNCATE32, /* ftruncate() */
313 OPT_FTRUNCATE64, /* ftruncate64() */
314 OPT_F_SETLKW_RD, /* fcntl with struct flock - read-lock, wait */
315 OPT_F_SETLKW_WR, /* fcntl with struct flock - write-lock, wait */
316 OPT_F_SETLK_RD, /* fcntl with struct flock - read-lock */
317 OPT_F_SETLK_WR, /* fcntl with struct flock - write-lock */
318 OPT_GROUP,
319 OPT_GROUP_EARLY,
320 OPT_GROUP_LATE,
321 OPT_HISTORY_FILE, /* readline history file */
322 OPT_HUPCL, /* termios.c_cflag */
323 OPT_ICANON, /* termios.c_lflag */
324 OPT_ICRNL, /* termios.c_iflag */
325 OPT_IEXTEN, /* termios.c_lflag */
326 OPT_IFF_ALLMULTI, /* struct ifreq.ifr_flags */
327 OPT_IFF_AUTOMEDIA, /* struct ifreq.ifr_flags */
328 OPT_IFF_BROADCAST, /* struct ifreq.ifr_flags */
329 OPT_IFF_DEBUG, /* struct ifreq.ifr_flags */
330 /*OPT_IFF_DYNAMIC,*/ /* struct ifreq.ifr_flags */
331 OPT_IFF_LOOPBACK, /* struct ifreq.ifr_flags */
332 OPT_IFF_MASTER, /* struct ifreq.ifr_flags */
333 OPT_IFF_MULTICAST, /* struct ifreq.ifr_flags */
334 OPT_IFF_NOARP, /* struct ifreq.ifr_flags */
335 OPT_IFF_NOTRAILERS, /* struct ifreq.ifr_flags */
336 OPT_IFF_NO_PI, /* tun: IFF_NO_PI */
337 OPT_IFF_PORTSEL, /* struct ifreq.ifr_flags */
338 OPT_IFF_POINTOPOINT, /* struct ifreq.ifr_flags */
339 OPT_IFF_PROMISC, /* struct ifreq.ifr_flags */
340 OPT_IFF_RUNNING, /* struct ifreq.ifr_flags */
341 OPT_IFF_SLAVE, /* struct ifreq.ifr_flags */
342 OPT_IFF_UP, /* struct ifreq.ifr_flags */
343 OPT_IGNBRK, /* termios.c_iflag */
344 OPT_IGNCR, /* termios.c_iflag */
345 OPT_IGNORECR, /* HTTP */
346 OPT_IGNOREEOF, /* customized */
347 OPT_IGNPAR, /* termios.c_iflag */
348 OPT_IMAXBEL, /* termios.c_iflag */
349 OPT_INLCR, /* termios.c_iflag */
350 OPT_INPCK, /* termios.c_iflag */
351 OPT_INTERVALL,
352 OPT_IPV6_AUTHHDR,
353 OPT_IPV6_DSTOPTS,
354 OPT_IPV6_FLOWINFO,
355 OPT_IPV6_HOPLIMIT,
356 OPT_IPV6_HOPOPTS,
357 OPT_IPV6_JOIN_GROUP,
358 OPT_IPV6_PKTINFO,
359 OPT_IPV6_RECVDSTOPTS,
360 OPT_IPV6_RECVERR,
361 OPT_IPV6_RECVHOPLIMIT,
362 OPT_IPV6_RECVHOPOPTS,
363 OPT_IPV6_RECVPATHMTU,
364 OPT_IPV6_RECVPKTINFO,
365 OPT_IPV6_RECVRTHDR,
366 OPT_IPV6_RECVTCLASS,
367 OPT_IPV6_RTHDR,
368 OPT_IPV6_TCLASS,
369 OPT_IPV6_UNICAST_HOPS,
370 OPT_IPV6_V6ONLY,
371 #if 0 /* see Linux: man 7 netlink; probably not what we need yet */
372 OPT_IO_SIOCGIFNAME,
373 #endif
374 OPT_IOCTL_BIN, /* generic ioctl with binary value (pointed to) */
375 OPT_IOCTL_INT, /* generic ioctl with integer value */
376 OPT_IOCTL_INTP, /* generic ioctl with integer value (pointed to) */
377 OPT_IOCTL_STRING, /* generic ioctl with integer value (pointed to) */
378 OPT_IOCTL_VOID, /* generic ioctl without value */
379 OPT_IP_ADD_MEMBERSHIP,
380 #ifdef IP_HDRINCL
381 OPT_IP_HDRINCL,
382 #endif
383 #ifdef IP_FREEBIND
384 OPT_IP_FREEBIND,
385 #endif
386 #ifdef IP_MTU
387 OPT_IP_MTU,
388 #endif
389 #ifdef IP_MTU_DISCOVER
390 OPT_IP_MTU_DISCOVER,
391 #endif
392 OPT_IP_MULTICAST_IF,
393 OPT_IP_MULTICAST_LOOP,
394 OPT_IP_MULTICAST_TTL,
395 OPT_IP_OPTIONS,
396 #ifdef IP_PKTINFO
397 OPT_IP_PKTINFO,
398 #endif
399 #ifdef IP_PKTOPTIONS
400 OPT_IP_PKTOPTIONS,
401 #endif
402 OPT_IP_RECVDSTADDR,
403 #ifdef IP_RECVERR
404 OPT_IP_RECVERR,
405 #endif
406 OPT_IP_RECVIF,
407 #ifdef IP_RECVOPTS
408 OPT_IP_RECVOPTS,
409 #endif
410 #ifdef IP_RECVTOS
411 OPT_IP_RECVTOS,
412 #endif
413 #ifdef IP_RECVTTL
414 OPT_IP_RECVTTL,
415 #endif
416 #ifdef IP_RETOPTS
417 OPT_IP_RETOPTS,
418 #endif
419 #ifdef IP_ROUTER_ALERT
420 OPT_IP_ROUTER_ALERT,
421 #endif
422 OPT_IP_TOS,
423 OPT_IP_TTL,
424 OPT_ISIG, /* termios.c_lflag */
425 OPT_ISPEED, /* termios.c_ispeed */
426 OPT_ISTRIP, /* termios.c_iflag */
427 #ifdef IUCLC
428 OPT_IUCLC, /* termios.c_iflag */
429 #endif
430 OPT_IXANY, /* termios.c_iflag */
431 OPT_IXOFF, /* termios.c_iflag */
432 OPT_IXON, /* termios.c_iflag */
433 OPT_LOCKFILE,
434 OPT_LOWPORT,
435 OPT_MAX_CHILDREN,
436 #ifdef NLDLY
437 # ifdef NL0
438 OPT_NL0, /* termios.c_oflag */
439 # endif
440 # ifdef NL0
441 OPT_NL1, /* termios.c_oflag */
442 # endif
443 OPT_NLDLY, /* termios.c_oflag */
444 #endif
445 OPT_NOECHO, /* readline */
446 OPT_NOFLSH, /* termios.c_lflag */
447 OPT_NOFORK, /* exec, system */
448 OPT_NOPROMPT, /* readline */
449 OPT_NULL_EOF, /* receiving empty packet triggers EOF */
450 #ifdef OCRNL
451 OPT_OCRNL, /* termios.c_oflag */
452 #endif
453 #ifdef OFDEL
454 OPT_OFDEL, /* termios.c_oflag */
455 #endif
456 #ifdef OFILL
457 OPT_OFILL, /* termios.c_oflag */
458 #endif
459 #ifdef OLCUC
460 OPT_OLCUC, /* termios.c_oflag */
461 #endif
462 OPT_ONLCR, /* termios.c_oflag */
463 #ifdef ONLRET
464 OPT_ONLRET, /* termios.c_oflag */
465 #endif
466 #ifdef ONOCR
467 OPT_ONOCR, /* termios.c_oflag */
468 #endif
469 #if HAVE_OPENPTY
470 OPT_OPENPTY,
471 #endif
472 OPT_OPENSSL_CAFILE,
473 OPT_OPENSSL_CAPATH,
474 OPT_OPENSSL_CERTIFICATE,
475 OPT_OPENSSL_CIPHERLIST,
476 OPT_OPENSSL_COMMONNAME,
477 #if OPENSSL_VERSION_NUMBER >= 0x00908000L
478 OPT_OPENSSL_COMPRESS,
479 #endif
480 OPT_OPENSSL_DHPARAM,
481 OPT_OPENSSL_EGD,
482 OPT_OPENSSL_FIPS,
483 OPT_OPENSSL_KEY,
484 OPT_OPENSSL_METHOD,
485 OPT_OPENSSL_PSEUDO,
486 OPT_OPENSSL_VERIFY,
487 OPT_OPOST, /* termios.c_oflag */
488 OPT_OSPEED, /* termios.c_ospeed */
489 OPT_O_APPEND,
490 #ifdef O_ASYNC
491 OPT_O_ASYNC,
492 #endif
493 OPT_O_BINARY, /* Cygwin */
494 OPT_O_CREATE,
495 #ifdef O_DEFER
496 OPT_O_DEFER,
497 #endif
498 #ifdef O_DELAY
499 OPT_O_DELAY,
500 #endif
501 #ifdef O_DIRECT
502 OPT_O_DIRECT,
503 #endif
504 #ifdef O_DIRECTORY
505 OPT_O_DIRECTORY,
506 #endif
507 #ifdef O_DSYNC
508 OPT_O_DSYNC,
509 #endif
510 OPT_O_EXCL,
511 #ifdef O_LARGEFILE
512 OPT_O_LARGEFILE,
513 #endif
514 #if defined(O_NDELAY) && (!defined(O_NONBLOCK) || O_NDELAY != O_NONBLOCK)
515 OPT_O_NDELAY,
516 #endif
517 OPT_O_NOATIME,
518 OPT_O_NOCTTY,
519 #ifdef O_NOFOLLOW
520 OPT_O_NOFOLLOW,
521 #endif
522 OPT_O_NOINHERIT, /* Cygwin */
523 OPT_O_NONBLOCK,
524 #ifdef O_NSHARE
525 OPT_O_NSHARE,
526 #endif
527 #ifdef O_PRIV
528 OPT_O_PRIV,
529 #endif
530 OPT_O_RDONLY, /* open() */
531 OPT_O_RDWR, /* open() */
532 #ifdef O_RSHARE
533 OPT_O_RSHARE,
534 #endif
535 #ifdef O_RSYNC
536 OPT_O_RSYNC,
537 #endif
538 #ifdef O_SYNC
539 OPT_O_SYNC,
540 #endif
541 OPT_O_TEXT, /* Cygwin */
542 OPT_O_TRUNC, /* open(): O_TRUNC */
543 OPT_O_WRONLY, /* open() */
544 OPT_PARENB, /* termios.c_cflag */
545 OPT_PARMRK, /* termios.c_iflag */
546 OPT_PARODD, /* termios.c_cflag */
547 OPT_PATH,
548 #ifdef PENDIN
549 OPT_PENDIN, /* termios.c_lflag */
550 #endif
551 OPT_PERM,
552 OPT_PERM_EARLY,
553 OPT_PERM_LATE,
554 OPT_PIPES,
555 /*OPT_PORT,*/
556 OPT_PROMPT, /* readline */
557 OPT_PROTOCOL, /* 6=TCP, 17=UDP */
558 OPT_PROTOCOL_FAMILY, /* 1=PF_UNIX, 2=PF_INET, 10=PF_INET6 */
559 OPT_PROXYPORT,
560 OPT_PROXY_AUTHORIZATION,
561 OPT_PROXY_RESOLVE,
562 #if HAVE_DEV_PTMX || HAVE_DEV_PTC
563 OPT_PTMX,
564 #endif
565 OPT_PTY,
566 OPT_PTY_INTERVALL,
567 OPT_PTY_WAIT_SLAVE,
568 OPT_RANGE, /* restrict client socket address */
569 OPT_RAW, /* termios */
570 OPT_READBYTES,
571 OPT_RES_AAONLY, /* resolver(3) */
572 OPT_RES_DEBUG, /* resolver(3) */
573 OPT_RES_DEFNAMES, /* resolver(3) */
574 OPT_RES_DNSRCH, /* resolver(3) */
575 OPT_RES_IGNTC, /* resolver(3) */
576 OPT_RES_PRIMARY, /* resolver(3) */
577 OPT_RES_RECURSE, /* resolver(3) */
578 OPT_RES_STAYOPEN, /* resolver(3) */
579 OPT_RES_USEVC, /* resolver(3) */
580 OPT_RETRY,
581 OPT_SANE, /* termios */
582 OPT_SCTP_MAXSEG,
583 OPT_SCTP_MAXSEG_LATE,
584 OPT_SCTP_NODELAY,
585 OPT_SEEK32_CUR,
586 OPT_SEEK32_END,
587 OPT_SEEK32_SET,
588 OPT_SEEK64_CUR,
589 OPT_SEEK64_END,
590 OPT_SEEK64_SET,
591 OPT_SETGID,
592 OPT_SETGID_EARLY,
593 OPT_SETPGID,
594 OPT_SETSID,
595 OPT_SETSOCKOPT_BIN,
596 OPT_SETSOCKOPT_INT,
597 OPT_SETSOCKOPT_STRING,
598 OPT_SETUID,
599 OPT_SETUID_EARLY,
600 OPT_SHUT_CLOSE,
601 OPT_SHUT_DOWN,
602 OPT_SHUT_NONE,
603 OPT_SHUT_NULL, /* send 0 bytes on shutdown */
604 OPT_SIGHUP,
605 OPT_SIGINT,
606 OPT_SIGQUIT,
607 #ifdef SIOCSPGRP
608 OPT_SIOCSPGRP,
609 #endif
610 #ifdef SO_ACCEPTCONN
611 OPT_SO_ACCEPTCONN,
612 #endif /* SO_ACCEPTCONN */
613 #ifdef SO_ATTACH_FILTER
614 OPT_SO_ATTACH_FILTER,
615 #endif
616 #ifdef SO_AUDIT /* AIX 4.3.3 */
617 OPT_SO_AUDIT,
618 #endif /* SO_AUDIT */
619 #ifdef SO_BINDTODEVICE
620 OPT_SO_BINDTODEVICE,
621 #endif
622 OPT_SO_BROADCAST,
623 #ifdef SO_BSDCOMPAT
624 OPT_SO_BSDCOMPAT,
625 #endif
626 #ifdef SO_CKSUMRECV
627 OPT_SO_CKSUMRECV,
628 #endif /* SO_CKSUMRECV */
629 OPT_SO_DEBUG,
630 #ifdef SO_DETACH_FILTER
631 OPT_SO_DETACH_FILTER,
632 #endif
633 #ifdef SO_DGRAM_ERRIND
634 OPT_SO_DGRAM_ERRIND,
635 #endif
636 #ifdef SO_DONTLINGER
637 OPT_SO_DONTLINGER,
638 #endif
639 OPT_SO_DONTROUTE,
640 OPT_SO_ERROR,
641 OPT_SO_KEEPALIVE,
642 #ifdef SO_KERNACCEPT /* AIX 4.3.3 */
643 OPT_SO_KERNACCEPT,
644 #endif /* SO_KERNACCEPT */
645 OPT_SO_LINGER,
646 #ifdef SO_NO_CHECK
647 OPT_SO_NO_CHECK,
648 #endif
649 #ifdef SO_NOREUSEADDR /* AIX 4.3.3 */
650 OPT_SO_NOREUSEADDR,
651 #endif /* SO_NOREUSEADDR */
652 OPT_SO_OOBINLINE,
653 #ifdef SO_PASSCRED
654 OPT_SO_PASSCRED,
655 #endif
656 #ifdef SO_PEERCRED
657 OPT_SO_PEERCRED,
658 #endif
659 #ifdef SO_PRIORITY
660 OPT_SO_PRIORITY,
661 #endif
662 OPT_SO_PROTOTYPE,
663 OPT_SO_RCVBUF,
664 OPT_SO_RCVBUF_LATE,
665 #ifdef SO_RCVLOWAT
666 OPT_SO_RCVLOWAT,
667 #endif
668 #ifdef SO_RCVTIMEO
669 OPT_SO_RCVTIMEO,
670 #endif
671 OPT_SO_REUSEADDR,
672 #ifdef SO_REUSEPORT
673 OPT_SO_REUSEPORT,
674 #endif /* defined(SO_REUSEPORT) */
675 #ifdef SO_SECURITY_AUTHENTICATION
676 OPT_SO_SECURITY_AUTHENTICATION,
677 #endif
678 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
679 OPT_SO_SECURITY_ENCRYPTION_NETWORK,
680 #endif
681 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
682 OPT_SO_SECURITY_ENCRYPTION_TRANSPORT,
683 #endif
684 OPT_SO_SNDBUF,
685 OPT_SO_SNDBUF_LATE,
686 #ifdef SO_SNDLOWAT
687 OPT_SO_SNDLOWAT,
688 #endif
689 #ifdef SO_SNDTIMEO
690 OPT_SO_SNDTIMEO,
691 #endif
692 OPT_SO_TIMESTAMP, /* Linux */
693 OPT_SO_TYPE,
694 #ifdef SO_USELOOPBACK
695 OPT_SO_USELOOPBACK,
696 #endif /* SO_USELOOPBACK */
697 #ifdef SO_USE_IFBUFS
698 OPT_SO_USE_IFBUFS,
699 #endif /* SO_USE_IFBUFS */
700 #if 1 || defined(WITH_SOCKS4)
701 OPT_SOCKSPORT,
702 OPT_SOCKSUSER,
703 #endif
704 OPT_SOURCEPORT,
705 OPT_STDERR, /* with exec, system */
706 # define ENABLE_OPTCODE
707 # include "xio-streams.h"
708 # undef ENABLE_OPTCODE
709 OPT_SUBSTUSER_EARLY,
710 OPT_SUBSTUSER,
711 #if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
712 OPT_SUBSTUSER_DELAYED,
713 #endif
714 OPT_SYMBOLIC_LINK, /* with pty */
715 #ifdef TABDLY
716 # ifdef TAB0
717 OPT_TAB0, /* termios.c_oflag */
718 # endif
719 # ifdef TAB1
720 OPT_TAB1, /* termios.c_oflag */
721 # endif
722 # ifdef TAB2
723 OPT_TAB2, /* termios.c_oflag */
724 # endif
725 # ifdef TAB3
726 OPT_TAB3, /* termios.c_oflag */
727 # endif
728 OPT_TABDLY, /* termios.c_oflag */
729 #endif
730 OPT_TCPWRAPPERS, /* libwrap */
731 OPT_TCPWRAP_ETC, /* libwrap */
732 OPT_TCPWRAP_HOSTS_ALLOW_TABLE, /* libwrap */
733 OPT_TCPWRAP_HOSTS_DENY_TABLE, /* libwrap */
734 OPT_TCP_ABORT_THRESHOLD, /* HP-UX */
735 OPT_TCP_CONN_ABORT_THRESHOLD, /* HP-UX */
736 #ifdef TCP_CORK
737 OPT_TCP_CORK,
738 #endif
739 #ifdef TCP_DEFER_ACCEPT
740 OPT_TCP_DEFER_ACCEPT, /* Linux 2.4.0 */
741 #endif
742 #ifdef TCP_INFO
743 OPT_TCP_INFO, /* Linux 2.4.0 */
744 #endif
745 #ifdef TCP_KEEPCNT
746 OPT_TCP_KEEPCNT, /* Linux 2.4.0 */
747 #endif
748 #ifdef TCP_KEEPIDLE
749 OPT_TCP_KEEPIDLE, /* Linux 2.4.0 */
750 #endif
751 OPT_TCP_KEEPINIT, /* OSF1 */
752 #ifdef TCP_KEEPINTVL
753 OPT_TCP_KEEPINTVL, /* Linux 2.4.0 */
754 #endif
755 #ifdef TCP_LINGER2
756 OPT_TCP_LINGER2, /* Linux 2.4.0 */
757 #endif
758 #ifdef TCP_MAXSEG
759 OPT_TCP_MAXSEG,
760 OPT_TCP_MAXSEG_LATE,
761 #endif
762 OPT_TCP_MD5SIG, /* FreeBSD */
763 #ifdef TCP_NODELAY
764 OPT_TCP_NODELAY,
765 #endif
766 OPT_TCP_NOOPT, /* FreeBSD */
767 OPT_TCP_NOPUSH, /* FreeBSD */
768 OPT_TCP_PAWS, /* OSF1 */
769 #ifdef TCP_QUICKACK
770 OPT_TCP_QUICKACK, /* Linux 2.4 */
771 #endif
772 #ifdef TCP_RFC1323
773 OPT_TCP_RFC1323, /* AIX 4.3.3 */
774 #endif
775 OPT_TCP_SACKENA, /* OSF1 */
776 OPT_TCP_SACK_DISABLE, /* OpenBSD */
777 OPT_TCP_SIGNATURE_ENABLE, /* OpenBSD */
778 #ifdef TCP_STDURG
779 OPT_TCP_STDURG, /* AIX 4.3.3; Linux: see man 7 tcp */
780 #endif
781 #ifdef TCP_SYNCNT
782 OPT_TCP_SYNCNT, /* Linux 2.4.0 */
783 #endif
784 OPT_TCP_TSOPTENA, /* OSF1 */
785 #ifdef TCP_WINDOW_CLAMP
786 OPT_TCP_WINDOW_CLAMP, /* Linux 2.4.0 */
787 #endif
788 OPT_TERMIOS_CFMAKERAW, /* termios.cfmakeraw() */
789 OPT_TERMIOS_RAWER,
790 OPT_TIOCSCTTY,
791 OPT_TOSTOP, /* termios.c_lflag */
792 OPT_TUN_DEVICE, /* tun: /dev/net/tun ... */
793 OPT_TUN_NAME, /* tun: tun0 */
794 OPT_TUN_TYPE, /* tun: tun|tap */
795 OPT_UMASK,
796 OPT_UNIX_TIGHTSOCKLEN, /* UNIX domain sockets */
797 OPT_UNLINK,
798 OPT_UNLINK_CLOSE,
799 OPT_UNLINK_EARLY,
800 OPT_UNLINK_LATE,
801 OPT_USER,
802 OPT_USER_EARLY,
803 OPT_USER_LATE,
804 #ifdef VDISCARD
805 OPT_VDISCARD, /* termios.c_cc */
806 #endif
807 OPT_VDSUSP, /* termios.c_cc - HP-UX */
808 OPT_VEOF, /* termios.c_cc */
809 OPT_VEOL, /* termios.c_cc */
810 OPT_VEOL2, /* termios.c_cc */
811 OPT_VERASE, /* termios.c_cc */
812 OPT_VINTR, /* termios.c_cc */
813 OPT_VKILL, /* termios.c_cc */
814 OPT_VLNEXT, /* termios.c_cc */
815 OPT_VMIN, /* termios.c_cc */
816 OPT_VQUIT, /* termios.c_cc */
817 OPT_VREPRINT, /* termios.c_cc */
818 OPT_VSTART, /* termios.c_cc */
819 OPT_VSTOP, /* termios.c_cc */
820 OPT_VSUSP, /* termios.c_cc */
821 OPT_VSWTC, /* termios.c_cc */
822 OPT_VTIME, /* termios.c_cc */
823 #ifdef VTDLY
824 # ifdef VT0
825 OPT_VT0, /* termios.c_oflag */
826 # endif
827 # ifdef VT1
828 OPT_VT1, /* termios.c_oflag */
829 # endif
830 OPT_VTDLY, /* termios.c_oflag */
831 #endif
832 #ifdef VWERASE
833 OPT_VWERASE, /* termios.c_cc */
834 #endif
835 OPT_WAITLOCK,
836 #ifdef XCASE
837 OPT_XCASE, /* termios.c_lflag */
838 #endif
839 #if defined(TABDLY) && defined(XTABS)
840 OPT_XTABS, /* termios.c_oflag */
841 #endif
842 OPT_nocomma /* make aix xlc happy, no trailing comma */
845 /* keep consistent with xiohelp.c:optionphasenames ! */
846 enum e_phase {
847 PH_ALL, /* not for option definitions; use in apply funcs to
848 say "all phases" */
849 PH_INIT, /* retrieving info from original state */
850 PH_EARLY, /* before any other processing */
851 PH_PREOPEN, /* before file descriptor is created/opened */
852 PH_OPEN, /* during filesystem entry creation/open */
853 PH_PASTOPEN, /* past filesystem entry creation/open */
854 PH_PRESOCKET, /* before socket call */
855 PH_SOCKET, /* for socket call */
856 PH_PASTSOCKET, /* after socket call */
857 PH_PREBIGEN, /* before socketpair() pipe() openpty() */
858 PH_BIGEN, /* during socketpair() pipe() openpty() */
859 PH_PASTBIGEN, /* past socketpair() pipe() openpty() */
860 PH_FD, /* soon after FD creation or identification */
861 PH_PREBIND, /* before socket bind() */
862 PH_BIND, /* during socket bind() ? */
863 PH_PASTBIND, /* past socket bind() - for client and server sockets! */
864 PH_PRELISTEN, /* before socket listen() */
865 PH_LISTEN, /* during socket listen() ? */
866 PH_PASTLISTEN, /* after socket listen() */
867 PH_PRECONNECT, /* before socket connect() */
868 PH_CONNECT, /* during socket connect() ? */
869 PH_PASTCONNECT, /* after socket connect() */
870 PH_PREACCEPT, /* before socket accept() */
871 PH_ACCEPT, /* during socket accept() ? */
872 PH_PASTACCEPT, /* after socket accept() */
873 PH_CONNECTED, /* for sockets, after connect() or accept() */
874 PH_PREFORK, /* before fork() (with both listen and exec!) */
875 PH_FORK, /* during fork() (with both listen and exec!) */
876 PH_PASTFORK, /* after fork() (with both listen and exec!) */
877 PH_LATE, /* FD is ready, before start of data loop */
878 PH_LATE2, /* FD is ready, dropping privileges */
879 PH_PREEXEC, /* before exec() or system() */
880 PH_EXEC, /* during exec() or system() */
881 PH_SPEC /* specific to situation, not fix */
884 /* atomic structure to describe the syntax and more important semantics of an
885 option */
886 struct optdesc {
887 const char *defname; /* default name */
888 const char *nickname; /* usual name */
889 enum e_optcode optcode; /* short form of option name */
890 unsigned int group;
891 enum e_phase phase; /* when this option is to be used */
892 enum e_types type; /* the data type as expected on input, and stored */
893 enum e_func func; /* which function can apply this option, e.g. ioctl(),
894 getsockopt(), or just a bit pattern */
895 int major; /* major id for func: level (SOL_...) for setsockopt(),
896 request for ioctl() */
897 int minor; /* minor id for func: SO_..., IP_..., */
898 long arg3;
901 extern bool xioopts_ignoregroups;
902 extern const struct optname optionnames[];
905 extern int retropt_bool(struct opt *opts, int optcode, bool *result);
906 extern int retropt_short(struct opt *opts, int optcode, short *result);
907 extern int retropt_ushort(struct opt *opts, int optcode, unsigned short *result);
908 extern int retropt_int(struct opt *opts, int optcode, int *result);
909 extern int retropt_uint(struct opt *opts, int optcode, unsigned int *result);
910 extern int retropt_long(struct opt *opts, int optcode, long *result);
911 extern int retropt_ulong(struct opt *opts, int optcode, unsigned long *result);
912 extern int retropt_flag(struct opt *opts, int optcode, flags_t *result);
913 extern int retropt_string(struct opt *opts, int optcode, char **result);
914 extern int retropt_timespec(struct opt *opts, int optcode, struct timespec *result);
915 extern int retropt_bind(struct opt *opts,
916 int af,
917 int socktype,
918 int ipproto,
919 struct sockaddr *sa,
920 socklen_t *salen,
921 int feats, /* TCP etc: 1..address allowed,
922 3..address and port allowed */
923 unsigned long res_opts0, unsigned long res_opts1);
924 extern int applyopts(int fd, struct opt *opts, enum e_phase phase);
925 extern int applyopts2(int fd, struct opt *opts, unsigned int from,
926 unsigned int to);
927 extern int applyopts_flags(struct opt *opts, int group, flags_t *result);
928 extern int applyopts_cloexec(int fd, struct opt *opts);
929 extern int applyopts_early(const char *path, struct opt *opts);
930 extern int applyopts_fchown(int fd, struct opt *opts);
931 extern int applyopts_single(struct single *fd, struct opt *opts, enum e_phase phase);
932 extern int applyopts_offset(struct single *xfd, struct opt *opts);
933 extern int applyopts_signal(struct single *xfd, struct opt *opts);
934 extern int _xio_openlate(struct single *fd, struct opt *opts);
935 extern int parseopts(const char **a, unsigned int groups, struct opt **opts);
936 extern int parseopts_table(const char **a, unsigned int groups,
937 struct opt **opts,
938 const struct optname optionnames[], size_t optionnum);
939 extern struct opt *copyopts(const struct opt *opts, unsigned int groups);
940 extern struct opt *moveopts(struct opt *opts, unsigned int groups);
941 extern int leftopts(const struct opt *opts);
942 extern int showleft(const struct opt *opts);
943 extern int groupbits(int fd);
944 extern int _groupbits(mode_t mode);
945 extern int dropopts(struct opt *opts, unsigned int phase);
946 extern int dropopts2(struct opt *opts, unsigned int from, unsigned int to);
948 #if HAVE_BASIC_UID_T==1
949 # define retropt_uid(o,c,r) retropt_short(o,c,r)
950 #elif HAVE_BASIC_UID_T==2
951 # define retropt_uid(o,c,r) retropt_ushort(o,c,r)
952 #elif HAVE_BASIC_UID_T==3
953 # define retropt_uid(o,c,r) retropt_int(o,c,r)
954 #elif HAVE_BASIC_UID_T==4
955 # define retropt_uid(o,c,r) retropt_uint(o,c,r)
956 #elif HAVE_BASIC_UID_T==5
957 # define retropt_uid(o,c,r) retropt_long(o,c,r)
958 #elif HAVE_BASIC_UID_T==6
959 # define retropt_uid(o,c,r) retropt_ulong(o,c,r)
960 #else
961 # error "HAVE_BASIC_UID_T is out of range: " HAVE_BASIC_UID_T
962 #endif
964 #if HAVE_BASIC_GID_T==1
965 # define retropt_gid(o,c,r) retropt_short(o,c,r)
966 #elif HAVE_BASIC_GID_T==2
967 # define retropt_gid(o,c,r) retropt_ushort(o,c,r)
968 #elif HAVE_BASIC_GID_T==3
969 # define retropt_gid(o,c,r) retropt_int(o,c,r)
970 #elif HAVE_BASIC_GID_T==4
971 # define retropt_gid(o,c,r) retropt_uint(o,c,r)
972 #elif HAVE_BASIC_GID_T==5
973 # define retropt_gid(o,c,r) retropt_long(o,c,r)
974 #elif HAVE_BASIC_GID_T==6
975 # define retropt_gid(o,c,r) retropt_ulong(o,c,r)
976 #else
977 # error "HAVE_BASIC_GID_T is out of range: " HAVE_BASIC_GID_T
978 #endif
980 #if HAVE_BASIC_MODE_T==1
981 # define retropt_mode(o,c,r) retropt_short(o,c,r)
982 #elif HAVE_BASIC_MODE_T==2
983 # define retropt_mode(o,c,r) retropt_ushort(o,c,r)
984 #elif HAVE_BASIC_MODE_T==3
985 # define retropt_mode(o,c,r) retropt_int(o,c,r)
986 #elif HAVE_BASIC_MODE_T==4
987 # define retropt_mode(o,c,r) retropt_uint(o,c,r)
988 #elif HAVE_BASIC_MODE_T==5
989 # define retropt_mode(o,c,r) retropt_long(o,c,r)
990 #elif HAVE_BASIC_MODE_T==6
991 # define retropt_mode(o,c,r) retropt_ulong(o,c,r)
992 #else
993 # error "HAVE_BASIC_MODE_T is out of range: " HAVE_BASIC_MODE_T
994 #endif
996 #endif /* !defined(__xioopts_h_included) */