assert(basetype == TYPE_INTEGER);
- if (div_round_up(i->len, BITS_PER_BYTE) >= 2) {
- op = byteorder_conversion_op(i, byteorder);
- unary = unary_expr_alloc(&i->location, op, i);
- if (expr_evaluate(ctx, &unary) < 0)
- return -1;
+ switch (i->etype) {
+ case EXPR_VALUE:
+ if (i->byteorder == BYTEORDER_HOST_ENDIAN)
+ mpz_switch_byteorder(i->value, div_round_up(i->len, BITS_PER_BYTE));
+ break;
+ default:
+ if (div_round_up(i->len, BITS_PER_BYTE) >= 2) {
+ op = byteorder_conversion_op(i, byteorder);
+ unary = unary_expr_alloc(&i->location, op, i);
+ if (expr_evaluate(ctx, &unary) < 0)
+ return -1;
- list_replace(&i->list, &unary->list);
+ list_replace(&i->list, &unary->list);
+ }
}
}
static void expr_postprocess_value(struct rule_pp_ctx *ctx, struct expr **exprp)
{
+ bool interval = (ctx->set && ctx->set->flags & NFT_SET_INTERVAL);
struct expr *expr = *exprp;
// FIXME
- if (expr->byteorder == BYTEORDER_HOST_ENDIAN)
+ if (expr->byteorder == BYTEORDER_HOST_ENDIAN && !interval)
mpz_switch_byteorder(expr->value, expr->len / BITS_PER_BYTE);
if (expr_basetype(expr)->type == TYPE_STRING)
datatype_set(expr->left, expr->right->dtype);
}
+ ctx->set = expr->right->set;
expr_postprocess(ctx, &expr->left);
+ ctx->set = NULL;
break;
default:
expr_postprocess(ctx, &expr->left);