xref: /freebsd/sys/netgraph/ng_ppp.h (revision c398230b64aea809cb7c5cea8db580af7097920c)
14cf49a43SJulian Elischer /*
24cf49a43SJulian Elischer  * ng_ppp.h
3c398230bSWarner Losh  */
4c398230bSWarner Losh 
5c398230bSWarner Losh /*-
6a9b3dca5SArchie Cobbs  * Copyright (c) 1996-2000 Whistle Communications, Inc.
74cf49a43SJulian Elischer  * All rights reserved.
84cf49a43SJulian Elischer  *
94cf49a43SJulian Elischer  * Subject to the following obligations and disclaimer of warranty, use and
104cf49a43SJulian Elischer  * redistribution of this software, in source or object code forms, with or
114cf49a43SJulian Elischer  * without modifications are expressly permitted by Whistle Communications;
124cf49a43SJulian Elischer  * provided, however, that:
134cf49a43SJulian Elischer  * 1. Any and all reproductions of the source or object code must include the
144cf49a43SJulian Elischer  *    copyright notice above and the following disclaimer of warranties; and
154cf49a43SJulian Elischer  * 2. No rights are granted, in any manner or form, to use Whistle
164cf49a43SJulian Elischer  *    Communications, Inc. trademarks, including the mark "WHISTLE
174cf49a43SJulian Elischer  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
184cf49a43SJulian Elischer  *    such appears in the above copyright notice or in the software.
194cf49a43SJulian Elischer  *
204cf49a43SJulian Elischer  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
214cf49a43SJulian Elischer  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
224cf49a43SJulian Elischer  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
234cf49a43SJulian Elischer  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
244cf49a43SJulian Elischer  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
254cf49a43SJulian Elischer  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
264cf49a43SJulian Elischer  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
274cf49a43SJulian Elischer  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
284cf49a43SJulian Elischer  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
294cf49a43SJulian Elischer  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
304cf49a43SJulian Elischer  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
314cf49a43SJulian Elischer  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
324cf49a43SJulian Elischer  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
334cf49a43SJulian Elischer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
344cf49a43SJulian Elischer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
354cf49a43SJulian Elischer  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
364cf49a43SJulian Elischer  * OF SUCH DAMAGE.
374cf49a43SJulian Elischer  *
386f16db81SArchie Cobbs  * Author: Archie Cobbs <archie@freebsd.org>
394cf49a43SJulian Elischer  *
404cf49a43SJulian Elischer  * $FreeBSD$
414cf49a43SJulian Elischer  * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
424cf49a43SJulian Elischer  */
434cf49a43SJulian Elischer 
44e20480bfSRuslan Ermilov #ifndef _NETGRAPH_NG_PPP_H_
45e20480bfSRuslan Ermilov #define _NETGRAPH_NG_PPP_H_
464cf49a43SJulian Elischer 
474cf49a43SJulian Elischer /* Node type name and magic cookie */
484cf49a43SJulian Elischer #define NG_PPP_NODE_TYPE	"ppp"
496f16db81SArchie Cobbs #define NGM_PPP_COOKIE		940897795
503949bee8SArchie Cobbs 
513949bee8SArchie Cobbs /* Maximum number of supported links */
523949bee8SArchie Cobbs #define NG_PPP_MAX_LINKS	16
533949bee8SArchie Cobbs 
543949bee8SArchie Cobbs /* Pseudo-link number representing the multi-link bundle */
553949bee8SArchie Cobbs #define NG_PPP_BUNDLE_LINKNUM	0xffff
563949bee8SArchie Cobbs 
573949bee8SArchie Cobbs /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
583949bee8SArchie Cobbs #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
593949bee8SArchie Cobbs #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
604cf49a43SJulian Elischer 
614cf49a43SJulian Elischer /* Hook names */
623949bee8SArchie Cobbs #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
633949bee8SArchie Cobbs #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
643949bee8SArchie Cobbs #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
653949bee8SArchie Cobbs #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
663949bee8SArchie Cobbs #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
673949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
683949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
693949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
703949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
713949bee8SArchie Cobbs #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
723949bee8SArchie Cobbs #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
733949bee8SArchie Cobbs #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
74a9b3dca5SArchie Cobbs #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
753949bee8SArchie Cobbs 
763949bee8SArchie Cobbs #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
774cf49a43SJulian Elischer 
784cf49a43SJulian Elischer /* Netgraph commands */
794cf49a43SJulian Elischer enum {
80a9b3dca5SArchie Cobbs 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
81a9b3dca5SArchie Cobbs 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
826f16db81SArchie Cobbs 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
833949bee8SArchie Cobbs 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
843949bee8SArchie Cobbs 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
85e149c4e2SArchie Cobbs 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
864cf49a43SJulian Elischer };
874cf49a43SJulian Elischer 
886f16db81SArchie Cobbs /* Multi-link sequence number state (for debugging) */
896f16db81SArchie Cobbs struct ng_ppp_mp_state {
906f16db81SArchie Cobbs 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
916f16db81SArchie Cobbs 	int32_t		mseq;			/* min rseq[i] */
926f16db81SArchie Cobbs 	int32_t		xseq;			/* next xmit MP seq # */
936f16db81SArchie Cobbs };
946f16db81SArchie Cobbs 
956f16db81SArchie Cobbs /* Keep this in sync with the above structure definition */
966f16db81SArchie Cobbs #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
976f16db81SArchie Cobbs 	  { "rseq",	(atype)			},		\
986f16db81SArchie Cobbs 	  { "mseq",	&ng_parse_hint32_type	},		\
996f16db81SArchie Cobbs 	  { "xseq",	&ng_parse_hint32_type	},		\
100f0184ff8SArchie Cobbs 	  { NULL }						\
1016f16db81SArchie Cobbs }
1026f16db81SArchie Cobbs 
1033949bee8SArchie Cobbs /* Per-link config structure */
104a9b3dca5SArchie Cobbs struct ng_ppp_link_conf {
1053949bee8SArchie Cobbs 	u_char		enableLink;	/* enable this link */
1063949bee8SArchie Cobbs 	u_char		enableProtoComp;/* enable protocol field compression */
107d690a6e7SArchie Cobbs 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
1083949bee8SArchie Cobbs 	u_int16_t	mru;		/* peer MRU */
1093949bee8SArchie Cobbs 	u_int32_t	latency;	/* link latency (in milliseconds) */
1103949bee8SArchie Cobbs 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/second) */
1114cf49a43SJulian Elischer };
1124cf49a43SJulian Elischer 
113f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
114f8307e12SArchie Cobbs #define NG_PPP_LINK_TYPE_INFO	{				\
11557b57be3SArchie Cobbs 	  { "enableLink",	&ng_parse_uint8_type	},	\
11657b57be3SArchie Cobbs 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
11757b57be3SArchie Cobbs 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
11857b57be3SArchie Cobbs 	  { "mru",		&ng_parse_uint16_type	},	\
11957b57be3SArchie Cobbs 	  { "latency",		&ng_parse_uint32_type	},	\
12057b57be3SArchie Cobbs 	  { "bandwidth",	&ng_parse_uint32_type	},	\
121f0184ff8SArchie Cobbs 	  { NULL }						\
122f8307e12SArchie Cobbs }
123f8307e12SArchie Cobbs 
124a9b3dca5SArchie Cobbs /* Bundle config structure */
125a9b3dca5SArchie Cobbs struct ng_ppp_bund_conf {
1263949bee8SArchie Cobbs 	u_int16_t	mrru;			/* multilink peer MRRU */
1273949bee8SArchie Cobbs 	u_char		enableMultilink;	/* enable multilink */
1283949bee8SArchie Cobbs 	u_char		recvShortSeq;		/* recv multilink short seq # */
1293949bee8SArchie Cobbs 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
1303949bee8SArchie Cobbs 	u_char		enableRoundRobin;	/* xmit whole packets */
1313949bee8SArchie Cobbs 	u_char		enableIP;		/* enable IP data flow */
132a9b3dca5SArchie Cobbs 	u_char		enableIPv6;		/* enable IPv6 data flow */
1333949bee8SArchie Cobbs 	u_char		enableAtalk;		/* enable AppleTalk data flow */
1343949bee8SArchie Cobbs 	u_char		enableIPX;		/* enable IPX data flow */
1353949bee8SArchie Cobbs 	u_char		enableCompression;	/* enable PPP compression */
1363949bee8SArchie Cobbs 	u_char		enableDecompression;	/* enable PPP decompression */
1373949bee8SArchie Cobbs 	u_char		enableEncryption;	/* enable PPP encryption */
1383949bee8SArchie Cobbs 	u_char		enableDecryption;	/* enable PPP decryption */
1393949bee8SArchie Cobbs 	u_char		enableVJCompression;	/* enable VJ compression */
1403949bee8SArchie Cobbs 	u_char		enableVJDecompression;	/* enable VJ decompression */
1413949bee8SArchie Cobbs };
1423949bee8SArchie Cobbs 
143f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
144a9b3dca5SArchie Cobbs #define NG_PPP_BUND_TYPE_INFO	{					\
14557b57be3SArchie Cobbs 	  { "mrru",			&ng_parse_uint16_type	},	\
14657b57be3SArchie Cobbs 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
14757b57be3SArchie Cobbs 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
14857b57be3SArchie Cobbs 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
14957b57be3SArchie Cobbs 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
15057b57be3SArchie Cobbs 	  { "enableIP",			&ng_parse_uint8_type	},	\
15157b57be3SArchie Cobbs 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
15257b57be3SArchie Cobbs 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
15357b57be3SArchie Cobbs 	  { "enableIPX",		&ng_parse_uint8_type	},	\
15457b57be3SArchie Cobbs 	  { "enableCompression",	&ng_parse_uint8_type	},	\
15557b57be3SArchie Cobbs 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
15657b57be3SArchie Cobbs 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
15757b57be3SArchie Cobbs 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
15857b57be3SArchie Cobbs 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
15957b57be3SArchie Cobbs 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
160a9b3dca5SArchie Cobbs 	  { NULL }							\
161a9b3dca5SArchie Cobbs }
162a9b3dca5SArchie Cobbs 
163a9b3dca5SArchie Cobbs /* Total node config structure */
164a9b3dca5SArchie Cobbs struct ng_ppp_node_conf {
165a9b3dca5SArchie Cobbs 	struct ng_ppp_bund_conf	bund;
166a9b3dca5SArchie Cobbs 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
167a9b3dca5SArchie Cobbs };
168a9b3dca5SArchie Cobbs 
169a9b3dca5SArchie Cobbs /* Keep this in sync with the above structure definition */
170a9b3dca5SArchie Cobbs #define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
171a9b3dca5SArchie Cobbs 	  { "bund",		(bctype)	},		\
172f8307e12SArchie Cobbs 	  { "links",		(arytype)	},		\
173a9b3dca5SArchie Cobbs 	  { NULL }						\
174f8307e12SArchie Cobbs }
175f8307e12SArchie Cobbs 
1763949bee8SArchie Cobbs /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
1773949bee8SArchie Cobbs struct ng_ppp_link_stat {
1783949bee8SArchie Cobbs 	u_int32_t xmitFrames;		/* xmit frames on link */
1793949bee8SArchie Cobbs 	u_int32_t xmitOctets;		/* xmit octets on link */
1803949bee8SArchie Cobbs 	u_int32_t recvFrames;		/* recv frames on link */
1813949bee8SArchie Cobbs 	u_int32_t recvOctets;		/* recv octets on link */
1823949bee8SArchie Cobbs 	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
183a9b3dca5SArchie Cobbs 	u_int32_t runts;		/* Too short MP fragments */
1843949bee8SArchie Cobbs 	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
185a9b3dca5SArchie Cobbs 	u_int32_t dropFragments;	/* MP fragments we had to drop */
1863949bee8SArchie Cobbs };
1874cf49a43SJulian Elischer 
188f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
189f8307e12SArchie Cobbs #define NG_PPP_STATS_TYPE_INFO	{				\
19057b57be3SArchie Cobbs 	  { "xmitFrames",	&ng_parse_uint32_type	},	\
19157b57be3SArchie Cobbs 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
19257b57be3SArchie Cobbs 	  { "recvFrames",	&ng_parse_uint32_type	},	\
19357b57be3SArchie Cobbs 	  { "recvOctets",	&ng_parse_uint32_type	},	\
19457b57be3SArchie Cobbs 	  { "badProtos",	&ng_parse_uint32_type	},	\
19557b57be3SArchie Cobbs 	  { "runts",		&ng_parse_uint32_type	},	\
19657b57be3SArchie Cobbs 	  { "dupFragments",	&ng_parse_uint32_type	},	\
19757b57be3SArchie Cobbs 	  { "dropFragments",	&ng_parse_uint32_type	},	\
198a9b3dca5SArchie Cobbs 	  { NULL }						\
199f8307e12SArchie Cobbs }
200f8307e12SArchie Cobbs 
201e20480bfSRuslan Ermilov #endif /* _NETGRAPH_NG_PPP_H_ */
202