111967Speter/*
211967Speter * ppp_defs.h - PPP definitions.
3139823Simp */
4139823Simp/*-
511967Speter * Copyright (c) 1994 The Australian National University.
611967Speter * All rights reserved.
711967Speter *
811967Speter * Permission to use, copy, modify, and distribute this software and its
911967Speter * documentation is hereby granted, provided that the above copyright
1011967Speter * notice appears in all copies.  This software is provided without any
1111967Speter * warranty, express or implied. The Australian National University
1211967Speter * makes no representations about the suitability of this software for
1311967Speter * any purpose.
1411967Speter *
1511967Speter * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
1611967Speter * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
1711967Speter * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
1811967Speter * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
1911967Speter * OF SUCH DAMAGE.
2011967Speter *
2111967Speter * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
2211967Speter * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
2311967Speter * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
2411967Speter * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
2511967Speter * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
2611967Speter * OR MODIFICATIONS.
2728415Speter *
2850477Speter * $FreeBSD$
2911967Speter */
3011967Speter
3111967Speter#ifndef _PPP_DEFS_H_
3211967Speter#define _PPP_DEFS_H_
3311967Speter
3411967Speter/*
3511967Speter * The basic PPP frame.
3611967Speter */
3711967Speter#define PPP_HDRLEN	4	/* octets for standard ppp header */
3811967Speter#define PPP_FCSLEN	2	/* octets for FCS */
3911967Speter#define PPP_MRU		1500	/* default MRU = max length of info field */
4011967Speter
4111967Speter#define PPP_ADDRESS(p)	(((u_char *)(p))[0])
4211967Speter#define PPP_CONTROL(p)	(((u_char *)(p))[1])
4311967Speter#define PPP_PROTOCOL(p)	((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
4411967Speter
4511967Speter/*
4611967Speter * Significant octet values.
4711967Speter */
4811967Speter#define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
4911967Speter#define	PPP_UI		0x03	/* Unnumbered Information */
5011967Speter#define	PPP_FLAG	0x7e	/* Flag Sequence */
5111967Speter#define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
5211967Speter#define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
5311967Speter
5411967Speter/*
5511967Speter * Protocol field values.
5611967Speter */
5711967Speter#define PPP_IP		0x21	/* Internet Protocol */
5811970Speter#define	PPP_XNS		0x25	/* Xerox NS */
5928415Speter#define PPP_AT		0x29	/* AppleTalk Protocol */
6011970Speter#define PPP_IPX		0x2b	/* IPX Datagram (RFC1552) */
6111967Speter#define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */
6211967Speter#define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */
6311967Speter#define PPP_COMP	0xfd	/* compressed packet */
6411967Speter#define PPP_IPCP	0x8021	/* IP Control Protocol */
6528415Speter#define PPP_ATCP	0x8029	/* AppleTalk Control Protocol */
6611970Speter#define PPP_IPXCP	0x802b	/* IPX Control Protocol (RFC1552) */
6711967Speter#define PPP_CCP		0x80fd	/* Compression Control Protocol */
6811967Speter#define PPP_LCP		0xc021	/* Link Control Protocol */
6911967Speter#define PPP_PAP		0xc023	/* Password Authentication Protocol */
7011967Speter#define PPP_LQR		0xc025	/* Link Quality Report protocol */
7111967Speter#define PPP_CHAP	0xc223	/* Cryptographic Handshake Auth. Protocol */
7228415Speter#define PPP_CBCP	0xc029	/* Callback Control Protocol */
7378064Sume#define PPP_IPV6	0x57	/* Internet Protocol version 6*/
7478064Sume#define PPP_IPV6CP	0x8057	/* IPv6 Control Protocol */
7511967Speter
7611967Speter/*
7711967Speter * Values for FCS calculations.
7811967Speter */
7911967Speter#define PPP_INITFCS	0xffff	/* Initial FCS value */
8011967Speter#define PPP_GOODFCS	0xf0b8	/* Good final FCS value */
8111967Speter#define PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
8211967Speter
8311967Speter/*
8411967Speter * Extended asyncmap - allows any character to be escaped.
8511967Speter */
8611967Spetertypedef u_int32_t	ext_accm[8];
8711967Speter
8811967Speter/*
8911967Speter * What to do with network protocol (NP) packets.
9011967Speter */
9111967Speterenum NPmode {
9211967Speter    NPMODE_PASS,		/* pass the packet through */
9311967Speter    NPMODE_DROP,		/* silently drop the packet */
9411967Speter    NPMODE_ERROR,		/* return an error */
9511967Speter    NPMODE_QUEUE		/* save it up for later. */
9611967Speter};
9711967Speter
9811967Speter/*
9911967Speter * Statistics.
10011967Speter */
10111967Speterstruct pppstat	{
10228415Speter    unsigned int ppp_ibytes;	/* bytes received */
10328415Speter    unsigned int ppp_ipackets;	/* packets received */
10428415Speter    unsigned int ppp_ierrors;	/* receive errors */
10528415Speter    unsigned int ppp_obytes;	/* bytes sent */
10628415Speter    unsigned int ppp_opackets;	/* packets sent */
10728415Speter    unsigned int ppp_oerrors;	/* transmit errors */
10811967Speter};
10911967Speter
11011967Speterstruct vjstat {
11128415Speter    unsigned int vjs_packets;	/* outbound packets */
11228415Speter    unsigned int vjs_compressed; /* outbound compressed packets */
11328415Speter    unsigned int vjs_searches;	/* searches for connection state */
11428415Speter    unsigned int vjs_misses;	/* times couldn't find conn. state */
11528415Speter    unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
11628415Speter    unsigned int vjs_compressedin; /* inbound compressed packets */
11728415Speter    unsigned int vjs_errorin;	/* inbound unknown type packets */
11828415Speter    unsigned int vjs_tossed;	/* inbound packets tossed because of error */
11911967Speter};
12011967Speter
12111967Speterstruct ppp_stats {
12228415Speter    struct pppstat p;		/* basic PPP statistics */
12328415Speter    struct vjstat vj;		/* VJ header compression statistics */
12411967Speter};
12511967Speter
12611967Speterstruct compstat {
12728415Speter    unsigned int unc_bytes;	/* total uncompressed bytes */
12828415Speter    unsigned int unc_packets;	/* total uncompressed packets */
12928415Speter    unsigned int comp_bytes;	/* compressed bytes */
13028415Speter    unsigned int comp_packets;	/* compressed packets */
13128415Speter    unsigned int inc_bytes;	/* incompressible bytes */
13228415Speter    unsigned int inc_packets;	/* incompressible packets */
13328415Speter    unsigned int ratio;		/* recent compression ratio << 8 */
13411967Speter};
13511967Speter
13611967Speterstruct ppp_comp_stats {
13728415Speter    struct compstat c;		/* packet compression statistics */
13828415Speter    struct compstat d;		/* packet decompression statistics */
13911967Speter};
14011967Speter
14111967Speter/*
14211967Speter * The following structure records the time in seconds since
14311967Speter * the last NP packet was sent or received.
14411967Speter */
14511967Speterstruct ppp_idle {
14611967Speter    time_t xmit_idle;		/* time since last NP packet sent */
14711967Speter    time_t recv_idle;		/* time since last NP packet received */
14811967Speter};
14911967Speter
15011967Speter#ifndef __P
15111967Speter#ifdef __STDC__
15211967Speter#define __P(x)	x
15311967Speter#else
15411967Speter#define __P(x)	()
15511967Speter#endif
15611967Speter#endif
15711967Speter
15811967Speter#endif /* _PPP_DEFS_H_ */
159