1  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2  /*
3   * ppp_defs.h - PPP definitions.
4   *
5   * Copyright 1994-2000 Paul Mackerras.
6   *
7   *  This program is free software; you can redistribute it and/or
8   *  modify it under the terms of the GNU General Public License
9   *  version 2 as published by the Free Software Foundation.
10   */
11  #include <linux/types.h>
12  
13  #ifndef _UAPI_PPP_DEFS_H_
14  #define _UAPI_PPP_DEFS_H_
15  
16  /*
17   * The basic PPP frame.
18   */
19  #define PPP_HDRLEN	4	/* octets for standard ppp header */
20  #define PPP_FCSLEN	2	/* octets for FCS */
21  #define PPP_MRU		1500	/* default MRU = max length of info field */
22  
23  #define PPP_ADDRESS(p)	(((__u8 *)(p))[0])
24  #define PPP_CONTROL(p)	(((__u8 *)(p))[1])
25  #define PPP_PROTOCOL(p)	((((__u8 *)(p))[2] << 8) + ((__u8 *)(p))[3])
26  
27  /*
28   * Significant octet values.
29   */
30  #define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
31  #define	PPP_UI		0x03	/* Unnumbered Information */
32  #define	PPP_FLAG	0x7e	/* Flag Sequence */
33  #define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
34  #define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
35  
36  /*
37   * Protocol field values.
38   */
39  #define PPP_IP		0x21	/* Internet Protocol */
40  #define PPP_AT		0x29	/* AppleTalk Protocol */
41  #define PPP_IPX		0x2b	/* IPX protocol */
42  #define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */
43  #define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */
44  #define PPP_MP		0x3d	/* Multilink protocol */
45  #define PPP_IPV6	0x57	/* Internet Protocol Version 6 */
46  #define PPP_COMPFRAG	0xfb	/* fragment compressed below bundle */
47  #define PPP_COMP	0xfd	/* compressed packet */
48  #define PPP_MPLS_UC	0x0281	/* Multi Protocol Label Switching - Unicast */
49  #define PPP_MPLS_MC	0x0283	/* Multi Protocol Label Switching - Multicast */
50  #define PPP_IPCP	0x8021	/* IP Control Protocol */
51  #define PPP_ATCP	0x8029	/* AppleTalk Control Protocol */
52  #define PPP_IPXCP	0x802b	/* IPX Control Protocol */
53  #define PPP_IPV6CP	0x8057	/* IPv6 Control Protocol */
54  #define PPP_CCPFRAG	0x80fb	/* CCP at link level (below MP bundle) */
55  #define PPP_CCP		0x80fd	/* Compression Control Protocol */
56  #define PPP_MPLSCP	0x80fd	/* MPLS Control Protocol */
57  #define PPP_LCP		0xc021	/* Link Control Protocol */
58  #define PPP_PAP		0xc023	/* Password Authentication Protocol */
59  #define PPP_LQR		0xc025	/* Link Quality Report protocol */
60  #define PPP_CHAP	0xc223	/* Cryptographic Handshake Auth. Protocol */
61  #define PPP_CBCP	0xc029	/* Callback Control Protocol */
62  
63  /*
64   * Values for FCS calculations.
65   */
66  
67  #define PPP_INITFCS	0xffff	/* Initial FCS value */
68  #define PPP_GOODFCS	0xf0b8	/* Good final FCS value */
69  
70  
71  /*
72   * Extended asyncmap - allows any character to be escaped.
73   */
74  
75  typedef __u32		ext_accm[8];
76  
77  /*
78   * What to do with network protocol (NP) packets.
79   */
80  enum NPmode {
81      NPMODE_PASS,		/* pass the packet through */
82      NPMODE_DROP,		/* silently drop the packet */
83      NPMODE_ERROR,		/* return an error */
84      NPMODE_QUEUE		/* save it up for later. */
85  };
86  
87  /*
88   * Statistics for LQRP and pppstats
89   */
90  struct pppstat	{
91      __u32	ppp_discards;	/* # frames discarded */
92  
93      __u32	ppp_ibytes;	/* bytes received */
94      __u32	ppp_ioctects;	/* bytes received not in error */
95      __u32	ppp_ipackets;	/* packets received */
96      __u32	ppp_ierrors;	/* receive errors */
97      __u32	ppp_ilqrs;	/* # LQR frames received */
98  
99      __u32	ppp_obytes;	/* raw bytes sent */
100      __u32	ppp_ooctects;	/* frame bytes sent */
101      __u32	ppp_opackets;	/* packets sent */
102      __u32	ppp_oerrors;	/* transmit errors */
103      __u32	ppp_olqrs;	/* # LQR frames sent */
104  };
105  
106  struct vjstat {
107      __u32	vjs_packets;	/* outbound packets */
108      __u32	vjs_compressed;	/* outbound compressed packets */
109      __u32	vjs_searches;	/* searches for connection state */
110      __u32	vjs_misses;	/* times couldn't find conn. state */
111      __u32	vjs_uncompressedin; /* inbound uncompressed packets */
112      __u32	vjs_compressedin;   /* inbound compressed packets */
113      __u32	vjs_errorin;	/* inbound unknown type packets */
114      __u32	vjs_tossed;	/* inbound packets tossed because of error */
115  };
116  
117  struct compstat {
118      __u32	unc_bytes;	/* total uncompressed bytes */
119      __u32	unc_packets;	/* total uncompressed packets */
120      __u32	comp_bytes;	/* compressed bytes */
121      __u32	comp_packets;	/* compressed packets */
122      __u32	inc_bytes;	/* incompressible bytes */
123      __u32	inc_packets;	/* incompressible packets */
124  
125      /* the compression ratio is defined as in_count / bytes_out */
126      __u32       in_count;	/* Bytes received */
127      __u32       bytes_out;	/* Bytes transmitted */
128  
129      double	ratio;		/* not computed in kernel. */
130  };
131  
132  struct ppp_stats {
133      struct pppstat	p;	/* basic PPP statistics */
134      struct vjstat	vj;	/* VJ header compression statistics */
135  };
136  
137  struct ppp_comp_stats {
138      struct compstat	c;	/* packet compression statistics */
139      struct compstat	d;	/* packet decompression statistics */
140  };
141  
142  /*
143   * The following structure records the time in seconds since
144   * the last NP packet was sent or received.
145   *
146   * Linux implements both 32-bit and 64-bit time_t versions
147   * for compatibility with user space that defines ppp_idle
148   * based on the libc time_t.
149   */
150  struct ppp_idle {
151      __kernel_old_time_t xmit_idle;	/* time since last NP packet sent */
152      __kernel_old_time_t recv_idle;	/* time since last NP packet received */
153  };
154  
155  struct ppp_idle32 {
156      __s32 xmit_idle;		/* time since last NP packet sent */
157      __s32 recv_idle;		/* time since last NP packet received */
158  };
159  
160  struct ppp_idle64 {
161      __s64 xmit_idle;		/* time since last NP packet sent */
162      __s64 recv_idle;		/* time since last NP packet received */
163  };
164  
165  #endif /* _UAPI_PPP_DEFS_H_ */
166