use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testStatefulTlvSyncOptimizationExtension.
@Test
public void testStatefulTlvSyncOptimizationExtension() throws PCEPDeserializerException {
final SyncOptimizationsCapabilityTlvParser parser = new SyncOptimizationsCapabilityTlvParser();
final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Stateful1Builder().setTriggeredInitialSync(Boolean.TRUE).setDeltaLspSyncCapability(Boolean.TRUE).setIncludeDbVersion(Boolean.TRUE).build()).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(STATEFUL_SYNC_OPT_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(STATEFUL_SYNC_OPT_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PcepStateUtils method showCapabilities.
private static void showCapabilities(final ShellTable table, final PeerCapabilities capa) {
if (capa == null) {
return;
}
final StatefulCapabilitiesStatsAug stateFulCapa = capa.augmentation(StatefulCapabilitiesStatsAug.class);
if (stateFulCapa != null) {
addHeader(table, "Stateful Capabilities");
table.addRow().addContent("Stateful", stateFulCapa.getStateful());
table.addRow().addContent("Active", stateFulCapa.getActive());
table.addRow().addContent("Instantiation", stateFulCapa.getInstantiation());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method onSessionUp.
@Override
protected void onSessionUp(final PCEPSession session, final PathComputationClientBuilder pccBuilder) {
final InetAddress peerAddress = session.getRemoteAddress();
final Tlvs tlvs = session.getRemoteTlvs();
if (tlvs != null && tlvs.augmentation(Tlvs1.class) != null) {
final Stateful stateful = tlvs.augmentation(Tlvs1.class).getStateful();
if (stateful != null) {
setStatefulCapabilities(stateful);
pccBuilder.setReportedLsp(Collections.emptyMap());
if (isSynchronized()) {
pccBuilder.setStateSync(PccSyncState.Synchronized);
} else if (isTriggeredInitialSynchro()) {
pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
} else if (isIncrementalSynchro()) {
pccBuilder.setStateSync(PccSyncState.IncrementalSync);
} else {
pccBuilder.setStateSync(PccSyncState.InitialResync);
}
pccBuilder.setStatefulTlv(new StatefulTlvBuilder().addAugmentation(new StatefulTlv1Builder(tlvs.augmentation(Tlvs1.class)).build()).build());
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class InitiatedStatefulCapabilityTlvParser method serializeFlags.
@Override
protected BitArray serializeFlags(final Stateful sct) {
final BitArray flags = new BitArray(FLAGS_F_LENGTH);
final Stateful1 sfi = sct.augmentation(Stateful1.class);
if (sfi != null) {
flags.set(I_FLAG_OFFSET, sfi.getInitiation());
}
flags.set(U_FLAG_OFFSET, sct.getLspUpdateCapability());
return flags;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class StatefulStatefulCapabilityTlvParser method parseTlv.
@Override
public Stateful parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
if (buffer.readableBytes() < FLAGS_F_LENGTH / Byte.SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >= " + FLAGS_F_LENGTH / Byte.SIZE + ".");
}
final StatefulBuilder sb = new StatefulBuilder();
parseFlags(sb, buffer);
return sb.build();
}
Aggregations