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