1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef __L2TPK_H__
25#define __L2TPK_H__
26
27#define L2TP_UDP_PORT 		1701
28
29#define PPPPROTO_L2TP		18		/* TEMP - move to ppp.h - 1..32 are reserved */
30#define L2TP_NAME		"L2TP"		/* */
31
32#ifdef KERNEL
33SYSCTL_DECL(_net_ppp_l2tp);
34#endif
35
36/* some default values */
37#define L2TP_DEFAULT_WINDOW_SIZE	4	/* default window size for both sides */
38#define L2TP_DEFAULT_INITIAL_TIMEOUT	1		/* 1 seconds */
39#define L2TP_DEFAULT_TIMEOUT_CAP	4		/* 4 seconds */
40#define L2TP_DEFAULT_RETRY_COUNT	9
41#define L2TP_DEFAULT_CONNECT_TIMEOUT		1	/* 1 seconds */
42#define L2TP_DEFAULT_CONNECT_RETRY_COUNT	60	/* 60 tries */
43
44#define L2TP_OPT_FLAGS			1	/* see flags definition below */
45#define L2TP_OPT_PEERADDRESS		2	/* peer IP address */
46#define L2TP_OPT_TUNNEL_ID		3	/* tunnel id for the connection */
47#define L2TP_OPT_NEW_TUNNEL_ID		4	/* create a new tunnel id for the connection */
48#define L2TP_OPT_PEER_TUNNEL_ID		5	/* peer tunnel id for the connection */
49#define L2TP_OPT_SESSION_ID		6	/* session id for the connection */
50#define L2TP_OPT_PEER_SESSION_ID	7	/* peer session id for the connection */
51#define L2TP_OPT_WINDOW			8	/* our receive window */
52#define L2TP_OPT_PEER_WINDOW		9	/* peer receive window */
53#define L2TP_OPT_INITIAL_TIMEOUT	10	/* reliable connection layer intial retry timeout */
54#define L2TP_OPT_TIMEOUT_CAP		11	/* reliable connection layer timeout cap */
55#define L2TP_OPT_MAX_RETRIES		12	/* reliable connection layer max retries */
56#define L2TP_OPT_ACCEPT			13	/* accept incomming connect request and transfer to new socket */
57#define L2TP_OPT_OURADDRESS		14	/* our IP address */
58#define L2TP_OPT_BAUDRATE		15	/* tunnel baudrate */
59#define L2TP_OPT_RELIABILITY		16	/* turn on/off reliability layer */
60#define L2TP_OPT_SETDELEGATEDPID    17  /* set the delegated process for traffic statistics */
61
62/* flags definition */
63#define L2TP_FLAG_DEBUG		0x00000002	/* debug mode, send verbose logs to syslog */
64#define L2TP_FLAG_CONTROL	0x00000004	/* this is a control session (as opposed to a data session) */
65#define L2TP_FLAG_SEQ_REQ	0x00000008	/* our sequencing required (ignored for control connection) */
66#define L2TP_FLAG_PEER_SEQ_REQ	0x00000010	/* peer sequencing required (ignored for control connection) */
67#define L2TP_FLAG_ADAPT_TIMER	0x00000020	/* use adaptative timer for reliable layer */
68#define L2TP_FLAG_IPSEC		0x00000040	/* is IPSec used for this connection */
69
70/* control and data flags */
71#define L2TP_FLAGS_T		0x8000
72#define L2TP_FLAGS_L		0x4000
73#define L2TP_FLAGS_S		0x0800
74#define L2TP_FLAGS_O		0x0200
75#define L2TP_FLAGS_P		0x0100
76
77#define L2TP_VERSION_MASK	0x000F
78#define L2TP_VERSION		2
79
80
81/* define well known values */
82#define L2TP_HDR_VERSION	2
83#define L2TP_CNTL_HDR_SIZE	12	/* control headers are always this size */
84#define L2TP_DATA_HDR_SIZE	8	/* hdr size for data we send - without sequencing */
85
86struct l2tp_header {
87    /* header for control messages */
88    u_int16_t	flags_vers;
89    u_int16_t	len;
90    u_int16_t	tunnel_id;
91    u_int16_t	session_id;
92    u_int16_t	ns;
93    u_int16_t	nr;
94    u_int16_t	off_size;
95};
96
97struct sockaddr_l2tp {
98    u_int8_t	l2tp_len;			/* sizeof(struct sockaddr_ppp) + variable part */
99    u_int8_t	l2tp_family;			/* AF_PPPCTL */
100    u_int16_t	l2tp_proto;			/* protocol coding address - PPPPROTO_L2TP */
101    u_int16_t 	l2tp_tunnel_id;
102    u_int16_t	l2tp_session_id;
103    u_int8_t	pad[8];
104};
105
106#endif
107