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