Search in sources :

Example 1 with ModOchSignalInstruction

use of org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction in project onos by opennetworkinglab.

the class InstructionJsonMatcher method matchModOchSingalInstruction.

/**
 * Matches the contents of a mod OCh singal instruction.
 *
 * @param instructionJson JSON instruction to match
 * @param description Description object used for recording errors
 * @return true if contents matches, false otherwise
 */
private boolean matchModOchSingalInstruction(JsonNode instructionJson, Description description) {
    ModOchSignalInstruction instructionToMatch = (ModOchSignalInstruction) instruction;
    String jsonSubType = instructionJson.get("subtype").textValue();
    if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
        description.appendText("subtype was " + jsonSubType);
        return false;
    }
    String jsonType = instructionJson.get("type").textValue();
    if (!instructionToMatch.type().name().equals(jsonType)) {
        description.appendText("type was " + jsonType);
        return false;
    }
    String jsonGridType = instructionJson.get("gridType").textValue();
    if (!instructionToMatch.lambda().gridType().name().equals(jsonGridType)) {
        description.appendText("gridType was " + jsonGridType);
        return false;
    }
    String jsonChannelSpacing = instructionJson.get("channelSpacing").textValue();
    if (!instructionToMatch.lambda().channelSpacing().name().equals(jsonChannelSpacing)) {
        description.appendText("channelSpacing was " + jsonChannelSpacing);
        return false;
    }
    int jsonSpacingMultiplier = instructionJson.get("spacingMultiplier").intValue();
    if (instructionToMatch.lambda().spacingMultiplier() != jsonSpacingMultiplier) {
        description.appendText("spacingMultiplier was " + jsonSpacingMultiplier);
        return false;
    }
    int jsonSlotGranularity = instructionJson.get("slotGranularity").intValue();
    if (instructionToMatch.lambda().slotGranularity() != jsonSlotGranularity) {
        description.appendText("slotGranularity was " + jsonSlotGranularity);
        return false;
    }
    return true;
}
Also used : ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) HexString(org.onlab.util.HexString)

Example 2 with ModOchSignalInstruction

use of org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction 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 ModOchSignalInstruction

use of org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction in project onos by opennetworkinglab.

the class FlowModBuilderVer13 method buildL0Modification.

protected OFAction buildL0Modification(Instruction i) {
    L0ModificationInstruction l0m = (L0ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch(l0m.subtype()) {
        case OCH:
            try {
                ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m;
                OchSignal signal = modOchSignalInstruction.lambda();
                byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
                byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
                oxm = factory().oxms().expOchSigId(new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
            } catch (NoMappingFoundException e) {
                log.warn(e.getMessage());
                break;
            }
            break;
        default:
            log.warn("Unimplemented action type {}.", l0m.subtype());
            break;
    }
    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
Also used : ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) OchSignal(org.onosproject.net.OchSignal) CircuitSignalID(org.projectfloodlight.openflow.types.CircuitSignalID) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) NoMappingFoundException(org.onosproject.provider.of.flow.util.NoMappingFoundException)

Aggregations

ModOchSignalInstruction (org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction)3 HexString (org.onlab.util.HexString)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 OchSignal (org.onosproject.net.OchSignal)1 GroupInstruction (org.onosproject.net.flow.instructions.Instructions.GroupInstruction)1 MeterInstruction (org.onosproject.net.flow.instructions.Instructions.MeterInstruction)1 NoActionInstruction (org.onosproject.net.flow.instructions.Instructions.NoActionInstruction)1 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)1 SetQueueInstruction (org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)1 L0ModificationInstruction (org.onosproject.net.flow.instructions.L0ModificationInstruction)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 NoMappingFoundException (org.onosproject.provider.of.flow.util.NoMappingFoundException)1