def setUp_with_data(self): self.unordered = 1 self.begin = 1 self.end = 1 self.length = 16 + 10 self.tsn = 12345 self.sid = 1 self.seq = 0 self.payload_id = 0 self.payload_data = b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" self.data = sctp.chunk_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] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += ( b"\x00\x07\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00" + b"\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" )
def setUp_with_sack(self): self.flags = 0 self.length = 16 + 2 * 2 * 5 + 4 * 5 self.tsn_ack = 123456 self.a_rwnd = 9876 self.gapack_num = 5 self.duptsn_num = 5 self.gapacks = [[2, 3], [10, 12], [20, 24], [51, 52], [62, 63]] self.duptsns = [123458, 123466, 123476, 123507, 123518] self.sack = sctp.chunk_sack( 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] self.sc = sctp.sctp( self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += '\x03\x00\x00\x38\x00\x01\xe2\x40' + \ '\x00\x00\x26\x94\x00\x05\x00\x05' + \ '\x00\x02\x00\x03\x00\x0a\x00\x0c\x00\x14\x00\x18' + \ '\x00\x33\x00\x34\x00\x3e\x00\x3f' + \ '\x00\x01\xe2\x42\x00\x01\xe2\x4a\x00\x01\xe2\x54' + \ '\x00\x01\xe2\x73\x00\x01\xe2\x7e'
def setUp(self): self.chunks = [] self.csum = 0 self.dst_port = 1234 self.src_port = 5678 self.vtag = 98765432 self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf = b"\x16\x2e\x04\xd2\x05\xe3\x0a\x78\x00\x00\x00\x00"
def setUp_with_shutdown_complete(self): self.tflag = 0 self.length = 4 self.shutdown_complete = sctp.chunk_shutdown_complete() self.chunks = [self.shutdown_complete] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x0e\x00\x00\x04"
def setUp_with_cookie_ack(self): self.flags = 0 self.length = 4 self.cookie_ack = sctp.chunk_cookie_ack() self.chunks = [self.cookie_ack] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x0b\x00\x00\x04"
def setUp_with_cookie_echo(self): self.flags = 0 self.length = 8 self.cookie = b"\x12\x34\x56\x78" self.cookie_echo = sctp.chunk_cookie_echo(cookie=self.cookie) self.chunks = [self.cookie_echo] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x0a\x00\x00\x08\x12\x34\x56\x78"
def setUp_with_shutdown(self): self.flags = 0 self.length = 8 self.tsn_ack = 123456 self.shutdown = sctp.chunk_shutdown(tsn_ack=self.tsn_ack) self.chunks = [self.shutdown] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x07\x00\x00\x08\x00\x01\xe2\x40"
def setUp_with_cwr(self): self.flags = 0 self.length = 8 self.low_tsn = 123456 self.cwr = sctp.chunk_cwr(low_tsn=self.low_tsn) self.chunks = [self.cwr] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x0d\x00\x00\x08\x00\x01\xe2\x40"
def setUp_with_ecn_echo(self): self.flags = 0 self.length = 8 self.low_tsn = 123456 self.ecn_echo = sctp.chunk_ecn_echo(low_tsn=self.low_tsn) self.chunks = [self.ecn_echo] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x0c\x00\x00\x08\x00\x01\xe2\x40"
def setUp_with_multi_chunks(self): self.s_flags = 0 self.s_length = 16 self.s_tsn_ack = 123456 self.s_a_rwnd = 9876 self.s_gapack_num = 0 self.s_duptsn_num = 0 self.s_gapacks = None self.s_duptsns = None self.sack = sctp.chunk_sack( tsn_ack=self.s_tsn_ack, a_rwnd=self.s_a_rwnd) self.d1_unordered = 0 self.d1_begin = 1 self.d1_end = 0 self.d1_length = 16 + 10 self.d1_tsn = 12345 self.d1_sid = 1 self.d1_seq = 0 self.d1_payload_id = 0 self.d1_payload_data = '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a' self.data1 = sctp.chunk_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 self.d2_end = 1 self.d2_length = 16 + 10 self.d2_tsn = 12346 self.d2_sid = 1 self.d2_seq = 1 self.d2_payload_id = 0 self.d2_payload_data = '\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a' self.data2 = sctp.chunk_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] self.sc = sctp.sctp( self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += '\x03\x00\x00\x10\x00\x01\xe2\x40' + \ '\x00\x00\x26\x94\x00\x00\x00\x00' + \ '\x00\x02\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00' + \ '\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a' + \ '\x00\x01\x00\x1a\x00\x00\x30\x3a\x00\x01\x00\x01' + \ '\x00\x00\x00\x00\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
def setUp_with_shutdown_ack(self): self.flags = 0 self.length = 4 self.shutdown_ack = sctp.chunk_shutdown_ack() self.chunks = [self.shutdown_ack] self.sc = sctp.sctp( self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += '\x08\x00\x00\x04'
def setUp_with_heartbeat_ack(self): self.flags = 0 self.length = 4 + 12 self.p_heartbeat = sctp.param_heartbeat(b"\xff\xee\xdd\xcc\xbb\xaa\x99\x88") self.heartbeat_ack = sctp.chunk_heartbeat_ack(info=self.p_heartbeat) self.chunks = [self.heartbeat_ack] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x05\x00\x00\x10" + b"\x00\x01\x00\x0c" + b"\xff\xee\xdd\xcc\xbb\xaa\x99\x88"
def setUp_with_heartbeat(self): self.flags = 0 self.length = 4 + 8 self.p_heartbeat = sctp.param_heartbeat(b"\x01\x02\x03\x04") self.heartbeat = sctp.chunk_heartbeat(info=self.p_heartbeat) self.chunks = [self.heartbeat] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += b"\x04\x00\x00\x0c" + b"\x00\x01\x00\x08" + b"\x01\x02\x03\x04"
def setUp_with_init(self): self.flags = 0 self.length = 20 + 8 + 20 + 8 + 4 + 16 + 16 self.init_tag = 123456 self.a_rwnd = 9876 self.os = 3 self.mis = 3 self.i_tsn = 123456 self.p_ipv4 = sctp.param_ipv4("192.168.1.1") self.p_ipv6 = sctp.param_ipv6("fe80::647e:1aff:fec4:8284") self.p_cookie_preserve = sctp.param_cookie_preserve(5000) self.p_ecn = sctp.param_ecn() self.p_host_addr = sctp.param_host_addr(b"test host\x00") 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( 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] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += ( b"\x01\x00\x00\x5c\x00\x01\xe2\x40\x00\x00\x26\x94" + b"\x00\x03\x00\x03\x00\x01\xe2\x40" + b"\x00\x05\x00\x08\xc0\xa8\x01\x01" + b"\x00\x06\x00\x14" + b"\xfe\x80\x00\x00\x00\x00\x00\x00" + b"\x64\x7e\x1a\xff\xfe\xc4\x82\x84" + b"\x00\x09\x00\x08\x00\x00\x13\x88" + b"\x80\x00\x00\x04" + b"\x00\x0b\x00\x0e" + b"\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00" + b"\x00\x0c\x00\x0e\x00\x05\x00\x06\x00\x09\x80\x00" + b"\x00\x0b\x00\x00" )
def setUp_with_init_ack(self): self.flags = 0 self.length = 20 + 8 + 8 + 20 + 8 + 4 + 16 self.init_tag = 123456 self.a_rwnd = 9876 self.os = 3 self.mis = 3 self.i_tsn = 123456 self.p_state_cookie = sctp.param_state_cookie(b"\x01\x02\x03") self.p_ipv4 = sctp.param_ipv4("192.168.1.1") self.p_ipv6 = sctp.param_ipv6("fe80::647e:1aff:fec4:8284") self.p_unrecognized_param = sctp.param_unrecognized_param(b"\xff\xff\x00\x04") self.p_ecn = sctp.param_ecn() self.p_host_addr = sctp.param_host_addr(b"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( 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] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += ( b"\x02\x00\x00\x54\x00\x01\xe2\x40\x00\x00\x26\x94" + b"\x00\x03\x00\x03\x00\x01\xe2\x40" + b"\x00\x07\x00\x07\x01\x02\x03\x00" + b"\x00\x05\x00\x08\xc0\xa8\x01\x01" + b"\x00\x06\x00\x14" + b"\xfe\x80\x00\x00\x00\x00\x00\x00" + b"\x64\x7e\x1a\xff\xfe\xc4\x82\x84" + b"\x00\x08\x00\x08\xff\xff\x00\x04" + b"\x80\x00\x00\x04" + b"\x00\x0b\x00\x0e" + b"\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00" )
def setUp_with_error(self): self.flags = 0 self.length = 4 + 8 + 16 + 8 + 4 + 20 + 8 + 4 + 8 + 8 + 4 + 12 \ + 20 + 20 self.c_invalid_stream_id = sctp.cause_invalid_stream_id(4096) self.c_missing_param = sctp.cause_missing_param( [sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR]) self.c_stale_cookie = sctp.cause_stale_cookie('\x00\x00\x13\x88') self.c_out_of_resource = sctp.cause_out_of_resource() self.c_unresolvable_addr = sctp.cause_unresolvable_addr( sctp.param_host_addr('test host\x00')) self.c_unrecognized_chunk = sctp.cause_unrecognized_chunk( '\xff\x00\x00\x04') self.c_invalid_param = sctp.cause_invalid_param() self.c_unrecognized_param = sctp.cause_unrecognized_param( '\xff\xff\x00\x04') self.c_no_userdata = sctp.cause_no_userdata('\x00\x01\xe2\x40') self.c_cookie_while_shutdown = sctp.cause_cookie_while_shutdown() self.c_restart_with_new_addr = sctp.cause_restart_with_new_addr( sctp.param_ipv4('192.168.1.1')) self.c_user_initiated_abort = sctp.cause_user_initiated_abort( 'Key Interrupt.\x00') self.c_protocol_violation = sctp.cause_protocol_violation( 'Unknown reason.\x00') self.causes = [ self.c_invalid_stream_id, self.c_missing_param, self.c_stale_cookie, self.c_out_of_resource, self.c_unresolvable_addr, self.c_unrecognized_chunk, self.c_invalid_param, self.c_unrecognized_param, self.c_no_userdata, self.c_cookie_while_shutdown, self.c_restart_with_new_addr, self.c_user_initiated_abort, self.c_protocol_violation] self.error = sctp.chunk_error(causes=self.causes) self.chunks = [self.error] self.sc = sctp.sctp( self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += '\x09\x00\x00\x90' + \ '\x00\x01\x00\x08\x10\x00\x00\x00' + \ '\x00\x02\x00\x10\x00\x00\x00\x04' + \ '\x00\x05\x00\x06\x00\x09\x00\x0b' + \ '\x00\x03\x00\x08\x00\x00\x13\x88' + \ '\x00\x04\x00\x04' + \ '\x00\x05\x00\x14' + \ '\x00\x0b\x00\x0e' + \ '\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \ '\x00\x06\x00\x08\xff\x00\x00\x04' + \ '\x00\x07\x00\x04' + \ '\x00\x08\x00\x08\xff\xff\x00\x04' + \ '\x00\x09\x00\x08\x00\x01\xe2\x40' + \ '\x00\x0a\x00\x04' + \ '\x00\x0b\x00\x0c' + \ '\x00\x05\x00\x08\xc0\xa8\x01\x01' + \ '\x00\x0c\x00\x13' + \ '\x4b\x65\x79\x20\x49\x6e\x74\x65' + \ '\x72\x72\x75\x70\x74\x2e\x00\x00' + \ '\x00\x0d\x00\x14' + \ '\x55\x6e\x6b\x6e\x6f\x77\x6e\x20' + \ '\x72\x65\x61\x73\x6f\x6e\x2e\x00'
def setUp_with_abort(self): self.tflag = 0 self.length = 4 + 8 + 16 + 8 + 4 + 20 + 8 + 4 + 8 + 8 + 4 + 12 + 20 + 20 self.c_invalid_stream_id = sctp.cause_invalid_stream_id(4096) self.c_missing_param = sctp.cause_missing_param( [sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR] ) self.c_stale_cookie = sctp.cause_stale_cookie(b"\x00\x00\x13\x88") self.c_out_of_resource = sctp.cause_out_of_resource() self.c_unresolvable_addr = sctp.cause_unresolvable_addr(sctp.param_host_addr(b"test host\x00")) self.c_unrecognized_chunk = sctp.cause_unrecognized_chunk(b"\xff\x00\x00\x04") self.c_invalid_param = sctp.cause_invalid_param() self.c_unrecognized_param = sctp.cause_unrecognized_param(b"\xff\xff\x00\x04") self.c_no_userdata = sctp.cause_no_userdata(b"\x00\x01\xe2\x40") self.c_cookie_while_shutdown = sctp.cause_cookie_while_shutdown() self.c_restart_with_new_addr = sctp.cause_restart_with_new_addr(sctp.param_ipv4("192.168.1.1")) self.c_user_initiated_abort = sctp.cause_user_initiated_abort(b"Key Interrupt.\x00") self.c_protocol_violation = sctp.cause_protocol_violation(b"Unknown reason.\x00") self.causes = [ self.c_invalid_stream_id, self.c_missing_param, self.c_stale_cookie, self.c_out_of_resource, self.c_unresolvable_addr, self.c_unrecognized_chunk, self.c_invalid_param, self.c_unrecognized_param, self.c_no_userdata, self.c_cookie_while_shutdown, self.c_restart_with_new_addr, self.c_user_initiated_abort, self.c_protocol_violation, ] self.abort = sctp.chunk_abort(causes=self.causes) self.chunks = [self.abort] self.sc = sctp.sctp(self.src_port, self.dst_port, self.vtag, self.csum, self.chunks) self.buf += ( b"\x06\x00\x00\x90" + b"\x00\x01\x00\x08\x10\x00\x00\x00" + b"\x00\x02\x00\x10\x00\x00\x00\x04" + b"\x00\x05\x00\x06\x00\x09\x00\x0b" + b"\x00\x03\x00\x08\x00\x00\x13\x88" + b"\x00\x04\x00\x04" + b"\x00\x05\x00\x14" + b"\x00\x0b\x00\x0e" + b"\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00" + b"\x00\x06\x00\x08\xff\x00\x00\x04" + b"\x00\x07\x00\x04" + b"\x00\x08\x00\x08\xff\xff\x00\x04" + b"\x00\x09\x00\x08\x00\x01\xe2\x40" + b"\x00\x0a\x00\x04" + b"\x00\x0b\x00\x0c" + b"\x00\x05\x00\x08\xc0\xa8\x01\x01" + b"\x00\x0c\x00\x13" + b"\x4b\x65\x79\x20\x49\x6e\x74\x65" + b"\x72\x72\x75\x70\x74\x2e\x00\x00" + b"\x00\x0d\x00\x14" + b"\x55\x6e\x6b\x6e\x6f\x77\x6e\x20" + b"\x72\x65\x61\x73\x6f\x6e\x2e\x00" )