Revision 508d9360 filter/filter.c

View differences:

filter/filter.c
440 440
  return CMP_ERROR;
441 441
}
442 442

  
443
static void val_print(struct f_val v);
444

  
445 443
static void
446 444
tree_node_print(struct f_tree *t, char **sep)
447 445
{
......
474 472
/*
475 473
 * val_print - format filter value
476 474
 */
477
static void
475
void
478 476
val_print(struct f_val v)
479 477
{
480 478
  char buf2[1024];
......
558 556
#define TWOARGS_C TWOARGS \
559 557
                  if (v1.type != v2.type) \
560 558
		    runtime( "Can't operate with values of incompatible types" );
559
#define ACCESS_RTE \
560
  do { if (!f_rte) runtime("No route to access"); } while (0)
561 561

  
562 562
/**
563 563
 * interpret
......
821 821
    break;
822 822
  case 'a':	/* rta access */
823 823
    {
824
      ACCESS_RTE;
824 825
      struct rta *rta = (*f_rte)->attrs;
825 826
      res.type = what->aux;
826 827
      switch(res.type) {
......
845 846
    }
846 847
    break;
847 848
  case P('a','S'):
849
    ACCESS_RTE;
848 850
    ONEARG;
849 851
    if (what->aux != v1.type)
850 852
      runtime( "Attempt to set static attribute to incompatible type" );
......
877 879
    }
878 880
    break;
879 881
  case P('e','a'):	/* Access to extended attributes */
882
    ACCESS_RTE;
880 883
    {
881 884
      eattr *e = NULL;
882 885
      if (!(f_flags & FF_FORCE_TMPATTR))
......
944 947
    }
945 948
    break;
946 949
  case P('e','S'):
950
    ACCESS_RTE;
947 951
    ONEARG;
948 952
    {
949 953
      struct ea_list *l = lp_alloc(f_pool, sizeof(struct ea_list) + sizeof(eattr));
......
1021 1025
    }
1022 1026
    break;
1023 1027
  case 'P':
1028
    ACCESS_RTE;
1024 1029
    res.type = T_INT;
1025 1030
    res.val.i = (*f_rte)->pref;
1026 1031
    break;
1027 1032
  case P('P','S'):
1033
    ACCESS_RTE;
1028 1034
    ONEARG;
1029 1035
    if (v1.type != T_INT)
1030 1036
      runtime( "Can't set preference to non-integer" );
......
1246 1252
    }
1247 1253
    else
1248 1254
    {
1255
      ACCESS_RTE;
1249 1256
      v1.val.px.ip = (*f_rte)->net->n.prefix;
1250 1257
      v1.val.px.len = (*f_rte)->net->n.pxlen;
1251 1258

  
......
1478 1485
  return res.val.i;
1479 1486
}
1480 1487

  
1481
int
1482
f_eval_int(struct f_inst *expr)
1488
struct f_val
1489
f_eval(struct f_inst *expr, struct linpool *tmp_pool)
1483 1490
{
1484
  /* Called independently in parse-time to eval expressions */
1485
  struct f_val res;
1486

  
1487 1491
  f_flags = 0;
1488 1492
  f_tmp_attrs = NULL;
1489 1493
  f_rte = NULL;
1490
  f_pool = cfg_mem;
1494
  f_pool = tmp_pool;
1491 1495

  
1492 1496
  log_reset();
1493
  res = interpret(expr);
1497
  return interpret(expr);
1498
}
1499

  
1500
int
1501
f_eval_int(struct f_inst *expr)
1502
{
1503
  /* Called independently in parse-time to eval expressions */
1504
  struct f_val res = f_eval(expr, cfg_mem);
1494 1505

  
1495 1506
  if (res.type != T_INT)
1496 1507
    cf_error("Integer expression expected");
1508

  
1497 1509
  return res.val.i;
1498 1510
}
1499 1511

  

Also available in: Unified diff