|
|
1.1 ! root 1: /* ! 2: * Copyright (c) University of British Columbia, 1984 ! 3: * Copyright (c) 1990 The Regents of the University of California. ! 4: * All rights reserved. ! 5: * ! 6: * This code is derived from software contributed to Berkeley by ! 7: * the Laboratory for Computation Vision and the Computer Science Department ! 8: * of the University of British Columbia. ! 9: * ! 10: * Redistribution and use in source and binary forms, with or without ! 11: * modification, are permitted provided that the following conditions ! 12: * are met: ! 13: * 1. Redistributions of source code must retain the above copyright ! 14: * notice, this list of conditions and the following disclaimer. ! 15: * 2. Redistributions in binary form must reproduce the above copyright ! 16: * notice, this list of conditions and the following disclaimer in the ! 17: * documentation and/or other materials provided with the distribution. ! 18: * 3. All advertising materials mentioning features or use of this software ! 19: * must display the following acknowledgement: ! 20: * This product includes software developed by the University of ! 21: * California, Berkeley and its contributors. ! 22: * 4. Neither the name of the University nor the names of its contributors ! 23: * may be used to endorse or promote products derived from this software ! 24: * without specific prior written permission. ! 25: * ! 26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 36: * SUCH DAMAGE. ! 37: * ! 38: * @(#)pk.h 7.8 (Berkeley) 4/30/91 ! 39: */ ! 40: ! 41: /* ! 42: * ! 43: * X.25 Packet Level Definitions: ! 44: * ! 45: */ ! 46: ! 47: /* Packet type identifier field defintions. */ ! 48: ! 49: #define X25_CALL 11 ! 50: #define X25_CALL_ACCEPTED 15 ! 51: #define X25_CLEAR 19 ! 52: #define X25_CLEAR_CONFIRM 23 ! 53: #define X25_DATA 0 ! 54: #define X25_INTERRUPT 35 ! 55: #define X25_INTERRUPT_CONFIRM 39 ! 56: ! 57: #define X25_RR 1 ! 58: #define X25_RNR 5 ! 59: #define X25_REJECT 9 ! 60: #define X25_RESET 27 ! 61: #define X25_RESET_CONFIRM 31 ! 62: #define X25_DIAGNOSTIC 241 ! 63: ! 64: #define X25_RESTART 251 ! 65: #define X25_RESTART_CONFIRM 255 ! 66: ! 67: /* Restart cause field definitions. */ ! 68: ! 69: #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1 ! 70: #define X25_RESTART_NETWORK_CONGESTION 3 ! 71: #define X25_RESTART_NETWORK_OPERATIONAL 7 ! 72: ! 73: /* Miscellaneous definitions. */ ! 74: ! 75: #define DATA_PACKET_DESIGNATOR 0x01 ! 76: #define RR_OR_RNR_PACKET_DESIGNATOR 0x02 ! 77: #define RR_PACKET_DESIGNATOR 0x04 ! 78: ! 79: #define DEFAULT_WINDOW_SIZE 2 ! 80: #define MODULUS 8 ! 81: ! 82: #define ADDRLN 1 ! 83: #define MAXADDRLN 15 ! 84: #define FACILITIESLN 1 ! 85: #define MAXFACILITIESLN 10 ! 86: #define MAXUSERDATA 16 ! 87: #define MAXCALLINFOLN 1+15+1+10+16 ! 88: ! 89: #define PACKET_OK 0 ! 90: #define IGNORE_PACKET 1 ! 91: #define ERROR_PACKET 2 ! 92: ! 93: typedef char bool; ! 94: #define FALSE 0 ! 95: #define TRUE 1 ! 96: ! 97: /* ! 98: * X.25 Packet format definitions ! 99: * This will eventually have to be rewritten without reference ! 100: * to bit fields, to be ansi C compliant and allignment safe. ! 101: */ ! 102: ! 103: #if BYTE_ORDER == BIG_ENDIAN ! 104: #define ORDER2(a, b) a , b ! 105: #define ORDER4(a, b, c, d) a , b , c , d ! 106: #endif ! 107: ! 108: #if BYTE_ORDER == LITTLE_ENDIAN ! 109: #define ORDER2(a, b) b , a ! 110: #define ORDER4(a, b, c, d) d , c , b , a ! 111: #endif ! 112: ! 113: typedef u_char octet; ! 114: ! 115: struct x25_calladdr { ! 116: octet ORDER2(calling_addrlen:4, called_addrlen:4); ! 117: octet address_field[MAXADDRLN]; ! 118: }; ! 119: ! 120: struct x25_packet { ! 121: octet ORDER4(q_bit:1, d_bit:1, fmt_identifier:2, lc_group_number:4); ! 122: octet logical_channel_number; ! 123: octet packet_type; ! 124: octet packet_data; ! 125: }; ! 126: ! 127: struct data_packet { ! 128: octet ORDER4(pr:3, m_bit:1, ps:3, z:1); ! 129: }; ! 130: ! 131: #define FACILITIES_REVERSE_CHARGE 0x1 ! 132: #define FACILITIES_THROUGHPUT 0x2 ! 133: #define FACILITIES_PACKETSIZE 0x42 ! 134: #define FACILITIES_WINDOWSIZE 0x43 ! 135: ! 136: #define PKHEADERLN 3 ! 137: ! 138: ! 139: #define PR(xp) (((struct data_packet *)&xp -> packet_type)->pr) ! 140: #define PS(xp) (((struct data_packet *)&xp -> packet_type)->ps) ! 141: #define MBIT(xp) (((struct data_packet *)&xp -> packet_type)->m_bit) ! 142: #define LCN(xp) (xp -> logical_channel_number + \ ! 143: (xp -> lc_group_number ? (xp -> lc_group_number >> 8) : 0)) ! 144: #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \ ! 145: (xp -> lc_group_number = lcn > 255 ? lcn >> 8 : 0)) ! 146: ! 147: struct mbuf *pk_template (); ! 148: ! 149: /* Define X.25 packet level states. */ ! 150: ! 151: /* Call setup and clearing substates. */ ! 152: ! 153: #define LISTEN 0 ! 154: #define READY 1 ! 155: #define RECEIVED_CALL 2 ! 156: #define SENT_CALL 3 ! 157: #define DATA_TRANSFER 4 ! 158: #define RECEIVED_CLEAR 5 ! 159: #define SENT_CLEAR 6 ! 160: ! 161: /* DTE states. */ ! 162: ! 163: #define DTE_WAITING 7 ! 164: #define DTE_RECEIVED_RESTART 8 ! 165: #define DTE_SENT_RESTART 9 ! 166: #define DTE_READY 0 ! 167: ! 168: #define MAXSTATES 10 ! 169: ! 170: /* ! 171: * The following definitions are used in a switch statement after ! 172: * determining the packet type. These values are returned by the ! 173: * pk_decode procedure. ! 174: */ ! 175: ! 176: #define CALL 0 * MAXSTATES ! 177: #define CALL_ACCEPTED 1 * MAXSTATES ! 178: #define CLEAR 2 * MAXSTATES ! 179: #define CLEAR_CONF 3 * MAXSTATES ! 180: #define DATA 4 * MAXSTATES ! 181: #define INTERRUPT 5 * MAXSTATES ! 182: #define INTERRUPT_CONF 6 * MAXSTATES ! 183: #define RR 7 * MAXSTATES ! 184: #define RNR 8 * MAXSTATES ! 185: #define RESET 9 * MAXSTATES ! 186: #define RESET_CONF 10 * MAXSTATES ! 187: #define RESTART 11 * MAXSTATES ! 188: #define RESTART_CONF 12 * MAXSTATES ! 189: #define REJECT 13 * MAXSTATES ! 190: #define DIAG_TYPE 14 * MAXSTATES ! 191: #define INVALID_PACKET 15 * MAXSTATES ! 192: #define DELETE_PACKET INVALID_PACKET
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.