summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2013-04-13 23:47:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-04-16 02:47:45 +0900
commite20fcad468a1f4043ca4eaa70d931e2519ada6e2 (patch)
tree88b863cbecc2322a20ebdc88fa985fbf77900509
parent3f3b683d204ced69154ce08ca74863dda4ba8415 (diff)
lib/packet/arp.py: add convenience function to create arp for ip
Since ip case is most often used, introduce a convenience function for that. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/arp.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ryu/lib/packet/arp.py b/ryu/lib/packet/arp.py
index 3cef38dc..9d0b3f8c 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)