Search in sources :

Example 1 with RsvpCase

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.RsvpCase in project bgpcep by opendaylight.

the class Stateful07RSVPErrorSpecTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof RsvpErrorSpec, "RSVPErrorSpecTlv is mandatory.");
    final RsvpErrorSpec rsvp = (RsvpErrorSpec) tlv;
    final ByteBuf body = Unpooled.buffer();
    if (rsvp.getErrorType().getImplementedInterface().equals(RsvpCase.class)) {
        final RsvpCase r = (RsvpCase) rsvp.getErrorType();
        serializeRsvp(r.getRsvpError(), body);
        TlvUtil.formatTlv(TYPE, body, buffer);
    } else {
        final UserCase u = (UserCase) rsvp.getErrorType();
        serializerUserError(u.getUserError(), body);
        TlvUtil.formatTlv(TYPE, body, buffer);
    }
}
Also used : RsvpCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCase) UserCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCase) ByteBuf(io.netty.buffer.ByteBuf) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec)

Example 2 with RsvpCase

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.RsvpCase in project bgpcep by opendaylight.

the class StatefulRSVPErrorSpecTlvParser method parseRsvp.

private static RsvpCase parseRsvp(final int classType, final ByteBuf buffer) {
    final RsvpErrorBuilder builder = new RsvpErrorBuilder();
    if (classType == RSVP_IPV4_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddressNoZone(Ipv4Util.addressForByteBuf(buffer)));
    } else if (classType == RSVP_IPV6_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer)));
    }
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
    builder.setCode(ByteBufUtils.readUint8(buffer));
    builder.setValue(ByteBufUtils.readUint16(buffer));
    return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
}
Also used : RsvpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags) RsvpErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder)

Example 3 with RsvpCase

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.RsvpCase in project bgpcep by opendaylight.

the class StatefulRSVPErrorSpecTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    checkArgument(tlv instanceof RsvpErrorSpec, "RSVPErrorSpecTlv is mandatory.");
    final RsvpErrorSpec rsvp = (RsvpErrorSpec) tlv;
    final ByteBuf body = Unpooled.buffer();
    if (rsvp.getErrorType().implementedInterface().equals(RsvpCase.class)) {
        final RsvpCase r = (RsvpCase) rsvp.getErrorType();
        serializeRsvp(r.getRsvpError(), body);
        TlvUtil.formatTlv(TYPE, body, buffer);
    } else {
        final UserCase u = (UserCase) rsvp.getErrorType();
        serializerUserError(u.getUserError(), body);
        TlvUtil.formatTlv(TYPE, body, buffer);
    }
}
Also used : RsvpCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCase) UserCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCase) ByteBuf(io.netty.buffer.ByteBuf) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)

Example 4 with RsvpCase

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.RsvpCase in project bgpcep by opendaylight.

the class Stateful07RSVPErrorSpecTlvParser method parseRsvp.

private static RsvpCase parseRsvp(final int classType, final ByteBuf buffer) {
    final RsvpErrorBuilder builder = new RsvpErrorBuilder();
    if (classType == RSVP_IPV4_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
    } else if (classType == RSVP_IPV6_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddress(Ipv6Util.addressForByteBuf(buffer)));
    }
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
    final short errorCode = buffer.readUnsignedByte();
    builder.setCode(errorCode);
    final int errorValue = buffer.readUnsignedShort();
    builder.setValue(errorValue);
    return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
}
Also used : RsvpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags) RsvpErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 BitArray (org.opendaylight.protocol.util.BitArray)2 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec)1 RsvpCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCase)1 RsvpCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder)1 UserCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCase)1 RsvpErrorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder)1 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)1 RsvpCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCase)1 RsvpCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder)1 UserCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCase)1 RsvpErrorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder)1