use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PcepStateUtils method showMessages.
private static void showMessages(final ShellTable table, final Messages messages) {
if (messages == null) {
return;
}
addHeader(table, "Messages");
table.addRow().addContent("Last Sent Msg Timestamp", messages.getLastSentMsgTimestamp());
table.addRow().addContent("Received Msg Count", messages.getReceivedMsgCount());
table.addRow().addContent("Sent Msg Count", messages.getSentMsgCount());
table.addRow().addContent("Unknown Msg Received", messages.getUnknownMsgReceived());
final StatefulMessagesStatsAug statefulMessages = messages.getAugmentation(StatefulMessagesStatsAug.class);
if (statefulMessages == null) {
return;
}
addHeader(table, " Stateful Messages");
table.addRow().addContent("Last Received RptMsg Timestamp", statefulMessages.getLastReceivedRptMsgTimestamp());
table.addRow().addContent("Received RptMsg", statefulMessages.getReceivedRptMsgCount());
table.addRow().addContent("Sent Init Msg", statefulMessages.getSentInitMsgCount());
table.addRow().addContent("Sent Upd Msg", statefulMessages.getSentUpdMsgCount());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testOpenObjectWithTLV.
@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
try (SyncOptimizationsActivator a = new SyncOptimizationsActivator()) {
a.start(this.ctx);
final SyncOptimizationsOpenObjectParser parser = new SyncOptimizationsOpenObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setVersion(new ProtocolVersion((short) 1));
builder.setKeepalive((short) 30);
builder.setDeadTimer((short) 120);
builder.setSessionId((short) 1);
final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(Stateful1.class, new Stateful1Builder().build()).build();
final Tlvs1Builder statBuilder = new Tlvs1Builder();
statBuilder.setStateful(tlv1);
final Tlvs3Builder syncOptBuilder = new Tlvs3Builder();
syncOptBuilder.setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(new BigInteger(DB_VERSION)).build());
syncOptBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build());
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, statBuilder.build()).addAugmentation(Tlvs3.class, syncOptBuilder.build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testStatefulTlv.
@Test
public void testStatefulTlv() throws PCEPDeserializerException {
final Stateful07StatefulCapabilityTlvParser parser = new Stateful07StatefulCapabilityTlvParser();
final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(statefulBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(statefulBytes, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class PCEPValidatorTest method testOpenMsg.
@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
try (StatefulActivator a = new StatefulActivator()) {
a.start(this.ctx);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
final OpenMessageBuilder builder = new OpenMessageBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
b.setProcessingRule(false);
b.setIgnore(false);
b.setVersion(new ProtocolVersion((short) 1));
b.setKeepalive((short) 30);
b.setDeadTimer((short) 120);
b.setSessionId((short) 1);
final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(tlv1).build()).build());
builder.setOpen(b.build());
assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful in project bgpcep by opendaylight.
the class Stateful07StatefulCapabilityTlvParser 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