use of org.onosproject.net.flow.instructions.Instructions.MeterInstruction in project onos by opennetworkinglab.
the class InstructionJsonMatcher method matchMeterInstruction.
/**
* Matches the contents of a meter instruction.
*
* @param instructionJson JSON instruction to match
* @param description Description object used for recording errors
* @return true if contents match, false otherwise
*/
private boolean matchMeterInstruction(JsonNode instructionJson, Description description) {
final String jsonType = instructionJson.get("type").textValue();
MeterInstruction instructionToMatch = (MeterInstruction) instruction;
if (!instructionToMatch.type().name().equals(jsonType)) {
description.appendText("type was " + jsonType);
return false;
}
final long jsonMeterId = instructionJson.get("meterId").longValue();
if (instructionToMatch.meterId().id() != jsonMeterId) {
description.appendText("meterId was " + jsonMeterId);
return false;
}
return true;
}
use of org.onosproject.net.flow.instructions.Instructions.MeterInstruction 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.MeterInstruction 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));
}
Aggregations