This implements the active close state set (FIN_WAIT_1, CLOSING,
FIN_WAIT_2, TIME_WAIT).
Change-Id: Id146ba3d6a774bfeac93401779a246fd32e2c523
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This transitions a connection to FIN_WAIT_1 state if it was in either
SYN_RCVD or ESTABLISHED states and the local peer decided to close the
connection.
A timer is started to close the connection after 2 MSL (which is 120
seconds; this might be easily tunable through kconfig). No transition
from this state to FIN_WAIT_2, CLOSING, or TIME_WAIT are implemented on
this change: oncoming changes will implement the rest of this
machinery.
Change-Id: Ic9e2eceef81a82fb37c0a829860cfcf52f424475
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Instead of having to write "NET_TCP_BUF(buf)->flags & NET_TCP_CTL"
every single time, provide a NET_TCP_FLAGS macro that expands to this
expression.
Change-Id: Ie876c538599fabae6b800a53613b6ad17dc45620
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
My previous race cleanup missed the fact that the memset would end up
clearing the IN_USE flag! So we were always allocating the same
struct net_tcp (which, because the typical use is to listen on one
socket and then transfer on an accepted socket, almost kinda worked
for a lot of stuff, making this hard to find).
Change-Id: I8ca0c7f835ebd72271df10d03004f38f8b8efbd5
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The receive window was always being filled as zero, and the
implementation of get_recv_wnd is awfully confusing as to what was
intended.
But this logic is needless anyway, the current architecture hands off
each received packet to a receive callback synchronously. There is no
queueing inside the stack, so the window size never needs to change.
The only complexity is that there appear to be two existing tunables
that affect it, we have to pick a (compile time) minimum.
Note this also removes the recv_wnd from struct net_tcp, as it no
longer needs to be tracked.
Change-Id: I58c7b2753f4714f4751d64630ca7f09823b5a6a8
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Print TCP flags in a similar fashion to tcpdump, where uppercase
characters mean a particular flag is set, and lowercase characters mean
a particular flag is unset.
Supported flags by net_tcp_trace() remain the same: FIN, SYN, RST, PSH,
ACK, and URG, respectively represented by the letters 'f', 's', 'r',
'p', 'a', and 'u'.
Change-Id: Iaeb0b5c4fa5b4ab2b877d523b155dc431e9fc909
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Instead of defining the poorly-named a2u32() and a2u16() functions
inside tcp.c, use macros provided in <misc/byteorder.h> to obtain
unsigned 32- and 16-bit values instead.
Change-Id: I344fe0e495c574cb8cc717036154221e912b4406
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
A bunch of if's are a poor substitute for straightforward interval
checking. You just have to be careful about the sign.
Also the seq_equal() routine was unused.
Change-Id: Id3a627ff75c8ab9889f226c733faa3fcb38207a7
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Move the IN_USE clear in net_tcp_release() to the END of the function
after the destruction is complete so someone else doesn't allocate it
while we're still cleaning it up.
Also, operations on the IN_USE flag need to be atomic for correctness.
Stick an irq_lock() around them.
Change-Id: I9d7557244fc8de5b0c69fd0bc749a9e28fa19a54
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Big chunks of this struct were essentially unused:
+ The prev_state field was stored at state change but never inspected.
+ The send_wnd, send_max_wnd, send_cwnd, send_pcount and
send_ss_threshold fields were simply unused.
+ The recv_scale field was never initialized to anything but zero,
remove the support. Windows greater than 64k seem very unlikely to
be useful to Zephyr anyway; if we actually want window scaling (in
either direction -- there are large memory costs!) it should
probably be optional via Kconfig. We surely don't want to carry
this for all builds.
+ The buf_max_len field was hard-coded static, replace with a #define
+ Double-memset of the ack_timer field in initialization
Change-Id: I223665518529dc6a7f267bbc6992a645a30f5735
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This creates initial TCP handling logic but does not yet
enable fully working TCP connection.
Some of the connection logic is taken from FNET TCP
implementation.
Origin: FNET 3.6.1
URL: https://github.com/butok/FNET/blob/master/fnet_stack/stack/fnet_tcp.c
Change-Id: I1e100d9fa9c91437562b933d94d0bd3db1a5885e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>