use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class GracefulCapabilityHandler method serializeTables.
private void serializeTables(final Map<TablesKey, Tables> tables, final ByteBuf bytes) {
if (tables == null) {
return;
}
for (final Tables t : tables.values()) {
final Class<? extends AddressFamily> afi = t.getAfi();
final Integer afival = this.afiReg.numberForClass(afi);
Preconditions.checkArgument(afival != null, "Unhandled address family " + afi);
bytes.writeShort(afival);
final Class<? extends SubsequentAddressFamily> safi = t.getSafi();
final Integer safival = this.safiReg.numberForClass(safi);
Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi);
bytes.writeByte(safival);
if (t.getAfiFlags() != null && t.getAfiFlags().getForwardingState()) {
bytes.writeByte(AFI_FLAG_FORWARDING_STATE);
} else {
bytes.writeByte(0);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class GracefulCapabilityHandler method parseCapability.
@Override
public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final GracefulRestartCapabilityBuilder cb = new GracefulRestartCapabilityBuilder();
final int flagBits = buffer.getByte(0) >> RESTART_FLAGS_SIZE;
cb.setRestartFlags(new RestartFlags((flagBits & Byte.SIZE) != 0));
final int timer = ((buffer.readUnsignedByte() & TIMER_TOPBITS_MASK) << Byte.SIZE) + buffer.readUnsignedByte();
cb.setRestartTime(Uint16.valueOf(timer));
final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
while (buffer.readableBytes() != 0) {
final int afiVal = buffer.readShort();
final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afiVal);
if (afi == null) {
LOG.debug("Ignoring GR capability for unknown address family {}", afiVal);
buffer.skipBytes(PER_AFI_SAFI_SIZE - 2);
continue;
}
final int safiVal = buffer.readUnsignedByte();
final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safiVal);
if (safi == null) {
LOG.debug("Ignoring GR capability for unknown subsequent address family {}", safiVal);
buffer.skipBytes(1);
continue;
}
final int flags = buffer.readUnsignedByte();
tables.add(new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new AfiFlags((flags & AFI_FLAG_FORWARDING_STATE) != 0)).build());
}
cb.setTables(tables.build());
return new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(cb.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class SimpleBGPTableTypeRegistryProvider method registerBGPTableType.
@Override
public Registration registerBGPTableType(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final Class<? extends AfiSafiType> afiSafiType) {
final BgpTableType tableType = new BgpTableTypeImpl(afi, safi);
final Class<? extends AfiSafiType> prev = tableTypes.putIfAbsent(tableType, afiSafiType);
checkState(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
final TablesKey tableKey = new TablesKey(afi, safi);
tableKeys.put(tableKey, afiSafiType);
// For completeness, we do not really want this to happen
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
tableTypes.remove(tableType);
tableKeys.remove(tableKey);
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class NeighborUtil method buildAfiSafiState.
private static org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State buildAfiSafiState(@NonNull final BGPAfiSafiState neighbor, @NonNull final TablesKey tablesKey, final boolean afiSafiSupported) {
final NeighborAfiSafiStateAugmentationBuilder builder = new NeighborAfiSafiStateAugmentationBuilder();
builder.setActive(afiSafiSupported);
if (afiSafiSupported) {
builder.setPrefixes(new PrefixesBuilder().setInstalled(saturatedUint32(neighbor.getPrefixesInstalledCount(tablesKey))).setReceived(saturatedUint32(neighbor.getPrefixesReceivedCount(tablesKey))).setSent(saturatedUint32(neighbor.getPrefixesSentCount(tablesKey))).build());
}
return new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().addAugmentation(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class Ipv6ReachabilityTopologyBuilderTest method setUp.
@Before
@Override
public void setUp() {
super.setUp();
this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
this.ipv6TopoBuilder.start();
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(Ipv6RoutesCase.class, Ipv6Routes.class).child(Ipv6Route.class, new Ipv6RouteKey(new PathId(PATH_ID), ROUTE_IP6PREFIX)).build();
}
Aggregations