dsched_fq - Refactor fqp allocation/destruction
[dragonfly.git] / sys / netgraph7 / ng_l2tp.h
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: src/sys/netgraph/ng_l2tp.h,v 1.5 2005/01/07 01:45:39 imp Exp $
40  * $DragonFly: src/sys/netgraph7/ng_l2tp.h,v 1.2 2008/06/26 23:05:35 dillon Exp $
41  */
42
43 #ifndef _NETGRAPH_NG_L2TP_H_
44 #define _NETGRAPH_NG_L2TP_H_
45
46 /* Node type name and magic cookie */
47 #define NG_L2TP_NODE_TYPE       "l2tp"
48 #define NGM_L2TP_COOKIE         1091515793
49
50 /* Hook names */
51 #define NG_L2TP_HOOK_CTRL       "ctrl"          /* control channel hook */
52 #define NG_L2TP_HOOK_LOWER      "lower"         /* hook to lower layers */
53
54 /* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */
55 #define NG_L2TP_HOOK_SESSION_P  "session_"      /* session data hook (prefix) */
56 #define NG_L2TP_HOOK_SESSION_F  "session_%04x"  /* session data hook (format) */
57
58 /* Set intial sequence numbers to not yet enabled node. */
59 struct ng_l2tp_seq_config {
60         u_int16_t       ns;             /* sequence number to send next */
61         u_int16_t       nr;             /* sequence number to be recved next */
62         u_int16_t       rack;           /* last 'nr' received */
63         u_int16_t       xack;           /* last 'nr' sent */
64 };
65
66 /* Keep this in sync with the above structure definition. */
67 #define NG_L2TP_SEQ_CONFIG_TYPE_INFO    {                       \
68           { "ns",               &ng_parse_uint16_type   },      \
69           { "nr",               &ng_parse_uint16_type   },      \
70           { NULL }                                              \
71 }
72
73 /* Configuration for a node */
74 struct ng_l2tp_config {
75         u_char          enabled;        /* enables traffic flow */
76         u_char          match_id;       /* tunnel id must match 'tunnel_id' */
77         u_int16_t       tunnel_id;      /* local tunnel id */
78         u_int16_t       peer_id;        /* peer's tunnel id */
79         u_int16_t       peer_win;       /* peer's max recv window size */
80         u_int16_t       rexmit_max;     /* max retransmits before failure */
81         u_int16_t       rexmit_max_to;  /* max delay between retransmits */
82 };
83
84 /* Keep this in sync with the above structure definition */
85 #define NG_L2TP_CONFIG_TYPE_INFO        {                       \
86           { "enabled",          &ng_parse_uint8_type    },      \
87           { "match_id",         &ng_parse_uint8_type    },      \
88           { "tunnel_id",        &ng_parse_hint16_type   },      \
89           { "peer_id",          &ng_parse_hint16_type   },      \
90           { "peer_win",         &ng_parse_uint16_type   },      \
91           { "rexmit_max",       &ng_parse_uint16_type   },      \
92           { "rexmit_max_to",    &ng_parse_uint16_type   },      \
93           { NULL }                                              \
94 }
95
96 /* Configuration for a session hook */
97 struct ng_l2tp_sess_config {
98         u_int16_t       session_id;     /* local session id */
99         u_int16_t       peer_id;        /* peer's session id */
100         u_char          control_dseq;   /* whether we control data sequencing */
101         u_char          enable_dseq;    /* whether to enable data sequencing */
102         u_char          include_length; /* whether to include length field */
103 };
104
105 /* Keep this in sync with the above structure definition */
106 #define NG_L2TP_SESS_CONFIG_TYPE_INFO   {                       \
107           { "session_id",       &ng_parse_hint16_type   },      \
108           { "peer_id",          &ng_parse_hint16_type   },      \
109           { "control_dseq",     &ng_parse_uint8_type    },      \
110           { "enable_dseq",      &ng_parse_uint8_type    },      \
111           { "include_length",   &ng_parse_uint8_type    },      \
112           { NULL }                                              \
113 }
114
115 /* Statistics struct */
116 struct ng_l2tp_stats {
117         u_int32_t xmitPackets;          /* number of packets xmit */
118         u_int32_t xmitOctets;           /* number of octets xmit */
119         u_int32_t xmitZLBs;             /* ack-only packets transmitted */
120         u_int32_t xmitDrops;            /* xmits dropped due to full window */
121         u_int32_t xmitTooBig;           /* ctrl pkts dropped because too big */
122         u_int32_t xmitInvalid;          /* ctrl packets with no session ID */
123         u_int32_t xmitDataTooBig;       /* data pkts dropped because too big */
124         u_int32_t xmitRetransmits;      /* retransmitted packets */
125         u_int32_t recvPackets;          /* number of packets rec'd */
126         u_int32_t recvOctets;           /* number of octets rec'd */
127         u_int32_t recvRunts;            /* too short packets rec'd */
128         u_int32_t recvInvalid;          /* invalid packets rec'd */
129         u_int32_t recvWrongTunnel;      /* packets rec'd with wrong tunnel id */
130         u_int32_t recvUnknownSID;       /* pkts rec'd with unknown session id */
131         u_int32_t recvBadAcks;          /* ctrl pkts rec'd with invalid 'nr' */
132         u_int32_t recvOutOfOrder;       /* out of order ctrl pkts rec'd */
133         u_int32_t recvDuplicates;       /* duplicate ctrl pkts rec'd */
134         u_int32_t recvDataDrops;        /* dup/out of order data pkts rec'd */
135         u_int32_t recvZLBs;             /* ack-only packets rec'd */
136         u_int32_t memoryFailures;       /* times we couldn't allocate memory */
137 };
138
139 /* Keep this in sync with the above structure definition */
140 #define NG_L2TP_STATS_TYPE_INFO {                       \
141           { "xmitPackets",      &ng_parse_uint32_type   },      \
142           { "xmitOctets",       &ng_parse_uint32_type   },      \
143           { "xmitZLBs",         &ng_parse_uint32_type   },      \
144           { "xmitDrops",        &ng_parse_uint32_type   },      \
145           { "xmitTooBig",       &ng_parse_uint32_type   },      \
146           { "xmitInvalid",      &ng_parse_uint32_type   },      \
147           { "xmitDataTooBig",   &ng_parse_uint32_type   },      \
148           { "xmitRetransmits",  &ng_parse_uint32_type   },      \
149           { "recvPackets",      &ng_parse_uint32_type   },      \
150           { "recvOctets",       &ng_parse_uint32_type   },      \
151           { "recvRunts",        &ng_parse_uint32_type   },      \
152           { "recvInvalid",      &ng_parse_uint32_type   },      \
153           { "recvWrongTunnel",  &ng_parse_uint32_type   },      \
154           { "recvUnknownSID",   &ng_parse_uint32_type   },      \
155           { "recvBadAcks",      &ng_parse_uint32_type   },      \
156           { "recvOutOfOrder",   &ng_parse_uint32_type   },      \
157           { "recvDuplicates",   &ng_parse_uint32_type   },      \
158           { "recvDataDrops",    &ng_parse_uint32_type   },      \
159           { "recvZLBs",         &ng_parse_uint32_type   },      \
160           { "memoryFailures",   &ng_parse_uint32_type   },      \
161           { NULL }                                              \
162 }
163
164 /* Session statistics struct. */
165 struct ng_l2tp_session_stats {
166         u_int64_t xmitPackets;          /* number of packets xmit */
167         u_int64_t xmitOctets;           /* number of octets xmit */
168         u_int64_t recvPackets;          /* number of packets received */
169         u_int64_t recvOctets;           /* number of octets received */
170 };
171
172 /* Keep this in sync with the above structure definition. */
173 #define NG_L2TP_SESSION_STATS_TYPE_INFO {                       \
174           { "xmitPackets",      &ng_parse_uint64_type   },      \
175           { "xmitOctets",       &ng_parse_uint64_type   },      \
176           { "recvPackets",      &ng_parse_uint64_type   },      \
177           { "recvOctets",       &ng_parse_uint64_type   },      \
178           { NULL }                                              \
179 }
180
181 /* Netgraph commands */
182 enum {
183         NGM_L2TP_SET_CONFIG = 1,        /* supply a struct ng_l2tp_config */
184         NGM_L2TP_GET_CONFIG,            /* returns a struct ng_l2tp_config */
185         NGM_L2TP_SET_SESS_CONFIG,       /* supply struct ng_l2tp_sess_config */
186         NGM_L2TP_GET_SESS_CONFIG,       /* supply a session id (u_int16_t) */
187         NGM_L2TP_GET_STATS,             /* returns struct ng_l2tp_stats */
188         NGM_L2TP_CLR_STATS,             /* clears stats */
189         NGM_L2TP_GETCLR_STATS,          /* returns & clears stats */
190         NGM_L2TP_GET_SESSION_STATS,     /* returns session stats */
191         NGM_L2TP_CLR_SESSION_STATS,     /* clears session stats */
192         NGM_L2TP_GETCLR_SESSION_STATS,  /* returns & clears session stats */
193         NGM_L2TP_ACK_FAILURE,           /* sent *from* node after ack timeout */
194         NGM_L2TP_SET_SEQ                /* supply a struct ng_l2tp_seq_config */
195 };
196
197 #endif /* _NETGRAPH_NG_L2TP_H_ */