本文整理汇总了Java中org.openflow.protocol.action.OFAction类的典型用法代码示例。如果您正苦于以下问题:Java OFAction类的具体用法?Java OFAction怎么用?Java OFAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFAction类属于org.openflow.protocol.action包,在下文中一共展示了OFAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTo
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
this.match.writeTo(data);
data.writeLong(cookie);
data.writeShort(command);
data.writeShort(idleTimeout);
data.writeShort(hardTimeout);
data.writeShort(priority);
data.writeInt(bufferId);
data.writeShort(outPort);
data.writeShort(flags);
if (actions != null) {
for (OFAction action : actions) {
action.writeTo(data);
}
}
}
示例2: writeTo
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
@Override
public void writeTo(ChannelBuffer data) {
data.writeShort(this.length);
data.writeByte(this.tableId);
data.writeByte((byte) 0);
this.match.writeTo(data);
data.writeInt(this.durationSeconds);
data.writeInt(this.durationNanoseconds);
data.writeShort(this.priority);
data.writeShort(this.idleTimeout);
data.writeShort(this.hardTimeout);
data.writeInt(0); // pad
data.writeShort((short)0); // pad
data.writeLong(this.cookie);
data.writeLong(this.packetCount);
data.writeLong(this.byteCount);
if (actions != null) {
for (OFAction action : actions) {
action.writeTo(data);
}
}
}
示例3: testCustomVendorAction
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public void testCustomVendorAction() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
byte[] deadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
ChannelBuffer buf = ChannelBuffers.copiedBuffer(deadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,deadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be MockVendorAction, but is "+ofAction.getClass(), ofAction instanceof MockVendorAction);
assertArrayEquals( new byte[] { 1,2,3,4,5,6,7,8}, ((MockVendorAction)ofAction).getMockData());
}
示例4: testGenericVendorAction
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public void testGenericVendorAction() throws MessageParseException {
byte[] nonDeadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0x7e, (byte) 0xe7, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
BasicFactory factory = BasicFactory.getInstance();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
ChannelBuffer buf = ChannelBuffers.copiedBuffer(nonDeadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,nonDeadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be OFActionVendorGeneric, but is "+ofAction.getClass(), ofAction instanceof OFActionVendorGeneric);
}
示例5: testCustomVendorAction
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public void testCustomVendorAction() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
byte[] deadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
ChannelBuffer buf = ChannelBuffers.copiedBuffer(deadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,deadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be MockVendorAction, but is "+ofAction.getClass(), ofAction instanceof MockVendorAction);
assertArrayEquals( new byte[] { 1,2,3,4,5,6,7,8}, ((MockVendorAction)ofAction).getMockData());
}
示例6: writeTo
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
@Override
public void writeTo(final ChannelBuffer data) {
data.writeShort(this.length);
data.writeByte(this.tableId);
data.writeByte((byte) 0);
this.match.writeTo(data);
data.writeInt(this.durationSeconds);
data.writeInt(this.durationNanoseconds);
data.writeShort(this.priority);
data.writeShort(this.idleTimeout);
data.writeShort(this.hardTimeout);
data.writeInt(0); // pad
data.writeShort((short) 0); // pad
data.writeLong(this.cookie);
data.writeLong(this.packetCount);
data.writeLong(this.byteCount);
if (this.actions != null) {
for (final OFAction action : this.actions) {
action.writeTo(data);
}
}
}
示例7: testIsFlowModAllowedSimple
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
@Test
public void testIsFlowModAllowedSimple(){
OFFlowMod flow = new OFFlowMod();
OFMatch match = new OFMatch();
match.setInputPort((short)1);
match.setDataLayerVirtualLan((short)1000);
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_VLAN));
match.setWildcards(match.getWildcardObj().matchOn(Flag.IN_PORT));
flow.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionVirtualLanIdentifier setVid = new OFActionVirtualLanIdentifier();
setVid.setVirtualLanIdentifier((short)102);
OFActionOutput output = new OFActionOutput();
output.setPort((short)2);
actions.add(setVid);
actions.add(output);
flow.setActions(actions);
List <OFFlowMod> flows = slicer.allowedFlows(flow);
assertTrue("flows is the right size", flows.size() == 1);
assertEquals("flow was allowed and matches", flow, flows.get(0));
}
示例8: createPacketOut
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
private OFPacketOut createPacketOut() {
//["packet", {"outport": 1, "protocol": 2, "header_len": 14, "inport": 2,
// "dstip": [49, 48, 46, 48, 46, 48, 46, 49],
// "srcmac": [99, 101, 58, 97, 56, 58, 100, 100, 58, 99, 102, 58, 49, 99, 58, 97, 101], "dstmac": [99, 101, 58, 97, 54, 58, 99, 51, 58, 100, 100, 58, 56, 57, 58, 99, 51],
// "raw": [206, 166, 195, 221, 137, 195, 206, 168, 221, 207, 28, 174, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 206, 168, 221, 207, 28, 174, 10, 0, 0, 2, 206, 166, 195, 221, 137, 195, 10, 0, 0, 1],
// "payload_len": 42, "switch": 1, "ethtype": 2054, "srcip": [49, 48, 46, 48, 46, 48, 46, 50] }] + TERM_CHAR
OFPacketOut packetOut = new OFPacketOut();
packetOut.setBufferId(10);
packetOut.setInPort((short)2);
packetOut.setPacketData(new byte[] {28, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 28, 10, 0, 0, 2, 10, 0, 0, 1});
BasicFactory factory = new BasicFactory();
packetOut.setActionFactory(factory.getActionFactory());
List<OFAction> actions = new ArrayList<OFAction>();
OFAction action = new OFActionOutput((short)3);
actions.add(action);
packetOut.setActions(actions);
return packetOut;
}
示例9: unsetLinkFields
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
/**
* Gets a list of actions based on the original MAC addresses.
*
* @return list of actions
*/
public List<OFAction> unsetLinkFields() {
final List<OFAction> actions = new LinkedList<OFAction>();
final OVXLinkField linkField = OpenVirteXController.getInstance()
.getOvxLinkField();
if (linkField == OVXLinkField.MAC_ADDRESS) {
LinkedList<MACAddress> macList;
try {
macList = this.getOriginalMacAddresses();
actions.add(new OFActionDataLayerSource(macList.get(0)
.toBytes()));
actions.add(new OFActionDataLayerDestination(macList.get(1)
.toBytes()));
} catch (NetworkMappingException e) {
OVXLinkUtils.log.error("Unable to restore actions: " + e);
}
} else {
if (linkField == OVXLinkField.VLAN) {
OVXLinkUtils.log
.warn("Unable to restore actions, VLANs not supported");
// actions.add(new
// OFActionVirtualLanIdentifier(getOriginalVlan()));
}
}
return actions;
}
示例10: testGenericVendorAction
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public void testGenericVendorAction() throws MessageParseException {
byte[] nonDeadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0x7e, (byte) 0xe7, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
BasicFactory factory = new BasicFactory();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
ChannelBuffer buf = ChannelBuffers.copiedBuffer(nonDeadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,nonDeadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be OFActionVendorGeneric, but is "+ofAction.getClass(), ofAction instanceof OFActionVendorGeneric);
}
示例11: virtualize
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
@Override
public void virtualize(final OVXSwitch sw,
final List<OFAction> approvedActions, final OVXMatch match)
throws ActionVirtualizationDenied {
/*final MACAddress mac = MACAddress.valueOf(this.dataLayerAddress);
try {
final Integer tid = sw.getMap().getMAC(mac);
if (tid != sw.getTenantId()) {
throw new ActionVirtualizationDenied("Target mac " + mac
+ " is not in virtual network " + sw.getTenantId(),
OFBadActionCode.OFPBAC_EPERM);
}
approvedActions.add(this);
} catch (AddressMappingException e) {
throw new ActionVirtualizationDenied("Target mac " + mac
+ " is not in virtual network " + sw.getTenantId(),
OFBadActionCode.OFPBAC_EPERM);
}*/
approvedActions.add(this);
}
示例12: prependRewriteActions
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public static List<OFAction> prependRewriteActions(final Integer tenantId,
final OFMatch match) {
final List<OFAction> actions = new LinkedList<OFAction>();
if (!match.getWildcardObj().isWildcarded(Flag.NW_SRC)) {
final OVXActionNetworkLayerSource srcAct = new OVXActionNetworkLayerSource();
srcAct.setNetworkAddress(getPhysicalIp(tenantId,
match.getNetworkSource()));
actions.add(srcAct);
}
if (!match.getWildcardObj().isWildcarded(Flag.NW_DST)) {
final OVXActionNetworkLayerDestination dstAct = new OVXActionNetworkLayerDestination();
dstAct.setNetworkAddress(getPhysicalIp(tenantId,
match.getNetworkDestination()));
actions.add(dstAct);
}
return actions;
}
示例13: toMap
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public Map<String, Object> toMap() {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
if (this.match != null) {
map.put("match", new OVXMatch(match).toMap());
}
LinkedList<Map<String, Object>> actions = new LinkedList<Map<String, Object>>();
for (OFAction act : this.actions) {
try {
actions.add(OVXUtil.actionToMap(act));
} catch (UnknownActionException e) {
log.warn("Ignoring action {} because {}", act, e.getMessage());
}
}
map.put("actionsList", actions);
map.put("priority", String.valueOf(this.priority));
return map;
}
示例14: actApplyMatch
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public static OFMatch actApplyMatch(OFMatch match, List<OFAction> actions) {
OFMatch m = match.clone();
for (OFAction action : actions) {
if (action instanceof OFActionNetworkLayerDestination) {
OFActionNetworkLayerDestination modNwDst = (OFActionNetworkLayerDestination) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_NW_DST_MASK);
m.setNetworkDestination(modNwDst.getNetworkAddress());
} else if (action instanceof OFActionDataLayerSource) {
OFActionDataLayerSource modDataSrc = (OFActionDataLayerSource) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_DL_SRC);
m.setDataLayerSource(modDataSrc.getDataLayerAddress());
} else if (action instanceof OFActionDataLayerDestination) {
OFActionDataLayerDestination modDataDst = (OFActionDataLayerDestination) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_DL_DST);
m.setDataLayerDestination(modDataDst.getDataLayerAddress());
}
}
return m;
}
示例15: actRevertMatch
import org.openflow.protocol.action.OFAction; //导入依赖的package包/类
public static OFMatch actRevertMatch(OFMatch match, List<OFAction> actions) {
OFMatch m = match.clone();
for (OFAction action : actions) {
if (action instanceof OFActionNetworkLayerDestination) {
OFActionNetworkLayerDestination modNwDst = (OFActionNetworkLayerDestination) action;
int mask = m.getWildcards() & OFMatch.OFPFW_NW_DST_MASK;
int shift = Math.min(mask >> OFMatch.OFPFW_NW_DST_SHIFT, 32);
int ip1 = (m.getNetworkDestination() >> shift) << shift;
int ip2 = (modNwDst.getNetworkAddress() >> shift) << shift;
if (shift == 32 || ip1 == ip2) {
m.setWildcards(m.getWildcards() | OFMatch.OFPFW_NW_DST_ALL);
m.setNetworkDestination(0);
}
else {
return null;
}
} else if (action instanceof OFActionDataLayerSource) {
m.setWildcards(m.getWildcards() | OFMatch.OFPFW_DL_SRC);
m.setDataLayerSource(HexString.fromHexString("00:00:00:00:00:00"));
} else if (action instanceof OFActionDataLayerDestination) {
m.setWildcards(m.getWildcards() | OFMatch.OFPFW_DL_DST);
m.setDataLayerDestination(HexString.fromHexString("00:00:00:00:00:00"));
}
}
return m;
}