use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib in project bgpcep by opendaylight.
the class BGPParserTest method testEORIpv6.
/*
* End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 1d <- length (29) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
* 00 06 <- total path attribute length
* 80 <- attribute flags
* 0f <- attribute type (15 - MP_UNREACH_NLRI)
* 03 <- attribute length
* 00 02 <- value (AFI 2: IPv6)
* 01 <- value (SAFI 1)
*/
@Test
public void testEORIpv6() throws Exception {
final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(6), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(INPUT_BYTES.get(6), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength, null);
final Class<? extends AddressFamily> afi = message.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri().getAfi();
final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri().getSafi();
assertEquals(Ipv6AddressFamily.class, afi);
assertEquals(UnicastSubsequentAddressFamily.class, safi);
final ByteBuf buffer = Unpooled.buffer();
BGPParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(INPUT_BYTES.get(6), ByteArray.readAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib in project bgpcep by opendaylight.
the class BGPParserTest method testEORIpv4.
/*
* End of Rib for Ipv4.
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 17 <- length (23) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
* 00 00 <- total path attribute length
*/
@Test
public void testEORIpv4() throws Exception {
final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(5), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(INPUT_BYTES.get(5), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength, null);
assertEquals(new UpdateBuilder().build(), message);
final ByteBuf buffer = Unpooled.buffer();
BGPParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(INPUT_BYTES.get(5), ByteArray.readAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib in project bgpcep by opendaylight.
the class BgpPeer method getBgpCapabilities.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static List<OptionalCapabilities> getBgpCapabilities(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<OptionalCapabilities> caps = new ArrayList<>();
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
final Collection<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false).values();
final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
if (!addPathCapability.isEmpty()) {
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
}
final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
for (final BgpTableType tableType : tableTypes) {
if (!rib.getLocalTables().contains(tableType)) {
LOG.info("RIB instance does not list {} in its local tables. Incoming data will be dropped.", tableType);
}
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
}
return caps;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib in project bgpcep by opendaylight.
the class BGPClusterSingletonService method onGlobalChanged.
synchronized void onGlobalChanged(final DataObjectModification<Global> dataObjectModification) {
switch(dataObjectModification.getModificationType()) {
case DELETE:
LOG.debug("Removing RIB instance: {}", bgpIid);
if (ribImpl != null) {
LOG.debug("RIB instance removed {}", ribImpl);
closeBoundPeers();
closeRibInstance();
ribImpl = null;
}
break;
case SUBTREE_MODIFIED:
case WRITE:
final Global global = dataObjectModification.getDataAfter();
if (ribImpl == null) {
onGlobalCreated(global);
} else if (!ribImpl.isGlobalEqual(requireNonNull(global))) {
onGlobalUpdated(global);
}
break;
default:
break;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method setUp.
@Before
public void setUp() {
doReturn(BGP_TABLE_TYPE_IPV4).when(tableTypeRegistry).getTableType(IPV4UNICAST.class);
doReturn(BGP_TABLE_TYPE_IPV6).when(tableTypeRegistry).getTableType(IPV6UNICAST.class);
doReturn(new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class)).when(tableTypeRegistry).getTableType(IPV6LABELLEDUNICAST.class);
doReturn(AS).when(rib).getLocalAs();
}
Aggregations