As well as 'length', calculate 'num' automatically at 'serialize()'.

Signed-off-by: Yuichi Ito <[email protected]>
---
 ryu/lib/packet/sctp.py |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ryu/lib/packet/sctp.py b/ryu/lib/packet/sctp.py
index 89b57a0..6ecefd0 100644
--- a/ryu/lib/packet/sctp.py
+++ b/ryu/lib/packet/sctp.py
@@ -1319,8 +1319,6 @@ class cause_missing_param(cause):
         for one in types:
             assert isinstance(one, int)
         self.types = types
-        if 0 == num:
-            num = len(self.types)
         self.num = num

     @classmethod
@@ -1339,6 +1337,9 @@ class cause_missing_param(cause):
             self._PACK_STR, self.cause_code(), self.length, self.num))
         for one in self.types:
             buf.extend(struct.pack('!H', one))
+        if 0 == self.num:
+            self.num = len(self.types)
+            struct.pack_into('!I', buf, 4, self.num)
         if 0 == self.length:
             self.length = len(buf)
             struct.pack_into('!H', buf, 2, self.length)
-- 
1.7.10.4


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to