use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class AbstractVendorInformationTlvParser method parseTlv.
@Override
public final VendorInformationTlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
final VendorInformationTlvBuilder viTlvBuider = new VendorInformationTlvBuilder();
viTlvBuider.setEnterpriseNumber(getEnterpriseNumber());
if (buffer.isReadable()) {
final EnterpriseSpecificInformation esInformation = parseEnterpriseSpecificInformation(buffer.slice());
if (esInformation != null) {
viTlvBuider.setEnterpriseSpecificInformation(esInformation);
}
}
return viTlvBuider.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testCloseObjectWithVendorInformationTlv.
@Test
public void testCloseObjectWithVendorInformationTlv() throws PCEPDeserializerException {
final byte[] closeBytes = { 0x0f, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05, /* vendor-information TLV */
0x00, 0x07, 0x00, 0x08, /* enterprise number */
0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
0x00, 0x00, 0x00, 0x05 };
final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO)).setEnterpriseSpecificInformation(esInfo).build();
final CCloseBuilder builder = new CCloseBuilder().setProcessingRule(false).setIgnore(false).setReason(Uint8.valueOf(5)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.c.close.TlvsBuilder().setVendorInformationTlv(Lists.newArrayList(viTlv)).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.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class AbstractObjectWithTlvsTest method setUp.
@Before
public void setUp() throws PCEPDeserializerException {
this.tlv = new OfListBuilder().setCodes(Collections.singletonList(new OfId(Uint16.TEN))).build();
this.viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(EN).build();
doNothing().when(this.viTlvRegistry).serializeVendorInformationTlv(any(VendorInformationTlv.class), any(ByteBuf.class));
doReturn(Optional.of(this.viTlv)).when(this.viTlvRegistry).parseVendorInformationTlv(EN, Unpooled.wrappedBuffer(new byte[0]));
doNothing().when(this.tlvRegistry).serializeTlv(any(Tlv.class), any(ByteBuf.class));
doReturn(this.tlv).when(this.tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testVendorInformationTlv.
@Test
public void testVendorInformationTlv() throws PCEPDeserializerException {
final TestVendorInformationTlvParser parser = new TestVendorInformationTlvParser();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO)).setEnterpriseSpecificInformation(esInfo).build();
final VendorInformationTlv parsedTlv = parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(VENDOR_INFO_BYTES, 8)));
assertEquals(viTlv, parsedTlv);
final ByteBuf buff = Unpooled.buffer(VENDOR_INFO_BYTES.length);
parser.serializeTlv(viTlv, buff);
assertArrayEquals(VENDOR_INFO_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
Aggregations