bring manpage up to date
[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 *
b650f46e 12 * @(#)pk.h 7.4 (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
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
658d6a25
KS
77#define ORDER4(a, b, c, d) a , b , c , d
78#endif
5b7aaaef 79
658d6a25
KS
80#if BYTE_ORDER == LITTLE_ENDIAN
81#define ORDER2(a, b) b , a
658d6a25 82#define ORDER4(a, b, c, d) d , c , b , a
5b7aaaef 83#endif
5b7aaaef 84
658d6a25 85typedef u_char octet;
5b7aaaef 86
658d6a25 87struct x25_calladdr {
b650f46e 88 octet ORDER2(calling_addrlen:4, called_addrlen:4);
658d6a25 89 octet address_field[MAXADDRLN];
4507dea2 90};
5b7aaaef
KS
91
92struct x25_packet {
b650f46e 93 octet ORDER4(q_bit:1, d_bit:1, fmt_identifier:2, lc_group_number:4);
5b7aaaef
KS
94 octet logical_channel_number;
95 octet packet_type;
96 octet packet_data;
97};
98
99struct data_packet {
b650f46e 100 octet ORDER4(pr:3, m_bit:1, ps:3, z:1);
5b7aaaef
KS
101};
102
658d6a25
KS
103#define FACILITIES_REVERSE_CHARGE 0x1
104#define FACILITIES_THROUGHPUT 0x2
105#define FACILITIES_PACKETSIZE 0x42
106#define FACILITIES_WINDOWSIZE 0x43
107
108#define PKHEADERLN 3
109
110
5b7aaaef
KS
111#define PR(xp) (((struct data_packet *)&xp -> packet_type)->pr)
112#define PS(xp) (((struct data_packet *)&xp -> packet_type)->ps)
113#define MBIT(xp) (((struct data_packet *)&xp -> packet_type)->m_bit)
114
115struct x25_packet *pk_template ();
116
117/* Define X.25 packet level states. */
118
119/* Call setup and clearing substates. */
120
121#define LISTEN 0
122#define READY 1
123#define RECEIVED_CALL 2
124#define SENT_CALL 3
125#define DATA_TRANSFER 4
126#define RECEIVED_CLEAR 5
127#define SENT_CLEAR 6
128
129/* DTE states. */
130
131#define DTE_WAITING 7
132#define DTE_RECEIVED_RESTART 8
133#define DTE_SENT_RESTART 9
134#define DTE_READY 0
135
136#define MAXSTATES 10
137
138/*
139 * The following definitions are used in a switch statement after
140 * determining the packet type. These values are returned by the
141 * pk_decode procedure.
142 */
143
144#define CALL 0 * MAXSTATES
145#define CALL_ACCEPTED 1 * MAXSTATES
146#define CLEAR 2 * MAXSTATES
147#define CLEAR_CONF 3 * MAXSTATES
148#define DATA 4 * MAXSTATES
149#define INTERRUPT 5 * MAXSTATES
150#define INTERRUPT_CONF 6 * MAXSTATES
151#define RR 7 * MAXSTATES
152#define RNR 8 * MAXSTATES
153#define RESET 9 * MAXSTATES
154#define RESET_CONF 10 * MAXSTATES
155#define RESTART 11 * MAXSTATES
156#define RESTART_CONF 12 * MAXSTATES
157#define INVALID_PACKET 13 * MAXSTATES
158#define DELETE_PACKET INVALID_PACKET