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