Search in sources :

Example 1 with UserErrorBuilder

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));
}
Also used : StatefulRSVPErrorSpecTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulRSVPErrorSpecTlvParser) UserCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) UserErrorBuilder(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) ByteBuf(io.netty.buffer.ByteBuf) RsvpErrorSpecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpecBuilder) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec) Test(org.junit.Test)

Example 2 with UserErrorBuilder

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();
}
Also used : UserCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) UserErrorBuilder(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)

Example 3 with UserErrorBuilder

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();
}
Also used : UserCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) UserErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder)

Aggregations

EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 UserCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder)2 UserErrorBuilder (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)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 StatefulRSVPErrorSpecTlvParser (org.opendaylight.protocol.pcep.ietf.stateful.StatefulRSVPErrorSpecTlvParser)1 UserCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder)1 UserErrorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder)1 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)1 RsvpErrorSpecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpecBuilder)1