Search in sources :

Example 61 with SubobjectContainer

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

the class XROSubobjectListParser method parseList.

public List<SubobjectContainer> parseList(final ByteBuf byteBuf) throws RSVPParsingException {
    final List<SubobjectContainer> subs = new ArrayList<>();
    while (byteBuf.isReadable()) {
        final boolean mandatory = (byteBuf.getUnsignedByte(byteBuf.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0;
        final int type = UnsignedBytes.checkedCast((byteBuf.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET));
        final int length = byteBuf.readUnsignedByte() - HEADER_LENGHT;
        if (length > byteBuf.readableBytes()) {
            throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + byteBuf.readableBytes());
        }
        LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(byteBuf));
        final SubobjectContainer sub = this.subobjReg.parseSubobject(type, byteBuf.readSlice(length), mandatory);
        if (sub == null) {
            LOG.warn("Parsing failed for 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.exclude.route.object.exclude.route.object.SubobjectContainer) ArrayList(java.util.ArrayList) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Example 62 with SubobjectContainer

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

the class SimpleEROSubobjectRegistryTest method testSerializerRegistration.

@Test
public void testSerializerRegistration() {
    assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
    final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
    assertEquals(1, output.readableBytes());
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.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.explicit.route.subobjects.list.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)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)34 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)23 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)11 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)9 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 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)7 BitArray (org.opendaylight.protocol.util.BitArray)7 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer)7 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)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 Preconditions (com.google.common.base.Preconditions)4 Attribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute)4 SubobjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType)4 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)4 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)3