17c478bd9Sstevel@tonic-gate /* 2707e74bcSKacheong Poon * CDDL HEADER START 3707e74bcSKacheong Poon * 4707e74bcSKacheong Poon * The contents of this file are subject to the terms of the 5707e74bcSKacheong Poon * Common Development and Distribution License (the "License"). 6707e74bcSKacheong Poon * You may not use this file except in compliance with the License. 7707e74bcSKacheong Poon * 8707e74bcSKacheong Poon * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9707e74bcSKacheong Poon * or http://www.opensolaris.org/os/licensing. 10707e74bcSKacheong Poon * See the License for the specific language governing permissions 11707e74bcSKacheong Poon * and limitations under the License. 12707e74bcSKacheong Poon * 13707e74bcSKacheong Poon * When distributing Covered Code, include this CDDL HEADER in each 14707e74bcSKacheong Poon * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15707e74bcSKacheong Poon * If applicable, add the following below this CDDL HEADER, with the 16707e74bcSKacheong Poon * fields enclosed by brackets "[]" replaced with your own identifying 17707e74bcSKacheong Poon * information: Portions Copyright [yyyy] [name of copyright owner] 18707e74bcSKacheong Poon * 19707e74bcSKacheong Poon * CDDL HEADER END 20707e74bcSKacheong Poon */ 21707e74bcSKacheong Poon 22707e74bcSKacheong Poon /* 23707e74bcSKacheong Poon * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. 243d0a255cSGarrett D'Amore * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. 25*861fa149SNils Nieuwejaar * Copyright 2022 Oxide Computer Company 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California. 307c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 317c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _NETINET_TCP_H 357c478bd9Sstevel@tonic-gate #define _NETINET_TCP_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86 */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 417c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate typedef uint32_t tcp_seq; 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * TCP header. 507c478bd9Sstevel@tonic-gate * Per RFC 793, September, 1981. 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate struct tcphdr { 537c478bd9Sstevel@tonic-gate uint16_t th_sport; /* source port */ 547c478bd9Sstevel@tonic-gate uint16_t th_dport; /* destination port */ 557c478bd9Sstevel@tonic-gate tcp_seq th_seq; /* sequence number */ 567c478bd9Sstevel@tonic-gate tcp_seq th_ack; /* acknowledgement number */ 577c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH 587c478bd9Sstevel@tonic-gate uint_t th_x2:4, /* (unused) */ 597c478bd9Sstevel@tonic-gate th_off:4; /* data offset */ 607c478bd9Sstevel@tonic-gate #else 617c478bd9Sstevel@tonic-gate uint_t th_off:4, /* data offset */ 627c478bd9Sstevel@tonic-gate th_x2:4; /* (unused) */ 637c478bd9Sstevel@tonic-gate #endif 647c478bd9Sstevel@tonic-gate uchar_t th_flags; 657c478bd9Sstevel@tonic-gate #define TH_FIN 0x01 667c478bd9Sstevel@tonic-gate #define TH_SYN 0x02 677c478bd9Sstevel@tonic-gate #define TH_RST 0x04 687c478bd9Sstevel@tonic-gate #define TH_PUSH 0x08 697c478bd9Sstevel@tonic-gate #define TH_ACK 0x10 707c478bd9Sstevel@tonic-gate #define TH_URG 0x20 717c478bd9Sstevel@tonic-gate #define TH_ECE 0x40 727c478bd9Sstevel@tonic-gate #define TH_CWR 0x80 737c478bd9Sstevel@tonic-gate uint16_t th_win; /* window */ 747c478bd9Sstevel@tonic-gate uint16_t th_sum; /* checksum */ 757c478bd9Sstevel@tonic-gate uint16_t th_urp; /* urgent pointer */ 767c478bd9Sstevel@tonic-gate }; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #define TCPOPT_EOL 0 797c478bd9Sstevel@tonic-gate #define TCPOPT_NOP 1 807c478bd9Sstevel@tonic-gate #define TCPOPT_MAXSEG 2 817c478bd9Sstevel@tonic-gate #define TCPOPT_WSCALE 3 827c478bd9Sstevel@tonic-gate #define TCPOPT_SACK_PERMITTED 4 837c478bd9Sstevel@tonic-gate #define TCPOPT_SACK 5 847c478bd9Sstevel@tonic-gate #define TCPOPT_TSTAMP 8 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * Default maximum segment size for TCP. 887c478bd9Sstevel@tonic-gate * With an IP MTU of 576, this is 536. 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate #define TCP_MSS 536 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Options for use with [gs]etsockopt at the TCP level. 947c478bd9Sstevel@tonic-gate * 957c478bd9Sstevel@tonic-gate * Note: Some of the TCP_ namespace has conflict with and 967c478bd9Sstevel@tonic-gate * and is exposed through <xti.h>. (It also requires exposing 977c478bd9Sstevel@tonic-gate * options not implemented). The options with potential 987c478bd9Sstevel@tonic-gate * for conflicts use #ifndef guards. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate #ifndef TCP_NODELAY 1017c478bd9Sstevel@tonic-gate #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 1027c478bd9Sstevel@tonic-gate #endif 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate #ifndef TCP_MAXSEG 1057c478bd9Sstevel@tonic-gate #define TCP_MAXSEG 0x02 /* set maximum segment size */ 1067c478bd9Sstevel@tonic-gate #endif 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #ifndef TCP_KEEPALIVE 1097c478bd9Sstevel@tonic-gate #define TCP_KEEPALIVE 0x8 /* set keepalive timer */ 1107c478bd9Sstevel@tonic-gate #endif 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define TCP_NOTIFY_THRESHOLD 0x10 1147c478bd9Sstevel@tonic-gate #define TCP_ABORT_THRESHOLD 0x11 1157c478bd9Sstevel@tonic-gate #define TCP_CONN_NOTIFY_THRESHOLD 0x12 1167c478bd9Sstevel@tonic-gate #define TCP_CONN_ABORT_THRESHOLD 0x13 1177c478bd9Sstevel@tonic-gate #define TCP_RECVDSTADDR 0x14 1187c478bd9Sstevel@tonic-gate #define TCP_INIT_CWND 0x15 1197c478bd9Sstevel@tonic-gate #define TCP_KEEPALIVE_THRESHOLD 0x16 1207c478bd9Sstevel@tonic-gate #define TCP_KEEPALIVE_ABORT_THRESHOLD 0x17 1217c478bd9Sstevel@tonic-gate #define TCP_CORK 0x18 122707e74bcSKacheong Poon #define TCP_RTO_INITIAL 0x19 123707e74bcSKacheong Poon #define TCP_RTO_MIN 0x1A 124707e74bcSKacheong Poon #define TCP_RTO_MAX 0x1B 125707e74bcSKacheong Poon #define TCP_LINGER2 0x1C 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* gap for expansion of ``standard'' options */ 1287c478bd9Sstevel@tonic-gate #define TCP_ANONPRIVBIND 0x20 /* for internal use only */ 1297c478bd9Sstevel@tonic-gate #define TCP_EXCLBIND 0x21 /* for internal use only */ 1303d0a255cSGarrett D'Amore #define TCP_KEEPIDLE 0x22 1313d0a255cSGarrett D'Amore #define TCP_KEEPCNT 0x23 1323d0a255cSGarrett D'Amore #define TCP_KEEPINTVL 0x24 133d4994511SCody Peter Mello #define TCP_CONGESTION 0x25 134*861fa149SNils Nieuwejaar #define TCP_QUICKACK 0x26 /* enable/disable quick acks */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate #endif 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #endif /* _NETINET_TCP_H */ 141