xref: /dragonfly/sys/netgraph7/ppp/ng_ppp.h (revision 0fe46dc6)
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: src/sys/netgraph/ng_ppp.h,v 1.14 2007/08/01 20:49:35 mav Exp $
41  * $DragonFly: src/sys/netgraph7/ng_ppp.h,v 1.2 2008/06/26 23:05:35 dillon Exp $
42  * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
43  */
44 
45 #ifndef _NETGRAPH_NG_PPP_H_
46 #define _NETGRAPH_NG_PPP_H_
47 
48 /* Node type name and magic cookie */
49 #define NG_PPP_NODE_TYPE	"ppp"
50 #define NGM_PPP_COOKIE		940897795
51 
52 /* 64bit stats presence flag */
53 #define NG_PPP_STATS64
54 
55 /* Maximum number of supported links */
56 #define NG_PPP_MAX_LINKS	16
57 
58 /* Pseudo-link number representing the multi-link bundle */
59 #define NG_PPP_BUNDLE_LINKNUM	0xffff
60 
61 /* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
62 #define NG_PPP_MAX_LATENCY	1000		/* 1 second */
63 #define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */
64 
65 /* Hook names */
66 #define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
67 #define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
68 #define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
69 #define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
70 #define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
71 #define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
72 #define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
73 #define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
74 #define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
75 #define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
76 #define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
77 #define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
78 #define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */
79 
80 #define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */
81 
82 /* Compress hook operation modes */
83 enum {
84 	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
85 	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
86 	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
87 };
88 
89 /* Decompress hook operation modes */
90 enum {
91 	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
92 	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
93 	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
94 };
95 
96 /* Netgraph commands */
97 enum {
98 	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
99 	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
100 	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
101 	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
102 	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
103 	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
104 	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
105 	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
106 };
107 
108 /* Multi-link sequence number state (for debugging) */
109 struct ng_ppp_mp_state {
110 	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
111 	int32_t		mseq;			/* min rseq[i] */
112 	int32_t		xseq;			/* next xmit MP seq # */
113 };
114 
115 /* Keep this in sync with the above structure definition */
116 #define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
117 	  { "rseq",	(atype)			},		\
118 	  { "mseq",	&ng_parse_hint32_type	},		\
119 	  { "xseq",	&ng_parse_hint32_type	},		\
120 	  { NULL }						\
121 }
122 
123 /* Per-link config structure */
124 struct ng_ppp_link_conf {
125 	u_char		enableLink;	/* enable this link */
126 	u_char		enableProtoComp;/* enable protocol field compression */
127 	u_char		enableACFComp;	/* enable addr/ctrl field compression */
128 	u_int16_t	mru;		/* peer MRU */
129 	u_int32_t	latency;	/* link latency (in milliseconds) */
130 	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
131 };
132 
133 /* Keep this in sync with the above structure definition */
134 #define NG_PPP_LINK_TYPE_INFO	{				\
135 	  { "enableLink",	&ng_parse_uint8_type	},	\
136 	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
137 	  { "enableACFComp",	&ng_parse_uint8_type	},	\
138 	  { "mru",		&ng_parse_uint16_type	},	\
139 	  { "latency",		&ng_parse_uint32_type	},	\
140 	  { "bandwidth",	&ng_parse_uint32_type	},	\
141 	  { NULL }						\
142 }
143 
144 /* Bundle config structure */
145 struct ng_ppp_bund_conf {
146 	u_int16_t	mrru;			/* multilink peer MRRU */
147 	u_char		enableMultilink;	/* enable multilink */
148 	u_char		recvShortSeq;		/* recv multilink short seq # */
149 	u_char		xmitShortSeq;		/* xmit multilink short seq # */
150 	u_char		enableRoundRobin;	/* xmit whole packets */
151 	u_char		enableIP;		/* enable IP data flow */
152 	u_char		enableIPv6;		/* enable IPv6 data flow */
153 	u_char		enableAtalk;		/* enable AppleTalk data flow */
154 	u_char		enableIPX;		/* enable IPX data flow */
155 	u_char		enableCompression;	/* enable PPP compression */
156 	u_char		enableDecompression;	/* enable PPP decompression */
157 	u_char		enableEncryption;	/* enable PPP encryption */
158 	u_char		enableDecryption;	/* enable PPP decryption */
159 	u_char		enableVJCompression;	/* enable VJ compression */
160 	u_char		enableVJDecompression;	/* enable VJ decompression */
161 };
162 
163 /* Keep this in sync with the above structure definition */
164 #define NG_PPP_BUND_TYPE_INFO	{					\
165 	  { "mrru",			&ng_parse_uint16_type	},	\
166 	  { "enableMultilink",		&ng_parse_uint8_type	},	\
167 	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
168 	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
169 	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
170 	  { "enableIP",			&ng_parse_uint8_type	},	\
171 	  { "enableIPv6",		&ng_parse_uint8_type	},	\
172 	  { "enableAtalk",		&ng_parse_uint8_type	},	\
173 	  { "enableIPX",		&ng_parse_uint8_type	},	\
174 	  { "enableCompression",	&ng_parse_uint8_type	},	\
175 	  { "enableDecompression",	&ng_parse_uint8_type	},	\
176 	  { "enableEncryption",		&ng_parse_uint8_type	},	\
177 	  { "enableDecryption",		&ng_parse_uint8_type	},	\
178 	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
179 	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
180 	  { NULL }							\
181 }
182 
183 /* Total node config structure */
184 struct ng_ppp_node_conf {
185 	struct ng_ppp_bund_conf	bund;
186 	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
187 };
188 
189 /* Keep this in sync with the above structure definition */
190 #define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
191 	  { "bund",		(bctype)	},		\
192 	  { "links",		(arytype)	},		\
193 	  { NULL }						\
194 }
195 
196 /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
197 struct ng_ppp_link_stat {
198 	u_int32_t xmitFrames;		/* xmit frames on link */
199 	u_int32_t xmitOctets;		/* xmit octets on link */
200 	u_int32_t recvFrames;		/* recv frames on link */
201 	u_int32_t recvOctets;		/* recv octets on link */
202 	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
203 	u_int32_t runts;		/* Too short MP fragments */
204 	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
205 	u_int32_t dropFragments;	/* MP fragments we had to drop */
206 };
207 
208 /* Keep this in sync with the above structure definition */
209 #define NG_PPP_STATS_TYPE_INFO	{				\
210 	  { "xmitFrames",	&ng_parse_uint32_type	},	\
211 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
212 	  { "recvFrames",	&ng_parse_uint32_type	},	\
213 	  { "recvOctets",	&ng_parse_uint32_type	},	\
214 	  { "badProtos",	&ng_parse_uint32_type	},	\
215 	  { "runts",		&ng_parse_uint32_type	},	\
216 	  { "dupFragments",	&ng_parse_uint32_type	},	\
217 	  { "dropFragments",	&ng_parse_uint32_type	},	\
218 	  { NULL }						\
219 }
220 
221 /* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
222 struct ng_ppp_link_stat64 {
223 	u_int64_t xmitFrames;		/* xmit frames on link */
224 	u_int64_t xmitOctets;		/* xmit octets on link */
225 	u_int64_t recvFrames;		/* recv frames on link */
226 	u_int64_t recvOctets;		/* recv octets on link */
227 	u_int64_t badProtos;		/* frames rec'd with bogus protocol */
228 	u_int64_t runts;		/* Too short MP fragments */
229 	u_int64_t dupFragments;		/* MP frames with duplicate seq # */
230 	u_int64_t dropFragments;	/* MP fragments we had to drop */
231 };
232 
233 /* Keep this in sync with the above structure definition */
234 #define NG_PPP_STATS64_TYPE_INFO	{			\
235 	  { "xmitFrames",	&ng_parse_uint64_type	},	\
236 	  { "xmitOctets",	&ng_parse_uint64_type	},	\
237 	  { "recvFrames",	&ng_parse_uint64_type	},	\
238 	  { "recvOctets",	&ng_parse_uint64_type	},	\
239 	  { "badProtos",	&ng_parse_uint64_type	},	\
240 	  { "runts",		&ng_parse_uint64_type	},	\
241 	  { "dupFragments",	&ng_parse_uint64_type	},	\
242 	  { "dropFragments",	&ng_parse_uint64_type	},	\
243 	  { NULL }						\
244 }
245 
246 #endif /* _NETGRAPH_NG_PPP_H_ */
247