Add circuit ID BICC_CIC
[obnox/wireshark/wip.git] / epan / address.h
1 /* address.h
2  * Definitions for structures storing addresses, and for the type of
3  * variables holding port-type values
4  *
5  * $Id$
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  * 
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.
15  * 
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.
20  * 
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.
24  */
25
26 #ifndef __ADDRESS_H__
27 #define __ADDRESS_H__
28
29 /* Types of addresses Ethereal 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 */
32
33 typedef enum {
34   AT_NONE,              /* no link-layer address */
35   AT_ETHER,             /* MAC (Ethernet, 802.x, FDDI) address */
36   AT_IPv4,              /* IPv4 */
37   AT_IPv6,              /* IPv6 */
38   AT_IPX,               /* IPX */
39   AT_SNA,               /* SNA */
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 } address_type;
50
51 typedef struct _address {
52   address_type  type;           /* type of address */
53   int           len;            /* length of address, in bytes */
54   const guint8 *data;           /* bytes that constitute address */
55 } address;
56
57 #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
58         (addr)->type = (addr_type); \
59         (addr)->len = (addr_len); \
60         (addr)->data = (void *)(addr_data); \
61         }
62
63 /*
64  * Given two addresses, return
65  *  0 if the addresses are equal,
66  *  a positive number if addr1>addr2 in some nondefined metric,
67  *  a negative number if addr1<addr2 in some nondefined metric
68  */
69 #define CMP_ADDRESS(addr1, addr2) \
70         (       ((addr1)->type > (addr2)->type)?1:      \
71                 ((addr1)->type < (addr2)->type)?-1:     \
72                 ((addr1)->len  > (addr2)->len) ?1:      \
73                 ((addr1)->len  < (addr2)->len) ?-1:     \
74                 memcmp((addr1)->data, (addr2)->data, (addr1)->len)\
75         )
76
77 /*
78  * Given two addresses, return "true" if they're equal, "false" otherwise.
79  * Addresses are equal only if they have the same type; if the type is
80  * AT_NONE, they are then equal, otherwise they must have the same
81  * amount of data and the data must be the same.
82  */
83 #define ADDRESSES_EQUAL(addr1, addr2)                                   \
84         (                                                               \
85          (addr1)->type == (addr2)->type &&                              \
86          (                                                              \
87           (addr1)->type == AT_NONE ||                                   \
88           (                                                             \
89            (addr1)->len == (addr2)->len &&                              \
90            memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0      \
91           )                                                             \
92          )                                                              \
93         )
94
95 /*
96  * Copy an address, allocating a new buffer for the address data.
97  */
98 #define COPY_ADDRESS(to, from) { \
99         guint8 *COPY_ADDRESS_data; \
100         (to)->type = (from)->type; \
101         (to)->len = (from)->len; \
102         COPY_ADDRESS_data = g_malloc((from)->len); \
103         memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \
104         (to)->data = COPY_ADDRESS_data; \
105         }
106
107 /* Types of port numbers Ethereal knows about. */
108 typedef enum {
109   PT_NONE,              /* no port number */
110   PT_SCTP,              /* SCTP */
111   PT_TCP,               /* TCP */
112   PT_UDP,               /* UDP */
113   PT_DCCP,              /* DCCP */
114   PT_IPX,               /* IPX sockets */
115   PT_NCP,               /* NCP connection */
116   PT_EXCHG,             /* Fibre Channel exchange */
117   PT_DDP,               /* DDP AppleTalk connection */
118   PT_SBCCS,             /* FICON */
119   PT_IDP                /* XNS IDP sockets */
120 } port_type;
121
122 /* Types of circuit IDs Ethereal knows about. */
123 typedef enum {
124   CT_NONE,              /* no circuit type */
125   CT_DLCI,              /* Frame Relay DLCI */
126   CT_ISDN,              /* ISDN channel number */
127   CT_X25,               /* X.25 logical channel number */
128   CT_ISUP,              /* ISDN User Part CIC */
129   CT_IAX2,              /* IAX2 call id */
130   CT_H223,              /* H.223 logical channel number */
131   CT_BICC               /* BICC Circuit identifier */
132   /* Could also have ATM VPI/VCI pairs */
133 } circuit_type;
134
135 #endif /* __ADDRESS_H__ */
136