10f74e101Schristos /* 20f74e101Schristos * Copyright (c) 1982, 1986, 1993 30f74e101Schristos * The Regents of the University of California. All rights reserved. 40f74e101Schristos * 50f74e101Schristos * Redistribution and use in source and binary forms, with or without 60f74e101Schristos * modification, are permitted provided that the following conditions 70f74e101Schristos * are met: 80f74e101Schristos * 1. Redistributions of source code must retain the above copyright 90f74e101Schristos * notice, this list of conditions and the following disclaimer. 100f74e101Schristos * 2. Redistributions in binary form must reproduce the above copyright 110f74e101Schristos * notice, this list of conditions and the following disclaimer in the 120f74e101Schristos * documentation and/or other materials provided with the distribution. 1311b3aaa1Schristos * 3. Neither the name of the University nor the names of its contributors 140f74e101Schristos * may be used to endorse or promote products derived from this software 150f74e101Schristos * without specific prior written permission. 160f74e101Schristos * 170f74e101Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 180f74e101Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 190f74e101Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 200f74e101Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 210f74e101Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 220f74e101Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 230f74e101Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 240f74e101Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 250f74e101Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 260f74e101Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 270f74e101Schristos * SUCH DAMAGE. 280f74e101Schristos * 290f74e101Schristos * @(#)tcp.h 8.1 (Berkeley) 6/10/93 300f74e101Schristos */ 310f74e101Schristos 320f74e101Schristos /* 330f74e101Schristos * TCP header. 340f74e101Schristos * Per RFC 793, September, 1981. 350f74e101Schristos */ 360f74e101Schristos struct tcphdr { 37c74ad251Schristos nd_uint16_t th_sport; /* source port */ 38c74ad251Schristos nd_uint16_t th_dport; /* destination port */ 39c74ad251Schristos nd_uint32_t th_seq; /* sequence number */ 40c74ad251Schristos nd_uint32_t th_ack; /* acknowledgement number */ 41c74ad251Schristos nd_uint8_t th_offx2; /* data offset, rsvd */ 42c74ad251Schristos nd_uint8_t th_flags; 43c74ad251Schristos nd_uint16_t th_win; /* window */ 44c74ad251Schristos nd_uint16_t th_sum; /* checksum */ 45c74ad251Schristos nd_uint16_t th_urp; /* urgent pointer */ 46c74ad251Schristos }; 470f74e101Schristos 48c74ad251Schristos #define TH_OFF(th) ((GET_U_1((th)->th_offx2) & 0xf0) >> 4) 490f74e101Schristos 500f74e101Schristos /* TCP flags */ 510f74e101Schristos #define TH_FIN 0x01 520f74e101Schristos #define TH_SYN 0x02 530f74e101Schristos #define TH_RST 0x04 540f74e101Schristos #define TH_PUSH 0x08 550f74e101Schristos #define TH_ACK 0x10 560f74e101Schristos #define TH_URG 0x20 570f74e101Schristos #define TH_ECNECHO 0x40 /* ECN Echo */ 580f74e101Schristos #define TH_CWR 0x80 /* ECN Cwnd Reduced */ 590f74e101Schristos 600f74e101Schristos 610f74e101Schristos #define TCPOPT_EOL 0 620f74e101Schristos #define TCPOPT_NOP 1 630f74e101Schristos #define TCPOPT_MAXSEG 2 640f74e101Schristos #define TCPOLEN_MAXSEG 4 650f74e101Schristos #define TCPOPT_WSCALE 3 /* window scale factor (rfc1323) */ 660f74e101Schristos #define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */ 670f74e101Schristos #define TCPOPT_SACK 5 /* selective ack (rfc2018) */ 680f74e101Schristos #define TCPOPT_ECHO 6 /* echo (rfc1072) */ 690f74e101Schristos #define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */ 700f74e101Schristos #define TCPOPT_TIMESTAMP 8 /* timestamp (rfc1323) */ 710f74e101Schristos #define TCPOLEN_TIMESTAMP 10 720f74e101Schristos #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 730f74e101Schristos #define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */ 740f74e101Schristos #define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */ 750f74e101Schristos #define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */ 760f74e101Schristos #define TCPOPT_SIGNATURE 19 /* Keyed MD5 (rfc2385) */ 770f74e101Schristos #define TCPOLEN_SIGNATURE 18 780f74e101Schristos #define TCP_SIGLEN 16 /* length of an option 19 digest */ 79dc860a36Sspz #define TCPOPT_SCPS 20 /* SCPS-TP (CCSDS 714.0-B-2) */ 800f74e101Schristos #define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */ 810f74e101Schristos #define TCPOLEN_UTO 4 82dc860a36Sspz #define TCPOPT_TCPAO 29 /* TCP authentication option (rfc5925) */ 83870189d2Schristos #define TCPOPT_MPTCP 30 /* MPTCP options */ 84fdccd7e4Schristos #define TCPOPT_FASTOPEN 34 /* TCP Fast Open (rfc7413) */ 85870189d2Schristos #define TCPOPT_EXPERIMENT2 254 /* experimental headers (rfc4727) */ 860f74e101Schristos 870f74e101Schristos #define TCPOPT_TSTAMP_HDR \ 880f74e101Schristos (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 890f74e101Schristos 90fdccd7e4Schristos #ifndef FTP_PORT 91fdccd7e4Schristos #define FTP_PORT 21 92fdccd7e4Schristos #endif 93fdccd7e4Schristos #ifndef SSH_PORT 94fdccd7e4Schristos #define SSH_PORT 22 95fdccd7e4Schristos #endif 960f74e101Schristos #ifndef TELNET_PORT 970f74e101Schristos #define TELNET_PORT 23 980f74e101Schristos #endif 99ba2ff121Schristos #ifndef SMTP_PORT 100ba2ff121Schristos #define SMTP_PORT 25 101ba2ff121Schristos #endif 102c74ad251Schristos #ifndef WHOIS_PORT 103c74ad251Schristos #define WHOIS_PORT 43 104c74ad251Schristos #endif 105fdccd7e4Schristos #ifndef NAMESERVER_PORT 106fdccd7e4Schristos #define NAMESERVER_PORT 53 107fdccd7e4Schristos #endif 108fdccd7e4Schristos #ifndef HTTP_PORT 109fdccd7e4Schristos #define HTTP_PORT 80 110fdccd7e4Schristos #endif 111fdccd7e4Schristos #ifndef NETBIOS_SSN_PORT 112fdccd7e4Schristos #define NETBIOS_SSN_PORT 139 /* RFC 1001, RFC 1002 */ 113fdccd7e4Schristos #endif 1140f74e101Schristos #ifndef BGP_PORT 1150f74e101Schristos #define BGP_PORT 179 1160f74e101Schristos #endif 117fdccd7e4Schristos #ifndef RPKI_RTR_PORT 118fdccd7e4Schristos #define RPKI_RTR_PORT 323 119fdccd7e4Schristos #endif 120fdccd7e4Schristos #ifndef SMB_PORT 121fdccd7e4Schristos #define SMB_PORT 445 122fdccd7e4Schristos #endif 123fdccd7e4Schristos #ifndef RTSP_PORT 124fdccd7e4Schristos #define RTSP_PORT 554 125fdccd7e4Schristos #endif 126fdccd7e4Schristos #ifndef MSDP_PORT 127fdccd7e4Schristos #define MSDP_PORT 639 128fdccd7e4Schristos #endif 129fdccd7e4Schristos #ifndef LDP_PORT 130fdccd7e4Schristos #define LDP_PORT 646 131fdccd7e4Schristos #endif 132fdccd7e4Schristos #ifndef PPTP_PORT 133fdccd7e4Schristos #define PPTP_PORT 1723 134fdccd7e4Schristos #endif 135fdccd7e4Schristos #ifndef NFS_PORT 136fdccd7e4Schristos #define NFS_PORT 2049 137fdccd7e4Schristos #endif 138*26ba0b50Schristos #ifndef REDIS_PORT 139*26ba0b50Schristos #define REDIS_PORT 6379 140*26ba0b50Schristos #endif 141b3a00663Schristos #ifndef OPENFLOW_PORT_OLD 142b3a00663Schristos #define OPENFLOW_PORT_OLD 6633 143b3a00663Schristos #endif 144b3a00663Schristos #ifndef OPENFLOW_PORT_IANA 145b3a00663Schristos #define OPENFLOW_PORT_IANA 6653 146870189d2Schristos #endif 147ba2ff121Schristos #ifndef HTTP_PORT_ALT 148ba2ff121Schristos #define HTTP_PORT_ALT 8080 149ba2ff121Schristos #endif 150ba2ff121Schristos #ifndef RTSP_PORT_ALT 151ba2ff121Schristos #define RTSP_PORT_ALT 8554 152ba2ff121Schristos #endif 153fdccd7e4Schristos #ifndef BEEP_PORT 154fdccd7e4Schristos #define BEEP_PORT 10288 155fdccd7e4Schristos #endif 156