use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags in project openflowplugin by opendaylight.
the class FlowUtils method createDirectMacToMacFlow.
/**
* Returns a {@link FlowBuilder} forwarding all packets to controller port.
*/
public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) {
FlowBuilder macToMacFlow = new FlowBuilder().setTableId(tableId).setFlowName("mac2mac");
macToMacFlow.setId(new FlowId(Long.toString(macToMacFlow.hashCode())));
EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build()).setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build()).build();
MatchBuilder match = new MatchBuilder();
match.setEthernetMatch(ethernetMatch);
Uri outputPort = dstPort.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId();
Action outputToControllerAction = new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setMaxLength(Integer.valueOf(0xffff)).setOutputNodeConnector(outputPort).build()).build()).build();
// Create an Apply Action
ApplyActions applyActions = new ApplyActionsBuilder().setAction(ImmutableList.of(outputToControllerAction)).build();
// Wrap our Apply Action in an Instruction
Instruction applyActionsInstruction = new InstructionBuilder().setOrder(0).setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActions).build()).build();
// Put our Instruction in a list of Instructions
macToMacFlow.setMatch(new MatchBuilder().setEthernetMatch(ethernetMatch).build()).setInstructions(new InstructionsBuilder().setInstruction(ImmutableList.of(applyActionsInstruction)).build()).setPriority(priority).setBufferId(OFConstants.OFP_NO_BUFFER).setHardTimeout(0).setIdleTimeout(0).setFlags(new FlowModFlags(false, false, false, false, false));
return macToMacFlow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final FlowAndStatisticsMapList flowStat = new FlowAndStatisticsMapListBuilder().setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setTableId(TABLE_NO).setByteCount(new Counter64(BigInteger.ONE)).setPacketCount(new Counter64(BigInteger.ONE)).setFlags(new FlowModFlags(true, false, false, false, false)).setMatch(new MatchBuilder().build()).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyFlowStatsBuilder().setFlowAndStatisticsMapList(Collections.singletonList(flowStat)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetFlowStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
assertEquals(stats.getTableId(), TABLE_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags in project openflowplugin by opendaylight.
the class FlowCreatorUtil method equalsFlowModFlags.
/**
* Return {@code true} only if given two FLOW_MOD flags are identical.
*
* @param flags1 A value to be compared.
* @param flags2 A value to be compared.
* @return {@code true} only if {@code flags1} and {@code flags2} are identical.
*/
public static boolean equalsFlowModFlags(FlowModFlags flags1, FlowModFlags flags2) {
FlowModFlags f1;
FlowModFlags f2;
if (flags1 == null) {
if (flags2 == null) {
return true;
}
f1 = DEFAULT_FLOW_MOD_FLAGS;
f2 = flags2;
} else {
f1 = flags1;
f2 = (flags2 == null) ? DEFAULT_FLOW_MOD_FLAGS : flags2;
}
return equalsWithDefault(f1.isCHECKOVERLAP(), f2.isCHECKOVERLAP(), Boolean.FALSE) && equalsWithDefault(f1.isNOBYTCOUNTS(), f2.isNOBYTCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isNOPKTCOUNTS(), f2.isNOPKTCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isRESETCOUNTS(), f2.isRESETCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isSENDFLOWREM(), f2.isSENDFLOWREM(), Boolean.FALSE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method test.
@Test
public void test() throws Exception {
ByteBuf bb = BufferHelper.buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 " + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 " + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 " + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), deserializedMessage.getFlags());
Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch());
Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags in project openflowplugin by opendaylight.
the class FlowFlagsInjector method addInjectors.
private static void addInjectors(final Map<ConvertorKey, ResultInjector<?, ?>> injectionMapping) {
// OF-1.3|FlowModFlags --> FlowModInputBuilder
injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, FlowModInputBuilder.class), (ResultInjector<FlowModFlags, FlowModInputBuilder>) (value, target) -> target.setFlags(value));
// OF-1.3|FlowModFlagsV10 --> FlowModInputBuilder
injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_0, FlowModInputBuilder.class), (ResultInjector<FlowModFlagsV10, FlowModInputBuilder>) (value, target) -> target.setFlagsV10(value));
}
Aggregations