blob: 5ca74dd0cb643f67e6640de78a207e5c32808682 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * L2TP-over-IP socket for L2TPv3.
3 *
4 * Author: James Chapman <jchapman@katalix.com>
5 */
6
7#ifndef _LINUX_L2TP_H_
8#define _LINUX_L2TP_H_
9
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
38/*****************************************************************************
39 * NETLINK_GENERIC netlink family.
40 *****************************************************************************/
41
42/*
43 * Commands.
44 * Valid TLVs of each command are:-
45 * TUNNEL_CREATE - CONN_ID, pw_type, netns, ifname, ipinfo, udpinfo, udpcsum, vlanid
46 * TUNNEL_DELETE - CONN_ID
47 * TUNNEL_MODIFY - CONN_ID, udpcsum
48 * TUNNEL_GETSTATS - CONN_ID, (stats)
49 * TUNNEL_GET - CONN_ID, (...)
50 * SESSION_CREATE - SESSION_ID, PW_TYPE, offset, data_seq, cookie, peer_cookie, offset, l2spec
51 * SESSION_DELETE - SESSION_ID
52 * SESSION_MODIFY - SESSION_ID, data_seq
53 * SESSION_GET - SESSION_ID, (...)
54 * SESSION_GETSTATS - SESSION_ID, (stats)
55 *
56 */
57enum {
58 L2TP_CMD_NOOP,
59 L2TP_CMD_TUNNEL_CREATE,
60 L2TP_CMD_TUNNEL_DELETE,
61 L2TP_CMD_TUNNEL_MODIFY,
62 L2TP_CMD_TUNNEL_GET,
63 L2TP_CMD_SESSION_CREATE,
64 L2TP_CMD_SESSION_DELETE,
65 L2TP_CMD_SESSION_MODIFY,
66 L2TP_CMD_SESSION_GET,
67 __L2TP_CMD_MAX,
68};
69
70#define L2TP_CMD_MAX (__L2TP_CMD_MAX - 1)
71
72/*
73 * ATTR types defined for L2TP
74 */
75enum {
76 L2TP_ATTR_NONE, /* no data */
77 L2TP_ATTR_PW_TYPE, /* u16, enum l2tp_pwtype */
78 L2TP_ATTR_ENCAP_TYPE, /* u16, enum l2tp_encap_type */
79 L2TP_ATTR_OFFSET, /* u16 */
80 L2TP_ATTR_DATA_SEQ, /* u16 */
81 L2TP_ATTR_L2SPEC_TYPE, /* u8, enum l2tp_l2spec_type */
82 L2TP_ATTR_L2SPEC_LEN, /* u8, enum l2tp_l2spec_type */
83 L2TP_ATTR_PROTO_VERSION, /* u8 */
84 L2TP_ATTR_IFNAME, /* string */
85 L2TP_ATTR_CONN_ID, /* u32 */
86 L2TP_ATTR_PEER_CONN_ID, /* u32 */
87 L2TP_ATTR_SESSION_ID, /* u32 */
88 L2TP_ATTR_PEER_SESSION_ID, /* u32 */
89 L2TP_ATTR_UDP_CSUM, /* u8 */
90 L2TP_ATTR_VLAN_ID, /* u16 */
91 L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
92 L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
93 L2TP_ATTR_DEBUG, /* u32 */
94 L2TP_ATTR_RECV_SEQ, /* u8 */
95 L2TP_ATTR_SEND_SEQ, /* u8 */
96 L2TP_ATTR_LNS_MODE, /* u8 */
97 L2TP_ATTR_USING_IPSEC, /* u8 */
98 L2TP_ATTR_RECV_TIMEOUT, /* msec */
99 L2TP_ATTR_FD, /* int */
100 L2TP_ATTR_IP_SADDR, /* u32 */
101 L2TP_ATTR_IP_DADDR, /* u32 */
102 L2TP_ATTR_UDP_SPORT, /* u16 */
103 L2TP_ATTR_UDP_DPORT, /* u16 */
104 L2TP_ATTR_MTU, /* u16 */
105 L2TP_ATTR_MRU, /* u16 */
106 L2TP_ATTR_STATS, /* nested */
107 __L2TP_ATTR_MAX,
108};
109
110#define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
111
112/* Nested in L2TP_ATTR_STATS */
113enum {
114 L2TP_ATTR_STATS_NONE, /* no data */
115 L2TP_ATTR_TX_PACKETS, /* u64 */
116 L2TP_ATTR_TX_BYTES, /* u64 */
117 L2TP_ATTR_TX_ERRORS, /* u64 */
118 L2TP_ATTR_RX_PACKETS, /* u64 */
119 L2TP_ATTR_RX_BYTES, /* u64 */
120 L2TP_ATTR_RX_SEQ_DISCARDS, /* u64 */
121 L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
122 L2TP_ATTR_RX_ERRORS, /* u64 */
123 __L2TP_ATTR_STATS_MAX,
124};
125
126#define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
127
128enum l2tp_pwtype {
129 L2TP_PWTYPE_NONE = 0x0000,
130 L2TP_PWTYPE_ETH_VLAN = 0x0004,
131 L2TP_PWTYPE_ETH = 0x0005,
132 L2TP_PWTYPE_PPP = 0x0007,
133 L2TP_PWTYPE_PPP_AC = 0x0008,
134 L2TP_PWTYPE_IP = 0x000b,
135 __L2TP_PWTYPE_MAX
136};
137
138enum l2tp_l2spec_type {
139 L2TP_L2SPECTYPE_NONE,
140 L2TP_L2SPECTYPE_DEFAULT,
141};
142
143enum l2tp_encap_type {
144 L2TP_ENCAPTYPE_UDP,
145 L2TP_ENCAPTYPE_IP,
146};
147
148enum l2tp_seqmode {
149 L2TP_SEQ_NONE = 0,
150 L2TP_SEQ_IP = 1,
151 L2TP_SEQ_ALL = 2,
152};
153
154/*
155 * NETLINK_GENERIC related info
156 */
157#define L2TP_GENL_NAME "l2tp"
158#define L2TP_GENL_VERSION 0x1
159
160#endif