diff --git a/zebra-dump-parser.pl b/zebra-dump-parser.pl index 52243e0..7b57b5b 100755 --- a/zebra-dump-parser.pl +++ b/zebra-dump-parser.pl @@ -73,6 +73,7 @@ BGP_ATTR_MP_REACH_NLRI => 14, BGP_ATTR_MP_UNREACH_NLRI => 15, BGP_ATTR_EXT_COMMUNITIES => 16, + BGP_ATTR_LARGE_COMMUNITIES => 32, }; my @BGP_ORIGIN = qw(IGP EGP Incomplete); @@ -377,6 +378,12 @@ sub parse_attributes { my $community = substr($attrib, 0, 4, ''); push(@{$attr[BGP_ATTR_COMMUNITIES]}, $community); } + } elsif ($type == BGP_ATTR_LARGE_COMMUNITIES) { + $attr[BGP_ATTR_LARGE_COMMUNITIES] = [ ]; + while (length $attrib > 0) { + my $community = substr($attrib, 0, 12, ''); + push(@{$attr[BGP_ATTR_LARGE_COMMUNITIES]}, $community); + } } elsif ($type == BGP_ATTR_MP_REACH_NLRI) { # FIXME v2 uses a different format my ($afi, $safi, $next_hop, $rest) = unpack('n C C/a a*', $attrib); @@ -517,6 +524,9 @@ sub print_verbose_attributes { print "COMMUNITIES: " . print_communities(@{$attr->[BGP_ATTR_COMMUNITIES]}) . "\n" if $attr->[BGP_ATTR_COMMUNITIES]; + print "LARGE_COMMUNITIES: " + . print_large_communities(@{$attr->[BGP_ATTR_LARGE_COMMUNITIES]}) . "\n" + if $attr->[BGP_ATTR_LARGE_COMMUNITIES]; } sub print_communities { @@ -529,6 +539,16 @@ sub print_communities { return join(' ', @communities); } +sub print_large_communities { + my @communities; + foreach my $community (@_) { + my ($ga, $ldp1, $ldp2) = unpack('N N N', $community); + push(@communities, "${ga}:${ldp1}:${ldp2}"); + } + + return join(' ', @communities); +} + sub pretty_as { my ($as_hi, $as_lo) = unpack('nn', $_[0]); return defined $as_lo ? ($as_hi ? unpack('N', $_[0]) : $as_lo) : $as_hi;