| Wireshark 4.7.3 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
29 extern "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
199 char *
200 abs_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 int64_t time_val);
226
234WS_DLL_PUBLIC char *unsigned_time_secs_to_str(wmem_allocator_t *scope, const uint64_t time_val);
235
243WS_DLL_PUBLIC char *signed_time_msecs_to_str(wmem_allocator_t *scope, int64_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
address_type
Identifies the type of a network layer or link layer address.
Definition address.h:37
address
struct _address address
Holds a network or link-layer address of any supported type.
port_type
port_type
Transport-layer port number types recognized by Wireshark.
Definition address.h:425
rel_time_to_str
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:479
rel_time_to_secs_str
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:530
address_to_str_buf
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
signed_time_msecs_to_str
WS_DLL_PUBLIC char * signed_time_msecs_to_str(wmem_allocator_t *scope, int64_t time_val)
Convert a signed time value in milliseconds to a string.
Definition to_str.c:446
port_type_to_str
WS_DLL_PUBLIC const char * port_type_to_str(port_type type)
Converts a port type to its string representation.
Definition to_str.c:657
tvb_address_with_resolution_to_str
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
abs_time_to_unix_str
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:541
abs_time_secs_to_str_ex
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
abs_time_to_str_ex
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
decode_bits_in_field
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:558
address_to_str
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
address_with_resolution_to_str
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
tvb_address_to_str
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
unsigned_time_secs_to_str
WS_DLL_PUBLIC char * unsigned_time_secs_to_str(wmem_allocator_t *scope, const uint64_t time_val)
Convert an unsigned value in seconds to a string.
Definition to_str.c:376
tvb_address_var_to_str
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
guid_to_str
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:623
address_to_display
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
signed_time_secs_to_str
WS_DLL_PUBLIC char * signed_time_secs_to_str(wmem_allocator_t *scope, const int64_t time_val)
Convert a signed value in seconds to a string.
Definition to_str.c:426
address_to_name
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
guid_to_str_buf
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:632
field_display_e
field_display_e
Enum for specifying the display format of a field.
Definition proto.h:686
wmem_allocator_t
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
e_guid_t
struct _e_guid_t e_guid_t
Represents a GUID/UUID value; may be larger than GUID_LEN so must not be used to directly overlay pac...
inet_cidr.h
nstime.h
packet_info.h
proto.h
nstime_t
Definition nstime.h:26
wmem_scopes.h
to_str.h