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