xref: /dflybsd-src/sys/netgraph/ppp/ng_ppp.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino 
286d7f5d3SJohn Marino /*
386d7f5d3SJohn Marino  * ng_ppp.h
486d7f5d3SJohn Marino  *
586d7f5d3SJohn Marino  * Copyright (c) 1996-2000 Whistle Communications, Inc.
686d7f5d3SJohn Marino  * All rights reserved.
786d7f5d3SJohn Marino  *
886d7f5d3SJohn Marino  * Subject to the following obligations and disclaimer of warranty, use and
986d7f5d3SJohn Marino  * redistribution of this software, in source or object code forms, with or
1086d7f5d3SJohn Marino  * without modifications are expressly permitted by Whistle Communications;
1186d7f5d3SJohn Marino  * provided, however, that:
1286d7f5d3SJohn Marino  * 1. Any and all reproductions of the source or object code must include the
1386d7f5d3SJohn Marino  *    copyright notice above and the following disclaimer of warranties; and
1486d7f5d3SJohn Marino  * 2. No rights are granted, in any manner or form, to use Whistle
1586d7f5d3SJohn Marino  *    Communications, Inc. trademarks, including the mark "WHISTLE
1686d7f5d3SJohn Marino  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1786d7f5d3SJohn Marino  *    such appears in the above copyright notice or in the software.
1886d7f5d3SJohn Marino  *
1986d7f5d3SJohn Marino  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2086d7f5d3SJohn Marino  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2186d7f5d3SJohn Marino  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2286d7f5d3SJohn Marino  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2386d7f5d3SJohn Marino  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2486d7f5d3SJohn Marino  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2586d7f5d3SJohn Marino  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2686d7f5d3SJohn Marino  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2786d7f5d3SJohn Marino  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2886d7f5d3SJohn Marino  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
2986d7f5d3SJohn Marino  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3086d7f5d3SJohn Marino  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3186d7f5d3SJohn Marino  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3286d7f5d3SJohn Marino  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3386d7f5d3SJohn Marino  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3486d7f5d3SJohn Marino  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3586d7f5d3SJohn Marino  * OF SUCH DAMAGE.
3686d7f5d3SJohn Marino  *
3786d7f5d3SJohn Marino  * Author: Archie Cobbs <archie@freebsd.org>
3886d7f5d3SJohn Marino  *
3986d7f5d3SJohn Marino  * $FreeBSD: src/sys/netgraph/ng_ppp.h,v 1.5.2.4 2002/07/02 23:44:03 archie Exp $
4086d7f5d3SJohn Marino  * $DragonFly: src/sys/netgraph/ppp/ng_ppp.h,v 1.2 2003/06/17 04:28:51 dillon Exp $
4186d7f5d3SJohn Marino  * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
4286d7f5d3SJohn Marino  */
4386d7f5d3SJohn Marino 
4486d7f5d3SJohn Marino #ifndef _NETGRAPH_PPP_H_
4586d7f5d3SJohn Marino #define _NETGRAPH_PPP_H_
4686d7f5d3SJohn Marino 
4786d7f5d3SJohn Marino /* Node type name and magic cookie */
4886d7f5d3SJohn Marino #define NG_PPP_NODE_TYPE	"ppp"
4986d7f5d3SJohn Marino #define NGM_PPP_COOKIE		940897795
5086d7f5d3SJohn Marino 
5186d7f5d3SJohn Marino /* Maximum number of supported links */
5286d7f5d3SJohn Marino #define NG_PPP_MAX_LINKS	16
5386d7f5d3SJohn Marino 
5486d7f5d3SJohn Marino /* Pseudo-link number representing the multi-link bundle */
5586d7f5d3SJohn Marino #define NG_PPP_BUNDLE_LINKNUM	0xffff
5686d7f5d3SJohn Marino 
5786d7f5d3SJohn Marino /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
5886d7f5d3SJohn Marino #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
5986d7f5d3SJohn Marino #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
6086d7f5d3SJohn Marino 
6186d7f5d3SJohn Marino /* Hook names */
6286d7f5d3SJohn Marino #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
6386d7f5d3SJohn Marino #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
6486d7f5d3SJohn Marino #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
6586d7f5d3SJohn Marino #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
6686d7f5d3SJohn Marino #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
6786d7f5d3SJohn Marino #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
6886d7f5d3SJohn Marino #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
6986d7f5d3SJohn Marino #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
7086d7f5d3SJohn Marino #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
7186d7f5d3SJohn Marino #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
7286d7f5d3SJohn Marino #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
7386d7f5d3SJohn Marino #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
7486d7f5d3SJohn Marino #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
7586d7f5d3SJohn Marino 
7686d7f5d3SJohn Marino #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
7786d7f5d3SJohn Marino 
7886d7f5d3SJohn Marino /* Netgraph commands */
7986d7f5d3SJohn Marino enum {
8086d7f5d3SJohn Marino 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
8186d7f5d3SJohn Marino 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
8286d7f5d3SJohn Marino 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
8386d7f5d3SJohn Marino 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
8486d7f5d3SJohn Marino 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
8586d7f5d3SJohn Marino 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
8686d7f5d3SJohn Marino };
8786d7f5d3SJohn Marino 
8886d7f5d3SJohn Marino /* Multi-link sequence number state (for debugging) */
8986d7f5d3SJohn Marino struct ng_ppp_mp_state {
9086d7f5d3SJohn Marino 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
9186d7f5d3SJohn Marino 	int32_t		mseq;			/* min rseq[i] */
9286d7f5d3SJohn Marino 	int32_t		xseq;			/* next xmit MP seq # */
9386d7f5d3SJohn Marino };
9486d7f5d3SJohn Marino 
9586d7f5d3SJohn Marino /* Keep this in sync with the above structure definition */
9686d7f5d3SJohn Marino #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
9786d7f5d3SJohn Marino 	  { "rseq",	(atype)			},		\
9886d7f5d3SJohn Marino 	  { "mseq",	&ng_parse_hint32_type	},		\
9986d7f5d3SJohn Marino 	  { "xseq",	&ng_parse_hint32_type	},		\
10086d7f5d3SJohn Marino 	  { NULL }						\
10186d7f5d3SJohn Marino }
10286d7f5d3SJohn Marino 
10386d7f5d3SJohn Marino /* Per-link config structure */
10486d7f5d3SJohn Marino struct ng_ppp_link_conf {
10586d7f5d3SJohn Marino 	u_char		enableLink;	/* enable this link */
10686d7f5d3SJohn Marino 	u_char		enableProtoComp;/* enable protocol field compression */
10786d7f5d3SJohn Marino 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
10886d7f5d3SJohn Marino 	u_int16_t	mru;		/* peer MRU */
10986d7f5d3SJohn Marino 	u_int32_t	latency;	/* link latency (in milliseconds) */
11086d7f5d3SJohn Marino 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/second) */
11186d7f5d3SJohn Marino };
11286d7f5d3SJohn Marino 
11386d7f5d3SJohn Marino /* Keep this in sync with the above structure definition */
11486d7f5d3SJohn Marino #define NG_PPP_LINK_TYPE_INFO	{				\
11586d7f5d3SJohn Marino 	  { "enableLink",	&ng_parse_uint8_type	},	\
11686d7f5d3SJohn Marino 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
11786d7f5d3SJohn Marino 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
11886d7f5d3SJohn Marino 	  { "mru",		&ng_parse_uint16_type	},	\
11986d7f5d3SJohn Marino 	  { "latency",		&ng_parse_uint32_type	},	\
12086d7f5d3SJohn Marino 	  { "bandwidth",	&ng_parse_uint32_type	},	\
12186d7f5d3SJohn Marino 	  { NULL }						\
12286d7f5d3SJohn Marino }
12386d7f5d3SJohn Marino 
12486d7f5d3SJohn Marino /* Bundle config structure */
12586d7f5d3SJohn Marino struct ng_ppp_bund_conf {
12686d7f5d3SJohn Marino 	u_int16_t	mrru;			/* multilink peer MRRU */
12786d7f5d3SJohn Marino 	u_char		enableMultilink;	/* enable multilink */
12886d7f5d3SJohn Marino 	u_char		recvShortSeq;		/* recv multilink short seq # */
12986d7f5d3SJohn Marino 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
13086d7f5d3SJohn Marino 	u_char		enableRoundRobin;	/* xmit whole packets */
13186d7f5d3SJohn Marino 	u_char		enableIP;		/* enable IP data flow */
13286d7f5d3SJohn Marino 	u_char		enableIPv6;		/* enable IPv6 data flow */
13386d7f5d3SJohn Marino 	u_char		enableAtalk;		/* enable AppleTalk data flow */
13486d7f5d3SJohn Marino 	u_char		enableIPX;		/* enable IPX data flow */
13586d7f5d3SJohn Marino 	u_char		enableCompression;	/* enable PPP compression */
13686d7f5d3SJohn Marino 	u_char		enableDecompression;	/* enable PPP decompression */
13786d7f5d3SJohn Marino 	u_char		enableEncryption;	/* enable PPP encryption */
13886d7f5d3SJohn Marino 	u_char		enableDecryption;	/* enable PPP decryption */
13986d7f5d3SJohn Marino 	u_char		enableVJCompression;	/* enable VJ compression */
14086d7f5d3SJohn Marino 	u_char		enableVJDecompression;	/* enable VJ decompression */
14186d7f5d3SJohn Marino };
14286d7f5d3SJohn Marino 
14386d7f5d3SJohn Marino /* Keep this in sync with the above structure definition */
14486d7f5d3SJohn Marino #define NG_PPP_BUND_TYPE_INFO	{					\
14586d7f5d3SJohn Marino 	  { "mrru",			&ng_parse_uint16_type	},	\
14686d7f5d3SJohn Marino 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
14786d7f5d3SJohn Marino 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
14886d7f5d3SJohn Marino 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
14986d7f5d3SJohn Marino 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
15086d7f5d3SJohn Marino 	  { "enableIP",			&ng_parse_uint8_type	},	\
15186d7f5d3SJohn Marino 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
15286d7f5d3SJohn Marino 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
15386d7f5d3SJohn Marino 	  { "enableIPX",		&ng_parse_uint8_type	},	\
15486d7f5d3SJohn Marino 	  { "enableCompression",	&ng_parse_uint8_type	},	\
15586d7f5d3SJohn Marino 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
15686d7f5d3SJohn Marino 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
15786d7f5d3SJohn Marino 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
15886d7f5d3SJohn Marino 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
15986d7f5d3SJohn Marino 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
16086d7f5d3SJohn Marino 	  { NULL }							\
16186d7f5d3SJohn Marino }
16286d7f5d3SJohn Marino 
16386d7f5d3SJohn Marino /* Total node config structure */
16486d7f5d3SJohn Marino struct ng_ppp_node_conf {
16586d7f5d3SJohn Marino 	struct ng_ppp_bund_conf	bund;
16686d7f5d3SJohn Marino 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
16786d7f5d3SJohn Marino };
16886d7f5d3SJohn Marino 
16986d7f5d3SJohn Marino /* Keep this in sync with the above structure definition */
17086d7f5d3SJohn Marino #define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
17186d7f5d3SJohn Marino 	  { "bund",		(bctype)	},		\
17286d7f5d3SJohn Marino 	  { "links",		(arytype)	},		\
17386d7f5d3SJohn Marino 	  { NULL }						\
17486d7f5d3SJohn Marino }
17586d7f5d3SJohn Marino 
17686d7f5d3SJohn Marino /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
17786d7f5d3SJohn Marino struct ng_ppp_link_stat {
17886d7f5d3SJohn Marino 	u_int32_t xmitFrames;		/* xmit frames on link */
17986d7f5d3SJohn Marino 	u_int32_t xmitOctets;		/* xmit octets on link */
18086d7f5d3SJohn Marino 	u_int32_t recvFrames;		/* recv frames on link */
18186d7f5d3SJohn Marino 	u_int32_t recvOctets;		/* recv octets on link */
18286d7f5d3SJohn Marino 	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
18386d7f5d3SJohn Marino 	u_int32_t runts;		/* Too short MP fragments */
18486d7f5d3SJohn Marino 	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
18586d7f5d3SJohn Marino 	u_int32_t dropFragments;	/* MP fragments we had to drop */
18686d7f5d3SJohn Marino };
18786d7f5d3SJohn Marino 
18886d7f5d3SJohn Marino /* Keep this in sync with the above structure definition */
18986d7f5d3SJohn Marino #define NG_PPP_STATS_TYPE_INFO	{				\
19086d7f5d3SJohn Marino 	  { "xmitFrames",	&ng_parse_uint32_type	},	\
19186d7f5d3SJohn Marino 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
19286d7f5d3SJohn Marino 	  { "recvFrames",	&ng_parse_uint32_type	},	\
19386d7f5d3SJohn Marino 	  { "recvOctets",	&ng_parse_uint32_type	},	\
19486d7f5d3SJohn Marino 	  { "badProtos",	&ng_parse_uint32_type	},	\
19586d7f5d3SJohn Marino 	  { "runts",		&ng_parse_uint32_type	},	\
19686d7f5d3SJohn Marino 	  { "dupFragments",	&ng_parse_uint32_type	},	\
19786d7f5d3SJohn Marino 	  { "dropFragments",	&ng_parse_uint32_type	},	\
19886d7f5d3SJohn Marino 	  { NULL }						\
19986d7f5d3SJohn Marino }
20086d7f5d3SJohn Marino 
20186d7f5d3SJohn Marino #endif /* _NETGRAPH_PPP_H_ */
202