本文整理汇总了Java中org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions类的典型用法代码示例。如果您正苦于以下问题:Java OFInstructionApplyActions类的具体用法?Java OFInstructionApplyActions怎么用?Java OFInstructionApplyActions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFInstructionApplyActions类属于org.projectfloodlight.openflow.protocol.instruction包,在下文中一共展示了OFInstructionApplyActions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installTransitFlow
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ImmutablePair<Long, Boolean> installTransitFlow(final DatapathId dpid, final String flowId,
final Long cookie, final int inputPort, final int outputPort,
final int transitVlanId) {
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
// build match by input port and transit vlan id
Match match = matchFlow(sw, inputPort, transitVlanId);
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command, no meter
OFFlowMod flowMod = buildFlowMod(sw, match, null, actions,
cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
// send FLOW_MOD to the switch
boolean response = pushFlow(flowId, dpid, flowMod);
return new ImmutablePair<>(flowMod.getXid(), response);
}
示例2: buildFlowMod
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Create an OFFlowMod that can be passed to StaticEntryPusher.
*
* @param sw switch object
* @param match match for the flow
* @param meter meter for the flow
* @param actions actions for the flow
* @param cookie cookie for the flow
* @param priority priority to set on the flow
* @return {@link OFFlowMod}
*/
private OFFlowMod buildFlowMod(final IOFSwitch sw, final Match match, final OFInstructionMeter meter,
final OFInstructionApplyActions actions, final long cookie, final int priority) {
OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();
fmb.setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT);
fmb.setHardTimeout(FlowModUtils.INFINITE_TIMEOUT);
fmb.setBufferId(OFBufferId.NO_BUFFER);
fmb.setCookie(U64.of(cookie));
fmb.setPriority(priority);
List<OFInstruction> instructions = new ArrayList<>(2);
if (meter != null) { // If no meter then no bandwidth limit
instructions.add(meter);
}
if (actions != null) { // If no instruction then Drops packet
instructions.add(actions);
}
if (match != null) { // If no then match everything
fmb.setMatch(match);
}
return fmb.setInstructions(instructions).build();
}
示例3: installVerificationRule
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Installs the verification rule
*
* @param dpid datapathId of switch
* @param isBroadcast if broadcast then set a generic match; else specific to switch Id
* @return true if the command is accepted to be sent to switch, false otherwise - switch is disconnected or in
* SLAVE mode
*/
private boolean installVerificationRule(final DatapathId dpid, final boolean isBroadcast) {
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
Match match = matchVerification(sw, isBroadcast);
ArrayList<OFAction> actionList = new ArrayList<>(2);
actionList.add(actionSendToController(sw));
actionList.add(actionSetDstMac(sw, dpidToMac(sw)));
OFInstructionApplyActions instructionApplyActions = sw.getOFFactory().instructions()
.applyActions(actionList).createBuilder().build();
final long cookie = isBroadcast ? 0x8000000000000002L : 0x8000000000000003L;
OFFlowMod flowMod = buildFlowMod(sw, match, null, instructionApplyActions,
cookie, FlowModUtils.PRIORITY_VERY_HIGH);
String flowname = (isBroadcast) ? "Broadcast" : "Unicast";
flowname += "--VerificationFlow--" + dpid.toString();
return pushFlow(flowname, dpid, flowMod);
}
示例4: installEgressFlow
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ImmutablePair<Long, Boolean> installEgressFlow(final DatapathId dpid, String flowId, final Long cookie,
final int inputPort, final int outputPort,
final int transitVlanId, final int outputVlanId,
final OutputVlanType outputVlanType) {
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
// build match by input port and transit vlan id
Match match = matchFlow(sw, inputPort, transitVlanId);
// output action based on encap scheme
actionList.addAll(outputVlanTypeToOFActionList(sw, outputVlanId, outputVlanType));
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command, no meter
OFFlowMod flowMod = buildFlowMod(sw, match, null, actions,
cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
// send FLOW_MOD to the switch
boolean response = pushFlow(flowId, dpid, flowMod);
return new ImmutablePair<>(flowMod.getXid(), response);
}
示例5: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
private TrafficTreatment buildTreatment() {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
for (OFInstruction in : instructions) {
switch (in.getType()) {
case GOTO_TABLE:
builder.transition(((int) ((OFInstructionGotoTable) in)
.getTableId().getValue()));
break;
case WRITE_METADATA:
OFInstructionWriteMetadata m = (OFInstructionWriteMetadata) in;
builder.writeMetadata(m.getMetadata().getValue(),
m.getMetadataMask().getValue());
break;
case WRITE_ACTIONS:
builder.deferred();
buildActions(((OFInstructionWriteActions) in).getActions(),
builder);
break;
case APPLY_ACTIONS:
builder.immediate();
buildActions(((OFInstructionApplyActions) in).getActions(),
builder);
break;
case CLEAR_ACTIONS:
builder.wipeDeferred();
break;
case EXPERIMENTER:
break;
case METER:
break;
default:
log.warn("Unknown instructions type {}", in.getType());
}
}
return builder.build();
}
示例6: applyActionsFromString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionApplyActions to
* an OFInstructionApplyActions. The instruction will be set within the
* OFFlowMod.Builder provided. Notice nothing is returned, but the
* side effect is the addition of an instruction in the OFFlowMod.Builder.
* @param fmb; The FMB in which to append the new instruction
* @param instStr; The string to parse the instruction from
* @param log
*/
public static void applyActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Apply Actions Instruction not supported in OpenFlow 1.0");
return;
}
OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify();
OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions();
ActionUtils.fromString(tmpFmb, inst, log);
ib.setActions(tmpFmb.getActions());
log.debug("Appending ApplyActions instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions()); }
示例7: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
private TrafficTreatment buildTreatment() {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
// If this is a drop rule
if (instructions.size() == 0) {
builder.drop();
return builder.build();
}
for (OFInstruction in : instructions) {
switch (in.getType()) {
case GOTO_TABLE:
builder.transition(tableType);
break;
case WRITE_METADATA:
break;
case WRITE_ACTIONS:
builder.deferred();
buildActions(((OFInstructionWriteActions) in).getActions(),
builder);
break;
case APPLY_ACTIONS:
builder.immediate();
buildActions(((OFInstructionApplyActions) in).getActions(),
builder);
break;
case CLEAR_ACTIONS:
builder.wipeDeferred();
break;
case EXPERIMENTER:
break;
case METER:
break;
default:
log.warn("Unknown instructions type {}", in.getType());
}
}
return builder.build();
}
示例8: deleteflowentry
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* ɾ��ԭʼ������
* @param src
* @param entry
*/
private void deleteflowentry(DatapathId src,OFFlowStatsEntry entry){
OFFlowMod.Builder fmb = switchService.getSwitch(src).getOFFactory().buildFlowDelete();
fmb.setMatch(entry.getMatch())
//.setActions(entry.getActions())
.setActions(((OFInstructionApplyActions)entry.getInstructions().get(0)).getActions())
.setIdleTimeout(entry.getIdleTimeout())
.setHardTimeout(entry.getHardTimeout());
switchService.getSwitch(src).write(fmb.build());
}
示例9: applyActionsFromString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionApplyActions to
* an OFInstructionApplyActions. The instruction will be set within the
* OFFlowMod.Builder provided. Notice nothing is returned, but the
* side effect is the addition of an instruction in the OFFlowMod.Builder.
* @param fmb; The FMB in which to append the new instruction
* @param instStr; The string to parse the instruction from
* @param log
*/
public static void applyActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Apply Actions Instruction not supported in OpenFlow 1.0");
return;
}
OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify();
OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions();
ActionUtils.fromString(tmpFmb, inst, log);
ib.setActions(tmpFmb.getActions());
log.debug("Appending ApplyActions instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions()); }
示例10: getActions
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
public static List<OFAction> getActions(OFFlowStatsEntry e) {
if(e.getVersion() == OFVersion.OF_10) {
return e.getActions();
} else {
for(OFInstruction i: e.getInstructions()) {
if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
return ((OFInstructionApplyActions) i).getActions();
}
}
return ImmutableList.of();
}
}
示例11: serializeInstructionList
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
public static void serializeInstructionList(JsonGenerator jGen, List<OFInstruction> instructions) throws IOException, JsonProcessingException {
jGen.writeObjectFieldStart("instructions");
if (instructions.isEmpty()) {
jGen.writeStringField("none", "drop");
} else {
for (OFInstruction i : instructions) {
switch (i.getType()) {
case CLEAR_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_CLEAR_ACTIONS);
break;
case WRITE_METADATA:
jGen.writeObjectFieldStart(InstructionUtils.STR_WRITE_METADATA);
jGen.writeNumberField(InstructionUtils.STR_WRITE_METADATA, ((OFInstructionWriteMetadata)i).getMetadata().getValue());
jGen.writeNumberField(InstructionUtils.STR_WRITE_METADATA + "_mask", ((OFInstructionWriteMetadata)i).getMetadataMask().getValue());
break;
case EXPERIMENTER:
jGen.writeObjectFieldStart(InstructionUtils.STR_EXPERIMENTER);
jGen.writeNumberField(InstructionUtils.STR_EXPERIMENTER, ((OFInstructionExperimenter)i).getExperimenter());
break;
case GOTO_TABLE:
jGen.writeObjectFieldStart(InstructionUtils.STR_GOTO_TABLE);
jGen.writeNumberField(InstructionUtils.STR_GOTO_TABLE, ((OFInstructionGotoTable)i).getTableId().getValue());
break;
case METER:
jGen.writeObjectFieldStart(InstructionUtils.STR_GOTO_METER);
jGen.writeNumberField(InstructionUtils.STR_GOTO_METER, ((OFInstructionMeter)i).getMeterId());
break;
case APPLY_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_APPLY_ACTIONS);
OFActionListSerializer.serializeActions(jGen, ((OFInstructionApplyActions)i).getActions());
break;
case WRITE_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_WRITE_ACTIONS);
OFActionListSerializer.serializeActions(jGen, ((OFInstructionWriteActions)i).getActions());
default:
// shouldn't ever get here
break;
} // end switch on instruction
jGen.writeEndObject(); // end specific instruction
} // end for instructions
} // end process instructions (OF1.1+ only)
jGen.writeEndObject(); // end object (either has instructions or a "none":"drop" key:value as specified above)
}
示例12: serializeInstructionList
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
public static void serializeInstructionList(JsonGenerator jGen, List<OFInstruction> instructions) throws IOException, JsonProcessingException {
jGen.writeObjectFieldStart("instructions");
if (instructions.isEmpty()) {
jGen.writeStringField("none", "drop");
} else {
for (OFInstruction i : instructions) {
switch (i.getType()) {
case CLEAR_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_CLEAR_ACTIONS);
break;
case WRITE_METADATA:
jGen.writeStartObject();
jGen.writeNumberField(InstructionUtils.STR_WRITE_METADATA, ((OFInstructionWriteMetadata)i).getMetadata().getValue());
jGen.writeNumberField(InstructionUtils.STR_WRITE_METADATA + "_mask", ((OFInstructionWriteMetadata)i).getMetadataMask().getValue());
break;
case EXPERIMENTER:
jGen.writeStartObject();
jGen.writeNumberField(InstructionUtils.STR_EXPERIMENTER, ((OFInstructionExperimenter)i).getExperimenter());
break;
case GOTO_TABLE:
jGen.writeStartObject();
jGen.writeNumberField(InstructionUtils.STR_GOTO_TABLE, ((OFInstructionGotoTable)i).getTableId().getValue());
break;
case METER:
jGen.writeStartObject();
jGen.writeNumberField(InstructionUtils.STR_GOTO_METER, ((OFInstructionMeter)i).getMeterId());
break;
case APPLY_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_APPLY_ACTIONS);
OFActionListSerializer.serializeActions(jGen, ((OFInstructionApplyActions)i).getActions());
break;
case WRITE_ACTIONS:
jGen.writeObjectFieldStart(InstructionUtils.STR_WRITE_ACTIONS);
OFActionListSerializer.serializeActions(jGen, ((OFInstructionWriteActions)i).getActions());
default:
// shouldn't ever get here
break;
} // end switch on instruction
jGen.writeEndObject(); // end specific instruction
} // end for instructions
jGen.writeEndObject();
} // end process instructions (OF1.1+ only)
}
示例13: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
private TrafficTreatment buildTreatment() {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
for (OFInstruction in : instructions) {
switch (in.getType()) {
case GOTO_TABLE:
builder.transition(((int) ((OFInstructionGotoTable) in)
.getTableId().getValue()));
break;
case WRITE_METADATA:
OFInstructionWriteMetadata m = (OFInstructionWriteMetadata) in;
builder.writeMetadata(m.getMetadata().getValue(),
m.getMetadataMask().getValue());
break;
case WRITE_ACTIONS:
builder.deferred();
buildActions(((OFInstructionWriteActions) in).getActions(),
builder);
break;
case APPLY_ACTIONS:
builder.immediate();
buildActions(((OFInstructionApplyActions) in).getActions(),
builder);
break;
case CLEAR_ACTIONS:
builder.wipeDeferred();
break;
case STAT_TRIGGER:
OFInstructionStatTrigger statTrigger = (OFInstructionStatTrigger) in;
buildStatTrigger(statTrigger.getThresholds(), statTrigger.getFlags(), builder);
break;
case EXPERIMENTER:
break;
case METER:
break;
default:
log.warn("Unknown instructions type {}", in.getType());
}
}
return builder.build();
}
示例14: buildInstructionApplyActions
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Create an OFInstructionApplyActions which applies actions.
*
* @param sw switch object
* @param actionList OFAction list to apply
* @return {@link OFInstructionApplyActions}
*/
private static OFInstructionApplyActions buildInstructionApplyActions(IOFSwitch sw, List<OFAction> actionList) {
return sw.getOFFactory().instructions().applyActions(actionList).createBuilder().build();
}
示例15: applyActionsToString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; //导入依赖的package包/类
/**
* Convert an OFInstructionApplyActions to string form. The string will be formatted
* in a dpctl/ofctl-style syntax.
* @param inst; The instruction to convert to a string
* @param log
* @return
*/
public static String applyActionsToString(OFInstructionApplyActions inst, Logger log) throws Exception {
return ActionUtils.actionsToString(inst.getActions(), log);
}