diff options
Diffstat (limited to 'src/datatype.c')
-rw-r--r-- | src/datatype.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/datatype.c b/src/datatype.c index 6d6826e9..039b4e52 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -113,7 +113,7 @@ void datatype_print(const struct expr *expr, struct output_ctx *octx) expr->dtype->name); } -struct error_record *symbol_parse(const struct expr *sym, +struct error_record *symbol_parse(struct parse_ctx *ctx, const struct expr *sym, struct expr **res) { const struct datatype *dtype = sym->dtype; @@ -124,9 +124,9 @@ struct error_record *symbol_parse(const struct expr *sym, return error(&sym->location, "No symbol type information"); do { if (dtype->parse != NULL) - return dtype->parse(sym, res); + return dtype->parse(ctx, sym, res); if (dtype->sym_tbl != NULL) - return symbolic_constant_parse(sym, dtype->sym_tbl, + return symbolic_constant_parse(ctx, sym, dtype->sym_tbl, res); } while ((dtype = dtype->basetype)); @@ -135,7 +135,8 @@ struct error_record *symbol_parse(const struct expr *sym, sym->dtype->desc); } -struct error_record *symbolic_constant_parse(const struct expr *sym, +struct error_record *symbolic_constant_parse(struct parse_ctx *ctx, + const struct expr *sym, const struct symbol_table *tbl, struct expr **res) { @@ -155,7 +156,7 @@ struct error_record *symbolic_constant_parse(const struct expr *sym, *res = NULL; do { if (dtype->basetype->parse) { - erec = dtype->basetype->parse(sym, res); + erec = dtype->basetype->parse(ctx, sym, res); if (erec != NULL) return erec; if (*res) @@ -300,7 +301,8 @@ static void verdict_type_print(const struct expr *expr, struct output_ctx *octx) } } -static struct error_record *verdict_type_parse(const struct expr *sym, +static struct error_record *verdict_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { *res = constant_expr_alloc(&sym->location, &string_type, @@ -359,7 +361,8 @@ static void integer_type_print(const struct expr *expr, struct output_ctx *octx) nft_gmp_print(octx, fmt, expr->value); } -static struct error_record *integer_type_parse(const struct expr *sym, +static struct error_record *integer_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { mpz_t v; @@ -397,7 +400,8 @@ static void string_type_print(const struct expr *expr, struct output_ctx *octx) nft_print(octx, "\"%s\"", data); } -static struct error_record *string_type_parse(const struct expr *sym, +static struct error_record *string_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { *res = constant_expr_alloc(&sym->location, &string_type, @@ -432,7 +436,8 @@ static void lladdr_type_print(const struct expr *expr, struct output_ctx *octx) } } -static struct error_record *lladdr_type_parse(const struct expr *sym, +static struct error_record *lladdr_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { char buf[strlen(sym->identifier) + 1], *p; @@ -483,7 +488,8 @@ static void ipaddr_type_print(const struct expr *expr, struct output_ctx *octx) nft_print(octx, "%s", buf); } -static struct error_record *ipaddr_type_parse(const struct expr *sym, +static struct error_record *ipaddr_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { struct addrinfo *ai, hints = { .ai_family = AF_INET, @@ -541,7 +547,8 @@ static void ip6addr_type_print(const struct expr *expr, struct output_ctx *octx) nft_print(octx, "%s", buf); } -static struct error_record *ip6addr_type_parse(const struct expr *sym, +static struct error_record *ip6addr_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { struct addrinfo *ai, hints = { .ai_family = AF_INET6, @@ -595,7 +602,8 @@ static void inet_protocol_type_print(const struct expr *expr, integer_type_print(expr, octx); } -static struct error_record *inet_protocol_type_parse(const struct expr *sym, +static struct error_record *inet_protocol_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { struct protoent *p; @@ -676,7 +684,8 @@ void inet_service_type_print(const struct expr *expr, struct output_ctx *octx) integer_type_print(expr, octx); } -static struct error_record *inet_service_type_parse(const struct expr *sym, +static struct error_record *inet_service_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { struct addrinfo *ai; @@ -796,10 +805,11 @@ static void mark_type_print(const struct expr *expr, struct output_ctx *octx) return symbolic_constant_print(mark_tbl, expr, true, octx); } -static struct error_record *mark_type_parse(const struct expr *sym, +static struct error_record *mark_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { - return symbolic_constant_parse(sym, mark_tbl, res); + return symbolic_constant_parse(ctx, sym, mark_tbl, res); } const struct datatype mark_type = { @@ -1019,7 +1029,8 @@ static void time_type_print(const struct expr *expr, struct output_ctx *octx) time_print(mpz_get_uint64(expr->value), octx); } -static struct error_record *time_type_parse(const struct expr *sym, +static struct error_record *time_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { struct error_record *erec; @@ -1050,7 +1061,8 @@ const struct datatype time_type = { .parse = time_type_parse, }; -static struct error_record *concat_type_parse(const struct expr *sym, +static struct error_record *concat_type_parse(struct parse_ctx *ctx, + const struct expr *sym, struct expr **res) { return error(&sym->location, "invalid data type, expected %s", |