| 1 | #cxx . . $ `<file>/include/utils.h`/ifndef LIBNFTNL_UTILS_H |
| 2 | #define LIBNFTNL_UTILS_Hcxx . . $ `include/utils.h:2:9`! 1 |
| 3 | |
| 4 | #include <errno.h> |
| 5 | #include <stdio.h> |
| 6 | #include <stdint.h> |
| 7 | #include <string.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <libnftnl/common.h>cxx . . $ `<file>/include/libnftnl/common.h`/ |
| 10 | |
| 11 | #include "config.h"cxx . . $ `<file>/config.h`/ |
| 12 | #ifdef HAVE_VISIBILITY_HIDDENcxx . . $ `config.h:35:9`! |
| 13 | # define __visiblecxx . . $ `include/utils.h:13:10`! __attribute__((visibility("default"))) |
| 14 | # define EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(x) typeof(x) (x) __visiblecxx . . $ `include/utils.h:13:10`!; |
| 15 | #else |
| 16 | # define __visible |
| 17 | # define EXPORT_SYMBOL |
| 18 | #endif |
| 19 | |
| 20 | #define __noreturncxx . . $ `include/utils.h:20:9`! __attribute__((__noreturn__)) |
| 21 | |
| 22 | #define xfreecxx . . $ `include/utils.h:22:9`!(ptr) free((void *)ptr); |
| 23 | |
| 24 | #define div_round_upcxx . . $ `include/utils.h:24:9`!(n, d) (((n) + (d) - 1) / (d)) |
| 25 | |
| 26 | void __noreturncxx . . $ `include/utils.h:20:9`! __abi_breakagecxx . . $ __abi_breakage(1eb19c77f92b47d4).(const char *file, int line, const char *reason); |
| 27 | |
| 28 | #define abi_breakagecxx . . $ `include/utils.h:28:9`!() \ |
| 29 | __abi_breakage(__FILE__, __LINE__, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 30 | |
| 31 | void __nftnl_assert_failcxx . . $ __nftnl_assert_fail(c96d46ecfa8e00ae).(uint16_tcxx . . $ uint16_t# attr, const char *filename, int line); |
| 32 | |
| 33 | #define nftnl_assertcxx . . $ `include/utils.h:33:9`!(val, attr, expr) \ |
| 34 | ((!val || expr) \ |
| 35 | ? (void)0 \ |
| 36 | : __nftnl_assert_fail(attr, __FILE__, __LINE__)) |
| 37 | |
| 38 | #define nftnl_assert_validatecxx . . $ `include/utils.h:38:9`!(data, _validate_array, _attr, _data_len) \ |
| 39 | ({ \ |
| 40 | if (!data) \ |
| 41 | __nftnl_assert_fail(_attr, __FILE__, __LINE__); \ |
| 42 | if (_validate_array[_attr]) \ |
| 43 | nftnl_assert(data, _attr, _validate_array[_attr] == _data_len); \ |
| 44 | }) |
| 45 | |
| 46 | void __nftnl_assert_attr_existscxx . . $ __nftnl_assert_attr_exists(62ad6cc440b3457b).(uint16_tcxx . . $ uint16_t# attr, uint16_tcxx . . $ uint16_t# attr_max, |
| 47 | const char *filename, int line); |
| 48 | |
| 49 | #define nftnl_assert_attr_existscxx . . $ `include/utils.h:49:9`!(_attr, _attr_max) \ |
| 50 | ({ \ |
| 51 | if (_attr > _attr_max) \ |
| 52 | __nftnl_assert_attr_exists(_attr, _attr_max, __FILE__, __LINE__); \ |
| 53 | }) |
| 54 | |
| 55 | #define SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset) \ |
| 56 | if (ret < 0) \ |
| 57 | ret = 0; \ |
| 58 | offset += ret; \ |
| 59 | if (ret > remain) \ |
| 60 | ret = remain; \ |
| 61 | remain -= ret; \ |
| 62 | |
| 63 | |
| 64 | #define BUILD_BUG_ON_ZEROcxx . . $ `include/utils.h:64:9`!(e) (sizeof(char[1 - 2 * !!(e)]) - 1) |
| 65 | |
| 66 | #define __must_be_arraycxx . . $ `include/utils.h:66:9`!(a) \ |
| 67 | BUILD_BUG_ON_ZEROcxx . . $ `include/utils.h:64:9`!(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) |
| 68 | |
| 69 | #define array_sizecxx . . $ `include/utils.h:69:9`!(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_arraycxx . . $ `include/utils.h:66:9`!(arr)) |
| 70 | |
| 71 | const char *nftnl_family2strcxx . . $ nftnl_family2str(81a3ae90da26a711).(uint32_tcxx . . $ uint32_t# family); |
| 72 | |
| 73 | const char *nftnl_verdict2strcxx . . $ nftnl_verdict2str(81a3ae90da26a711).(uint32_tcxx . . $ uint32_t# verdict); |
| 74 | |
| 75 | enum nftnl_cmd_typecxx . . $ nftnl_cmd_type# nftnl_flag2cmdcxx . . $ nftnl_flag2cmd(73b61a9477c235b4).(uint32_tcxx . . $ uint32_t# flags); |
| 76 | |
| 77 | int nftnl_fprintfcxx . . $ nftnl_fprintf(959aea809fde9589).(FILEcxx . . $ FILE# *fpconst, const void *obj, uint32_tcxx . . $ uint32_t# cmd, uint32_tcxx . . $ uint32_t# type, |
| 78 | uint32_tcxx . . $ uint32_t# flags, |
| 79 | int (*snprintf_cb)(char *buf, size_t bufsiz, const void *obj, |
| 80 | uint32_tcxx . . $ uint32_t# cmd, uint32_tcxx . . $ uint32_t# type, |
| 81 | uint32_tcxx . . $ uint32_t# flags)); |
| 82 | |
| 83 | int nftnl_set_str_attrcxx . . $ nftnl_set_str_attr(fd565288bd370d98).(const char **dptr, uint32_tcxx . . $ uint32_t# *flags, |
| 84 | uint16_tcxx . . $ uint16_t# attr, const void *data, uint32_tcxx . . $ uint32_t# data_len); |
| 85 | |
| 86 | struct nlattrcxx . . $ nlattr#; |
| 87 | |
| 88 | void nftnl_attr_put_ifnamecxx . . $ nftnl_attr_put_ifname(96236743ed9497eb).(struct nlmsghdrcxx . . $ nlmsghdr# *nlh, const char *ifname); |
| 89 | char *nftnl_attr_get_ifnamecxx . . $ nftnl_attr_get_ifname(5e785b67b24f52d1).(const struct nlattrcxx . . $ nlattr# *attr); |
| 90 | |
| 91 | int nftnl_parse_str_attrcxx . . $ nftnl_parse_str_attr(2002c8408bf98f7f).(const struct nlattrcxx . . $ nlattr# *tb, int attr, |
| 92 | const char **field, uint32_tcxx . . $ uint32_t# *flags); |
| 93 | |
| 94 | static inline uint32_tcxx . . $ uint32_t# bytesumcxx . . $ bytesum(8cbb85865c56216f).(uint8_tcxx . . $ uint8_t# *buf, size_t buflen) |
| 95 | { |
| 96 | uint32_tcxx . . $ uint32_t# ret = 0; |
| 97 | |
| 98 | while (buflen--) |
| 99 | ret += buf[buflen]; |
| 100 | |
| 101 | return ret; |
| 102 | } |
| 103 | |
| 104 | #endif |