|
|
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: *
1.1.1.2 ! root 38: * from: @(#)pk.h 7.8 (Berkeley) 4/30/91
! 39: * pk.h,v 1.3 1993/05/20 04:12:14 cgd Exp
1.1 root 40: */
41:
1.1.1.2 ! root 42: #ifndef _NETCCITT_PK_H_
! 43: #define _NETCCITT_PK_H_
! 44:
1.1 root 45: /*
46: *
47: * X.25 Packet Level Definitions:
48: *
49: */
50:
51: /* Packet type identifier field defintions. */
52:
53: #define X25_CALL 11
54: #define X25_CALL_ACCEPTED 15
55: #define X25_CLEAR 19
56: #define X25_CLEAR_CONFIRM 23
57: #define X25_DATA 0
58: #define X25_INTERRUPT 35
59: #define X25_INTERRUPT_CONFIRM 39
60:
61: #define X25_RR 1
62: #define X25_RNR 5
63: #define X25_REJECT 9
64: #define X25_RESET 27
65: #define X25_RESET_CONFIRM 31
66: #define X25_DIAGNOSTIC 241
67:
68: #define X25_RESTART 251
69: #define X25_RESTART_CONFIRM 255
70:
71: /* Restart cause field definitions. */
72:
73: #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1
74: #define X25_RESTART_NETWORK_CONGESTION 3
75: #define X25_RESTART_NETWORK_OPERATIONAL 7
76:
77: /* Miscellaneous definitions. */
78:
79: #define DATA_PACKET_DESIGNATOR 0x01
80: #define RR_OR_RNR_PACKET_DESIGNATOR 0x02
81: #define RR_PACKET_DESIGNATOR 0x04
82:
83: #define DEFAULT_WINDOW_SIZE 2
84: #define MODULUS 8
85:
86: #define ADDRLN 1
87: #define MAXADDRLN 15
88: #define FACILITIESLN 1
89: #define MAXFACILITIESLN 10
90: #define MAXUSERDATA 16
91: #define MAXCALLINFOLN 1+15+1+10+16
92:
93: #define PACKET_OK 0
94: #define IGNORE_PACKET 1
95: #define ERROR_PACKET 2
96:
97: typedef char bool;
98: #define FALSE 0
99: #define TRUE 1
100:
101: /*
102: * X.25 Packet format definitions
103: * This will eventually have to be rewritten without reference
104: * to bit fields, to be ansi C compliant and allignment safe.
105: */
106:
107: #if BYTE_ORDER == BIG_ENDIAN
108: #define ORDER2(a, b) a , b
109: #define ORDER4(a, b, c, d) a , b , c , d
110: #endif
111:
112: #if BYTE_ORDER == LITTLE_ENDIAN
113: #define ORDER2(a, b) b , a
114: #define ORDER4(a, b, c, d) d , c , b , a
115: #endif
116:
117: typedef u_char octet;
118:
119: struct x25_calladdr {
120: octet ORDER2(calling_addrlen:4, called_addrlen:4);
121: octet address_field[MAXADDRLN];
122: };
123:
124: struct x25_packet {
125: octet ORDER4(q_bit:1, d_bit:1, fmt_identifier:2, lc_group_number:4);
126: octet logical_channel_number;
127: octet packet_type;
128: octet packet_data;
129: };
130:
131: struct data_packet {
132: octet ORDER4(pr:3, m_bit:1, ps:3, z:1);
133: };
134:
135: #define FACILITIES_REVERSE_CHARGE 0x1
136: #define FACILITIES_THROUGHPUT 0x2
137: #define FACILITIES_PACKETSIZE 0x42
138: #define FACILITIES_WINDOWSIZE 0x43
139:
140: #define PKHEADERLN 3
141:
142:
143: #define PR(xp) (((struct data_packet *)&xp -> packet_type)->pr)
144: #define PS(xp) (((struct data_packet *)&xp -> packet_type)->ps)
145: #define MBIT(xp) (((struct data_packet *)&xp -> packet_type)->m_bit)
146: #define LCN(xp) (xp -> logical_channel_number + \
147: (xp -> lc_group_number ? (xp -> lc_group_number >> 8) : 0))
148: #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \
149: (xp -> lc_group_number = lcn > 255 ? lcn >> 8 : 0))
150:
151: struct mbuf *pk_template ();
152:
153: /* Define X.25 packet level states. */
154:
155: /* Call setup and clearing substates. */
156:
157: #define LISTEN 0
158: #define READY 1
159: #define RECEIVED_CALL 2
160: #define SENT_CALL 3
161: #define DATA_TRANSFER 4
162: #define RECEIVED_CLEAR 5
163: #define SENT_CLEAR 6
164:
165: /* DTE states. */
166:
167: #define DTE_WAITING 7
168: #define DTE_RECEIVED_RESTART 8
169: #define DTE_SENT_RESTART 9
170: #define DTE_READY 0
171:
172: #define MAXSTATES 10
173:
174: /*
175: * The following definitions are used in a switch statement after
176: * determining the packet type. These values are returned by the
177: * pk_decode procedure.
178: */
179:
180: #define CALL 0 * MAXSTATES
181: #define CALL_ACCEPTED 1 * MAXSTATES
182: #define CLEAR 2 * MAXSTATES
183: #define CLEAR_CONF 3 * MAXSTATES
184: #define DATA 4 * MAXSTATES
185: #define INTERRUPT 5 * MAXSTATES
186: #define INTERRUPT_CONF 6 * MAXSTATES
187: #define RR 7 * MAXSTATES
188: #define RNR 8 * MAXSTATES
189: #define RESET 9 * MAXSTATES
190: #define RESET_CONF 10 * MAXSTATES
191: #define RESTART 11 * MAXSTATES
192: #define RESTART_CONF 12 * MAXSTATES
193: #define REJECT 13 * MAXSTATES
194: #define DIAG_TYPE 14 * MAXSTATES
195: #define INVALID_PACKET 15 * MAXSTATES
196: #define DELETE_PACKET INVALID_PACKET
1.1.1.2 ! root 197:
! 198: #endif /* !_NETCCITT_PK_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.