Search in sources :

Example 6 with ClassType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType 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)

Example 7 with ClassType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType in project bgpcep by opendaylight.

the class PCEPClassTypeObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof ClassType, "Wrong instance of PCEPObject. Passed %s. Needed ClassTypeObject.", object.getClass());
    final ByteBuf body = Unpooled.buffer(SIZE);
    body.writeZero(SIZE - 1);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType classType = ((ClassType) object).getClassType();
    Preconditions.checkArgument(classType != null, "ClassType is mandatory.");
    writeUnsignedByte(classType.getValue(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Preconditions(com.google.common.base.Preconditions) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

Preconditions (com.google.common.base.Preconditions)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 ClassType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)2 ClassType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType)2 ClassTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassTypeBuilder)2 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)1 PCEPClassTypeObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)1 BitArray (org.opendaylight.protocol.util.BitArray)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)1 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)1 PcepCreateP2pTunnelInput1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcepCreateP2pTunnelInput1Builder)1 PcepUpdateTunnelInput1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcepUpdateTunnelInput1Builder)1 RsvpErrorSpecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpecBuilder)1 ErrorType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.ErrorType)1