Search in sources :

Example 6 with RpBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder in project bgpcep by opendaylight.

the class PCEPValidatorTest method testReqMesgWithLSP.

@Test
public void testReqMesgWithLSP() throws IOException, PCEPDeserializerException {
    // Test PcRequest message with an LSP Object as per RFC8231
    new StatefulActivator().start(ctx);
    final Rp rp = new RpBuilder().setProcessingRule(true).setIgnore(false).setReoptimization(false).setBiDirectional(false).setLoose(true).setMakeBeforeBreak(false).setOrder(false).setPathKey(false).setSupplyOf(false).setFragmentation(false).setP2mp(false).setEroCompression(false).setPriority(Uint8.ONE).setRequestId(new RequestId(Uint32.TEN)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().build()).build();
    final Lsp lspReq = new LspBuilder().setIgnore(false).setProcessingRule(false).setAdministrative(false).setDelegate(false).setPlspId(new PlspId(Uint32.ZERO)).setOperational(OperationalStatus.Down).setSync(false).setRemove(false).setTlvs(new TlvsBuilder().build()).build();
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder epBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder().setIgnore(false).setProcessingRule(true).setAddressFamily(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder().setIpv4(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder().setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).setDestinationIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).build()).build());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder rBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder().setRp(rp).setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder().setEndpointsObj(epBuilder.build()).addAugmentation(new P2p1Builder().setLsp(lspReq).build()).build()).build());
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests> reqs = new ArrayList<>();
    reqs.add(rBuilder.build());
    final Pcreq pcReq = new PcreqBuilder().setPcreqMessage(new PcreqMessageBuilder().setRequests(reqs).build()).build();
    final StatefulPCRequestMessageParser parser = new StatefulPCRequestMessageParser(this.ctx.getObjectHandlerRegistry());
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.1.bin"));
    assertEquals(pcReq, parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(pcReq, buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : Collections(java.util.Collections) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId) StatefulPCRequestMessageParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCRequestMessageParser) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) P2p1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.P2p1Builder) SegmentComputationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputationBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) PcreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcreqBuilder) P2pBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder) Pcreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq) Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject) Test(org.junit.Test)

Example 7 with RpBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder 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));
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder) Test(org.junit.Test)

Aggregations

RpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder)7 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId)6 ByteBuf (io.netty.buffer.ByteBuf)5 Collections (java.util.Collections)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject)4 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator)2 PCEPRequestParameterObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser)2 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)2 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder)2 Srp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp)2 PcreqBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcreqBuilder)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion)2 P2mpIpv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder)2 Ipv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder)2 P2mpIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder)2 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder)2 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder)2