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