key/value structure

Pavlos Parissis pavlos.parissis at gmail.com
Sat May 9 20:15:51 CEST 2015


On 09/05/2015 01:32 πμ, Ondrej Zajicek wrote:
> On Fri, May 08, 2015 at 11:35:33PM +0200, Pavlos Parissis wrote:
>> Hi,
>>
>> For each ip_prefix I advertize I need to add a BGP community in the form
>> of  (ASN,<RouterID>).
>> I have the following mapping between IPs and RouterIDs
>>
>> ip_prefix, RouterID
>> 10.10.10.1, 1
>> 10.10.10.2, 2
>> 10.10.10.3, 3
>> 10.10.10.4, 1
>> 10.10.10.5, 2
>> 10.10.10.6, 3
>> .....
>>
>> So, inside a function I need to express the following
>> lookup_community_router_id() {
>>    return some_kind_of_dict_structure(net.ip)
>> }
>>
>> and the use it in a filter/function
>> filter {
>>    bgp.community((1111, lookup_community_router_id(net)));
>>    accept;
>> }
>>
>> Is this possible?
> 
> Hi
> 
> Surprisingly, it is possible - you could use big case expression which
> returns appropriate value. As case uses the same implementation as sets,
> it will be fairly efficient:
> 
> function lookup(ip val)
> {
>     case val {
> 	10.10.10.1: return 1;
> 	10.10.10.2: return 2;
> 	...
>     }
>   return 0;
> }
> 
> 

I am impressed,

Thanks a lot for the assistance.
Next time I should read twice Control structures:
http://bird.network.cz/?get_doc&f=bird-5.html#ss5.4.

Sorry for the noise,
Pavlos

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150509/39752732/attachment.asc>


More information about the Bird-users mailing list