mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
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>
This commit is contained in:
parent
521a7d2167
commit
42942c7c5d
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user