1172009Simp/*
2172009Simp * ng_ppp.h
3172009Simp */
4172009Simp
5172009Simp/*-
6172009Simp * Copyright (c) 1996-2000 Whistle Communications, Inc.
7172009Simp * All rights reserved.
8172009Simp *
9172009Simp * Subject to the following obligations and disclaimer of warranty, use and
10172009Simp * redistribution of this software, in source or object code forms, with or
11172009Simp * without modifications are expressly permitted by Whistle Communications;
12172009Simp * provided, however, that:
13172009Simp * 1. Any and all reproductions of the source or object code must include the
14172009Simp *    copyright notice above and the following disclaimer of warranties; and
15172009Simp * 2. No rights are granted, in any manner or form, to use Whistle
16172009Simp *    Communications, Inc. trademarks, including the mark "WHISTLE
17172009Simp *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
18172009Simp *    such appears in the above copyright notice or in the software.
19172009Simp *
20172009Simp * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
21172009Simp * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
22172009Simp * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
23172009Simp * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
24172009Simp * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
25172009Simp * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
26172009Simp * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
27172009Simp * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
28172009Simp * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
29172009Simp * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
30172009Simp * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31172009Simp * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
32172009Simp * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33172009Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34172009Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35247915Sgavin * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36172009Simp * OF SUCH DAMAGE.
37172009Simp *
38172009Simp * Author: Archie Cobbs <archie@freebsd.org>
39172009Simp *
40172009Simp * $FreeBSD: releng/10.3/sys/netgraph/ng_ppp.h 171688 2007-08-01 20:49:35Z mav $
41172009Simp * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
42172068Sbrueffer */
43172068Sbrueffer
44172068Sbrueffer#ifndef _NETGRAPH_NG_PPP_H_
45172068Sbrueffer#define _NETGRAPH_NG_PPP_H_
46172068Sbrueffer
47172068Sbrueffer/* Node type name and magic cookie */
48172068Sbrueffer#define NG_PPP_NODE_TYPE	"ppp"
49172068Sbrueffer#define NGM_PPP_COOKIE		940897795
50172068Sbrueffer
51172068Sbrueffer/* 64bit stats presence flag */
52172068Sbrueffer#define NG_PPP_STATS64
53172068Sbrueffer
54172068Sbrueffer/* Maximum number of supported links */
55172068Sbrueffer#define NG_PPP_MAX_LINKS	16
56172068Sbrueffer
57172068Sbrueffer/* Pseudo-link number representing the multi-link bundle */
58172068Sbrueffer#define NG_PPP_BUNDLE_LINKNUM	0xffff
59172068Sbrueffer
60172068Sbrueffer/* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
61172009Simp#define NG_PPP_MAX_LATENCY	1000		/* 1 second */
62172009Simp#define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
63172009Simp
64172009Simp/* Hook names */
65172009Simp#define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
66172009Simp#define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
67172009Simp#define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
68178354Ssam#define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
69180419Sweongyo#define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
70178354Ssam#define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
71178354Ssam#define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
72178354Ssam#define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
73178354Ssam#define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
74178354Ssam#define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
75178354Ssam#define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
76172009Simp#define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
77172009Simp#define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
78172009Simp
79172009Simp#define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
80172009Simp
81172009Simp/* Compress hook operation modes */
82172009Simpenum {
83172009Simp	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
84172009Simp	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
85172009Simp	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
86172009Simp};
87184523Sbrueffer
88172009Simp/* Decompress hook operation modes */
89172009Simpenum {
90172009Simp	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
91172009Simp	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
92172009Simp	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
93172009Simp};
94172009Simp
95172009Simp/* Netgraph commands */
96172009Simpenum {
97172009Simp	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
98172009Simp	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
99172009Simp	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
100172009Simp	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
101184523Sbrueffer	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
102172009Simp	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
103172009Simp	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
104172009Simp	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
105172009Simp};
106172009Simp
107172009Simp/* Multi-link sequence number state (for debugging) */
108172009Simpstruct ng_ppp_mp_state {
109172009Simp	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
110172009Simp	int32_t		mseq;			/* min rseq[i] */
111172009Simp	int32_t		xseq;			/* next xmit MP seq # */
112172009Simp};
113172009Simp
114172009Simp/* Keep this in sync with the above structure definition */
115172009Simp#define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
116197724Sweongyo	  { "rseq",	(atype)			},		\
117172009Simp	  { "mseq",	&ng_parse_hint32_type	},		\
118172009Simp	  { "xseq",	&ng_parse_hint32_type	},		\
119172009Simp	  { NULL }						\
120172009Simp}
121172009Simp
122172009Simp/* Per-link config structure */
123172009Simpstruct ng_ppp_link_conf {
124247915Sgavin	u_char		enableLink;	/* enable this link */
125172009Simp	u_char		enableProtoComp;/* enable protocol field compression */
126172009Simp	u_char		enableACFComp;	/* enable addr/ctrl field compression */
127172009Simp	u_int16_t	mru;		/* peer MRU */
128172009Simp	u_int32_t	latency;	/* link latency (in milliseconds) */
129184523Sbrueffer	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
130172009Simp};
131172009Simp
132172009Simp/* Keep this in sync with the above structure definition */
133178354Ssam#define NG_PPP_LINK_TYPE_INFO	{				\
134178354Ssam	  { "enableLink",	&ng_parse_uint8_type	},	\
135178354Ssam	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
136172009Simp	  { "enableACFComp",	&ng_parse_uint8_type	},	\
137172009Simp	  { "mru",		&ng_parse_uint16_type	},	\
138172009Simp	  { "latency",		&ng_parse_uint32_type	},	\
139172009Simp	  { "bandwidth",	&ng_parse_uint32_type	},	\
140172009Simp	  { NULL }						\
141178354Ssam}
142178354Ssam
143172009Simp/* Bundle config structure */
144172009Simpstruct ng_ppp_bund_conf {
145172009Simp	u_int16_t	mrru;			/* multilink peer MRRU */
146172009Simp	u_char		enableMultilink;	/* enable multilink */
147172009Simp	u_char		recvShortSeq;		/* recv multilink short seq # */
148172009Simp	u_char		xmitShortSeq;		/* xmit multilink short seq # */
149172009Simp	u_char		enableRoundRobin;	/* xmit whole packets */
150172009Simp	u_char		enableIP;		/* enable IP data flow */
151172009Simp	u_char		enableIPv6;		/* enable IPv6 data flow */
152172009Simp	u_char		enableAtalk;		/* enable AppleTalk data flow */
153172009Simp	u_char		enableIPX;		/* enable IPX data flow */
154172009Simp	u_char		enableCompression;	/* enable PPP compression */
155172009Simp	u_char		enableDecompression;	/* enable PPP decompression */
156172009Simp	u_char		enableEncryption;	/* enable PPP encryption */
157172009Simp	u_char		enableDecryption;	/* enable PPP decryption */
158172009Simp	u_char		enableVJCompression;	/* enable VJ compression */
159172009Simp	u_char		enableVJDecompression;	/* enable VJ decompression */
160172009Simp};
161172009Simp
162172009Simp/* Keep this in sync with the above structure definition */
163172009Simp#define NG_PPP_BUND_TYPE_INFO	{					\
164172009Simp	  { "mrru",			&ng_parse_uint16_type	},	\
165172009Simp	  { "enableMultilink",		&ng_parse_uint8_type	},	\
166172009Simp	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
167172009Simp	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
168178354Ssam	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
169178354Ssam	  { "enableIP",			&ng_parse_uint8_type	},	\
170178354Ssam	  { "enableIPv6",		&ng_parse_uint8_type	},	\
171178354Ssam	  { "enableAtalk",		&ng_parse_uint8_type	},	\
172184523Sbrueffer	  { "enableIPX",		&ng_parse_uint8_type	},	\
173172009Simp	  { "enableCompression",	&ng_parse_uint8_type	},	\
174172009Simp	  { "enableDecompression",	&ng_parse_uint8_type	},	\
175178354Ssam	  { "enableEncryption",		&ng_parse_uint8_type	},	\
176172009Simp	  { "enableDecryption",		&ng_parse_uint8_type	},	\
177172009Simp	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
178172009Simp	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
179172009Simp	  { NULL }							\
180172009Simp}
181172009Simp
182172009Simp/* Total node config structure */
183172009Simpstruct ng_ppp_node_conf {
184172009Simp	struct ng_ppp_bund_conf	bund;
185172009Simp	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
186172009Simp};
187172009Simp
188/* Keep this in sync with the above structure definition */
189#define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
190	  { "bund",		(bctype)	},		\
191	  { "links",		(arytype)	},		\
192	  { NULL }						\
193}
194
195/* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
196struct ng_ppp_link_stat {
197	u_int32_t xmitFrames;		/* xmit frames on link */
198	u_int32_t xmitOctets;		/* xmit octets on link */
199	u_int32_t recvFrames;		/* recv frames on link */
200	u_int32_t recvOctets;		/* recv octets on link */
201	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
202	u_int32_t runts;		/* Too short MP fragments */
203	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
204	u_int32_t dropFragments;	/* MP fragments we had to drop */
205};
206
207/* Keep this in sync with the above structure definition */
208#define NG_PPP_STATS_TYPE_INFO	{				\
209	  { "xmitFrames",	&ng_parse_uint32_type	},	\
210	  { "xmitOctets",	&ng_parse_uint32_type	},	\
211	  { "recvFrames",	&ng_parse_uint32_type	},	\
212	  { "recvOctets",	&ng_parse_uint32_type	},	\
213	  { "badProtos",	&ng_parse_uint32_type	},	\
214	  { "runts",		&ng_parse_uint32_type	},	\
215	  { "dupFragments",	&ng_parse_uint32_type	},	\
216	  { "dropFragments",	&ng_parse_uint32_type	},	\
217	  { NULL }						\
218}
219
220/* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
221struct ng_ppp_link_stat64 {
222	u_int64_t xmitFrames;		/* xmit frames on link */
223	u_int64_t xmitOctets;		/* xmit octets on link */
224	u_int64_t recvFrames;		/* recv frames on link */
225	u_int64_t recvOctets;		/* recv octets on link */
226	u_int64_t badProtos;		/* frames rec'd with bogus protocol */
227	u_int64_t runts;		/* Too short MP fragments */
228	u_int64_t dupFragments;		/* MP frames with duplicate seq # */
229	u_int64_t dropFragments;	/* MP fragments we had to drop */
230};
231
232/* Keep this in sync with the above structure definition */
233#define NG_PPP_STATS64_TYPE_INFO	{			\
234	  { "xmitFrames",	&ng_parse_uint64_type	},	\
235	  { "xmitOctets",	&ng_parse_uint64_type	},	\
236	  { "recvFrames",	&ng_parse_uint64_type	},	\
237	  { "recvOctets",	&ng_parse_uint64_type	},	\
238	  { "badProtos",	&ng_parse_uint64_type	},	\
239	  { "runts",		&ng_parse_uint64_type	},	\
240	  { "dupFragments",	&ng_parse_uint64_type	},	\
241	  { "dropFragments",	&ng_parse_uint64_type	},	\
242	  { NULL }						\
243}
244
245#endif /* _NETGRAPH_NG_PPP_H_ */
246