add details for doxygen, various code cleanups as a result of this
[obnox/wireshark/wip.git] / packet-tcp.h
1 /* packet-tcp.h
2  *
3  * $Id: packet-tcp.h,v 1.21 2003/12/30 00:03:48 guy Exp $
4  *
5  * Ethereal - Network traffic analyzer
6  * By Gerald Combs <gerald@ethereal.com>
7  * Copyright 1998 Gerald Combs
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #ifndef __PACKET_TCP_H__
25 #define __PACKET_TCP_H__
26
27 /* TCP flags */
28 #define TH_FIN  0x01
29 #define TH_SYN  0x02
30 #define TH_RST  0x04
31 #define TH_PUSH 0x08
32 #define TH_ACK  0x10
33 #define TH_URG  0x20
34 #define TH_ECN  0x40
35 #define TH_CWR  0x80
36
37
38 /* the tcp header structure, passed to tap listeners */
39 struct tcpheader {
40         guint32 th_seq;
41         guint32 th_ack;
42         gboolean th_have_seglen;        /* TRUE if th_seglen is valid */
43         guint32 th_seglen;
44         guint32 th_win;   /* make it 32 bits so we can handle some scaling */
45         guint16 th_sport;
46         guint16 th_dport;
47         guint8  th_hlen;
48         guint8  th_flags;
49         address ip_src;
50         address ip_dst;
51 };
52
53 /*
54  * Private data passed from the TCP dissector to subdissectors.
55  */
56 struct tcpinfo {
57         guint32 seq;             /* Sequence number of first byte in the data */
58         guint32 nxtseq;          /* Sequence number of first byte after data */
59         gboolean is_reassembled; /* This is reassembled data. */
60         gboolean urgent;         /* TRUE if "urgent_pointer" is valid */
61         guint16 urgent_pointer;  /* Urgent pointer value for the current packet. */
62 };
63
64 /*
65  * Loop for dissecting PDUs within a TCP stream; assumes that a PDU
66  * consists of a fixed-length chunk of data that contains enough information
67  * to determine the length of the PDU, followed by rest of the PDU.
68  *
69  * The first three arguments are the arguments passed to the dissector
70  * that calls this routine.
71  *
72  * "proto_desegment" is the dissector's flag controlling whether it should
73  * desegment PDUs that cross TCP segment boundaries.
74  *
75  * "fixed_len" is the length of the fixed-length part of the PDU.
76  *
77  * "get_pdu_len()" is a routine called to get the length of the PDU from
78  * the fixed-length part of the PDU; it's passed "tvb" and "offset".
79  *
80  * "dissect_pdu()" is the routine to dissect a PDU.
81  */
82 extern void
83 tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
84                  gboolean proto_desegment, guint fixed_len,
85                  guint (*get_pdu_len)(tvbuff_t *, int),
86                  void (*dissect_pdu)(tvbuff_t *, packet_info *, proto_tree *));
87
88 extern gboolean decode_tcp_ports(tvbuff_t *, int, packet_info *,
89         proto_tree *, int, int);
90
91 extern void dissect_tcp_payload(tvbuff_t *tvb, packet_info *pinfo, int offset,
92                                 guint32 seq, guint32 nxtseq, guint32 sport,
93                                 guint32 dport, proto_tree *tree,
94                                 proto_tree *tcp_tree);
95
96 #endif