FreeBSD kernel netgraph code
ng_l2tp.h
Go to the documentation of this file.
1/*-
2 * Copyright (c) 2001-2002 Packet Design, LLC.
3 * All rights reserved.
4 *
5 * Subject to the following obligations and disclaimer of warranty,
6 * use and redistribution of this software, in source or object code
7 * forms, with or without modifications are expressly permitted by
8 * Packet Design; provided, however, that:
9 *
10 * (i) Any and all reproductions of the source or object code
11 * must include the copyright notice above and the following
12 * disclaimer of warranties; and
13 * (ii) No rights are granted, in any manner or form, to use
14 * Packet Design trademarks, including the mark "PACKET DESIGN"
15 * on advertising, endorsements, or otherwise except as such
16 * appears in the above copyright notice or in the software.
17 *
18 * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
19 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
20 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
21 * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
22 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
23 * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
24 * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
25 * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
26 * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
27 * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
28 * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
30 * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
31 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
34 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $FreeBSD$
40 */
41
42#ifndef _NETGRAPH_NG_L2TP_H_
43#define _NETGRAPH_NG_L2TP_H_
44
45/* Node type name and magic cookie */
46#define NG_L2TP_NODE_TYPE "l2tp"
47#define NGM_L2TP_COOKIE 1091515793
48
49/* Hook names */
50#define NG_L2TP_HOOK_CTRL "ctrl" /* control channel hook */
51#define NG_L2TP_HOOK_LOWER "lower" /* hook to lower layers */
52
53/* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */
54#define NG_L2TP_HOOK_SESSION_P "session_" /* session data hook (prefix) */
55#define NG_L2TP_HOOK_SESSION_F "session_%04x" /* session data hook (format) */
56
57/* Set initial sequence numbers to not yet enabled node. */
59 u_int16_t ns; /* sequence number to send next */
60 u_int16_t nr; /* sequence number to be recved next */
61 u_int16_t rack; /* last 'nr' received */
62 u_int16_t xack; /* last 'nr' sent */
63};
64
65/* Keep this in sync with the above structure definition. */
66#define NG_L2TP_SEQ_CONFIG_TYPE_INFO { \
67 { "ns", &ng_parse_uint16_type }, \
68 { "nr", &ng_parse_uint16_type }, \
69 { NULL } \
70}
71
72/* Configuration for a node */
74 u_char enabled; /* enables traffic flow */
75 u_char match_id; /* tunnel id must match 'tunnel_id' */
76 u_int16_t tunnel_id; /* local tunnel id */
77 u_int16_t peer_id; /* peer's tunnel id */
78 u_int16_t peer_win; /* peer's max recv window size */
79 u_int16_t rexmit_max; /* max retransmits before failure */
80 u_int16_t rexmit_max_to; /* max delay between retransmits */
81};
82
83/* Keep this in sync with the above structure definition */
84#define NG_L2TP_CONFIG_TYPE_INFO { \
85 { "enabled", &ng_parse_uint8_type }, \
86 { "match_id", &ng_parse_uint8_type }, \
87 { "tunnel_id", &ng_parse_hint16_type }, \
88 { "peer_id", &ng_parse_hint16_type }, \
89 { "peer_win", &ng_parse_uint16_type }, \
90 { "rexmit_max", &ng_parse_uint16_type }, \
91 { "rexmit_max_to", &ng_parse_uint16_type }, \
92 { NULL } \
93}
94
95/* Configuration for a session hook */
97 u_int16_t session_id; /* local session id */
98 u_int16_t peer_id; /* peer's session id */
99 u_char control_dseq; /* whether we control data sequencing */
100 u_char enable_dseq; /* whether to enable data sequencing */
101 u_char include_length; /* whether to include length field */
102};
103
104/* Keep this in sync with the above structure definition */
105#define NG_L2TP_SESS_CONFIG_TYPE_INFO { \
106 { "session_id", &ng_parse_hint16_type }, \
107 { "peer_id", &ng_parse_hint16_type }, \
108 { "control_dseq", &ng_parse_uint8_type }, \
109 { "enable_dseq", &ng_parse_uint8_type }, \
110 { "include_length", &ng_parse_uint8_type }, \
111 { NULL } \
112}
113
114/* Statistics struct */
116 u_int32_t xmitPackets; /* number of packets xmit */
117 u_int32_t xmitOctets; /* number of octets xmit */
118 u_int32_t xmitZLBs; /* ack-only packets transmitted */
119 u_int32_t xmitDrops; /* xmits dropped due to full window */
120 u_int32_t xmitTooBig; /* ctrl pkts dropped because too big */
121 u_int32_t xmitInvalid; /* ctrl packets with no session ID */
122 u_int32_t xmitDataTooBig; /* data pkts dropped because too big */
123 u_int32_t xmitRetransmits; /* retransmitted packets */
124 u_int32_t recvPackets; /* number of packets rec'd */
125 u_int32_t recvOctets; /* number of octets rec'd */
126 u_int32_t recvRunts; /* too short packets rec'd */
127 u_int32_t recvInvalid; /* invalid packets rec'd */
128 u_int32_t recvWrongTunnel; /* packets rec'd with wrong tunnel id */
129 u_int32_t recvUnknownSID; /* pkts rec'd with unknown session id */
130 u_int32_t recvBadAcks; /* ctrl pkts rec'd with invalid 'nr' */
131 u_int32_t recvOutOfOrder; /* out of order ctrl pkts rec'd */
132 u_int32_t recvDuplicates; /* duplicate ctrl pkts rec'd */
133 u_int32_t recvDataDrops; /* dup/out of order data pkts rec'd */
134 u_int32_t recvZLBs; /* ack-only packets rec'd */
135 u_int32_t memoryFailures; /* times we couldn't allocate memory */
136};
137
138/* Keep this in sync with the above structure definition */
139#define NG_L2TP_STATS_TYPE_INFO { \
140 { "xmitPackets", &ng_parse_uint32_type }, \
141 { "xmitOctets", &ng_parse_uint32_type }, \
142 { "xmitZLBs", &ng_parse_uint32_type }, \
143 { "xmitDrops", &ng_parse_uint32_type }, \
144 { "xmitTooBig", &ng_parse_uint32_type }, \
145 { "xmitInvalid", &ng_parse_uint32_type }, \
146 { "xmitDataTooBig", &ng_parse_uint32_type }, \
147 { "xmitRetransmits", &ng_parse_uint32_type }, \
148 { "recvPackets", &ng_parse_uint32_type }, \
149 { "recvOctets", &ng_parse_uint32_type }, \
150 { "recvRunts", &ng_parse_uint32_type }, \
151 { "recvInvalid", &ng_parse_uint32_type }, \
152 { "recvWrongTunnel", &ng_parse_uint32_type }, \
153 { "recvUnknownSID", &ng_parse_uint32_type }, \
154 { "recvBadAcks", &ng_parse_uint32_type }, \
155 { "recvOutOfOrder", &ng_parse_uint32_type }, \
156 { "recvDuplicates", &ng_parse_uint32_type }, \
157 { "recvDataDrops", &ng_parse_uint32_type }, \
158 { "recvZLBs", &ng_parse_uint32_type }, \
159 { "memoryFailures", &ng_parse_uint32_type }, \
160 { NULL } \
161}
162
163/* Session statistics struct. */
165 u_int64_t xmitPackets; /* number of packets xmit */
166 u_int64_t xmitOctets; /* number of octets xmit */
167 u_int64_t recvPackets; /* number of packets received */
168 u_int64_t recvOctets; /* number of octets received */
169};
170
171/* Keep this in sync with the above structure definition. */
172#define NG_L2TP_SESSION_STATS_TYPE_INFO { \
173 { "xmitPackets", &ng_parse_uint64_type }, \
174 { "xmitOctets", &ng_parse_uint64_type }, \
175 { "recvPackets", &ng_parse_uint64_type }, \
176 { "recvOctets", &ng_parse_uint64_type }, \
177 { NULL } \
178}
179
180/* Netgraph commands */
181enum {
182 NGM_L2TP_SET_CONFIG = 1, /* supply a struct ng_l2tp_config */
183 NGM_L2TP_GET_CONFIG, /* returns a struct ng_l2tp_config */
184 NGM_L2TP_SET_SESS_CONFIG, /* supply struct ng_l2tp_sess_config */
185 NGM_L2TP_GET_SESS_CONFIG, /* supply a session id (u_int16_t) */
186 NGM_L2TP_GET_STATS, /* returns struct ng_l2tp_stats */
187 NGM_L2TP_CLR_STATS, /* clears stats */
188 NGM_L2TP_GETCLR_STATS, /* returns & clears stats */
189 NGM_L2TP_GET_SESSION_STATS, /* returns session stats */
190 NGM_L2TP_CLR_SESSION_STATS, /* clears session stats */
191 NGM_L2TP_GETCLR_SESSION_STATS, /* returns & clears session stats */
192 NGM_L2TP_ACK_FAILURE, /* sent *from* node after ack timeout */
193 NGM_L2TP_SET_SEQ /* supply a struct ng_l2tp_seq_config */
195
196#endif /* _NETGRAPH_NG_L2TP_H_ */
@ NGM_L2TP_SET_CONFIG
Definition: ng_l2tp.h:182
@ NGM_L2TP_GETCLR_SESSION_STATS
Definition: ng_l2tp.h:191
@ NGM_L2TP_GET_SESSION_STATS
Definition: ng_l2tp.h:189
@ NGM_L2TP_SET_SESS_CONFIG
Definition: ng_l2tp.h:184
@ NGM_L2TP_CLR_SESSION_STATS
Definition: ng_l2tp.h:190
@ NGM_L2TP_GETCLR_STATS
Definition: ng_l2tp.h:188
@ NGM_L2TP_GET_SESS_CONFIG
Definition: ng_l2tp.h:185
@ NGM_L2TP_GET_STATS
Definition: ng_l2tp.h:186
@ NGM_L2TP_CLR_STATS
Definition: ng_l2tp.h:187
@ NGM_L2TP_GET_CONFIG
Definition: ng_l2tp.h:183
@ NGM_L2TP_SET_SEQ
Definition: ng_l2tp.h:193
@ NGM_L2TP_ACK_FAILURE
Definition: ng_l2tp.h:192
u_int16_t rexmit_max
Definition: ng_l2tp.h:79
u_char enabled
Definition: ng_l2tp.h:74
u_int16_t peer_id
Definition: ng_l2tp.h:77
u_int16_t rexmit_max_to
Definition: ng_l2tp.h:80
u_char match_id
Definition: ng_l2tp.h:75
u_int16_t tunnel_id
Definition: ng_l2tp.h:76
u_int16_t peer_win
Definition: ng_l2tp.h:78
u_int16_t rack
Definition: ng_l2tp.h:61
u_int16_t xack
Definition: ng_l2tp.h:62
u_int16_t ns
Definition: ng_l2tp.h:59
u_int16_t nr
Definition: ng_l2tp.h:60
u_char enable_dseq
Definition: ng_l2tp.h:100
u_int16_t session_id
Definition: ng_l2tp.h:97
u_int16_t peer_id
Definition: ng_l2tp.h:98
u_char control_dseq
Definition: ng_l2tp.h:99
u_char include_length
Definition: ng_l2tp.h:101
u_int64_t recvOctets
Definition: ng_l2tp.h:168
u_int64_t xmitOctets
Definition: ng_l2tp.h:166
u_int64_t recvPackets
Definition: ng_l2tp.h:167
u_int64_t xmitPackets
Definition: ng_l2tp.h:165
u_int32_t recvPackets
Definition: ng_l2tp.h:124
u_int32_t recvInvalid
Definition: ng_l2tp.h:127
u_int32_t xmitPackets
Definition: ng_l2tp.h:116
u_int32_t recvBadAcks
Definition: ng_l2tp.h:130
u_int32_t recvWrongTunnel
Definition: ng_l2tp.h:128
u_int32_t xmitOctets
Definition: ng_l2tp.h:117
u_int32_t recvRunts
Definition: ng_l2tp.h:126
u_int32_t recvOctets
Definition: ng_l2tp.h:125
u_int32_t xmitDataTooBig
Definition: ng_l2tp.h:122
u_int32_t memoryFailures
Definition: ng_l2tp.h:135
u_int32_t recvDataDrops
Definition: ng_l2tp.h:133
u_int32_t recvDuplicates
Definition: ng_l2tp.h:132
u_int32_t recvOutOfOrder
Definition: ng_l2tp.h:131
u_int32_t xmitInvalid
Definition: ng_l2tp.h:121
u_int32_t xmitRetransmits
Definition: ng_l2tp.h:123
u_int32_t xmitZLBs
Definition: ng_l2tp.h:118
u_int32_t recvZLBs
Definition: ng_l2tp.h:134
u_int32_t xmitTooBig
Definition: ng_l2tp.h:120
u_int32_t recvUnknownSID
Definition: ng_l2tp.h:129
u_int32_t xmitDrops
Definition: ng_l2tp.h:119