summaryrefslogtreecommitdiffstats
path: root/include/json.h
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-06-18 10:11:46 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-06-18 11:18:02 +0200
commit4677971a01dc4d92087dab139428cf4eaa189536 (patch)
tree6f287f244a935755cf004f737b2b850694820871 /include/json.h
parent5ca7ad252366865225d5c59d297e71215b68f027 (diff)
libnftables: Simplify nft_run_cmd_from_buffer footprint
With libnftables documentation being upstream and one confirmed external user (nftlb), time to break the API! First of all, the command buffer passed to nft_run_cmd_from_buffer may (and should) be const. One should consider it a bug if that function ever changed it's content. On the other hand, there is no point in passing the buffer's length as separate argument: NULL bytes are not expected to occur in the input, so it is safe to rely upon strlen(). Also, the actual parsers don't require a buffer length passed to them, either. The only use-case for it is when reallocating the buffer to append a final newline character, there strlen() is perfectly sufficient. Suggested-by: Harald Welte <laforge@gnumonks.org> Cc: Laura Garcia Liebana <nevola@gmail.com> Cc: Eric Leblond <eric@regit.org> Cc: Arturo Borrero Gonzalez <arturo@netfilter.org> Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/json.h')
-rw-r--r--include/json.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/json.h b/include/json.h
index 0a93bca8..b75512b8 100644
--- a/include/json.h
+++ b/include/json.h
@@ -78,7 +78,7 @@ json_t *connlimit_stmt_json(const struct stmt *stmt, struct output_ctx *octx);
int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd);
-int nft_parse_json_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
struct list_head *msgs, struct list_head *cmds);
int nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
struct list_head *msgs, struct list_head *cmds);
@@ -168,11 +168,12 @@ static inline int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd)
}
static inline int
-nft_parse_json_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
struct list_head *msgs, struct list_head *cmds)
{
return -EINVAL;
}
+
static inline int
nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
struct list_head *msgs, struct list_head *cmds)