aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/l2tp.h
diff options
context:
space:
mode:
authorJames Chapman <jchapman@katalix.com>2010-04-02 02:19:10 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-03 17:56:05 -0400
commit309795f4bec2d69cd507a631f82065c2198a0825 (patch)
treeb3676be9a8f65f0d828a07e3bd6906bf7cd7b664 /include/linux/l2tp.h
parentf408e0ce40270559ef80f231843c93baa9947bc5 (diff)
l2tp: Add netlink control API for L2TP
In L2TPv3, we need to create/delete/modify/query L2TP tunnel and session contexts. The number of parameters is significant. So let's use netlink. Userspace uses this API to control L2TP tunnel/session contexts in the kernel. The previous pppol2tp driver was managed using [gs]etsockopt(). This API is retained for backwards compatibility. Unlike L2TPv2 which carries only PPP frames, L2TPv3 can carry raw ethernet frames or other frame types and these do not always have an associated socket family. Therefore, we need a way to use L2TP sessions that doesn't require a socket type for each supported frame type. Hence netlink is used. Signed-off-by: James Chapman <jchapman@katalix.com> Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/l2tp.h')
-rw-r--r--include/linux/l2tp.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/include/linux/l2tp.h b/include/linux/l2tp.h
index deff7bca4e05..4bdb31df8e72 100644
--- a/include/linux/l2tp.h
+++ b/include/linux/l2tp.h
@@ -11,6 +11,8 @@
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12#include <linux/socket.h> 12#include <linux/socket.h>
13#include <linux/in.h> 13#include <linux/in.h>
14#else
15#include <netinet/in.h>
14#endif 16#endif
15 17
16#define IPPROTO_L2TP 115 18#define IPPROTO_L2TP 115
@@ -21,6 +23,7 @@
21 * @l2tp_addr: protocol specific address information 23 * @l2tp_addr: protocol specific address information
22 * @l2tp_conn_id: connection id of tunnel 24 * @l2tp_conn_id: connection id of tunnel
23 */ 25 */
26#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
24struct sockaddr_l2tpip { 27struct sockaddr_l2tpip {
25 /* The first fields must match struct sockaddr_in */ 28 /* The first fields must match struct sockaddr_in */
26 sa_family_t l2tp_family; /* AF_INET */ 29 sa_family_t l2tp_family; /* AF_INET */
@@ -35,4 +38,126 @@ struct sockaddr_l2tpip {
35 sizeof(__u32)]; 38 sizeof(__u32)];
36}; 39};
37 40
41/*****************************************************************************
42 * NETLINK_GENERIC netlink family.
43 *****************************************************************************/
44
45/*
46 * Commands.
47 * Valid TLVs of each command are:-
48 * TUNNEL_CREATE - CONN_ID, pw_type, netns, ifname, ipinfo, udpinfo, udpcsum, vlanid
49 * TUNNEL_DELETE - CONN_ID
50 * TUNNEL_MODIFY - CONN_ID, udpcsum
51 * TUNNEL_GETSTATS - CONN_ID, (stats)
52 * TUNNEL_GET - CONN_ID, (...)
53 * SESSION_CREATE - SESSION_ID, PW_TYPE, offset, data_seq, cookie, peer_cookie, offset, l2spec
54 * SESSION_DELETE - SESSION_ID
55 * SESSION_MODIFY - SESSION_ID, data_seq
56 * SESSION_GET - SESSION_ID, (...)
57 * SESSION_GETSTATS - SESSION_ID, (stats)
58 *
59 */
60enum {
61 L2TP_CMD_NOOP,
62 L2TP_CMD_TUNNEL_CREATE,
63 L2TP_CMD_TUNNEL_DELETE,
64 L2TP_CMD_TUNNEL_MODIFY,
65 L2TP_CMD_TUNNEL_GET,
66 L2TP_CMD_SESSION_CREATE,
67 L2TP_CMD_SESSION_DELETE,
68 L2TP_CMD_SESSION_MODIFY,
69 L2TP_CMD_SESSION_GET,
70 __L2TP_CMD_MAX,
71};
72
73#define L2TP_CMD_MAX (__L2TP_CMD_MAX - 1)
74
75/*
76 * ATTR types defined for L2TP
77 */
78enum {
79 L2TP_ATTR_NONE, /* no data */
80 L2TP_ATTR_PW_TYPE, /* u16, enum l2tp_pwtype */
81 L2TP_ATTR_ENCAP_TYPE, /* u16, enum l2tp_encap_type */
82 L2TP_ATTR_OFFSET, /* u16 */
83 L2TP_ATTR_DATA_SEQ, /* u16 */
84 L2TP_ATTR_L2SPEC_TYPE, /* u8, enum l2tp_l2spec_type */
85 L2TP_ATTR_L2SPEC_LEN, /* u8, enum l2tp_l2spec_type */
86 L2TP_ATTR_PROTO_VERSION, /* u8 */
87 L2TP_ATTR_IFNAME, /* string */
88 L2TP_ATTR_CONN_ID, /* u32 */
89 L2TP_ATTR_PEER_CONN_ID, /* u32 */
90 L2TP_ATTR_SESSION_ID, /* u32 */
91 L2TP_ATTR_PEER_SESSION_ID, /* u32 */
92 L2TP_ATTR_UDP_CSUM, /* u8 */
93 L2TP_ATTR_VLAN_ID, /* u16 */
94 L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
95 L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
96 L2TP_ATTR_DEBUG, /* u32 */
97 L2TP_ATTR_RECV_SEQ, /* u8 */
98 L2TP_ATTR_SEND_SEQ, /* u8 */
99 L2TP_ATTR_LNS_MODE, /* u8 */
100 L2TP_ATTR_USING_IPSEC, /* u8 */
101 L2TP_ATTR_RECV_TIMEOUT, /* msec */
102 L2TP_ATTR_FD, /* int */
103 L2TP_ATTR_IP_SADDR, /* u32 */
104 L2TP_ATTR_IP_DADDR, /* u32 */
105 L2TP_ATTR_UDP_SPORT, /* u16 */
106 L2TP_ATTR_UDP_DPORT, /* u16 */
107 L2TP_ATTR_MTU, /* u16 */
108 L2TP_ATTR_MRU, /* u16 */
109 L2TP_ATTR_STATS, /* nested */
110 __L2TP_ATTR_MAX,
111};
112
113#define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
114
115/* Nested in L2TP_ATTR_STATS */
116enum {
117 L2TP_ATTR_STATS_NONE, /* no data */
118 L2TP_ATTR_TX_PACKETS, /* u64 */
119 L2TP_ATTR_TX_BYTES, /* u64 */
120 L2TP_ATTR_TX_ERRORS, /* u64 */
121 L2TP_ATTR_RX_PACKETS, /* u64 */
122 L2TP_ATTR_RX_BYTES, /* u64 */
123 L2TP_ATTR_RX_SEQ_DISCARDS, /* u64 */
124 L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
125 L2TP_ATTR_RX_ERRORS, /* u64 */
126 __L2TP_ATTR_STATS_MAX,
127};
128
129#define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
130
131enum l2tp_pwtype {
132 L2TP_PWTYPE_NONE = 0x0000,
133 L2TP_PWTYPE_ETH_VLAN = 0x0004,
134 L2TP_PWTYPE_ETH = 0x0005,
135 L2TP_PWTYPE_PPP = 0x0007,
136 L2TP_PWTYPE_PPP_AC = 0x0008,
137 L2TP_PWTYPE_IP = 0x000b,
138 __L2TP_PWTYPE_MAX
139};
140
141enum l2tp_l2spec_type {
142 L2TP_L2SPECTYPE_NONE,
143 L2TP_L2SPECTYPE_DEFAULT,
144};
145
146enum l2tp_encap_type {
147 L2TP_ENCAPTYPE_UDP,
148 L2TP_ENCAPTYPE_IP,
149};
150
151enum l2tp_seqmode {
152 L2TP_SEQ_NONE = 0,
153 L2TP_SEQ_IP = 1,
154 L2TP_SEQ_ALL = 2,
155};
156
157/*
158 * NETLINK_GENERIC related info
159 */
160#define L2TP_GENL_NAME "l2tp"
161#define L2TP_GENL_VERSION 0x1
162
38#endif 163#endif