62
pm_format(struct f_path_mask *p, byte *buf, unsigned int size)
62
pm_format(struct f_path_mask *p, buffer *buf)
64
byte *end = buf + size - 16;
64
buffer_puts(buf, "[= ");
77
buf += bsprintf(buf, " %u", p->val);
81
buf += bsprintf(buf, " ?");
85
buf += bsprintf(buf, " *");
89
buf += bsprintf(buf, " %u", f_eval_asn((struct f_inst *) p->val));
71
buffer_print(buf, "%u ", p->val);
75
buffer_puts(buf, "? ");
79
buffer_puts(buf, "* ");
83
buffer_print(buf, "%u ", f_eval_asn((struct f_inst *) p->val));
100
int_cmp(int i1, int i2)
102
return (i1 > i2) - (i1 < i2);
106
uint_cmp(unsigned int i1, unsigned int i2)
90
buffer_puts(buf, "=]");
94
uint_cmp(uint i1, uint i2)
108
96
return (int)(i1 > i2) - (int)(i1 < i2);
437
424
return CMP_ERROR;
441
tree_node_print(struct f_tree *t, char **sep)
446
tree_node_print(t->left, sep);
450
if (val_compare(t->from, t->to) != 0)
457
tree_node_print(t->right, sep);
461
tree_print(struct f_tree *t)
465
tree_node_print(t, &sep);
470
* val_print - format filter value
428
* val_format - format filter value
473
val_print(struct f_val v)
431
val_format(struct f_val v, buffer *buf)
477
case T_VOID: logn("(void)"); return;
478
case T_BOOL: logn(v.val.i ? "TRUE" : "FALSE"); return;
479
case T_INT: logn("%d", v.val.i); return;
480
case T_STRING: logn("%s", v.val.s); return;
481
case T_IP: logn("%I", v.val.px.ip); return;
482
case T_PREFIX: logn("%I/%d", v.val.px.ip, v.val.px.len); return;
483
case T_PAIR: logn("(%d,%d)", v.val.i >> 16, v.val.i & 0xffff); return;
484
case T_QUAD: logn("%R", v.val.i); return;
485
case T_EC: ec_format(buf2, v.val.ec); logn("%s", buf2); return;
486
case T_PREFIX_SET: trie_print(v.val.ti); return;
487
case T_SET: tree_print(v.val.t); return;
488
case T_ENUM: logn("(enum %x)%d", v.type, v.val.i); return;
489
case T_PATH: as_path_format(v.val.ad, buf2, 1000); logn("(path %s)", buf2); return;
490
case T_CLIST: int_set_format(v.val.ad, 1, -1, buf2, 1000); logn("(clist %s)", buf2); return;
491
case T_ECLIST: ec_set_format(v.val.ad, -1, buf2, 1000); logn("(eclist %s)", buf2); return;
492
case T_PATH_MASK: pm_format(v.val.path_mask, buf2, 1000); logn("(pathmask%s)", buf2); return;
493
default: logn( "[unknown type %x]", v.type ); return;
436
case T_VOID: buffer_puts(buf, "(void)"); return;
437
case T_BOOL: buffer_puts(buf, v.val.i ? "TRUE" : "FALSE"); return;
438
case T_INT: buffer_print(buf, "%u", v.val.i); return;
439
case T_STRING: buffer_print(buf, "%s", v.val.s); return;
440
case T_IP: buffer_print(buf, "%I", v.val.px.ip); return;
441
case T_PREFIX: buffer_print(buf, "%I/%d", v.val.px.ip, v.val.px.len); return;
442
case T_PAIR: buffer_print(buf, "(%u,%u)", v.val.i >> 16, v.val.i & 0xffff); return;
443
case T_QUAD: buffer_print(buf, "%R", v.val.i); return;
444
case T_EC: ec_format(buf2, v.val.ec); buffer_print(buf, "%s", buf2); return;
445
case T_PREFIX_SET: trie_format(v.val.ti, buf); return;
446
case T_SET: tree_format(v.val.t, buf); return;
447
case T_ENUM: buffer_print(buf, "(enum %x)%u", v.type, v.val.i); return;
448
case T_PATH: as_path_format(v.val.ad, buf2, 1000); buffer_print(buf, "(path %s)", buf2); return;
449
case T_CLIST: int_set_format(v.val.ad, 1, -1, buf2, 1000); buffer_print(buf, "(clist %s)", buf2); return;
450
case T_ECLIST: ec_set_format(v.val.ad, -1, buf2, 1000); buffer_print(buf, "(eclist %s)", buf2); return;
451
case T_PATH_MASK: pm_format(v.val.path_mask, buf); return;
452
default: buffer_print(buf, "[unknown type %x]", v.type); return;
1223
1183
if (arg_set == 1)
1224
1184
runtime("Can't add set");
1225
1185
else if (!arg_set)
1226
res.val.ad = int_set_add(f_pool, v1.val.ad, i);
1186
res.val.ad = int_set_add(f_pool, v1.val.ad, n);
1228
1188
res.val.ad = int_set_union(f_pool, v1.val.ad, v2.val.ad);
1233
res.val.ad = int_set_del(f_pool, v1.val.ad, i);
1193
res.val.ad = int_set_del(f_pool, v1.val.ad, n);
1235
1195
res.val.ad = clist_filter(f_pool, v1.val.ad, v2, 0);