import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.EvpnChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.destination.EvpnDestination;
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
private List<EvpnDestination> dest;
private EvpnNlriParser parser;
- static ChoiceNode createMACIpAdvChoice() {
+ private static ChoiceNode createMACIpAdvChoice() {
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
choice.withNodeIdentifier(EVPN_CHOICE_NID);
return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build();
}
@Test
- public void testSerializeNlri() throws BGPParsingException {
+ public void testSerializeNlri() {
final ByteBuf buffer = Unpooled.buffer();
EvpnNlriParser.serializeNlri(this.dest, buffer);
assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
@Test
public void testMpUnreach() throws BGPParsingException {
final MpUnreachNlriBuilder mpReach = new MpUnreachNlriBuilder();
- this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach);
+ this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
assertEquals(createUnreach(), mpReach.build());
}
@Test
public void testMpReach() throws BGPParsingException {
final MpReachNlriBuilder mpReach = new MpReachNlriBuilder();
- this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach);
+ this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder();
final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder()
@Test
public void testNullMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpb = new MpReachNlriBuilder();
- this.parser.parseNlri(Unpooled.buffer(), mpb);
+ this.parser.parseNlri(Unpooled.buffer(), mpb, null);
assertEquals(new MpReachNlriBuilder().build(), mpb.build());
}
@Test
public void testNullMpUnReachNlri() throws BGPParsingException {
final MpUnreachNlriBuilder mpb = new MpUnreachNlriBuilder();
- this.parser.parseNlri(Unpooled.buffer(), mpb);
+ this.parser.parseNlri(Unpooled.buffer(), mpb, null);
assertEquals(new MpUnreachNlriBuilder().build(), mpb.build());
}
@Test
- public void testExtractEvpnDestination() throws BGPParsingException {
+ public void testExtractEvpnDestination() {
final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI =
ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_NID);
}
@Test
- public void testExtractRouteKey() throws BGPParsingException {
+ public void testExtractRouteKey() {
final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI =
ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_CHOICE_NID);
/**
* Add this constant to length value to achieve all ones in the leftmost nibble.
*/
- protected static final int LENGTH_MAGIC = 61440;
- protected static final int MAX_NLRI_LENGTH = 0xFFF;
- protected static final int MAX_NLRI_LENGTH_ONE_BYTE = 0xF0;
+ private static final int LENGTH_MAGIC = 61440;
+ private static final int MAX_NLRI_LENGTH = 0xFFF;
+ private static final int MAX_NLRI_LENGTH_ONE_BYTE = 0xF0;
@VisibleForTesting
static final String DO_NOT_VALUE = "do-not";
}
}
- @Override
- public final void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
- @Override
- public final void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
protected void serializeNlri(@Nonnull final Object[] nlriFields, @Nonnull final ByteBuf buffer) {
final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
serializeNlri(flowspecList, buffer);
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
+ parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result);
+ this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv6();
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
+ this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv6();
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspec()
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
+ parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspec()
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_BATCHED), result);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_BATCHED), result, null);
final MpReachNlri nlri = result.build();
final List<Flowspec> flowspecList = ((DestinationFlowspecCase) nlri.getAdvertizedRoutes().getDestinationType())
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result);
+ this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspec().getFlowspec();
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
+ this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspec().getFlowspec();
return new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build();
}
- @Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
- parseNlri(nlri, builder, null);
- }
-
- @Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) {
- parseNlri(nlri, builder, null);
- }
-
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) {
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupportUtil;
import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
return new DestinationIpv6Builder().setIpv6Prefixes(prefixes).build();
}
- @Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
- @Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) {
public void parseUnreachedNlriTest() {
final MpUnreachNlriBuilder b = new MpUnreachNlriBuilder();
b.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
- this.parser.parseNlri(this.inputBytes, b);
+ this.parser.parseNlri(this.inputBytes, b, null);
assertNotNull("Withdrawn routes, destination type should not be null", b.getWithdrawnRoutes()
.getDestinationType());
public void parseReachedNlriTest() throws BGPParsingException {
final MpReachNlriBuilder b = new MpReachNlriBuilder();
b.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
- this.parser.parseNlri(this.inputBytes, b);
+ this.parser.parseNlri(this.inputBytes, b, null);
assertNotNull("Advertized routes, destination type should not be null", b.getAdvertizedRoutes()
.getDestinationType());
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
- PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
+ PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
Assert.assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
- PARSER.parseNlri(Unpooled.copiedBuffer(UNREACH_NLRI), testBuilder);
+ PARSER.parseNlri(Unpooled.copiedBuffer(UNREACH_NLRI), testBuilder, null);
Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
- PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
+ PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
Assert.assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
- PARSER.parseNlri(Unpooled.copiedBuffer(UNREACH_NLRI), testBuilder);
+ PARSER.parseNlri(Unpooled.copiedBuffer(UNREACH_NLRI), testBuilder, null);
Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
return ByteArray.readAllBytes(buffer);
}
- @Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
private static List<CLabeledUnicastDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi, final boolean mPathSupported) {
if (!nlri.isReadable()) {
return null;
return labels;
}
- @Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
- parseNlri(nlri, builder, null);
- }
-
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) throws BGPParsingException {
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4), testBuilder);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4), testBuilder);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4), testBuilder, null);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6), testBuilder);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6), testBuilder);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6), testBuilder, null);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Identifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.ObjectType;
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final List<CLinkstateDestination> dst = parseNlri(nlri);
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(
- dst).build()).build()).build());
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder()
+ .setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination
+ .type.destination.linkstate._case.DestinationLinkstateBuilder()
+ .setCLinkstateDestination(dst).build()).build()).build());
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
- parser.parseNlri(Unpooled.copiedBuffer(data), builder);
+ parser.parseNlri(Unpooled.copiedBuffer(data), builder, null);
final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate();
assertEquals(1, ls.getCLinkstateDestination().size());
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
-import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
import org.opendaylight.yangtools.yang.binding.DataObject;
-
-public final class MPReachAttributeParser implements AttributeParser, AttributeSerializer {
+public final class MPReachAttributeParser extends ReachAttributeParser{
public static final int TYPE = 14;
}
@Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException {
- parseAttribute(buffer, builder, null);
- }
-
- @Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint)
+ public void parseAttribute(
+ final ByteBuf buffer,
+ final AttributesBuilder builder,
+ final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException {
try {
final MpReachNlri mpReachNlri = this.reg.parseMpReach(buffer, constraint);
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
if (pathAttributes1 == null) {
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
-import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
import org.opendaylight.yangtools.yang.binding.DataObject;
-public final class MPUnreachAttributeParser implements AttributeParser, AttributeSerializer {
+public final class MPUnreachAttributeParser extends ReachAttributeParser {
public static final int TYPE = 15;
private final NlriRegistry reg;
}
@Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException {
- parseAttribute(buffer, builder, null);
- }
-
- @Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint)
+ public void parseAttribute(
+ final ByteBuf buffer,
+ final AttributesBuilder builder,
+ final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException {
try {
final MpUnreachNlri mpUnreachNlri = this.reg.parseMpUnreach(buffer, constraint);
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
if (pathAttributes2 == null) {
--- /dev/null
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.impl.message.update;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
+import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
+
+/**
+ * @author Claudio D. Gasparini
+ */
+public abstract class ReachAttributeParser implements AttributeParser, AttributeSerializer {
+
+ @Override
+ public final void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder)
+ throws BGPDocumentedException, BGPParsingException {
+ parseAttribute(buffer, builder, null);
+ }
+}
* @param builder Path attributes builder. Guaranteed to contain all valid attributes whose type is numerically
* lower than this attribute's type.
*/
- void parseAttribute(@Nonnull ByteBuf buffer, @Nonnull AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException;
+ void parseAttribute(@Nonnull ByteBuf buffer, @Nonnull AttributesBuilder builder)
+ throws BGPDocumentedException, BGPParsingException;
/**
* Invokes {@link #parseAttribute(ByteBuf, AttributesBuilder)}, so the constraint is omitted. Override for specific parser behavior.
* @param builder Path attributes builder. Guaranteed to contain all valid attributes whose type is numerically
* lower than this attribute's type.
* @param constraint Peer specific constraints.
- * @throws BGPDocumentedException
- * @throws BGPParsingException
+ * @throws BGPDocumentedException exception.
+ * @throws BGPParsingException exception.
*/
- default void parseAttribute(@Nonnull final ByteBuf buffer, @Nonnull final AttributesBuilder builder, @Nullable final PeerSpecificParserConstraint constraint)
+ default void parseAttribute(
+ @Nonnull final ByteBuf buffer,
+ @Nonnull final AttributesBuilder builder,
+ @Nullable final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPParsingException {
parseAttribute(buffer, builder);
}
* Common interface for NLRI parser implementation.
*/
public interface NlriParser {
-
/**
* Parse MP UN_REACH NLRI from buffer.
*
- * @param nlri Encoded unreachabel NLRI in ByteBuf.
- * @param builder MP UNREACH NLRI builder.
- * @throws BGPParsingException
- */
- void parseNlri(@Nonnull ByteBuf nlri, @Nonnull MpUnreachNlriBuilder builder) throws BGPParsingException;
-
- /**
- * Parse MP REACH NLRI from buffer.
- *
- * @param nlri Encoded reachable NLRI in ByteBuf.
- * @param builder MP REACH NLRI builder.
- * @throws BGPParsingException
- */
- void parseNlri(@Nonnull ByteBuf nlri, @Nonnull MpReachNlriBuilder builder) throws BGPParsingException;
-
- /**
- * Invokes {@link #parseNlri(ByteBuf, MpReachNlriBuilder)}, so the constraint is omitted. Override for specific parser behavior.
- *
* @param nlri Encoded reachable NLRI in ByteBuf.
* @param builder MP REACH NLRI builder.
* @param constraint Peer specific constraints.
- * @throws BGPParsingException
+ * @throws BGPParsingException exception.
*/
- default void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint)
- throws BGPParsingException {
- parseNlri(nlri, builder);
- }
-
+ void parseNlri(
+ @Nonnull final ByteBuf nlri,
+ @Nonnull final MpReachNlriBuilder builder,
+ @Nullable final PeerSpecificParserConstraint constraint)
+ throws BGPParsingException;
/**
- * Invokes {@link #parseNlri(ByteBuf, MpUnreachNlriBuilder)}, so the constraint is omitted. Override for specific parser behavior.
+ * Parse MP UN_REACH NLRI from buffer.
*
* @param nlri Encoded unreachable NLRI in ByteBuf.
* @param builder MP UNREACH NLRI builder.
* @param constraint Peer specific constraints.
- * @throws BGPParsingException
+ * @throws BGPParsingException exception.
*/
- default void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint)
- throws BGPParsingException {
- parseNlri(nlri, builder);
- }
+ void parseNlri(
+ @Nonnull final ByteBuf nlri,
+ @Nonnull final MpUnreachNlriBuilder builder,
+ @Nullable final PeerSpecificParserConstraint constraint)
+ throws BGPParsingException;
}
* @return Parsed reach NLRI.
* @throws BGPParsingException
*/
- @Nonnull MpReachNlri parseMpReach(@Nonnull ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
+ @Nonnull MpReachNlri parseMpReach(
+ @Nonnull ByteBuf buffer,
+ @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
/**
* Decode MP REACH NLRI Attribute.
* @return Parsed unreach NLRI.
* @throws BGPParsingException
*/
- @Nonnull MpUnreachNlri parseMpUnreach(@Nonnull ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
+ @Nonnull MpUnreachNlri parseMpUnreach(
+ @Nonnull ByteBuf buffer,
+ @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
/**
* Encode BGP MP REACH NLRI Attribute.
private final ConcurrentMap<BgpTableType, NlriParser> handlers = new ConcurrentHashMap<>();
private final ConcurrentMap<Class<? extends DataObject>, NlriSerializer> serializers = new ConcurrentHashMap<>();
private final ConcurrentMap<BgpTableType, NextHopParserSerializer> nextHopParsers = new ConcurrentHashMap<>();
- private final ConcurrentMap<Entry<Class<? extends CNextHop>, BgpTableType>, NextHopParserSerializer> nextHopSerializers = new ConcurrentHashMap<>();
+ private final ConcurrentMap<Entry<Class<? extends CNextHop>, BgpTableType>,
+ NextHopParserSerializer> nextHopSerializers = new ConcurrentHashMap<>();
private final SubsequentAddressFamilyRegistry safiReg;
private final AddressFamilyRegistry afiReg;
SimpleNlriRegistry.this.handlers.remove(key);
SimpleNlriRegistry.this.nextHopParsers.remove(key);
if (cNextHopClass != null) {
- final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
+ final Entry<Class<? extends CNextHop>, BgpTableType> nhKey
+ = new SimpleEntry<>(cNextHopClass, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKey);
for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
- final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
+ final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys
+ = new SimpleEntry<>(cNextHop, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKeys);
}
}