summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2013-10-28 16:05:02 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-10-28 22:55:16 +0900
commit1d2255113c4acb7b72ec3805b1fb605fc118e066 (patch)
tree0b976ba42d77e5e8a19c34e5ee792282f3a7020f
parent6048694889d3cb27a5c7162d2476a295306b5002 (diff)
packet lib: sctp: support default parameters and the auto calculation of lengths
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/sctp.py117
-rw-r--r--ryu/tests/unit/packet/test_sctp.py72
2 files changed, 123 insertions, 66 deletions
diff --git a/ryu/lib/packet/sctp.py b/ryu/lib/packet/sctp.py
index 8c1a20b0..f44f4da2 100644
--- a/ryu/lib/packet/sctp.py
+++ b/ryu/lib/packet/sctp.py
@@ -81,6 +81,7 @@ class sctp(packet_base.PacketBase):
dst_port Destination Port
vtag Verification Tag
csum Checksum
+ (0 means automatically-calculate when encoding)
chunks a list of derived classes of ryu.lib.packet.sctp.chunk.
============== =====================================================
"""
@@ -97,7 +98,7 @@ class sctp(packet_base.PacketBase):
return cls
return _register_chunk_type(args[0])
- def __init__(self, src_port, dst_port, vtag, csum, chunks=None):
+ def __init__(self, src_port=0, dst_port=0, vtag=0, csum=0, chunks=None):
super(sctp, self).__init__()
self.src_port = src_port
self.dst_port = dst_port
@@ -250,8 +251,8 @@ class chunk_init_base(chunk):
_PACK_STR = '!BBHIIHHI'
_MIN_LEN = struct.calcsize(_PACK_STR)
- def __init__(self, flags, length, init_tag, a_rwnd, os, mis, i_tsn,
- params=None):
+ def __init__(self, flags=0, length=0, init_tag=0, a_rwnd=0, os=0,
+ mis=0, i_tsn=0, params=None):
super(chunk_init_base, self).__init__(self.chunk_type(), length)
self.flags = flags
self.init_tag = init_tag
@@ -289,6 +290,9 @@ class chunk_init_base(chunk):
self.i_tsn))
for one in self.params:
buf.extend(one.serialize())
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -296,11 +300,12 @@ class chunk_heartbeat_base(chunk):
__metaclass__ = abc.ABCMeta
- def __init__(self, flags, length, info):
+ def __init__(self, flags=0, length=0, info=None):
super(chunk_heartbeat_base, self).__init__(
self.chunk_type(), length)
self.flags = flags
- assert isinstance(info, param)
+ if info is not None:
+ assert isinstance(info, param)
self.info = info
@classmethod
@@ -316,7 +321,11 @@ class chunk_heartbeat_base(chunk):
buf = bytearray(struct.pack(
self._PACK_STR, self.chunk_type(), self.flags,
self.length))
- buf.extend(self.info.serialize())
+ if self.info is not None:
+ buf.extend(self.info.serialize())
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -324,7 +333,7 @@ class chunk_ack_base(chunk):
__metaclass__ = abc.ABCMeta
- def __init__(self, flags, length):
+ def __init__(self, flags=0, length=0):
super(chunk_ack_base, self).__init__(self.chunk_type(), length)
self.flags = flags
@@ -334,6 +343,8 @@ class chunk_ack_base(chunk):
return cls(flags, length)
def serialize(self):
+ if 0 == self.length:
+ self.length = self._MIN_LEN
buf = struct.pack(
self._PACK_STR, self.chunk_type(), self.flags,
self.length)
@@ -346,7 +357,7 @@ class chunk_ecn_base(chunk):
_PACK_STR = '!BBHI'
_MIN_LEN = struct.calcsize(_PACK_STR)
- def __init__(self, flags, length, low_tsn):
+ def __init__(self, flags=0, length=0, low_tsn=0):
super(chunk_ecn_base, self).__init__(self.chunk_type(), length)
self.flags = flags
self.low_tsn = low_tsn
@@ -357,6 +368,8 @@ class chunk_ecn_base(chunk):
return cls(flags, length, low_tsn)
def serialize(self):
+ if 0 == self.length:
+ self.length = self._MIN_LEN
buf = struct.pack(
self._PACK_STR, self.chunk_type(), self.flags, self.length,
self.low_tsn)
@@ -383,6 +396,7 @@ class chunk_data(chunk):
begin if set to '1', this chunk is the first fragment.
end if set to '1', this chunk is the last fragment.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
tsn Transmission Sequence Number.
sid stream id.
seq the sequence number.
@@ -399,11 +413,12 @@ class chunk_data(chunk):
def chunk_type(cls):
return TYPE_DATA
- def __init__(self, unordered, begin, end, length, tsn, sid, seq,
- payload_id, payload_data):
+ def __init__(self, unordered=0, begin=0, end=0, length=0, tsn=0,
+ sid=0, seq=0, payload_id=0, payload_data=None):
assert (1 == unordered | 1)
assert (1 == begin | 1)
assert (1 == end | 1)
+ assert (payload_data is not None)
super(chunk_data, self).__init__(self.chunk_type(), length)
self.unordered = unordered
self.begin = begin
@@ -435,6 +450,9 @@ class chunk_data(chunk):
self._PACK_STR, self.chunk_type(), flags, self.length,
self.tsn, self.sid, self.seq, self.payload_id))
buf.extend(self.payload_data)
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -456,6 +474,7 @@ class chunk_init(chunk_init_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
init_tag the tag that be used as Verification Tag.
a_rwnd Advertised Receiver Window Credit.
os number of outbound streams.
@@ -505,6 +524,7 @@ class chunk_init_ack(chunk_init_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
init_tag the tag that be used as Verification Tag.
a_rwnd Advertised Receiver Window Credit.
os number of outbound streams.
@@ -554,6 +574,7 @@ class chunk_sack(chunk):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
tsn_ack TSN of the last DATA chunk received in sequence
before a gap.
a_rwnd Advertised Receiver Window Credit.
@@ -577,8 +598,8 @@ class chunk_sack(chunk):
def chunk_type(cls):
return TYPE_SACK
- def __init__(self, flags, length, tsn_ack, a_rwnd, gapack_num,
- duptsn_num, gapacks=None, duptsns=None):
+ def __init__(self, flags=0, length=0, tsn_ack=0, a_rwnd=0,
+ gapack_num=0, duptsn_num=0, gapacks=None, duptsns=None):
super(chunk_sack, self).__init__(self.chunk_type(), length)
self.flags = flags
self.tsn_ack = tsn_ack
@@ -623,6 +644,9 @@ class chunk_sack(chunk):
buf.extend(struct.pack(chunk_sack._GAPACK_STR, one[0], one[1]))
for one in self.duptsns:
buf.extend(struct.pack(chunk_sack._DUPTSN_STR, one))
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -645,6 +669,7 @@ class chunk_heartbeat(chunk_heartbeat_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
info ryu.lib.packet.sctp.param_heartbeat.
============== =====================================================
"""
@@ -687,6 +712,7 @@ class chunk_heartbeat_ack(chunk_heartbeat_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
info ryu.lib.packet.sctp.param_heartbeat.
============== =====================================================
"""
@@ -729,6 +755,7 @@ class chunk_abort(chunk):
tflag '0' means the Verification tag is normal. '1' means
the Verification tag is copy of the sender.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
causes a list of derived classes of ryu.lib.packet.sctp.causes.
============== =====================================================
"""
@@ -748,7 +775,7 @@ class chunk_abort(chunk):
def chunk_type(cls):
return TYPE_ABORT
- def __init__(self, tflag, length, causes=None):
+ def __init__(self, tflag=0, length=0, causes=None):
super(chunk_abort, self).__init__(self.chunk_type(), length)
assert (1 == tflag | 1)
self.tflag = tflag
@@ -780,6 +807,9 @@ class chunk_abort(chunk):
self._PACK_STR, self.chunk_type(), flags, self.length))
for one in self.causes:
buf.extend(one.serialize())
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -802,6 +832,7 @@ class chunk_shutdown(chunk):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
tsn_ack TSN of the last DATA chunk received in sequence
before a gap.
============== =====================================================
@@ -814,7 +845,7 @@ class chunk_shutdown(chunk):
def chunk_type(cls):
return TYPE_SHUTDOWN
- def __init__(self, flags, length, tsn_ack):
+ def __init__(self, flags=0, length=0, tsn_ack=0):
super(chunk_shutdown, self).__init__(self.chunk_type(), length)
self.flags = flags
self.tsn_ack = tsn_ack
@@ -827,6 +858,8 @@ class chunk_shutdown(chunk):
return msg
def serialize(self):
+ if 0 == self.length:
+ self.length = self._MIN_LEN
buf = struct.pack(
self._PACK_STR, self.chunk_type(), self.flags,
self.length, self.tsn_ack)
@@ -852,6 +885,7 @@ class chunk_shutdown_ack(chunk_ack_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
============== =====================================================
"""
@@ -878,6 +912,7 @@ class chunk_error(chunk):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
causes a list of derived classes of ryu.lib.packet.sctp.causes.
============== =====================================================
"""
@@ -897,7 +932,7 @@ class chunk_error(chunk):
def chunk_type(cls):
return TYPE_ERROR
- def __init__(self, flags, length, causes=None):
+ def __init__(self, flags=0, length=0, causes=None):
super(chunk_error, self).__init__(self.chunk_type(), length)
self.flags = flags
causes = causes or []
@@ -926,6 +961,9 @@ class chunk_error(chunk):
self._PACK_STR, self.chunk_type(), self.flags, self.length))
for one in self.causes:
buf.extend(one.serialize())
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
return str(buf)
@@ -947,6 +985,7 @@ class chunk_cookie_echo(chunk):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
cookie cookie data.
============== =====================================================
"""
@@ -958,7 +997,7 @@ class chunk_cookie_echo(chunk):
def chunk_type(cls):
return TYPE_COOKIE_ECHO
- def __init__(self, flags, length, cookie):
+ def __init__(self, flags=0, length=0, cookie=None):
super(chunk_cookie_echo, self).__init__(self.chunk_type(), length)
self.flags = flags
self.cookie = cookie
@@ -966,15 +1005,25 @@ class chunk_cookie_echo(chunk):
@classmethod
def parser(cls, buf):
(_, flags, length) = struct.unpack_from(cls._PACK_STR, buf)
- fmt = '%ds' % (length - cls._MIN_LEN)
- (cookie, ) = struct.unpack_from(fmt, buf, cls._MIN_LEN)
+ _len = length - cls._MIN_LEN
+ cookie = None
+ if _len:
+ fmt = '%ds' % _len
+ (cookie, ) = struct.unpack_from(fmt, buf, cls._MIN_LEN)
return cls(flags, length, cookie)
def serialize(self):
buf = bytearray(struct.pack(
self._PACK_STR, self.chunk_type(), self.flags,
self.length))
- buf.extend(self.cookie)
+ if self.cookie is not None:
+ buf.extend(self.cookie)
+ if 0 == self.length:
+ self.length = len(buf)
+ struct.pack_into('!H', buf, 2, self.length)
+ mod = len(buf) % 4
+ if mod:
+ buf.extend(bytearray(4 - mod))
return str(buf)
@@ -997,6 +1046,7 @@ class chunk_cookie_ack(chunk_ack_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
============== =====================================================
"""
@@ -1023,6 +1073,7 @@ class chunk_ecn_echo(chunk_ecn_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
low_tsn the lowest TSN.
============== =====================================================
"""
@@ -1050,6 +1101,7 @@ class chunk_cwr(chunk_ecn_base):
============== =====================================================
flags set to '0'. this field will be ignored.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
low_tsn the lowest TSN.
============== =====================================================
"""
@@ -1079,6 +1131,7 @@ class chunk_shutdown_complete(chunk):
tflag '0' means the Verification tag is normal. '1' means
the Verification tag is copy of the sender.
length length of this chunk containing this header.
+ (0 means automatically-calculate when encoding)
============== =====================================================
"""
@@ -1089,7 +1142,7 @@ class chunk_shutdown_complete(chunk):
def chunk_type(cls):
return TYPE_SHUTDOWN_COMPLETE
- def __init__(self, tflag, length):
+ def __init__(self, tflag=0, length=0):
assert (1 == tflag | 1)
super(chunk_shutdown_complete, self).__init__(
self.chunk_type(), length)
@@ -1103,6 +1156,8 @@ class chunk_shutdown_complete(chunk):
return msg
def serialize(self):
+ if 0 == self.length:
+ self.length = self._MIN_LEN
buf = struct.pack(
self._PACK_STR, self.chunk_type(),
self.tflag, self.length)
@@ -1152,7 +1207,7 @@ class cause_with_value(cause):
__metaclass__ = abc.ABCMeta
- def __init__(self, value, length=0):
+ def __init__(self, value=None, length=0):
super(cause_with_value, self).__init__(length)
self.value = value
@@ -1168,7 +1223,7 @@ class cause_with_value(cause):
def serialize(self):
buf = bytearray(struct.pack(
self._PACK_STR, self.cause_code(), self.length))
- if self.value:
+ if self.value is not None:
buf.extend(self.value)
if 0 == self.length:
self.length = len(buf)
@@ -1210,6 +1265,9 @@ class cause_invalid_stream_id(cause_with_value):
def cause_code(cls):
return CCODE_INVALID_STREAM_ID
+ def __init__(self, value=0, length=0):
+ super(cause_invalid_stream_id, self).__init__(value, length)
+
@classmethod
def parser(cls, buf):
(_, length, value) = struct.unpack_from(cls._PACK_STR, buf)
@@ -1612,7 +1670,7 @@ class cause_restart_with_new_addr(cause_with_value):
def cause_code(cls):
return CCODE_RESTART_WITH_NEW_ADDR
- def __init__(self, value, length=0):
+ def __init__(self, value=None, length=0):
if not isinstance(value, list):
value = [value]
super(cause_restart_with_new_addr, self).__init__(value, length)
@@ -1720,7 +1778,7 @@ class param(stringify.StringifyMixin):
def param_type(cls):
pass
- def __init__(self, value, length=0):
+ def __init__(self, value=None, length=0):
self.length = length
self.value = value
@@ -1866,6 +1924,9 @@ class param_cookie_preserve(param):
def param_type(cls):
return PTYPE_COOKIE_PRESERVE
+ def __init__(self, value=0, length=0):
+ super(param_cookie_preserve, self).__init__(value, length)
+
@classmethod
def parser(cls, buf):
(_, length, value) = struct.unpack_from(cls._PACK_STR, buf)
@@ -1973,7 +2034,7 @@ class param_supported_addr(param):
def param_type(cls):
return PTYPE_SUPPORTED_ADDR
- def __init__(self, value, length=0):
+ def __init__(self, value=None, length=0):
if not isinstance(value, list):
value = [value]
for one in value:
@@ -2037,6 +2098,9 @@ class param_ipv4(param):
def param_type(cls):
return PTYPE_IPV4
+ def __init__(self, value='127.0.0.1', length=0):
+ super(param_ipv4, self).__init__(value, length)
+
@classmethod
def parser(cls, buf):
(_, length) = struct.unpack_from(cls._PACK_STR, buf)
@@ -2089,6 +2153,9 @@ class param_ipv6(param):
def param_type(cls):
return PTYPE_IPV6
+ def __init__(self, value='::1', length=0):
+ super(param_ipv6, self).__init__(value, length)
+
@classmethod
def parser(cls, buf):
(_, length) = struct.unpack_from(cls._PACK_STR, buf)
diff --git a/ryu/tests/unit/packet/test_sctp.py b/ryu/tests/unit/packet/test_sctp.py
index 6f6132a4..ad50fdaf 100644
--- a/ryu/tests/unit/packet/test_sctp.py
+++ b/ryu/tests/unit/packet/test_sctp.py
@@ -60,8 +60,8 @@ class Test_sctp(unittest.TestCase):
self.payload_data = '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
self.data = sctp.chunk_data(
- self.unordered, self.begin, self.end, self.length, self.tsn,
- self.sid, self.seq, self.payload_id, self.payload_data)
+ unordered=self.unordered, begin=self.begin, end=self.end,
+ tsn=self.tsn, sid=self.sid, payload_data=self.payload_data)
self.chunks = [self.data]
@@ -89,12 +89,13 @@ class Test_sctp(unittest.TestCase):
self.p_support_type = sctp.param_supported_addr(
[sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE,
sctp.PTYPE_ECN, sctp.PTYPE_HOST_ADDR])
+ self.params = [
+ self.p_ipv4, self.p_ipv6, self.p_cookie_preserve,
+ self.p_ecn, self.p_host_addr, self.p_support_type]
self.init = sctp.chunk_init(
- self.flags, self.length, self.init_tag, self.a_rwnd,
- self.os, self.mis, self.i_tsn,
- [self.p_ipv4, self.p_ipv6, self.p_cookie_preserve,
- self.p_ecn, self.p_host_addr, self.p_support_type])
+ init_tag=self.init_tag, a_rwnd=self.a_rwnd, os=self.os,
+ mis=self.mis, i_tsn=self.i_tsn, params=self.params)
self.chunks = [self.init]
@@ -131,12 +132,13 @@ class Test_sctp(unittest.TestCase):
'\xff\xff\x00\x04')
self.p_ecn = sctp.param_ecn()
self.p_host_addr = sctp.param_host_addr('test host\x00')
+ self.params = [
+ self.p_state_cookie, self.p_ipv4, self.p_ipv6,
+ self.p_unrecognized_param, self.p_ecn, self.p_host_addr]
self.init_ack = sctp.chunk_init_ack(
- self.flags, self.length, self.init_tag, self.a_rwnd,
- self.os, self.mis, self.i_tsn,
- [self.p_state_cookie, self.p_ipv4, self.p_ipv6,
- self.p_unrecognized_param, self.p_ecn, self.p_host_addr])
+ init_tag=self.init_tag, a_rwnd=self.a_rwnd, os=self.os,
+ mis=self.mis, i_tsn=self.i_tsn, params=self.params)
self.chunks = [self.init_ack]
@@ -167,8 +169,9 @@ class Test_sctp(unittest.TestCase):
self.duptsns = [123458, 123466, 123476, 123507, 123518]
self.sack = sctp.chunk_sack(
- self.flags, self.length, self.tsn_ack, self.a_rwnd,
- self.gapack_num, self.duptsn_num, self.gapacks, self.duptsns)
+ tsn_ack=self.tsn_ack, a_rwnd=self.a_rwnd,
+ gapack_num=self.gapack_num, duptsn_num=self.duptsn_num,
+ gapacks=self.gapacks, duptsns=self.duptsns)
self.chunks = [self.sack]
@@ -189,8 +192,7 @@ class Test_sctp(unittest.TestCase):
self.p_heartbeat = sctp.param_heartbeat('\x01\x02\x03\x04')
- self.heartbeat = sctp.chunk_heartbeat(
- self.flags, self.length, self.p_heartbeat)
+ self.heartbeat = sctp.chunk_heartbeat(info=self.p_heartbeat)
self.chunks = [self.heartbeat]
@@ -209,8 +211,7 @@ class Test_sctp(unittest.TestCase):
self.p_heartbeat = sctp.param_heartbeat(
'\xff\xee\xdd\xcc\xbb\xaa\x99\x88')
- self.heartbeat_ack = sctp.chunk_heartbeat_ack(
- self.flags, self.length, self.p_heartbeat)
+ self.heartbeat_ack = sctp.chunk_heartbeat_ack(info=self.p_heartbeat)
self.chunks = [self.heartbeat_ack]
@@ -258,7 +259,7 @@ class Test_sctp(unittest.TestCase):
self.c_restart_with_new_addr, self.c_user_initiated_abort,
self.c_protocol_violation]
- self.abort = sctp.chunk_abort(self.tflag, self.length, self.causes)
+ self.abort = sctp.chunk_abort(causes=self.causes)
self.chunks = [self.abort]
@@ -294,8 +295,7 @@ class Test_sctp(unittest.TestCase):
self.length = 8
self.tsn_ack = 123456
- self.shutdown = sctp.chunk_shutdown(
- self.flags, self.length, self.tsn_ack)
+ self.shutdown = sctp.chunk_shutdown(tsn_ack=self.tsn_ack)
self.chunks = [self.shutdown]
@@ -309,8 +309,7 @@ class Test_sctp(unittest.TestCase):
self.flags = 0
self.length = 4
- self.shutdown_ack = sctp.chunk_shutdown_ack(
- self.flags, self.length)
+ self.shutdown_ack = sctp.chunk_shutdown_ack()
self.chunks = [self.shutdown_ack]
@@ -356,7 +355,7 @@ class Test_sctp(unittest.TestCase):
self.c_restart_with_new_addr, self.c_user_initiated_abort,
self.c_protocol_violation]
- self.error = sctp.chunk_error(self.flags, self.length, self.causes)
+ self.error = sctp.chunk_error(causes=self.causes)
self.chunks = [self.error]
@@ -392,8 +391,7 @@ class Test_sctp(unittest.TestCase):
self.length = 8
self.cookie = '\x12\x34\x56\x78'
- self.cookie_echo = sctp.chunk_cookie_echo(
- self.flags, self.length, self.cookie)
+ self.cookie_echo = sctp.chunk_cookie_echo(cookie=self.cookie)
self.chunks = [self.cookie_echo]
@@ -407,8 +405,7 @@ class Test_sctp(unittest.TestCase):
self.flags = 0
self.length = 4
- self.cookie_ack = sctp.chunk_cookie_ack(
- self.flags, self.length)
+ self.cookie_ack = sctp.chunk_cookie_ack()
self.chunks = [self.cookie_ack]
@@ -423,8 +420,7 @@ class Test_sctp(unittest.TestCase):
self.length = 8
self.low_tsn = 123456
- self.ecn_echo = sctp.chunk_ecn_echo(
- self.flags, self.length, self.low_tsn)
+ self.ecn_echo = sctp.chunk_ecn_echo(low_tsn=self.low_tsn)
self.chunks = [self.ecn_echo]
@@ -439,8 +435,7 @@ class Test_sctp(unittest.TestCase):
self.length = 8
self.low_tsn = 123456
- self.cwr = sctp.chunk_cwr(
- self.flags, self.length, self.low_tsn)
+ self.cwr = sctp.chunk_cwr(low_tsn=self.low_tsn)
self.chunks = [self.cwr]
@@ -454,8 +449,7 @@ class Test_sctp(unittest.TestCase):
self.tflag = 0
self.length = 4
- self.shutdown_complete = sctp.chunk_shutdown_complete(
- self.tflag, self.length)
+ self.shutdown_complete = sctp.chunk_shutdown_complete()
self.chunks = [self.shutdown_complete]
@@ -476,9 +470,7 @@ class Test_sctp(unittest.TestCase):
self.s_duptsns = None
self.sack = sctp.chunk_sack(
- self.s_flags, self.s_length, self.s_tsn_ack, self.s_a_rwnd,
- self.s_gapack_num, self.s_duptsn_num, self.s_gapacks,
- self.s_duptsns)
+ tsn_ack=self.s_tsn_ack, a_rwnd=self.s_a_rwnd)
self.d1_unordered = 0
self.d1_begin = 1
@@ -491,9 +483,8 @@ class Test_sctp(unittest.TestCase):
self.d1_payload_data = '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
self.data1 = sctp.chunk_data(
- self.d1_unordered, self.d1_begin, self.d1_end,
- self.d1_length, self.d1_tsn, self.d1_sid, self.d1_seq,
- self.d1_payload_id, self.d1_payload_data)
+ begin=self.d1_begin, tsn=self.d1_tsn, sid=self.d1_sid,
+ payload_data=self.d1_payload_data)
self.d2_unordered = 0
self.d2_begin = 0
@@ -506,9 +497,8 @@ class Test_sctp(unittest.TestCase):
self.d2_payload_data = '\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
self.data2 = sctp.chunk_data(
- self.d2_unordered, self.d2_begin, self.d2_end,
- self.d2_length, self.d2_tsn, self.d2_sid, self.d2_seq,
- self.d2_payload_id, self.d2_payload_data)
+ end=self.d2_end, tsn=self.d2_tsn, sid=self.d2_sid,
+ seq=self.d2_seq, payload_data=self.d2_payload_data)
self.chunks = [self.sack, self.data1, self.data2]