use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testRpObjectWithPstTlvParser.
@Test
public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef, /* pst-tlv */
0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
final RpBuilder builder = new RpBuilder().setProcessingRule(false).setIgnore(false).setReoptimization(true).setBiDirectional(false).setLoose(true).setMakeBeforeBreak(true).setOrder(false).setPathKey(false).setSupplyOf(false).setFragmentation(false).setP2mp(false).setEroCompression(false).setPriority(Uint8.valueOf(5)).setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL))).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst(Uint8.ZERO).build()).build());
final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOverloadedDurationTlv.
@Test
public void testOverloadedDurationTlv() throws PCEPDeserializerException {
final OverloadedDurationTlvParser parser = new OverloadedDurationTlvParser();
final OverloadDuration tlv = new OverloadDurationBuilder().setDuration(Uint32.valueOf(0x7FFFFFFFL)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(OVERLOADED_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(OVERLOADED_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOrderTlv.
@Test
public void testOrderTlv() throws PCEPDeserializerException {
final OrderTlvParser parser = new OrderTlvParser();
final Order tlv = new OrderBuilder().setDelete(Uint32.valueOf(0xFFFFFFFFL)).setSetup(Uint32.valueOf(0x00000001L)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(ORDER_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(ORDER_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testReqMissingTlv.
@Test
public void testReqMissingTlv() throws PCEPDeserializerException {
final ReqMissingTlvParser parser = new ReqMissingTlvParser();
final ReqMissing tlv = new ReqMissingBuilder().setRequestId(new RequestId(Uint32.valueOf(0xF7823517L))).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(REQ_MISSING_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(REQ_MISSING_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class Ipv6BgpPrefixSidParser method serializeBgpPrefixSidTlv.
@Override
public void serializeBgpPrefixSidTlv(final BgpPrefixSidTlv tlv, final ByteBuf bytes) {
Preconditions.checkArgument(tlv instanceof Ipv6SidTlv, "Incoming TLV is not Ipv6SidTlv");
final Ipv6SidTlv ipv6Tlv = (Ipv6SidTlv) tlv;
bytes.writeZero(RESERVED);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(PROCESS_IPV6_HEADER_FLAG, ipv6Tlv.getProcessIpv6HeadAbility());
flags.toByteBuf(bytes);
}
Aggregations