From 6048694889d3cb27a5c7162d2476a295306b5002 Mon Sep 17 00:00:00 2001 From: Yuichi Ito Date: Mon, 28 Oct 2013 16:04:45 +0900 Subject: packet lib: sctp: aggregate the same method into the base class Signed-off-by: Yuichi Ito Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/sctp.py | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/ryu/lib/packet/sctp.py b/ryu/lib/packet/sctp.py index e491c37f..8c1a20b0 100644 --- a/ryu/lib/packet/sctp.py +++ b/ryu/lib/packet/sctp.py @@ -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 -- cgit v1.2.3