use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class SimpleNlriRegistry method serializeMpReach.
@Override
public void serializeMpReach(final MpReachNlri mpReachNlri, final ByteBuf byteAggregator) {
final Class<? extends AddressFamily> afi = mpReachNlri.getAfi();
final Class<? extends SubsequentAddressFamily> safi = mpReachNlri.getSafi();
byteAggregator.writeShort(this.afiReg.numberForClass(afi));
byteAggregator.writeByte(this.safiReg.numberForClass(safi));
final CNextHop cNextHop = mpReachNlri.getCNextHop();
if (cNextHop != null) {
final Entry<Class<? extends CNextHop>, BgpTableType> key = new SimpleEntry(cNextHop.implementedInterface(), new BgpTableTypeImpl(afi, safi));
final NextHopParserSerializer nextHopSerializer = this.nextHopSerializers.get(key);
final ByteBuf nextHopBuffer = Unpooled.buffer();
nextHopSerializer.serializeNextHop(cNextHop, nextHopBuffer);
byteAggregator.writeByte(nextHopBuffer.writerIndex());
byteAggregator.writeBytes(nextHopBuffer);
} else {
byteAggregator.writeByte(0);
}
byteAggregator.writeZero(RESERVED);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class UtilsTest method testUnsupportedAfi.
@Test
public void testUnsupportedAfi() {
final byte[] bytes = new byte[] { 0, 2, 0, 1 };
final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg, this.safiReg);
assertFalse(parsedAfiSafi.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class SimpleNlriRegistry method parseMpUnreach.
@Override
public MpUnreachNlri parseMpUnreach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
final MpUnreachNlriBuilder builder = new MpUnreachNlriBuilder();
builder.setAfi(getAfi(buffer));
builder.setSafi(getSafi(buffer));
if (buffer.isReadable()) {
final ByteBuf nlri = buffer.slice();
final BgpTableType key = createKey(builder.getAfi(), builder.getSafi());
final NlriParser parser = this.handlers.get(key);
if (parser == null) {
LOG.warn(PARSER_NOT_FOUND, key);
} else {
parser.parseNlri(nlri, builder, constraint);
}
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class OpenConfigMappingUtil method toAddPathCapability.
static List<AddressFamilies> toAddPathCapability(final Collection<AfiSafi> afiSafis, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<AddressFamilies> addPathCapability = new ArrayList<>();
for (final AfiSafi afiSafi : afiSafis) {
final BgpNeighborAddPathsConfig afiSafi1 = afiSafi.augmentation(NeighborAddPathsConfig.class);
final BgpTableType bgpTableType = tableTypeRegistry.getTableType(afiSafi.getAfiSafiName());
if (afiSafi1 != null && bgpTableType != null) {
final AddressFamiliesBuilder builder = new AddressFamiliesBuilder(bgpTableType);
builder.setSendReceive(toSendReceiveMode(afiSafi1));
addPathCapability.add(builder.build());
}
}
return addPathCapability;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class ParserToSalTest method assertTablesExists.
private void assertTablesExists(final List<BgpTableType> expectedTables) throws InterruptedException, ExecutionException {
readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
final var tables = bgpRib.nonnullRib().values().iterator().next().getLocRib().getTables();
assertNotNull(tables);
for (final BgpTableType tableType : expectedTables) {
boolean found = false;
for (final Tables table : tables.values()) {
if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
found = true;
assertEquals(Boolean.TRUE, table.getAttributes().getUptodate());
}
}
assertTrue(found);
}
return bgpRib;
});
}
Aggregations