| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */cxx . . $ `<file>/src/table.c`/ |
| 2 | /* |
| 3 | * (C) 2012-2013 by Pablo Neira Ayuso <[email protected]> |
| 4 | * |
| 5 | * This code has been sponsored by Sophos Astaro <http://www.sophos.com> |
| 6 | */ |
| 7 | #include "internal.h"cxx . . $ `<file>/include/internal.h`/ |
| 8 | |
| 9 | #include <time.h> |
| 10 | #include <endian.h> |
| 11 | #include <stdint.h> |
| 12 | #include <limits.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | #include <netinet/in.h> |
| 16 | #include <errno.h> |
| 17 | |
| 18 | #include <libmnl/libmnl.h> |
| 19 | #include <linux/netfilter/nfnetlink.h>cxx . . $ `<file>/include/linux/netfilter/nfnetlink.h`/ |
| 20 | #include <linux/netfilter/nf_tables.h>cxx . . $ `<file>/include/linux/netfilter/nf_tables.h`/ |
| 21 | |
| 22 | #include <libnftnl/table.h>cxx . . $ `<file>/include/libnftnl/table.h`/ |
| 23 | |
| 24 | struct nftnl_tablecxx . . $ nftnl_table# { |
| 25 | struct list_headcxx . . $ list_head# headcxx . . $ nftnl_table#head.; |
| 26 | |
| 27 | const char *namecxx . . $ nftnl_table#name.; |
| 28 | uint32_tcxx . . $ uint32_t# familycxx . . $ nftnl_table#family.; |
| 29 | uint32_tcxx . . $ uint32_t# table_flagscxx . . $ nftnl_table#table_flags.; |
| 30 | uint64_tcxx . . $ uint64_t# handlecxx . . $ nftnl_table#handle.; |
| 31 | uint32_tcxx . . $ uint32_t# usecxx . . $ nftnl_table#use.; |
| 32 | uint32_tcxx . . $ uint32_t# flagscxx . . $ nftnl_table#flags.; |
| 33 | uint32_tcxx . . $ uint32_t# ownercxx . . $ nftnl_table#owner.; |
| 34 | structcxx . . $ nftnl_table#$anonymous_type_0# { |
| 35 | void *datacxx . . $ nftnl_table#$anonymous_type_0#data.; |
| 36 | uint32_tcxx . . $ uint32_t# lencxx . . $ nftnl_table#$anonymous_type_0#len.; |
| 37 | } usercxx . . $ nftnl_table#user.; |
| 38 | }; |
| 39 | |
| 40 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_alloc); |
| 41 | struct nftnl_tablecxx . . $ nftnl_table# *nftnl_table_alloccxx . . $ nftnl_table_alloc(5cf528887e35a09e).(void) |
| 42 | { |
| 43 | return calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct nftnl_tablecxx . . $ nftnl_table#)); |
| 44 | } |
| 45 | |
| 46 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_free); |
| 47 | void nftnl_table_freecxx . . $ nftnl_table_free(9d199e246d0ec5ae).(const struct nftnl_tablecxx . . $ nftnl_table# *t) |
| 48 | { |
| 49 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME.)) |
| 50 | xfreecxx . . $ `include/utils.h:22:9`!(t->name); |
| 51 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.)) |
| 52 | xfreecxx . . $ `include/utils.h:22:9`!(t->user.data); |
| 53 | |
| 54 | xfreecxx . . $ `include/utils.h:22:9`!(t); |
| 55 | } |
| 56 | |
| 57 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_is_set); |
| 58 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! nftnl_table_is_setcxx . . $ nftnl_table_is_set(3c8ee9385d02d95a).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 59 | { |
| 60 | return t->flagscxx . . $ nftnl_table#flags. & (1 << attr); |
| 61 | } |
| 62 | |
| 63 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_unset); |
| 64 | void nftnl_table_unsetcxx . . $ nftnl_table_unset(d12a84b5d32ea984).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 65 | { |
| 66 | if (!(t->flagscxx . . $ nftnl_table#flags. & (1 << attr))) |
| 67 | return; |
| 68 | |
| 69 | switch (attr) { |
| 70 | case NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME.: |
| 71 | xfreecxx . . $ `include/utils.h:22:9`!(t->name); |
| 72 | break; |
| 73 | case NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.: |
| 74 | xfreecxx . . $ `include/utils.h:22:9`!(t->user.data); |
| 75 | break; |
| 76 | case NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.: |
| 77 | case NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.: |
| 78 | case NFTNL_TABLE_FAMILYcxx . . $ NFTNL_TABLE_FAMILY.: |
| 79 | case NFTNL_TABLE_USEcxx . . $ NFTNL_TABLE_USE.: |
| 80 | case NFTNL_TABLE_OWNERcxx . . $ NFTNL_TABLE_OWNER.: |
| 81 | break; |
| 82 | } |
| 83 | t->flagscxx . . $ nftnl_table#flags. &= ~(1 << attr); |
| 84 | } |
| 85 | |
| 86 | static uint32_tcxx . . $ uint32_t# nftnl_table_validatecxx . . $ nftnl_table_validate.[NFTNL_TABLE_MAXcxx . . $ `include/libnftnl/table.h:30:9`! + 1] = { |
| 87 | [NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.] = sizeof(uint32_tcxx . . $ uint32_t#), |
| 88 | [NFTNL_TABLE_FAMILYcxx . . $ NFTNL_TABLE_FAMILY.] = sizeof(uint32_tcxx . . $ uint32_t#), |
| 89 | [NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.] = sizeof(uint64_tcxx . . $ uint64_t#), |
| 90 | [NFTNL_TABLE_USEcxx . . $ NFTNL_TABLE_USE.] = sizeof(uint32_tcxx . . $ uint32_t#), |
| 91 | [NFTNL_TABLE_OWNERcxx . . $ NFTNL_TABLE_OWNER.] = sizeof(uint32_tcxx . . $ uint32_t#), |
| 92 | }; |
| 93 | |
| 94 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_set_data); |
| 95 | int nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, |
| 96 | const void *data, uint32_tcxx . . $ uint32_t# data_len) |
| 97 | { |
| 98 | nftnl_assert_attr_existscxx . . $ `include/utils.h:49:9`!(attr, NFTNL_TABLE_MAXcxx . . $ `include/libnftnl/table.h:30:9`!); |
| 99 | nftnl_assert_validatecxx . . $ `include/utils.h:38:9`!(data, nftnl_table_validate, attr, data_len); |
| 100 | |
| 101 | switch (attr) { |
| 102 | case NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME.: |
| 103 | return nftnl_set_str_attrcxx . . $ nftnl_set_str_attr(fd565288bd370d98).(&t->namecxx . . $ nftnl_table#name., &t->flagscxx . . $ nftnl_table#flags., |
| 104 | attr, data, data_len); |
| 105 | case NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.: |
| 106 | memcpycxx . . $ memcpy(cc817cb175f282d).(&t->handlecxx . . $ nftnl_table#handle., data, sizeof(t->handlecxx . . $ nftnl_table#handle.)); |
| 107 | break; |
| 108 | case NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.: |
| 109 | memcpycxx . . $ memcpy(cc817cb175f282d).(&t->table_flagscxx . . $ nftnl_table#table_flags., data, sizeof(t->table_flagscxx . . $ nftnl_table#table_flags.)); |
| 110 | break; |
| 111 | case NFTNL_TABLE_FAMILYcxx . . $ NFTNL_TABLE_FAMILY.: |
| 112 | memcpycxx . . $ memcpy(cc817cb175f282d).(&t->familycxx . . $ nftnl_table#family., data, sizeof(t->familycxx . . $ nftnl_table#family.)); |
| 113 | break; |
| 114 | case NFTNL_TABLE_USEcxx . . $ NFTNL_TABLE_USE.: |
| 115 | memcpycxx . . $ memcpy(cc817cb175f282d).(&t->usecxx . . $ nftnl_table#use., data, sizeof(t->usecxx . . $ nftnl_table#use.)); |
| 116 | break; |
| 117 | case NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.: |
| 118 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.)) |
| 119 | xfreecxx . . $ `include/utils.h:22:9`!(t->user.data); |
| 120 | |
| 121 | t->usercxx . . $ nftnl_table#user..datacxx . . $ nftnl_table#$anonymous_type_0#data. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(data_len); |
| 122 | if (!t->usercxx . . $ nftnl_table#user..datacxx . . $ nftnl_table#$anonymous_type_0#data.) |
| 123 | return -1; |
| 124 | memcpycxx . . $ memcpy(cc817cb175f282d).(t->usercxx . . $ nftnl_table#user..datacxx . . $ nftnl_table#$anonymous_type_0#data., data, data_len); |
| 125 | t->usercxx . . $ nftnl_table#user..lencxx . . $ nftnl_table#$anonymous_type_0#len. = data_len; |
| 126 | break; |
| 127 | case NFTNL_TABLE_OWNERcxx . . $ NFTNL_TABLE_OWNER.: |
| 128 | memcpycxx . . $ memcpy(cc817cb175f282d).(&t->ownercxx . . $ nftnl_table#owner., data, sizeof(t->ownercxx . . $ nftnl_table#owner.)); |
| 129 | break; |
| 130 | } |
| 131 | t->flagscxx . . $ nftnl_table#flags. |= (1 << attr); |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | void nftnl_table_setcxx . . $ nftnl_table_set(7b9f1f6501468b73).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, const void *data) __visiblecxx . . $ `include/utils.h:13:10`!; |
| 136 | void nftnl_table_setcxx . . $ nftnl_table_set(7b9f1f6501468b73).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, const void *data) |
| 137 | { |
| 138 | nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, attr, data, nftnl_table_validatecxx . . $ nftnl_table_validate.[attr]); |
| 139 | } |
| 140 | |
| 141 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_set_u32); |
| 142 | void nftnl_table_set_u32cxx . . $ nftnl_table_set_u32(11c6c84ac65392b5).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, uint32_tcxx . . $ uint32_t# val) |
| 143 | { |
| 144 | nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, attr, &val, sizeof(uint32_tcxx . . $ uint32_t#)); |
| 145 | } |
| 146 | |
| 147 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_set_u64); |
| 148 | void nftnl_table_set_u64cxx . . $ nftnl_table_set_u64(390093b538f166c0).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, uint64_tcxx . . $ uint64_t# val) |
| 149 | { |
| 150 | nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, attr, &val, sizeof(uint64_tcxx . . $ uint64_t#)); |
| 151 | } |
| 152 | |
| 153 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_set_u8); |
| 154 | void nftnl_table_set_u8cxx . . $ nftnl_table_set_u8(ed68b6441b42772a).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, uint8_tcxx . . $ uint8_t# val) |
| 155 | { |
| 156 | nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, attr, &val, sizeof(uint8_tcxx . . $ uint8_t#)); |
| 157 | } |
| 158 | |
| 159 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_set_str); |
| 160 | int nftnl_table_set_strcxx . . $ nftnl_table_set_str(8d177a82ea9b5daa).(struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, const char *str) |
| 161 | { |
| 162 | return nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, attr, str, strlencxx . . $ strlen(751346f8406fd082).(str) + 1); |
| 163 | } |
| 164 | |
| 165 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get_data); |
| 166 | const void *nftnl_table_get_datacxx . . $ nftnl_table_get_data(83842f37189c1bbe).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr, |
| 167 | uint32_tcxx . . $ uint32_t# *data_len) |
| 168 | { |
| 169 | if (!(t->flagscxx . . $ nftnl_table#flags. & (1 << attr))) |
| 170 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 171 | |
| 172 | switch(attr) { |
| 173 | case NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME.: |
| 174 | *data_len = strlencxx . . $ strlen(751346f8406fd082).(t->namecxx . . $ nftnl_table#name.) + 1; |
| 175 | return t->namecxx . . $ nftnl_table#name.; |
| 176 | case NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.: |
| 177 | *data_len = sizeof(uint64_tcxx . . $ uint64_t#); |
| 178 | return &t->handlecxx . . $ nftnl_table#handle.; |
| 179 | case NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.: |
| 180 | *data_len = sizeof(uint32_tcxx . . $ uint32_t#); |
| 181 | return &t->table_flagscxx . . $ nftnl_table#table_flags.; |
| 182 | case NFTNL_TABLE_FAMILYcxx . . $ NFTNL_TABLE_FAMILY.: |
| 183 | *data_len = sizeof(uint32_tcxx . . $ uint32_t#); |
| 184 | return &t->familycxx . . $ nftnl_table#family.; |
| 185 | case NFTNL_TABLE_USEcxx . . $ NFTNL_TABLE_USE.: |
| 186 | *data_len = sizeof(uint32_tcxx . . $ uint32_t#); |
| 187 | return &t->usecxx . . $ nftnl_table#use.; |
| 188 | case NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.: |
| 189 | *data_len = t->usercxx . . $ nftnl_table#user..lencxx . . $ nftnl_table#$anonymous_type_0#len.; |
| 190 | return t->usercxx . . $ nftnl_table#user..datacxx . . $ nftnl_table#$anonymous_type_0#data.; |
| 191 | case NFTNL_TABLE_OWNERcxx . . $ NFTNL_TABLE_OWNER.: |
| 192 | *data_len = sizeof(uint32_tcxx . . $ uint32_t#); |
| 193 | return &t->ownercxx . . $ nftnl_table#owner.; |
| 194 | } |
| 195 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 196 | } |
| 197 | |
| 198 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get); |
| 199 | const void *nftnl_table_getcxx . . $ nftnl_table_get(bb88a6587d15d1d2).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 200 | { |
| 201 | uint32_tcxx . . $ uint32_t# data_len; |
| 202 | return nftnl_table_get_datacxx . . $ nftnl_table_get_data(83842f37189c1bbe).(t, attr, &data_len); |
| 203 | } |
| 204 | |
| 205 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get_u32); |
| 206 | uint32_tcxx . . $ uint32_t# nftnl_table_get_u32cxx . . $ nftnl_table_get_u32(c18ef6bbe0cf0283).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 207 | { |
| 208 | const void *ret = nftnl_table_getcxx . . $ nftnl_table_get(bb88a6587d15d1d2).(t, attr); |
| 209 | return ret == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! ? 0 : *((uint32_tcxx . . $ uint32_t# *)ret); |
| 210 | } |
| 211 | |
| 212 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get_u64); |
| 213 | uint64_tcxx . . $ uint64_t# nftnl_table_get_u64cxx . . $ nftnl_table_get_u64(5e0b034deb623d64).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 214 | { |
| 215 | const void *ret = nftnl_table_getcxx . . $ nftnl_table_get(bb88a6587d15d1d2).(t, attr); |
| 216 | return ret == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! ? 0 : *((uint64_tcxx . . $ uint64_t# *)ret); |
| 217 | } |
| 218 | |
| 219 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get_u8); |
| 220 | uint8_tcxx . . $ uint8_t# nftnl_table_get_u8cxx . . $ nftnl_table_get_u8(9e40f55d9fb55b).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 221 | { |
| 222 | const void *ret = nftnl_table_getcxx . . $ nftnl_table_get(bb88a6587d15d1d2).(t, attr); |
| 223 | return ret == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! ? 0 : *((uint8_tcxx . . $ uint8_t# *)ret); |
| 224 | } |
| 225 | |
| 226 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_get_str); |
| 227 | const char *nftnl_table_get_strcxx . . $ nftnl_table_get_str(d0679702df7998b0).(const struct nftnl_tablecxx . . $ nftnl_table# *t, uint16_tcxx . . $ uint16_t# attr) |
| 228 | { |
| 229 | return nftnl_table_getcxx . . $ nftnl_table_get(bb88a6587d15d1d2).(t, attr); |
| 230 | } |
| 231 | |
| 232 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_nlmsg_build_payload); |
| 233 | void nftnl_table_nlmsg_build_payloadcxx . . $ nftnl_table_nlmsg_build_payload(23ce635fe44a6319).(struct nlmsghdrcxx . . $ nlmsghdr# *nlh, const struct nftnl_tablecxx . . $ nftnl_table# *t) |
| 234 | { |
| 235 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME.)) |
| 236 | mnl_attr_put_strzcxx . . $ mnl_attr_put_strz(eb76286d4bfc1a8d).(nlh, NFTA_TABLE_NAMEcxx . . $ NFTA_TABLE_NAME., t->namecxx . . $ nftnl_table#name.); |
| 237 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.)) |
| 238 | mnl_attr_put_u64cxx . . $ mnl_attr_put_u64(6d753f4d486e3a2f).(nlh, NFTA_TABLE_HANDLEcxx . . $ NFTA_TABLE_HANDLE., htobe64cxx . . $ `<external>/15855202785537844739/endian.h:49:11`!(t->handle)); |
| 239 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.)) |
| 240 | mnl_attr_put_u32cxx . . $ mnl_attr_put_u32(b46fd0aeb0cfb96d).(nlh, NFTA_TABLE_FLAGScxx . . $ NFTA_TABLE_FLAGS., htonlcxx . . $ `<external>/9581057695539925927/in.h:430:12`!(t->table_flags)); |
| 241 | if (t->flagscxx . . $ nftnl_table#flags. & (1 << NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA.)) |
| 242 | mnl_attr_putcxx . . $ mnl_attr_put(612d908c39ff741d).(nlh, NFTA_TABLE_USERDATAcxx . . $ NFTA_TABLE_USERDATA., t->usercxx . . $ nftnl_table#user..lencxx . . $ nftnl_table#$anonymous_type_0#len., t->usercxx . . $ nftnl_table#user..datacxx . . $ nftnl_table#$anonymous_type_0#data.); |
| 243 | } |
| 244 | |
| 245 | static int nftnl_table_parse_attr_cbcxx . . $ nftnl_table_parse_attr_cb(de2ef18c48fd675c).(const struct nlattrcxx . . $ nlattr# *attr, void *data) |
| 246 | { |
| 247 | const struct nlattrcxx . . $ nlattr# **tb = data; |
| 248 | int type = mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr); |
| 249 | |
| 250 | if (mnl_attr_type_validcxx . . $ mnl_attr_type_valid(47df1cce1c7be855).(attr, NFTA_TABLE_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:214:9`!) < 0) |
| 251 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 252 | |
| 253 | switch(type) { |
| 254 | case NFTA_TABLE_NAMEcxx . . $ NFTA_TABLE_NAME.: |
| 255 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_STRINGcxx . . $ MNL_TYPE_STRING.) < 0) |
| 256 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 257 | break; |
| 258 | case NFTA_TABLE_HANDLEcxx . . $ NFTA_TABLE_HANDLE.: |
| 259 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U64cxx . . $ MNL_TYPE_U64.) < 0) |
| 260 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 261 | break; |
| 262 | case NFTA_TABLE_FLAGScxx . . $ NFTA_TABLE_FLAGS.: |
| 263 | case NFTA_TABLE_USEcxx . . $ NFTA_TABLE_USE.: |
| 264 | case NFTA_TABLE_OWNERcxx . . $ NFTA_TABLE_OWNER.: |
| 265 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U32cxx . . $ MNL_TYPE_U32.) < 0) |
| 266 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 267 | break; |
| 268 | case NFTA_TABLE_USERDATAcxx . . $ NFTA_TABLE_USERDATA.: |
| 269 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_BINARYcxx . . $ MNL_TYPE_BINARY.) < 0) |
| 270 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 271 | break; |
| 272 | } |
| 273 | |
| 274 | tb[type] = attr; |
| 275 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 276 | } |
| 277 | |
| 278 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_nlmsg_parse); |
| 279 | int nftnl_table_nlmsg_parsecxx . . $ nftnl_table_nlmsg_parse(b38c6f9053c07a1f).(const struct nlmsghdrcxx . . $ nlmsghdr# *nlh, struct nftnl_tablecxx . . $ nftnl_table# *t) |
| 280 | { |
| 281 | struct nlattrcxx . . $ nlattr# *tb[NFTA_TABLE_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:214:9`!+1] = {}; |
| 282 | struct nfgenmsgcxx . . $ nfgenmsg# *nfg = mnl_nlmsg_get_payloadcxx . . $ mnl_nlmsg_get_payload(33f780b45aa89a18).(nlh); |
| 283 | int ret; |
| 284 | |
| 285 | if (mnl_attr_parsecxx . . $ mnl_attr_parse(8b80a5a12c5e6592).(nlh, sizeof(*nfg), nftnl_table_parse_attr_cbcxx . . $ nftnl_table_parse_attr_cb(de2ef18c48fd675c)., tb) < 0) |
| 286 | return -1; |
| 287 | |
| 288 | if (nftnl_parse_str_attrcxx . . $ nftnl_parse_str_attr(2002c8408bf98f7f).(tb[NFTA_TABLE_NAMEcxx . . $ NFTA_TABLE_NAME.], NFTNL_TABLE_NAMEcxx . . $ NFTNL_TABLE_NAME., |
| 289 | &t->namecxx . . $ nftnl_table#name., &t->flagscxx . . $ nftnl_table#flags.) < 0) |
| 290 | return -1; |
| 291 | if (tb[NFTA_TABLE_FLAGScxx . . $ NFTA_TABLE_FLAGS.]) { |
| 292 | t->table_flagscxx . . $ nftnl_table#table_flags. = ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[NFTA_TABLE_FLAGS])); |
| 293 | t->flagscxx . . $ nftnl_table#flags. |= (1 << NFTNL_TABLE_FLAGScxx . . $ NFTNL_TABLE_FLAGS.); |
| 294 | } |
| 295 | if (tb[NFTA_TABLE_USEcxx . . $ NFTA_TABLE_USE.]) { |
| 296 | t->usecxx . . $ nftnl_table#use. = ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[NFTA_TABLE_USE])); |
| 297 | t->flagscxx . . $ nftnl_table#flags. |= (1 << NFTNL_TABLE_USEcxx . . $ NFTNL_TABLE_USE.); |
| 298 | } |
| 299 | if (tb[NFTA_TABLE_HANDLEcxx . . $ NFTA_TABLE_HANDLE.]) { |
| 300 | t->handlecxx . . $ nftnl_table#handle. = be64tohcxx . . $ `<external>/15855202785537844739/endian.h:51:11`!(mnl_attr_get_u64(tb[NFTA_TABLE_HANDLE])); |
| 301 | t->flagscxx . . $ nftnl_table#flags. |= (1 << NFTNL_TABLE_HANDLEcxx . . $ NFTNL_TABLE_HANDLE.); |
| 302 | } |
| 303 | if (tb[NFTA_TABLE_USERDATAcxx . . $ NFTA_TABLE_USERDATA.]) { |
| 304 | ret = nftnl_table_set_datacxx . . $ nftnl_table_set_data(e160f300301657a6).(t, NFTNL_TABLE_USERDATAcxx . . $ NFTNL_TABLE_USERDATA., |
| 305 | mnl_attr_get_payloadcxx . . $ mnl_attr_get_payload(cbbcdcb61d3bc7e8).(tb[NFTA_TABLE_USERDATAcxx . . $ NFTA_TABLE_USERDATA.]), |
| 306 | mnl_attr_get_payload_lencxx . . $ mnl_attr_get_payload_len(1da47bcc4c4b975).(tb[NFTA_TABLE_USERDATAcxx . . $ NFTA_TABLE_USERDATA.])); |
| 307 | if (ret < 0) |
| 308 | return ret; |
| 309 | } |
| 310 | if (tb[NFTA_TABLE_OWNERcxx . . $ NFTA_TABLE_OWNER.]) { |
| 311 | t->ownercxx . . $ nftnl_table#owner. = ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[NFTA_TABLE_OWNER])); |
| 312 | t->flagscxx . . $ nftnl_table#flags. |= (1 << NFTNL_TABLE_OWNERcxx . . $ NFTNL_TABLE_OWNER.); |
| 313 | } |
| 314 | |
| 315 | t->familycxx . . $ nftnl_table#family. = nfg->nfgen_familycxx . . $ nfgenmsg#nfgen_family.; |
| 316 | t->flagscxx . . $ nftnl_table#flags. |= (1 << NFTNL_TABLE_FAMILYcxx . . $ NFTNL_TABLE_FAMILY.); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_parse); |
| 322 | int nftnl_table_parsecxx . . $ nftnl_table_parse(9f4fe5c14ab64f9).(struct nftnl_tablecxx . . $ nftnl_table# *t, enum nftnl_parse_typecxx . . $ nftnl_parse_type# type, |
| 323 | const char *data, struct nftnl_parse_errcxx . . $ nftnl_parse_err# *err) |
| 324 | { |
| 325 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!; |
| 326 | |
| 327 | return -1; |
| 328 | } |
| 329 | |
| 330 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_parse_file); |
| 331 | int nftnl_table_parse_filecxx . . $ nftnl_table_parse_file(3f1d4206bd01c1ca).(struct nftnl_tablecxx . . $ nftnl_table# *t, enum nftnl_parse_typecxx . . $ nftnl_parse_type# type, |
| 332 | FILEcxx . . $ FILE# *fp, struct nftnl_parse_errcxx . . $ nftnl_parse_err# *err) |
| 333 | { |
| 334 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!; |
| 335 | |
| 336 | return -1; |
| 337 | } |
| 338 | |
| 339 | static int nftnl_table_snprintf_defaultcxx . . $ nftnl_table_snprintf_default(b237fa3f562ce753).(char *buf, size_t size, |
| 340 | const struct nftnl_tablecxx . . $ nftnl_table# *t) |
| 341 | { |
| 342 | return snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, size, "table %s %s flags %x use %d handle %llu", |
| 343 | t->namecxx . . $ nftnl_table#name., nftnl_family2strcxx . . $ nftnl_family2str(81a3ae90da26a711).(t->familycxx . . $ nftnl_table#family.), |
| 344 | t->table_flagscxx . . $ nftnl_table#table_flags., t->usecxx . . $ nftnl_table#use., (unsigned long long)t->handlecxx . . $ nftnl_table#handle.); |
| 345 | } |
| 346 | |
| 347 | static int nftnl_table_cmd_snprintfcxx . . $ nftnl_table_cmd_snprintf(4bcfec3d78fff56d).(char *buf, size_t remain, |
| 348 | const struct nftnl_tablecxx . . $ nftnl_table# *t, uint32_tcxx . . $ uint32_t# cmd, |
| 349 | uint32_tcxx . . $ uint32_t# type, uint32_tcxx . . $ uint32_t# flags) |
| 350 | { |
| 351 | int ret, offset = 0; |
| 352 | |
| 353 | if (type != NFTNL_OUTPUT_DEFAULTcxx . . $ NFTNL_OUTPUT_DEFAULT.) |
| 354 | return -1; |
| 355 | |
| 356 | ret = nftnl_table_snprintf_defaultcxx . . $ nftnl_table_snprintf_default(b237fa3f562ce753).(buf + offset, remain, t); |
| 357 | SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset); |
| 358 | return offset; |
| 359 | } |
| 360 | |
| 361 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_snprintf); |
| 362 | int nftnl_table_snprintfcxx . . $ nftnl_table_snprintf(97a205a6ddb8ccf2).(char *buf, size_t size, const struct nftnl_tablecxx . . $ nftnl_table# *t, |
| 363 | uint32_tcxx . . $ uint32_t# type, uint32_tcxx . . $ uint32_t# flags) |
| 364 | { |
| 365 | if (size) |
| 366 | buf[0] = '\0'; |
| 367 | |
| 368 | return nftnl_table_cmd_snprintfcxx . . $ nftnl_table_cmd_snprintf(4bcfec3d78fff56d).(buf, size, t, nftnl_flag2cmdcxx . . $ nftnl_flag2cmd(73b61a9477c235b4).(flags), type, |
| 369 | flags); |
| 370 | } |
| 371 | |
| 372 | static int nftnl_table_do_snprintfcxx . . $ nftnl_table_do_snprintf(809f16203406eb30).(char *buf, size_t size, const void *t, |
| 373 | uint32_tcxx . . $ uint32_t# cmd, uint32_tcxx . . $ uint32_t# type, uint32_tcxx . . $ uint32_t# flags) |
| 374 | { |
| 375 | return nftnl_table_snprintfcxx . . $ nftnl_table_snprintf(97a205a6ddb8ccf2).(buf, size, t, type, flags); |
| 376 | } |
| 377 | |
| 378 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_fprintf); |
| 379 | int nftnl_table_fprintfcxx . . $ nftnl_table_fprintf(77649173605e3b48).(FILEcxx . . $ FILE# *fp, const struct nftnl_tablecxx . . $ nftnl_table# *t, uint32_tcxx . . $ uint32_t# type, |
| 380 | uint32_tcxx . . $ uint32_t# flags) |
| 381 | { |
| 382 | return nftnl_fprintfcxx . . $ nftnl_fprintf(959aea809fde9589).(fp, t, NFTNL_CMD_UNSPECcxx . . $ NFTNL_CMD_UNSPEC., type, flags, |
| 383 | nftnl_table_do_snprintfcxx . . $ nftnl_table_do_snprintf(809f16203406eb30).); |
| 384 | } |
| 385 | |
| 386 | struct nftnl_table_listcxx . . $ nftnl_table_list# { |
| 387 | struct list_headcxx . . $ list_head# listcxx . . $ nftnl_table_list#list.; |
| 388 | }; |
| 389 | |
| 390 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_alloc); |
| 391 | struct nftnl_table_listcxx . . $ nftnl_table_list# *nftnl_table_list_alloccxx . . $ nftnl_table_list_alloc(464f806b73c26da8).(void) |
| 392 | { |
| 393 | struct nftnl_table_listcxx . . $ nftnl_table_list# *list; |
| 394 | |
| 395 | list = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct nftnl_table_listcxx . . $ nftnl_table_list#)); |
| 396 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 397 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 398 | |
| 399 | INIT_LIST_HEADcxx . . $ `include/linux_list.h:66:9`!(&list->list); |
| 400 | |
| 401 | return list; |
| 402 | } |
| 403 | |
| 404 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_free); |
| 405 | void nftnl_table_list_freecxx . . $ nftnl_table_list_free(b306a8d41ed1b520).(struct nftnl_table_listcxx . . $ nftnl_table_list# *list) |
| 406 | { |
| 407 | struct nftnl_tablecxx . . $ nftnl_table# *r, *tmp; |
| 408 | |
| 409 | list_for_each_entry_safecxx . . $ `include/linux_list.h:435:9`!(r, tmp, &list->list, head) { |
| 410 | list_delcxx . . $ list_del(35ab6d74de6aba0a).(&r->headcxx . . $ nftnl_table#head.); |
| 411 | nftnl_table_freecxx . . $ nftnl_table_free(9d199e246d0ec5ae).(r); |
| 412 | } |
| 413 | xfreecxx . . $ `include/utils.h:22:9`!(list); |
| 414 | } |
| 415 | |
| 416 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_is_empty); |
| 417 | int nftnl_table_list_is_emptycxx . . $ nftnl_table_list_is_empty(c535914e6e62c262).(const struct nftnl_table_listcxx . . $ nftnl_table_list# *list) |
| 418 | { |
| 419 | return list_emptycxx . . $ list_empty(df525b6afabf24a2).(&list->listcxx . . $ nftnl_table_list#list.); |
| 420 | } |
| 421 | |
| 422 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_add); |
| 423 | void nftnl_table_list_addcxx . . $ nftnl_table_list_add(7f6245b25fb35ca6).(struct nftnl_tablecxx . . $ nftnl_table# *r, struct nftnl_table_listcxx . . $ nftnl_table_list# *list) |
| 424 | { |
| 425 | list_addcxx . . $ list_add(6c3f7387ec573de3).(&r->headcxx . . $ nftnl_table#head., &list->listcxx . . $ nftnl_table_list#list.); |
| 426 | } |
| 427 | |
| 428 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_add_tail); |
| 429 | void nftnl_table_list_add_tailcxx . . $ nftnl_table_list_add_tail(7f6245b25fb35ca6).(struct nftnl_tablecxx . . $ nftnl_table# *r, struct nftnl_table_listcxx . . $ nftnl_table_list# *list) |
| 430 | { |
| 431 | list_add_tailcxx . . $ list_add_tail(6c3f7387ec573de3).(&r->headcxx . . $ nftnl_table#head., &list->listcxx . . $ nftnl_table_list#list.); |
| 432 | } |
| 433 | |
| 434 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_del); |
| 435 | void nftnl_table_list_delcxx . . $ nftnl_table_list_del(b4694c517f3ffaf9).(struct nftnl_tablecxx . . $ nftnl_table# *t) |
| 436 | { |
| 437 | list_delcxx . . $ list_del(35ab6d74de6aba0a).(&t->headcxx . . $ nftnl_table#head.); |
| 438 | } |
| 439 | |
| 440 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_foreach); |
| 441 | int nftnl_table_list_foreachcxx . . $ nftnl_table_list_foreach(6357061e6d5f93ab).(struct nftnl_table_listcxx . . $ nftnl_table_list# *table_list, |
| 442 | int (*cb)(struct nftnl_tablecxx . . $ nftnl_table# *t, void *data), |
| 443 | void *data) |
| 444 | { |
| 445 | struct nftnl_tablecxx . . $ nftnl_table# *cur, *tmp; |
| 446 | int ret; |
| 447 | |
| 448 | list_for_each_entry_safecxx . . $ `include/linux_list.h:435:9`!(cur, tmp, &table_list->list, head) { |
| 449 | ret = cb(cur, data); |
| 450 | if (ret < 0) |
| 451 | return ret; |
| 452 | } |
| 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter# { |
| 457 | const struct nftnl_table_listcxx . . $ nftnl_table_list# *listcxx . . $ nftnl_table_list_iter#list.; |
| 458 | struct nftnl_tablecxx . . $ nftnl_table# *curcxx . . $ nftnl_table_list_iter#cur.; |
| 459 | }; |
| 460 | |
| 461 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_iter_create); |
| 462 | struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter# * |
| 463 | nftnl_table_list_iter_createcxx . . $ nftnl_table_list_iter_create(117d499ef39538ba).(const struct nftnl_table_listcxx . . $ nftnl_table_list# *l) |
| 464 | { |
| 465 | struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter# *iter; |
| 466 | |
| 467 | iter = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter#)); |
| 468 | if (iter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 469 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 470 | |
| 471 | iter->listcxx . . $ nftnl_table_list_iter#list. = l; |
| 472 | if (nftnl_table_list_is_emptycxx . . $ nftnl_table_list_is_empty(c535914e6e62c262).(l)) |
| 473 | iter->curcxx . . $ nftnl_table_list_iter#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 474 | else |
| 475 | iter->curcxx . . $ nftnl_table_list_iter#cur. = list_entrycxx . . $ `include/linux_list.h:334:9`!(l->list.next, struct nftnl_table, head); |
| 476 | |
| 477 | return iter; |
| 478 | } |
| 479 | |
| 480 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_iter_next); |
| 481 | struct nftnl_tablecxx . . $ nftnl_table# *nftnl_table_list_iter_nextcxx . . $ nftnl_table_list_iter_next(7438dcc808d229fd).(struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter# *iter) |
| 482 | { |
| 483 | struct nftnl_tablecxx . . $ nftnl_table# *r = iter->curcxx . . $ nftnl_table_list_iter#cur.; |
| 484 | |
| 485 | if (r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 486 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 487 | |
| 488 | /* get next table, if any */ |
| 489 | iter->curcxx . . $ nftnl_table_list_iter#cur. = list_entrycxx . . $ `include/linux_list.h:334:9`!(iter->cur->head.next, struct nftnl_table, head); |
| 490 | if (&iter->curcxx . . $ nftnl_table_list_iter#cur.->headcxx . . $ nftnl_table#head. == iter->listcxx . . $ nftnl_table_list_iter#list.->listcxx . . $ nftnl_table_list#list..nextcxx . . $ list_head#next.) |
| 491 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 492 | |
| 493 | return r; |
| 494 | } |
| 495 | |
| 496 | EXPORT_SYMBOLcxx . . $ `include/utils.h:14:10`!(nftnl_table_list_iter_destroy); |
| 497 | void nftnl_table_list_iter_destroycxx . . $ nftnl_table_list_iter_destroy(8b8829bcbe02f639).(const struct nftnl_table_list_itercxx . . $ nftnl_table_list_iter# *iter) |
| 498 | { |
| 499 | xfreecxx . . $ `include/utils.h:22:9`!(iter); |
| 500 | } |