| 1 | #cxx . . $ `<file>/src/expr/osf.c`/include <stdio.h> |
| 2 | #include <stdint.h> |
| 3 | #include <string.h> |
| 4 | #include <arpa/inet.h> |
| 5 | #include <errno.h> |
| 6 | #include <linux/netfilter/nf_tables.h>cxx . . $ `<file>/include/linux/netfilter/nf_tables.h`/ |
| 7 | |
| 8 | #include "internal.h"cxx . . $ `<file>/include/internal.h`/ |
| 9 | #include <libmnl/libmnl.h> |
| 10 | #include <libnftnl/expr.h>cxx . . $ `<file>/include/libnftnl/expr.h`/ |
| 11 | #include <libnftnl/rule.h>cxx . . $ `<file>/include/libnftnl/rule.h`/ |
| 12 | |
| 13 | #define OSF_GENRE_SIZEcxx . . $ `src/expr/osf.c:13:9`! 32 |
| 14 | |
| 15 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# { |
| 16 | enum nft_registerscxx . . $ nft_registers# dregcxx . . $ nftnl_expr_osf#dreg.; |
| 17 | uint8_tcxx . . $ uint8_t# ttlcxx . . $ nftnl_expr_osf#ttl.; |
| 18 | uint32_tcxx . . $ uint32_t# flagscxx . . $ nftnl_expr_osf#flags.; |
| 19 | }; |
| 20 | |
| 21 | static int |
| 22 | nftnl_expr_osf_setcxx . . $ nftnl_expr_osf_set(211371a3e3842127).(struct nftnl_exprcxx . . $ nftnl_expr# *e, uint16_tcxx . . $ uint16_t# type, |
| 23 | const void *data, uint32_tcxx . . $ uint32_t# data_len, uint32_tcxx . . $ uint32_t# byteorder) |
| 24 | { |
| 25 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# *osf = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 26 | |
| 27 | switch(type) { |
| 28 | case NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.: |
| 29 | memcpycxx . . $ memcpy(cc817cb175f282d).(&osf->dregcxx . . $ nftnl_expr_osf#dreg., data, data_len); |
| 30 | break; |
| 31 | case NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.: |
| 32 | memcpycxx . . $ memcpy(cc817cb175f282d).(&osf->ttlcxx . . $ nftnl_expr_osf#ttl., data, data_len); |
| 33 | break; |
| 34 | case NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.: |
| 35 | memcpycxx . . $ memcpy(cc817cb175f282d).(&osf->flagscxx . . $ nftnl_expr_osf#flags., data, data_len); |
| 36 | break; |
| 37 | } |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static const void * |
| 42 | nftnl_expr_osf_getcxx . . $ nftnl_expr_osf_get(9de263c4f9e71c4b).(const struct nftnl_exprcxx . . $ nftnl_expr# *e, uint16_tcxx . . $ uint16_t# type, |
| 43 | uint32_tcxx . . $ uint32_t# *data_len) |
| 44 | { |
| 45 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# *osf = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 46 | |
| 47 | switch(type) { |
| 48 | case NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.: |
| 49 | *data_len = sizeof(osf->dregcxx . . $ nftnl_expr_osf#dreg.); |
| 50 | return &osf->dregcxx . . $ nftnl_expr_osf#dreg.; |
| 51 | case NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.: |
| 52 | *data_len = sizeof(osf->ttlcxx . . $ nftnl_expr_osf#ttl.); |
| 53 | return &osf->ttlcxx . . $ nftnl_expr_osf#ttl.; |
| 54 | case NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.: |
| 55 | *data_len = sizeof(osf->flagscxx . . $ nftnl_expr_osf#flags.); |
| 56 | return &osf->flagscxx . . $ nftnl_expr_osf#flags.; |
| 57 | } |
| 58 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 59 | } |
| 60 | |
| 61 | static int nftnl_expr_osf_cbcxx . . $ nftnl_expr_osf_cb(de2ef18c48fd675c).(const struct nlattrcxx . . $ nlattr# *attr, void *data) |
| 62 | { |
| 63 | const struct nlattrcxx . . $ nlattr# **tb = data; |
| 64 | int type = mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr); |
| 65 | |
| 66 | if (mnl_attr_type_validcxx . . $ mnl_attr_type_valid(47df1cce1c7be855).(attr, NFTA_OSF_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1763:9`!) < 0) |
| 67 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 68 | |
| 69 | switch(type) { |
| 70 | case NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.: |
| 71 | case NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.: |
| 72 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U32cxx . . $ MNL_TYPE_U32.) < 0) |
| 73 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 74 | break; |
| 75 | |
| 76 | case NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.: |
| 77 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U8cxx . . $ MNL_TYPE_U8.) < 0) |
| 78 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 79 | break; |
| 80 | |
| 81 | } |
| 82 | |
| 83 | tb[type] = attr; |
| 84 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 85 | } |
| 86 | |
| 87 | static void |
| 88 | nftnl_expr_osf_buildcxx . . $ nftnl_expr_osf_build(93c7528a9cf90b41).(struct nlmsghdrcxx . . $ nlmsghdr# *nlh, const struct nftnl_exprcxx . . $ nftnl_expr# *e) |
| 89 | { |
| 90 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# *osf = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 91 | |
| 92 | if (e->flagscxx . . $ nftnl_expr#flags. & (1 << NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.)) |
| 93 | mnl_attr_put_u32cxx . . $ mnl_attr_put_u32(b46fd0aeb0cfb96d).(nlh, NFTA_OSF_DREGcxx . . $ NFTA_OSF_DREG., htonlcxx . . $ `<external>/9581057695539925927/in.h:430:12`!(osf->dreg)); |
| 94 | if (e->flagscxx . . $ nftnl_expr#flags. & (1 << NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.)) |
| 95 | mnl_attr_put_u8cxx . . $ mnl_attr_put_u8(897b09f57801d77).(nlh, NFTA_OSF_TTLcxx . . $ NFTA_OSF_TTL., osf->ttlcxx . . $ nftnl_expr_osf#ttl.); |
| 96 | if (e->flagscxx . . $ nftnl_expr#flags. & (1 << NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.)) |
| 97 | if (osf->flagscxx . . $ nftnl_expr_osf#flags.) |
| 98 | mnl_attr_put_u32cxx . . $ mnl_attr_put_u32(b46fd0aeb0cfb96d).(nlh, NFTA_OSF_FLAGScxx . . $ NFTA_OSF_FLAGS., htonlcxx . . $ `<external>/9581057695539925927/in.h:430:12`!(osf->flags)); |
| 99 | } |
| 100 | |
| 101 | static int |
| 102 | nftnl_expr_osf_parsecxx . . $ nftnl_expr_osf_parse(ed61207049d8af9a).(struct nftnl_exprcxx . . $ nftnl_expr# *e, struct nlattrcxx . . $ nlattr# *attr) |
| 103 | { |
| 104 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# *osf = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 105 | struct nlattrcxx . . $ nlattr# *tb[NFTA_OSF_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1763:9`! + 1] = {}; |
| 106 | |
| 107 | if (mnl_attr_parse_nestedcxx . . $ mnl_attr_parse_nested(f99c0e9fa94f99d9).(attr, nftnl_expr_osf_cbcxx . . $ nftnl_expr_osf_cb(de2ef18c48fd675c)., tb) < 0) |
| 108 | return -1; |
| 109 | |
| 110 | if (tb[NFTA_OSF_DREGcxx . . $ NFTA_OSF_DREG.]) { |
| 111 | osf->dregcxx . . $ nftnl_expr_osf#dreg. = ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[NFTA_OSF_DREG])); |
| 112 | e->flagscxx . . $ nftnl_expr#flags. |= (1 << NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.); |
| 113 | } |
| 114 | |
| 115 | if (tb[NFTA_OSF_TTLcxx . . $ NFTA_OSF_TTL.]) { |
| 116 | osf->ttlcxx . . $ nftnl_expr_osf#ttl. = mnl_attr_get_u8cxx . . $ mnl_attr_get_u8(68d72702597f1127).(tb[NFTA_OSF_TTLcxx . . $ NFTA_OSF_TTL.]); |
| 117 | e->flagscxx . . $ nftnl_expr#flags. |= (1 << NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.); |
| 118 | } |
| 119 | |
| 120 | if (tb[NFTA_OSF_FLAGScxx . . $ NFTA_OSF_FLAGS.]) { |
| 121 | osf->flagscxx . . $ nftnl_expr_osf#flags. = ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[NFTA_OSF_FLAGS])); |
| 122 | e->flagscxx . . $ nftnl_expr#flags. |= (1 << NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.); |
| 123 | } |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | static int |
| 129 | nftnl_expr_osf_snprintfcxx . . $ nftnl_expr_osf_snprintf(2b4af69501aef780).(char *buf, size_t len, |
| 130 | uint32_tcxx . . $ uint32_t# flags, const struct nftnl_exprcxx . . $ nftnl_expr# *e) |
| 131 | { |
| 132 | struct nftnl_expr_osfcxx . . $ nftnl_expr_osf# *osf = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 133 | int ret, offset = 0; |
| 134 | |
| 135 | if (e->flagscxx . . $ nftnl_expr#flags. & (1 << NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.)) { |
| 136 | ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, len, "dreg %u ", osf->dregcxx . . $ nftnl_expr_osf#dreg.); |
| 137 | SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, len, offset); |
| 138 | } |
| 139 | |
| 140 | return offset; |
| 141 | } |
| 142 | |
| 143 | static struct attr_policycxx . . $ attr_policy# osf_attr_policycxx . . $ osf_attr_policy.[__NFTNL_EXPR_OSF_MAXcxx . . $ __NFTNL_EXPR_OSF_MAX.] = { |
| 144 | [NFTNL_EXPR_OSF_DREGcxx . . $ NFTNL_EXPR_OSF_DREG.] = { .maxlen = sizeof(uint32_tcxx . . $ uint32_t#) }, |
| 145 | [NFTNL_EXPR_OSF_TTLcxx . . $ NFTNL_EXPR_OSF_TTL.] = { .maxlen = sizeof(uint8_tcxx . . $ uint8_t#) }, |
| 146 | [NFTNL_EXPR_OSF_FLAGScxx . . $ NFTNL_EXPR_OSF_FLAGS.] = { .maxlen = sizeof(uint32_tcxx . . $ uint32_t#) }, |
| 147 | }; |
| 148 | |
| 149 | struct expr_opscxx . . $ expr_ops# expr_ops_osfcxx . . $ expr_ops_osf. = { |
| 150 | .name = "osf", |
| 151 | .alloc_len = sizeof(struct nftnl_expr_osfcxx . . $ nftnl_expr_osf#), |
| 152 | .nftnl_max_attr = __NFTNL_EXPR_OSF_MAXcxx . . $ __NFTNL_EXPR_OSF_MAX. - 1, |
| 153 | .attr_policy = osf_attr_policycxx . . $ osf_attr_policy., |
| 154 | .set = nftnl_expr_osf_setcxx . . $ nftnl_expr_osf_set(211371a3e3842127)., |
| 155 | .get = nftnl_expr_osf_getcxx . . $ nftnl_expr_osf_get(9de263c4f9e71c4b)., |
| 156 | .parse = nftnl_expr_osf_parsecxx . . $ nftnl_expr_osf_parse(ed61207049d8af9a)., |
| 157 | .build = nftnl_expr_osf_buildcxx . . $ nftnl_expr_osf_build(93c7528a9cf90b41)., |
| 158 | .output = nftnl_expr_osf_snprintfcxx . . $ nftnl_expr_osf_snprintf(2b4af69501aef780)., |
| 159 | }; |