summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2016-04-26 14:16:58 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-05-09 22:57:10 +0200
commit600890067c40e1846398db373b9c38b6fe9a16a6 (patch)
treea2419ba0f0a817937bce9ca0f048ec43d24e5b42 /src/rule.c
parent813da08a8bd9d320d6a6a52b3cacc87b8d0ed1f9 (diff)
libnftnl: constify object arguments to various functions
flow table support needs constant object arguments to printing functions to avoid ugly casts. While at it, also constify object arguments to message construction, destructor and a few helper functions. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/rule.c b/src/rule.c
index 9c09127..31c0658 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -64,7 +64,7 @@ struct nftnl_rule *nftnl_rule_alloc(void)
}
EXPORT_SYMBOL_ALIAS(nftnl_rule_alloc, nft_rule_alloc);
-void nftnl_rule_free(struct nftnl_rule *r)
+void nftnl_rule_free(const struct nftnl_rule *r)
{
struct nftnl_expr *e, *tmp;
@@ -716,8 +716,9 @@ int nftnl_rule_parse_file(struct nftnl_rule *r, enum nftnl_parse_type type,
}
EXPORT_SYMBOL_ALIAS(nftnl_rule_parse_file, nft_rule_parse_file);
-static int nftnl_rule_snprintf_json(char *buf, size_t size, struct nftnl_rule *r,
- uint32_t type, uint32_t flags)
+static int nftnl_rule_snprintf_json(char *buf, size_t size,
+ const struct nftnl_rule *r,
+ uint32_t type, uint32_t flags)
{
int ret, len = size, offset = 0;
struct nftnl_expr *expr;
@@ -794,8 +795,9 @@ static int nftnl_rule_snprintf_json(char *buf, size_t size, struct nftnl_rule *r
return offset;
}
-static int nftnl_rule_snprintf_xml(char *buf, size_t size, struct nftnl_rule *r,
- uint32_t type, uint32_t flags)
+static int nftnl_rule_snprintf_xml(char *buf, size_t size,
+ const struct nftnl_rule *r,
+ uint32_t type, uint32_t flags)
{
int ret, len = size, offset = 0;
struct nftnl_expr *expr;
@@ -860,8 +862,9 @@ static int nftnl_rule_snprintf_xml(char *buf, size_t size, struct nftnl_rule *r,
return offset;
}
-static int nftnl_rule_snprintf_default(char *buf, size_t size, struct nftnl_rule *r,
- uint32_t type, uint32_t flags)
+static int nftnl_rule_snprintf_default(char *buf, size_t size,
+ const struct nftnl_rule *r,
+ uint32_t type, uint32_t flags)
{
struct nftnl_expr *expr;
int ret, len = size, offset = 0, i;
@@ -930,8 +933,9 @@ static int nftnl_rule_snprintf_default(char *buf, size_t size, struct nftnl_rule
return offset;
}
-static int nftnl_rule_cmd_snprintf(char *buf, size_t size, struct nftnl_rule *r,
- uint32_t cmd, uint32_t type, uint32_t flags)
+static int nftnl_rule_cmd_snprintf(char *buf, size_t size,
+ const struct nftnl_rule *r, uint32_t cmd,
+ uint32_t type, uint32_t flags)
{
int ret, len = size, offset = 0;
uint32_t inner_flags = flags;
@@ -966,23 +970,23 @@ static int nftnl_rule_cmd_snprintf(char *buf, size_t size, struct nftnl_rule *r,
return offset;
}
-int nftnl_rule_snprintf(char *buf, size_t size, struct nftnl_rule *r,
- uint32_t type, uint32_t flags)
+int nftnl_rule_snprintf(char *buf, size_t size, const struct nftnl_rule *r,
+ uint32_t type, uint32_t flags)
{
return nftnl_rule_cmd_snprintf(buf, size, r, nftnl_flag2cmd(flags), type,
flags);
}
EXPORT_SYMBOL_ALIAS(nftnl_rule_snprintf, nft_rule_snprintf);
-static inline int nftnl_rule_do_snprintf(char *buf, size_t size, void *r,
- uint32_t cmd, uint32_t type,
- uint32_t flags)
+static inline int nftnl_rule_do_snprintf(char *buf, size_t size, const void *r,
+ uint32_t cmd, uint32_t type,
+ uint32_t flags)
{
return nftnl_rule_snprintf(buf, size, r, type, flags);
}
-int nftnl_rule_fprintf(FILE *fp, struct nftnl_rule *r, uint32_t type,
- uint32_t flags)
+int nftnl_rule_fprintf(FILE *fp, const struct nftnl_rule *r, uint32_t type,
+ uint32_t flags)
{
return nftnl_fprintf(fp, r, NFTNL_CMD_UNSPEC, type, flags,
nftnl_rule_do_snprintf);
@@ -1081,7 +1085,7 @@ void nftnl_rule_list_free(struct nftnl_rule_list *list)
}
EXPORT_SYMBOL_ALIAS(nftnl_rule_list_free, nft_rule_list_free);
-int nftnl_rule_list_is_empty(struct nftnl_rule_list *list)
+int nftnl_rule_list_is_empty(const struct nftnl_rule_list *list)
{
return list_empty(&list->list);
}
@@ -1166,7 +1170,7 @@ struct nftnl_rule *nftnl_rule_list_iter_next(struct nftnl_rule_list_iter *iter)
}
EXPORT_SYMBOL_ALIAS(nftnl_rule_list_iter_next, nft_rule_list_iter_next);
-void nftnl_rule_list_iter_destroy(struct nftnl_rule_list_iter *iter)
+void nftnl_rule_list_iter_destroy(const struct nftnl_rule_list_iter *iter)
{
xfree(iter);
}