use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class ExtendedCommunitiesAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final List<ExtendedCommunities> communitiesList = ((Attributes) attribute).getExtendedCommunities();
if (communitiesList == null || communitiesList.isEmpty()) {
return;
}
final ByteBuf extendedCommunitiesBuffer = Unpooled.buffer();
for (final ExtendedCommunities extendedCommunities : communitiesList) {
this.ecReg.serializeExtendedCommunity(extendedCommunities, extendedCommunitiesBuffer);
}
if (extendedCommunitiesBuffer.readableBytes() > 0) {
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, extendedCommunitiesBuffer, byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class ExtendedCommunitiesAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
final List<ExtendedCommunities> set = new ArrayList<>();
while (buffer.isReadable()) {
final ExtendedCommunities exComm = this.ecReg.parseExtendedCommunity(buffer);
if (exComm != null) {
set.add(exComm);
}
}
builder.setExtendedCommunities(set);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testTrafficActionSerializer.
@Test
public void testTrafficActionSerializer() throws BGPDocumentedException, BGPParsingException {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase trafficAction = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(TRAFFIC_ACTION.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(TRAFFIC_ACTION, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv4NhParser.
@Test
public void testRedirectIpv4NhParser() throws BGPDocumentedException, BGPParsingException {
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).setCopy(true).build()).build()).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV4));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testTrafficActionParser.
@Test
public void testTrafficActionParser() throws BGPDocumentedException, BGPParsingException {
final TrafficActionExtendedCommunityCase trafficAction = new TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_ACTION));
Assert.assertEquals(expected, parsed);
}
Aggregations