Search in sources :

Example 1 with MeterInstruction

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;
}
Also used : MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) HexString(org.onlab.util.HexString)

Example 2 with MeterInstruction

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;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) PiInstruction(org.onosproject.net.flow.instructions.PiInstruction) JsonNode(com.fasterxml.jackson.databind.JsonNode) HexString(org.onlab.util.HexString) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) ModMplsHeaderInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModOduSignalIdInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) ModMplsLabelInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) NoActionInstruction(org.onosproject.net.flow.instructions.Instructions.NoActionInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) ModIPv6FlowLabelInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction) GroupInstruction(org.onosproject.net.flow.instructions.Instructions.GroupInstruction) ModVlanPcpInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction)

Example 3 with MeterInstruction

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));
}
Also used : SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)

Aggregations

MeterInstruction (org.onosproject.net.flow.instructions.Instructions.MeterInstruction)3 HexString (org.onlab.util.HexString)2 SetQueueInstruction (org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1 GroupInstruction (org.onosproject.net.flow.instructions.Instructions.GroupInstruction)1 NoActionInstruction (org.onosproject.net.flow.instructions.Instructions.NoActionInstruction)1 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)1 ModOchSignalInstruction (org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction)1 ModOduSignalIdInstruction (org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction)1 ModEtherInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction)1 ModMplsHeaderInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction)1 ModMplsLabelInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction)1 ModVlanIdInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction)1 ModVlanPcpInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction)1 ModIPInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction)1 ModIPv6FlowLabelInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction)1 PiInstruction (org.onosproject.net.flow.instructions.PiInstruction)1