date and time created 90/08/30 17:35:33 by sklower
[unix-history] / usr / src / sys / netccitt / pk.h
CommitLineData
658d6a25
KS
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 * %sccs.include.redist.c%
11 *
12 * @(#)pk.h 7.2 (Berkeley) %G%
13 */
5b7aaaef
KS
14
15/*
16 *
17 * X.25 Packet Level Definitions:
18 *
19 */
20
21/* Packet type identifier field defintions. */
22
23#define X25_CALL 11
24#define X25_CALL_ACCEPTED 15
25#define X25_CLEAR 19
26#define X25_CLEAR_CONFIRM 23
27#define X25_DATA 0
28#define X25_INTERRUPT 35
29#define X25_INTERRUPT_CONFIRM 39
30
31#define X25_RR 1
32#define X25_RNR 5
33#define X25_RESET 27
34#define X25_RESET_CONFIRM 31
35
36#define X25_RESTART 251
37#define X25_RESTART_CONFIRM 255
38
39/* Restart cause field definitions. */
40
41#define X25_RESTART_LOCAL_PROCEDURE_ERROR 1
42#define X25_RESTART_NETWORK_CONGESTION 3
43#define X25_RESTART_NETWORK_OPERATIONAL 7
44
45/* Miscellaneous definitions. */
46
47#define DATA_PACKET_DESIGNATOR 0x01
48#define RR_OR_RNR_PACKET_DESIGNATOR 0x02
49#define RR_PACKET_DESIGNATOR 0x04
50
51#define DEFAULT_WINDOW_SIZE 2
52#define MODULUS 8
53
54#define ADDRLN 1
55#define MAXADDRLN 15
56#define FACILITIESLN 1
57#define MAXFACILITIESLN 10
58#define MAXUSERDATA 16
59#define MAXCALLINFOLN 1+15+1+10+16
60
61#define PACKET_OK 0
62#define IGNORE_PACKET 1
63#define ERROR_PACKET 2
64
65typedef char bool;
66#define FALSE 0
67#define TRUE 1
68
69/*
70 * X.25 Packet format definitions
658d6a25
KS
71 * This will eventually have to be rewritten without reference
72 * to bit fields, to be ansi C compliant and allignment safe.
5b7aaaef
KS
73 */
74
658d6a25
KS
75#if BYTE_ORDER == BIG_ENDIAN
76#define ORDER2(a, b) a , b
77#define ORDER3(a, b, c) a , b , c
78#define ORDER4(a, b, c, d) a , b , c , d
79#endif
5b7aaaef 80
658d6a25
KS
81#if BYTE_ORDER == LITTLE_ENDIAN
82#define ORDER2(a, b) b , a
83#define ORDER3(a, b, c) c , b , a
84#define ORDER4(a, b, c, d) d , c , b , a
5b7aaaef 85#endif
5b7aaaef 86
658d6a25 87typedef u_char octet;
5b7aaaef 88
658d6a25
KS
89struct x25_calladdr {
90 octet ORDER2(called_addrlen:4, calling_addrlen:4);
91 octet address_field[MAXADDRLN];
92}
5b7aaaef
KS
93
94struct x25_packet {
658d6a25 95 octet ORDER3(lc_group_number:4, fmt_identifier:3, q_bit:1);
5b7aaaef
KS
96 octet logical_channel_number;
97 octet packet_type;
98 octet packet_data;
99};
100
101struct data_packet {
658d6a25 102 octet ORDER4(z:1, ps:3, m_bit:1, pr:3);
5b7aaaef
KS
103};
104
658d6a25
KS
105#define FACILITIES_REVERSE_CHARGE 0x1
106#define FACILITIES_THROUGHPUT 0x2
107#define FACILITIES_PACKETSIZE 0x42
108#define FACILITIES_WINDOWSIZE 0x43
109
110#define PKHEADERLN 3
111
112
5b7aaaef
KS
113#define PR(xp) (((struct data_packet *)&xp -> packet_type)->pr)
114#define PS(xp) (((struct data_packet *)&xp -> packet_type)->ps)
115#define MBIT(xp) (((struct data_packet *)&xp -> packet_type)->m_bit)
116
117struct x25_packet *pk_template ();
118
119/* Define X.25 packet level states. */
120
121/* Call setup and clearing substates. */
122
123#define LISTEN 0
124#define READY 1
125#define RECEIVED_CALL 2
126#define SENT_CALL 3
127#define DATA_TRANSFER 4
128#define RECEIVED_CLEAR 5
129#define SENT_CLEAR 6
130
131/* DTE states. */
132
133#define DTE_WAITING 7
134#define DTE_RECEIVED_RESTART 8
135#define DTE_SENT_RESTART 9
136#define DTE_READY 0
137
138#define MAXSTATES 10
139
140/*
141 * The following definitions are used in a switch statement after
142 * determining the packet type. These values are returned by the
143 * pk_decode procedure.
144 */
145
146#define CALL 0 * MAXSTATES
147#define CALL_ACCEPTED 1 * MAXSTATES
148#define CLEAR 2 * MAXSTATES
149#define CLEAR_CONF 3 * MAXSTATES
150#define DATA 4 * MAXSTATES
151#define INTERRUPT 5 * MAXSTATES
152#define INTERRUPT_CONF 6 * MAXSTATES
153#define RR 7 * MAXSTATES
154#define RNR 8 * MAXSTATES
155#define RESET 9 * MAXSTATES
156#define RESET_CONF 10 * MAXSTATES
157#define RESTART 11 * MAXSTATES
158#define RESTART_CONF 12 * MAXSTATES
159#define INVALID_PACKET 13 * MAXSTATES
160#define DELETE_PACKET INVALID_PACKET