Search in sources :

Example 11 with L3ModificationInstruction

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

the class HPPipelineV3800 method checkUnSupportedFeatures.

// Return TRUE if ForwardingObjective fwd includes UNSUPPORTED features
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;
    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V3800 Driver - unsupported criteria {}", criterion.type());
            unsupportedFeatures = true;
        }
    }
    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V3800 Driver - unsupported instruction {}", instruction.type());
            unsupportedFeatures = true;
        }
        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3800 Driver - unsupported L2MODIFICATION instruction {}", ((L2ModificationInstruction) instruction).subtype());
                unsupportedFeatures = true;
            }
        }
        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3800 Driver - unsupported L3MODIFICATION instruction {}", ((L3ModificationInstruction) instruction).subtype());
                unsupportedFeatures = true;
            }
        }
    }
    return unsupportedFeatures;
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction)

Example 12 with L3ModificationInstruction

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

the class FlowObjectiveCompositionUtil method revertTreatmentSelector.

public static TrafficSelector revertTreatmentSelector(TrafficTreatment trafficTreatment, TrafficSelector trafficSelector) {
    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
    Map<Criterion.Type, Criterion> criterionMap = new HashMap<>();
    for (Criterion criterion : trafficSelector.criteria()) {
        criterionMap.put(criterion.type(), criterion);
    }
    for (Instruction instruction : trafficTreatment.allInstructions()) {
        switch(instruction.type()) {
            case OUTPUT:
                break;
            case GROUP:
                break;
            case L0MODIFICATION:
                {
                    L0ModificationInstruction l0 = (L0ModificationInstruction) instruction;
                    switch(l0.subtype()) {
                        case OCH:
                            if (criterionMap.containsKey(Criterion.Type.OCH_SIGID)) {
                                if (((OchSignalCriterion) criterionMap.get((Criterion.Type.OCH_SIGID))).lambda().equals(((L0ModificationInstruction.ModOchSignalInstruction) l0).lambda())) {
                                    criterionMap.remove(Criterion.Type.OCH_SIGID);
                                } else {
                                    return null;
                                }
                            }
                        default:
                            break;
                    }
                    break;
                }
            case L1MODIFICATION:
                {
                    L1ModificationInstruction l1 = (L1ModificationInstruction) instruction;
                    switch(l1.subtype()) {
                        case ODU_SIGID:
                            if (criterionMap.containsKey(Criterion.Type.ODU_SIGID)) {
                                if (((OduSignalIdCriterion) criterionMap.get((Criterion.Type.ODU_SIGID))).oduSignalId().equals(((L1ModificationInstruction.ModOduSignalIdInstruction) l1).oduSignalId())) {
                                    criterionMap.remove(Criterion.Type.ODU_SIGID);
                                } else {
                                    return null;
                                }
                            }
                        default:
                            break;
                    }
                    break;
                }
            case L2MODIFICATION:
                {
                    L2ModificationInstruction l2 = (L2ModificationInstruction) instruction;
                    switch(l2.subtype()) {
                        case ETH_SRC:
                            if (criterionMap.containsKey(Criterion.Type.ETH_SRC)) {
                                if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_SRC))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
                                    criterionMap.remove(Criterion.Type.ETH_SRC);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case ETH_DST:
                            if (criterionMap.containsKey(Criterion.Type.ETH_DST)) {
                                if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_DST))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
                                    criterionMap.remove(Criterion.Type.ETH_DST);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case VLAN_ID:
                            if (criterionMap.containsKey(Criterion.Type.VLAN_VID)) {
                                if (((VlanIdCriterion) criterionMap.get((Criterion.Type.VLAN_VID))).vlanId().equals(((L2ModificationInstruction.ModVlanIdInstruction) l2).vlanId())) {
                                    criterionMap.remove(Criterion.Type.VLAN_VID);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case VLAN_PCP:
                            if (criterionMap.containsKey(Criterion.Type.VLAN_PCP)) {
                                if (((VlanPcpCriterion) criterionMap.get((Criterion.Type.VLAN_PCP))).priority() == ((L2ModificationInstruction.ModVlanPcpInstruction) l2).vlanPcp()) {
                                    criterionMap.remove(Criterion.Type.VLAN_PCP);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case MPLS_LABEL:
                            if (criterionMap.containsKey(Criterion.Type.MPLS_LABEL)) {
                                if (((MplsCriterion) criterionMap.get((Criterion.Type.MPLS_LABEL))).label().equals(((L2ModificationInstruction.ModMplsLabelInstruction) l2).label())) {
                                    criterionMap.remove(Criterion.Type.ETH_DST);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        default:
                            break;
                    }
                    break;
                }
            case TABLE:
                break;
            case L3MODIFICATION:
                {
                    L3ModificationInstruction l3 = (L3ModificationInstruction) instruction;
                    switch(l3.subtype()) {
                        case IPV4_SRC:
                            if (criterionMap.containsKey(Criterion.Type.IPV4_SRC)) {
                                if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
                                    criterionMap.remove(Criterion.Type.IPV4_SRC);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case IPV4_DST:
                            if (criterionMap.containsKey(Criterion.Type.IPV4_DST)) {
                                if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
                                    criterionMap.remove(Criterion.Type.IPV4_DST);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case IPV6_SRC:
                            if (criterionMap.containsKey(Criterion.Type.IPV6_SRC)) {
                                if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
                                    criterionMap.remove(Criterion.Type.IPV6_SRC);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case IPV6_DST:
                            if (criterionMap.containsKey(Criterion.Type.IPV6_DST)) {
                                if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
                                    criterionMap.remove(Criterion.Type.IPV6_DST);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        case IPV6_FLABEL:
                            if (criterionMap.containsKey(Criterion.Type.IPV6_FLABEL)) {
                                if (((IPv6FlowLabelCriterion) criterionMap.get(Criterion.Type.IPV6_FLABEL)).flowLabel() == (((L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3).flowLabel())) {
                                    criterionMap.remove(Criterion.Type.IPV4_SRC);
                                } else {
                                    return null;
                                }
                            } else {
                                break;
                            }
                        default:
                            break;
                    }
                    break;
                }
            case METADATA:
                break;
            default:
                break;
        }
    }
    for (Criterion criterion : criterionMap.values()) {
        selectorBuilder.add(criterion);
    }
    return selectorBuilder.build();
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) HashMap(java.util.HashMap) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) L1ModificationInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) L1ModificationInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 13 with L3ModificationInstruction

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

the class FlowModBuilderVer10 method buildL3Modification.

private OFAction buildL3Modification(Instruction i) {
    L3ModificationInstruction l3m = (L3ModificationInstruction) i;
    ModIPInstruction ip;
    Ip4Address ip4;
    switch(l3m.subtype()) {
        case IPV4_SRC:
            ip = (ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            return factory().actions().setNwSrc(IPv4Address.of(ip4.toInt()));
        case IPV4_DST:
            ip = (ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            return factory().actions().setNwDst(IPv4Address.of(ip4.toInt()));
        default:
            log.warn("Unimplemented action type {}.", l3m.subtype());
            break;
    }
    return null;
}
Also used : L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Ip4Address(org.onlab.packet.Ip4Address) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction)

Example 14 with L3ModificationInstruction

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

the class FlowModBuilderVer13 method buildL3Modification.

protected OFAction buildL3Modification(Instruction i) {
    L3ModificationInstruction l3m = (L3ModificationInstruction) i;
    ModIPInstruction ip;
    Ip4Address ip4;
    Ip6Address ip6;
    OFOxm<?> oxm = null;
    switch(l3m.subtype()) {
        case IPV4_SRC:
            ip = (ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
            break;
        case IPV4_DST:
            ip = (ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
            break;
        case IP_DSCP:
            L3ModificationInstruction.ModDscpInstruction dscp = (L3ModificationInstruction.ModDscpInstruction) i;
            IpDscp ipDscp = IpDscp.of(dscp.dscp());
            oxm = factory().oxms().ipDscp(ipDscp);
            break;
        case IPV6_SRC:
            ip = (ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_DST:
            ip = (ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_FLABEL:
            ModIPv6FlowLabelInstruction flowLabelInstruction = (ModIPv6FlowLabelInstruction) i;
            int flowLabel = flowLabelInstruction.flowLabel();
            oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
            break;
        case ARP_SPA:
            ModArpIPInstruction sAip = (ModArpIPInstruction) i;
            ip4 = sAip.ip().getIp4Address();
            oxm = factory().oxms().arpSpa(IPv4Address.of(ip4.toInt()));
            break;
        case ARP_SHA:
            ModArpEthInstruction sAei = (ModArpEthInstruction) i;
            oxm = factory().oxms().arpSha(MacAddress.of(sAei.mac().toLong()));
            break;
        case ARP_TPA:
            ModArpIPInstruction dAip = (ModArpIPInstruction) i;
            ip4 = dAip.ip().getIp4Address();
            oxm = factory().oxms().arpTpa(IPv4Address.of(ip4.toInt()));
            break;
        case ARP_THA:
            ModArpEthInstruction dAei = (ModArpEthInstruction) i;
            oxm = factory().oxms().arpTha(MacAddress.of(dAei.mac().toLong()));
            break;
        case ARP_OP:
            ModArpOpInstruction oi = (ModArpOpInstruction) i;
            oxm = factory().oxms().arpOp(ArpOpcode.of((int) oi.op()));
            break;
        case DEC_TTL:
            return factory().actions().decNwTtl();
        case TTL_IN:
            return factory().actions().copyTtlIn();
        case TTL_OUT:
            return factory().actions().copyTtlOut();
        default:
            log.warn("Unimplemented action type {}.", l3m.subtype());
            break;
    }
    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
Also used : ModArpEthInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Ip4Address(org.onlab.packet.Ip4Address) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModArpIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction) Ip6Address(org.onlab.packet.Ip6Address) ModIPv6FlowLabelInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction) ModArpOpInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction) IpDscp(org.projectfloodlight.openflow.types.IpDscp)

Example 15 with L3ModificationInstruction

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

the class EncodeInstructionCodecHelper method encodeL3.

/**
 * Encode an L3 modification instruction.
 *
 * @param result json node that the instruction attributes are added to
 */
private void encodeL3(ObjectNode result) {
    L3ModificationInstruction l3Instruction = (L3ModificationInstruction) instruction;
    result.put(InstructionCodec.SUBTYPE, l3Instruction.subtype().name());
    switch(l3Instruction.subtype()) {
        case IPV4_SRC:
        case IPV4_DST:
        case IPV6_SRC:
        case IPV6_DST:
            final L3ModificationInstruction.ModIPInstruction modIPInstruction = (L3ModificationInstruction.ModIPInstruction) l3Instruction;
            result.put(InstructionCodec.IP, modIPInstruction.ip().toString());
            break;
        case IPV6_FLABEL:
            final L3ModificationInstruction.ModIPv6FlowLabelInstruction modFlowLabelInstruction = (L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3Instruction;
            result.put(InstructionCodec.FLOW_LABEL, modFlowLabelInstruction.flowLabel());
            break;
        case IP_DSCP:
            final L3ModificationInstruction.ModDscpInstruction modDscpInstruction = (L3ModificationInstruction.ModDscpInstruction) l3Instruction;
            result.put(InstructionCodec.IP_DSCP, modDscpInstruction.dscp());
            break;
        case TTL_IN:
        case TTL_OUT:
        case DEC_TTL:
            // These instructions have no values to be encoded
            break;
        default:
            log.info("Cannot convert L3 subtype of {}", l3Instruction.subtype());
            break;
    }
}
Also used : L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction)

Aggregations

L3ModificationInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction)15 Instruction (org.onosproject.net.flow.instructions.Instruction)11 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)11 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)9 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)8 Criterion (org.onosproject.net.flow.criteria.Criterion)7 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)7 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)7 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)6 Ip4Address (org.onlab.packet.Ip4Address)3 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 FlowRule (org.onosproject.net.flow.FlowRule)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)3 L4ModificationInstruction (org.onosproject.net.flow.instructions.L4ModificationInstruction)3 Group (org.onosproject.net.group.Group)3 ArrayDeque (java.util.ArrayDeque)2