xref: /titanic_50/usr/src/uts/common/net/ppp_defs.h (revision a0b85df49408b3ff0ca3c0780974f13a7b485ae3)
1 /*	$Id: ppp_defs.h,v 1.14 1999/08/13 01:55:40 paulus Exp $	*/
2 
3 /*
4  * ppp_defs.h - PPP definitions.
5  *
6  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
7  * Use is subject to license terms.
8  *
9  * Copyright (c) 1994 The Australian National University.
10  * All rights reserved.
11  *
12  * Permission to use, copy, modify, and distribute this software and its
13  * documentation is hereby granted, provided that the above copyright
14  * notice appears in all copies.  This software is provided without any
15  * warranty, express or implied. The Australian National University
16  * makes no representations about the suitability of this software for
17  * any purpose.
18  *
19  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
20  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
22  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
23  * OF SUCH DAMAGE.
24  *
25  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
28  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
29  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
30  * OR MODIFICATIONS.
31  */
32 
33 #ifndef _PPP_DEFS_H_
34 #define	_PPP_DEFS_H_
35 
36 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * The basic PPP frame.
44  */
45 #define	PPP_HDRLEN	4	/* octets for standard ppp header */
46 #define	PPP_FCSLEN	2	/* octets for FCS */
47 #define	PPP_FCS32LEN	4	/* octets for FCS-32 */
48 #define	PPP_MAX_MUX_LEN	127	/* maximum length of muxed frame */
49 #define	PFF		0x80	/* protocol field flag */
50 
51 /*
52  * Packet sizes
53  */
54 #define	PPP_MTU		1500	/* Default MTU (size of Info field) */
55 #define	PPP_MAXMTU	65535 - (PPP_HDRLEN + PPP_FCSLEN)
56 #define	PPP_MINMTU	64
57 #define	PPP_MRU		1500	/* default MRU = max length of info field */
58 #define	PPP_MAXMRU	65000	/* Largest MRU we allow */
59 #define	PPP_MINMRU	128
60 
61 #define	PPP_ADDRESS(p)	(((uchar_t *)(p))[0])
62 #define	PPP_CONTROL(p)	(((uchar_t *)(p))[1])
63 #define	PPP_PROTOCOL(p)	((((uchar_t *)(p))[2] << 8) + ((uchar_t *)(p))[3])
64 
65 /*
66  * Significant octet values.
67  */
68 #define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
69 #define	PPP_UI		0x03	/* Unnumbered Information */
70 #define	PPP_FLAG	0x7e	/* Flag Sequence */
71 #define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
72 #define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
73 
74 /*
75  * Protocol field values.
76  */
77 #define	PPP_IP		0x21	/* Internet Protocol */
78 #define	PPP_OSI		0x23	/* OSI Network Layer */
79 #define	PPP_AT		0x29	/* AppleTalk Protocol */
80 #define	PPP_IPX		0x2b	/* IPX protocol */
81 #define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */
82 #define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */
83 #define	PPP_BRIDGE	0x31	/* Bridging */
84 #define	PPP_MP		0x3d	/* Multilink protocol */
85 #define	PPP_ENCRYPT	0x53	/* Encryption */
86 #define	PPP_ENCRYPTFRAG	0x55	/* Individual Link Encryption */
87 #define	PPP_IPV6	0x57	/* Internet Protocol Version 6 */
88 #define	PPP_MUX		0x59	/* PPP Muxing */
89 #define	PPP_FULLHDR	0x61	/* IP Compression; full header */
90 #define	PPP_COMPTCP	0x63	/* IP Compression; compressed TCP */
91 #define	PPP_COMPNONTCP	0x65	/* IP Compression; non TCP */
92 #define	PPP_COMPUDP8	0x67	/* IP Compression; UDP, 8 bit CID */
93 #define	PPP_COMPRTP8	0x69	/* IP Compression; RTP, 8 bit CID */
94 #define	PPP_COMPFRAG	0xfb	/* fragment compressed below bundle */
95 #define	PPP_COMP	0xfd	/* compressed packet */
96 #define	PPP_802HELLO	0x201	/* 802.1d Hello (OBSOLETE) */
97 #define	PPP_MPLS	0x281	/* MPLS Unicast */
98 #define	PPP_MPLSMC	0x283	/* MPLS Multicast */
99 #define	PPP_COMPTCPND	0x2063	/* IP Compression; compressed TCP no delta */
100 #define	PPP_COMPSTATE	0x2065	/* IP Compression; state message */
101 #define	PPP_COMPUDP16	0x2067	/* IP Compression; UDP, 16 bit CID */
102 #define	PPP_COMPRTP16	0x2069	/* IP Compression; RTP, 16 bit CID */
103 #define	PPP_IPCP	0x8021	/* IP Control Protocol */
104 #define	PPP_OSINLCP	0x8023	/* OSI Network Layer Control Protocol */
105 #define	PPP_ATCP	0x8029	/* AppleTalk Control Protocol */
106 #define	PPP_IPXCP	0x802b	/* IPX Control Protocol */
107 #define	PPP_BCP		0x8031	/* Bridging Control Protocol */
108 #define	PPP_ECP		0x8053	/* Encryption Control Protocol */
109 #define	PPP_ECPFRAG	0x8055	/* ECP at link level (below MP bundle) */
110 #define	PPP_IPV6CP	0x8057	/* IPv6 Control Protocol */
111 #define	PPP_MUXCP	0x8059	/* PPP Muxing Control Protocol */
112 #define	PPP_CCPFRAG	0x80fb	/* CCP at link level (below MP bundle) */
113 #define	PPP_CCP		0x80fd	/* Compression Control Protocol */
114 #define	PPP_MPLSCP	0x8281	/* MPLS Control Protocol */
115 #define	PPP_LCP		0xc021	/* Link Control Protocol */
116 #define	PPP_PAP		0xc023	/* Password Authentication Protocol */
117 #define	PPP_LQR		0xc025	/* Link Quality Report protocol */
118 #define	PPP_BACP	0xc02b	/* Bandwidth Allocation Control Protocol */
119 #define	PPP_BAP		0xc02d	/* Bandwidth Allocation Protocol */
120 #define	PPP_CBCP	0xc029	/* Callback Control Protocol */
121 #define	PPP_CHAP	0xc223	/* Challenge Handshake Auth. Protocol */
122 #define	PPP_EAP		0xc227	/* Extensible Authentication Protocol */
123 
124 /*
125  * Values for FCS calculations.
126  */
127 #define	PPP_INITFCS	0xffff	/* Initial FCS value */
128 #define	PPP_GOODFCS	0xf0b8	/* Good final FCS value */
129 #define	PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
130 
131 #define	PPPINITFCS16	PPP_INITFCS
132 #define	PPPGOODFCS16	PPP_GOODFCS
133 #define	PPPFCS16(fcs, c)	PPP_FCS((fcs), (c))
134 
135 #define	PPPINITFCS32	0xfffffffful
136 #define	PPPGOODFCS32	0xdebb20e3ul
137 #define	PPPFCS32(fcs, c) (((fcs) >> 8) ^ crc32_table[((fcs) ^ (c)) & 0xff])
138 
139 /* Marker values shared between pppdump and pppd. */
140 #define	RECMARK_STARTSEND	1
141 #define	RECMARK_STARTRECV	2
142 #define	RECMARK_ENDSEND		3
143 #define	RECMARK_ENDRECV		4
144 #define	RECMARK_TIMEDELTA32	5
145 #define	RECMARK_TIMEDELTA8	6
146 #define	RECMARK_TIMESTART	7
147 
148 /*
149  * A 32-bit unsigned integral type.
150  */
151 
152 #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) && \
153 	!defined(__FreeBSD__) && (NS_TARGET < 40)
154 #ifdef	UINT32_T
155 typedef UINT32_T	u_int32_t;
156 #else
157 typedef unsigned int	u_int32_t;
158 typedef unsigned short  u_int16_t;
159 #endif
160 #endif
161 
162 #if defined(__sun) && !defined(_SYS_INT_TYPES_H) && !defined(_UINT32_T)
163 /* Backward compatibility */
164 typedef uint_t uint32_t;
165 typedef ushort_t uint16_t;
166 typedef uchar_t uint8_t;
167 typedef unsigned long uintptr_t;
168 #define	_UINT32_T
169 #endif
170 
171 /*
172  * Extended asyncmap - allows any character to be escaped.
173  */
174 typedef u_int32_t	ext_accm[8];
175 
176 /*
177  * What to do with network protocol (NP) packets.
178  */
179 enum NPmode {
180     NPMODE_PASS,		/* pass the packet through */
181     NPMODE_DROP,		/* silently drop the packet */
182     NPMODE_ERROR,		/* return an error */
183     NPMODE_QUEUE		/* save it up for later. */
184 };
185 
186 /*
187  * Statistics.
188  */
189 struct pppstat	{
190     u_int32_t ppp_ibytes;	/* bytes received */
191     u_int32_t ppp_ipackets;	/* packets received */
192     u_int32_t ppp_ierrors;	/* receive errors */
193     u_int32_t ppp_obytes;	/* bytes sent */
194     u_int32_t ppp_opackets;	/* packets sent */
195     u_int32_t ppp_oerrors;	/* transmit errors */
196 };
197 
198 struct vjstat {
199     u_int32_t vjs_packets;	/* outbound packets */
200     u_int32_t vjs_compressed; /* outbound compressed packets */
201     u_int32_t vjs_searches;	/* searches for connection state */
202     u_int32_t vjs_misses;	/* times couldn't find conn. state */
203     u_int32_t vjs_uncompressedin; /* inbound uncompressed packets */
204     u_int32_t vjs_compressedin; /* inbound compressed packets */
205     u_int32_t vjs_errorin;	/* inbound unknown type packets */
206     u_int32_t vjs_tossed;	/* inbound packets tossed because of error */
207 };
208 
209 struct ppp_stats {
210     struct pppstat p;		/* basic PPP statistics */
211     struct vjstat vj;		/* VJ header compression statistics */
212 };
213 
214 #ifdef SOL2
215 #define	PPP_COUNTER_F	"llu"
216 typedef uint64_t	ppp_counter_t;
217 
218 struct pppstat64 {
219 	ppp_counter_t ppp_ibytes;	/* bytes received */
220 	ppp_counter_t ppp_ipackets;	/* packets received */
221 	ppp_counter_t ppp_ierrors;	/* receive errors */
222 	ppp_counter_t ppp_obytes;	/* bytes sent */
223 	ppp_counter_t ppp_opackets;	/* packets sent */
224 	ppp_counter_t ppp_oerrors;	/* transmit errors */
225 };
226 
227 struct ppp_stats64 {
228 	struct pppstat64 p;
229 	struct vjstat vj;
230 };
231 #else
232 #define	PPP_COUNTER_F	"u"
233 typedef u_int32_t	ppp_counter_t;
234 #endif
235 
236 struct compstat {
237     u_int32_t unc_bytes;	/* total uncompressed bytes */
238     u_int32_t unc_packets;	/* total uncompressed packets */
239     u_int32_t comp_bytes;	/* compressed bytes */
240     u_int32_t comp_packets;	/* compressed packets */
241     u_int32_t inc_bytes;	/* incompressible bytes */
242     u_int32_t inc_packets;	/* incompressible packets */
243     u_int32_t ratio;		/* recent compression ratio << 8 */
244 };
245 
246 struct ppp_comp_stats {
247     struct compstat c;		/* packet compression statistics */
248     struct compstat d;		/* packet decompression statistics */
249 };
250 
251 /*
252  * The following structure records the time in seconds since
253  * the last NP packet was sent or received.
254  */
255 struct ppp_idle {
256 	/*
257 	 * Fix the length of these fields to be 32-bit, since
258 	 * otherwise, a time_t (long) is 64-bit in kernel while 32-bit
259 	 * in userland when running on a 64-bit CPU with a 64-bit OS.
260 	 */
261     u_int32_t xmit_idle;	/* time since last NP packet sent */
262     u_int32_t recv_idle;	/* time since last NP packet received */
263 };
264 
265 enum LSstat {
266     PPP_LINKSTAT_HANGUP = 0xabcd, /* link is hung up */
267     PPP_LINKSTAT_NEEDUP,	/* link is down and needs to be up */
268     PPP_LINKSTAT_IPV4_UNBOUND,	/* DL_UNBIND received on IPv4 stream */
269     PPP_LINKSTAT_IPV6_UNBOUND,	/* DL_UNBIND received on IPv6 stream */
270     PPP_LINKSTAT_IPV4_BOUND,	/* DL_BIND received on IPv4 stream */
271     PPP_LINKSTAT_IPV6_BOUND,	/* DL_BIND received on IPv6 stream */
272     PPP_LINKSTAT_UP		/* Integrated driver; hardware is up */
273 };
274 
275 #define	PPPLSMAGIC	0x53505050
276 
277 struct ppp_ls {
278     u_int32_t magic;		/* magic number identifier (PPPLSMAGIC) */
279     u_int32_t ppp_message;	/* link status message */
280 };
281 
282 #ifndef __P
283 #ifdef __STDC__
284 #define	__P(x)	x
285 #else
286 #define	__P(x)	()
287 #endif
288 #endif
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif /* _PPP_DEFS_H_ */
295