Since ip case is most often used, introduce a convenience
function for that.

Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
---
Changes v1 -> v2:
- improve commit message
- rename arp_ether_ip -> arp_ip
---
 ryu/lib/packet/arp.py |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ryu/lib/packet/arp.py b/ryu/lib/packet/arp.py
index 3cef38d..9d0b3f8 100644
--- a/ryu/lib/packet/arp.py
+++ b/ryu/lib/packet/arp.py
@@ -14,6 +14,8 @@
 # limitations under the License.
 
 import struct
+
+from ryu.ofproto import ether
 from . import packet_base
 
 ARP_HW_TYPE_ETHERNET = 1  # ethernet hardware type
@@ -55,3 +57,10 @@ class arp(packet_base.PacketBase):
                            self.hlen, self.plen, self.opcode,
                            self.src_mac, self.src_ip, self.dst_mac,
                            self.dst_ip)
+
+
+def arp_ip(opcode, src_mac, src_ip, dst_mac, dst_ip):
+    return arp(ARP_HW_TYPE_ETHERNET, ether.ETH_TYPE_IP,
+               6,  # ether mac address length
+               4,  # ipv4 address length,
+               opcode, src_mac, src_ip, dst_mac, dst_ip)
-- 
1.7.10.4


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to