Search in sources :

Example 11 with PCEPDeserializerException

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

the class XROSRLGSubobjectParser 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 SubobjectBuilder builder = new SubobjectBuilder();
    builder.setMandatory(mandatory);
    builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer.readUnsignedInt())).build()).build());
    buffer.readByte();
    builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
Also used : SrlgCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCaseBuilder) 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) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId) SrlgBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder)

Example 12 with PCEPDeserializerException

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

the class PCEPByteToMessageDecoder method parse.

private Message parse(final ByteBuf buffer, final List<Message> errors) throws PCEPDeserializerException {
    buffer.skipBytes(1);
    final int type = buffer.readUnsignedByte();
    final int msgLength = buffer.readUnsignedShort();
    final int actualLength = buffer.readableBytes();
    final ByteBuf msgBody = buffer.slice();
    if (actualLength != msgLength - PCEPMessageConstants.COMMON_HEADER_LENGTH) {
        throw new PCEPDeserializerException("Body size " + actualLength + " does not match header size " + (msgLength - PCEPMessageConstants.COMMON_HEADER_LENGTH));
    }
    buffer.skipBytes(actualLength);
    return this.registry.parseMessage(type, msgBody, errors);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 13 with PCEPDeserializerException

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

the class PCEPCloseMessageParser method validate.

@Override
protected Close validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    if (objects.isEmpty() || !(objects.get(0) instanceof CClose)) {
        throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
    }
    final Object o = objects.get(0);
    final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
    objects.remove(0);
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new CloseBuilder().setCCloseMessage(msg).build();
}
Also used : CloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder) CClose(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose) CCloseMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder) CCloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessage) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 14 with PCEPDeserializerException

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

the class PCEPNotificationMessageParser method validate.

@Override
protected 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("Notification message cannot be empty.");
    }
    final List<Notifications> compositeNotifications = new ArrayList<>();
    while (!objects.isEmpty()) {
        final Notifications comObj = getValidNotificationComposite(objects, errors);
        if (comObj == null) {
            break;
        }
        compositeNotifications.add(comObj);
    }
    if (compositeNotifications.isEmpty()) {
        throw new PCEPDeserializerException("Atleast one Notifications is mandatory.");
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcntfBuilder().setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
}
Also used : PcntfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder) ArrayList(java.util.ArrayList) PcntfMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder) Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 15 with PCEPDeserializerException

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

the class PCEPReplyMessageParser method validate.

@Override
protected Pcrep 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("Pcrep message cannot be empty.");
    }
    final List<Replies> replies = new ArrayList<>();
    while (!objects.isEmpty()) {
        final Replies r = this.getValidReply(objects, errors);
        if (r != null) {
            replies.add(r);
        }
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().setReplies(replies).build()).build();
}
Also used : PcrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.PcrepMessageBuilder) ArrayList(java.util.ArrayList) PcrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder) Replies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.Replies) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

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