RFC2402 says:
All IPv6 extension headers, as per RFC 1883, encode the "Hdr Ext Len" field
by first
subtracting 1 (64-bit word) from the header length (measured in 64-bit
words).
AH is an IPv6 extension header. However, since its length is measured in
32-bit words,
the "Payload Length" is calculated by subtracting 2 (32 bit words).
This patch fixes as follows:
return (int(size) - 1) * 8 ->
return (int(size) + 2) * 4
^ ^ ^
And, this patch also fixes a default argument of length.
Signed-off-by: TAKAHASHI Minoru <[email protected]>
---
ryu/lib/packet/ipv6.py | 4 ++--
ryu/tests/unit/packet/test_ipv6.py | 11 +++++++++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py
index 960f1ac..b02ca51 100644
--- a/ryu/lib/packet/ipv6.py
+++ b/ryu/lib/packet/ipv6.py
@@ -409,7 +409,7 @@ class auth(header):
_PACK_STR = '!BB2xII'
_MIN_LEN = struct.calcsize(_PACK_STR)
- def __init__(self, nxt=inet.IPPROTO_TCP, size=3, spi=0, seq=0,
+ def __init__(self, nxt=inet.IPPROTO_TCP, size=2, spi=0, seq=0,
data='\x00\x00\x00\x00'):
super(auth, self).__init__(nxt)
assert data is not None
@@ -420,7 +420,7 @@ class auth(header):
@classmethod
def _get_size(cls, size):
- return (int(size) - 1) * 8
+ return (int(size) + 2) * 4
@classmethod
def parser(cls, buf):
diff --git a/ryu/tests/unit/packet/test_ipv6.py
b/ryu/tests/unit/packet/test_ipv6.py
index a2a1343..4229b18 100644
--- a/ryu/tests/unit/packet/test_ipv6.py
+++ b/ryu/tests/unit/packet/test_ipv6.py
@@ -786,7 +786,14 @@ class Test_auth(unittest.TestCase):
eq_(self.data, res[4])
def test_len(self):
- eq_((4 - 1) * 8, len(self.auth))
+ eq_((4 + 2) * 4, len(self.auth))
+
+ def test_len_re(self):
+ size = 5
+ auth = ipv6.auth(
+ 0, size, 256, 1,
+ '\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8')
+ eq_((size + 2) * 4, len(auth))
def test_default_args(self):
hdr = ipv6.auth()
@@ -796,7 +803,7 @@ class Test_auth(unittest.TestCase):
LOG.info(res)
eq_(res[0], 6)
- eq_(res[1], 3)
+ eq_(res[1], 2)
eq_(res[2], 0)
eq_(res[3], 0)
eq_(buf[ipv6.auth._MIN_LEN:], '\x00\x00\x00\x00')
--
1.7.10.4
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel