use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.
the class InstructionJsonMatcher method matchSetQueueInstruction.
/**
* Matches the contents of a set queue instruction.
*
* @param instructionJson JSON instruction to match
* @param description Description object used for recording errors
* @return true if contents match, false otherwise
*/
private boolean matchSetQueueInstruction(JsonNode instructionJson, Description description) {
final String jsonType = instructionJson.get("type").textValue();
SetQueueInstruction instructionToMatch = (SetQueueInstruction) instruction;
if (!instructionToMatch.type().name().equals(jsonType)) {
description.appendText("type was " + jsonType);
return false;
}
final long jsonQueueId = instructionJson.get("queueId").longValue();
if (instructionToMatch.queueId() != jsonQueueId) {
description.appendText("queueId was " + jsonQueueId);
return false;
}
if (instructionJson.get("port").isLong() || instructionJson.get("port").isInt()) {
final long jsonPort = instructionJson.get("port").asLong();
if (instructionToMatch.port().toLong() != (jsonPort)) {
description.appendText("port was " + jsonPort);
return false;
}
} else if (instructionJson.get("port").isTextual()) {
final String jsonPort = instructionJson.get("port").textValue();
if (!instructionToMatch.port().toString().equals(jsonPort)) {
description.appendText("port was " + jsonPort);
return false;
}
} else {
final String jsonPort = instructionJson.get("port").toString();
description.appendText("Unmatching types ");
description.appendText("instructionToMatch " + instructionToMatch.port().toString());
description.appendText("jsonPort " + jsonPort);
}
return true;
}
use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.
the class InstructionJsonMatcher method matchesSafely.
@Override
public boolean matchesSafely(JsonNode jsonInstruction, Description description) {
// check type
final JsonNode jsonTypeNode = jsonInstruction.get("type");
final String jsonType = jsonTypeNode.textValue();
final String type = instruction.type().name();
if (!jsonType.equals(type)) {
description.appendText("type was " + type);
return false;
}
if (instruction instanceof ModMplsHeaderInstruction) {
return matchModMplsHeaderInstruction(jsonInstruction, description);
} else if (instruction instanceof OutputInstruction) {
return matchOutputInstruction(jsonInstruction, description);
} else if (instruction instanceof GroupInstruction) {
return matchGroupInstruction(jsonInstruction, description);
} else if (instruction instanceof MeterInstruction) {
return matchMeterInstruction(jsonInstruction, description);
} else if (instruction instanceof SetQueueInstruction) {
return matchSetQueueInstruction(jsonInstruction, description);
} else if (instruction instanceof ModOchSignalInstruction) {
return matchModOchSingalInstruction(jsonInstruction, description);
} else if (instruction instanceof ModEtherInstruction) {
return matchModEtherInstruction(jsonInstruction, description);
} else if (instruction instanceof ModVlanIdInstruction) {
return matchModVlanIdInstruction(jsonInstruction, description);
} else if (instruction instanceof ModVlanPcpInstruction) {
return matchModVlanPcpInstruction(jsonInstruction, description);
} else if (instruction instanceof ModIPInstruction) {
return matchModIpInstruction(jsonInstruction, description);
} else if (instruction instanceof ModIPv6FlowLabelInstruction) {
return matchModIPv6FlowLabelInstruction(jsonInstruction, description);
} else if (instruction instanceof ModMplsLabelInstruction) {
return matchModMplsLabelInstruction(jsonInstruction, description);
} else if (instruction instanceof ModOduSignalIdInstruction) {
return matchModOduSingalIdInstruction(jsonInstruction, description);
} else if (instruction instanceof PiInstruction) {
return matchPiInstruction(jsonInstruction, description);
} else if (instruction instanceof NoActionInstruction) {
return true;
}
return false;
}
use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.
the class DefaultNicFlowRule method populate.
/**
* Parses FlowRule's traffic selector and treatment
* and keeps relevant information for this NIC rule.
*/
private void populate() {
this.ethTypeCriterion = (EthTypeCriterion) this.selector().getCriterion(ETH_TYPE);
this.ethSrcAddrCriterion = (EthCriterion) this.selector().getCriterion(ETH_SRC);
this.ethDstAddrCriterion = (EthCriterion) this.selector().getCriterion(ETH_DST);
this.ipv4ProtoCriterion = (IPProtocolCriterion) this.selector().getCriterion(IP_PROTO);
this.ipv4SrcAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
this.ipv4DstAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
this.ipv4SrcMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
this.ipv4DstMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
this.udpSrcPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_SRC);
this.udpDstPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_DST);
this.tcpSrcPortCriterion = (TcpPortCriterion) this.selector().getCriterion(TCP_SRC);
this.tcpDstPortCriterion = (TcpPortCriterion) this.selector().getCriterion(TCP_DST);
this.actions = new HashSet<NicRuleAction>();
// TODO: Expand this translator with more actions
for (Instruction instr : this.treatment().allInstructions()) {
if (instr.type() == NOACTION) {
this.actions.add(new NicRuleAction(NicRuleAction.Action.DROP));
} else if (instr.type() == QUEUE) {
SetQueueInstruction queueInstruction = (SetQueueInstruction) instr;
this.actions.add(new NicRuleAction(NicRuleAction.Action.QUEUE, queueInstruction.queueId()));
this.interfaceNumber = queueInstruction.port().toLong();
} else if (instr.type() == METER) {
MeterInstruction meterInstruction = (MeterInstruction) instr;
this.actions.add(new NicRuleAction(NicRuleAction.Action.METER, meterInstruction.meterId().id()));
}
}
// This action provides basic rule match counters
this.actions.add(new NicRuleAction(NicRuleAction.Action.COUNT));
}
use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildActions.
private List<OFAction> buildActions(List<Instruction> treatments) {
if (treatment == null) {
return Collections.emptyList();
}
boolean tableFound = false;
List<OFAction> actions = new LinkedList<>();
for (Instruction i : treatments) {
switch(i.type()) {
case NOACTION:
return Collections.emptyList();
case L0MODIFICATION:
actions.add(buildL0Modification(i));
break;
case L1MODIFICATION:
actions.add(buildL1Modification(i));
break;
case L2MODIFICATION:
actions.add(buildL2Modification(i));
break;
case L3MODIFICATION:
actions.add(buildL3Modification(i));
break;
case L4MODIFICATION:
actions.add(buildL4Modification(i));
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
actions.add(action.build());
break;
case GROUP:
GroupInstruction group = (GroupInstruction) i;
OFActionGroup.Builder groupBuilder = factory().actions().buildGroup().setGroup(OFGroup.of(group.groupId().id()));
actions.add(groupBuilder.build());
break;
case QUEUE:
SetQueueInstruction queue = (SetQueueInstruction) i;
OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue().setQueueId(queue.queueId());
actions.add(queueBuilder.build());
break;
case TABLE:
// FIXME: should not occur here.
tableFound = true;
break;
case EXTENSION:
actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i).extensionInstruction()));
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
if (tableFound && actions.isEmpty()) {
// a goto instruction for the next table
return Collections.emptyList();
}
return actions;
}
use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.
the class FlowModBuilderVer10 method buildActions.
private List<OFAction> buildActions() {
List<OFAction> acts = new LinkedList<>();
OFAction act;
if (treatment == null) {
return acts;
}
for (Instruction i : treatment.immediate()) {
switch(i.type()) {
case NOACTION:
return Collections.emptyList();
case L2MODIFICATION:
act = buildL2Modification(i);
if (act != null) {
acts.add(buildL2Modification(i));
}
break;
case L3MODIFICATION:
act = buildL3Modification(i);
if (act != null) {
acts.add(buildL3Modification(i));
}
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
acts.add(action.build());
break;
case QUEUE:
SetQueueInstruction queue = (SetQueueInstruction) i;
if (queue.port() == null) {
log.warn("Required argument 'port' undefined for OFActionEnqueue");
}
OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue().setQueueId(queue.queueId()).setPort(OFPort.ofInt((int) queue.port().toLong()));
acts.add(queueBuilder.build());
break;
case L0MODIFICATION:
case L1MODIFICATION:
case GROUP:
case TABLE:
case METADATA:
log.warn("Instruction type {} not supported with protocol version {}", i.type(), factory().getVersion());
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return acts;
}
Aggregations