use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.
the class LlGracefulCapabilityHandler method parseCapability.
@Override
public CParameters parseCapability(final ByteBuf buffer) {
final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
while (buffer.isReadable()) {
final short 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_TABLE_SIZE - 2);
continue;
}
final byte safival = buffer.readByte();
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(PER_TABLE_SIZE - 3);
continue;
}
final byte afiFlags = buffer.readByte();
final int staleTime = buffer.readUnsignedMedium();
final Tables table = new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new Tables.AfiFlags(afiFlags == AFI_FLAG_FORWARDING_STATE)).setLongLivedStaleTime(new Uint24(Uint32.valueOf(staleTime))).build();
tables.add(table);
}
return new CParametersBuilder().addAugmentation(new CParameters1Builder().setLlGracefulRestartCapability(new LlGracefulRestartCapabilityBuilder().setTables(tables.build()).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables 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.Tables 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.Tables in project bgpcep by opendaylight.
the class ComplementaryTest method testBGPParameter.
@Test
public void testBGPParameter() {
final MultiprotocolCapability cap = new MultiprotocolCapabilityBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv1 = new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(cap).build()).build();
final MultiprotocolCapability cap1 = new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv2 = new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(cap1).build()).build();
final Map<TablesKey, Tables> tt = BindingMap.of(new TablesBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build(), new TablesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build());
final GracefulRestartCapability tlv3 = new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(Boolean.FALSE)).setRestartTime(Uint16.ZERO).setTables(tt).build();
final CParameters tlv4 = new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(40))).build()).build();
assertFalse(tlv3.getRestartFlags().getRestartState());
assertEquals(0, tlv3.getRestartTime().intValue());
assertNotEquals(tlv1, tlv2);
assertNotSame(tlv1.hashCode(), tlv3.hashCode());
assertNotSame(tlv2.toString(), tlv3.toString());
assertEquals(tt, tlv3.getTables());
assertEquals(cap.getSafi(), cap1.getSafi());
assertNotSame(cap.getAfi(), cap1.getAfi());
assertEquals(40, tlv4.getAs4BytesCapability().getAsNumber().getValue().longValue());
assertEquals(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(40))).build()).build(), tlv4);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.
the class Ipv4ReachabilityTopologyBuilderTest method setUp.
@Before
@Override
public void setUp() {
super.setUp();
this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
this.ipv4TopoBuilder.start();
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(Ipv4RoutesCase.class, Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID), ROUTE_IP4PREFIX)).build();
}
Aggregations