mirror of
				https://gitlab.labs.nic.cz/labs/bird.git
				synced 2024-05-11 16:54:54 +00:00 
			
		
		
		
	Filter: adding explicit route-block type
This is a split-commit of the neighboring aggregator branch with a bit improved lvalue handling, to have easier merge into v3.
This commit is contained in:
		@@ -58,6 +58,7 @@ static const char * const f_type_str[] = {
 | 
			
		||||
  [T_RD]	= "rd",
 | 
			
		||||
 | 
			
		||||
  [T_ROUTE]	= "route",
 | 
			
		||||
  [T_ROUTES_BLOCK] = "block of routes",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
@@ -80,6 +81,7 @@ f_type_element_type(enum f_type t)
 | 
			
		||||
    case T_CLIST:  return T_PAIR;
 | 
			
		||||
    case T_ECLIST: return T_EC;
 | 
			
		||||
    case T_LCLIST: return T_LC;
 | 
			
		||||
    case T_ROUTES_BLOCK: return T_ROUTE;
 | 
			
		||||
    default: return T_VOID;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
@@ -209,6 +211,7 @@ val_compare(const struct f_val *v1, const struct f_val *v2)
 | 
			
		||||
  case T_STRING:
 | 
			
		||||
    return strcmp(v1->val.s, v2->val.s);
 | 
			
		||||
  case T_ROUTE:
 | 
			
		||||
  case T_ROUTES_BLOCK:
 | 
			
		||||
  default:
 | 
			
		||||
    return F_CMP_ERROR;
 | 
			
		||||
  }
 | 
			
		||||
@@ -301,6 +304,15 @@ val_same(const struct f_val *v1, const struct f_val *v2)
 | 
			
		||||
    return trie_same(v1->val.ti, v2->val.ti);
 | 
			
		||||
  case T_ROUTE:
 | 
			
		||||
    return rte_same(v1->val.rte, v2->val.rte);
 | 
			
		||||
  case T_ROUTES_BLOCK:
 | 
			
		||||
    for (
 | 
			
		||||
	rte *r1 = v1->val.rte, *r2 = v2->val.rte;
 | 
			
		||||
	r1 || r2;
 | 
			
		||||
	r1 = r1->next, r2 = r2->next
 | 
			
		||||
	)
 | 
			
		||||
      if (!r1 || !r2 || !rte_same(r1, r2))
 | 
			
		||||
	return 0;
 | 
			
		||||
    return 1;
 | 
			
		||||
  default:
 | 
			
		||||
    bug("Invalid type in val_same(): %x", v1->type);
 | 
			
		||||
  }
 | 
			
		||||
@@ -589,6 +601,19 @@ rte_format(const struct rte *rte, buffer *buf)
 | 
			
		||||
    buffer_puts(buf, "[No route]");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
rte_block_format(const struct rte *rte, buffer *buf)
 | 
			
		||||
{
 | 
			
		||||
  buffer_print(buf, "Block of routes:");
 | 
			
		||||
 | 
			
		||||
  for (int i = 0; rte; rte = rte->next, i++)
 | 
			
		||||
  {
 | 
			
		||||
    buffer_print(buf, "%s%d: ", i ? "; " : " ", i);
 | 
			
		||||
    rte_format(rte, buf);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * val_format - format filter value
 | 
			
		||||
 */
 | 
			
		||||
@@ -619,6 +644,7 @@ val_format(const struct f_val *v, buffer *buf)
 | 
			
		||||
  case T_LCLIST: lc_set_format(v->val.ad, -1, buf2, 1000); buffer_print(buf, "(lclist %s)", buf2); return;
 | 
			
		||||
  case T_PATH_MASK: pm_format(v->val.path_mask, buf); return;
 | 
			
		||||
  case T_ROUTE: rte_format(v->val.rte, buf); return;
 | 
			
		||||
  case T_ROUTES_BLOCK: rte_block_format(v->val.rte, buf); return;
 | 
			
		||||
  default:	buffer_print(buf, "[unknown type %x]", v->type); return;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user