本文整理汇总了Java中org.openflow.protocol.action.OFActionType类的典型用法代码示例。如果您正苦于以下问题:Java OFActionType类的具体用法?Java OFActionType怎么用?Java OFActionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFActionType类属于org.openflow.protocol.action包,在下文中一共展示了OFActionType类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAll
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
private void testAll(OFActionTunnelDstIP tip) {
assertEquals(OFActionType.VENDOR, tip.getType());
assertEquals(2, tip.getSubtype());
assertEquals(16, tip.getLength());
assertEquals(0x005c16c7, tip.getVendor());
tip.setTunnelDstIP(24);
assertEquals(24, tip.getTunnelDstIP());
// Test wire format
int ip = IPv4.toIPv4Address("17.33.49.65");
tip.setTunnelDstIP(ip);
ChannelBuffer buf = ChannelBuffers.buffer(32);
tip.writeTo(buf);
ChannelBuffer buf2 = buf.copy();
assertEquals(16, buf.readableBytes());
byte fromBuffer[] = new byte[16];
buf.readBytes(fromBuffer);
assertArrayEquals(expectedWireFormat1, fromBuffer);
OFActionTunnelDstIP act2 = new OFActionTunnelDstIP();
act2.readFrom(buf2);
assertEquals(tip, act2);
}
示例2: getLocalPort
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* Checks if provided Port is local Port
*
* @param port
* @return true --> port is local
*/
private OFPhysicalPort getLocalPort(OFPacketOut po) {
// Action port check
short port = (short) -42;
if (po.getActions().size() == 1) {
OFAction action = po.getActions().get(0);
if (action.getType().equals(OFActionType.OUTPUT)) {
OFActionOutput outputAction = (OFActionOutput) action;
port = outputAction.getPort();
}
}
List<OFPhysicalPort> phyPorts = this.feat_reply.getPorts();
for (OFPhysicalPort phyPort : phyPorts) {
if (phyPort.getPortNumber() == port) {
return phyPort;
}
}
return null;
}
示例3: testAllowedPacketOutALL
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* tests packetOut event slicing
*/
@Test
public void testAllowedPacketOutALL(){
OFPacketOut out = new OFPacketOut();
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setType(OFActionType.OUTPUT);
output.setPort(OFPort.OFPP_ALL.getValue());
actions.add(output);
out.setActions(actions);
Ethernet pkt = new Ethernet();
pkt.setVlanID((short)1000);
pkt.setDestinationMACAddress("aa:bb:cc:dd:ee:ff");
pkt.setSourceMACAddress("ff:ee:dd:cc:bb:aa");
pkt.setEtherType((short)35020);
out.setPacketData(pkt.serialize());
List<OFMessage> outPackets = slicer.allowedPacketOut(out);
assertTrue("OutPacket size is correct, expected 5 got " + outPackets.size(), outPackets.size() == 5);
}
示例4: testMapping
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
@Test
public void testMapping() throws Exception {
TestCase.assertEquals(OFActionType.OUTPUT,
OFActionType.valueOf((short) 0));
TestCase.assertEquals(OFActionType.OPAQUE_ENQUEUE,
OFActionType.valueOf((short) 11));
TestCase.assertEquals(OFActionType.VENDOR,
OFActionType.valueOf((short) 0xffff));
}
示例5: testAction
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
@Test
public void testAction() {
ChannelBuffer buf = ChannelBuffers.buffer(32);
OFActionNiciraTtlDecrement act = new OFActionNiciraTtlDecrement();
assertEquals(true, act instanceof OFActionNiciraVendor);
assertEquals(true, act instanceof OFActionVendor);
assertEquals(true, act instanceof OFAction);
act.writeTo(buf);
ChannelBuffer buf2 = buf.copy();
assertEquals(16, buf.readableBytes());
byte fromBuffer[] = new byte[16];
buf.readBytes(fromBuffer);
assertArrayEquals(expectedWireFormat, fromBuffer);
// Test parsing. TODO: we don't really have the proper parsing
// infrastructure....
OFActionNiciraVendor act2 = new OFActionNiciraTtlDecrement();
act2.readFrom(buf2);
assertEquals(act, act2);
assertNotSame(act, act2);
assertEquals(OFActionType.VENDOR, act2.getType());
assertEquals(16, act2.getLength());
assertEquals(OFActionNiciraVendor.NICIRA_VENDOR_ID, act2.getVendor());
assertEquals((short)18, act2.getSubtype());
}
示例6: parseActionOne
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
private OFAction parseActionOne(final OFActionType type,
final ChannelBuffer data) {
OFAction ofa;
data.markReaderIndex();
ofa = this.getAction(type);
ofa.readFrom(data);
if (type == OFActionType.VENDOR) {
final OFActionVendor vendorAction = (OFActionVendor) ofa;
final OFVendorActionFactory vendorActionFactory = this.vendorActionRegistry
.get(vendorAction.getVendor());
if (vendorActionFactory != null) {
// if we have a specific vendorActionFactory for this vendor id,
// delegate to it for vendor-specific reparsing of the message
data.resetReaderIndex();
final OFActionVendor newAction = vendorActionFactory
.readFrom(data);
if (newAction != null) {
ofa = newAction;
}
}
}
if (OFAction.class.equals(ofa.getClass())) {
// advance the position for un-implemented messages
data.readerIndex(data.readerIndex() + ofa.getLengthU()
- OFAction.MINIMUM_LENGTH);
}
return ofa;
}
示例7: createLLDPPacketOut
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* Creates packet_out LLDP for specified output port.
*
* @param port the port
* @return Packet_out message with LLDP data
* @throws PortMappingException
*/
private OFPacketOut createLLDPPacketOut(final PhysicalPort port)
throws PortMappingException {
if (port == null) {
throw new PortMappingException(
"Cannot send LLDP associated with a nonexistent port");
}
final OFPacketOut packetOut = (OFPacketOut) this.ovxMessageFactory
.getMessage(OFType.PACKET_OUT);
packetOut.setBufferId(OFPacketOut.BUFFER_ID_NONE);
final List<OFAction> actionsList = new LinkedList<OFAction>();
final OFActionOutput out = (OFActionOutput) this.ovxMessageFactory
.getAction(OFActionType.OUTPUT);
out.setPort(port.getPortNumber());
actionsList.add(out);
packetOut.setActions(actionsList);
final short alen = SwitchDiscoveryManager.countActionsLen(actionsList);
this.lldpPacket.setPort(port);
this.ethPacket.setSourceMACAddress(port.getHardwareAddress());
final byte[] lldp = this.ethPacket.serialize();
packetOut.setActionsLength(alen);
packetOut.setPacketData(lldp);
packetOut
.setLength((short) (OFPacketOut.MINIMUM_LENGTH + alen + lldp.length));
return packetOut;
}
示例8: createBDDPPacketOut
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* Creates packet_out LLDP for specified output port.
*
* @param port the port
* @return Packet_out message with LLDP data
* @throws PortMappingException
*/
private OFPacketOut createBDDPPacketOut(final PhysicalPort port)
throws PortMappingException {
if (port == null) {
throw new PortMappingException(
"Cannot send LLDP associated with a nonexistent port");
}
final OFPacketOut packetOut = (OFPacketOut) this.ovxMessageFactory
.getMessage(OFType.PACKET_OUT);
packetOut.setBufferId(OFPacketOut.BUFFER_ID_NONE);
final List<OFAction> actionsList = new LinkedList<OFAction>();
final OFActionOutput out = (OFActionOutput) this.ovxMessageFactory
.getAction(OFActionType.OUTPUT);
out.setPort(port.getPortNumber());
actionsList.add(out);
packetOut.setActions(actionsList);
final short alen = SwitchDiscoveryManager.countActionsLen(actionsList);
this.lldpPacket.setPort(port);
this.bddpEth.setSourceMACAddress(port.getHardwareAddress());
final byte[] bddp = this.bddpEth.serialize();
packetOut.setActionsLength(alen);
packetOut.setPacketData(bddp);
packetOut
.setLength((short) (OFPacketOut.MINIMUM_LENGTH + alen + bddp.length));
return packetOut;
}
示例9: getAction
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public OFAction getAction(final OFActionType t) {
final Class<? extends OFAction> c = OVXMessageFactory.CONVERT_ACTIONS_MAP[t
.getTypeValue()];
try {
return c.getConstructor(new Class[] {}).newInstance();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例10: actionsContainOutport
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* Does OFAction contain Port?
*
* @param port the port to check
* @return true if ofaction contains outport
*/
public boolean actionsContainOutport(short port) {
Iterator<OFAction> iter = this.actionList.iterator();
while (iter.hasNext()) {
OFAction action = iter.next();
if (action.getType().equals(OFActionType.OUTPUT)) {
OFActionOutput outputAction = (OFActionOutput) action;
if (outputAction.getPort() == port) {
return true;
}
}
}
return false;
}
示例11: parseActionOne
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
private OFAction parseActionOne(OFActionType type, ChannelBuffer data) {
OFAction ofa;
data.markReaderIndex();
ofa = getAction(type);
ofa.readFrom(data);
if(type == OFActionType.VENDOR) {
OFActionVendor vendorAction = (OFActionVendor) ofa;
OFVendorActionFactory vendorActionFactory = vendorActionRegistry.get(vendorAction.getVendor());
if(vendorActionFactory != null) {
// if we have a specific vendorActionFactory for this vendor id,
// delegate to it for vendor-specific reparsing of the message
data.resetReaderIndex();
OFActionVendor newAction = vendorActionFactory.readFrom(data);
if(newAction != null)
ofa = newAction;
}
}
if (OFAction.class.equals(ofa.getClass())) {
// advance the position for un-implemented messages
data.readerIndex(data.readerIndex()+(ofa.getLengthU() -
OFAction.MINIMUM_LENGTH));
}
return ofa;
}
示例12: testStatsFlow
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
@Test
public void testStatsFlow() {
String message = "[\"flow_stats_reply\", 3, [{\"packet_count\": 1, \"hard_timeout\": 0, \"byte_count\": 4, \"idle_timeout\": 5, \"actions\": \"[{'output': 65533}]\", " +
"\"duration_nsec\": 27000000, \"priority\": 6, \"duration_sec\": 0, \"table_id\": 25, \"cookie\": 2, \"match\": \"{}\"}]]";
MessageParser mp = new MessageParser();
OFStatisticsReply reply = mp.parseStatsReply(OFStatisticsType.FLOW, message);
//TESTS
assertEquals("Statistics type not set correctly", OFStatisticsType.FLOW, reply.getStatisticType());
OFStatistics stat = reply.getStatistics().get(0);
assertTrue("Returned stat is not a FlowStat class", (stat instanceof OFFlowStatisticsReply));
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) stat;
//TEST FLOWS STATS REPY
assertEquals("'byte_count' not set correctly", 4, flowStat.getByteCount());
assertEquals("'cookie' not set correctly", 2, flowStat.getCookie());
assertEquals("'duration_nsec' not set correctly", 27000000, flowStat.getDurationNanoseconds());
assertEquals("'idle_timeout' not set correctly", 5, flowStat.getIdleTimeout());
assertEquals("'packet_count' not set correctly", 1, flowStat.getPacketCount());
assertEquals("'table_id' not set correctly", (byte)25, flowStat.getTableId());
assertEquals("'priority' not set correctly", 6, flowStat.getPriority());
OFAction action = flowStat.getActions().get(0);
assertEquals("Output type not set properly not set correctly", OFActionType.OUTPUT, action.getType());
assertTrue("Output class type not set properly", (action instanceof OFActionOutput));
OFActionOutput actionOut = (OFActionOutput)action;
//PORT IS A SHORT, SO MUST BE CONVERTED FROM INT
assertEquals("Port not set properly in ActionOut", 65533, (0x0FFFF&(actionOut.getPort())));
}
示例13: testAllowedPacketOut
import org.openflow.protocol.action.OFActionType; //导入依赖的package包/类
/**
* tests packetOut event slicing
*/
@Test
public void testAllowedPacketOut(){
OFPacketOut out = new OFPacketOut();
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setType(OFActionType.OUTPUT);
output.setPort((short)1);
actions.add(output);
out.setActions(actions);
Ethernet pkt = new Ethernet();
pkt.setVlanID((short)1000);
pkt.setDestinationMACAddress("aa:bb:cc:dd:ee:ff");
pkt.setSourceMACAddress("ff:ee:dd:cc:bb:aa");
pkt.setEtherType((short)35020);
out.setPacketData(pkt.serialize());
List<OFMessage> outPackets = slicer.allowedPacketOut(out);
assertTrue("OutPacket size is correct, expected 1 got " + outPackets.size(), outPackets.size() == 1);
pkt.setVlanID((short)2000);
out.setPacketData(pkt.serialize());
outPackets = slicer.allowedPacketOut(out);
assertTrue("Packet out was denied", outPackets.size() == 0);
}