1901fadf7SArchie Cobbs 2901fadf7SArchie Cobbs /* 3901fadf7SArchie Cobbs * Copyright (c) 2001-2002 Packet Design, LLC. 4901fadf7SArchie Cobbs * All rights reserved. 5901fadf7SArchie Cobbs * 6901fadf7SArchie Cobbs * Subject to the following obligations and disclaimer of warranty, 7901fadf7SArchie Cobbs * use and redistribution of this software, in source or object code 8901fadf7SArchie Cobbs * forms, with or without modifications are expressly permitted by 9901fadf7SArchie Cobbs * Packet Design; provided, however, that: 10901fadf7SArchie Cobbs * 11901fadf7SArchie Cobbs * (i) Any and all reproductions of the source or object code 12901fadf7SArchie Cobbs * must include the copyright notice above and the following 13901fadf7SArchie Cobbs * disclaimer of warranties; and 14901fadf7SArchie Cobbs * (ii) No rights are granted, in any manner or form, to use 15901fadf7SArchie Cobbs * Packet Design trademarks, including the mark "PACKET DESIGN" 16901fadf7SArchie Cobbs * on advertising, endorsements, or otherwise except as such 17901fadf7SArchie Cobbs * appears in the above copyright notice or in the software. 18901fadf7SArchie Cobbs * 19901fadf7SArchie Cobbs * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND 20901fadf7SArchie Cobbs * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO 21901fadf7SArchie Cobbs * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING 22901fadf7SArchie Cobbs * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED 23901fadf7SArchie Cobbs * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 24901fadf7SArchie Cobbs * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE, 25901fadf7SArchie Cobbs * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS 26901fadf7SArchie Cobbs * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, 27901fadf7SArchie Cobbs * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE 28901fadf7SArchie Cobbs * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE 29901fadf7SArchie Cobbs * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT, 30901fadf7SArchie Cobbs * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL 31901fadf7SArchie Cobbs * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF 32901fadf7SArchie Cobbs * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 33901fadf7SArchie Cobbs * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34901fadf7SArchie Cobbs * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 35901fadf7SArchie Cobbs * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 36901fadf7SArchie Cobbs * THE POSSIBILITY OF SUCH DAMAGE. 37901fadf7SArchie Cobbs * 38901fadf7SArchie Cobbs * Author: Archie Cobbs <archie@freebsd.org> 39901fadf7SArchie Cobbs * 40901fadf7SArchie Cobbs * $FreeBSD$ 41901fadf7SArchie Cobbs */ 42901fadf7SArchie Cobbs 43e20480bfSRuslan Ermilov #ifndef _NETGRAPH_NG_L2TP_H_ 44e20480bfSRuslan Ermilov #define _NETGRAPH_NG_L2TP_H_ 45901fadf7SArchie Cobbs 46901fadf7SArchie Cobbs /* Node type name and magic cookie */ 47901fadf7SArchie Cobbs #define NG_L2TP_NODE_TYPE "l2tp" 484807330cSBjoern A. Zeeb #define NGM_L2TP_COOKIE 1091515793 49901fadf7SArchie Cobbs 50901fadf7SArchie Cobbs /* Hook names */ 51901fadf7SArchie Cobbs #define NG_L2TP_HOOK_CTRL "ctrl" /* control channel hook */ 52901fadf7SArchie Cobbs #define NG_L2TP_HOOK_LOWER "lower" /* hook to lower layers */ 53901fadf7SArchie Cobbs 54901fadf7SArchie Cobbs /* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */ 55901fadf7SArchie Cobbs #define NG_L2TP_HOOK_SESSION_P "session_" /* session data hook (prefix) */ 56901fadf7SArchie Cobbs #define NG_L2TP_HOOK_SESSION_F "session_%04x" /* session data hook (format) */ 57901fadf7SArchie Cobbs 581e031324SBjoern A. Zeeb /* Set intial sequence numbers to not yet enabled node. */ 591e031324SBjoern A. Zeeb struct ng_l2tp_seq_config { 601e031324SBjoern A. Zeeb u_int16_t ns; /* sequence number to send next */ 611e031324SBjoern A. Zeeb u_int16_t nr; /* sequence number to be recved next */ 621e031324SBjoern A. Zeeb u_int16_t rack; /* last 'nr' received */ 631e031324SBjoern A. Zeeb u_int16_t xack; /* last 'nr' sent */ 641e031324SBjoern A. Zeeb }; 651e031324SBjoern A. Zeeb 661e031324SBjoern A. Zeeb /* Keep this in sync with the above structure definition. */ 671e031324SBjoern A. Zeeb #define NG_L2TP_SEQ_CONFIG_TYPE_INFO { \ 681e031324SBjoern A. Zeeb { "ns", &ng_parse_uint16_type }, \ 691e031324SBjoern A. Zeeb { "nr", &ng_parse_uint16_type }, \ 701e031324SBjoern A. Zeeb { NULL } \ 711e031324SBjoern A. Zeeb } 721e031324SBjoern A. Zeeb 73901fadf7SArchie Cobbs /* Configuration for a node */ 74901fadf7SArchie Cobbs struct ng_l2tp_config { 75901fadf7SArchie Cobbs u_char enabled; /* enables traffic flow */ 76901fadf7SArchie Cobbs u_char match_id; /* tunnel id must match 'tunnel_id' */ 77901fadf7SArchie Cobbs u_int16_t tunnel_id; /* local tunnel id */ 78901fadf7SArchie Cobbs u_int16_t peer_id; /* peer's tunnel id */ 79901fadf7SArchie Cobbs u_int16_t peer_win; /* peer's max recv window size */ 80901fadf7SArchie Cobbs u_int16_t rexmit_max; /* max retransmits before failure */ 81901fadf7SArchie Cobbs u_int16_t rexmit_max_to; /* max delay between retransmits */ 82901fadf7SArchie Cobbs }; 83901fadf7SArchie Cobbs 84901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */ 85901fadf7SArchie Cobbs #define NG_L2TP_CONFIG_TYPE_INFO { \ 86901fadf7SArchie Cobbs { "enabled", &ng_parse_uint8_type }, \ 87901fadf7SArchie Cobbs { "match_id", &ng_parse_uint8_type }, \ 88901fadf7SArchie Cobbs { "tunnel_id", &ng_parse_hint16_type }, \ 89901fadf7SArchie Cobbs { "peer_id", &ng_parse_hint16_type }, \ 90901fadf7SArchie Cobbs { "peer_win", &ng_parse_uint16_type }, \ 91901fadf7SArchie Cobbs { "rexmit_max", &ng_parse_uint16_type }, \ 92901fadf7SArchie Cobbs { "rexmit_max_to", &ng_parse_uint16_type }, \ 93901fadf7SArchie Cobbs { NULL } \ 94901fadf7SArchie Cobbs } 95901fadf7SArchie Cobbs 96901fadf7SArchie Cobbs /* Configuration for a session hook */ 97901fadf7SArchie Cobbs struct ng_l2tp_sess_config { 98901fadf7SArchie Cobbs u_int16_t session_id; /* local session id */ 99901fadf7SArchie Cobbs u_int16_t peer_id; /* peer's session id */ 100901fadf7SArchie Cobbs u_char control_dseq; /* whether we control data sequencing */ 101901fadf7SArchie Cobbs u_char enable_dseq; /* whether to enable data sequencing */ 102901fadf7SArchie Cobbs u_char include_length; /* whether to include length field */ 103901fadf7SArchie Cobbs }; 104901fadf7SArchie Cobbs 105901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */ 106901fadf7SArchie Cobbs #define NG_L2TP_SESS_CONFIG_TYPE_INFO { \ 107901fadf7SArchie Cobbs { "session_id", &ng_parse_hint16_type }, \ 108901fadf7SArchie Cobbs { "peer_id", &ng_parse_hint16_type }, \ 109901fadf7SArchie Cobbs { "control_dseq", &ng_parse_uint8_type }, \ 110901fadf7SArchie Cobbs { "enable_dseq", &ng_parse_uint8_type }, \ 111901fadf7SArchie Cobbs { "include_length", &ng_parse_uint8_type }, \ 112901fadf7SArchie Cobbs { NULL } \ 113901fadf7SArchie Cobbs } 114901fadf7SArchie Cobbs 115901fadf7SArchie Cobbs /* Statistics struct */ 116901fadf7SArchie Cobbs struct ng_l2tp_stats { 117901fadf7SArchie Cobbs u_int32_t xmitPackets; /* number of packets xmit */ 118901fadf7SArchie Cobbs u_int32_t xmitOctets; /* number of octets xmit */ 119901fadf7SArchie Cobbs u_int32_t xmitZLBs; /* ack-only packets transmitted */ 120901fadf7SArchie Cobbs u_int32_t xmitDrops; /* xmits dropped due to full window */ 121901fadf7SArchie Cobbs u_int32_t xmitTooBig; /* ctrl pkts dropped because too big */ 122901fadf7SArchie Cobbs u_int32_t xmitInvalid; /* ctrl packets with no session ID */ 123901fadf7SArchie Cobbs u_int32_t xmitDataTooBig; /* data pkts dropped because too big */ 124901fadf7SArchie Cobbs u_int32_t xmitRetransmits; /* retransmitted packets */ 125901fadf7SArchie Cobbs u_int32_t recvPackets; /* number of packets rec'd */ 126901fadf7SArchie Cobbs u_int32_t recvOctets; /* number of octets rec'd */ 127901fadf7SArchie Cobbs u_int32_t recvRunts; /* too short packets rec'd */ 128901fadf7SArchie Cobbs u_int32_t recvInvalid; /* invalid packets rec'd */ 129901fadf7SArchie Cobbs u_int32_t recvWrongTunnel; /* packets rec'd with wrong tunnel id */ 130901fadf7SArchie Cobbs u_int32_t recvUnknownSID; /* pkts rec'd with unknown session id */ 131901fadf7SArchie Cobbs u_int32_t recvBadAcks; /* ctrl pkts rec'd with invalid 'nr' */ 132901fadf7SArchie Cobbs u_int32_t recvOutOfOrder; /* out of order ctrl pkts rec'd */ 133901fadf7SArchie Cobbs u_int32_t recvDuplicates; /* duplicate ctrl pkts rec'd */ 134901fadf7SArchie Cobbs u_int32_t recvDataDrops; /* dup/out of order data pkts rec'd */ 135901fadf7SArchie Cobbs u_int32_t recvZLBs; /* ack-only packets rec'd */ 136901fadf7SArchie Cobbs u_int32_t memoryFailures; /* times we couldn't allocate memory */ 137901fadf7SArchie Cobbs }; 138901fadf7SArchie Cobbs 139901fadf7SArchie Cobbs /* Keep this in sync with the above structure definition */ 140901fadf7SArchie Cobbs #define NG_L2TP_STATS_TYPE_INFO { \ 141901fadf7SArchie Cobbs { "xmitPackets", &ng_parse_uint32_type }, \ 142901fadf7SArchie Cobbs { "xmitOctets", &ng_parse_uint32_type }, \ 143901fadf7SArchie Cobbs { "xmitZLBs", &ng_parse_uint32_type }, \ 144901fadf7SArchie Cobbs { "xmitDrops", &ng_parse_uint32_type }, \ 145901fadf7SArchie Cobbs { "xmitTooBig", &ng_parse_uint32_type }, \ 146901fadf7SArchie Cobbs { "xmitInvalid", &ng_parse_uint32_type }, \ 147901fadf7SArchie Cobbs { "xmitDataTooBig", &ng_parse_uint32_type }, \ 148901fadf7SArchie Cobbs { "xmitRetransmits", &ng_parse_uint32_type }, \ 149901fadf7SArchie Cobbs { "recvPackets", &ng_parse_uint32_type }, \ 150901fadf7SArchie Cobbs { "recvOctets", &ng_parse_uint32_type }, \ 151901fadf7SArchie Cobbs { "recvRunts", &ng_parse_uint32_type }, \ 152901fadf7SArchie Cobbs { "recvInvalid", &ng_parse_uint32_type }, \ 153901fadf7SArchie Cobbs { "recvWrongTunnel", &ng_parse_uint32_type }, \ 154901fadf7SArchie Cobbs { "recvUnknownSID", &ng_parse_uint32_type }, \ 155901fadf7SArchie Cobbs { "recvBadAcks", &ng_parse_uint32_type }, \ 156901fadf7SArchie Cobbs { "recvOutOfOrder", &ng_parse_uint32_type }, \ 157901fadf7SArchie Cobbs { "recvDuplicates", &ng_parse_uint32_type }, \ 158901fadf7SArchie Cobbs { "recvDataDrops", &ng_parse_uint32_type }, \ 159901fadf7SArchie Cobbs { "recvZLBs", &ng_parse_uint32_type }, \ 160901fadf7SArchie Cobbs { "memoryFailures", &ng_parse_uint32_type }, \ 161901fadf7SArchie Cobbs { NULL } \ 162901fadf7SArchie Cobbs } 163901fadf7SArchie Cobbs 1644807330cSBjoern A. Zeeb /* Session statistics struct. */ 1654807330cSBjoern A. Zeeb struct ng_l2tp_session_stats { 1664807330cSBjoern A. Zeeb u_int64_t xmitPackets; /* number of packets xmit */ 1674807330cSBjoern A. Zeeb u_int64_t xmitOctets; /* number of octets xmit */ 1684807330cSBjoern A. Zeeb u_int64_t recvPackets; /* number of packets received */ 1694807330cSBjoern A. Zeeb u_int64_t recvOctets; /* number of octets received */ 1704807330cSBjoern A. Zeeb }; 1714807330cSBjoern A. Zeeb 1724807330cSBjoern A. Zeeb /* Keep this in sync with the above structure definition. */ 1734807330cSBjoern A. Zeeb #define NG_L2TP_SESSION_STATS_TYPE_INFO { \ 1744807330cSBjoern A. Zeeb { "xmitPackets", &ng_parse_uint64_type }, \ 1754807330cSBjoern A. Zeeb { "xmitOctets", &ng_parse_uint64_type }, \ 1764807330cSBjoern A. Zeeb { "recvPackets", &ng_parse_uint64_type }, \ 1774807330cSBjoern A. Zeeb { "recvOctets", &ng_parse_uint64_type }, \ 1784807330cSBjoern A. Zeeb { NULL } \ 1794807330cSBjoern A. Zeeb } 1804807330cSBjoern A. Zeeb 181901fadf7SArchie Cobbs /* Netgraph commands */ 182901fadf7SArchie Cobbs enum { 183901fadf7SArchie Cobbs NGM_L2TP_SET_CONFIG = 1, /* supply a struct ng_l2tp_config */ 184901fadf7SArchie Cobbs NGM_L2TP_GET_CONFIG, /* returns a struct ng_l2tp_config */ 185901fadf7SArchie Cobbs NGM_L2TP_SET_SESS_CONFIG, /* supply struct ng_l2tp_sess_config */ 186901fadf7SArchie Cobbs NGM_L2TP_GET_SESS_CONFIG, /* supply a session id (u_int16_t) */ 187901fadf7SArchie Cobbs NGM_L2TP_GET_STATS, /* returns struct ng_l2tp_stats */ 188901fadf7SArchie Cobbs NGM_L2TP_CLR_STATS, /* clears stats */ 189901fadf7SArchie Cobbs NGM_L2TP_GETCLR_STATS, /* returns & clears stats */ 1904807330cSBjoern A. Zeeb NGM_L2TP_GET_SESSION_STATS, /* returns session stats */ 1914807330cSBjoern A. Zeeb NGM_L2TP_CLR_SESSION_STATS, /* clears session stats */ 1924807330cSBjoern A. Zeeb NGM_L2TP_GETCLR_SESSION_STATS, /* returns & clears session stats */ 193901fadf7SArchie Cobbs NGM_L2TP_ACK_FAILURE, /* sent *from* node after ack timeout */ 1941e031324SBjoern A. Zeeb NGM_L2TP_SET_SEQ /* supply a struct ng_l2tp_seq_config */ 195901fadf7SArchie Cobbs }; 196901fadf7SArchie Cobbs 197e20480bfSRuslan Ermilov #endif /* _NETGRAPH_NG_L2TP_H_ */ 198