| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
to_str.h
Go to the documentation of this file.
1
12#ifndef __WSUTIL_TO_STR_H__
13#define __WSUTIL_TO_STR_H__
14
15#include <wireshark.h>
16
17#include <wsutil/wmem/wmem.h>
18#include <wsutil/inet_addr.h>
19#include <wsutil/nstime.h>
20
21#ifdef __cplusplus
22 extern "C" {
23#endif /* __cplusplus */
24
34WS_DLL_PUBLIC char *uint8_to_hex(char *out, uint8_t val);
35
36WS_DEPRECATED_X("Use uint8_to_hex instead")
37static inline char *guint8_to_hex(char *out, uint8_t val) { return uint8_to_hex(out, val); }
38
50WS_DLL_PUBLIC char *word_to_hex(char *out, uint16_t word);
51
65WS_DLL_PUBLIC char *word_to_hex_punct(char *out, uint16_t word, char punct);
66
78WS_DLL_PUBLIC char *word_to_hex_npad(char *out, uint16_t word);
79
91WS_DLL_PUBLIC char *dword_to_hex(char *out, uint32_t dword);
92
106WS_DLL_PUBLIC char *dword_to_hex_punct(char *out, uint32_t dword, char punct);
107
119WS_DLL_PUBLIC char *qword_to_hex(char *out, uint64_t qword);
120
134WS_DLL_PUBLIC char *qword_to_hex_punct(char *out, uint64_t qword, char punct);
135
148WS_DLL_PUBLIC char *bytes_to_hexstr(char *out, const uint8_t *ad, size_t len);
149
166WS_DLL_PUBLIC char *bytes_to_hexstr_punct(char *out, const uint8_t *ad, size_t len, char punct);
167
179WS_DLL_PUBLIC char *bytes_to_str_punct_maxlen(wmem_allocator_t *scope,
180 const uint8_t *buf, size_t buf_size,
181 char punct, size_t max_bytes_len);
182
183#define bytes_to_str_punct(scope, buf, buf_size, punct) \
184 bytes_to_str_punct_maxlen(scope, buf, buf_size, punct, 24)
185
195WS_DLL_PUBLIC char *bytes_to_str_maxlen(wmem_allocator_t *scope,
196 const uint8_t *buf, size_t buf_size,
197 size_t max_bytes_len);
198
199#define bytes_to_str(scope, buf, buf_size) \
200 bytes_to_str_maxlen(scope, buf, buf_size, 36)
201
213WS_DLL_PUBLIC char *oct_to_str_back(char *ptr, uint32_t value);
214
226WS_DLL_PUBLIC char *oct64_to_str_back(char *ptr, uint64_t value);
227
241WS_DLL_PUBLIC char *hex_to_str_back_len(char *ptr, uint32_t value, int len);
242
256WS_DLL_PUBLIC char *hex64_to_str_back_len(char *ptr, uint64_t value, int len);
257
269WS_DLL_PUBLIC char *uint_to_str_back(char *ptr, uint32_t value);
270
282WS_DLL_PUBLIC char *uint64_to_str_back(char *ptr, uint64_t value);
283
297WS_DLL_PUBLIC char *uint_to_str_back_len(char *ptr, uint32_t value, int len);
298
312WS_DLL_PUBLIC char *uint64_to_str_back_len(char *ptr, uint64_t value, int len);
313
326WS_DLL_PUBLIC char *int_to_str_back(char *ptr, int32_t value);
327
340WS_DLL_PUBLIC char *int64_to_str_back(char *ptr, int64_t value);
341
352WS_DLL_PUBLIC void uint32_to_str_buf(uint32_t u, char *buf, size_t buf_len);
353
354WS_DEPRECATED_X("Use uint32_to_str_buf instead")
355static inline void guint32_to_str_buf(uint32_t u, char *buf, size_t buf_len) { uint32_to_str_buf(u, buf, buf_len); }
356
368WS_DLL_PUBLIC void uint64_to_str_buf(uint64_t u, char *buf, size_t buf_len);
369
370WS_DEPRECATED_X("Use uint64_to_str_buf instead")
371static inline void guint64_to_str_buf(uint64_t u, char *buf, size_t buf_len) { uint64_to_str_buf(u, buf, buf_len); }
372
373WS_DEPRECATED_X("Use ip_num_to_str_buf() or ip_addr_to_str() instead")
374WS_DLL_PUBLIC void ip_to_str_buf(const uint8_t *ad, char *buf, const int buf_len);
375
376WS_DEPRECATED_X("Use ip_num_to_str() or ip_addr_to_str() instead")
377WS_DLL_PUBLIC char *ip_to_str(wmem_allocator_t *scope, const uint8_t *ad);
378
389WS_DLL_PUBLIC void ip_num_to_str_buf(uint32_t ad, char *buf, const int buf_len);
390
401WS_DLL_PUBLIC char *ip_num_to_str(wmem_allocator_t *scope, uint32_t ad);
402
412WS_DLL_PUBLIC void ip_addr_to_str_buf(const ws_in4_addr *ad, char *buf, const int buf_len);
413
423WS_DLL_PUBLIC char *ip_addr_to_str(wmem_allocator_t *scope, const ws_in4_addr *ad);
424
434WS_DLL_PUBLIC void ip6_to_str_buf(const ws_in6_addr *ad, char *buf, size_t buf_size);
435
445WS_DLL_PUBLIC char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad);
446
458WS_DLL_PUBLIC char *ipxnet_to_str_punct(wmem_allocator_t *scope, const uint32_t ad, const char punct);
459
470WS_DLL_PUBLIC char *eui64_to_str(wmem_allocator_t *scope, const uint64_t ad);
471
484WS_DLL_PUBLIC int format_fractional_part_nsecs(char *buf, size_t buflen, uint32_t nsecs, const char *decimal_point, int precision);
485
496WS_DLL_PUBLIC void display_epoch_time(char *buf, size_t buflen, const nstime_t *ns, int precision);
497
508WS_DLL_PUBLIC void display_signed_time(char *buf, size_t buf_size, const nstime_t *nstime, int precision);
509
522WS_DLL_PUBLIC void format_nstime_as_iso8601(char *buf, size_t buf_size, const nstime_t *nstime, char *frac_buf, bool include_tz, int precision);
523
524#ifdef __cplusplus
525}
526#endif /* __cplusplus */
527
528#endif /* __TO_STR_H__ */
inet_addr.h
ws_in4_addr
uint32_t ws_in4_addr
Represents a 32-bit IPv4 address in network byte order.
Definition inet_addr.h:22
nstime.h
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
e_in6_addr
Represents a 128-bit IPv6 address.
Definition inet_addr.h:27
nstime_t
Definition nstime.h:26
wmem.h
word_to_hex_punct
WS_DLL_PUBLIC char * word_to_hex_punct(char *out, uint16_t word, char punct)
Converts a 16-bit word to a hexadecimal string with byte-level punctuation.
Definition to_str.c:112
bytes_to_str_maxlen
WS_DLL_PUBLIC char * bytes_to_str_maxlen(wmem_allocator_t *scope, const uint8_t *buf, size_t buf_size, size_t max_bytes_len)
Turn an array of bytes into a string showing the bytes in hex.
Definition to_str.c:263
bytes_to_hexstr
WS_DLL_PUBLIC char * bytes_to_hexstr(char *out, const uint8_t *ad, size_t len)
Converts a byte array to a hexadecimal string.
Definition to_str.c:176
hex64_to_str_back_len
WS_DLL_PUBLIC char * hex64_to_str_back_len(char *ptr, uint64_t value, int len)
Converts a 64-bit unsigned integer to hex string in reverse with fixed length.
Definition to_str.c:351
hex_to_str_back_len
WS_DLL_PUBLIC char * hex_to_str_back_len(char *ptr, uint32_t value, int len)
Converts a 32-bit unsigned integer to hex string in reverse with fixed length.
Definition to_str.c:330
word_to_hex_npad
WS_DLL_PUBLIC char * word_to_hex_npad(char *out, uint16_t word)
Converts a 16-bit word to a hexadecimal string without padding.
Definition to_str.c:121
format_fractional_part_nsecs
WS_DLL_PUBLIC int format_fractional_part_nsecs(char *buf, size_t buflen, uint32_t nsecs, const char *decimal_point, int precision)
Formats the fractional part of a timestamp in nanoseconds.
Definition to_str.c:700
ip_addr_to_str
WS_DLL_PUBLIC char * ip_addr_to_str(wmem_allocator_t *scope, const ws_in4_addr *ad)
Converts a ws_in4_addr structure to a string using memory scope.
Definition to_str.c:600
uint32_to_str_buf
WS_DLL_PUBLIC void uint32_to_str_buf(uint32_t u, char *buf, size_t buf_len)
Converts a 32-bit unsigned integer to a decimal string.
Definition to_str.c:502
bytes_to_str_punct_maxlen
WS_DLL_PUBLIC char * bytes_to_str_punct_maxlen(wmem_allocator_t *scope, const uint8_t *buf, size_t buf_size, char punct, size_t max_bytes_len)
Turn an array of bytes into a string showing the bytes in hex, separated by a punctuation character.
Definition to_str.c:218
uint64_to_str_buf
WS_DLL_PUBLIC void uint64_to_str_buf(uint64_t u, char *buf, size_t buf_len)
Converts a 64-bit unsigned integer to a decimal string.
Definition to_str.c:544
qword_to_hex_punct
WS_DLL_PUBLIC char * qword_to_hex_punct(char *out, uint64_t qword, char punct)
Converts a 64-bit word to a hexadecimal string with punctuation.
Definition to_str.c:159
bytes_to_hexstr_punct
WS_DLL_PUBLIC char * bytes_to_hexstr_punct(char *out, const uint8_t *ad, size_t len, char punct)
Converts a byte array to a hexadecimal string with punctuation.
Definition to_str.c:196
oct64_to_str_back
WS_DLL_PUBLIC char * oct64_to_str_back(char *ptr, uint64_t value)
Converts a 64-bit unsigned integer to octal string in reverse.
Definition to_str.c:318
ip6_to_str
WS_DLL_PUBLIC char * ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad)
Converts a ws_in6_addr structure to a string using memory scope.
Definition to_str.c:647
qword_to_hex
WS_DLL_PUBLIC char * qword_to_hex(char *out, uint64_t qword)
Converts a 64-bit word to a fixed-width hexadecimal string.
Definition to_str.c:151
format_nstime_as_iso8601
WS_DLL_PUBLIC void format_nstime_as_iso8601(char *buf, size_t buf_size, const nstime_t *nstime, char *frac_buf, bool include_tz, int precision)
Formats an nstime_t value as an ISO 8601 timestamp.
Definition to_str.c:965
uint64_to_str_back_len
WS_DLL_PUBLIC char * uint64_to_str_back_len(char *ptr, uint64_t value, int len)
Converts a 64-bit unsigned integer to a zero-padded decimal string in reverse.
Definition to_str.c:441
dword_to_hex_punct
WS_DLL_PUBLIC char * dword_to_hex_punct(char *out, uint32_t dword, char punct)
Converts a 32-bit word to a hexadecimal string with punctuation.
Definition to_str.c:142
ip_num_to_str_buf
WS_DLL_PUBLIC void ip_num_to_str_buf(uint32_t ad, char *buf, const int buf_len)
Converts a 32-bit IPv4 address to string format.
Definition to_str.c:610
dword_to_hex
WS_DLL_PUBLIC char * dword_to_hex(char *out, uint32_t dword)
Converts a 32-bit word to a fixed-width hexadecimal string.
Definition to_str.c:134
ip6_to_str_buf
WS_DLL_PUBLIC void ip6_to_str_buf(const ws_in6_addr *ad, char *buf, size_t buf_size)
Converts a ws_in6_addr structure to string format.
Definition to_str.c:637
uint64_to_str_back
WS_DLL_PUBLIC char * uint64_to_str_back(char *ptr, uint64_t value)
Converts a 64-bit unsigned integer to a decimal string in reverse.
Definition to_str.c:396
int_to_str_back
WS_DLL_PUBLIC char * int_to_str_back(char *ptr, int32_t value)
Converts a 32-bit signed integer to a decimal string in reverse.
Definition to_str.c:461
ipxnet_to_str_punct
WS_DLL_PUBLIC char * ipxnet_to_str_punct(wmem_allocator_t *scope, const uint32_t ad, const char punct)
Converts an IPX network address to a string with punctuation.
Definition to_str.c:657
word_to_hex
WS_DLL_PUBLIC char * word_to_hex(char *out, uint16_t word)
Converts a 16-bit word to a fixed-width hexadecimal string.
Definition to_str.c:104
uint_to_str_back_len
WS_DLL_PUBLIC char * uint_to_str_back_len(char *ptr, uint32_t value, int len)
Converts a 32-bit unsigned integer to a zero-padded decimal string in reverse.
Definition to_str.c:421
display_epoch_time
WS_DLL_PUBLIC void display_epoch_time(char *buf, size_t buflen, const nstime_t *ns, int precision)
Formats an epoch time value for display.
Definition to_str.c:888
ip_addr_to_str_buf
WS_DLL_PUBLIC void ip_addr_to_str_buf(const ws_in4_addr *ad, char *buf, const int buf_len)
Converts a ws_in4_addr structure to string format.
Definition to_str.c:562
eui64_to_str
WS_DLL_PUBLIC char * eui64_to_str(wmem_allocator_t *scope, const uint64_t ad)
Converts a 64-bit EUI-64 address to string format.
Definition to_str.c:668
oct_to_str_back
WS_DLL_PUBLIC char * oct_to_str_back(char *ptr, uint32_t value)
Converts a 32-bit unsigned integer to octal string in reverse.
Definition to_str.c:306
display_signed_time
WS_DLL_PUBLIC void display_signed_time(char *buf, size_t buf_size, const nstime_t *nstime, int precision)
Formats a signed time value for display.
Definition to_str.c:894
uint_to_str_back
WS_DLL_PUBLIC char * uint_to_str_back(char *ptr, uint32_t value)
Converts a 32-bit unsigned integer to decimal string in reverse.
Definition to_str.c:372
uint8_to_hex
WS_DLL_PUBLIC char * uint8_to_hex(char *out, uint8_t val)
Definition to_str.c:98
int64_to_str_back
WS_DLL_PUBLIC char * int64_to_str_back(char *ptr, int64_t value)
Converts a 64-bit signed integer to a decimal string in reverse.
Definition to_str.c:473
ip_num_to_str
WS_DLL_PUBLIC char * ip_num_to_str(wmem_allocator_t *scope, uint32_t ad)
Converts a 32-bit IPv4 address to a string using memory scope.
Definition to_str.c:618