|
|
#include <sys/stream.h> #include <sys/stropts.h> #include <sys/ddi.h>
ulong_t so_flags; ushort_t so_readopt; ushort_t so_wroff; long so_minpsz; long so_maxpsz; ulong_t so_hiwat; ulong_t so_lowat; uchar so_band;
so_flags
The first set of flags determines how data messages are treated when they are read:
The second set of flags determines how protocol messages
M_PROTO(D7str)
and
M_PCPROTO(D7str)
protocol messages are treated during a
read( )
operation:
set the read mode (see
read)
as specified by the value of
so_readopt
:
One of the last three flags can be exclusive ORed with one of the first three flags.
so_wroff
into the first
message block of all M_DATA messages created
as a result of a
write
system call.
The same offset is inserted into the first M_DATA
message block, if any, of all messages created
by a
putmsg
system call.
The default offset is 0.
The offset must be less than
the maximum message buffer size (system-dependent).
Under certain circumstances, a write offset may not be inserted.
A module or driver must test
that b_rptr
in the mblk_t structure
is greater than db_base
in the dblk_t structure
to determine whether an offset
has been inserted in the first message block.
The check is:
mblk_t *bp;if (bp->b_rptr > bp->b_datap->db_datap) { /* SO_WROFF has been done */ }
so_minpsz
.
This value is advisory for the module immediately below the Stream head.
It is intended to limit the size of M_DATA messages
that the module should put to the Stream head.
There is no intended minimum size for other message types.
The default value in the Stream head is 0.
so_maxpsz
.
This value is advisory for the module immediately below the Stream head.
It is intended to limit the size of M_DATA messages
that the module should put to the Stream head.
There is no intended maximum size for other message types.
The default value in the Stream head is INFPSZ,
the maximum STREAMS allows.
q_hiwat
in the queue structure,
qb_hiwat
in the qband structure)
on the Stream head read queue
to the value specified in so_hiwat
.
q_lowat
in the queue structure,
qb_lowat
in the qband structure)
on the Stream head read queue to the value
specified in so_lowat
.
If both SO_MREADON and SO_MREADOFF
are set in so_flags
,
SO_MREADOFF has precedence.
This is the default.
If both SO_MREADON and SO_MREADOFF
are set in so_flags
,
SO_MREADOFF has precedence.
Regardless of the state of O_NDELAY (or O_NONBLOCK), a write( ) will block on flow control and will block if buffers are not available.
If O_NDELAY (or O_NONBLOCK) is set, a write( ) will return -1 and set EAGAIN if flow control is in effect when the call is received. It will block if buffers are not available. If O_NDELAY (or O_NONBLOCK) is set and part of the buffer has been written and a flow control or buffers not available condition is encountered, write( ) will terminate and return the number of bytes written.
If O_NDELAY (or O_NONBLOCK)
is clear, a
write( )
will block on flow control
and will block if buffers are not available.
This is the default.
If both O_NDELAY (or O_NONBLOCK)
are set in so_flags
,
SO_NDELOFF has precedence.
In the STREAMS -based pipe mechanism, the behavior of read( ) and write( ) is different for the O_NDELAY (or O_NONBLOCK) flags. See read and write for details.
so_band
member contains the priority band number
to which the so_hiwat
and so_lowat
members pertain.
If the SO_BAND flag is not set and the SO_HIWAT and SO_LOWAT flags are on, the normal high and low water marks are affected. The SO_BAND flag has no effect if SO_HIWAT and SO_LOWAT flags are off.
Only one band's water marks can be updated with a single M_SETOPTS message.
Note that band 0 is the same as normal priority messages.
For SO_ISTTY, the Stream may or may not be allocated as a controlling terminal via an M_SETOPTS message that arrives upstream during open processing. If the Stream head is opened before receiving this message, the Stream will not be allocated as a controlling terminal until it is queued again by a session leader.
SO_TOSTOP and SO_TONSTOP are used with job control.
so_wroff
so_minpsz
so_maxpsz
so_hiwat
so_lowat
so_band
The following options are supported in ODDI but are not supported in DDI.
The RPROTNORM, RPROTDAT, and RPROTDIS flags to SO_READOPT are not supported in ODDI version 1 and 2 STREAMS implementations. For backwards compatibility, the first three flags can be used without any of the last three flags to preserve the behavior of read with control messages from earlier ODDI versions.
ODDI 1 and 2 support a slightly different stroptions structure:
struct stroptions /* ODDI 1,2 */ { short so_flags; /* options to set */ short so_readopt; /* read option */ ushort so_wroff; /* write offset */ short so_minpsz; /* minimum read packet size*/ short so_maxpsz; /* maximum read packet size*/ ushort so_hiwat; /*read queue high-watermark*/ ushort so_lowat; /*read queue low-water mark*/ };The old structure definition is supported and handled by the ODDI 3 and later Stream head for backwards compatibility. The new structure is source code compatible, meaning that any driver or module that is recompiled will use the new structure, even if no code modifications are made.
The following tables compare the stroptions structure members and supported options for all DDI and ODDI versions:
stroptions structure members for DDI and ODDI
Member | DDI 8 | DDI 7 | ODDI 3,4,5 | ODDI 1,2 |
---|---|---|---|---|
so_flags | ulong | ulong | ulong | short |
so_readopt | ushort | short | short | short |
so_wroff | ushort | ushort | ushort | ushort |
so_minpsz | long | long | long | short |
so_maxpasz | long | long | long | short |
so_hiwat | ulong | ulong | ulong | ushort |
so_lowat | ulong | ulong | ulong | ushort |
so_band | uchar | uchar | uchar | -- |
stroptions options for DDI and ODDI
options | DDI 8 | DDI 7 | ODDI 3,4,5 | ODDI 1,2 |
---|---|---|---|---|
SO_READOPT | Yes | Yes | Yes | Yes |
RNORM | Yes | Yes | Yes | Yes |
RMSGD | Yes | Yes | Yes | Yes |
RMSGN | Yes | Yes | Yes | Yes |
RPROTNORM | Yes | Yes | Yes | -- |
RPROTDAT | Yes | Yes | Yes | -- |
RPROTDIS | Yes | Yes | Yes | -- |
SO_ALL | Yes | Yes | Yes | Yes |
SO_WROFF | Yes | Yes | Yes | Yes |
SO_MINPSZ | Yes | Yes | Yes | Yes |
SO_MAXPSZ | Yes | Yes | Yes | Yes |
SO_HIWAT | Yes | Yes | Yes | Yes |
SO_LOWAT | Yes | Yes | Yes | Yes |
SO_MREADON | Yes | Yes | Yes | Yes |
SO_MREADOFF | Yes | Yes | Yes | Yes |
SO_NDELON | Yes | Yes | Yes | Yes |
SO_NDELOFF | Yes | Yes | Yes | Yes |
SO_BAND | Yes | Yes | Yes | Yes |
SO_ISTTY | Yes | Yes | -- | -- |
SO_ISNTTY | Yes | Yes | -- | -- |
SO_TOSTOP | Yes | Yes | -- | -- |
SO_TONSTOP | Yes | Yes | -- | -- |
SO_NSWITCHON | -- | -- | Yes | -- |
SO_NSWITCHOFF | -- | -- | Yes | -- |