ppp_defs.h revision 11967
111967Speter/*	$Id: ppp_defs.h,v 1.7 1995/08/10 06:49:35 paulus Exp $	*/
211967Speter
311967Speter/*
411967Speter * ppp_defs.h - PPP definitions.
511967Speter *
611967Speter * Copyright (c) 1994 The Australian National University.
711967Speter * All rights reserved.
811967Speter *
911967Speter * Permission to use, copy, modify, and distribute this software and its
1011967Speter * documentation is hereby granted, provided that the above copyright
1111967Speter * notice appears in all copies.  This software is provided without any
1211967Speter * warranty, express or implied. The Australian National University
1311967Speter * makes no representations about the suitability of this software for
1411967Speter * any purpose.
1511967Speter *
1611967Speter * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
1711967Speter * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
1811967Speter * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
1911967Speter * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
2011967Speter * OF SUCH DAMAGE.
2111967Speter *
2211967Speter * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
2311967Speter * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
2411967Speter * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
2511967Speter * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
2611967Speter * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
2711967Speter * OR MODIFICATIONS.
2811967Speter */
2911967Speter
3011967Speter#ifndef _PPP_DEFS_H_
3111967Speter#define _PPP_DEFS_H_
3211967Speter
3311967Speter/*
3411967Speter * The basic PPP frame.
3511967Speter */
3611967Speter#define PPP_HDRLEN	4	/* octets for standard ppp header */
3711967Speter#define PPP_FCSLEN	2	/* octets for FCS */
3811967Speter#define PPP_MRU		1500	/* default MRU = max length of info field */
3911967Speter
4011967Speter#define PPP_ADDRESS(p)	(((u_char *)(p))[0])
4111967Speter#define PPP_CONTROL(p)	(((u_char *)(p))[1])
4211967Speter#define PPP_PROTOCOL(p)	((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
4311967Speter
4411967Speter/*
4511967Speter * Significant octet values.
4611967Speter */
4711967Speter#define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
4811967Speter#define	PPP_UI		0x03	/* Unnumbered Information */
4911967Speter#define	PPP_FLAG	0x7e	/* Flag Sequence */
5011967Speter#define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
5111967Speter#define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
5211967Speter
5311967Speter/*
5411967Speter * Protocol field values.
5511967Speter */
5611967Speter#define PPP_IP		0x21	/* Internet Protocol */
5711967Speter#define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */
5811967Speter#define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */
5911967Speter#define PPP_COMP	0xfd	/* compressed packet */
6011967Speter#define PPP_IPCP	0x8021	/* IP Control Protocol */
6111967Speter#define PPP_CCP		0x80fd	/* Compression Control Protocol */
6211967Speter#define PPP_LCP		0xc021	/* Link Control Protocol */
6311967Speter#define PPP_PAP		0xc023	/* Password Authentication Protocol */
6411967Speter#define PPP_LQR		0xc025	/* Link Quality Report protocol */
6511967Speter#define PPP_CHAP	0xc223	/* Cryptographic Handshake Auth. Protocol */
6611967Speter
6711967Speter/*
6811967Speter * Values for FCS calculations.
6911967Speter */
7011967Speter#define PPP_INITFCS	0xffff	/* Initial FCS value */
7111967Speter#define PPP_GOODFCS	0xf0b8	/* Good final FCS value */
7211967Speter#define PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
7311967Speter
7411967Speter/*
7511967Speter * A 32-bit unsigned integral type.
7611967Speter */
7711967Speter#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES)
7811967Speter#ifdef	UINT32_T
7911967Spetertypedef UINT32_T	u_int32_t;
8011967Speter#else
8111967Spetertypedef unsigned int	u_int32_t;
8211967Speter#endif
8311967Speter#endif
8411967Speter
8511967Speter/*
8611967Speter * Extended asyncmap - allows any character to be escaped.
8711967Speter */
8811967Spetertypedef u_int32_t	ext_accm[8];
8911967Speter
9011967Speter/*
9111967Speter * What to do with network protocol (NP) packets.
9211967Speter */
9311967Speterenum NPmode {
9411967Speter    NPMODE_PASS,		/* pass the packet through */
9511967Speter    NPMODE_DROP,		/* silently drop the packet */
9611967Speter    NPMODE_ERROR,		/* return an error */
9711967Speter    NPMODE_QUEUE		/* save it up for later. */
9811967Speter};
9911967Speter
10011967Speter/*
10111967Speter * Statistics.
10211967Speter */
10311967Speterstruct pppstat	{
10411967Speter    u_int	ppp_ibytes;	/* bytes received */
10511967Speter    u_int	ppp_ipackets;	/* packets received */
10611967Speter    u_int	ppp_ierrors;	/* receive errors */
10711967Speter    u_int	ppp_obytes;	/* bytes sent */
10811967Speter    u_int	ppp_opackets;	/* packets sent */
10911967Speter    u_int	ppp_oerrors;	/* transmit errors */
11011967Speter};
11111967Speter
11211967Speterstruct vjstat {
11311967Speter    u_int	vjs_packets;	/* outbound packets */
11411967Speter    u_int	vjs_compressed;	/* outbound compressed packets */
11511967Speter    u_int	vjs_searches;	/* searches for connection state */
11611967Speter    u_int	vjs_misses;	/* times couldn't find conn. state */
11711967Speter    u_int	vjs_uncompressedin; /* inbound uncompressed packets */
11811967Speter    u_int	vjs_compressedin;   /* inbound compressed packets */
11911967Speter    u_int	vjs_errorin;	/* inbound unknown type packets */
12011967Speter    u_int	vjs_tossed;	/* inbound packets tossed because of error */
12111967Speter};
12211967Speter
12311967Speterstruct ppp_stats {
12411967Speter    struct pppstat	p;	/* basic PPP statistics */
12511967Speter    struct vjstat	vj;	/* VJ header compression statistics */
12611967Speter};
12711967Speter
12811967Speterstruct compstat {
12911967Speter    u_int	unc_bytes;	/* total uncompressed bytes */
13011967Speter    u_int	unc_packets;	/* total uncompressed packets */
13111967Speter    u_int	comp_bytes;	/* compressed bytes */
13211967Speter    u_int	comp_packets;	/* compressed packets */
13311967Speter    u_int	inc_bytes;	/* incompressible bytes */
13411967Speter    u_int	inc_packets;	/* incompressible packets */
13511967Speter    u_int	ratio;		/* recent compression ratio << 8 */
13611967Speter};
13711967Speter
13811967Speterstruct ppp_comp_stats {
13911967Speter    struct compstat	c;	/* packet compression statistics */
14011967Speter    struct compstat	d;	/* packet decompression statistics */
14111967Speter};
14211967Speter
14311967Speter/*
14411967Speter * The following structure records the time in seconds since
14511967Speter * the last NP packet was sent or received.
14611967Speter */
14711967Speterstruct ppp_idle {
14811967Speter    time_t xmit_idle;		/* time since last NP packet sent */
14911967Speter    time_t recv_idle;		/* time since last NP packet received */
15011967Speter};
15111967Speter
15211967Speter#ifndef __P
15311967Speter#ifdef __STDC__
15411967Speter#define __P(x)	x
15511967Speter#else
15611967Speter#define __P(x)	()
15711967Speter#endif
15811967Speter#endif
15911967Speter
16011967Speter#endif /* _PPP_DEFS_H_ */
161