home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / stream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  20.0 KB  |  739 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_STREAM_H
  11. #define _SYS_STREAM_H
  12.  
  13. #ident    "@(#)/usr/include/sys/stream.h.sl 1.1 4.0 12/08/90 59011 AT&T-USL"
  14.  
  15. /*
  16.  * For source compatibility
  17.  */
  18. #include <sys/vnode.h>
  19. #include <sys/poll.h>
  20. #include <sys/strmdep.h>
  21. #include <sys/cred.h>
  22.  
  23. /*
  24.  * Data queue
  25.  */
  26. #ifdef _STYPES
  27.  
  28. struct    queue {
  29.     struct    qinit    *q_qinfo;    /* procs and limits for queue */
  30.     struct    msgb    *q_first;    /* first data block */
  31.     struct    msgb    *q_last;    /* last data block */
  32.     struct    queue    *q_next;    /* Q of next stream */
  33.     struct    equeue    *q_eq;        /* extended queue info */
  34.     _VOID        *q_ptr;        /* to private data structure */
  35.     ushort        q_count;    /* number of bytes on Q */
  36.     ushort        q_flag;        /* queue state */
  37.     short        q_minpsz;    /* min packet size accepted by */
  38.                     /* this module */
  39.     short        q_maxpsz;    /* max packet size accepted by */
  40.                     /* this module */
  41.     ushort        q_hiwat;    /* queue high water mark */
  42.     ushort        q_lowat;    /* queue low water mark */
  43. };
  44.  
  45. /*
  46.  * Extended queue structure containing information that belongs
  47.  * in the queue, but can't be added because of binary compatibility
  48.  * of STREAMS modules and drivers.
  49.  */
  50. struct equeue {
  51.     struct queue    *eq_link;    /* to next Q for scheduling */
  52.     struct qband    *eq_bandp;    /* separate flow information */
  53.     unsigned char    eq_nband;    /* number of priority bands > 0 */
  54. };
  55.  
  56. #define q_link    q_eq->eq_link
  57. #define q_bandp    q_eq->eq_bandp
  58. #define q_nband    q_eq->eq_nband
  59.  
  60. #else /* large definition */
  61.  
  62. struct    queue {
  63.     struct    qinit    *q_qinfo;    /* procs and limits for queue */
  64.     struct    msgb    *q_first;    /* first data block */
  65.     struct    msgb    *q_last;    /* last data block */
  66.     struct    queue    *q_next;    /* Q of next stream */
  67.     struct    queue    *q_link;    /* to next Q for scheduling */
  68.     _VOID        *q_ptr;        /* to private data structure */
  69.     ulong        q_count;    /* number of bytes on Q */
  70.     ulong        q_flag;        /* queue state */
  71.     long        q_minpsz;    /* min packet size accepted by */
  72.                     /* this module */
  73.     long        q_maxpsz;    /* max packet size accepted by */
  74.                     /* this module */
  75.     ulong        q_hiwat;    /* queue high water mark */
  76.     ulong        q_lowat;    /* queue low water mark */
  77.     struct qband    *q_bandp;    /* separate flow information */
  78.     unsigned char    q_nband;    /* number of priority bands > 0 */
  79.     unsigned char    q_pad1[3];    /* reserved for future use */
  80.     long        q_pad2[2];    /* reserved for future use */
  81. };
  82.  
  83. #endif /* _STYPES */
  84.  
  85. typedef struct queue queue_t;
  86.  
  87. /*
  88.  * Queue flags
  89.  */
  90. #define    QENAB    0x001            /* Queue is already enabled to run */
  91. #define    QWANTR    0x002            /* Someone wants to read Q */
  92. #define    QWANTW    0x004            /* Someone wants to write Q */
  93. #define    QFULL    0x008            /* Q is considered full */
  94. #define    QREADR    0x010            /* This is the reader (first) Q */
  95. #define    QUSE    0x020            /* This queue in use (allocation) */
  96. #define    QNOENB    0x040            /* Don't enable Q via putq */
  97. #define    QOLD    0x080            /* Pre-SVR4 open/close interface */
  98. #define QBACK    0x100            /* queue has been back-enabled */
  99. #define QHLIST    0x200            /* strhead write queue is on "scanqhead" */
  100.  
  101. /*
  102.  * Structure that describes the separate information
  103.  * for each priority band in the queue.
  104.  */
  105. struct qband {
  106.     struct qband    *qb_next;    /* next band's info */
  107.     ulong        qb_count;    /* number of bytes in band */
  108.     struct msgb    *qb_first;    /* beginning of band's data */
  109.     struct msgb    *qb_last;    /* end of band's data */
  110.     ulong        qb_hiwat;    /* high water mark for band */
  111.     ulong        qb_lowat;    /* low water mark for band */
  112.     ulong        qb_flag;    /* see below */
  113.     long        qb_pad1;    /* reserved for future use */
  114. };
  115.  
  116. typedef struct qband qband_t;
  117.  
  118. /*
  119.  * qband flags
  120.  */
  121. #define QB_FULL        0x01        /* band is considered full */
  122. #define QB_WANTW    0x02        /* Someone wants to write to band */
  123. #define QB_BACK        0x04        /* queue has been back-enabled */
  124.  
  125. /*
  126.  * Maximum number of bands.
  127.  */
  128. #define NBAND    256
  129.  
  130. /*
  131.  * Fields that can be manipulated through strqset() and strqget().
  132.  */
  133. typedef enum qfields {
  134.     QHIWAT    = 0,        /* q_hiwat or qb_hiwat */
  135.     QLOWAT    = 1,        /* q_lowat or qb_lowat */
  136.     QMAXPSZ    = 2,        /* q_maxpsz */
  137.     QMINPSZ    = 3,        /* q_minpsz */
  138.     QCOUNT    = 4,        /* q_count or qb_count */
  139.     QFIRST    = 5,        /* q_first or qb_first */
  140.     QLAST    = 6,        /* q_last or qb_last */
  141.     QFLAG    = 7,        /* q_flag or qb_flag */
  142.     QBAD    = 8
  143. } qfields_t;
  144.  
  145. /*
  146.  * Module information structure
  147.  */
  148.  
  149. #ifdef _STYPES
  150.  
  151. struct module_info {
  152.     ushort    mi_idnum;        /* module id number */
  153.     char     *mi_idname;        /* module name */
  154.     short   mi_minpsz;        /* min packet size accepted */
  155.     short   mi_maxpsz;        /* max packet size accepted */
  156.     ushort    mi_hiwat;        /* hi-water mark */
  157.     ushort     mi_lowat;        /* lo-water mark */
  158. };
  159.  
  160. #else /* large definition */
  161.  
  162. struct module_info {
  163.     ushort    mi_idnum;        /* module id number */
  164.     char     *mi_idname;        /* module name */
  165.     long    mi_minpsz;        /* min packet size accepted */
  166.     long    mi_maxpsz;        /* max packet size accepted */
  167.     ulong    mi_hiwat;        /* hi-water mark */
  168.     ulong     mi_lowat;        /* lo-water mark */
  169. };
  170.  
  171. #endif /* _STYPES */
  172.  
  173. /*
  174.  * queue information structure
  175.  */
  176. struct    qinit {
  177.     int    (*qi_putp)();        /* put procedure */
  178.     int    (*qi_srvp)();        /* service procedure */
  179.     int    (*qi_qopen)();        /* called on startup */
  180.     int    (*qi_qclose)();        /* called on finish */
  181.     int    (*qi_qadmin)();        /* for future use */
  182.     struct module_info *qi_minfo;    /* module information structure */
  183.     struct module_stat *qi_mstat;    /* module statistics structure */
  184. };
  185.  
  186. /*
  187.  * Streamtab (used in cdevsw and fmodsw to point to module or driver)
  188.  */
  189.  
  190. struct streamtab {
  191.     struct qinit *st_rdinit;
  192.     struct qinit *st_wrinit;
  193.     struct qinit *st_muxrinit;
  194.     struct qinit *st_muxwinit;
  195. };
  196.  
  197. /*
  198.  * Structure sent to mux drivers to indicate a link.
  199.  */
  200. #ifdef _STYPES
  201.  
  202. struct linkblk {
  203.     queue_t *l_qtop;    /* lowest level write queue of upper stream */
  204.                 /* (set to NULL for persistent links) */
  205.     queue_t *l_qbot;    /* highest level write queue of lower stream */
  206.     int      l_index;    /* index for lower stream. */
  207. };
  208.  
  209. #else /* large definition */
  210.  
  211. struct linkblk {
  212.     queue_t *l_qtop;    /* lowest level write queue of upper stream */
  213.                 /* (set to NULL for persistent links) */
  214.     queue_t *l_qbot;    /* highest level write queue of lower stream */
  215.     int      l_index;    /* index for lower stream. */
  216.     long     l_pad[5];    /* reserved for future use */
  217. };
  218.  
  219. #endif /* _STYPES */
  220.  
  221. /*
  222.  * Class 0 data buffer freeing routine
  223.  */
  224. struct free_rtn {
  225.     void (*free_func)();
  226.     char *free_arg;
  227. };
  228.  
  229. /*
  230.  *  Data block descriptor
  231.  */
  232.  
  233. #ifdef _STYPES
  234.  
  235. struct datab {
  236.     union {
  237.         struct datab    *freep;
  238.         struct free_rtn *frtnp;
  239.     } db_f;
  240.     unsigned char    *db_base;
  241.     unsigned char    *db_lim;
  242.     unsigned char    db_ref;
  243.     unsigned char    db_type;
  244.     unsigned char    db_band;
  245.     unsigned char    db_iswhat;    /* status of the mesg/data/buffer triplet */
  246.     unsigned int    db_size;
  247.     unsigned short    db_flag;
  248.     unsigned short    db_pad;    
  249.     caddr_t        db_msgaddr;     /* triplet mesg header that points to datab */
  250. };
  251.  
  252. #else /* large definition */
  253.  
  254. struct datab {
  255.     union {
  256.         struct datab    *freep;
  257.         struct free_rtn *frtnp;
  258.     } db_f;
  259.     unsigned char    *db_base;
  260.     unsigned char    *db_lim;
  261.     unsigned char    db_ref;
  262.     unsigned char    db_type;
  263.     unsigned char    db_iswhat;    /* status of the mesg/data/buffer triplet */
  264.     unsigned int    db_size;
  265.     long        db_filler;    /* reserved for future use */
  266.     caddr_t        db_msgaddr;    /* triplet mesg header that points to datab */
  267. };
  268.  
  269. #endif /* _STYPES */
  270.  
  271. #define db_freep db_f.freep
  272. #define db_frtnp db_f.frtnp
  273.  
  274. /*
  275.  * Message block descriptor
  276.  */
  277.  
  278. #ifdef _STYPES
  279.  
  280. struct    msgb {
  281.     struct    msgb    *b_next;
  282.     struct  msgb    *b_prev;
  283.     struct    msgb    *b_cont;
  284.     unsigned char    *b_rptr;
  285.     unsigned char    *b_wptr;
  286.     struct datab     *b_datap;
  287. };
  288.  
  289. #define b_band    b_datap->db_band
  290. #define b_flag    b_datap->db_flag
  291.  
  292. #else /* large definition */
  293.  
  294. struct    msgb {
  295.     struct    msgb    *b_next;
  296.     struct  msgb    *b_prev;
  297.     struct    msgb    *b_cont;
  298.     unsigned char    *b_rptr;
  299.     unsigned char    *b_wptr;
  300.     struct datab     *b_datap;
  301.     unsigned char    b_band;
  302.     unsigned char    b_pad1;
  303.     unsigned short    b_flag;
  304.     long        b_pad2;
  305. };
  306.  
  307. #endif /* _STYPES */
  308.  
  309. typedef struct msgb mblk_t;
  310. typedef struct datab dblk_t;
  311. typedef struct free_rtn frtn_t;
  312.  
  313.  
  314.  
  315.  
  316. /*
  317.  * Message flags.  These are interpreted by the stream head.
  318.  */
  319. #define MSGMARK        0x01        /* last byte of message is "marked" */
  320. #define MSGNOLOOP    0x02        /* don't loop message around to */
  321.                     /* write side of stream */
  322. #define MSGDELIM    0x04        /* message is delimited */
  323. #define MSGNOGET    0x08        /* getq does not return message */
  324.  
  325. /*
  326.  * Streams message types.
  327.  */
  328.  
  329. /*
  330.  * Data and protocol messages (regular and priority)
  331.  */
  332. #define    M_DATA        0x00        /* regular data */
  333. #define M_PROTO        0x01        /* protocol control */
  334.  
  335. /*
  336.  * Control messages (regular and priority)
  337.  */
  338. #define    M_BREAK        0x08        /* line break */
  339. #define M_PASSFP    0x09        /* pass file pointer */
  340. #define M_EVENT        0x0a        /* post an event to an event queue */
  341. #define    M_SIG        0x0b        /* generate process signal */
  342. #define    M_DELAY        0x0c        /* real-time xmit delay (1 param) */
  343. #define M_CTL        0x0d        /* device-specific control message */
  344. #define    M_IOCTL        0x0e        /* ioctl; set/get params */
  345. #define M_SETOPTS    0x10        /* set various stream head options */
  346. #define M_RSE        0x11        /* reserved for RSE use only */
  347.  
  348. /*
  349.  * Control messages (high priority; go to head of queue)
  350.  */
  351. #define    M_IOCACK    0x81        /* acknowledge ioctl */
  352. #define    M_IOCNAK    0x82        /* negative ioctl acknowledge */
  353. #define M_PCPROTO    0x83        /* priority proto message */
  354. #define    M_PCSIG        0x84        /* generate process signal */
  355. #define    M_READ        0x85        /* generate read notification */
  356. #define    M_FLUSH        0x86        /* flush your queues */
  357. #define    M_STOP        0x87        /* stop transmission immediately */
  358. #define    M_START        0x88        /* restart transmission after stop */
  359. #define    M_HANGUP    0x89        /* line disconnect */
  360. #define M_ERROR        0x8a        /* fatal error used to set u.u_error */
  361. #define M_COPYIN    0x8b        /* request to copyin data */
  362. #define M_COPYOUT    0x8c        /* request to copyout data */
  363. #define M_IOCDATA    0x8d        /* response to M_COPYIN and M_COPYOUT */
  364. #define M_PCRSE        0x8e        /* reserved for RSE use only */
  365. #define    M_STOPI        0x8f        /* stop reception immediately */
  366. #define    M_STARTI    0x90        /* restart reception after stop */
  367. #define M_PCEVENT    0x91        /* post an event to an event queue */
  368.  
  369. /*
  370.  * Queue message class definitions.  
  371.  */
  372. #define QNORM        0x00        /* normal priority messages */
  373. #define QPCTL        0x80        /* high priority cntrl messages */
  374.  
  375. /*
  376.  *  IOCTL structure - this structure is the format of the M_IOCTL message type.
  377.  */
  378.  
  379. #ifdef _STYPES
  380.  
  381. struct iocblk {
  382.     int     ioc_cmd;        /* ioctl command type */
  383.     o_uid_t    ioc_uid;        /* effective uid of user */
  384.     o_gid_t    ioc_gid;        /* effective gid of user */
  385.     uint    ioc_id;            /* ioctl id */
  386.     uint    ioc_count;        /* count of bytes in data field */
  387.     int    ioc_error;        /* error code */
  388.     int    ioc_rval;        /* return value  */
  389. };
  390.  
  391. #else /* large definition */
  392.  
  393. struct iocblk {
  394.     int     ioc_cmd;        /* ioctl command type */
  395.     cred_t    *ioc_cr;        /* full credentials */
  396.     uint    ioc_id;            /* ioctl id */
  397.     uint    ioc_count;        /* count of bytes in data field */
  398.     int    ioc_error;        /* error code */
  399.     int    ioc_rval;        /* return value  */
  400.     long    ioc_filler[4];        /* reserved for future use */
  401. };
  402.  
  403. #define ioc_uid ioc_cr->cr_uid
  404. #define ioc_gid ioc_cr->cr_gid
  405.  
  406. #endif /* _STYPES */
  407.  
  408. /*
  409.  * structure for the M_COPYIN and M_COPYOUT message types.
  410.  */
  411.  
  412. #ifdef _STYPES
  413.  
  414. struct copyreq {
  415.     int    cq_cmd;            /* ioctl command (from ioc_cmd) */
  416.     o_uid_t    cq_uid;            /* effective uid of user */
  417.     o_gid_t    cq_gid;            /* effective gid of user */
  418.     uint    cq_id;            /* ioctl id (from ioc_id) */
  419.     caddr_t    cq_addr;        /* address to copy data to/from */
  420.     uint    cq_size;        /* number of bytes to copy */
  421.     int    cq_flag;        /* see below */
  422.     mblk_t *cq_private;        /* privtate state information */
  423. };
  424.  
  425. #else /* large defintion */
  426.  
  427. struct copyreq {
  428.     int    cq_cmd;            /* ioctl command (from ioc_cmd) */
  429.     cred_t    *cq_cr;            /* full credentials */
  430.     uint    cq_id;            /* ioctl id (from ioc_id) */
  431.     caddr_t    cq_addr;        /* address to copy data to/from */
  432.     uint    cq_size;        /* number of bytes to copy */
  433.     int    cq_flag;        /* see below */
  434.     mblk_t *cq_private;        /* privtate state information */
  435.     long    cq_filler[4];        /* reserved for future use */
  436. };
  437.  
  438. #define cq_uid cq_cr->cr_uid
  439. #define cq_gid cq_cr->cr_gid
  440.  
  441. #endif /* _STYPES */
  442.  
  443. /* cq_flag values */
  444.  
  445. #define STRCANON    0x01        /* b_cont data block contains */
  446.                     /* canonical format specifier */
  447. #define RECOPY        0x02        /* perform I_STR copyin again, */
  448.                     /* this time using canonical */
  449.                     /* format specifier */
  450.  
  451. /*
  452.  * structure for the M_IOCDATA message type.
  453.  */
  454.  
  455. #ifdef _STYPES
  456.  
  457. struct copyresp {
  458.     int    cp_cmd;            /* ioctl command (from ioc_cmd) */
  459.     o_uid_t    cp_uid;            /* effective uid of user */
  460.     o_gid_t    cp_gid;            /* effective gid of user */
  461.     uint    cp_id;            /* ioctl id (from ioc_id) */
  462.     caddr_t    cp_rval;        /* status of request: 0 -> success */
  463.                     /*             non-zero -> failure */
  464.     uint    cp_pad1;        /* reserved */
  465.     int    cp_pad2;        /* reserved */
  466.     mblk_t *cp_private;        /* private state information */
  467. };
  468.  
  469. #else /* large definition */
  470.  
  471. struct copyresp {
  472.     int    cp_cmd;            /* ioctl command (from ioc_cmd) */
  473.     cred_t    *cp_cr;            /* full credentials */
  474.     uint    cp_id;            /* ioctl id (from ioc_id) */
  475.     caddr_t    cp_rval;        /* status of request: 0 -> success */
  476.                     /*             non-zero -> failure */
  477.     uint    cp_pad1;        /* reserved */
  478.     int    cp_pad2;        /* reserved */
  479.     mblk_t *cp_private;        /* private state information */
  480.     long    cp_filler[4];        /* reserved for future use */
  481. };
  482.  
  483. #define cp_uid cp_cr->cr_uid
  484. #define cp_gid cp_cr->cr_gid
  485.  
  486. #endif /* _STYPES */
  487.  
  488. /*
  489.  * Options structure for M_SETOPTS message.  This is sent upstream
  490.  * by a module or driver to set stream head options.
  491.  */
  492.  
  493. #ifdef _STYPES
  494.  
  495. struct stroptions {
  496.     short    so_flags;        /* options to set */
  497.     short    so_readopt;        /* read option */
  498.     ushort    so_wroff;        /* write offset */
  499.     short    so_minpsz;        /* minimum read packet size */
  500.     short    so_maxpsz;        /* maximum read packet size */
  501.     ushort    so_hiwat;        /* read queue high water mark */
  502.     ushort    so_lowat;        /* read queue low water mark */
  503.     unsigned char so_band;        /* band for water marks */
  504. };
  505.  
  506. #else /* large definition */
  507.  
  508. struct stroptions {
  509.     ulong    so_flags;        /* options to set */
  510.     short    so_readopt;        /* read option */
  511.     ushort    so_wroff;        /* write offset */
  512.     long    so_minpsz;        /* minimum read packet size */
  513.     long    so_maxpsz;        /* maximum read packet size */
  514.     ulong    so_hiwat;        /* read queue high water mark */
  515.     ulong    so_lowat;        /* read queue low water mark */
  516.     unsigned char so_band;        /* band for water marks */
  517. };
  518.  
  519. #endif /* _STYPES */
  520.  
  521. /* flags for stream options set message */
  522.  
  523. #define SO_ALL        0x003f    /* set all old options */
  524. #define SO_READOPT    0x0001    /* set read option */
  525. #define SO_WROFF    0x0002    /* set write offset */
  526. #define SO_MINPSZ    0x0004    /* set min packet size */
  527. #define SO_MAXPSZ    0x0008    /* set max packet size */
  528. #define SO_HIWAT    0x0010    /* set high water mark */
  529. #define SO_LOWAT    0x0020    /* set low water mark */
  530. #define SO_MREADON      0x0040    /* set read notification ON */
  531. #define SO_MREADOFF     0x0080    /* set read notification OFF */
  532. #define SO_NDELON    0x0100    /* old TTY semantics for NDELAY reads/writes */
  533. #define SO_NDELOFF      0x0200    /* STREAMS semantics for NDELAY reads/writes */
  534. #define SO_ISTTY    0x0400    /* the stream is acting as a terminal */
  535. #define SO_ISNTTY    0x0800    /* the stream is not acting as a terminal */
  536. #define SO_TOSTOP    0x1000    /* stop on background writes to this stream */
  537. #define SO_TONSTOP    0x2000    /* do not stop on background writes to stream */
  538. #define SO_BAND        0x4000    /* water marks affect band */
  539. #define SO_DELIM    0x8000    /* messages are delimited */
  540. #ifndef _STYPES
  541. #define SO_NODELIM    0x010000    /* turn off delimiters */
  542. #define SO_STRHOLD    0x020000    /* enable strwrite message coalescing */
  543. #endif /* _STYPES */
  544.  
  545. /*
  546.  * Structure for M_EVENT and M_PCEVENT messages.  This is sent upstream
  547.  * by a module or driver to have the stream head generate a call to the
  548.  * General Events subsystem.  It is also contained in the first M_DATA
  549.  * block of an M_IOCTL message for the I_STREV and I_UNSTREV ioctls.
  550.  */
  551. struct str_evmsg {
  552.     long         sv_event;    /* the event (module-specific) */
  553.     vnode_t        *sv_vp;        /* vnode pointer of event queue */
  554.     long         sv_eid;    /* same as ev_eid */
  555.     long         sv_evpri;    /* same as ev_pri */
  556.     long         sv_flags;    /* same as ev_flags */
  557.     uid_t         sv_uid;    /* user id of posting process */
  558.     pid_t         sv_pid;    /* process id of posting process */
  559.     hostid_t     sv_hostid;    /* host id of posting process */
  560.     long         sv_pad[4];    /* reserved for future use */
  561. };
  562.  
  563. /*
  564.  * Miscellaneous parameters and flags.
  565.  */
  566.  
  567. /*
  568.  * New code for two-byte M_ERROR message.
  569.  */
  570. #define NOERROR    ((unsigned char)-1)
  571.  
  572. /*
  573.  * Values for stream flag in open to indicate module open, clone open;
  574.  * return value for failure.
  575.  */
  576. #define MODOPEN     0x1        /* open as a module */
  577. #define CLONEOPEN    0x2        /* open for clone, pick own minor device */
  578. #define OPENFAIL    -1        /* returned for open failure */
  579.  
  580. /*
  581.  * Priority definitions for block allocation.
  582.  */
  583. #define BPRI_LO        1
  584. #define BPRI_MED    2
  585. #define BPRI_HI        3
  586.  
  587. /*
  588.  * Value for packet size that denotes infinity
  589.  */
  590. #define INFPSZ        -1
  591.  
  592. /*
  593.  * Flags for flushq()
  594.  */
  595. #define FLUSHALL    1    /* flush all messages */
  596. #define FLUSHDATA    0    /* don't flush control messages */
  597.  
  598. /*
  599.  * Flag for transparent ioctls
  600.  */
  601. #define TRANSPARENT    (unsigned int)(-1)
  602.  
  603. /*
  604.  * Sleep priorities for stream io
  605.  */
  606. #define    STIPRI    PZERO+3
  607. #define    STOPRI    PZERO+3
  608.  
  609. /*
  610.  * Stream head default high/low water marks 
  611.  */
  612. #define STRHIGH 5120
  613. #define STRLOW    1024
  614.  
  615. /*
  616.  * Block allocation parameters
  617.  */
  618. #define MAXIOCBSZ    1024        /* max ioctl data block size */
  619.  
  620. /*
  621.  * amount of time to hold small messages in strwrite hoping to to
  622.  * able to append more data from a subsequent write.  one tick min.
  623.  */
  624. #define STRSCANP    ((10*HZ+999)/1000)    /* 10 ms in ticks */
  625.  
  626. /*
  627.  * Definitions of Streams macros and function interfaces.
  628.  */
  629.  
  630. /*
  631.  * Definition of spl function needed to provide critical region protection
  632.  * for streams drivers and modules.
  633.  */
  634. #define splstr() spl6()
  635.  
  636. /*
  637.  * canenable - check if queue can be enabled by putq().
  638.  */
  639. #define canenable(q)    !((q)->q_flag & QNOENB)
  640.  
  641. /*
  642.  * Finding related queues
  643.  */
  644. #define    OTHERQ(q)    ((q)->q_flag&QREADR? (q)+1: (q)-1)
  645. #define    WR(q)        ((q)+1)
  646. #define    RD(q)        ((q)-1)
  647. #define SAMESTR(q)    (((q)->q_next) && (((q)->q_flag&QREADR) == ((q)->q_next->q_flag&QREADR)))
  648.  
  649. /*
  650.  * Put a message of the next queue of the given queue.
  651.  */
  652. #define putnext(q, mp)    ((*(q)->q_next->q_qinfo->qi_putp)((q)->q_next, (mp)))
  653.  
  654. /*
  655.  * Test if data block type is one of the data messages (i.e. not a control
  656.  * message).
  657.  */
  658. #define datamsg(type) ((type) == M_DATA || (type) == M_PROTO || (type) == M_PCPROTO || (type) == M_DELAY)
  659.  
  660. /*
  661.  * Extract queue class of message block.
  662.  */
  663. #define queclass(bp) (((bp)->b_datap->db_type >= QPCTL) ? QPCTL : QNORM)
  664.  
  665. /*
  666.  * Align address on next lower word boundary.
  667.  */
  668. #define straln(a)    (caddr_t)((long)(a) & ~(sizeof(int)-1))
  669.  
  670. /*
  671.  * Find the max size of data block.
  672.  */
  673. #define bpsize(bp) ((unsigned int)(bp->b_datap->db_lim - bp->b_datap->db_base))
  674.  
  675. /*
  676.  * declarations of common routines
  677.  */
  678. extern mblk_t *allocb();
  679. extern mblk_t *esballoc();
  680. extern int esbbcall();
  681. extern int testb();
  682. extern int bufcall();
  683. extern void freeb();
  684. extern void freemsg();
  685. extern mblk_t *dupb();
  686. extern mblk_t *dupmsg();
  687. extern mblk_t *copyb();
  688. extern mblk_t *copymsg();
  689. extern void linkb();
  690. extern mblk_t *unlinkb();
  691. extern mblk_t *rmvb();
  692. extern int pullupmsg();
  693. extern int adjmsg();
  694. extern int msgdsize();
  695. extern mblk_t *getq();
  696. extern void rmvq();
  697. extern void flushq();
  698. extern void flushband();
  699. extern int canput();
  700. extern int bcanput();
  701. extern int putq();
  702. extern int putbq();
  703. extern int insq();
  704. extern int putctl();
  705. extern int putctl1();
  706. extern queue_t *backq();
  707. extern void qreply();
  708. extern void qenable();
  709. extern int qsize();
  710. extern void noenable();
  711. extern void enableok();
  712. extern ushort getmid();
  713. extern int strqset();
  714. extern int strqget();
  715. extern void unbufcall();
  716.  
  717. /*
  718.  * shared or externally configured data structures
  719.  */
  720. extern int strmsgsz;            /* maximum stream message size */
  721. extern int strctlsz;            /* maximum size of ctl part of message */
  722. extern int nstrpush;            /* maxmimum number of pushes allowed */
  723. extern struct strstat strst;        /* STREAMS statistics structure */
  724. extern char queueflag;          /* set iff inside queuerun() */
  725.  
  726. /*
  727.  * Structure for 386 ioctls requiring user context
  728. */
  729. struct  v86blk {
  730.     struct  proc    *v86_u_procp;
  731.     ulong   v86_u_renv ;
  732.     pid_t   v86_p_pid;
  733.     pid_t   v86_p_ppid;
  734.     struct cred *v86_p_cred;
  735.     struct  v86dat  *v86_p_v86;
  736. };
  737.  
  738. #endif    /* _SYS_STREAM_H */
  739.