This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathmptcp.h
213 lines (187 loc) · 6.41 KB
/
mptcp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Userspace API for Multipath TCP
*
* Author: Gregory Detal <gregory.detal@tessares.net>
* Christoph Paasch <cpaasch@apple.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_MPTCP_H
#define _LINUX_MPTCP_H
#ifndef __KERNEL__
#include <netinet/in.h> /* for sockaddr_in and sockaddr_in6 */
#include <sys/socket.h> /* for struct sockaddr */
#endif
#include <linux/in.h> /* for sockaddr_in */
#include <linux/in6.h> /* for sockaddr_in6 */
#include <linux/socket.h> /* for sockaddr_storage and sa_family */
/** NETLINK API **/
#define MPTCP_GENL_NAME "mptcp"
#define MPTCP_GENL_EV_GRP_NAME "mptcp_events"
#define MPTCP_GENL_CMD_GRP_NAME "mptcp_commands"
#define MPTCP_GENL_VER 0x1
/*
* ATTR types defined for MPTCP
*/
enum {
MPTCP_ATTR_UNSPEC = 0,
MPTCP_ATTR_TOKEN, /* u32 */
MPTCP_ATTR_FAMILY, /* u16 */
MPTCP_ATTR_LOC_ID, /* u8 */
MPTCP_ATTR_REM_ID, /* u8 */
MPTCP_ATTR_SADDR4, /* u32 */
MPTCP_ATTR_SADDR6, /* struct in6_addr */
MPTCP_ATTR_DADDR4, /* u32 */
MPTCP_ATTR_DADDR6, /* struct in6_addr */
MPTCP_ATTR_SPORT, /* u16 */
MPTCP_ATTR_DPORT, /* u16 */
MPTCP_ATTR_BACKUP, /* u8 */
MPTCP_ATTR_ERROR, /* u8 */
MPTCP_ATTR_FLAGS, /* u16 */
MPTCP_ATTR_TIMEOUT, /* u32 */
MPTCP_ATTR_IF_IDX, /* s32 */
__MPTCP_ATTR_AFTER_LAST
};
#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1)
/*
* Events generated by MPTCP:
* - MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport
* A new connection has been created. It is the good time to allocate
* memory and send ADD_ADDR if needed. Depending on the traffic-patterns
* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.
*
* - MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport
* A connection is established (can start new subflows).
*
* - MPTCP_EVENT_CLOSED: token
* A connection has stopped.
*
* - MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport]
* A new address has been announced by the peer.
*
* - MPTCP_EVENT_REMOVED: token, rem_id
* An address has been lost by the peer.
*
* - MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id,
* saddr4 | saddr6, daddr4 | daddr6, sport,
* dport, backup, if_idx [, error]
* A new subflow has been established. 'error' should not be set.
*
* - MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* A subflow has been closed. An error (copy of sk_err) could be set if an
* error has been detected for this subflow.
*
* - MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* The priority of a subflow has changed. 'error' should not be set.
*
* Commands for MPTCP:
* - MPTCP_CMD_ANNOUNCE: token, loc_id, family, saddr4 | saddr6 [, sport]
* Announce a new address to the peer.
*
* - MPTCP_CMD_REMOVE: token, loc_id
* Announce that an address has been lost to the peer.
*
* - MPTCP_CMD_SUB_CREATE: token, family, loc_id, rem_id, daddr4 | daddr6,
* dport [, saddr4 | saddr6, sport, backup, if_idx]
* Create a new subflow.
*
* - MPTCP_CMD_SUB_DESTROY: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport
* Close a subflow.
*
* - MPTCP_CMD_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport, backup
* Change the priority of a subflow.
*
* - MPTCP_CMD_SET_FILTER: flags
* Set the filter on events. Set MPTCPF_* flags to only receive specific
* events. Default is to receive all events.
*
* - MPTCP_CMD_EXIST: token
* Check if this token is linked to an existing socket.
*/
enum {
MPTCP_CMD_UNSPEC = 0,
MPTCP_EVENT_CREATED,
MPTCP_EVENT_ESTABLISHED,
MPTCP_EVENT_CLOSED,
MPTCP_CMD_ANNOUNCE,
MPTCP_CMD_REMOVE,
MPTCP_EVENT_ANNOUNCED,
MPTCP_EVENT_REMOVED,
MPTCP_CMD_SUB_CREATE,
MPTCP_CMD_SUB_DESTROY,
MPTCP_EVENT_SUB_ESTABLISHED,
MPTCP_EVENT_SUB_CLOSED,
MPTCP_CMD_SUB_PRIORITY,
MPTCP_EVENT_SUB_PRIORITY,
MPTCP_CMD_SET_FILTER,
MPTCP_CMD_EXIST,
__MPTCP_CMD_AFTER_LAST
};
#define MPTCP_CMD_MAX (__MPTCP_CMD_AFTER_LAST - 1)
enum {
MPTCPF_EVENT_CREATED = (1 << 1),
MPTCPF_EVENT_ESTABLISHED = (1 << 2),
MPTCPF_EVENT_CLOSED = (1 << 3),
MPTCPF_EVENT_ANNOUNCED = (1 << 4),
MPTCPF_EVENT_REMOVED = (1 << 5),
MPTCPF_EVENT_SUB_ESTABLISHED = (1 << 6),
MPTCPF_EVENT_SUB_CLOSED = (1 << 7),
MPTCPF_EVENT_SUB_PRIORITY = (1 << 8),
};
/** Upstream Linux compatibility **/
/* MPTCP socket options */
#define MPTCP_INFO_UPSTREAM 1
#define MPTCP_TCPINFO 2
#define MPTCP_SUBFLOW_ADDRS 3
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
struct mptcp_info_upstream {
__u8 mptcpi_subflows;
__u8 mptcpi_add_addr_signal;
__u8 mptcpi_add_addr_accepted;
__u8 mptcpi_subflows_max;
__u8 mptcpi_add_addr_signal_max;
__u8 mptcpi_add_addr_accepted_max;
__u32 mptcpi_flags;
__u32 mptcpi_token;
__u64 mptcpi_write_seq;
__u64 mptcpi_snd_una;
__u64 mptcpi_rcv_nxt;
__u8 mptcpi_local_addr_used;
__u8 mptcpi_local_addr_max;
__u8 mptcpi_csum_enabled;
};
struct mptcp_subflow_data {
__u32 size_subflow_data; /* size of this structure in userspace */
__u32 num_subflows; /* must be 0, set by kernel */
__u32 size_kernel; /* must be 0, set by kernel */
__u32 size_user; /* size of one element in data[] */
} __attribute__((aligned(8)));
struct mptcp_subflow_addrs {
union {
__kernel_sa_family_t sa_family;
struct sockaddr sa_local;
struct sockaddr_in sin_local;
struct sockaddr_in6 sin6_local;
struct __kernel_sockaddr_storage ss_local;
};
union {
struct sockaddr sa_remote;
struct sockaddr_in sin_remote;
struct sockaddr_in6 sin6_remote;
struct __kernel_sockaddr_storage ss_remote;
};
};
#endif /* _LINUX_MPTCP_H */