Search in sources :

Example 1 with Codes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.

the class NumericOperandParserTest method testSerializeOneByte.

@Test
public void testSerializeOneByte() {
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    final List<Codes> codes = new ArrayList<>();
    // create 3 ports without end-of-list bit set
    for (int i = 0; i < 3; i++) {
        codes.add(new CodesBuilder().setOp(new NumericOperand(false, false, true, false, false)).setValue(Uint8.valueOf(100 + i)).build());
    }
    NumericOneByteOperandParser.INSTANCE.serialize(codes, nlriByteBuf);
    assertArrayEquals(ONE_BYTE_CODE_LIST, ByteArray.readAllBytes(nlriByteBuf));
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand) Codes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) CodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder) Test(org.junit.Test)

Example 2 with Codes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createCodes.

private static List<Codes> createCodes(final UnkeyedListNode codesData) {
    final List<Codes> codes = new ArrayList<>();
    for (final UnkeyedListEntryNode node : codesData.body()) {
        final CodesBuilder codesBuilder = new CodesBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> codesBuilder.setValue((Uint8) dataContainerChild.body()));
        codes.add(codesBuilder.build());
    }
    return codes;
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) Codes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) CodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder)

Example 3 with Codes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.

the class FSIcmpCodeHandler method parseIcmpCode.

private static List<Codes> parseIcmpCode(final ByteBuf nlri) {
    final List<Codes> codes = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final CodesBuilder builder = new CodesBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        builder.setValue(ByteBufUtils.readUint8(nlri));
        end = op.getEndOfList();
        codes.add(builder.build());
    }
    return codes;
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand) Codes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes) ArrayList(java.util.ArrayList) CodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder)

Aggregations

ArrayList (java.util.ArrayList)3 Codes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes)3 CodesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder)3 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 Uint8 (org.opendaylight.yangtools.yang.common.Uint8)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1