From e7d7e167d858e93ca549698f2bcc0c69d28e0bf6 Mon Sep 17 00:00:00 2001 From: Dustin Rodrigues Date: Sun, 19 Mar 2017 14:14:06 -0400 Subject: [PATCH] test gettting, setting header offset in TCP --- dpkt/tcp.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dpkt/tcp.py b/dpkt/tcp.py index 4818e8a1..c051b2fa 100644 --- a/dpkt/tcp.py +++ b/dpkt/tcp.py @@ -159,8 +159,16 @@ def test_parse_opts(): opts = parse_opts(buf) assert opts == [None] +def test_offset(): + tcpheader = TCP(b'\x01\xbb\xc0\xd7\xb6\x56\xa8\xb9\xd1\xac\xaa\xb1\x50\x18\x40\x00\x56\xf8\x00\x00') + assert tcpheader.off == 5 + + # test setting header offset + tcpheader.off = 8 + assert bytes(tcpheader) == b'\x01\xbb\xc0\xd7\xb6\x56\xa8\xb9\xd1\xac\xaa\xb1\x80\x18\x40\x00\x56\xf8\x00\x00' if __name__ == '__main__': # Runs all the test associated with this class/file test_parse_opts() + test_offset() print('Tests Successful...')