summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog3
-rw-r--r--nuttx/Documentation/NuttX.html5
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html5
-rw-r--r--nuttx/Documentation/NuttxUserGuide.html8
-rw-r--r--nuttx/TODO4
-rw-r--r--nuttx/configs/README.txt3
-rw-r--r--nuttx/configs/c5471evm/defconfig3
-rw-r--r--nuttx/configs/c5471evm/dhcpconfig3
-rw-r--r--nuttx/configs/c5471evm/netconfig3
-rw-r--r--nuttx/configs/c5471evm/nshconfig3
-rw-r--r--nuttx/configs/ez80f910200kitg/ostest/defconfig2
-rw-r--r--nuttx/configs/m68332evb/defconfig2
-rw-r--r--nuttx/configs/mcu123-lpc214x/nsh/defconfig2
-rw-r--r--nuttx/configs/mcu123-lpc214x/ostest/defconfig2
-rw-r--r--nuttx/configs/mcu123-lpc214x/usbserial/defconfig2
-rw-r--r--nuttx/configs/mcu123-lpc214x/usbstorage/defconfig2
-rw-r--r--nuttx/configs/ntosd-dm320/nettest/defconfig4
-rw-r--r--nuttx/configs/ntosd-dm320/nsh/defconfig4
-rw-r--r--nuttx/configs/ntosd-dm320/ostest/defconfig2
-rw-r--r--nuttx/configs/ntosd-dm320/poll/defconfig5
-rw-r--r--nuttx/configs/ntosd-dm320/udp/defconfig4
-rw-r--r--nuttx/configs/ntosd-dm320/uip/defconfig4
-rw-r--r--nuttx/configs/olimex-strp711/ostest/defconfig2
-rw-r--r--nuttx/configs/pjrc-8051/defconfig2
-rw-r--r--nuttx/configs/sim/mount/defconfig2
-rw-r--r--nuttx/configs/sim/nettest/defconfig2
-rw-r--r--nuttx/configs/sim/nsh/defconfig2
-rw-r--r--nuttx/configs/sim/ostest/defconfig2
-rw-r--r--nuttx/configs/sim/pashello/defconfig2
-rw-r--r--nuttx/configs/us7032evb1/nsh/defconfig2
-rw-r--r--nuttx/configs/us7032evb1/ostest/defconfig2
-rw-r--r--nuttx/configs/xtrs/nsh/defconfig2
-rw-r--r--nuttx/configs/xtrs/ostest/defconfig2
-rw-r--r--nuttx/configs/xtrs/pashello/defconfig2
-rw-r--r--nuttx/configs/z16f2800100zcog/ostest/defconfig2
-rw-r--r--nuttx/configs/z16f2800100zcog/pashello/defconfig2
-rw-r--r--nuttx/configs/z80sim/nsh/defconfig2
-rw-r--r--nuttx/configs/z80sim/ostest/defconfig2
-rw-r--r--nuttx/configs/z80sim/pashello/defconfig2
-rw-r--r--nuttx/configs/z8encore000zco/ostest/defconfig2
-rw-r--r--nuttx/configs/z8f64200100kit/ostest/defconfig2
-rw-r--r--nuttx/examples/README.txt5
-rw-r--r--nuttx/examples/poll/Makefile2
-rw-r--r--nuttx/examples/poll/poll_main.c2
-rw-r--r--nuttx/include/net/uip/uip-tcp.h95
-rw-r--r--nuttx/include/net/uip/uip.h16
-rw-r--r--nuttx/net/accept.c112
-rw-r--r--nuttx/net/listen.c19
-rw-r--r--nuttx/net/net-poll.c10
-rw-r--r--nuttx/net/uip/Make.defs2
-rw-r--r--nuttx/net/uip/uip-internal.h2
-rw-r--r--nuttx/net/uip/uip-listen.c29
-rw-r--r--nuttx/net/uip/uip-tcpbacklog.c348
-rw-r--r--nuttx/net/uip/uip-tcpconn.c18
-rw-r--r--nuttx/net/uip/uip-tcpinput.c2
-rw-r--r--nuttx/net/uip/uip-tcpreadahead.c2
-rw-r--r--nuttx/net/uip/uip-tcptimer.c2
57 files changed, 682 insertions, 97 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index f928eb02e..c880ef3e2 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -576,4 +576,7 @@
and not recv() is in-place when a TCP/IP packet is received, the packet is placed into
a read-ahead buffer. However, the old contents of the read-ahead buffer were not being
cleared and old data would contaminate the newly received buffer.
+ * Implemented support for connection backlog. The size of the backlog is specified by the
+ second argument of the standard listen() API. Hooks are provided to support poll()/select()
+ waiting for connections, with a subsequent call to accept() to use the backlogged connection.
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 39ba8dcc3..3dd0d53fa 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
- <p>Last Updated: November 17, 2008</p>
+ <p>Last Updated: November 20, 2008</p>
</td>
</tr>
</table>
@@ -1212,6 +1212,9 @@ nuttx-0.3.19 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
and not recv() is in-place when a TCP/IP packet is received, the packet is placed into
a read-ahead buffer. However, the old contents of the read-ahead buffer were not being
cleared and old data would contaminate the newly received buffer.
+ * Implemented support for connection backlog. The size of the backlog is specified by the
+ second argument of the standard listen() API. Hooks are provided to support poll()/select()
+ waiting for connections, with a subsequent call to accept() to use the backlogged connection.
pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index f32138fcd..0d3b978d0 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -1595,6 +1595,11 @@ The system can be re-made subsequently by just typing <code>make</code>.
<code>CONFIG_NET_TCP_CONNS</code>: Maximum number of TCP connections (all tasks).
</li>
<li>
+ <code>CONFIG_NET_TCPBACKLOG</code>:
+ Incoming connections pend in a backlog until <code>accept()</code> is called.
+ The size of the backlog is selected when <code>listen()</code> is called.
+ </li>
+ <li>
<code>CONFIG_NET_TCP_READAHEAD_BUFSIZE</code>: Size of TCP read-ahead buffers
</li>
<li>
diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html
index e843908a7..0dfa64a87 100644
--- a/nuttx/Documentation/NuttxUserGuide.html
+++ b/nuttx/Documentation/NuttxUserGuide.html
@@ -6070,6 +6070,14 @@ interface of the same name.
<li><code>CONFIG_NET_NTCP_READAHEAD_BUFFERS</code> Defined to be greater than zero</li>
</ul>
<p>
+ In order to for select to work with incoming connections, you must also select:
+</p>
+<ul>
+ <li><code>CONFIG_NET_TCPBACKLOG</code>
+ Incoming connections pend in a backlog until <code>accept()</cod> is called.
+ The size of the backlog is selected when <code>listen()</code> is called.</li>
+</ul>
+<p>
<b>Input Parameters:</b>
</p>
<ul>
diff --git a/nuttx/TODO b/nuttx/TODO
index 4d31d9dbd..e90e10e9c 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated November 17, 2008)
+NuttX TODO List (Last updated November 19, 2008)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(7) Task/Scheduler (sched/)
@@ -7,7 +7,7 @@ NuttX TODO List (Last updated November 17, 2008)
(1) Signals (sched/, arch/)
(1) pthreads (sched/)
(1) C++ Support
- (14) Network (net/, netutils/)
+ (15) Network (net/, netutils/)
(1) USB (drivers/usbdev)
(4) Libraries (lib/)
(6) File system/Generic drivers (fs/, drivers/)
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 750d945a9..176cbbe6f 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -287,6 +287,9 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers
(may be zero)
+ CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+ accept() is called. The size of the backlog is selected when listen()
+ is called.
CONFIG_NET_UDP - UDP support on or off
CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP
diff --git a/nuttx/configs/c5471evm/defconfig b/nuttx/configs/c5471evm/defconfig
index 5b5c70ed3..e388541aa 100644
--- a/nuttx/configs/c5471evm/defconfig
+++ b/nuttx/configs/c5471evm/defconfig
@@ -279,6 +279,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -300,6 +302,7 @@ CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=n
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_NTCP_READAHEAD_BUFFERS=8
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/c5471evm/dhcpconfig b/nuttx/configs/c5471evm/dhcpconfig
index 7a44e126c..8359dd6c9 100644
--- a/nuttx/configs/c5471evm/dhcpconfig
+++ b/nuttx/configs/c5471evm/dhcpconfig
@@ -279,6 +279,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -300,6 +302,7 @@ CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=n
CONFIG_NET_TCP_CONNS=0
CONFIG_NET_NTCP_READAHEAD_BUFFERS=0
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=0
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/c5471evm/netconfig b/nuttx/configs/c5471evm/netconfig
index 135f87ec9..61c3176f7 100644
--- a/nuttx/configs/c5471evm/netconfig
+++ b/nuttx/configs/c5471evm/netconfig
@@ -279,6 +279,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -300,6 +302,7 @@ CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
CONFIG_NET_NTCP_READAHEAD_BUFFERS=32
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/c5471evm/nshconfig b/nuttx/configs/c5471evm/nshconfig
index 39a3b1121..c6566fe0f 100644
--- a/nuttx/configs/c5471evm/nshconfig
+++ b/nuttx/configs/c5471evm/nshconfig
@@ -279,6 +279,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -300,6 +302,7 @@ CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
CONFIG_NET_NTCP_READAHEAD_BUFFERS=32
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/ez80f910200kitg/ostest/defconfig b/nuttx/configs/ez80f910200kitg/ostest/defconfig
index 117495ba3..12b9efb78 100644
--- a/nuttx/configs/ez80f910200kitg/ostest/defconfig
+++ b/nuttx/configs/ez80f910200kitg/ostest/defconfig
@@ -279,6 +279,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/m68332evb/defconfig b/nuttx/configs/m68332evb/defconfig
index 12af3888a..2e668f2bb 100644
--- a/nuttx/configs/m68332evb/defconfig
+++ b/nuttx/configs/m68332evb/defconfig
@@ -263,6 +263,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/mcu123-lpc214x/nsh/defconfig b/nuttx/configs/mcu123-lpc214x/nsh/defconfig
index 9f6d9edd7..f7ea9ae7b 100644
--- a/nuttx/configs/mcu123-lpc214x/nsh/defconfig
+++ b/nuttx/configs/mcu123-lpc214x/nsh/defconfig
@@ -316,6 +316,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/mcu123-lpc214x/ostest/defconfig b/nuttx/configs/mcu123-lpc214x/ostest/defconfig
index be623258c..83824dd65 100644
--- a/nuttx/configs/mcu123-lpc214x/ostest/defconfig
+++ b/nuttx/configs/mcu123-lpc214x/ostest/defconfig
@@ -311,6 +311,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/mcu123-lpc214x/usbserial/defconfig b/nuttx/configs/mcu123-lpc214x/usbserial/defconfig
index 63cabf7c4..cd318b422 100644
--- a/nuttx/configs/mcu123-lpc214x/usbserial/defconfig
+++ b/nuttx/configs/mcu123-lpc214x/usbserial/defconfig
@@ -312,6 +312,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/mcu123-lpc214x/usbstorage/defconfig b/nuttx/configs/mcu123-lpc214x/usbstorage/defconfig
index aeaa2e914..294e3fc8f 100644
--- a/nuttx/configs/mcu123-lpc214x/usbstorage/defconfig
+++ b/nuttx/configs/mcu123-lpc214x/usbstorage/defconfig
@@ -312,6 +312,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/ntosd-dm320/nettest/defconfig b/nuttx/configs/ntosd-dm320/nettest/defconfig
index f25b9ac8b..eea5c03c6 100644
--- a/nuttx/configs/ntosd-dm320/nettest/defconfig
+++ b/nuttx/configs/ntosd-dm320/nettest/defconfig
@@ -277,6 +277,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -297,6 +299,8 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
+CONFIG_NET_NTCP_READAHEAD_BUFFERS=16
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/ntosd-dm320/nsh/defconfig b/nuttx/configs/ntosd-dm320/nsh/defconfig
index e1b318dd4..1134b7204 100644
--- a/nuttx/configs/ntosd-dm320/nsh/defconfig
+++ b/nuttx/configs/ntosd-dm320/nsh/defconfig
@@ -285,6 +285,8 @@ CONFIG_FS_ROMFS=y
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -305,6 +307,8 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=562
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
+CONFIG_NET_NTCP_READAHEAD_BUFFERS=16
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/ntosd-dm320/ostest/defconfig b/nuttx/configs/ntosd-dm320/ostest/defconfig
index c4f70d85f..96dfa7127 100644
--- a/nuttx/configs/ntosd-dm320/ostest/defconfig
+++ b/nuttx/configs/ntosd-dm320/ostest/defconfig
@@ -277,6 +277,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/ntosd-dm320/poll/defconfig b/nuttx/configs/ntosd-dm320/poll/defconfig
index c7dd78daf..f88a6b951 100644
--- a/nuttx/configs/ntosd-dm320/poll/defconfig
+++ b/nuttx/configs/ntosd-dm320/poll/defconfig
@@ -277,6 +277,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -297,7 +299,8 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
-CONFIG_NET_TCP_READAHEAD_BUFSIZE=16
+CONFIG_NET_NTCP_READAHEAD_BUFFERS=16
+CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/ntosd-dm320/udp/defconfig b/nuttx/configs/ntosd-dm320/udp/defconfig
index f2562d2ee..8237ac4b3 100644
--- a/nuttx/configs/ntosd-dm320/udp/defconfig
+++ b/nuttx/configs/ntosd-dm320/udp/defconfig
@@ -277,6 +277,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -297,6 +299,8 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=n
CONFIG_NET_TCP_CONNS=0
+CONFIG_NET_NTCP_READAHEAD_BUFFERS=16
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=0
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/ntosd-dm320/uip/defconfig b/nuttx/configs/ntosd-dm320/uip/defconfig
index 3219b4e86..190d5f185 100644
--- a/nuttx/configs/ntosd-dm320/uip/defconfig
+++ b/nuttx/configs/ntosd-dm320/uip/defconfig
@@ -277,6 +277,8 @@ CONFIG_PREALLOC_TIMERS=8
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
@@ -297,6 +299,8 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
+CONFIG_NET_NTCP_READAHEAD_BUFFERS=16
+CONFIG_NET_TCPBACKLOG=n
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
diff --git a/nuttx/configs/olimex-strp711/ostest/defconfig b/nuttx/configs/olimex-strp711/ostest/defconfig
index 1632dbb08..17f0d90a4 100644
--- a/nuttx/configs/olimex-strp711/ostest/defconfig
+++ b/nuttx/configs/olimex-strp711/ostest/defconfig
@@ -378,6 +378,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/pjrc-8051/defconfig b/nuttx/configs/pjrc-8051/defconfig
index 934e255a8..68cf619c0 100644
--- a/nuttx/configs/pjrc-8051/defconfig
+++ b/nuttx/configs/pjrc-8051/defconfig
@@ -260,6 +260,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/sim/mount/defconfig b/nuttx/configs/sim/mount/defconfig
index 2c39b55a9..ff24f5bff 100644
--- a/nuttx/configs/sim/mount/defconfig
+++ b/nuttx/configs/sim/mount/defconfig
@@ -235,6 +235,8 @@ CONFIG_FS_ROMFS=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/sim/nettest/defconfig b/nuttx/configs/sim/nettest/defconfig
index f211b86cc..65a0a5c48 100644
--- a/nuttx/configs/sim/nettest/defconfig
+++ b/nuttx/configs/sim/nettest/defconfig
@@ -235,6 +235,8 @@ CONFIG_FS_ROMFS=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig
index 3ea4b4e44..f5a0531f9 100644
--- a/nuttx/configs/sim/nsh/defconfig
+++ b/nuttx/configs/sim/nsh/defconfig
@@ -235,6 +235,8 @@ CONFIG_FS_ROMFS=y
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/sim/ostest/defconfig b/nuttx/configs/sim/ostest/defconfig
index 4c1249466..4ea688e85 100644
--- a/nuttx/configs/sim/ostest/defconfig
+++ b/nuttx/configs/sim/ostest/defconfig
@@ -236,6 +236,8 @@ CONFIG_FS_ROMFS=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/sim/pashello/defconfig b/nuttx/configs/sim/pashello/defconfig
index 164c4ac6b..67dd4688c 100644
--- a/nuttx/configs/sim/pashello/defconfig
+++ b/nuttx/configs/sim/pashello/defconfig
@@ -235,6 +235,8 @@ CONFIG_FS_ROMFS=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/us7032evb1/nsh/defconfig b/nuttx/configs/us7032evb1/nsh/defconfig
index e4e150b09..b97c94185 100644
--- a/nuttx/configs/us7032evb1/nsh/defconfig
+++ b/nuttx/configs/us7032evb1/nsh/defconfig
@@ -330,6 +330,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/us7032evb1/ostest/defconfig b/nuttx/configs/us7032evb1/ostest/defconfig
index e21df0942..ae3160cb6 100644
--- a/nuttx/configs/us7032evb1/ostest/defconfig
+++ b/nuttx/configs/us7032evb1/ostest/defconfig
@@ -330,6 +330,8 @@ CONFIG_MMCSD_READONLY=n
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/xtrs/nsh/defconfig b/nuttx/configs/xtrs/nsh/defconfig
index d26ff9d06..0938ef807 100644
--- a/nuttx/configs/xtrs/nsh/defconfig
+++ b/nuttx/configs/xtrs/nsh/defconfig
@@ -256,6 +256,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/xtrs/ostest/defconfig b/nuttx/configs/xtrs/ostest/defconfig
index b17d18c23..4ede528f3 100644
--- a/nuttx/configs/xtrs/ostest/defconfig
+++ b/nuttx/configs/xtrs/ostest/defconfig
@@ -256,6 +256,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/xtrs/pashello/defconfig b/nuttx/configs/xtrs/pashello/defconfig
index 7e7e7f986..cca03f9d7 100644
--- a/nuttx/configs/xtrs/pashello/defconfig
+++ b/nuttx/configs/xtrs/pashello/defconfig
@@ -256,6 +256,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z16f2800100zcog/ostest/defconfig b/nuttx/configs/z16f2800100zcog/ostest/defconfig
index 6b3959ec4..a7706199a 100644
--- a/nuttx/configs/z16f2800100zcog/ostest/defconfig
+++ b/nuttx/configs/z16f2800100zcog/ostest/defconfig
@@ -282,6 +282,8 @@ CONFIG_PREALLOC_TIMERS=4
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z16f2800100zcog/pashello/defconfig b/nuttx/configs/z16f2800100zcog/pashello/defconfig
index d1ac37bd3..0ea008a40 100644
--- a/nuttx/configs/z16f2800100zcog/pashello/defconfig
+++ b/nuttx/configs/z16f2800100zcog/pashello/defconfig
@@ -282,6 +282,8 @@ CONFIG_PREALLOC_TIMERS=4
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z80sim/nsh/defconfig b/nuttx/configs/z80sim/nsh/defconfig
index 0589cdc06..14fd9c0c2 100644
--- a/nuttx/configs/z80sim/nsh/defconfig
+++ b/nuttx/configs/z80sim/nsh/defconfig
@@ -246,6 +246,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z80sim/ostest/defconfig b/nuttx/configs/z80sim/ostest/defconfig
index ecf71cb6d..0dc407750 100644
--- a/nuttx/configs/z80sim/ostest/defconfig
+++ b/nuttx/configs/z80sim/ostest/defconfig
@@ -246,6 +246,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z80sim/pashello/defconfig b/nuttx/configs/z80sim/pashello/defconfig
index 4e2e6a6a0..cad124da5 100644
--- a/nuttx/configs/z80sim/pashello/defconfig
+++ b/nuttx/configs/z80sim/pashello/defconfig
@@ -246,6 +246,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z8encore000zco/ostest/defconfig b/nuttx/configs/z8encore000zco/ostest/defconfig
index 4f8a8c4e2..776cecd08 100644
--- a/nuttx/configs/z8encore000zco/ostest/defconfig
+++ b/nuttx/configs/z8encore000zco/ostest/defconfig
@@ -280,6 +280,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/configs/z8f64200100kit/ostest/defconfig b/nuttx/configs/z8f64200100kit/ostest/defconfig
index 444ff59d0..50df6ae07 100644
--- a/nuttx/configs/z8f64200100kit/ostest/defconfig
+++ b/nuttx/configs/z8f64200100kit/ostest/defconfig
@@ -280,6 +280,8 @@ CONFIG_PREALLOC_TIMERS=0
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
+# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
+# accept() is called. The size of the backlog is selected when listen() is called.
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
diff --git a/nuttx/examples/README.txt b/nuttx/examples/README.txt
index f6528e5f4..f2a597800 100644
--- a/nuttx/examples/README.txt
+++ b/nuttx/examples/README.txt
@@ -118,6 +118,11 @@ examples/poll
CONFIG_EXAMPLE_POLL_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_POLL_NETMASK - Network mask
+ In order to for select to work with incoming connections, you
+ must also select:
+
+ CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until accept() is called.
+
In additional to the target device-side example, there is also
a host-side application in this directory. It can be compiled under
Linux or Cygwin as follows:
diff --git a/nuttx/examples/poll/Makefile b/nuttx/examples/poll/Makefile
index b52719912..e91f5018c 100644
--- a/nuttx/examples/poll/Makefile
+++ b/nuttx/examples/poll/Makefile
@@ -70,6 +70,6 @@ clean:
$(call CLEAN)
distclean: clean
- @rm -f Make.dep .depend
+ @rm -f Make.dep .depend host
-include Make.dep
diff --git a/nuttx/examples/poll/poll_main.c b/nuttx/examples/poll/poll_main.c
index 713c77e3a..dbf5eec65 100644
--- a/nuttx/examples/poll/poll_main.c
+++ b/nuttx/examples/poll/poll_main.c
@@ -156,7 +156,7 @@ int user_start(int argc, char *argv[])
}
#ifdef HAVE_NETPOLL
-#if 0 /* select doesn't work for connections yet */
+#ifdef CONFIG_NET_TCPBACKLOG
message("user_start: Starting net_listener thread\n");
ret = pthread_create(&tid3, NULL, net_listener, NULL);
diff --git a/nuttx/include/net/uip/uip-tcp.h b/nuttx/include/net/uip/uip-tcp.h
index 409081f28..91c5ecbd0 100644
--- a/nuttx/include/net/uip/uip-tcp.h
+++ b/nuttx/include/net/uip/uip-tcp.h
@@ -77,19 +77,19 @@
/* The TCP states used in the struct uip_conn tcpstateflags field */
-#define UIP_CLOSED 0 /* The connection is not in use and available */
-#define UIP_ALLOCATED 1 /* The connection is allocated, but not yet initialized */
-#define UIP_SYN_RCVD 2
-#define UIP_SYN_SENT 3
-#define UIP_ESTABLISHED 4
-#define UIP_FIN_WAIT_1 5
-#define UIP_FIN_WAIT_2 6
-#define UIP_CLOSING 7
-#define UIP_TIME_WAIT 8
-#define UIP_LAST_ACK 9
-
-#define UIP_TS_MASK 15
-#define UIP_STOPPED 16
+#define UIP_TS_MASK 0x0f /* Bits 0-3: TCP state */
+#define UIP_CLOSED 0x00 /* The connection is not in use and available */
+#define UIP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */
+#define UIP_SYN_RCVD 0x02
+#define UIP_SYN_SENT 0x03
+#define UIP_ESTABLISHED 0x04
+#define UIP_FIN_WAIT_1 0x05
+#define UIP_FIN_WAIT_2 0x06
+#define UIP_CLOSING 0x07
+#define UIP_TIME_WAIT 0x08
+#define UIP_LAST_ACK 0x09
+#define UIP_STOPPED 0x10 /* Bit 4: stopped */
+ /* Bit 5-7: Unused, but not available */
/* Flag bits in 16-bit flags+ipoffset IPv4 TCP header field */
@@ -118,13 +118,11 @@
struct uip_driver_s; /* Forward reference */
struct uip_callback_s; /* Forward reference */
+struct uip_backlog_s; /* Forward reference */
struct uip_conn
{
dq_entry_t node; /* Implements a doubly linked list */
-#if 0 /* Not used */
- uip_ipaddr_t lipaddr; /* The local IP address */
-#endif
uip_ipaddr_t ripaddr; /* The IP address of the remote host */
uint16 lport; /* The local TCP port, in network byte order */
uint16 rport; /* The remoteTCP port, in network byte order */
@@ -146,10 +144,29 @@ struct uip_conn
uint8 nrtx; /* The number of retransmissions for the last
* segment sent */
- /* Read-ahead buffering */
+ /* Read-ahead buffering.
+ *
+ * readahead - A singly linked list of type struct uip_readahead_s
+ * where the TCP/IP read-ahead data is retained.
+ */
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
- sq_queue_t readahead;
+ sq_queue_t readahead; /* Read-ahead buffering */
+#endif
+
+ /* 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 uip_backlog_s tear-off structure that manages that backlog.
+ */
+
+#ifdef CONFIG_NET_TCPBACKLOG
+ struct uip_conn *blparent;
+ struct uip_backlog_s *backlog;
#endif
/* Application callbacks:
@@ -204,6 +221,27 @@ struct uip_readahead_s
};
#endif
+/* Support for listen backlog:
+ *
+ * struct uip_blcontainer_s describes one backlogged connection
+ * struct uip_backlog_s is a "tear-off" describing all backlog for a
+ * listener connection
+ */
+
+#ifdef CONFIG_NET_TCPBACKLOG
+struct uip_blcontainer_s
+{
+ dq_entry_t bc_node; /* Implements a doubly linked list */
+ FAR struct uip_conn *bc_conn; /* Holds reference to the new connection structure */
+};
+
+struct uip_backlog_s
+{
+ dq_queue_t bl_free; /* Implements a doubly-linked list of free containers */
+ dq_queue_t bl_pending; /* Implements a doubly-linked list of pending connections */
+};
+#endif
+
/* The structure holding the TCP/IP statistics that are gathered if
* CONFIG_NET_STATISTICS is defined.
*/
@@ -350,6 +388,27 @@ extern struct uip_readahead_s *uip_tcpreadaheadalloc(void);
extern void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */
+/* Backlog support */
+
+#ifdef CONFIG_NET_TCPBACKLOG
+/* APIs to create and terminate TCP backlog support */
+
+extern int uip_backlogcreate(FAR struct uip_conn *conn, int nblg);
+extern int uip_backlogdestroy(FAR struct uip_conn *conn);
+
+/* APIs to manage individual backlog actions */
+
+extern int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn);
+extern FAR struct uip_conn *uip_backlogremove(FAR struct uip_conn *conn);
+extern int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn);
+
+#else
+# define uip_backlogcreate(conn,nblg) (-ENOSYS)
+# define uip_backlogdestroy(conn) (-ENOSYS)
+# define uip_backlogadd(conn,blconn) (-ENOSYS)
+# define uip_backlogremove(conn) (NULL)
+#endif
+
/* Tell the sending host to stop sending data.
*
* This function will close our receiver's window so that we stop
diff --git a/nuttx/include/net/uip/uip.h b/nuttx/include/net/uip/uip.h
index 54a94bf98..bc79f64e7 100644
--- a/nuttx/include/net/uip/uip.h
+++ b/nuttx/include/net/uip/uip.h
@@ -81,7 +81,10 @@
* UIP_POLL IN: Used for polling the application. This is provided
* periodically from the drivers to support (1) timed
* operations, and (2) to check if the application has
-* data that it wants to send
+ * data that it wants to send
+ * OUT: Not used
+ * UIP_BACKLOG IN: There is a new connection in the backlog list set
+ * up by the listen() command. (TCP only)
* OUT: Not used
* UIP_CLOSE IN: The remote host has closed the connection, thus the
* connection has gone away. (TCP only)
@@ -110,11 +113,12 @@
#define UIP_SNDACK (1 << 2)
#define UIP_REXMIT (1 << 3)
#define UIP_POLL (1 << 4)
-#define UIP_CLOSE (1 << 5)
-#define UIP_ABORT (1 << 6)
-#define UIP_CONNECTED (1 << 7)
-#define UIP_TIMEDOUT (1 << 8)
-#define UIP_ECHOREPLY (1 << 9)
+#define UIP_BACKLOG (1 << 5)
+#define UIP_CLOSE (1 << 6)
+#define UIP_ABORT (1 << 7)
+#define UIP_CONNECTED (1 << 8)
+#define UIP_TIMEDOUT (1 << 9)
+#define UIP_ECHOREPLY (1 << 10)
#define UIP_CONN_EVENTS (UIP_CLOSE|UIP_ABORT|UIP_CONNECTED|UIP_TIMEDOUT)
diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c
index 122e67c43..3fea60b19 100644
--- a/nuttx/net/accept.c
+++ b/nuttx/net/accept.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/accept.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -289,7 +289,9 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
goto errout;
}
- /* Verify that a valid memory block has been provided to receive the address address */
+ /* Verify that a valid memory block has been provided to receive
+ * the address
+ */
#ifdef CONFIG_NET_IPv6
if (addr->sa_family != AF_INET6 || *addrlen < sizeof(struct sockaddr_in6))
@@ -301,7 +303,9 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
goto errout;
}
- /* Allocate a socket descriptor for the new connection now (so that it cannot fail later) */
+ /* Allocate a socket descriptor for the new connection now
+ * (so that it cannot fail later)
+ */
newfd = sockfd_allocate();
if (newfd < 0)
@@ -317,68 +321,79 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
goto errout_with_socket;
}
- /* Set the socket state to accepting */
+ /* Check the backlog to see if there is a connection already pending
+ * for this listener.
+ */
- psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_ACCEPT);
+ save = irqsave();
+ conn = (struct uip_conn *)psock->s_conn;
- /* Perform the TCP accept operation */
+#ifdef CONFIG_NET_TCPBACKLOG
+ state.acpt_newconn = uip_backlogremove(conn);
+ if (!state.acpt_newconn)
+#endif
+ {
+ /* Set the socket state to accepting */
- /* Initialize the state structure. This is done with interrupts
- * disabled because we don't want anything to happen until we
- * are ready.
- */
+ psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_ACCEPT);
- save = irqsave();
- state.acpt_addr = inaddr;
- state.acpt_newconn = NULL;
- state.acpt_result = OK;
- sem_init(&state.acpt_sem, 0, 0);
+ /* Perform the TCP accept operation */
- /* Set up the callback in the connection */
+ /* Initialize the state structure. This is done with interrupts
+ * disabled because we don't want anything to happen until we
+ * are ready.
+ */
- conn = (struct uip_conn *)psock->s_conn;
- conn->accept_private = (void*)&state;
- conn->accept = accept_interrupt;
+ state.acpt_addr = inaddr;
+ state.acpt_newconn = NULL;
+ state.acpt_result = OK;
+ sem_init(&state.acpt_sem, 0, 0);
- /* Wait for the send to complete or an error to occur: NOTES: (1)
- * sem_wait will also terminate if a signal is received, (2) interrupts
- * are disabled! They will be re-enabled while the task sleeps and
- * automatically re-enabled when the task restarts.
- */
+ /* Set up the callback in the connection */
- ret = sem_wait(&state.acpt_sem);
+ conn->accept_private = (void*)&state;
+ conn->accept = accept_interrupt;
- /* Make sure that no further interrupts are processed */
+ /* Wait for the send to complete or an error to occur: NOTES: (1)
+ * sem_wait will also terminate if a signal is received, (2) interrupts
+ * are disabled! They will be re-enabled while the task sleeps and
+ * automatically re-enabled when the task restarts.
+ */
- conn->accept_private = NULL;
- conn->accept = NULL;
+ ret = sem_wait(&state.acpt_sem);
- sem_destroy(&state. acpt_sem);
- irqrestore(save);
+ /* Make sure that no further interrupts are processed */
- /* Set the socket state to idle */
+ conn->accept_private = NULL;
+ conn->accept = NULL;
- psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
+ sem_destroy(&state. acpt_sem);
- /* Check for a errors. Errors are signaled by negative errno values
- * for the send length
- */
+ /* Set the socket state to idle */
- if (state.acpt_result != 0)
- {
- err = state.acpt_result;
- goto errout_with_socket;
- }
+ psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
- /* If sem_wait failed, then we were probably reawakened by a signal. In
- * this case, sem_wait will have set errno appropriately.
- */
+ /* Check for a errors. Errors are signaled by negative errno values
+ * for the send length
+ */
- if (ret < 0)
- {
- err = -ret;
- goto errout_with_socket;
+ if (state.acpt_result != 0)
+ {
+ err = state.acpt_result;
+ goto errout_with_irq;
+ }
+
+ /* If sem_wait failed, then we were probably reawakened by a signal. In
+ * this case, sem_wait will have set errno appropriately.
+ */
+
+ if (ret < 0)
+ {
+ err = -ret;
+ goto errout_with_irq;
+ }
}
+ irqrestore(save);
/* Initialize the socket structure and mark the socket as connected */
@@ -387,6 +402,9 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
pnewsock->s_flags |= _SF_CONNECTED;
return newfd;
+errout_with_irq:
+ irqrestore(save);
+
errout_with_socket:
sockfd_release(newfd);
diff --git a/nuttx/net/listen.c b/nuttx/net/listen.c
index f2f91b1f4..46bad5d94 100644
--- a/nuttx/net/listen.c
+++ b/nuttx/net/listen.c
@@ -114,7 +114,7 @@ int listen(int sockfd, int backlog)
}
/* Verify that the sockfd corresponds to a connected SOCK_STREAM */
-
+
conn = (struct uip_conn *)psock->s_conn;
if (psock->s_type != SOCK_STREAM || !psock->s_conn || conn->lport <= 0)
{
@@ -122,16 +122,27 @@ int listen(int sockfd, int backlog)
goto errout;
}
+ /* Set up the backlog for this connection */
+
+#ifdef CONFIG_NET_TCPBACKLOG
+ err = uip_backlogcreate(conn, backlog);
+ if (err < 0)
+ {
+ err = -err;
+ goto errout;
+ }
+#endif
+
/* Start listening to the bound port. This enables callbacks when accept()
- * is called; and someday should enable post() or select() logic.
+ * is called and enables poll()/select() logic.
*/
-
+
uip_listen(conn);
psock->s_flags |= _SF_LISTENING;
return OK;
errout:
- *get_errno_ptr() = err;
+ errno = err;
return ERROR;
}
diff --git a/nuttx/net/net-poll.c b/nuttx/net/net-poll.c
index 22bd03ce9..6dcb4c2d0 100644
--- a/nuttx/net/net-poll.c
+++ b/nuttx/net/net-poll.c
@@ -114,9 +114,9 @@ static uint16 poll_interrupt(struct uip_driver_s *dev, FAR void *conn,
{
pollevent_t eventset = 0;
- /* Check for data availability events. */
+ /* Check for data or connection availability events. */
- if ((flags & UIP_NEWDATA) != 0)
+ if ((flags & (UIP_NEWDATA|UIP_BACKLOG)) != 0)
{
eventset |= POLLIN & fds->events;
}
@@ -174,8 +174,7 @@ static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
#ifdef CONFIG_DEBUG
if (!conn || !fds)
{
- ret = -EINVAL;
- goto errout;
+ return -EINVAL;
}
#endif
@@ -194,7 +193,7 @@ static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
/* Initialize the callbcack structure */
- cb->flags = UIP_NEWDATA|UIP_POLL|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT;
+ cb->flags = UIP_NEWDATA|UIP_BACKLOG|UIP_POLL|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT;
cb->private = (FAR void *)fds;
cb->event = poll_interrupt;
@@ -219,7 +218,6 @@ static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
errout_with_irq:
irqrestore(flags);
-errout:
return ret;
}
#endif /* HAVE_NETPOLL */
diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs
index 0a1031684..543a8e856 100644
--- a/nuttx/net/uip/Make.defs
+++ b/nuttx/net/uip/Make.defs
@@ -53,7 +53,7 @@ ifeq ($(CONFIG_NET_TCP),y)
UIP_CSRCS += uip-tcpconn.c uip-tcppoll.c uip-tcptimer.c uip-tcpsend.c \
uip-tcpinput.c uip-tcpappsend.c uip-listen.c uip-tcpcallback.c \
- uip-tcpreadahead.c
+ uip-tcpreadahead.c uip-tcpbacklog.c
endif
diff --git a/nuttx/net/uip/uip-internal.h b/nuttx/net/uip/uip-internal.h
index 362cecc57..841555760 100644
--- a/nuttx/net/uip/uip-internal.h
+++ b/nuttx/net/uip/uip-internal.h
@@ -123,7 +123,7 @@ EXTERN void uip_tcptimer(struct uip_driver_s *dev, struct uip_conn *conn, int hs
EXTERN void uip_listeninit(void);
EXTERN boolean uip_islistener(uint16 port);
-EXTERN int uip_accept(struct uip_conn *conn, uint16 portno);
+EXTERN int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16 portno);
/* Defined in uip-tcpsend.c *************************************************/
diff --git a/nuttx/net/uip/uip-listen.c b/nuttx/net/uip/uip-listen.c
index 82d4238cd..b5e17a6bf 100644
--- a/nuttx/net/uip/uip-listen.c
+++ b/nuttx/net/uip/uip-listen.c
@@ -228,22 +228,41 @@ boolean uip_islistener(uint16 portno)
*
****************************************************************************/
-int uip_accept(struct uip_conn *conn, uint16 portno)
+int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16 portno)
{
struct uip_conn *listener;
int ret = ERROR;
/* The interrupt logic has already allocated and initialized a TCP
- * connection -- now check if is an application in place to accept the
+ * connection -- now check there if is an application in place to accept the
* connection.
*/
listener = uip_tcplistener(portno);
- if (listener && listener->accept)
+ if (listener)
{
- /* Yes.. accept the connection */
+ /* Yes, there is a listener. Is it accepting connections now? */
- ret = listener->accept(listener, conn);
+ if (listener->accept)
+ {
+ /* Yes.. accept the connection */
+
+ ret = listener->accept(listener, conn);
+ }
+#ifdef CONFIG_NET_TCPBACKLOG
+ else
+ {
+ /* Add the connection to the backlog and notify any threads that
+ * may be waiting on poll()/select() that the connection is available.
+ */
+
+ ret = uip_backlogadd(listener, conn);
+ if (ret == OK)
+ {
+ (void)uip_tcpcallback(dev, conn, UIP_BACKLOG);
+ }
+ }
+#endif
}
return ret;
}
diff --git a/nuttx/net/uip/uip-tcpbacklog.c b/nuttx/net/uip/uip-tcpbacklog.c
new file mode 100644
index 000000000..152d374ba
--- /dev/null
+++ b/nuttx/net/uip/uip-tcpbacklog.c
@@ -0,0 +1,348 @@
+/****************************************************************************
+ * net/uip/uip-tcpbacklog.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <net/uip/uipopt.h>
+#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) && defined(CONFIG_NET_TCPBACKLOG)
+
+#include <sys/types.h>
+
+#include <stdlib.h>
+#include <queue.h>
+#include <debug.h>
+
+#include <net/uip/uip.h>
+#include <net/uip/uip-tcp.h>
+
+#include "uip-internal.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: uip_backlogcreate
+ *
+ * Description:
+ * Called from the listen() logic to setup the backlog as specified in the
+ * the listen arguments *.
+ *
+ * Assumptions:
+ * Called from normal user code. Interrupts may be disabled.
+ *
+ ****************************************************************************/
+
+int uip_backlogcreate(FAR struct uip_conn *conn, int nblg)
+{
+ FAR struct uip_backlog_s *bls = NULL;
+ FAR struct uip_blcontainer_s *blc;
+ irqstate_t flags;
+ int size;
+ int offset;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!conn)
+ {
+ return -EINVAL;
+ }
+#endif
+
+ /* Then allocate the backlog as requested */
+
+ if (nblg > 0)
+ {
+ /* Align the list of backlog structures to 32-bit boundaries. This
+ * may be excessive on 24-16-bit address machines; and insufficient
+ * on 64-bit address machines -- REVISIT
+ */
+
+ offset = (sizeof(struct uip_backlog_s) + 3) & ~3;
+
+ /* Then determine the full size of the allocation include the
+ * uip_backlog_s, a pre-allocated array of struct uip_blcontainer_s
+ * and alignement padding
+ */
+
+ size = offset + nblg * sizeof(struct uip_blcontainer_s);
+
+ /* Then allocate that much */
+
+ bls = (FAR struct uip_backlog_s *)zalloc(size);
+ if (!bls)
+ {
+ return -ENOMEM;
+ }
+
+ /* Then add all of the pre-allocated containers to the the free list */
+
+ blc = (FAR struct uip_blcontainer_s*)(((FAR ubyte*)bls) + offset);
+ for (i = 0; i < nblg; i++)
+ {
+ dq_addfirst(&blc->bc_node, &bls->bl_free);
+ }
+ }
+
+ /* Destroy any existing backlog (shouldn't be any) */
+
+ flags = irqsave();
+ uip_backlogdestroy(conn);
+
+ /* Now install the backlog tear-off in the connection. NOTE that bls may
+ * actually be NULL if nblg is <= 0; In that case, we are disabling backlog
+ * support. Since interrupts are disabled, destroying the old backlog and
+ * replace it with the new is an atomic operation
+ */
+
+ conn->backlog = bls;
+ irqrestore(flags);
+ return OK;
+}
+
+/****************************************************************************
+ * Function: uip_backlogdestroy
+ *
+ * Description:
+ * (1) Called from uip_tcpfree() whenever a connection is freed.
+ * (2) Called from uip_backlogcreate() to destroy any old backlog
+ *
+ * NOTE: This function may re-enter uip_tcpfree when a connection that
+ * is freed that has pending connections.
+ *
+ * Assumptions:
+ * The caller has disabled interrupts so that there can be no conflict
+ * with ongoing, interrupt driven activity
+ *
+ ****************************************************************************/
+
+int uip_backlogdestroy(FAR struct uip_conn *conn)
+{
+ FAR struct uip_backlog_s *blg;
+ FAR struct uip_blcontainer_s *blc;
+ FAR struct uip_conn *blconn;
+
+#ifdef CONFIG_DEBUG
+ if (!conn)
+ {
+ return -EINVAL;
+ }
+#endif
+
+ /* Make sure that the connection has a backlog to be destroyed */
+
+ if (conn->backlog)
+ {
+ /* Remove the backlog structure reference from the connection */
+
+ blg = conn->backlog;
+ conn->backlog = NULL;
+
+ /* Handle any pending connections in the backlog */
+
+ while ((blc = (FAR struct uip_blcontainer_s*)dq_remfirst(&blg->bl_pending)) != NULL)
+ {
+ blconn = blc->bc_conn;
+ if (blconn)
+ {
+ /* REVISIT -- such connections really need to be gracefully closed */
+
+ blconn->blparent = NULL;
+ blconn->backlog = NULL;
+ uip_tcpfree(blconn);
+ }
+ }
+
+ /* Then free the entire backlog structure */
+
+ free(blg);
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Function: uip_backlogadd
+ *
+ * Description:
+ * Called uip_listen when a new connection is made with a listener socket
+ * but when there is not accept() in place to receive the connection. This
+ * function adds the new connection to the backlog.
+ *
+ * Assumptions:
+ * Called from the interrupt level with interrupts disabled
+ *
+ ****************************************************************************/
+
+int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn)
+{
+ FAR struct uip_backlog_s *bls;
+ FAR struct uip_blcontainer_s *blc;
+ int ret = -EINVAL;
+
+#ifdef CONFIG_DEBUG
+ if (!conn)
+ {
+ return -EINVAL;
+ }
+#endif
+
+ bls = conn->backlog;
+ if (conn->backlog && blconn)
+ {
+ /* Allocate a container for the connection from the free list */
+
+ blc = (FAR struct uip_blcontainer_s *)dq_remfirst(&bls->bl_free);
+ if (!blc)
+ {
+ ret = -ENOMEM;
+ }
+ else
+ {
+ /* Save the connection reference in the container and put the
+ * container at the end of the pending connection list (FIFO).
+ */
+
+ blc->bc_conn = blconn;
+ dq_addlast(&blc->bc_node, &bls->bl_pending);
+ ret = OK;
+ }
+ }
+ return ret;
+}
+
+/****************************************************************************
+ * Function: uip_backlogremove
+ *
+ * Description:
+ * Called from accept(). Before waiting for a new connection, accept will
+ * call this API to see if there are pending connections in the backlog.
+ *
+ * Assumptions:
+ * Called from normal user code, but with interrupts disabled,
+ *
+ ****************************************************************************/
+
+struct uip_conn *uip_backlogremove(FAR struct uip_conn *conn)
+{
+ FAR struct uip_backlog_s *bls;
+ FAR struct uip_blcontainer_s *blc;
+ FAR struct uip_conn *blconn = NULL;
+
+#ifdef CONFIG_DEBUG
+ if (!conn)
+ {
+ return NULL;
+ }
+#endif
+ bls = conn->backlog;
+ if (bls && blconn)
+ {
+ /* Remove the a container at the head of the pending connection list
+ * (FIFO)
+ */
+
+ blc = (FAR struct uip_blcontainer_s *)dq_remfirst(&bls->bl_pending);
+ if (blc)
+ {
+ /* Extract the connection reference from the container and put
+ * container in the free list
+ */
+
+ blconn = blc->bc_conn;
+ blc->bc_conn = NULL;
+ dq_addlast(&blc->bc_node, &bls->bl_free);
+ }
+ }
+ return blconn;
+}
+
+/****************************************************************************
+ * Function: uip_backlogdelete
+ *
+ * Description:
+ * Called from uip_tcpfree() when a connection is freed that this also
+ * retained in the pending connectino list of a listener. We simply need
+ * to remove the defunct connecton from the list.
+ *
+ * Assumptions:
+ * Called from the interrupt level with interrupts disabled
+ *
+ ****************************************************************************/
+
+int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn)
+{
+ FAR struct uip_backlog_s *bls;
+ FAR struct uip_blcontainer_s *blc;
+
+#ifdef CONFIG_DEBUG
+ if (!conn)
+ {
+ return NULL;
+ }
+#endif
+ bls = conn->backlog;
+ if (bls)
+ {
+ /* Find the container hold the connection */
+
+ for (blc = (FAR struct uip_blcontainer_s *)dq_peek(&bls->bl_pending);
+ blc;
+ blc = (FAR struct uip_blcontainer_s *)dq_next(&blc->bc_node))
+ {
+ if (blc->bc_conn == blconn)
+ {
+ /* Remove the a container from the list of pending connections */
+
+ dq_rem(&blc->bc_node, &bls->bl_pending);
+ return OK;
+ }
+ }
+ return -EINVAL;
+ }
+ return OK;
+}
+
+#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCPBACKLOG */
diff --git a/nuttx/net/uip/uip-tcpconn.c b/nuttx/net/uip/uip-tcpconn.c
index 0f48a4607..e36520b05 100644
--- a/nuttx/net/uip/uip-tcpconn.c
+++ b/nuttx/net/uip/uip-tcpconn.c
@@ -316,6 +316,24 @@ void uip_tcpfree(struct uip_conn *conn)
}
#endif
+ /* Remove any backlog attached to this connection */
+
+#ifdef CONFIG_NET_TCPBACKLOG
+ if (conn->backlog)
+ {
+ uip_backlogdestroy(conn);
+ }
+
+ /* If this connection is, itself, backlogged, then remove it from the
+ * parent connection's backlog list.
+ */
+
+ if (conn->blparent)
+ {
+ uip_backlogdelete(conn->blparent, conn);
+ }
+#endif
+
/* Mark the connection available and put it into the free list */
conn->tcpstateflags = UIP_CLOSED;
diff --git a/nuttx/net/uip/uip-tcpinput.c b/nuttx/net/uip/uip-tcpinput.c
index 5a7b5b923..5d220aeb5 100644
--- a/nuttx/net/uip/uip-tcpinput.c
+++ b/nuttx/net/uip/uip-tcpinput.c
@@ -165,7 +165,7 @@ void uip_tcpinput(struct uip_driver_s *dev)
* least queue it it for acceptance).
*/
- if (uip_accept(conn, tmp16) != OK)
+ if (uip_accept(dev, conn, tmp16) != OK)
{
/* No, then we have to give the connection back */
diff --git a/nuttx/net/uip/uip-tcpreadahead.c b/nuttx/net/uip/uip-tcpreadahead.c
index abadb4f50..c00ea7b38 100644
--- a/nuttx/net/uip/uip-tcpreadahead.c
+++ b/nuttx/net/uip/uip-tcpreadahead.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/uip/uip-tcpreadahead.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
*
diff --git a/nuttx/net/uip/uip-tcptimer.c b/nuttx/net/uip/uip-tcptimer.c
index e0da04ead..aadd2b5ea 100644
--- a/nuttx/net/uip/uip-tcptimer.c
+++ b/nuttx/net/uip/uip-tcptimer.c
@@ -2,7 +2,7 @@
* net/uip/uip-tcptimer.c
* Poll for the availability of TCP TX data
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Adapted for NuttX from logic in uIP which also has a BSD-like license: