175115Sfenner/* 275115Sfenner * Copyright (c) 1982, 1986, 1993 375115Sfenner * The Regents of the University of California. All rights reserved. 475115Sfenner * 575115Sfenner * Redistribution and use in source and binary forms, with or without 675115Sfenner * modification, are permitted provided that the following conditions 775115Sfenner * are met: 875115Sfenner * 1. Redistributions of source code must retain the above copyright 975115Sfenner * notice, this list of conditions and the following disclaimer. 1075115Sfenner * 2. Redistributions in binary form must reproduce the above copyright 1175115Sfenner * notice, this list of conditions and the following disclaimer in the 1275115Sfenner * documentation and/or other materials provided with the distribution. 1375115Sfenner * 3. All advertising materials mentioning features or use of this software 1475115Sfenner * must display the following acknowledgement: 1575115Sfenner * This product includes software developed by the University of 1675115Sfenner * California, Berkeley and its contributors. 1775115Sfenner * 4. Neither the name of the University nor the names of its contributors 1875115Sfenner * may be used to endorse or promote products derived from this software 1975115Sfenner * without specific prior written permission. 2075115Sfenner * 2175115Sfenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2275115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2375115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2475115Sfenner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2575115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2675115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2775115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2875115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2975115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3075115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3175115Sfenner * SUCH DAMAGE. 3275115Sfenner * 3375115Sfenner * @(#)tcp.h 8.1 (Berkeley) 6/10/93 3475115Sfenner */ 3575115Sfenner 36276788Sdelphijtypedef uint32_t tcp_seq; 3775115Sfenner/* 3875115Sfenner * TCP header. 3975115Sfenner * Per RFC 793, September, 1981. 4075115Sfenner */ 4175115Sfennerstruct tcphdr { 42276788Sdelphij uint16_t th_sport; /* source port */ 43276788Sdelphij uint16_t th_dport; /* destination port */ 4475115Sfenner tcp_seq th_seq; /* sequence number */ 4575115Sfenner tcp_seq th_ack; /* acknowledgement number */ 46276788Sdelphij uint8_t th_offx2; /* data offset, rsvd */ 47276788Sdelphij uint8_t th_flags; 48276788Sdelphij uint16_t th_win; /* window */ 49276788Sdelphij uint16_t th_sum; /* checksum */ 50276788Sdelphij uint16_t th_urp; /* urgent pointer */ 51276788Sdelphij} UNALIGNED; 5275115Sfenner 53190207Srpaulo#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) 54190207Srpaulo 55190207Srpaulo/* TCP flags */ 56190207Srpaulo#define TH_FIN 0x01 57190207Srpaulo#define TH_SYN 0x02 58190207Srpaulo#define TH_RST 0x04 59190207Srpaulo#define TH_PUSH 0x08 60190207Srpaulo#define TH_ACK 0x10 61190207Srpaulo#define TH_URG 0x20 62190207Srpaulo#define TH_ECNECHO 0x40 /* ECN Echo */ 63190207Srpaulo#define TH_CWR 0x80 /* ECN Cwnd Reduced */ 64190207Srpaulo 65190207Srpaulo 6675115Sfenner#define TCPOPT_EOL 0 6775115Sfenner#define TCPOPT_NOP 1 6875115Sfenner#define TCPOPT_MAXSEG 2 6975115Sfenner#define TCPOLEN_MAXSEG 4 7098524Sfenner#define TCPOPT_WSCALE 3 /* window scale factor (rfc1323) */ 7198524Sfenner#define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */ 7298524Sfenner#define TCPOPT_SACK 5 /* selective ack (rfc2018) */ 7398524Sfenner#define TCPOPT_ECHO 6 /* echo (rfc1072) */ 7498524Sfenner#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */ 7598524Sfenner#define TCPOPT_TIMESTAMP 8 /* timestamp (rfc1323) */ 7675115Sfenner#define TCPOLEN_TIMESTAMP 10 7775115Sfenner#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 7898524Sfenner#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */ 7998524Sfenner#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */ 8098524Sfenner#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */ 81146773Ssam#define TCPOPT_SIGNATURE 19 /* Keyed MD5 (rfc2385) */ 82146773Ssam#define TCPOLEN_SIGNATURE 18 83146773Ssam#define TCP_SIGLEN 16 /* length of an option 19 digest */ 84313537Sglebius#define TCPOPT_SCPS 20 /* SCPS-TP (CCSDS 714.0-B-2) */ 85197829Srpaulo#define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */ 86197829Srpaulo#define TCPOLEN_UTO 4 87313537Sglebius#define TCPOPT_TCPAO 29 /* TCP authentication option (rfc5925) */ 88276788Sdelphij#define TCPOPT_MPTCP 30 /* MPTCP options */ 89313537Sglebius#define TCPOPT_FASTOPEN 34 /* TCP Fast Open (rfc7413) */ 90276788Sdelphij#define TCPOPT_EXPERIMENT2 254 /* experimental headers (rfc4727) */ 91146773Ssam 9275115Sfenner#define TCPOPT_TSTAMP_HDR \ 9375115Sfenner (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 94190207Srpaulo 95313537Sglebius#ifndef FTP_PORT 96313537Sglebius#define FTP_PORT 21 97313537Sglebius#endif 98313537Sglebius#ifndef SSH_PORT 99313537Sglebius#define SSH_PORT 22 100313537Sglebius#endif 101190207Srpaulo#ifndef TELNET_PORT 102313537Sglebius#define TELNET_PORT 23 103190207Srpaulo#endif 104285275Spkelsey#ifndef SMTP_PORT 105285275Spkelsey#define SMTP_PORT 25 106285275Spkelsey#endif 107313537Sglebius#ifndef NAMESERVER_PORT 108313537Sglebius#define NAMESERVER_PORT 53 109313537Sglebius#endif 110313537Sglebius#ifndef HTTP_PORT 111313537Sglebius#define HTTP_PORT 80 112313537Sglebius#endif 113313537Sglebius#ifndef NETBIOS_NS_PORT 114313537Sglebius#define NETBIOS_NS_PORT 137 /* RFC 1001, RFC 1002 */ 115313537Sglebius#endif 116313537Sglebius#ifndef NETBIOS_SSN_PORT 117313537Sglebius#define NETBIOS_SSN_PORT 139 /* RFC 1001, RFC 1002 */ 118313537Sglebius#endif 119190207Srpaulo#ifndef BGP_PORT 120313537Sglebius#define BGP_PORT 179 121190207Srpaulo#endif 122313537Sglebius#ifndef RPKI_RTR_PORT 123313537Sglebius#define RPKI_RTR_PORT 323 124276788Sdelphij#endif 125313537Sglebius#ifndef SMB_PORT 126313537Sglebius#define SMB_PORT 445 127276788Sdelphij#endif 128313537Sglebius#ifndef RTSP_PORT 129313537Sglebius#define RTSP_PORT 554 130313537Sglebius#endif 131313537Sglebius#ifndef MSDP_PORT 132313537Sglebius#define MSDP_PORT 639 133313537Sglebius#endif 134313537Sglebius#ifndef LDP_PORT 135313537Sglebius#define LDP_PORT 646 136313537Sglebius#endif 137190207Srpaulo#ifndef PPTP_PORT 138313537Sglebius#define PPTP_PORT 1723 139190207Srpaulo#endif 140190207Srpaulo#ifndef NFS_PORT 141313537Sglebius#define NFS_PORT 2049 142190207Srpaulo#endif 143313537Sglebius#ifndef OPENFLOW_PORT_OLD 144313537Sglebius#define OPENFLOW_PORT_OLD 6633 145190207Srpaulo#endif 146313537Sglebius#ifndef OPENFLOW_PORT_IANA 147313537Sglebius#define OPENFLOW_PORT_IANA 6653 148285275Spkelsey#endif 149285275Spkelsey#ifndef HTTP_PORT_ALT 150285275Spkelsey#define HTTP_PORT_ALT 8080 151285275Spkelsey#endif 152285275Spkelsey#ifndef RTSP_PORT_ALT 153285275Spkelsey#define RTSP_PORT_ALT 8554 154285275Spkelsey#endif 155313537Sglebius#ifndef BEEP_PORT 156313537Sglebius#define BEEP_PORT 10288 157285275Spkelsey#endif 158313537Sglebius#ifndef REDIS_PORT 159313537Sglebius#define REDIS_PORT 6379 160313537Sglebius#endif 161