2 * Definitions for structures storing addresses, and for the type of
3 * variables holding port-type values
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #endif /* __cplusplus */
33 /* Types of addresses Wireshark knows about. */
34 /* If a new address type is added here, a string representation procedure should */
35 /* also be included in address_to_str_buf defined in to_str.c, for presentation purposes */
38 AT_NONE, /* no link-layer address */
39 AT_ETHER, /* MAC (Ethernet, 802.x, FDDI) address */
44 AT_ATALK, /* Appletalk DDP */
45 AT_VINES, /* Banyan Vines */
46 AT_OSI, /* OSI NSAP */
47 AT_ARCNET, /* ARCNET */
48 AT_FC, /* Fibre Channel */
49 AT_SS7PC, /* SS7 Point Code */
50 AT_STRINGZ, /* null-terminated string */
51 AT_EUI64, /* IEEE EUI-64 */
52 AT_URI, /* URI/URL/URN */
53 AT_TIPC, /* TIPC Address Zone,Subnetwork,Processor */
54 AT_USB /* USB Device address
55 * (0xffffffff represents the host) */
58 typedef struct _address {
59 address_type type; /* type of address */
60 int len; /* length of address, in bytes */
61 const guint8 *data; /* bytes that constitute address */
64 #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
65 (addr)->type = (addr_type); \
66 (addr)->len = (addr_len); \
67 (addr)->data = (void *)(addr_data); \
71 * Given two addresses, return
72 * 0 if the addresses are equal,
73 * a positive number if addr1>addr2 in some nondefined metric,
74 * a negative number if addr1<addr2 in some nondefined metric
76 #define CMP_ADDRESS(addr1, addr2) \
77 ( ((addr1)->type > (addr2)->type)?1: \
78 ((addr1)->type < (addr2)->type)?-1: \
79 ((addr1)->len > (addr2)->len) ?1: \
80 ((addr1)->len < (addr2)->len) ?-1: \
81 memcmp((addr1)->data, (addr2)->data, (addr1)->len)\
85 * Given two addresses, return "true" if they're equal, "false" otherwise.
86 * Addresses are equal only if they have the same type; if the type is
87 * AT_NONE, they are then equal, otherwise they must have the same
88 * amount of data and the data must be the same.
90 #define ADDRESSES_EQUAL(addr1, addr2) \
92 (addr1)->type == (addr2)->type && \
94 (addr1)->type == AT_NONE || \
96 (addr1)->len == (addr2)->len && \
97 memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0 \
103 * Copy an address, allocating a new buffer for the address data.
105 #define COPY_ADDRESS(to, from) { \
106 guint8 *COPY_ADDRESS_data; \
107 (to)->type = (from)->type; \
108 (to)->len = (from)->len; \
109 COPY_ADDRESS_data = g_malloc((from)->len); \
110 memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
111 (to)->data = COPY_ADDRESS_data; \
114 /* Types of port numbers Wireshark knows about. */
116 PT_NONE, /* no port number */
121 PT_IPX, /* IPX sockets */
122 PT_NCP, /* NCP connection */
123 PT_EXCHG, /* Fibre Channel exchange */
124 PT_DDP, /* DDP AppleTalk connection */
125 PT_SBCCS, /* FICON */
126 PT_IDP, /* XNS IDP sockets */
127 PT_TIPC, /* TIPC PORT */
128 PT_USB /* USB endpoint 0xffff means the host */
131 /* Types of circuit IDs Wireshark knows about. */
133 CT_NONE, /* no circuit type */
134 CT_DLCI, /* Frame Relay DLCI */
135 CT_ISDN, /* ISDN channel number */
136 CT_X25, /* X.25 logical channel number */
137 CT_ISUP, /* ISDN User Part CIC */
138 CT_IAX2, /* IAX2 call id */
139 CT_H223, /* H.223 logical channel number */
140 CT_BICC /* BICC Circuit identifier */
141 /* Could also have ATM VPI/VCI pairs */
146 #endif /* __cplusplus */
148 #endif /* __ADDRESS_H__ */