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