本文整理汇总了Java中org.openflow.protocol.OFPacketIn.OFPacketInReason类的典型用法代码示例。如果您正苦于以下问题:Java OFPacketInReason类的具体用法?Java OFPacketInReason怎么用?Java OFPacketInReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFPacketInReason类属于org.openflow.protocol.OFPacketIn包,在下文中一共展示了OFPacketInReason类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPacketIn
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
protected void setPacketIn(IPacket packet) {
byte[] serializedPacket = packet.serialize();
// Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) serializedPacket.length);
// Add the packet to the context store
IFloodlightProviderService.bcStore.
put(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
(Ethernet)packet);
}
示例2: setPacketIn
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
protected void setPacketIn(IPacket packet) {
byte[] serializedPacket = packet.serialize();
// Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) serializedPacket.length);
// Add the packet to the context store
IFloodlightProviderService.bcStore.
put(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
(Ethernet)packet);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:17,代码来源:FirewallTest.java
示例3: convertBCastToUcast
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
private OFPacketIn convertBCastToUcast(Ethernet eth,
OFPacketIn pi,
IDevice dst) {
byte[] dstMac = Ethernet.toByteArray(dst.getMACAddress());
eth.setDestinationMACAddress(dstMac);
byte[] serializedPacket = eth.serialize();
OFPacketIn fakePi =
((OFPacketIn) controllerProvider.getOFMessageFactory()
.getMessage(OFType.PACKET_IN))
.setInPort(pi.getInPort())
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setReason(OFPacketInReason.NO_MATCH);
fakePi.setPacketData(serializedPacket);
fakePi.setTotalLength((short) serializedPacket.length);
fakePi.setLength((short)(OFPacketIn.MINIMUM_LENGTH +
serializedPacket.length));
return fakePi;
}
示例4: testNoAcl
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
/**
* No ACL, should pass by default
*/
@Test
public void testNoAcl() throws Exception {
ListenerContext cntx = new ListenerContext();
List<VNSInterface> ifaces = new ArrayList<VNSInterface>();
ifaces.add(if1);
INetVirtManagerService.bcStore.put(cntx, INetVirtManagerService.CONTEXT_SRC_IFACES, ifaces);
INetVirtManagerService.bcStore.put(cntx, INetVirtManagerService.CONTEXT_DST_IFACES, ifaces);
OFPacketIn pi = new OFPacketIn()
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(udpPacketSerialized1)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) udpPacketSerialized1.length);
// Clear ACL from storage
IStorageSourceService storageSource = getStorageSource();
clearStorage(storageSource);
testAclInternal(pi, cntx, RoutingAction.FORWARD, udpPacketSerialized1);
}
示例5: parseMessage
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
/**
* Parses message into relevant properties
* @param rawMessage Assumes the following format and parses into properties:
* "[\"packet\", {\"raw\": [186, 100, 113, 119, ...], \"switch\": 1, \"inport\": 1}]"
*/
public void parseMessage(String rawMessage) {
//EXTRACT THE JSON
System.out.println("rawMessage size is "+ rawMessage.length());
System.out.println(rawMessage);
String tmp = rawMessage.substring(rawMessage.indexOf(",")+1, rawMessage.length()-1);
System.out.println("index and size of raw "+ rawMessage.indexOf(",") +" "+tmp.length());
JSONObject json = new JSONObject(tmp.trim());
this.switchId = json.getLong("switch");
this.inPort = (short)json.getInt("inport");
JSONArray arr = json.getJSONArray("raw");
this.packetData = new byte[arr.length()];
for (int i=0; i<arr.length(); i++) {
int number = (int) arr.get(i);
this.packetData[i] = (byte)number;
}
//ADD PROPS TO PACKET_IN OBJECT
packetIn = new OFPacketIn();
packetIn.setInPort(inPort);
packetIn.setPacketData(packetData);
packetIn.setBufferId(-1);
packetIn.setReason(OFPacketInReason.NO_MATCH);
packetIn.setXid((int)this.switchId);
}
示例6: updateUDPPacketIn
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
/**
* Updates testUDPPacketIn and testUDPPacketSrld from testUDPPacket
* To be called after testUDPPacket has been mangled.
*/
private void updateUDPPacketIn() {
this.testUDPPacketSrld = this.testUDPPacket.serialize();
// Build the PacketIn
this.testUDPPacketIn = ((OFPacketIn) mockFloodlightProvider.
getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 3)
.setPacketData(this.testUDPPacketSrld)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testUDPPacketSrld.length);
}
示例7: setUp
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
mockFloodlightProvider = getMockFloodlightProvider();
hub = new Hub();
mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
hub.setFloodlightProvider(mockFloodlightProvider);
// Build our test packet
this.testPacket = new Ethernet()
.setDestinationMACAddress("00:11:22:33:44:55")
.setSourceMACAddress("00:44:33:22:11:00")
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress("192.168.1.1")
.setDestinationAddress("192.168.1.2")
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
this.testPacketSerialized = testPacket.serialize();
// Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testPacketSerialized.length);
}
示例8: createPacketIn
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
String srcIp, String dstIp, short vlan) {
IPacket testPacket = new Ethernet()
.setDestinationMACAddress(dstMAC)
.setSourceMACAddress(srcMAC)
.setVlanID(vlan)
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress(srcIp)
.setDestinationAddress(dstIp)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
byte[] testPacketSerialized = testPacket.serialize();
OFPacketIn pi;
// build out input packet
pi = ((OFPacketIn) BasicFactory.getInstance().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) testPacketSerialized.length);
return pi;
}
示例9: setUp
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
blockMessage = null;
// Build our test packet
testPacket = new Ethernet()
.setSourceMACAddress(srcMac)
.setDestinationMACAddress("00:11:22:33:44:55")
.setEtherType(Ethernet.TYPE_ARP)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REPLY)
.setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
testPacketSerialized = testPacket.serialize();
pi = ((OFPacketIn) BasicFactory.getInstance().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) testPacketSerialized.length);
floodlightProvider = createMock(IFloodlightProviderService.class);
sw = new OFSwitchTest(floodlightProvider);
IDebugCounterService debugCounter = new DebugCounter();
sw.setDebugCounterService(debugCounter);
switches = new ConcurrentHashMap<Long, IOFSwitch>();
switches.put(sw.getId(), sw);
expect(floodlightProvider.getSwitch(sw.getId())).andReturn(sw).anyTimes();
expect(floodlightProvider.getOFMessageFactory())
.andReturn(BasicFactory.getInstance()).anyTimes();
}
示例10: DhcpDiscoveryRequestOFPacketIn
import org.openflow.protocol.OFPacketIn.OFPacketInReason; //导入依赖的package包/类
/**
* Generates a DHCP request OFPacketIn.
* @param hostMac The host MAC address of for the request.
* @return An OFPacketIn that contains a DHCP request packet.
*/
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(MACAddress hostMac) {
byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
return (((OFPacketIn)OFMessageFactory
.getMessage(OFType.PACKET_IN))
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setInPort((short) 1)
.setPacketData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short)serializedPacket.length));
}