Search in sources :

Example 1 with FlowRemovedMask

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

the class SetAsyncInputMessageFactory method serializerFlowRemovedMask.

private static void serializerFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {
    if (flowRemovedMask != null) {
        for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {
            List<FlowRemovedReason> mask = currentFlowRemovedMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> flowRemovedReasonMap = new HashMap<>();
                for (FlowRemovedReason packetInReason : mask) {
                    if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap));
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) FlowRemovedMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask) FlowRemovedReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason)

Example 2 with FlowRemovedMask

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

the class SetAsyncInputMessageFactory method decodeFlowRemovedMask.

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

Example 3 with FlowRemovedMask

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

the class GetAsyncReplyMessageFactory method decodeFlowRemovedMask.

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

Example 4 with FlowRemovedMask

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

the class GetAsyncReplyMessageFactoryTest method testGetAsyncReplyMessage.

/**
 * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testGetAsyncReplyMessage() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 " + "00 00 00 00 " + "00 00 00 07 " + "00 00 00 00 " + "00 00 00 0F " + "00 00 00 00");
    GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong packetInMask", createPacketInMask(), builtByFactory.getPacketInMask());
    Assert.assertEquals("Wrong portStatusMask", createPortStatusMask(), builtByFactory.getPortStatusMask());
    Assert.assertEquals("Wrong flowRemovedMask", createFlowRemovedMask(), builtByFactory.getFlowRemovedMask());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput) Test(org.junit.Test)

Example 5 with FlowRemovedMask

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

the class GetAsyncReplyMessageFactoryTest method createFlowRemovedMask.

private static List<FlowRemovedMask> createFlowRemovedMask() {
    final List<FlowRemovedMask> inMasks = new ArrayList<>();
    FlowRemovedMaskBuilder maskBuilder;
    // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
    maskBuilder = new FlowRemovedMaskBuilder();
    List<FlowRemovedReason> reasons = new ArrayList<>();
    reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
    reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
    reasons.add(FlowRemovedReason.OFPRRDELETE);
    reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
    maskBuilder.setMask(reasons);
    inMasks.add(maskBuilder.build());
    // OFPCR_ROLE_SLAVE
    maskBuilder = new FlowRemovedMaskBuilder();
    reasons = new ArrayList<>();
    maskBuilder.setMask(reasons);
    inMasks.add(maskBuilder.build());
    return inMasks;
}
Also used : FlowRemovedMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder) ArrayList(java.util.ArrayList) FlowRemovedMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask) FlowRemovedReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason)

Aggregations

FlowRemovedMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask)8 ArrayList (java.util.ArrayList)6 FlowRemovedReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason)6 FlowRemovedMaskBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder)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