summaryrefslogtreecommitdiffstats
path: root/src/obj/secmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/obj/secmark.c')
-rw-r--r--src/obj/secmark.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/src/obj/secmark.c b/src/obj/secmark.c
index e27b5fa..25b04e2 100644
--- a/src/obj/secmark.c
+++ b/src/obj/secmark.c
@@ -1,10 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* (C) 2012-2016 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.
*/
#include <stdio.h>
@@ -30,8 +26,6 @@ static int nftnl_obj_secmark_set(struct nftnl_obj *e, uint16_t type,
case NFTNL_OBJ_SECMARK_CTX:
snprintf(secmark->ctx, sizeof(secmark->ctx), "%s", (const char *)data);
break;
- default:
- return -1;
}
return 0;
}
@@ -98,40 +92,28 @@ nftnl_obj_secmark_parse(struct nftnl_obj *e, struct nlattr *attr)
return 0;
}
-static int nftnl_obj_secmark_snprintf_default(char *buf, size_t len,
- const struct nftnl_obj *e)
+static int nftnl_obj_secmark_snprintf(char *buf, size_t len,
+ uint32_t flags,
+ const struct nftnl_obj *e)
{
struct nftnl_obj_secmark *secmark = nftnl_obj_data(e);
return snprintf(buf, len, "context %s ", secmark->ctx);
}
-static int nftnl_obj_secmark_snprintf(char *buf, size_t len, uint32_t type,
- uint32_t flags,
- const struct nftnl_obj *e)
-{
- if (len)
- buf[0] = '\0';
-
- switch (type) {
- case NFTNL_OUTPUT_DEFAULT:
- return nftnl_obj_secmark_snprintf_default(buf, len, e);
- case NFTNL_OUTPUT_XML:
- case NFTNL_OUTPUT_JSON:
- default:
- break;
- }
- return -1;
-}
+static struct attr_policy obj_secmark_attr_policy[__NFTNL_OBJ_SECMARK_MAX] = {
+ [NFTNL_OBJ_SECMARK_CTX] = { .maxlen = NFT_SECMARK_CTX_MAXLEN },
+};
struct obj_ops obj_ops_secmark = {
.name = "secmark",
.type = NFT_OBJECT_SECMARK,
.alloc_len = sizeof(struct nftnl_obj_secmark),
- .max_attr = NFTA_SECMARK_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_SECMARK_MAX - 1,
+ .attr_policy = obj_secmark_attr_policy,
.set = nftnl_obj_secmark_set,
.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,
};