Search in sources :

Example 96 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPNoPathObjectParser method parseObject.

@Override
public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    final Uint8 issue = ByteBufUtils.readUint8(bytes);
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    bytes.skipBytes(RESERVED_F_LENGTH);
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    return new NoPathBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setNatureOfIssue(issue).setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)).setTlvs(tlvsBuilder.build()).build();
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) NoPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 97 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPNoPathObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
    final NoPath nPObj = (NoPath) object;
    final ByteBuf body = Unpooled.buffer();
    ByteBufUtils.writeMandatory(body, nPObj.getNatureOfIssue(), "NatureOfIssue");
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(C_FLAG_OFFSET, nPObj.getUnsatisfiedConstraints());
    flags.toByteBuf(body);
    body.writeZero(RESERVED_F_LENGTH);
    serializeTlvs(nPObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 98 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPOverloadObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    checkArgument(object instanceof Overload, "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
    final Overload overload = (Overload) object;
    final ByteBuf body = Unpooled.buffer(BODY_SIZE);
    body.writeZero(RESERVED + FLAGS);
    ByteBufUtils.writeOrZero(body, overload.getDuration());
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : Overload(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.Overload) ByteBuf(io.netty.buffer.ByteBuf)

Example 99 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.

the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    if (buffer.readableBytes() != CONTENT_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
    }
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    buffer.skipBytes(RESERVED);
    return new SubobjectBuilder().setProtectionAvailable(flags.get(LPA_F_OFFSET)).setProtectionInUse(flags.get(LPIU_F_OFFSET)).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(ByteBufUtils.readUint32(buffer)).setInterfaceId(ByteBufUtils.readUint32(buffer)).build()).build()).build();
}
Also used : UnnumberedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder) BitArray(org.opendaylight.protocol.util.BitArray) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder) UnnumberedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder)

Example 100 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPSvecObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.", object.getClass());
    final Svec svecObj = (Svec) object;
    final ByteBuf body = Unpooled.buffer();
    body.writeZero(FLAGS_F_OFFSET);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(L_FLAG_OFFSET, svecObj.getLinkDiverse());
    flags.set(N_FLAG_OFFSET, svecObj.getNodeDiverse());
    flags.set(S_FLAG_OFFSET, svecObj.getSrlgDiverse());
    flags.set(D_FLAG_OFFSET, svecObj.getLinkDirectionDiverse());
    flags.set(P_FLAG_OFFSET, svecObj.getPartialPathDiverse());
    flags.toByteBuf(body);
    final List<RequestId> requestIDs = svecObj.getRequestsIds();
    // FIXME: remove this assert
    assert !requestIDs.isEmpty() : "Empty Svec Object - no request ids.";
    for (final RequestId requestId : requestIDs) {
        ByteBufUtils.write(body, requestId.getValue());
    }
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)120 Test (org.junit.Test)106 BitArray (org.opendaylight.protocol.util.BitArray)77 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)61 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)40 ArrayList (java.util.ArrayList)29 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)23 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)20 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)12 BigInteger (java.math.BigInteger)11 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)8 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)8 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)8 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)7