Search in sources :

Example 11 with ObjectHeader

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

the class PCEPNoPathObjectParser method parseObject.

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

Example 12 with ObjectHeader

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

the class PCEPOpenObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
    final OpenBuilder builder = new OpenBuilder();
    builder.setVersion(new ProtocolVersion((short) versionValue));
    builder.setProcessingRule(header.isProcessingRule());
    builder.setIgnore(header.isIgnore());
    final short keepalive = bytes.readUnsignedByte();
    builder.setKeepalive(keepalive);
    final short deadTimer = bytes.readUnsignedByte();
    if (keepalive == 0) {
        builder.setDeadTimer((short) 0);
    } else {
        builder.setDeadTimer(deadTimer);
    }
    builder.setSessionId(bytes.readUnsignedByte());
    final TlvsBuilder tbuilder = new TlvsBuilder();
    parseTlvs(tbuilder, bytes.slice());
    builder.setTlvs(tbuilder.build());
    final Open obj = builder.build();
    if (versionValue != PCEP_VERSION) {
        // TODO: Should we move this check into the negotiator
        LOG.debug("Unsupported PCEP version {}", versionValue);
        return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
    }
    return obj;
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Example 13 with ObjectHeader

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

the class PCEPOverloadObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final OverloadBuilder builder = new OverloadBuilder();
    buffer.readBytes(RESERVED + FLAGS);
    builder.setDuration(buffer.readUnsignedShort());
    return builder.build();
}
Also used : OverloadBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.OverloadBuilder)

Example 14 with ObjectHeader

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

the class PCEPPccIdReqIPv4ObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final PccIdReqBuilder builder = new PccIdReqBuilder();
    builder.setIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
    return builder.build();
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PccIdReqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReqBuilder)

Example 15 with ObjectHeader

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

the class PCEPBandwidthObjectParser method parseObject.

@Override
public Bandwidth parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (bytes.readableBytes() != BANDWIDTH_F_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + BANDWIDTH_F_LENGTH + ".");
    }
    final BandwidthBuilder builder = new BandwidthBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(ByteArray.getAllBytes(bytes)));
    return builder.build();
}
Also used : Preconditions(com.google.common.base.Preconditions) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder)

Aggregations

PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)11 BitArray (org.opendaylight.protocol.util.BitArray)8 Preconditions (com.google.common.base.Preconditions)5 ByteBuf (io.netty.buffer.ByteBuf)5 ObjectHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder)3 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)2 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)2 Ipv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder)2 Ipv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4Builder)2 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 BandwidthUsageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev171025.bandwidth.usage.object.BandwidthUsageBuilder)1