xref: /freebsd/sys/netgraph/ng_ppp.h (revision d8a0fe102c0cfdfcd5b818f850eff09d8536c9bc)
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  *
40  * $FreeBSD$
41  * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
42  */
43 
44 #ifndef _NETGRAPH_NG_PPP_H_
45 #define _NETGRAPH_NG_PPP_H_
46 
47 /* Node type name and magic cookie */
48 #define NG_PPP_NODE_TYPE	"ppp"
49 #define NGM_PPP_COOKIE		940897795
50 
51 /* 64bit stats presence flag */
52 #define NG_PPP_STATS64
53 
54 /* Maximum number of supported links */
55 #define NG_PPP_MAX_LINKS	16
56 
57 /* Pseudo-link number representing the multi-link bundle */
58 #define NG_PPP_BUNDLE_LINKNUM	0xffff
59 
60 /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
61 #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
62 #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
63 
64 /* Hook names */
65 #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
66 #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
67 #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
68 #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
69 #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
70 #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
71 #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
72 #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
73 #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
74 #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
75 #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
76 #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
77 #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
78 
79 #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
80 
81 /* Compress hook operation modes */
82 enum {
83 	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
84 	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
85 	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
86 };
87 
88 /* Decompress hook operation modes */
89 enum {
90 	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
91 	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
92 	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
93 };
94 
95 /* Netgraph commands */
96 enum {
97 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
98 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
99 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
100 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
101 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
102 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
103 	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
104 	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
105 };
106 
107 /* Multi-link sequence number state (for debugging) */
108 struct ng_ppp_mp_state {
109 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
110 	int32_t		mseq;			/* min rseq[i] */
111 	int32_t		xseq;			/* next xmit MP seq # */
112 };
113 
114 /* Keep this in sync with the above structure definition */
115 #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
116 	  { "rseq",	(atype)			},		\
117 	  { "mseq",	&ng_parse_hint32_type	},		\
118 	  { "xseq",	&ng_parse_hint32_type	},		\
119 	  { NULL }						\
120 }
121 
122 /* Per-link config structure */
123 struct ng_ppp_link_conf {
124 	u_char		enableLink;	/* enable this link */
125 	u_char		enableProtoComp;/* enable protocol field compression */
126 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
127 	u_int16_t	mru;		/* peer MRU */
128 	u_int32_t	latency;	/* link latency (in milliseconds) */
129 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
130 };
131 
132 /* Keep this in sync with the above structure definition */
133 #define NG_PPP_LINK_TYPE_INFO	{				\
134 	  { "enableLink",	&ng_parse_uint8_type	},	\
135 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
136 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
137 	  { "mru",		&ng_parse_uint16_type	},	\
138 	  { "latency",		&ng_parse_uint32_type	},	\
139 	  { "bandwidth",	&ng_parse_uint32_type	},	\
140 	  { NULL }						\
141 }
142 
143 /* Bundle config structure */
144 struct ng_ppp_bund_conf {
145 	u_int16_t	mrru;			/* multilink peer MRRU */
146 	u_char		enableMultilink;	/* enable multilink */
147 	u_char		recvShortSeq;		/* recv multilink short seq # */
148 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
149 	u_char		enableRoundRobin;	/* xmit whole packets */
150 	u_char		enableIP;		/* enable IP data flow */
151 	u_char		enableIPv6;		/* enable IPv6 data flow */
152 	u_char		enableAtalk;		/* enable AppleTalk data flow */
153 	u_char		enableIPX;		/* enable IPX data flow */
154 	u_char		enableCompression;	/* enable PPP compression */
155 	u_char		enableDecompression;	/* enable PPP decompression */
156 	u_char		enableEncryption;	/* enable PPP encryption */
157 	u_char		enableDecryption;	/* enable PPP decryption */
158 	u_char		enableVJCompression;	/* enable VJ compression */
159 	u_char		enableVJDecompression;	/* enable VJ decompression */
160 };
161 
162 /* Keep this in sync with the above structure definition */
163 #define NG_PPP_BUND_TYPE_INFO	{					\
164 	  { "mrru",			&ng_parse_uint16_type	},	\
165 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
166 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
167 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
168 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
169 	  { "enableIP",			&ng_parse_uint8_type	},	\
170 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
171 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
172 	  { "enableIPX",		&ng_parse_uint8_type	},	\
173 	  { "enableCompression",	&ng_parse_uint8_type	},	\
174 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
175 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
176 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
177 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
178 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
179 	  { NULL }							\
180 }
181 
182 /* Total node config structure */
183 struct ng_ppp_node_conf {
184 	struct ng_ppp_bund_conf	bund;
185 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
186 };
187 
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) */
196 struct 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) */
221 struct 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