| 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
47WS_DEPRECATED_X("Use uint8_to_hex instead")
48static inline char *guint8_to_hex(char *out, uint8_t val) { return uint8_to_hex(out, val); }
49
61WS_DLL_PUBLIC char *word_to_hex(char *out, uint16_t word);
62
76WS_DLL_PUBLIC char *word_to_hex_punct(char *out, uint16_t word, char punct);
77
89WS_DLL_PUBLIC char *word_to_hex_npad(char *out, uint16_t word);
90
102WS_DLL_PUBLIC char *dword_to_hex(char *out, uint32_t dword);
103
117WS_DLL_PUBLIC char *dword_to_hex_punct(char *out, uint32_t dword, char punct);
118
130WS_DLL_PUBLIC char *qword_to_hex(char *out, uint64_t qword);
131
145WS_DLL_PUBLIC char *qword_to_hex_punct(char *out, uint64_t qword, char punct);
146
159WS_DLL_PUBLIC char *bytes_to_hexstr(char *out, const uint8_t *ad, size_t len);
160
177WS_DLL_PUBLIC char *bytes_to_hexstr_punct(char *out, const uint8_t *ad, size_t len, char punct);
178
190WS_DLL_PUBLIC char *bytes_to_str_punct_maxlen(wmem_allocator_t *scope,
191 const uint8_t *buf, size_t buf_size,
192 char punct, size_t max_bytes_len);
193
194#define bytes_to_str_punct(scope, buf, buf_size, punct) \
195 bytes_to_str_punct_maxlen(scope, buf, buf_size, punct, 24)
196
206WS_DLL_PUBLIC char *bytes_to_str_maxlen(wmem_allocator_t *scope,
207 const uint8_t *buf, size_t buf_size,
208 size_t max_bytes_len);
209
210#define bytes_to_str(scope, buf, buf_size) \
211 bytes_to_str_maxlen(scope, buf, buf_size, 36)
212
224WS_DLL_PUBLIC char *oct_to_str_back(char *ptr, uint32_t value);
225
237WS_DLL_PUBLIC char *oct64_to_str_back(char *ptr, uint64_t value);
238
252WS_DLL_PUBLIC char *hex_to_str_back_len(char *ptr, uint32_t value, int len);
253
267WS_DLL_PUBLIC char *hex64_to_str_back_len(char *ptr, uint64_t value, int len);
268
280WS_DLL_PUBLIC char *uint_to_str_back(char *ptr, uint32_t value);
281
293WS_DLL_PUBLIC char *uint64_to_str_back(char *ptr, uint64_t value);
294
308WS_DLL_PUBLIC char *uint_to_str_back_len(char *ptr, uint32_t value, int len);
309
323WS_DLL_PUBLIC char *uint64_to_str_back_len(char *ptr, uint64_t value, int len);
324
337WS_DLL_PUBLIC char *int_to_str_back(char *ptr, int32_t value);
338
351WS_DLL_PUBLIC char *int64_to_str_back(char *ptr, int64_t value);
352
363WS_DLL_PUBLIC void uint32_to_str_buf(uint32_t u, char *buf, size_t buf_len);
364
376WS_DEPRECATED_X("Use uint32_to_str_buf instead")
377static inline void guint32_to_str_buf(uint32_t u, char *buf, size_t buf_len) { uint32_to_str_buf(u, buf, buf_len); }
378
390WS_DLL_PUBLIC void uint64_to_str_buf(uint64_t u, char *buf, size_t buf_len);
391
399WS_DEPRECATED_X("Use uint64_to_str_buf instead")
400static inline void guint64_to_str_buf(uint64_t u, char *buf, size_t buf_len) { uint64_to_str_buf(u, buf, buf_len); }
401
402WS_DEPRECATED_X("Use ip_num_to_str_buf() or ip_addr_to_str() instead")
403WS_DLL_PUBLIC void ip_to_str_buf(const uint8_t *ad, char *buf, const int buf_len);
404
414WS_DEPRECATED_X("Use ip_num_to_str() or ip_addr_to_str() instead")
415WS_DLL_PUBLIC char *ip_to_str(wmem_allocator_t *scope, const uint8_t *ad);
416
427WS_DLL_PUBLIC void ip_num_to_str_buf(uint32_t ad, char *buf, const int buf_len);
428
439WS_DLL_PUBLIC char *ip_num_to_str(wmem_allocator_t *scope, uint32_t ad);
440
450WS_DLL_PUBLIC void ip_addr_to_str_buf(const ws_in4_addr *ad, char *buf, const int buf_len);
451
461WS_DLL_PUBLIC char *ip_addr_to_str(wmem_allocator_t *scope, const ws_in4_addr *ad);
462
472WS_DLL_PUBLIC void ip6_to_str_buf(const ws_in6_addr *ad, char *buf, size_t buf_size);
473
483WS_DLL_PUBLIC char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad);
484
496WS_DLL_PUBLIC char *ipxnet_to_str_punct(wmem_allocator_t *scope, const uint32_t ad, const char punct);
497
508WS_DLL_PUBLIC char *eui64_to_str(wmem_allocator_t *scope, const uint64_t ad);
509
522WS_DLL_PUBLIC int format_fractional_part_nsecs(char *buf, size_t buflen, uint32_t nsecs, const char *decimal_point, int precision);
523
534WS_DLL_PUBLIC void display_epoch_time(char *buf, size_t buflen, const nstime_t *ns, int precision);
535
546WS_DLL_PUBLIC void display_signed_time(char *buf, size_t buf_size, const nstime_t *nstime, int precision);
547
560WS_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);
561
562#ifdef __cplusplus
563}
564#endif /* __cplusplus */
565
566#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