xref: /freebsd/sys/netgraph/ng_l2tp.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1c398230bSWarner Losh /*-
2901fadf7SArchie Cobbs  * Copyright (c) 2001-2002 Packet Design, LLC.
3901fadf7SArchie Cobbs  * All rights reserved.
4901fadf7SArchie Cobbs  *
5901fadf7SArchie Cobbs  * Subject to the following obligations and disclaimer of warranty,
6901fadf7SArchie Cobbs  * use and redistribution of this software, in source or object code
7901fadf7SArchie Cobbs  * forms, with or without modifications are expressly permitted by
8901fadf7SArchie Cobbs  * Packet Design; provided, however, that:
9901fadf7SArchie Cobbs  *
10901fadf7SArchie Cobbs  *    (i)  Any and all reproductions of the source or object code
11901fadf7SArchie Cobbs  *         must include the copyright notice above and the following
12901fadf7SArchie Cobbs  *         disclaimer of warranties; and
13901fadf7SArchie Cobbs  *    (ii) No rights are granted, in any manner or form, to use
14901fadf7SArchie Cobbs  *         Packet Design trademarks, including the mark "PACKET DESIGN"
15901fadf7SArchie Cobbs  *         on advertising, endorsements, or otherwise except as such
16901fadf7SArchie Cobbs  *         appears in the above copyright notice or in the software.
17901fadf7SArchie Cobbs  *
18901fadf7SArchie Cobbs  * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
19901fadf7SArchie Cobbs  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
20901fadf7SArchie Cobbs  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
21901fadf7SArchie Cobbs  * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
22901fadf7SArchie Cobbs  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
23901fadf7SArchie Cobbs  * OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
24901fadf7SArchie Cobbs  * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
25901fadf7SArchie Cobbs  * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
26901fadf7SArchie Cobbs  * RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
27901fadf7SArchie Cobbs  * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
28901fadf7SArchie Cobbs  * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
29901fadf7SArchie Cobbs  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
30901fadf7SArchie Cobbs  * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
31901fadf7SArchie Cobbs  * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
32901fadf7SArchie Cobbs  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33901fadf7SArchie Cobbs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
34901fadf7SArchie Cobbs  * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
35901fadf7SArchie Cobbs  * THE POSSIBILITY OF SUCH DAMAGE.
36901fadf7SArchie Cobbs  *
37901fadf7SArchie Cobbs  * Author: Archie Cobbs <archie@freebsd.org>
38901fadf7SArchie Cobbs  */
39901fadf7SArchie Cobbs 
40e20480bfSRuslan Ermilov #ifndef _NETGRAPH_NG_L2TP_H_
41e20480bfSRuslan Ermilov #define _NETGRAPH_NG_L2TP_H_
42901fadf7SArchie Cobbs 
43901fadf7SArchie Cobbs /* Node type name and magic cookie */
44901fadf7SArchie Cobbs #define NG_L2TP_NODE_TYPE	"l2tp"
454807330cSBjoern A. Zeeb #define NGM_L2TP_COOKIE		1091515793
46901fadf7SArchie Cobbs 
47901fadf7SArchie Cobbs /* Hook names */
48901fadf7SArchie Cobbs #define NG_L2TP_HOOK_CTRL	"ctrl"		/* control channel hook */
49901fadf7SArchie Cobbs #define NG_L2TP_HOOK_LOWER	"lower"		/* hook to lower layers */
50901fadf7SArchie Cobbs 
51901fadf7SArchie Cobbs /* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */
52901fadf7SArchie Cobbs #define NG_L2TP_HOOK_SESSION_P	"session_"	/* session data hook (prefix) */
53901fadf7SArchie Cobbs #define NG_L2TP_HOOK_SESSION_F	"session_%04x"	/* session data hook (format) */
54901fadf7SArchie Cobbs 
55*053359b7SPedro F. Giffuni /* Set initial sequence numbers to not yet enabled node. */
561e031324SBjoern A. Zeeb struct ng_l2tp_seq_config {
571e031324SBjoern A. Zeeb 	u_int16_t	ns;		/* sequence number to send next */
581e031324SBjoern A. Zeeb 	u_int16_t	nr;		/* sequence number to be recved next */
591e031324SBjoern A. Zeeb 	u_int16_t	rack;		/* last 'nr' received */
601e031324SBjoern A. Zeeb 	u_int16_t	xack;		/* last 'nr' sent */
611e031324SBjoern A. Zeeb };
621e031324SBjoern A. Zeeb 
631e031324SBjoern A. Zeeb /* Keep this in sync with the above structure definition. */
641e031324SBjoern A. Zeeb #define	NG_L2TP_SEQ_CONFIG_TYPE_INFO	{			\
651e031324SBjoern A. Zeeb 	  { "ns",		&ng_parse_uint16_type	},	\
661e031324SBjoern A. Zeeb 	  { "nr",		&ng_parse_uint16_type	},	\
671e031324SBjoern A. Zeeb 	  { NULL }						\
681e031324SBjoern A. Zeeb }
691e031324SBjoern A. Zeeb 
70901fadf7SArchie Cobbs /* Configuration for a node */
71901fadf7SArchie Cobbs struct ng_l2tp_config {
72901fadf7SArchie Cobbs 	u_char		enabled;	/* enables traffic flow */
73901fadf7SArchie Cobbs 	u_char		match_id;	/* tunnel id must match 'tunnel_id' */
74901fadf7SArchie Cobbs 	u_int16_t	tunnel_id;	/* local tunnel id */
75901fadf7SArchie Cobbs 	u_int16_t	peer_id;	/* peer's tunnel id */
76901fadf7SArchie Cobbs 	u_int16_t	peer_win;	/* peer's max recv window size */
77901fadf7SArchie Cobbs 	u_int16_t	rexmit_max;	/* max retransmits before failure */
78901fadf7SArchie Cobbs 	u_int16_t	rexmit_max_to;	/* max delay between retransmits */
79901fadf7SArchie Cobbs };
80901fadf7SArchie Cobbs 
81901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */
82901fadf7SArchie Cobbs #define NG_L2TP_CONFIG_TYPE_INFO	{			\
83901fadf7SArchie Cobbs 	  { "enabled",		&ng_parse_uint8_type	},	\
84901fadf7SArchie Cobbs 	  { "match_id",		&ng_parse_uint8_type	},	\
85901fadf7SArchie Cobbs 	  { "tunnel_id",	&ng_parse_hint16_type	},	\
86901fadf7SArchie Cobbs 	  { "peer_id",		&ng_parse_hint16_type	},	\
87901fadf7SArchie Cobbs 	  { "peer_win",		&ng_parse_uint16_type	},	\
88901fadf7SArchie Cobbs 	  { "rexmit_max",	&ng_parse_uint16_type	},	\
89901fadf7SArchie Cobbs 	  { "rexmit_max_to",	&ng_parse_uint16_type	},	\
90901fadf7SArchie Cobbs 	  { NULL }						\
91901fadf7SArchie Cobbs }
92901fadf7SArchie Cobbs 
93901fadf7SArchie Cobbs /* Configuration for a session hook */
94901fadf7SArchie Cobbs struct ng_l2tp_sess_config {
95901fadf7SArchie Cobbs 	u_int16_t	session_id;	/* local session id */
96901fadf7SArchie Cobbs 	u_int16_t	peer_id;	/* peer's session id */
97901fadf7SArchie Cobbs 	u_char		control_dseq;	/* whether we control data sequencing */
98901fadf7SArchie Cobbs 	u_char		enable_dseq;	/* whether to enable data sequencing */
99901fadf7SArchie Cobbs 	u_char		include_length;	/* whether to include length field */
100901fadf7SArchie Cobbs };
101901fadf7SArchie Cobbs 
102901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */
103901fadf7SArchie Cobbs #define NG_L2TP_SESS_CONFIG_TYPE_INFO	{			\
104901fadf7SArchie Cobbs 	  { "session_id",	&ng_parse_hint16_type	},	\
105901fadf7SArchie Cobbs 	  { "peer_id",		&ng_parse_hint16_type	},	\
106901fadf7SArchie Cobbs 	  { "control_dseq",	&ng_parse_uint8_type	},	\
107901fadf7SArchie Cobbs 	  { "enable_dseq",	&ng_parse_uint8_type	},	\
108901fadf7SArchie Cobbs 	  { "include_length",	&ng_parse_uint8_type	},	\
109901fadf7SArchie Cobbs 	  { NULL }						\
110901fadf7SArchie Cobbs }
111901fadf7SArchie Cobbs 
112901fadf7SArchie Cobbs /* Statistics struct */
113901fadf7SArchie Cobbs struct ng_l2tp_stats {
114901fadf7SArchie Cobbs 	u_int32_t xmitPackets;		/* number of packets xmit */
115901fadf7SArchie Cobbs 	u_int32_t xmitOctets;		/* number of octets xmit */
116901fadf7SArchie Cobbs 	u_int32_t xmitZLBs;		/* ack-only packets transmitted */
117901fadf7SArchie Cobbs 	u_int32_t xmitDrops;		/* xmits dropped due to full window */
118901fadf7SArchie Cobbs 	u_int32_t xmitTooBig;		/* ctrl pkts dropped because too big */
119901fadf7SArchie Cobbs 	u_int32_t xmitInvalid;		/* ctrl packets with no session ID */
120901fadf7SArchie Cobbs 	u_int32_t xmitDataTooBig;	/* data pkts dropped because too big */
121901fadf7SArchie Cobbs 	u_int32_t xmitRetransmits;	/* retransmitted packets */
122901fadf7SArchie Cobbs 	u_int32_t recvPackets;		/* number of packets rec'd */
123901fadf7SArchie Cobbs 	u_int32_t recvOctets;		/* number of octets rec'd */
124901fadf7SArchie Cobbs 	u_int32_t recvRunts;		/* too short packets rec'd */
125901fadf7SArchie Cobbs 	u_int32_t recvInvalid;		/* invalid packets rec'd */
126901fadf7SArchie Cobbs 	u_int32_t recvWrongTunnel;	/* packets rec'd with wrong tunnel id */
127901fadf7SArchie Cobbs 	u_int32_t recvUnknownSID;	/* pkts rec'd with unknown session id */
128901fadf7SArchie Cobbs 	u_int32_t recvBadAcks;		/* ctrl pkts rec'd with invalid 'nr' */
129901fadf7SArchie Cobbs 	u_int32_t recvOutOfOrder;	/* out of order ctrl pkts rec'd */
130901fadf7SArchie Cobbs 	u_int32_t recvDuplicates;	/* duplicate ctrl pkts rec'd */
131901fadf7SArchie Cobbs 	u_int32_t recvDataDrops;	/* dup/out of order data pkts rec'd */
132901fadf7SArchie Cobbs 	u_int32_t recvZLBs;		/* ack-only packets rec'd */
133901fadf7SArchie Cobbs 	u_int32_t memoryFailures;	/* times we couldn't allocate memory */
134901fadf7SArchie Cobbs };
135901fadf7SArchie Cobbs 
136901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */
137901fadf7SArchie Cobbs #define NG_L2TP_STATS_TYPE_INFO	{			\
138901fadf7SArchie Cobbs 	  { "xmitPackets",	&ng_parse_uint32_type	},	\
139901fadf7SArchie Cobbs 	  { "xmitOctets",	&ng_parse_uint32_type	},	\
140901fadf7SArchie Cobbs 	  { "xmitZLBs",		&ng_parse_uint32_type	},	\
141901fadf7SArchie Cobbs 	  { "xmitDrops",	&ng_parse_uint32_type	},	\
142901fadf7SArchie Cobbs 	  { "xmitTooBig",	&ng_parse_uint32_type	},	\
143901fadf7SArchie Cobbs 	  { "xmitInvalid",	&ng_parse_uint32_type	},	\
144901fadf7SArchie Cobbs 	  { "xmitDataTooBig",	&ng_parse_uint32_type	},	\
145901fadf7SArchie Cobbs 	  { "xmitRetransmits",	&ng_parse_uint32_type	},	\
146901fadf7SArchie Cobbs 	  { "recvPackets",	&ng_parse_uint32_type	},	\
147901fadf7SArchie Cobbs 	  { "recvOctets",	&ng_parse_uint32_type	},	\
148901fadf7SArchie Cobbs 	  { "recvRunts",	&ng_parse_uint32_type	},	\
149901fadf7SArchie Cobbs 	  { "recvInvalid",	&ng_parse_uint32_type	},	\
150901fadf7SArchie Cobbs 	  { "recvWrongTunnel",	&ng_parse_uint32_type	},	\
151901fadf7SArchie Cobbs 	  { "recvUnknownSID",	&ng_parse_uint32_type	},	\
152901fadf7SArchie Cobbs 	  { "recvBadAcks",	&ng_parse_uint32_type	},	\
153901fadf7SArchie Cobbs 	  { "recvOutOfOrder",	&ng_parse_uint32_type	},	\
154901fadf7SArchie Cobbs 	  { "recvDuplicates",	&ng_parse_uint32_type	},	\
155901fadf7SArchie Cobbs 	  { "recvDataDrops",	&ng_parse_uint32_type	},	\
156901fadf7SArchie Cobbs 	  { "recvZLBs",		&ng_parse_uint32_type	},	\
157901fadf7SArchie Cobbs 	  { "memoryFailures",	&ng_parse_uint32_type	},	\
158901fadf7SArchie Cobbs 	  { NULL }						\
159901fadf7SArchie Cobbs }
160901fadf7SArchie Cobbs 
1614807330cSBjoern A. Zeeb /* Session statistics struct. */
1624807330cSBjoern A. Zeeb struct ng_l2tp_session_stats {
1634807330cSBjoern A. Zeeb 	u_int64_t xmitPackets;		/* number of packets xmit */
1644807330cSBjoern A. Zeeb 	u_int64_t xmitOctets;		/* number of octets xmit */
1654807330cSBjoern A. Zeeb 	u_int64_t recvPackets;		/* number of packets received */
1664807330cSBjoern A. Zeeb 	u_int64_t recvOctets;		/* number of octets received */
1674807330cSBjoern A. Zeeb };
1684807330cSBjoern A. Zeeb 
1694807330cSBjoern A. Zeeb /* Keep this in sync with the above structure definition. */
1704807330cSBjoern A. Zeeb #define NG_L2TP_SESSION_STATS_TYPE_INFO	{			\
1714807330cSBjoern A. Zeeb 	  { "xmitPackets",	&ng_parse_uint64_type	},	\
1724807330cSBjoern A. Zeeb 	  { "xmitOctets",	&ng_parse_uint64_type	},	\
1734807330cSBjoern A. Zeeb 	  { "recvPackets",	&ng_parse_uint64_type	},	\
1744807330cSBjoern A. Zeeb 	  { "recvOctets",	&ng_parse_uint64_type	},	\
1754807330cSBjoern A. Zeeb 	  { NULL }						\
1764807330cSBjoern A. Zeeb }
1774807330cSBjoern A. Zeeb 
178901fadf7SArchie Cobbs /* Netgraph commands */
179901fadf7SArchie Cobbs enum {
180901fadf7SArchie Cobbs 	NGM_L2TP_SET_CONFIG = 1,	/* supply a struct ng_l2tp_config */
181901fadf7SArchie Cobbs 	NGM_L2TP_GET_CONFIG,		/* returns a struct ng_l2tp_config */
182901fadf7SArchie Cobbs 	NGM_L2TP_SET_SESS_CONFIG,	/* supply struct ng_l2tp_sess_config */
183901fadf7SArchie Cobbs 	NGM_L2TP_GET_SESS_CONFIG,	/* supply a session id (u_int16_t) */
184901fadf7SArchie Cobbs 	NGM_L2TP_GET_STATS,		/* returns struct ng_l2tp_stats */
185901fadf7SArchie Cobbs 	NGM_L2TP_CLR_STATS,		/* clears stats */
186901fadf7SArchie Cobbs 	NGM_L2TP_GETCLR_STATS,		/* returns & clears stats */
1874807330cSBjoern A. Zeeb 	NGM_L2TP_GET_SESSION_STATS,	/* returns session stats */
1884807330cSBjoern A. Zeeb 	NGM_L2TP_CLR_SESSION_STATS,	/* clears session stats */
1894807330cSBjoern A. Zeeb 	NGM_L2TP_GETCLR_SESSION_STATS,	/* returns & clears session stats */
190901fadf7SArchie Cobbs 	NGM_L2TP_ACK_FAILURE,		/* sent *from* node after ack timeout */
1911e031324SBjoern A. Zeeb 	NGM_L2TP_SET_SEQ		/* supply a struct ng_l2tp_seq_config */
192901fadf7SArchie Cobbs };
193901fadf7SArchie Cobbs 
194e20480bfSRuslan Ermilov #endif /* _NETGRAPH_NG_L2TP_H_ */
195