1214478Srpaulo/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.14 2007-12-09 00:30:47 guy Exp $ (LBL) */ 275115Sfenner/* 375115Sfenner * Copyright (c) 1982, 1986, 1993 475115Sfenner * The Regents of the University of California. All rights reserved. 575115Sfenner * 675115Sfenner * Redistribution and use in source and binary forms, with or without 775115Sfenner * modification, are permitted provided that the following conditions 875115Sfenner * are met: 975115Sfenner * 1. Redistributions of source code must retain the above copyright 1075115Sfenner * notice, this list of conditions and the following disclaimer. 1175115Sfenner * 2. Redistributions in binary form must reproduce the above copyright 1275115Sfenner * notice, this list of conditions and the following disclaimer in the 1375115Sfenner * documentation and/or other materials provided with the distribution. 1475115Sfenner * 3. All advertising materials mentioning features or use of this software 1575115Sfenner * must display the following acknowledgement: 1675115Sfenner * This product includes software developed by the University of 1775115Sfenner * California, Berkeley and its contributors. 1875115Sfenner * 4. Neither the name of the University nor the names of its contributors 1975115Sfenner * may be used to endorse or promote products derived from this software 2075115Sfenner * without specific prior written permission. 2175115Sfenner * 2275115Sfenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2375115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2475115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2575115Sfenner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2675115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2775115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2875115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2975115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3075115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3175115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3275115Sfenner * SUCH DAMAGE. 3375115Sfenner * 3475115Sfenner * @(#)tcp.h 8.1 (Berkeley) 6/10/93 3575115Sfenner */ 3675115Sfenner 3775115Sfennertypedef u_int32_t tcp_seq; 3875115Sfenner/* 3975115Sfenner * TCP header. 4075115Sfenner * Per RFC 793, September, 1981. 4175115Sfenner */ 4275115Sfennerstruct tcphdr { 4375115Sfenner u_int16_t th_sport; /* source port */ 4475115Sfenner u_int16_t th_dport; /* destination port */ 4575115Sfenner tcp_seq th_seq; /* sequence number */ 4675115Sfenner tcp_seq th_ack; /* acknowledgement number */ 4775115Sfenner u_int8_t th_offx2; /* data offset, rsvd */ 4875115Sfenner u_int8_t th_flags; 4975115Sfenner u_int16_t th_win; /* window */ 5075115Sfenner u_int16_t th_sum; /* checksum */ 5175115Sfenner u_int16_t th_urp; /* urgent pointer */ 5275115Sfenner}; 5375115Sfenner 54190207Srpaulo#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) 55190207Srpaulo 56190207Srpaulo/* TCP flags */ 57190207Srpaulo#define TH_FIN 0x01 58190207Srpaulo#define TH_SYN 0x02 59190207Srpaulo#define TH_RST 0x04 60190207Srpaulo#define TH_PUSH 0x08 61190207Srpaulo#define TH_ACK 0x10 62190207Srpaulo#define TH_URG 0x20 63190207Srpaulo#define TH_ECNECHO 0x40 /* ECN Echo */ 64190207Srpaulo#define TH_CWR 0x80 /* ECN Cwnd Reduced */ 65190207Srpaulo 66190207Srpaulo 6775115Sfenner#define TCPOPT_EOL 0 6875115Sfenner#define TCPOPT_NOP 1 6975115Sfenner#define TCPOPT_MAXSEG 2 7075115Sfenner#define TCPOLEN_MAXSEG 4 7198524Sfenner#define TCPOPT_WSCALE 3 /* window scale factor (rfc1323) */ 7298524Sfenner#define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */ 7398524Sfenner#define TCPOPT_SACK 5 /* selective ack (rfc2018) */ 7498524Sfenner#define TCPOPT_ECHO 6 /* echo (rfc1072) */ 7598524Sfenner#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */ 7698524Sfenner#define TCPOPT_TIMESTAMP 8 /* timestamp (rfc1323) */ 7775115Sfenner#define TCPOLEN_TIMESTAMP 10 7875115Sfenner#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 7998524Sfenner#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */ 8098524Sfenner#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */ 8198524Sfenner#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */ 82146773Ssam#define TCPOPT_SIGNATURE 19 /* Keyed MD5 (rfc2385) */ 83146773Ssam#define TCPOLEN_SIGNATURE 18 84146773Ssam#define TCP_SIGLEN 16 /* length of an option 19 digest */ 85172683Smlaier#define TCPOPT_AUTH 20 /* Enhanced AUTH option */ 86197829Srpaulo#define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */ 87197829Srpaulo#define TCPOLEN_UTO 4 88146773Ssam 89214478Srpaulo 9075115Sfenner#define TCPOPT_TSTAMP_HDR \ 9175115Sfenner (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 92190207Srpaulo 93190207Srpaulo#ifndef TELNET_PORT 94190207Srpaulo#define TELNET_PORT 23 95190207Srpaulo#endif 96190207Srpaulo#ifndef BGP_PORT 97190207Srpaulo#define BGP_PORT 179 98190207Srpaulo#endif 99190207Srpaulo#define NETBIOS_SSN_PORT 139 100190207Srpaulo#ifndef PPTP_PORT 101190207Srpaulo#define PPTP_PORT 1723 102190207Srpaulo#endif 103190207Srpaulo#define BEEP_PORT 10288 104190207Srpaulo#ifndef NFS_PORT 105190207Srpaulo#define NFS_PORT 2049 106190207Srpaulo#endif 107190207Srpaulo#define MSDP_PORT 639 108251158Sdelphij#define RPKI_RTR_PORT 323 109190207Srpaulo#define LDP_PORT 646 110190207Srpaulo#ifndef SMB_PORT 111190207Srpaulo#define SMB_PORT 445 112190207Srpaulo#endif 113