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
22extern "C" {
23#endif /* __cplusplus */
24
38WS_DLL_PUBLIC char *uint8_to_hex(char *out, uint8_t val);
39
51WS_DEPRECATED_X("Use uint8_to_hex instead")
52static inline char *guint8_to_hex(char *out, uint8_t val) { return uint8_to_hex(out, val); }
53
65WS_DLL_PUBLIC char *word_to_hex(char *out, uint16_t word);
66
80WS_DLL_PUBLIC char *word_to_hex_punct(char *out, uint16_t word, char punct);
81
93WS_DLL_PUBLIC char *word_to_hex_npad(char *out, uint16_t word);
94
106WS_DLL_PUBLIC char *dword_to_hex(char *out, uint32_t dword);
107
121WS_DLL_PUBLIC char *dword_to_hex_punct(char *out, uint32_t dword, char punct);
122
134WS_DLL_PUBLIC char *qword_to_hex(char *out, uint64_t qword);
135
149WS_DLL_PUBLIC char *qword_to_hex_punct(char *out, uint64_t qword, char punct);
150
163WS_DLL_PUBLIC char *bytes_to_hexstr(char *out, const uint8_t *ad, size_t len);
164
181WS_DLL_PUBLIC char *bytes_to_hexstr_punct(char *out, const uint8_t *ad, size_t len, char punct);
182
194WS_DLL_PUBLIC char *bytes_to_str_punct_maxlen(wmem_allocator_t *scope,
195 const uint8_t *buf, size_t buf_size,
196 char punct, size_t max_bytes_len);
197
198#define bytes_to_str_punct(scope, buf, buf_size, punct) \
199 bytes_to_str_punct_maxlen(scope, buf, buf_size, punct, 24)
200
210WS_DLL_PUBLIC char *bytes_to_str_maxlen(wmem_allocator_t *scope,
211 const uint8_t *buf, size_t buf_size,
212 size_t max_bytes_len);
213
214#define bytes_to_str(scope, buf, buf_size) \
215 bytes_to_str_maxlen(scope, buf, buf_size, 36)
216
228WS_DLL_PUBLIC char *oct_to_str_back(char *ptr, uint32_t value);
229
241WS_DLL_PUBLIC char *oct64_to_str_back(char *ptr, uint64_t value);
242
256WS_DLL_PUBLIC char *hex_to_str_back_len(char *ptr, uint32_t value, int len);
257
271WS_DLL_PUBLIC char *hex64_to_str_back_len(char *ptr, uint64_t value, int len);
272
284WS_DLL_PUBLIC char *uint_to_str_back(char *ptr, uint32_t value);
285
297WS_DLL_PUBLIC char *uint64_to_str_back(char *ptr, uint64_t value);
298
312WS_DLL_PUBLIC char *uint_to_str_back_len(char *ptr, uint32_t value, int len);
313
327WS_DLL_PUBLIC char *uint64_to_str_back_len(char *ptr, uint64_t value, int len);
328
341WS_DLL_PUBLIC char *int_to_str_back(char *ptr, int32_t value);
342
355WS_DLL_PUBLIC char *int64_to_str_back(char *ptr, int64_t value);
356
367WS_DLL_PUBLIC void uint32_to_str_buf(uint32_t u, char *buf, size_t buf_len);
368
380WS_DEPRECATED_X("Use uint32_to_str_buf instead")
381static inline void guint32_to_str_buf(uint32_t u, char *buf, size_t buf_len) { uint32_to_str_buf(u, buf, buf_len); }
382
394WS_DLL_PUBLIC void uint64_to_str_buf(uint64_t u, char *buf, size_t buf_len);
395
403WS_DEPRECATED_X("Use uint64_to_str_buf instead")
404static inline void guint64_to_str_buf(uint64_t u, char *buf, size_t buf_len) { uint64_to_str_buf(u, buf, buf_len); }
405
415WS_DEPRECATED_X("Use ip_num_to_str_buf() or ip_addr_to_str() instead")
416WS_DLL_PUBLIC void ip_to_str_buf(const uint8_t *ad, char *buf, const int buf_len);
417
428WS_DLL_PUBLIC char *ip_to_str(wmem_allocator_t *scope, const uint8_t *ad);
429
440WS_DLL_PUBLIC void ip_num_to_str_buf(uint32_t ad, char *buf, const int buf_len);
441
452WS_DLL_PUBLIC char *ip_num_to_str(wmem_allocator_t *scope, uint32_t ad);
453
463WS_DLL_PUBLIC void ip_addr_to_str_buf(const ws_in4_addr *ad, char *buf, const int buf_len);
464
474WS_DLL_PUBLIC char *ip_addr_to_str(wmem_allocator_t *scope, const ws_in4_addr *ad);
475
485WS_DLL_PUBLIC void ip6_to_str_buf(const ws_in6_addr *ad, char *buf, size_t buf_size);
486
496WS_DLL_PUBLIC char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad);
497
509WS_DLL_PUBLIC char *ipxnet_to_str_punct(wmem_allocator_t *scope, const uint32_t ad, const char punct);
510
521WS_DLL_PUBLIC char *eui64_to_str(wmem_allocator_t *scope, const uint64_t ad);
522
535WS_DLL_PUBLIC int format_fractional_part_nsecs(char *buf, size_t buflen, uint32_t nsecs, const char *decimal_point, int precision);
536
547WS_DLL_PUBLIC void display_epoch_time(char *buf, size_t buflen, const nstime_t *ns, int precision);
548
559WS_DLL_PUBLIC void display_signed_time(char *buf, size_t buf_size, const nstime_t *nstime, int precision);
560
573WS_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);
574
575#ifdef __cplusplus
576}
577#endif /* __cplusplus */
578
579#endif /* __TO_STR_H__ */
uint32_t ws_in4_addr
Represents a 32-bit IPv4 address in network byte order.
Definition inet_addr.h:22
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Represents a 128-bit IPv6 address.
Definition inet_addr.h:27
Definition nstime.h:26
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
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
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
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
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
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
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
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
WS_DEPRECATED_X("Use ip_num_to_str_buf() or ip_addr_to_str() instead") WS_DLL_PUBLIC void ip_to_str_buf(const uint8_t *ad
Converts a 32-bit IPv4 address to string format.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
WS_DLL_PUBLIC char * uint8_to_hex(char *out, uint8_t val)
Converts bytes to a hexadecimal string.
Definition to_str.c:98
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
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