xref: /titanic_50/usr/src/uts/common/sys/stropts.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef _SYS_STROPTS_H
32 #define	_SYS_STROPTS_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 11.20	*/
35 
36 #include <sys/feature_tests.h>
37 #include <sys/types.h>
38 /*
39  * For FMNAMESZ define.
40  */
41 #include <sys/conf.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Write options
49  */
50 #define	SNDZERO		0x001		/* send a zero length message */
51 #define	SNDPIPE		0x002		/* send SIGPIPE on write and */
52 					/* putmsg if sd_werror is set */
53 
54 /*
55  * Read options
56  */
57 #define	RNORM		0x000		/* read msg norm */
58 #define	RMSGD		0x001		/* read msg discard */
59 #define	RMSGN		0x002		/* read msg no discard */
60 
61 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
62 #define	RMODEMASK	0x003		/* all above bits */
63 #endif
64 
65 /*
66  * These next three read options are added for the sake of
67  * user-level transparency.  RPROTDAT will cause the stream head
68  * to treat the contents of M_PROTO and M_PCPROTO message blocks
69  * as data.  RPROTDIS will prevent the stream head from failing
70  * a read with EBADMSG if an M_PROTO or M_PCPROTO message is on
71  * the front of the stream head read queue.  Rather, the protocol
72  * blocks will be silently discarded and the data associated with
73  * the message (in linked M_DATA blocks), if any, will be delivered
74  * to the user.  RPROTNORM sets the default behavior, where read
75  * will fail with EBADMSG if an M_PROTO or M_PCPROTO are at the
76  * stream head.
77  */
78 #define	RPROTDAT	0x004		/* read protocol messages as data */
79 #define	RPROTDIS	0x008		/* discard protocol messages, but */
80 					/* read data portion */
81 #define	RPROTNORM	0x010
82 
83 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
84 #define	RPROTMASK	0x01c		/* all RPROT bits */
85 
86 /*
87  * The next read option is used so that a TPI aware module can tell the
88  * stream head to not flush M_PCPROTO messages when processing a read side
89  * flush. This will avoid problems where a flush removes a T_OK_ACK.
90  */
91 #define	RFLUSHMASK	0x020		/* all RFLUSH bits */
92 
93 #define	RFLUSHPCPROT	0x020		/* do not flush PCPROTOs */
94 
95 #endif
96 
97 /*
98  * Error options
99  */
100 
101 /*
102  * Error options to adjust the stream head error behavior with respect
103  * to M_ERROR message for read and write side errors respectively.
104  * The normal case is that the read/write side error is
105  * persistent and these options allow the application or streams module/driver
106  * to specify that errors are nonpersistent. In this case the error is cleared
107  * after having been returned to read(), getmsg(), ioctl(), write(), putmsg(),
108  * etc.
109  */
110 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
111 #define	RERRNORM	0x001		/* Normal, persistent read errors */
112 #define	RERRNONPERSIST	0x002		/* Nonpersistent read errors */
113 
114 #define	RERRMASK	(RERRNORM|RERRNONPERSIST)
115 
116 #define	WERRNORM	0x004		/* Normal, persistent write errors */
117 #define	WERRNONPERSIST	0x008		/* Nonpersistent write errors */
118 
119 #define	WERRMASK	(WERRNORM|WERRNONPERSIST)
120 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
121 
122 /*
123  * Flush options
124  */
125 
126 #define	FLUSHR		0x01		/* flush read queue */
127 #define	FLUSHW		0x02		/* flush write queue */
128 #define	FLUSHRW		0x03		/* flush both queues */
129 #define	FLUSHBAND	0x04		/* flush only band specified */
130 					/* in next byte */
131 /*
132  * Copy options for M_SETOPS/SO_COPYOPT
133  */
134 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
135 #define	ZCVMSAFE	0x01		/* safe to borrow file (segmapped) */
136 					/* pages instead of bcopy */
137 #define	ZCVMUNSAFE	0x02		/* unsafe to borrow file pages */
138 #define	COPYCACHED	0x04		/* copy should NOT bypass cache */
139 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
140 
141 /*
142  * Events for which the SIGPOLL signal is to be sent.
143  */
144 #define	S_INPUT		0x0001		/* any msg but hipri on read Q */
145 #define	S_HIPRI		0x0002		/* high priority msg on read Q */
146 #define	S_OUTPUT	0x0004		/* write Q no longer full */
147 #define	S_MSG		0x0008		/* signal msg at front of read Q */
148 #define	S_ERROR		0x0010		/* error msg arrived at stream head */
149 #define	S_HANGUP	0x0020		/* hangup msg arrived at stream head */
150 #define	S_RDNORM	0x0040		/* normal msg on read Q */
151 #define	S_WRNORM	S_OUTPUT
152 #define	S_RDBAND	0x0080		/* out of band msg on read Q */
153 #define	S_WRBAND	0x0100		/* can write out of band */
154 #define	S_BANDURG	0x0200		/* modifier to S_RDBAND, to generate */
155 					/* SIGURG instead of SIGPOLL */
156 
157 /*
158  * Flags for getmsg() and putmsg() syscall arguments.
159  * "RS" stands for recv/send.  The system calls were originally called
160  * recv() and send(), but were renamed to avoid confusion with the BSD
161  * calls of the same name.  A value of zero will cause getmsg() to return
162  * the first message on the stream head read queue and putmsg() to send
163  * a normal priority message.
164  *
165  * Flags for strmakemsg() arguments (should define strmakemsg() flags).
166  * Used to determine the message type of the control part of a message,
167  * if RS_HIPRI, M_PCPROTO, else M_PROTO.
168  */
169 
170 #define	RS_HIPRI	0x01		/* send/recv high priority message */
171 #define	STRUIO_POSTPONE	0x08		/* postpone copyin() for struio() */
172 
173 /*
174  * Flags for getpmsg() and putpmsg() syscall arguments.
175  */
176 
177 /*
178  * These are settable by the user and will be set on return
179  * to indicate the priority of message received.
180  */
181 #define	MSG_HIPRI	0x01		/* send/recv high priority message */
182 #define	MSG_ANY		0x02		/* recv any messages */
183 #define	MSG_BAND	0x04		/* recv messages from specified band */
184 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
185 /*
186  * This is a private flag passed by libc to kernel to
187  * identify that it is a XPG4_2 application. No
188  * applications need to know about this flag.
189  */
190 #define	MSG_XPG4	0x08
191 #endif
192 
193 #ifdef _KERNEL
194 
195 /*
196  * Additional private flags for kstrgetmsg and kstrputmsg.
197  * These must be bit-wise distinct from the above MSG flags.
198  */
199 #define	MSG_IPEEK	0x10		/* Peek - don't remove the message */
200 #define	MSG_DISCARDTAIL	0x20		/* Discard tail if it doesn't fit */
201 #define	MSG_HOLDSIG	0x40		/* Ignore signals. */
202 #define	MSG_IGNERROR	0x80		/* Ignore stream head errors */
203 #define	MSG_DELAYERROR	0x100		/* Delay error check until we sleep */
204 #define	MSG_IGNFLOW	0x200		/* Ignore flow control */
205 #define	MSG_NOMARK	0x400		/* Do not read if message is marked */
206 
207 #endif /* _KERNEL */
208 
209 /*
210  * Flags returned as value of getmsg() and getpmsg() syscall.
211  */
212 #define	MORECTL		1		/* more ctl info is left in message */
213 #define	MOREDATA	2		/* more data is left in message */
214 
215 /*
216  * Define to indicate that all multiplexors beneath a stream should
217  * be unlinked.
218  */
219 #define	MUXID_ALL	(-1)
220 
221 /*
222  * Flag definitions for the I_ATMARK ioctl.
223  */
224 #define	ANYMARK		0x01
225 #define	LASTMARK	0x02
226 
227 /*
228  *  Stream Ioctl defines
229  */
230 #define	STR		('S'<<8)
231 /* (STR|000) in use */
232 #define	I_NREAD		(STR|01)
233 #define	I_PUSH		(STR|02)
234 #define	I_POP		(STR|03)
235 #define	I_LOOK		(STR|04)
236 #define	I_FLUSH		(STR|05)
237 #define	I_SRDOPT	(STR|06)
238 #define	I_GRDOPT	(STR|07)
239 #define	I_STR		(STR|010)
240 #define	I_SETSIG	(STR|011)
241 #define	I_GETSIG	(STR|012)
242 #define	I_FIND		(STR|013)
243 #define	I_LINK		(STR|014)
244 #define	I_UNLINK	(STR|015)
245 /* (STR|016) in use */
246 #define	I_PEEK		(STR|017)
247 #define	I_FDINSERT	(STR|020)
248 #define	I_SENDFD	(STR|021)
249 
250 #if defined(_KERNEL)
251 #define	I_RECVFD	(STR|022)
252 #define	I_E_RECVFD	(STR|016)
253 #else	/* user level definition */
254 #define	I_RECVFD	(STR|016)	/* maps to kernel I_E_RECVFD */
255 #endif /* defined(_KERNEL) */
256 
257 #define	I_SWROPT	(STR|023)
258 #define	I_GWROPT	(STR|024)
259 #define	I_LIST		(STR|025)
260 #define	I_PLINK		(STR|026)
261 #define	I_PUNLINK	(STR|027)
262 #define	I_ANCHOR	(STR|030)
263 #define	I_FLUSHBAND	(STR|034)
264 #define	I_CKBAND	(STR|035)
265 #define	I_GETBAND	(STR|036)
266 #define	I_ATMARK	(STR|037)
267 #define	I_SETCLTIME	(STR|040)
268 #define	I_GETCLTIME	(STR|041)
269 #define	I_CANPUT	(STR|042)
270 #define	I_SERROPT	(STR|043)
271 #define	I_GERROPT	(STR|044)
272 #define	I_ESETSIG	(STR|045)
273 #define	I_EGETSIG	(STR|046)
274 
275 #define	__I_PUSH_NOCTTY	(STR|047)	/* push module, no cntrl tty */
276 
277 /*
278  * IOCTLs (STR|050) - (STR|055) are available for use.
279  */
280 
281 #define	_I_MUXID2FD	(STR|056)	/* Private, get a fd from a muxid */
282 #define	_I_INSERT	(STR|057)	/* Private, insert a module */
283 #define	_I_REMOVE	(STR|060)	/* Private, remove a module */
284 
285 #define	_I_GETPEERCRED	(STR|061)	/* Private, get peer cred */
286 
287 /* Private Layered Driver ioctl's */
288 #define	_I_PLINK_LH	(STR|062)
289 
290 /*
291  * User level ioctl format for ioctls that go downstream (I_STR)
292  */
293 struct strioctl {
294 	int 	ic_cmd;			/* command */
295 	int	ic_timout;		/* timeout value */
296 	int	ic_len;			/* length of data */
297 	char	*ic_dp;			/* pointer to data */
298 };
299 
300 #if defined(_SYSCALL32)
301 
302 struct strioctl32 {
303 	int32_t 	ic_cmd;			/* command */
304 	int32_t		ic_timout;		/* timeout value */
305 	int32_t		ic_len;			/* length of data */
306 	caddr32_t	ic_dp;			/* pointer to data */
307 };
308 
309 #endif /* _SYSCALL32 */
310 
311 /*
312  * Value for timeouts (ioctl, select) that denotes infinity
313  */
314 #define	_INFTIM		-1
315 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
316 #define	INFTIM		_INFTIM
317 #endif
318 
319 /*
320  * Stream buffer structure for putmsg and getmsg system calls
321  */
322 struct strbuf {
323 	int	maxlen;		/* no. of bytes in buffer */
324 	int	len;		/* no. of bytes returned */
325 	caddr_t	buf;		/* pointer to data */
326 };
327 
328 #if defined(_SYSCALL32)
329 
330 struct strbuf32 {
331 	int32_t	maxlen;		/* no. of bytes in buffer */
332 	int32_t	len;		/* no. of bytes returned */
333 	caddr32_t buf;		/* pointer to data */
334 };
335 #endif /* _SYSCALL32 */
336 
337 /*
338  * Stream I_PEEK ioctl format
339  */
340 struct strpeek {
341 	struct strbuf	ctlbuf;
342 	struct strbuf	databuf;
343 	t_uscalar_t	flags;
344 };
345 
346 #if defined(_SYSCALL32)
347 
348 struct strpeek32 {
349 	struct strbuf32	ctlbuf;
350 	struct strbuf32	databuf;
351 	uint32_t	flags;
352 };
353 
354 #endif /* _SYSCALL32 */
355 
356 /*
357  * Stream I_FDINSERT ioctl format
358  */
359 struct strfdinsert {
360 	struct strbuf	ctlbuf;
361 	struct strbuf	databuf;
362 	t_uscalar_t	flags;
363 	int		fildes;
364 	int		offset;
365 };
366 
367 #if defined(_SYSCALL32)
368 
369 struct strfdinsert32 {
370 	struct strbuf32	ctlbuf;
371 	struct strbuf32	databuf;
372 	uint32_t	flags;
373 	int32_t		fildes;
374 	int32_t		offset;
375 };
376 
377 #endif /* _SYSCALL32 */
378 
379 /*
380  * Receive file descriptor structure
381  */
382 #if defined(_KERNEL)
383 
384 struct o_strrecvfd {	/* SVR3 syscall structure */
385 	int fd;
386 	o_uid_t uid;		/* always ushort */
387 	o_gid_t gid;
388 	char fill[8];
389 };
390 
391 /*
392  * Although EFT is enabled in the kernel we kept the following definition
393  * to support an EFT application on a 4.0 non-EFT system.
394  */
395 struct k_strrecvfd {	/* SVR4 expanded syscall interface structure */
396 	struct file *fp;
397 	uid_t uid;
398 	gid_t gid;
399 	char fill[8];
400 };
401 
402 /*
403  * Private _I_GETPEERCRED data.
404  */
405 
406 typedef struct k_peercred {
407 	cred_t	*pc_cr;
408 	pid_t	pc_cpid;
409 } k_peercred_t;
410 
411 #endif	/* defined(_KERNEL) */
412 
413 struct strrecvfd {
414 	int fd;
415 	uid_t uid;
416 	gid_t gid;
417 #if defined(_XPG4_2)
418 	char __fill[8];
419 #else
420 	char fill[8];
421 #endif
422 };
423 
424 
425 /*
426  * For I_LIST ioctl.
427  */
428 struct str_mlist {
429 	char l_name[FMNAMESZ+1];
430 };
431 
432 struct str_list {
433 	int sl_nmods;
434 	struct str_mlist *sl_modlist;
435 };
436 
437 #if defined(_SYSCALL32)
438 
439 struct str_list32 {
440 	int32_t 	sl_nmods;
441 	caddr32_t 	sl_modlist;
442 };
443 
444 #endif /* _SYSCALL32 */
445 
446 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
447 /*
448  * Private, for _I_INSERT/_I_REMOVE ioctl.
449  */
450 struct strmodconf {
451 	int	pos;			/* Position to be inserted/removed. */
452 	caddr_t	mod_name;		/* Name of module. */
453 };
454 
455 #if defined(_SYSCALL32)
456 
457 struct strmodconf32 {
458 	int32_t		pos;
459 	caddr32_t	mod_name;
460 };
461 
462 #endif /* _SYSCALL32 */
463 #endif /* (_XPG4_2) || defined(__EXTENSIONS__) */
464 
465 /*
466  * For I_FLUSHBAND ioctl.  Describes the priority
467  * band for which the operation applies.
468  */
469 struct bandinfo {
470 	unsigned char	bi_pri;
471 	int		bi_flag;
472 };
473 
474 
475 /*
476  * The argument for I_ESETSIG and I_EGETSIG ioctls.
477  */
478 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
479 struct strsigset {
480 	pid_t		ss_pid;		/* pgrp if negative */
481 	int		ss_events;	/* S_ events */
482 };
483 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
484 
485 #ifdef	_XPG4_2
486 #ifdef	__PRAGMA_REDEFINE_EXTNAME
487 
488 #pragma	redefine_extname putmsg		__xpg4_putmsg
489 #pragma	redefine_extname putpmsg	__xpg4_putpmsg
490 
491 #else	/* __PRAGMA_REDEFINE_EXTNAME */
492 
493 #define	putmsg	__xpg4_putmsg
494 #define	putpmsg	__xpg4_putpmsg
495 
496 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
497 #endif	/* _XPG4_2 */
498 
499 #ifdef	__cplusplus
500 }
501 #endif
502 
503 #endif	/* _SYS_STROPTS_H */
504