Fix small typo
[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.17 2002/07/31 11:16:19 sahlberg 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
59  *  0 if the addresses are equal,
60  *  1 if addr1>addr2 in some nondefined metric
61  * -1 if addr1<addr2 in some nondefined metric
62  */
63 #define CMP_ADDRESS(addr1, addr2) \
64         (       ((addr1)->type > (addr2)->type)?1:      \
65                 ((addr1)->type < (addr2)->type)?-1:     \
66                 ((addr1)->len  > (addr2)->len) ?1:      \
67                 ((addr1)->len  < (addr2)->len) ?-1:     \
68                 memcmp((addr1)->data, (addr2)->data, (addr1)->len)\
69         )
70
71 /*
72  * Given two addresses, return "true" if they're equal, "false" otherwise.
73  */
74 #define ADDRESSES_EQUAL(addr1, addr2) \
75         ((addr1)->type == (addr2)->type && \
76          (addr1)->len == (addr2)->len && \
77          memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0)
78
79 /*
80  * Copy an address, allocating a new buffer for the address data.
81  */
82 #define COPY_ADDRESS(to, from) { \
83         guint8 *COPY_ADDRESS_data; \
84         (to)->type = (from)->type; \
85         (to)->len = (from)->len; \
86         COPY_ADDRESS_data = g_malloc((from)->len); \
87         memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
88         (to)->data = COPY_ADDRESS_data; \
89         }
90
91 /* Types of port numbers Ethereal knows about. */
92 typedef enum {
93   PT_NONE,              /* no port number */
94   PT_SCTP,              /* SCTP */
95   PT_TCP,               /* TCP */
96   PT_UDP,               /* UDP */
97   PT_NCP,               /* NCP connection */
98   PT_DDP                /* DDP AppleTalk connection */
99 } port_type;
100
101 #define P2P_DIR_UNKNOWN -1
102 #define P2P_DIR_SENT    0
103 #define P2P_DIR_RECV    1
104
105 typedef struct _packet_info {
106   const char *current_proto;    /* name of protocol currently being dissected */
107   column_info *cinfo;           /* Column formatting information */
108   frame_data *fd;
109   union wtap_pseudo_header *pseudo_header;
110   GSList *data_src;             /* Frame data sources */
111   address dl_src;               /* link-layer source address */
112   address dl_dst;               /* link-layer destination address */
113   address net_src;              /* network-layer source address */
114   address net_dst;              /* network-layer destination address */
115   address src;                  /* source address (net if present, DL otherwise )*/
116   address dst;                  /* destination address (net if present, DL otherwise )*/
117   guint32 ethertype;            /* Ethernet Type Code, if this is an Ethernet packet */
118   guint32 ipproto;              /* IP protocol, if this is an IP packet */
119   guint32 ipxptype;             /* IPX packet type, if this is an IPX packet */
120   gboolean fragmented;          /* TRUE if the protocol is only a fragment */
121   gboolean in_error_pkt;        /* TRUE if we're inside an {ICMP,CLNP,...} error packet */
122   port_type ptype;              /* type of the following two port numbers */
123   guint32 srcport;              /* source port */
124   guint32 destport;             /* destination port */
125   guint32 match_port;
126   guint16 can_desegment;        /* >0 if this segment could be desegmented.
127                                    A dissector that can offer this API (e.g. TCP)
128                                    sets can_desegment=2, then can_desegment is
129                                    decremented by 1 each time we pass to the next
130                                    subdissector. Thus only the dissector immediately
131                                    above the protocol which sets the flag can use it*/
132   int desegment_offset;         /* offset of stuff needing desegmentation */
133   guint32 desegment_len;        /* requested desegmentation additional length */
134   int     iplen;
135   int     iphdrlen;
136   int     p2p_dir;
137   void    *private_data;        /* pointer to data passed from one dissector to another */
138 } packet_info;
139
140 #endif /* __PACKET_INFO_H__ */