2021-11-26 03:31:05 +00:00
|
|
|
/** @file
|
2004-07-19 02:27:17 +00:00
|
|
|
* Definitions for structures storing addresses, and for the type of
|
|
|
|
* variables holding port-type values
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-07-19 02:27:17 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2010-11-17 02:57:22 +00:00
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2004-07-19 02:27:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ADDRESS_H__
|
|
|
|
#define __ADDRESS_H__
|
|
|
|
|
2010-11-17 02:57:22 +00:00
|
|
|
#include <string.h> /* for memcmp */
|
2007-04-10 13:35:39 +00:00
|
|
|
|
2015-10-29 03:12:53 +00:00
|
|
|
#include "tvbuff.h"
|
2021-07-26 00:31:17 +00:00
|
|
|
#include <epan/wmem_scopes.h>
|
2021-06-18 18:21:42 +00:00
|
|
|
#include <wsutil/ws_assert.h>
|
2023-10-31 12:51:52 +00:00
|
|
|
#include <wsutil/inet_cidr.h>
|
2015-10-29 03:12:53 +00:00
|
|
|
|
2007-01-18 18:43:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2015-02-08 21:36:07 +00:00
|
|
|
/* Types of "global" addresses Wireshark knows about. */
|
|
|
|
/* Address types can be added here if there are many dissectors that use them or just
|
|
|
|
* within a specific dissector.
|
|
|
|
* If an address type is added here, it must be "registered" within address_types.c
|
|
|
|
* For dissector address types, just use the address_type_dissector_register function
|
|
|
|
* from address_types.h
|
2022-06-22 09:38:39 +00:00
|
|
|
*
|
|
|
|
* AT_NUMERIC - a numeric address type can consist of a guint8, guint16, guint32 or guint64
|
2022-06-23 15:27:44 +00:00
|
|
|
* value. If no correct length is provided, to avoid data bleed, a guint8 is
|
|
|
|
* assumed. Only representation (aka conversion of value to string) is implemented for this type.
|
2015-02-08 21:36:07 +00:00
|
|
|
*/
|
2004-07-19 02:27:17 +00:00
|
|
|
typedef enum {
|
2013-09-07 12:51:29 +00:00
|
|
|
AT_NONE, /* no link-layer address */
|
|
|
|
AT_ETHER, /* MAC (Ethernet, 802.x, FDDI) address */
|
|
|
|
AT_IPv4, /* IPv4 */
|
|
|
|
AT_IPv6, /* IPv6 */
|
|
|
|
AT_IPX, /* IPX */
|
|
|
|
AT_FC, /* Fibre Channel */
|
2014-12-24 05:06:35 +00:00
|
|
|
AT_FCWWN, /* Fibre Channel WWN */
|
2013-09-07 12:51:29 +00:00
|
|
|
AT_STRINGZ, /* null-terminated string */
|
|
|
|
AT_EUI64, /* IEEE EUI-64 */
|
|
|
|
AT_IB, /* Infiniband GID/LID */
|
|
|
|
AT_AX25, /* AX.25 */
|
2018-08-28 20:13:15 +00:00
|
|
|
AT_VINES, /* Banyan Vines address */
|
2022-06-22 09:38:39 +00:00
|
|
|
AT_NUMERIC, /* Numeric address type. */
|
2021-10-28 01:01:06 +00:00
|
|
|
AT_MCTP, /* MCTP */
|
2015-02-08 03:15:55 +00:00
|
|
|
|
|
|
|
AT_END_OF_LIST /* Must be last in list */
|
2004-07-19 02:27:17 +00:00
|
|
|
} address_type;
|
|
|
|
|
|
|
|
typedef struct _address {
|
2015-02-08 03:15:55 +00:00
|
|
|
int type; /* type of address */
|
2014-08-05 20:10:44 +00:00
|
|
|
int len; /* length of address, in bytes */
|
2015-11-26 04:44:52 +00:00
|
|
|
const void *data; /* pointer to address data */
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
void *priv;
|
2004-07-19 02:27:17 +00:00
|
|
|
} address;
|
|
|
|
|
2015-11-26 04:44:52 +00:00
|
|
|
#define ADDRESS_INIT(type, len, data) {type, len, data, NULL}
|
|
|
|
#define ADDRESS_INIT_NONE ADDRESS_INIT(AT_NONE, 0, NULL)
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
clear_address(address *addr)
|
|
|
|
{
|
|
|
|
addr->type = AT_NONE;
|
|
|
|
addr->len = 0;
|
|
|
|
addr->data = NULL;
|
|
|
|
addr->priv = NULL;
|
|
|
|
}
|
|
|
|
|
2013-09-16 21:15:49 +00:00
|
|
|
/** Initialize an address with the given values.
|
|
|
|
*
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param addr [in,out] The address to initialize.
|
|
|
|
* @param addr_type [in] Address type.
|
|
|
|
* @param addr_len [in] The length in bytes of the address data. For example, 4 for
|
2017-10-26 08:50:00 +00:00
|
|
|
* AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param addr_data [in] Pointer to the address data.
|
2013-09-16 21:15:49 +00:00
|
|
|
*/
|
|
|
|
static inline void
|
2015-10-29 03:12:53 +00:00
|
|
|
set_address(address *addr, int addr_type, int addr_len, const void *addr_data) {
|
2016-06-12 01:59:25 +00:00
|
|
|
if (addr_len == 0) {
|
|
|
|
/* Zero length must mean no data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_data == NULL);
|
2016-06-12 01:59:25 +00:00
|
|
|
} else {
|
|
|
|
/* Must not be AT_NONE - AT_NONE must have no data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_type != AT_NONE);
|
2016-06-12 01:59:25 +00:00
|
|
|
/* Make sure we *do* have data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_data != NULL);
|
2016-06-12 01:59:25 +00:00
|
|
|
}
|
2013-09-16 21:15:49 +00:00
|
|
|
addr->type = addr_type;
|
|
|
|
addr->len = addr_len;
|
2015-11-26 04:44:52 +00:00
|
|
|
addr->data = addr_data;
|
|
|
|
addr->priv = NULL;
|
2013-09-16 21:15:49 +00:00
|
|
|
}
|
|
|
|
|
2023-10-29 11:46:46 +00:00
|
|
|
static inline void
|
|
|
|
set_address_ipv4(address *addr, const ipv4_addr_and_mask *ipv4) {
|
|
|
|
addr->type = AT_IPv4;
|
|
|
|
addr->len = 4;
|
|
|
|
uint32_t val = g_htonl(ipv4->addr);
|
|
|
|
addr->priv = g_memdup2(&val, sizeof(val));
|
|
|
|
addr->data = addr->priv;
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:03:28 +00:00
|
|
|
static inline void
|
|
|
|
set_address_ipv6(address *addr, const ipv6_addr_and_prefix *ipv6) {
|
|
|
|
set_address(addr, AT_IPv6, sizeof(ws_in6_addr), &ipv6->addr);
|
|
|
|
}
|
|
|
|
|
2013-09-16 21:15:49 +00:00
|
|
|
/** Initialize an address from TVB data.
|
|
|
|
*
|
2015-10-24 02:23:41 +00:00
|
|
|
* Same as set_address but it takes a TVB and an offset. This is preferred
|
2013-09-16 21:15:49 +00:00
|
|
|
* over passing the return value of tvb_get_ptr() to set_address().
|
|
|
|
*
|
|
|
|
* This calls tvb_get_ptr() (including throwing any exceptions) before
|
|
|
|
* modifying the address.
|
|
|
|
*
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param addr [in,out] The address to initialize.
|
|
|
|
* @param addr_type [in] Address type.
|
|
|
|
* @param tvb [in] Pointer to the TVB.
|
|
|
|
* @param offset [in] Offset within the TVB.
|
|
|
|
* @param addr_len [in] The length in bytes of the address data. For example, 4 for
|
2017-10-26 08:50:00 +00:00
|
|
|
* AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
|
Introduce, and start using, TVB_SET_ADDRESS() and TVB_SET_ADDRESS_HF(). They
are like the non-TVB versions except that they take a TVB and an offset
instead of (frequently) a pointer into the TVB.
Calling tvb_get_ptr() before modifying the rest of the fields should help fix
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7960 (though I can't
reproduce that problem).
Replace a bunch of calls like:
SET_ADDRESS(..., AT_XXX, length, tvb_get_ptr(tvb, offset, length));
with:
TVB_SET_ADDRESS(..., AT_XXX, tvb, offset, length);
svn path=/trunk/; revision=46324
2012-12-02 04:49:13 +00:00
|
|
|
*/
|
2015-10-29 03:12:53 +00:00
|
|
|
static inline void
|
|
|
|
set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int offset) {
|
|
|
|
const void *p;
|
|
|
|
|
2016-06-12 01:59:25 +00:00
|
|
|
if (addr_len != 0) {
|
|
|
|
/* Must not be AT_NONE - AT_NONE must have no data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_type != AT_NONE);
|
2016-03-27 14:11:00 +00:00
|
|
|
p = tvb_get_ptr(tvb, offset, addr_len);
|
2016-06-12 01:59:25 +00:00
|
|
|
} else
|
2016-03-27 14:11:00 +00:00
|
|
|
p = NULL;
|
2015-10-29 03:12:53 +00:00
|
|
|
set_address(addr, addr_type, addr_len, p);
|
|
|
|
}
|
2013-09-07 12:51:29 +00:00
|
|
|
|
2015-11-26 04:44:52 +00:00
|
|
|
/** Initialize an address with the given values, allocating a new buffer
|
|
|
|
* for the address data using wmem-scoped memory.
|
|
|
|
*
|
2021-07-16 15:36:34 +00:00
|
|
|
* @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
|
2015-11-26 04:44:52 +00:00
|
|
|
* @param addr [in,out] The address to initialize.
|
|
|
|
* @param addr_type [in] Address type.
|
|
|
|
* @param addr_len [in] The length in bytes of the address data. For example, 4 for
|
2017-10-26 08:50:00 +00:00
|
|
|
* AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
|
2015-11-26 04:44:52 +00:00
|
|
|
* @param addr_data [in] Pointer to the address data.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
alloc_address_wmem(wmem_allocator_t *scope, address *addr,
|
|
|
|
int addr_type, int addr_len, const void *addr_data) {
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr);
|
2016-02-29 16:51:18 +00:00
|
|
|
clear_address(addr);
|
2015-11-26 04:44:52 +00:00
|
|
|
addr->type = addr_type;
|
2016-06-12 01:59:25 +00:00
|
|
|
if (addr_len == 0) {
|
|
|
|
/* Zero length must mean no data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_data == NULL);
|
2016-06-12 01:59:25 +00:00
|
|
|
/* Nothing to copy */
|
2015-11-26 04:44:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-06-12 01:59:25 +00:00
|
|
|
/* Must not be AT_NONE - AT_NONE must have no data */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_type != AT_NONE);
|
2016-06-12 01:59:25 +00:00
|
|
|
/* Make sure we *do* have data to copy */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr_data != NULL);
|
2016-02-29 16:51:18 +00:00
|
|
|
addr->data = addr->priv = wmem_memdup(scope, addr_data, addr_len);
|
|
|
|
addr->len = addr_len;
|
2015-11-26 04:44:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Allocate an address from TVB data.
|
|
|
|
*
|
|
|
|
* Same as alloc_address_wmem but it takes a TVB and an offset.
|
|
|
|
*
|
2021-07-16 15:36:34 +00:00
|
|
|
* @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
|
2015-11-26 04:44:52 +00:00
|
|
|
* @param addr [in,out] The address to initialize.
|
|
|
|
* @param addr_type [in] Address type.
|
|
|
|
* @param addr_len [in] The length in bytes of the address data. For example, 4 for
|
2017-10-26 08:50:00 +00:00
|
|
|
* AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
|
2015-11-26 04:44:52 +00:00
|
|
|
* @param tvb [in] Pointer to the TVB.
|
|
|
|
* @param offset [in] Offset within the TVB.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
alloc_address_tvb(wmem_allocator_t *scope, address *addr,
|
|
|
|
int addr_type, int addr_len, tvbuff_t *tvb, int offset) {
|
|
|
|
const void *p;
|
|
|
|
|
|
|
|
p = tvb_get_ptr(tvb, offset, addr_len);
|
|
|
|
alloc_address_wmem(scope, addr, addr_type, addr_len, p);
|
|
|
|
}
|
|
|
|
|
2013-09-16 21:15:49 +00:00
|
|
|
/** Compare two addresses.
|
|
|
|
*
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param addr1 [in] The first address to compare.
|
|
|
|
* @param addr2 [in] The second address to compare.
|
2013-09-16 21:15:49 +00:00
|
|
|
* @return 0 if the addresses are equal,
|
|
|
|
* A positive number if addr1 > addr2 in some nondefined metric,
|
|
|
|
* A negative number if addr1 < addr2 in some nondefined metric.
|
2004-07-19 02:27:17 +00:00
|
|
|
*/
|
2013-09-16 21:15:49 +00:00
|
|
|
static inline int
|
|
|
|
cmp_address(const address *addr1, const address *addr2) {
|
|
|
|
if (addr1->type > addr2->type) return 1;
|
|
|
|
if (addr1->type < addr2->type) return -1;
|
|
|
|
if (addr1->len > addr2->len) return 1;
|
|
|
|
if (addr1->len < addr2->len) return -1;
|
2016-06-12 02:13:14 +00:00
|
|
|
if (addr1->len == 0) {
|
|
|
|
/*
|
|
|
|
* memcmp(NULL, NULL, 0) is *not* guaranteed to work, so
|
|
|
|
* if both addresses are zero-length, don't compare them
|
|
|
|
* (there's nothing to compare, so they're equal).
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-16 21:15:49 +00:00
|
|
|
return memcmp(addr1->data, addr2->data, addr1->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Check two addresses for equality.
|
|
|
|
*
|
2004-07-19 02:27:17 +00:00
|
|
|
* Given two addresses, return "true" if they're equal, "false" otherwise.
|
2016-06-12 01:59:25 +00:00
|
|
|
* Addresses are equal only if they have the same type and length; if the
|
|
|
|
* length is zero, they are then equal, otherwise the data must be the
|
|
|
|
* same.
|
2013-09-16 21:15:49 +00:00
|
|
|
*
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param addr1 [in] The first address to compare.
|
|
|
|
* @param addr2 [in] The second address to compare.
|
2017-06-11 19:30:49 +00:00
|
|
|
* @return TRUE if the addresses are equal, FALSE otherwise.
|
2004-07-19 02:27:17 +00:00
|
|
|
*/
|
2013-09-16 21:15:49 +00:00
|
|
|
static inline gboolean
|
2013-09-16 21:33:26 +00:00
|
|
|
addresses_equal(const address *addr1, const address *addr2) {
|
2016-06-12 01:59:25 +00:00
|
|
|
/*
|
|
|
|
* memcmp(NULL, NULL, 0) is *not* guaranteed to work, so
|
|
|
|
* if both addresses are zero-length, don't compare them
|
|
|
|
* (there's nothing to compare, so they're equal).
|
|
|
|
*/
|
|
|
|
if (addr1->type == addr2->type &&
|
|
|
|
addr1->len == addr2->len &&
|
|
|
|
(addr1->len == 0 ||
|
|
|
|
memcmp(addr1->data, addr2->data, addr1->len) == 0))
|
|
|
|
return TRUE;
|
2013-09-16 21:15:49 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-08-18 18:46:12 +00:00
|
|
|
/** Check the data of two addresses for equality.
|
|
|
|
*
|
|
|
|
* Given two addresses, return "true" if they have the same length and,
|
|
|
|
* their data is equal, "false" otherwise.
|
|
|
|
* The address types are ignored. This can be used to compare custom
|
|
|
|
* address types defined with address_type_dissector_register.
|
|
|
|
*
|
|
|
|
* @param addr1 [in] The first address to compare.
|
|
|
|
* @param addr2 [in] The second address to compare.
|
2017-06-11 19:30:49 +00:00
|
|
|
* @return TRUE if the addresses are equal, FALSE otherwise.
|
2015-08-18 18:46:12 +00:00
|
|
|
*/
|
|
|
|
static inline gboolean
|
|
|
|
addresses_data_equal(const address *addr1, const address *addr2) {
|
|
|
|
if ( addr1->len == addr2->len
|
|
|
|
&& memcmp(addr1->data, addr2->data, addr1->len) == 0
|
|
|
|
) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:44:52 +00:00
|
|
|
/** Perform a shallow copy of the address (both addresses point to the same
|
|
|
|
* memory location).
|
2013-09-16 21:15:49 +00:00
|
|
|
*
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param to [in,out] The destination address.
|
|
|
|
* @param from [in] The source address.
|
2015-11-26 04:44:52 +00:00
|
|
|
*
|
|
|
|
* \warning Make sure 'from' memory stays valid for the lifetime of this object.
|
|
|
|
* Also it's strongly recommended to use this function instead of copy-assign.
|
2004-07-19 02:27:17 +00:00
|
|
|
*/
|
2013-09-16 21:15:49 +00:00
|
|
|
static inline void
|
2015-11-26 04:44:52 +00:00
|
|
|
copy_address_shallow(address *to, const address *from) {
|
|
|
|
set_address(to, from->type, from->len, from->data);
|
2013-09-16 21:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-26 04:44:52 +00:00
|
|
|
/** Copy an address, allocating a new buffer for the address data
|
|
|
|
* using wmem-scoped memory.
|
2013-09-16 21:15:49 +00:00
|
|
|
*
|
2021-07-16 15:36:34 +00:00
|
|
|
* @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
|
2013-12-02 13:46:10 +00:00
|
|
|
* @param to [in,out] The destination address.
|
|
|
|
* @param from [in] The source address.
|
2012-12-18 23:28:38 +00:00
|
|
|
*/
|
2013-09-16 21:15:49 +00:00
|
|
|
static inline void
|
2015-11-26 04:44:52 +00:00
|
|
|
copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) {
|
|
|
|
alloc_address_wmem(scope, to, from->type, from->len, from->data);
|
2013-09-16 21:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-26 04:44:52 +00:00
|
|
|
/** Copy an address, allocating a new buffer for the address data.
|
2013-09-16 21:15:49 +00:00
|
|
|
*
|
2013-12-03 13:37:40 +00:00
|
|
|
* @param to [in,out] The destination address.
|
|
|
|
* @param from [in] The source address.
|
2007-04-26 00:51:33 +00:00
|
|
|
*/
|
2015-10-29 03:12:53 +00:00
|
|
|
static inline void
|
2015-11-26 04:44:52 +00:00
|
|
|
copy_address(address *to, const address *from) {
|
|
|
|
copy_address_wmem(NULL, to, from);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free an address allocated with wmem-scoped memory.
|
|
|
|
*
|
2021-07-16 15:36:34 +00:00
|
|
|
* @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
|
2015-11-26 04:44:52 +00:00
|
|
|
* @param addr [in,out] The address whose data to free.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
free_address_wmem(wmem_allocator_t *scope, address *addr) {
|
|
|
|
/* Because many dissectors set 'type = AT_NONE' to mean clear we check for that */
|
|
|
|
if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL) {
|
|
|
|
/* Make sure API use is correct */
|
|
|
|
/* if priv is not null then data == priv */
|
2021-06-18 18:21:42 +00:00
|
|
|
ws_assert(addr->data == addr->priv);
|
2015-11-26 04:44:52 +00:00
|
|
|
wmem_free(scope, addr->priv);
|
|
|
|
}
|
|
|
|
clear_address(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free an address.
|
|
|
|
*
|
|
|
|
* @param addr [in,out] The address whose data to free.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
free_address(address *addr) {
|
|
|
|
free_address_wmem(NULL, addr);
|
2015-10-29 03:12:53 +00:00
|
|
|
}
|
2013-09-16 21:15:49 +00:00
|
|
|
|
|
|
|
/** Hash an address into a hash value (which must already have been set).
|
|
|
|
*
|
|
|
|
* @param hash_val The existing hash value.
|
|
|
|
* @param addr The address to add.
|
|
|
|
* @return The new hash value.
|
|
|
|
*/
|
|
|
|
static inline guint
|
|
|
|
add_address_to_hash(guint hash_val, const address *addr) {
|
|
|
|
const guint8 *hash_data = (const guint8 *)(addr)->data;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < (addr)->len; idx++) {
|
|
|
|
hash_val += hash_data[idx];
|
|
|
|
hash_val += ( hash_val << 10 );
|
|
|
|
hash_val ^= ( hash_val >> 6 );
|
|
|
|
}
|
|
|
|
return hash_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Hash an address into a hash value (which must already have been set).
|
|
|
|
* 64-bit version of add_address_to_hash().
|
|
|
|
*
|
|
|
|
* @param hash_val The existing hash value.
|
|
|
|
* @param addr The address to add.
|
|
|
|
* @return The new hash value.
|
|
|
|
*/
|
|
|
|
static inline guint64
|
|
|
|
add_address_to_hash64(guint64 hash_val, const address *addr) {
|
|
|
|
const guint8 *hash_data = (const guint8 *)(addr)->data;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < (addr)->len; idx++) {
|
|
|
|
hash_val += hash_data[idx];
|
|
|
|
hash_val += ( hash_val << 10 );
|
|
|
|
hash_val ^= ( hash_val >> 6 );
|
|
|
|
}
|
|
|
|
return hash_val;
|
|
|
|
}
|
2007-04-26 00:51:33 +00:00
|
|
|
|
2016-06-22 02:23:05 +00:00
|
|
|
WS_DLL_PUBLIC guint address_to_bytes(const address *addr, guint8 *buf, guint buf_len);
|
|
|
|
|
2006-05-28 19:49:07 +00:00
|
|
|
/* Types of port numbers Wireshark knows about. */
|
2004-07-19 02:27:17 +00:00
|
|
|
typedef enum {
|
2014-08-05 20:10:44 +00:00
|
|
|
PT_NONE, /* no port number */
|
|
|
|
PT_SCTP, /* SCTP */
|
|
|
|
PT_TCP, /* TCP */
|
|
|
|
PT_UDP, /* UDP */
|
|
|
|
PT_DCCP, /* DCCP */
|
|
|
|
PT_IPX, /* IPX sockets */
|
|
|
|
PT_DDP, /* DDP AppleTalk connection */
|
|
|
|
PT_IDP, /* XNS IDP sockets */
|
|
|
|
PT_USB, /* USB endpoint 0xffff means the host */
|
2013-09-07 12:51:29 +00:00
|
|
|
PT_I2C,
|
2014-08-05 20:10:44 +00:00
|
|
|
PT_IBQP, /* Infiniband QP number */
|
2021-08-25 20:15:39 +00:00
|
|
|
PT_BLUETOOTH,
|
2021-10-28 01:01:06 +00:00
|
|
|
PT_IWARP_MPA, /* iWarp MPA */
|
|
|
|
PT_MCTP
|
2004-07-19 02:27:17 +00:00
|
|
|
} port_type;
|
|
|
|
|
2007-01-18 18:43:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
2004-07-19 02:27:17 +00:00
|
|
|
|
2007-01-18 18:43:30 +00:00
|
|
|
#endif /* __ADDRESS_H__ */
|
2013-09-07 12:51:29 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2013-09-07 12:51:29 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|