aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
Diffstat (limited to 'epan')
-rw-r--r--epan/addr_resolv.c27
-rw-r--r--epan/address_types.c270
-rw-r--r--epan/address_types.h14
-rw-r--r--epan/dissectors/packet-arcnet.c16
-rw-r--r--epan/dissectors/packet-atalk.c17
-rw-r--r--epan/dissectors/packet-devicenet.c7
-rw-r--r--epan/dissectors/packet-ieee80211.c6
-rw-r--r--epan/dissectors/packet-ieee802154.c8
-rw-r--r--epan/dissectors/packet-j1939.c7
-rw-r--r--epan/dissectors/packet-jxta.c6
-rw-r--r--epan/dissectors/packet-mp2t.c2
-rw-r--r--epan/dissectors/packet-mstp.c16
-rw-r--r--epan/dissectors/packet-sna.c8
-rw-r--r--epan/dissectors/packet-tipc.c6
-rw-r--r--epan/osi-utils.c6
-rw-r--r--epan/proto.c21
-rw-r--r--epan/to_str.h1
17 files changed, 291 insertions, 147 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index ff4dc02cf3..f08e6fe964 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -2968,32 +2968,7 @@ address_to_display(wmem_allocator_t *allocator, const address *addr)
const gchar *
get_addr_name(const address *addr)
{
- guint32 ip4_addr;
- struct e_in6_addr ip6_addr;
-
- /*
- * Try to look up a name for this address.
- * If it's not found, this might return a string corresponding to
- * the address, or it might return NULL.
- *
- * Whatever string is returned has at least session scope.
- */
- switch (addr->type) {
-
- case AT_ETHER:
- return get_ether_name((const guint8 *)addr->data);
-
- case AT_IPv4:
- memcpy(&ip4_addr, addr->data, sizeof ip4_addr);
- return get_hostname(ip4_addr);
-
- case AT_IPv6:
- memcpy(&ip6_addr.bytes, addr->data, sizeof ip6_addr.bytes);
- return get_hostname6(&ip6_addr);
-
- default:
- return NULL;
- }
+ return solve_address_to_name(addr);
}
gchar *
diff --git a/epan/address_types.c b/epan/address_types.c
index 901670fc41..f04ef53e35 100644
--- a/epan/address_types.c
+++ b/epan/address_types.c
@@ -53,9 +53,10 @@ struct _address_type_t {
AddrValueToStringLen addr_str_len;
AddrColFilterString addr_col_filter;
AddrFixedLen addr_fixed_len;
+ AddrNameResolutionToString addr_name_res_str;
+ AddrNameResolutionLen addr_name_res_len;
/* XXX - Some sort of compare functions (like ftype)? ***/
- /* XXX - Include functions for name resolution? ***/
};
#define MAX_DISSECTOR_ADDR_TYPE 20
@@ -84,12 +85,21 @@ static void address_type_register(int addr_type, address_type_t *at)
/* Don't re-register. */
g_assert(type_list[addr_type] == NULL);
+ /* Sanity check */
+ DISSECTOR_ASSERT(at->name);
+ DISSECTOR_ASSERT(at->pretty_name);
+ DISSECTOR_ASSERT(at->addr_to_str);
+ DISSECTOR_ASSERT(at->addr_str_len);
+ DISSECTOR_ASSERT(((at->addr_name_res_str != NULL) && (at->addr_name_res_str != NULL)) ||
+ ((at->addr_name_res_len == NULL) && (at->addr_name_res_len == NULL)));
+
type_list[addr_type] = at;
}
int address_type_dissector_register(const char* name, const char* pretty_name,
AddrValueToString to_str_func, AddrValueToStringLen str_len_func,
- AddrColFilterString col_filter_str_func, AddrFixedLen fixed_len_func)
+ AddrColFilterString col_filter_str_func, AddrFixedLen fixed_len_func,
+ AddrNameResolutionToString name_res_str_func, AddrNameResolutionLen name_res_len_func)
{
int addr_type;
@@ -98,6 +108,9 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
DISSECTOR_ASSERT(pretty_name);
DISSECTOR_ASSERT(to_str_func);
DISSECTOR_ASSERT(str_len_func);
+ /* Either have both or neither */
+ DISSECTOR_ASSERT(((name_res_str_func != NULL) && (name_res_len_func != NULL)) ||
+ ((name_res_str_func == NULL) && (name_res_len_func == NULL)));
/* This shouldn't happen, so flag it for fixing */
DISSECTOR_ASSERT(num_dissector_addr_type < MAX_DISSECTOR_ADDR_TYPE);
@@ -110,6 +123,8 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
dissector_type_addresses[num_dissector_addr_type].addr_str_len = str_len_func;
dissector_type_addresses[num_dissector_addr_type].addr_col_filter = col_filter_str_func;
dissector_type_addresses[num_dissector_addr_type].addr_fixed_len = fixed_len_func;
+ dissector_type_addresses[num_dissector_addr_type].addr_name_res_str = name_res_str_func;
+ dissector_type_addresses[num_dissector_addr_type].addr_name_res_len = name_res_len_func;
type_list[addr_type] = &dissector_type_addresses[num_dissector_addr_type];
@@ -121,10 +136,10 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
/******************************************************************************
* AT_NONE
******************************************************************************/
-gboolean none_addr_to_str(const address* addr _U_, gchar *buf, int buf_len _U_)
+int none_addr_to_str(const address* addr _U_, gchar *buf, int buf_len _U_)
{
buf[0] = '\0';
- return TRUE;
+ return none_addr_str_len(addr);
}
int none_addr_str_len(const address* addr _U_)
@@ -137,14 +152,24 @@ int none_addr_len(void)
return 0;
}
+static int none_name_res_len(void)
+{
+ return 5;
+}
+
+static const gchar* none_name_res_str(const address* addr _U_)
+{
+ return "NONE";
+}
+
/******************************************************************************
* AT_ETHER
******************************************************************************/
-gboolean ether_to_str(const address* addr, gchar *buf, int buf_len _U_)
+int ether_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
bytes_to_hexstr_punct(buf, (const guint8*)addr->data, 6, ':');
buf[17] = '\0';
- return TRUE;
+ return ether_str_len(addr);
}
int ether_str_len(const address* addr _U_)
@@ -165,6 +190,16 @@ int ether_len(void)
return 6;
}
+const gchar* ether_name_resolution_str(const address* addr)
+{
+ return get_ether_name((const guint8 *)addr->data);
+}
+
+int ether_name_resolution_len(void)
+{
+ return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
+}
+
/******************************************************************************
* AT_IPv4
******************************************************************************/
@@ -192,6 +227,18 @@ static int ipv4_len(void)
return 4;
}
+const gchar* ipv4_name_res_str(const address* addr)
+{
+ guint32 ip4_addr;
+ memcpy(&ip4_addr, addr->data, sizeof ip4_addr);
+ return get_hostname(ip4_addr);
+}
+
+int ipv4_name_res_len(void)
+{
+ return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
+}
+
/******************************************************************************
* AT_IPv6
******************************************************************************/
@@ -336,6 +383,18 @@ static int ipv6_len(void)
return 16;
}
+const gchar* ipv6_name_res_str(const address* addr)
+{
+ struct e_in6_addr ip6_addr;
+ memcpy(&ip6_addr.bytes, addr->data, sizeof ip6_addr.bytes);
+ return get_hostname6(&ip6_addr);
+}
+
+int ipv6_name_res_len(void)
+{
+ return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
+}
+
/******************************************************************************
* AT_IPX
******************************************************************************/
@@ -411,7 +470,6 @@ static int fc_len(void)
/******************************************************************************
* AT_FCWWN
* XXX - Doubles as a "field type", should it be defined here?
- * XXX - currently this has some address resolution worked into the "base" string
******************************************************************************/
/* FC Network Header Network Address Authority Identifiers */
#define FC_NH_NAA_IEEE 1 /* IEEE 802.1a */
@@ -424,28 +482,40 @@ static int fc_len(void)
#define FC_NH_NAA_CCITT_INDV 12 /* CCITT 60 bit individual address */
#define FC_NH_NAA_CCITT_GRP 14 /* CCITT 60 bit group address */
-static gboolean fcwwn_to_str(const address* addr, gchar *buf, int buf_len)
+static int fcwwn_str_len(const address* addr _U_)
+{
+ return 24;
+}
+
+static int fcwwn_to_str(const address* addr, gchar *buf, int buf_len _U_)
+{
+ const guint8 *addrp = (const guint8*)addr->data;
+
+ buf = bytes_to_hexstr_punct(buf, addrp, 8, ':'); /* 23 bytes */
+ buf[23] = '\0';
+
+ return fcwwn_str_len(addr);
+}
+
+static int fcwwn_len(void)
+{
+ return FCWWN_ADDR_LEN;
+}
+
+const gchar* fcwwn_name_res_str(const address* addr)
{
const guint8 *addrp = (const guint8*)addr->data;
int fmt;
guint8 oui[6];
- gchar *ethptr;
- if (buf_len < 200) { /* This is mostly for manufacturer name */
- g_strlcpy(buf, BUF_TOO_SMALL_ERR, buf_len); /* Let the unexpected value alert user */
- return FALSE;
- }
-
- ethptr = bytes_to_hexstr_punct(buf, addrp, 8, ':'); /* 23 bytes */
fmt = (addrp[0] & 0xF0) >> 4;
switch (fmt) {
case FC_NH_NAA_IEEE:
case FC_NH_NAA_IEEE_E:
- memcpy (oui, &addrp[2], 6);
- g_snprintf (ethptr, buf_len-23, " (%s)", get_manuf_name(oui));
- break;
+ memcpy (oui, &addrp[2], 6);
+ return get_manuf_name(oui);
case FC_NH_NAA_IEEE_R:
oui[0] = ((addrp[0] & 0x0F) << 4) | ((addrp[1] & 0xF0) >> 4);
@@ -455,25 +525,15 @@ static gboolean fcwwn_to_str(const address* addr, gchar *buf, int buf_len)
oui[4] = ((addrp[4] & 0x0F) << 4) | ((addrp[5] & 0xF0) >> 4);
oui[5] = ((addrp[5] & 0x0F) << 4) | ((addrp[6] & 0xF0) >> 4);
- g_snprintf (ethptr, buf_len-23, " (%s)", get_manuf_name(oui));
- break;
-
- default:
- *ethptr = '\0';
- break;
+ return get_manuf_name(oui);
}
- return TRUE;
+ return "";
}
-static int fcwwn_str_len(const address* addr _U_)
+int fcwwn_name_res_len(void)
{
- return 200;
-}
-
-static int fcwwn_len(void)
-{
- return FCWWN_ADDR_LEN;
+ return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
}
/******************************************************************************
@@ -631,7 +691,9 @@ void address_types_initialize(void)
none_addr_to_str, /* addr_to_str */
none_addr_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- none_addr_len /* addr_fixed_len */
+ none_addr_len, /* addr_fixed_len */
+ none_name_res_str, /* addr_name_res_str */
+ none_name_res_len, /* addr_name_res_len */
};
static address_type_t ether_address = {
@@ -641,7 +703,9 @@ void address_types_initialize(void)
ether_to_str, /* addr_to_str */
ether_str_len, /* addr_str_len */
ether_col_filter_str, /* addr_col_filter */
- ether_len /* addr_fixed_len */
+ ether_len, /* addr_fixed_len */
+ ether_name_resolution_str, /* addr_name_res_str */
+ ether_name_resolution_len, /* addr_name_res_len */
};
static address_type_t ipv4_address = {
@@ -651,7 +715,9 @@ void address_types_initialize(void)
ipv4_to_str, /* addr_to_str */
ipv4_str_len, /* addr_str_len */
ipv4_col_filter_str, /* addr_col_filter */
- ipv4_len /* addr_fixed_len */
+ ipv4_len, /* addr_fixed_len */
+ ipv4_name_res_str, /* addr_name_res_str */
+ ipv4_name_res_len, /* addr_name_res_len */
};
static address_type_t ipv6_address = {
@@ -661,7 +727,9 @@ void address_types_initialize(void)
ipv6_to_str, /* addr_to_str */
ipv6_str_len, /* addr_str_len */
ipv6_col_filter_str, /* addr_col_filter */
- ipv6_len /* addr_fixed_len */
+ ipv6_len, /* addr_fixed_len */
+ ipv6_name_res_str, /* addr_name_res_str */
+ ipv6_name_res_len, /* addr_name_res_len */
};
static address_type_t ipx_address = {
@@ -671,7 +739,9 @@ void address_types_initialize(void)
ipx_to_str, /* addr_to_str */
ipx_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- ipx_len /* addr_fixed_len */
+ ipx_len, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t vines_address = {
@@ -680,8 +750,10 @@ void address_types_initialize(void)
"Banyan Vines address", /* pretty_name */
vines_to_str, /* addr_to_str */
vines_str_len, /* addr_str_len */
- NULL, /* addr_col_filter */
- vines_len /*addr_fixed_len */
+ NULL, /* addr_col_filter */
+ vines_len, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t fc_address = {
@@ -691,7 +763,9 @@ void address_types_initialize(void)
fc_to_str, /* addr_to_str */
fc_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- fc_len /*addr_fixed_len */
+ fc_len, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t fcwwn_address = {
@@ -701,7 +775,9 @@ void address_types_initialize(void)
fcwwn_to_str, /* addr_to_str */
fcwwn_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- fcwwn_len /* addr_fixed_len */
+ fcwwn_len, /* addr_fixed_len */
+ fcwwn_name_res_str, /* addr_name_res_str */
+ fcwwn_name_res_len, /* addr_name_res_len */
};
static address_type_t ss7pc_address = {
@@ -711,7 +787,9 @@ void address_types_initialize(void)
ss7pc_to_str, /* addr_to_str */
ss7pc_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- NULL /* addr_fixed_len */
+ NULL, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t stringz_address = {
@@ -721,7 +799,9 @@ void address_types_initialize(void)
stringz_addr_to_str, /* addr_to_str */
stringz_addr_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- NULL /* addr_fixed_len */
+ NULL, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t eui64_address = {
@@ -731,7 +811,9 @@ void address_types_initialize(void)
eui64_addr_to_str, /* addr_to_str */
eui64_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- eui64_len /* addr_fixed_len */
+ eui64_len, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t ib_address = {
@@ -741,7 +823,9 @@ void address_types_initialize(void)
ib_addr_to_str, /* addr_to_str */
ib_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- NULL /* addr_fixed_len */
+ NULL, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t usb_address = {
@@ -751,7 +835,9 @@ void address_types_initialize(void)
usb_addr_to_str, /* addr_to_str */
usb_addr_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
- NULL /* addr_fixed_len */
+ NULL, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
static address_type_t ax25_address = {
@@ -761,7 +847,9 @@ void address_types_initialize(void)
ax25_addr_to_str, /* addr_to_str */
ax25_addr_str_len,/* addr_str_len */
ax25_col_filter_str, /* addr_col_filter */
- ax25_len /* addr_fixed_len */
+ ax25_len, /* addr_fixed_len */
+ NULL, /* addr_name_res_str */
+ NULL, /* addr_name_res_len */
};
num_dissector_addr_type = 0;
@@ -798,20 +886,12 @@ static int address_type_get_length(const address* addr)
ADDR_TYPE_LOOKUP(addr->type, at);
- if ((at == NULL) || (at->addr_str_len == NULL))
+ if (at == NULL)
return 0;
return at->addr_str_len(addr);
}
-/*XXX FIXME the code below may be called very very frequently in the future.
- optimize it for speed and get rid of the slow sprintfs */
-/* XXX - perhaps we should have individual address types register
- a table of routines to do operations such as address-to-name translation,
- address-to-string translation, and the like, and have this call them,
- and also have an address-to-string-with-a-name routine */
-/* convert an address struct into a printable string */
-
gchar*
address_to_str(wmem_allocator_t *scope, const address *addr)
{
@@ -844,6 +924,84 @@ void address_to_str_buf(const address* addr, gchar *buf, int buf_len)
at->addr_to_str(addr, buf, buf_len);
}
+static void address_with_resolution_to_str_buf(const address* addr, gchar *buf, int buf_len)
+{
+ address_type_t *at;
+ int addr_len;
+ gsize pos;
+ gboolean empty;
+
+ if (!buf || !buf_len)
+ return;
+
+ ADDR_TYPE_LOOKUP(addr->type, at);
+
+ if (at == NULL)
+ {
+ buf[0] = '\0';
+ return;
+ }
+
+#if 0 /* XXX - If this remains a static function, we've already made this check in the only
+ function that can call it. If this function becomes "public", need to put this
+ check back in */
+ /* No name resolution support, just return address string */
+ if (at->addr_name_res_str == NULL)
+ return address_to_str_buf(addr, buf, buf_len);
+#endif
+
+ /* Copy the resolved name */
+ pos = g_strlcpy(buf, at->addr_name_res_str(addr), buf_len);
+
+ /* Don't wrap "emptyness" in parathesis */
+ if (addr->type == AT_NONE)
+ return;
+
+ /* Make sure there is enough room for the address string wrapped in parathesis */
+ if ((int)(pos + 4 + at->addr_str_len(addr)) >= buf_len)
+ return;
+
+ empty = (pos <= 1) ? TRUE : FALSE;
+
+ if (!empty)
+ {
+ buf[pos++] = ' ';
+ buf[pos++] = '(';
+ }
+
+ addr_len = at->addr_to_str(addr, &buf[pos], buf_len-pos);
+ pos += addr_len;
+
+ if (!empty)
+ {
+ buf[pos++] = ')';
+ buf[pos++] = '\0';
+ }
+}
+
+gchar* address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr)
+{
+ address_type_t *at;
+ int len;
+ gchar *str;
+
+ ADDR_TYPE_LOOKUP(addr->type, at);
+
+ if (at == NULL)
+ return wmem_strdup(scope, "");
+
+ /* No name resolution support, just return address string */
+ if (at->addr_name_res_str == NULL)
+ return address_to_str(scope, addr);
+
+ len = at->addr_name_res_len() + at->addr_str_len(addr) + 4; /* For format of %s (%s) */
+
+ str=(gchar *)wmem_alloc(scope, len);
+ address_with_resolution_to_str_buf(addr, str, len);
+ return str;
+}
+
+
const char* address_type_column_filter_string(const address* addr, gboolean src)
{
address_type_t *at;
diff --git a/epan/address_types.h b/epan/address_types.h
index e2cbe05ab1..d27cdb4688 100644
--- a/epan/address_types.h
+++ b/epan/address_types.h
@@ -29,27 +29,33 @@
extern "C" {
#endif /* __cplusplus */
-typedef gboolean (*AddrValueToString)(const address* addr, gchar *buf, int buf_len);
+typedef int (*AddrValueToString)(const address* addr, gchar *buf, int buf_len);
typedef int (*AddrValueToStringLen)(const address* addr);
typedef int (*AddrFixedLen)(void);
typedef const char* (*AddrColFilterString)(const address* addr, gboolean src);
+typedef int (*AddrNameResolutionLen)(void);
+typedef const gchar* (*AddrNameResolutionToString)(const address* addr);
struct _address_type_t;
typedef struct _address_type_t address_type_t;
int address_type_dissector_register(const char* name, const char* pretty_name,
AddrValueToString to_str_func, AddrValueToStringLen str_len_func,
- AddrColFilterString col_filter_str_func, AddrFixedLen fixed_len_func);
+ AddrColFilterString col_filter_str_func, AddrFixedLen fixed_len_func,
+ AddrNameResolutionToString name_res_str_func, AddrNameResolutionLen name_res_len_func);
void address_types_initialize(void);
/* Address type functions used by multiple (dissector) address types */
-gboolean none_addr_to_str(const address* addr, gchar *buf, int buf_len);
+int none_addr_to_str(const address* addr, gchar *buf, int buf_len);
int none_addr_str_len(const address* addr);
int none_addr_len(void);
-gboolean ether_to_str(const address* addr, gchar *buf, int buf_len);
+
+int ether_to_str(const address* addr, gchar *buf, int buf_len);
int ether_str_len(const address* addr);
int ether_len(void);
+const gchar* ether_name_resolution_str(const address* addr);
+int ether_name_resolution_len(void);
diff --git a/epan/dissectors/packet-arcnet.c b/epan/dissectors/packet-arcnet.c
index a09cc59469..251a0d3e5c 100644
--- a/epan/dissectors/packet-arcnet.c
+++ b/epan/dissectors/packet-arcnet.c
@@ -53,19 +53,19 @@ static int arcnet_address_type = -1;
static dissector_table_t arcnet_dissector_table;
static dissector_handle_t data_handle;
-static gboolean arcnet_to_str(const address* addr, gchar *buf, int buf_len _U_)
+static int arcnet_str_len(const address* addr _U_)
+{
+ return 5;
+}
+
+static int arcnet_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
*buf++ = '0';
*buf++ = 'x';
buf = bytes_to_hexstr(buf, (const guint8 *)addr->data, 1);
*buf = '\0'; /* NULL terminate */
- return TRUE;
-}
-
-static int arcnet_str_len(const address* addr _U_)
-{
- return 5;
+ return arcnet_str_len(addr);
}
static const char* arcnet_col_filter_str(const address* addr _U_, gboolean is_src)
@@ -385,7 +385,7 @@ proto_register_arcnet (void)
proto_register_field_array (proto_arcnet, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
- arcnet_address_type = address_type_dissector_register("AT_ARCNET", "ARCNET Address", arcnet_to_str, arcnet_str_len, arcnet_col_filter_str, arcnet_len);
+ arcnet_address_type = address_type_dissector_register("AT_ARCNET", "ARCNET Address", arcnet_to_str, arcnet_str_len, arcnet_col_filter_str, arcnet_len, NULL, NULL);
}
diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c
index 0b97a667e6..972c54b09c 100644
--- a/epan/dissectors/packet-atalk.c
+++ b/epan/dissectors/packet-atalk.c
@@ -1177,7 +1177,13 @@ struct atalk_ddp_addr {
guint8 node;
};
-static gboolean atalk_to_str(const address* addr, gchar *buf, int buf_len _U_)
+
+static int atalk_str_len(const address* addr _U_)
+{
+ return 8;
+}
+
+static int atalk_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
struct atalk_ddp_addr atalk;
memcpy(&atalk, addr->data, sizeof atalk);
@@ -1187,12 +1193,7 @@ static gboolean atalk_to_str(const address* addr, gchar *buf, int buf_len _U_)
buf = bytes_to_hexstr(buf, &atalk.node, 1);
*buf++ = '\0'; /* NULL terminate */
- return TRUE;
-}
-
-static int atalk_str_len(const address* addr _U_)
-{
- return 14;
+ return atalk_str_len(addr);
}
static const char* atalk_col_filter_str(const address* addr _U_, gboolean is_src)
@@ -2067,7 +2068,7 @@ proto_register_atalk(void)
ddp_dissector_table = register_dissector_table("ddp.type", "DDP packet type",
FT_UINT8, BASE_HEX);
- atalk_address_type = address_type_dissector_register("AT_ATALK", "Appletalk DDP", atalk_to_str, atalk_str_len, atalk_col_filter_str, atalk_len);
+ atalk_address_type = address_type_dissector_register("AT_ATALK", "Appletalk DDP", atalk_to_str, atalk_str_len, atalk_col_filter_str, atalk_len, NULL, NULL);
}
void
diff --git a/epan/dissectors/packet-devicenet.c b/epan/dissectors/packet-devicenet.c
index 29a1e08b0b..2e283e0383 100644
--- a/epan/dissectors/packet-devicenet.c
+++ b/epan/dissectors/packet-devicenet.c
@@ -781,13 +781,14 @@ static int dissect_devicenet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
return tvb_captured_length(tvb);
}
-static gboolean devicenet_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
+static int devicenet_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
guint8 addrdata = *((guint8*)addr->data) & 0x3F;
+ gchar *start_buf = buf;
buf = uint_to_str_back(buf, addrdata);
*buf = '\0';
- return TRUE;
+ return buf-start_buf+1;
}
static int devicenet_addr_str_len(const address* addr _U_)
@@ -1030,7 +1031,7 @@ void proto_register_devicenet(void)
new_register_dissector("devicenet", dissect_devicenet, proto_devicenet);
- devicenet_address_type = address_type_dissector_register("AT_DEVICENET", "DeviceNet Address", devicenet_addr_to_str, devicenet_addr_str_len, NULL, devicenet_addr_len);
+ devicenet_address_type = address_type_dissector_register("AT_DEVICENET", "DeviceNet Address", devicenet_addr_to_str, devicenet_addr_str_len, NULL, devicenet_addr_len, NULL, NULL);
devicenet_module = prefs_register_protocol(proto_devicenet, NULL);
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index e1ad7dade4..46e46d01cd 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -26806,8 +26806,10 @@ proto_register_ieee80211 (void)
wlan_tap = register_tap("wlan");
register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet, wlan_hostlist_packet);
- wlan_address_type = address_type_dissector_register("AT_ETHER_WLAN", "WLAN Address", ether_to_str, ether_str_len, wlan_col_filter_str, ether_len);
- wlan_bssid_address_type = address_type_dissector_register("AT_ETHER_BSSID", "WLAN BSSID Address", ether_to_str, ether_str_len, wlan_bssid_col_filter_str, ether_len);
+ wlan_address_type = address_type_dissector_register("AT_ETHER_WLAN", "WLAN Address", ether_to_str, ether_str_len, wlan_col_filter_str,
+ ether_len, ether_name_resolution_str, ether_name_resolution_len);
+ wlan_bssid_address_type = address_type_dissector_register("AT_ETHER_BSSID", "WLAN BSSID Address", ether_to_str, ether_str_len, wlan_bssid_col_filter_str,
+ ether_len, ether_name_resolution_str, ether_name_resolution_len);
/* Register configuration options */
wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys);
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index 2467bc1651..4488634945 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -392,14 +392,14 @@ static gboolean ieee802154_extend_auth = TRUE;
#define ieee802154_crc_tvb(tvb, offset) (crc16_ccitt_tvb_seed(tvb, offset, IEEE802154_CRC_SEED) ^ IEEE802154_CRC_XOROUT)
-static gboolean ieee802_15_4_short_address_to_str(const address* addr, gchar *buf, int buf_len)
+static int ieee802_15_4_short_address_to_str(const address* addr, gchar *buf, int buf_len)
{
guint16 ieee_802_15_4_short_addr = pletoh16(addr->data);
if (ieee_802_15_4_short_addr == 0xffff)
{
g_strlcpy(buf, "Broadcast", buf_len);
- return TRUE;
+ return 10;
}
*buf++ = '0';
@@ -407,7 +407,7 @@ static gboolean ieee802_15_4_short_address_to_str(const address* addr, gchar *bu
buf = word_to_hex(buf, ieee_802_15_4_short_addr);
*buf = '\0'; /* NULL terminate */
- return TRUE;
+ return 7;
}
static int ieee802_15_4_short_address_str_len(const address* addr _U_)
@@ -2790,7 +2790,7 @@ void proto_register_ieee802154(void)
expert_register_field_array(expert_ieee802154, ei, array_length(ei));
ieee802_15_4_short_address_type = address_type_dissector_register("AT_IEEE_802_15_4_SHORT", "IEEE 802.15.4 16-bit short address",
- ieee802_15_4_short_address_to_str, ieee802_15_4_short_address_str_len, NULL, ieee802_15_4_short_address_len);
+ ieee802_15_4_short_address_to_str, ieee802_15_4_short_address_str_len, NULL, ieee802_15_4_short_address_len, NULL, NULL);
/* add a user preference to set the 802.15.4 ethertype */
ieee802154_module = prefs_register_protocol(proto_ieee802154,
diff --git a/epan/dissectors/packet-j1939.c b/epan/dissectors/packet-j1939.c
index 10c8a7860c..66d4493c20 100644
--- a/epan/dissectors/packet-j1939.c
+++ b/epan/dissectors/packet-j1939.c
@@ -259,13 +259,14 @@ static int dissect_j1939(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
return tvb_captured_length(tvb);
}
-static gboolean J1939_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
+static int J1939_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
const guint8 *addrdata = (const guint8 *)addr->data;
+ gchar *start_buf = buf;
buf = uint_to_str_back(buf, *addrdata);
*buf = '\0';
- return TRUE;
+ return buf-start_buf+1;
}
static int J1939_addr_str_len(const address* addr _U_)
@@ -350,7 +351,7 @@ void proto_register_j1939(void)
subdissector_pgn_table = register_dissector_table("j1939.pgn", "PGN Handle", FT_UINT32, BASE_DEC);
- j1939_address_type = address_type_dissector_register("AT_J1939", "J1939 Address", J1939_addr_to_str, J1939_addr_str_len, J1939_col_filter_str, J1939_addr_len);
+ j1939_address_type = address_type_dissector_register("AT_J1939", "J1939 Address", J1939_addr_to_str, J1939_addr_str_len, J1939_col_filter_str, J1939_addr_len, NULL, NULL);
}
/*
diff --git a/epan/dissectors/packet-jxta.c b/epan/dissectors/packet-jxta.c
index 6a8d8ab59f..af0b9c1831 100644
--- a/epan/dissectors/packet-jxta.c
+++ b/epan/dissectors/packet-jxta.c
@@ -244,12 +244,12 @@ jxta_hostlist_packet(void *pit, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
return 1;
}
-static gboolean uri_to_str(const address* addr, gchar *buf, int buf_len)
+static int uri_to_str(const address* addr, gchar *buf, int buf_len)
{
int copy_len = addr->len < (buf_len - 1) ? addr->len : (buf_len - 1);
memcpy(buf, addr->data, copy_len );
buf[copy_len] = '\0';
- return TRUE;
+ return copy_len+1;
}
static int uri_str_len(const address* addr)
@@ -2368,7 +2368,7 @@ void proto_register_jxta(void)
/* Register JXTA Sub-tree */
proto_register_subtree_array(ett, array_length(ett));
- uri_address_type = address_type_dissector_register("AT_URI", "URI/URL/URN", uri_to_str, uri_str_len, uri_col_filter_str, NULL);
+ uri_address_type = address_type_dissector_register("AT_URI", "URI/URL/URN", uri_to_str, uri_str_len, uri_col_filter_str, NULL, NULL, NULL);
/* Register preferences */
/* register re-init routine */
diff --git a/epan/dissectors/packet-mp2t.c b/epan/dissectors/packet-mp2t.c
index 6d3426b112..82e65cbe66 100644
--- a/epan/dissectors/packet-mp2t.c
+++ b/epan/dissectors/packet-mp2t.c
@@ -1513,7 +1513,7 @@ proto_register_mp2t(void)
expert_mp2t = expert_register_protocol(proto_mp2t);
expert_register_field_array(expert_mp2t, ei, array_length(ei));
- mp2t_no_address_type = address_type_dissector_register("AT_MP2T_NONE", "No MP2T Address", none_addr_to_str, none_addr_str_len, NULL, none_addr_len);
+ mp2t_no_address_type = address_type_dissector_register("AT_MP2T_NONE", "No MP2T Address", none_addr_to_str, none_addr_str_len, NULL, none_addr_len, NULL, NULL);
heur_subdissector_list = register_heur_dissector_list("mp2t.pid");
/* Register init of processing of fragmented DEPI packets */
diff --git a/epan/dissectors/packet-mstp.c b/epan/dissectors/packet-mstp.c
index c8159c99aa..f0c2b9f4dd 100644
--- a/epan/dissectors/packet-mstp.c
+++ b/epan/dissectors/packet-mstp.c
@@ -149,19 +149,19 @@ mstp_frame_type_text(guint32 val)
"Unknown Frame Type (%u)");
}
-static gboolean mstp_to_str(const address* addr, gchar *buf, int buf_len _U_)
+static int mstp_str_len(const address* addr _U_)
+{
+ return 5;
+}
+
+static int mstp_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
*buf++ = '0';
*buf++ = 'x';
buf = bytes_to_hexstr(buf, (const guint8 *)addr->data, 1);
*buf = '\0'; /* NULL terminate */
- return TRUE;
-}
-
-static int mstp_str_len(const address* addr _U_)
-{
- return 5;
+ return mstp_str_len(addr);
}
static const char* mstp_col_filter_str(const address* addr _U_, gboolean is_src)
@@ -465,7 +465,7 @@ proto_register_mstp(void)
"MSTP Vendor specific Frametypes", FT_UINT24, BASE_DEC);
/* Table_type: (Vendor ID << 16) + Frametype */
- mstp_address_type = address_type_dissector_register("AT_MSTP", "BACnet MS/TP Address", mstp_to_str, mstp_str_len, mstp_col_filter_str, mstp_len);
+ mstp_address_type = address_type_dissector_register("AT_MSTP", "BACnet MS/TP Address", mstp_to_str, mstp_str_len, mstp_col_filter_str, mstp_len, NULL, NULL);
}
void
diff --git a/epan/dissectors/packet-sna.c b/epan/dissectors/packet-sna.c
index 1f50007ac9..cfa5bd2e09 100644
--- a/epan/dissectors/packet-sna.c
+++ b/epan/dissectors/packet-sna.c
@@ -829,7 +829,7 @@ static void dissect_gds (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
static void dissect_rh (tvbuff_t*, int, proto_tree*);
static void dissect_control(tvbuff_t*, int, int, proto_tree*, int, enum parse);
-static gboolean sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len _U_)
+static int sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len _U_)
{
const guint8 *addrdata;
struct sna_fid_type_4_addr sna_fid_type_4_addr;
@@ -859,10 +859,10 @@ static gboolean sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len
break;
default:
buf[0] = '\0';
- return FALSE;
+ return 1;
}
- return TRUE;
+ return strlen(buf)+1;
}
@@ -3481,7 +3481,7 @@ proto_register_sna(void)
"Systems Network Architecture XID", "SNA XID", "sna_xid");
register_dissector("sna_xid", dissect_sna_xid, proto_sna_xid);
- sna_address_type = address_type_dissector_register("AT_SNA", "SNA Address", sna_fid_to_str_buf, sna_address_str_len, NULL, NULL);
+ sna_address_type = address_type_dissector_register("AT_SNA", "SNA Address", sna_fid_to_str_buf, sna_address_str_len, NULL, NULL, NULL, NULL);
/* Register configuration options */
sna_module = prefs_register_protocol(proto_sna, NULL);
diff --git a/epan/dissectors/packet-tipc.c b/epan/dissectors/packet-tipc.c
index a9dc4cb05c..68baf63281 100644
--- a/epan/dissectors/packet-tipc.c
+++ b/epan/dissectors/packet-tipc.c
@@ -605,7 +605,7 @@ tipc_addr_to_str(guint tipc_address)
return tipc_addr_value_to_buf(tipc_address, buf, MAX_TIPC_ADDRESS_STR_LEN);
}
-static gboolean
+static int
tipc_addr_to_str_buf(const address* addr, gchar *buf, int buf_len)
{
const guint8 *data = (const guint8 *)addr->data;
@@ -617,7 +617,7 @@ tipc_addr_to_str_buf(const address* addr, gchar *buf, int buf_len)
tipc_address = (tipc_address << 8) ^ data[3];
tipc_addr_value_to_buf(tipc_address, buf, buf_len);
- return TRUE;
+ return strlen(buf)+1;
}
static int tipc_addr_str_len(const address* addr _U_)
@@ -2962,7 +2962,7 @@ proto_register_tipc(void)
tipc_module = prefs_register_protocol(proto_tipc, proto_reg_handoff_tipc);
tipc_address_type = address_type_dissector_register("tipc_address_type", "TIPC Address Zone,Subnetwork,Processor",
- tipc_addr_to_str_buf, tipc_addr_str_len, NULL, NULL);
+ tipc_addr_to_str_buf, tipc_addr_str_len, NULL, NULL, NULL, NULL);
/* Set default ports */
range_convert_str(&global_tipc_udp_port_range, DEFAULT_TIPC_PORT_RANGE, MAX_TCP_PORT);
diff --git a/epan/osi-utils.c b/epan/osi-utils.c
index 95354c7d1b..073c43ba35 100644
--- a/epan/osi-utils.c
+++ b/epan/osi-utils.c
@@ -220,10 +220,10 @@ print_area_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
******************************************************************************/
static int osi_address_type = -1;
-static gboolean osi_address_to_str(const address* addr, gchar *buf, int buf_len)
+static int osi_address_to_str(const address* addr, gchar *buf, int buf_len)
{
print_nsap_net_buf((const guint8 *)addr->data, addr->len, buf, buf_len);
- return TRUE;
+ return strlen(buf)+1;
}
static int osi_address_str_len(const address* addr _U_)
@@ -241,7 +241,7 @@ void register_osi_address_type(void)
if (osi_address_type != -1)
return;
- osi_address_type = address_type_dissector_register("AT_OSI", "OSI Address", osi_address_to_str, osi_address_str_len, NULL, NULL);
+ osi_address_type = address_type_dissector_register("AT_OSI", "OSI Address", osi_address_to_str, osi_address_str_len, NULL, NULL, NULL, NULL);
}
diff --git a/epan/proto.c b/epan/proto.c
index cbb6274f91..ac4e44f9c4 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -6192,9 +6192,9 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.len = 6;
addr.data = bytes;
- addr_str = (char*)address_to_str(NULL, &addr);
- label_fill_descr(label_str, 0, hfinfo,
- get_ether_name(bytes), addr_str);
+ addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
+ g_snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@@ -6206,9 +6206,9 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.len = 4;
addr.data = &n_addr;
- addr_str = (char*)address_to_str(NULL, &addr);
- label_fill_descr(label_str, 0, hfinfo,
- get_hostname(n_addr), addr_str);
+ addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
+ g_snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@@ -6219,10 +6219,9 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.len = 16;
addr.data = bytes;
- addr_str = (char*)address_to_str(NULL, &addr);
- label_fill_descr(label_str, 0, hfinfo,
- get_hostname6((struct e_in6_addr *)bytes),
- addr_str);
+ addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
+ g_snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@@ -6231,7 +6230,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.len = FCWWN_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);
- addr_str = (char*)address_to_str(NULL, &addr);
+ addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
diff --git a/epan/to_str.h b/epan/to_str.h
index 1eb46e3791..9557eaeedb 100644
--- a/epan/to_str.h
+++ b/epan/to_str.h
@@ -52,6 +52,7 @@ extern "C" {
struct e_in6_addr;
WS_DLL_PUBLIC gchar* address_to_str(wmem_allocator_t *scope, const address *addr);
+WS_DLL_PUBLIC gchar* address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr);
WS_DLL_PUBLIC void address_to_str_buf(const address *addr, gchar *buf, int buf_len);