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