Demo entry 1971460

receiveDataPacket(RawPacket inPkt)

   

Submitted by anonymous on Jun 20, 2015 at 19:36
Language: Java. Code size: 984 Bytes.

public PacketResult receiveDataPacket(RawPacket inPkt) {
	// Use DataPacketService to decode the packet.
	Packet pkt = dataPacketService.decodeDataPacket(inPkt);
	if (pkt instanceof Ethernet) {
		// packet-in is ethernet
		Ethernet ethFrame = (Ethernet) pkt;
		Object l3Pkt = ethFrame.getPayload();
		byte[] dstMAC = ethFrame.getDestinationMACAddress();

		byte[] srcMAC = ethFrame.getSourceMACAddress();

		if (l3Pkt instanceof IPv4) {
			// packet-in is IPv4
			IPv4 ipv4Pkt = (IPv4) l3Pkt;
			InetAddress srcAddr = intToInetAddress(ipv4Pkt
					.getSourceAddress());
			InetAddress dstAddr = intToInetAddress(ipv4Pkt
					.getDestinationAddress());
			System.out.println("packet in de " + srcAddr.toString()
					+ " para " + dstAddr.toString());
			// Object l4Datagram = ipv4Pkt.getPayload();
			// System.out.println("MAC paquete " + dstMAC);
			return installPathFlows(inPkt, srcMAC, dstMAC, srcAddr, dstAddr);
		}
	}

	return PacketResult.IGNORED;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).