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.
29 /* Types of addresses Wireshark knows about. */
30 /* If a new address type is added here, a string representation procedure should */
31 /* also be included in address_to_str_buf defined in to_str.c, for presentation purposes */
34 AT_NONE, /* no link-layer address */
35 AT_ETHER, /* MAC (Ethernet, 802.x, FDDI) address */
40 AT_ATALK, /* Appletalk DDP */
41 AT_VINES, /* Banyan Vines */
42 AT_OSI, /* OSI NSAP */
43 AT_ARCNET, /* ARCNET */
44 AT_FC, /* Fibre Channel */
45 AT_SS7PC, /* SS7 Point Code */
46 AT_STRINGZ, /* null-terminated string */
47 AT_EUI64, /* IEEE EUI-64 */
48 AT_URI, /* URI/URL/URN */
49 AT_TIPC, /* TIPC Address Zone,Subnetwork,Processor */
50 AT_USB /* USB Device address
51 * (0xffffffff represents the host) */
54 typedef struct _address {
55 address_type type; /* type of address */
56 int len; /* length of address, in bytes */
57 const guint8 *data; /* bytes that constitute address */
60 #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
61 (addr)->type = (addr_type); \
62 (addr)->len = (addr_len); \
63 (addr)->data = (void *)(addr_data); \
67 * Given two addresses, return
68 * 0 if the addresses are equal,
69 * a positive number if addr1>addr2 in some nondefined metric,
70 * a negative number if addr1<addr2 in some nondefined metric
72 #define CMP_ADDRESS(addr1, addr2) \
73 ( ((addr1)->type > (addr2)->type)?1: \
74 ((addr1)->type < (addr2)->type)?-1: \
75 ((addr1)->len > (addr2)->len) ?1: \
76 ((addr1)->len < (addr2)->len) ?-1: \
77 memcmp((addr1)->data, (addr2)->data, (addr1)->len)\
81 * Given two addresses, return "true" if they're equal, "false" otherwise.
82 * Addresses are equal only if they have the same type; if the type is
83 * AT_NONE, they are then equal, otherwise they must have the same
84 * amount of data and the data must be the same.
86 #define ADDRESSES_EQUAL(addr1, addr2) \
88 (addr1)->type == (addr2)->type && \
90 (addr1)->type == AT_NONE || \
92 (addr1)->len == (addr2)->len && \
93 memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0 \
99 * Copy an address, allocating a new buffer for the address data.
101 #define COPY_ADDRESS(to, from) { \
102 guint8 *COPY_ADDRESS_data; \
103 (to)->type = (from)->type; \
104 (to)->len = (from)->len; \
105 COPY_ADDRESS_data = g_malloc((from)->len); \
106 memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
107 (to)->data = COPY_ADDRESS_data; \
110 /* Types of port numbers Wireshark knows about. */
112 PT_NONE, /* no port number */
117 PT_IPX, /* IPX sockets */
118 PT_NCP, /* NCP connection */
119 PT_EXCHG, /* Fibre Channel exchange */
120 PT_DDP, /* DDP AppleTalk connection */
121 PT_SBCCS, /* FICON */
122 PT_IDP, /* XNS IDP sockets */
123 PT_TIPC, /* TIPC PORT */
124 PT_USB /* USB endpoint 0xffff means the host */
127 /* Types of circuit IDs Wireshark knows about. */
129 CT_NONE, /* no circuit type */
130 CT_DLCI, /* Frame Relay DLCI */
131 CT_ISDN, /* ISDN channel number */
132 CT_X25, /* X.25 logical channel number */
133 CT_ISUP, /* ISDN User Part CIC */
134 CT_IAX2, /* IAX2 call id */
135 CT_H223, /* H.223 logical channel number */
136 CT_BICC /* BICC Circuit identifier */
137 /* Could also have ATM VPI/VCI pairs */
140 #endif /* __ADDRESS_H__ */