Revision e29fa06e

View differences:

doc/bird.sgml
544 544
<p>The filter language supports common integer operators <cf>(+,-,*,/)</cf>, parentheses <cf/(a*(b+c))/, comparison
545 545
<cf/(a=b, a!=b, a&lt;b, a&gt;=b)/. Logical operations include unary not (<cf/!/), and (<cf/&amp;&amp;/) and or (<cf/&verbar;&verbar;/). 
546 546
Special operators include <cf/&tilde;/ for "is element of a set" operation - it can be
547
used on element and set of elements of the same type (returning true if element is contained in the given set), or on IP and prefix (returning true if IP is within the range defined by that prefix), or on
547
used on element and set of elements of the same type (returning true if element is contained in the given set), or
548
on two strings (returning true if first string matches a shell-like pattern stored in second string) or on IP and prefix (returning true if IP is within the range defined by that prefix), or on
548 549
prefix and prefix (returning true if first prefix is more specific than second one) or on bgppath and bgpmask (returning true if the path matches the mask) or on pair and clist (returning true if the community is element of the community list).
549 550

  
550 551

  
......
601 602
	<tag><m/ip/ gw</tag>
602 603
	Next hop packets routed using this route should be forwarded to.
603 604

  
605
	<tag><m/string/ proto</tag>
606
	The name of the protocol which the route has been imported from. Read-only.
607

  
604 608
	<tag><m/enum/ source</tag>
605 609
	what protocol has told me about this route. Possible values: <cf/RTS_DUMMY/, <cf/RTS_STATIC/, <cf/RTS_INHERIT/, <cf/RTS_DEVICE/, <cf/RTS_STATIC_DEVICE/, <cf/RTS_REDIRECT/, <cf/RTS_RIP/, <cf/RTS_OSPF/, <cf/RTS_OSPF_IA/, <cf/RTS_OSPF_EXT/, <cf/RTS_BGP/, <cf/RTS_PIPE/.
606 610

  
filter/config.Y
21 21
	INT, BOOL, IP, PREFIX, PAIR, SET, STRING, BGPMASK, BGPPATH, CLIST,
22 22
	IF, THEN, ELSE, CASE,
23 23
	TRUE, FALSE,
24
	FROM, GW, NET, MASK, SOURCE, SCOPE, CAST, DEST, PREFERENCE,
24
	FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, CAST, DEST, PREFERENCE,
25 25
	LEN,
26 26
	DEFINED,
27 27
	ADD, DELETE, CONTAINS, RESET,
......
331 331

  
332 332
 | GW      { $$ = f_new_inst(); $$->aux = T_IP;         $$->a2.i = OFFSETOF(struct rta, gw);     $$->a1.i = 1; }
333 333
 | NET     { $$ = f_new_inst(); $$->aux = T_PREFIX;     $$->a2.i = 0x12345678; /* This is actually ok - T_PREFIX is special-cased. */ }
334
 | PROTO   { $$ = f_new_inst(); $$->aux = T_STRING;     $$->a2.i = 0x12345678; /* T_STRING is also special-cased. */ }
334 335
 | SOURCE  { $$ = f_new_inst(); $$->aux = T_ENUM_RTS;   $$->a2.i = OFFSETOF(struct rta, source); }
335 336
 | SCOPE   { $$ = f_new_inst(); $$->aux = T_ENUM_SCOPE; $$->a2.i = OFFSETOF(struct rta, scope);  $$->a1.i = 1; }
336 337
 | CAST    { $$ = f_new_inst(); $$->aux = T_ENUM_RTC;   $$->a2.i = OFFSETOF(struct rta, cast); }
filter/filter.c
137 137
    return 0;
138 138
  case T_PATH_MASK:
139 139
    return pm_path_compare(v1.val.path_mask, v2.val.path_mask);
140
  case T_STRING:
141
    return strcmp(v1.val.s, v2.val.s);
140 142
  default:
141 143
    debug( "Compare of unkown entities: %x\n", v1.type );
142 144
    return CMP_ERROR;
......
153 155
    return as_path_match(v1.val.ad, v2.val.path_mask);
154 156
  if ((v1.type == T_PAIR) && (v2.type == T_CLIST))
155 157
    return int_set_contains(v2.val.ad, v1.val.i);
158
  if ((v1.type == T_STRING) && (v2.type == T_STRING))
159
    return patmatch(v2.val.s, v1.val.s);
156 160

  
157 161
  if ((v1.type == T_IP) && (v2.type == T_PREFIX))
158 162
    return !(ipa_compare(ipa_and(v2.val.px.ip, ipa_mkmask(v2.val.px.len)), ipa_and(v1.val.px.ip, ipa_mkmask(v2.val.px.len))));
......
497 501
      case T_ENUM:
498 502
	res.val.i = * ((char *) rta + what->a2.i);
499 503
	break;
504
      case T_STRING:	/* Warning: this is a special case for proto attribute */
505
	res.val.s = rta->proto->name;
506
	break;
500 507
      case T_PREFIX:	/* Warning: this works only for prefix of network */
501 508
	{
502 509
	  res.val.px.ip = (*f_rte)->net->n.prefix;

Also available in: Unified diff