3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <string.h> /* for memcmp */
26 #include "address_types.h"
28 #include "to_str-int.h"
29 #include "addr_resolv.h"
30 #include "wsutil/pint.h"
31 #include "wsutil/str_util.h"
32 #include "wsutil/inet_addr.h"
34 struct _address_type_t {
35 int addr_type; /* From address_type enumeration or registered value */
37 const char *pretty_name;
38 AddrValueToString addr_to_str;
39 AddrValueToStringLen addr_str_len;
40 AddrValueToByte addr_to_byte;
41 AddrColFilterString addr_col_filter;
42 AddrFixedLen addr_fixed_len;
43 AddrNameResolutionToString addr_name_res_str;
44 AddrNameResolutionLen addr_name_res_len;
46 /* XXX - Some sort of compare functions (like ftype)? ***/
49 #define MAX_DISSECTOR_ADDR_TYPE 30
50 #define MAX_ADDR_TYPE_VALUE (AT_END_OF_LIST+MAX_DISSECTOR_ADDR_TYPE)
52 static int num_dissector_addr_type;
53 static address_type_t dissector_type_addresses[MAX_DISSECTOR_ADDR_TYPE];
55 /* Keep track of address_type_t's via their id number */
56 static address_type_t* type_list[MAX_ADDR_TYPE_VALUE + 1];
59 * If a user _does_ pass in a too-small buffer, this is probably
60 * going to be too long to fit. However, even a partial string
61 * starting with "[Buf" should provide enough of a clue to be
64 #define BUF_TOO_SMALL_ERR "[Buffer too small]"
66 static void address_type_register(int addr_type, address_type_t *at)
69 g_assert(addr_type < MAX_ADDR_TYPE_VALUE);
70 g_assert(addr_type == at->addr_type);
72 /* Don't re-register. */
73 g_assert(type_list[addr_type] == NULL);
76 DISSECTOR_ASSERT(at->name);
77 DISSECTOR_ASSERT(at->pretty_name);
78 DISSECTOR_ASSERT(at->addr_to_str);
79 DISSECTOR_ASSERT(at->addr_str_len);
80 DISSECTOR_ASSERT(((at->addr_name_res_str != NULL) && (at->addr_name_res_len != NULL)) ||
81 ((at->addr_name_res_str == NULL) && (at->addr_name_res_len == NULL)));
83 type_list[addr_type] = at;
86 int address_type_dissector_register(const char* name, const char* pretty_name,
87 AddrValueToString to_str_func, AddrValueToStringLen str_len_func,
88 AddrValueToByte to_bytes_func, AddrColFilterString col_filter_str_func, AddrFixedLen fixed_len_func,
89 AddrNameResolutionToString name_res_str_func, AddrNameResolutionLen name_res_len_func)
93 /* Ensure valid data/functions for required fields */
94 DISSECTOR_ASSERT(name);
95 DISSECTOR_ASSERT(pretty_name);
96 DISSECTOR_ASSERT(to_str_func);
97 DISSECTOR_ASSERT(str_len_func);
98 /* Either have both or neither */
99 DISSECTOR_ASSERT(((name_res_str_func != NULL) && (name_res_len_func != NULL)) ||
100 ((name_res_str_func == NULL) && (name_res_len_func == NULL)));
102 /* This shouldn't happen, so flag it for fixing */
103 DISSECTOR_ASSERT(num_dissector_addr_type < MAX_DISSECTOR_ADDR_TYPE);
105 addr_type = AT_END_OF_LIST+num_dissector_addr_type;
106 dissector_type_addresses[num_dissector_addr_type].addr_type = addr_type;
107 dissector_type_addresses[num_dissector_addr_type].name = name;
108 dissector_type_addresses[num_dissector_addr_type].pretty_name = pretty_name;
109 dissector_type_addresses[num_dissector_addr_type].addr_to_str = to_str_func;
110 dissector_type_addresses[num_dissector_addr_type].addr_str_len = str_len_func;
111 dissector_type_addresses[num_dissector_addr_type].addr_to_byte = to_bytes_func;
112 dissector_type_addresses[num_dissector_addr_type].addr_col_filter = col_filter_str_func;
113 dissector_type_addresses[num_dissector_addr_type].addr_fixed_len = fixed_len_func;
114 dissector_type_addresses[num_dissector_addr_type].addr_name_res_str = name_res_str_func;
115 dissector_type_addresses[num_dissector_addr_type].addr_name_res_len = name_res_len_func;
117 type_list[addr_type] = &dissector_type_addresses[num_dissector_addr_type];
119 num_dissector_addr_type++;
124 int address_type_get_by_name(const char* name)
126 address_type_t** addr;
128 for (addr = type_list; *addr != NULL; addr++)
130 if (!strcmp((*addr)->name, name))
132 return (*addr)->addr_type;
139 /******************************************************************************
141 ******************************************************************************/
142 int none_addr_to_str(const address* addr _U_, gchar *buf, int buf_len _U_)
145 return none_addr_str_len(addr);
148 int none_addr_str_len(const address* addr _U_)
150 return 1; /* NULL character for empty string */
153 int none_addr_len(void)
158 static int none_name_res_len(void)
163 static const gchar* none_name_res_str(const address* addr _U_)
168 /******************************************************************************
170 ******************************************************************************/
171 int ether_to_str(const address* addr, gchar *buf, int buf_len _U_)
173 bytes_to_hexstr_punct(buf, (const guint8*)addr->data, 6, ':');
175 return ether_str_len(addr);
178 int ether_str_len(const address* addr _U_)
183 static const char* ether_col_filter_str(const address* addr _U_, gboolean is_src)
196 const gchar* ether_name_resolution_str(const address* addr)
198 return get_ether_name((const guint8 *)addr->data);
201 int ether_name_resolution_len(void)
203 return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
206 /******************************************************************************
208 ******************************************************************************/
209 static int ipv4_to_str(const address* addr, gchar *buf, int buf_len)
211 ip_to_str_buf((const guint8*)addr->data, buf, buf_len);
212 return (int)(strlen(buf)+1);
215 static int ipv4_str_len(const address* addr _U_)
217 return MAX_IP_STR_LEN;
220 static const char* ipv4_col_filter_str(const address* addr _U_, gboolean is_src)
228 static int ipv4_len(void)
233 static const gchar* ipv4_name_res_str(const address* addr)
236 memcpy(&ip4_addr, addr->data, sizeof ip4_addr);
237 return get_hostname(ip4_addr);
240 static int ipv4_name_res_len(void)
242 return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
245 /******************************************************************************
247 ******************************************************************************/
248 static int ipv6_to_str(const address* addr, gchar *buf, int buf_len)
250 ip6_to_str_buf((const struct e_in6_addr *)addr->data, buf, buf_len);
251 return (int)(strlen(buf)+1);
254 static int ipv6_str_len(const address* addr _U_)
256 return MAX_IP6_STR_LEN;
259 static const char* ipv6_col_filter_str(const address* addr _U_, gboolean is_src)
267 static int ipv6_len(void)
272 static const gchar* ipv6_name_res_str(const address* addr)
274 struct e_in6_addr ip6_addr;
275 memcpy(&ip6_addr.bytes, addr->data, sizeof ip6_addr.bytes);
276 return get_hostname6(&ip6_addr);
279 static int ipv6_name_res_len(void)
281 return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
284 /******************************************************************************
286 ******************************************************************************/
287 static int ipx_to_str(const address* addr, gchar *buf, int buf_len _U_)
289 const guint8 *addrdata = (const guint8 *)addr->data;
292 bufp = bytes_to_hexstr(bufp, &addrdata[0], 4); /* 8 bytes */
293 *bufp++ = '.'; /*1 byte */
294 bufp = bytes_to_hexstr(bufp, &addrdata[4], 6); /* 12 bytes */
295 *bufp++ = '\0'; /* NULL terminate */
296 return (int)(bufp - buf);
299 static int ipx_str_len(const address* addr _U_)
304 static int ipx_len(void)
309 /******************************************************************************
311 ******************************************************************************/
312 static int fc_to_str(const address* addr, gchar *buf, int buf_len _U_)
316 bufp = bytes_to_hexstr_punct(bufp, (const guint8 *)addr->data, 3, '.');
317 *bufp++ = '\0'; /* NULL terminate */
319 return (int)(bufp - buf);
322 static int fc_str_len(const address* addr _U_)
327 static int fc_len(void)
332 /******************************************************************************
334 * XXX - Doubles as a "field type", should it be defined here?
335 ******************************************************************************/
336 /* FC Network Header Network Address Authority Identifiers */
337 #define FC_NH_NAA_IEEE 1 /* IEEE 802.1a */
338 #define FC_NH_NAA_IEEE_E 2 /* IEEE Exteneded */
339 #define FC_NH_NAA_LOCAL 3
340 #define FC_NH_NAA_IP 4 /* 32-bit IP address */
341 #define FC_NH_NAA_IEEE_R 5 /* IEEE Registered */
342 #define FC_NH_NAA_IEEE_R_E 6 /* IEEE Registered Exteneded */
343 /* according to FC-PH 3 draft these are now reclaimed and reserved */
344 #define FC_NH_NAA_CCITT_INDV 12 /* CCITT 60 bit individual address */
345 #define FC_NH_NAA_CCITT_GRP 14 /* CCITT 60 bit group address */
347 static int fcwwn_str_len(const address* addr _U_)
352 static int fcwwn_to_str(const address* addr, gchar *buf, int buf_len _U_)
354 const guint8 *addrp = (const guint8*)addr->data;
356 buf = bytes_to_hexstr_punct(buf, addrp, 8, ':'); /* 23 bytes */
359 return fcwwn_str_len(addr);
362 static int fcwwn_len(void)
364 return FCWWN_ADDR_LEN;
367 static const gchar* fcwwn_name_res_str(const address* addr)
369 const guint8 *addrp = (const guint8*)addr->data;
373 fmt = (addrp[0] & 0xF0) >> 4;
377 case FC_NH_NAA_IEEE_E:
379 memcpy (oui, &addrp[2], 6);
380 return get_manuf_name(oui);
382 case FC_NH_NAA_IEEE_R:
383 oui[0] = ((addrp[0] & 0x0F) << 4) | ((addrp[1] & 0xF0) >> 4);
384 oui[1] = ((addrp[1] & 0x0F) << 4) | ((addrp[2] & 0xF0) >> 4);
385 oui[2] = ((addrp[2] & 0x0F) << 4) | ((addrp[3] & 0xF0) >> 4);
386 oui[3] = ((addrp[3] & 0x0F) << 4) | ((addrp[4] & 0xF0) >> 4);
387 oui[4] = ((addrp[4] & 0x0F) << 4) | ((addrp[5] & 0xF0) >> 4);
388 oui[5] = ((addrp[5] & 0x0F) << 4) | ((addrp[6] & 0xF0) >> 4);
390 return get_manuf_name(oui);
396 static int fcwwn_name_res_len(void)
398 return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
401 /******************************************************************************
403 ******************************************************************************/
404 static int stringz_addr_to_str(const address* addr, gchar *buf, int buf_len)
406 g_strlcpy(buf, (const gchar *)addr->data, buf_len);
407 return (int)(strlen(buf)+1);
410 static int stringz_addr_str_len(const address* addr)
415 /******************************************************************************
417 ******************************************************************************/
418 static int eui64_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
420 buf = bytes_to_hexstr_punct(buf, (const guint8 *)addr->data, 8, ':');
421 *buf = '\0'; /* NULL terminate */
422 return sizeof(buf) + 1;
425 static int eui64_str_len(const address* addr _U_)
427 return EUI64_STR_LEN;
430 static int eui64_len(void)
435 /******************************************************************************
437 ******************************************************************************/
439 ib_addr_to_str( const address *addr, gchar *buf, int buf_len){
440 if (addr->len >= 16) { /* GID is 128bits */
441 #define PREAMBLE_STR_LEN ((int)(sizeof("GID: ") - 1))
442 g_strlcpy(buf, "GID: ", buf_len);
443 if (buf_len < PREAMBLE_STR_LEN ||
444 ws_inet_ntop6(addr->data, buf + PREAMBLE_STR_LEN,
445 buf_len - PREAMBLE_STR_LEN) == NULL ) /* Returns NULL if no space and does not touch buf */
446 g_strlcpy(buf, BUF_TOO_SMALL_ERR, buf_len); /* Let the unexpected value alert user */
447 } else { /* this is a LID (16 bits) */
450 memcpy((void *)&lid_number, addr->data, sizeof lid_number);
451 g_snprintf(buf,buf_len,"LID: %u",lid_number);
454 return sizeof(buf) + 1;
457 static int ib_str_len(const address* addr _U_)
459 return MAX_ADDR_STR_LEN; /* XXX - This is overkill */
462 /******************************************************************************
464 ******************************************************************************/
465 static int ax25_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
467 const guint8 *addrdata = (const guint8 *)addr->data;
470 *bufp++ = printable_char_or_period(addrdata[0] >> 1);
471 *bufp++ = printable_char_or_period(addrdata[1] >> 1);
472 *bufp++ = printable_char_or_period(addrdata[2] >> 1);
473 *bufp++ = printable_char_or_period(addrdata[3] >> 1);
474 *bufp++ = printable_char_or_period(addrdata[4] >> 1);
475 *bufp++ = printable_char_or_period(addrdata[5] >> 1);
477 bufp = uint_to_str_back(bufp, (addrdata[6] >> 1) & 0x0f);
478 *bufp++ = '\0'; /* NULL terminate */
480 return (int)(bufp - buf);
483 static int ax25_addr_str_len(const address* addr _U_)
485 return 21; /* Leaves extra space (10 bytes) just for uint_to_str_back() */
488 static const char* ax25_col_filter_str(const address* addr _U_, gboolean is_src)
496 static int ax25_len(void)
498 return AX25_ADDR_LEN;
501 /******************************************************************************
502 * END OF PROVIDED ADDRESS TYPES
503 ******************************************************************************/
508 void address_types_initialize(void)
510 static address_type_t none_address = {
511 AT_NONE, /* addr_type */
512 "AT_NONE", /* name */
513 "No address", /* pretty_name */
514 none_addr_to_str, /* addr_to_str */
515 none_addr_str_len, /* addr_str_len */
516 NULL, /* addr_to_byte */
517 NULL, /* addr_col_filter */
518 none_addr_len, /* addr_fixed_len */
519 none_name_res_str, /* addr_name_res_str */
520 none_name_res_len, /* addr_name_res_len */
523 static address_type_t ether_address = {
524 AT_ETHER, /* addr_type */
525 "AT_ETHER", /* name */
526 "Ethernet address", /* pretty_name */
527 ether_to_str, /* addr_to_str */
528 ether_str_len, /* addr_str_len */
529 NULL, /* addr_to_byte */
530 ether_col_filter_str, /* addr_col_filter */
531 ether_len, /* addr_fixed_len */
532 ether_name_resolution_str, /* addr_name_res_str */
533 ether_name_resolution_len, /* addr_name_res_len */
536 static address_type_t ipv4_address = {
537 AT_IPv4, /* addr_type */
538 "AT_IPv4", /* name */
539 "IPv4 address", /* pretty_name */
540 ipv4_to_str, /* addr_to_str */
541 ipv4_str_len, /* addr_str_len */
542 NULL, /* addr_to_byte */
543 ipv4_col_filter_str, /* addr_col_filter */
544 ipv4_len, /* addr_fixed_len */
545 ipv4_name_res_str, /* addr_name_res_str */
546 ipv4_name_res_len, /* addr_name_res_len */
549 static address_type_t ipv6_address = {
550 AT_IPv6, /* addr_type */
551 "AT_IPv6", /* name */
552 "IPv6 address", /* pretty_name */
553 ipv6_to_str, /* addr_to_str */
554 ipv6_str_len, /* addr_str_len */
555 NULL, /* addr_to_byte */
556 ipv6_col_filter_str, /* addr_col_filter */
557 ipv6_len, /* addr_fixed_len */
558 ipv6_name_res_str, /* addr_name_res_str */
559 ipv6_name_res_len, /* addr_name_res_len */
562 static address_type_t ipx_address = {
563 AT_IPX, /* addr_type */
565 "IPX address", /* pretty_name */
566 ipx_to_str, /* addr_to_str */
567 ipx_str_len, /* addr_str_len */
568 NULL, /* addr_to_byte */
569 NULL, /* addr_col_filter */
570 ipx_len, /* addr_fixed_len */
571 NULL, /* addr_name_res_str */
572 NULL, /* addr_name_res_len */
575 static address_type_t fc_address = {
576 AT_FC, /* addr_type */
578 "FC address", /* pretty_name */
579 fc_to_str, /* addr_to_str */
580 fc_str_len, /* addr_str_len */
581 NULL, /* addr_to_byte */
582 NULL, /* addr_col_filter */
583 fc_len, /* addr_fixed_len */
584 NULL, /* addr_name_res_str */
585 NULL, /* addr_name_res_len */
588 static address_type_t fcwwn_address = {
589 AT_FCWWN, /* addr_type */
590 "AT_FCWWN", /* name */
591 "Fibre Channel WWN", /* pretty_name */
592 fcwwn_to_str, /* addr_to_str */
593 fcwwn_str_len, /* addr_str_len */
594 NULL, /* addr_to_byte */
595 NULL, /* addr_col_filter */
596 fcwwn_len, /* addr_fixed_len */
597 fcwwn_name_res_str, /* addr_name_res_str */
598 fcwwn_name_res_len, /* addr_name_res_len */
601 static address_type_t stringz_address = {
602 AT_STRINGZ, /* addr_type */
603 "AT_STRINGZ", /* name */
604 "String address", /* pretty_name */
605 stringz_addr_to_str, /* addr_to_str */
606 stringz_addr_str_len, /* addr_str_len */
607 NULL, /* addr_to_byte */
608 NULL, /* addr_col_filter */
609 NULL, /* addr_fixed_len */
610 NULL, /* addr_name_res_str */
611 NULL, /* addr_name_res_len */
614 static address_type_t eui64_address = {
615 AT_EUI64, /* addr_type */
616 "AT_EUI64", /* name */
617 "IEEE EUI-64", /* pretty_name */
618 eui64_addr_to_str, /* addr_to_str */
619 eui64_str_len, /* addr_str_len */
620 NULL, /* addr_to_byte */
621 NULL, /* addr_col_filter */
622 eui64_len, /* addr_fixed_len */
623 NULL, /* addr_name_res_str */
624 NULL, /* addr_name_res_len */
627 static address_type_t ib_address = {
628 AT_IB, /* addr_type */
630 "Infiniband GID/LID", /* pretty_name */
631 ib_addr_to_str, /* addr_to_str */
632 ib_str_len, /* addr_str_len */
633 NULL, /* addr_to_byte */
634 NULL, /* addr_col_filter */
635 NULL, /* addr_fixed_len */
636 NULL, /* addr_name_res_str */
637 NULL, /* addr_name_res_len */
640 static address_type_t ax25_address = {
641 AT_AX25, /* addr_type */
642 "AT_AX25", /* name */
643 "AX.25 Address", /* pretty_name */
644 ax25_addr_to_str, /* addr_to_str */
645 ax25_addr_str_len,/* addr_str_len */
646 NULL, /* addr_to_byte */
647 ax25_col_filter_str, /* addr_col_filter */
648 ax25_len, /* addr_fixed_len */
649 NULL, /* addr_name_res_str */
650 NULL, /* addr_name_res_len */
653 num_dissector_addr_type = 0;
655 /* Initialize the type array. This is mostly for handling
656 "dissector registered" address type range (for NULL checking) */
657 memset(type_list, 0, (MAX_ADDR_TYPE_VALUE + 1)*sizeof(address_type_t*));
659 address_type_register(AT_NONE, &none_address );
660 address_type_register(AT_ETHER, ðer_address );
661 address_type_register(AT_IPv4, &ipv4_address );
662 address_type_register(AT_IPv6, &ipv6_address );
663 address_type_register(AT_IPX, &ipx_address );
664 address_type_register(AT_FC, &fc_address );
665 address_type_register(AT_FCWWN, &fcwwn_address );
666 address_type_register(AT_STRINGZ, &stringz_address );
667 address_type_register(AT_EUI64, &eui64_address );
668 address_type_register(AT_IB, &ib_address );
669 address_type_register(AT_AX25, &ax25_address );
672 /* Given an address type id, return an address_type_t* */
673 #define ADDR_TYPE_LOOKUP(addr_type, result) \
675 g_assert(addr_type < MAX_ADDR_TYPE_VALUE); \
676 result = type_list[addr_type];
678 static int address_type_get_length(const address* addr)
682 ADDR_TYPE_LOOKUP(addr->type, at);
687 return at->addr_str_len(addr);
691 address_to_str(wmem_allocator_t *scope, const address *addr)
694 int len = address_type_get_length(addr);
697 len = MAX_ADDR_STR_LEN;
699 str=(gchar *)wmem_alloc(scope, len);
700 address_to_str_buf(addr, str, len);
704 void address_to_str_buf(const address* addr, gchar *buf, int buf_len)
708 if (!buf || !buf_len)
711 ADDR_TYPE_LOOKUP(addr->type, at);
713 if ((at == NULL) || (at->addr_to_str == NULL))
719 at->addr_to_str(addr, buf, buf_len);
723 guint address_to_bytes(const address *addr, guint8 *buf, guint buf_len)
728 if (!buf || !buf_len)
731 ADDR_TYPE_LOOKUP(addr->type, at);
736 if (at->addr_to_byte == NULL)
738 /* If a specific function isn't provided, just do a memcpy */
739 copy_len = MIN(((guint)addr->len), buf_len);
740 memcpy(buf, addr->data, copy_len);
744 copy_len = at->addr_to_byte(addr, buf, buf_len);
751 address_to_name(const address *addr)
755 ADDR_TYPE_LOOKUP(addr->type, at);
763 * XXX - addr_name_res_str is expected to return a string from
764 * a persistent database, so that it lives a long time, past
765 * the lifetime of addr itself.
767 * We'd like to avoid copying, so this is what we do here.
769 switch (addr->type) {
772 return (const gchar *)addr->data;
775 if (at->addr_name_res_str != NULL)
776 return at->addr_name_res_str(addr);
783 address_to_display(wmem_allocator_t *allocator, const address *addr)
786 const gchar *result = address_to_name(addr);
788 if (result != NULL) {
789 str = wmem_strdup(allocator, result);
791 else if (addr->type == AT_NONE) {
792 str = wmem_strdup(allocator, "NONE");
795 str = (gchar *) wmem_alloc(allocator, MAX_ADDR_STR_LEN);
796 address_to_str_buf(addr, str, MAX_ADDR_STR_LEN);
802 static void address_with_resolution_to_str_buf(const address* addr, gchar *buf, int buf_len)
809 if (!buf || !buf_len)
812 ADDR_TYPE_LOOKUP(addr->type, at);
820 #if 0 /* XXX - If this remains a static function, we've already made this check in the only
821 function that can call it. If this function becomes "public", need to put this
823 /* No name resolution support, just return address string */
824 if (at->addr_name_res_str == NULL)
825 return address_to_str_buf(addr, buf, buf_len);
828 /* Copy the resolved name */
829 pos = g_strlcpy(buf, at->addr_name_res_str(addr), buf_len);
831 /* Don't wrap "emptyness" in parentheses */
832 if (addr->type == AT_NONE)
835 /* Make sure there is enough room for the address string wrapped in parentheses */
836 if ((int)(pos + 4 + at->addr_str_len(addr)) >= buf_len)
839 empty = (pos <= 1) ? TRUE : FALSE;
847 addr_len = at->addr_to_str(addr, &buf[pos], (int)(buf_len-pos));
848 pos += addr_len - 1; /* addr_len includes the trailing '\0' */
857 gchar* address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr)
863 ADDR_TYPE_LOOKUP(addr->type, at);
866 return wmem_strdup(scope, "");
868 /* No name resolution support, just return address string */
869 if ((at->addr_name_res_str == NULL) ||
870 (ADDR_RESOLV_MACADDR(addr) && !gbl_resolv_flags.mac_name) ||
871 (ADDR_RESOLV_NETADDR(addr) && !gbl_resolv_flags.network_name)) {
872 return address_to_str(scope, addr);
875 len = at->addr_name_res_len() + at->addr_str_len(addr) + 4; /* For format of %s (%s) */
877 str=(gchar *)wmem_alloc(scope, len);
878 address_with_resolution_to_str_buf(addr, str, len);
883 const char* address_type_column_filter_string(const address* addr, gboolean src)
887 ADDR_TYPE_LOOKUP(addr->type, at);
889 if ((at == NULL) || (at->addr_col_filter == NULL))
894 return at->addr_col_filter(addr, src);
898 tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset)
903 ADDR_TYPE_LOOKUP(type, at);
910 /* The address type must have a fixed length to use this function */
911 /* For variable length fields, use tvb_address_var_to_str() */
912 if (at->addr_fixed_len == NULL)
914 g_assert_not_reached();
918 set_address_tvb(&addr, type, at->addr_fixed_len(), tvb, offset);
920 return address_to_str(scope, &addr);
923 gchar* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const gint offset, int length)
927 set_address_tvb(&addr, type, length, tvb, offset);
929 return address_to_str(scope, &addr);
933 tvb_address_with_resolution_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset)
938 ADDR_TYPE_LOOKUP(type, at);
945 /* The address type must have a fixed length to use this function */
946 /* For variable length fields, use tvb_address_var_with_resolution_to_str() */
947 if (at->addr_fixed_len == NULL)
949 g_assert_not_reached();
953 set_address_tvb(&addr, type, at->addr_fixed_len(), tvb, offset);
955 return address_with_resolution_to_str(scope, &addr);
960 * Editor modelines - http://www.wireshark.org/tools/modelines.html
965 * indent-tabs-mode: nil
968 * vi: set shiftwidth=4 tabstop=8 expandtab:
969 * :indentSize=4:tabSize=8:noTabs=true: