Reported-by: Sam Russell <[email protected]>
Signed-off-by: Minoru TAKAHASHI <[email protected]>
---
ryu/lib/packet/dhcp.py | 2 +-
ryu/tests/unit/packet/test_dhcp.py | 53 ++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/ryu/lib/packet/dhcp.py b/ryu/lib/packet/dhcp.py
index 5320079..a172e79 100644
--- a/ryu/lib/packet/dhcp.py
+++ b/ryu/lib/packet/dhcp.py
@@ -154,7 +154,7 @@ class dhcp(packet_base.PacketBase):
self.op = op
self.htype = htype
if hlen == 0:
- self.hlen = len(chaddr)
+ self.hlen = len(addrconv.mac.text_to_bin(chaddr))
else:
self.hlen = hlen
self.hops = hops
diff --git a/ryu/tests/unit/packet/test_dhcp.py
b/ryu/tests/unit/packet/test_dhcp.py
index 44a10c5..cd4e8c4 100644
--- a/ryu/tests/unit/packet/test_dhcp.py
+++ b/ryu/tests/unit/packet/test_dhcp.py
@@ -205,3 +205,56 @@ class Test_dhcp_offer(unittest.TestCase):
jsondict = self.dh.to_jsondict()
dh = dhcp.dhcp.from_jsondict(jsondict['dhcp'])
eq_(str(self.dh), str(dh))
+
+
+class Test_dhcp_offer_with_hlen_zero(unittest.TestCase):
+
+ op = dhcp.DHCP_BOOT_REPLY
+ chaddr = 'aa:aa:aa:aa:aa:aa'
+ htype = 1
+ hlen = 6
+ hops = 0
+ xid = 1
+ secs = 0
+ flags = 1
+ ciaddr = '192.168.10.10'
+ yiaddr = '192.168.20.20'
+ siaddr = '192.168.30.30'
+ giaddr = '192.168.40.40'
+ sname = 'abc'
+ boot_file = ''
+
+ option_list = [
+ dhcp.option(dhcp.DHCP_MESSAGE_TYPE_OPT, '\x02', 1),
+ dhcp.option(dhcp.DHCP_SUBNET_MASK_OPT, '\xff\xff\xff\x00', 4),
+ dhcp.option(dhcp.DHCP_GATEWAY_ADDR_OPT, '\xc0\xa8\x0a\x09', 4),
+ dhcp.option(dhcp.DHCP_DNS_SERVER_ADDR_OPT, '\xc0\xa8\x0a\x09', 4),
+ dhcp.option(dhcp.DHCP_IP_ADDR_LEASE_TIME_OPT, '\x00\x03\xf4\x80', 4),
+ dhcp.option(dhcp.DHCP_RENEWAL_TIME_OPT, '\x00\x01\xfa\x40', 4),
+ dhcp.option(dhcp.DHCP_REBINDING_TIME_OPT, '\x00\x03\x75\xf0', 4),
+ dhcp.option(dhcp.DHCP_SERVER_IDENTIFIER_OPT, '\xc0\xa8\x0a\x09', 4)]
+ magic_cookie = '99.130.83.99'
+ options = dhcp.options(option_list=option_list, options_len=50,
+ magic_cookie=magic_cookie)
+
+ dh = dhcp.dhcp(op, chaddr, options, htype=htype, hlen=0,
+ hops=hops, xid=xid, secs=secs, flags=flags,
+ ciaddr=ciaddr, yiaddr=yiaddr, siaddr=siaddr,
+ giaddr=giaddr, sname=sname, boot_file=boot_file)
+
+ def test_init(self):
+ eq_(self.op, self.dh.op)
+ eq_(self.htype, self.dh.htype)
+ eq_(self.hlen, self.dh.hlen)
+ eq_(self.hops, self.dh.hops)
+ eq_(self.xid, self.dh.xid)
+ eq_(self.secs, self.dh.secs)
+ eq_(self.flags, self.dh.flags)
+ eq_(self.ciaddr, self.dh.ciaddr)
+ eq_(self.yiaddr, self.dh.yiaddr)
+ eq_(self.siaddr, self.dh.siaddr)
+ eq_(self.giaddr, self.dh.giaddr)
+ eq_(self.chaddr, self.dh.chaddr)
+ eq_(self.sname, self.dh.sname)
+ eq_(self.boot_file, self.dh.boot_file)
+ eq_(str(self.options), str(self.dh.options))
--
1.9.1
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel