bitwise operation in filters

Ondrej Zajicek santiago at crfreenet.org
Fri Feb 28 20:12:40 CET 2014


On Fri, Feb 28, 2014 at 01:27:35PM +0100, Daniel Wendler wrote:
> Hello List,
> 
> at the moment we try to implement an fine granulary filter mechanism in our Bird 
> OSPF setup. We ask ourselfes if anyone has implementet bitwise operations in 
> Bird filters which is not in official code.
> If not, are there any plans to implement such an feature in Bird filters or 
> should we try it to implement on our own and contribute this to the mailing 
> list?

Hi

Although adding bitfield operations is generally a good idea, your
problem could be easily solved with current code and this filter
function (a - number, b - value of the bit):

function bittest(int a; int b)
{
        return a/(2*b) != (a+b)/(2*b);
}

bittest(13,1) -> true
bittest(13,2) -> false
bittest(13,4) -> true
bittest(13,8) -> true
bittest(13,16) -> false

-- 

Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20140228/f10bf3f1/attachment-0001.asc>


More information about the Bird-users mailing list