use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class PeerUpHandler method addTlv.
@Override
protected void addTlv(final InformationBuilder builder, final Tlv tlv) {
if (tlv instanceof StringTlv) {
final ImmutableList.Builder<StringInformation> stringInfoListBuilder = ImmutableList.builder();
if (builder.getStringInformation() != null) {
stringInfoListBuilder.addAll(builder.getStringInformation());
}
builder.setStringInformation(stringInfoListBuilder.add(new StringInformationBuilder().setStringTlv(new StringTlvBuilder((StringTlv) tlv).build()).build()).build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class AbstractBmpMessageWithTlvParser method parseTlvs.
protected final void parseTlvs(final T builder, final ByteBuf bytes) throws BmpDeserializationException {
Preconditions.checkArgument(bytes != null, "Array of bytes is mandatory. Can't be null.");
if (!bytes.isReadable()) {
return;
}
while (bytes.isReadable()) {
final int type = bytes.readUnsignedShort();
final int length = bytes.readUnsignedShort();
if (length > bytes.readableBytes()) {
throw new BmpDeserializationException("Wrong length specified. Passed: " + length + "; Expected: <= " + bytes.readableBytes() + ".");
}
final ByteBuf tlvBytes = bytes.readSlice(length);
LOG.trace("Parsing BMP TLV : {}", ByteBufUtil.hexDump(tlvBytes));
final Tlv tlv = this.tlvRegistry.parseTlv(type, tlvBytes);
if (tlv != null) {
LOG.trace("Parsed BMP TLV {}.", tlv);
addTlv(builder, tlv);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class SimpleBmpTlvRegistryTest method testParseTlv.
@Test
public void testParseTlv() throws BmpDeserializationException {
final Tlv output = this.bmpTlvRegistry.parseTlv(DESCRIPTION_TLV_TYPE, this.input);
assertNotNull(output);
assertTrue(output instanceof MockDescriptionTlv);
final ByteBuf aggregator = Unpooled.EMPTY_BUFFER;
this.bmpTlvRegistry.serializeTlv(output, aggregator);
Mockito.verify(this.descriptionTlvSerializer).serializeTlv(output, aggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class StatType009TlvHandler method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf output) {
Preconditions.checkArgument(tlv instanceof PerAfiSafiAdjRibInTlv, "PerAfiSafiAdjRibInTlv is mandatory.");
final ByteBuf buffer = Unpooled.buffer();
ByteBufWriteUtil.writeUnsignedShort(this.afiRegistry.numberForClass(((PerAfiSafiAdjRibInTlv) tlv).getAfi()), buffer);
ByteBufWriteUtil.writeUnsignedByte(this.safiRegistry.numberForClass(((PerAfiSafiAdjRibInTlv) tlv).getSafi()).shortValue(), buffer);
ByteBufWriteUtil.writeUnsignedLong(((PerAfiSafiAdjRibInTlv) tlv).getCount().getValue(), buffer);
TlvUtil.formatTlv(TYPE, buffer, output);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class StatType010TlvHandler method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf output) {
Preconditions.checkArgument(tlv instanceof PerAfiSafiLocRibTlv, "PerAfiSafiLocRibInTlv is mandatory.");
final ByteBuf buffer = Unpooled.buffer();
writeUnsignedShort(this.afiRegistry.numberForClass(((PerAfiSafiLocRibTlv) tlv).getAfi()), buffer);
writeUnsignedByte(this.safiRegistry.numberForClass(((PerAfiSafiLocRibTlv) tlv).getSafi()).shortValue(), buffer);
writeUnsignedLong(((PerAfiSafiLocRibTlv) tlv).getCount().getValue(), buffer);
TlvUtil.formatTlv(TYPE, buffer, output);
}
Aggregations