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