summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-02-03 14:04:42 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2014-02-03 18:43:13 +0100
commit29fd6a1df9f6c80d155a7a73b8514a68dc9cd22d (patch)
tree9dc15a3e19a6ff36ae9ee3d38c7b8190b73f0a72 /src/common.c
parent16871a3615edcf358d688a8d079b1e7b20053fb1 (diff)
parent076fd1e66e7f1bc3b2bd91f3efb84080da26fb9c (diff)
Merge branch 'master' into next-3.14
This patch includes changes to adapt this branch to the library rename that happened in the master branch. Conflicts: src/Makefile.am src/expr/cmp.c src/expr/ct.c src/expr/data_reg.c src/expr/meta.c tests/jsonfiles/01-table.json tests/jsonfiles/02-table.json tests/jsonfiles/64-ruleset.json tests/xmlfiles/01-table.xml tests/xmlfiles/02-table.xml
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index f03e730..336d2b4 100644
--- a/src/common.c
+++ b/src/common.c
@@ -7,11 +7,13 @@
* (at your option) any later version.
*/
+#include <stdlib.h>
+#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/netfilter/nfnetlink.h>
#include <libmnl/libmnl.h>
-#include <libnftables/common.h>
+#include <libnftnl/common.h>
#include "internal.h"
@@ -34,3 +36,33 @@ struct nlmsghdr *nft_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family,
return nlh;
}
EXPORT_SYMBOL(nft_nlmsg_build_hdr);
+
+struct nft_parse_err *nft_parse_err_alloc(void)
+{
+ return calloc(1, sizeof(struct nft_parse_err));
+}
+EXPORT_SYMBOL(nft_parse_err_alloc);
+
+void nft_parse_err_free(struct nft_parse_err *err)
+{
+ xfree(err);
+}
+EXPORT_SYMBOL(nft_parse_err_free);
+
+int nft_parse_perror(const char *str, struct nft_parse_err *err)
+{
+ switch (err->error) {
+ case NFT_PARSE_EBADINPUT:
+ return fprintf(stderr, "%s : Bad input format in line %d column %d\n",
+ str, err->line, err->column);
+ case NFT_PARSE_EMISSINGNODE:
+ return fprintf(stderr, "%s : Node \"%s\" not found\n",
+ str, err->node_name);
+ case NFT_PARSE_EBADTYPE:
+ return fprintf(stderr, "%s: Invalid type in node \"%s\"\n",
+ str, err->node_name);
+ default:
+ return fprintf(stderr, "Undefined error\n");
+ }
+}
+EXPORT_SYMBOL(nft_parse_perror);