Wireshark  4.3.0
The Wireshark network protocol analyzer
to_str.h
Go to the documentation of this file.
1 
11 #ifndef __TO_STR_H__
12 #define __TO_STR_H__
13 
14 #include <glib.h>
15 
16 #include "wsutil/nstime.h"
17 #include <wsutil/inet_cidr.h>
18 #include <epan/proto.h>
19 #include <epan/packet_info.h>
20 #include "ws_symbol_export.h"
21 #include <epan/wmem_scopes.h>
22 #include <wsutil/to_str.h>
23 
24 #define GUID_STR_LEN 37
25 #define MAX_ADDR_STR_LEN 256
26 #define VINES_ADDR_LEN 6
27 #define EUI64_STR_LEN 24
28 #define AX25_ADDR_LEN 7
29 #define FCWWN_ADDR_LEN 8
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35 
36 /*
37  * These are utility functions which convert various types to strings,
38  * but for which no more specific module applies.
39  */
40 
41 /*
42  ************** Address
43  */
44 
45 WS_DLL_PUBLIC gchar *address_to_str(wmem_allocator_t *scope, const address *addr);
46 
47 WS_DLL_PUBLIC gchar *address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr);
48 
49 /*
50  * address_to_name takes as input an "address", as defined in address.h.
51  *
52  * If the address is of a type that can be translated into a name, and the
53  * user has activated name resolution, and the name can be resolved, it
54  * returns a string containing the translated name.
55  *
56  * Otherwise, it returns NULL.
57  */
58 WS_DLL_PUBLIC const gchar *address_to_name(const address *addr);
59 
60 /*
61  * address_to_display takes as input an "address", as defined in address.h .
62  *
63  * If the address is of a type that can be translated into a name, and the
64  * user has activated name resolution, and the name can be resolved, it
65  * returns a string containing the translated name.
66  *
67  * Otherwise, if the address is of type AT_NONE, it returns "NONE".
68  *
69  * Otherwise, it returns a string containing the result of address_to_str
70  * on the argument, which should be a string representation for the address,
71  * e.g. "10.10.10.10" for IPv4 address 10.10.10.10.
72  */
73 WS_DLL_PUBLIC gchar *address_to_display(wmem_allocator_t *allocator, const address *addr);
74 
75 WS_DLL_PUBLIC void address_to_str_buf(const address *addr, gchar *buf, int buf_len);
76 
77 WS_DLL_PUBLIC const gchar *port_type_to_str (port_type type);
78 
79 /*
80  ************** TVB
81  */
82 
83 WS_DLL_PUBLIC gchar* tvb_address_with_resolution_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset);
84 
85 #define tvb_ether_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_ETHER, offset)
86 
87 #define tvb_ip_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_IPv4, offset)
88 
89 #define tvb_ip6_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_IPv6, offset)
90 
91 #define tvb_fcwwn_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_FCWWN, offset)
92 
93 #define tvb_fc_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_FC, offset)
94 
95 #define tvb_eui64_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_EUI64, offset)
96 
106 WS_DLL_PUBLIC gchar* tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset);
107 
118 WS_DLL_PUBLIC gchar* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const gint offset, int length);
119 
120 /*
121  ************** Time
122  */
123 
124 #define ABS_TIME_TO_STR_SHOW_ZONE (1U << 0)
125 #define ABS_TIME_TO_STR_ADD_DQUOTES (1U << 1)
126 #define ABS_TIME_TO_STR_SHOW_UTC_ONLY (1U << 2)
127 
128 WS_DLL_PUBLIC char *abs_time_to_str_ex(wmem_allocator_t *scope,
129  const nstime_t *, field_display_e fmt,
130  int flags);
131 
132 #define abs_time_to_str(scope, nst, fmt, show_zone) \
133  abs_time_to_str_ex(scope, nst, fmt, (show_zone) ? ABS_TIME_TO_STR_SHOW_ZONE : 0)
134 
135 gchar *
136 abs_time_to_unix_str(wmem_allocator_t *scope, const nstime_t *rel_time);
137 
138 WS_DLL_PUBLIC char *abs_time_secs_to_str_ex(wmem_allocator_t *scope,
139  const time_t, field_display_e fmt,
140  int flags);
141 
142 #define abs_time_secs_to_str(scope, nst, fmt, show_zone) \
143  abs_time_secs_to_str_ex(scope, nst, fmt, (show_zone) ? ABS_TIME_TO_STR_SHOW_ZONE : 0)
144 
145 WS_DLL_PUBLIC gchar *signed_time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val);
146 
147 WS_DLL_PUBLIC gchar *unsigned_time_secs_to_str(wmem_allocator_t *scope, const guint32);
148 
149 WS_DLL_PUBLIC gchar *signed_time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val);
150 
151 WS_DLL_PUBLIC gchar *rel_time_to_str(wmem_allocator_t *scope, const nstime_t *);
152 
153 WS_DLL_PUBLIC gchar *rel_time_to_secs_str(wmem_allocator_t *scope, const nstime_t *);
154 
155 /*
156  ************** Misc
157  */
158 
159 WS_DLL_PUBLIC gchar *guid_to_str_buf(const e_guid_t *, gchar *, int);
160 
161 WS_DLL_PUBLIC gchar *guid_to_str(wmem_allocator_t *scope, const e_guid_t *);
162 
163 WS_DLL_PUBLIC char *decode_bits_in_field(wmem_allocator_t *scope, const guint bit_offset, const gint no_of_bits, const guint64 value, const guint encoding);
164 
165 #ifdef __cplusplus
166 }
167 #endif /* __cplusplus */
168 
169 #endif /* __TO_STR_H__ */
WS_DLL_PUBLIC gchar * tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint offset)
Definition: address_types.c:1077
WS_DLL_PUBLIC gchar * tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const gint offset, int length)
Definition: address_types.c:1102
field_display_e
Definition: proto.h:685
Definition: address.h:56
Definition: guid-utils.h:22
Definition: wmem_allocator.h:27
Definition: nstime.h:26
Definition: tvbuff-int.h:35