2014-06-21 23:23:39 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/tcp/tcp.h
|
|
|
|
*
|
2024-09-11 14:39:39 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-01-15 03:44:35 +01:00
|
|
|
#ifndef __NET_TCP_TCP_H
|
|
|
|
#define __NET_TCP_TCP_H
|
2014-06-21 23:23:39 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2014-06-24 16:03:44 +02:00
|
|
|
#include <sys/types.h>
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2018-03-12 17:59:46 +01:00
|
|
|
#include <nuttx/clock.h>
|
2022-09-25 17:08:38 +02:00
|
|
|
#include <nuttx/queue.h>
|
2021-07-19 15:45:46 +02:00
|
|
|
#include <nuttx/semaphore.h>
|
2017-05-09 15:34:59 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
2014-07-06 20:34:27 +02:00
|
|
|
#include <nuttx/net/ip.h>
|
2022-02-07 04:49:41 +01:00
|
|
|
#include <nuttx/net/net.h>
|
2022-11-23 12:39:40 +01:00
|
|
|
#include <nuttx/net/tcp.h>
|
2022-04-25 17:08:24 +02:00
|
|
|
#include <nuttx/wqueue.h>
|
2018-09-09 23:01:44 +02:00
|
|
|
|
2022-10-31 04:10:04 +01:00
|
|
|
#ifdef CONFIG_NET_TCP
|
2014-06-21 23:23:39 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2017-03-31 16:58:14 +02:00
|
|
|
|
2022-10-31 04:10:04 +01:00
|
|
|
/* This is a helper pointer for accessing the contents of the tcp header */
|
|
|
|
|
|
|
|
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv4_HDRLEN))
|
|
|
|
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv6_HDRLEN))
|
|
|
|
|
|
|
|
#ifndef CONFIG_NET_TCP_NO_STACK
|
|
|
|
|
2017-03-31 16:58:14 +02:00
|
|
|
#define NET_TCP_HAVE_STACK 1
|
|
|
|
|
2014-06-29 02:36:09 +02:00
|
|
|
/* Allocate a new TCP data callback */
|
|
|
|
|
2015-05-30 19:29:47 +02:00
|
|
|
/* These macros allocate and free callback structures used for receiving
|
|
|
|
* notifications of TCP data-related events.
|
|
|
|
*/
|
|
|
|
|
2017-08-08 22:24:12 +02:00
|
|
|
#define tcp_callback_alloc(conn) \
|
2022-02-07 04:49:41 +01:00
|
|
|
devif_callback_alloc((conn)->dev, &(conn)->sconn.list, &(conn)->sconn.list_tail)
|
2017-08-08 22:24:12 +02:00
|
|
|
#define tcp_callback_free(conn,cb) \
|
2022-02-07 04:49:41 +01:00
|
|
|
devif_conn_callback_free((conn)->dev, (cb), &(conn)->sconn.list, &(conn)->sconn.list_tail)
|
2015-05-30 19:29:47 +02:00
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
/* TCP write buffer access macros */
|
|
|
|
|
2018-01-23 02:33:14 +01:00
|
|
|
# define TCP_WBSEQNO(wrb) ((wrb)->wb_seqno)
|
|
|
|
# define TCP_WBPKTLEN(wrb) ((wrb)->wb_iob->io_pktlen)
|
|
|
|
# define TCP_WBSENT(wrb) ((wrb)->wb_sent)
|
|
|
|
# define TCP_WBNRTX(wrb) ((wrb)->wb_nrtx)
|
2023-04-20 05:08:02 +02:00
|
|
|
#if defined(CONFIG_NET_TCP_FAST_RETRANSMIT) && !defined(CONFIG_NET_TCP_CC_NEWRENO)
|
net/tcp: implement the fast retransmit
RFC2001: TCP Slow Start, Congestion Avoidance, Fast Retransmit,
and Fast Recovery Algorithms
...
3. Fast Retransmit
Modifications to the congestion avoidance algorithm were proposed in
1990 [3]. Before describing the change, realize that TCP may
generate an immediate acknowledgment (a duplicate ACK) when an out-
of-order segment is received (Section 4.2.2.21 of [1], with a note
that one reason for doing so was for the experimental fast-
retransmit algorithm). This duplicate ACK should not be delayed.
The purpose of this duplicate ACK is to let the other end know that a
segment was received out of order, and to tell it what sequence
number is expected.
Since TCP does not know whether a duplicate ACK is caused by a lost
segment or just a reordering of segments, it waits for a small number
of duplicate ACKs to be received. It is assumed that if there is
just a reordering of the segments, there will be only one or two
duplicate ACKs before the reordered segment is processed, which will
then generate a new ACK. If three or more duplicate ACKs are
received in a row, it is a strong indication that a segment has been
lost. TCP then performs a retransmission of what appears to be the
missing segment, without waiting for a retransmission timer to
expire.
Change-Id: Ie2cbcecab507c3d831f74390a6a85e0c5c8e0652
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-10-22 09:02:52 +02:00
|
|
|
# define TCP_WBNACK(wrb) ((wrb)->wb_nack)
|
2022-01-25 18:49:04 +01:00
|
|
|
#endif
|
2018-01-23 02:33:14 +01:00
|
|
|
# define TCP_WBIOB(wrb) ((wrb)->wb_iob)
|
|
|
|
# define TCP_WBCOPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0))
|
tcp_send_buffered.c: improve tcp write buffering
* Send data chunk-by-chunk
Note: A stream socket doesn't have atomicity requirement.
* Increase the chance to use full-sized segments
Benchmark numbers in my environment:
* Over ESP32 wifi
* The peer is NetBSD, which has traditional delayed ack TCP
* iperf uses 16384 bytes buffer
---
without this patch,
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
does not work.
see https://github.com/apache/incubator-nuttx/pull/2772#discussion_r592820639
---
without this patch,
CONFIG_IOB_NBUFFERS=128
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 4.11 Mbits/sec
3- 6 sec, 4.63 Mbits/sec
6- 9 sec, 4.89 Mbits/sec
9- 12 sec, 4.63 Mbits/sec
12- 15 sec, 4.85 Mbits/sec
15- 18 sec, 4.85 Mbits/sec
18- 21 sec, 5.02 Mbits/sec
21- 24 sec, 3.67 Mbits/sec
24- 27 sec, 4.94 Mbits/sec
27- 30 sec, 4.81 Mbits/sec
0- 30 sec, 4.64 Mbits/sec
nsh>
```
---
with this patch,
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 5.33 Mbits/sec
3- 6 sec, 5.59 Mbits/sec
6- 9 sec, 5.55 Mbits/sec
9- 12 sec, 5.59 Mbits/sec
12- 15 sec, 5.59 Mbits/sec
15- 18 sec, 5.72 Mbits/sec
18- 21 sec, 5.68 Mbits/sec
21- 24 sec, 5.29 Mbits/sec
24- 27 sec, 4.67 Mbits/sec
27- 30 sec, 4.50 Mbits/sec
0- 30 sec, 5.35 Mbits/sec
nsh>
```
---
with this patch,
CONFIG_IOB_NBUFFERS=128
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 5.51 Mbits/sec
3- 6 sec, 4.67 Mbits/sec
6- 9 sec, 4.54 Mbits/sec
9- 12 sec, 5.42 Mbits/sec
12- 15 sec, 5.37 Mbits/sec
15- 18 sec, 5.11 Mbits/sec
18- 21 sec, 5.07 Mbits/sec
21- 24 sec, 5.29 Mbits/sec
24- 27 sec, 5.77 Mbits/sec
27- 30 sec, 4.63 Mbits/sec
0- 30 sec, 5.14 Mbits/sec
nsh>
```
2021-03-15 08:19:42 +01:00
|
|
|
# define TCP_WBCOPYIN(wrb,src,n,off) \
|
2022-08-08 04:21:03 +02:00
|
|
|
(iob_copyin((wrb)->wb_iob,src,(n),(off),true))
|
tcp_send_buffered.c: improve tcp write buffering
* Send data chunk-by-chunk
Note: A stream socket doesn't have atomicity requirement.
* Increase the chance to use full-sized segments
Benchmark numbers in my environment:
* Over ESP32 wifi
* The peer is NetBSD, which has traditional delayed ack TCP
* iperf uses 16384 bytes buffer
---
without this patch,
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
does not work.
see https://github.com/apache/incubator-nuttx/pull/2772#discussion_r592820639
---
without this patch,
CONFIG_IOB_NBUFFERS=128
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 4.11 Mbits/sec
3- 6 sec, 4.63 Mbits/sec
6- 9 sec, 4.89 Mbits/sec
9- 12 sec, 4.63 Mbits/sec
12- 15 sec, 4.85 Mbits/sec
15- 18 sec, 4.85 Mbits/sec
18- 21 sec, 5.02 Mbits/sec
21- 24 sec, 3.67 Mbits/sec
24- 27 sec, 4.94 Mbits/sec
27- 30 sec, 4.81 Mbits/sec
0- 30 sec, 4.64 Mbits/sec
nsh>
```
---
with this patch,
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 5.33 Mbits/sec
3- 6 sec, 5.59 Mbits/sec
6- 9 sec, 5.55 Mbits/sec
9- 12 sec, 5.59 Mbits/sec
12- 15 sec, 5.59 Mbits/sec
15- 18 sec, 5.72 Mbits/sec
18- 21 sec, 5.68 Mbits/sec
21- 24 sec, 5.29 Mbits/sec
24- 27 sec, 4.67 Mbits/sec
27- 30 sec, 4.50 Mbits/sec
0- 30 sec, 5.35 Mbits/sec
nsh>
```
---
with this patch,
CONFIG_IOB_NBUFFERS=128
CONFIG_IOB_BUFSIZE=196
```
nsh> iperf -c 192.168.8.1
IP: 192.168.8.103
mode=tcp-client sip=192.168.8.103:5001,dip=192.168.8.1:5001, interval=3, time=30
Interval Bandwidth
0- 3 sec, 5.51 Mbits/sec
3- 6 sec, 4.67 Mbits/sec
6- 9 sec, 4.54 Mbits/sec
9- 12 sec, 5.42 Mbits/sec
12- 15 sec, 5.37 Mbits/sec
15- 18 sec, 5.11 Mbits/sec
18- 21 sec, 5.07 Mbits/sec
21- 24 sec, 5.29 Mbits/sec
24- 27 sec, 5.77 Mbits/sec
27- 30 sec, 4.63 Mbits/sec
0- 30 sec, 5.14 Mbits/sec
nsh>
```
2021-03-15 08:19:42 +01:00
|
|
|
# define TCP_WBTRYCOPYIN(wrb,src,n,off) \
|
2022-08-08 04:21:03 +02:00
|
|
|
(iob_trycopyin((wrb)->wb_iob,src,(n),(off),true))
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2018-01-23 02:33:14 +01:00
|
|
|
# define TCP_WBTRIM(wrb,n) \
|
2022-08-08 04:21:03 +02:00
|
|
|
do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0)
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2016-06-11 22:14:08 +02:00
|
|
|
#ifdef CONFIG_DEBUG_FEATURES
|
2018-01-23 02:33:14 +01:00
|
|
|
# define TCP_WBDUMP(msg,wrb,len,offset) \
|
2014-07-06 20:34:27 +02:00
|
|
|
tcp_wrbuffer_dump(msg,wrb,len,offset)
|
2018-01-22 18:11:23 +01:00
|
|
|
# else
|
2018-01-23 02:33:14 +01:00
|
|
|
# define TCP_WBDUMP(msg,wrb,len,offset)
|
2018-01-22 18:11:23 +01:00
|
|
|
# endif
|
2014-07-06 20:34:27 +02:00
|
|
|
#endif
|
|
|
|
|
2021-06-01 06:48:47 +02:00
|
|
|
/* 32-bit modular arithmetics for tcp sequence numbers */
|
|
|
|
|
2023-07-11 14:36:33 +02:00
|
|
|
#define TCP_SEQ_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
|
|
|
#define TCP_SEQ_GT(a, b) TCP_SEQ_LT(b, a)
|
|
|
|
#define TCP_SEQ_LTE(a, b) (!TCP_SEQ_GT(a, b))
|
|
|
|
#define TCP_SEQ_GTE(a, b) (!TCP_SEQ_LT(a, b))
|
2021-06-01 06:48:47 +02:00
|
|
|
|
2023-07-11 14:36:33 +02:00
|
|
|
#define TCP_SEQ_ADD(a, b) ((uint32_t)((a) + (b)))
|
|
|
|
#define TCP_SEQ_SUB(a, b) ((uint32_t)((a) - (b)))
|
2021-06-01 06:48:47 +02:00
|
|
|
|
2021-07-05 11:28:11 +02:00
|
|
|
/* The TCP options flags */
|
|
|
|
|
|
|
|
#define TCP_WSCALE 0x01U /* Window Scale option enabled */
|
2023-01-10 06:41:02 +01:00
|
|
|
#define TCP_SACK 0x02U /* Selective ACKs enabled */
|
2023-05-26 10:44:34 +02:00
|
|
|
#define TCP_CLOSE_ARRANGED 0x04U /* Connection is arranged to be freed */
|
2021-07-05 11:28:11 +02:00
|
|
|
|
2023-04-20 05:08:02 +02:00
|
|
|
#ifdef CONFIG_NET_TCP_CC_NEWRENO
|
|
|
|
/* The TCP flags for congestion control */
|
|
|
|
|
2023-05-26 10:44:34 +02:00
|
|
|
#define TCP_INFR 0x08U /* The flag in Fast Recovery */
|
|
|
|
#define TCP_INFT 0x10U /* The flag in Fast Transmitted */
|
2023-04-20 05:08:02 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2023-01-06 08:30:58 +01:00
|
|
|
/* The Max Range count of TCP Selective ACKs */
|
|
|
|
|
|
|
|
#define TCP_SACK_RANGES_MAX 4
|
|
|
|
|
2022-01-25 18:49:04 +01:00
|
|
|
/* After receiving 3 duplicate ACKs, TCP performs a retransmission
|
|
|
|
* (RFC 5681 (3.2))
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define TCP_FAST_RETRANSMISSION_THRESH 3
|
|
|
|
|
2023-06-20 13:43:37 +02:00
|
|
|
#define TCP_RTO_MAX 240 /* 120s,The unit is half a second */
|
|
|
|
#define TCP_RTO_MIN 1 /* 0.5s */
|
|
|
|
|
2014-06-21 23:23:39 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
2016-02-26 14:35:55 +01:00
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
struct file; /* Forward reference */
|
|
|
|
struct sockaddr; /* Forward reference */
|
|
|
|
struct socket; /* Forward reference */
|
|
|
|
struct pollfd; /* Forward reference */
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/* Representation of a TCP connection.
|
|
|
|
*
|
|
|
|
* The tcp_conn_s structure is used for identifying a connection. All
|
|
|
|
* but one field in the structure are to be considered read-only by an
|
|
|
|
* application. The only exception is the 'private' fields whose purpose
|
|
|
|
* is to let the application store application-specific state (e.g.,
|
|
|
|
* file pointers) for the connection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct net_driver_s; /* Forward reference */
|
|
|
|
struct devif_callback_s; /* Forward reference */
|
|
|
|
struct tcp_backlog_s; /* Forward reference */
|
2015-01-15 22:06:46 +01:00
|
|
|
struct tcp_hdr_s; /* Forward reference */
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
/* This is a container that holds the poll-related information */
|
|
|
|
|
|
|
|
struct tcp_poll_s
|
|
|
|
{
|
2022-02-08 17:08:15 +01:00
|
|
|
FAR struct tcp_conn_s *conn; /* Needed to handle loss of connection */
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct pollfd *fds; /* Needed to handle poll events */
|
2019-12-31 16:26:14 +01:00
|
|
|
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
|
|
|
|
};
|
|
|
|
|
2023-01-06 08:30:58 +01:00
|
|
|
/* Out-of-order segments */
|
|
|
|
|
|
|
|
struct tcp_ofoseg_s
|
|
|
|
{
|
|
|
|
uint32_t left; /* Left edge of segment */
|
|
|
|
uint32_t right; /* Right edge of segment */
|
|
|
|
FAR struct iob_s *data; /* Out-of-order buffering */
|
|
|
|
};
|
|
|
|
|
2023-01-10 06:41:02 +01:00
|
|
|
/* SACK ranges to include in ACK packets. */
|
|
|
|
|
|
|
|
struct tcp_sack_s
|
|
|
|
{
|
|
|
|
uint32_t left; /* Left edge of the SACK */
|
|
|
|
uint32_t right; /* Right edge of the SACK */
|
|
|
|
};
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
struct tcp_conn_s
|
|
|
|
{
|
2019-09-01 16:47:01 +02:00
|
|
|
/* Common prologue of all connection structures. */
|
|
|
|
|
|
|
|
/* TCP callbacks:
|
|
|
|
*
|
|
|
|
* Data transfer events are retained in 'list'. Event handlers in 'list'
|
|
|
|
* are called for events specified in the flags set within struct
|
|
|
|
* devif_callback_s
|
|
|
|
*
|
|
|
|
* When an callback is executed from 'list', the input flags are normally
|
|
|
|
* returned, however, the implementation may set one of the following:
|
|
|
|
*
|
|
|
|
* TCP_CLOSE - Gracefully close the current connection
|
|
|
|
* TCP_ABORT - Abort (reset) the current connection on an error that
|
|
|
|
* prevents TCP_CLOSE from working.
|
|
|
|
*
|
|
|
|
* And/Or set/clear the following:
|
|
|
|
*
|
|
|
|
* TCP_NEWDATA - May be cleared to indicate that the data was consumed
|
|
|
|
* and that no further process of the new data should be
|
|
|
|
* attempted.
|
2019-12-31 07:44:44 +01:00
|
|
|
* TCP_SNDACK - If TCP_NEWDATA is cleared, then TCP_SNDACK may be set to
|
|
|
|
* indicate that an ACK should be included in the response.
|
|
|
|
* (In TCP_NEWDATA is cleared bu TCP_SNDACK is not set,
|
|
|
|
* then dev->d_len should also be cleared).
|
2019-09-01 16:47:01 +02:00
|
|
|
*/
|
|
|
|
|
2022-02-07 04:49:41 +01:00
|
|
|
struct socket_conn_s sconn;
|
2019-09-01 16:47:01 +02:00
|
|
|
|
|
|
|
/* TCP-specific content follows */
|
|
|
|
|
2015-01-16 17:01:54 +01:00
|
|
|
union ip_binding_u u; /* IP address binding */
|
2014-07-06 20:34:27 +02:00
|
|
|
uint8_t rcvseq[4]; /* The sequence number that we expect to
|
|
|
|
* receive next */
|
|
|
|
uint8_t sndseq[4]; /* The sequence number that was last sent by us */
|
2022-07-03 18:58:44 +02:00
|
|
|
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS) || \
|
|
|
|
defined(CONFIG_NET_SENDFILE)
|
2021-10-12 06:15:54 +02:00
|
|
|
uint32_t rexmit_seq; /* The sequence number to be retrasmitted */
|
2022-07-03 18:58:44 +02:00
|
|
|
#endif
|
2014-07-06 20:34:27 +02:00
|
|
|
uint8_t crefs; /* Reference counts on this instance */
|
2015-01-17 21:13:56 +01:00
|
|
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
2016-02-26 13:45:37 +01:00
|
|
|
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
2015-01-17 21:13:56 +01:00
|
|
|
#endif
|
2014-07-06 20:34:27 +02:00
|
|
|
uint8_t sa; /* Retransmission time-out calculation state
|
|
|
|
* variable */
|
|
|
|
uint8_t sv; /* Retransmission time-out calculation state
|
|
|
|
* variable */
|
|
|
|
uint8_t rto; /* Retransmission time-out */
|
|
|
|
uint8_t tcpstateflags; /* TCP state and flags */
|
2022-04-25 17:08:24 +02:00
|
|
|
struct work_s work; /* TCP timer handle */
|
|
|
|
bool timeout; /* Trigger from timer expiry */
|
2014-07-06 20:34:27 +02:00
|
|
|
uint8_t timer; /* The retransmission timer (units: half-seconds) */
|
|
|
|
uint8_t nrtx; /* The number of retransmissions for the last
|
|
|
|
* segment sent */
|
2019-12-08 20:13:51 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_DELAYED_ACK
|
|
|
|
uint8_t rx_unackseg; /* Number of un-ACKed received segments */
|
|
|
|
uint8_t rx_acktimer; /* Time since last ACK sent (units: half-seconds) */
|
|
|
|
#endif
|
2014-07-06 20:34:27 +02:00
|
|
|
uint16_t lport; /* The local TCP port, in network byte order */
|
|
|
|
uint16_t rport; /* The remoteTCP port, in network byte order */
|
|
|
|
uint16_t mss; /* Current maximum segment size for the
|
|
|
|
* connection */
|
2023-03-08 16:43:38 +01:00
|
|
|
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
|
|
|
uint16_t user_mss; /* Configured maximum segment size for the
|
|
|
|
* connection */
|
|
|
|
#endif
|
2021-07-05 11:28:11 +02:00
|
|
|
uint32_t rcv_adv; /* The right edge of the recv window advertized */
|
2023-04-20 05:08:02 +02:00
|
|
|
#ifdef CONFIG_NET_TCP_CC_NEWRENO
|
|
|
|
uint32_t last_ackno; /* The ack number at the last receive ack */
|
|
|
|
uint32_t dupacks; /* The number of duplicate ack */
|
|
|
|
uint32_t fr_recover; /* The snd_seq at the retransmissions */
|
|
|
|
|
|
|
|
uint32_t cwnd; /* The Congestion window */
|
|
|
|
uint32_t max_cwnd; /* The Congestion window maximum value */
|
|
|
|
uint32_t ssthresh; /* The Slow start threshold */
|
|
|
|
#endif
|
2021-07-05 11:28:11 +02:00
|
|
|
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
|
|
|
uint32_t snd_wnd; /* Sequence and acknowledgement numbers of last
|
|
|
|
* window update */
|
|
|
|
uint8_t snd_scale; /* Sender window scale factor */
|
|
|
|
uint8_t rcv_scale; /* Receiver windows scale factor */
|
|
|
|
#else
|
2020-12-07 06:51:08 +01:00
|
|
|
uint16_t snd_wnd; /* Sequence and acknowledgement numbers of last
|
|
|
|
* window update */
|
2021-07-05 11:28:11 +02:00
|
|
|
#endif
|
2021-07-16 12:47:08 +02:00
|
|
|
uint32_t snd_wl1;
|
|
|
|
uint32_t snd_wl2;
|
2021-07-05 10:01:48 +02:00
|
|
|
#if CONFIG_NET_RECV_BUFSIZE > 0
|
|
|
|
int32_t rcv_bufs; /* Maximum amount of bytes queued in recv */
|
|
|
|
#endif
|
2021-07-19 15:45:46 +02:00
|
|
|
#if CONFIG_NET_SEND_BUFSIZE > 0
|
|
|
|
int32_t snd_bufs; /* Maximum amount of bytes queued in send */
|
|
|
|
sem_t snd_sem; /* Semaphore signals send completion */
|
|
|
|
#endif
|
2021-12-26 20:50:29 +01:00
|
|
|
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) || \
|
|
|
|
defined(CONFIG_NET_TCP_WINDOW_SCALE)
|
2019-12-08 20:13:51 +01:00
|
|
|
uint32_t tx_unacked; /* Number bytes sent but not yet ACKed */
|
2014-07-06 20:34:27 +02:00
|
|
|
#else
|
2019-12-08 20:13:51 +01:00
|
|
|
uint16_t tx_unacked; /* Number bytes sent but not yet ACKed */
|
2014-07-06 20:34:27 +02:00
|
|
|
#endif
|
2021-07-05 11:28:11 +02:00
|
|
|
uint16_t flags; /* Flags of TCP-specific options */
|
2023-01-16 04:57:03 +01:00
|
|
|
#ifdef CONFIG_NET_SOLINGER
|
|
|
|
sclock_t ltimeout; /* Linger timeout expiration */
|
2024-05-16 04:08:16 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_NETDEV_RSS
|
|
|
|
int rcvcpu; /* Currect cpu id */
|
2023-01-16 04:57:03 +01:00
|
|
|
#endif
|
2015-05-30 17:12:27 +02:00
|
|
|
/* If the TCP socket is bound to a local address, then this is
|
|
|
|
* a reference to the device that routes traffic on the corresponding
|
|
|
|
* network.
|
|
|
|
*/
|
|
|
|
|
|
|
|
FAR struct net_driver_s *dev;
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/* Read-ahead buffering.
|
|
|
|
*
|
2023-07-04 07:24:51 +02:00
|
|
|
* readahead - An IOB chain where the TCP/IP read-ahead data is retained.
|
2014-07-06 20:34:27 +02:00
|
|
|
*/
|
|
|
|
|
2023-07-04 07:24:51 +02:00
|
|
|
FAR struct iob_s *readahead; /* Read-ahead buffering */
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2023-01-06 08:30:58 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_OUT_OF_ORDER
|
|
|
|
|
|
|
|
/* Number of out-of-order segments */
|
|
|
|
|
|
|
|
uint8_t nofosegs;
|
|
|
|
|
|
|
|
/* This defines a out of order segment block. */
|
|
|
|
|
|
|
|
struct tcp_ofoseg_s ofosegs[TCP_SACK_RANGES_MAX];
|
|
|
|
#endif
|
|
|
|
|
2015-05-30 17:12:27 +02:00
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
2014-07-06 20:34:27 +02:00
|
|
|
/* Write buffering
|
|
|
|
*
|
|
|
|
* write_q - The queue of unsent I/O buffers. The head of this
|
|
|
|
* list may be partially sent. FIFO ordering.
|
|
|
|
* unacked_q - A queue of completely sent, but unacked I/O buffer
|
|
|
|
* chains. Sequence number ordering.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sq_queue_t write_q; /* Write buffering for segments */
|
|
|
|
sq_queue_t unacked_q; /* Write buffering for un-ACKed segments */
|
|
|
|
uint16_t expired; /* Number segments retransmitted but not yet ACKed,
|
2014-07-07 00:10:26 +02:00
|
|
|
* it can only be updated at TCP_ESTABLISHED state */
|
2015-05-11 15:14:25 +02:00
|
|
|
uint32_t sent; /* The number of bytes sent (ACKed and un-ACKed) */
|
2014-07-06 20:34:27 +02:00
|
|
|
uint32_t isn; /* Initial sequence number */
|
While working with version 7.10 I discovered a problem in TCP stack that could be observed on high network load. Generally speaking, the problem is that RST flag is set in unnecessary case, in which between loss of some TCP packet and its proper retransmission, another packets had been successfully sent. The scenario is as follows: NuttX did not receive ACK for some sent packet, so it has been probably lost somewhere. But before its retransmission starts, NuttX is correctly issuing next TCP packets, with sequence numbers increasing properly. When the retransmission of previously lost packet finally succeeds, tcp_input receives the accumulated ACK value, which acknowledges also the packets sent in the meantime (i.e. between unsuccessful sending of lost packet and its proper retransmission). However, variable unackseq is still set to conn->isn + conn->sent, which is truth only if no further packets transmission occurred in the meantime. Because of incorrect (in such specific case) unackseq value, few lines further condition if (ackseq <= unackseq)is not met, and, as a result, we are going to reset label.
2016-06-20 14:55:29 +02:00
|
|
|
uint32_t sndseq_max; /* The sequence number of next not-retransmitted
|
|
|
|
* segment (next greater sndseq) */
|
2014-07-06 20:34:27 +02:00
|
|
|
#endif
|
|
|
|
|
2015-05-30 17:12:27 +02:00
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
2014-07-06 20:34:27 +02:00
|
|
|
/* Listen backlog support
|
|
|
|
*
|
|
|
|
* blparent - The backlog parent. If this connection is backlogged,
|
|
|
|
* this field will be non-null and will refer to the TCP connection
|
|
|
|
* structure in which this connection is backlogged.
|
|
|
|
* backlog - The pending connection backlog. If this connection is
|
|
|
|
* configured as a listener with backlog, then this refers to the
|
|
|
|
* struct tcp_backlog_s tear-off structure that manages that backlog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
FAR struct tcp_conn_s *blparent;
|
|
|
|
FAR struct tcp_backlog_s *backlog;
|
|
|
|
#endif
|
|
|
|
|
2018-03-12 17:59:46 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_KEEPALIVE
|
|
|
|
/* There fields manage TCP/IP keep-alive. All times are in units of the
|
|
|
|
* system clock tick.
|
|
|
|
*/
|
|
|
|
|
2022-05-18 07:32:56 +02:00
|
|
|
uint32_t keeptimer; /* KeepAlive timer (dsec) */
|
2020-10-22 12:07:39 +02:00
|
|
|
uint32_t keepidle; /* Elapsed idle time before first probe sent (dsec) */
|
|
|
|
uint32_t keepintvl; /* Interval between probes (dsec) */
|
2018-03-12 17:59:46 +01:00
|
|
|
bool keepalive; /* True: KeepAlive enabled; false: disabled */
|
|
|
|
uint8_t keepcnt; /* Number of retries before the socket is closed */
|
|
|
|
uint8_t keepretries; /* Number of retries attempted */
|
|
|
|
#endif
|
|
|
|
|
2022-01-16 05:40:08 +01:00
|
|
|
#if defined(CONFIG_NET_SENDFILE) && defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
|
|
|
bool sendfile; /* True if sendfile operation is in progress */
|
|
|
|
#endif
|
2023-06-20 13:43:37 +02:00
|
|
|
bool zero_probe; /* TCP zero window probe timer */
|
2022-01-16 05:40:08 +01:00
|
|
|
|
2017-08-29 18:38:01 +02:00
|
|
|
/* connevents is a list of callbacks for each socket the uses this
|
|
|
|
* connection (there can be more that one in the event that the the socket
|
|
|
|
* was dup'ed). It is used with the network monitor to handle
|
|
|
|
* asynchronous loss-of-connection events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
FAR struct devif_callback_s *connevents;
|
net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.
Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-08-29 22:57:26 +02:00
|
|
|
FAR struct devif_callback_s *connevents_tail;
|
2017-08-29 18:38:01 +02:00
|
|
|
|
2023-01-18 11:28:32 +01:00
|
|
|
/* Reference to TCP shutdown/close callback instance */
|
2022-08-25 14:15:56 +02:00
|
|
|
|
2023-01-18 11:28:32 +01:00
|
|
|
FAR struct devif_callback_s *shdcb;
|
2022-08-25 14:15:56 +02:00
|
|
|
FAR struct devif_callback_s *clscb;
|
net/tcp: use independent work to free the conn instance
I noticed that the conn instance will leak during stress test,
The close work queued from tcp_close_eventhandler() will be canceled
by tcp_timer() immediately:
Breakpoint 1, tcp_close_eventhandler (dev=0x565cd338 <up_irq_restore+108>, pvpriv=0x5655e6ff <getpid+12>, flags=0) at tcp/tcp_close.c:71
(gdb) bt
| #0 tcp_close_eventhandler (dev=0x565cd338 <up_irq_restore+108>, pvpriv=0x5655e6ff <getpid+12>, flags=0) at tcp/tcp_close.c:71
| #1 0x5658bf1e in devif_conn_event (dev=0x5660bd80 <g_sim_dev>, flags=512, list=0x5660d558 <g_cbprealloc+312>) at devif/devif_callback.c:508
| #2 0x5658a219 in tcp_callback (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>, flags=512) at tcp/tcp_callback.c:167
| #3 0x56589253 in tcp_timer (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:378
| #4 0x5658dd47 in tcp_poll (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_devpoll.c:95
| #5 0x5658b95f in devif_poll_tcp_connections (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:601
| #6 0x5658b9ea in devif_poll (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:722
| #7 0x56577230 in netdriver_txavail_work (arg=0x5660bd80 <g_sim_dev>) at sim/up_netdriver.c:308
| #8 0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #9 0x5655983f in nxtask_start () at task/task_start.c:129
(gdb) c
Continuing.
Breakpoint 2, tcp_update_timer (conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:178
(gdb) bt
| #0 tcp_update_timer (conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:178
| #1 0x5658952a in tcp_timer (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:708
| #2 0x5658dd47 in tcp_poll (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_devpoll.c:95
| #3 0x5658b95f in devif_poll_tcp_connections (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:601
| #4 0x5658b9ea in devif_poll (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:722
| #5 0x56577230 in netdriver_txavail_work (arg=0x5660bd80 <g_sim_dev>) at sim/up_netdriver.c:308
| #6 0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #7 0x5655983f in nxtask_start () at task/task_start.c:129
Since a separate work will add 24 bytes to each conn instance,
but in order to support the feature of asynchronous close(),
I can not find a better way than adding a separate work,
for resource constraints, I recommend the developers to enable
CONFIG_NET_ALLOC_CONNS, which will reduce the ram usage.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-08-30 05:04:31 +02:00
|
|
|
struct work_s clswork;
|
2022-08-25 14:15:56 +02:00
|
|
|
|
2022-02-07 04:03:03 +01:00
|
|
|
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
|
|
|
/* Callback instance for TCP send() */
|
|
|
|
|
|
|
|
FAR struct devif_callback_s *sndcb;
|
|
|
|
#endif
|
|
|
|
|
2015-05-30 19:29:47 +02:00
|
|
|
/* accept() is called when the TCP logic has created a connection
|
|
|
|
*
|
|
|
|
* accept_private: This is private data that will be available to the
|
|
|
|
* accept() handler when it is invoked with a point to this structure
|
|
|
|
* as an argument.
|
2017-05-11 21:35:56 +02:00
|
|
|
* accept: This is the pointer to the accept handler.
|
2015-05-30 19:29:47 +02:00
|
|
|
*/
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
FAR void *accept_private;
|
2024-08-25 01:21:12 +02:00
|
|
|
CODE int (*accept)(FAR struct tcp_conn_s *listener,
|
|
|
|
FAR struct tcp_conn_s *conn);
|
2019-12-31 16:26:14 +01:00
|
|
|
|
|
|
|
/* The following is a list of poll structures of threads waiting for
|
|
|
|
* socket events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct tcp_poll_s pollinfo[CONFIG_NET_TCP_NPOLLWAITERS];
|
2014-07-06 20:34:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This structure supports TCP write buffering */
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
struct tcp_wrbuffer_s
|
|
|
|
{
|
|
|
|
sq_entry_t wb_node; /* Supports a singly linked list */
|
|
|
|
uint32_t wb_seqno; /* Sequence number of the write segment */
|
|
|
|
uint16_t wb_sent; /* Number of bytes sent from the I/O buffer chain */
|
|
|
|
uint8_t wb_nrtx; /* The number of retransmissions for the last
|
|
|
|
* segment sent */
|
2023-04-20 05:08:02 +02:00
|
|
|
#if defined(CONFIG_NET_TCP_FAST_RETRANSMIT) && !defined(CONFIG_NET_TCP_CC_NEWRENO)
|
net/tcp: implement the fast retransmit
RFC2001: TCP Slow Start, Congestion Avoidance, Fast Retransmit,
and Fast Recovery Algorithms
...
3. Fast Retransmit
Modifications to the congestion avoidance algorithm were proposed in
1990 [3]. Before describing the change, realize that TCP may
generate an immediate acknowledgment (a duplicate ACK) when an out-
of-order segment is received (Section 4.2.2.21 of [1], with a note
that one reason for doing so was for the experimental fast-
retransmit algorithm). This duplicate ACK should not be delayed.
The purpose of this duplicate ACK is to let the other end know that a
segment was received out of order, and to tell it what sequence
number is expected.
Since TCP does not know whether a duplicate ACK is caused by a lost
segment or just a reordering of segments, it waits for a small number
of duplicate ACKs to be received. It is assumed that if there is
just a reordering of the segments, there will be only one or two
duplicate ACKs before the reordered segment is processed, which will
then generate a new ACK. If three or more duplicate ACKs are
received in a row, it is a strong indication that a segment has been
lost. TCP then performs a retransmission of what appears to be the
missing segment, without waiting for a retransmission timer to
expire.
Change-Id: Ie2cbcecab507c3d831f74390a6a85e0c5c8e0652
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-10-22 09:02:52 +02:00
|
|
|
uint8_t wb_nack; /* The number of ack count */
|
2022-01-25 18:49:04 +01:00
|
|
|
#endif
|
2014-07-06 20:34:27 +02:00
|
|
|
struct iob_s *wb_iob; /* Head of the I/O buffer chain */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Support for listen backlog:
|
|
|
|
*
|
|
|
|
* struct tcp_blcontainer_s describes one backlogged connection
|
|
|
|
* struct tcp_backlog_s is a "tear-off" describing all backlog for a
|
|
|
|
* listener connection
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
struct tcp_blcontainer_s
|
|
|
|
{
|
|
|
|
sq_entry_t bc_node; /* Implements a singly linked list */
|
|
|
|
FAR struct tcp_conn_s *bc_conn; /* Holds reference to the new connection structure */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tcp_backlog_s
|
|
|
|
{
|
|
|
|
sq_queue_t bl_free; /* Implements a singly-linked list of free containers */
|
|
|
|
sq_queue_t bl_pending; /* Implements a singly-linked list of pending connections */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-06-21 23:23:39 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_initialize
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the TCP/IP connection structures. Called only once and only
|
2018-06-25 20:41:28 +02:00
|
|
|
* from the network layer at start-up.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-25 02:12:49 +02:00
|
|
|
void tcp_initialize(void);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_alloc
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Find a free TCP/IP connection structure and allocate it
|
|
|
|
* for use. This is normally something done by the implementation of the
|
2018-07-05 18:54:45 +02:00
|
|
|
* socket() API but is also called from the event processing logic when a
|
|
|
|
* TCP packet is received while "listening"
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-01-17 20:07:48 +01:00
|
|
|
FAR struct tcp_conn_s *tcp_alloc(uint8_t domain);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2023-01-03 13:16:07 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_free_rx_buffers
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Free rx buffer of a connection
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_free_rx_buffers(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_free
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Free a connection structure that is no longer in use. This should be
|
|
|
|
* done by the implementation of close()
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_free(FAR struct tcp_conn_s *conn);
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_active
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Find a connection structure that is the appropriate
|
|
|
|
* connection to be used with the provided TCP/IP header
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-01-15 22:06:46 +01:00
|
|
|
FAR struct tcp_conn_s *tcp_active(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct tcp_hdr_s *tcp);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_nextconn
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Traverse the list of active TCP connections
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct tcp_conn_s *tcp_nextconn(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2015-05-30 17:12:27 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_local_ipv4_device
|
2015-05-30 17:12:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-09-03 03:48:31 +02:00
|
|
|
* Select the network driver to use with the IPv4 TCP transaction based
|
|
|
|
* on the locally bound IPv4 address
|
2015-05-30 17:12:27 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - TCP connection structure. The locally bound address, laddr,
|
|
|
|
* should be set to a non-zero value in this structure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success. A negated errno value is returned
|
2015-09-03 04:03:28 +02:00
|
|
|
* on failure. -ENETUNREACH is the only expected error value.
|
2015-05-30 17:12:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
2015-09-03 03:48:31 +02:00
|
|
|
int tcp_local_ipv4_device(FAR struct tcp_conn_s *conn);
|
2015-05-30 17:12:27 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_remote_ipv4_device
|
2015-05-30 17:12:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-09-03 03:48:31 +02:00
|
|
|
* Select the network driver to use with the IPv4 TCP transaction based
|
|
|
|
* on the remotely connected IPv4 address
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-02-14 15:50:45 +01:00
|
|
|
* conn - TCP connection structure. The remotely connected address, raddr,
|
2015-09-03 03:48:31 +02:00
|
|
|
* should be set to a non-zero value in this structure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success. A negated errno value is returned
|
2015-09-03 04:03:28 +02:00
|
|
|
* on failure. -ENETUNREACH is the only expected error value.
|
2015-09-03 03:48:31 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
int tcp_remote_ipv4_device(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_local_ipv6_device
|
2015-09-03 03:48:31 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Select the network driver to use with the IPv6 TCP transaction based
|
|
|
|
* on the locally bound IPv6 address
|
2015-05-30 17:12:27 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - TCP connection structure. The locally bound address, laddr,
|
|
|
|
* should be set to a non-zero value in this structure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success. A negated errno value is returned
|
|
|
|
* on failure. -EHOSTUNREACH is the only expected error value.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
2015-09-03 03:48:31 +02:00
|
|
|
int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_remote_ipv6_device
|
2015-09-03 03:48:31 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Select the network driver to use with the IPv6 TCP transaction based
|
2018-01-22 18:11:23 +01:00
|
|
|
* on the remotely connected IPv6 address
|
2015-09-03 03:48:31 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - TCP connection structure. The remotely connected address, raddr,
|
|
|
|
* should be set to a non-zero value in this structure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success. A negated errno value is returned
|
|
|
|
* on failure. -EHOSTUNREACH is the only expected error value.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
int tcp_remote_ipv6_device(FAR struct tcp_conn_s *conn);
|
2015-05-30 17:12:27 +02:00
|
|
|
#endif
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_alloc_accept
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called when driver processing matches the incoming packet with a
|
|
|
|
* connection in LISTEN. In that case, this function will create a new
|
|
|
|
* connection and initialize it to send a SYNACK in return.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-11-15 20:13:23 +01:00
|
|
|
FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
|
2023-03-09 05:37:43 +01:00
|
|
|
FAR struct tcp_hdr_s *tcp,
|
|
|
|
FAR struct tcp_conn_s *listener);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2022-10-28 10:08:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_selectport
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* If the port number is zero; select an unused port for the connection.
|
|
|
|
* If the port number is non-zero, verify that no other connection has
|
|
|
|
* been created with this port number.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Selected or verified port number in network order on success, a negated
|
|
|
|
* errno on failure.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Interrupts are disabled
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_selectport(uint8_t domain,
|
|
|
|
FAR const union ip_addr_u *ipaddr,
|
|
|
|
uint16_t portno);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_bind
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function implements the lower level parts of the standard TCP
|
|
|
|
* bind() operation.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* 0 on success or -EADDRINUSE on failure
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from normal user level code.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-01-18 00:07:54 +01:00
|
|
|
int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_connect
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function implements the lower level parts of the standard
|
|
|
|
* TCP connect() operation: It connects to a remote host using TCP.
|
|
|
|
*
|
|
|
|
* This function is used to start a new connection to the specified
|
|
|
|
* port on the specified host. It uses the connection structure that was
|
|
|
|
* allocated by a preceding socket() call. It sets the connection to
|
|
|
|
* the SYN_SENT state and sets the retransmission timer to 0. This will
|
|
|
|
* cause a TCP SYN segment to be sent out the next time this connection
|
|
|
|
* is periodically processed, which usually is done within 0.5 seconds
|
|
|
|
* after the call to tcp_connect().
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from normal user level code.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 07:44:44 +01:00
|
|
|
int tcp_connect(FAR struct tcp_conn_s *conn,
|
|
|
|
FAR const struct sockaddr *addr);
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2017-08-29 17:25:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: psock_tcp_connect
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform a TCP connection
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2019-12-31 07:44:44 +01:00
|
|
|
* psock - A reference to the structure of the socket to be connected
|
2017-08-29 17:25:22 +02:00
|
|
|
* addr - The address of the remote server to connect to
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 22:08:04 +02:00
|
|
|
* The network is locked
|
2017-08-29 17:25:22 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int psock_tcp_connect(FAR struct socket *psock,
|
|
|
|
FAR const struct sockaddr *addr);
|
|
|
|
|
2017-08-29 16:40:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_start_monitor
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to receive TCP connection state changes for a given socket
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - The socket of interest
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, tcp_start_monitor returns OK; On any failure,
|
|
|
|
* tcp_start_monitor will return a negated errno value. The only failure
|
|
|
|
* that can occur is if the socket has already been closed and, in this
|
|
|
|
* case, -ENOTCONN is returned.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The caller holds the network lock (if not, it will be locked momentarily
|
|
|
|
* by this function).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_start_monitor(FAR struct socket *psock);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_stop_monitor
|
|
|
|
*
|
|
|
|
* Description:
|
2017-08-29 20:27:58 +02:00
|
|
|
* Stop monitoring TCP connection changes for a sockets associated with
|
2018-01-22 18:11:23 +01:00
|
|
|
* a given TCP connection structure.
|
2017-08-29 16:40:13 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
2017-08-29 20:27:58 +02:00
|
|
|
* flags Set of disconnection events
|
2017-08-29 16:40:13 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The caller holds the network lock (if not, it will be locked momentarily
|
|
|
|
* by this function).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-29 20:27:58 +02:00
|
|
|
void tcp_stop_monitor(FAR struct tcp_conn_s *conn, uint16_t flags);
|
2017-08-29 16:40:13 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_lost_connection
|
|
|
|
*
|
|
|
|
* Description:
|
2017-08-29 20:27:58 +02:00
|
|
|
* Called when a loss-of-connection event has been detected by network
|
2017-08-29 22:08:04 +02:00
|
|
|
* event handling logic. Perform operations like tcp_stop_monitor but
|
|
|
|
* (1) explicitly mark this socket and (2) disable further callbacks
|
|
|
|
* the event handler.
|
2017-08-29 16:40:13 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2022-02-08 17:08:15 +01:00
|
|
|
* conn - The TCP connection of interest
|
2017-08-29 20:27:58 +02:00
|
|
|
* cb - devif callback structure
|
2023-06-20 13:43:37 +02:00
|
|
|
* flags - Set of connection events
|
2017-08-29 16:40:13 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 20:27:58 +02:00
|
|
|
* The caller holds the network lock (if not, it will be locked momentarily
|
|
|
|
* by this function).
|
2017-08-29 16:40:13 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-02-08 17:08:15 +01:00
|
|
|
void tcp_lost_connection(FAR struct tcp_conn_s *conn,
|
2017-08-29 20:27:58 +02:00
|
|
|
FAR struct devif_callback_s *cb, uint16_t flags);
|
2017-08-29 16:40:13 +02:00
|
|
|
|
2020-01-21 07:11:29 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_close
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Break any current TCP connection
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - An instance of the internal socket structure.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from normal user-level logic
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_close(FAR struct socket *psock);
|
|
|
|
|
2023-01-18 11:28:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_shutdown
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Gracefully shutdown a TCP connection by sending a SYN
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - An instance of the internal socket structure.
|
|
|
|
* how - Specifies the type of shutdown.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from normal user-level logic
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_shutdown(FAR struct socket *psock, int how);
|
|
|
|
|
2015-01-17 14:42:09 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_ipv4_select
|
2015-01-17 14:42:09 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure to send or receive an TCP IPv4 packet
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
void tcp_ipv4_select(FAR struct net_driver_s *dev);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_ipv6_select
|
2015-01-17 14:42:09 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure to send or receive an TCP IPv6 packet
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
void tcp_ipv6_select(FAR struct net_driver_s *dev);
|
|
|
|
#endif
|
|
|
|
|
2023-01-29 06:11:57 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_ip_select
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure to send or receive an TCP IPv[4|6] packet for connection
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_ip_select(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_setsequence
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set the TCP/IP sequence number
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
|
|
|
void tcp_setsequence(FAR uint8_t *seqno, uint32_t value);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_getsequence
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get the TCP/IP sequence number
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-25 02:12:49 +02:00
|
|
|
uint32_t tcp_getsequence(FAR uint8_t *seqno);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_addsequence
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add the length to get the next TCP sequence number.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-25 02:12:49 +02:00
|
|
|
uint32_t tcp_addsequence(FAR uint8_t *seqno, uint16_t len);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_initsequence
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set the (initial) the TCP/IP sequence number when a TCP connection is
|
|
|
|
* established.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-11-01 04:30:36 +01:00
|
|
|
void tcp_initsequence(FAR struct tcp_conn_s *conn);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_nextsequence
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Increment the TCP/IP sequence number
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-25 02:12:49 +02:00
|
|
|
void tcp_nextsequence(void);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_poll
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Poll a TCP connection structure for availability of TX data
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn);
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_timer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle a TCP timer expiration for the provided TCP connection
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2022-04-25 17:08:24 +02:00
|
|
|
void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn);
|
|
|
|
|
2023-01-16 04:57:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_update_timer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update the TCP timer for the provided TCP connection,
|
|
|
|
* The timeout is accurate
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* conn is not NULL.
|
|
|
|
* The connection (conn) is bound to the polling device (dev).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_update_timer(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2022-04-25 17:08:24 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_update_retrantimer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update the retransmit TCP timer for the provided TCP connection,
|
|
|
|
* The timeout is accurate
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
* timeout - Time for the next timeout
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* conn is not NULL.
|
|
|
|
* The connection (conn) is bound to the polling device (dev).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_update_retrantimer(FAR struct tcp_conn_s *conn, int timeout);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_update_keeptimer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update the keeplive TCP timer for the provided TCP connection,
|
|
|
|
* The timeout is accurate
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
* timeout - Time for the next timeout
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* conn is not NULL.
|
|
|
|
* The connection (conn) is bound to the polling device (dev).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_KEEPALIVE
|
|
|
|
void tcp_update_keeptimer(FAR struct tcp_conn_s *conn, int timeout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_stop_timer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Stop TCP timer for the provided TCP connection
|
|
|
|
* When the connection is closed
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* conn is not NULL.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_stop_timer(FAR struct tcp_conn_s *conn);
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2017-05-14 18:56:25 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_findlistener
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the connection listener for connections on this port (if any)
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 22:08:04 +02:00
|
|
|
* The network is locked
|
2017-05-14 18:56:25 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-05-25 09:48:55 +02:00
|
|
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
2021-09-23 08:55:19 +02:00
|
|
|
FAR struct tcp_conn_s *tcp_findlistener(FAR union ip_binding_u *uaddr,
|
|
|
|
uint16_t portno,
|
|
|
|
uint8_t domain);
|
2017-05-25 09:48:55 +02:00
|
|
|
#else
|
2021-09-23 08:55:19 +02:00
|
|
|
FAR struct tcp_conn_s *tcp_findlistener(FAR union ip_binding_u *uaddr,
|
|
|
|
uint16_t portno);
|
2017-05-25 09:48:55 +02:00
|
|
|
#endif
|
2017-05-14 18:56:25 +02:00
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_unlisten
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Stop listening to the port bound to the specified TCP connection
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from normal user code.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_unlisten(FAR struct tcp_conn_s *conn);
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_listen
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Start listening to the port bound to the specified TCP connection
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from normal user code.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_listen(FAR struct tcp_conn_s *conn);
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_islistener
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return true is there is a listener for the specified port
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-05-25 09:48:55 +02:00
|
|
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
2021-09-23 08:55:19 +02:00
|
|
|
bool tcp_islistener(FAR union ip_binding_u *uaddr, uint16_t portno,
|
|
|
|
uint8_t domain);
|
2017-05-25 09:48:55 +02:00
|
|
|
#else
|
2021-09-23 08:55:19 +02:00
|
|
|
bool tcp_islistener(FAR union ip_binding_u *uaddr, uint16_t portno);
|
2017-05-25 09:48:55 +02:00
|
|
|
#endif
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_accept_connection
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Accept the new connection for the specified listening port.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
int tcp_accept_connection(FAR struct net_driver_s *dev,
|
2014-06-25 02:12:49 +02:00
|
|
|
FAR struct tcp_conn_s *conn, uint16_t portno);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_send
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Setup to send a TCP packet
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP connection structure holding connection information
|
|
|
|
* flags - flags to apply to the TCP header
|
|
|
|
* len - length of the message
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
2014-06-25 02:12:49 +02:00
|
|
|
uint16_t flags, uint16_t len);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2017-08-29 17:25:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_sendfile
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The tcp_sendfile() call may be used only when the INET socket is in a
|
|
|
|
* connected state (so that the intended recipient is known).
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-08-29 17:25:22 +02:00
|
|
|
* psock An instance of the internal socket structure.
|
|
|
|
* buf Data to send
|
|
|
|
* len Length of data to send
|
|
|
|
* flags Send flags
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, returns the number of characters sent. On error,
|
|
|
|
* a negated errno value is returned. See sendfile() for a list
|
|
|
|
* appropriate error return values.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_SENDFILE
|
|
|
|
ssize_t tcp_sendfile(FAR struct socket *psock, FAR struct file *infile,
|
|
|
|
FAR off_t *offset, size_t count);
|
|
|
|
#endif
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_reset
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send a TCP reset (no-data) message
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
2022-12-21 05:40:42 +01:00
|
|
|
* conn - The TCP connection structure holding connection information
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-12-21 05:40:42 +01:00
|
|
|
void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
2021-06-01 11:43:24 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_rx_mss
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the MSS to advertize to the peer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* The MSS value.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint16_t tcp_rx_mss(FAR struct net_driver_s *dev);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2019-12-08 20:13:51 +01:00
|
|
|
* Name: tcp_synack
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send the SYN or SYNACK response.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP connection structure holding connection information
|
|
|
|
* ack - The ACK response to send
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-08 20:13:51 +01:00
|
|
|
void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|
|
|
uint8_t ack);
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_appsend
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle application or TCP protocol response. If this function is called
|
|
|
|
* with dev->d_sndlen > 0, then this is an application attempting to send
|
|
|
|
* packet.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP connection structure holding connection information
|
|
|
|
* result - App result event sent
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
2014-06-25 02:12:49 +02:00
|
|
|
uint16_t result);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_rexmit
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle application retransmission
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
* conn - The TCP connection structure holding connection information
|
|
|
|
* result - App result event sent
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
2014-06-25 02:12:49 +02:00
|
|
|
uint16_t result);
|
|
|
|
|
2021-06-01 10:03:57 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_send_txnotify
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Notify the appropriate device driver that we are have data ready to
|
|
|
|
* be send (TCP)
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - Socket state structure
|
|
|
|
* conn - The TCP connection structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_send_txnotify(FAR struct socket *psock,
|
|
|
|
FAR struct tcp_conn_s *conn);
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2015-01-15 22:06:46 +01:00
|
|
|
* Name: tcp_ipv4_input
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Handle incoming TCP input with IPv4 header
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-07-06 20:34:27 +02:00
|
|
|
* dev - The device driver structure containing the received TCP packet.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from the Ethernet driver with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2015-01-15 22:06:46 +01:00
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
void tcp_ipv4_input(FAR struct net_driver_s *dev);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_ipv6_input
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle incoming TCP input with IPv4 header
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2018-11-03 00:50:01 +01:00
|
|
|
* dev - The device driver structure containing the received TCP packet.
|
|
|
|
* iplen - The size of the IPv6 header. This may be larger than
|
|
|
|
* IPv6_HDRLEN the IPv6 header if IPv6 extension headers are
|
|
|
|
* present.
|
2015-01-15 22:06:46 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-01-15 22:06:46 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from the Ethernet driver with the network stack locked
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
2018-11-03 00:50:01 +01:00
|
|
|
void tcp_ipv6_input(FAR struct net_driver_s *dev, unsigned int iplen);
|
2015-01-15 22:06:46 +01:00
|
|
|
#endif
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_callback
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Inform the application holding the TCP socket of a change in state.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-25 02:12:49 +02:00
|
|
|
|
2014-06-28 00:48:12 +02:00
|
|
|
uint16_t tcp_callback(FAR struct net_driver_s *dev,
|
2014-06-25 02:12:49 +02:00
|
|
|
FAR struct tcp_conn_s *conn, uint16_t flags);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_datahandler
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle data that is not accepted by the application. This may be called
|
|
|
|
* either (1) from the data receive logic if it cannot buffer the data, or
|
|
|
|
* (2) from the TCP event logic is there is no listener in place ready to
|
|
|
|
* receive the data.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - A pointer to the TCP connection structure
|
|
|
|
* buffer - A pointer to the buffer to be copied to the read-ahead
|
|
|
|
* buffers
|
|
|
|
* buflen - The number of bytes to copy to the read-ahead buffer.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-07-06 20:34:27 +02:00
|
|
|
* The number of bytes actually buffered is returned. This will be either
|
|
|
|
* zero or equal to buflen; partial packets are not buffered.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2014-07-07 01:22:02 +02:00
|
|
|
* - The caller has checked that TCP_NEWDATA is set in flags and that is no
|
2014-07-06 20:34:27 +02:00
|
|
|
* other handler available to process the incoming data.
|
2015-01-15 22:06:46 +01:00
|
|
|
* - Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-11-23 12:39:40 +01:00
|
|
|
uint16_t tcp_datahandler(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct tcp_conn_s *conn,
|
|
|
|
uint16_t offset);
|
2014-07-06 20:34:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_backlogcreate
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from the listen() logic to setup the backlog as specified in the
|
|
|
|
* the listen arguments.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-31 15:23:19 +02:00
|
|
|
* Called from network socket logic. The network may or may not be locked.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg);
|
|
|
|
#else
|
|
|
|
# define tcp_backlogcreate(c,n) (-ENOSYS)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_backlogdestroy
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* (1) Called from tcp_free() whenever a connection is freed.
|
|
|
|
* (2) Called from tcp_backlogcreate() to destroy any old backlog
|
|
|
|
*
|
|
|
|
* NOTE: This function may re-enter tcp_free when a connection that
|
|
|
|
* is freed that has pending connections.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-31 15:23:19 +02:00
|
|
|
* Called from network socket logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
int tcp_backlogdestroy(FAR struct tcp_conn_s *conn);
|
|
|
|
#else
|
|
|
|
# define tcp_backlogdestroy(conn) (-ENOSYS)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_backlogadd
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called tcp_listen when a new connection is made with a listener socket
|
|
|
|
* but when there is no accept() in place to receive the connection. This
|
|
|
|
* function adds the new connection to the backlog.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
int tcp_backlogadd(FAR struct tcp_conn_s *conn,
|
|
|
|
FAR struct tcp_conn_s *blconn);
|
|
|
|
#else
|
|
|
|
# define tcp_backlogadd(conn,blconn) (-ENOSYS)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2023-04-17 16:07:31 +02:00
|
|
|
* Name: tcp_backlogpending
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2017-08-29 22:08:04 +02:00
|
|
|
* Called from poll(). Before waiting for a new connection, poll will
|
|
|
|
* call this API to see if there are pending connections in the backlog.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2020-02-22 19:31:14 +01:00
|
|
|
* The network is locked.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-17 16:07:31 +02:00
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
bool tcp_backlogpending(FAR struct tcp_conn_s *conn);
|
|
|
|
#else
|
|
|
|
# define tcp_backlogpending(c) (false)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_backlogavailable
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from tcp_input(). Before alloc a new accept connection, tcp_input
|
|
|
|
* will call this API to see if there are free node in the backlog.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from network socket logic with the network locked
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-05-22 02:57:54 +02:00
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
2014-07-06 20:34:27 +02:00
|
|
|
bool tcp_backlogavailable(FAR struct tcp_conn_s *conn);
|
|
|
|
#else
|
2023-04-17 16:07:31 +02:00
|
|
|
# define tcp_backlogavailable(c) (true)
|
2014-07-06 20:34:27 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_backlogremove
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2017-08-29 22:08:04 +02:00
|
|
|
* Called from accept(). Before waiting for a new connection, accept will
|
|
|
|
* call this API to see if there are pending connections in the backlog.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 22:08:04 +02:00
|
|
|
* The network is locked.
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
FAR struct tcp_conn_s *tcp_backlogremove(FAR struct tcp_conn_s *conn);
|
|
|
|
#else
|
|
|
|
# define tcp_backlogremove(c) (NULL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_backlogdelete
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from tcp_free() when a connection is freed that this also
|
|
|
|
* retained in the pending connection list of a listener. We simply need
|
|
|
|
* to remove the defunct connection from the list.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-07-06 20:34:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPBACKLOG
|
|
|
|
int tcp_backlogdelete(FAR struct tcp_conn_s *conn,
|
2014-07-07 01:58:36 +02:00
|
|
|
FAR struct tcp_conn_s *blconn);
|
2014-07-06 20:34:27 +02:00
|
|
|
#else
|
|
|
|
# define tcp_backlogdelete(c,b) (-ENOSYS)
|
2014-06-25 02:12:49 +02:00
|
|
|
#endif
|
|
|
|
|
2015-01-25 22:46:05 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_accept
|
2015-01-25 22:46:05 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function implements accept() for TCP/IP sockets. See the
|
|
|
|
* description of accept() for further information.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2015-01-25 22:46:05 +01:00
|
|
|
* psock The listening TCP socket structure
|
|
|
|
* addr Receives the address of the connecting client
|
2019-12-31 07:44:44 +01:00
|
|
|
* addrlen Input: allocated size of 'addr'
|
|
|
|
* Return: returned size of 'addr'
|
2015-01-25 22:46:05 +01:00
|
|
|
* newconn The new, accepted TCP connection structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns zero (OK) on success or a negated errno value on failure.
|
|
|
|
* See the description of accept of the possible errno values in the
|
|
|
|
* description of accept().
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Network is locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int psock_tcp_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|
|
|
FAR socklen_t *addrlen, FAR void **newconn);
|
|
|
|
|
2020-01-21 08:50:39 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: psock_tcp_recvfrom
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the recvfrom operation for a TCP/IP SOCK_STREAM
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-02-19 19:21:28 +01:00
|
|
|
* psock Pointer to the socket structure for the SOCK_DRAM socket
|
2022-08-24 08:55:56 +02:00
|
|
|
* msg Receive info and buffer for receive data
|
2020-02-19 19:21:28 +01:00
|
|
|
* flags Receive flags
|
2020-01-21 08:50:39 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, returns the number of characters received. On error,
|
|
|
|
* -errno is returned (see recvfrom for list of errnos).
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-08-24 08:55:56 +02:00
|
|
|
ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR struct msghdr *msg,
|
|
|
|
int flags);
|
2020-01-21 08:50:39 +01:00
|
|
|
|
2014-06-24 16:03:44 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: psock_tcp_send
|
2014-06-24 16:03:44 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2014-06-25 02:12:49 +02:00
|
|
|
* The psock_tcp_send() call may be used only when the TCP socket is in a
|
2014-06-24 16:03:44 +02:00
|
|
|
* connected state (so that the intended recipient is known).
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-06-24 16:03:44 +02:00
|
|
|
* psock An instance of the internal socket structure.
|
|
|
|
* buf Data to send
|
|
|
|
* len Length of data to send
|
2020-02-19 19:21:28 +01:00
|
|
|
* flags Send flags
|
2014-06-24 16:03:44 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, returns the number of characters sent. On error,
|
|
|
|
* -1 is returned, and errno is set appropriately:
|
|
|
|
*
|
|
|
|
* EAGAIN or EWOULDBLOCK
|
|
|
|
* The socket is marked non-blocking and the requested operation
|
|
|
|
* would block.
|
|
|
|
* EBADF
|
|
|
|
* An invalid descriptor was specified.
|
|
|
|
* ECONNRESET
|
|
|
|
* Connection reset by peer.
|
|
|
|
* EDESTADDRREQ
|
|
|
|
* The socket is not connection-mode, and no peer address is set.
|
|
|
|
* EFAULT
|
|
|
|
* An invalid user space address was specified for a parameter.
|
|
|
|
* EINTR
|
|
|
|
* A signal occurred before any data was transmitted.
|
|
|
|
* EINVAL
|
|
|
|
* Invalid argument passed.
|
|
|
|
* EISCONN
|
|
|
|
* The connection-mode socket was connected already but a recipient
|
|
|
|
* was specified. (Now either this error is returned, or the recipient
|
|
|
|
* specification is ignored.)
|
|
|
|
* EMSGSIZE
|
|
|
|
* The socket type requires that message be sent atomically, and the
|
|
|
|
* size of the message to be sent made this impossible.
|
|
|
|
* ENOBUFS
|
|
|
|
* The output queue for a network interface was full. This generally
|
|
|
|
* indicates that the interface has stopped sending, but may be
|
|
|
|
* caused by transient congestion.
|
|
|
|
* ENOMEM
|
|
|
|
* No memory available.
|
|
|
|
* ENOTCONN
|
|
|
|
* The socket is not connected, and no target has been given.
|
|
|
|
* ENOTSOCK
|
|
|
|
* The argument s is not a socket.
|
|
|
|
* EPIPE
|
|
|
|
* The local end has been shut down on a connection oriented socket.
|
|
|
|
* In this case the process will also receive a SIGPIPE unless
|
|
|
|
* MSG_NOSIGNAL is set.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-25 02:12:49 +02:00
|
|
|
ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
2020-02-19 19:21:28 +01:00
|
|
|
size_t len, int flags);
|
2014-06-24 16:03:44 +02:00
|
|
|
|
2018-03-12 17:59:46 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_setsockopt
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* tcp_setsockopt() sets the TCP-protocol option specified by the
|
|
|
|
* 'option' argument to the value pointed to by the 'value' argument for
|
|
|
|
* the socket specified by the 'psock' argument.
|
|
|
|
*
|
|
|
|
* See <netinet/tcp.h> for the a complete list of values of TCP protocol
|
|
|
|
* options.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock Socket structure of socket to operate on
|
|
|
|
* option identifies the option to set
|
|
|
|
* value Points to the argument value
|
|
|
|
* value_len The length of the argument value
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns zero (OK) on success. On failure, it returns a negated errno
|
|
|
|
* value to indicate the nature of the error. See psock_setcockopt() for
|
|
|
|
* the list of possible error values.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
|
|
|
int tcp_setsockopt(FAR struct socket *psock, int option,
|
|
|
|
FAR const void *value, socklen_t value_len);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_getsockopt
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* tcp_getsockopt() retrieves the value for the option specified by the
|
|
|
|
* 'option' argument for the socket specified by the 'psock' argument. If
|
|
|
|
* the size of the option value is greater than 'value_len', the value
|
|
|
|
* stored in the object pointed to by the 'value' argument will be silently
|
|
|
|
* truncated. Otherwise, the length pointed to by the 'value_len' argument
|
|
|
|
* will be modified to indicate the actual length of the 'value'.
|
|
|
|
*
|
|
|
|
* The 'level' argument specifies the protocol level of the option. To
|
|
|
|
* retrieve options at the socket level, specify the level argument as
|
|
|
|
* SOL_SOCKET; to retrieve options at the TCP-protocol level, the level
|
2020-12-13 14:58:02 +01:00
|
|
|
* argument is SOL_TCP.
|
2018-03-12 17:59:46 +01:00
|
|
|
*
|
|
|
|
* See <sys/socket.h> a complete list of values for the socket-level
|
|
|
|
* 'option' argument. Protocol-specific options are are protocol specific
|
|
|
|
* header files (such as netinet/tcp.h for the case of the TCP protocol).
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2018-03-12 17:59:46 +01:00
|
|
|
* psock Socket structure of the socket to query
|
|
|
|
* level Protocol level to set the option
|
|
|
|
* option identifies the option to get
|
|
|
|
* value Points to the argument value
|
|
|
|
* value_len The length of the argument value
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns zero (OK) on success. On failure, it returns a negated errno
|
|
|
|
* value to indicate the nature of the error. See psock_getsockopt() for
|
|
|
|
* the complete list of appropriate return error codes.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
|
|
|
int tcp_getsockopt(FAR struct socket *psock, int option,
|
|
|
|
FAR void *value, FAR socklen_t *value_len);
|
|
|
|
#endif
|
|
|
|
|
2018-07-01 04:50:07 +02:00
|
|
|
/****************************************************************************
|
2018-07-01 15:59:33 +02:00
|
|
|
* Name: tcp_get_recvwindow
|
2018-07-01 04:50:07 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2018-07-01 15:59:33 +02:00
|
|
|
* Calculate the TCP receive window for the specified device.
|
2018-07-01 04:50:07 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-11-27 02:50:38 +01:00
|
|
|
* dev - The device whose TCP receive window will be updated.
|
|
|
|
* conn - The TCP connection structure holding connection information.
|
2018-07-01 04:50:07 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
2018-07-01 15:59:33 +02:00
|
|
|
* The value of the TCP receive window to use.
|
2018-07-01 04:50:07 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-07-07 06:01:25 +02:00
|
|
|
uint32_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
|
2020-11-27 02:50:38 +01:00
|
|
|
FAR struct tcp_conn_s *conn);
|
2018-07-01 04:50:07 +02:00
|
|
|
|
2021-06-01 09:57:00 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_should_send_recvwindow
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Determine if we should advertize the new recv window to the peer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection structure holding connection information.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* If we should send an update.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
bool tcp_should_send_recvwindow(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2016-01-22 22:52:14 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: psock_tcp_cansend
|
2016-01-22 22:52:14 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* psock_tcp_cansend() returns a value indicating if a write to the socket
|
|
|
|
* would block. No space in the buffer is actually reserved, so it is
|
|
|
|
* possible that the write may still block if the buffer is filled by
|
|
|
|
* another means.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2022-02-08 17:08:15 +01:00
|
|
|
* conn The TCP connection of interest
|
2016-01-22 22:52:14 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* OK
|
2018-01-22 18:11:23 +01:00
|
|
|
* At least one byte of data could be successfully written.
|
2016-01-22 22:52:14 +01:00
|
|
|
* -EWOULDBLOCK
|
|
|
|
* There is no room in the output buffer.
|
|
|
|
* -EBADF
|
|
|
|
* An invalid descriptor was specified.
|
|
|
|
* -ENOTCONN
|
|
|
|
* The socket is not connected.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-02-08 17:08:15 +01:00
|
|
|
int psock_tcp_cansend(FAR struct tcp_conn_s *conn);
|
2016-01-22 22:52:14 +01:00
|
|
|
|
2014-06-21 23:23:39 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_wrbuffer_initialize
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the list of free write buffers
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called once early initialization.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
void tcp_wrbuffer_initialize(void);
|
|
|
|
#endif /* CONFIG_NET_TCP_WRITE_BUFFERS */
|
|
|
|
|
2022-02-17 05:58:00 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
|
|
|
|
struct tcp_wrbuffer_s;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_wrbuffer_timedalloc
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a TCP write buffer by taking a pre-allocated buffer from
|
|
|
|
* the free list. This function is called from TCP logic when a buffer
|
|
|
|
* of TCP data is about to sent
|
|
|
|
* This function is wrapped version of tcp_wrbuffer_alloc(),
|
|
|
|
* this wait will be terminated when the specified timeout expires.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* timeout - The relative time to wait until a timeout is declared.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from user logic with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct tcp_wrbuffer_s *tcp_wrbuffer_timedalloc(unsigned int timeout);
|
|
|
|
|
2014-06-21 23:23:39 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_wrbuffer_alloc
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a TCP write buffer by taking a pre-allocated buffer from
|
|
|
|
* the free list. This function is called from TCP logic when a buffer
|
|
|
|
* of TCP data is about to sent
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2014-06-24 19:53:19 +02:00
|
|
|
* None
|
|
|
|
*
|
2014-06-21 23:23:39 +02:00
|
|
|
* Assumptions:
|
2015-01-28 18:56:11 +01:00
|
|
|
* Called from user logic with the network locked.
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-22 19:27:57 +02:00
|
|
|
FAR struct tcp_wrbuffer_s *tcp_wrbuffer_alloc(void);
|
2018-04-20 15:37:51 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_wrbuffer_tryalloc
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Try to allocate a TCP write buffer by taking a pre-allocated buffer from
|
|
|
|
* the free list. This function is called from TCP logic when a buffer
|
|
|
|
* of TCP data is about to be sent if the socket is non-blocking. Returns
|
|
|
|
* immediately if allocation fails.
|
|
|
|
*
|
|
|
|
* Input parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from user logic with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct tcp_wrbuffer_s *tcp_wrbuffer_tryalloc(void);
|
2014-06-21 23:23:39 +02:00
|
|
|
#endif /* CONFIG_NET_TCP_WRITE_BUFFERS */
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_wrbuffer_release
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Release a TCP write buffer by returning the buffer to the free list.
|
|
|
|
* This function is called from user logic after it is consumed the
|
|
|
|
* buffered data.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-01-15 22:06:46 +01:00
|
|
|
* Called from network stack logic with the network stack locked
|
2014-06-21 23:23:39 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
2014-06-22 19:27:57 +02:00
|
|
|
void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb);
|
|
|
|
#endif /* CONFIG_NET_TCP_WRITE_BUFFERS */
|
|
|
|
|
2022-03-31 05:40:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_wrbuffer_inqueue_size
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get the in-queued write buffer size from connection
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from user logic with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if CONFIG_NET_SEND_BUFSIZE > 0
|
|
|
|
uint32_t tcp_wrbuffer_inqueue_size(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
2016-01-22 22:52:14 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_wrbuffer_test
|
2016-01-22 22:52:14 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Check if there is room in the write buffer. Does not reserve any space.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
int tcp_wrbuffer_test(void);
|
|
|
|
#endif /* CONFIG_NET_TCP_WRITE_BUFFERS */
|
|
|
|
|
2022-01-29 19:13:22 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_event_handler_dump
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the TCP event handler related variables
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FEATURES
|
|
|
|
void tcp_event_handler_dump(FAR struct net_driver_s *dev,
|
|
|
|
FAR void *pvpriv,
|
|
|
|
uint16_t flags,
|
|
|
|
FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
2014-06-22 19:27:57 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_wrbuffer_dump
|
2014-06-22 19:27:57 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the contents of a write buffer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
2016-06-11 22:14:08 +02:00
|
|
|
#ifdef CONFIG_DEBUG_FEATURES
|
2014-06-23 17:40:17 +02:00
|
|
|
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb,
|
|
|
|
unsigned int len, unsigned int offset);
|
2014-06-22 19:27:57 +02:00
|
|
|
#else
|
2014-06-23 02:53:18 +02:00
|
|
|
# define tcp_wrbuffer_dump(msg,wrb)
|
2014-06-22 19:27:57 +02:00
|
|
|
#endif
|
2014-06-21 23:23:39 +02:00
|
|
|
#endif /* CONFIG_NET_TCP_WRITE_BUFFERS */
|
|
|
|
|
2015-01-30 14:25:01 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_pollsetup
|
2015-01-30 14:25:01 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Setup to monitor events on one TCP/IP socket
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - The TCP/IP socket of interest
|
|
|
|
* fds - The structure describing the events to be monitored, OR NULL if
|
|
|
|
* this is a request to stop monitoring events.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0: Success; Negated errno on failure
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds);
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: tcp_pollteardown
|
2015-01-30 14:25:01 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Teardown monitoring of events on an TCP/IP socket
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - The TCP/IP socket of interest
|
|
|
|
* fds - The structure describing the events to be monitored, OR NULL if
|
|
|
|
* this is a request to stop monitoring events.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0: Success; Negated errno on failure
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
|
|
|
|
|
2018-09-09 17:21:39 +02:00
|
|
|
/****************************************************************************
|
2018-09-10 01:32:10 +02:00
|
|
|
* Name: tcp_readahead_notifier_setup
|
2018-09-09 17:21:39 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2018-09-09 23:01:44 +02:00
|
|
|
* Set up to perform a callback to the worker function when an TCP data
|
|
|
|
* is added to the read-ahead buffer. The worker function will execute
|
|
|
|
* on the high priority worker thread.
|
2018-09-09 19:57:25 +02:00
|
|
|
*
|
2018-09-09 17:21:39 +02:00
|
|
|
* Input Parameters:
|
2018-09-09 23:01:44 +02:00
|
|
|
* worker - The worker function to execute on the high priority work
|
2018-09-10 01:32:10 +02:00
|
|
|
* queue when data is available in the TCP read-ahead buffer.
|
2019-07-01 20:25:32 +02:00
|
|
|
* conn - The TCP connection where read-ahead data is needed.
|
2018-09-09 23:01:44 +02:00
|
|
|
* arg - A user-defined argument that will be available to the worker
|
|
|
|
* function when it runs.
|
2018-09-09 17:21:39 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* > 0 - The signal notification is in place. The returned value is a
|
|
|
|
* key that may be used later in a call to
|
|
|
|
* tcp_notifier_teardown().
|
|
|
|
* == 0 - There is already buffered read-ahead data. No signal
|
|
|
|
* notification will be provided.
|
|
|
|
* < 0 - An unexpected error occurred and no signal will be sent. The
|
|
|
|
* returned value is a negated errno value that indicates the
|
|
|
|
* nature of the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2018-09-10 01:32:10 +02:00
|
|
|
int tcp_readahead_notifier_setup(worker_t worker,
|
|
|
|
FAR struct tcp_conn_s *conn,
|
|
|
|
FAR void *arg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2019-07-01 20:25:32 +02:00
|
|
|
* Name: tcp_writebuffer_notifier_setup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to perform a callback to the worker function when an TCP write
|
|
|
|
* buffer is emptied. The worker function will execute on the high
|
|
|
|
* priority worker thread.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* worker - The worker function to execute on the high priority work
|
|
|
|
* queue when all buffer TX data has been sent.
|
|
|
|
* conn - The TCP connection where buffer write data is pending.
|
|
|
|
* arg - A user-defined argument that will be available to the worker
|
|
|
|
* function when it runs.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* > 0 - The signal notification is in place. The returned value is a
|
|
|
|
* key that may be used later in a call to
|
|
|
|
* tcp_notifier_teardown().
|
|
|
|
* == 0 - There is already buffered read-ahead data. No signal
|
|
|
|
* notification will be provided.
|
|
|
|
* < 0 - An unexpected error occurred and no signal will be sent. The
|
|
|
|
* returned value is a negated errno value that indicates the
|
|
|
|
* nature of the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2019-07-01 20:25:32 +02:00
|
|
|
int tcp_writebuffer_notifier_setup(worker_t worker,
|
|
|
|
FAR struct tcp_conn_s *conn,
|
|
|
|
FAR void *arg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_disconnect_notifier_setup
|
2018-09-10 01:32:10 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to perform a callback to the worker function if the TCP
|
|
|
|
* connection is lost.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* worker - The worker function to execute on the high priority work
|
|
|
|
* queue when data is available in the TCP read-ahead buffer.
|
|
|
|
* conn - The TCP connection where read-ahead data is needed.
|
|
|
|
* arg - A user-defined argument that will be available to the worker
|
|
|
|
* function when it runs.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* > 0 - The signal notification is in place. The returned value is a
|
|
|
|
* key that may be used later in a call to
|
|
|
|
* tcp_notifier_teardown().
|
2019-07-27 18:26:52 +02:00
|
|
|
* == 0 - No connection has been established.
|
2018-09-10 01:32:10 +02:00
|
|
|
* < 0 - An unexpected error occurred and no signal will be sent. The
|
|
|
|
* returned value is a negated errno value that indicates the
|
|
|
|
* nature of the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2019-07-01 20:25:32 +02:00
|
|
|
int tcp_disconnect_notifier_setup(worker_t worker,
|
|
|
|
FAR struct tcp_conn_s *conn,
|
|
|
|
FAR void *arg);
|
2018-09-09 17:21:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_notifier_teardown
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Eliminate a TCP read-ahead notification previously setup by
|
2018-09-10 01:32:10 +02:00
|
|
|
* tcp_readahead_notifier_setup(). This function should only be called
|
|
|
|
* if the notification should be aborted prior to the notification. The
|
2018-09-09 17:21:39 +02:00
|
|
|
* notification will automatically be torn down after the signal is sent.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* key - The key value returned from a previous call to
|
2018-09-10 01:32:10 +02:00
|
|
|
* tcp_readahead_notifier_setup().
|
2018-09-09 17:21:39 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
2022-05-13 12:26:42 +02:00
|
|
|
* None.
|
2018-09-09 17:21:39 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2022-05-13 12:26:42 +02:00
|
|
|
void tcp_notifier_teardown(int key);
|
2018-09-09 17:21:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2018-09-10 01:32:10 +02:00
|
|
|
* Name: tcp_readahead_signal
|
2018-09-09 17:21:39 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read-ahead data has been buffered. Signal all threads waiting for
|
|
|
|
* read-ahead data to become available.
|
|
|
|
*
|
2018-09-09 23:01:44 +02:00
|
|
|
* When read-ahead data becomes available, *all* of the workers waiting
|
|
|
|
* for read-ahead data will be executed. If there are multiple workers
|
|
|
|
* waiting for read-ahead data then only the first to execute will get the
|
2018-09-10 01:32:10 +02:00
|
|
|
* data. Others will need to call tcp_readahead_notifier_setup() once
|
|
|
|
* again.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection where read-ahead data was just buffered.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-01-11 04:56:03 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2018-09-10 01:32:10 +02:00
|
|
|
void tcp_readahead_signal(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
2019-07-01 20:25:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_writebuffer_signal
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* All buffer Tx data has been sent. Signal all threads waiting for the
|
|
|
|
* write buffers to become empty.
|
|
|
|
*
|
|
|
|
* When write buffer becomes empty, *all* of the workers waiting
|
|
|
|
* for that event data will be executed. If there are multiple workers
|
|
|
|
* waiting for read-ahead data then only the first to execute will get the
|
|
|
|
* data. Others will need to call tcp_writebuffer_notifier_setup() once
|
|
|
|
* again.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection where read-ahead data was just buffered.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) && defined(CONFIG_NET_TCP_NOTIFIER)
|
2019-07-01 20:25:32 +02:00
|
|
|
void tcp_writebuffer_signal(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
2018-09-10 01:32:10 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_disconnect_signal
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The TCP connection has been lost. Signal all threads monitoring TCP
|
|
|
|
* state events.
|
2018-09-09 19:57:25 +02:00
|
|
|
*
|
2018-09-09 17:21:39 +02:00
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection where read-ahead data was just buffered.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#ifdef CONFIG_NET_TCP_NOTIFIER
|
2018-09-10 01:32:10 +02:00
|
|
|
void tcp_disconnect_signal(FAR struct tcp_conn_s *conn);
|
2018-09-09 17:21:39 +02:00
|
|
|
#endif
|
|
|
|
|
2019-07-01 20:25:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_txdrain
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Wait for all write buffers to be sent (or for a timeout to occur).
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - An instance of the internal socket structure.
|
2020-01-04 11:37:46 +01:00
|
|
|
* timeout - The relative time when the timeout will occur
|
2019-07-01 20:25:32 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on any failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) && defined(CONFIG_NET_TCP_NOTIFIER)
|
2020-01-04 11:37:46 +01:00
|
|
|
int tcp_txdrain(FAR struct socket *psock, unsigned int timeout);
|
2019-07-01 20:25:32 +02:00
|
|
|
#else
|
2020-01-04 11:37:46 +01:00
|
|
|
# define tcp_txdrain(conn, timeout) (0)
|
2019-07-01 20:25:32 +02:00
|
|
|
#endif
|
|
|
|
|
2021-06-07 12:06:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_ioctl
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function performs tcp specific ioctl() operations.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* conn The TCP connection of interest
|
|
|
|
* cmd The ioctl command
|
|
|
|
* arg The argument of the ioctl cmd
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-08-30 20:18:33 +02:00
|
|
|
int tcp_ioctl(FAR struct tcp_conn_s *conn, int cmd, unsigned long arg);
|
2021-06-07 12:06:44 +02:00
|
|
|
|
2021-07-19 15:45:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_sendbuffer_notify
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Notify the send buffer semaphore
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called from user logic with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if CONFIG_NET_SEND_BUFSIZE > 0
|
|
|
|
void tcp_sendbuffer_notify(FAR struct tcp_conn_s *conn);
|
|
|
|
#endif /* CONFIG_NET_SEND_BUFSIZE */
|
|
|
|
|
2022-11-23 12:39:40 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcpip_hdrsize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get the total size of L3 and L4 TCP header
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn The connection structure associated with the socket
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* the total size of L3 and L4 TCP header
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint16_t tcpip_hdrsize(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2023-01-06 08:30:58 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_ofoseg_bufsize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Calculate the pending size of out-of-order buffer
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Total size of out-of-order buffer
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function must be called with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int tcp_ofoseg_bufsize(FAR struct tcp_conn_s *conn);
|
|
|
|
|
2023-01-10 06:41:02 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_reorder_ofosegs
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Sort out-of-order segments by left edge
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* nofosegs - Number of out-of-order semgnets
|
|
|
|
* ofosegs - Pointer to out-of-order segments
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* True if re-order occurs
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
bool tcp_reorder_ofosegs(int nofosegs, FAR struct tcp_ofoseg_s *ofosegs);
|
|
|
|
|
2023-04-20 05:08:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_cc_init
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the congestion control variables, cwnd, ssthresh and dupacks.
|
|
|
|
* The function is called on starting a new connection.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The normal user level code is calling the connect/accept to start a new
|
|
|
|
* connection.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_CC_NEWRENO
|
|
|
|
void tcp_cc_init(FAR struct tcp_conn_s *conn);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_cc_update
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update the congestion control variables when recieve the SYNACK/ACK
|
|
|
|
* packet from the peer in the connection phase.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
* tcp - The TCP header.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_cc_update(FAR struct tcp_conn_s *conn, FAR struct tcp_hdr_s *tcp);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_cc_recv_ack
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update congestion control variables
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP connection of interest
|
|
|
|
* tcp - The TCP header.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_cc_recv_ack(FAR struct tcp_conn_s *conn, FAR struct tcp_hdr_s *tcp);
|
|
|
|
#endif
|
|
|
|
|
2014-06-21 23:23:39 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-06-20 13:43:37 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: tcp_set_zero_probe
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update the TCP probe timer for the provided TCP connection,
|
|
|
|
* The timeout is accurate
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The TCP "connection" to poll for TX data
|
|
|
|
* flags - Set of connection events
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* conn is not NULL.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void tcp_set_zero_probe(FAR struct tcp_conn_s *conn, uint16_t flags);
|
|
|
|
|
2022-10-31 04:10:04 +01:00
|
|
|
#endif /* !CONFIG_NET_TCP_NO_STACK */
|
|
|
|
#endif /* CONFIG_NET_TCP */
|
2022-01-15 03:44:35 +01:00
|
|
|
#endif /* __NET_TCP_TCP_H */
|