xref: /netbsd/sys/net/ppp_defs.h (revision c4a72b64)
1 /*	$NetBSD: ppp_defs.h,v 1.8 2002/09/13 14:32:11 itojun Exp $	*/
2 /*	Id: ppp_defs.h,v 1.11 1997/04/30 05:46:24 paulus Exp 	*/
3 
4 /*
5  * ppp_defs.h - PPP definitions.
6  *
7  * Copyright (c) 1989-2002 Paul Mackerras. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in
18  *    the documentation and/or other materials provided with the
19  *    distribution.
20  *
21  * 3. The name(s) of the authors of this software must not be used to
22  *    endorse or promote products derived from this software without
23  *    prior written permission.
24  *
25  * 4. Redistributions of any form whatsoever must retain the following
26  *    acknowledgment:
27  *    "This product includes software developed by Paul Mackerras
28  *     <paulus@samba.org>".
29  *
30  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
31  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
33  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
34  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
35  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
36  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
37  */
38 
39 #ifndef _NET_PPP_DEFS_H_
40 #define _NET_PPP_DEFS_H_
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 
48 /*
49  * Packet sizes
50  *
51  * Note - lcp shouldn't be allowed to negotiate stuff outside these
52  *	  limits.  See lcp.h in the pppd directory.
53  * (XXX - these constants should simply be shared by lcp.c instead
54  *	  of living in lcp.h)
55  */
56 #define	PPP_MTU		1500	/* Default MTU (size of Info field) */
57 #define PPP_MAXMTU	65535 - (PPP_HDRLEN + PPP_FCSLEN)
58 #define PPP_MINMTU	64
59 #define PPP_MRU		1500	/* default MRU = max length of info field */
60 #define PPP_MAXMRU	65000	/* Largest MRU we allow */
61 #define PPP_MINMRU	128
62 
63 #define PPP_ADDRESS(p)	(((u_char *)(p))[0])
64 #define PPP_CONTROL(p)	(((u_char *)(p))[1])
65 #define PPP_PROTOCOL(p)	((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
66 
67 /*
68  * Significant octet values.
69  */
70 #define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
71 #define	PPP_UI		0x03	/* Unnumbered Information */
72 #define	PPP_FLAG	0x7e	/* Flag Sequence */
73 #define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
74 #define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
75 
76 /*
77  * Protocol field values.
78  */
79 #define PPP_IP		0x0021		/* Internet Protocol */
80 #define PPP_ISO		0x0023		/* ISO OSI Protocol */
81 #define PPP_XNS		0x0025		/* Xerox NS Protocol */
82 #define PPP_AT		0x0029		/* AppleTalk Protocol */
83 #define PPP_IPX		0x002b		/* IPX protocol */
84 #define	PPP_VJC_COMP	0x002d		/* VJ compressed TCP */
85 #define	PPP_VJC_UNCOMP	0x002f		/* VJ uncompressed TCP */
86 #define PPP_IPV6	0x0057		/* Internet Protocol Version 6 */
87 #define PPP_COMP	0x00fd		/* compressed packet */
88 #define PPP_IPCP	0x8021		/* IP Control Protocol */
89 #define PPP_ATCP	0x8029		/* AppleTalk Control Protocol */
90 #define PPP_IPXCP	0x802b		/* IPX Control Protocol */
91 #define PPP_IPV6CP	0x8057		/* IPv6 Control Protocol */
92 #define PPP_CCP		0x80fd		/* Compression Control Protocol */
93 #define PPP_LCP		0xc021		/* Link Control Protocol */
94 #define PPP_PAP		0xc023		/* Password Authentication Protocol */
95 #define PPP_LQR		0xc025		/* Link Quality Report protocol */
96 #define PPP_CHAP	0xc223		/* Crypto Handshake Auth. Protocol */
97 #define PPP_CBCP	0xc029		/* Callback Control Protocol */
98 
99 /*
100  * Values for FCS calculations.
101  */
102 #define PPP_INITFCS	0xffff	/* Initial FCS value */
103 #define PPP_GOODFCS	0xf0b8	/* Good final FCS value */
104 #define PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
105 
106 /*
107  * A 32-bit unsigned integral type.
108  */
109 #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) && !defined(__FreeBSD__)
110 #ifdef	UINT32_T
111 typedef UINT32_T	u_int32_t;
112 #else
113 typedef unsigned int	u_int32_t;
114 #endif
115 #endif
116 
117 /*
118  * Extended asyncmap - allows any character to be escaped.
119  */
120 typedef u_int32_t	ext_accm[8];
121 
122 /*
123  * What to do with network protocol (NP) packets.
124  */
125 enum NPmode {
126     NPMODE_PASS,		/* pass the packet through */
127     NPMODE_DROP,		/* silently drop the packet */
128     NPMODE_ERROR,		/* return an error */
129     NPMODE_QUEUE		/* save it up for later. */
130 };
131 
132 /*
133  * Statistics.
134  */
135 struct pppstat	{
136     unsigned int ppp_ibytes;	/* bytes received */
137     unsigned int ppp_ipackets;	/* packets received */
138     unsigned int ppp_ierrors;	/* receive errors */
139     unsigned int ppp_obytes;	/* bytes sent */
140     unsigned int ppp_opackets;	/* packets sent */
141     unsigned int ppp_oerrors;	/* transmit errors */
142 };
143 
144 struct vjstat {
145     unsigned int vjs_packets;	/* outbound packets */
146     unsigned int vjs_compressed; /* outbound compressed packets */
147     unsigned int vjs_searches;	/* searches for connection state */
148     unsigned int vjs_misses;	/* times couldn't find conn. state */
149     unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
150     unsigned int vjs_compressedin; /* inbound compressed packets */
151     unsigned int vjs_errorin;	/* inbound unknown type packets */
152     unsigned int vjs_tossed;	/* inbound packets tossed because of error */
153 };
154 
155 struct ppp_stats {
156     struct pppstat p;		/* basic PPP statistics */
157     struct vjstat vj;		/* VJ header compression statistics */
158 };
159 
160 struct compstat {
161     unsigned int unc_bytes;	/* total uncompressed bytes */
162     unsigned int unc_packets;	/* total uncompressed packets */
163     unsigned int comp_bytes;	/* compressed bytes */
164     unsigned int comp_packets;	/* compressed packets */
165     unsigned int inc_bytes;	/* incompressible bytes */
166     unsigned int inc_packets;	/* incompressible packets */
167     unsigned int ratio;		/* recent compression ratio << 8 */
168 };
169 
170 struct ppp_comp_stats {
171     struct compstat c;		/* packet compression statistics */
172     struct compstat d;		/* packet decompression statistics */
173 };
174 
175 /*
176  * The following structure records the time in seconds since
177  * the last NP packet was sent or received.
178  */
179 struct ppp_idle {
180     time_t xmit_idle;		/* time since last NP packet sent */
181     time_t recv_idle;		/* time since last NP packet received */
182 };
183 
184 #ifndef __P
185 #ifdef __STDC__
186 #define __P(x)	x
187 #else
188 #define __P(x)	()
189 #endif
190 #endif
191 
192 #endif /* _NET_PPP_DEFS_H_ */
193