| 1 | /* |
| 2 | * Copyright (c) 1982, 1986, 1993 |
| 3 | *	The Regents of the University of California. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 4. Neither the name of the University nor the names of its contributors |
| 14 | * may be used to endorse or promote products derived from this software |
| 15 | * without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | * |
| 29 | *	@(#)tcp.h	8.1 (Berkeley) 6/10/93 |
| 30 | */ |
| 31 | |
| 32 | #ifndef _NETINET_TCP_H |
| 33 | #define _NETINET_TCP_H	1 |
| 34 | |
| 35 | #include <features.h> |
| 36 | |
| 37 | /* |
| 38 | * User-settable options (used with setsockopt). |
| 39 | */ |
| 40 | #define	TCP_NODELAY		 1 /* Don't delay send to coalesce packets */ |
| 41 | #define	TCP_MAXSEG		 2 /* Set maximum segment size */ |
| 42 | #define TCP_CORK		 3 /* Control sending of partial frames */ |
| 43 | #define TCP_KEEPIDLE		 4 /* Start keeplives after this period */ |
| 44 | #define TCP_KEEPINTVL		 5 /* Interval between keepalives */ |
| 45 | #define TCP_KEEPCNT		 6 /* Number of keepalives before death */ |
| 46 | #define TCP_SYNCNT		 7 /* Number of SYN retransmits */ |
| 47 | #define TCP_LINGER2		 8 /* Life time of orphaned FIN-WAIT-2 state */ |
| 48 | #define TCP_DEFER_ACCEPT	 9 /* Wake up listener only when data arrive */ |
| 49 | #define TCP_WINDOW_CLAMP	 10 /* Bound advertised window */ |
| 50 | #define TCP_INFO		 11 /* Information about this connection. */ |
| 51 | #define	TCP_QUICKACK		 12 /* Bock/re-enable quick ACKs. */ |
| 52 | #define TCP_CONGESTION		 13 /* Congestion control algorithm. */ |
| 53 | #define TCP_MD5SIG		 14 /* TCP MD5 Signature (RFC2385) */ |
| 54 | #define TCP_COOKIE_TRANSACTIONS	 15 /* TCP Cookie Transactions */ |
| 55 | #define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/ |
| 56 | #define TCP_THIN_DUPACK		 17 /* Fast retrans. after 1 dupack */ |
| 57 | #define TCP_USER_TIMEOUT	 18 /* How long for loss retry before timeout */ |
| 58 | #define TCP_REPAIR		 19 /* TCP sock is under repair right now */ |
| 59 | #define TCP_REPAIR_QUEUE	 20 /* Set TCP queue to repair */ |
| 60 | #define TCP_QUEUE_SEQ		 21 /* Set sequence number of repaired queue. */ |
| 61 | #define TCP_REPAIR_OPTIONS	 22 /* Repair TCP connection options */ |
| 62 | #define TCP_FASTOPEN		 23 /* Enable FastOpen on listeners */ |
| 63 | #define TCP_TIMESTAMP		 24 /* TCP time stamp */ |
| 64 | #define TCP_NOTSENT_LOWAT	 25 /* Limit number of unsent bytes in |
| 65 | 				 write queue. */ |
| 66 | #define TCP_CC_INFO		 26 /* Get Congestion Control |
| 67 | 				 (optional) info. */ |
| 68 | #define TCP_SAVE_SYN		 27 /* Record SYN headers for new |
| 69 | 				 connections. */ |
| 70 | #define TCP_SAVED_SYN		 28 /* Get SYN headers recorded for |
| 71 | 				 connection. */ |
| 72 | #define TCP_REPAIR_WINDOW	 29 /* Get/set window parameters. */ |
| 73 | #define TCP_FASTOPEN_CONNECT	 30 /* Attempt FastOpen with connect. */ |
| 74 | #define TCP_ULP			 31 /* Attach a ULP to a TCP connection. */ |
| 75 | #define TCP_MD5SIG_EXT		 32 /* TCP MD5 Signature with extensions. */ |
| 76 | #define TCP_FASTOPEN_KEY	 33 /* Set the key for Fast Open (cookie). */ |
| 77 | #define TCP_FASTOPEN_NO_COOKIE	 34 /* Enable TFO without a TFO cookie. */ |
| 78 | #define TCP_ZEROCOPY_RECEIVE	 35 |
| 79 | #define TCP_INQ			 36 /* Notify bytes available to read |
| 80 | 				 as a cmsg on read. */ |
| 81 | #define TCP_CM_INQ		 TCP_INQ |
| 82 | #define TCP_TX_DELAY		 37 /* Delay outgoing packets by XX usec. */ |
| 83 | #define TCP_RTO_MAX_MS		 44 /* Max time to retransmit (msec). */ |
| 84 | #define TCP_RTO_MIN_US		 45 /* Min time to retransmit (usec). */ |
| 85 | #define TCP_DELACK_MAX_US	 46 /* Max delayed ack time (usec). */ |
| 86 | |
| 87 | #define TCP_REPAIR_ON		 1 |
| 88 | #define TCP_REPAIR_OFF		 0 |
| 89 | #define TCP_REPAIR_OFF_NO_WP	 -1 |
| 90 | |
| 91 | #ifdef __USE_MISC |
| 92 | # include <sys/types.h> |
| 93 | # include <sys/socket.h> |
| 94 | # include <stdint.h> |
| 95 | |
| 96 | typedef	uint32_t tcp_seq; |
| 97 | /* |
| 98 | * TCP header. |
| 99 | * Per RFC 793, September, 1981. |
| 100 | */ |
| 101 | struct tcphdr |
| 102 | { |
| 103 | __extension__ union |
| 104 | { |
| 105 | struct |
| 106 | { |
| 107 | 	uint16_t th_sport;	/* source port */ |
| 108 | 	uint16_t th_dport;	/* destination port */ |
| 109 | 	tcp_seq th_seq;		/* sequence number */ |
| 110 | 	tcp_seq th_ack;		/* acknowledgement number */ |
| 111 | # if __BYTE_ORDER == __LITTLE_ENDIAN |
| 112 | 	uint8_t th_x2:4;	/* (unused) */ |
| 113 | 	uint8_t th_off:4;	/* data offset */ |
| 114 | # endif |
| 115 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 116 | 	uint8_t th_off:4;	/* data offset */ |
| 117 | 	uint8_t th_x2:4;	/* (unused) */ |
| 118 | # endif |
| 119 | 	uint8_t th_flags; |
| 120 | # define TH_FIN	0x01 |
| 121 | # define TH_SYN	0x02 |
| 122 | # define TH_RST	0x04 |
| 123 | # define TH_PUSH	0x08 |
| 124 | # define TH_ACK	0x10 |
| 125 | # define TH_URG	0x20 |
| 126 | 	uint16_t th_win;	/* window */ |
| 127 | 	uint16_t th_sum;	/* checksum */ |
| 128 | 	uint16_t th_urp;	/* urgent pointer */ |
| 129 | }; |
| 130 | struct |
| 131 | { |
| 132 | 	uint16_t source; |
| 133 | 	uint16_t dest; |
| 134 | 	uint32_t seq; |
| 135 | 	uint32_t ack_seq; |
| 136 | # if __BYTE_ORDER == __LITTLE_ENDIAN |
| 137 | 	uint16_t res1:4; |
| 138 | 	uint16_t doff:4; |
| 139 | 	uint16_t fin:1; |
| 140 | 	uint16_t syn:1; |
| 141 | 	uint16_t rst:1; |
| 142 | 	uint16_t psh:1; |
| 143 | 	uint16_t ack:1; |
| 144 | 	uint16_t urg:1; |
| 145 | 	uint16_t res2:2; |
| 146 | # elif __BYTE_ORDER == __BIG_ENDIAN |
| 147 | 	uint16_t doff:4; |
| 148 | 	uint16_t res1:4; |
| 149 | 	uint16_t res2:2; |
| 150 | 	uint16_t urg:1; |
| 151 | 	uint16_t ack:1; |
| 152 | 	uint16_t psh:1; |
| 153 | 	uint16_t rst:1; |
| 154 | 	uint16_t syn:1; |
| 155 | 	uint16_t fin:1; |
| 156 | # else |
| 157 | # error "Adjust your <bits/endian.h> defines" |
| 158 | # endif |
| 159 | 	uint16_t window; |
| 160 | 	uint16_t check; |
| 161 | 	uint16_t urg_ptr; |
| 162 | }; |
| 163 | }; |
| 164 | }; |
| 165 | |
| 166 | enum |
| 167 | { |
| 168 | TCP_ESTABLISHED = 1, |
| 169 | TCP_SYN_SENT, |
| 170 | TCP_SYN_RECV, |
| 171 | TCP_FIN_WAIT1, |
| 172 | TCP_FIN_WAIT2, |
| 173 | TCP_TIME_WAIT, |
| 174 | TCP_CLOSE, |
| 175 | TCP_CLOSE_WAIT, |
| 176 | TCP_LAST_ACK, |
| 177 | TCP_LISTEN, |
| 178 | TCP_CLOSING /* now a valid state */ |
| 179 | }; |
| 180 | |
| 181 | # define TCPOPT_EOL		0 |
| 182 | # define TCPOPT_NOP		1 |
| 183 | # define TCPOPT_MAXSEG		2 |
| 184 | # define TCPOLEN_MAXSEG		4 |
| 185 | # define TCPOPT_WINDOW		3 |
| 186 | # define TCPOLEN_WINDOW		3 |
| 187 | # define TCPOPT_SACK_PERMITTED	4		/* Experimental */ |
| 188 | # define TCPOLEN_SACK_PERMITTED	2 |
| 189 | # define TCPOPT_SACK		5		/* Experimental */ |
| 190 | # define TCPOPT_TIMESTAMP	8 |
| 191 | # define TCPOLEN_TIMESTAMP	10 |
| 192 | # define TCPOLEN_TSTAMP_APPA	(TCPOLEN_TIMESTAMP+2) /* appendix A */ |
| 193 | |
| 194 | # define TCPOPT_TSTAMP_HDR	\ |
| 195 | (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) |
| 196 | |
| 197 | /* |
| 198 | * Default maximum segment size for TCP. |
| 199 | * With an IP MSS of 576, this is 536, |
| 200 | * but 512 is probably more convenient. |
| 201 | * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). |
| 202 | */ |
| 203 | # define TCP_MSS	512 |
| 204 | |
| 205 | # define TCP_MAXWIN	65535	/* largest value for (unscaled) window */ |
| 206 | |
| 207 | # define TCP_MAX_WINSHIFT	14	/* maximum window shift */ |
| 208 | |
| 209 | # define SOL_TCP		6	/* TCP level */ |
| 210 | |
| 211 | |
| 212 | # define TCPI_OPT_TIMESTAMPS	1 |
| 213 | # define TCPI_OPT_SACK		2 |
| 214 | # define TCPI_OPT_WSCALE	4 |
| 215 | # define TCPI_OPT_ECN		8 /* ECN was negotiated at TCP session init */ |
| 216 | # define TCPI_OPT_ECN_SEEN	16 /* we received at least one packet with ECT */ |
| 217 | # define TCPI_OPT_SYN_DATA	32 /* SYN-ACK acked data in SYN sent or rcvd */ |
| 218 | # define TCPI_OPT_USEC_TS	64 /* usec timestamps */ |
| 219 | # define TCPI_OPT_TFO_CHILD	128 /* child from a Fast Open option on SYN */ |
| 220 | |
| 221 | |
| 222 | /* Values for tcpi_state. */ |
| 223 | enum tcp_ca_state |
| 224 | { |
| 225 | TCP_CA_Open = 0, |
| 226 | TCP_CA_Disorder = 1, |
| 227 | TCP_CA_CWR = 2, |
| 228 | TCP_CA_Recovery = 3, |
| 229 | TCP_CA_Loss = 4 |
| 230 | }; |
| 231 | |
| 232 | /* Values for tcpi_ecn_mode after negotiation. */ |
| 233 | #define TCPI_ECN_MODE_DISABLED	0x0 |
| 234 | #define TCPI_ECN_MODE_RFC3168	0x1 |
| 235 | #define TCPI_ECN_MODE_ACCECN	0x2 |
| 236 | #define TCPI_ECN_MODE_PENDING	0x3 |
| 237 | |
| 238 | /* Values for tcpi_accecn_opt_seen. */ |
| 239 | #define TCP_ACCECN_OPT_NOT_SEEN		0x0 |
| 240 | #define TCP_ACCECN_OPT_EMPTY_SEEN	0x1 |
| 241 | #define TCP_ACCECN_OPT_COUNTER_SEEN	0x2 |
| 242 | #define TCP_ACCECN_OPT_FAIL_SEEN	0x3 |
| 243 | |
| 244 | /* Values for tcpi_accecn_fail_mode. */ |
| 245 | #define TCP_ACCECN_ACE_FAIL_SEND	0x1 |
| 246 | #define TCP_ACCECN_ACE_FAIL_RECV	0x2 |
| 247 | #define TCP_ACCECN_OPT_FAIL_SEND	0x4 |
| 248 | #define TCP_ACCECN_OPT_FAIL_RECV	0x8 |
| 249 | |
| 250 | struct tcp_info |
| 251 | { |
| 252 | uint8_t	tcpi_state; |
| 253 | uint8_t	tcpi_ca_state; |
| 254 | uint8_t	tcpi_retransmits; |
| 255 | uint8_t	tcpi_probes; |
| 256 | uint8_t	tcpi_backoff; |
| 257 | uint8_t	tcpi_options; |
| 258 | uint8_t	tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; |
| 259 | |
| 260 | uint32_t	tcpi_rto; |
| 261 | uint32_t	tcpi_ato; |
| 262 | uint32_t	tcpi_snd_mss; |
| 263 | uint32_t	tcpi_rcv_mss; |
| 264 | |
| 265 | uint32_t	tcpi_unacked; |
| 266 | uint32_t	tcpi_sacked; |
| 267 | uint32_t	tcpi_lost; |
| 268 | uint32_t	tcpi_retrans; |
| 269 | uint32_t	tcpi_fackets; |
| 270 | |
| 271 | /* Times. */ |
| 272 | uint32_t	tcpi_last_data_sent; |
| 273 | uint32_t	tcpi_last_ack_sent;	/* Not remembered, sorry. */ |
| 274 | uint32_t	tcpi_last_data_recv; |
| 275 | uint32_t	tcpi_last_ack_recv; |
| 276 | |
| 277 | /* Metrics. */ |
| 278 | uint32_t	tcpi_pmtu; |
| 279 | uint32_t	tcpi_rcv_ssthresh; |
| 280 | uint32_t	tcpi_rtt; |
| 281 | uint32_t	tcpi_rttvar; |
| 282 | uint32_t	tcpi_snd_ssthresh; |
| 283 | uint32_t	tcpi_snd_cwnd; |
| 284 | uint32_t	tcpi_advmss; |
| 285 | uint32_t	tcpi_reordering; |
| 286 | |
| 287 | uint32_t	tcpi_rcv_rtt; |
| 288 | uint32_t	tcpi_rcv_space; |
| 289 | |
| 290 | uint32_t	tcpi_total_retrans; |
| 291 | |
| 292 | uint64_t	tcpi_pacing_rate; |
| 293 | uint64_t	tcpi_max_pacing_rate; |
| 294 | uint64_t	tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */ |
| 295 | uint64_t	tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */ |
| 296 | uint32_t	tcpi_segs_out; /* RFC4898 tcpEStatsPerfSegsOut */ |
| 297 | uint32_t	tcpi_segs_in; /* RFC4898 tcpEStatsPerfSegsIn */ |
| 298 | |
| 299 | uint32_t	tcpi_notsent_bytes; |
| 300 | uint32_t	tcpi_min_rtt; |
| 301 | uint32_t	tcpi_data_segs_in; /* RFC4898 tcpEStatsDataSegsIn */ |
| 302 | uint32_t	tcpi_data_segs_out; /* RFC4898 tcpEStatsDataSegsOut */ |
| 303 | |
| 304 | uint64_t	tcpi_delivery_rate; |
| 305 | |
| 306 | uint64_t	tcpi_busy_time; /* Time (usec) busy sending data */ |
| 307 | uint64_t	tcpi_rwnd_limited; /* Time (usec) limited by receive window */ |
| 308 | uint64_t	tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */ |
| 309 | |
| 310 | uint32_t	tcpi_delivered; |
| 311 | uint32_t	tcpi_delivered_ce; |
| 312 | |
| 313 | uint64_t	tcpi_bytes_sent; /* RFC4898 tcpEStatsPerfHCDataOctetsOut */ |
| 314 | uint64_t	tcpi_bytes_retrans; /* RFC4898 tcpEStatsPerfOctetsRetrans */ |
| 315 | uint32_t	tcpi_dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups */ |
| 316 | uint32_t	tcpi_reord_seen; /* reordering events seen */ |
| 317 | |
| 318 | |
| 319 | uint32_t	tcpi_rcv_ooopack; /* Out-of-order packets received */ |
| 320 | /* Peer's advertised receive window after scaling (bytes) */ |
| 321 | uint32_t	tcpi_snd_wnd; |
| 322 | /* Local advertised receive window after scaling (bytes) */ |
| 323 | uint32_t	tcpi_rcv_wnd; |
| 324 | |
| 325 | uint32_t	tcpi_rehash; /* PLB or timeout triggered rehash attempts */ |
| 326 | /* Total number of RTO timeouts, including |
| 327 | * SYN/SYN-ACK and recurring timeouts |
| 328 | */ |
| 329 | uint16_t	tcpi_total_rto; |
| 330 | /* Total number of RTO recoveries, including any unfinished recovery. */ |
| 331 | uint16_t	tcpi_total_rto_recoveries; |
| 332 | /* Total time spent in RTO recoveries in milliseconds, including any |
| 333 | * unfinished recovery. |
| 334 | */ |
| 335 | uint32_t	tcpi_total_rto_time; |
| 336 | uint32_t	tcpi_received_ce; /* # of CE marks received */ |
| 337 | uint32_t	tcpi_delivered_e1_bytes; /* Accurate ECN byte counters */ |
| 338 | uint32_t	tcpi_delivered_e0_bytes; |
| 339 | uint32_t	tcpi_delivered_ce_bytes; |
| 340 | uint32_t	tcpi_received_e1_bytes; |
| 341 | uint32_t	tcpi_received_e0_bytes; |
| 342 | uint32_t	tcpi_received_ce_bytes; |
| 343 | uint32_t	tcpi_ecn_mode:2, |
| 344 | 		tcpi_accecn_opt_seen:2, |
| 345 | 		tcpi_accecn_fail_mode:4, |
| 346 | 		tcpi_options2:24; |
| 347 | }; |
| 348 | |
| 349 | /* Netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */ |
| 350 | enum { |
| 351 | TCP_NLA_PAD, |
| 352 | TCP_NLA_BUSY, /* Time (usec) busy sending data */ |
| 353 | TCP_NLA_RWND_LIMITED, /* Time (usec) limited by receive window */ |
| 354 | TCP_NLA_SNDBUF_LIMITED, /* Time (usec) limited by send buffer */ |
| 355 | TCP_NLA_DATA_SEGS_OUT, /* Data pkts sent including retransmission */ |
| 356 | TCP_NLA_TOTAL_RETRANS, /* Data pkts retransmitted */ |
| 357 | TCP_NLA_PACING_RATE, /* Pacing rate in bytes per second */ |
| 358 | TCP_NLA_DELIVERY_RATE, /* Delivery rate in bytes per second */ |
| 359 | TCP_NLA_SND_CWND, /* Sending congestion window */ |
| 360 | TCP_NLA_REORDERING, /* Reordering metric */ |
| 361 | TCP_NLA_MIN_RTT, /* minimum RTT */ |
| 362 | TCP_NLA_RECUR_RETRANS, /* Recurring retransmits for the current pkt */ |
| 363 | TCP_NLA_DELIVERY_RATE_APP_LMT, /* delivery rate application limited ? */ |
| 364 | TCP_NLA_SNDQ_SIZE, /* Data (bytes) pending in send queue */ |
| 365 | TCP_NLA_CA_STATE, /* ca_state of socket */ |
| 366 | TCP_NLA_SND_SSTHRESH, /* Slow start size threshold */ |
| 367 | TCP_NLA_DELIVERED, /* Data pkts delivered incl. out-of-order */ |
| 368 | TCP_NLA_DELIVERED_CE, /* Like above but only ones w/ CE marks */ |
| 369 | TCP_NLA_BYTES_SENT, /* Data bytes sent including retransmission */ |
| 370 | TCP_NLA_BYTES_RETRANS, /* Data bytes retransmitted */ |
| 371 | TCP_NLA_DSACK_DUPS, /* DSACK blocks received */ |
| 372 | TCP_NLA_REORD_SEEN, /* reordering events seen */ |
| 373 | TCP_NLA_SRTT, /* smoothed RTT in usecs */ |
| 374 | TCP_NLA_TIMEOUT_REHASH, /* Timeout-triggered rehash attempts */ |
| 375 | TCP_NLA_BYTES_NOTSENT, /* Bytes in write queue not yet sent */ |
| 376 | TCP_NLA_EDT, /* Earliest departure time (CLOCK_MONOTONIC) */ |
| 377 | TCP_NLA_TTL, /* TTL or hop limit of a packet received */ |
| 378 | TCP_NLA_REHASH, /* PLB and timeout triggered rehash attempts */ |
| 379 | }; |
| 380 | |
| 381 | /* For TCP_MD5SIG socket option. */ |
| 382 | #define TCP_MD5SIG_MAXKEYLEN	80 |
| 383 | |
| 384 | /* tcp_md5sig extension flags for TCP_MD5SIG_EXT. */ |
| 385 | #define TCP_MD5SIG_FLAG_PREFIX	1 /* Address prefix length. */ |
| 386 | #define TCP_MD5SIG_FLAG_IFINDEX	2 /* Ifindex set. */ |
| 387 | |
| 388 | struct tcp_md5sig |
| 389 | { |
| 390 | struct sockaddr_storage tcpm_addr;		/* Address associated. */ |
| 391 | uint8_t	tcpm_flags;			/* Extension flags. */ |
| 392 | uint8_t	tcpm_prefixlen;			/* Address prefix. */ |
| 393 | uint16_t	tcpm_keylen;			/* Key length. */ |
| 394 | int		tcpm_ifindex;			/* Device index for scope. */ |
| 395 | uint8_t	tcpm_key[TCP_MD5SIG_MAXKEYLEN];	/* Key (binary). */ |
| 396 | }; |
| 397 | |
| 398 | /* INET_DIAG_MD5SIG */ |
| 399 | struct tcp_diag_md5sig { |
| 400 | uint8_t tcpm_family; |
| 401 | uint8_t tcpm_prefixlen; |
| 402 | uint16_t tcpm_keylen; |
| 403 | uint32_t tcpm_addr[4]; |
| 404 | uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; |
| 405 | }; |
| 406 | |
| 407 | #define TCP_AO_MAXKEYLEN 80 |
| 408 | |
| 409 | #define TCP_AO_KEYF_IFINDEX (1 << 0) /* L3 ifindex for VRF */ |
| 410 | #define TCP_AO_KEYF_EXCLUDE_OPT (1 << 1) /* Indicates whether TCP options |
| 411 | * other than TCP-AO are included |
| 412 | * in the MAC calculation |
| 413 | */ |
| 414 | |
| 415 | struct tcp_ao_add { /* setsockopt(TCP_AO_ADD_KEY) */ |
| 416 | struct sockaddr_storage addr; /* Peer's address for the key */ |
| 417 | int8_t alg_name[64]; /* Crypto hash algorithm to use */ |
| 418 | int32_t ifindex; /* L3 dev index for VRF */ |
| 419 | uint32_t set_current :1, /* Set key as Current_key at once */ |
| 420 | set_rnext :1, /* Request it from peer with RNext_key */ |
| 421 | reserved :30; /* Must be 0 */ |
| 422 | uint16_t reserved2; /* Padding, must be 0 */ |
| 423 | uint8_t prefix; /* Peer's address prefix */ |
| 424 | uint8_t sndid; /* SendID for outgoing segments */ |
| 425 | uint8_t rcvid; /* RecvID to match for incoming seg */ |
| 426 | uint8_t maclen; /* length of authentication code (hash) */ |
| 427 | uint8_t keyflags; /* See TCP_AO_KEYF_ */ |
| 428 | uint8_t keylen; /* Length of ::key */ |
| 429 | uint8_t key[TCP_AO_MAXKEYLEN]; |
| 430 | } __attribute__((aligned(8))); |
| 431 | |
| 432 | struct tcp_ao_del { /* setsockopt(TCP_AO_DEL_KEY) */ |
| 433 | struct sockaddr_storage addr; /* Peer's address for the key */ |
| 434 | int32_t ifindex; /* L3 dev index for VRF */ |
| 435 | uint32_t set_current :1, /* Corresponding ::current_key */ |
| 436 | set_rnext :1, /* Corresponding ::rnext */ |
| 437 | del_async :1, /* Only valid for listen sockets */ |
| 438 | reserved :29; /* Must be 0 */ |
| 439 | uint16_t reserved2; /* Padding, must be 0 */ |
| 440 | uint8_t prefix; /* Peer's address prefix */ |
| 441 | uint8_t sndid; /* SendID for outgoing segments */ |
| 442 | uint8_t rcvid; /* RecvID to match for incoming seg */ |
| 443 | uint8_t current_key; /* KeyID to set as Current_key */ |
| 444 | uint8_t rnext; /* KeyID to set as Rnext_key */ |
| 445 | uint8_t keyflags; /* See TCP_AO_KEYF_ */ |
| 446 | } __attribute__((aligned(8))); |
| 447 | |
| 448 | struct tcp_ao_info_opt { /* setsockopt(TCP_AO_INFO), getsockopt(TCP_AO_INFO) |
| 449 | */ |
| 450 | /* Here 'in' is for setsockopt(), 'out' is for getsockopt() */ |
| 451 | uint32_t set_current :1, /* In/out: corresponding ::current_key */ |
| 452 | set_rnext :1, /* In/out: corresponding ::rnext */ |
| 453 | ao_required :1, /* In/out: don't accept non-AO connects */ |
| 454 | set_counters :1, /* In: set/clear ::pkt_* counters */ |
| 455 | accept_icmps :1, /* In/out: accept incoming ICMPs */ |
| 456 | reserved :27; /* must be 0 */ |
| 457 | uint16_t reserved2; /* Padding, must be 0 */ |
| 458 | uint8_t current_key; /* In/out: KeyID of Current_key */ |
| 459 | uint8_t rnext; /* In/out: keyid of RNext_key */ |
| 460 | uint64_t pkt_good; /* In/out: verified segments */ |
| 461 | uint64_t pkt_bad; /* In/out: failed verification */ |
| 462 | uint64_t pkt_key_not_found; /* In/out: could not find a key to verify */ |
| 463 | uint64_t pkt_ao_required; /* In/out: segments missing TCP-AO sign */ |
| 464 | uint64_t pkt_dropped_icmp; /* In/out: ICMPs that were ignored */ |
| 465 | } __attribute__((aligned(8))); |
| 466 | |
| 467 | struct tcp_ao_getsockopt { /* getsockopt(TCP_AO_GET_KEYS) */ |
| 468 | struct sockaddr_storage addr; /* In/out: dump keys for peer |
| 469 | * with this address/prefix |
| 470 | */ |
| 471 | uint8_t alg_name[64]; /* out: crypto hash algorithm */ |
| 472 | uint8_t key[TCP_AO_MAXKEYLEN]; |
| 473 | uint32_t nkeys; /* In: size of the userspace buffer |
| 474 | * @optval, measured in @optlen - the |
| 475 | * sizeof(struct tcp_ao_getsockopt) |
| 476 | * Out: number of keys that matched |
| 477 | */ |
| 478 | uint16_t is_current :1, /* In: match and dump Current_key, |
| 479 | * Out: the dumped key is Current_key |
| 480 | */ |
| 481 | is_rnext :1, /* In: match and dump RNext_key, |
| 482 | * Out: the dumped key is RNext_key |
| 483 | */ |
| 484 | get_all :1, /* In: dump all keys */ |
| 485 | reserved :13; /* Padding, must be 0 */ |
| 486 | uint8_t sndid; /* In/out: dump keys with SendID */ |
| 487 | uint8_t rcvid; /* In/out: dump keys with RecvID */ |
| 488 | uint8_t prefix; /* In/out: dump keys with address/prefix */ |
| 489 | uint8_t maclen; /* Out: key's length of authentication |
| 490 | * code (hash) |
| 491 | */ |
| 492 | uint8_t keyflags; /* In/out: see TCP_AO_KEYF_ */ |
| 493 | uint8_t keylen; /* Out: length of ::key */ |
| 494 | int32_t ifindex; /* In/out: L3 dev index for VRF */ |
| 495 | uint64_t pkt_good; /* Out: verified segments */ |
| 496 | uint64_t pkt_bad; /* Out: segments that failed verification */ |
| 497 | } __attribute__((aligned(8))); |
| 498 | |
| 499 | struct tcp_ao_repair { /* {s,g}etsockopt(TCP_AO_REPAIR) */ |
| 500 | uint32_t snt_isn; |
| 501 | uint32_t rcv_isn; |
| 502 | uint32_t snd_sne; |
| 503 | uint32_t rcv_sne; |
| 504 | } __attribute__((aligned(8))); |
| 505 | |
| 506 | /* For socket repair options. */ |
| 507 | struct tcp_repair_opt |
| 508 | { |
| 509 | uint32_t	opt_code; |
| 510 | uint32_t	opt_val; |
| 511 | }; |
| 512 | |
| 513 | /* Queue to repair, for TCP_REPAIR_QUEUE. */ |
| 514 | enum |
| 515 | { |
| 516 | TCP_NO_QUEUE, |
| 517 | TCP_RECV_QUEUE, |
| 518 | TCP_SEND_QUEUE, |
| 519 | TCP_QUEUES_NR, |
| 520 | }; |
| 521 | |
| 522 | /* For cookie transactions socket options. */ |
| 523 | #define TCP_COOKIE_MIN		8		/* 64-bits */ |
| 524 | #define TCP_COOKIE_MAX		16		/* 128-bits */ |
| 525 | #define TCP_COOKIE_PAIR_SIZE	(2*TCP_COOKIE_MAX) |
| 526 | |
| 527 | /* Flags for both getsockopt and setsockopt */ |
| 528 | #define TCP_COOKIE_IN_ALWAYS	(1 << 0)	/* Discard SYN without cookie */ |
| 529 | #define TCP_COOKIE_OUT_NEVER	(1 << 1)	/* Prohibit outgoing cookies, |
| 530 | 						 * supersedes everything. */ |
| 531 | |
| 532 | /* Flags for getsockopt */ |
| 533 | #define TCP_S_DATA_IN		(1 << 2)	/* Was data received? */ |
| 534 | #define TCP_S_DATA_OUT		(1 << 3)	/* Was data sent? */ |
| 535 | |
| 536 | #define TCP_MSS_DEFAULT		 536U	/* IPv4 (RFC1122, RFC2581) */ |
| 537 | #define TCP_MSS_DESIRED		1220U	/* IPv6 (tunneled), EDNS0 (RFC3226) */ |
| 538 | |
| 539 | struct tcp_cookie_transactions |
| 540 | { |
| 541 | uint16_t	tcpct_flags; |
| 542 | uint8_t	__tcpct_pad1; |
| 543 | uint8_t	tcpct_cookie_desired; |
| 544 | uint16_t	tcpct_s_data_desired; |
| 545 | uint16_t	tcpct_used; |
| 546 | uint8_t	tcpct_value[TCP_MSS_DEFAULT]; |
| 547 | }; |
| 548 | |
| 549 | /* For use with TCP_REPAIR_WINDOW. */ |
| 550 | struct tcp_repair_window |
| 551 | { |
| 552 | uint32_t snd_wl1; |
| 553 | uint32_t snd_wnd; |
| 554 | uint32_t max_window; |
| 555 | uint32_t rcv_wnd; |
| 556 | uint32_t rcv_wup; |
| 557 | }; |
| 558 | |
| 559 | /* For use with TCP_ZEROCOPY_RECEIVE. */ |
| 560 | struct tcp_zerocopy_receive |
| 561 | { |
| 562 | uint64_t address; /* In: address of mapping. */ |
| 563 | uint32_t length; /* In/out: number of bytes to map/mapped. */ |
| 564 | uint32_t recv_skip_hint; /* Out: amount of bytes to skip. */ |
| 565 | uint32_t inq; /* Out: amount of bytes in read queue. */ |
| 566 | int32_t err; /* Out: socket error. */ |
| 567 | uint64_t copybuf_address; /* On: copybuf address (small reads). */ |
| 568 | int32_t copybuf_len; /* In/Out: copybuf bytes avail/used or error. */ |
| 569 | uint32_t flags; /* In: flags. */ |
| 570 | uint64_t msg_control; /* Ancillary data. */ |
| 571 | uint64_t msg_controllen; |
| 572 | uint32_t msg_flags; |
| 573 | uint32_t reserved; /* Set to 0 for now. */ |
| 574 | }; |
| 575 | |
| 576 | #endif /* Misc. */ |
| 577 | |
| 578 | #endif /* netinet/tcp.h */ |