use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie in project openflowplugin by opendaylight.
the class PacketReceivedTranslator method translate.
@Override
public PacketReceived translate(final PacketInMessage input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
PacketReceivedBuilder packetReceivedBuilder = new PacketReceivedBuilder();
BigInteger datapathId = deviceInfo.getDatapathId();
// TODO: connection cookie from connection distinguisher
packetReceivedBuilder.setPayload(input.getData());
// get the Cookie if it exists
if (input.getCookie() != null) {
packetReceivedBuilder.setFlowCookie(new FlowCookie(input.getCookie()));
}
// Try to create the NodeConnectorRef
BigInteger dataPathId = deviceInfo.getDatapathId();
NodeConnectorRef nodeConnectorRef = NodeConnectorRefToPortTranslator.toNodeConnectorRef(input, dataPathId);
// If we was able to create NodeConnectorRef, use it
if (nodeConnectorRef != null) {
packetReceivedBuilder.setIngress(nodeConnectorRef);
}
packetReceivedBuilder.setPacketInReason(PacketInUtil.getMdSalPacketInReason(input.getReason()));
if (input.getTableId() != null) {
packetReceivedBuilder.setTableId(new TableId(input.getTableId().getValue().shortValue()));
}
if (input.getMatch() != null) {
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match packetInMatch = getPacketInMatch(input, datapathId);
packetReceivedBuilder.setMatch(packetInMatch);
}
return packetReceivedBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie in project openflowplugin by opendaylight.
the class MultipartReplyFlowStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyFlowStatsBuilder builder = new MultipartReplyFlowStatsBuilder();
final List<FlowAndStatisticsMapList> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final FlowAndStatisticsMapListBuilder itemBuilder = new FlowAndStatisticsMapListBuilder();
final int itemLength = message.readUnsignedShort();
final ByteBuf itemMessage = message.readSlice(itemLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
itemBuilder.setTableId(itemMessage.readUnsignedByte());
itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
itemBuilder.setDuration(new DurationBuilder().setSecond(new Counter32(itemMessage.readUnsignedInt())).setNanosecond(new Counter32(itemMessage.readUnsignedInt())).build()).setPriority(itemMessage.readUnsignedShort()).setIdleTimeout(itemMessage.readUnsignedShort()).setHardTimeout(itemMessage.readUnsignedShort()).setFlags(createFlowModFlagsFromBitmap(itemMessage.readUnsignedShort()));
itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
final byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(cookie);
final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(packetCount);
final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(byteCount);
itemBuilder.setCookie(new FlowCookie(new BigInteger(1, cookie))).setCookieMask(new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount)));
final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
itemBuilder.setMatch(MatchUtil.transformMatch(matchDeserializer.deserialize(itemMessage), org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match.class));
final int length = itemMessage.readableBytes();
if (length > 0) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructions = new ArrayList<>();
final int startIndex = itemMessage.readerIndex();
int offset = 0;
while (itemMessage.readerIndex() - startIndex < length) {
instructions.add(new InstructionBuilder().setKey(new InstructionKey(offset)).setOrder(offset).setInstruction(InstructionUtil.readInstruction(EncodeConstants.OF13_VERSION_ID, itemMessage, registry)).build());
offset++;
}
itemBuilder.setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
}
items.add(itemBuilder.build());
}
return builder.setFlowAndStatisticsMapList(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie in project openflowplugin by opendaylight.
the class OFPluginFlowTest method createTestFlow.
static FlowBuilder createTestFlow() {
short tableId = 0;
FlowBuilder flow = new FlowBuilder();
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
FlowId flowId = new FlowId("127");
FlowKey key = new FlowKey(flowId);
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
BigInteger value = BigInteger.TEN;
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(flowId);
flow.setTableId(tableId);
flow.setKey(key);
flow.setFlowName("Foo" + "X" + "f1");
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie in project openflowplugin by opendaylight.
the class TestFlowHelper method createFlowAndStatisticsMapListBuilder.
/**
* Creates flow and statistics builder.
* @param index data seed
* @return flow stats builder with dummy content
*/
protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) {
FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
flowAndStatisticsMapListBuilder.setPriority(index);
flowAndStatisticsMapListBuilder.setTableId((short) index);
flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + index);
ethernetSourceBuilder.setAddress(macAddress);
ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + index + ":00:00"));
ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
return flowAndStatisticsMapListBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie in project openflowplugin by opendaylight.
the class OpenflowPluginBulkTransactionProvider method createTestFlow.
private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
FlowBuilder flow = new FlowBuilder();
long id = 123;
String flowType = flowTypeArg;
if (flowType == null) {
flowType = "f1";
}
switch(flowType) {
case "f1":
id += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f2":
id += 2;
flow.setMatch(createMatch2().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f3":
id += 3;
flow.setMatch(createMatch3().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f4":
id += 4;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f5":
id += 5;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction().build());
break;
case "f6":
id += 6;
flow.setMatch(createMatch1().build());
flow.setInstructions(createGotoTableInstructions().build());
break;
case "f7":
id += 7;
flow.setMatch(createMatch1().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f8":
id += 8;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f9":
id += 9;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction2().build());
break;
case "f10":
id += 10;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction3().build());
break;
case "f23":
id += 23;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction16().build());
break;
case "f230":
id += 23;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction160().build());
break;
case "f34":
id += 34;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction26().build());
break;
case "f35":
id += 35;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction27().build());
break;
case "f36":
id += 36;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction28().build());
break;
case "f42":
id += 42;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction34().build());
break;
case "f43":
id += 43;
flow.setMatch(createICMPv6Match().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f44":
id += 44;
flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
flow.setInstructions(createDropInstructions().build());
break;
case "f45":
id += 45;
flow.setMatch(createMetadataMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f46":
id += 46;
flow.setMatch(createL3IPv6Match().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f81":
id += 81;
flow.setMatch(createLLDPMatch().build());
flow.setInstructions(createSentToControllerInstructions().build());
break;
case "f82":
id += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f83":
id += 2;
flow.setMatch(createMatch2().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f84":
id += 3;
flow.setMatch(createMatch3().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f85":
id += 4;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f86":
id += 6;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f87":
id += 12;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f88":
id += 13;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f89":
id += 14;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f90":
id += 15;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction9().build());
break;
case "f91":
id += 7;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction9().build());
break;
case "f92":
id += 8;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f93":
id += 9;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f94":
id += 10;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f95":
id += 42;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f96":
id += 43;
flow.setMatch(createICMPv6Match().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f97":
id += 44;
flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f98":
id += 45;
flow.setMatch(createMetadataMatch().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f99":
id += 34;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f100":
id += 35;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f101":
id += 36;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction8().build());
break;
case "f700":
id += 3;
flow.setMatch(createMatch3().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f800":
id += 8;
flow.setMatch(createMatch1000().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f900":
id += 5;
flow.setMatch(createMatch1000().build());
flow.setInstructions(createAppyActionInstruction2().build());
break;
case "f1000":
id += 10;
flow.setMatch(createMatch1000().build());
flow.setInstructions(createAppyActionInstruction3().build());
break;
default:
LOG.warn("flow type not understood: {}", flowType);
}
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
// flow.setBufferId(12L);
BigInteger value = BigInteger.valueOf(10);
BigInteger outputPort = BigInteger.valueOf(4294967295L);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(new FlowId("12"));
flow.setTableId(getTableId(tableId));
flow.setOutGroup(4294967295L);
// set outport to OFPP_NONE (65535) to disable remove restriction for
// flow
flow.setOutPort(outputPort);
FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
flow.setKey(key);
flow.setPriority(2);
flow.setFlowName(originalFlowName + "X" + flowType);
return flow;
}
Aggregations