2001-04-01 02:47:56 +00:00
|
|
|
/* to_str.h
|
|
|
|
* Definitions for utilities to convert various other types to strings.
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-04-01 02:47:56 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-04-01 02:47:56 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-04-01 02:47:56 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-04-01 02:47:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2001-04-01 02:47:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TO_STR_H__
|
|
|
|
#define __TO_STR_H__
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
#include <glib.h>
|
2001-04-01 02:47:56 +00:00
|
|
|
|
2013-06-25 22:02:20 +00:00
|
|
|
#include "wsutil/nstime.h"
|
2010-02-27 19:01:27 +00:00
|
|
|
#include "time_fmt.h"
|
2009-08-21 20:51:13 +00:00
|
|
|
#include <epan/packet_info.h>
|
2013-03-01 23:53:11 +00:00
|
|
|
#include "ws_symbol_export.h"
|
2013-11-23 22:17:27 +00:00
|
|
|
#include "wmem/wmem.h"
|
2001-09-14 07:10:13 +00:00
|
|
|
|
2014-12-24 05:06:35 +00:00
|
|
|
#define GUID_STR_LEN 37
|
|
|
|
#define MAX_IP_STR_LEN 16
|
|
|
|
#define MAX_IP6_STR_LEN 40
|
2007-01-29 20:25:26 +00:00
|
|
|
#define MAX_ADDR_STR_LEN 256
|
2014-12-24 05:06:35 +00:00
|
|
|
#define VINES_ADDR_LEN 6
|
|
|
|
#define EUI64_STR_LEN 24
|
|
|
|
#define AX25_ADDR_LEN 7
|
|
|
|
#define FCWWN_ADDR_LEN 8
|
2005-04-28 09:51:55 +00:00
|
|
|
|
2013-08-30 21:15:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
2001-04-01 02:47:56 +00:00
|
|
|
* These are utility functions which convert various types to strings,
|
2002-08-28 20:41:00 +00:00
|
|
|
* but for which no more specific module applies.
|
2001-04-01 02:47:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct e_in6_addr;
|
2002-12-08 02:32:36 +00:00
|
|
|
|
2013-11-23 22:17:27 +00:00
|
|
|
WS_DLL_PUBLIC gchar* address_to_str(wmem_allocator_t *scope, const address *addr);
|
2015-02-12 17:03:49 +00:00
|
|
|
WS_DLL_PUBLIC gchar* address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr);
|
2015-01-06 00:26:28 +00:00
|
|
|
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC void address_to_str_buf(const address *addr, gchar *buf, int buf_len);
|
2015-01-06 00:26:28 +00:00
|
|
|
|
|
|
|
#define tvb_ether_to_str(tvb, offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_ETHER, offset)
|
|
|
|
#define tvb_ip_to_str(tvb, offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_IPv4, offset)
|
|
|
|
#define tvb_ip6_to_str(tvb, offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_IPv6, offset)
|
|
|
|
#define tvb_fcwwn_to_str(tvb, offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_FCWWN, offset)
|
|
|
|
#define tvb_fc_to_str(tvb, offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_FC, offset)
|
|
|
|
#define tvb_eui64_to_str(tvb, opt_offset) tvb_address_to_str(wmem_packet_scope(), tvb, AT_EUI64, offset)
|
|
|
|
|
2013-03-01 23:53:11 +00:00
|
|
|
void ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len);
|
2014-01-30 17:43:52 +00:00
|
|
|
|
2013-03-01 23:53:11 +00:00
|
|
|
void ip6_to_str_buf(const struct e_in6_addr *, gchar *);
|
2015-01-08 17:13:18 +00:00
|
|
|
extern gchar* ipxnet_to_str_punct(wmem_allocator_t *scope, const guint32 ad, const char punct);
|
2015-01-08 18:16:01 +00:00
|
|
|
WS_DLL_PUBLIC gchar* eui64_to_str(wmem_allocator_t *scope, const guint64 ad);
|
2015-01-08 16:54:36 +00:00
|
|
|
|
2014-06-16 06:42:14 +00:00
|
|
|
WS_DLL_PUBLIC gchar* time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val);
|
2014-06-16 17:54:20 +00:00
|
|
|
gchar* time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32);
|
2014-06-16 06:42:14 +00:00
|
|
|
WS_DLL_PUBLIC gchar* time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val);
|
|
|
|
WS_DLL_PUBLIC gchar* abs_time_to_str(wmem_allocator_t *scope, const nstime_t*, const absolute_time_display_e fmt,
|
2010-05-21 06:33:25 +00:00
|
|
|
gboolean show_zone);
|
2014-06-16 06:42:14 +00:00
|
|
|
WS_DLL_PUBLIC gchar* abs_time_secs_to_str(wmem_allocator_t *scope, const time_t, const absolute_time_display_e fmt,
|
2010-05-21 06:33:25 +00:00
|
|
|
gboolean show_zone);
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC void display_signed_time(gchar *, int, const gint32, gint32, const to_str_time_res_t);
|
|
|
|
WS_DLL_PUBLIC void display_epoch_time(gchar *, int, const time_t, gint32, const to_str_time_res_t);
|
2006-12-05 03:19:51 +00:00
|
|
|
|
2010-02-23 19:28:38 +00:00
|
|
|
extern void guint32_to_str_buf(guint32 u, gchar *buf, int buf_len);
|
2014-12-17 20:19:20 +00:00
|
|
|
extern void guint64_to_str_buf(guint64 u, gchar *buf, int buf_len);
|
2010-02-23 19:28:38 +00:00
|
|
|
|
2014-06-16 06:42:14 +00:00
|
|
|
WS_DLL_PUBLIC gchar* rel_time_to_str(wmem_allocator_t *scope, const nstime_t*);
|
2014-06-16 17:54:20 +00:00
|
|
|
WS_DLL_PUBLIC gchar* rel_time_to_secs_str(wmem_allocator_t *scope, const nstime_t*);
|
2015-01-08 00:24:52 +00:00
|
|
|
WS_DLL_PUBLIC gchar* guid_to_str(wmem_allocator_t *scope, const e_guid_t*);
|
2013-03-01 23:53:11 +00:00
|
|
|
gchar* guid_to_str_buf(const e_guid_t*, gchar*, int);
|
2001-04-01 02:47:56 +00:00
|
|
|
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC char *decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value);
|
2009-05-15 18:38:13 +00:00
|
|
|
|
2014-09-17 16:39:22 +00:00
|
|
|
WS_DLL_PUBLIC char *other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask,
|
2010-04-03 18:18:50 +00:00
|
|
|
const int width);
|
2014-09-17 16:39:22 +00:00
|
|
|
WS_DLL_PUBLIC char *decode_bitfield_value(char *buf, const guint64 val, const guint64 mask,
|
2010-04-03 18:18:50 +00:00
|
|
|
const int width);
|
2001-04-01 02:47:56 +00:00
|
|
|
|
2013-06-17 21:54:21 +00:00
|
|
|
WS_DLL_PUBLIC const gchar* port_type_to_str (port_type type);
|
|
|
|
|
2015-01-06 00:26:28 +00:00
|
|
|
/** Turn an address type retrieved from a tvb into a string.
|
|
|
|
*
|
|
|
|
* @param scope memory allocation scheme used
|
|
|
|
* @param tvb tvbuff to retrieve address
|
|
|
|
* @param type address type to retrieve
|
|
|
|
* @param offset offset into tvb to retrieve address
|
|
|
|
* @return A pointer to the formatted string
|
|
|
|
*
|
|
|
|
*/
|
2015-02-09 01:36:03 +00:00
|
|
|
WS_DLL_PUBLIC gchar* tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset);
|
2015-01-06 00:26:28 +00:00
|
|
|
|
|
|
|
/** Turn an address type retrieved from a tvb into a string.
|
|
|
|
*
|
|
|
|
* @param scope memory allocation scheme used
|
|
|
|
* @param tvb tvbuff to retrieve address
|
|
|
|
* @param type address type to retrieve
|
|
|
|
* @param offset offset into tvb to retrieve address
|
|
|
|
* @return A pointer to the formatted string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC gchar* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const gint offset, int length);
|
|
|
|
|
2013-11-10 09:44:02 +00:00
|
|
|
/** Turn an array of bytes into a string showing the bytes in hex.
|
|
|
|
*
|
2015-01-07 23:13:23 +00:00
|
|
|
* @param scope memory allocation scheme used
|
2013-11-10 09:44:02 +00:00
|
|
|
* @param bd A pointer to the byte array
|
|
|
|
* @param bd_len The length of the byte array
|
|
|
|
* @return A pointer to the formatted string
|
|
|
|
*/
|
2015-01-10 15:26:55 +00:00
|
|
|
WS_DLL_PUBLIC char *bytes_to_str(wmem_allocator_t *scope, const guint8 *bd, int bd_len);
|
2014-12-29 05:21:15 +00:00
|
|
|
|
2013-11-10 09:44:02 +00:00
|
|
|
/** Turn an array of bytes into a string showing the bytes in hex,
|
|
|
|
* separated by a punctuation character.
|
|
|
|
*
|
2015-01-07 14:36:06 +00:00
|
|
|
* @param scope memory allocation scheme used
|
|
|
|
* @param ad A pointer to the byte array
|
|
|
|
* @param len The length of the byte array
|
2013-11-10 09:44:02 +00:00
|
|
|
* @param punct The punctuation character
|
|
|
|
* @return A pointer to the formatted string
|
|
|
|
*
|
2015-01-07 14:36:06 +00:00
|
|
|
* @see bytes_to_str()
|
2013-11-10 09:44:02 +00:00
|
|
|
*/
|
2013-12-19 20:53:44 +00:00
|
|
|
WS_DLL_PUBLIC const gchar *bytestring_to_str(wmem_allocator_t *scope, const guint8 *ad, const guint32 len, const char punct);
|
|
|
|
|
2013-08-30 21:15:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2001-04-01 02:47:56 +00:00
|
|
|
#endif /* __TO_STR_H__ */
|