Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
to_str.h
Go to the documentation of this file.
1
10#pragma once
11#include "wsutil/nstime.h"
12#include <wsutil/inet_cidr.h>
13#include <epan/proto.h>
14#include <epan/packet_info.h>
15#include "ws_symbol_export.h"
16#include <epan/wmem_scopes.h>
17#include <wsutil/to_str.h>
18
19#define GUID_STR_LEN 37
20#define MAX_ADDR_STR_LEN 256
21#define VINES_ADDR_LEN 6
22#define EUI64_STR_LEN 24
23#define EUI64_ADDR_LEN 8
24#define AX25_ADDR_LEN 7
25#define FCWWN_ADDR_LEN 8
26
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
32/*
33 * These are utility functions which convert various types to strings,
34 * but for which no more specific module applies.
35 */
36
37/*
38 ************** Address
39 */
40
47WS_DLL_PUBLIC char *address_to_str(wmem_allocator_t *scope, const address *addr);
48
56WS_DLL_PUBLIC char *address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr);
57
72WS_DLL_PUBLIC const char *address_to_name(const address *addr);
73
93WS_DLL_PUBLIC char *address_to_display(wmem_allocator_t *allocator, const address *addr);
94
102WS_DLL_PUBLIC void address_to_str_buf(const address *addr, char *buf, int buf_len);
103
110WS_DLL_PUBLIC const char *port_type_to_str (port_type type);
111
112/*
113 ************** TVB
114 */
115
125WS_DLL_PUBLIC char* tvb_address_with_resolution_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const unsigned offset);
126
127#define tvb_ether_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_ETHER, offset)
128
129#define tvb_ip_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_IPv4, offset)
130
131#define tvb_ip6_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_IPv6, offset)
132
133#define tvb_fcwwn_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_FCWWN, offset)
134
135#define tvb_fc_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_FC, offset)
136
137/* Note this assumes that the address is in network byte order, but
138 * IEEE 802.15.4 puts EUI-64 addresses in reverse (Little Endian) order.
139 */
140#define tvb_eui64_to_str(scope, tvb, offset) tvb_address_to_str(scope, tvb, AT_EUI64, offset)
141
151WS_DLL_PUBLIC char* tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const unsigned offset);
152
163WS_DLL_PUBLIC char* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const unsigned offset, unsigned length);
164
165/*
166 ************** Time
167 */
168
169#define ABS_TIME_TO_STR_SHOW_ZONE (1U << 0)
170#define ABS_TIME_TO_STR_ADD_DQUOTES (1U << 1)
171#define ABS_TIME_TO_STR_SHOW_UTC_ONLY (1U << 2)
172#define ABS_TIME_TO_STR_ISO8601 (1U << 3)
173
185WS_DLL_PUBLIC char *abs_time_to_str_ex(wmem_allocator_t *scope,
186 const nstime_t * abs_time, field_display_e fmt,
187 int flags);
188
189#define abs_time_to_str(scope, nst, fmt, show_zone) \
190 abs_time_to_str_ex(scope, nst, fmt, (show_zone) ? ABS_TIME_TO_STR_SHOW_ZONE : 0)
191
199char *
200abs_time_to_unix_str(wmem_allocator_t *scope, const nstime_t *rel_time);
201
211WS_DLL_PUBLIC char *abs_time_secs_to_str_ex(wmem_allocator_t *scope,
212 const time_t abs_time_secs, field_display_e fmt,
213 int flags);
214
215#define abs_time_secs_to_str(scope, nst, fmt, show_zone) \
216 abs_time_secs_to_str_ex(scope, nst, fmt, (show_zone) ? ABS_TIME_TO_STR_SHOW_ZONE : 0)
217
225WS_DLL_PUBLIC char *signed_time_secs_to_str(wmem_allocator_t *scope, const int32_t time_val);
226
234WS_DLL_PUBLIC char *unsigned_time_secs_to_str(wmem_allocator_t *scope, const uint32_t time_val);
235
243WS_DLL_PUBLIC char *signed_time_msecs_to_str(wmem_allocator_t *scope, int32_t time_val);
244
252WS_DLL_PUBLIC char *rel_time_to_str(wmem_allocator_t *scope, const nstime_t *rel_time);
253
261WS_DLL_PUBLIC char *rel_time_to_secs_str(wmem_allocator_t *scope, const nstime_t *rel_time);
262
263/*
264 ************** Misc
265 */
266
274WS_DLL_PUBLIC char *guid_to_str_buf(const e_guid_t *guid, char *buf, int buf_len);
275
283WS_DLL_PUBLIC char *guid_to_str(wmem_allocator_t *scope, const e_guid_t *guid);
284
295WS_DLL_PUBLIC char *decode_bits_in_field(wmem_allocator_t *scope, const unsigned bit_offset, const int no_of_bits, const uint64_t value, const unsigned encoding);
296
297#ifdef __cplusplus
298}
299#endif /* __cplusplus */
address_type
Identifies the type of a network layer or link layer address.
Definition address.h:37
port_type
Transport-layer port number types recognized by Wireshark.
Definition address.h:425
WS_DLL_PUBLIC char * rel_time_to_str(wmem_allocator_t *scope, const nstime_t *rel_time)
Convert a relative time to a string representation.
Definition to_str.c:480
WS_DLL_PUBLIC char * rel_time_to_secs_str(wmem_allocator_t *scope, const nstime_t *rel_time)
Converts a relative time to a string representation in seconds.
Definition to_str.c:531
WS_DLL_PUBLIC void address_to_str_buf(const address *addr, char *buf, int buf_len)
Convert an address to a string buffer.
Definition address_types.c:970
WS_DLL_PUBLIC char * signed_time_secs_to_str(wmem_allocator_t *scope, const int32_t time_val)
Convert a signed value in seconds to a string.
Definition to_str.c:430
WS_DLL_PUBLIC const char * port_type_to_str(port_type type)
Converts a port type to its string representation.
Definition to_str.c:658
WS_DLL_PUBLIC char * tvb_address_with_resolution_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const unsigned offset)
Converts a TVB address to a string with resolution.
Definition address_types.c:1231
char * abs_time_to_unix_str(wmem_allocator_t *scope, const nstime_t *rel_time)
Converts an absolute time to a Unix timestamp string.
Definition to_str.c:542
WS_DLL_PUBLIC char * abs_time_secs_to_str_ex(wmem_allocator_t *scope, const time_t abs_time_secs, field_display_e fmt, int flags)
Convert an absolute time in seconds to a string representation.
Definition to_str.c:298
WS_DLL_PUBLIC char * abs_time_to_str_ex(wmem_allocator_t *scope, const nstime_t *abs_time, field_display_e fmt, int flags)
Convert an absolute time to a string representation.
Definition to_str.c:236
WS_DLL_PUBLIC char * decode_bits_in_field(wmem_allocator_t *scope, const unsigned bit_offset, const int no_of_bits, const uint64_t value, const unsigned encoding)
Decodes bits from a given offset and number of bits in a value.
Definition to_str.c:559
WS_DLL_PUBLIC char * address_to_str(wmem_allocator_t *scope, const address *addr)
Converts an address to a string.
Definition address_types.c:957
WS_DLL_PUBLIC char * address_with_resolution_to_str(wmem_allocator_t *scope, const address *addr)
Converts an address to a string with name resolution if possible.
Definition address_types.c:1155
WS_DLL_PUBLIC char * tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const unsigned offset)
Definition address_types.c:1196
WS_DLL_PUBLIC char * signed_time_msecs_to_str(wmem_allocator_t *scope, int32_t time_val)
Convert a signed time value in milliseconds to a string.
Definition to_str.c:450
WS_DLL_PUBLIC char * tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const unsigned offset, unsigned length)
Definition address_types.c:1221
WS_DLL_PUBLIC char * guid_to_str(wmem_allocator_t *scope, const e_guid_t *guid)
Convert a GUID to a string.
Definition to_str.c:624
WS_DLL_PUBLIC char * address_to_display(wmem_allocator_t *allocator, const address *addr)
Converts an address to a string representation to be displayed.
Definition address_types.c:1051
WS_DLL_PUBLIC const char * address_to_name(const address *addr)
Converts an address to a name string if possible.
Definition address_types.c:1017
WS_DLL_PUBLIC char * unsigned_time_secs_to_str(wmem_allocator_t *scope, const uint32_t time_val)
Convert an unsigned value in seconds to a string.
Definition to_str.c:376
WS_DLL_PUBLIC char * guid_to_str_buf(const e_guid_t *guid, char *buf, int buf_len)
Convert a GUID to a string buffer.
Definition to_str.c:633
field_display_e
Enum for specifying the display format of a field.
Definition proto.h:681
Holds a network or link-layer address of any supported type.
Definition address.h:62
Represents a GUID/UUID value; may be larger than GUID_LEN so must not be used to directly overlay pac...
Definition guid-utils.h:21
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition nstime.h:26
Core tvbuff (testy virtual buffer) structure representing a region of packet data,...
Definition tvbuff-int.h:95