本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFActionType类的典型用法代码示例。如果您正苦于以下问题:Java OFActionType类的具体用法?Java OFActionType怎么用?Java OFActionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFActionType类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFActionType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapAction
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
if (action.getType().equals(OFActionType.SET_FIELD)) {
OFActionSetField setFieldAction = (OFActionSetField) action;
OFOxm<?> oxm = setFieldAction.getField();
switch (oxm.getMatchField().id) {
case VLAN_VID:
OFOxmVlanVid vlanVid = (OFOxmVlanVid) oxm;
return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid.getValue().getRawVid()));
default:
throw new UnsupportedOperationException(
"Driver does not support extension type " + oxm.getMatchField().id);
}
}
throw new UnsupportedOperationException(
"Unexpected OFAction: " + action.toString());
}
示例2: serializeFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
/* Common to All OF Versions */
jGen.writeStringField("capabilities", fr.getCapabilities().toString());
jGen.writeStringField("dpid", fr.getDatapathId().toString());
jGen.writeNumberField("buffers", fr.getNBuffers());
jGen.writeNumberField("tables", fr.getNTables());
jGen.writeStringField("version", fr.getVersion().toString());
if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
serializePortDesc(fr.getPorts(), jGen);
}
if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
String actions = "[";
for (OFActionType action : fr.getActions()) {
actions = actions + action.toString() + ", ";
}
actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
actions = actions + "]";
jGen.writeStringField("actions", actions);
}
}
示例3: SwitchSyncRepresentation
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
/**
* @param dpid
* @param buffers
* @param tables
* @param capabilities
* @param actions
* @param ports
* @param manufacturerDescription
* @param hardwareDescription
* @param softwareDescription
* @param serialNumber
* @param datapathDescription
*/
@JsonCreator
public SwitchSyncRepresentation(
@JsonProperty("dpid") DatapathId dpid,
@JsonProperty("buffers") int buffers,
@JsonProperty("tables") byte tables,
@JsonProperty("capabilities") Set<OFCapabilities> capabilities,
@JsonProperty("actions") Set<OFActionType> actions,
@JsonProperty("ports") List<SyncedPort> ports,
@JsonProperty("manufacturerDescription") String manufacturerDescription,
@JsonProperty("hardwareDescription") String hardwareDescription,
@JsonProperty("softwareDescription") String softwareDescription,
@JsonProperty("serialNumber") String serialNumber,
@JsonProperty("datapathDescription") String datapathDescription) {
this.dpid = dpid;
this.buffers = buffers;
this.tables = tables;
this.capabilities = capabilities;
this.actions = actions;
this.ports = ports;
this.manufacturerDescription = manufacturerDescription;
this.hardwareDescription = hardwareDescription;
this.softwareDescription = softwareDescription;
this.serialNumber = serialNumber;
this.datapathDescription = datapathDescription;
}
示例4: getFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
/**
* FIXME Icky work around; if a null actions got written to storage
* then fake up an empty one so the builder() doesn't throw
* a NPE. Need to root cause why someone would write a null actions.
* This code will all be removed shortly -- needed to unblock BVS team.
*/
Set<OFActionType> workAroundActions;
if (actions != null)
workAroundActions = actions;
else
workAroundActions = Collections.<OFActionType> emptySet();
OFFeaturesReply featuresReply = factory.buildFeaturesReply()
.setXid(0)
.setDatapathId(dpid)
.setNBuffers(buffers)
.setNTables(tables)
.setCapabilities(capabilities)
.setActions(workAroundActions)
.setPorts(toOFPortDescList(factory, ports))
.build();
return featuresReply;
}
示例5: serializeFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
/* Common to All OF Versions */
jGen.writeStringField("capabilities", fr.getCapabilities().toString());
jGen.writeStringField("dpid", fr.getDatapathId().toString());
jGen.writeNumberField("buffers", fr.getNBuffers());
jGen.writeNumberField("tables", fr.getNTables());
jGen.writeStringField("version", fr.getVersion().toString());
if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
serializePortDesc(fr.getPorts(), jGen);
}
if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
String actions = "[";
for (OFActionType action : fr.getActions()) {
actions = actions + action.toString() + ", ";
}
actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
actions = actions + "]";
jGen.writeStringField("actions", actions);
}
}
示例6: sendOFGroupModDelMemberMsg
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
protected void sendOFGroupModDelMemberMsg(IOFSwitch sw, OFPort destPort) {
/* removes member port form the group*/
OFBucket ofb = multicastGroup.removeMemberOFBucket(sw.getId(), destPort);
/* prepares a modify object sends it to the switch */
pushOFModifyGroup(sw);
long queueId = -1;
for (OFAction ofa: ofb.getActions()){
if (ofa.getType() == OFActionType.SET_QUEUE){
OFActionSetQueue ofas = (OFActionSetQueue) ofa;
queueId = ofas.getQueueId();
}
}
/* removes queue using OVSDBContext on the switch */
OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId());
ovsdbContext.deleteQueueOnPort(destPort, (int)queueId);
}
示例7: serializeFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
/* Common to All OF Versions */
jGen.writeStringField("capabilities", fr.getCapabilities().toString());
jGen.writeStringField("dpid", fr.getDatapathId().toString());
jGen.writeNumberField("buffers", fr.getNBuffers());
jGen.writeNumberField("tables", fr.getNTables());
jGen.writeStringField("version", fr.getVersion().toString());
if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
serializePortDesc(fr.getPorts(), jGen);
}
if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
String actions = "[";
for (OFActionType action : fr.getActions()) {
actions = actions + action.toString() + ", ";
}
actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
actions = actions + "]";
jGen.writeStringField("actions", actions);
}
}
示例8: applyFlowMods
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
/**
* Applies all applicable FlowMods from a list of given FlowMods to the given Ethernet packet. The wrapperMessage is necessary for FlowMods that match on the InPort.
*
* @param flowMods The list of flowmods to apply.
* @param original The packet to apply them to.
* @param wrapperMessage The PakcetIn message that caused this. Needed for FlowMods that match on the InPort.
* @return The modified packet.
*/
public static Ethernet applyFlowMods(final List<OFFlowMod> flowMods, Ethernet original, OFPacketIn wrapperMessage) {
OFFlowMod matchingFlowMod = getFirstMatchingFlowMod(flowMods, original, wrapperMessage);
Ethernet modified = (Ethernet) original.clone();
List<OFFlowMod> appliedFlowMods = new ArrayList<>();
while (matchingFlowMod != null && !appliedFlowMods.contains(matchingFlowMod)) {
modified = (Ethernet) modified.clone();
for (OFAction action : matchingFlowMod.getActions()) {
if (action.getType() == OFActionType.SET_TP_SRC) {
((TCP) modified.getPayload().getPayload()).setSourcePort((short) ((OFActionSetTpSrc) action).getTpPort().getPort());
} else if (action.getType() == OFActionType.SET_TP_DST) {
((TCP) modified.getPayload().getPayload()).setDestinationPort((short) ((OFActionSetTpDst) action).getTpPort().getPort());
}
// TODO support more actions
}
appliedFlowMods.add(matchingFlowMod);
matchingFlowMod = getFirstMatchingFlowMod(flowMods, modified, wrapperMessage);
}
return modified;
}
示例9: serializeActions
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
public void serializeActions(Set<OFActionType> actions, JsonGenerator jGen)
throws IOException, JsonProcessingException {
if ( null == actions)
jGen.writeStringField("actions","null");
else{
jGen.writeFieldName("actions");
jGen.writeStartArray();
for(OFActionType action : actions){
jGen.writeString(action.toString());
}
jGen.writeEndArray();
}
}
示例10: setUpFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
public void setUpFeaturesReply() {
portDesc = factory.buildPortDesc()
.setName("Eth1")
.setPortNo(OFPort.of(1))
.build();
featuresReply = factory.buildFeaturesReply()
.setDatapathId(DatapathId.of(0x42L))
.setNBuffers(1)
.setNTables((short)1)
.setCapabilities(EnumSet.<OFCapabilities>of(OFCapabilities.FLOW_STATS, OFCapabilities.TABLE_STATS))
.setActions(EnumSet.<OFActionType>of(OFActionType.SET_VLAN_PCP))
.setPorts(ImmutableList.<OFPortDesc>of(portDesc))
.build();
}
示例11: getFeaturesReply
import org.projectfloodlight.openflow.protocol.OFActionType; //导入依赖的package包/类
@Override
OFFeaturesReply getFeaturesReply() {
OFPortDesc portDesc = factory.buildPortDesc()
.setName("Eth1")
.setPortNo(OFPort.of(1))
.build();
return factory.buildFeaturesReply()
.setDatapathId(dpid)
.setNBuffers(1)
.setNTables((short)1)
.setCapabilities(EnumSet.<OFCapabilities>of(OFCapabilities.FLOW_STATS, OFCapabilities.TABLE_STATS))
.setActions(EnumSet.<OFActionType>of(OFActionType.SET_VLAN_PCP))
.setPorts(ImmutableList.<OFPortDesc>of(portDesc))
.build();
}