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