2 * Definitions for packet info structures and routines
4 * $Id: packet_info.h,v 1.7 2001/10/01 08:29:37 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
25 #ifndef __PACKET_INFO_H__
26 #define __PACKET_INFO_H__
28 #include "frame_data.h"
31 /* Types of addresses Ethereal knows about. */
33 AT_NONE, /* no link-layer address */
34 AT_ETHER, /* MAC (Ethernet, 802.x, FDDI) address */
39 AT_ATALK, /* Appletalk DDP */
40 AT_VINES, /* Banyan Vines */
41 AT_OSI, /* OSI NSAP */
42 AT_DLCI /* Frame Relay DLCI */
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 */
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); \
58 * Given two addresses, return "true" if they're equal, "false" otherwise.
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)
66 * Copy an address, allocating a new buffer for the address data.
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; \
77 /* Types of port numbers Ethereal knows about. */
79 PT_NONE, /* no port number */
83 PT_NCP /* NCP connection */
86 #define P2P_DIR_UNKNOWN -1
87 #define P2P_DIR_SENT 0
88 #define P2P_DIR_RECV 1
90 typedef struct _packet_info {
91 const char *current_proto; /* name of protocol currently being dissected */
93 tvbuff_t *compat_top_tvb; /* only needed while converting Ethereal to use tvbuffs */
94 union wtap_pseudo_header *pseudo_header;
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 gboolean in_error_pkt; /* TRUE if we're inside an {ICMP,CLNP,...} error packet */
108 port_type ptype; /* type of the following two port numbers */
109 guint32 srcport; /* source port */
110 guint32 destport; /* destination port */
112 gboolean can_desegment; /* TRUE if this segment could be desegmented */
113 int desegment_offset; /* offset of stuff needing desegmentation */
114 guint32 desegment_len; /* requested desegmentation additional length */
118 void *private; /* pointer to data passed from one dissector to another */
121 void blank_packetinfo(void);
123 extern packet_info pi;
125 #endif /* __PACKET_INFO_H__ */