use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv6NhParser.
@Test
public void testRedirectIpv6NhParser() throws BGPDocumentedException, BGPParsingException {
final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddressNoZone(new Ipv6AddressNoZone("2001::1"))).setCopy(false).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV6));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase in project bgpcep by opendaylight.
the class RedirectIpNextHopEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.RedirectIpNhExtendedCommunity, "The extended community %s is not RedirectIpNhExtendedCommunityCase type.", extendedCommunity);
final RedirectIpNhExtendedCommunity redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.RedirectIpNhExtendedCommunity) extendedCommunity).getRedirectIpNhExtendedCommunity();
final IpAddressNoZone nextHopAddress = redirect.getNextHopAddress();
if (nextHopAddress.getIpv4AddressNoZone() != null) {
Ipv4Util.writeIpv4Address(nextHopAddress.getIpv4AddressNoZone(), byteAggregator);
} else {
Ipv6Util.writeIpv6Address(nextHopAddress.getIpv6AddressNoZone(), byteAggregator);
}
byteAggregator.writeShort(Boolean.TRUE.equals(redirect.getCopy()) ? 1 : 0);
}
Aggregations