Add support for TCP/IP connection backlog
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1294 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
14d2342d9e
commit
73a6fc026d
57 changed files with 690 additions and 105 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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 <spudmonkey@racsa.co.cr>
|
|||
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 <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
|
|
@ -1594,6 +1594,11 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
|||
<li>
|
||||
<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>
|
||||
|
|
|
@ -6069,6 +6069,14 @@ interface of the same name.
|
|||
<li><code>CONFIG_NSOCKET_DESCRIPTORS</code> Defined to be greater than 0</li>
|
||||
<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>
|
||||
|
|
4
TODO
4
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/)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -70,6 +70,6 @@ clean:
|
|||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
@rm -f Make.dep .depend host
|
||||
|
||||
-include Make.dep
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
128
net/accept.c
128
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,69 +321,80 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||
goto errout_with_socket;
|
||||
}
|
||||
|
||||
/* Set the socket state to accepting */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_ACCEPT);
|
||||
|
||||
/* Perform the TCP accept operation */
|
||||
|
||||
/* Initialize the state structure. This is done with interrupts
|
||||
* disabled because we don't want anything to happen until we
|
||||
* are ready.
|
||||
/* Check the backlog to see if there is a connection already pending
|
||||
* for this listener.
|
||||
*/
|
||||
|
||||
save = irqsave();
|
||||
state.acpt_addr = inaddr;
|
||||
state.acpt_newconn = NULL;
|
||||
state.acpt_result = OK;
|
||||
sem_init(&state.acpt_sem, 0, 0);
|
||||
save = irqsave();
|
||||
conn = (struct uip_conn *)psock->s_conn;
|
||||
|
||||
/* Set up the callback in the connection */
|
||||
#ifdef CONFIG_NET_TCPBACKLOG
|
||||
state.acpt_newconn = uip_backlogremove(conn);
|
||||
if (!state.acpt_newconn)
|
||||
#endif
|
||||
{
|
||||
/* Set the socket state to accepting */
|
||||
|
||||
conn = (struct uip_conn *)psock->s_conn;
|
||||
conn->accept_private = (void*)&state;
|
||||
conn->accept = accept_interrupt;
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_ACCEPT);
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
/* Perform the TCP accept operation */
|
||||
|
||||
ret = sem_wait(&state.acpt_sem);
|
||||
/* Initialize the state structure. This is done with interrupts
|
||||
* disabled because we don't want anything to happen until we
|
||||
* are ready.
|
||||
*/
|
||||
|
||||
/* Make sure that no further interrupts are processed */
|
||||
state.acpt_addr = inaddr;
|
||||
state.acpt_newconn = NULL;
|
||||
state.acpt_result = OK;
|
||||
sem_init(&state.acpt_sem, 0, 0);
|
||||
|
||||
conn->accept_private = NULL;
|
||||
conn->accept = NULL;
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
sem_destroy(&state. acpt_sem);
|
||||
conn->accept_private = (void*)&state;
|
||||
conn->accept = accept_interrupt;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
ret = sem_wait(&state.acpt_sem);
|
||||
|
||||
/* Make sure that no further interrupts are processed */
|
||||
|
||||
conn->accept_private = NULL;
|
||||
conn->accept = NULL;
|
||||
|
||||
sem_destroy(&state. acpt_sem);
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||
|
||||
/* Check for a errors. Errors are signaled by negative errno values
|
||||
* for the send length
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||
|
||||
/* Check for a errors. Errors are signaled by negative errno values
|
||||
* for the send length
|
||||
*/
|
||||
|
||||
if (state.acpt_result != 0)
|
||||
{
|
||||
err = state.acpt_result;
|
||||
goto errout_with_socket;
|
||||
}
|
||||
|
||||
/* 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_socket;
|
||||
}
|
||||
|
||||
/* Initialize the socket structure and mark the socket as connected */
|
||||
|
||||
pnewsock->s_type = SOCK_STREAM;
|
||||
|
@ -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);
|
||||
|
||||
|
|
19
net/listen.c
19
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 *************************************************/
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
348
net/uip/uip-tcpbacklog.c
Normal file
348
net/uip/uip-tcpbacklog.c
Normal file
|
@ -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 */
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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>
|
||||
*
|
||||
*
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue