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