Search in sources :

Example 6 with PortStatusMask

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

the class GetAsyncReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(createPacketInMask());
    builder.setPortStatusMask(createPortStatusMask());
    builder.setFlowRemovedMask(createFlowRemowedMask());
    GetAsyncOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32);
    Assert.assertEquals("Wrong packetInMask", 7, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong packetInMask", 0, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 7, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 0, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 15, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 0, serializedBuffer.readUnsignedInt());
}
Also used : GetAsyncOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 7 with PortStatusMask

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

the class SetAsyncInputMessageFactoryTest method createPortStatusMask.

private static List<PortStatusMask> createPortStatusMask() {
    final List<PortStatusMask> masks = new ArrayList<>();
    PortStatusMaskBuilder builder;
    builder = new PortStatusMaskBuilder();
    // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
    List<PortReason> portReasonList = new ArrayList<>();
    portReasonList.add(PortReason.OFPPRADD);
    portReasonList.add(PortReason.OFPPRDELETE);
    portReasonList.add(PortReason.OFPPRMODIFY);
    builder.setMask(portReasonList);
    masks.add(builder.build());
    // OFPCR_ROLE_SLAVE
    builder = new PortStatusMaskBuilder();
    portReasonList = new ArrayList<>();
    builder.setMask(portReasonList);
    masks.add(builder.build());
    return masks;
}
Also used : PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason) ArrayList(java.util.ArrayList) PortStatusMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder) PortStatusMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)

Example 8 with PortStatusMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask 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 9 with PortStatusMask

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

the class GetAsyncReplyMessageFactory method serializePortStatusMask.

private static void serializePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
    if (portStatusMask != null) {
        for (PortStatusMask currentPortStatusMask : portStatusMask) {
            List<PortReason> mask = currentPortStatusMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();
                for (PortReason packetInReason : mask) {
                    if (PortReason.OFPPRADD.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);
                    } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);
                    } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason) PortStatusMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)

Example 10 with PortStatusMask

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

the class SetAsyncInputMessageFactory method serializePortStatusMask.

private static void serializePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
    if (portStatusMask != null) {
        for (PortStatusMask currentPortStatusMask : portStatusMask) {
            List<PortReason> mask = currentPortStatusMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();
                for (PortReason packetInReason : mask) {
                    if (PortReason.OFPPRADD.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);
                    } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);
                    } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason) PortStatusMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)

Aggregations

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