Search in sources :

Example 1 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer in project bgpcep by opendaylight.

the class SimpleXROSubobjectRegistryTest method testSerializerRegistration.

@Test
public void testSerializerRegistration() {
    assertNotNull(this.simpleXROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
    final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.simpleXROSubobjectRegistry.serializeSubobject(container, output);
    assertEquals(1, output.readableBytes());
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer) LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer in project bgpcep by opendaylight.

the class RROSubobjectListParser method parseList.

public List<SubobjectContainer> parseList(final ByteBuf buffer) throws RSVPParsingException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final List<SubobjectContainer> subs = new ArrayList<>();
    while (buffer.isReadable()) {
        final int type = buffer.readUnsignedByte();
        final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
        if (length > buffer.readableBytes()) {
            throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
        }
        LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
        final SubobjectContainer sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length));
        if (sub == null) {
            LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
        } else {
            LOG.debug("Subobject was parsed. {}", sub);
            subs.add(sub);
        }
    }
    return subs;
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer) ArrayList(java.util.ArrayList) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Example 3 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer in project bgpcep by opendaylight.

the class SimpleEROSubobjectRegistryTest method testUnrecognizedType.

@Test
public void testUnrecognizedType() throws RSVPParsingException {
    final int wrongType = 99;
    assertNull(this.simpleEROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
    final ByteBuf output = Unpooled.EMPTY_BUFFER;
    final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
    this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
    assertEquals(0, output.readableBytes());
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) ByteBuf(io.netty.buffer.ByteBuf) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder) Test(org.junit.Test)

Example 4 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer in project bgpcep by opendaylight.

the class TEObjectTest method testSSRODynamicProtectionSubobjectParser.

@Test
public void testSSRODynamicProtectionSubobjectParser() throws RSVPParsingException {
    final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
    final SRRODynamicProtectionSubobjectParser dynamicParser = new SRRODynamicProtectionSubobjectParser();
    final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION.length - 2)));
    final ByteBuf output = Unpooled.buffer();
    dynamicParser.serializeSubobject(sub, output);
    assertArrayEquals(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer) SRRODynamicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRRODynamicProtectionSubobjectParser) SRROBasicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRROBasicProtectionSubobjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer in project bgpcep by opendaylight.

the class TEObjectTest method testSSROBasicProtectionSubobjectParser.

@Test
public void testSSROBasicProtectionSubobjectParser() throws RSVPParsingException {
    final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
    final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION.length - 2)));
    final ByteBuf output = Unpooled.buffer();
    parser.serializeSubobject(sub, output);
    assertArrayEquals(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer) SRROBasicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRROBasicProtectionSubobjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)35 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)21 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)12 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)11 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)9 Test (org.junit.Test)8 BitArray (org.opendaylight.protocol.util.BitArray)8 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder)8 ArrayList (java.util.ArrayList)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)6 ProtectionSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)6 LabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder)5 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer)5 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer)5 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)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 PathKeyCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder)4 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer)4 LabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase)3