Search in sources :

Example 6 with PCEPDeserializerException

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

the class RROUnnumberedInterfaceSubobjectParser 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 SubobjectBuilder builder = new SubobjectBuilder();
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
    builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
    final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
    buffer.skipBytes(RESERVED);
    ubuilder.setRouterId(buffer.readUnsignedInt());
    ubuilder.setInterfaceId(buffer.readUnsignedInt());
    builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
    return builder.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.rev131005.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 7 with PCEPDeserializerException

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

the class Stateful07PCReportMessageParser method validate.

@Override
public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    if (objects.isEmpty()) {
        throw new PCEPDeserializerException("Pcrpt message cannot be empty.");
    }
    final List<Reports> reports = Lists.newArrayList();
    while (!objects.isEmpty()) {
        final Reports report = getValidReports(objects, errors);
        if (report != null) {
            reports.add(report);
        }
    }
    return new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
}
Also used : PcrptBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports) PcrptMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 8 with PCEPDeserializerException

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

the class Stateful07StatefulCapabilityTlvParser method parseTlv.

@Override
public Stateful parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    if (buffer.readableBytes() < FLAGS_F_LENGTH / Byte.SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >= " + FLAGS_F_LENGTH / Byte.SIZE + ".");
    }
    final StatefulBuilder sb = new StatefulBuilder();
    parseFlags(sb, buffer);
    return sb.build();
}
Also used : StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 9 with PCEPDeserializerException

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

the class XROIpv4PrefixSubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectBuilder builder = new SubobjectBuilder();
    builder.setMandatory(mandatory);
    if (buffer.readableBytes() != CONTENT4_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length)));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    buffer.skipBytes(PREFIX_F_LENGTH);
    builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
    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.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 10 with PCEPDeserializerException

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

the class XROPathKey32SubobjectParser method parseSubobject.

@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) 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.setMandatory(mandatory);
    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.explicit.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.explicit.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.exclude.route.object.xro.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