xref: /freebsd/sys/netgraph/ng_ppp.h (revision d6fe462ac16b73d5a449ab8bcdadb893e398ace1)
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 
51d6fe462aSAlexander Motin /* 64bit stats presence flag */
52d6fe462aSAlexander Motin #define NG_PPP_STATS64
53d6fe462aSAlexander Motin 
543949bee8SArchie Cobbs /* Maximum number of supported links */
553949bee8SArchie Cobbs #define NG_PPP_MAX_LINKS	16
563949bee8SArchie Cobbs 
573949bee8SArchie Cobbs /* Pseudo-link number representing the multi-link bundle */
583949bee8SArchie Cobbs #define NG_PPP_BUNDLE_LINKNUM	0xffff
593949bee8SArchie Cobbs 
603949bee8SArchie Cobbs /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
613949bee8SArchie Cobbs #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
623949bee8SArchie Cobbs #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
634cf49a43SJulian Elischer 
644cf49a43SJulian Elischer /* Hook names */
653949bee8SArchie Cobbs #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
663949bee8SArchie Cobbs #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
673949bee8SArchie Cobbs #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
683949bee8SArchie Cobbs #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
693949bee8SArchie Cobbs #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
703949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
713949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
723949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
733949bee8SArchie Cobbs #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
743949bee8SArchie Cobbs #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
753949bee8SArchie Cobbs #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
763949bee8SArchie Cobbs #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
77a9b3dca5SArchie Cobbs #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
783949bee8SArchie Cobbs 
793949bee8SArchie Cobbs #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
804cf49a43SJulian Elischer 
81ccb07cc3SGleb Smirnoff /* Compress hook operation modes */
82ccb07cc3SGleb Smirnoff enum {
83ccb07cc3SGleb Smirnoff 	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
84ccb07cc3SGleb Smirnoff 	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
85ccb07cc3SGleb Smirnoff 	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
86ccb07cc3SGleb Smirnoff };
87ccb07cc3SGleb Smirnoff 
88ccb07cc3SGleb Smirnoff /* Decompress hook operation modes */
89ccb07cc3SGleb Smirnoff enum {
90ccb07cc3SGleb Smirnoff 	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
91ccb07cc3SGleb Smirnoff 	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
92ccb07cc3SGleb Smirnoff 	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
93ccb07cc3SGleb Smirnoff };
94ccb07cc3SGleb Smirnoff 
954cf49a43SJulian Elischer /* Netgraph commands */
964cf49a43SJulian Elischer enum {
97a9b3dca5SArchie Cobbs 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
98a9b3dca5SArchie Cobbs 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
996f16db81SArchie Cobbs 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
1003949bee8SArchie Cobbs 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
1013949bee8SArchie Cobbs 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
102e149c4e2SArchie Cobbs 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
103d6fe462aSAlexander Motin 	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
104d6fe462aSAlexander Motin 	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
1054cf49a43SJulian Elischer };
1064cf49a43SJulian Elischer 
1076f16db81SArchie Cobbs /* Multi-link sequence number state (for debugging) */
1086f16db81SArchie Cobbs struct ng_ppp_mp_state {
1096f16db81SArchie Cobbs 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
1106f16db81SArchie Cobbs 	int32_t		mseq;			/* min rseq[i] */
1116f16db81SArchie Cobbs 	int32_t		xseq;			/* next xmit MP seq # */
1126f16db81SArchie Cobbs };
1136f16db81SArchie Cobbs 
1146f16db81SArchie Cobbs /* Keep this in sync with the above structure definition */
1156f16db81SArchie Cobbs #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
1166f16db81SArchie Cobbs 	  { "rseq",	(atype)			},		\
1176f16db81SArchie Cobbs 	  { "mseq",	&ng_parse_hint32_type	},		\
1186f16db81SArchie Cobbs 	  { "xseq",	&ng_parse_hint32_type	},		\
119f0184ff8SArchie Cobbs 	  { NULL }						\
1206f16db81SArchie Cobbs }
1216f16db81SArchie Cobbs 
1223949bee8SArchie Cobbs /* Per-link config structure */
123a9b3dca5SArchie Cobbs struct ng_ppp_link_conf {
1243949bee8SArchie Cobbs 	u_char		enableLink;	/* enable this link */
1253949bee8SArchie Cobbs 	u_char		enableProtoComp;/* enable protocol field compression */
126d690a6e7SArchie Cobbs 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
1273949bee8SArchie Cobbs 	u_int16_t	mru;		/* peer MRU */
1283949bee8SArchie Cobbs 	u_int32_t	latency;	/* link latency (in milliseconds) */
12925b67768SArchie Cobbs 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
1304cf49a43SJulian Elischer };
1314cf49a43SJulian Elischer 
132f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
133f8307e12SArchie Cobbs #define NG_PPP_LINK_TYPE_INFO	{				\
13457b57be3SArchie Cobbs 	  { "enableLink",	&ng_parse_uint8_type	},	\
13557b57be3SArchie Cobbs 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
13657b57be3SArchie Cobbs 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
13757b57be3SArchie Cobbs 	  { "mru",		&ng_parse_uint16_type	},	\
13857b57be3SArchie Cobbs 	  { "latency",		&ng_parse_uint32_type	},	\
13957b57be3SArchie Cobbs 	  { "bandwidth",	&ng_parse_uint32_type	},	\
140f0184ff8SArchie Cobbs 	  { NULL }						\
141f8307e12SArchie Cobbs }
142f8307e12SArchie Cobbs 
143a9b3dca5SArchie Cobbs /* Bundle config structure */
144a9b3dca5SArchie Cobbs struct ng_ppp_bund_conf {
1453949bee8SArchie Cobbs 	u_int16_t	mrru;			/* multilink peer MRRU */
1463949bee8SArchie Cobbs 	u_char		enableMultilink;	/* enable multilink */
1473949bee8SArchie Cobbs 	u_char		recvShortSeq;		/* recv multilink short seq # */
1483949bee8SArchie Cobbs 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
1493949bee8SArchie Cobbs 	u_char		enableRoundRobin;	/* xmit whole packets */
1503949bee8SArchie Cobbs 	u_char		enableIP;		/* enable IP data flow */
151a9b3dca5SArchie Cobbs 	u_char		enableIPv6;		/* enable IPv6 data flow */
1523949bee8SArchie Cobbs 	u_char		enableAtalk;		/* enable AppleTalk data flow */
1533949bee8SArchie Cobbs 	u_char		enableIPX;		/* enable IPX data flow */
1543949bee8SArchie Cobbs 	u_char		enableCompression;	/* enable PPP compression */
1553949bee8SArchie Cobbs 	u_char		enableDecompression;	/* enable PPP decompression */
1563949bee8SArchie Cobbs 	u_char		enableEncryption;	/* enable PPP encryption */
1573949bee8SArchie Cobbs 	u_char		enableDecryption;	/* enable PPP decryption */
1583949bee8SArchie Cobbs 	u_char		enableVJCompression;	/* enable VJ compression */
1593949bee8SArchie Cobbs 	u_char		enableVJDecompression;	/* enable VJ decompression */
1603949bee8SArchie Cobbs };
1613949bee8SArchie Cobbs 
162f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
163a9b3dca5SArchie Cobbs #define NG_PPP_BUND_TYPE_INFO	{					\
16457b57be3SArchie Cobbs 	  { "mrru",			&ng_parse_uint16_type	},	\
16557b57be3SArchie Cobbs 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
16657b57be3SArchie Cobbs 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
16757b57be3SArchie Cobbs 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
16857b57be3SArchie Cobbs 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
16957b57be3SArchie Cobbs 	  { "enableIP",			&ng_parse_uint8_type	},	\
17057b57be3SArchie Cobbs 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
17157b57be3SArchie Cobbs 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
17257b57be3SArchie Cobbs 	  { "enableIPX",		&ng_parse_uint8_type	},	\
17357b57be3SArchie Cobbs 	  { "enableCompression",	&ng_parse_uint8_type	},	\
17457b57be3SArchie Cobbs 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
17557b57be3SArchie Cobbs 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
17657b57be3SArchie Cobbs 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
17757b57be3SArchie Cobbs 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
17857b57be3SArchie Cobbs 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
179a9b3dca5SArchie Cobbs 	  { NULL }							\
180a9b3dca5SArchie Cobbs }
181a9b3dca5SArchie Cobbs 
182a9b3dca5SArchie Cobbs /* Total node config structure */
183a9b3dca5SArchie Cobbs struct ng_ppp_node_conf {
184a9b3dca5SArchie Cobbs 	struct ng_ppp_bund_conf	bund;
185a9b3dca5SArchie Cobbs 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
186a9b3dca5SArchie Cobbs };
187a9b3dca5SArchie Cobbs 
188a9b3dca5SArchie Cobbs /* Keep this in sync with the above structure definition */
189a9b3dca5SArchie Cobbs #define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
190a9b3dca5SArchie Cobbs 	  { "bund",		(bctype)	},		\
191f8307e12SArchie Cobbs 	  { "links",		(arytype)	},		\
192a9b3dca5SArchie Cobbs 	  { NULL }						\
193f8307e12SArchie Cobbs }
194f8307e12SArchie Cobbs 
1953949bee8SArchie Cobbs /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
1963949bee8SArchie Cobbs struct ng_ppp_link_stat {
1973949bee8SArchie Cobbs 	u_int32_t xmitFrames;		/* xmit frames on link */
1983949bee8SArchie Cobbs 	u_int32_t xmitOctets;		/* xmit octets on link */
1993949bee8SArchie Cobbs 	u_int32_t recvFrames;		/* recv frames on link */
2003949bee8SArchie Cobbs 	u_int32_t recvOctets;		/* recv octets on link */
2013949bee8SArchie Cobbs 	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
202a9b3dca5SArchie Cobbs 	u_int32_t runts;		/* Too short MP fragments */
2033949bee8SArchie Cobbs 	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
204a9b3dca5SArchie Cobbs 	u_int32_t dropFragments;	/* MP fragments we had to drop */
2053949bee8SArchie Cobbs };
2064cf49a43SJulian Elischer 
207f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
208f8307e12SArchie Cobbs #define NG_PPP_STATS_TYPE_INFO	{				\
20957b57be3SArchie Cobbs 	  { "xmitFrames",	&ng_parse_uint32_type	},	\
21057b57be3SArchie Cobbs 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
21157b57be3SArchie Cobbs 	  { "recvFrames",	&ng_parse_uint32_type	},	\
21257b57be3SArchie Cobbs 	  { "recvOctets",	&ng_parse_uint32_type	},	\
21357b57be3SArchie Cobbs 	  { "badProtos",	&ng_parse_uint32_type	},	\
21457b57be3SArchie Cobbs 	  { "runts",		&ng_parse_uint32_type	},	\
21557b57be3SArchie Cobbs 	  { "dupFragments",	&ng_parse_uint32_type	},	\
21657b57be3SArchie Cobbs 	  { "dropFragments",	&ng_parse_uint32_type	},	\
217a9b3dca5SArchie Cobbs 	  { NULL }						\
218f8307e12SArchie Cobbs }
219f8307e12SArchie Cobbs 
220d6fe462aSAlexander Motin /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
221d6fe462aSAlexander Motin struct ng_ppp_link_stat64 {
222d6fe462aSAlexander Motin 	u_int64_t xmitFrames;		/* xmit frames on link */
223d6fe462aSAlexander Motin 	u_int64_t xmitOctets;		/* xmit octets on link */
224d6fe462aSAlexander Motin 	u_int64_t recvFrames;		/* recv frames on link */
225d6fe462aSAlexander Motin 	u_int64_t recvOctets;		/* recv octets on link */
226d6fe462aSAlexander Motin 	u_int64_t badProtos;		/* frames rec'd with bogus protocol */
227d6fe462aSAlexander Motin 	u_int64_t runts;		/* Too short MP fragments */
228d6fe462aSAlexander Motin 	u_int64_t dupFragments;		/* MP frames with duplicate seq # */
229d6fe462aSAlexander Motin 	u_int64_t dropFragments;	/* MP fragments we had to drop */
230d6fe462aSAlexander Motin };
231d6fe462aSAlexander Motin 
232d6fe462aSAlexander Motin /* Keep this in sync with the above structure definition */
233d6fe462aSAlexander Motin #define NG_PPP_STATS64_TYPE_INFO	{			\
234d6fe462aSAlexander Motin 	  { "xmitFrames",	&ng_parse_uint64_type	},	\
235d6fe462aSAlexander Motin 	  { "xmitOctets",	&ng_parse_uint64_type	},	\
236d6fe462aSAlexander Motin 	  { "recvFrames",	&ng_parse_uint64_type	},	\
237d6fe462aSAlexander Motin 	  { "recvOctets",	&ng_parse_uint64_type	},	\
238d6fe462aSAlexander Motin 	  { "badProtos",	&ng_parse_uint64_type	},	\
239d6fe462aSAlexander Motin 	  { "runts",		&ng_parse_uint64_type	},	\
240d6fe462aSAlexander Motin 	  { "dupFragments",	&ng_parse_uint64_type	},	\
241d6fe462aSAlexander Motin 	  { "dropFragments",	&ng_parse_uint64_type	},	\
242d6fe462aSAlexander Motin 	  { NULL }						\
243d6fe462aSAlexander Motin }
244d6fe462aSAlexander Motin 
245e20480bfSRuslan Ermilov #endif /* _NETGRAPH_NG_PPP_H_ */
246