]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: expose delinearize/linearize structures and stmt_error()
authorPablo Neira <pablo@netfilter.org>
Tue, 12 Jul 2016 20:04:16 +0000 (22:04 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Jul 2016 09:39:24 +0000 (11:39 +0200)
Needed by the follow up xt compatibility layer patch.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/erec.h
include/netlink.h
src/erec.c
src/evaluate.c
src/netlink_delinearize.c

index 25df1d0fad8e8d84363ab0162f0536adeb7c6847..36e0efa4fc1d91ac322ce6e58ea88c8a1733f181 100644 (file)
@@ -61,4 +61,16 @@ static inline void erec_queue(struct error_record *erec,
 extern void erec_print(FILE *f, const struct error_record *erec);
 extern void erec_print_list(FILE *f, struct list_head *list);
 
+struct eval_ctx;
+
+extern int __fmtstring(4, 5) __stmt_binary_error(struct eval_ctx *ctx,
+                                                const struct location *l1,
+                                                const struct location *l2,
+                                                const char *fmt, ...);
+
+#define stmt_error(ctx, s1, fmt, args...) \
+       __stmt_binary_error(ctx, &(s1)->location, NULL, fmt, ## args)
+#define stmt_binary_error(ctx, s1, s2, fmt, args...) \
+       __stmt_binary_error(ctx, &(s1)->location, &(s2)->location, fmt, ## args)
+
 #endif /* NFTABLES_EREC_H */
index 9f4656018f61255ab017f62da090c6a559e86095..76a9da44ace6161d2229b22682dd7498e02ee784 100644 (file)
 
 #include <rule.h>
 
+struct netlink_parse_ctx {
+       struct list_head        *msgs;
+       struct table            *table;
+       struct rule             *rule;
+       struct stmt             *stmt;
+       struct expr             *registers[1 + NFT_REG32_15 - NFT_REG32_00 + 1];
+};
+
+struct rule_pp_ctx {
+       struct proto_ctx        pctx;
+       struct payload_dep_ctx  pdctx;
+       struct stmt             *stmt;
+};
+
 extern const struct input_descriptor indesc_netlink;
 extern const struct location netlink_location;
 
index d5142307791195da3bc9dab6e58f6a2bae7816dd..0a1e6c74781dc38a6467443d10d02aa7401d6695 100644 (file)
@@ -176,3 +176,20 @@ void erec_print_list(FILE *f, struct list_head *list)
                erec_destroy(erec);
        }
 }
+
+int __fmtstring(4, 5) __stmt_binary_error(struct eval_ctx *ctx,
+                                         const struct location *l1,
+                                         const struct location *l2,
+                                         const char *fmt, ...)
+{
+       struct error_record *erec;
+       va_list ap;
+
+       va_start(ap, fmt);
+       erec = erec_vcreate(EREC_ERROR, l1, fmt, ap);
+       if (l2 != NULL)
+               erec_add_location(erec, l2);
+       va_end(ap);
+       erec_queue(erec, ctx->msgs);
+       return -1;
+}
index f24e5f3eabf5977d3d9cd22bfdfa22ba453c38ab..27deb15fe232f515761a888f79fc8f9729dc2600 100644 (file)
@@ -37,28 +37,6 @@ static const char *byteorder_names[] = {
        [BYTEORDER_BIG_ENDIAN]          = "big endian",
 };
 
-static int __fmtstring(4, 5) __stmt_binary_error(struct eval_ctx *ctx,
-                                                const struct location *l1,
-                                                const struct location *l2,
-                                                const char *fmt, ...)
-{
-       struct error_record *erec;
-       va_list ap;
-
-       va_start(ap, fmt);
-       erec = erec_vcreate(EREC_ERROR, l1, fmt, ap);
-       if (l2 != NULL)
-               erec_add_location(erec, l2);
-       va_end(ap);
-       erec_queue(erec, ctx->msgs);
-       return -1;
-
-}
-
-#define stmt_error(ctx, s1, fmt, args...) \
-       __stmt_binary_error(ctx, &(s1)->location, NULL, fmt, ## args)
-#define stmt_binary_error(ctx, s1, s2, fmt, args...) \
-       __stmt_binary_error(ctx, &(s1)->location, &(s2)->location, fmt, ## args)
 #define chain_error(ctx, s1, fmt, args...) \
        __stmt_binary_error(ctx, &(s1)->location, NULL, fmt, ## args)
 #define monitor_error(ctx, s1, fmt, args...) \
index 773569980e439fb122468183c9a6b01320ae9c93..fffbe266d1cc100717d2185071f9aec3806cc847 100644 (file)
 #include <sys/socket.h>
 #include <libnftnl/udata.h>
 
-struct netlink_parse_ctx {
-       struct list_head        *msgs;
-       struct table            *table;
-       struct rule             *rule;
-       struct stmt             *stmt;
-       struct expr             *registers[1 + NFT_REG32_15 - NFT_REG32_00 + 1];
-};
-
 static int netlink_parse_expr(const struct nftnl_expr *nle,
                              struct netlink_parse_ctx *ctx);
 
@@ -1047,12 +1039,6 @@ struct stmt *netlink_parse_set_expr(const struct set *set,
        return pctx->stmt;
 }
 
-struct rule_pp_ctx {
-       struct proto_ctx        pctx;
-       struct payload_dep_ctx  pdctx;
-       struct stmt             *stmt;
-};
-
 static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp);
 
 static void integer_type_postprocess(struct expr *expr)