2 * Definitions for utilities to convert various other types to strings.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "wsutil/nstime.h"
32 #include <epan/packet_info.h>
33 #include "ws_symbol_export.h"
34 #include "wmem/wmem.h"
36 #define GUID_STR_LEN 37
37 #define MAX_IP_STR_LEN 16
38 #define MAX_IP6_STR_LEN 40
39 #define MAX_ADDR_STR_LEN 256
40 #define VINES_ADDR_LEN 6
41 #define EUI64_STR_LEN 24
45 #endif /* __cplusplus */
48 * These are utility functions which convert various types to strings,
49 * but for which no more specific module applies.
54 WS_DLL_PUBLIC gchar* address_to_str(wmem_allocator_t *scope, const address *addr);
55 WS_DLL_PUBLIC gchar* ep_address_to_str(const address *);
56 extern gchar* se_address_to_str(const address *);
57 WS_DLL_PUBLIC void address_to_str_buf(const address *addr, gchar *buf, int buf_len);
58 WS_DLL_PUBLIC const gchar* ether_to_str(const guint8 *);
59 WS_DLL_PUBLIC const gchar* tvb_ether_to_str(tvbuff_t *tvb, const gint offset);
60 extern const gchar* ax25_to_str(const guint8 *);
61 extern gchar* get_ax25_name(const guint8 *);
62 WS_DLL_PUBLIC const gchar* ip_to_str(const guint8 *);
63 WS_DLL_PUBLIC const gchar* tvb_ip_to_str(tvbuff_t *tvb, const gint offset);
64 void ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len);
65 extern const gchar* fc_to_str(const guint8 *);
66 extern gchar* fcwwn_to_str (const guint8 *);
67 WS_DLL_PUBLIC const gchar* tvb_fc_to_str(tvbuff_t *tvb, const gint offset);
68 WS_DLL_PUBLIC gchar* tvb_fcwwn_to_str (tvbuff_t *tvb, const gint offset);
69 WS_DLL_PUBLIC gchar* ip6_to_str(const struct e_in6_addr *);
70 WS_DLL_PUBLIC gchar* tvb_ip6_to_str(tvbuff_t *tvb, const gint offset);
71 void ip6_to_str_buf(const struct e_in6_addr *, gchar *);
72 extern gchar* ipx_addr_to_str(const guint32, const guint8 *);
73 extern gchar* ipxnet_to_string(const guint8 *ad);
74 extern gchar* ipxnet_to_str_punct(const guint32 ad, const char punct);
75 extern gchar* tvb_vines_addr_to_str(tvbuff_t *tvb, const gint offset);
76 WS_DLL_PUBLIC gchar* eui64_to_str(const guint64 ad);
77 WS_DLL_PUBLIC gchar* tvb_eui64_to_str(tvbuff_t *tvb, const gint offset, const guint encoding);
78 WS_DLL_PUBLIC gchar* time_secs_to_str(const gint32 time_val);
79 gchar* time_secs_to_str_unsigned(const guint32);
80 WS_DLL_PUBLIC gchar* time_msecs_to_str(gint32 time_val);
81 WS_DLL_PUBLIC gchar* abs_time_to_str(const nstime_t*, const absolute_time_display_e fmt,
83 WS_DLL_PUBLIC gchar* abs_time_secs_to_str(const time_t, const absolute_time_display_e fmt,
85 WS_DLL_PUBLIC void display_signed_time(gchar *, int, const gint32, gint32, const to_str_time_res_t);
86 WS_DLL_PUBLIC void display_epoch_time(gchar *, int, const time_t, gint32, const to_str_time_res_t);
88 extern gchar* guint32_to_str(const guint32 u);
89 extern void guint32_to_str_buf(guint32 u, gchar *buf, int buf_len);
91 WS_DLL_PUBLIC gchar* rel_time_to_str(const nstime_t*);
92 WS_DLL_PUBLIC gchar* rel_time_to_secs_str(const nstime_t*);
93 WS_DLL_PUBLIC gchar* guid_to_str(const e_guid_t*);
94 gchar* guid_to_str_buf(const e_guid_t*, gchar*, int);
96 WS_DLL_PUBLIC char *decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value);
98 WS_DLL_PUBLIC char *other_decode_bitfield_value(char *buf, const guint32 val, const guint32 mask,
100 WS_DLL_PUBLIC char *decode_bitfield_value(char *buf, const guint32 val, const guint32 mask,
102 WS_DLL_PUBLIC const char *decode_boolean_bitfield(const guint32 val, const guint32 mask, const int width,
103 const char *truedesc, const char *falsedesc);
104 WS_DLL_PUBLIC const char *decode_numeric_bitfield(const guint32 val, const guint32 mask, const int width,
107 WS_DLL_PUBLIC const gchar* port_type_to_str (port_type type);
109 /** Turn an array of bytes into a string showing the bytes in hex.
111 * @param bd A pointer to the byte array
112 * @param bd_len The length of the byte array
113 * @return A pointer to the formatted string
115 * @see bytes_to_ep_str_punct()
117 WS_DLL_PUBLIC gchar *bytes_to_ep_str(const guint8 *bd, int bd_len);
119 /** Turn an array of bytes into a string showing the bytes in hex,
120 * separated by a punctuation character.
122 * @param bd A pointer to the byte array
123 * @param bd_len The length of the byte array
124 * @param punct The punctuation character
125 * @return A pointer to the formatted string
127 * @see bytes_to_ep_str()
129 WS_DLL_PUBLIC gchar *bytes_to_ep_str_punct(const guint8 *bd, int bd_len, gchar punct);
131 WS_DLL_PUBLIC const gchar *bytestring_to_ep_str(const guint8 *, const guint32, const char punct);
135 #endif /* __cplusplus */
137 #endif /* __TO_STR_H__ */