Ejemplo n.º 1
0
    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"
        )
Ejemplo n.º 2
0
    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"
        )
Ejemplo n.º 3
0
    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'
Ejemplo n.º 4
0
    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"
        )