(no message)
[unix-history] / usr / src / sys / netccitt / pk.h
CommitLineData
658d6a25
KS
1/*
2 * Copyright (c) University of British Columbia, 1984
8ef71a63 3 * Copyright (c) 1990, 1992 The Regents of the University of California.
658d6a25
KS
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 *
8ef71a63 12 * @(#)pk.h 7.10 (Berkeley) %G%
658d6a25 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
94a9d981 33#define X25_REJECT 9
5b7aaaef
KS
34#define X25_RESET 27
35#define X25_RESET_CONFIRM 31
94a9d981 36#define X25_DIAGNOSTIC 241
5b7aaaef
KS
37
38#define X25_RESTART 251
39#define X25_RESTART_CONFIRM 255
40
41/* Restart cause field definitions. */
42
8ef71a63 43#define X25_RESTART_DTE_ORIGINATED 0
5b7aaaef
KS
44#define X25_RESTART_LOCAL_PROCEDURE_ERROR 1
45#define X25_RESTART_NETWORK_CONGESTION 3
46#define X25_RESTART_NETWORK_OPERATIONAL 7
8ef71a63
KS
47#define X25_RESTART_DTE_ORIGINATED2 128
48
5b7aaaef
KS
49
50/* Miscellaneous definitions. */
51
52#define DATA_PACKET_DESIGNATOR 0x01
53#define RR_OR_RNR_PACKET_DESIGNATOR 0x02
54#define RR_PACKET_DESIGNATOR 0x04
55
56#define DEFAULT_WINDOW_SIZE 2
57#define MODULUS 8
58
59#define ADDRLN 1
60#define MAXADDRLN 15
61#define FACILITIESLN 1
62#define MAXFACILITIESLN 10
63#define MAXUSERDATA 16
64#define MAXCALLINFOLN 1+15+1+10+16
65
66#define PACKET_OK 0
67#define IGNORE_PACKET 1
68#define ERROR_PACKET 2
69
70typedef char bool;
71#define FALSE 0
72#define TRUE 1
73
74/*
75 * X.25 Packet format definitions
658d6a25
KS
76 * This will eventually have to be rewritten without reference
77 * to bit fields, to be ansi C compliant and allignment safe.
5b7aaaef
KS
78 */
79
658d6a25 80typedef u_char octet;
5b7aaaef 81
658d6a25 82struct x25_calladdr {
8ef71a63 83 octet addrlens;
658d6a25 84 octet address_field[MAXADDRLN];
4507dea2 85};
5b7aaaef
KS
86
87struct x25_packet {
8ef71a63 88 octet bits;
5b7aaaef
KS
89 octet logical_channel_number;
90 octet packet_type;
91 octet packet_data;
92};
8ef71a63 93#define packet_cause packet_data
5b7aaaef
KS
94
95struct data_packet {
8ef71a63 96 octet bits;
5b7aaaef
KS
97};
98
658d6a25
KS
99#define FACILITIES_REVERSE_CHARGE 0x1
100#define FACILITIES_THROUGHPUT 0x2
101#define FACILITIES_PACKETSIZE 0x42
102#define FACILITIES_WINDOWSIZE 0x43
103
104#define PKHEADERLN 3
105
8ef71a63
KS
106#define DP(xp) (((struct data_packet *)&(xp) -> packet_type) -> bits)
107#define PS(xp) X25GBITS(DP(xp), p_s)
108#define PR(xp) X25GBITS(DP(xp), p_r)
109#define MBIT(xp) X25GBITS(DP(xp), m_bit)
110#define SPR(xp, v) X25SBITS(DP(xp), p_r, (v))
111#define SPS(xp, v) X25SBITS(DP(xp), p_s, (v))
112#define SMBIT(xp, v) X25SBITS(DP(xp), m_bit, (v))
658d6a25 113
a71ac3e2 114#define LCN(xp) (xp -> logical_channel_number + \
8ef71a63 115 (X25GBITS(xp -> bits, lc_group_number) ? (X25GBITS(xp -> bits, lc_group_number) << 8) : 0))
a71ac3e2 116#define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \
8ef71a63 117 (X25SBITS(xp -> bits, lc_group_number, lcn > 255 ? lcn >> 8 : 0)))
5b7aaaef 118
d3b78629 119struct mbuf *pk_template ();
5b7aaaef
KS
120
121/* Define X.25 packet level states. */
122
123/* Call setup and clearing substates. */
124
125#define LISTEN 0
126#define READY 1
127#define RECEIVED_CALL 2
128#define SENT_CALL 3
129#define DATA_TRANSFER 4
130#define RECEIVED_CLEAR 5
131#define SENT_CLEAR 6
132
133/* DTE states. */
134
135#define DTE_WAITING 7
136#define DTE_RECEIVED_RESTART 8
137#define DTE_SENT_RESTART 9
138#define DTE_READY 0
139
8ef71a63
KS
140/* Cleaning out ... */
141
142#define LCN_ZOMBIE 10
143
144#define MAXSTATES 11
5b7aaaef
KS
145
146/*
147 * The following definitions are used in a switch statement after
148 * determining the packet type. These values are returned by the
149 * pk_decode procedure.
150 */
151
152#define CALL 0 * MAXSTATES
153#define CALL_ACCEPTED 1 * MAXSTATES
154#define CLEAR 2 * MAXSTATES
155#define CLEAR_CONF 3 * MAXSTATES
156#define DATA 4 * MAXSTATES
157#define INTERRUPT 5 * MAXSTATES
158#define INTERRUPT_CONF 6 * MAXSTATES
159#define RR 7 * MAXSTATES
160#define RNR 8 * MAXSTATES
161#define RESET 9 * MAXSTATES
162#define RESET_CONF 10 * MAXSTATES
163#define RESTART 11 * MAXSTATES
164#define RESTART_CONF 12 * MAXSTATES
94a9d981 165#define REJECT 13 * MAXSTATES
5336ccc3 166#define DIAG_TYPE 14 * MAXSTATES
94a9d981 167#define INVALID_PACKET 15 * MAXSTATES
5b7aaaef 168#define DELETE_PACKET INVALID_PACKET
8ef71a63
KS
169
170/*
171 * The following definitions are used by the restart procedures
172 * for noting wether the PLE is supposed to behave as DTE or DCE
173 * (essentially necessary for operation over LLC2)
174 */
175#define DTE_DXERESOLVING 0x0001
176#define DTE_PLAYDTE 0x0002
177#define DTE_PLAYDCE 0x0004
178#define DTE_CONNECTPENDING 0x0010
179#define DTE_PRETENDDTE 0x0020
180
181#define MAXRESTARTCOLLISIONS 10