本文整理汇总了Java中org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable类的典型用法代码示例。如果您正苦于以下问题:Java OFInstructionGotoTable类的具体用法?Java OFInstructionGotoTable怎么用?Java OFInstructionGotoTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFInstructionGotoTable类属于org.projectfloodlight.openflow.protocol.instruction包,在下文中一共展示了OFInstructionGotoTable类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gotoTableFromString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionGotoTable to
* an OFInstructionGotoTable. 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 gotoTableFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (inst == null || inst.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();
// Get the table ID
if (inst.startsWith("0x")) {
ib.setTableId(TableId.of(Integer.parseInt(inst.replaceFirst("0x", ""), 16)));
} else {
ib.setTableId(TableId.of(Integer.parseInt(inst))).build();
}
log.debug("Appending GotoTable instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions());
}
示例2: gotoTableFromString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionGotoTable to
* an OFInstructionGotoTable. 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 gotoTableFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (inst == null || inst.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();
// Get the table ID
if (inst.startsWith("0x")) {
ib.setTableId(TableId.of(Integer.parseInt(inst.replaceFirst("0x", ""), 16)));
} else {
ib.setTableId(TableId.of(Integer.parseInt(inst))).build();
}
log.debug("Appending GotoTable instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions());
}
示例3: gotoTableFromString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionGotoTable to
* an OFInstructionGotoTable. 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 gotoTableFromString(OFFlowMod.Builder fmb, String instStr, Logger log) {
if (instStr == null || instStr.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
// Split into pairs of key=value
String[] keyValue = instStr.split("=");
if (keyValue.length != 2) {
throw new IllegalArgumentException("[Key, Value] " + keyValue + " does not have form 'key=value' parsing " + instStr);
}
OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();
ib.setTableId(TableId.of(Integer.parseInt(keyValue[1]))).build();
log.debug("Appending GotoTable instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions()); }
示例4: buildTreatment
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的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();
}
示例5: transformAndSendMsg
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的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));
}
}
示例6: serializeInstructionList
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的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.OFInstructionGotoTable; //导入依赖的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.OFInstructionGotoTable; //导入依赖的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();
}
示例9: gotoTableToString
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; //导入依赖的package包/类
/**
* Convert an OFInstructionGotoTable 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 gotoTableToString(OFInstructionGotoTable inst, Logger log) {
return Short.toString(inst.getTableId().getValue());
}