1139823Simp/*- 2102195Sarchie * Copyright (c) 2001-2002 Packet Design, LLC. 3102195Sarchie * All rights reserved. 4102195Sarchie * 5102195Sarchie * Subject to the following obligations and disclaimer of warranty, 6102195Sarchie * use and redistribution of this software, in source or object code 7102195Sarchie * forms, with or without modifications are expressly permitted by 8102195Sarchie * Packet Design; provided, however, that: 9102195Sarchie * 10102195Sarchie * (i) Any and all reproductions of the source or object code 11102195Sarchie * must include the copyright notice above and the following 12102195Sarchie * disclaimer of warranties; and 13102195Sarchie * (ii) No rights are granted, in any manner or form, to use 14102195Sarchie * Packet Design trademarks, including the mark "PACKET DESIGN" 15102195Sarchie * on advertising, endorsements, or otherwise except as such 16102195Sarchie * appears in the above copyright notice or in the software. 17102195Sarchie * 18102195Sarchie * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND 19102195Sarchie * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO 20102195Sarchie * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING 21102195Sarchie * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED 22102195Sarchie * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 23102195Sarchie * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE, 24102195Sarchie * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS 25102195Sarchie * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, 26102195Sarchie * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE 27102195Sarchie * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE 28102195Sarchie * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT, 29102195Sarchie * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL 30102195Sarchie * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF 31102195Sarchie * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 32102195Sarchie * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33102195Sarchie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34102195Sarchie * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 35102195Sarchie * THE POSSIBILITY OF SUCH DAMAGE. 36102195Sarchie * 37102195Sarchie * Author: Archie Cobbs <archie@freebsd.org> 38102195Sarchie * 39102195Sarchie * $FreeBSD$ 40102195Sarchie */ 41102195Sarchie 42122481Sru#ifndef _NETGRAPH_NG_L2TP_H_ 43122481Sru#define _NETGRAPH_NG_L2TP_H_ 44102195Sarchie 45102195Sarchie/* Node type name and magic cookie */ 46102195Sarchie#define NG_L2TP_NODE_TYPE "l2tp" 47133060Sbz#define NGM_L2TP_COOKIE 1091515793 48102195Sarchie 49102195Sarchie/* Hook names */ 50102195Sarchie#define NG_L2TP_HOOK_CTRL "ctrl" /* control channel hook */ 51102195Sarchie#define NG_L2TP_HOOK_LOWER "lower" /* hook to lower layers */ 52102195Sarchie 53102195Sarchie/* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */ 54102195Sarchie#define NG_L2TP_HOOK_SESSION_P "session_" /* session data hook (prefix) */ 55102195Sarchie#define NG_L2TP_HOOK_SESSION_F "session_%04x" /* session data hook (format) */ 56102195Sarchie 57133058Sbz/* Set intial sequence numbers to not yet enabled node. */ 58133058Sbzstruct ng_l2tp_seq_config { 59133058Sbz u_int16_t ns; /* sequence number to send next */ 60133058Sbz u_int16_t nr; /* sequence number to be recved next */ 61133058Sbz u_int16_t rack; /* last 'nr' received */ 62133058Sbz u_int16_t xack; /* last 'nr' sent */ 63133058Sbz}; 64133058Sbz 65133058Sbz/* Keep this in sync with the above structure definition. */ 66133058Sbz#define NG_L2TP_SEQ_CONFIG_TYPE_INFO { \ 67133058Sbz { "ns", &ng_parse_uint16_type }, \ 68133058Sbz { "nr", &ng_parse_uint16_type }, \ 69133058Sbz { NULL } \ 70133058Sbz} 71133058Sbz 72102195Sarchie/* Configuration for a node */ 73102195Sarchiestruct ng_l2tp_config { 74102195Sarchie u_char enabled; /* enables traffic flow */ 75102195Sarchie u_char match_id; /* tunnel id must match 'tunnel_id' */ 76102195Sarchie u_int16_t tunnel_id; /* local tunnel id */ 77102195Sarchie u_int16_t peer_id; /* peer's tunnel id */ 78102195Sarchie u_int16_t peer_win; /* peer's max recv window size */ 79102195Sarchie u_int16_t rexmit_max; /* max retransmits before failure */ 80102195Sarchie u_int16_t rexmit_max_to; /* max delay between retransmits */ 81102195Sarchie}; 82102195Sarchie 83102195Sarchie/* Keep this in sync with the above structure definition */ 84102195Sarchie#define NG_L2TP_CONFIG_TYPE_INFO { \ 85102195Sarchie { "enabled", &ng_parse_uint8_type }, \ 86102195Sarchie { "match_id", &ng_parse_uint8_type }, \ 87102195Sarchie { "tunnel_id", &ng_parse_hint16_type }, \ 88102195Sarchie { "peer_id", &ng_parse_hint16_type }, \ 89102195Sarchie { "peer_win", &ng_parse_uint16_type }, \ 90102195Sarchie { "rexmit_max", &ng_parse_uint16_type }, \ 91102195Sarchie { "rexmit_max_to", &ng_parse_uint16_type }, \ 92102195Sarchie { NULL } \ 93102195Sarchie} 94102195Sarchie 95102195Sarchie/* Configuration for a session hook */ 96102195Sarchiestruct ng_l2tp_sess_config { 97102195Sarchie u_int16_t session_id; /* local session id */ 98102195Sarchie u_int16_t peer_id; /* peer's session id */ 99102195Sarchie u_char control_dseq; /* whether we control data sequencing */ 100102195Sarchie u_char enable_dseq; /* whether to enable data sequencing */ 101102195Sarchie u_char include_length; /* whether to include length field */ 102102195Sarchie}; 103102195Sarchie 104102195Sarchie/* Keep this in sync with the above structure definition */ 105102195Sarchie#define NG_L2TP_SESS_CONFIG_TYPE_INFO { \ 106102195Sarchie { "session_id", &ng_parse_hint16_type }, \ 107102195Sarchie { "peer_id", &ng_parse_hint16_type }, \ 108102195Sarchie { "control_dseq", &ng_parse_uint8_type }, \ 109102195Sarchie { "enable_dseq", &ng_parse_uint8_type }, \ 110102195Sarchie { "include_length", &ng_parse_uint8_type }, \ 111102195Sarchie { NULL } \ 112102195Sarchie} 113102195Sarchie 114102195Sarchie/* Statistics struct */ 115102195Sarchiestruct ng_l2tp_stats { 116102195Sarchie u_int32_t xmitPackets; /* number of packets xmit */ 117102195Sarchie u_int32_t xmitOctets; /* number of octets xmit */ 118102195Sarchie u_int32_t xmitZLBs; /* ack-only packets transmitted */ 119102195Sarchie u_int32_t xmitDrops; /* xmits dropped due to full window */ 120102195Sarchie u_int32_t xmitTooBig; /* ctrl pkts dropped because too big */ 121102195Sarchie u_int32_t xmitInvalid; /* ctrl packets with no session ID */ 122102195Sarchie u_int32_t xmitDataTooBig; /* data pkts dropped because too big */ 123102195Sarchie u_int32_t xmitRetransmits; /* retransmitted packets */ 124102195Sarchie u_int32_t recvPackets; /* number of packets rec'd */ 125102195Sarchie u_int32_t recvOctets; /* number of octets rec'd */ 126102195Sarchie u_int32_t recvRunts; /* too short packets rec'd */ 127102195Sarchie u_int32_t recvInvalid; /* invalid packets rec'd */ 128102195Sarchie u_int32_t recvWrongTunnel; /* packets rec'd with wrong tunnel id */ 129102195Sarchie u_int32_t recvUnknownSID; /* pkts rec'd with unknown session id */ 130102195Sarchie u_int32_t recvBadAcks; /* ctrl pkts rec'd with invalid 'nr' */ 131102195Sarchie u_int32_t recvOutOfOrder; /* out of order ctrl pkts rec'd */ 132102195Sarchie u_int32_t recvDuplicates; /* duplicate ctrl pkts rec'd */ 133102195Sarchie u_int32_t recvDataDrops; /* dup/out of order data pkts rec'd */ 134102195Sarchie u_int32_t recvZLBs; /* ack-only packets rec'd */ 135102195Sarchie u_int32_t memoryFailures; /* times we couldn't allocate memory */ 136102195Sarchie}; 137102195Sarchie 138102195Sarchie/* Keep this in sync with the above structure definition */ 139102195Sarchie#define NG_L2TP_STATS_TYPE_INFO { \ 140102195Sarchie { "xmitPackets", &ng_parse_uint32_type }, \ 141102195Sarchie { "xmitOctets", &ng_parse_uint32_type }, \ 142102195Sarchie { "xmitZLBs", &ng_parse_uint32_type }, \ 143102195Sarchie { "xmitDrops", &ng_parse_uint32_type }, \ 144102195Sarchie { "xmitTooBig", &ng_parse_uint32_type }, \ 145102195Sarchie { "xmitInvalid", &ng_parse_uint32_type }, \ 146102195Sarchie { "xmitDataTooBig", &ng_parse_uint32_type }, \ 147102195Sarchie { "xmitRetransmits", &ng_parse_uint32_type }, \ 148102195Sarchie { "recvPackets", &ng_parse_uint32_type }, \ 149102195Sarchie { "recvOctets", &ng_parse_uint32_type }, \ 150102195Sarchie { "recvRunts", &ng_parse_uint32_type }, \ 151102195Sarchie { "recvInvalid", &ng_parse_uint32_type }, \ 152102195Sarchie { "recvWrongTunnel", &ng_parse_uint32_type }, \ 153102195Sarchie { "recvUnknownSID", &ng_parse_uint32_type }, \ 154102195Sarchie { "recvBadAcks", &ng_parse_uint32_type }, \ 155102195Sarchie { "recvOutOfOrder", &ng_parse_uint32_type }, \ 156102195Sarchie { "recvDuplicates", &ng_parse_uint32_type }, \ 157102195Sarchie { "recvDataDrops", &ng_parse_uint32_type }, \ 158102195Sarchie { "recvZLBs", &ng_parse_uint32_type }, \ 159102195Sarchie { "memoryFailures", &ng_parse_uint32_type }, \ 160102195Sarchie { NULL } \ 161102195Sarchie} 162102195Sarchie 163133060Sbz/* Session statistics struct. */ 164133060Sbzstruct ng_l2tp_session_stats { 165133060Sbz u_int64_t xmitPackets; /* number of packets xmit */ 166133060Sbz u_int64_t xmitOctets; /* number of octets xmit */ 167133060Sbz u_int64_t recvPackets; /* number of packets received */ 168133060Sbz u_int64_t recvOctets; /* number of octets received */ 169133060Sbz}; 170133060Sbz 171133060Sbz/* Keep this in sync with the above structure definition. */ 172133060Sbz#define NG_L2TP_SESSION_STATS_TYPE_INFO { \ 173133060Sbz { "xmitPackets", &ng_parse_uint64_type }, \ 174133060Sbz { "xmitOctets", &ng_parse_uint64_type }, \ 175133060Sbz { "recvPackets", &ng_parse_uint64_type }, \ 176133060Sbz { "recvOctets", &ng_parse_uint64_type }, \ 177133060Sbz { NULL } \ 178133060Sbz} 179133060Sbz 180102195Sarchie/* Netgraph commands */ 181102195Sarchieenum { 182102195Sarchie NGM_L2TP_SET_CONFIG = 1, /* supply a struct ng_l2tp_config */ 183102195Sarchie NGM_L2TP_GET_CONFIG, /* returns a struct ng_l2tp_config */ 184102195Sarchie NGM_L2TP_SET_SESS_CONFIG, /* supply struct ng_l2tp_sess_config */ 185102195Sarchie NGM_L2TP_GET_SESS_CONFIG, /* supply a session id (u_int16_t) */ 186102195Sarchie NGM_L2TP_GET_STATS, /* returns struct ng_l2tp_stats */ 187102195Sarchie NGM_L2TP_CLR_STATS, /* clears stats */ 188102195Sarchie NGM_L2TP_GETCLR_STATS, /* returns & clears stats */ 189133060Sbz NGM_L2TP_GET_SESSION_STATS, /* returns session stats */ 190133060Sbz NGM_L2TP_CLR_SESSION_STATS, /* clears session stats */ 191133060Sbz NGM_L2TP_GETCLR_SESSION_STATS, /* returns & clears session stats */ 192102195Sarchie NGM_L2TP_ACK_FAILURE, /* sent *from* node after ack timeout */ 193133058Sbz NGM_L2TP_SET_SEQ /* supply a struct ng_l2tp_seq_config */ 194102195Sarchie}; 195102195Sarchie 196122481Sru#endif /* _NETGRAPH_NG_L2TP_H_ */ 197