lsquic_util.h revision 8c1565cb
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_util.h -- Utility functions 4 */ 5 6#ifndef LSQUIC_UTIL_H 7#define LSQUIC_UTIL_H 1 8 9#ifdef __cplusplus 10extern "C" { 11#endif 12 13struct sockaddr; 14 15lsquic_time_t 16lsquic_time_now (void); 17 18void 19lsquic_init_timers (void); 20 21/* Returns 1 if `buf' contains only zero bytes, 0 otherwise. 22 */ 23int 24lsquic_is_zero (const void *buf, size_t bufsz); 25 26 27 28char * get_bin_str(const void *s, size_t len, size_t max_display_len); 29 30size_t 31lsquic_hex_encode (const void *src, size_t src_sz, void *dst, size_t dst_sz); 32 33/* `out_sz' is assumed to be at least 1. `out' is always NUL-terminated. */ 34size_t 35lsquic_hexdump (const void *src, size_t src_sz, char *out, size_t out_sz); 36 37void 38lsquic_hexstr (const unsigned char *buf, size_t bufsz, char *out, size_t outsz); 39 40#define HEXSTR(buf, bufsz, out) \ 41 (lsquic_hexstr(buf, bufsz, out, sizeof(out)), out) 42 43int 44lsquic_sockaddr_eq (const struct sockaddr *a, const struct sockaddr *b); 45 46#ifdef __cplusplus 47} 48#endif 49 50 51#endif 52