Search in sources :

Example 1 with StatefulPCUpdateRequestMessageParser

use of org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser in project bgpcep by opendaylight.

the class PCEPValidatorTest method testUnexpectedRroObjectInPcUpdMsg.

@Test
public void testUnexpectedRroObjectInPcUpdMsg() throws PCEPDeserializerException {
    final byte[] badUpdateMsg = { (byte) 0x20, (byte) 0x0b, (byte) 0x00, (byte) 0x50, /* SRP, LSP and ERO objects */
    (byte) 0x21, (byte) 0x12, (byte) 0x00, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x20, (byte) 0x10, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x09, (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x08, (byte) 0x05, (byte) 0x05, (byte) 0x05, (byte) 0x03, (byte) 0x18, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x04, (byte) 0x18, (byte) 0x00, /* RRO object */
    (byte) 0x08, (byte) 0x10, (byte) 0x00, (byte) 0x24, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x00, (byte) 0x83, (byte) 0x20, (byte) 0x20, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x09, (byte) 0xde, (byte) 0x20, (byte) 0x00, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    new InitiatedActivator().start(ctx);
    final StatefulPCUpdateRequestMessageParser parser = new StatefulPCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
    final ByteBuf buf = Unpooled.wrappedBuffer(badUpdateMsg);
    final List<Message> errors = new ArrayList<>();
    parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
    assertFalse(errors.isEmpty());
    assertEquals(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder().setErrors(List.of(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType(Uint8.valueOf(6)).setValue(Uint8.valueOf(10)).build()).build())).build()).build(), errors.get(0));
}
Also used : StatefulPCUpdateRequestMessageParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser) PcerrBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder) InitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) ArrayList(java.util.ArrayList) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder) ByteBuf(io.netty.buffer.ByteBuf) PcerrMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessageBuilder) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder) Test(org.junit.Test)

Example 2 with StatefulPCUpdateRequestMessageParser

use of org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser in project bgpcep by opendaylight.

the class PCEPValidatorTest method testUpdMsg.

@Test
public void testUpdMsg() throws IOException, PCEPDeserializerException {
    new InitiatedActivator().start(ctx);
    final StatefulPCUpdateRequestMessageParser parser = new StatefulPCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
    final PathBuilder pBuilder = new PathBuilder().setEro(this.ero).setLspa(this.lspa);
    final PcupdMessageBuilder builder = new PcupdMessageBuilder().setUpdates(List.of(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build()));
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin"));
    assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
    ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
    builder.setUpdates(List.of(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build(), new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(new PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build()));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.5.bin"));
    assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
    buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : StatefulPCUpdateRequestMessageParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) InitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator) PcupdMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.PcupdMessageBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder) ByteBuf(io.netty.buffer.ByteBuf) PcupdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcupdBuilder) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 InitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator)2 StatefulPCUpdateRequestMessageParser (org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser)2 ArrayList (java.util.ArrayList)1 PcupdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcupdBuilder)1 PcupdMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.PcupdMessageBuilder)1 UpdatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder)1 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder)1 PcerrBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder)1 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message)1 ErrorObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder)1 PcerrMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessageBuilder)1 ErrorsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder)1