blob: 5b0e36d0f62b99a922da2796da56f3239a6d9c32 [file] [log] [blame]
Stephen Hemminger38cd3112011-12-23 20:52:10 -08001/*
2 * L2TP-over-IP socket for L2TPv3.
3 *
4 * Author: James Chapman <jchapman@katalix.com>
5 */
6
Stephen Hemminger910773d2012-12-11 11:16:36 -08007#ifndef _LINUX_L2TP_H_
8#define _LINUX_L2TP_H_
Stephen Hemminger38cd3112011-12-23 20:52:10 -08009
10#include <linux/types.h>
11#include <linux/socket.h>
12#include <netinet/in.h>
13
14#define IPPROTO_L2TP 115
15
16/**
17 * struct sockaddr_l2tpip - the sockaddr structure for L2TP-over-IP sockets
18 * @l2tp_family: address family number AF_L2TPIP.
19 * @l2tp_addr: protocol specific address information
20 * @l2tp_conn_id: connection id of tunnel
21 */
22#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
23struct sockaddr_l2tpip {
24 /* The first fields must match struct sockaddr_in */
25 __kernel_sa_family_t l2tp_family; /* AF_INET */
26 __be16 l2tp_unused; /* INET port number (unused) */
27 struct in_addr l2tp_addr; /* Internet address */
28
29 __u32 l2tp_conn_id; /* Connection ID of tunnel */
30
31 /* Pad to size of `struct sockaddr'. */
32 unsigned char __pad[sizeof(struct sockaddr) -
33 sizeof(__kernel_sa_family_t) -
34 sizeof(__be16) - sizeof(struct in_addr) -
35 sizeof(__u32)];
36};
37
Stephen Hemminger5e4dc842012-05-22 14:02:49 -070038/**
39 * struct sockaddr_l2tpip6 - the sockaddr structure for L2TP-over-IPv6 sockets
40 * @l2tp_family: address family number AF_L2TPIP.
41 * @l2tp_addr: protocol specific address information
42 * @l2tp_conn_id: connection id of tunnel
43 */
44struct sockaddr_l2tpip6 {
45 /* The first fields must match struct sockaddr_in6 */
46 __kernel_sa_family_t l2tp_family; /* AF_INET6 */
47 __be16 l2tp_unused; /* INET port number (unused) */
48 __be32 l2tp_flowinfo; /* IPv6 flow information */
49 struct in6_addr l2tp_addr; /* IPv6 address */
50 __u32 l2tp_scope_id; /* scope id (new in RFC2553) */
51 __u32 l2tp_conn_id; /* Connection ID of tunnel */
52};
53
Stephen Hemminger38cd3112011-12-23 20:52:10 -080054/*****************************************************************************
55 * NETLINK_GENERIC netlink family.
56 *****************************************************************************/
57
58/*
59 * Commands.
60 * Valid TLVs of each command are:-
61 * TUNNEL_CREATE - CONN_ID, pw_type, netns, ifname, ipinfo, udpinfo, udpcsum, vlanid
62 * TUNNEL_DELETE - CONN_ID
63 * TUNNEL_MODIFY - CONN_ID, udpcsum
64 * TUNNEL_GETSTATS - CONN_ID, (stats)
65 * TUNNEL_GET - CONN_ID, (...)
66 * SESSION_CREATE - SESSION_ID, PW_TYPE, offset, data_seq, cookie, peer_cookie, offset, l2spec
67 * SESSION_DELETE - SESSION_ID
68 * SESSION_MODIFY - SESSION_ID, data_seq
69 * SESSION_GET - SESSION_ID, (...)
70 * SESSION_GETSTATS - SESSION_ID, (stats)
71 *
72 */
73enum {
74 L2TP_CMD_NOOP,
75 L2TP_CMD_TUNNEL_CREATE,
76 L2TP_CMD_TUNNEL_DELETE,
77 L2TP_CMD_TUNNEL_MODIFY,
78 L2TP_CMD_TUNNEL_GET,
79 L2TP_CMD_SESSION_CREATE,
80 L2TP_CMD_SESSION_DELETE,
81 L2TP_CMD_SESSION_MODIFY,
82 L2TP_CMD_SESSION_GET,
83 __L2TP_CMD_MAX,
84};
85
86#define L2TP_CMD_MAX (__L2TP_CMD_MAX - 1)
87
88/*
89 * ATTR types defined for L2TP
90 */
91enum {
92 L2TP_ATTR_NONE, /* no data */
93 L2TP_ATTR_PW_TYPE, /* u16, enum l2tp_pwtype */
94 L2TP_ATTR_ENCAP_TYPE, /* u16, enum l2tp_encap_type */
95 L2TP_ATTR_OFFSET, /* u16 */
96 L2TP_ATTR_DATA_SEQ, /* u16 */
97 L2TP_ATTR_L2SPEC_TYPE, /* u8, enum l2tp_l2spec_type */
98 L2TP_ATTR_L2SPEC_LEN, /* u8, enum l2tp_l2spec_type */
99 L2TP_ATTR_PROTO_VERSION, /* u8 */
100 L2TP_ATTR_IFNAME, /* string */
101 L2TP_ATTR_CONN_ID, /* u32 */
102 L2TP_ATTR_PEER_CONN_ID, /* u32 */
103 L2TP_ATTR_SESSION_ID, /* u32 */
104 L2TP_ATTR_PEER_SESSION_ID, /* u32 */
105 L2TP_ATTR_UDP_CSUM, /* u8 */
106 L2TP_ATTR_VLAN_ID, /* u16 */
107 L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
108 L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
109 L2TP_ATTR_DEBUG, /* u32 */
110 L2TP_ATTR_RECV_SEQ, /* u8 */
111 L2TP_ATTR_SEND_SEQ, /* u8 */
112 L2TP_ATTR_LNS_MODE, /* u8 */
113 L2TP_ATTR_USING_IPSEC, /* u8 */
114 L2TP_ATTR_RECV_TIMEOUT, /* msec */
115 L2TP_ATTR_FD, /* int */
116 L2TP_ATTR_IP_SADDR, /* u32 */
117 L2TP_ATTR_IP_DADDR, /* u32 */
118 L2TP_ATTR_UDP_SPORT, /* u16 */
119 L2TP_ATTR_UDP_DPORT, /* u16 */
120 L2TP_ATTR_MTU, /* u16 */
121 L2TP_ATTR_MRU, /* u16 */
122 L2TP_ATTR_STATS, /* nested */
Stephen Hemminger5e4dc842012-05-22 14:02:49 -0700123 L2TP_ATTR_IP6_SADDR, /* struct in6_addr */
124 L2TP_ATTR_IP6_DADDR, /* struct in6_addr */
Stephen Hemmingerfd5c1d42014-06-09 12:50:30 -0700125 L2TP_ATTR_UDP_ZERO_CSUM6_TX, /* u8 */
126 L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* u8 */
Stephen Hemminger38cd3112011-12-23 20:52:10 -0800127 __L2TP_ATTR_MAX,
128};
129
130#define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
131
132/* Nested in L2TP_ATTR_STATS */
133enum {
134 L2TP_ATTR_STATS_NONE, /* no data */
135 L2TP_ATTR_TX_PACKETS, /* u64 */
136 L2TP_ATTR_TX_BYTES, /* u64 */
137 L2TP_ATTR_TX_ERRORS, /* u64 */
138 L2TP_ATTR_RX_PACKETS, /* u64 */
139 L2TP_ATTR_RX_BYTES, /* u64 */
140 L2TP_ATTR_RX_SEQ_DISCARDS, /* u64 */
141 L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
142 L2TP_ATTR_RX_ERRORS, /* u64 */
143 __L2TP_ATTR_STATS_MAX,
144};
145
146#define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
147
148enum l2tp_pwtype {
149 L2TP_PWTYPE_NONE = 0x0000,
150 L2TP_PWTYPE_ETH_VLAN = 0x0004,
151 L2TP_PWTYPE_ETH = 0x0005,
152 L2TP_PWTYPE_PPP = 0x0007,
153 L2TP_PWTYPE_PPP_AC = 0x0008,
154 L2TP_PWTYPE_IP = 0x000b,
155 __L2TP_PWTYPE_MAX
156};
157
158enum l2tp_l2spec_type {
159 L2TP_L2SPECTYPE_NONE,
160 L2TP_L2SPECTYPE_DEFAULT,
161};
162
163enum l2tp_encap_type {
164 L2TP_ENCAPTYPE_UDP,
165 L2TP_ENCAPTYPE_IP,
166};
167
168enum l2tp_seqmode {
169 L2TP_SEQ_NONE = 0,
170 L2TP_SEQ_IP = 1,
171 L2TP_SEQ_ALL = 2,
172};
173
174/*
175 * NETLINK_GENERIC related info
176 */
177#define L2TP_GENL_NAME "l2tp"
178#define L2TP_GENL_VERSION 0x1
Stephen Hemmingerf2334102015-01-13 17:39:32 -0800179#define L2TP_GENL_MCGROUP "l2tp"
Stephen Hemminger38cd3112011-12-23 20:52:10 -0800180
Stephen Hemminger910773d2012-12-11 11:16:36 -0800181#endif /* _LINUX_L2TP_H_ */