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