use of org.onosproject.openflow.controller.ExtensionTreatmentInterpreter in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildExtensionAction.
protected OFAction buildExtensionAction(ExtensionTreatment i) {
if (!driverService.isPresent()) {
log.error("No driver service present");
return null;
}
Driver driver = driverService.get().getDriver(deviceId);
if (driver.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
ExtensionTreatmentInterpreter interpreter = handler.behaviour(ExtensionTreatmentInterpreter.class);
return interpreter.mapInstruction(factory(), i);
}
return null;
}
use of org.onosproject.openflow.controller.ExtensionTreatmentInterpreter 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;
}
}
use of org.onosproject.openflow.controller.ExtensionTreatmentInterpreter in project onos by opennetworkinglab.
the class FlowEntryBuilder method configureTreatmentBuilder.
/**
* Configures traffic treatment builder with a given collection of actions.
*
* @param actions a set of OpenFlow actions
* @param builder traffic treatment builder
* @param driverHandler driver handler
* @param deviceId device identifier
* @return configured traffic treatment builder
*/
public static TrafficTreatment.Builder configureTreatmentBuilder(List<OFAction> actions, TrafficTreatment.Builder builder, DriverHandler driverHandler, DeviceId deviceId) {
ExtensionTreatmentInterpreter interpreter;
if (driverHandler.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
interpreter = driverHandler.behaviour(ExtensionTreatmentInterpreter.class);
} else {
interpreter = null;
}
for (OFAction act : actions) {
switch(act.getType()) {
case OUTPUT:
OFActionOutput out = (OFActionOutput) act;
builder.setOutput(PortNumber.portNumber(out.getPort().getPortNumber()));
break;
case SET_VLAN_VID:
OFActionSetVlanVid vlan = (OFActionSetVlanVid) act;
builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan()));
break;
case SET_VLAN_PCP:
OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act;
builder.setVlanPcp(pcp.getVlanPcp().getValue());
break;
case SET_DL_DST:
OFActionSetDlDst dldst = (OFActionSetDlDst) act;
builder.setEthDst(MacAddress.valueOf(dldst.getDlAddr().getLong()));
break;
case SET_DL_SRC:
OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act;
builder.setEthSrc(MacAddress.valueOf(dlsrc.getDlAddr().getLong()));
break;
case SET_NW_DST:
OFActionSetNwDst nwdst = (OFActionSetNwDst) act;
IPv4Address di = nwdst.getNwAddr();
builder.setIpDst(Ip4Address.valueOf(di.getInt()));
break;
case SET_NW_SRC:
OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act;
IPv4Address si = nwsrc.getNwAddr();
builder.setIpSrc(Ip4Address.valueOf(si.getInt()));
break;
case EXPERIMENTER:
OFActionExperimenter exp = (OFActionExperimenter) act;
if (exp.getExperimenter() == 0x80005A06 || exp.getExperimenter() == 0x748771) {
OFActionCircuit ct = (OFActionCircuit) exp;
CircuitSignalID circuitSignalID = ((OFOxmOchSigid) ct.getField()).getValue();
builder.add(Instructions.modL0Lambda(Lambda.ochSignal(lookupGridType(circuitSignalID.getGridType()), lookupChannelSpacing(circuitSignalID.getChannelSpacing()), circuitSignalID.getChannelNumber(), circuitSignalID.getSpectralWidth())));
} else if (interpreter != null) {
builder.extension(interpreter.mapAction(exp), deviceId);
} else {
log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
}
break;
case SET_FIELD:
OFActionSetField setField = (OFActionSetField) act;
handleSetField(builder, setField, driverHandler, deviceId);
break;
case POP_MPLS:
OFActionPopMpls popMpls = (OFActionPopMpls) act;
builder.popMpls(new EthType(popMpls.getEthertype().getValue()));
break;
case PUSH_MPLS:
builder.pushMpls();
break;
case COPY_TTL_IN:
builder.copyTtlIn();
break;
case COPY_TTL_OUT:
builder.copyTtlOut();
break;
case DEC_MPLS_TTL:
builder.decMplsTtl();
break;
case DEC_NW_TTL:
builder.decNwTtl();
break;
case GROUP:
OFActionGroup group = (OFActionGroup) act;
builder.group(new GroupId(group.getGroup().getGroupNumber()));
break;
case SET_QUEUE:
OFActionSetQueue setQueue = (OFActionSetQueue) act;
builder.setQueue(setQueue.getQueueId());
break;
case ENQUEUE:
OFActionEnqueue enqueue = (OFActionEnqueue) act;
builder.setQueue(enqueue.getQueueId(), PortNumber.portNumber(enqueue.getPort().getPortNumber()));
break;
case STRIP_VLAN:
case POP_VLAN:
builder.popVlan();
break;
case PUSH_VLAN:
OFActionPushVlan pushVlan = (OFActionPushVlan) act;
builder.pushVlan(new EthType((short) pushVlan.getEthertype().getValue()));
break;
case METER:
OFActionMeter actionMeter = (OFActionMeter) act;
builder.meter(MeterId.meterId(actionMeter.getMeterId()));
break;
case SET_TP_DST:
case SET_TP_SRC:
case POP_PBB:
case PUSH_PBB:
case SET_MPLS_LABEL:
case SET_MPLS_TC:
case SET_MPLS_TTL:
case SET_NW_ECN:
case SET_NW_TOS:
case SET_NW_TTL:
default:
log.warn("Action type {} not yet implemented.", act.getType());
}
}
return builder;
}
use of org.onosproject.openflow.controller.ExtensionTreatmentInterpreter in project onos by opennetworkinglab.
the class GroupModBuilder method buildExtensionAction.
private OFAction buildExtensionAction(ExtensionTreatment i, DeviceId deviceId) {
if (!driverService.isPresent()) {
log.error("No driver service present");
return null;
}
Driver driver = driverService.get().getDriver(deviceId);
if (driver.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
ExtensionTreatmentInterpreter interpreter = handler.behaviour(ExtensionTreatmentInterpreter.class);
return interpreter.mapInstruction(factory, i);
}
return null;
}
Aggregations