Signed-off-by: Fernando Fernandez Mancera <[email protected]>
---
 src/json.c        | 7 ++++++-
 src/parser_json.c | 9 +++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/json.c b/src/json.c
index 276a3c0..4900c02 100644
--- a/src/json.c
+++ b/src/json.c
@@ -864,7 +864,12 @@ json_t *socket_expr_json(const struct expr *expr, struct 
output_ctx *octx)
 
 json_t *osf_expr_json(const struct expr *expr, struct output_ctx *octx)
 {
-       json_t *root = json_pack("{s:s}", "key", "name");
+       json_t *root;
+
+       if (expr->osf.flags & NFT_OSF_F_VERSION)
+               root = json_pack("{s:s}", "key", "version");
+       else
+               root = json_pack("{s:s}", "key", "name");
 
        switch (expr->osf.ttl) {
        case 1:
diff --git a/src/parser_json.c b/src/parser_json.c
index 7b190bc..07defc0 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -381,6 +381,7 @@ static struct expr *json_parse_osf_expr(struct json_ctx 
*ctx,
                                        const char *type, json_t *root)
 {
        const char *key, *ttl;
+       uint32_t flagval = 0;
        uint8_t ttlval = 0;
 
        if (json_unpack_err(ctx, root, "{s:s}", "key", &key))
@@ -397,8 +398,12 @@ static struct expr *json_parse_osf_expr(struct json_ctx 
*ctx,
                }
        }
 
-       if (!strcmp(key, "name"))
-               return osf_expr_alloc(int_loc, ttlval);
+       if (!strcmp(key, "name")) {
+               return osf_expr_alloc(int_loc, ttlval, flagval);
+       } else if (!strcmp(key, "version")) {
+               flagval |= NFT_OSF_F_VERSION;
+               return osf_expr_alloc(int_loc, ttlval, flagval);
+       }
 
        json_error(ctx, "Invalid osf key value.");
        return NULL;
-- 
2.20.1

Reply via email to