mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
This commit adds support for TCP Fast Open, without cookie management. To add support for this, I looked at the FreeBSD codebase and brought in some code from FreeBSD 12.0 that implements TCP Fast Open --- the version of FreeBSD that TCPlp is based on did not fully support TCP Fast Open. Normally, a part of TFO is cookie management --- the server generates a cookie and includes it in the initial handshake, and client is expected to present this cookie on future handshakes. This part is not yet implemented, and I changed the logic from FreeBSD to allow data to be exchanged in the TFO handshake even if the client does not present a cookie. If we implement this functionality for TFO later, it is probably worth departing from FreeBSD's data structures and policies for maintaining cookie state in favor of something that is simpler and more memory-efficient.
113 lines
3.2 KiB
Plaintext
Executable File
113 lines
3.2 KiB
Plaintext
Executable File
#!/usr/bin/expect -f
|
|
#
|
|
# Copyright (c) 2023, The OpenThread Authors.
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
# 3. Neither the name of the copyright holder nor the
|
|
# names of its contributors may be used to endorse or promote products
|
|
# derived from this software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
|
|
source "tests/scripts/expect/_common.exp"
|
|
source "tests/scripts/expect/_multinode.exp"
|
|
|
|
spawn_node 2 "cli"
|
|
spawn_node 1 "cli"
|
|
setup_leader
|
|
setup_node 2 "rnd" "router"
|
|
|
|
switch_node 1
|
|
send "tcp init tls\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 2
|
|
send "tcp init tls\n"
|
|
expect_line "Done"
|
|
set addr_2 [get_ipaddr mleid]
|
|
send "tcp listen :: 30000\n"
|
|
expect_line "Done"
|
|
send "tcp stoplistening\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 1
|
|
send "tcp connect $addr_2 30000\n"
|
|
expect_line "Done"
|
|
expect "TCP: Connection refused"
|
|
|
|
switch_node 2
|
|
send "tcp listen :: 30000\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 1
|
|
set addr_1 [get_ipaddr mleid]
|
|
send "tcp bind $addr_1 25000\n"
|
|
expect_line "Done"
|
|
send "tcp connect $addr_2 30000 fast\n"
|
|
expect_line "Done"
|
|
expect "TCP: Connection established"
|
|
expect "TLS Handshake Complete"
|
|
|
|
switch_node 2
|
|
expect "Accepted connection from \\\[$addr_1\\\]:25000"
|
|
expect "TCP: Connection established"
|
|
expect "TLS Handshake Complete"
|
|
|
|
switch_node 1
|
|
send "tcp send hello\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 2
|
|
expect "TLS: Received 5 bytes: hello"
|
|
expect "(TCP: Received 26 bytes)"
|
|
send "tcp send world\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 1
|
|
expect "TLS: Received 5 bytes: world"
|
|
expect "(TCP: Received 26 bytes)"
|
|
send "tcp sendend\n"
|
|
expect_line "Done"
|
|
send "tcp send more\n"
|
|
expect_line "Error 1: Failed"
|
|
|
|
switch_node 2
|
|
expect "TCP: Reached end of stream"
|
|
send "tcp send goodbye\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 1
|
|
expect "TLS: Received 7 bytes: goodbye"
|
|
expect "(TCP: Received 28 bytes)"
|
|
|
|
switch_node 2
|
|
send "tcp sendend\n"
|
|
expect_line "Done"
|
|
expect "TCP: Disconnected"
|
|
|
|
switch_node 1
|
|
expect "TCP: Reached end of stream"
|
|
expect "TCP: Entered TIME-WAIT state"
|
|
set timeout 130
|
|
expect "TCP: Disconnected"
|
|
|
|
dispose_all
|