nonzero if there are some errors.
<tag>-s <m/name of communication socket/</tag>
-- use given filename for a socket for communications with the client, default is <it/prefix/<file>/var/run/bird.ctl</file>.
++ use given filename for a socket for communications with the client, default is <it/prefix/<file>/var/run/bird.ctl</file>.
++
++ <tag>-P <m/name of PID file/</tag>
++ create a PID file with given filename</file>.
<tag>-u <m/user/</tag>
drop privileges and use that user ID, see the next section for details.
incompatible with each other (that is to prevent you from shooting in the foot).
<descrip>
-- <tag/bool/ This is a boolean type, it can have only two values, <cf/true/ and
-- <cf/false/. Boolean is the only type you can use in <cf/if/
-- statements.
--
-- <tag/int/ This is a general integer type, you can expect it to store signed values from -2000000000
-- to +2000000000. Overflows are not checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
--
-- <tag/pair/ This is a pair of two short integers. Each component can have values from 0 to
-- 65535. Literals of this type are written as <cf/(1234,5678)/. The same syntax can also be
-- used to construct a pair from two arbitrary integer expressions (for example <cf/(1+2,a)/).
--
-- <tag/quad/ This is a dotted quad of numbers used to represent
-- router IDs (and others). Each component can have a value
-- from 0 to 255. Literals of this type are written like IPv4
-- addresses.
--
- <tag/string/ This is a string of characters. There are no ways
- to modify strings in filters. You can pass them between
- functions, assign them to variables of type <cf/string/,
- print such variables, use standard string comparison
- operations (e.g. <cf/=, !=, <, >, <=, >=/), but
- you can't concatenate two strings. String literals are
- written as <cf/"This is a string constant"/. Additionaly
- matching <cf/˜/ operator could be used to match a
- string value against a shell pattern (represented also as a
- string).
- <tag/string/ This is a string of characters. There are no ways to modify strings in
- filters. You can pass them between functions, assign them to variables of type <cf/string/, print
- such variables, but you can't concatenate two strings. String literals
- are written as <cf/"This is a string constant"/.
--
-- <tag/ip/ This type can hold a single IP address. Depending on the compile-time configuration of BIRD you are using, it
-- is either an IPv4 or IPv6 address. IP addresses are written in the standard notation (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special operator <cf>.mask(<M>num</M>)</cf>
-- on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from the IP
-- address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
--
-- <tag/prefix/ This type can hold a network prefix consisting of IP address and prefix length. Prefix literals are written as
-- <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
++ <tag/bool/ This is a boolean type, it can have only two values,
++ <cf/true/ and <cf/false/. Boolean is the only type you can use in
++ <cf/if/ statements.
++
++ <tag/int/ This is a general integer type, you can expect it to store
++ signed values from -2000000000 to +2000000000. Overflows are not
++ checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
++
++ <tag/pair/ This is a pair of two short integers. Each component can have
++ values from 0 to 65535. Literals of this type are written as
++ <cf/(1234,5678)/. The same syntax can also be used to construct a pair
++ from two arbitrary integer expressions (for example <cf/(1+2,a)/).
++
++ <tag/quad/ This is a dotted quad of numbers used to represent router IDs
++ (and others). Each component can have a value from 0 to 255. Literals
++ of this type are written like IPv4 addresses.
++
++ <tag/string/ This is a string of characters. There are no ways to modify
++ strings in filters. You can pass them between functions, assign them
++ to variables of type <cf/string/, print such variables, use standard
++ string comparison operations (e.g. <cf/=, !=, <, >, <=,
++ >=/), but you can't concatenate two strings. String literals are
++ written as <cf/"This is a string constant"/. Additionaly matching
++ <cf/˜/ operator could be used to match a string value against a
++ shell pattern (represented also as a string).
++
++ <tag/ip/ This type can hold a single IP address. Depending on the
++ compile-time configuration of BIRD you are using, it is either an IPv4
++ or IPv6 address. IP addresses are written in the standard notation
++ (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special
++ operator <cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out
++ all but first <cf><M>num</M></cf> bits from the IP address. So
++ <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
++
++ <tag/prefix/ This type can hold a network prefix consisting of IP
++ address and prefix length. Prefix literals are written
++ as <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
<cf><m>ipaddress</m>/<m>netmask</m></cf>. There are two special
-- operators on prefixes:
-- <cf/.ip/ which extracts the IP address from the pair, and <cf/.len/, which separates prefix
-- length from the pair. So <cf>1.2.0.0/16.pxlen = 16</cf> is true.
--
-- <tag/ec/ This is a specialized type used to represent BGP
-- extended community values. It is essentially a 64bit value,
-- literals of this type are usually written as <cf>(<m/kind/,
-- <m/key/, <m/value/)</cf>, where <cf/kind/ is a kind of
-- extended community (e.g. <cf/rt/ / <cf/ro/ for a route
-- target / route origin communities), the format and possible
-- values of <cf/key/ and <cf/value/ are usually integers, but
++ operators on prefixes: <cf/.ip/ which extracts the IP address from the
++ pair, and <cf/.len/, which separates prefix length from the
++ pair. So <cf>1.2.0.0/16.pxlen = 16</cf> is true.
++
++ <tag/ec/ This is a specialized type used to represent BGP extended
++ community values. It is essentially a 64bit value, literals of this
++ type are usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>,
++ where <cf/kind/ is a kind of extended community (e.g. <cf/rt/ /
++ <cf/ro/ for a route target / route origin communities), the format and
++ possible values of <cf/key/ and <cf/value/ are usually integers, but
it depends on the used kind. Similarly to pairs, ECs can be
-- constructed using expressions for <cf/key/ and
-- <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where
-- <cf/myas/ is an integer variable).
++ constructed using expressions for <cf/key/ and <cf/value/ parts,
++ (e.g. <cf/(ro, myas, 3*10)/, where <cf/myas/ is an integer variable).
-- <tag/int|pair|quad|ip|prefix|ec|enum set/
-- Filters recognize four types of sets. Sets are similar to strings: you can pass them around
-- but you can't modify them. Literals of type <cf>int set</cf> look like <cf>
-- [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
-- sets.
++ <tag/int|pair|quad|ip|prefix|ec|enum set/ Filters recognize four types
++ of sets. Sets are similar to strings: you can pass them around but you
++ can't modify them. Literals of type <cf>int set</cf> look like <cf> [
++ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are
++ permitted in sets.
For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in
that case <cf/(123,0)..(123,65535)/). You can also use <cf/(123,5..100)/ for range
return res;
}
-static int
-pm_path_compare(struct f_path_mask *m1, struct f_path_mask *m2)
-{
- while (1) {
- if ((!m1) || (!m2))
- return !((!m1) && (!m2));
-
- /* FIXME: buggy, should return -1, 0, 1; but it doesn't matter */
- if ((m1->kind != m2->kind) || (m1->val != m2->val)) return 1;
- m1 = m1->next;
- m2 = m2->next;
- }
-}
-
-u32 f_eval_asn(struct f_inst *expr);
-
static void
- pm_format(struct f_path_mask *p, byte *buf, unsigned int size)
+ pm_format(struct f_path_mask *p, buffer *buf)
{
- byte *end = buf + size - 16;
+ buffer_puts(buf, "[= ");
while (p)
+ {
+ switch(p->kind)
{
- if (buf > end)
- {
- strcpy(buf, " ...");
- return;
- }
-
- switch(p->kind)
- {
- case PM_ASN:
- buf += bsprintf(buf, " %u", p->val);
- break;
-
- case PM_QUESTION:
- buf += bsprintf(buf, " ?");
- break;
+ case PM_ASN:
+ buffer_print(buf, "%u ", p->val);
+ break;
- case PM_ASTERISK:
- buf += bsprintf(buf, " *");
- break;
+ case PM_QUESTION:
+ buffer_puts(buf, "? ");
+ break;
- case PM_ASN_EXPR:
- buf += bsprintf(buf, " %u", f_eval_asn((struct f_inst *) p->val));
- break;
- }
+ case PM_ASTERISK:
+ buffer_puts(buf, "* ");
+ break;
- p = p->next;
+ case PM_ASN_EXPR:
+ buffer_print(buf, "%u ", f_eval_asn((struct f_inst *) p->val));
+ break;
}
- *buf = 0;
+ p = p->next;
+ }
+
+ buffer_puts(buf, "=]");
}
-static inline int int_cmp(int i1, int i2)
+static inline int
+int_cmp(int i1, int i2)
{
- if (i1 == i2) return 0;
- if (i1 < i2) return -1;
- else return 1;
+ return (i1 > i2) - (i1 < i2);
}
-static inline int uint_cmp(uint i1, uint i2)
+static inline int
- uint_cmp(unsigned int i1, unsigned int i2)
++uint_cmp(uint i1, uint i2)
{
- if (i1 == i2) return 0;
- if (i1 < i2) return -1;
- else return 1;
+ return (int)(i1 > i2) - (int)(i1 < i2);
}
-static inline int u64_cmp(u64 i1, u64 i2)
+static inline int
+u64_cmp(u64 i1, u64 i2)
{
- if (i1 == i2) return 0;
- if (i1 < i2) return -1;
- else return 1;
+ return (int)(i1 > i2) - (int)(i1 < i2);
}
/**