use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PathAttributeParserTest method testParsingAigpAttributeWithCorrectTLV.
@Test
public void testParsingAigpAttributeWithCorrectTLV() throws BGPDocumentedException, BGPParsingException {
final byte[] value = new byte[] { 1, 0, 11, 0, 0, 0, 0, 0, 0, 0, 8 };
final ByteBuf buffer = Unpooled.buffer();
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE, Unpooled.copiedBuffer(value), buffer);
final Attributes pathAttributes = ctx.getAttributeRegistry().parseAttributes(buffer, null).getAttributes();
final Aigp aigp = pathAttributes.getAigp();
final AigpTlv tlv = aigp.getAigpTlv();
assertNotNull("Tlv should not be null.", tlv);
assertEquals("Aigp tlv should have metric with value 8.", 8, tlv.getMetric().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class StatType010TlvHandler method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf output) {
checkArgument(tlv instanceof PerAfiSafiLocRibTlv, "PerAfiSafiLocRibInTlv is mandatory.");
final PerAfiSafiLocRibTlv perAfiSafi = (PerAfiSafiLocRibTlv) tlv;
final ByteBuf buffer = Unpooled.buffer();
final Integer afiInt = this.afiRegistry.numberForClass(perAfiSafi.getAfi());
buffer.writeShort(afiInt != null ? afiInt : 0);
buffer.writeByte(this.safiRegistry.numberForClass(perAfiSafi.getSafi()));
ByteBufUtils.write(buffer, perAfiSafi.getCount().getValue());
TlvUtil.formatTlv(TYPE, buffer, output);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.rev181109.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.rev181109.Tlv in project bgpcep by opendaylight.
the class StatType009TlvHandler method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf output) {
checkArgument(tlv instanceof PerAfiSafiAdjRibInTlv, "PerAfiSafiAdjRibInTlv is mandatory.");
final PerAfiSafiAdjRibInTlv perAfiSafi = (PerAfiSafiAdjRibInTlv) tlv;
final ByteBuf buffer = Unpooled.buffer();
final Integer afiInt = this.afiRegistry.numberForClass(perAfiSafi.getAfi());
buffer.writeShort(afiInt != null ? afiInt : 0);
buffer.writeByte(this.safiRegistry.numberForClass(perAfiSafi.getSafi()));
ByteBufUtils.write(buffer, perAfiSafi.getCount().getValue());
TlvUtil.formatTlv(TYPE, buffer, output);
}
Aggregations