summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2013-10-22 14:56:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-10-23 11:53:23 +0900
commit208fe1d16b302e2e99fe080757b3aa786b8ff26e (patch)
treedb84806610e65ea21689308acbdfd4edc2571daa
parentaa2b5a054ce05ba3735e26310e1e84115493f105 (diff)
packet lib: sctp: add tests for protocol stack
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/unit/packet/test_sctp.py89
1 files changed, 89 insertions, 0 deletions
diff --git a/ryu/tests/unit/packet/test_sctp.py b/ryu/tests/unit/packet/test_sctp.py
index 09bcd336..adacb96a 100644
--- a/ryu/tests/unit/packet/test_sctp.py
+++ b/ryu/tests/unit/packet/test_sctp.py
@@ -20,8 +20,14 @@ import struct
import unittest
from nose.tools import eq_
+from nose.tools import ok_
from ryu.lib import addrconv
+from ryu.lib.packet import packet
+from ryu.lib.packet import ethernet
+from ryu.lib.packet import ipv4
from ryu.lib.packet import sctp
+from ryu.ofproto import ether
+from ryu.ofproto import inet
LOG = logging.getLogger(__name__)
@@ -1228,6 +1234,89 @@ class Test_sctp(unittest.TestCase):
buf[sctp.chunk_data._MIN_LEN:
sctp.chunk_data._MIN_LEN + 10])
+ def test_build_sctp(self):
+ eth = ethernet.ethernet('00:aa:aa:aa:aa:aa', '00:bb:bb:bb:bb:bb',
+ ether.ETH_TYPE_IP)
+ ip4 = ipv4.ipv4(4, 5, 16, 0, 0, 2, 0, 64, inet.IPPROTO_SCTP, 0,
+ '192.168.1.1', '10.144.1.1')
+ pkt = eth/ip4/self.sc
+
+ eth = pkt.get_protocol(ethernet.ethernet)
+ ok_(eth)
+ eq_(eth.ethertype, ether.ETH_TYPE_IP)
+
+ ip4 = pkt.get_protocol(ipv4.ipv4)
+ ok_(ip4)
+ eq_(ip4.proto, inet.IPPROTO_SCTP)
+
+ sc = pkt.get_protocol(sctp.sctp)
+ ok_(sc)
+ eq_(sc, self.sc)
+
+ def test_build_sctp_with_data(self):
+ self.setUp_with_data()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_init(self):
+ self.setUp_with_init()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_init_ack(self):
+ self.setUp_with_init_ack()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_sack(self):
+ self.setUp_with_sack()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_heartbeat(self):
+ self.setUp_with_heartbeat()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_heartbeat_ack(self):
+ self.setUp_with_heartbeat_ack()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_abort(self):
+ self.setUp_with_abort()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_shutdown(self):
+ self.setUp_with_shutdown()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_shutdown_ack(self):
+ self.setUp_with_shutdown_ack()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_error(self):
+ self.setUp_with_error()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_cookie_echo(self):
+ self.setUp_with_cookie_echo()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_cookie_ack(self):
+ self.setUp_with_cookie_ack()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_ecn_echo(self):
+ self.setUp_with_ecn_echo()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_cwr(self):
+ self.setUp_with_cwr()
+ self.test_build_sctp()
+
+ def test_build_sctp_with_shutdown_complete(self):
+ self.setUp_with_shutdown_complete()
+ self.test_build_sctp()
+
+ def tset_build_sctp_with_multi_chunks(self):
+ self.setUp_with_multi_chunks()
+ self.test_build_sctp()
+
def test_to_string(self):
sctp_values = {'src_port': self.src_port,
'dst_port': self.dst_port,