Search in sources :

Example 1 with IpDscp

use of org.projectfloodlight.openflow.types.IpDscp in project onos by opennetworkinglab.

the class FlowEntryBuilder method handleSetField.

// CHECKSTYLE IGNORE MethodLength FOR NEXT 1 LINES
private static void handleSetField(TrafficTreatment.Builder builder, OFActionSetField action, DriverHandler driverHandler, DeviceId deviceId) {
    ExtensionTreatmentInterpreter treatmentInterpreter;
    if (driverHandler.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
        treatmentInterpreter = driverHandler.behaviour(ExtensionTreatmentInterpreter.class);
    } else {
        treatmentInterpreter = null;
    }
    OFOxm<?> oxm = action.getField();
    switch(oxm.getMatchField().id) {
        case VLAN_PCP:
            @SuppressWarnings("unchecked") OFOxm<VlanPcp> vlanpcp = (OFOxm<VlanPcp>) oxm;
            builder.setVlanPcp(vlanpcp.getValue().getValue());
            break;
        case VLAN_VID:
            if (treatmentInterpreter != null) {
                try {
                    builder.extension(treatmentInterpreter.mapAction(action), deviceId);
                    break;
                } catch (UnsupportedOperationException e) {
                    log.debug("Unsupported action extension; defaulting to native OF");
                }
            }
            @SuppressWarnings("unchecked") OFOxm<OFVlanVidMatch> vlanvid = (OFOxm<OFVlanVidMatch>) oxm;
            builder.setVlanId(VlanId.vlanId(vlanvid.getValue().getVlan()));
            break;
        case ETH_DST:
            @SuppressWarnings("unchecked") OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethdst = (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
            builder.setEthDst(MacAddress.valueOf(ethdst.getValue().getLong()));
            break;
        case ETH_SRC:
            @SuppressWarnings("unchecked") OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethsrc = (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
            builder.setEthSrc(MacAddress.valueOf(ethsrc.getValue().getLong()));
            break;
        case IPV4_DST:
            @SuppressWarnings("unchecked") OFOxm<IPv4Address> ip4dst = (OFOxm<IPv4Address>) oxm;
            builder.setIpDst(Ip4Address.valueOf(ip4dst.getValue().getInt()));
            break;
        case IPV4_SRC:
            @SuppressWarnings("unchecked") OFOxm<IPv4Address> ip4src = (OFOxm<IPv4Address>) oxm;
            builder.setIpSrc(Ip4Address.valueOf(ip4src.getValue().getInt()));
            break;
        case MPLS_LABEL:
            @SuppressWarnings("unchecked") OFOxm<U32> labelId = (OFOxm<U32>) oxm;
            builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue()));
            break;
        case MPLS_BOS:
            @SuppressWarnings("unchecked") OFOxm<OFBooleanValue> mplsBos = (OFOxm<OFBooleanValue>) oxm;
            builder.setMplsBos(mplsBos.getValue().getValue());
            break;
        case TUNNEL_ID:
            @SuppressWarnings("unchecked") OFOxm<U64> tunnelId = (OFOxm<U64>) oxm;
            builder.setTunnelId(tunnelId.getValue().getValue());
            break;
        case TCP_DST:
            @SuppressWarnings("unchecked") OFOxm<TransportPort> tcpdst = (OFOxm<TransportPort>) oxm;
            builder.setTcpDst(TpPort.tpPort(tcpdst.getValue().getPort()));
            break;
        case TCP_SRC:
            @SuppressWarnings("unchecked") OFOxm<TransportPort> tcpsrc = (OFOxm<TransportPort>) oxm;
            builder.setTcpSrc(TpPort.tpPort(tcpsrc.getValue().getPort()));
            break;
        case UDP_DST:
            @SuppressWarnings("unchecked") OFOxm<TransportPort> udpdst = (OFOxm<TransportPort>) oxm;
            builder.setUdpDst(TpPort.tpPort(udpdst.getValue().getPort()));
            break;
        case UDP_SRC:
            @SuppressWarnings("unchecked") OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm;
            builder.setUdpSrc(TpPort.tpPort(udpsrc.getValue().getPort()));
            break;
        case TUNNEL_IPV4_DST:
        case NSP:
        case NSI:
        case NSH_C1:
        case NSH_C2:
        case NSH_C3:
        case NSH_C4:
        case NSH_MDTYPE:
        case NSH_NP:
        case ENCAP_ETH_SRC:
        case ENCAP_ETH_DST:
        case ENCAP_ETH_TYPE:
        case TUN_GPE_NP:
            if (treatmentInterpreter != null) {
                try {
                    builder.extension(treatmentInterpreter.mapAction(action), deviceId);
                } catch (UnsupportedOperationException e) {
                    log.debug(e.getMessage());
                }
            }
            break;
        case EXP_ODU_SIG_ID:
            @SuppressWarnings("unchecked") OFOxm<OduSignalID> oduID = (OFOxm<OduSignalID>) oxm;
            OduSignalID oduSignalID = oduID.getValue();
            OduSignalId oduSignalId = OduSignalId.oduSignalId(oduSignalID.getTpn(), oduSignalID.getTslen(), oduSignalID.getTsmap());
            builder.add(modL1OduSignalId(oduSignalId));
            break;
        case EXP_OCH_SIG_ID:
            try {
                @SuppressWarnings("unchecked") OFOxm<CircuitSignalID> ochId = (OFOxm<CircuitSignalID>) oxm;
                CircuitSignalID circuitSignalID = ochId.getValue();
                builder.add(modL0Lambda(Lambda.ochSignal(lookupGridType(circuitSignalID.getGridType()), lookupChannelSpacing(circuitSignalID.getChannelSpacing()), circuitSignalID.getChannelNumber(), circuitSignalID.getSpectralWidth())));
            } catch (NoMappingFoundException e) {
                log.warn(e.getMessage());
                break;
            }
            break;
        case ARP_OP:
            @SuppressWarnings("unchecked") OFOxm<org.projectfloodlight.openflow.types.ArpOpcode> arpop = (OFOxm<org.projectfloodlight.openflow.types.ArpOpcode>) oxm;
            builder.setArpOp((short) arpop.getValue().getOpcode());
            break;
        case ARP_SHA:
            @SuppressWarnings("unchecked") OFOxm<org.projectfloodlight.openflow.types.MacAddress> arpsha = (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
            builder.setArpSha(MacAddress.valueOf(arpsha.getValue().getLong()));
            break;
        case ARP_SPA:
            @SuppressWarnings("unchecked") OFOxm<IPv4Address> arpspa = (OFOxm<IPv4Address>) oxm;
            builder.setArpSpa(Ip4Address.valueOf(arpspa.getValue().getInt()));
            break;
        case OFDPA_MPLS_TYPE:
        case OFDPA_OVID:
        case OFDPA_MPLS_L2_PORT:
        case OFDPA_ALLOW_VLAN_TRANSLATION:
        case OFDPA_QOS_INDEX:
            if (treatmentInterpreter != null) {
                try {
                    builder.extension(treatmentInterpreter.mapAction(action), deviceId);
                    break;
                } catch (UnsupportedOperationException e) {
                    log.warn("Unsupported action extension");
                }
            }
            break;
        case IP_DSCP:
            @SuppressWarnings("unchecked") OFOxm<IpDscp> ipDscp = (OFOxm<IpDscp>) oxm;
            builder.setIpDscp(ipDscp.getValue().getDscpValue());
            break;
        case ARP_THA:
            @SuppressWarnings("unchecked") OFOxm<org.projectfloodlight.openflow.types.MacAddress> arptha = (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
            builder.setArpTha(MacAddress.valueOf(arptha.getValue().getLong()));
            break;
        case ARP_TPA:
            @SuppressWarnings("unchecked") OFOxm<IPv4Address> arptpa = (OFOxm<IPv4Address>) oxm;
            builder.setArpTpa(Ip4Address.valueOf(arptpa.getValue().getInt()));
            break;
        case BSN_EGR_PORT_GROUP_ID:
        case BSN_GLOBAL_VRF_ALLOWED:
        case BSN_IN_PORTS_128:
        case BSN_L3_DST_CLASS_ID:
        case BSN_L3_INTERFACE_CLASS_ID:
        case BSN_L3_SRC_CLASS_ID:
        case BSN_LAG_ID:
        case BSN_TCP_FLAGS:
        case BSN_UDF0:
        case BSN_UDF1:
        case BSN_UDF2:
        case BSN_UDF3:
        case BSN_UDF4:
        case BSN_UDF5:
        case BSN_UDF6:
        case BSN_UDF7:
        case BSN_VLAN_XLATE_PORT_GROUP_ID:
        case BSN_VRF:
        case ETH_TYPE:
        case ICMPV4_CODE:
        case ICMPV4_TYPE:
        case ICMPV6_CODE:
        case ICMPV6_TYPE:
        case IN_PHY_PORT:
        case IN_PORT:
        case IPV6_DST:
        case IPV6_FLABEL:
        case IPV6_ND_SLL:
        case IPV6_ND_TARGET:
        case IPV6_ND_TLL:
        case IPV6_SRC:
        case IP_ECN:
        case IP_PROTO:
        case METADATA:
        case MPLS_TC:
        case OCH_SIGID:
        case OCH_SIGID_BASIC:
        case OCH_SIGTYPE:
        case OCH_SIGTYPE_BASIC:
        case SCTP_DST:
        case SCTP_SRC:
        case EXP_ODU_SIGTYPE:
        case EXP_OCH_SIGTYPE:
        default:
            log.warn("Set field type {} not yet implemented.", oxm.getMatchField().id);
            break;
    }
}
Also used : OFBooleanValue(org.projectfloodlight.openflow.types.OFBooleanValue) IPv4Address(org.projectfloodlight.openflow.types.IPv4Address) ExtensionTreatmentInterpreter(org.onosproject.openflow.controller.ExtensionTreatmentInterpreter) U64(org.projectfloodlight.openflow.types.U64) OduSignalId(org.onosproject.net.OduSignalId) Instructions.modL1OduSignalId(org.onosproject.net.flow.instructions.Instructions.modL1OduSignalId) TransportPort(org.projectfloodlight.openflow.types.TransportPort) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) CircuitSignalID(org.projectfloodlight.openflow.types.CircuitSignalID) MacAddress(org.onlab.packet.MacAddress) U32(org.projectfloodlight.openflow.types.U32) OFActionSetVlanPcp(org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp) VlanPcp(org.projectfloodlight.openflow.types.VlanPcp) OFOxm(org.projectfloodlight.openflow.protocol.oxm.OFOxm) OduSignalID(org.projectfloodlight.openflow.types.OduSignalID) IpDscp(org.projectfloodlight.openflow.types.IpDscp)

Example 2 with IpDscp

use of org.projectfloodlight.openflow.types.IpDscp 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)

Aggregations

IpDscp (org.projectfloodlight.openflow.types.IpDscp)2 Ip4Address (org.onlab.packet.Ip4Address)1 Ip6Address (org.onlab.packet.Ip6Address)1 MacAddress (org.onlab.packet.MacAddress)1 OduSignalId (org.onosproject.net.OduSignalId)1 Instructions.modL1OduSignalId (org.onosproject.net.flow.instructions.Instructions.modL1OduSignalId)1 L3ModificationInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction)1 ModArpEthInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction)1 ModArpIPInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction)1 ModArpOpInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction)1 ModIPInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction)1 ModIPv6FlowLabelInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction)1 ExtensionTreatmentInterpreter (org.onosproject.openflow.controller.ExtensionTreatmentInterpreter)1 OFActionSetVlanPcp (org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp)1 OFOxm (org.projectfloodlight.openflow.protocol.oxm.OFOxm)1 CircuitSignalID (org.projectfloodlight.openflow.types.CircuitSignalID)1 IPv4Address (org.projectfloodlight.openflow.types.IPv4Address)1 OFBooleanValue (org.projectfloodlight.openflow.types.OFBooleanValue)1 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)1 OduSignalID (org.projectfloodlight.openflow.types.OduSignalID)1