mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
packet lib: icmp: support len(icmp.*)
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
1d1cdeea99
commit
8de99416fa
@ -115,6 +115,9 @@ class icmp(packet_base.PacketBase):
|
||||
|
||||
return hdr
|
||||
|
||||
def __len__(self):
|
||||
return self._MIN_LEN + len(self.data)
|
||||
|
||||
|
||||
@icmp.register_icmp_type(ICMP_ECHO_REPLY, ICMP_ECHO_REQUEST)
|
||||
class echo(stringify.StringifyMixin):
|
||||
@ -167,6 +170,12 @@ class echo(stringify.StringifyMixin):
|
||||
|
||||
return hdr
|
||||
|
||||
def __len__(self):
|
||||
length = self._MIN_LEN
|
||||
if self.data is not None:
|
||||
length += len(self.data)
|
||||
return length
|
||||
|
||||
|
||||
@icmp.register_icmp_type(ICMP_DEST_UNREACH)
|
||||
class dest_unreach(stringify.StringifyMixin):
|
||||
@ -227,6 +236,12 @@ class dest_unreach(stringify.StringifyMixin):
|
||||
|
||||
return hdr
|
||||
|
||||
def __len__(self):
|
||||
length = self._MIN_LEN
|
||||
if self.data is not None:
|
||||
length += len(self.data)
|
||||
return length
|
||||
|
||||
|
||||
@icmp.register_icmp_type(ICMP_TIME_EXCEEDED)
|
||||
class TimeExceeded(stringify.StringifyMixin):
|
||||
@ -276,3 +291,9 @@ class TimeExceeded(stringify.StringifyMixin):
|
||||
hdr += 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