json_t *meter_stmt_json(const struct stmt *stmt, struct output_ctx *octx);
json_t *queue_stmt_json(const struct stmt *stmt, struct output_ctx *octx);
json_t *verdict_stmt_json(const struct stmt *stmt, struct output_ctx *octx);
+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);
STMT_PRINT_STUB(meter)
STMT_PRINT_STUB(queue)
STMT_PRINT_STUB(verdict)
+STMT_PRINT_STUB(connlimit)
#undef STMT_PRINT_STUB
#undef EXPR_PRINT_STUB
return expr_print_json(stmt->expr, octx);
}
+json_t *connlimit_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
+{
+ json_t *root = json_pack("{s:i}", "val", stmt->connlimit.count);
+
+ if (stmt->connlimit.flags & NFT_CONNLIMIT_F_INV)
+ json_object_set_new(root, "inv", json_true());
+
+ return json_pack("{s:o}", "ct count", root);
+}
+
static json_t *table_print_json_full(struct netlink_ctx *ctx,
struct table *table)
{
return stmt;
}
+static struct stmt *json_parse_connlimit_stmt(struct json_ctx *ctx,
+ const char *key, json_t *value)
+{
+ struct stmt *stmt = connlimit_stmt_alloc(int_loc);
+
+ if (json_unpack_err(ctx, value, "{s:i}",
+ "val", &stmt->connlimit.count)) {
+ stmt_free(stmt);
+ return NULL;
+ }
+
+ json_unpack(value, "{s:b}", "inv", &stmt->connlimit.flags);
+ if (stmt->connlimit.flags)
+ stmt->connlimit.flags = NFT_CONNLIMIT_F_INV;
+
+ return stmt;
+}
+
static struct stmt *json_parse_stmt(struct json_ctx *ctx, json_t *root)
{
struct {
{ "ct helper", json_parse_cthelper_stmt },
{ "meter", json_parse_meter_stmt },
{ "queue", json_parse_queue_stmt },
+ { "ct count", json_parse_connlimit_stmt },
};
const char *type;
unsigned int i;
.type = STMT_CONNLIMIT,
.name = "connlimit",
.print = connlimit_stmt_print,
+ .json = connlimit_stmt_json,
};
struct stmt *connlimit_stmt_alloc(const struct location *loc)