summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--include/expr_ops.h8
-rw-r--r--include/internal.h1
-rw-r--r--include/libnftnl/Makefile.am1
-rw-r--r--include/libnftnl/regs.h23
-rw-r--r--include/obj.h2
-rw-r--r--include/regs.h70
-rw-r--r--src/Makefile.am1
-rw-r--r--src/expr.c4
-rw-r--r--src/expr/bitwise.c2
-rw-r--r--src/expr/byteorder.c2
-rw-r--r--src/expr/cmp.c2
-rw-r--r--src/expr/connlimit.c2
-rw-r--r--src/expr/counter.c2
-rw-r--r--src/expr/ct.c84
-rw-r--r--src/expr/dup.c2
-rw-r--r--src/expr/dynset.c2
-rw-r--r--src/expr/exthdr.c39
-rw-r--r--src/expr/fib.c47
-rw-r--r--src/expr/flow_offload.c2
-rw-r--r--src/expr/fwd.c2
-rw-r--r--src/expr/hash.c2
-rw-r--r--src/expr/immediate.c2
-rw-r--r--src/expr/last.c2
-rw-r--r--src/expr/limit.c2
-rw-r--r--src/expr/log.c2
-rw-r--r--src/expr/lookup.c2
-rw-r--r--src/expr/masq.c2
-rw-r--r--src/expr/match.c2
-rw-r--r--src/expr/meta.c46
-rw-r--r--src/expr/nat.c2
-rw-r--r--src/expr/numgen.c2
-rw-r--r--src/expr/objref.c2
-rw-r--r--src/expr/osf.c34
-rw-r--r--src/expr/payload.c33
-rw-r--r--src/expr/queue.c2
-rw-r--r--src/expr/quota.c2
-rw-r--r--src/expr/range.c2
-rw-r--r--src/expr/redir.c2
-rw-r--r--src/expr/reject.c2
-rw-r--r--src/expr/rt.c48
-rw-r--r--src/expr/socket.c49
-rw-r--r--src/expr/synproxy.c2
-rw-r--r--src/expr/target.c2
-rw-r--r--src/expr/tproxy.c2
-rw-r--r--src/expr/tunnel.c2
-rw-r--r--src/expr/xfrm.c53
-rw-r--r--src/libnftnl.map7
-rw-r--r--src/obj/counter.c2
-rw-r--r--src/obj/ct_expect.c2
-rw-r--r--src/obj/ct_helper.c2
-rw-r--r--src/obj/ct_timeout.c2
-rw-r--r--src/obj/limit.c2
-rw-r--r--src/obj/quota.c2
-rw-r--r--src/obj/secmark.c2
-rw-r--r--src/obj/synproxy.c2
-rw-r--r--src/obj/tunnel.c2
-rw-r--r--src/object.c2
-rw-r--r--src/regs.c239
59 files changed, 53 insertions, 816 deletions
diff --git a/configure.ac b/configure.ac
index 8e68035..dc14392 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to create configure.
-AC_INIT([libnftnl], [1.2.1])
+AC_INIT([libnftnl], [1.2.2])
AC_CONFIG_AUX_DIR([build-aux])
AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIR([m4])
diff --git a/include/expr_ops.h b/include/expr_ops.h
index 01f6fef..a7d747a 100644
--- a/include/expr_ops.h
+++ b/include/expr_ops.h
@@ -7,7 +7,6 @@
struct nlattr;
struct nlmsghdr;
struct nftnl_expr;
-struct nftnl_reg;
struct expr_ops {
const char *name;
@@ -19,12 +18,7 @@ struct expr_ops {
const void *(*get)(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len);
int (*parse)(struct nftnl_expr *e, struct nlattr *attr);
void (*build)(struct nlmsghdr *nlh, const struct nftnl_expr *e);
- int (*snprintf)(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e);
- struct {
- int (*len)(const struct nftnl_expr *e);
- bool (*cmp)(const struct nftnl_reg *reg, const struct nftnl_expr *e);
- void (*update)(struct nftnl_reg *reg, const struct nftnl_expr *e);
- } reg;
+ int (*output)(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e);
};
struct expr_ops *nftnl_expr_ops_lookup(const char *name);
diff --git a/include/internal.h b/include/internal.h
index 9f88828..1f96731 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -12,6 +12,5 @@
#include "expr.h"
#include "expr_ops.h"
#include "rule.h"
-#include "regs.h"
#endif /* _LIBNFTNL_INTERNAL_H_ */
diff --git a/include/libnftnl/Makefile.am b/include/libnftnl/Makefile.am
index 186f758..d846a57 100644
--- a/include/libnftnl/Makefile.am
+++ b/include/libnftnl/Makefile.am
@@ -3,7 +3,6 @@ pkginclude_HEADERS = batch.h \
trace.h \
chain.h \
object.h \
- regs.h \
rule.h \
expr.h \
set.h \
diff --git a/include/libnftnl/regs.h b/include/libnftnl/regs.h
deleted file mode 100644
index 7df79ec..0000000
--- a/include/libnftnl/regs.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _LIBNFTNL_REGS_H_
-#define _LIBNFTNL_REGS_H_
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct nftnl_regs;
-struct nftnl_expr;
-
-struct nftnl_regs *nftnl_regs_alloc(uint32_t num_regs);
-void nftnl_regs_free(const struct nftnl_regs *regs);
-
-uint32_t nftnl_reg_get(struct nftnl_regs *regs, const struct nftnl_expr *expr);
-uint32_t nftnl_reg_get_scratch(struct nftnl_regs *regs, uint32_t len);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* _LIBNFTNL_REGS_H_ */
diff --git a/include/obj.h b/include/obj.h
index 60dc853..d848ac9 100644
--- a/include/obj.h
+++ b/include/obj.h
@@ -109,7 +109,7 @@ struct obj_ops {
const void *(*get)(const struct nftnl_obj *e, uint16_t type, uint32_t *data_len);
int (*parse)(struct nftnl_obj *e, struct nlattr *attr);
void (*build)(struct nlmsghdr *nlh, const struct nftnl_obj *e);
- int (*snprintf)(char *buf, size_t len, uint32_t flags, const struct nftnl_obj *e);
+ int (*output)(char *buf, size_t len, uint32_t flags, const struct nftnl_obj *e);
};
extern struct obj_ops obj_ops_counter;
diff --git a/include/regs.h b/include/regs.h
deleted file mode 100644
index dcbb0f4..0000000
--- a/include/regs.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef _LIBNFTNL_REGS_INTERNAL_H_
-#define _LIBNFTNL_REGS_INTERNAL_H_
-
-enum nftnl_expr_type {
- NFT_EXPR_UNSPEC = 0,
- NFT_EXPR_PAYLOAD,
- NFT_EXPR_META,
- NFT_EXPR_CT,
- NFT_EXPR_EXTHDR,
- NFT_EXPR_FIB,
- NFT_EXPR_OSF,
- NFT_EXPR_RT,
- NFT_EXPR_XFRM,
- NFT_EXPR_SOCKET,
-};
-
-struct nftnl_reg {
- enum nftnl_expr_type type;
- uint32_t len;
- uint64_t genid;
- uint8_t word;
- union {
- struct {
- enum nft_meta_keys key;
- } meta;
- struct {
- enum nft_payload_bases base;
- uint32_t offset;
- } payload;
- struct {
- enum nft_ct_keys key;
- uint8_t dir;
- } ct;
- struct {
- uint32_t offset;
- uint32_t len;
- uint8_t type;
- uint32_t op;
- uint32_t flags;
- } exthdr;
- struct {
- uint32_t flags;
- uint32_t result;
- } fib;
- struct {
- uint8_t ttl;
- uint32_t flags;
- } osf;
- struct {
- enum nft_rt_keys key;
- } rt;
- struct {
- enum nft_socket_keys key;
- uint32_t level;
- } socket;
- struct {
- enum nft_xfrm_keys key;
- uint32_t spnum;
- uint8_t dir;
- } xfrm;
- };
-};
-
-struct nftnl_regs {
- uint32_t num_regs;
- struct nftnl_reg *reg;
- uint64_t genid;
-};
-
-#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a26d24..c3b0ab9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,6 @@ libnftnl_la_SOURCES = utils.c \
trace.c \
chain.c \
object.c \
- regs.c \
rule.c \
set.c \
set_elem.c \
diff --git a/src/expr.c b/src/expr.c
index 277bbde..b4581f1 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -279,10 +279,10 @@ int nftnl_expr_snprintf(char *buf, size_t remain, const struct nftnl_expr *expr,
if (remain)
buf[0] = '\0';
- if (!expr->ops->snprintf || type != NFTNL_OUTPUT_DEFAULT)
+ if (!expr->ops->output || type != NFTNL_OUTPUT_DEFAULT)
return 0;
- ret = expr->ops->snprintf(buf + offset, remain, flags, expr);
+ ret = expr->ops->output(buf + offset, remain, flags, expr);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c
index d0c7827..2d27233 100644
--- a/src/expr/bitwise.c
+++ b/src/expr/bitwise.c
@@ -282,5 +282,5 @@ struct expr_ops expr_ops_bitwise = {
.get = nftnl_expr_bitwise_get,
.parse = nftnl_expr_bitwise_parse,
.build = nftnl_expr_bitwise_build,
- .snprintf = nftnl_expr_bitwise_snprintf,
+ .output = nftnl_expr_bitwise_snprintf,
};
diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c
index d299745..89ed0a8 100644
--- a/src/expr/byteorder.c
+++ b/src/expr/byteorder.c
@@ -220,5 +220,5 @@ struct expr_ops expr_ops_byteorder = {
.get = nftnl_expr_byteorder_get,
.parse = nftnl_expr_byteorder_parse,
.build = nftnl_expr_byteorder_build,
- .snprintf = nftnl_expr_byteorder_snprintf,
+ .output = nftnl_expr_byteorder_snprintf,
};
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index 6030693..f9d15bb 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -202,5 +202,5 @@ struct expr_ops expr_ops_cmp = {
.get = nftnl_expr_cmp_get,
.parse = nftnl_expr_cmp_parse,
.build = nftnl_expr_cmp_build,
- .snprintf = nftnl_expr_cmp_snprintf,
+ .output = nftnl_expr_cmp_snprintf,
};
diff --git a/src/expr/connlimit.c b/src/expr/connlimit.c
index 3b37587..549417b 100644
--- a/src/expr/connlimit.c
+++ b/src/expr/connlimit.c
@@ -135,5 +135,5 @@ struct expr_ops expr_ops_connlimit = {
.get = nftnl_expr_connlimit_get,
.parse = nftnl_expr_connlimit_parse,
.build = nftnl_expr_connlimit_build,
- .snprintf = nftnl_expr_connlimit_snprintf,
+ .output = nftnl_expr_connlimit_snprintf,
};
diff --git a/src/expr/counter.c b/src/expr/counter.c
index 1676d70..d139a5f 100644
--- a/src/expr/counter.c
+++ b/src/expr/counter.c
@@ -133,5 +133,5 @@ struct expr_ops expr_ops_counter = {
.get = nftnl_expr_counter_get,
.parse = nftnl_expr_counter_parse,
.build = nftnl_expr_counter_build,
- .snprintf = nftnl_expr_counter_snprintf,
+ .output = nftnl_expr_counter_snprintf,
};
diff --git a/src/expr/ct.c b/src/expr/ct.c
index f17491c..f4a2aea 100644
--- a/src/expr/ct.c
+++ b/src/expr/ct.c
@@ -14,7 +14,6 @@
#include <stdint.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <assert.h>
#include <linux/netfilter/nf_tables.h>
#include "internal.h"
@@ -149,82 +148,6 @@ nftnl_expr_ct_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-#ifndef XT_CONNLABEL_MAXBIT
-#define XT_CONNLABEL_MAXBIT 127
-#endif
-
-#ifndef NF_CT_LABELS_MAX_SIZE
-#define NF_CT_LABELS_MAX_SIZE ((XT_CONNLABEL_MAXBIT + 1) / 8)
-#endif
-
-#ifndef NF_CT_HELPER_NAME_LEN
-#define NF_CT_HELPER_NAME_LEN 16
-#endif
-
-static int
-nftnl_expr_ct_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_ct *ct = nftnl_expr_data(e);
-
- switch (ct->key) {
- case NFT_CT_DIRECTION:
- case NFT_CT_PROTOCOL:
- case NFT_CT_L3PROTOCOL:
- return sizeof(uint8_t);
- case NFT_CT_ZONE:
- case NFT_CT_LABELS:
- return NF_CT_LABELS_MAX_SIZE;
- case NFT_CT_HELPER:
- return NF_CT_HELPER_NAME_LEN;
- case NFT_CT_PROTO_SRC:
- case NFT_CT_PROTO_DST:
- return sizeof(uint16_t);
- case NFT_CT_ID:
- case NFT_CT_STATE:
- case NFT_CT_STATUS:
- case NFT_CT_MARK:
- case NFT_CT_SECMARK:
- case NFT_CT_EXPIRATION:
- case NFT_CT_EVENTMASK:
- case NFT_CT_SRC_IP:
- case NFT_CT_DST_IP:
- return sizeof(uint32_t);
- case NFT_CT_BYTES:
- case NFT_CT_PKTS:
- case NFT_CT_AVGPKT:
- return sizeof(uint64_t);
- case NFT_CT_SRC:
- case NFT_CT_DST:
- case NFT_CT_SRC_IP6:
- case NFT_CT_DST_IP6:
- return sizeof(uint32_t) * 4;
- default:
- assert(0);
- }
-
- return sizeof(uint32_t);
-}
-
-static bool
-nftnl_expr_ct_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_ct *ct = nftnl_expr_data(e);
-
- return reg->ct.key == ct->key &&
- reg->ct.dir == ct->dir;
-}
-
-static void
-nftnl_expr_ct_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_ct *ct = nftnl_expr_data(e);
-
- reg->ct.key = ct->key;
- reg->ct.dir = ct->dir;
-}
-
static const char *ctkey2str_array[NFT_CT_MAX + 1] = {
[NFT_CT_STATE] = "state",
[NFT_CT_DIRECTION] = "direction",
@@ -335,10 +258,5 @@ struct expr_ops expr_ops_ct = {
.get = nftnl_expr_ct_get,
.parse = nftnl_expr_ct_parse,
.build = nftnl_expr_ct_build,
- .snprintf = nftnl_expr_ct_snprintf,
- .reg = {
- .len = nftnl_expr_ct_reg_len,
- .cmp = nftnl_expr_ct_reg_cmp,
- .update = nftnl_expr_ct_reg_update,
- },
+ .output = nftnl_expr_ct_snprintf,
};
diff --git a/src/expr/dup.c b/src/expr/dup.c
index f041b55..a239ff3 100644
--- a/src/expr/dup.c
+++ b/src/expr/dup.c
@@ -138,5 +138,5 @@ struct expr_ops expr_ops_dup = {
.get = nftnl_expr_dup_get,
.parse = nftnl_expr_dup_parse,
.build = nftnl_expr_dup_build,
- .snprintf = nftnl_expr_dup_snprintf,
+ .output = nftnl_expr_dup_snprintf,
};
diff --git a/src/expr/dynset.c b/src/expr/dynset.c
index 85d64bb..5bcf1c6 100644
--- a/src/expr/dynset.c
+++ b/src/expr/dynset.c
@@ -373,5 +373,5 @@ struct expr_ops expr_ops_dynset = {
.get = nftnl_expr_dynset_get,
.parse = nftnl_expr_dynset_parse,
.build = nftnl_expr_dynset_build,
- .snprintf = nftnl_expr_dynset_snprintf,
+ .output = nftnl_expr_dynset_snprintf,
};
diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c
index 53a2a80..739c7ff 100644
--- a/src/expr/exthdr.c
+++ b/src/expr/exthdr.c
@@ -194,38 +194,6 @@ nftnl_expr_exthdr_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int
-nftnl_expr_exthdr_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e);
-
- return exthdr->len;
-}
-
-static bool
-nftnl_expr_exthdr_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e);
-
- return reg->exthdr.offset == exthdr->offset &&
- reg->exthdr.type == exthdr->type &&
- reg->exthdr.op == exthdr->op &&
- reg->exthdr.flags == exthdr->flags;
-}
-
-static void
-nftnl_expr_exthdr_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e);
-
- reg->exthdr.offset = exthdr->offset;
- reg->exthdr.type = exthdr->type;
- reg->exthdr.op = exthdr->op;
- reg->exthdr.flags = exthdr->flags;
-}
-
static const char *op2str(uint8_t op)
{
switch (op) {
@@ -299,10 +267,5 @@ struct expr_ops expr_ops_exthdr = {
.get = nftnl_expr_exthdr_get,
.parse = nftnl_expr_exthdr_parse,
.build = nftnl_expr_exthdr_build,
- .snprintf = nftnl_expr_exthdr_snprintf,
- .reg = {
- .len = nftnl_expr_exthdr_reg_len,
- .cmp = nftnl_expr_exthdr_reg_cmp,
- .update = nftnl_expr_exthdr_reg_update,
- },
+ .output = nftnl_expr_exthdr_snprintf,
};
diff --git a/src/expr/fib.c b/src/expr/fib.c
index 59b335a..957f929 100644
--- a/src/expr/fib.c
+++ b/src/expr/fib.c
@@ -14,7 +14,6 @@
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <net/if.h>
#include <linux/netfilter/nf_tables.h>
#include "internal.h"
@@ -129,45 +128,6 @@ nftnl_expr_fib_parse(struct nftnl_expr *e, struct nlattr *attr)
return ret;
}
-static int
-nftnl_expr_fib_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_fib *fib = nftnl_expr_data(e);
-
- switch (fib->result) {
- case NFT_FIB_RESULT_OIF:
- return sizeof(int);
- case NFT_FIB_RESULT_OIFNAME:
- return IFNAMSIZ;
- case NFT_FIB_RESULT_ADDRTYPE:
- return sizeof(uint32_t);
- default:
- assert(0);
- break;
- }
- return sizeof(uint32_t);
-}
-
-static bool
-nftnl_expr_fib_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_fib *fib = nftnl_expr_data(e);
-
- return reg->fib.result == fib->result &&
- reg->fib.flags == fib->flags;
-}
-
-static void
-nftnl_expr_fib_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_fib *fib = nftnl_expr_data(e);
-
- reg->fib.result = fib->result;
- reg->fib.flags = fib->flags;
-}
-
static const char *fib_type[NFT_FIB_RESULT_MAX + 1] = {
[NFT_FIB_RESULT_OIF] = "oif",
[NFT_FIB_RESULT_OIFNAME] = "oifname",
@@ -238,10 +198,5 @@ struct expr_ops expr_ops_fib = {
.get = nftnl_expr_fib_get,
.parse = nftnl_expr_fib_parse,
.build = nftnl_expr_fib_build,
- .snprintf = nftnl_expr_fib_snprintf,
- .reg = {
- .len = nftnl_expr_fib_reg_len,
- .cmp = nftnl_expr_fib_reg_cmp,
- .update = nftnl_expr_fib_reg_update,
- },
+ .output = nftnl_expr_fib_snprintf,
};
diff --git a/src/expr/flow_offload.c b/src/expr/flow_offload.c
index a826202..4fc0563 100644
--- a/src/expr/flow_offload.c
+++ b/src/expr/flow_offload.c
@@ -120,5 +120,5 @@ struct expr_ops expr_ops_flow = {
.get = nftnl_expr_flow_get,
.parse = nftnl_expr_flow_parse,
.build = nftnl_expr_flow_build,
- .snprintf = nftnl_expr_flow_snprintf,
+ .output = nftnl_expr_flow_snprintf,
};
diff --git a/src/expr/fwd.c b/src/expr/fwd.c
index 82e5a41..51f6612 100644
--- a/src/expr/fwd.c
+++ b/src/expr/fwd.c
@@ -158,5 +158,5 @@ struct expr_ops expr_ops_fwd = {
.get = nftnl_expr_fwd_get,
.parse = nftnl_expr_fwd_parse,
.build = nftnl_expr_fwd_build,
- .snprintf = nftnl_expr_fwd_snprintf,
+ .output = nftnl_expr_fwd_snprintf,
};
diff --git a/src/expr/hash.c b/src/expr/hash.c
index 10b4a72..6e2dd19 100644
--- a/src/expr/hash.c
+++ b/src/expr/hash.c
@@ -226,5 +226,5 @@ struct expr_ops expr_ops_hash = {
.get = nftnl_expr_hash_get,
.parse = nftnl_expr_hash_parse,
.build = nftnl_expr_hash_build,
- .snprintf = nftnl_expr_hash_snprintf,
+ .output = nftnl_expr_hash_snprintf,
};
diff --git a/src/expr/immediate.c b/src/expr/immediate.c
index 94b043c..5d477a8 100644
--- a/src/expr/immediate.c
+++ b/src/expr/immediate.c
@@ -229,5 +229,5 @@ struct expr_ops expr_ops_immediate = {
.get = nftnl_expr_immediate_get,
.parse = nftnl_expr_immediate_parse,
.build = nftnl_expr_immediate_build,
- .snprintf = nftnl_expr_immediate_snprintf,
+ .output = nftnl_expr_immediate_snprintf,
};
diff --git a/src/expr/last.c b/src/expr/last.c
index e2a60c4..641b713 100644
--- a/src/expr/last.c
+++ b/src/expr/last.c
@@ -134,5 +134,5 @@ struct expr_ops expr_ops_last = {
.get = nftnl_expr_last_get,
.parse = nftnl_expr_last_parse,
.build = nftnl_expr_last_build,
- .snprintf = nftnl_expr_last_snprintf,
+ .output = nftnl_expr_last_snprintf,
};
diff --git a/src/expr/limit.c b/src/expr/limit.c
index 3dfd54a..1870e0e 100644
--- a/src/expr/limit.c
+++ b/src/expr/limit.c
@@ -202,5 +202,5 @@ struct expr_ops expr_ops_limit = {
.get = nftnl_expr_limit_get,
.parse = nftnl_expr_limit_parse,
.build = nftnl_expr_limit_build,
- .snprintf = nftnl_expr_limit_snprintf,
+ .output = nftnl_expr_limit_snprintf,
};
diff --git a/src/expr/log.c b/src/expr/log.c
index 86db548..180d839 100644
--- a/src/expr/log.c
+++ b/src/expr/log.c
@@ -253,5 +253,5 @@ struct expr_ops expr_ops_log = {
.get = nftnl_expr_log_get,
.parse = nftnl_expr_log_parse,
.build = nftnl_expr_log_build,
- .snprintf = nftnl_expr_log_snprintf,
+ .output = nftnl_expr_log_snprintf,
};
diff --git a/src/expr/lookup.c b/src/expr/lookup.c
index 83adce9..a06c338 100644
--- a/src/expr/lookup.c
+++ b/src/expr/lookup.c
@@ -206,5 +206,5 @@ struct expr_ops expr_ops_lookup = {
.get = nftnl_expr_lookup_get,
.parse = nftnl_expr_lookup_parse,
.build = nftnl_expr_lookup_build,
- .snprintf = nftnl_expr_lookup_snprintf,
+ .output = nftnl_expr_lookup_snprintf,
};
diff --git a/src/expr/masq.c b/src/expr/masq.c
index 684708c..e6e528d 100644
--- a/src/expr/masq.c
+++ b/src/expr/masq.c
@@ -163,5 +163,5 @@ struct expr_ops expr_ops_masq = {
.get = nftnl_expr_masq_get,
.parse = nftnl_expr_masq_parse,
.build = nftnl_expr_masq_build,
- .snprintf = nftnl_expr_masq_snprintf,
+ .output = nftnl_expr_masq_snprintf,
};
diff --git a/src/expr/match.c b/src/expr/match.c
index 533fdf5..f472add 100644
--- a/src/expr/match.c
+++ b/src/expr/match.c
@@ -189,5 +189,5 @@ struct expr_ops expr_ops_match = {
.get = nftnl_expr_match_get,
.parse = nftnl_expr_match_parse,
.build = nftnl_expr_match_build,
- .snprintf = nftnl_expr_match_snprintf,
+ .output = nftnl_expr_match_snprintf,
};
diff --git a/src/expr/meta.c b/src/expr/meta.c
index 601248f..96544a4 100644
--- a/src/expr/meta.c
+++ b/src/expr/meta.c
@@ -14,7 +14,6 @@
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <net/if.h>
#include <linux/netfilter/nf_tables.h>
#include "internal.h"
@@ -133,44 +132,6 @@ nftnl_expr_meta_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int nftnl_meta_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_meta *meta = nftnl_expr_data(e);
-
- switch (meta->key) {
- case NFT_META_IIFNAME:
- case NFT_META_OIFNAME:
- case NFT_META_IIFKIND:
- case NFT_META_OIFKIND:
- case NFT_META_SDIFNAME:
- case NFT_META_BRI_IIFNAME:
- case NFT_META_BRI_OIFNAME:
- return IFNAMSIZ;
- case NFT_META_TIME_NS:
- return sizeof(uint64_t);
- default:
- break;
- }
-
- return sizeof(uint32_t);
-}
-
-static bool nftnl_meta_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_meta *meta = nftnl_expr_data(e);
-
- return reg->meta.key == meta->key;
-}
-
-static void nftnl_meta_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_meta *meta = nftnl_expr_data(e);
-
- reg->meta.key = meta->key;
-}
-
static const char *meta_key2str_array[NFT_META_MAX] = {
[NFT_META_LEN] = "len",
[NFT_META_PROTOCOL] = "protocol",
@@ -255,10 +216,5 @@ struct expr_ops expr_ops_meta = {
.get = nftnl_expr_meta_get,
.parse = nftnl_expr_meta_parse,
.build = nftnl_expr_meta_build,
- .snprintf = nftnl_expr_meta_snprintf,
- .reg = {
- .len = nftnl_meta_reg_len,
- .cmp = nftnl_meta_reg_cmp,
- .update = nftnl_meta_reg_update,
- },
+ .output = nftnl_expr_meta_snprintf,
};
diff --git a/src/expr/nat.c b/src/expr/nat.c
index 0a9cdd7..ca727be 100644
--- a/src/expr/nat.c
+++ b/src/expr/nat.c
@@ -274,5 +274,5 @@ struct expr_ops expr_ops_nat = {
.get = nftnl_expr_nat_get,
.parse = nftnl_expr_nat_parse,
.build = nftnl_expr_nat_build,
- .snprintf = nftnl_expr_nat_snprintf,
+ .output = nftnl_expr_nat_snprintf,
};
diff --git a/src/expr/numgen.c b/src/expr/numgen.c
index 159dfec..d4020a6 100644
--- a/src/expr/numgen.c
+++ b/src/expr/numgen.c
@@ -180,5 +180,5 @@ struct expr_ops expr_ops_ng = {
.get = nftnl_expr_ng_get,
.parse = nftnl_expr_ng_parse,
.build = nftnl_expr_ng_build,
- .snprintf = nftnl_expr_ng_snprintf,
+ .output = nftnl_expr_ng_snprintf,
};
diff --git a/src/expr/objref.c b/src/expr/objref.c
index a4b6470..ad0688f 100644
--- a/src/expr/objref.c
+++ b/src/expr/objref.c
@@ -205,5 +205,5 @@ struct expr_ops expr_ops_objref = {
.get = nftnl_expr_objref_get,
.parse = nftnl_expr_objref_parse,
.build = nftnl_expr_objref_build,
- .snprintf = nftnl_expr_objref_snprintf,
+ .output = nftnl_expr_objref_snprintf,
};
diff --git a/src/expr/osf.c b/src/expr/osf.c
index 666b6b7..f15a722 100644
--- a/src/expr/osf.c
+++ b/src/expr/osf.c
@@ -11,7 +11,6 @@
#include <libnftnl/rule.h>
#define OSF_GENRE_SIZE 32
-#define NFT_OSF_MAXGENRELEN 16
struct nftnl_expr_osf {
enum nft_registers dreg;
@@ -126,32 +125,6 @@ nftnl_expr_osf_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_osf_reg_len(const struct nftnl_expr *e)
-{
- return NFT_OSF_MAXGENRELEN;
-}
-
-static bool
-nftnl_expr_osf_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_osf *osf = nftnl_expr_data(e);
-
- return reg->osf.ttl == osf->ttl &&
- reg->osf.flags == osf->flags;
-}
-
-static void
-nftnl_expr_osf_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_osf *osf = nftnl_expr_data(e);
-
- reg->osf.ttl = osf->ttl;
- reg->osf.flags = osf->flags;
-}
-
-static int
nftnl_expr_osf_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
{
@@ -174,10 +147,5 @@ struct expr_ops expr_ops_osf = {
.get = nftnl_expr_osf_get,
.parse = nftnl_expr_osf_parse,
.build = nftnl_expr_osf_build,
- .snprintf = nftnl_expr_osf_snprintf,
- .reg = {
- .len = nftnl_expr_osf_reg_len,
- .cmp = nftnl_expr_osf_reg_cmp,
- .update = nftnl_expr_osf_reg_update,
- },
+ .output = nftnl_expr_osf_snprintf,
};
diff --git a/src/expr/payload.c b/src/expr/payload.c
index 8b41a9d..a0402c8 100644
--- a/src/expr/payload.c
+++ b/src/expr/payload.c
@@ -203,32 +203,6 @@ nftnl_expr_payload_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int nftnl_payload_reg_len(const struct nftnl_expr *expr)
-{
- const struct nftnl_expr_payload *payload = nftnl_expr_data(expr);
-
- return payload->len;
-}
-
-static bool nftnl_payload_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_payload *payload = nftnl_expr_data(e);
-
- return reg->payload.base == payload->base &&
- reg->payload.offset == payload->offset &&
- reg->len >= payload->len;
-}
-
-static void nftnl_payload_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_payload *payload = nftnl_expr_data(e);
-
- reg->payload.base = payload->base;
- reg->payload.offset = payload->offset;
-}
-
static const char *base2str_array[NFT_PAYLOAD_INNER_HEADER + 1] = {
[NFT_PAYLOAD_LL_HEADER] = "link",
[NFT_PAYLOAD_NETWORK_HEADER] = "network",
@@ -285,10 +259,5 @@ struct expr_ops expr_ops_payload = {
.get = nftnl_expr_payload_get,
.parse = nftnl_expr_payload_parse,
.build = nftnl_expr_payload_build,
- .snprintf = nftnl_expr_payload_snprintf,
- .reg = {
- .len = nftnl_payload_reg_len,
- .cmp = nftnl_payload_reg_cmp,
- .update = nftnl_payload_reg_update,
- },
+ .output = nftnl_expr_payload_snprintf,
};
diff --git a/src/expr/queue.c b/src/expr/queue.c
index 8f70977..de287f2 100644
--- a/src/expr/queue.c
+++ b/src/expr/queue.c
@@ -193,5 +193,5 @@ struct expr_ops expr_ops_queue = {
.get = nftnl_expr_queue_get,
.parse = nftnl_expr_queue_parse,
.build = nftnl_expr_queue_build,
- .snprintf = nftnl_expr_queue_snprintf,
+ .output = nftnl_expr_queue_snprintf,
};
diff --git a/src/expr/quota.c b/src/expr/quota.c
index 8c841d8..835729c 100644
--- a/src/expr/quota.c
+++ b/src/expr/quota.c
@@ -147,5 +147,5 @@ struct expr_ops expr_ops_quota = {
.get = nftnl_expr_quota_get,
.parse = nftnl_expr_quota_parse,
.build = nftnl_expr_quota_build,
- .snprintf = nftnl_expr_quota_snprintf,
+ .output = nftnl_expr_quota_snprintf,
};
diff --git a/src/expr/range.c b/src/expr/range.c
index f76843a..473add8 100644
--- a/src/expr/range.c
+++ b/src/expr/range.c
@@ -213,5 +213,5 @@ struct expr_ops expr_ops_range = {
.get = nftnl_expr_range_get,
.parse = nftnl_expr_range_parse,
.build = nftnl_expr_range_build,
- .snprintf = nftnl_expr_range_snprintf,
+ .output = nftnl_expr_range_snprintf,
};
diff --git a/src/expr/redir.c b/src/expr/redir.c
index 4f56cb4..87c2acc 100644
--- a/src/expr/redir.c
+++ b/src/expr/redir.c
@@ -167,5 +167,5 @@ struct expr_ops expr_ops_redir = {
.get = nftnl_expr_redir_get,
.parse = nftnl_expr_redir_parse,
.build = nftnl_expr_redir_build,
- .snprintf = nftnl_expr_redir_snprintf,
+ .output = nftnl_expr_redir_snprintf,
};
diff --git a/src/expr/reject.c b/src/expr/reject.c
index 716d25c..c7c9441 100644
--- a/src/expr/reject.c
+++ b/src/expr/reject.c
@@ -134,5 +134,5 @@ struct expr_ops expr_ops_reject = {
.get = nftnl_expr_reject_get,
.parse = nftnl_expr_reject_parse,
.build = nftnl_expr_reject_build,
- .snprintf = nftnl_expr_reject_snprintf,
+ .output = nftnl_expr_reject_snprintf,
};
diff --git a/src/expr/rt.c b/src/expr/rt.c
index 16a1aff..695a658 100644
--- a/src/expr/rt.c
+++ b/src/expr/rt.c
@@ -12,7 +12,6 @@
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <assert.h>
#include <linux/netfilter/nf_tables.h>
#include "internal.h"
@@ -113,46 +112,6 @@ nftnl_expr_rt_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int nftnl_expr_rt_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_rt *rt = nftnl_expr_data(e);
-
- switch (rt->key) {
- case NFT_RT_CLASSID:
- case NFT_RT_NEXTHOP4:
- return sizeof(uint32_t);
- case NFT_RT_NEXTHOP6:
- return sizeof(uint32_t) * 4;
- case NFT_RT_TCPMSS:
- return sizeof(uint16_t);
- case NFT_RT_XFRM:
- return sizeof(uint8_t);
- default:
- assert(0);
- break;
- }
-
- return sizeof(uint32_t);
-}
-
-static bool
-nftnl_expr_rt_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_rt *rt = nftnl_expr_data(e);
-
- return reg->rt.key == rt->key;
-}
-
-static void
-nftnl_expr_rt_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_rt *rt = nftnl_expr_data(e);
-
- reg->rt.key = rt->key;
-}
-
static const char *rt_key2str_array[NFT_RT_MAX + 1] = {
[NFT_RT_CLASSID] = "classid",
[NFT_RT_NEXTHOP4] = "nexthop4",
@@ -203,10 +162,5 @@ struct expr_ops expr_ops_rt = {
.get = nftnl_expr_rt_get,
.parse = nftnl_expr_rt_parse,
.build = nftnl_expr_rt_build,
- .snprintf = nftnl_expr_rt_snprintf,
- .reg = {
- .len = nftnl_expr_rt_reg_len,
- .cmp = nftnl_expr_rt_reg_cmp,
- .update = nftnl_expr_rt_reg_update,
- },
+ .output = nftnl_expr_rt_snprintf,
};
diff --git a/src/expr/socket.c b/src/expr/socket.c
index edd28ca..83045c0 100644
--- a/src/expr/socket.c
+++ b/src/expr/socket.c
@@ -12,7 +12,6 @@
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <assert.h>
#include <linux/netfilter/nf_tables.h>
#include "internal.h"
@@ -127,47 +126,6 @@ nftnl_expr_socket_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int
-nftnl_expr_socket_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_socket *socket = nftnl_expr_data(e);
-
- switch(socket->key) {
- case NFT_SOCKET_TRANSPARENT:
- case NFT_SOCKET_WILDCARD:
- return sizeof(uint8_t);
- case NFT_SOCKET_MARK:
- return sizeof(uint32_t);
- case NFT_SOCKET_CGROUPV2:
- return sizeof(uint64_t);
- default:
- assert(0);
- break;
- }
-
- return sizeof(uint32_t);
-}
-
-static bool
-nftnl_expr_socket_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_socket *socket = nftnl_expr_data(e);
-
- return reg->socket.key == socket->key &&
- reg->socket.level == socket->level;
-}
-
-static void
-nftnl_expr_socket_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_socket *socket = nftnl_expr_data(e);
-
- reg->socket.key = socket->key;
- reg->socket.level = socket->level;
-}
-
static const char *socket_key2str_array[NFT_SOCKET_MAX + 1] = {
[NFT_SOCKET_TRANSPARENT] = "transparent",
[NFT_SOCKET_MARK] = "mark",
@@ -207,10 +165,5 @@ struct expr_ops expr_ops_socket = {
.get = nftnl_expr_socket_get,
.parse = nftnl_expr_socket_parse,
.build = nftnl_expr_socket_build,
- .snprintf = nftnl_expr_socket_snprintf,
- .reg = {
- .len = nftnl_expr_socket_reg_len,
- .cmp = nftnl_expr_socket_reg_cmp,
- .update = nftnl_expr_socket_reg_update,
- },
+ .output = nftnl_expr_socket_snprintf,
};
diff --git a/src/expr/synproxy.c b/src/expr/synproxy.c
index 630f3f4..47fcaef 100644
--- a/src/expr/synproxy.c
+++ b/src/expr/synproxy.c
@@ -152,5 +152,5 @@ struct expr_ops expr_ops_synproxy = {
.get = nftnl_expr_synproxy_get,
.parse = nftnl_expr_synproxy_parse,
.build = nftnl_expr_synproxy_build,
- .snprintf = nftnl_expr_synproxy_snprintf,
+ .output = nftnl_expr_synproxy_snprintf,
};
diff --git a/src/expr/target.c b/src/expr/target.c
index b7c595a..2a3fe8a 100644
--- a/src/expr/target.c
+++ b/src/expr/target.c
@@ -189,5 +189,5 @@ struct expr_ops expr_ops_target = {
.get = nftnl_expr_target_get,
.parse = nftnl_expr_target_parse,
.build = nftnl_expr_target_build,
- .snprintf = nftnl_expr_target_snprintf,
+ .output = nftnl_expr_target_snprintf,
};
diff --git a/src/expr/tproxy.c b/src/expr/tproxy.c
index d3ee8f8..bd5ffbf 100644
--- a/src/expr/tproxy.c
+++ b/src/expr/tproxy.c
@@ -170,5 +170,5 @@ struct expr_ops expr_ops_tproxy = {
.get = nftnl_expr_tproxy_get,
.parse = nftnl_expr_tproxy_parse,
.build = nftnl_expr_tproxy_build,
- .snprintf = nftnl_expr_tproxy_snprintf,
+ .output = nftnl_expr_tproxy_snprintf,
};
diff --git a/src/expr/tunnel.c b/src/expr/tunnel.c
index 1460fd2..a00f620 100644
--- a/src/expr/tunnel.c
+++ b/src/expr/tunnel.c
@@ -145,5 +145,5 @@ struct expr_ops expr_ops_tunnel = {
.get = nftnl_expr_tunnel_get,
.parse = nftnl_expr_tunnel_parse,
.build = nftnl_expr_tunnel_build,
- .snprintf = nftnl_expr_tunnel_snprintf,
+ .output = nftnl_expr_tunnel_snprintf,
};
diff --git a/src/expr/xfrm.c b/src/expr/xfrm.c
index 7f6d7fe..2db00d5 100644
--- a/src/expr/xfrm.c
+++ b/src/expr/xfrm.c
@@ -10,7 +10,6 @@
#include <stdint.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <assert.h>
#include <linux/netfilter/nf_tables.h>
#include <linux/xfrm.h>
@@ -142,51 +141,6 @@ nftnl_expr_xfrm_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int
-nftnl_expr_xfrm_reg_len(const struct nftnl_expr *e)
-{
- const struct nftnl_expr_xfrm *xfrm = nftnl_expr_data(e);
-
- switch (xfrm->key) {
- case NFT_XFRM_KEY_REQID:
- case NFT_XFRM_KEY_SPI:
- return sizeof(uint32_t);
- case NFT_XFRM_KEY_DADDR_IP4:
- case NFT_XFRM_KEY_SADDR_IP4:
- return sizeof(struct in_addr);
- case NFT_XFRM_KEY_DADDR_IP6:
- case NFT_XFRM_KEY_SADDR_IP6:
- return sizeof(struct in6_addr);
- default:
- assert(0);
- break;
- }
-
- return sizeof(struct in_addr);
-}
-
-static bool
-nftnl_expr_xfrm_reg_cmp(const struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_xfrm *xfrm = nftnl_expr_data(e);
-
- return reg->xfrm.key == xfrm->key &&
- reg->xfrm.spnum == xfrm->spnum &&
- reg->xfrm.dir == xfrm->dir;
-}
-
-static void
-nftnl_expr_xfrm_reg_update(struct nftnl_reg *reg,
- const struct nftnl_expr *e)
-{
- const struct nftnl_expr_xfrm *xfrm = nftnl_expr_data(e);
-
- reg->xfrm.key = xfrm->key;
- reg->xfrm.spnum = xfrm->spnum;
- reg->xfrm.dir = xfrm->dir;
-}
-
static const char *xfrmkey2str_array[] = {
[NFT_XFRM_KEY_DADDR_IP4] = "daddr4",
[NFT_XFRM_KEY_SADDR_IP4] = "saddr4",
@@ -242,10 +196,5 @@ struct expr_ops expr_ops_xfrm = {
.get = nftnl_expr_xfrm_get,
.parse = nftnl_expr_xfrm_parse,
.build = nftnl_expr_xfrm_build,
- .snprintf = nftnl_expr_xfrm_snprintf,
- .reg = {
- .len = nftnl_expr_xfrm_reg_len,
- .cmp = nftnl_expr_xfrm_reg_cmp,
- .update = nftnl_expr_xfrm_reg_update,
- },
+ .output = nftnl_expr_xfrm_snprintf,
};
diff --git a/src/libnftnl.map b/src/libnftnl.map
index 3a85325..ad8f2af 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -387,10 +387,3 @@ LIBNFTNL_16 {
LIBNFTNL_17 {
nftnl_set_elem_nlmsg_build;
} LIBNFTNL_16;
-
-LIBNFTNL_18 {
- nftnl_regs_alloc;
- nftnl_regs_free;
- nftnl_reg_get;
- nftnl_reg_get_scratch;
-} LIBNFTNL_17;
diff --git a/src/obj/counter.c b/src/obj/counter.c
index ef0cd20..ebf3e74 100644
--- a/src/obj/counter.c
+++ b/src/obj/counter.c
@@ -127,5 +127,5 @@ struct obj_ops obj_ops_counter = {
.get = nftnl_obj_counter_get,
.parse = nftnl_obj_counter_parse,
.build = nftnl_obj_counter_build,
- .snprintf = nftnl_obj_counter_snprintf,
+ .output = nftnl_obj_counter_snprintf,
};
diff --git a/src/obj/ct_expect.c b/src/obj/ct_expect.c
index 8136ad9..810ba9a 100644
--- a/src/obj/ct_expect.c
+++ b/src/obj/ct_expect.c
@@ -196,5 +196,5 @@ struct obj_ops obj_ops_ct_expect = {
.get = nftnl_obj_ct_expect_get,
.parse = nftnl_obj_ct_expect_parse,
.build = nftnl_obj_ct_expect_build,
- .snprintf = nftnl_obj_ct_expect_snprintf,
+ .output = nftnl_obj_ct_expect_snprintf,
};
diff --git a/src/obj/ct_helper.c b/src/obj/ct_helper.c
index c52032a..a31bd6f 100644
--- a/src/obj/ct_helper.c
+++ b/src/obj/ct_helper.c
@@ -150,5 +150,5 @@ struct obj_ops obj_ops_ct_helper = {
.get = nftnl_obj_ct_helper_get,
.parse = nftnl_obj_ct_helper_parse,
.build = nftnl_obj_ct_helper_build,
- .snprintf = nftnl_obj_ct_helper_snprintf,
+ .output = nftnl_obj_ct_helper_snprintf,
};
diff --git a/src/obj/ct_timeout.c b/src/obj/ct_timeout.c
index 1d4f8fb..65b48bd 100644
--- a/src/obj/ct_timeout.c
+++ b/src/obj/ct_timeout.c
@@ -316,5 +316,5 @@ struct obj_ops obj_ops_ct_timeout = {
.get = nftnl_obj_ct_timeout_get,
.parse = nftnl_obj_ct_timeout_parse,
.build = nftnl_obj_ct_timeout_build,
- .snprintf = nftnl_obj_ct_timeout_snprintf,
+ .output = nftnl_obj_ct_timeout_snprintf,
};
diff --git a/src/obj/limit.c b/src/obj/limit.c
index 8b40f9d..d7b1aed 100644
--- a/src/obj/limit.c
+++ b/src/obj/limit.c
@@ -168,5 +168,5 @@ struct obj_ops obj_ops_limit = {
.get = nftnl_obj_limit_get,
.parse = nftnl_obj_limit_parse,
.build = nftnl_obj_limit_build,
- .snprintf = nftnl_obj_limit_snprintf,
+ .output = nftnl_obj_limit_snprintf,
};
diff --git a/src/obj/quota.c b/src/obj/quota.c
index 8ab3300..6c7559a 100644
--- a/src/obj/quota.c
+++ b/src/obj/quota.c
@@ -144,5 +144,5 @@ struct obj_ops obj_ops_quota = {
.get = nftnl_obj_quota_get,
.parse = nftnl_obj_quota_parse,
.build = nftnl_obj_quota_build,
- .snprintf = nftnl_obj_quota_snprintf,
+ .output = nftnl_obj_quota_snprintf,
};
diff --git a/src/obj/secmark.c b/src/obj/secmark.c
index 2ccc803..e5c24b3 100644
--- a/src/obj/secmark.c
+++ b/src/obj/secmark.c
@@ -116,5 +116,5 @@ struct obj_ops obj_ops_secmark = {
.get = nftnl_obj_secmark_get,
.parse = nftnl_obj_secmark_parse,
.build = nftnl_obj_secmark_build,
- .snprintf = nftnl_obj_secmark_snprintf,
+ .output = nftnl_obj_secmark_snprintf,
};
diff --git a/src/obj/synproxy.c b/src/obj/synproxy.c
index d689fee..baef5c2 100644
--- a/src/obj/synproxy.c
+++ b/src/obj/synproxy.c
@@ -143,5 +143,5 @@ struct obj_ops obj_ops_synproxy = {
.get = nftnl_obj_synproxy_get,
.parse = nftnl_obj_synproxy_parse,
.build = nftnl_obj_synproxy_build,
- .snprintf = nftnl_obj_synproxy_snprintf,
+ .output = nftnl_obj_synproxy_snprintf,
};
diff --git a/src/obj/tunnel.c b/src/obj/tunnel.c
index 5ede6bd..d2503dc 100644
--- a/src/obj/tunnel.c
+++ b/src/obj/tunnel.c
@@ -547,5 +547,5 @@ struct obj_ops obj_ops_tunnel = {
.get = nftnl_obj_tunnel_get,
.parse = nftnl_obj_tunnel_parse,
.build = nftnl_obj_tunnel_build,
- .snprintf = nftnl_obj_tunnel_snprintf,
+ .output = nftnl_obj_tunnel_snprintf,
};
diff --git a/src/object.c b/src/object.c
index 46e208b..232b97a 100644
--- a/src/object.c
+++ b/src/object.c
@@ -396,7 +396,7 @@ static int nftnl_obj_snprintf_dflt(char *buf, size_t remain,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
if (obj->ops) {
- ret = obj->ops->snprintf(buf + offset, remain, flags, obj);
+ ret = obj->ops->output(buf + offset, remain, flags, obj);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
ret = snprintf(buf + offset, remain, "]");
diff --git a/src/regs.c b/src/regs.c
deleted file mode 100644
index 1551aa7..0000000
--- a/src/regs.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * (C) 2012-2022 by Pablo Neira Ayuso <pablo@netfilter.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-/* Funded through the NGI0 PET Fund established by NLnet (https://nlnet.nl)
- * with support from the European Commission's Next Generation Internet
- * programme.
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <libnftnl/regs.h>
-
-#include "internal.h"
-
-EXPORT_SYMBOL(nftnl_regs_alloc);
-struct nftnl_regs *nftnl_regs_alloc(uint32_t num_regs)
-{
- struct nftnl_regs *regs;
-
- if (num_regs < 16)
- num_regs = 16;
-
- regs = calloc(1, sizeof(struct nftnl_regs));
- if (!regs)
- return NULL;
-
- regs->reg = calloc(num_regs, sizeof(struct nftnl_reg));
- if (!regs->reg) {
- free(regs->reg);
- return NULL;
- }
-
- regs->num_regs = num_regs;
-
- return regs;
-}
-
-EXPORT_SYMBOL(nftnl_regs_free);
-void nftnl_regs_free(const struct nftnl_regs *regs)
-{
- xfree(regs->reg);
- xfree(regs);
-}
-
-static enum nftnl_expr_type nftnl_expr_type(const struct nftnl_expr *expr)
-{
- if (!strcmp(expr->ops->name, "ct"))
- return NFT_EXPR_CT;
- else if (!strcmp(expr->ops->name, "exthdr"))
- return NFT_EXPR_EXTHDR;
- else if (!strcmp(expr->ops->name, "fib"))
- return NFT_EXPR_FIB;
- else if (!strcmp(expr->ops->name, "meta"))
- return NFT_EXPR_META;
- else if (!strcmp(expr->ops->name, "osf"))
- return NFT_EXPR_OSF;
- else if (!strcmp(expr->ops->name, "payload"))
- return NFT_EXPR_PAYLOAD;
- else if (!strcmp(expr->ops->name, "rt"))
- return NFT_EXPR_RT;
- else if (!strcmp(expr->ops->name, "socket"))
- return NFT_EXPR_SOCKET;
- else if (!strcmp(expr->ops->name, "xfrm"))
- return NFT_EXPR_XFRM;
-
- assert(0);
- return NFT_EXPR_UNSPEC;
-}
-
-static int nftnl_expr_reg_len(const struct nftnl_expr *expr)
-{
- return expr->ops->reg.len(expr);
-}
-
-static bool nftnl_expr_reg_cmp(const struct nftnl_regs *regs,
- const struct nftnl_expr *expr, int i)
-{
- if (regs->reg[i].type != nftnl_expr_type(expr))
- return false;
-
- return expr->ops->reg.cmp(&regs->reg[i], expr);
-}
-
-static void nft_expr_reg_update(struct nftnl_regs *regs,
- const struct nftnl_expr *expr, int i)
-{
- return expr->ops->reg.update(&regs->reg[i], expr);
-}
-
-static int reg_space(const struct nftnl_regs *regs, int i)
-{
- return sizeof(uint32_t) * regs->num_regs - sizeof(uint32_t) * i;
-}
-
-struct nftnl_reg_ctx {
- uint64_t genid;
- int reg;
- int evict;
-};
-
-static void register_track(struct nftnl_reg_ctx *ctx,
- const struct nftnl_regs *regs, int i, int len)
-{
- if (ctx->reg >= 0 || regs->reg[i].word || reg_space(regs, i) < len)
- return;
-
- if (regs->reg[i].type == NFT_EXPR_UNSPEC) {
- ctx->genid = regs->genid;
- ctx->reg = i;
- } else if (regs->reg[i].genid < ctx->genid) {
- ctx->genid = regs->reg[i].genid;
- ctx->evict = i;
- }
-}
-
-static void register_evict(struct nftnl_reg_ctx *ctx)
-{
- if (ctx->reg < 0) {
- assert(ctx->evict >= 0);
- ctx->reg = ctx->evict;
- }
-}
-
-static void __register_update(struct nftnl_regs *regs, uint8_t reg,
- int type, uint32_t len, uint8_t word,
- uint64_t genid, const struct nftnl_expr *expr)
-{
- regs->reg[reg].type = type;
- regs->reg[reg].genid = genid;
- regs->reg[reg].len = len;
- regs->reg[reg].word = word;
- nft_expr_reg_update(regs, expr, reg);
-}
-
-static void __register_cancel(struct nftnl_regs *regs, int i)
-{
- regs->reg[i].type = NFT_EXPR_UNSPEC;
- regs->reg[i].word = 0;
- regs->reg[i].len = 0;
- regs->reg[i].genid = 0;
-}
-
-static void register_cancel(struct nftnl_reg_ctx *ctx, struct nftnl_regs *regs,
- int len)
-{
- int i;
-
- for (i = ctx->reg; len > 0; i++, len -= sizeof(uint32_t)) {
- if (regs->reg[i].type == NFT_EXPR_UNSPEC)
- continue;
-
- __register_cancel(regs, i);
- }
-
- while (i < regs->num_regs && regs->reg[i].word != 0) {
- __register_cancel(regs, i);
- i++;
- }
-}
-
-static void register_update(struct nftnl_reg_ctx *ctx, struct nftnl_regs *regs,
- int type, uint32_t len, uint64_t genid,
- const struct nftnl_expr *expr)
-{
- register_cancel(ctx, regs, len);
- __register_update(regs, ctx->reg, type, len, 0, genid, expr);
-}
-
-static uint64_t reg_genid(struct nftnl_regs *regs)
-{
- return ++regs->genid;
-}
-
-EXPORT_SYMBOL(nftnl_reg_get);
-uint32_t nftnl_reg_get(struct nftnl_regs *regs, const struct nftnl_expr *expr)
-{
- struct nftnl_reg_ctx ctx = {
- .reg = -1,
- .evict = -1,
- .genid = UINT64_MAX,
- };
- enum nftnl_expr_type type;
- uint64_t genid;
- int i, j, len;
-
- type = nftnl_expr_type(expr);
- len = nftnl_expr_reg_len(expr);
-
- for (i = 0; i < regs->num_regs; i++) {
- register_track(&ctx, regs, i, len);
-
- if (!nftnl_expr_reg_cmp(regs, expr, i))
- continue;
-
- regs->reg[i].genid = reg_genid(regs);
- return i + NFT_REG32_00;
- }
-
- register_evict(&ctx);
- genid = reg_genid(regs);
- register_update(&ctx, regs, type, len, genid, expr);
-
- len -= sizeof(uint32_t);
- j = 1;
- for (i = ctx.reg + 1; len > 0; i++, len -= sizeof(uint32_t))
- __register_update(regs, i, type, len, j++, genid, expr);
-
- return ctx.reg + NFT_REG32_00;
-}
-
-EXPORT_SYMBOL(nftnl_reg_get_scratch);
-uint32_t nftnl_reg_get_scratch(struct nftnl_regs *regs, uint32_t len)
-{
- struct nftnl_reg_ctx ctx = {
- .reg = -1,
- .evict = -1,
- .genid = UINT64_MAX,
- };
- int i;
-
- for (i = 0; i < regs->num_regs; i++)
- register_track(&ctx, regs, i, len);
-
- register_evict(&ctx);
- register_cancel(&ctx, regs, len);
-
- return ctx.reg + NFT_REG32_00;
-}