2 * Definitions for packet info structures and routines
4 * $Id: packet_info.h,v 1.36 2003/12/08 21:36:53 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_ARCNET, /* ARCNET */
43 AT_FC, /* Fibre Channel */
44 AT_SS7PC /* SS7 Point Code */
47 typedef struct _address {
48 address_type type; /* type of address */
49 int len; /* length of address, in bytes */
50 const guint8 *data; /* bytes that constitute address */
53 #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
54 (addr)->type = (addr_type); \
55 (addr)->len = (addr_len); \
56 (addr)->data = (addr_data); \
60 * Given two addresses, return
61 * 0 if the addresses are equal,
62 * a positive number if addr1>addr2 in some nondefined metric,
63 * a negative number if addr1<addr2 in some nondefined metric
65 #define CMP_ADDRESS(addr1, addr2) \
66 ( ((addr1)->type > (addr2)->type)?1: \
67 ((addr1)->type < (addr2)->type)?-1: \
68 ((addr1)->len > (addr2)->len) ?1: \
69 ((addr1)->len < (addr2)->len) ?-1: \
70 memcmp((addr1)->data, (addr2)->data, (addr1)->len)\
74 * Given two addresses, return "true" if they're equal, "false" otherwise.
75 * Addresses are equal only if they have the same type; if the type is
76 * AT_NONE, they are then equal, otherwise they must have the same
77 * amount of data and the data must be the same.
79 #define ADDRESSES_EQUAL(addr1, addr2) \
81 (addr1)->type == (addr2)->type && \
83 (addr1)->type == AT_NONE || \
85 (addr1)->len == (addr2)->len && \
86 memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0 \
92 * Copy an address, allocating a new buffer for the address data.
94 #define COPY_ADDRESS(to, from) { \
95 guint8 *COPY_ADDRESS_data; \
96 (to)->type = (from)->type; \
97 (to)->len = (from)->len; \
98 COPY_ADDRESS_data = g_malloc((from)->len); \
99 memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
100 (to)->data = COPY_ADDRESS_data; \
103 /* Types of port numbers Ethereal knows about. */
105 PT_NONE, /* no port number */
109 PT_IPX, /* IPX sockets */
110 PT_NCP, /* NCP connection */
111 PT_EXCHG, /* Fibre Channel exchange */
112 PT_DDP, /* DDP AppleTalk connection */
116 /* Types of circuit IDs Ethereal knows about. */
118 CT_NONE, /* no port number */
119 CT_DLCI, /* Frame Relay DLCI */
120 CT_ISDN, /* ISDN channel number */
121 CT_X25 /* X.25 logical channel number */
122 /* Could also have ATM VPI/VCI pairs */
125 #define P2P_DIR_UNKNOWN -1
126 #define P2P_DIR_SENT 0
127 #define P2P_DIR_RECV 1
129 #define PINFO_SOF_FIRST_FRAME 0x1
130 #define PINFO_SOF_SOFF 0x2
131 #define PINFO_EOF_LAST_FRAME 0x80
132 #define PINFO_EOF_INVALID 0x40
134 typedef struct _packet_info {
135 const char *current_proto; /* name of protocol currently being dissected */
136 column_info *cinfo; /* Column formatting information */
138 union wtap_pseudo_header *pseudo_header;
139 GSList *data_src; /* Frame data sources */
140 address dl_src; /* link-layer source address */
141 address dl_dst; /* link-layer destination address */
142 address net_src; /* network-layer source address */
143 address net_dst; /* network-layer destination address */
144 address src; /* source address (net if present, DL otherwise )*/
145 address dst; /* destination address (net if present, DL otherwise )*/
146 guint32 ethertype; /* Ethernet Type Code, if this is an Ethernet packet */
147 guint32 ipproto; /* IP protocol, if this is an IP packet */
148 guint32 ipxptype; /* IPX packet type, if this is an IPX packet */
149 circuit_type ctype; /* type of circuit, for protocols with a VC identifier */
150 guint32 circuit_id; /* circuit ID, for protocols with a VC identifier */
151 char *noreassembly_reason; /* reason why reassembly wasn't done, if any */
152 gboolean fragmented; /* TRUE if the protocol is only a fragment */
153 gboolean in_error_pkt; /* TRUE if we're inside an {ICMP,CLNP,...} error packet */
154 port_type ptype; /* type of the following two port numbers */
155 guint32 srcport; /* source port */
156 guint32 destport; /* destination port */
158 const char *match_string; /* Subdissectors with string dissector tables use this */
159 guint16 can_desegment; /* >0 if this segment could be desegmented.
160 A dissector that can offer this API (e.g. TCP)
161 sets can_desegment=2, then can_desegment is
162 decremented by 1 each time we pass to the next
163 subdissector. Thus only the dissector immediately
164 above the protocol which sets the flag can use it*/
165 int desegment_offset; /* offset to stuff needing desegmentation */
166 guint32 desegment_len; /* requested desegmentation additional length */
167 guint16 want_pdu_tracking; /* >0 if the subdissector has specified
168 a value in 'bytes_until_next_pdu'.
169 When a dissector detects that the next PDU
170 will start beyond the start of the next
171 segment, it can set this value to 2
172 and 'bytes_until_next_pdu' to the number of
173 bytes beyond the next segment where the
176 If the protocol dissector below this
177 one is capable of PDU tracking it can
178 use this hint to detect PDUs that starts
179 unaligned to the segment boundaries.
180 The TCP dissector is using this hint from
181 (some) protocols to detect when a new PDU
182 starts in the middle of a tcp segment.
184 There is intelligence in the glue between
185 dissector layers to make sure that this
186 request is only passed down to the protocol
187 immediately below the current one and not
190 guint32 bytes_until_next_pdu;
196 guint16 oxid; /* next 2 fields reqd to identify fibre */
197 guint16 rxid; /* channel conversations */
198 guint8 r_ctl; /* R_CTL field in Fibre Channel Protocol */
199 guint8 sof_eof; /* FC's SOF/EOF encoding passed to FC decoder
200 * Bit 7 set if Last frame in sequence
201 * Bit 6 set if invalid frame content
203 * Bit 1 set if first frame in sequence
205 guint16 src_idx; /* Source port index (Cisco MDS-specific) */
206 guint16 dst_idx; /* Dest port index (Cisco MDS-specific) */
207 guint16 vsan; /* Fibre channel/Cisco MDS-specific */
208 void *private_data; /* pointer to data passed from one dissector to another */
211 #endif /* __PACKET_INFO_H__ */