xref: /f-stack/tools/compat/include/netgraph/ng_ppp.h (revision 3b2bd0f6)
1*3b2bd0f6Slogwang /*
2*3b2bd0f6Slogwang  * ng_ppp.h
3*3b2bd0f6Slogwang  */
4*3b2bd0f6Slogwang 
5*3b2bd0f6Slogwang /*-
6*3b2bd0f6Slogwang  * Copyright (c) 1996-2000 Whistle Communications, Inc.
7*3b2bd0f6Slogwang  * All rights reserved.
8*3b2bd0f6Slogwang  *
9*3b2bd0f6Slogwang  * Subject to the following obligations and disclaimer of warranty, use and
10*3b2bd0f6Slogwang  * redistribution of this software, in source or object code forms, with or
11*3b2bd0f6Slogwang  * without modifications are expressly permitted by Whistle Communications;
12*3b2bd0f6Slogwang  * provided, however, that:
13*3b2bd0f6Slogwang  * 1. Any and all reproductions of the source or object code must include the
14*3b2bd0f6Slogwang  *    copyright notice above and the following disclaimer of warranties; and
15*3b2bd0f6Slogwang  * 2. No rights are granted, in any manner or form, to use Whistle
16*3b2bd0f6Slogwang  *    Communications, Inc. trademarks, including the mark "WHISTLE
17*3b2bd0f6Slogwang  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
18*3b2bd0f6Slogwang  *    such appears in the above copyright notice or in the software.
19*3b2bd0f6Slogwang  *
20*3b2bd0f6Slogwang  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
21*3b2bd0f6Slogwang  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
22*3b2bd0f6Slogwang  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
23*3b2bd0f6Slogwang  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
24*3b2bd0f6Slogwang  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
25*3b2bd0f6Slogwang  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
26*3b2bd0f6Slogwang  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
27*3b2bd0f6Slogwang  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
28*3b2bd0f6Slogwang  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
29*3b2bd0f6Slogwang  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
30*3b2bd0f6Slogwang  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31*3b2bd0f6Slogwang  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
32*3b2bd0f6Slogwang  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33*3b2bd0f6Slogwang  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34*3b2bd0f6Slogwang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35*3b2bd0f6Slogwang  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36*3b2bd0f6Slogwang  * OF SUCH DAMAGE.
37*3b2bd0f6Slogwang  *
38*3b2bd0f6Slogwang  * Author: Archie Cobbs <[email protected]>
39*3b2bd0f6Slogwang  *
40*3b2bd0f6Slogwang  * $FreeBSD$
41*3b2bd0f6Slogwang  * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
42*3b2bd0f6Slogwang  */
43*3b2bd0f6Slogwang 
44*3b2bd0f6Slogwang #ifndef _NETGRAPH_NG_PPP_H_
45*3b2bd0f6Slogwang #define _NETGRAPH_NG_PPP_H_
46*3b2bd0f6Slogwang 
47*3b2bd0f6Slogwang /* Node type name and magic cookie */
48*3b2bd0f6Slogwang #define NG_PPP_NODE_TYPE	"ppp"
49*3b2bd0f6Slogwang #define NGM_PPP_COOKIE		940897795
50*3b2bd0f6Slogwang 
51*3b2bd0f6Slogwang /* 64bit stats presence flag */
52*3b2bd0f6Slogwang #define NG_PPP_STATS64
53*3b2bd0f6Slogwang 
54*3b2bd0f6Slogwang /* Maximum number of supported links */
55*3b2bd0f6Slogwang #define NG_PPP_MAX_LINKS	16
56*3b2bd0f6Slogwang 
57*3b2bd0f6Slogwang /* Pseudo-link number representing the multi-link bundle */
58*3b2bd0f6Slogwang #define NG_PPP_BUNDLE_LINKNUM	0xffff
59*3b2bd0f6Slogwang 
60*3b2bd0f6Slogwang /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
61*3b2bd0f6Slogwang #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
62*3b2bd0f6Slogwang #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
63*3b2bd0f6Slogwang 
64*3b2bd0f6Slogwang /* Hook names */
65*3b2bd0f6Slogwang #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
66*3b2bd0f6Slogwang #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
67*3b2bd0f6Slogwang #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
68*3b2bd0f6Slogwang #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
69*3b2bd0f6Slogwang #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
70*3b2bd0f6Slogwang #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
71*3b2bd0f6Slogwang #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
72*3b2bd0f6Slogwang #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
73*3b2bd0f6Slogwang #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
74*3b2bd0f6Slogwang #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
75*3b2bd0f6Slogwang #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
76*3b2bd0f6Slogwang #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
77*3b2bd0f6Slogwang #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
78*3b2bd0f6Slogwang 
79*3b2bd0f6Slogwang #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
80*3b2bd0f6Slogwang 
81*3b2bd0f6Slogwang /* Compress hook operation modes */
82*3b2bd0f6Slogwang enum {
83*3b2bd0f6Slogwang 	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
84*3b2bd0f6Slogwang 	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
85*3b2bd0f6Slogwang 	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
86*3b2bd0f6Slogwang };
87*3b2bd0f6Slogwang 
88*3b2bd0f6Slogwang /* Decompress hook operation modes */
89*3b2bd0f6Slogwang enum {
90*3b2bd0f6Slogwang 	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
91*3b2bd0f6Slogwang 	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
92*3b2bd0f6Slogwang 	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
93*3b2bd0f6Slogwang };
94*3b2bd0f6Slogwang 
95*3b2bd0f6Slogwang /* Netgraph commands */
96*3b2bd0f6Slogwang enum {
97*3b2bd0f6Slogwang 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
98*3b2bd0f6Slogwang 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
99*3b2bd0f6Slogwang 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
100*3b2bd0f6Slogwang 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
101*3b2bd0f6Slogwang 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
102*3b2bd0f6Slogwang 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
103*3b2bd0f6Slogwang 	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
104*3b2bd0f6Slogwang 	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
105*3b2bd0f6Slogwang };
106*3b2bd0f6Slogwang 
107*3b2bd0f6Slogwang /* Multi-link sequence number state (for debugging) */
108*3b2bd0f6Slogwang struct ng_ppp_mp_state {
109*3b2bd0f6Slogwang 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
110*3b2bd0f6Slogwang 	int32_t		mseq;			/* min rseq[i] */
111*3b2bd0f6Slogwang 	int32_t		xseq;			/* next xmit MP seq # */
112*3b2bd0f6Slogwang };
113*3b2bd0f6Slogwang 
114*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
115*3b2bd0f6Slogwang #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
116*3b2bd0f6Slogwang 	  { "rseq",	(atype)			},		\
117*3b2bd0f6Slogwang 	  { "mseq",	&ng_parse_hint32_type	},		\
118*3b2bd0f6Slogwang 	  { "xseq",	&ng_parse_hint32_type	},		\
119*3b2bd0f6Slogwang 	  { NULL }						\
120*3b2bd0f6Slogwang }
121*3b2bd0f6Slogwang 
122*3b2bd0f6Slogwang /* Per-link config structure */
123*3b2bd0f6Slogwang struct ng_ppp_link_conf {
124*3b2bd0f6Slogwang 	u_char		enableLink;	/* enable this link */
125*3b2bd0f6Slogwang 	u_char		enableProtoComp;/* enable protocol field compression */
126*3b2bd0f6Slogwang 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
127*3b2bd0f6Slogwang 	u_int16_t	mru;		/* peer MRU */
128*3b2bd0f6Slogwang 	u_int32_t	latency;	/* link latency (in milliseconds) */
129*3b2bd0f6Slogwang 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
130*3b2bd0f6Slogwang };
131*3b2bd0f6Slogwang 
132*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
133*3b2bd0f6Slogwang #define NG_PPP_LINK_TYPE_INFO	{				\
134*3b2bd0f6Slogwang 	  { "enableLink",	&ng_parse_uint8_type	},	\
135*3b2bd0f6Slogwang 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
136*3b2bd0f6Slogwang 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
137*3b2bd0f6Slogwang 	  { "mru",		&ng_parse_uint16_type	},	\
138*3b2bd0f6Slogwang 	  { "latency",		&ng_parse_uint32_type	},	\
139*3b2bd0f6Slogwang 	  { "bandwidth",	&ng_parse_uint32_type	},	\
140*3b2bd0f6Slogwang 	  { NULL }						\
141*3b2bd0f6Slogwang }
142*3b2bd0f6Slogwang 
143*3b2bd0f6Slogwang /* Bundle config structure */
144*3b2bd0f6Slogwang struct ng_ppp_bund_conf {
145*3b2bd0f6Slogwang 	u_int16_t	mrru;			/* multilink peer MRRU */
146*3b2bd0f6Slogwang 	u_char		enableMultilink;	/* enable multilink */
147*3b2bd0f6Slogwang 	u_char		recvShortSeq;		/* recv multilink short seq # */
148*3b2bd0f6Slogwang 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
149*3b2bd0f6Slogwang 	u_char		enableRoundRobin;	/* xmit whole packets */
150*3b2bd0f6Slogwang 	u_char		enableIP;		/* enable IP data flow */
151*3b2bd0f6Slogwang 	u_char		enableIPv6;		/* enable IPv6 data flow */
152*3b2bd0f6Slogwang 	u_char		enableAtalk;		/* enable AppleTalk data flow */
153*3b2bd0f6Slogwang 	u_char		enableIPX;		/* enable IPX data flow */
154*3b2bd0f6Slogwang 	u_char		enableCompression;	/* enable PPP compression */
155*3b2bd0f6Slogwang 	u_char		enableDecompression;	/* enable PPP decompression */
156*3b2bd0f6Slogwang 	u_char		enableEncryption;	/* enable PPP encryption */
157*3b2bd0f6Slogwang 	u_char		enableDecryption;	/* enable PPP decryption */
158*3b2bd0f6Slogwang 	u_char		enableVJCompression;	/* enable VJ compression */
159*3b2bd0f6Slogwang 	u_char		enableVJDecompression;	/* enable VJ decompression */
160*3b2bd0f6Slogwang };
161*3b2bd0f6Slogwang 
162*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
163*3b2bd0f6Slogwang #define NG_PPP_BUND_TYPE_INFO	{					\
164*3b2bd0f6Slogwang 	  { "mrru",			&ng_parse_uint16_type	},	\
165*3b2bd0f6Slogwang 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
166*3b2bd0f6Slogwang 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
167*3b2bd0f6Slogwang 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
168*3b2bd0f6Slogwang 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
169*3b2bd0f6Slogwang 	  { "enableIP",			&ng_parse_uint8_type	},	\
170*3b2bd0f6Slogwang 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
171*3b2bd0f6Slogwang 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
172*3b2bd0f6Slogwang 	  { "enableIPX",		&ng_parse_uint8_type	},	\
173*3b2bd0f6Slogwang 	  { "enableCompression",	&ng_parse_uint8_type	},	\
174*3b2bd0f6Slogwang 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
175*3b2bd0f6Slogwang 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
176*3b2bd0f6Slogwang 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
177*3b2bd0f6Slogwang 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
178*3b2bd0f6Slogwang 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
179*3b2bd0f6Slogwang 	  { NULL }							\
180*3b2bd0f6Slogwang }
181*3b2bd0f6Slogwang 
182*3b2bd0f6Slogwang /* Total node config structure */
183*3b2bd0f6Slogwang struct ng_ppp_node_conf {
184*3b2bd0f6Slogwang 	struct ng_ppp_bund_conf	bund;
185*3b2bd0f6Slogwang 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
186*3b2bd0f6Slogwang };
187*3b2bd0f6Slogwang 
188*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
189*3b2bd0f6Slogwang #define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
190*3b2bd0f6Slogwang 	  { "bund",		(bctype)	},		\
191*3b2bd0f6Slogwang 	  { "links",		(arytype)	},		\
192*3b2bd0f6Slogwang 	  { NULL }						\
193*3b2bd0f6Slogwang }
194*3b2bd0f6Slogwang 
195*3b2bd0f6Slogwang /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
196*3b2bd0f6Slogwang struct ng_ppp_link_stat {
197*3b2bd0f6Slogwang 	u_int32_t xmitFrames;		/* xmit frames on link */
198*3b2bd0f6Slogwang 	u_int32_t xmitOctets;		/* xmit octets on link */
199*3b2bd0f6Slogwang 	u_int32_t recvFrames;		/* recv frames on link */
200*3b2bd0f6Slogwang 	u_int32_t recvOctets;		/* recv octets on link */
201*3b2bd0f6Slogwang 	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
202*3b2bd0f6Slogwang 	u_int32_t runts;		/* Too short MP fragments */
203*3b2bd0f6Slogwang 	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
204*3b2bd0f6Slogwang 	u_int32_t dropFragments;	/* MP fragments we had to drop */
205*3b2bd0f6Slogwang };
206*3b2bd0f6Slogwang 
207*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
208*3b2bd0f6Slogwang #define NG_PPP_STATS_TYPE_INFO	{				\
209*3b2bd0f6Slogwang 	  { "xmitFrames",	&ng_parse_uint32_type	},	\
210*3b2bd0f6Slogwang 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
211*3b2bd0f6Slogwang 	  { "recvFrames",	&ng_parse_uint32_type	},	\
212*3b2bd0f6Slogwang 	  { "recvOctets",	&ng_parse_uint32_type	},	\
213*3b2bd0f6Slogwang 	  { "badProtos",	&ng_parse_uint32_type	},	\
214*3b2bd0f6Slogwang 	  { "runts",		&ng_parse_uint32_type	},	\
215*3b2bd0f6Slogwang 	  { "dupFragments",	&ng_parse_uint32_type	},	\
216*3b2bd0f6Slogwang 	  { "dropFragments",	&ng_parse_uint32_type	},	\
217*3b2bd0f6Slogwang 	  { NULL }						\
218*3b2bd0f6Slogwang }
219*3b2bd0f6Slogwang 
220*3b2bd0f6Slogwang /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
221*3b2bd0f6Slogwang struct ng_ppp_link_stat64 {
222*3b2bd0f6Slogwang 	u_int64_t xmitFrames;		/* xmit frames on link */
223*3b2bd0f6Slogwang 	u_int64_t xmitOctets;		/* xmit octets on link */
224*3b2bd0f6Slogwang 	u_int64_t recvFrames;		/* recv frames on link */
225*3b2bd0f6Slogwang 	u_int64_t recvOctets;		/* recv octets on link */
226*3b2bd0f6Slogwang 	u_int64_t badProtos;		/* frames rec'd with bogus protocol */
227*3b2bd0f6Slogwang 	u_int64_t runts;		/* Too short MP fragments */
228*3b2bd0f6Slogwang 	u_int64_t dupFragments;		/* MP frames with duplicate seq # */
229*3b2bd0f6Slogwang 	u_int64_t dropFragments;	/* MP fragments we had to drop */
230*3b2bd0f6Slogwang };
231*3b2bd0f6Slogwang 
232*3b2bd0f6Slogwang /* Keep this in sync with the above structure definition */
233*3b2bd0f6Slogwang #define NG_PPP_STATS64_TYPE_INFO	{			\
234*3b2bd0f6Slogwang 	  { "xmitFrames",	&ng_parse_uint64_type	},	\
235*3b2bd0f6Slogwang 	  { "xmitOctets",	&ng_parse_uint64_type	},	\
236*3b2bd0f6Slogwang 	  { "recvFrames",	&ng_parse_uint64_type	},	\
237*3b2bd0f6Slogwang 	  { "recvOctets",	&ng_parse_uint64_type	},	\
238*3b2bd0f6Slogwang 	  { "badProtos",	&ng_parse_uint64_type	},	\
239*3b2bd0f6Slogwang 	  { "runts",		&ng_parse_uint64_type	},	\
240*3b2bd0f6Slogwang 	  { "dupFragments",	&ng_parse_uint64_type	},	\
241*3b2bd0f6Slogwang 	  { "dropFragments",	&ng_parse_uint64_type	},	\
242*3b2bd0f6Slogwang 	  { NULL }						\
243*3b2bd0f6Slogwang }
244*3b2bd0f6Slogwang 
245*3b2bd0f6Slogwang #endif /* _NETGRAPH_NG_PPP_H_ */
246