use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask in project openflowplugin by opendaylight.
the class SetAsyncInputMessageFactoryTest method createFlowRemowedMask.
private static List<FlowRemovedMask> createFlowRemowedMask() {
final List<FlowRemovedMask> masks = new ArrayList<>();
FlowRemovedMaskBuilder builder;
// OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
builder = new FlowRemovedMaskBuilder();
List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
builder.setMask(flowRemovedReasonList);
masks.add(builder.build());
// OFPCR_ROLE_SLAVE
builder = new FlowRemovedMaskBuilder();
flowRemovedReasonList = new ArrayList<>();
builder.setMask(flowRemovedReasonList);
masks.add(builder.build());
return masks;
}
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 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask 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());
}
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 serializeFlowRemovedMask.
private static void serializeFlowRemovedMask(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));
}
}
}
}
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 createFlowRemowedMask.
private static List<FlowRemovedMask> createFlowRemowedMask() {
final List<FlowRemovedMask> masks = new ArrayList<>();
FlowRemovedMaskBuilder builder;
// OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
builder = new FlowRemovedMaskBuilder();
List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
builder.setMask(flowRemovedReasonList);
masks.add(builder.build());
// OFPCR_ROLE_SLAVE
builder = new FlowRemovedMaskBuilder();
flowRemovedReasonList = new ArrayList<>();
builder.setMask(flowRemovedReasonList);
masks.add(builder.build());
return masks;
}
Aggregations