Search in sources :

Example 1 with Overload

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

the class PCEPOverloadObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Overload, "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
    final Overload overload = (Overload) object;
    final ByteBuf body = Unpooled.buffer(BODY_SIZE);
    body.writeZero(RESERVED + FLAGS);
    ByteBufWriteUtil.writeUnsignedShort(overload.getDuration(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Overload(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.Overload) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with Overload

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

the class PCEPObjectParserTest method testOverloadObject.

@Test
public void testOverloadObject() throws PCEPDeserializerException {
    final byte[] overloadBytes = { /* object header */
    0x1B, 0x10, 0x00, 0x08, /* overload duration */
    0x00, 0x00, 0x00, 0x78 };
    final PCEPOverloadObjectParser parser = new PCEPOverloadObjectParser();
    final Overload overload = new OverloadBuilder().setDuration(120).build();
    final ByteBuf result = Unpooled.wrappedBuffer(overloadBytes);
    assertEquals(overload, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer(overloadBytes.length);
    parser.serializeObject(overload, buf);
    assertArrayEquals(overloadBytes, buf.array());
}
Also used : OverloadBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.OverloadBuilder) Overload(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.Overload) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) PCEPOverloadObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPOverloadObjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with Overload

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

the class NodeAttributesParser method parseNodeFlags.

private static void parseNodeFlags(final ByteBuf value, final NodeAttributesBuilder builder) {
    final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
    builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
    LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.", flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
}
Also used : NodeFlagBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.NodeFlagBits) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Overload (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.Overload)2 Test (org.junit.Test)1 PCEPOverloadObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPOverloadObjectParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 BitArray (org.opendaylight.protocol.util.BitArray)1 NodeFlagBits (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.NodeFlagBits)1 OverloadBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.OverloadBuilder)1