Skip to content

Commit

Permalink
Merge pull request #344 from kbandla/dhcp_header_py3
Browse files Browse the repository at this point in the history
change a few dhcp header fields to be initialized with bytes
  • Loading branch information
brifordwylie committed Mar 23, 2017
2 parents d30ece1 + 01a44e6 commit 3412c4f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dpkt/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ class DHCP(dpkt.Packet):
('yiaddr', 'I', 0),
('siaddr', 'I', 0),
('giaddr', 'I', 0),
('chaddr', '16s', 16 * '\x00'),
('sname', '64s', 64 * '\x00'),
('file', '128s', 128 * '\x00'),
('chaddr', '16s', 16 * b'\x00'),
('sname', '64s', 64 * b'\x00'),
('file', '128s', 128 * b'\x00'),
('magic', 'I', DHCP_MAGIC),
)
opts = (
Expand Down Expand Up @@ -176,7 +176,15 @@ def test_dhcp():
s = b'\x01\x01\x06\x00\xadS\xc8c\xb8\x87\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02U\x82\xf3\xa6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x82Sc5\x01\x01\xfb\x01\x01=\x07\x01\x00\x02U\x82\xf3\xa62\x04\n\x00\x01e\x0c\tGuinevere<\x08MSFT 5.07\n\x01\x0f\x03\x06,./\x1f!+\xff\x00\x00\x00\x00\x00'
dhcp = DHCP(s)
assert (s == bytes(dhcp))

assert isinstance(dhcp.chaddr, bytes)
assert isinstance(dhcp.sname, bytes)
assert isinstance(dhcp.file, bytes)

# Test default construction
dhcp = DHCP()
assert isinstance(dhcp.chaddr, bytes)
assert isinstance(dhcp.sname, bytes)
assert isinstance(dhcp.file, bytes)

if __name__ == '__main__':
test_dhcp()
Expand Down

0 comments on commit 3412c4f

Please sign in to comment.