Debian Codegraph @

src/libsystemd-network/network-common.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "sd-forward.h"
5 #include "log-link.h"
6 #include "sparse-endian.h"
7 #include "time-util.h"
8
9 #define log_interface_prefix_full_errno_zerook(prefix, type, val, error, fmt, ...) \
10 ({ \
11 int _e = (error); \
12 if (DEBUG_LOGGING) { \
13 const char *_n = NULL; \
14 type *_v = (val); \
15 \
16 if (_v) \
17 (void) type##_get_ifname(_v, &_n); \
18 log_interface_full_errno_zerook( \
19 _n, LOG_DEBUG, _e, prefix fmt, \
20 ##__VA_ARGS__); \
21 } \
22 -ERRNO_VALUE(_e); \
23 })
24
25 #define log_interface_prefix_full_errno(prefix, type, val, error, fmt, ...) \
26 ({ \
27 int _error = (error); \
28 ASSERT_NON_ZERO(_error); \
29 log_interface_prefix_full_errno_zerook( \
30 prefix, type, val, _error, fmt, ##__VA_ARGS__); \
31 })
32
33 int get_ifname(int ifindex, char **ifname);
34
35 usec_t unaligned_be32_sec_to_usec(const void *p, bool max_as_infinity);
36 usec_t be32_sec_to_usec(be32_t t, bool max_as_infinity);
37 usec_t be32_msec_to_usec(be32_t t, bool max_as_infinity);
38 usec_t be16_sec_to_usec(be16_t t, bool max_as_infinity);
39 be32_t usec_to_be32_sec(usec_t t);
40 be32_t usec_to_be32_msec(usec_t t);
41 be16_t usec_to_be16_sec(usec_t t);
42 usec_t time_span_to_stamp(usec_t span, usec_t base);
43
44 bool network_test_mode_enabled(void);
45
46 triple_timestamp* triple_timestamp_from_cmsg(triple_timestamp *t, struct msghdr *mh);
47 #define TRIPLE_TIMESTAMP_FROM_CMSG(mh) \
48 triple_timestamp_from_cmsg(&(triple_timestamp) {}, mh)