use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testCloseObjectWithVendorInformationTlv.
@Test
public void testCloseObjectWithVendorInformationTlv() throws IOException, 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(0L)).setEnterpriseSpecificInformation(esInfo).build();
final CCloseBuilder builder = new CCloseBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setReason((short) 5);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.iana.rev130816.EnterpriseNumber in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testVendorInformationObject.
@Test
public void testVendorInformationObject() throws PCEPDeserializerException {
final byte[] viObjBytes = { /* vendor-information object */
0x22, 0x10, 0x00, 0x0C, /* enterprise number */
0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
0x00, 0x00, 0x00, 0x05 };
final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
result.readerIndex(8);
final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
assertEquals(viObj, o);
final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
parser.serializeObject(viObj, buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber 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(0L)).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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber in project bgpcep by opendaylight.
the class Stateful07RSVPErrorSpecTlvParser method parseUserError.
private static UserCase parseUserError(final ByteBuf buffer) {
final UserErrorBuilder error = new UserErrorBuilder();
error.setEnterprise(new EnterpriseNumber(buffer.readUnsignedInt()));
error.setSubOrg(buffer.readUnsignedByte());
final int errDescrLength = buffer.readUnsignedByte();
error.setValue(buffer.readUnsignedShort());
error.setDescription(ByteArray.bytesToHRString(ByteArray.readBytes(buffer, errDescrLength)));
// if we have any subobjects, place the implementation here
return new UserCaseBuilder().setUserError(error.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber in project bgpcep by opendaylight.
the class AbstractVendorInformationObjectParser method parseObject.
@Override
public final Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final VendorInformationObjectBuilder builder = new VendorInformationObjectBuilder();
builder.setEnterpriseNumber(new EnterpriseNumber(getEnterpriseNumber()));
builder.setEnterpriseSpecificInformation(parseEnterpriseSpecificInformation(buffer));
return builder.build();
}
Aggregations