Annotation of researchv9/jerq/include/sys/xtproto.h, revision 1.1

1.1     ! root        1: /*
        !             2:        @(#)  xtproto.h  version 2.1 (Blit) of 7/20/83 15:43:49
        !             3:        Last Delta:  7/10/83 19:08:18 to /usr/jerq/sccs/src/xt/uts/sys/s.xtproto.h
        !             4: */
        !             5: 
        !             6: /*
        !             7: **     Bx -- Blit packet protocol definition
        !             8: */
        !             9: 
        !            10: typedef        unsigned char   Pbyte;                  /* The unit of communication */
        !            11: 
        !            12: #define        NPCBUFS         2                       /* Double buffered protocol */
        !            13: #define        MAXPCHAN        8                       /* Maximum channel number */
        !            14: #define        CHANBITS        3                       /* Bits for channel number */
        !            15: #define        CHANMASK        07                      /* 2**CHANBITS - 1 */
        !            16: /*
        !            17:  *     MAXPKTDSIZE should be CLSIZE - sizeof(struct P_header) - EDSIZE
        !            18:  */
        !            19: #define        MAXPKTDSIZE     (32 * sizeof(Pbyte))    /* Maximum data part size */
        !            20: #define        EDSIZE          (2 * sizeof(Pbyte))     /* Error detection part size */
        !            21: #define        SEQMOD          8                       /* Sequence number modulus */
        !            22: #define        SEQBITS         3                       /* Bits for sequence number */
        !            23: #define        SEQMASK         07                      /* 2**SEQBITS - 1 */
        !            24: 
        !            25: /*
        !            26: **     Packet header
        !            27: **     (if only bit fields in C were m/c independent, sigh...)
        !            28: */
        !            29: 
        !            30: #ifndef        u3b
        !            31: 
        !            32: struct P_header
        !            33: {
        !            34: #      ifdef   vax
        !            35: #      ifdef   OLDMPX
        !            36:        Pbyte           channel :CHANBITS,      /* Channel number */
        !            37:                        seq     :SEQBITS,       /* Sequence number */
        !            38: #      else    OLDMPX
        !            39:        Pbyte           seq     :SEQBITS,       /* Sequence number */
        !            40:                        channel :CHANBITS,      /* Channel number */
        !            41: #      endif   OLDMPX
        !            42:                        cntl    :1,             /* TRUE if control packet */
        !            43:                        ptyp    :1;             /* Always 1 */
        !            44:        Pbyte           dsize;                  /* Size of data part */
        !            45: #      endif   vax
        !            46: #      ifdef   mc68000
        !            47:        short           ptyp    :1,             /* Always 1 */
        !            48:                        cntl    :1,             /* TRUE if control packet */
        !            49:                        channel :CHANBITS,      /* Channel number */
        !            50:                        seq     :SEQBITS,       /* Sequence number */
        !            51:                        dsize   :8;             /* Size of data part */
        !            52: #      endif   mc68000
        !            53: };
        !            54: 
        !            55: typedef        struct P_header Ph_t;
        !            56: 
        !            57: /*
        !            58: **     Packet definition for maximum sized packet
        !            59: */
        !            60: 
        !            61: struct Packet
        !            62: {
        !            63:        Ph_t            header;                 /* Header part */
        !            64:        Pbyte           data[MAXPKTDSIZE];      /* Data part */
        !            65:        Pbyte           edb[EDSIZE];            /* Error detection part */
        !            66: };
        !            67: 
        !            68: #else u3b
        !            69: 
        !            70: /*
        !            71: **     Packet header (real size) 
        !            72: */
        !            73: 
        !            74: typedef short Ph_t;
        !            75: 
        !            76: /*
        !            77: **     Packet definition for maximum sized packet
        !            78: */
        !            79: 
        !            80: struct Packet {
        !            81:        Pbyte           header;                 /* Packet into */
        !            82:        Pbyte           dsize;                  /* Size of data part */
        !            83:        Pbyte           data[MAXPKTDSIZE];      /* Data part */
        !            84:        Pbyte           edb[EDSIZE];            /* Error detection part */
        !            85: };
        !            86: 
        !            87: /*
        !            88: **     Macros to access fields of header byte
        !            89: */
        !            90: 
        !            91: #define SET_CNTL(x)            (x)|=0100
        !            92: #define GET_CNTL(x)            (((x)>>6)&1)
        !            93: #define GET_PTYP(x)            (((x)>>7)&1)
        !            94: #define GET_SEQ(x)             ((x)&7)
        !            95: #define GET_CHAN(x)            (((x)>>3)&7)
        !            96: #define MK_HDR(x,chan,seq)     (x)=0200|((chan)<<3)|(seq)
        !            97: 
        !            98: #endif u3b
        !            99: 
        !           100: typedef struct Packet *        Pkt_p;
        !           101: 
        !           102: /*
        !           103: **     Control codes
        !           104: */
        !           105: 
        !           106: #define        PCDATA          (Pbyte)002              /* Data only control packet */
        !           107: #define        ACK             (Pbyte)006              /* Last packet with same sequence ok and in sequence */
        !           108: #define        NAK             (Pbyte)025              /* Last packet with same sequence received out of sequence */
        !           109: 
        !           110: /*
        !           111: **     Definition of a structure to hold status information
        !           112: **     for a conversation with a channel.
        !           113: */
        !           114: 
        !           115: struct Pktstate
        !           116: {
        !           117:        struct Packet   pkt;                    /* The packet */
        !           118:        short           timo;                   /* Timeout count */
        !           119:        unsigned char   state;                  /* Protocol state */
        !           120:        unsigned char   size;                   /* Packet size */
        !           121: };
        !           122: 
        !           123: typedef struct Pktstate *Pks_p;
        !           124: 
        !           125: struct Pchannel
        !           126: {
        !           127:        struct Pktstate pkts[NPCBUFS];          /* The packets */
        !           128:        Pks_p           nextpkt;                /* Next packet to be acknowledged */
        !           129:        Pbyte           cdata[SEQMOD];          /* Remember transmitted control data */
        !           130:        Pbyte           rseq    :SEQBITS;       /* Next receive sequence number */
        !           131:        Pbyte           xseq    :SEQBITS;       /* Next transmit sequence number */
        !           132:        char            outen;                  /* Output packets enabled */
        !           133:        char            flags;                  /* Control flags */
        !           134: #if XTDRIVER == 1
        !           135:        char            channo;                 /* This channel's number */
        !           136:        char            link;                   /* This channel's link */
        !           137: #      ifdef u3b
        !           138:        struct clist    xoutq;                  /* Processed output for channel */
        !           139:        struct clist    xinq;                   /* Processed input for channel */
        !           140:        char            esc;                    /* saw "\" flag for tty input */
        !           141: #      endif u3b
        !           142: #endif
        !           143: };
        !           144: 
        !           145: #define        XACK            1                       /* Send ACK */
        !           146: #define        XNAK            2                       /* Send NAK */
        !           147: #define        XCDATA          4                       /* Send control data in ACK packet */
        !           148: 
        !           149: typedef struct Pchannel *Pch_p;
        !           150: 
        !           151: /**    Transmit packet states  **/
        !           152: 
        !           153: enum { px_null, px_ready, px_wait, px_ok       };
        !           154: 
        !           155: #define        PX_NULL         (int)px_null            /* Empty packet */
        !           156: #define        PX_READY        (int)px_ready           /* Full packet awaiting transmission */
        !           157: #define        PX_WAIT         (int)px_wait            /* Packet awaiting acknowledgement */
        !           158: #define        PX_OK           (int)px_ok              /* Packet has been acknowledged */
        !           159: 
        !           160: /**    Receive packet states   **/
        !           161: 
        !           162: enum { pr_null, pr_size, pr_data };
        !           163: 
        !           164: #define        PR_NULL         (int)pr_null            /* New packet expected */
        !           165: #define        PR_SIZE         (int)pr_size            /* Size byte next */
        !           166: #define        PR_DATA         (int)pr_data            /* Receiving data */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.