import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.string.tlv.StringTlvBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
-/**
- * Created by cgasparini on 13.5.2015.
- */
public class InitiationHandler extends AbstractBmpMessageWithTlvParser<TlvsBuilder> {
public InitiationHandler(final BmpTlvRegistry tlvRegistry) {
public class PeerDownHandler extends AbstractBmpPerPeerMessageParser<PeerDownNotificationBuilder> {
private static final int MESSAGE_TYPE = 2;
+ private final MessageRegistry msgRegistry;
public PeerDownHandler(final MessageRegistry bgpMssageRegistry) {
super(bgpMssageRegistry);
+ this.msgRegistry = getBgpMessageRegistry();
}
@Override
private void serializePDU(final Data data, final ByteBuf buffer) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.down.data.Notification notification
= (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.down.data.Notification) data;
- this.getBgpMessageRegistry().serializeMessage(new NotifyBuilder(notification.getNotification()).build(), buffer);
+ this.msgRegistry.serializeMessage(new NotifyBuilder(notification.getNotification()).build(), buffer);
}
@Override
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.down.data.notification.NotificationBuilder notificationBuilder
= new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.down.data.notification.NotificationBuilder();
try {
- final Notification not = this.getBgpMessageRegistry().parseMessage(bytes);
+ final Notification not = this.msgRegistry.parseMessage(bytes, null);
Preconditions.checkNotNull(not, "Notify message may not be null.");
Preconditions.checkArgument(not instanceof NotifyMessage, "An instance of NotifyMessage is required");
notificationBuilder.fieldsFrom((NotifyMessage) not);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.string.tlv.StringTlvBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
-/**
- * Created by cgasparini on 13.5.2015.
- */
public class PeerUpHandler extends AbstractBmpPerPeerMessageParser<InformationBuilder> {
private static final int MESSAGE_TYPE = 3;
+ private final MessageRegistry msgRegistry;
public PeerUpHandler(final MessageRegistry bgpMssageRegistry, final BmpTlvRegistry tlvRegistry) {
super(bgpMssageRegistry, tlvRegistry);
+ this.msgRegistry = getBgpMessageRegistry();
}
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
super.serializeMessageBody(message, buffer);
- Preconditions.checkArgument(message instanceof PeerUpNotification, "An instance of Peer Up notification is required");
+ Preconditions.checkArgument(message instanceof PeerUpNotification,
+ "An instance of Peer Up notification is required");
final PeerUpNotification peerUp = (PeerUpNotification) message;
if (peerUp.getLocalAddress().getIpv4Address() != null) {
ByteBufWriteUtil.writeUnsignedShort(peerUp.getLocalPort().getValue(), buffer);
ByteBufWriteUtil.writeUnsignedShort(peerUp.getRemotePort().getValue(), buffer);
- getBgpMessageRegistry().serializeMessage(new OpenBuilder(peerUp.getSentOpen()).build(), buffer);
- getBgpMessageRegistry().serializeMessage(new OpenBuilder(peerUp.getReceivedOpen()).build(), buffer);
+ this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getSentOpen()).build(), buffer);
+ this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getReceivedOpen()).build(), buffer);
serializeTlvs(peerUp.getInformation(), buffer);
}
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
- final PeerUpNotificationBuilder peerUpNot = new PeerUpNotificationBuilder().setPeerHeader(parsePerPeerHeader(bytes));
+ final PeerUpNotificationBuilder peerUpNot = new PeerUpNotificationBuilder()
+ .setPeerHeader(parsePerPeerHeader(bytes));
if (peerUpNot.getPeerHeader().isIpv4()) {
bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
peerUpNot.setLocalPort(new PortNumber(bytes.readUnsignedShort()));
peerUpNot.setRemotePort(new PortNumber(bytes.readUnsignedShort()));
try {
- final Notification opSent = getBgpMessageRegistry().parseMessage(bytes.readSlice(getBgpMessageLength(bytes)));
- Preconditions.checkNotNull(opSent, "Error on parse Sent OPEN Message, Sent OPEN Message is null");
- Preconditions.checkArgument(opSent instanceof OpenMessage, "An instance of OpenMessage notification is required");
+ final Notification opSent = this.msgRegistry
+ .parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
+ Preconditions.checkNotNull(opSent,
+ "Error on parse Sent OPEN Message, Sent OPEN Message is null");
+ Preconditions.checkArgument(opSent instanceof OpenMessage,
+ "An instance of OpenMessage notification is required");
final OpenMessage sent = (OpenMessage) opSent;
- final Notification opRec = getBgpMessageRegistry().parseMessage(bytes.readSlice(getBgpMessageLength(bytes)));
- Preconditions.checkNotNull(opRec, "Error on parse Received OPEN Message, Received OPEN Message is null");
- Preconditions.checkArgument(opRec instanceof OpenMessage, "An instance of OpenMessage notification is required");
+ final Notification opRec = this.msgRegistry
+ .parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
+ Preconditions.checkNotNull(opRec,
+ "Error on parse Received OPEN Message, Received OPEN Message is null");
+ Preconditions.checkArgument(opRec instanceof OpenMessage,
+ "An instance of OpenMessage notification is required");
final OpenMessage received = (OpenMessage) opRec;
peerUpNot.setSentOpen(new SentOpenBuilder(sent).build());
if ( builder.getStringInformation() != null ) {
stringInfoListBuilder.addAll(builder.getStringInformation());
}
- builder.setStringInformation(stringInfoListBuilder
- .add(new StringInformationBuilder().setStringTlv(
- new StringTlvBuilder((StringTlv) tlv).build()).build()).build());
+ builder.setStringInformation(stringInfoListBuilder.add(new StringInformationBuilder().setStringTlv(
+ new StringTlvBuilder((StringTlv) tlv).build()).build()).build());
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.RouteMonitoringMessageBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
-/**
- * Created by cgasparini on 13.5.2015.
- */
public class RouteMonitoringMessageHandler extends AbstractBmpPerPeerMessageParser<RouteMonitoringMessageBuilder> {
private static final int MESSAGE_TYPE = 0;
+ private final MessageRegistry msgRegistry;
public RouteMonitoringMessageHandler(final MessageRegistry bgpMssageRegistry) {
super(bgpMssageRegistry);
+ this.msgRegistry = getBgpMessageRegistry();
}
@Override
super.serializeMessageBody(message, buffer);
Preconditions.checkArgument(message instanceof RouteMonitoringMessage, "An instance of RouteMonitoringMessage is required");
final RouteMonitoringMessage routeMonitor = (RouteMonitoringMessage) message;
- getBgpMessageRegistry().serializeMessage(new UpdateBuilder(routeMonitor.getUpdate()).build(), buffer);
+ this.msgRegistry.serializeMessage(new UpdateBuilder(routeMonitor.getUpdate()).build(), buffer);
}
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final RouteMonitoringMessageBuilder routeMonitor = new RouteMonitoringMessageBuilder().setPeerHeader(parsePerPeerHeader(bytes));
try {
- final Notification message = getBgpMessageRegistry().parseMessage(bytes);
+ final Notification message = this.msgRegistry.parseMessage(bytes, null);
Preconditions.checkNotNull(message, "UpdateMessage may not be null");
Preconditions.checkArgument(message instanceof UpdateMessage, "An instance of UpdateMessage is required");
final UpdateMessage updateMessage = (UpdateMessage) message;
public class BGPParserTest {
- private static int MAX_SIZE = 300;
+ private static final int MAX_SIZE = 300;
private static MessageRegistry messageRegistry;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport;
import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
-import org.opendaylight.protocol.util.Ipv4Util;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.DestinationIpv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.destination.ipv4.Ipv4Prefixes;
new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
this.ip4caseADWrong = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
- this.inputBytes.writeBytes(Ipv4Util.bytesForPrefixBegin(prefix1));
- this.inputBytes.writeBytes(Ipv4Util.bytesForPrefixBegin(prefix2));
+ final ByteBuf buffer1 = Unpooled.buffer(5);
+ ByteBufWriteUtil.writeMinimalPrefix(prefix1, buffer1);
+ this.inputBytes.writeBytes(buffer1.array());
+
+ final ByteBuf buffer2 = Unpooled.buffer(5);
+ ByteBufWriteUtil.writeMinimalPrefix(prefix2, buffer2);
+ this.inputBytes.writeBytes(buffer2.array());
Mockito.doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(Mockito.any());
Mockito.doReturn(true).when(this.muliPathSupport).isTableTypeSupported(Mockito.any());
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.protocol.util.Ipv6Util;
import org.opendaylight.protocol.util.MplsLabelUtil;
if (mpUnreachNlri.getWithdrawnRoutes() != null) {
final DestinationType destinationType = mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
if (destinationType instanceof DestinationLabeledUnicastCase) {
- final DestinationLabeledUnicastCase labeledUnicastCase = (DestinationLabeledUnicastCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
- serializeNlri(labeledUnicastCase.getDestinationLabeledUnicast().getCLabeledUnicastDestination(), true, byteAggregator);
+ final DestinationLabeledUnicastCase labeledUnicastCase = (DestinationLabeledUnicastCase)
+ mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ serializeNlri(labeledUnicastCase.getDestinationLabeledUnicast().getCLabeledUnicastDestination(),
+ true, byteAggregator);
} else if(destinationType instanceof DestinationIpv6LabeledUnicastCase) {
- final DestinationIpv6LabeledUnicastCase labeledUnicastCase = (DestinationIpv6LabeledUnicastCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
- serializeNlri(labeledUnicastCase.getDestinationIpv6LabeledUnicast().getCLabeledUnicastDestination(), true, byteAggregator);
+ final DestinationIpv6LabeledUnicastCase labeledUnicastCase = (DestinationIpv6LabeledUnicastCase)
+ mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ serializeNlri(labeledUnicastCase.getDestinationIpv6LabeledUnicast().getCLabeledUnicastDestination(),
+ true, byteAggregator);
}
}
}
}
private static byte[] getPrefixBytes(final IpPrefix prefix) {
+ final ByteBuf buffer = Unpooled.buffer();
+
if (prefix.getIpv4Prefix() != null) {
- return Ipv4Util.bytesForPrefixBegin(prefix.getIpv4Prefix());
+ ByteBufWriteUtil.writeMinimalPrefix(prefix.getIpv4Prefix(), buffer);
+ } else {
+ ByteBufWriteUtil.writeMinimalPrefix(prefix.getIpv6Prefix(), buffer);
}
- return Ipv6Util.bytesForPrefixBegin(prefix.getIpv6Prefix());
+ return ByteArray.readAllBytes(buffer);
}
@Override
}
@Override
- public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
- final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
+ final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
+ new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
DestinationType destination = null;
*/
package org.opendaylight.protocol.bgp.labeled.unicast;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX)
+ .setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build()).build());
+ new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
+ .build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
//test parser
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4), testBuilder);
- Assert.assertEquals(mpReachExpected, testBuilder.build());
+ assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- Assert.assertArrayEquals(LU_REACH_NLRI_IPv4, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPv4, ByteArray.readAllBytes(output));
}
@Test
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv4_PREFIX).setLabelStack
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv4_PREFIX).setLabelStack
(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build()).build());
+ new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu))
+ .build()).build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
//test parser
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4_ADD_PATH), testBuilder, this.constraint);
- Assert.assertEquals(mpReachExpected, testBuilder.build());
+ assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- Assert.assertArrayEquals(LU_REACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
}
@Test
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
+ .setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX)
+ .setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
+ .setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
+ destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4), testBuilder);
- Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
+ assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output1));
}
@Test
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv4_PREFIX).build();
+ final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv4_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
+ .setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
+ .setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4_ADD_PATH), testBuilder, this.constraint);
- Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
+ assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output1));
}
@Test
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
- mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6LabeledUnicastCaseBuilder()
- .setDestinationIpv6LabeledUnicast(new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX)
+ .setLabelStack(LABEL_STACK).build();
+ mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
+ new DestinationIpv6LabeledUnicastCaseBuilder()
+ .setDestinationIpv6LabeledUnicast(new DestinationIpv6LabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
.build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6), testBuilder);
- Assert.assertEquals(mpReachExpected, testBuilder.build());
+ assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- Assert.assertArrayEquals(LU_REACH_NLRI_IPv6, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPv6, ByteArray.readAllBytes(output));
}
@Test
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
- .build())
+ new DestinationIpv6LabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build())
.build());
final MpReachNlri mpReachExpected = mpBuilder.build();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6_ADD_PATH), testBuilder, this.constraint);
- Assert.assertEquals(mpReachExpected, testBuilder.build());
+ assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- Assert.assertArrayEquals(LU_REACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
}
@Test
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach
- .nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder()
+ .setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
- mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach
- .nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX)
+ .setLabelStack(LABEL_STACK).build();
+ mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1
+ .urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach
+ .nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder()
+ .setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6), testBuilder);
- Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
+ assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output1));
}
@Test
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv6_PREFIX).build();
+ final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv6_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach
- .nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder()
+ .setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.labeled.unicast.rev150525.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv6_PREFIX).setLabelStack
- (LABEL_STACK).build();
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
+ .setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp.unreach
- .nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled
+ .unicast._case.DestinationIpv6LabeledUnicastBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6_ADD_PATH), testBuilder, this.constraint);
- Assert.assertEquals(mpUnreachExpected1, testBuilder.build());
+ assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- Assert.assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output1));
}
}
import com.google.common.annotations.VisibleForTesting;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.protocol.util.Ipv4Util;
if (prefixDesc.getChild(IP_REACH_NID).isPresent()) {
final String prefix = (String) prefixDesc.getChild(IP_REACH_NID).get().getValue();
try {
- Ipv4Util.bytesForPrefixBegin(new Ipv4Prefix(prefix));
+ final ByteBuf buffer = Unpooled.buffer(5);
+ ByteBufWriteUtil.writeMinimalPrefix(new Ipv4Prefix(prefix), buffer);
return new IpPrefix(new Ipv4Prefix(prefix));
} catch (final IllegalArgumentException e) {
LOG.debug("Creating Ipv6 prefix because", e);
@Before
public void setUp() throws Exception {
- updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry());
+ updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext
+ .getSingletonInstance().getAttributeRegistry());
for (int i = 1; i <= COUNTER; i++) {
final String name = "/up" + i + ".bin";
try (final InputStream is = ParserTest.class.getResourceAsStream(name)){
@Test
public void testEORLS() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
- final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+ final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0),
+ MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
- final Class<? extends AddressFamily> afi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getAfi();
- final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getSafi();
+ final Class<? extends AddressFamily> afi = message.getAttributes()
+ .getAugmentation(Attributes2.class).getMpUnreachNlri().getAfi();
+ final Class<? extends SubsequentAddressFamily> safi = message.getAttributes()
+ .getAugmentation(Attributes2.class).getMpUnreachNlri().getSafi();
assertEquals(LinkstateAddressFamily.class, afi);
assertEquals(LinkstateSubsequentAddressFamily.class, safi);
@Test
public void testBGPLink() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(1), MessageUtil.COMMON_HEADER_LENGTH);
- final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+ final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1),
+ MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
final UpdateBuilder builder = new UpdateBuilder();
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("25.25.25.1")).build()).build();
- final LocalNodeDescriptorsBuilder ndBuilder = new LocalNodeDescriptorsBuilder().setAsNumber(new AsNumber((long) 100)).setDomainId(
+ final LocalNodeDescriptorsBuilder ndBuilder = new LocalNodeDescriptorsBuilder()
+ .setAsNumber(new AsNumber((long) 100)).setDomainId(
new DomainIdentifier(0x19191901L)).setAreaId(new AreaIdentifier(0L));
- final RemoteNodeDescriptorsBuilder rdBuilder = new RemoteNodeDescriptorsBuilder().setAsNumber(new AsNumber((long) 100)).setDomainId(
+ final RemoteNodeDescriptorsBuilder rdBuilder = new RemoteNodeDescriptorsBuilder()
+ .setAsNumber(new AsNumber((long) 100)).setDomainId(
new DomainIdentifier(0x19191901L)).setAreaId(new AreaIdentifier(0L));
final CLinkstateDestinationBuilder clBuilder = new CLinkstateDestinationBuilder();
final List<CLinkstateDestination> linkstates = Lists.newArrayList();
final LinkCaseBuilder lCase = new LinkCaseBuilder().setLocalNodeDescriptors(ndBuilder.setCRouterIdentifier(
new OspfPseudonodeCaseBuilder().setOspfPseudonode(
- new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L).setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
+ new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L)
+ .setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
lCase.setRemoteNodeDescriptors(rdBuilder.setCRouterIdentifier(
- new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x03030304L).build()).build()).build());
+ new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder()
+ .setOspfRouterId(0x03030304L).build()).build()).build());
lCase.setLinkDescriptors(new LinkDescriptorsBuilder().setIpv4InterfaceAddress(
new Ipv4InterfaceIdentifier(new Ipv4Address("11.11.11.3"))).build());
linkstates.add(clBuilder.setObjectType(lCase.build()).build());
lCase.setRemoteNodeDescriptors(rdBuilder.setCRouterIdentifier(
- new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x01010102L).build()).build()).build());
+ new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder()
+ .setOspfRouterId(0x01010102L).build()).build()).build());
lCase.setLinkDescriptors(new LinkDescriptorsBuilder().setIpv4InterfaceAddress(
new Ipv4InterfaceIdentifier(new Ipv4Address("11.11.11.1"))).build());
linkstates.add(clBuilder.setObjectType(lCase.build()).build());
lCase.setLocalNodeDescriptors(ndBuilder.setCRouterIdentifier(
- new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x01010102L).build()).build()).build());
+ new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder()
+ .setOspfRouterId(0x01010102L).build()).build()).build());
lCase.setRemoteNodeDescriptors(rdBuilder.setCRouterIdentifier(
- new OspfPseudonodeCaseBuilder().setOspfPseudonode(new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L).setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
+ new OspfPseudonodeCaseBuilder().setOspfPseudonode(new OspfPseudonodeBuilder()
+ .setOspfRouterId(0x03030304L)
+ .setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
linkstates.add(clBuilder.setObjectType(lCase.build()).build());
lsBuilder.setMpReachNlri(mpBuilder.build());
paBuilder.addAugmentation(Attributes1.class, lsBuilder.build());
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.Attributes1Builder lsAttrBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.Attributes1Builder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.
+ Attributes1Builder lsAttrBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
+ bgp.linkstate.rev150210.Attributes1Builder();
lsAttrBuilder.setLinkStateAttribute(
- new LinkAttributesCaseBuilder().setLinkAttributes(new LinkAttributesBuilder().setMetric(new Metric(1L)).build()).build());
+ new LinkAttributesCaseBuilder().setLinkAttributes(new LinkAttributesBuilder()
+ .setMetric(new Metric(1L)).build()).build());
paBuilder.addAugmentation(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.Attributes1.class,
lsAttrBuilder.build());
assertEquals(
lsAttrBuilder.build(),
- attrs.getAugmentation(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.Attributes1.class));
+ attrs.getAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .linkstate.rev150210.Attributes1.class));
- final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
+ final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes()
+ .getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
assertEquals(linkstates.size(), dests.size());
@Test
public void testBGPNode() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
- final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+ final int messageLength = ByteArray
+ .bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
final UpdateBuilder builder = new UpdateBuilder();
clBuilder.setProtocolId(ProtocolId.Ospf);
final NodeDescriptorsBuilder n = new NodeDescriptorsBuilder();
- n.setAsNumber(new AsNumber((long) 100)).setDomainId(new DomainIdentifier(0x19191901L)).setAreaId(new AreaIdentifier(0L));
+ n.setAsNumber(new AsNumber((long) 100)).setDomainId(new DomainIdentifier(0x19191901L))
+ .setAreaId(new AreaIdentifier(0L));
final List<CLinkstateDestination> linkstates = Lists.newArrayList();
final NodeCaseBuilder nCase = new NodeCaseBuilder();
nCase.setNodeDescriptors(n.setCRouterIdentifier(
new OspfPseudonodeCaseBuilder().setOspfPseudonode(
- new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L).setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
+ new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L)
+ .setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
nCase.setNodeDescriptors(n.setCRouterIdentifier(
- new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x03030304L).build()).build()).build());
+ new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder()
+ .setOspfRouterId(0x03030304L).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
nCase.setNodeDescriptors(n.setCRouterIdentifier(
- new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x01010102L).build()).build()).build());
+ new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder()
+ .setOspfRouterId(0x01010102L).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
final Attributes1Builder lsBuilder = new Attributes1Builder();
assertEquals(mpBuilder.getSafi(), mp.getSafi());
assertEquals(mpBuilder.getCNextHop(), mp.getCNextHop());
- final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
+ final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes()
+ .getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
assertEquals(linkstates.size(), dests.size());
*/
@Test
public void testOpenMessage() throws Exception {
- final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
- final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)));
+ final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext
+ .getSingletonInstance().getMessageRegistry();
+ final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)), null);
final Open open = (Open) o;
final Set<BgpTableType> types = Sets.newHashSet();
for (final BgpParameters param : open.getBgpParameters()) {
final CParameters cParam = optCapa.getCParameters();
if(cParam != null && cParam.getAugmentation(CParameters1.class) != null && cParam.getAugmentation
(CParameters1.class).getMultiprotocolCapability() != null) {
- final MultiprotocolCapability mp = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
+ final MultiprotocolCapability mp = cParam
+ .getAugmentation(CParameters1.class).getMultiprotocolCapability();
final BgpTableType type = new BgpTableTypeImpl(mp.getAfi(), mp.getSafi());
types.add(type);
}
public class ParserTest {
- private static final byte[] openBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
- (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+ private static final byte[] openBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04,
+ (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14,
+ (byte) 0x00 };
- private static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+ private static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
- private static final byte[] notificationBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
+ private static final byte[] notificationBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02,
+ (byte) 0x04, (byte) 0x04, (byte) 0x09 };
private static final byte[] updMsgWithUnrecognizedAttribute = new byte[] {
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x79, (byte) 0x02,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x62, (byte) 0x90, (byte) 0x0e, (byte) 0x00, (byte) 0x34, (byte) 0x40, (byte) 0x04, (byte) 0x47, (byte) 0x04, (byte) 0x0a, (byte) 0x19,
- (byte) 0x02, (byte) 0x1b, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x27, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)0x00,
- (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x1a, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x48, (byte) 0x02, (byte)0x01,
- (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)0x00,
- (byte) 0x43, (byte) 0x40, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x40, (byte) 0x02, (byte) 0x00, (byte) 0x40, (byte) 0x05, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)0x64,
- (byte) 0x00, (byte) 0x63, (byte) 0x19, (byte) 0x04, (byte) 0x02, (byte) 0x00, (byte) 0x08, (byte) 0x4f, (byte) 0x66, (byte) 0x2d, (byte) 0x39, (byte) 0x6b, (byte) 0x2d, (byte) 0x30, (byte)0x33,
- (byte) 0x04, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x72, (byte) 0x04, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x2b, (byte) 0x2b, (byte) 0x2b, (byte) 0x2b
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x79, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x62, (byte) 0x90, (byte) 0x0e, (byte) 0x00, (byte) 0x34, (byte) 0x40, (byte) 0x04, (byte) 0x47,
+ (byte) 0x04, (byte) 0x0a, (byte) 0x19, (byte) 0x02, (byte) 0x1b, (byte) 0x00, (byte) 0x00, (byte) 0x01,
+ (byte) 0x00, (byte) 0x27, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte)0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x1a, (byte) 0x02,
+ (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x48, (byte) 0x02,
+ (byte)0x01, (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x02,
+ (byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)0x00,
+ (byte) 0x43, (byte) 0x40, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x40, (byte) 0x02, (byte) 0x00,
+ (byte) 0x40, (byte) 0x05, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)0x64, (byte) 0x00,
+ (byte) 0x63, (byte) 0x19, (byte) 0x04, (byte) 0x02, (byte) 0x00, (byte) 0x08, (byte) 0x4f, (byte) 0x66,
+ (byte) 0x2d, (byte) 0x39, (byte) 0x6b, (byte) 0x2d, (byte) 0x30, (byte)0x33, (byte) 0x04, (byte) 0x03,
+ (byte) 0x00, (byte) 0x01, (byte) 0x72, (byte) 0x04, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x2b,
+ (byte) 0x2b, (byte) 0x2b, (byte) 0x2b
};
// Update message with one IPv4 prefix NLRI and all mandatory path attributes present
(byte) 0xfe, (byte) 0x03
};
- private static final byte[] RR_MSG = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01 };
+ private static final byte[] RR_MSG = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x05, (byte) 0x00, (byte) 0x01,
+ (byte) 0x00, (byte) 0x01 };
- static MessageRegistry reg;
+ private static MessageRegistry reg;
@BeforeClass
public static void setupClass() throws Exception {
@Test
public void testHeaderErrors() throws BGPParsingException, BGPDocumentedException {
- byte[] wrong = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00 };
+ byte[] wrong = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00 };
wrong = ByteArray.cutBytes(wrong, 16);
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(wrong));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(wrong), null);
fail("Exception should have occcured.");
} catch (final IllegalArgumentException e) {
- assertEquals("Too few bytes in passed array. Passed: " + wrong.length + ". Expected: >= 19.", e.getMessage());
+ assertEquals("Too few bytes in passed array. Passed: " + wrong.length + ". Expected: >= 19.",
+ e.getMessage());
return;
}
fail();
@Test
public void testBadMsgType() throws BGPParsingException {
- final byte[] bytes = { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x13, (byte) 0x08 };
+ final byte[] bytes = { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x08 };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals(BGPError.BAD_MSG_TYPE, e.getError());
ParserTest.reg.serializeMessage(keepAlive, buffer);
assertArrayEquals(keepAliveBMsg, ByteArray.getAllBytes(buffer));
- final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)));
+ final Notification m = ParserTest.reg.parseMessage(Unpooled.
+ copiedBuffer(ByteArray.getAllBytes(buffer)), null);
assertTrue(m instanceof Keepalive);
}
@Test
public void testBadKeepAliveMsg() throws BGPParsingException {
- final byte[] bytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x14, (byte) 0x04, (byte) 0x05 };
+ final byte[] bytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x14, (byte) 0x04, (byte) 0x05 };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertThat(e.getMessage(), containsString("Message length field not within valid range."));
@Test
public void testOpenMessage() throws UnknownHostException, BGPParsingException, BGPDocumentedException {
- final Notification open = new OpenBuilder().setMyAsNumber(100).setHoldTimer(180).setBgpIdentifier(new Ipv4Address("20.20.20.20")).setVersion(
+ final Notification open = new OpenBuilder().setMyAsNumber(100).setHoldTimer(180)
+ .setBgpIdentifier(new Ipv4Address("20.20.20.20")).setVersion(
new ProtocolVersion((short) 4)).build();
final ByteBuf bytes = Unpooled.buffer();
ParserTest.reg.serializeMessage(open, bytes);
assertArrayEquals(openBMsg, ByteArray.getAllBytes(bytes));
- final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes));
+ final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes), null);
assertTrue(m instanceof Open);
assertEquals(100, ((Open) m).getMyAsNumber().intValue());
@Test
public void testBadHoldTimeError() throws BGPParsingException {
- final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0x01, (byte) 0x14,
- (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+ final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64,
+ (byte) 0x00, (byte) 0x01, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("Hold time value not acceptable.", e.getMessage());
@Test
public void testBadMsgLength() throws BGPParsingException {
- final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x1b, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4, (byte) 0xff,
- (byte) 0xff, (byte) 0xff };
+ final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x1b, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64,
+ (byte) 0x00, (byte) 0xb4, (byte) 0xff, (byte) 0xff, (byte) 0xff };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("Open message too small.", e.getMessage());
@Test
public void testBadVersion() throws BGPParsingException {
- final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4, (byte) 0x14,
- (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+ final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x64,
+ (byte) 0x00, (byte) 0xb4, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("BGP Protocol version 8 not supported.", e.getMessage());
@Test
public void testNotificationMsg() throws BGPParsingException, BGPDocumentedException {
- Notification notMsg = new NotifyBuilder().setErrorCode(BGPError.OPT_PARAM_NOT_SUPPORTED.getCode()).setErrorSubcode(
- BGPError.OPT_PARAM_NOT_SUPPORTED.getSubcode()).setData(new byte[] { 4, 9 }).build();
+ Notification notMsg = new NotifyBuilder().setErrorCode(BGPError.OPT_PARAM_NOT_SUPPORTED.getCode())
+ .setErrorSubcode(BGPError.OPT_PARAM_NOT_SUPPORTED.getSubcode()).setData(new byte[] { 4, 9 }).build();
final ByteBuf bytes = Unpooled.buffer();
ParserTest.reg.serializeMessage(notMsg, bytes);
assertArrayEquals(notificationBMsg, ByteArray.subByte(bytes.array(),0,bytes.writerIndex()));
- Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes));
+ Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes), null);
assertTrue(m instanceof Notify);
- assertEquals(BGPError.OPT_PARAM_NOT_SUPPORTED, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
+ assertEquals(BGPError.OPT_PARAM_NOT_SUPPORTED, BGPError.forValue(((Notify) m).getErrorCode(),
+ ((Notify) m).getErrorSubcode()));
assertArrayEquals(new byte[] { 4, 9 }, ((Notify) m).getData());
notMsg = new NotifyBuilder().setErrorCode(BGPError.CONNECTION_NOT_SYNC.getCode()).setErrorSubcode(
ParserTest.reg.serializeMessage(notMsg, bytes);
- m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes));
+ m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bytes), null);
assertTrue(m instanceof Notify);
- assertEquals(BGPError.CONNECTION_NOT_SYNC, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
+ assertEquals(BGPError.CONNECTION_NOT_SYNC, BGPError.forValue(((Notify) m).getErrorCode(),
+ ((Notify) m).getErrorSubcode()));
assertNull(((Notify) m).getData());
}
@Test
public void testWrongLength() throws BGPParsingException {
- final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x14, (byte) 0x03, (byte) 0x02 };
+ final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x14, (byte) 0x03, (byte) 0x02 };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("Notification message too small.", e.getMessage());
@Test
public void testUnrecognizedError() throws BGPParsingException, BGPDocumentedException {
- final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0x15, (byte) 0x03, (byte) 0x02, (byte) 0xaa };
+ final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x15, (byte) 0x03, (byte) 0x02, (byte) 0xaa };
try {
- ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg));
+ ParserTest.reg.parseMessage(Unpooled.copiedBuffer(bMsg), null);
fail("Exception should have occured.");
} catch (final IllegalArgumentException e) {
assertEquals("BGP Error code 2 and subcode 170 not recognized.", e.getMessage());
@Test
public void testParseUpdMsgWithUnrecognizedAttribute() throws BGPDocumentedException, BGPParsingException {
try {
- reg.parseMessage(Unpooled.copiedBuffer(updMsgWithUnrecognizedAttribute));
+ reg.parseMessage(Unpooled.copiedBuffer(updMsgWithUnrecognizedAttribute), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("Well known attribute not recognized.", e.getMessage());
@Test
public void testParseUpdMsgWithMandatoryAttributesPresent() throws BGPDocumentedException, BGPParsingException {
try {
- Notification msg = reg.parseMessage(Unpooled.copiedBuffer(updMsgWithMandatoryAttributesPresent));
+ final Notification msg = reg.parseMessage(Unpooled.copiedBuffer(updMsgWithMandatoryAttributesPresent),
+ null);
assertTrue(msg instanceof Update);
} catch (final BGPDocumentedException e) {
fail("Exception should not have occured.");
}
@Test
- public void testParseUpdMsgWithOneMandatoryAttributeNotPresent() throws BGPDocumentedException, BGPParsingException {
+ public void testParseUpdMsgWithOneMandatoryAttributeNotPresent()
+ throws BGPDocumentedException, BGPParsingException {
try {
- reg.parseMessage(Unpooled.copiedBuffer(updMsgWithOneMandatoryAttributeNotPresent));
+ reg.parseMessage(Unpooled.copiedBuffer(updMsgWithOneMandatoryAttributeNotPresent), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals(BGPError.MANDATORY_ATTR_MISSING_MSG + "ORIGIN", e.getMessage());
}
@Test
- public void testParseUpdMsgWithMultipleMandatoryAttributesNotPresent() throws BGPDocumentedException, BGPParsingException {
+ public void testParseUpdMsgWithMultipleMandatoryAttributesNotPresent()
+ throws BGPDocumentedException, BGPParsingException {
try {
- reg.parseMessage(Unpooled.copiedBuffer(updMsgWithMultipleMandatoryAttributesNotPresent));
+ reg.parseMessage(Unpooled.copiedBuffer(updMsgWithMultipleMandatoryAttributesNotPresent), null);
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals(BGPError.MANDATORY_ATTR_MISSING_MSG + "NEXT_HOP", e.getMessage());
@Test
public void testRouteRefreshMsg() throws BGPDocumentedException, BGPParsingException {
- final Notification rrMsg = new RouteRefreshBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
+ final Notification rrMsg = new RouteRefreshBuilder().setAfi(Ipv4AddressFamily.class)
+ .setSafi(UnicastSubsequentAddressFamily.class).build();
final ByteBuf buffer = Unpooled.buffer();
ParserTest.reg.serializeMessage(rrMsg, buffer);
assertArrayEquals(RR_MSG, ByteArray.getAllBytes(buffer));
- final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)));
+ final Notification m = ParserTest.reg.parseMessage(
+ Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)), null);
assertTrue(m instanceof RouteRefresh);
}
public void testOriginParser() {
try {
ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry().parseAttributes(
- Unpooled.copiedBuffer(new byte[] { 0x40, 0x01, 0x01, 0x04 }));
+ Unpooled.copiedBuffer(new byte[] { 0x40, 0x01, 0x01, 0x04 }), null);
fail("This needs to fail.");
} catch (final BGPDocumentedException e) {
assertEquals("Unknown Origin type.", e.getMessage());
final byte[] value = new byte[] { 1, 0, 11, 0, 0, 0, 0, 0, 0, 0, 8 };
final ByteBuf buffer = Unpooled.buffer();
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE, Unpooled.copiedBuffer(value), buffer);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE,
+ Unpooled.copiedBuffer(value), buffer);
- final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
- final Attributes pathAttributes = providerContext.getAttributeRegistry().parseAttributes(buffer);
+ final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext
+ .getSingletonInstance();
+ final Attributes pathAttributes = providerContext.getAttributeRegistry()
+ .parseAttributes(buffer, null);
final Aigp aigp = pathAttributes.getAigp();
final AigpTlv tlv = aigp.getAigpTlv();
assertNotNull("Tlv should not be null.", tlv);
- assertEquals("Aigp tlv should have metric with value 8.", 8, tlv.getMetric().getValue().intValue());
+ assertEquals("Aigp tlv should have metric with value 8.", 8,
+ tlv.getMetric().getValue().intValue());
}
@Test
final ByteBuf inputData = Unpooled.buffer();
final ByteBuf testBuffer = Unpooled.buffer();
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE, Unpooled.copiedBuffer(value), inputData);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE,
+ Unpooled.copiedBuffer(value), inputData);
- final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
- final Attributes pathAttributes = providerContext.getAttributeRegistry().parseAttributes(inputData);
+ final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext
+ .getSingletonInstance();
+ final Attributes pathAttributes = providerContext.getAttributeRegistry()
+ .parseAttributes(inputData, null);
final Aigp aigp = pathAttributes.getAigp();
final AttributesBuilder pathAttributesBuilder = new AttributesBuilder();
ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry()
.serializeAttribute(paBuilder.build(), actual);
assertArrayEquals(CommunitiesBytes, ByteArray.getAllBytes(actual));
- final Attributes attributeOut = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry()
- .parseAttributes(actual);
+ final Attributes attributeOut = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+ .getAttributeRegistry().parseAttributes(actual, null);
assertEquals(comms, attributeOut.getCommunities());
}
this.messages = messages;
}
- @Override
- public Notification parseMessage(final ByteBuf buffer) throws BGPParsingException, BGPDocumentedException {
- final Notification ret = this.messages.get(buffer);
- Preconditions.checkArgument(ret != null, "Undefined message encountered");
- return ret;
- }
-
@Override
public void serializeMessage(final Notification msg, final ByteBuf buffer) {
// no action needed, it's a mock for parsing, not serializing
}
@Override
- public Notification parseMessage(final ByteBuf bytes, final PeerSpecificParserConstraint constraint)
+ public Notification parseMessage(final ByteBuf buffer, final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPParsingException {
- return parseMessage(bytes);
+ final Notification ret = this.messages.get(buffer);
+ Preconditions.checkArgument(ret != null, "Undefined message encountered");
+ return ret;
}
}
final BGPMessageParserMock mockParser = new BGPMessageParserMock(updateMap);
for (int i = 0; i < this.inputBytes.length; i++) {
- assertEquals(this.messages.get(i), mockParser.parseMessage(Unpooled.copiedBuffer(this.inputBytes[i])));
+ assertEquals(this.messages.get(i), mockParser.parseMessage(Unpooled.copiedBuffer(this.inputBytes[i]), null));
}
- assertNotSame(this.messages.get(3), mockParser.parseMessage(Unpooled.copiedBuffer(this.inputBytes[8])));
+ assertNotSame(this.messages.get(3), mockParser.parseMessage(Unpooled.copiedBuffer(this.inputBytes[8]), null));
}
/**
updateMap.put(Unpooled.copiedBuffer(this.inputBytes[i]), this.messages.get(i));
}
final BGPMessageParserMock mockParser = new BGPMessageParserMock(updateMap);
- mockParser.parseMessage(Unpooled.copiedBuffer(new byte[] { 7, 4, 6 }));
+ mockParser.parseMessage(Unpooled.copiedBuffer(new byte[] { 7, 4, 6 }), null);
}
/**
final byte[] input = new byte[] { 5, 8, 13, 21 };
- openMap.put(Unpooled.copiedBuffer(input), new OpenBuilder().setMyAsNumber(30).setHoldTimer(30).setBgpParameters(params).setVersion(
- new ProtocolVersion((short) 4)).build());
+ openMap.put(Unpooled.copiedBuffer(input), new OpenBuilder().setMyAsNumber(30).setHoldTimer(30)
+ .setBgpParameters(params).setVersion(new ProtocolVersion((short) 4)).build());
final BGPMessageParserMock mockParser = new BGPMessageParserMock(openMap);
final Set<BgpTableType> result = Sets.newHashSet();
- for (final BgpParameters p : ((Open) mockParser.parseMessage(Unpooled.copiedBuffer(input))).getBgpParameters()) {
+ for (final BgpParameters p : ((Open) mockParser.parseMessage(Unpooled.copiedBuffer(input), null)).getBgpParameters()) {
for (final OptionalCapabilities capa : p.getOptionalCapabilities()) {
final CParameters cp = capa.getCParameters();
if (cp.getAugmentation(CParameters1.class) != null && cp.getAugmentation(CParameters1.class).getMultiprotocolCapability() != null) {
Arrays.fill(MARKER, UnsignedBytes.MAX_VALUE);
}
- @Override
- public final Notification parseMessage(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
- return parseMessage(buffer, null);
- }
-
@Override
public Notification parseMessage(final ByteBuf buffer, final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPParsingException {
*
*/
public interface AttributeRegistry {
-
- /**
- * @deprecated Use {@link #parseAttributes(ByteBuf, PeerSpecificParserConstraint)}
- */
- @Deprecated
- Attributes parseAttributes(ByteBuf buffer) throws BGPDocumentedException, BGPParsingException;
-
/**
* Parse BGP Attribute from buffer.
* @param buffer Input buffer.
AutoCloseable registerBgpPrefixSidTlvSerializer(Class<? extends BgpPrefixSidTlv> tlvClass, BgpPrefixSidTlvSerializer serializer);
- /**
- * Each extension requires a specific NextHop handler. Therefore this method has been deprecated for
- * the method which enforce user to register it.
- */
- @Deprecated
- AutoCloseable registerNlriParser(Class<? extends AddressFamily> afi, Class<? extends SubsequentAddressFamily> safi, NlriParser parser);
-
AutoCloseable registerNlriParser(Class<? extends AddressFamily> afi, Class<? extends SubsequentAddressFamily> safi,
NlriParser parser, final NextHopParserSerializer nextHopHandler, final Class<? extends CNextHop> cNextHopClass,
final Class<? extends CNextHop>... cNextHopClassList);
* to encode/decode messages.
*/
public interface MessageRegistry {
-
- /**
- * @deprecated Use {@link #parseMessage(ByteBuf, PeerSpecificParserConstraint)}
- */
- @Deprecated
- Notification parseMessage(ByteBuf bytes) throws BGPDocumentedException, BGPParsingException;
-
/**
* Decode input buffer to BGP Message.
* @param bytes Input buffer with encoded message.
*
*/
public interface NlriRegistry {
-
- /**
- * @deprecated Use {@link #parseMpReach(ByteBuf, PeerSpecificParserConstraint)}
- */
- @Deprecated
- MpReachNlri parseMpReach(ByteBuf buffer) throws BGPParsingException;
-
- /**
- * @deprecated Use {@link #parseMpUnreach(ByteBuf, PeerSpecificParserConstraint)}
- */
- @Deprecated
- MpUnreachNlri parseMpUnreach(ByteBuf buffer) throws BGPParsingException;
-
/**
* Decode MP REACH NLRI Attribute.
* @param buffer Input buffer.
LOG.debug("Unrecognized attribute were parsed: {}", unrecognizedAttribute);
}
- @Override
- public Attributes parseAttributes(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
- return parseAttributes(buffer, null);
- }
-
@Override
public Attributes parseAttributes(final ByteBuf buffer, final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPParsingException {
return this.getMessageRegistry().registerMessageSerializer(messageClass, serializer);
}
- /**
- * Each extension requires a specific NextHop handler. Therefore this method has been deprecated for
- * the method which enforce user to register it.
- */
- @Deprecated
- @Override
- public AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final NlriParser parser) {
- return this.getNlriRegistry().registerNlriParser(afi, safi, parser, null, null);
- }
-
@Override
public AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi,
final NlriParser parser, final NextHopParserSerializer nextHopParserSerializer, final Class<? extends
return safi;
}
- @Override
- public MpUnreachNlri parseMpUnreach(final ByteBuf buffer) throws BGPParsingException {
- return parseMpUnreach(buffer, null);
- }
-
@Override
public MpUnreachNlri parseMpUnreach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint)
throws BGPParsingException {
new BgpTableTypeImpl(afi, safi));
final NextHopParserSerializer nextHopSerializer = this.nextHopSerializers.get(key);
final ByteBuf nextHopBuffer = Unpooled.buffer();
- if (nextHopSerializer == null) {
- //TODO Remove once deprecated registerNlriParser is removed
- LOG.warn("NexHop Parser/Serializer for AFI/SAFI ({},{}) not bound", afi, safi);
- NextHopUtil.serializeNextHop(cNextHop, nextHopBuffer);
- } else {
- nextHopSerializer.serializeNextHop(cNextHop, nextHopBuffer);
- }
+ nextHopSerializer.serializeNextHop(cNextHop, nextHopBuffer);
byteAggregator.writeByte(nextHopBuffer.writerIndex());
byteAggregator.writeBytes(nextHopBuffer);
return Iterables.unmodifiableIterable(this.serializers.values());
}
- @Override
- public MpReachNlri parseMpReach(final ByteBuf buffer) throws BGPParsingException {
- return parseMpReach(buffer, null);
- }
-
@Override
public MpReachNlri parseMpReach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint)
throws BGPParsingException {
this.registry.serializeMessage(keepAlive, buffer);
assertArrayEquals(keepAliveBMsg, ByteArray.getAllBytes(buffer));
- final Notification not = this.registry.parseMessage(Unpooled.copiedBuffer(keepAliveBMsg));
+ final Notification not = this.registry.parseMessage(Unpooled.copiedBuffer(keepAliveBMsg), null);
assertTrue(not instanceof Keepalive);
}
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
try {
- this.registry.parseMessage(Unpooled.copiedBuffer(testBytes));
+ this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
} catch (BGPDocumentedException | BGPParsingException e) {
assertTrue(e instanceof BGPDocumentedException);
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0x00, (byte) 0x12, (byte) 0x04 };
try {
- this.registry.parseMessage(Unpooled.copiedBuffer(testBytes));
+ this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
} catch (BGPDocumentedException | BGPParsingException e) {
assertTrue(e instanceof BGPDocumentedException);
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04, (byte) 0x04 };
try {
- this.registry.parseMessage(Unpooled.copiedBuffer(testBytes));
+ this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
} catch (BGPDocumentedException | BGPParsingException e) {
assertTrue(e instanceof BGPParsingException);
public void testBGPHeaderParser() throws Exception {
final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
try {
- msgReg.parseMessage(Unpooled.copiedBuffer(new byte[] { (byte) 0, (byte) 0 }));
+ msgReg.parseMessage(Unpooled.copiedBuffer(new byte[] { (byte) 0, (byte) 0 }), null);
fail("Exception should have occured.");
} catch (final IllegalArgumentException e) {
assertEquals("Too few bytes in passed array. Passed: 2. Expected: >= 19.", e.getMessage());
public void testUnrecognizedAttributesWithoutOptionalFlag() throws BGPDocumentedException, BGPParsingException {
this.expException.expect(BGPDocumentedException.class);
this.expException.expectMessage("Well known attribute not recognized.");
- simpleAttrReg.parseAttributes(Unpooled.wrappedBuffer(new byte[] { 0x03, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 }));
+ simpleAttrReg.parseAttributes(
+ Unpooled.wrappedBuffer(new byte[] { 0x03, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 }), null);
}
@Test
public void testUnrecognizedAttributes() throws BGPDocumentedException, BGPParsingException {
final byte[] attributeBytes = { (byte)0xe0, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 };
- final List<UnrecognizedAttributes> unrecogAttribs = simpleAttrReg.parseAttributes(Unpooled.wrappedBuffer(attributeBytes)).getUnrecognizedAttributes();
+ final List<UnrecognizedAttributes> unrecogAttribs = simpleAttrReg
+ .parseAttributes(Unpooled.wrappedBuffer(attributeBytes), null).getUnrecognizedAttributes();
assertEquals(UNRECOGNIZED_ATTRIBUTE_COUNT, unrecogAttribs.size());
final UnrecognizedAttributes unrecogAttrib = unrecogAttribs.get(FIRST_ATTRIBUTE);
- final UnrecognizedAttributesKey expectedAttribKey = new UnrecognizedAttributesKey(unrecogAttrib.getType().shortValue());
+ final UnrecognizedAttributesKey expectedAttribKey =
+ new UnrecognizedAttributesKey(unrecogAttrib.getType().shortValue());
assertTrue(unrecogAttrib.isPartial());
assertTrue(unrecogAttrib.isTransitive());
return attributes == null || role == null ? null : this.policy.effectiveAttributes(role, attributes);
}
- @Override
- public Collection<Map.Entry<PeerId, PeerExporTuple>> getPeers() {
- synchronized (this.peers) {
- return this.peers.entrySet();
- }
- }
-
@Override
public boolean containsPeer(final PeerId routePeerId) {
synchronized (this.peers) {
* Tracks peers for adj-rib-out writeout.
*/
public interface ExportPolicyPeerTracker {
- /**
- * Update set with supported tables per peer
- * @param peerId which receveid the change
- * @param node data change
- */
- @Deprecated
- default void onTablesChanged(PeerId peerId, DataTreeCandidateNode node) {}
-
/**
* Register Peer
* @param peerId Peer Id
*/
boolean isAddPathSupportedByPeer(@Nonnull PeerId peerId);
- /**
- * Invoked whenever a peer role changes.
- *
- * @param peerPath Peer's path
- * @param role Peer's new role, null indicates the peer has disappeared.
- */
- @Deprecated
- default void peerRoleChanged(@Nonnull YangInstanceIdentifier peerPath, @Nullable PeerRole role) {
- }
-
/**
* Flags peers once empty structure has been created, then changes under it can
* be applied
*/
ContainerNode effectiveAttributes(PeerRole role, ContainerNode attributes);
- /**
- * @return map of peer
- * @deprecated Use {@link #forEach}
- */
- @Deprecated
- Collection<Map.Entry<PeerId, PeerExporTuple>> getPeers();
-
/**
*
* @param routePeerId PeerId
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. 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.rib.spi;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-
-@Deprecated
-public interface RouteEncoder {
- Update updateMessageFor(Object key, Route route);
-}
registerDataChangeListener();
}
- @Deprecated
- public final InstanceIdentifier<Tables> tableInstanceIdentifier(final Class<? extends AddressFamily> afi,
- final Class<? extends SubsequentAddressFamily> safi) {
- return this.locRibReference.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(afi, safi)).build();
- }
-
/**
* Register to data tree change listener
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.OriginBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.LocRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
super.setUp();
this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
this.ipv4TopoBuilder.start();
- final InstanceIdentifier<Tables> path = this.ipv4TopoBuilder.tableInstanceIdentifier(Ipv4AddressFamily.class,
- UnicastSubsequentAddressFamily.class);
+ final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class)
+ .child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).build();
+
this.ipv4RouteIID = path.builder().child((Class) Ipv4Routes.class)
- .child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID),
- new Ipv4Prefix(ROUTE_IP4PREFIX))).build();
+ .child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID), new Ipv4Prefix(ROUTE_IP4PREFIX))).build();
}
@Test
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.Origin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.OriginBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.LocRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
super.setUp();
this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
this.ipv6TopoBuilder.start();
- final InstanceIdentifier<Tables> path = this.ipv6TopoBuilder
- .tableInstanceIdentifier(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class)
+ .child(Tables.class, new TablesKey(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class)).build();
this.ipv6RouteIID = path.builder().child((Class) Ipv6Routes.class)
.child(Ipv6Route.class, new Ipv6RouteKey(new PathId(PATH_ID),
new Ipv6Prefix(ROUTE_IP6PREFIX))).build();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.node.identifier.c.router.identifier.isis.node._case.IsisNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.OriginBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.LocRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IgpMetric;
public class LinkstateTopologyBuilderTest extends AbstractTopologyBuilderTest {
- private static final byte[] LINKSTATE_ROUTE_KEY = Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode("linkstate-route")).array();
+ private static final byte[] LINKSTATE_ROUTE_KEY = Unpooled.wrappedBuffer(
+ StandardCharsets.UTF_8.encode("linkstate-route")).array();
private static final String ROUTER_1_ID = "127.0.0.1";
private static final String ROUTER_2_ID = "127.0.0.2";
private static final String NODE_1_PREFIX = "127.0.1.1/32";
@Override
public void setUp() {
super.setUp();
- this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
+ this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID,
+ LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
this.linkstateTopoBuilder.start();
- final InstanceIdentifier<Tables> path = this.linkstateTopoBuilder.tableInstanceIdentifier(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
- this.linkstateRouteIID = path.builder().child((Class) LinkstateRoutes.class).child(LinkstateRoute.class, new LinkstateRouteKey(LINKSTATE_ROUTE_KEY)).build();
+ final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class)
+ .child(Tables.class, new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class))
+ .build();
+ this.linkstateRouteIID = path.builder().child((Class) LinkstateRoutes.class)
+ .child(LinkstateRoute.class, new LinkstateRouteKey(LINKSTATE_ROUTE_KEY)).build();
}
return IetfInetUtil.INSTANCE.ipv4PrefixToBytes(prefix);
}
- /**
- * Converts Ipv4Prefix to byte array. Prefix length at the beginning.
- * Prefix bytes are trimmed from the end to match prefix length.
- *
- * @param prefix Ipv4Prefix to be converted
- * @return byte array with the prefix length at the beginning
- *
- * @deprecated This is inefficient, refactor code to use {@link #bytesForAddress(Ipv4Address)} or
- * {@link ByteBufWriteUtil#writeMinimalPrefix(Ipv4Prefix, ByteBuf)}.
- */
- @Deprecated
- public static byte[] bytesForPrefixBegin(final Ipv4Prefix prefix) {
- final byte[] addrWithPrefix = bytesForPrefix(prefix);
- return prefixedBytes(addrWithPrefix[IP4_LENGTH], addrWithPrefix);
- }
-
- static byte[] prefixedBytes(final byte prefixBits, final byte[] address) {
- if (prefixBits != 0) {
- final int prefixBytes = prefixBitsToBytes(Byte.toUnsignedInt(prefixBits));
- final byte[] ret = new byte[prefixBytes + 1];
- ret[0] = prefixBits;
- System.arraycopy(address, 0, ret, 1, prefixBytes);
- return ret;
- } else {
- return new byte[] { 0 };
- }
- }
-
/**
* Creates an Ipv4Prefix object from given byte array.
*
return IetfInetUtil.INSTANCE.ipv6PrefixToBytes(prefix);
}
- /**
- * Converts Ipv6Prefix to byte array. Prefix length at the beginning.
- * Prefix bytes are trimmed from the end to match prefix length.
- *
- * @param prefix Ipv6Prefix to be converted
- * @return byte array with the prefix length at the beginning
- *
- * @deprecated This is inefficient, refactor code to use {@link #bytesForAddress(Ipv6Address)} or
- * {@link ByteBufWriteUtil#writeMinimalPrefix(Ipv6Prefix, ByteBuf)}.
- */
- @Deprecated
- public static byte[] bytesForPrefixBegin(final Ipv6Prefix prefix) {
- final byte[] addrWithPrefix = bytesForPrefix(prefix);
- return Ipv4Util.prefixedBytes(addrWithPrefix[IPV6_LENGTH], addrWithPrefix);
- }
-
/**
* Creates an Ipv6Prefix object from given byte array.
*
public void testBytesForPrefix4Begin() {
byte[] bytes = new byte[] { 123, 122, 4, 5 };
assertEquals(new Ipv4Prefix("123.122.4.5/8"), Ipv4Util.prefixForBytes(bytes, 8));
- assertArrayEquals(new byte[] { 8, 102 }, Ipv4Util.bytesForPrefixBegin(new Ipv4Prefix("102.0.0.0/8")));
bytes = new byte[] { (byte) 255, (byte) 255, 0, 0 };
assertEquals(new Ipv4Prefix("255.255.0.0/16"), Ipv4Util.prefixForBytes(bytes, 16));
- assertArrayEquals(new byte[] { 16, (byte) 255, (byte) 255 }, Ipv4Util.bytesForPrefixBegin(new Ipv4Prefix("255.255.0.0/16")));
-
bytes = new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
assertEquals(new Ipv4Prefix("0.0.0.0/0"), Ipv4Util.prefixForBytes(bytes, 0));
-
- bytes = new byte[] { (byte) 0 };
- assertArrayEquals(bytes, Ipv4Util.bytesForPrefixBegin(new Ipv4Prefix("0.0.0.0/0")));
}
@Test
public void testBytesForPrefix6Begin() {
byte[] bytes = new byte[] { 0x20, 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02 };
assertEquals(new Ipv6Prefix("2001:db8:1:2::/64"), Ipv6Util.prefixForBytes(bytes, 64));
- assertArrayEquals(new byte[] { 0x40, 0x20, (byte) 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02 }, Ipv6Util.bytesForPrefixBegin(new Ipv6Prefix("2001:db8:1:2::/64")));
bytes = new byte[] { (byte) 0 };
assertEquals(new Ipv6Prefix("::/0"), Ipv6Util.prefixForBytes(bytes, 0));
- assertArrayEquals(bytes, Ipv6Util.bytesForPrefixBegin(new Ipv6Prefix("::/0")));
}
@Test