Search in sources :

Example 1 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class EROLabelSubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (buffer.readableBytes() < HEADER_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + HEADER_LENGTH + ".");
    }
    final BitArray reserved = BitArray.valueOf(buffer, FLAGS_SIZE);
    final short cType = buffer.readUnsignedByte();
    final LabelType labelType = this.registry.parseLabel(cType, buffer.slice());
    if (labelType == null) {
        throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + cType);
    }
    final LabelBuilder builder = new LabelBuilder();
    builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
    builder.setLabelType(labelType);
    return new SubobjectBuilder().setLoose(loose).setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
Also used : LabelType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType) LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.LabelBuilder) BitArray(org.opendaylight.protocol.util.BitArray) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)

Example 2 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class RROIpv6PrefixSubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectBuilder builder = new SubobjectBuilder();
    if (buffer.readableBytes() != CONTENT_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv6Util.IPV6_LENGTH), length)));
    buffer.skipBytes(PREFIX_F_LENGTH);
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
    builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    return builder.build();
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder) BitArray(org.opendaylight.protocol.util.BitArray) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 3 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class RROLabelSubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (buffer.readableBytes() < HEADER_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + HEADER_LENGTH + ".");
    }
    final BitArray reserved = BitArray.valueOf(buffer, FLAGS_SIZE);
    final short cType = buffer.readUnsignedByte();
    final LabelType labelType = this.registry.parseLabel(cType, buffer.slice());
    if (labelType == null) {
        throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + cType);
    }
    final LabelBuilder builder = new LabelBuilder();
    builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
    builder.setGlobal(reserved.get(G_FLAG_OFFSET));
    builder.setLabelType(labelType);
    return new SubobjectBuilder().setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
Also used : LabelType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType) LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.label._case.LabelBuilder) BitArray(org.opendaylight.protocol.util.BitArray) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCaseBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)

Example 4 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class RROPathKey128SubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (buffer.readableBytes() != CONTENT128_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + CONTENT128_LENGTH + ".");
    }
    final int pathKey = buffer.readUnsignedShort();
    final byte[] pceId = ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
    final SubobjectBuilder builder = new SubobjectBuilder();
    final PathKeyBuilder pBuilder = new PathKeyBuilder();
    pBuilder.setPceId(new PceId(pceId));
    pBuilder.setPathKey(new PathKey(pathKey));
    builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
    return builder.build();
}
Also used : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) PathKeyCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)

Example 5 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class RROPathKey32SubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't 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 int pathKey = buffer.readUnsignedShort();
    final byte[] pceId = ByteArray.readBytes(buffer, PCE_ID_F_LENGTH);
    final SubobjectBuilder builder = new SubobjectBuilder();
    final PathKeyBuilder pBuilder = new PathKeyBuilder();
    pBuilder.setPceId(new PceId(pceId));
    pBuilder.setPathKey(new PathKey(pathKey));
    builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
    return builder.build();
}
Also used : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) PathKeyCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)

Aggregations

PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)46 ArrayList (java.util.ArrayList)8 BitArray (org.opendaylight.protocol.util.BitArray)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)6 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder)6 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)5 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)4 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)4 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)4 Preconditions (com.google.common.base.Preconditions)3 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder)3 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)3 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)3 ByteBuf (io.netty.buffer.ByteBuf)2 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 PcerrBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder)2 Ipv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder)2