nexmon – Blame information for rev 1

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