mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
packet lib: sctp: aggregate the same method into the base class
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
d9e4791c56
commit
6048694889
@ -1133,9 +1133,12 @@ class cause(stringify.StringifyMixin):
|
||||
def parser(cls, buf):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def serialize(self):
|
||||
pass
|
||||
if 0 == self.length:
|
||||
self.length = self._MIN_LEN
|
||||
buf = struct.pack(
|
||||
self._PACK_STR, self.cause_code(), self.length)
|
||||
return buf
|
||||
|
||||
def __len__(self):
|
||||
length = self.length
|
||||
@ -1350,13 +1353,6 @@ class cause_out_of_resource(cause):
|
||||
(_, length) = struct.unpack_from(cls._PACK_STR, buf)
|
||||
return cls(length)
|
||||
|
||||
def serialize(self):
|
||||
if 0 == self.length:
|
||||
self.length = self._MIN_LEN
|
||||
buf = struct.pack(
|
||||
self._PACK_STR, self.cause_code(), self.length)
|
||||
return buf
|
||||
|
||||
|
||||
@chunk_abort.register_cause_code
|
||||
@chunk_error.register_cause_code
|
||||
@ -1483,13 +1479,6 @@ class cause_invalid_param(cause):
|
||||
(_, length) = struct.unpack_from(cls._PACK_STR, buf)
|
||||
return cls(length)
|
||||
|
||||
def serialize(self):
|
||||
if 0 == self.length:
|
||||
self.length = self._MIN_LEN
|
||||
buf = struct.pack(
|
||||
self._PACK_STR, self.cause_code(), self.length)
|
||||
return buf
|
||||
|
||||
|
||||
@chunk_abort.register_cause_code
|
||||
@chunk_error.register_cause_code
|
||||
@ -1583,13 +1572,6 @@ class cause_cookie_while_shutdown(cause):
|
||||
(_, length) = struct.unpack_from(cls._PACK_STR, buf)
|
||||
return cls(length)
|
||||
|
||||
def serialize(self):
|
||||
if 0 == self.length:
|
||||
self.length = self._MIN_LEN
|
||||
buf = struct.pack(
|
||||
self._PACK_STR, self.cause_code(), self.length)
|
||||
return buf
|
||||
|
||||
|
||||
@chunk_abort.register_cause_code
|
||||
@chunk_error.register_cause_code
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user