use of org.projectfloodlight.openflow.protocol.action.OFActionEnqueue 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.projectfloodlight.openflow.protocol.action.OFActionEnqueue in project onos by opennetworkinglab.
the class FlowModBuilderVer10 method buildActions.
private List<OFAction> buildActions() {
List<OFAction> acts = new LinkedList<>();
OFAction act;
if (treatment == null) {
return acts;
}
for (Instruction i : treatment.immediate()) {
switch(i.type()) {
case NOACTION:
return Collections.emptyList();
case L2MODIFICATION:
act = buildL2Modification(i);
if (act != null) {
acts.add(buildL2Modification(i));
}
break;
case L3MODIFICATION:
act = buildL3Modification(i);
if (act != null) {
acts.add(buildL3Modification(i));
}
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
acts.add(action.build());
break;
case QUEUE:
SetQueueInstruction queue = (SetQueueInstruction) i;
if (queue.port() == null) {
log.warn("Required argument 'port' undefined for OFActionEnqueue");
}
OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue().setQueueId(queue.queueId()).setPort(OFPort.ofInt((int) queue.port().toLong()));
acts.add(queueBuilder.build());
break;
case L0MODIFICATION:
case L1MODIFICATION:
case GROUP:
case TABLE:
case METADATA:
log.warn("Instruction type {} not supported with protocol version {}", i.type(), factory().getVersion());
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return acts;
}
Aggregations