本文整理汇总了Java中org.projectfloodlight.openflow.protocol.instruction.OFInstruction类的典型用法代码示例。如果您正苦于以下问题:Java OFInstruction类的具体用法?Java OFInstruction怎么用?Java OFInstruction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFInstruction类属于org.projectfloodlight.openflow.protocol.instruction包,在下文中一共展示了OFInstruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFlowMod
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的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();
}
示例2: appendInstruction
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
/**
* Adds the instructions to the list of OFInstructions in the OFFlowMod. Any pre-existing
* instruction of the same type is replaced with OFInstruction inst.
* @param fmb, the flow mod to append the instruction to
* @param inst, the instuction to append
*/
public static void appendInstruction(OFFlowMod.Builder fmb, OFInstruction inst) {
List<OFInstruction> newIl = new ArrayList<OFInstruction>();
List<OFInstruction> oldIl = fmb.getInstructions();
if (oldIl != null) { // keep any existing instructions that were added earlier
newIl.addAll(fmb.getInstructions());
}
for (OFInstruction i : newIl) { // remove any duplicates. Only one of each instruction.
if (i.getType() == inst.getType()) {
newIl.remove(i);
}
}
newIl.add(inst);
fmb.setInstructions(newIl);
}
示例3: appendInstruction
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
/**
* Adds the instructions to the list of OFInstructions in the OFFlowMod. Any pre-existing
* instruction of the same type is replaced with OFInstruction inst.
* @param fmb, the flow mod to append the instruction to
* @param inst, the instuction to append
*/
public static void appendInstruction(OFFlowMod.Builder fmb, OFInstruction inst) {
List<OFInstruction> newIl = new ArrayList<OFInstruction>();
List<OFInstruction> oldIl = fmb.getInstructions();
if (oldIl != null) { // keep any existing instructions that were added earlier
newIl.addAll(fmb.getInstructions());
}
for (OFInstruction i : newIl) { // remove any duplicates. Only one of each instruction.
if (i.getType() == inst.getType()) {
newIl.remove(i);
}
}
newIl.add(inst);
fmb.setInstructions(newIl);
}
示例4: getInstructions
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
private List<OFInstruction> getInstructions(OFFlowMod entry) {
switch (entry.getVersion()) {
case OF_10:
return Lists.newArrayList(OFFactoryVer13.INSTANCE.instructions()
.applyActions(
entry.getActions()));
case OF_11:
case OF_12:
case OF_13:
case OF_14:
case OF_15:
return entry.getInstructions();
default:
log.warn("Unknown OF version {}", entry.getVersion());
}
return Lists.newLinkedList();
}
示例5: getInstructions
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
private List<OFInstruction> getInstructions(OFFlowMod entry) {
switch (entry.getVersion()) {
case OF_10:
return Lists.newArrayList(OFFactoryVer13.INSTANCE.instructions()
.applyActions(
entry.getActions()));
case OF_11:
case OF_12:
case OF_13:
return entry.getInstructions();
default:
log.warn("Unknown OF version {}", entry.getVersion());
}
return Lists.newLinkedList();
}
示例6: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的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();
}
示例7: setActions
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
/**
* Sets the actions in fmb according to the sw version.
*
* @param fmb the FlowMod Builder that is being built
* @param actions the actions to set
* @param sw the switch that will receive the FlowMod
*/
public static void setActions(OFFlowMod.Builder fmb,
List<OFAction> actions, IOFSwitch sw) {
if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_11) >= 0) {
// Instructions are used starting in OF 1.1
fmb.setInstructions(Collections.singletonList((OFInstruction) sw
.getOFFactory().instructions().applyActions(actions)));
} else {
// OF 1.0 only supports actions
fmb.setActions(actions);
}
}
示例8: setActions
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
/**
* Sets the actions in fmb according to the sw version.
*
* @param fmb the FlowMod Builder that is being built
* @param actions the actions to set
* @param sw the switch that will receive the FlowMod
*/
public static void setActions(OFFlowMod.Builder fmb,
List<OFAction> actions, IOFSwitch sw) {
if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_11) >= 0) {
// Instructions are used starting in OF 1.1
fmb.setInstructions(Collections.singletonList((OFInstruction) sw
.getOFFactory().instructions().applyActions(actions)));
} else {
// OF 1.0 only supports actions
fmb.setActions(actions);
}
}
示例9: transformAndSendMsg
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
@Override
public void transformAndSendMsg(OFMessage msg, TableType type) {
if (msg.getType() == OFType.FLOW_MOD) {
OFFlowMod flowMod = (OFFlowMod) msg;
OFFlowMod.Builder builder = flowMod.createBuilder();
List<OFInstruction> instructions = flowMod.getInstructions();
List<OFInstruction> newInstructions = Lists.newArrayList();
for (OFInstruction i : instructions) {
if (i instanceof OFInstructionGotoTable) {
OFInstructionGotoTable gotoTable = (OFInstructionGotoTable) i;
TableType tid = TableType.values()[gotoTable.getTableId().getValue()];
newInstructions.add(
gotoTable.createBuilder()
.setTableId(getTableId(tid)).build());
} else {
newInstructions.add(i);
}
}
builder.setTableId(getTableId(type));
builder.setInstructions(newInstructions);
OFMessage msgnew = builder.build();
channel.write(Collections.singletonList(msgnew));
log.trace("Installed {}", msgnew);
} else {
channel.write(Collections.singletonList(msg));
}
}
示例10: buildFlowAdd
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
@Override
public OFFlowAdd buildFlowAdd() {
Match match = buildMatch();
List<OFAction> deferredActions = buildActions(treatment.deferred());
List<OFAction> immediateActions = buildActions(treatment.immediate());
List<OFInstruction> instructions = Lists.newLinkedList();
if (immediateActions.size() > 0) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
if (deferredActions.size() > 0) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
instructions.add(buildTableGoto(treatment.tableTransition()));
}
long cookie = flowRule().id().value();
OFFlowAdd fm = factory().buildFlowAdd()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setInstructions(instructions)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().type().ordinal()))
.build();
return fm;
}
示例11: buildFlowMod
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowMod() {
Match match = buildMatch();
List<OFAction> deferredActions = buildActions(treatment.deferred());
List<OFAction> immediateActions = buildActions(treatment.immediate());
List<OFInstruction> instructions = Lists.newLinkedList();
if (immediateActions.size() > 0) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
if (deferredActions.size() > 0) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
instructions.add(buildTableGoto(treatment.tableTransition()));
}
long cookie = flowRule().id().value();
OFFlowMod fm = factory().buildFlowModify()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setInstructions(instructions)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().type().ordinal()))
.build();
return fm;
}
示例12: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的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();
}
示例13: getActions
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的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();
}
}
示例14: buildFlowAdd
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowAdd() {
Match match = buildMatch();
List<OFAction> deferredActions = buildActions(treatment.deferred());
List<OFAction> immediateActions = buildActions(treatment.immediate());
List<OFInstruction> instructions = Lists.newLinkedList();
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
if (immediateActions.size() > 0) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (deferredActions.size() > 0) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
instructions.add(buildTableGoto(treatment.tableTransition()));
}
if (treatment.writeMetadata() != null) {
instructions.add(buildMetadata(treatment.writeMetadata()));
}
if (treatment.metered() != null) {
instructions.add(buildMeter(treatment.metered()));
}
long cookie = flowRule().id().value();
OFFlowAdd fm = factory().buildFlowAdd()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setInstructions(instructions)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
}
示例15: buildFlowMod
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowMod() {
Match match = buildMatch();
List<OFAction> deferredActions = buildActions(treatment.deferred());
List<OFAction> immediateActions = buildActions(treatment.immediate());
List<OFInstruction> instructions = Lists.newLinkedList();
if (immediateActions.size() > 0) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
if (deferredActions.size() > 0) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
instructions.add(buildTableGoto(treatment.tableTransition()));
}
if (treatment.writeMetadata() != null) {
instructions.add(buildMetadata(treatment.writeMetadata()));
}
if (treatment.metered() != null) {
instructions.add(buildMeter(treatment.metered()));
}
long cookie = flowRule().id().value();
OFFlowMod fm = factory().buildFlowModify()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setInstructions(instructions)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
}