Search in sources :

Example 1 with VlanPcp

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

Aggregations

MacAddress (org.onlab.packet.MacAddress)1 OduSignalId (org.onosproject.net.OduSignalId)1 Instructions.modL1OduSignalId (org.onosproject.net.flow.instructions.Instructions.modL1OduSignalId)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 IpDscp (org.projectfloodlight.openflow.types.IpDscp)1 OFBooleanValue (org.projectfloodlight.openflow.types.OFBooleanValue)1 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)1 OduSignalID (org.projectfloodlight.openflow.types.OduSignalID)1 TransportPort (org.projectfloodlight.openflow.types.TransportPort)1 U32 (org.projectfloodlight.openflow.types.U32)1 U64 (org.projectfloodlight.openflow.types.U64)1 VlanPcp (org.projectfloodlight.openflow.types.VlanPcp)1