diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2013-11-06 17:15:47 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-11-08 10:44:29 +0900 |
commit | 42942c7c5dac2913a682e2c62641b29df502b357 (patch) | |
tree | 6392d769121cbd6c1938784a6d7f33a53cbf2042 | |
parent | 521a7d2167085f8696c085849f72161283d5a0ca (diff) |
packet lib: icmpv6: support len(icmpv6.*)
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/packet/icmpv6.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py index 5d4146f3..bcf1fff7 100644 --- a/ryu/lib/packet/icmpv6.py +++ b/ryu/lib/packet/icmpv6.py @@ -138,6 +138,12 @@ class icmpv6(packet_base.PacketBase): return hdr + def __len__(self): + length = self._MIN_LEN + if self.data is not None: + length += len(self.data) + return length + @icmpv6.register_icmpv6_type(ND_NEIGHBOR_SOLICIT, ND_NEIGHBOR_ADVERT) class nd_neighbor(stringify.StringifyMixin): @@ -206,6 +212,12 @@ class nd_neighbor(stringify.StringifyMixin): hdr.extend(self.option) return str(hdr) + def __len__(self): + length = self._MIN_LEN + if self.option is not None: + length += len(self.option) + return length + @icmpv6.register_icmpv6_type(ND_ROUTER_SOLICIT) class nd_router_solicit(stringify.StringifyMixin): @@ -269,6 +281,12 @@ class nd_router_solicit(stringify.StringifyMixin): hdr.extend(self.option) return str(hdr) + def __len__(self): + length = self._MIN_LEN + if self.option is not None: + length += len(self.option) + return length + @icmpv6.register_icmpv6_type(ND_ROUTER_ADVERT) class nd_router_advert(stringify.StringifyMixin): @@ -348,6 +366,12 @@ class nd_router_advert(stringify.StringifyMixin): hdr.extend(option) return str(hdr) + def __len__(self): + length = self._MIN_LEN + for option in self.options: + length += len(option) + return length + class nd_option(stringify.StringifyMixin): @@ -372,6 +396,9 @@ class nd_option(stringify.StringifyMixin): def serialize(self): pass + def __len__(self): + return self._MIN_LEN + class nd_option_la(nd_option): @@ -405,6 +432,12 @@ class nd_option_la(nd_option): buf.extend(bytearray(8 - mod)) return str(buf) + def __len__(self): + length = self._MIN_LEN + if self.data is not None: + length += len(self.data) + return length + @nd_neighbor.register_nd_option_type @nd_router_solicit.register_nd_option_type @@ -594,3 +627,9 @@ class echo(stringify.StringifyMixin): hdr += bytearray(self.data) return hdr + + def __len__(self): + length = self._MIN_LEN + if self.data is not None: + length += len(self.data) + return length |