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