Search in sources :

Example 6 with VendorInformationObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.

the class AbstractMessageParser method addVendorInformationObjects.

protected static List<VendorInformationObject> addVendorInformationObjects(final List<Object> objects) {
    final List<VendorInformationObject> vendorInfo = new ArrayList<>();
    while (!objects.isEmpty() && objects.get(0) instanceof VendorInformationObject) {
        final VendorInformationObject viObject = (VendorInformationObject) objects.get(0);
        vendorInfo.add(viObject);
        objects.remove(0);
    }
    return vendorInfo;
}
Also used : VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) ArrayList(java.util.ArrayList)

Example 7 with VendorInformationObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testVendorInformationObject.

@Test
public void testVendorInformationObject() throws PCEPDeserializerException {
    final byte[] viObjBytes = { /* vendor-information object */
    0x22, 0x10, 0x00, 0x0C, /* enterprise number */
    0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
    0x00, 0x00, 0x00, 0x05 };
    final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
    final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
    final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
    final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
    result.readerIndex(8);
    final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
    assertEquals(viObj, o);
    final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
    parser.serializeObject(viObj, buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) TestEnterpriseSpecificInformation(org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) VendorInformationObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObjectBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 8 with VendorInformationObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject 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)

Example 9 with VendorInformationObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.

the class AbstractVendorInformationObjectParser method serializeObject.

@Override
public final void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof VendorInformationObject, "Wrong instance of PCEPObject. Passed %s. Needed VendorInformationObject.", object.getClass());
    final ByteBuf body = Unpooled.buffer();
    writeUnsignedInt(getEnterpriseNumber().getValue(), body);
    serializeEnterpriseSpecificInformation(((VendorInformationObject) object).getEnterpriseSpecificInformation(), body);
    ObjectUtil.formatSubobject(VENDOR_INFORMATION_OBJECT_TYPE, VENDOR_INFORMATION_OBJECT_CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)9 ArrayList (java.util.ArrayList)5 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)3 Preconditions (com.google.common.base.Preconditions)2 ByteBuf (io.netty.buffer.ByteBuf)2 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)2 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)2 MetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.MetricsBuilder)2 Rp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)2 Collections (java.util.Collections)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 SimplePCEPExtensionProviderContext (org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)1 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder)1 OfId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId)1