tcp.h revision 172683
1172683Smlaier/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.11.2.1 2005/11/29 09:09:26 hannes 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#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) 4975115Sfenner u_int8_t th_flags; 5075115Sfenner#define TH_FIN 0x01 5175115Sfenner#define TH_SYN 0x02 5275115Sfenner#define TH_RST 0x04 5375115Sfenner#define TH_PUSH 0x08 5475115Sfenner#define TH_ACK 0x10 5575115Sfenner#define TH_URG 0x20 5698524Sfenner#define TH_ECNECHO 0x40 /* ECN Echo */ 5798524Sfenner#define TH_CWR 0x80 /* ECN Cwnd Reduced */ 5875115Sfenner u_int16_t th_win; /* window */ 5975115Sfenner u_int16_t th_sum; /* checksum */ 6075115Sfenner u_int16_t th_urp; /* urgent pointer */ 6175115Sfenner}; 6275115Sfenner 6375115Sfenner#define TCPOPT_EOL 0 6475115Sfenner#define TCPOPT_NOP 1 6575115Sfenner#define TCPOPT_MAXSEG 2 6675115Sfenner#define TCPOLEN_MAXSEG 4 6798524Sfenner#define TCPOPT_WSCALE 3 /* window scale factor (rfc1323) */ 6898524Sfenner#define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */ 6998524Sfenner#define TCPOPT_SACK 5 /* selective ack (rfc2018) */ 7098524Sfenner#define TCPOPT_ECHO 6 /* echo (rfc1072) */ 7198524Sfenner#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */ 7298524Sfenner#define TCPOPT_TIMESTAMP 8 /* timestamp (rfc1323) */ 7375115Sfenner#define TCPOLEN_TIMESTAMP 10 7475115Sfenner#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 7598524Sfenner#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */ 7698524Sfenner#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */ 7798524Sfenner#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */ 78146773Ssam#define TCPOPT_SIGNATURE 19 /* Keyed MD5 (rfc2385) */ 79146773Ssam#define TCPOLEN_SIGNATURE 18 80146773Ssam#define TCP_SIGLEN 16 /* length of an option 19 digest */ 81172683Smlaier#define TCPOPT_AUTH 20 /* Enhanced AUTH option */ 82146773Ssam 8375115Sfenner#define TCPOPT_TSTAMP_HDR \ 8475115Sfenner (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 85