use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.Overload in project bgpcep by opendaylight.
the class PCEPOverloadObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
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);
ByteBufUtils.writeOrZero(body, overload.getDuration());
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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(Uint16.valueOf(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());
}
Aggregations