home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / nxt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  7.3 KB  |  232 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_NXT_H
  11. #define _SYS_NXT_H
  12.  
  13. #ident    "@(#)/usr/include/sys/nxt.h.sl 1.1 4.0 12/08/90 63615 AT&T-USL"
  14.  
  15. /*
  16.  * nxt.h -- Defines for the windowing terminal streams xt driver. See xt(7).
  17.  */
  18.  
  19. #define    NPCBUFS    2            /* number of saved packets in proto*/
  20. #define    SEQMOD    8            /* sequence number modulus */
  21. #define    SEQBITS    3            /* bits for sequence number */
  22. #define    MAXPCHAN    8        /* number of chans per xt */
  23. #define    CHANBITS    3        /* number of bits for channel number */
  24. #define    LINK(dev)    ((dev >> CHANBITS) & (0xff >> CHANBITS))
  25. #define    SEQMOD        8        /* Seq num modulus */
  26.  
  27. #define    XTSCANRATE    (2*HZ)        /* call xtscan @ 2 seconds */
  28. #define XTSCANSLOP    (HZ + (HZ/2))     /* Increment to exact calculated
  29.                        retransmission timeout
  30.                        to allow for turnaround, the
  31.                        terminal being slow, etc. */
  32.  
  33. #define    SET_CNTL(x)    (x)|=0100
  34. #define    CHANMASK    07
  35. #define    CHAN(dev)    (dev&CHANMASK)
  36. #define    SEQMASK        07        /* 2**SEQBITS - 1 */
  37.  
  38. /* define to get packet type  (control or not) */
  39. #define    GET_CNTL(x)    (((x) >> 6) &1)
  40. #define    GET_PTYP(x)    (((x) >> 7) &1)
  41. #define    GET_SEQ(x)    ((x) & 7)
  42. #define    GET_CHAN(x)    (((x) >> 3) & 7)
  43.  
  44.  
  45. /* These are no longer used by nxt.c since they are always
  46. ** enabled. The defines are retained, however, for other commands
  47. ** like xtt.
  48. */
  49. #define XTRACE        1    /* 1 to enable tracing */
  50. #define XTSTATS        1    /* 1 to enable statistics */
  51.  
  52. typedef long Stats_t;
  53.  
  54. #define PKTPTSZ 11        /* Pkt part captured for trace */
  55. #define PKTHIST 40        /* Size of trace history */
  56.  
  57. struct Tpkt
  58. {
  59.     unsigned char    pktpart[PKTPTSZ];    /* record of captured pkts */
  60.     unsigned char    flag;            /* packet direction */
  61.     clock_t        time;            /* log time (ticks) */
  62. };
  63.  
  64. struct Tbuf
  65. {
  66.     struct Tpkt    log[PKTHIST];    /* history of transactions */
  67.     short        flags;        /* assorted status flags */
  68.     char         index;        /* next slot */
  69.     char        used;        /* # of slots used */
  70. };
  71.  
  72.  
  73. #define S_XPKTS        0
  74. #define S_RPKTS        1
  75. #define    S_CRCERR    2
  76. #define    S_BADACK    3
  77. #define    S_BADNAK    4
  78. #define    S_OUTSEQ    5
  79. #define    S_NAKRETRYS    6
  80. #define    S_RDUP        7
  81. #define    S_RNAK        8
  82. #define    S_XNAK        9
  83. #define    S_RACK        10
  84. #define    S_XACK        11
  85. #define    S_BADHDR    12
  86. #define    S_BADSIZE    13
  87. #define    S_LOSTACK    14
  88. #define    S_BADCNTL    15
  89. #define    S_BADCDATA    16
  90. #define    S_NOMBLK    17
  91. #define    S_BADCOUNT    18
  92. #define    S_BADCHAN    19
  93. #define    S_BADCTYPE    20
  94. #define    S_NORBUF    21
  95. #define    S_RTIMO        22
  96. #define    S_XTIMO        23
  97. #define    S_WIOW        24 /* not used in STREAMS XT driver */
  98. #define    S_WOAS        25 /* not used in STREAMS XT driver */
  99. #define    S_NSTATS    26    /* 'count' macro used only for size below */
  100.                 /* make sure this one remains last in the list */
  101.  
  102. #define STATS(A,B)    (A)->stats[B]++    /* A is a channel pointer, B an offset */
  103.  
  104.  
  105. /*
  106.  *    XT Driver Control Structures
  107.  *
  108.  *    One "xtctl" structure is allocated for each instantiation
  109.  *    of the XT driver.
  110.  *
  111.  *    One "xtchan" structure is allocated for each window on
  112.  *    the user's terminal.
  113.  *
  114.  */
  115. struct xt_msg {
  116.     mblk_t *mp;            /* ptr to message */
  117.     clock_t timestamp;        /* stamp for ACK/NAK timeout */
  118.     unsigned char seq;        /* sequence number */
  119.     unsigned char xt_saveoutpkts;    /* outpkts when packet was sent */
  120. };
  121.  
  122.  
  123. struct xt_chan {
  124.     queue_t *xt_upq;        /* upstream read queue */
  125.     struct xtctl *xt_ctlp;        /* ptr to ctl struct */
  126.     struct jwinsize xt_jwinsize;    /* Layer parms for JWINSIZE ioctl */
  127.     short xt_chflg;            /* flags */
  128. #ifdef SVR32
  129.     t_pid_t xt_pgrp;        /* proc grp of first opening proc*/
  130. #endif /* SVR32 */
  131. #ifdef SVR40
  132.     pid_t xt_pgrp;            /* proc grp of first opening proc*/
  133. #endif /* SVR40 */
  134.     short xt_channo;        /* channel number for easy ref*/
  135.     short xt_outbufs;        /* slots for outpackets */
  136.     struct xt_msg xt_msg[2];    /* outpacket awaiting ACK */
  137.     unsigned char xt_inseq;        /* expected inpacket sequence num */
  138.     unsigned short xt_bytesent;    /* for flow control in network xt */
  139. #ifdef VPIX
  140.     v86_t *xt_v86p;
  141.     pid_t *xt_v86pid;
  142.     struct proc *xt_v86procp;
  143. #endif /* VPIX */
  144. };
  145.  
  146. /* flags for channels */
  147. #define    XT_CTL        0x1        /* control channel */
  148. #define    XT_ON        0x2        /* channel has been opened */
  149. #define    XT_WCLOSE    0x4        /* channel being closed */
  150. #define XT_IOCTL    0x8        /* channel processing ioctl */
  151. #define XT_NONETFLOW    0x10        /* network xt flow control disabled */
  152. #define XT_M_STOPPED    0x20        /* channel stopped by user ^S */
  153. #define XT_HOLDFLOW    0x40        /* temp disable net flow - see recvpkt() */
  154. #define XT_WAIT4COPYIN  0x80            /* M_COPYIN for ioctl is pending */
  155.  
  156. struct xtioctl {
  157.     int xti_seg;            /* which segment of ioctl to process */
  158.     mblk_t *xti_bp;            /* state information for ioctl */
  159. };
  160.  
  161.  
  162. struct xtctl {
  163.     struct queue *xt_ttyq;            /* downstream write queue */
  164.     struct xt_chan xt_chan[MAXPCHAN];    /* channels per active tty */
  165.     unsigned char xt_next;            /* sched this chan next */
  166.     unsigned char xt_lastscan;        /* chan which got canput failure */
  167.     short xt_ctlflg;            /* control flags */
  168.     mblk_t *xt_inbp;            /* block for incoming packet */
  169.     mblk_t *xt_pendjagent;            /* pending JAGENT ioctl pkt */
  170.     unsigned short xt_insize;        /* number data bytes expected */
  171.     unsigned short xt_incount;        /* number data bytes left */
  172.     clock_t xt_intime;            /* timestamp for input timeout */
  173.     short xt_instate;            /* state of incoming packet */
  174.     unsigned char xt_inchan;        /* chan number of incoming packet */
  175.     unsigned char xt_maxpkt;        /* max packet data size to terminal -
  176.                            equals 1 for network xt */
  177.     unsigned long xt_ttycflag;        /* dummy c_cflag (termio struct) */
  178.     unsigned char xt_hex;            /* 1 if 6-bit path, 0 if 8-bit    */
  179.     unsigned char xt_firstchar;        /* first char in pkt on input */
  180.     unsigned char xt_inpktcmd;        /* input packet command byte */
  181.     unsigned char xt_outpkts;        /* total outstanding pkts waiting
  182.                            for an ACK */
  183.     short xt_recvtimo;            /* receive timeout in HZ for
  184.                            current baud rate */
  185.     short xt_HZperpkt;            /* time in HZ to transfer 1
  186.                            outgoing pkt at current baud
  187.                            rate */
  188.     struct Tbuf trace;            /* trace strings stored here */
  189.     Stats_t stats[S_NSTATS];        /* usage statistics */
  190. };
  191.  
  192. /* xt_ctlflg flags for control struct */
  193. #define    XT_INUSE    0x1    /* xt dev is in use */
  194. #define XT_NETACK    0x2    /* processing incoming network xt ack packet */
  195. #define XT_WANTTIMEOUT    0x4    /* nxtscan() found a chan that needs timeout */
  196. #define XT_EXIT        0x8    /* C_EXIT in progress*/
  197. #define XT_UNLINK    0x10    /* UNLINK in progress*/
  198.  
  199.  
  200. /* The following are used for XT tracing. */
  201.  
  202.  
  203. #define XMITLOG        0    /* Transmitted packet */
  204. #define RECVLOG        1    /* Received packet */
  205. #define TRACE_BADPKT    0x2    /* Bad packet flag */
  206. #define TRACE_CMDBYTE    0x4    /* Packet has a command byte */
  207.  
  208. #define TRACEON        0x1    /* tracing enabled */
  209. #define TRACELOCK    0x2    /* tracing locked */
  210. #define TRACE_NETXT    0x4    /* tracing network xt protocol */
  211.  
  212. static void logpkt();
  213.  
  214. #define ISTRACEON(CTLP) (((CTLP)->trace.flags&(TRACEON|TRACELOCK))==TRACEON)
  215.  
  216.  
  217. /*
  218.  * ioctls for the XT driver
  219.  *
  220.  * Numbers 1, 5 and 6 have been used in old versions of the XT
  221.  * driver and should not be re-used.
  222.  *
  223.  */
  224. #define XTIOCTYPE ('b'<<8)
  225. #define XTIOCSTATS (XTIOCTYPE|2)    /* Get xts statistics */
  226. #define XTIOCTRACE (XTIOCTYPE|3)    /* Enable/Get xtt statistics */
  227. #define XTIOCNOTRACE (XTIOCTYPE|4)    /* Disable xtt tracing */
  228. #define XTIOCHEX (XTIOCTYPE|7)        /* Set LAN encoding */
  229.  
  230.  
  231. #endif    /* _SYS_NXT_H */
  232.