Search in sources :

Example 6 with PacketInMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactoryTest method createPacketInMask.

private static List<PacketInMask> createPacketInMask() {
    final List<PacketInMask> masks = new ArrayList<>();
    PacketInMaskBuilder builder;
    // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
    builder = new PacketInMaskBuilder();
    List<PacketInReason> packetInReasonList = new ArrayList<>();
    packetInReasonList.add(PacketInReason.OFPRNOMATCH);
    packetInReasonList.add(PacketInReason.OFPRACTION);
    packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
    builder.setMask(packetInReasonList);
    masks.add(builder.build());
    // OFPCR_ROLE_SLAVE
    builder = new PacketInMaskBuilder();
    packetInReasonList = new ArrayList<>();
    builder.setMask(packetInReasonList);
    masks.add(builder.build());
    return masks;
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason) PacketInMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder) ArrayList(java.util.ArrayList)

Example 7 with PacketInMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask in project openflowplugin by opendaylight.

the class SetAsyncInputMessageFactoryTest method testSetAsyncInputMessage.

/**
 * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testSetAsyncInputMessage() throws Exception {
    SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(createPacketInMask());
    builder.setPortStatusMask(createPortStatusMask());
    builder.setFlowRemovedMask(createFlowRemowedMask());
    SetAsyncInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    setAsyncFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 28, 32);
    Assert.assertEquals("Wrong packetInMask", 7, out.readUnsignedInt());
    Assert.assertEquals("Wrong packetInMask", 0, out.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 7, out.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 15, out.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 0, out.readUnsignedInt());
}
Also used : SetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder) SetAsyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 8 with PacketInMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method serializePacketInMask.

private static void serializePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {
    if (packetInMask != null) {
        for (PacketInMask currentPacketMask : packetInMask) {
            List<PacketInReason> mask = currentPacketMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> packetInReasonMap = new HashMap<>();
                for (PacketInReason packetInReason : mask) {
                    if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);
                    } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);
                    } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));
            }
        }
    }
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) HashMap(java.util.HashMap) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason)

Example 9 with PacketInMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask in project openflowplugin by opendaylight.

the class SetAsyncInputMessageFactory method serializePacketInMask.

private static void serializePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {
    if (packetInMask != null) {
        for (PacketInMask currentPacketMask : packetInMask) {
            List<PacketInReason> mask = currentPacketMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> packetInReasonMap = new HashMap<>();
                for (PacketInReason packetInReason : mask) {
                    if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);
                    } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);
                    } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));
            }
        }
    }
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) HashMap(java.util.HashMap) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason)

Example 10 with PacketInMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method decodePacketInMask.

private static List<PacketInMask> decodePacketInMask(ByteBuf input) {
    List<PacketInMask> inMasks = new ArrayList<>();
    PacketInMaskBuilder maskBuilder;
    for (int i = 0; i < SEPARATE_ROLES; i++) {
        maskBuilder = new PacketInMaskBuilder();
        maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt()));
        inMasks.add(maskBuilder.build());
    }
    return inMasks;
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) PacketInMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder) ArrayList(java.util.ArrayList)

Aggregations

PacketInMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask)8 ArrayList (java.util.ArrayList)6 PacketInReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason)6 PacketInMaskBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 GetAsyncOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput)2 GetAsyncOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder)1 SetAsyncInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput)1 SetAsyncInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder)1