mptcp.h (3870B) - Raw
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 #ifndef _MPTCP_H 3 #define _MPTCP_H 4 5 #include <netinet/in.h> /* for sockaddr_in and sockaddr_in6 */ 6 #include <sys/socket.h> /* for struct sockaddr */ 7 8 #include <linux/const.h> 9 #include <linux/types.h> 10 #include <linux/in.h> /* for sockaddr_in */ 11 #include <linux/in6.h> /* for sockaddr_in6 */ 12 #include <linux/socket.h> /* for sockaddr_storage and sa_family */ 13 14 #define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0) 15 #define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1) 16 #define MPTCP_SUBFLOW_FLAG_JOIN_REM _BITUL(2) 17 #define MPTCP_SUBFLOW_FLAG_JOIN_LOC _BITUL(3) 18 #define MPTCP_SUBFLOW_FLAG_BKUP_REM _BITUL(4) 19 #define MPTCP_SUBFLOW_FLAG_BKUP_LOC _BITUL(5) 20 #define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED _BITUL(6) 21 #define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7) 22 #define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8) 23 24 #define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds" 25 #define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events" 26 27 #include <linux/mptcp_pm.h> 28 29 #define MPTCP_INFO_FLAG_FALLBACK _BITUL(0) 30 #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) 31 32 #define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) 33 #define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) 34 #define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) 35 #define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) 36 #define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) 37 38 struct mptcp_info { 39 __u8 mptcpi_subflows; 40 __u8 mptcpi_add_addr_signal; 41 __u8 mptcpi_add_addr_accepted; 42 __u8 mptcpi_subflows_max; 43 __u8 mptcpi_add_addr_signal_max; 44 __u8 mptcpi_add_addr_accepted_max; 45 __u32 mptcpi_flags; 46 __u32 mptcpi_token; 47 __u64 mptcpi_write_seq; 48 __u64 mptcpi_snd_una; 49 __u64 mptcpi_rcv_nxt; 50 __u8 mptcpi_local_addr_used; 51 __u8 mptcpi_local_addr_max; 52 __u8 mptcpi_csum_enabled; 53 __u32 mptcpi_retransmits; 54 __u64 mptcpi_bytes_retrans; 55 __u64 mptcpi_bytes_sent; 56 __u64 mptcpi_bytes_received; 57 __u64 mptcpi_bytes_acked; 58 __u8 mptcpi_subflows_total; 59 __u8 reserved[3]; 60 __u32 mptcpi_last_data_sent; 61 __u32 mptcpi_last_data_recv; 62 __u32 mptcpi_last_ack_recv; 63 }; 64 65 /* MPTCP Reset reason codes, rfc8684 */ 66 #define MPTCP_RST_EUNSPEC 0 67 #define MPTCP_RST_EMPTCP 1 68 #define MPTCP_RST_ERESOURCE 2 69 #define MPTCP_RST_EPROHIBIT 3 70 #define MPTCP_RST_EWQ2BIG 4 71 #define MPTCP_RST_EBADPERF 5 72 #define MPTCP_RST_EMIDDLEBOX 6 73 74 struct mptcp_subflow_data { 75 __u32 size_subflow_data; /* size of this structure in userspace */ 76 __u32 num_subflows; /* must be 0, set by kernel */ 77 __u32 size_kernel; /* must be 0, set by kernel */ 78 __u32 size_user; /* size of one element in data[] */ 79 } __attribute__((aligned(8))); 80 81 struct mptcp_subflow_addrs { 82 union { 83 __kernel_sa_family_t sa_family; 84 struct sockaddr sa_local; 85 struct sockaddr_in sin_local; 86 struct sockaddr_in6 sin6_local; 87 struct __kernel_sockaddr_storage ss_local; 88 }; 89 union { 90 struct sockaddr sa_remote; 91 struct sockaddr_in sin_remote; 92 struct sockaddr_in6 sin6_remote; 93 struct __kernel_sockaddr_storage ss_remote; 94 }; 95 }; 96 97 struct mptcp_subflow_info { 98 __u32 id; 99 struct mptcp_subflow_addrs addrs; 100 }; 101 102 struct mptcp_full_info { 103 __u32 size_tcpinfo_kernel; /* must be 0, set by kernel */ 104 __u32 size_tcpinfo_user; 105 __u32 size_sfinfo_kernel; /* must be 0, set by kernel */ 106 __u32 size_sfinfo_user; 107 __u32 num_subflows; /* must be 0, set by kernel (real subflow count) */ 108 __u32 size_arrays_user; /* max subflows that userspace is interested in; 109 * the buffers at subflow_info/tcp_info 110 * are respectively at least: 111 * size_arrays * size_sfinfo_user 112 * size_arrays * size_tcpinfo_user 113 * bytes wide 114 */ 115 __aligned_u64 subflow_info; 116 __aligned_u64 tcp_info; 117 struct mptcp_info mptcp_info; 118 }; 119 120 /* MPTCP socket options */ 121 #define MPTCP_INFO 1 122 #define MPTCP_TCPINFO 2 123 #define MPTCP_SUBFLOW_ADDRS 3 124 #define MPTCP_FULL_INFO 4 125 126 #endif /* _MPTCP_H */