Search in sources :

Example 1 with PortReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactoryTest method createPortStatusMask.

private static List<PortStatusMask> createPortStatusMask() {
    final List<PortStatusMask> inMasks = new ArrayList<>();
    PortStatusMaskBuilder maskBuilder;
    // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
    maskBuilder = new PortStatusMaskBuilder();
    List<PortReason> reasons = new ArrayList<>();
    reasons.add(PortReason.OFPPRADD);
    reasons.add(PortReason.OFPPRDELETE);
    reasons.add(PortReason.OFPPRMODIFY);
    inMasks.add(maskBuilder.setMask(reasons).build());
    // OFPCR_ROLE_SLAVE
    maskBuilder = new PortStatusMaskBuilder();
    reasons = new ArrayList<>();
    maskBuilder.setMask(reasons);
    inMasks.add(maskBuilder.build());
    return inMasks;
}
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 2 with PortReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason 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 3 with PortReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason 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 4 with PortReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason 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 5 with PortReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason 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

PortReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason)6 PortStatusMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)6 ArrayList (java.util.ArrayList)4 PortStatusMaskBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder)4 HashMap (java.util.HashMap)2