Search in sources :

Example 61 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class AdminStatusObjectParser method localSerializeObject.

@Override
protected void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
    Preconditions.checkArgument(teLspObject instanceof AdminStatusObject, "AssociationObject is mandatory.");
    final AdminStatusObject addObject = (AdminStatusObject) teLspObject;
    serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
    final BitArray reflect = new BitArray(FLAGS_SIZE);
    reflect.set(REFLECT, addObject.isReflect());
    reflect.toByteBuf(output);
    output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(TESTING, addObject.isTesting());
    flags.set(DOWN, addObject.isAdministrativelyDown());
    flags.set(DELETION, addObject.isDeletionInProgress());
    flags.toByteBuf(output);
}
Also used : AdminStatusObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject) BitArray(org.opendaylight.protocol.util.BitArray)

Example 62 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class TrafficActionEcHandler method parseExtendedCommunity.

@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
    buffer.skipBytes(RESERVED);
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    final boolean sample = flags.get(SAMPLE_BIT);
    final boolean terminal = flags.get(TERMINAL_BIT);
    return new TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(new TrafficActionExtendedCommunityBuilder().setSample(sample).setTerminalAction(terminal).build()).build();
}
Also used : TrafficActionExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.action.extended.community.TrafficActionExtendedCommunityBuilder) TrafficActionExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 63 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class Ipv6BgpPrefixSidParser method serializeBgpPrefixSidTlv.

@Override
public void serializeBgpPrefixSidTlv(final BgpPrefixSidTlv tlv, final ByteBuf bytes) {
    Preconditions.checkArgument(tlv instanceof Ipv6SidTlv, "Incoming TLV is not Ipv6SidTlv");
    final Ipv6SidTlv ipv6Tlv = (Ipv6SidTlv) tlv;
    bytes.writeZero(RESERVED);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(PROCESS_IPV6_HEADER_FLAG, ipv6Tlv.isProcessIpv6HeadAbility());
    flags.toByteBuf(bytes);
}
Also used : Ipv6SidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.Ipv6SidTlv) BitArray(org.opendaylight.protocol.util.BitArray)

Example 64 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class AbstractNumericOperandParser method serialize.

@Override
public final void serialize(final NumericOperand operand, final int length, final boolean endOfList, final ByteBuf buffer) {
    final BitArray operandValues = new BitArray(OPERAND_LENGTH);
    operandValues.set(END_OF_LIST, endOfList);
    operandValues.set(AND_BIT, operand.isAndBit());
    operandValues.set(LESS_THAN, operand.isLessThan());
    operandValues.set(GREATER_THAN, operand.isGreaterThan());
    operandValues.set(EQUAL, operand.isEquals());
    final byte byteLength = (byte) (Integer.numberOfTrailingZeros(length) << LENGTH_SHIFT);
    buffer.writeByte(operandValues.toByte() | byteLength);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 65 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class SyncOptimizationsCapabilityTlvParser method parseFlags.

@Override
protected void parseFlags(final StatefulBuilder sb, final ByteBuf buffer) {
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_F_LENGTH);
    sb.setLspUpdateCapability(flags.get(U_FLAG_OFFSET));
    if (flags.get(I_FLAG_OFFSET)) {
        sb.addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(Boolean.TRUE).build());
    }
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder syncOptBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder();
    if (flags.get(S_FLAG_OFFSET)) {
        syncOptBuilder.setIncludeDbVersion(Boolean.TRUE);
    }
    if (flags.get(T_FLAG_OFFSET)) {
        syncOptBuilder.setTriggeredResync(Boolean.TRUE);
    }
    if (flags.get(D_FLAG_OFFSET)) {
        syncOptBuilder.setDeltaLspSyncCapability(Boolean.TRUE);
    }
    if (flags.get(F_FLAG_OFFSET)) {
        syncOptBuilder.setTriggeredInitialSync(Boolean.TRUE);
    }
    sb.addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1.class, syncOptBuilder.build());
}
Also used : Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1Builder) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)100 ByteBuf (io.netty.buffer.ByteBuf)27 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)4 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCase)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)3 LabelType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType)3 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)3 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder)3 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)3 ArrayList (java.util.ArrayList)2 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)2 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)2 Nai (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai)2 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)2 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags)2