本文整理汇总了Java中org.projectfloodlight.openflow.protocol.instruction.OFInstruction.getType方法的典型用法代码示例。如果您正苦于以下问题:Java OFInstruction.getType方法的具体用法?Java OFInstruction.getType怎么用?Java OFInstruction.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.protocol.instruction.OFInstruction
的用法示例。
在下文中一共展示了OFInstruction.getType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例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: 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();
}
示例4: 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();
}
示例5: 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();
}
}
示例6: serializeInstructionList
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入方法依赖的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)
}
示例7: serializeInstructionList
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; //导入方法依赖的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)
}
示例8: 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 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();
}