use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testUserErrorSpecTlv.
@Test
public void testUserErrorSpecTlv() throws PCEPDeserializerException {
final StatefulRSVPErrorSpecTlvParser parser = new StatefulRSVPErrorSpecTlvParser();
final UserErrorBuilder builder = new UserErrorBuilder().setEnterprise(new EnterpriseNumber(Uint32.valueOf(12345))).setSubOrg(Uint8.valueOf(5)).setValue(Uint16.valueOf(38)).setDescription("user desc");
final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new UserCaseBuilder().setUserError(builder.build()).build()).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(USER_ERROR_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(USER_ERROR_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder in project bgpcep by opendaylight.
the class StatefulRSVPErrorSpecTlvParser method parseUserError.
private static UserCase parseUserError(final ByteBuf buffer) {
final UserErrorBuilder error = new UserErrorBuilder().setEnterprise(new EnterpriseNumber(ByteBufUtils.readUint32(buffer)));
error.setSubOrg(ByteBufUtils.readUint8(buffer));
final int errDescrLength = buffer.readUnsignedByte();
error.setValue(ByteBufUtils.readUint16(buffer));
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.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder 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();
}
Aggregations