| Wireshark 4.7.0 The Wireshark network protocol analyzer

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