TCP desegmentation support, and changes to the ONC RPC and NBSS
[obnox/wireshark/wip.git] / epan / packet_info.h
1 /* packet_info.h
2  * Definitions for packet info structures and routines
3  *
4  * $Id: packet_info.h,v 1.6 2001/09/13 07:53:53 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  * 
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  * 
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __PACKET_INFO_H__
26 #define __PACKET_INFO_H__
27
28 #include "frame_data.h"
29 #include "tvbuff.h"
30
31 /* Types of addresses Ethereal knows about. */
32 typedef enum {
33   AT_NONE,              /* no link-layer address */
34   AT_ETHER,             /* MAC (Ethernet, 802.x, FDDI) address */
35   AT_IPv4,              /* IPv4 */
36   AT_IPv6,              /* IPv6 */
37   AT_IPX,               /* IPX */
38   AT_SNA,               /* SNA */
39   AT_ATALK,             /* Appletalk DDP */
40   AT_VINES,             /* Banyan Vines */
41   AT_OSI,               /* OSI NSAP */
42   AT_DLCI               /* Frame Relay DLCI */
43 } address_type;
44
45 typedef struct _address {
46   address_type  type;           /* type of address */
47   int           len;            /* length of address, in bytes */
48   const guint8 *data;           /* bytes that constitute address */
49 } address;
50
51 #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
52         (addr)->type = (addr_type); \
53         (addr)->len = (addr_len); \
54         (addr)->data = (addr_data); \
55         }
56
57 /*
58  * Given two addresses, return "true" if they're equal, "false" otherwise.
59  */
60 #define ADDRESSES_EQUAL(addr1, addr2) \
61         ((addr1)->type == (addr2)->type && \
62          (addr1)->len == (addr2)->len && \
63          memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0)
64
65 /*
66  * Copy an address, allocating a new buffer for the address data.
67  */
68 #define COPY_ADDRESS(to, from) { \
69         guint8 *COPY_ADDRESS_data; \
70         (to)->type = (from)->type; \
71         (to)->len = (from)->len; \
72         COPY_ADDRESS_data = g_malloc((from)->len); \
73         memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
74         (to)->data = COPY_ADDRESS_data; \
75         }
76
77 /* Types of port numbers Ethereal knows about. */
78 typedef enum {
79   PT_NONE,              /* no port number */
80   PT_SCTP,              /* SCTP */
81   PT_TCP,               /* TCP */
82   PT_UDP,               /* UDP */
83   PT_NCP                /* NCP connection */
84 } port_type;
85
86 #define P2P_DIR_UNKNOWN -1
87 #define P2P_DIR_SENT    0
88 #define P2P_DIR_RECV    1
89
90 typedef struct _packet_info {
91   const char *current_proto;    /* name of protocol currently being dissected */
92   frame_data *fd;
93   tvbuff_t *compat_top_tvb;     /* only needed while converting Ethereal to use tvbuffs */
94   union wtap_pseudo_header *pseudo_header;
95   int     len;
96   int     captured_len;
97   address dl_src;               /* link-layer source address */
98   address dl_dst;               /* link-layer destination address */
99   address net_src;              /* network-layer source address */
100   address net_dst;              /* network-layer destination address */
101   address src;                  /* source address (net if present, DL otherwise )*/
102   address dst;                  /* destination address (net if present, DL otherwise )*/
103   guint32 ethertype;            /* Ethernet Type Code, if this is an Ethernet packet */
104   guint32 ipproto;              /* IP protocol, if this is an IP packet */
105   guint32 ipxptype;             /* IPX packet type, if this is an IPX packet */
106   gboolean fragmented;          /* TRUE if the protocol is only a fragment */
107   port_type ptype;              /* type of the following two port numbers */
108   guint32 srcport;              /* source port */
109   guint32 destport;             /* destination port */
110   guint32 match_port;
111   gboolean can_desegment;       /* TRUE if this segment could be desegmented */
112   int desegment_offset;         /* offset of stuff needing desegmentation */
113   guint32 desegment_len;        /* requested desegmentation additional length */
114   int     iplen;
115   int     iphdrlen;
116   int     p2p_dir;
117   void    *private;             /* pointer to data passed from one dissector to another */
118 } packet_info;
119
120 void blank_packetinfo(void);
121
122 extern packet_info pi;
123
124 #endif /* __PACKET_INFO_H__ */