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