Search in sources :

Example 16 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero in project bgpcep by opendaylight.

the class TunelProgrammingUtil method buildEro.

public static Ero buildEro(final List<ExplicitHops> explicitHops) {
    final EroBuilder b = new EroBuilder();
    if (!explicitHops.isEmpty()) {
        final List<Subobject> subobjs = new ArrayList<>(explicitHops.size());
        for (final ExplicitHops h : explicitHops) {
            final ExplicitHops1 h1 = h.getAugmentation(ExplicitHops1.class);
            if (h1 != null) {
                final SubobjectBuilder sb = new SubobjectBuilder();
                sb.fieldsFrom(h1);
                sb.setLoose(h.isLoose());
                subobjs.add(sb.build());
            } else {
                LOG.debug("Ignoring unhandled explicit hop {}", h);
            }
        }
        b.setSubobject(subobjs);
    }
    return b.build();
}
Also used : ExplicitHops1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.ExplicitHops1) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject) ExplicitHops(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.p2p.rev130819.tunnel.p2p.path.cfg.attributes.ExplicitHops) ArrayList(java.util.ArrayList) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)

Example 17 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero in project bgpcep by opendaylight.

the class RROLabelSubobjectParser method parseSubobject.

@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (buffer.readableBytes() < HEADER_LENGTH) {
        throw new RSVPParsingException("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 RSVPParsingException("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 SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
Also used : SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder) 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) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Example 18 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero in project bgpcep by opendaylight.

the class PCEPValidatorTest method testMissingLspObjectErrorInPcRptMsg.

@Test
public void testMissingLspObjectErrorInPcRptMsg() throws PCEPDeserializerException {
    final byte[] statefulMsg = { (byte) 0x20, (byte) 0x0B, (byte) 0x00, (byte) 0x1C, /* srp-object */
    (byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x001, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, /* sr-ero-object */
    (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x0C, /* ipv4 prefix subobject */
    (byte) 0x81, (byte) 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x00 };
    try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
        StatefulActivator b = new StatefulActivator()) {
        a.start(this.ctx);
        b.start(this.ctx);
        final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
        final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
        errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType((short) 6).setValue((short) 8).build()).build()));
        final PcerrBuilder builder = new PcerrBuilder();
        builder.setPcerrMessage(errMsgBuilder.build());
        final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
        final List<Message> errors = Lists.newArrayList();
        parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
        assertFalse(errors.isEmpty());
        assertEquals(builder.build(), errors.get(0));
    }
}
Also used : StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) Stateful07PCReportMessageParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser) PcerrBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder) ByteBuf(io.netty.buffer.ByteBuf) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator) PcerrMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder) Test(org.junit.Test)

Example 19 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero in project bgpcep by opendaylight.

the class Stateful07PCUpdateRequestMessageParser method validatePath.

private static boolean validatePath(final List<Object> objects, final List<Message> errors, final UpdatesBuilder builder) {
    final PathBuilder pBuilder = new PathBuilder();
    Object object = objects.remove(0);
    if (object instanceof Ero) {
        pBuilder.setEro((Ero) object);
    } else {
        errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.absent()));
        return false;
    }
    parsePath(objects, pBuilder);
    builder.setPath(pBuilder.build());
    return true;
}
Also used : PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)

Example 20 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method handleEro.

private Result handleEro(final Ero ero, final List<Object> objects) {
    objects.remove(0);
    final SuccessBuilder builder = new SuccessBuilder();
    final List<Paths> paths = new ArrayList<>();
    final PathsBuilder pBuilder = new PathsBuilder();
    pBuilder.setEro(ero);
    while (!objects.isEmpty() && !(objects.get(0) instanceof PceId)) {
        final List<VendorInformationObject> vendorInfoObjects = addVendorInformationObjects(objects);
        if (!vendorInfoObjects.isEmpty()) {
            builder.setVendorInformationObject(vendorInfoObjects);
        }
        this.parsePath(pBuilder, objects);
        paths.add(pBuilder.build());
    }
    builder.setPaths(paths);
    return new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
Also used : SuccessBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder) SuccessCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder) ArrayList(java.util.ArrayList) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) Paths(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths) PathsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder)

Aggregations

ArrayList (java.util.ArrayList)8 ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)7 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero)7 EroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder)7 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)5 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)5 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)5 BitArray (org.opendaylight.protocol.util.BitArray)4 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject)4 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)3 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)3 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)3 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder)3 LabelType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType)3 CrabbeInitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator)2 SrRange (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrRange)2 SrRangeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrRangeBuilder)2