mirror of
https://github.com/apache/nuttx.git
synced 2025-12-08 19:02:43 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ce5085cc8 | ||
|
|
ef651cc6bc | ||
|
|
961336e574 | ||
|
|
276e2880bd | ||
|
|
5a508351e4 | ||
|
|
99c94d9cbe | ||
|
|
5c0768fb0d | ||
|
|
21c9f463a2 | ||
|
|
7d1031cc71 | ||
|
|
b54499d254 | ||
|
|
295bf51f3f | ||
|
|
ea2ca7bfc3 | ||
|
|
26c91f4733 |
22
ChangeLog
22
ChangeLog
@@ -215,7 +215,7 @@
|
||||
* Added listen() and accept()
|
||||
* Added DM90x0 ethernet driver
|
||||
* ARP timer is now built into the network layer
|
||||
* Basic client functionality verified: socket(), bind(), connect(), recv(), send().
|
||||
* Basic client functionality verified: TCP socket(), bind(), connect(), recv(), send().
|
||||
|
||||
0.3.1 2007-11-19 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
@@ -223,10 +223,26 @@
|
||||
* Corrected a TCP problem where packets were dropped because there was no
|
||||
recv() in place but the packet was being ACKed. There are still TCP
|
||||
recv buffering issues, but this is part of a larger buffering issue.
|
||||
* Basic server functionality verified: listen(), accept()
|
||||
* Basic server functionality verified: TCP listen(), accept()
|
||||
* Fix DM90x0 driver problem that caused TX overruns
|
||||
* Add strncmp()
|
||||
* Added TCP/IP read-ahead buffer to minimize failed ACKs and packet loss.
|
||||
|
||||
0.3.2 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
0.3.2 2007-11-23 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Add strcat() and strncat()
|
||||
* Integrated uIP micro webserver
|
||||
* Corrected a serious bug in TCP queue management
|
||||
* Fix leak in socket close logic
|
||||
* Add TX notification to driver so that it can respond faster to
|
||||
the availability of TX data.
|
||||
* Moved urgent data info into device structure.
|
||||
* TCP and ICMP protocols can now be disabled.
|
||||
* Added UDP test in examples/udp
|
||||
* Verified/debugged UDP socket(), bind(), sendto() and recvfrom() logic
|
||||
using examples/udp
|
||||
* recvfrom() and accept() now correctly return the remote address.
|
||||
* Fixed computation error in ntohl().
|
||||
|
||||
0.3.3 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
||||
@@ -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 19, 2007</p>
|
||||
<p>Last Updated: November 23, 2007</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -183,27 +183,36 @@
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The 13th release of NuttX (nuttx-0.3.0) is available for download
|
||||
from the <a href="http://sourceforge.net/project/showfiles.php?group_id=189573">SourceForge</a>
|
||||
website.
|
||||
The change log associated with the release is available <a href="#currentrelease">here</a>.
|
||||
Unreleased changes after this release are avalable in CVS.
|
||||
These unreleased changes are listed <a href="#pendingchanges">here</a>.
|
||||
The 14th release of NuttX (nuttx-0.3.2) is available for download
|
||||
from the <a href="http://sourceforge.net/project/showfiles.php?group_id=189573">SourceForge</a>
|
||||
website.
|
||||
The change log associated with the release is available <a href="#currentrelease">here</a>.
|
||||
Unreleased changes after this release are avalable in CVS.
|
||||
These unreleased changes are listed <a href="#pendingchanges">here</a>.
|
||||
</p>
|
||||
<p>
|
||||
NuttX 0.3.1 is the second release containing the integration of a network
|
||||
NuttX 0.3.2 is the 3rd release containing the integration of a network
|
||||
subsystem and the uIP TCP/IP, UDP, and ICMP stacks based on
|
||||
<a href="http://www.sics.se/~adam/uip/index.php/Main_Page">uIP</a>
|
||||
into NuttX.
|
||||
</p>
|
||||
<p>
|
||||
Many network-related problems have been fixed from version 0.3.0
|
||||
Many network-related problems have been fixed from version 0.3.1
|
||||
and the implementation has matured significantly.
|
||||
However, the level of network reliability is probably still at the
|
||||
pre-alpha or early level.
|
||||
It is sufficiently complete that you may begin to perform some network
|
||||
integration and is exepcted to achieve beta level of reliability over
|
||||
the next few releases.
|
||||
Changes in this release include:
|
||||
</p>
|
||||
<ul>
|
||||
<li>TCP-related bug-fixes,</li>
|
||||
<li>TCP performance improvements,</li>
|
||||
<li>Initial UDP integration, and</li>
|
||||
<li>Initial uIP micro webserver integration
|
||||
</ul>
|
||||
</p>
|
||||
See the ChangeLog for a complete list of changes.
|
||||
</p>
|
||||
<p>
|
||||
The level of network reliability is a a strong alpha level is expected to
|
||||
achieve beta level of reliability over the next few releases.
|
||||
</p>
|
||||
<p>
|
||||
The baseline functionality of NuttX continues to mature and remains at
|
||||
@@ -358,14 +367,24 @@ is available that be used to build a NuttX-compatible arm-elf toolchain.</blockq
|
||||
53272 428 3568 57268 dfb4 nuttx
|
||||
</pre>
|
||||
<p><b>DM320 (ARM9)</b>
|
||||
This build for the ARM9 target includes a signficant subset of OS
|
||||
features, ethernet driver and full TCP/IP, UDP and (minimal) ICMP
|
||||
stacks (via uIP). (11/8/07)
|
||||
This build for the ARM9 target includes a significant subset of OS
|
||||
features, a filesystem, Ethernet driver, full TCP/IP, UDP and (minimal)
|
||||
ICMP stacks (via uIP) and a small network test application: (11/8/07,
|
||||
configuration netconfig, examples/nettest)
|
||||
</p>
|
||||
<pre>
|
||||
text data bss dec hex filename
|
||||
49472 296 3972 53740 d1ec nuttx
|
||||
</pre>
|
||||
<p>
|
||||
Another build for the ARM9 target includes a minimal OS feature
|
||||
set, Ethernet driver, full TCP/IP and (minimal) ICMP stacks, and
|
||||
a small webserver: (11/20/07, configuration uipconfig, examples/uip)
|
||||
</p>
|
||||
<pre>
|
||||
text data bss dec hex filename
|
||||
52040 72 4148 56260 dbc4 nuttx
|
||||
</pre>
|
||||
<p><b>87C52</b>
|
||||
A reduced functionality OS test for the 8052 target requires only
|
||||
about 18-19Kb:
|
||||
@@ -657,17 +676,7 @@ Other memory:
|
||||
* Added DM90x0 ethernet driver
|
||||
* ARP timer is now built into the network layer
|
||||
* Basic client functionality verified: socket(), bind(), connect(), recv(), send().
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="currentrelease">ChangeLog for Current Release</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<pre><ul>
|
||||
0.3.1 2007-11-19 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Separated net/uip/uip.c into several functions in several files.
|
||||
@@ -683,13 +692,39 @@ Other memory:
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="pendingchanges">Unreleased Changes</a>
|
||||
<a name="currentrelease">ChangeLog for Current Release</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<pre><ul>
|
||||
0.3.2 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Add strcat() and strncat()
|
||||
* Integrated uIP micro webserver
|
||||
* Corrected a serious bug in TCP queue management
|
||||
* Fix leak in socket close logic
|
||||
* Add TX notification to driver so that it can respond faster to
|
||||
the availability of TX data.
|
||||
* Moved urgent data info into device structure.
|
||||
* TCP and ICMP protocols can now be disabled.
|
||||
* Added UDP test in examples/udp
|
||||
* Verified/debugged UDP socket(), bind(), sendto() and recvfrom() logic
|
||||
using examples/udp
|
||||
* recvfrom() and accept() now correctly return the remote address.
|
||||
* Fixed computation error in ntohl().
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="pendingchanges">Unreleased Changes</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<pre><ul>
|
||||
0.3.3 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
|
||||
@@ -1352,24 +1352,32 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
<li>
|
||||
<code>CONFIG_NSOCKET_DESCRIPTORS</code>: Maximum number of socket descriptors per task/thread.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_TCP_CONNS</code>: Maximum number of TCP connections (all tasks).
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_MAX_LISTENPORTS</code>: Maximum number of listening TCP ports (all tasks).
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_SOCKOPTS</code>: Enable or disable support for socket options.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_BUFSIZE</code>: uIP buffer size
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_TCP</code>: TCP support on or off
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_TCP_CONNS</code>: Maximum number of TCP connections (all tasks).
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_TCP_READAHEAD_BUFSIZE</code>: Size of TCP read-ahead buffers
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_NTCP_READAHEAD_BUFFERS</code>: Number of TCP read-ahead buffers (may be zero)
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_MAX_LISTENPORTS</code>: Maximum number of listening TCP ports (all tasks).
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_TCPURGDATA</code>: Determines if support for TCP urgent data
|
||||
notification should be compiled in. Urgent data (out-of-band data)
|
||||
is a rarely used TCP feature that is very seldom would be required.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_UDP</code>: UDP support on or off
|
||||
</li>
|
||||
@@ -1380,11 +1388,14 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
<code>CONFIG_NET_UDP_CONNS</code>: The maximum amount of concurrent UDP connections
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_STATISTICS</code>: uIP statistics on or off
|
||||
<code>CONFIG_NET_ICMP</code>: ICMP ping support on or off
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_PINGADDRCONF</code>: Use "ping" packet for setting IP address
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_STATISTICS</code>: uIP statistics on or off
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_RECEIVE_WINDOW</code>: The size of the advertised receiver's window
|
||||
</li>
|
||||
|
||||
25
Makefile
25
Makefile
@@ -60,11 +60,17 @@ endif
|
||||
# MAKEDIRS are the directories in which we will build targets
|
||||
|
||||
CLEANDIRS = $(NONFSDIRS) $(FSDIRS)
|
||||
MAKEDIRS = $(NONFSDIRS)
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
MAKEDIRS = $(NONFSDIRS)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
MAKEDIRS += fs
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
MAKEDIRS += drivers
|
||||
endif
|
||||
else
|
||||
MAKEDIRS = $(NONFSDIRS) $(FSDIRS)
|
||||
MAKEDIRS += $(FSDIRS)
|
||||
endif
|
||||
|
||||
# LINKLIBS is the list of NuttX libraries that is passed to the
|
||||
@@ -75,14 +81,21 @@ endif
|
||||
LINKLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
|
||||
lib/liblib$(LIBEXT) examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT)
|
||||
|
||||
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
LINKLIBS += fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
LINKLIBS += fs/libfs$(LIBEXT)
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
LINKLIBS += drivers/libdrivers$(LIBEXT)
|
||||
endif
|
||||
else
|
||||
LINKLIBS += fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT)
|
||||
endif
|
||||
|
||||
# This is the name of the final target
|
||||
BIN = nuttx$(EXEEXT)
|
||||
|
||||
|
||||
24
ReleaseNotes
24
ReleaseNotes
@@ -1,23 +1,27 @@
|
||||
nuttx-0.3.1
|
||||
nuttx-0.3.2
|
||||
^^^^^^^^^^^
|
||||
|
||||
This is the 13th release of NuttX and the second release containing
|
||||
This is the 14th release of NuttX and the 3rd release containing
|
||||
the integration of a network subsystem and the uIP TCP/IP, UDP, and
|
||||
ICMP stacks into NuttX (see http://www.sics.se/~adam/uip/index.php/Main_Page).
|
||||
|
||||
Many network-related problems have been fixed and the implementation
|
||||
has matured significantly. However, the level of network reliability
|
||||
is probably still at the pre-alpha or early level. It is sufficiently
|
||||
complete that you may begin to perform some network integration and
|
||||
is exepcted to achieve beta level of reliability over the next few
|
||||
releases.
|
||||
has matured significantly. This release consists of:
|
||||
|
||||
The baseline functionality of NuttX continues to mature and remains at
|
||||
post-beta (as long as the network is not used).
|
||||
o TCP-related bug-fixes
|
||||
o TCP performance improvements
|
||||
o Initial UDP integration
|
||||
o Initial uIP micro webserver integration
|
||||
|
||||
See the ChangeLog for a complete list of changes.
|
||||
|
||||
The level of network reliability is at alpha level is expected to
|
||||
achieve beta level of reliability over the next few releases.
|
||||
|
||||
The baseline functionality of NuttX continues to mature and remains at
|
||||
post-beta.
|
||||
|
||||
This release has been verified only on the Neuros OSD (DM320 ARM9)
|
||||
platform using the DM90x0 driver.
|
||||
|
||||
This tarball contains a complete CVS snapshot from November 19, 2007.
|
||||
This tarball contains a complete CVS snapshot from November 23, 2007.
|
||||
|
||||
12
TODO
12
TODO
@@ -31,16 +31,14 @@ o C++ Support
|
||||
o Network
|
||||
- Did not implement send() and sendto() timeouts. Option is setable via setsockopt,
|
||||
but is not implemented.
|
||||
- netutils/telnetd (and maybe others) are seriously broken.
|
||||
- uIP's netutils/telnetd (and maybe others) are seriously broken.
|
||||
Need to be re-written to use listen() and accept()
|
||||
- uIP's netutils/webserver hangs
|
||||
- uIP's netutils/smtp, dpcpc, resolv, webclient -- untested
|
||||
- Should implement SOCK_RAW
|
||||
- accept() and recvfrom() need to return connection address
|
||||
- Performance Improvements (uIP is not very fast):
|
||||
- Improve performance by stimulating the driver to accept new TX data before the
|
||||
next polling interval.
|
||||
Add a txail callback into driver to eliminate send delays. Since we want to
|
||||
support multiple network devices, this means we will have to add some infrastructure
|
||||
to map to device.
|
||||
Need to extend logic so that uIP can have more than on packet in flight and to
|
||||
handle deferred acknowledgements.
|
||||
- uIP polling issues:
|
||||
(1) Current logic will not support multiple ethernet drivers. Each driver should
|
||||
poll on TCP connections connect on the network supported by the driver; UDP
|
||||
|
||||
@@ -77,6 +77,8 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
int i;
|
||||
dbg(" TCB=%p name=%s\n", tcb, tcb->argv[0]);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
dbg(" filelist refcount=%d\n",
|
||||
@@ -92,7 +94,9 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
dbg(" streamlist refcount=%d\n",
|
||||
@@ -109,6 +113,7 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -129,7 +129,9 @@ void up_initialize(void)
|
||||
|
||||
/* Register devices */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
devnull_register(); /* Standard /dev/null */
|
||||
#endif
|
||||
|
||||
/* Initialize the serial device driver */
|
||||
|
||||
|
||||
@@ -129,8 +129,13 @@ extern void up_vectorfiq(void);
|
||||
|
||||
/* Defined in up_serial.c */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
extern void up_earlyserialinit(void);
|
||||
extern void up_serialinit(void);
|
||||
#else
|
||||
# define up_earlyserialinit()
|
||||
# define up_serialinit()
|
||||
#endif
|
||||
|
||||
/* Defined in up_watchdog.c */
|
||||
|
||||
|
||||
@@ -84,10 +84,10 @@
|
||||
up_lowputc:
|
||||
/* On entry, r0 holds the character to be printed */
|
||||
|
||||
#ifdef CONFIG_UART0_SERIAL_CONSOLE
|
||||
ldr r2, =DM320_UART0_REGISTER_BASE /* r2=UART0 base */
|
||||
#else
|
||||
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||
ldr r2, =DM320_UART1_REGISTER_BASE /* r2=UART1 base */
|
||||
#else
|
||||
ldr r2, =DM320_UART0_REGISTER_BASE /* r2=UART0 base */
|
||||
#endif
|
||||
|
||||
/* Poll the TX fifo trigger level bit of the UART_SSR
|
||||
|
||||
@@ -38,20 +38,25 @@
|
||||
************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/serial.h>
|
||||
#include <arch/serial.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
/************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
@@ -723,3 +728,59 @@ int up_putc(int ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
#else /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
||||
|
||||
/************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
|
||||
# ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# define DM320_REGISTER_BASE DM320_UART1_REGISTER_BASE
|
||||
# else
|
||||
# define DM320_REGISTER_BASE DM320_UART0_REGISTER_BASE
|
||||
# endif
|
||||
|
||||
/************************************************************
|
||||
* Private Functions
|
||||
************************************************************/
|
||||
|
||||
static inline void up_waittxfifonotfull(void)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
for (tmp = 1000 ; tmp > 0 ; tmp--)
|
||||
{
|
||||
|
||||
if ((getreg16(DM320_REGISTER_BASE + UART_SR) & UART_SR_TFTI) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Public Functions
|
||||
************************************************************/
|
||||
|
||||
int up_putc(int ch)
|
||||
{
|
||||
up_waittxfifonotfull();
|
||||
putreg16((uint16)ch, DM320_REGISTER_BASE + UART_DTRR);
|
||||
|
||||
/* Check for LF */
|
||||
|
||||
if (ch == '\n')
|
||||
{
|
||||
/* Add CR */
|
||||
|
||||
up_waittxfifonotfull();
|
||||
putreg16((uint16)'\r', DM320_REGISTER_BASE + UART_DTRR);
|
||||
}
|
||||
|
||||
up_waittxfifonotfull();
|
||||
return ch;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
||||
|
||||
|
||||
|
||||
@@ -213,11 +213,15 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors
|
||||
per task/thread.
|
||||
CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
|
||||
CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
CONFIG_NET_TCPURGDATA - Determines if support for TCP urgent data
|
||||
notification should be compiled in. Urgent data (out-of-band data)
|
||||
is a rarely used TCP feature that is very seldom would be required.
|
||||
CONFIG_NET_TCP - TCP support on or off
|
||||
CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (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)
|
||||
@@ -225,8 +229,9 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
|
||||
CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP
|
||||
connections
|
||||
CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's
|
||||
window
|
||||
CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
|
||||
@@ -254,17 +254,19 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -273,15 +275,17 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -243,17 +243,19 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -262,15 +264,17 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -267,17 +267,19 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -286,15 +288,17 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -1,11 +1,37 @@
|
||||
README
|
||||
^^^^^^
|
||||
|
||||
The configuration netconfig may be used instead of the
|
||||
default configuration (defconfig). This configuration
|
||||
enables networking using the OSDs DM9000A ethernet
|
||||
interface.
|
||||
defconfig
|
||||
^^^^^^^^^
|
||||
The default configuration file, defconfig, performs a
|
||||
simple OS test using examples/ostest. This can be
|
||||
configuration as follows:
|
||||
|
||||
cd tools
|
||||
./configure.sh ntosd-dm320
|
||||
cd -
|
||||
. ./setenv.sh
|
||||
|
||||
netconfig
|
||||
^^^^^^^^^
|
||||
This alternative configuration file, netconfig, may be used
|
||||
instead of the default configuration (defconfig). This
|
||||
configuration enables networking using the OSDs DM9000A
|
||||
Ethernet interface. It uses examples/nettest to excercise
|
||||
the TCP/IP network.
|
||||
|
||||
uipconfig
|
||||
^^^^^^^^^
|
||||
This configuration file demonstrates the tiny webserver
|
||||
at examples/uip.
|
||||
|
||||
These alternative configurations can be selected by
|
||||
|
||||
(Seleted the default configuration as show above)
|
||||
cp config/ntosd-dm320/uiponfig .config
|
||||
|
||||
udpconfig
|
||||
^^^^^^^^^
|
||||
This alternative configuration file, is similar to netconfig
|
||||
except that is use examples/upd to exercise UDP.
|
||||
|
||||
Disclaimer: The NuttX network subsystem is a "work in
|
||||
progress" at this time and minimal network functionality
|
||||
should be expected.
|
||||
|
||||
@@ -252,17 +252,19 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -271,15 +273,17 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
# arch/ntosd-dm320/netconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -126,7 +126,6 @@ CONFIG_UART1_2STOP=0
|
||||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
#
|
||||
#CONFIG_EXAMPLE=uip
|
||||
CONFIG_EXAMPLE=nettest
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
@@ -158,9 +157,9 @@ CONFIG_DEV_CONSOLE=y
|
||||
#
|
||||
CONFIG_DISABLE_CLOCK=n
|
||||
CONFIG_DISABLE_POSIX_TIMERS=n
|
||||
CONFIG_DISABLE_PTHREAD=n
|
||||
CONFIG_DISABLE_PTHREAD=y
|
||||
CONFIG_DISABLE_SIGNALS=n
|
||||
CONFIG_DISABLE_MQUEUE=n
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
|
||||
@@ -237,15 +236,15 @@ CONFIG_RRLOAD_BINARY=n
|
||||
CONFIG_MAX_TASKS=64
|
||||
CONFIG_MAX_TASK_ARGS=4
|
||||
CONFIG_NPTHREAD_KEYS=4
|
||||
CONFIG_NFILE_DESCRIPTORS=32
|
||||
CONFIG_NFILE_STREAMS=16
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NAME_MAX=32
|
||||
CONFIG_STDIO_BUFFER_SIZE=1024
|
||||
CONFIG_NUNGET_CHARS=2
|
||||
CONFIG_PREALLOC_MQ_MSGS=32
|
||||
CONFIG_MQ_MAXMSGSIZE=32
|
||||
CONFIG_MAX_WDOGPARMS=4
|
||||
CONFIG_PREALLOC_WDOGS=32
|
||||
CONFIG_PREALLOC_WDOGS=8
|
||||
CONFIG_PREALLOC_TIMERS=8
|
||||
|
||||
#
|
||||
@@ -253,17 +252,19 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -272,15 +273,17 @@ CONFIG_PREALLOC_TIMERS=8
|
||||
CONFIG_NET=y
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=8
|
||||
CONFIG_NET_TCP_CONNS=8
|
||||
CONFIG_NET_MAX_LISTENPORTS=8
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_CONNS=8
|
||||
CONFIG_NET_MAX_LISTENPORTS=8
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=n
|
||||
CONFIG_NET_ICMP=y
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=n
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
363
configs/ntosd-dm320/udpconfig
Normal file
363
configs/ntosd-dm320/udpconfig
Normal file
@@ -0,0 +1,363 @@
|
||||
############################################################
|
||||
# arch/ntosd-dm320/udpconfig
|
||||
#
|
||||
# Copyright (C) 2007 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 Gregory Nutt 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.
|
||||
#
|
||||
############################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
|
||||
# processor architecture.
|
||||
# CONFIG_ARCH_name - for use in C code. This identifies the
|
||||
# particular chip or SoC that the architecture is implemented
|
||||
# in.
|
||||
# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
|
||||
# CONFIG_ARCH_CHIP_name - For use in C code
|
||||
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
|
||||
# the board that supports the particular chip or SoC.
|
||||
# CONFIG_ARCH_BOARD_name - for use in C code
|
||||
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
|
||||
# CONFIG_BOARD_LOOPSPERMSEC - for delay loops
|
||||
# CONFIG_DRAM_SIZE - Describes the installed DRAM.
|
||||
# CONFIG_DRAM_START - The start address of DRAM (physical)
|
||||
# CONFIG_DRAM_VSTART - The startaddress of DRAM (virtual)
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
#
|
||||
CONFIG_ARCH=arm
|
||||
CONFIG_ARCH_ARM=y
|
||||
CONFIG_ARCH_CHIP=dm320
|
||||
CONFIG_ARCH_CHIP_DM320=y
|
||||
CONFIG_ARCH_BOARD=ntosd-dm320
|
||||
CONFIG_ARCH_BOARD_NTOSD_DM320=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16945
|
||||
CONFIG_DRAM_SIZE=0x01000000
|
||||
CONFIG_DRAM_START=0x01000000
|
||||
CONFIG_DRAM_VSTART=0x00000000
|
||||
CONFIG_DRAM_NUTTXENTRY=0x01008000
|
||||
CONFIG_ARCH_STACKDUMP=n
|
||||
|
||||
#
|
||||
# DM320 specific device driver settings
|
||||
#
|
||||
# CONFIG_UARTn_SERIAL_CONSOLE - selects the UARTn for the
|
||||
# console and ttys0 (default is the UART0).
|
||||
# CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
|
||||
# This specific the size of the receive buffer
|
||||
# CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
|
||||
# being sent. This specific the size of the transmit buffer
|
||||
# CONFIG_UARTn_BAUD - The configure BAUD of the UART. Must be
|
||||
# CONFIG_UARTn_BITS - The number of bits. Must be either 7 or 8.
|
||||
# CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
|
||||
# CONFIG_UARTn_2STOP - Two stop bits
|
||||
#
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=n
|
||||
CONFIG_UART0_TXBUFSIZE=256
|
||||
CONFIG_UART1_TXBUFSIZE=256
|
||||
CONFIG_UART0_RXBUFSIZE=256
|
||||
CONFIG_UART1_RXBUFSIZE=256
|
||||
CONFIG_UART0_BAUD=115200
|
||||
CONFIG_UART1_BAUD=115200
|
||||
CONFIG_UART0_BITS=8
|
||||
CONFIG_UART1_BITS=8
|
||||
CONFIG_UART0_PARITY=0
|
||||
CONFIG_UART1_PARITY=0
|
||||
CONFIG_UART0_2STOP=0
|
||||
CONFIG_UART1_2STOP=0
|
||||
|
||||
#
|
||||
# General OS setup
|
||||
#
|
||||
# CONFIG_EXAMPLE - identifies the subdirectory in examples
|
||||
# that will be used in the build
|
||||
# CONFIG_DEBUG - enables built-in debug options
|
||||
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
|
||||
# CONFIG_MM_REGIONS - If the architecture includes multiple
|
||||
# regions of memory to allocate from, this specifies the
|
||||
# number of memory regions that the memory manager must
|
||||
# handle and enables the API mm_addregion(start, end);
|
||||
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
|
||||
# time console output
|
||||
# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
|
||||
# or TICKS_PER_MSEC=10. This setting may be defined to
|
||||
# inform NuttX that the processor hardware is providing
|
||||
# system timer interrupts at some interrupt interval other
|
||||
# than 10 msec.
|
||||
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
|
||||
# this number of milliseconds; Round robin scheduling can
|
||||
# be disabled by setting this value to zero.
|
||||
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
|
||||
# scheduler to monitor system performance
|
||||
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
|
||||
# task name to save in the TCB. Useful if scheduler
|
||||
# instrumentation is selected. Set to zero to disable.
|
||||
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
|
||||
# Used to initialize the internal time logic.
|
||||
# CONFIG_JULIAN_TIME - Enables Julian time conversions
|
||||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
#
|
||||
CONFIG_EXAMPLE=udp
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_MM_REGIONS=1
|
||||
CONFIG_ARCH_LOWPUTC=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_START_YEAR=2007
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_START_DAY=13
|
||||
CONFIG_JULIAN_TIME=n
|
||||
CONFIG_DEV_CONSOLE=y
|
||||
|
||||
#
|
||||
# The following can be used to disable categories of
|
||||
# APIs supported by the OS. If the compiler supports
|
||||
# weak functions, then it should not be necessary to
|
||||
# disable functions unless you want to restrict usage
|
||||
# of those APIs.
|
||||
#
|
||||
# There are certain dependency relationships in these
|
||||
# features.
|
||||
#
|
||||
# o mq_notify logic depends on signals to awaken tasks
|
||||
# waiting for queues to become full or empty.
|
||||
# o pthread_condtimedwait() depends on signals to wake
|
||||
# up waiting tasks.
|
||||
#
|
||||
CONFIG_DISABLE_CLOCK=n
|
||||
CONFIG_DISABLE_POSIX_TIMERS=n
|
||||
CONFIG_DISABLE_PTHREAD=y
|
||||
CONFIG_DISABLE_SIGNALS=n
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
|
||||
#
|
||||
# Misc libc settings
|
||||
#
|
||||
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
|
||||
# little smaller if we do not support fieldwidthes
|
||||
#
|
||||
CONFIG_NOPRINTF_FIELDWIDTH=n
|
||||
|
||||
#
|
||||
# Allow for architecture optimized implementations
|
||||
#
|
||||
# The architecture can provide optimized versions of the
|
||||
# following to improve sysem performance
|
||||
#
|
||||
CONFIG_ARCH_MEMCPY=n
|
||||
CONFIG_ARCH_MEMCMP=n
|
||||
CONFIG_ARCH_MEMMOVE=n
|
||||
CONFIG_ARCH_MEMSET=n
|
||||
CONFIG_ARCH_STRCMP=n
|
||||
CONFIG_ARCH_STRCPY=n
|
||||
CONFIG_ARCH_STRNCPY=n
|
||||
CONFIG_ARCH_STRLEN=n
|
||||
CONFIG_ARCH_BZERO=n
|
||||
CONFIG_ARCH_KMALLOC=n
|
||||
CONFIG_ARCH_KZMALLOC=n
|
||||
CONFIG_ARCH_KFREE=n
|
||||
|
||||
#
|
||||
# General build options
|
||||
#
|
||||
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
|
||||
# BSPs from www.ridgerun.com
|
||||
#
|
||||
CONFIG_RRLOAD_BINARY=n
|
||||
|
||||
#
|
||||
# Sizes of configurable things (0 disables)
|
||||
#
|
||||
# CONFIG_MAX_TASKS - The maximum number of simultaneously
|
||||
# active tasks. This value must be a power of two.
|
||||
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
|
||||
# of parameters that a task may receive (i.e., maxmum value
|
||||
# of 'argc')
|
||||
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
|
||||
# specific data that can be retained
|
||||
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
|
||||
# descriptors (one for each open)
|
||||
# CONFIG_NFILE_STREAMS - The maximum number of streams that
|
||||
# can be fopen'ed
|
||||
# CONFIG_NAME_MAX - The maximum size of a file name.
|
||||
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
|
||||
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_NUNGET_CHARS - Number of characters that can be
|
||||
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
|
||||
# structures. The system manages a pool of preallocated
|
||||
# message structures to minimize dynamic allocations
|
||||
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
|
||||
# a fixed payload size given by this settin (does not include
|
||||
# other message structure overhead.
|
||||
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
|
||||
# can be passed to a watchdog handler
|
||||
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
|
||||
# structures. The system manages a pool of preallocated
|
||||
# watchdog structures to minimize dynamic allocations
|
||||
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
|
||||
# timer structures. The system manages a pool of preallocated
|
||||
# timer structures to minimize dynamic allocations. Set to
|
||||
# zero for all dynamic allocations.
|
||||
#
|
||||
CONFIG_MAX_TASKS=64
|
||||
CONFIG_MAX_TASK_ARGS=4
|
||||
CONFIG_NPTHREAD_KEYS=4
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NAME_MAX=32
|
||||
CONFIG_STDIO_BUFFER_SIZE=1024
|
||||
CONFIG_NUNGET_CHARS=2
|
||||
CONFIG_PREALLOC_MQ_MSGS=32
|
||||
CONFIG_MQ_MAXMSGSIZE=32
|
||||
CONFIG_MAX_WDOGPARMS=4
|
||||
CONFIG_PREALLOC_WDOGS=8
|
||||
CONFIG_PREALLOC_TIMERS=8
|
||||
|
||||
#
|
||||
# TCP/IP and UDP support via uIP
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
# CONFIG_NET_LLH_LEN - The link level header length
|
||||
# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
|
||||
CONFIG_NET=y
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=8
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=0
|
||||
CONFIG_NET_MAX_LISTENPORTS=0
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_ICMP=y
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=n
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
#CONFIG_NET_LLH_LEN=14
|
||||
#CONFIG_NET_FWCACHE_SIZE=2
|
||||
|
||||
#
|
||||
# UIP Network Utilities
|
||||
# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
|
||||
# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
|
||||
CONFIG_NET_DHCP_LIGHT=n
|
||||
CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/uip
|
||||
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_UIP_SMTP=n
|
||||
CONFIG_EXAMPLE_UIP_TELNETD=n
|
||||
CONFIG_EXAMPLE_UIP_WEBSERVER=y
|
||||
CONFIG_EXAMPLE_UIP_DHCPC=n
|
||||
CONFIG_EXAMPLE_UIP_RESOLV=n
|
||||
CONFIG_EXAMPLE_UIP_WEBCLIENT=n
|
||||
|
||||
#
|
||||
# Settings for examples/nettest
|
||||
CONFIG_EXAMPLE_NETTEST_SERVER=n
|
||||
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
|
||||
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/udp
|
||||
CONFIG_EXAMPLE_UDP_SERVER=n
|
||||
CONFIG_EXAMPLE_UDP_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLE_UDP_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_UDP_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_UDP_SERVERIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# DM90x0 Driver Settings
|
||||
CONFIG_NET_DM90x0=y
|
||||
CONFIG_DM9X_NINTERFACES=1
|
||||
CONFIG_DM9X_STATS=n
|
||||
CONFIG_DM9X_BASE=0xd0000300
|
||||
CONFIG_DM9X_IRQ=27
|
||||
CONFIG_DM9X_BUSWIDTH8=n
|
||||
CONFIG_DM9X_BUSWIDTH16=y
|
||||
CONFIG_DM9X_BUSWIDTH32=n
|
||||
CONFIG_DM9X_CHECKSUM=n
|
||||
CONFIG_DM9X_ETRANS=n
|
||||
|
||||
#
|
||||
# Stack and heap information
|
||||
#
|
||||
# CONFIG_BOOT_FROM_FLASH - Some configurations support XIP
|
||||
# operation from FLASH.
|
||||
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
|
||||
# all stack operations outside of the nuttx model.
|
||||
# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only)
|
||||
# CONFIG_PROC_STACK_SIZE - The size of the initial stack
|
||||
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
|
||||
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
|
||||
# CONFIG_HEAP_BASE - The beginning of the heap
|
||||
# CONFIG_HEAP_SIZE - The size of the heap
|
||||
#
|
||||
CONFIG_BOOT_FROM_FLASH=n
|
||||
CONFIG_CUSTOM_STACK=n
|
||||
CONFIG_STACK_POINTER=
|
||||
CONFIG_PROC_STACK_SIZE=4096
|
||||
CONFIG_PTHREAD_STACK_MIN=256
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
||||
CONFIG_HEAP_BASE=
|
||||
CONFIG_HEAP_SIZE=
|
||||
355
configs/ntosd-dm320/uipconfig
Normal file
355
configs/ntosd-dm320/uipconfig
Normal file
@@ -0,0 +1,355 @@
|
||||
############################################################
|
||||
# arch/ntosd-dm320/uipconfig
|
||||
#
|
||||
# Copyright (C) 2007 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 Gregory Nutt 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.
|
||||
#
|
||||
############################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
|
||||
# processor architecture.
|
||||
# CONFIG_ARCH_name - for use in C code. This identifies the
|
||||
# particular chip or SoC that the architecture is implemented
|
||||
# in.
|
||||
# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
|
||||
# CONFIG_ARCH_CHIP_name - For use in C code
|
||||
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
|
||||
# the board that supports the particular chip or SoC.
|
||||
# CONFIG_ARCH_BOARD_name - for use in C code
|
||||
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
|
||||
# CONFIG_BOARD_LOOPSPERMSEC - for delay loops
|
||||
# CONFIG_DRAM_SIZE - Describes the installed DRAM.
|
||||
# CONFIG_DRAM_START - The start address of DRAM (physical)
|
||||
# CONFIG_DRAM_VSTART - The startaddress of DRAM (virtual)
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
#
|
||||
CONFIG_ARCH=arm
|
||||
CONFIG_ARCH_ARM=y
|
||||
CONFIG_ARCH_CHIP=dm320
|
||||
CONFIG_ARCH_CHIP_DM320=y
|
||||
CONFIG_ARCH_BOARD=ntosd-dm320
|
||||
CONFIG_ARCH_BOARD_NTOSD_DM320=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16945
|
||||
CONFIG_DRAM_SIZE=0x01000000
|
||||
CONFIG_DRAM_START=0x01000000
|
||||
CONFIG_DRAM_VSTART=0x00000000
|
||||
CONFIG_DRAM_NUTTXENTRY=0x01008000
|
||||
CONFIG_ARCH_STACKDUMP=n
|
||||
|
||||
#
|
||||
# DM320 specific device driver settings
|
||||
#
|
||||
# CONFIG_UARTn_SERIAL_CONSOLE - selects the UARTn for the
|
||||
# console and ttys0 (default is the UART0).
|
||||
# CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
|
||||
# This specific the size of the receive buffer
|
||||
# CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
|
||||
# being sent. This specific the size of the transmit buffer
|
||||
# CONFIG_UARTn_BAUD - The configure BAUD of the UART. Must be
|
||||
# CONFIG_UARTn_BITS - The number of bits. Must be either 7 or 8.
|
||||
# CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
|
||||
# CONFIG_UARTn_2STOP - Two stop bits
|
||||
#
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=n
|
||||
CONFIG_UART0_TXBUFSIZE=256
|
||||
CONFIG_UART1_TXBUFSIZE=256
|
||||
CONFIG_UART0_RXBUFSIZE=256
|
||||
CONFIG_UART1_RXBUFSIZE=256
|
||||
CONFIG_UART0_BAUD=115200
|
||||
CONFIG_UART1_BAUD=115200
|
||||
CONFIG_UART0_BITS=8
|
||||
CONFIG_UART1_BITS=8
|
||||
CONFIG_UART0_PARITY=0
|
||||
CONFIG_UART1_PARITY=0
|
||||
CONFIG_UART0_2STOP=0
|
||||
CONFIG_UART1_2STOP=0
|
||||
|
||||
#
|
||||
# General OS setup
|
||||
#
|
||||
# CONFIG_EXAMPLE - identifies the subdirectory in examples
|
||||
# that will be used in the build
|
||||
# CONFIG_DEBUG - enables built-in debug options
|
||||
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
|
||||
# CONFIG_MM_REGIONS - If the architecture includes multiple
|
||||
# regions of memory to allocate from, this specifies the
|
||||
# number of memory regions that the memory manager must
|
||||
# handle and enables the API mm_addregion(start, end);
|
||||
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
|
||||
# time console output
|
||||
# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
|
||||
# or TICKS_PER_MSEC=10. This setting may be defined to
|
||||
# inform NuttX that the processor hardware is providing
|
||||
# system timer interrupts at some interrupt interval other
|
||||
# than 10 msec.
|
||||
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
|
||||
# this number of milliseconds; Round robin scheduling can
|
||||
# be disabled by setting this value to zero.
|
||||
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
|
||||
# scheduler to monitor system performance
|
||||
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
|
||||
# task name to save in the TCB. Useful if scheduler
|
||||
# instrumentation is selected. Set to zero to disable.
|
||||
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
|
||||
# Used to initialize the internal time logic.
|
||||
# CONFIG_JULIAN_TIME - Enables Julian time conversions
|
||||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
#
|
||||
CONFIG_EXAMPLE=uip
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_MM_REGIONS=1
|
||||
CONFIG_ARCH_LOWPUTC=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_START_YEAR=2007
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_START_DAY=13
|
||||
CONFIG_JULIAN_TIME=n
|
||||
CONFIG_DEV_CONSOLE=n
|
||||
|
||||
#
|
||||
# The following can be used to disable categories of
|
||||
# APIs supported by the OS. If the compiler supports
|
||||
# weak functions, then it should not be necessary to
|
||||
# disable functions unless you want to restrict usage
|
||||
# of those APIs.
|
||||
#
|
||||
# There are certain dependency relationships in these
|
||||
# features.
|
||||
#
|
||||
# o mq_notify logic depends on signals to awaken tasks
|
||||
# waiting for queues to become full or empty.
|
||||
# o pthread_condtimedwait() depends on signals to wake
|
||||
# up waiting tasks.
|
||||
#
|
||||
CONFIG_DISABLE_CLOCK=n
|
||||
CONFIG_DISABLE_POSIX_TIMERS=n
|
||||
CONFIG_DISABLE_PTHREAD=n
|
||||
CONFIG_DISABLE_SIGNALS=n
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
|
||||
#
|
||||
# Misc libc settings
|
||||
#
|
||||
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
|
||||
# little smaller if we do not support fieldwidthes
|
||||
#
|
||||
CONFIG_NOPRINTF_FIELDWIDTH=n
|
||||
|
||||
#
|
||||
# Allow for architecture optimized implementations
|
||||
#
|
||||
# The architecture can provide optimized versions of the
|
||||
# following to improve sysem performance
|
||||
#
|
||||
CONFIG_ARCH_MEMCPY=n
|
||||
CONFIG_ARCH_MEMCMP=n
|
||||
CONFIG_ARCH_MEMMOVE=n
|
||||
CONFIG_ARCH_MEMSET=n
|
||||
CONFIG_ARCH_STRCMP=n
|
||||
CONFIG_ARCH_STRCPY=n
|
||||
CONFIG_ARCH_STRNCPY=n
|
||||
CONFIG_ARCH_STRLEN=n
|
||||
CONFIG_ARCH_BZERO=n
|
||||
CONFIG_ARCH_KMALLOC=n
|
||||
CONFIG_ARCH_KZMALLOC=n
|
||||
CONFIG_ARCH_KFREE=n
|
||||
|
||||
#
|
||||
# General build options
|
||||
#
|
||||
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
|
||||
# BSPs from www.ridgerun.com
|
||||
#
|
||||
CONFIG_RRLOAD_BINARY=n
|
||||
|
||||
#
|
||||
# Sizes of configurable things (0 disables)
|
||||
#
|
||||
# CONFIG_MAX_TASKS - The maximum number of simultaneously
|
||||
# active tasks. This value must be a power of two.
|
||||
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
|
||||
# of parameters that a task may receive (i.e., maxmum value
|
||||
# of 'argc')
|
||||
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
|
||||
# specific data that can be retained
|
||||
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
|
||||
# descriptors (one for each open)
|
||||
# CONFIG_NFILE_STREAMS - The maximum number of streams that
|
||||
# can be fopen'ed
|
||||
# CONFIG_NAME_MAX - The maximum size of a file name.
|
||||
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
|
||||
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_NUNGET_CHARS - Number of characters that can be
|
||||
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
|
||||
# structures. The system manages a pool of preallocated
|
||||
# message structures to minimize dynamic allocations
|
||||
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
|
||||
# a fixed payload size given by this settin (does not include
|
||||
# other message structure overhead.
|
||||
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
|
||||
# can be passed to a watchdog handler
|
||||
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
|
||||
# structures. The system manages a pool of preallocated
|
||||
# watchdog structures to minimize dynamic allocations
|
||||
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
|
||||
# timer structures. The system manages a pool of preallocated
|
||||
# timer structures to minimize dynamic allocations. Set to
|
||||
# zero for all dynamic allocations.
|
||||
#
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_TASK_ARGS=4
|
||||
CONFIG_NPTHREAD_KEYS=4
|
||||
CONFIG_NFILE_DESCRIPTORS=0
|
||||
CONFIG_NFILE_STREAMS=0
|
||||
CONFIG_NAME_MAX=32
|
||||
CONFIG_STDIO_BUFFER_SIZE=1024
|
||||
CONFIG_NUNGET_CHARS=2
|
||||
CONFIG_PREALLOC_MQ_MSGS=0
|
||||
CONFIG_MQ_MAXMSGSIZE=32
|
||||
CONFIG_MAX_WDOGPARMS=4
|
||||
CONFIG_PREALLOC_WDOGS=8
|
||||
CONFIG_PREALLOC_TIMERS=8
|
||||
|
||||
#
|
||||
# TCP/IP and UDP support via uIP
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
# CONFIG_NET_LLH_LEN - The link level header length
|
||||
# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
|
||||
CONFIG_NET=y
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=8
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_CONNS=8
|
||||
CONFIG_NET_MAX_LISTENPORTS=8
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_ICMP=y
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=n
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
#CONFIG_NET_LLH_LEN=14
|
||||
#CONFIG_NET_FWCACHE_SIZE=2
|
||||
|
||||
#
|
||||
# UIP Network Utilities
|
||||
# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
|
||||
# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
|
||||
CONFIG_NET_DHCP_LIGHT=n
|
||||
CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/uip
|
||||
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_UIP_SMTP=n
|
||||
CONFIG_EXAMPLE_UIP_TELNETD=n
|
||||
CONFIG_EXAMPLE_UIP_WEBSERVER=y
|
||||
CONFIG_EXAMPLE_UIP_DHCPC=n
|
||||
CONFIG_EXAMPLE_UIP_RESOLV=n
|
||||
CONFIG_EXAMPLE_UIP_WEBCLIENT=n
|
||||
|
||||
#
|
||||
# Settings for examples/nettest
|
||||
CONFIG_EXAMPLE_NETTEST_SERVER=n
|
||||
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
|
||||
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# DM90x0 Driver Settings
|
||||
CONFIG_NET_DM90x0=y
|
||||
CONFIG_DM9X_NINTERFACES=1
|
||||
CONFIG_DM9X_STATS=n
|
||||
CONFIG_DM9X_BASE=0xd0000300
|
||||
CONFIG_DM9X_IRQ=27
|
||||
CONFIG_DM9X_BUSWIDTH8=n
|
||||
CONFIG_DM9X_BUSWIDTH16=y
|
||||
CONFIG_DM9X_BUSWIDTH32=n
|
||||
CONFIG_DM9X_CHECKSUM=n
|
||||
CONFIG_DM9X_ETRANS=n
|
||||
|
||||
#
|
||||
# Stack and heap information
|
||||
#
|
||||
# CONFIG_BOOT_FROM_FLASH - Some configurations support XIP
|
||||
# operation from FLASH.
|
||||
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
|
||||
# all stack operations outside of the nuttx model.
|
||||
# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only)
|
||||
# CONFIG_PROC_STACK_SIZE - The size of the initial stack
|
||||
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
|
||||
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
|
||||
# CONFIG_HEAP_BASE - The beginning of the heap
|
||||
# CONFIG_HEAP_SIZE - The size of the heap
|
||||
#
|
||||
CONFIG_BOOT_FROM_FLASH=n
|
||||
CONFIG_CUSTOM_STACK=n
|
||||
CONFIG_STACK_POINTER=
|
||||
CONFIG_PROC_STACK_SIZE=4096
|
||||
CONFIG_PTHREAD_STACK_MIN=256
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
||||
CONFIG_HEAP_BASE=
|
||||
CONFIG_HEAP_SIZE=
|
||||
@@ -240,17 +240,19 @@ CONFIG_PREALLOC_TIMERS=0
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -259,15 +261,17 @@ CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -214,17 +214,19 @@ CONFIG_FS_FAT=y
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -233,15 +235,17 @@ CONFIG_FS_FAT=y
|
||||
CONFIG_NET=n
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=0
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=n
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=n
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -215,17 +215,19 @@ CONFIG_FS_FAT=y
|
||||
# CONFIG_NET - Enable or disable all network features
|
||||
# CONFIG_NET_IPv6 - Build in support for IPv6
|
||||
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
|
||||
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
|
||||
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
|
||||
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
|
||||
# CONFIG_NET_BUFSIZE - uIP buffer size
|
||||
# CONFIG_NET_TCP - TCP support on or off
|
||||
# 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_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
|
||||
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_ICMP - ICMP ping support on or off
|
||||
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
|
||||
# CONFIG_NET_STATISTICS - uIP statistics on or off
|
||||
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
|
||||
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
|
||||
# CONFIG_NET_BROADCAST - Broadcast support
|
||||
@@ -234,15 +236,17 @@ CONFIG_FS_FAT=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NET_IPv6=n
|
||||
CONFIG_NSOCKET_DESCRIPTORS=8
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_BUFSIZE=420
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_CONNS=40
|
||||
CONFIG_NET_MAX_LISTENPORTS=40
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_CHECKSUMS=y
|
||||
#CONFIG_NET_UDP_CONNS=10
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_ICMP=y
|
||||
#CONFIG_NET_PINGADDRCONF=0
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_RECEIVE_WINDOW=
|
||||
#CONFIG_NET_ARPTAB_SIZE=8
|
||||
CONFIG_NET_BROADCAST=n
|
||||
|
||||
@@ -44,7 +44,11 @@ endif
|
||||
ASRCS = $(NET_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = dev_null.c serial.c $(NET_CSRCS)
|
||||
CSRCS =
|
||||
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
CSRCS += dev_null.c serial.c
|
||||
endif
|
||||
CSRCS += $(NET_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
||||
@@ -393,6 +393,7 @@ static void dm9x_txtimeout(int argc, uint32 arg, ...);
|
||||
|
||||
static int dm9x_ifup(struct uip_driver_s *dev);
|
||||
static int dm9x_ifdown(struct uip_driver_s *dev);
|
||||
static int dm9x_txavail(struct uip_driver_s *dev);
|
||||
|
||||
/* Initialization functions */
|
||||
|
||||
@@ -825,7 +826,7 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x)
|
||||
* 3. During normal TX polling
|
||||
*
|
||||
* Parameters:
|
||||
* dm9x - Reference to the driver state structure
|
||||
* dev - Reference to the NuttX driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; a negated errno on failure
|
||||
@@ -1447,6 +1448,46 @@ static int dm9x_ifdown(struct uip_driver_s *dev)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: dm9x_txavail
|
||||
*
|
||||
* Description:
|
||||
* Driver callback invoked when new TX data is available. This is a
|
||||
* stimulus perform an out-of-cycle poll and, thereby, reduce the TX
|
||||
* latency.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - Reference to the NuttX driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called in normal user mode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int dm9x_txavail(struct uip_driver_s *dev)
|
||||
{
|
||||
struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)dev->d_private;
|
||||
irqstate_t flags;
|
||||
|
||||
dbg("Polling\n");
|
||||
flags = irqsave();
|
||||
|
||||
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
|
||||
* that can be 2 packets, otherwise it is a single packet.
|
||||
*/
|
||||
|
||||
if (dm9x->dm_ntxpending < 1 || (dm9x->dm_b100M && dm9x->dm_ntxpending < 2))
|
||||
{
|
||||
/* If so, then poll uIP for new XMIT data */
|
||||
|
||||
(void)uip_poll(&dm9x->dm_dev, dm9x_uiptxpoll);
|
||||
}
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: dm9x_bringup
|
||||
*
|
||||
@@ -1659,6 +1700,7 @@ int dm9x_initialize(void)
|
||||
memset(g_dm9x, 0, CONFIG_DM9X_NINTERFACES*sizeof(struct dm9x_driver_s));
|
||||
g_dm9x[0].dm_dev.d_ifup = dm9x_ifup; /* I/F down callback */
|
||||
g_dm9x[0].dm_dev.d_ifdown = dm9x_ifdown; /* I/F up (new IP address) callback */
|
||||
g_dm9x[0].dm_dev.d_txavail = dm9x_txavail; /* New TX data callback */
|
||||
g_dm9x[0].dm_dev.d_private = (void*)g_dm9x; /* Used to recover private state from dev */
|
||||
|
||||
/* Create a watchdog for timing polling for and timing of transmisstions */
|
||||
|
||||
@@ -46,4 +46,24 @@ examples/null
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
This is the do nothing application. It is only used for bringing
|
||||
up new NuttX architectures
|
||||
up new NuttX architectures.
|
||||
|
||||
examples/uip
|
||||
^^^^^^^^^^^^
|
||||
|
||||
This is a port of uIP example application. It includes
|
||||
conditionally compiled logic to exercise the uIP webserver,
|
||||
webclient, telnet, smtp, dncpc, and resolver.
|
||||
|
||||
examples/netttest
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is a simple network test for verifying client- and server-
|
||||
functionality in a TCP/IP connection.
|
||||
|
||||
examples/udp
|
||||
^^^^^^^^^^^^
|
||||
|
||||
This is a simple network test for verifying client- and server-
|
||||
functionality over UDP.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettestn-client.c
|
||||
* examples/nettest/nettest-client.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettest.c
|
||||
* examples/nettest/nettest-server.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
106
examples/udp/Makefile
Normal file
106
examples/udp/Makefile
Normal file
@@ -0,0 +1,106 @@
|
||||
############################################################
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2007 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 Gregory Nutt 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.
|
||||
#
|
||||
############################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
TARG_ASRCS =
|
||||
TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT))
|
||||
|
||||
TARG_CSRCS = target.c
|
||||
ifeq ($(CONFIG_EXAMPLE_UDP_SERVER),y)
|
||||
TARG_CSRCS += udp-server.c
|
||||
else
|
||||
TARG_CSRCS += udp-client.c
|
||||
endif
|
||||
|
||||
TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT))
|
||||
|
||||
TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS)
|
||||
TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS)
|
||||
|
||||
TARG_BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
|
||||
|
||||
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_HOST=1
|
||||
ifeq ($(CONFIG_EXAMPLE_UDP_SERVER),y)
|
||||
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_SERVER=1 \
|
||||
-DCONFIG_EXAMPLE_UDP_SERVERIP="$(CONFIG_EXAMPLE_UDP_SERVERIP)"
|
||||
endif
|
||||
|
||||
HOST_SRCS = host.c
|
||||
ifeq ($(CONFIG_EXAMPLE_UDP_SERVER),y)
|
||||
HOST_SRCS += udp-client.c
|
||||
else
|
||||
HOST_SRCS += udp-server.c
|
||||
endif
|
||||
|
||||
HOST_OBJS = $(HOST_SRCS:.c=.o)
|
||||
HOST_BIN = host
|
||||
|
||||
all: $(TARG_BIN)
|
||||
|
||||
$(TARG_AOBJS): %$(OBJEXT): %.S
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(TARG_COBJS): %$(OBJEXT): %.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(TARG_BIN): $(TARG_OBJS) $(HOST_BIN)
|
||||
( for obj in $(TARG_OBJS) ; do \
|
||||
$(AR) $@ $${obj} || \
|
||||
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
|
||||
done ; )
|
||||
|
||||
$(HOST_OBJS): %.o: %.c
|
||||
$(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
||||
|
||||
$(HOST_BIN): $(HOST_OBJS)
|
||||
$(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
||||
|
||||
.depend: Makefile $(TARG_SRCS)
|
||||
$(MKDEP) $(CC) -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep
|
||||
touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
rm -f $(TARG_BIN) $(HOST_BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
|
||||
|
||||
distclean: clean
|
||||
rm -f Make.dep .depend
|
||||
|
||||
-include Make.dep
|
||||
63
examples/udp/host.c
Normal file
63
examples/udp/host.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/host.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 "udp-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLE_UDP_SERVER
|
||||
send_client();
|
||||
#else
|
||||
recv_server();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
104
examples/udp/target.c
Normal file
104
examples/udp/target.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/nettest.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
#include "udp-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* user_initialize
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
void user_initialize(void)
|
||||
{
|
||||
/* Stub that must be provided only if the toolchain does
|
||||
* not support weak functions.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* user_start
|
||||
****************************************************************************/
|
||||
|
||||
int user_start(int argc, char *argv[])
|
||||
{
|
||||
struct in_addr addr;
|
||||
|
||||
/* Set up our host address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLE_UDP_IPADDR);
|
||||
uip_sethostaddr("eth0", &addr);
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLE_UDP_DRIPADDR);
|
||||
uip_setdraddr("eth0", &addr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLE_UDP_NETMASK);
|
||||
uip_setnetmask("eth0", &addr);
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_UDP_SERVER
|
||||
recv_server();
|
||||
#else
|
||||
send_client();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
133
examples/udp/udp-client.c
Normal file
133
examples/udp/udp-client.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/udp-client.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "udp-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline void fill_buffer(unsigned char *buf, int offset)
|
||||
{
|
||||
int ch;
|
||||
int j;
|
||||
|
||||
buf[0] = offset;
|
||||
for (ch = 0x20, j = offset + 1; ch < 0x7f; ch++, j++)
|
||||
{
|
||||
if (j >= SENDSIZE)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
buf[j] = ch;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void send_client(void)
|
||||
{
|
||||
struct sockaddr_in server;
|
||||
unsigned char outbuf[SENDSIZE];
|
||||
int sockfd;
|
||||
int nbytes;
|
||||
int offset;
|
||||
|
||||
/* Create a new TCP socket */
|
||||
|
||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
message("client socket failure %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Then send and receive 256 messages */
|
||||
|
||||
for (offset = 0; offset < 256; offset++)
|
||||
{
|
||||
/* Set up the output buffer */
|
||||
|
||||
fill_buffer(outbuf, offset);
|
||||
|
||||
/* Send the message */
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = HTONS(PORTNO);
|
||||
server.sin_addr.s_addr = HTONL(CONFIG_EXAMPLE_UDP_SERVERIP);
|
||||
|
||||
message("client: %d. Sending %d bytes\n", offset, SENDSIZE);
|
||||
nbytes = sendto(sockfd, outbuf, SENDSIZE, 0,
|
||||
(struct sockaddr*)&server, sizeof(struct sockaddr_in));
|
||||
message("client: %d. Sent %d bytes\n", offset, nbytes);
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
message("client: %d. sendto failed: %d\n", offset, errno);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
else if (nbytes != SENDSIZE)
|
||||
{
|
||||
message("client: %d. Bad send length: %d Expected: %d\n",
|
||||
offset, nbytes, SENDSIZE);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Now, sleep a bit. No packets should be dropped due to overrunning
|
||||
* the server.
|
||||
*/
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
close(sockfd);
|
||||
}
|
||||
94
examples/udp/udp-internal.h
Normal file
94
examples/udp/udp-internal.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/udp-internal.h
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __EXAMPLES_UIP_INTERNAL_H
|
||||
#define __EXAMPLES_UIP_INTERNAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_UDP_HOST
|
||||
#else
|
||||
# include <debug.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_UDP_HOST
|
||||
/* HTONS/L macros are unique to uIP */
|
||||
|
||||
# define HTONS(a) htons(a)
|
||||
# define HTONL(a) htonl(a)
|
||||
|
||||
/* Used printf for debug output */
|
||||
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
|
||||
/* Have SO_LINGER */
|
||||
|
||||
#else
|
||||
|
||||
/* Get errno using a pointer */
|
||||
|
||||
# define errno *get_errno_ptr()
|
||||
|
||||
/* If debug is enabled, use the synchronous lib_lowprintf so that the
|
||||
* program output does not get disassociated in the debug output.
|
||||
*/
|
||||
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) lib_lowprintf(__VA_ARGS__)
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#define PORTNO 5471
|
||||
|
||||
#define ASCIISIZE (0x7f - 0x20)
|
||||
#define SENDSIZE (ASCIISIZE+1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void send_client(void);
|
||||
extern void recv_server(void);
|
||||
|
||||
#endif /* __EXAMPLES_UIP_INTERNAL_H */
|
||||
174
examples/udp/udp-server.c
Normal file
174
examples/udp/udp-server.c
Normal file
@@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/udp-server.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "udp-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline int check_buffer(unsigned char *buf)
|
||||
{
|
||||
int ret = 1;
|
||||
int offset;
|
||||
int ch;
|
||||
int j;
|
||||
|
||||
offset = buf[0];
|
||||
for (ch = 0x20, j = offset + 1; ch < 0x7f; ch++, j++)
|
||||
{
|
||||
if (j >= SENDSIZE)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
if (buf[j] != ch)
|
||||
{
|
||||
message("server: Buffer content error for offset=%d, index=%d\n", offset, j);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void recv_server(void)
|
||||
{
|
||||
struct sockaddr_in server;
|
||||
struct sockaddr_in client;
|
||||
uint32 tmpaddr;
|
||||
unsigned char inbuf[1024];
|
||||
int sockfd;
|
||||
int nbytes;
|
||||
int optval;
|
||||
int offset;
|
||||
socklen_t addrlen;
|
||||
|
||||
/* Create a new UDP socket */
|
||||
|
||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
message("server: socket failure: %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Set socket to reuse address */
|
||||
|
||||
optval = 1;
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0)
|
||||
{
|
||||
message("server: setsockopt SO_REUSEADDR failure: %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = HTONS(PORTNO);
|
||||
server.sin_addr.s_addr = HTONL(INADDR_ANY);
|
||||
|
||||
if (bind(sockfd, (struct sockaddr*)&server, sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
message("server: bind failure: %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Then receive up to 256 packets of data */
|
||||
|
||||
for (offset = 0; offset < 256; offset++)
|
||||
{
|
||||
message("server: %d. Receiving up 1024 bytes\n", offset);
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
nbytes = recvfrom(sockfd, inbuf, 1024, 0,
|
||||
(struct sockaddr*)&client, &addrlen);
|
||||
|
||||
tmpaddr = ntohl(client.sin_addr.s_addr);
|
||||
message("server: %d. Received %d bytes from %d.%d.%d.%d:%d\n",
|
||||
offset, nbytes,
|
||||
tmpaddr >> 24, (tmpaddr >> 16) & 0xff,
|
||||
(tmpaddr >> 8) & 0xff, tmpaddr & 0xff,
|
||||
ntohs(client.sin_port));
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
message("server: %d. recv failed: %d\n", offset, errno);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (nbytes != SENDSIZE)
|
||||
{
|
||||
message("server: %d. recv size incorrect: %d vs %d\n", offset, nbytes, SENDSIZE);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (offset < inbuf[0])
|
||||
{
|
||||
message("server: %d. %d packets lost, resetting offset\n", offset, inbuf[0] - offset);
|
||||
offset = inbuf[0];
|
||||
}
|
||||
else if (offset > inbuf[0])
|
||||
{
|
||||
message("server: %d. Bad offset in buffer: %d\n", offset, inbuf[0]);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!check_buffer(inbuf))
|
||||
{
|
||||
message("server: %d. Bad buffer contents\n", offset);
|
||||
close(sockfd);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
close(sockfd);
|
||||
}
|
||||
31
fs/Makefile
31
fs/Makefile
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# Makefile
|
||||
############################################################################
|
||||
# fs/Makefile
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
@@ -40,22 +40,29 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c fs_dup.c \
|
||||
fs_opendir.c fs_closedir.c fs_stat.c fs_readdir.c fs_readdirr.c \
|
||||
fs_seekdir.c fs_telldir.c fs_rewinddir.c fs_files.c \
|
||||
fs_inode.c fs_inodefind.c fs_inodereserve.c fs_statfs.c \
|
||||
fs_inoderemove.c fs_registerdriver.c fs_unregisterdriver.c \
|
||||
fs_inodeaddref.c fs_inoderelease.c
|
||||
CSRCS =
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
CSRCS += fs_close.c fs_write.c fs_ioctl.c
|
||||
endif
|
||||
else
|
||||
CSRCS += fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c fs_dup.c \
|
||||
fs_opendir.c fs_closedir.c fs_stat.c fs_readdir.c fs_readdirr.c \
|
||||
fs_seekdir.c fs_telldir.c fs_rewinddir.c fs_files.c \
|
||||
fs_inode.c fs_inodefind.c fs_inodereserve.c fs_statfs.c \
|
||||
fs_inoderemove.c fs_registerdriver.c fs_unregisterdriver.c \
|
||||
fs_inodeaddref.c fs_inoderelease.c
|
||||
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
||||
CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c \
|
||||
fs_mount.c fs_umount.c \
|
||||
fs_fsync.c fs_unlink.c fs_rename.c \
|
||||
fs_mkdir.c fs_rmdir.c
|
||||
fs_mount.c fs_umount.c \
|
||||
fs_fsync.c fs_unlink.c fs_rename.c \
|
||||
fs_mkdir.c fs_rmdir.c
|
||||
|
||||
ifeq ($(CONFIG_FS_FAT),y)
|
||||
CSRCS += fs_fat32.c fs_fat32util.c fs_fat32attrib.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ int open(const char *path, int oflags, ...)
|
||||
struct filelist *list;
|
||||
FAR struct inode *inode;
|
||||
const char *relpath = NULL;
|
||||
#ifdef CONFIG_FILE_MODE
|
||||
#if defined(CONFIG_FILE_MODE) || !defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||
mode_t mode = 0666;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/************************************************************
|
||||
* fs_write.c
|
||||
/****************************************************************************
|
||||
* fs/fs_write.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,15 +31,15 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Compilation Switches
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@@ -54,11 +54,11 @@
|
||||
|
||||
#include "fs_internal.h"
|
||||
|
||||
/************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
* Function: send
|
||||
*
|
||||
* Description:
|
||||
@@ -106,15 +106,17 @@
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
********************************************************************************************/
|
||||
|
||||
int write(int fd, const void *buf, unsigned int nbytes)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *list;
|
||||
FAR struct file *this_file;
|
||||
FAR struct inode *inode;
|
||||
int err;
|
||||
int ret;
|
||||
#endif
|
||||
int err;
|
||||
|
||||
/* Did we get a valid file descriptor? */
|
||||
|
||||
@@ -122,7 +124,7 @@ int write(int fd, const void *buf, unsigned int nbytes)
|
||||
{
|
||||
/* Write to a socket descriptor is equivalent to send with flags == 0 */
|
||||
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
#if defined(CONFIG_NET_TCP) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
|
||||
{
|
||||
return send(fd, buf, nbytes, 0);
|
||||
@@ -135,6 +137,8 @@ int write(int fd, const void *buf, unsigned int nbytes)
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
/* Get the thread-specific file list */
|
||||
|
||||
list = sched_getfiles();
|
||||
@@ -172,6 +176,7 @@ int write(int fd, const void *buf, unsigned int nbytes)
|
||||
}
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
errout:
|
||||
*get_errno_ptr() = err;
|
||||
|
||||
@@ -106,14 +106,17 @@ struct uip_driver_s
|
||||
* void
|
||||
* devicedriver_send(void)
|
||||
* {
|
||||
* hwsend(&dev->d_buf[0], UIP_LLH_LEN);
|
||||
* if(dev->d_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
|
||||
* hwsend(&dev->d_buf[UIP_LLH_LEN], dev->d_len - UIP_LLH_LEN);
|
||||
* } else {
|
||||
* hwsend(&dev->d_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
|
||||
* hwsend(dev->d_appdata, dev->d_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
|
||||
* }
|
||||
* }
|
||||
* hwsend(&dev->d_buf[0], UIP_LLH_LEN);
|
||||
* if(dev->d_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN)
|
||||
* {
|
||||
* hwsend(&dev->d_buf[UIP_LLH_LEN], dev->d_len - UIP_LLH_LEN);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* hwsend(&dev->d_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
|
||||
* hwsend(dev->d_appdata, dev->d_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
uint8 d_buf[CONFIG_NET_BUFSIZE + 2];
|
||||
@@ -130,6 +133,18 @@ struct uip_driver_s
|
||||
|
||||
uint8 *d_snddata;
|
||||
|
||||
#ifdef CONFIG_NET_TCPURGDATA
|
||||
/* This pointer points to any urgent TCP data that has been received. Only
|
||||
* present if compiled with support for urgent data (CONFIG_NET_TCPURGDATA).
|
||||
*/
|
||||
|
||||
uint8 *d_urgdata;
|
||||
|
||||
/* Length of the (received) urgent data */
|
||||
|
||||
uint16 d_urglen;
|
||||
#endif
|
||||
|
||||
/* The length of the packet in the d_buf buffer.
|
||||
*
|
||||
* Holds the length of the packet in the d_buf buffer.
|
||||
@@ -155,6 +170,7 @@ struct uip_driver_s
|
||||
|
||||
int (*d_ifup)(struct uip_driver_s *dev);
|
||||
int (*d_ifdown)(struct uip_driver_s *dev);
|
||||
int (*d_txavail)(struct uip_driver_s *dev);
|
||||
|
||||
/* Drivers may attached device-specific, private information */
|
||||
|
||||
|
||||
139
include/net/uip/uip-icmp.h
Normal file
139
include/net/uip/uip-icmp.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* net/uip/uip-icmp.h
|
||||
* Header file for the uIP ICMP stack.
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
*
|
||||
* Author Adam Dunkels <adam@dunkels.com>
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_UIP_UIP_ICMP_H
|
||||
#define __NET_UIP_UIP_ICMP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The ICMP and IP headers */
|
||||
|
||||
struct uip_icmpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 IP header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* ICMP (echo) header */
|
||||
|
||||
uint8 type;
|
||||
uint8 icode;
|
||||
uint16 icmpchksum;
|
||||
|
||||
#ifndef CONFIG_NET_IPv6
|
||||
|
||||
uint16 id;
|
||||
uint16 seqno;
|
||||
|
||||
#else /* !CONFIG_NET_IPv6 */
|
||||
|
||||
uint8 flags;
|
||||
uint8 reserved1;
|
||||
uint8 reserved2;
|
||||
uint8 reserved3;
|
||||
uint8 icmp6data[16];
|
||||
uint8 options[1];
|
||||
|
||||
#endif /* !CONFIG_NET_IPv6 */
|
||||
};
|
||||
|
||||
/* The structure holding the ICMP statistics that are gathered if
|
||||
* CONFIG_NET_STATISTICS is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct uip_icmp_stats_s
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped ICMP packets */
|
||||
uip_stats_t recv; /* Number of received ICMP packets */
|
||||
uip_stats_t sent; /* Number of sent ICMP packets */
|
||||
uip_stats_t typeerr; /* Number of ICMP packets with a wrong type */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __NET_UIP_UIP_ICMP_H */
|
||||
361
include/net/uip/uip-tcp.h
Normal file
361
include/net/uip/uip-tcp.h
Normal file
@@ -0,0 +1,361 @@
|
||||
/****************************************************************************
|
||||
* net/uip/uip-tcp.h
|
||||
* Header file for the uIP TCP/IP stack.
|
||||
*
|
||||
* The uIP TCP/IP stack header file contains definitions for a number
|
||||
* of C macros that are used by uIP programs as well as internal uIP
|
||||
* structures, TCP/IP header structures and function declarations.
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
*
|
||||
* Author Adam Dunkels <adam@dunkels.com>
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_UIP_UIP_TCP_H
|
||||
#define __NET_UIP_UIP_TCP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET_TCP
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* 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
|
||||
|
||||
/* Header sizes */
|
||||
|
||||
#define UIP_TCPH_LEN 20 /* Size of TCP header */
|
||||
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */
|
||||
#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Representation of a uIP TCP connection.
|
||||
*
|
||||
* The uip_conn structure is used for identifying a connection. All
|
||||
* but one field in the structure are to be considered read-only by an
|
||||
* application. The only exception is the "private: field whos purpose
|
||||
* is to let the application store application-specific state (e.g.,
|
||||
* file pointers) for the connection.
|
||||
*/
|
||||
|
||||
struct uip_driver_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 */
|
||||
uint8 rcv_nxt[4]; /* The sequence number that we expect to
|
||||
* receive next */
|
||||
uint8 snd_nxt[4]; /* The sequence number that was last sent by us */
|
||||
uint16 len; /* Length of the data that was previously sent */
|
||||
uint16 mss; /* Current maximum segment size for the
|
||||
* connection */
|
||||
uint16 initialmss; /* Initial maximum segment size for the
|
||||
* connection */
|
||||
uint8 sa; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
uint8 sv; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
uint8 rto; /* Retransmission time-out */
|
||||
uint8 tcpstateflags; /* TCP state and flags */
|
||||
uint8 timer; /* The retransmission timer (units: half-seconds) */
|
||||
uint8 nrtx; /* The number of retransmissions for the last
|
||||
* segment sent */
|
||||
|
||||
/* Read-ahead buffering */
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
sq_queue_t readahead;
|
||||
#endif
|
||||
|
||||
/* Higher level logic can retain application specific information
|
||||
* in the following:
|
||||
*
|
||||
* data_event() is called on all events. Normally, the input flags are
|
||||
* returned, however, the implemenation may set one of the following:
|
||||
*
|
||||
* UIP_CLOSE - Gracefully close the current connection
|
||||
* UIP_ABORT - Abort (reset) the current connection on an error that
|
||||
* prevents UIP_CLOSE from working.
|
||||
*
|
||||
* Or clear the following:
|
||||
*
|
||||
* UIP_NEWDATA - May be cleared to suppress returning the ACK response.
|
||||
* (dev->d_len should also be set to zero in this case).
|
||||
*
|
||||
* accept() is called when the TCP logic has created a connection
|
||||
* connection_event() is called on any of the subset of connection-related events
|
||||
*/
|
||||
|
||||
void *data_private;
|
||||
uint8 (*data_event)(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags);
|
||||
|
||||
void *accept_private;
|
||||
int (*accept)(struct uip_conn *listener, struct uip_conn *conn);
|
||||
|
||||
void *connection_private;
|
||||
void (*connection_event)(struct uip_conn *conn, uint8 flags);
|
||||
};
|
||||
|
||||
/* The following structure is used to handle read-ahead buffering for TCP
|
||||
* connection. When incoming TCP data is received while no application is
|
||||
* listening for the data, that data will be retained in these read-ahead
|
||||
* buffers so that no data is lost.
|
||||
*/
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
struct uip_readahead_s
|
||||
{
|
||||
sq_entry_t rh_node; /* Supports a singly linked list */
|
||||
uint16 rh_nbytes; /* Number of bytes available in this buffer */
|
||||
uint8 rh_buffer[CONFIG_NET_TCP_READAHEAD_BUFSIZE];
|
||||
};
|
||||
#endif
|
||||
|
||||
/* The structure holding the TCP/IP statistics that are gathered if
|
||||
* CONFIG_NET_STATISTICS is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct uip_tcp_stats_s
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped TCP segments */
|
||||
uip_stats_t recv; /* Number of received TCP segments */
|
||||
uip_stats_t sent; /* Number of sent TCP segments */
|
||||
uip_stats_t chkerr; /* Number of TCP segments with a bad checksum */
|
||||
uip_stats_t ackerr; /* Number of TCP segments with a bad ACK number */
|
||||
uip_stats_t rst; /* Number of recevied TCP RST (reset) segments */
|
||||
uip_stats_t rexmit; /* Number of retransmitted TCP segments */
|
||||
uip_stats_t syndrop; /* Number of dropped SYNs due to too few
|
||||
available connections */
|
||||
uip_stats_t synrst; /* Number of SYNs for closed ports triggering a RST */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* The TCP and IP headers */
|
||||
|
||||
struct uip_tcpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 IP header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* TCP header */
|
||||
|
||||
uint16 srcport;
|
||||
uint16 destport;
|
||||
uint8 seqno[4];
|
||||
uint8 ackno[4];
|
||||
uint8 tcpoffset;
|
||||
uint8 flags;
|
||||
uint8 wnd[2];
|
||||
uint16 tcpchksum;
|
||||
uint8 urgp[2];
|
||||
uint8 optdata[4];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* uIP application functions
|
||||
*
|
||||
* Functions used by an application running of top of uIP. This includes
|
||||
* functions for opening and closing connections, sending and receiving
|
||||
* data, etc.
|
||||
*
|
||||
* Find a free connection structure and allocate it for use. This is
|
||||
* normally something done by the implementation of the socket() API
|
||||
*/
|
||||
|
||||
extern struct uip_conn *uip_tcpalloc(void);
|
||||
|
||||
/* Free a connection structure that is no longer in use. This should
|
||||
* be done by the implementation of close()
|
||||
*/
|
||||
|
||||
extern void uip_tcpfree(struct uip_conn *conn);
|
||||
|
||||
/* Bind a TCP connection to a local address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* This function implements the UIP specific parts of the standard
|
||||
* TCP connect() operation: It connects to a remote host using TCP.
|
||||
*
|
||||
* This function is used to start a new connection to the specified
|
||||
* port on the specied host. It uses the connection structure that was
|
||||
* allocated by a preceding socket() call. It sets the connection to
|
||||
* the SYN_SENT state and sets the retransmission timer to 0. This will
|
||||
* cause a TCP SYN segment to be sent out the next time this connection
|
||||
* is periodically processed, which usually is done within 0.5 seconds
|
||||
* after the call to uip_tcpconnect().
|
||||
*
|
||||
* This function is called from normal user level code.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* Start listening to the port bound to the specified TCP connection */
|
||||
|
||||
extern int uip_listen(struct uip_conn *conn);
|
||||
|
||||
/* Stop listening to the port bound to the specified TCP connection */
|
||||
|
||||
extern int uip_unlisten(struct uip_conn *conn);
|
||||
|
||||
/* Check if a connection has outstanding (i.e., unacknowledged) data */
|
||||
|
||||
#define uip_outstanding(conn) ((conn)->len)
|
||||
|
||||
/* Access to TCP read-ahead buffers */
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
extern struct uip_readahead_s *uip_tcpreadaheadalloc(void);
|
||||
extern void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */
|
||||
|
||||
/* Tell the sending host to stop sending data.
|
||||
*
|
||||
* This function will close our receiver's window so that we stop
|
||||
* receiving data for the current connection.
|
||||
*/
|
||||
|
||||
#define uip_stop(conn) ((conn)->tcpstateflags |= UIP_STOPPED)
|
||||
|
||||
/* Find out if the current connection has been previously stopped with
|
||||
* uip_stop().
|
||||
*/
|
||||
|
||||
#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED)
|
||||
|
||||
/* Restart the current connection, if is has previously been stopped
|
||||
* with uip_stop().
|
||||
*
|
||||
* This function will open the receiver's window again so that we
|
||||
* start receiving data for the current connection.
|
||||
*/
|
||||
|
||||
#define uip_restart(conn,f) \
|
||||
do { \
|
||||
(f) |= UIP_NEWDATA; \
|
||||
(conn)->tcpstateflags &= ~UIP_STOPPED; \
|
||||
} while(0)
|
||||
|
||||
/* Get the initial maxium segment size (MSS) of the current
|
||||
* connection.
|
||||
*/
|
||||
|
||||
#define uip_initialmss(conn) ((conn)->initialmss)
|
||||
|
||||
/* Get the current maxium segment size that can be sent on the current
|
||||
* connection.
|
||||
*
|
||||
* The current maxiumum segment size that can be sent on the
|
||||
* connection is computed from the receiver's window and the MSS of
|
||||
* the connection (which also is available by calling
|
||||
* uip_initialmss()).
|
||||
*/
|
||||
|
||||
#define uip_mss(conn) ((conn)->mss)
|
||||
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
#endif /* __NET_UIP_UIP_TCP_H */
|
||||
199
include/net/uip/uip-udp.h
Normal file
199
include/net/uip/uip-udp.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/****************************************************************************
|
||||
* net/uip/uip-udp.h
|
||||
* Header file for the uIP UDP stack.
|
||||
*
|
||||
* The uIP UDP stack header file contains definitions for a number
|
||||
* of C macros that are used by uIP programs as well as internal uIP
|
||||
* structures, UDP header structures and function declarations.
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
*
|
||||
* Author Adam Dunkels <adam@dunkels.com>
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_UIP_UIP_UDP_H
|
||||
#define __NET_UIP_UIP_UDP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Header sizes */
|
||||
|
||||
#define UIP_UDPH_LEN 8 /* Size of UDP header */
|
||||
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Representation of a uIP UDP connection */
|
||||
|
||||
struct uip_driver_s; /* Forward reference */
|
||||
struct uip_udp_conn
|
||||
{
|
||||
dq_entry_t node; /* Supports a doubly linked list */
|
||||
uip_ipaddr_t ripaddr; /* The IP address of the remote peer */
|
||||
uint16 lport; /* The local port number in network byte order */
|
||||
uint16 rport; /* The remote port number in network byte order */
|
||||
uint8 ttl; /* Default time-to-live */
|
||||
|
||||
/* Defines the UDP callback */
|
||||
|
||||
void *private;
|
||||
void (*event)(struct uip_driver_s *dev, struct uip_udp_conn *conn, uint8 flags);
|
||||
};
|
||||
|
||||
/* The UDP and IP headers */
|
||||
|
||||
struct uip_udpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* UDP header */
|
||||
|
||||
uint16 srcport;
|
||||
uint16 destport;
|
||||
uint16 udplen;
|
||||
uint16 udpchksum;
|
||||
};
|
||||
|
||||
/* The structure holding the UDP statistics that are gathered if
|
||||
* CONFIG_NET_STATISTICS is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct uip_udp_stats_s
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped UDP segments */
|
||||
uip_stats_t recv; /* Number of recived UDP segments */
|
||||
uip_stats_t sent; /* Number of sent UDP segments */
|
||||
uip_stats_t chkerr; /* Number of UDP segments with a bad checksum */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* uIP application functions
|
||||
*
|
||||
* Functions used by an application running of top of uIP. This includes
|
||||
* functions for opening and closing connections, sending and receiving
|
||||
* data, etc.
|
||||
*
|
||||
* Find a free connection structure and allocate it for use. This is
|
||||
* normally something done by the implementation of the socket() API
|
||||
*/
|
||||
|
||||
extern struct uip_udp_conn *uip_udpalloc(void);
|
||||
|
||||
/* Free a connection structure that is no longer in use. This should
|
||||
* be done by the implementation of close()
|
||||
*/
|
||||
|
||||
extern void uip_udpfree(struct uip_udp_conn *conn);
|
||||
|
||||
/* Bind a UDP connection to a local address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* This function sets up a new UDP connection. The function will
|
||||
* automatically allocate an unused local port for the new
|
||||
* connection. However, another port can be chosen by using the
|
||||
* uip_udpbind() call, after the uip_udpconnect() function has been
|
||||
* called.
|
||||
*
|
||||
* This function is called as part of the implementation of sendto
|
||||
* and recvfrom.
|
||||
*
|
||||
* addr The address of the remote host.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* Enable/disable UDP callbacks on a connection */
|
||||
|
||||
extern void uip_udpenable(struct uip_udp_conn *conn);
|
||||
extern void uip_udpdisable(struct uip_udp_conn *conn);
|
||||
|
||||
#endif /* __NET_UIP_UIP_UDP_H */
|
||||
@@ -1,10 +1,9 @@
|
||||
/****************************************************************************
|
||||
* uip.h
|
||||
* Header file for the uIP TCP/IP stack.
|
||||
* net/uip/uip.h
|
||||
*
|
||||
* The uIP TCP/IP stack header file contains definitions for a number
|
||||
* of C macros that are used by uIP programs as well as internal uIP
|
||||
* structures, TCP/IP header structures and function declarations.
|
||||
* The uIP header file contains definitions for a number of C macros that
|
||||
* are used by uIP programs as well as internal uIP structures and function
|
||||
* declarations.
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -18,6 +17,7 @@
|
||||
* 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
|
||||
@@ -49,11 +49,12 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <queue.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
#include <net/uip/uipopt.h>
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
@@ -85,22 +86,6 @@
|
||||
#define UIP_DATA_EVENTS (UIP_ACKDATA|UIP_NEWDATA|UIP_REXMIT|UIP_POLL)
|
||||
#define UIP_CONN_EVENTS (UIP_CLOSE|UIP_ABORT|UIP_CONNECTED|UIP_TIMEDOUT)
|
||||
|
||||
/* 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
|
||||
|
||||
/* The buffer size available for user data in the d_buf buffer.
|
||||
*
|
||||
* This macro holds the available size for user data in the
|
||||
@@ -122,16 +107,10 @@
|
||||
/* Header sizes */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# define UIP_IPH_LEN 40
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
# define UIP_IPH_LEN 40 /* Size of IP header */
|
||||
#else
|
||||
# define UIP_IPH_LEN 20 /* Size of IP header */
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
#define UIP_UDPH_LEN 8 /* Size of UDP header */
|
||||
#define UIP_TCPH_LEN 20 /* Size of TCP header */
|
||||
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */
|
||||
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */
|
||||
#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
@@ -144,317 +123,92 @@ typedef uint16 uip_ip6addr_t[8];
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
typedef uip_ip6addr_t uip_ipaddr_t;
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
#else
|
||||
typedef uip_ip4addr_t uip_ipaddr_t;
|
||||
#endif
|
||||
|
||||
/* The IP header */
|
||||
|
||||
struct uip_ip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 IP header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Representation of a uIP TCP connection.
|
||||
*
|
||||
* The uip_conn structure is used for identifying a connection. All
|
||||
* but one field in the structure are to be considered read-only by an
|
||||
* application. The only exception is the "private: field whos purpose
|
||||
* is to let the application store application-specific state (e.g.,
|
||||
* file pointers) for the connection.
|
||||
*/
|
||||
|
||||
struct uip_driver_s; /* Forward reference */
|
||||
struct uip_conn
|
||||
{
|
||||
dq_entry_t node; /* Implements a doubly linked list */
|
||||
uip_ipaddr_t lipaddr; /* The local IP address */
|
||||
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 */
|
||||
uint8 rcv_nxt[4]; /* The sequence number that we expect to
|
||||
* receive next */
|
||||
uint8 snd_nxt[4]; /* The sequence number that was last sent by us */
|
||||
uint16 len; /* Length of the data that was previously sent */
|
||||
uint16 mss; /* Current maximum segment size for the
|
||||
* connection */
|
||||
uint16 initialmss; /* Initial maximum segment size for the
|
||||
* connection */
|
||||
uint8 sa; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
uint8 sv; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
uint8 rto; /* Retransmission time-out */
|
||||
uint8 tcpstateflags; /* TCP state and flags */
|
||||
uint8 timer; /* The retransmission timer (units: half-seconds) */
|
||||
uint8 nrtx; /* The number of retransmissions for the last
|
||||
* segment sent */
|
||||
|
||||
/* Read-ahead buffering */
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
sq_queue_t readahead;
|
||||
#endif
|
||||
|
||||
/* Higher level logic can retain application specific information
|
||||
* in the following:
|
||||
*
|
||||
* data_event() is called on all events. Normally, the input flags are
|
||||
* returned, however, the implemenation may set one of the following:
|
||||
*
|
||||
* UIP_CLOSE - Gracefully close the current connection
|
||||
* UIP_ABORT - Abort (reset) the current connection on an error that
|
||||
* prevents UIP_CLOSE from working.
|
||||
*
|
||||
* Or clear the following:
|
||||
*
|
||||
* UIP_NEWDATA - May be cleared to suppress returning the ACK response.
|
||||
* (dev->d_len should also be set to zero in this case).
|
||||
*
|
||||
* accept() is called when the TCP logic has created a connection
|
||||
* connection_event() is called on any of the subset of connection-related events
|
||||
*/
|
||||
|
||||
void *data_private;
|
||||
uint8 (*data_event)(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags);
|
||||
|
||||
void *accept_private;
|
||||
int (*accept)(struct uip_conn *listener, struct uip_conn *conn);
|
||||
|
||||
void *connection_private;
|
||||
void (*connection_event)(struct uip_conn *conn, uint8 flags);
|
||||
};
|
||||
|
||||
/* The following structure is used to handle read-ahead buffering for TCP
|
||||
* connection. When incoming TCP data is received while no application is
|
||||
* listening for the data, that data will be retained in these read-ahead
|
||||
* buffers so that no data is lost.
|
||||
*/
|
||||
/* Protocol-specific support */
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
struct uip_readahead_s
|
||||
{
|
||||
sq_entry_t rh_node; /* Supports a singly linked list */
|
||||
uint16 rh_nbytes; /* Number of bytes available in this buffer */
|
||||
uint8 rh_buffer[CONFIG_NET_TCP_READAHEAD_BUFSIZE];
|
||||
};
|
||||
#endif
|
||||
#include <net/uip/uip-tcp.h>
|
||||
#include <net/uip/uip-udp.h>
|
||||
#include <net/uip/uip-icmp.h>
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
/* Representation of a uIP UDP connection */
|
||||
|
||||
struct uip_udp_conn
|
||||
{
|
||||
dq_entry_t node; /* Supports a doubly linked list */
|
||||
uip_ipaddr_t ripaddr; /* The IP address of the remote peer */
|
||||
uint16 lport; /* The local port number in network byte order */
|
||||
uint16 rport; /* The remote port number in network byte order */
|
||||
uint8 ttl; /* Default time-to-live */
|
||||
|
||||
/* Defines the UDP callback */
|
||||
|
||||
void *private;
|
||||
void (*event)(struct uip_driver_s *dev, struct uip_udp_conn *conn, uint8 flags);
|
||||
};
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
/* The structure holding the TCP/IP statistics that are gathered if
|
||||
/* The structure holding the uIP statistics that are gathered if
|
||||
* CONFIG_NET_STATISTICS is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct uip_ip_stats_s
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped packets at the IP layer */
|
||||
uip_stats_t recv; /* Number of received packets at the IP layer */
|
||||
uip_stats_t sent; /* Number of sent packets at the IP layer */
|
||||
uip_stats_t vhlerr; /* Number of packets dropped due to wrong
|
||||
IP version or header length */
|
||||
uip_stats_t hblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, high byte */
|
||||
uip_stats_t lblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, low byte */
|
||||
uip_stats_t fragerr; /* Number of packets dropped since they
|
||||
were IP fragments */
|
||||
uip_stats_t chkerr; /* Number of packets dropped due to IP
|
||||
checksum errors */
|
||||
uip_stats_t protoerr; /* Number of packets dropped since they
|
||||
were neither ICMP, UDP nor TCP */
|
||||
};
|
||||
|
||||
struct uip_stats
|
||||
{
|
||||
struct
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped packets at the IP layer */
|
||||
uip_stats_t recv; /* Number of received packets at the IP layer */
|
||||
uip_stats_t sent; /* Number of sent packets at the IP layer */
|
||||
uip_stats_t vhlerr; /* Number of packets dropped due to wrong
|
||||
IP version or header length */
|
||||
uip_stats_t hblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, high byte */
|
||||
uip_stats_t lblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, low byte */
|
||||
uip_stats_t fragerr; /* Number of packets dropped since they
|
||||
were IP fragments */
|
||||
uip_stats_t chkerr; /* Number of packets dropped due to IP
|
||||
checksum errors */
|
||||
uip_stats_t protoerr; /* Number of packets dropped since they
|
||||
were neither ICMP, UDP nor TCP */
|
||||
} ip; /* IP statistics */
|
||||
struct uip_ip_stats_s ip; /* IP statistics */
|
||||
|
||||
struct
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped ICMP packets */
|
||||
uip_stats_t recv; /* Number of received ICMP packets */
|
||||
uip_stats_t sent; /* Number of sent ICMP packets */
|
||||
uip_stats_t typeerr; /* Number of ICMP packets with a wrong type */
|
||||
} icmp; /* ICMP statistics */
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
struct uip_icmp_stats_s icmp; /* ICMP statistics */
|
||||
#endif
|
||||
|
||||
struct
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped TCP segments */
|
||||
uip_stats_t recv; /* Number of received TCP segments */
|
||||
uip_stats_t sent; /* Number of sent TCP segments */
|
||||
uip_stats_t chkerr; /* Number of TCP segments with a bad checksum */
|
||||
uip_stats_t ackerr; /* Number of TCP segments with a bad ACK number */
|
||||
uip_stats_t rst; /* Number of recevied TCP RST (reset) segments */
|
||||
uip_stats_t rexmit; /* Number of retransmitted TCP segments */
|
||||
uip_stats_t syndrop; /* Number of dropped SYNs due to too few
|
||||
available connections */
|
||||
uip_stats_t synrst; /* Number of SYNs for closed ports triggering a RST */
|
||||
} tcp; /* TCP statistics */
|
||||
#ifdef CONFIG_NET_TCP
|
||||
struct uip_tcp_stats_s tcp; /* TCP statistics */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
struct
|
||||
{
|
||||
uip_stats_t drop; /* Number of dropped UDP segments */
|
||||
uip_stats_t recv; /* Number of recived UDP segments */
|
||||
uip_stats_t sent; /* Number of sent UDP segments */
|
||||
uip_stats_t chkerr; /* Number of UDP segments with a bad checksum */
|
||||
} udp; /* UDP statistics */
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
};
|
||||
|
||||
/* The TCP and IP headers */
|
||||
|
||||
struct uip_tcpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 IP header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* TCP header */
|
||||
|
||||
uint16 srcport;
|
||||
uint16 destport;
|
||||
uint8 seqno[4];
|
||||
uint8 ackno[4];
|
||||
uint8 tcpoffset;
|
||||
uint8 flags;
|
||||
uint8 wnd[2];
|
||||
uint16 tcpchksum;
|
||||
uint8 urgp[2];
|
||||
uint8 optdata[4];
|
||||
};
|
||||
|
||||
/* The ICMP and IP headers */
|
||||
|
||||
struct uip_icmpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 IP header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* ICMP (echo) header */
|
||||
|
||||
uint8 type;
|
||||
uint8 icode;
|
||||
uint16 icmpchksum;
|
||||
|
||||
#ifndef CONFIG_NET_IPv6
|
||||
|
||||
uint16 id;
|
||||
uint16 seqno;
|
||||
|
||||
#else /* !CONFIG_NET_IPv6 */
|
||||
|
||||
uint8 flags;
|
||||
uint8 reserved1;
|
||||
uint8 reserved2;
|
||||
uint8 reserved3;
|
||||
uint8 icmp6data[16];
|
||||
uint8 options[1];
|
||||
|
||||
#endif /* !CONFIG_NET_IPv6 */
|
||||
};
|
||||
|
||||
/* The UDP and IP headers */
|
||||
|
||||
struct uip_udpip_hdr
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/* IPv6 Ip header */
|
||||
|
||||
uint8 vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
|
||||
uint8 tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
|
||||
uint16 flow; /* 16-bit flow label (LS) */
|
||||
uint8 len[2]; /* 16-bit Payload length */
|
||||
uint8 proto; /* 8-bit Next header (same as IPv4 protocol field) */
|
||||
uint8 ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
|
||||
uip_ip6addr_t srcipaddr; /* 128-bit Source address */
|
||||
uip_ip6addr_t destipaddr; /* 128-bit Destination address */
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* IPv4 header */
|
||||
|
||||
uint8 vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
||||
uint8 tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
||||
uint8 len[2]; /* 16-bit Total length */
|
||||
uint8 ipid[2]; /* 16-bit Identification */
|
||||
uint8 ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
||||
uint8 ttl; /* 8-bit Time to Live */
|
||||
uint8 proto; /* 8-bit Protocol */
|
||||
uint16 ipchksum; /* 16-bit Header checksum */
|
||||
uint16 srcipaddr[2]; /* 32-bit Source IP address */
|
||||
uint16 destipaddr[2]; /* 32-bit Destination IP address */
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* UDP header */
|
||||
|
||||
uint16 srcport;
|
||||
uint16 destport;
|
||||
uint16 udplen;
|
||||
uint16 udpchksum;
|
||||
struct uip_udp_stats_s udp; /* UDP statistics */
|
||||
#endif
|
||||
};
|
||||
#endif /* CONFIG_NET_STATISTICS */
|
||||
|
||||
/* Representation of a 48-bit Ethernet address */
|
||||
|
||||
@@ -467,45 +221,16 @@ struct uip_eth_addr
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#if UIP_URGDATA > 0
|
||||
/* uint8 *uip_urgdata:
|
||||
*
|
||||
* This pointer points to any urgent data that has been received. Only
|
||||
* present if compiled with support for urgent data (UIP_URGDATA).
|
||||
*/
|
||||
extern void *uip_urgdata;
|
||||
#endif /* UIP_URGDATA > 0 */
|
||||
|
||||
|
||||
/* Variables used in uIP device drivers
|
||||
*
|
||||
* uIP has a few global variables that are used in device drivers for
|
||||
* uIP.
|
||||
*/
|
||||
|
||||
#if UIP_URGDATA > 0
|
||||
extern uint16 uip_urglen; /* Length of (received) urgent data */
|
||||
#endif /* UIP_URGDATA > 0 */
|
||||
|
||||
/* The current UDP connection */
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
extern struct uip_udp_conn *uip_udp_conn;
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
/* The uIP TCP/IP statistics.
|
||||
*
|
||||
* This is the variable in which the uIP TCP/IP statistics are gathered.
|
||||
*/
|
||||
/* This is the structure in which the statistics are gathered. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
extern struct uip_stats uip_stat;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* uIP configuration functions */
|
||||
|
||||
/* uIP initialization functions
|
||||
*
|
||||
* The uIP initialization functions are used for booting uIP.
|
||||
@@ -525,77 +250,8 @@ extern void uip_setipid(uint16 id);
|
||||
* Functions used by an application running of top of uIP. This includes
|
||||
* functions for opening and closing connections, sending and receiving
|
||||
* data, etc.
|
||||
*
|
||||
* Find a free connection structure and allocate it for use. This is
|
||||
* normally something done by the implementation of the socket() API
|
||||
*/
|
||||
|
||||
extern struct uip_conn *uip_tcpalloc(void);
|
||||
#ifdef CONFIG_NET_UDP
|
||||
extern struct uip_udp_conn *uip_udpalloc(void);
|
||||
#endif
|
||||
|
||||
/* Free a connection structure that is no longer in use. This should
|
||||
* be done by the implementation of close()
|
||||
*/
|
||||
|
||||
extern void uip_tcpfree(struct uip_conn *conn);
|
||||
#ifdef CONFIG_NET_UDP
|
||||
extern void uip_udpfree(struct uip_udp_conn *conn);
|
||||
#endif
|
||||
|
||||
/* Bind a TCP connection to a local address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* This function implements the UIP specific parts of the standard
|
||||
* TCP connect() operation: It connects to a remote host using TCP.
|
||||
*
|
||||
* This function is used to start a new connection to the specified
|
||||
* port on the specied host. It uses the connection structure that was
|
||||
* allocated by a preceding socket() call. It sets the connection to
|
||||
* the SYN_SENT state and sets the retransmission timer to 0. This will
|
||||
* cause a TCP SYN segment to be sent out the next time this connection
|
||||
* is periodically processed, which usually is done within 0.5 seconds
|
||||
* after the call to uip_tcpconnect().
|
||||
*
|
||||
* This function is called from normal user level code.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* Start listening to the specified port.
|
||||
*
|
||||
* Note: Since this function expects the port number in network byte
|
||||
* order, a conversion using HTONS() or htons() is necessary.
|
||||
*
|
||||
* port A 16-bit port number in network byte order.
|
||||
*/
|
||||
|
||||
extern int uip_listen(uint16 port);
|
||||
|
||||
/* Stop listening to the specified port.
|
||||
*
|
||||
* Note: Since this function expects the port number in network byte
|
||||
* order, a conversion using HTONS() or htons() is necessary.
|
||||
*
|
||||
* port A 16-bit port number in network byte order.
|
||||
*/
|
||||
|
||||
extern int uip_unlisten(uint16 port);
|
||||
|
||||
/* Check if a connection has outstanding (i.e., unacknowledged) data */
|
||||
|
||||
#define uip_outstanding(conn) ((conn)->len)
|
||||
|
||||
/* Send data on the current connection.
|
||||
*
|
||||
* This function is used to send out a single segment of TCP
|
||||
@@ -621,13 +277,6 @@ extern int uip_unlisten(uint16 port);
|
||||
|
||||
extern void uip_send(struct uip_driver_s *dev, const void *buf, int len);
|
||||
|
||||
/* Access to TCP read-ahead buffers */
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
extern struct uip_readahead_s *uip_tcpreadaheadalloc(void);
|
||||
extern void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */
|
||||
|
||||
/* The length of any incoming data that is currently avaliable (if avaliable)
|
||||
* in the d_appdata buffer.
|
||||
*
|
||||
@@ -637,43 +286,6 @@ extern void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
|
||||
#define uip_datalen(dev) ((dev)->d_len)
|
||||
|
||||
/* The length of any out-of-band data (urgent data) that has arrived
|
||||
* on the connection.
|
||||
*
|
||||
* Note: The configuration parameter UIP_URGDATA must be set for this
|
||||
* function to be enabled.
|
||||
*/
|
||||
|
||||
#define uip_urgdatalen() uip_urglen
|
||||
|
||||
/* Tell the sending host to stop sending data.
|
||||
*
|
||||
* This function will close our receiver's window so that we stop
|
||||
* receiving data for the current connection.
|
||||
*/
|
||||
|
||||
#define uip_stop(conn) ((conn)->tcpstateflags |= UIP_STOPPED)
|
||||
|
||||
/* Find out if the current connection has been previously stopped with
|
||||
* uip_stop().
|
||||
*/
|
||||
|
||||
#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED)
|
||||
|
||||
/* Restart the current connection, if is has previously been stopped
|
||||
* with uip_stop().
|
||||
*
|
||||
* This function will open the receiver's window again so that we
|
||||
* start receiving data for the current connection.
|
||||
*/
|
||||
|
||||
#define uip_restart(conn,f) \
|
||||
do { \
|
||||
(f) |= UIP_NEWDATA; \
|
||||
(conn)->tcpstateflags &= ~UIP_STOPPED; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* uIP tests that can be made to determine in what state the current
|
||||
* connection is, and what the application function should do.
|
||||
*
|
||||
@@ -751,54 +363,6 @@ extern void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
|
||||
#define uip_poll_event(f) ((f) & UIP_POLL)
|
||||
|
||||
/* Get the initial maxium segment size (MSS) of the current
|
||||
* connection.
|
||||
*/
|
||||
|
||||
#define uip_initialmss(conn) ((conn)->initialmss)
|
||||
|
||||
/* Get the current maxium segment size that can be sent on the current
|
||||
* connection.
|
||||
*
|
||||
* The current maxiumum segment size that can be sent on the
|
||||
* connection is computed from the receiver's window and the MSS of
|
||||
* the connection (which also is available by calling
|
||||
* uip_initialmss()).
|
||||
*/
|
||||
|
||||
#define uip_mss(conn) ((conn)->mss)
|
||||
|
||||
/* Bind a UDP connection to a local address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* This function sets up a new UDP connection. The function will
|
||||
* automatically allocate an unused local port for the new
|
||||
* connection. However, another port can be chosen by using the
|
||||
* uip_udpbind() call, after the uip_udpconnect() function has been
|
||||
* called.
|
||||
*
|
||||
* This function is called as part of the implementation of sendto
|
||||
* and recvfrom.
|
||||
*
|
||||
* addr The address of the remote host.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr);
|
||||
#else
|
||||
extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/* Enable/disable UDP callbacks on a connection */
|
||||
|
||||
extern void uip_udpenable(struct uip_udp_conn *conn);
|
||||
extern void uip_udpdisable(struct uip_udp_conn *conn);
|
||||
|
||||
/* uIP convenience and converting functions.
|
||||
*
|
||||
* These functions can be used for converting between different data
|
||||
@@ -921,9 +485,10 @@ extern void uip_udpdisable(struct uip_udp_conn *conn);
|
||||
* uip_ipaddr(&mask, 255,255,255,0);
|
||||
* uip_ipaddr(&ipaddr1, 192,16,1,2);
|
||||
* uip_ipaddr(&ipaddr2, 192,16,1,3);
|
||||
* if(uip_ipaddr_maskcmp(ipaddr1, ipaddr2, &mask)) {
|
||||
* printf("They are the same");
|
||||
* }
|
||||
* if(uip_ipaddr_maskcmp(ipaddr1, ipaddr2, &mask))
|
||||
* {
|
||||
* printf("They are the same");
|
||||
* }
|
||||
*
|
||||
* addr1 The first IP address.
|
||||
* addr2 The second IP address.
|
||||
@@ -932,9 +497,12 @@ extern void uip_udpdisable(struct uip_udp_conn *conn);
|
||||
|
||||
#ifndef CONFIG_NET_IPv6
|
||||
# define uip_ipaddr_maskcmp(addr1, addr2, mask) \
|
||||
(((in_addr_t)(addr1) & (in_addr_t)(mask)) == ((in_addr_t)(addr2) & (in_addr_t)(mask)))
|
||||
#else /* !CONFIG_NET_IPv6 */
|
||||
#endif /* !CONFIG_NET_IPv6 */
|
||||
(((in_addr_t)(addr1) & (in_addr_t)(mask)) == \
|
||||
((in_addr_t)(addr2) & (in_addr_t)(mask)))
|
||||
#else
|
||||
extern boolean uip_ipaddr_maskcmp(uip_addr_t addr1, uip_addr_t addr2,
|
||||
uip_addr_t mask);
|
||||
#endif
|
||||
|
||||
/* Mask out the network part of an IP address.
|
||||
*
|
||||
|
||||
@@ -128,15 +128,6 @@
|
||||
# define CONFIG_NET_MAX_LISTENPORTS 20
|
||||
#endif
|
||||
|
||||
/* Determines if support for TCP urgent data notification should be
|
||||
* compiled in.
|
||||
*
|
||||
* Urgent data (out-of-band data) is a rarely used TCP feature that
|
||||
* very seldom would be required.
|
||||
*/
|
||||
|
||||
#define UIP_URGDATA 0
|
||||
|
||||
/* The initial retransmission timeout counted in timer pulses.
|
||||
*
|
||||
* This should not be changed.
|
||||
|
||||
@@ -63,6 +63,7 @@ EXTERN char *strchr(const char *s, int c);
|
||||
EXTERN FAR char *strdup(const char *s);
|
||||
EXTERN const char *strerror(int);
|
||||
EXTERN size_t strlen(const char *);
|
||||
EXTERN char *strcat(char *, const char *);
|
||||
EXTERN char *strncat(char *, const char *, size_t);
|
||||
EXTERN int strcmp(const char *, const char *);
|
||||
EXTERN int strncmp(const char *, const char *, size_t);
|
||||
|
||||
@@ -47,9 +47,9 @@ endif
|
||||
|
||||
STRING_SRCS = lib_memset.c lib_memcpy.c lib_memcmp.c lib_memmove.c \
|
||||
lib_strcpy.c lib_strncpy.c lib_strcmp.c lib_strncmp.c \
|
||||
lib_strlen.c lib_strdup.c lib_strtol.c lib_strchr.c \
|
||||
lib_strrchr.c lib_strspn.c lib_strcspn.c lib_strtok.c \
|
||||
lib_strtokr.c lib_strerror.c
|
||||
lib_strlen.c lib_strdup.c lib_strcat.c lib_strncat.c \
|
||||
lib_strtol.c lib_strchr.c lib_strrchr.c lib_strspn.c \
|
||||
lib_strcspn.c lib_strtok.c lib_strtokr.c lib_strerror.c
|
||||
|
||||
CTYPE_SRCS =
|
||||
|
||||
|
||||
@@ -53,7 +53,10 @@ uint32 htonl(uint32 hl)
|
||||
#ifdef CONFIG_ENDIAN_BIG
|
||||
return hl;
|
||||
#else
|
||||
return (uint32)htons((uint16)((hl) << 16)) | (uint32)htons((uint16)((hl) & 0xffff));
|
||||
return (( (hl) >> 24) |
|
||||
(((hl) >> 8) & 0x0000ff00) |
|
||||
(((hl) << 8) & 0x00ff0000) |
|
||||
( (hl) << 24));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -104,8 +104,10 @@ struct lib_rawstream_s
|
||||
|
||||
/* Defined in lib_streamsem.c */
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
extern void stream_semtake(FAR struct streamlist *list);
|
||||
extern void stream_semgive(FAR struct streamlist *list);
|
||||
#endif
|
||||
|
||||
/* Defined in lib_memstream.c */
|
||||
|
||||
|
||||
62
lib/lib_strcat.c
Normal file
62
lib/lib_strcat.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/************************************************************
|
||||
* lib/lib_strcat.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_STRCAT
|
||||
char *strcat(char *dest, const char *src)
|
||||
{
|
||||
char *ret = dest;
|
||||
|
||||
dest += strlen(dest);
|
||||
while (*src != '\0')
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
62
lib/lib_strncat.c
Normal file
62
lib/lib_strncat.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/************************************************************
|
||||
* lib/lib_strncat.c
|
||||
*
|
||||
* Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_STRNCAT
|
||||
char *strncat(char *dest, const char *src, size_t n)
|
||||
{
|
||||
char *ret = dest;
|
||||
|
||||
dest += strlen(dest);
|
||||
for (; n > 0 && *src != '\0' ; n--)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
11
net/Makefile
11
net/Makefile
@@ -40,8 +40,12 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
SOCK_ASRCS =
|
||||
SOCK_CSRCS = socket.c bind.c connect.c listen.c accept.c send.c sendto.c \
|
||||
recv.c recvfrom.c net-sockets.c net-close.c
|
||||
SOCK_CSRCS = socket.c bind.c connect.c sendto.c recv.c recvfrom.c \
|
||||
net-sockets.c net-close.c
|
||||
|
||||
ifeq ($(CONFIG_NET_TCP),y)
|
||||
SOCK_CSRCS += send.c listen.c accept.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_SOCKOPTS),y)
|
||||
SOCK_CSRCS += setsockopt.c getsockopt.c
|
||||
@@ -51,7 +55,8 @@ endif
|
||||
endif
|
||||
|
||||
NETDEV_ASRCS =
|
||||
NETDEV_CSRCS = netdev-register.c netdev-ioctl.c netdev-find.c netdev-count.c
|
||||
NETDEV_CSRCS = netdev-register.c netdev-ioctl.c netdev-txnotify.c \
|
||||
netdev-findbyname.c netdev-findbyaddr.c netdev-count.c
|
||||
|
||||
include uip/Make.defs
|
||||
endif
|
||||
|
||||
52
net/accept.c
52
net/accept.c
@@ -38,7 +38,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -52,6 +52,10 @@
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -76,6 +80,47 @@ struct accept_s
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: accept_tcpsender
|
||||
*
|
||||
* Description:
|
||||
* Getting the sender's address from the UDP packet
|
||||
*
|
||||
* Parameters:
|
||||
* conn - The newly accepted TCP connection
|
||||
* pstate - the recvfrom state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Running at the interrupt level
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline void accept_tcpsender(struct uip_conn *conn, struct accept_s *pstate)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct sockaddr_in6 *addr = pstate->acpt_addr;
|
||||
#else
|
||||
FAR struct sockaddr_in *addr = pstate->acpt_addr;
|
||||
#endif
|
||||
|
||||
if (addr)
|
||||
{
|
||||
addr->sin_family = AF_INET;
|
||||
addr->sin_port = conn->rport;
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
|
||||
#else
|
||||
uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: accept_interrupt
|
||||
*
|
||||
@@ -102,7 +147,8 @@ static int accept_interrupt(struct uip_conn *listener, struct uip_conn *conn)
|
||||
if (pstate)
|
||||
{
|
||||
/* Get the connection address */
|
||||
#warning "need to return the address of the connection"
|
||||
|
||||
accept_tcpsender(conn, pstate);
|
||||
|
||||
/* Save the connection structure */
|
||||
|
||||
@@ -354,4 +400,4 @@ errout:
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_TCP*/
|
||||
|
||||
@@ -85,11 +85,15 @@
|
||||
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
FAR struct socket *psock = sockfd_socket(sockfd);
|
||||
|
||||
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR const struct sockaddr_in6 *inaddr = (const struct sockaddr_in6 *)addr;
|
||||
#else
|
||||
FAR const struct sockaddr_in *inaddr = (const struct sockaddr_in *)addr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
@@ -117,16 +121,19 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
|
||||
switch (psock->s_type)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case SOCK_STREAM:
|
||||
ret = uip_tcpbind(psock->s_conn, inaddr);
|
||||
psock->s_flags |= _SF_BOUND;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
case SOCK_DGRAM:
|
||||
ret = uip_udpbind(psock->s_conn, inaddr);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
err = EBADF;
|
||||
goto errout;
|
||||
|
||||
@@ -54,17 +54,20 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
struct tcp_connect_s
|
||||
{
|
||||
FAR struct uip_conn *tc_conn; /* Reference to TCP connection structure */
|
||||
sem_t tc_sem; /* Semaphore signals recv completion */
|
||||
int tc_result; /* OK on success, otherwise a negated errno. */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static void connection_event(struct uip_conn *conn, uint8 flags);
|
||||
static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket *psock,
|
||||
FAR struct tcp_connect_s *pstate);
|
||||
@@ -76,6 +79,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in
|
||||
#else
|
||||
static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in *inaddr);
|
||||
#endif
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -99,6 +103,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static void connection_event(struct uip_conn *conn, uint8 flags)
|
||||
{
|
||||
FAR struct socket *psock = (FAR struct socket *)conn->connection_private;
|
||||
@@ -128,11 +133,13 @@ static void connection_event(struct uip_conn *conn, uint8 flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: tcp_setup_callbacks
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket *psock,
|
||||
FAR struct tcp_connect_s *pstate)
|
||||
{
|
||||
@@ -146,11 +153,13 @@ static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket
|
||||
conn->connection_private = (void*)psock;
|
||||
conn->connection_event = connection_event;
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: tcp_teardown_callbacks
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status)
|
||||
{
|
||||
/* Make sure that no further interrupts are processed */
|
||||
@@ -170,6 +179,7 @@ static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status)
|
||||
conn->connection_event = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: tcp_connect_interrupt
|
||||
@@ -191,6 +201,7 @@ static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static uint8 tcp_connect_interrupt(struct uip_driver_s *dev,
|
||||
struct uip_conn *conn, uint8 flags)
|
||||
{
|
||||
@@ -262,6 +273,7 @@ static uint8 tcp_connect_interrupt(struct uip_driver_s *dev,
|
||||
|
||||
return flags;
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: tcp_connect
|
||||
@@ -281,6 +293,7 @@ static uint8 tcp_connect_interrupt(struct uip_driver_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in6 *inaddr)
|
||||
#else
|
||||
@@ -367,6 +380,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in
|
||||
irqrestore(flags);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@@ -443,13 +457,17 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in
|
||||
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
FAR struct socket *psock = sockfd_socket(sockfd);
|
||||
|
||||
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR const struct sockaddr_in6 *inaddr = (const struct sockaddr_in6 *)addr;
|
||||
#else
|
||||
FAR const struct sockaddr_in *inaddr = (const struct sockaddr_in *)addr;
|
||||
#endif
|
||||
int err;
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
int err;
|
||||
|
||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||
|
||||
@@ -475,6 +493,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
|
||||
switch (psock->s_type)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case SOCK_STREAM:
|
||||
{
|
||||
/* Verify that the socket is not already connected */
|
||||
@@ -495,6 +514,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
case SOCK_DGRAM:
|
||||
|
||||
@@ -126,9 +126,9 @@ int listen(int sockfd, int backlog)
|
||||
* is called; and someday should enable post() or select() logic.
|
||||
*/
|
||||
|
||||
uip_listen(conn->lport);
|
||||
uip_listen(conn);
|
||||
psock->s_flags |= _SF_LISTENING;
|
||||
return OK;
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
*get_errno_ptr() = err;
|
||||
|
||||
@@ -79,29 +79,34 @@ int net_close(int sockfd)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Perform the close depending on the protocol type */
|
||||
/* Perform uIP side of the close depending on the protocol type */
|
||||
|
||||
switch (psock->s_type)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case SOCK_STREAM:
|
||||
uip_tcpfree(psock->s_conn);
|
||||
{
|
||||
struct uip_conn *conn = psock->s_conn;
|
||||
uip_unlisten(conn);
|
||||
uip_tcpfree(conn);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
case SOCK_DGRAM:
|
||||
uip_udpfree(psock->s_conn);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
err = -EBADF;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Save the protocol type */
|
||||
|
||||
psock->s_type = 0;
|
||||
psock->s_conn = NULL;
|
||||
/* Then release the socket structure containing the connection */
|
||||
|
||||
sockfd_release(sockfd);
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <nuttx/net.h>
|
||||
#include <net/uip/uip.h>
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
@@ -164,10 +165,22 @@ EXTERN void netdev_semtake(void);
|
||||
# define netdev_semgive() sem_post(&g_netdev_sem)
|
||||
#endif
|
||||
|
||||
/* net-find.c ****************************************************************/
|
||||
/* net-findbyname.c **********************************************************/
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
EXTERN FAR struct uip_driver_s *netdev_find(const char *ifname);
|
||||
EXTERN FAR struct uip_driver_s *netdev_findbyname(const char *ifname);
|
||||
#endif
|
||||
|
||||
/* net-findbyaddr.c **********************************************************/
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
EXTERN FAR struct uip_driver_s *netdev_findbyaddr(uip_ipaddr_t *raddr);
|
||||
#endif
|
||||
|
||||
/* net-txnotify.c ************************************************************/
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
EXTERN void netdev_txnotify(uip_ipaddr_t *raddr);
|
||||
#endif
|
||||
|
||||
/* net-count.c ***************************************************************/
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <assert.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/uip/uip.h>
|
||||
#include <nuttx/net.h>
|
||||
|
||||
128
net/netdev-findbyaddr.c
Normal file
128
net/netdev-findbyaddr.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/****************************************************************************
|
||||
* net/netdev-findbyaddr.c
|
||||
*
|
||||
* Copyright (C) 2007 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 <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/uip/uip-arch.h>
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Priviate Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: netdev_maskcmp
|
||||
****************************************************************************/
|
||||
|
||||
static inline boolean netdev_maskcmp(uip_ipaddr_t *ipaddr, uip_ipaddr_t *raddr,
|
||||
uip_ipaddr_t *netmask)
|
||||
{
|
||||
#ifndef CONFIG_NET_IPv6
|
||||
return (*ipaddr & *netmask) == (*raddr & *netmask);
|
||||
#else
|
||||
# warning "Not implemented for IPv6"
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: netdev_findbyaddr
|
||||
*
|
||||
* Description:
|
||||
* Find a previously registered network device by matching a remote address
|
||||
* with the subnet served by the device
|
||||
*
|
||||
* Parameters:
|
||||
* raddr - Pointer to the remote address of a connection
|
||||
*
|
||||
* Returned Value:
|
||||
* Pointer to driver on success; null on failure
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from normal user mode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct uip_driver_s *netdev_findbyaddr(uip_ipaddr_t *raddr)
|
||||
{
|
||||
struct uip_driver_s *dev;
|
||||
|
||||
if (raddr)
|
||||
{
|
||||
netdev_semtake();
|
||||
for (dev = g_netdevices; dev; dev = dev->flink)
|
||||
{
|
||||
if (netdev_maskcmp(&dev->d_ipaddr, raddr, &dev->d_netmask))
|
||||
{
|
||||
netdev_semgive();
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
netdev_semgive();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* net/netdev-find.c
|
||||
* net/netdev-findbyname.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -73,10 +73,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: netdev_find
|
||||
* Function: netdev_findbyname
|
||||
*
|
||||
* Description:
|
||||
* Find a previously registered network device
|
||||
* Find a previously registered network device using its assigned
|
||||
* network interface name
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The interface name of the device of interest
|
||||
@@ -89,7 +90,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct uip_driver_s *netdev_find(const char *ifname)
|
||||
FAR struct uip_driver_s *netdev_findbyname(const char *ifname)
|
||||
{
|
||||
struct uip_driver_s *dev;
|
||||
if (ifname)
|
||||
@@ -177,7 +177,7 @@ int netdev_ioctl(int sockfd, int cmd, struct ifreq *req)
|
||||
* in the request data.
|
||||
*/
|
||||
|
||||
dev = netdev_find(req->ifr_name);
|
||||
dev = netdev_findbyname(req->ifr_name);
|
||||
if (!dev)
|
||||
{
|
||||
err = EINVAL;
|
||||
|
||||
106
net/netdev-txnotify.c
Normal file
106
net/netdev-txnotify.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
* net/netdev-txnotify.c
|
||||
*
|
||||
* Copyright (C) 2007 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 <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/uip/uip-arch.h>
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Priviate Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: netdev_txnotify
|
||||
*
|
||||
* Description:
|
||||
* Notify the device driver that new TX data is available.
|
||||
*
|
||||
* Parameters:
|
||||
* raddr - Pointer to the remote address to send the data
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from normal user mode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void netdev_txnotify(uip_ipaddr_t *raddr)
|
||||
{
|
||||
/* Find the device driver that serves the subnet of the remote address */
|
||||
|
||||
struct uip_driver_s *dev = netdev_findbyaddr(raddr);
|
||||
if (dev && dev->d_txavail)
|
||||
{
|
||||
/* Notify the device driver that new TX data is available. */
|
||||
|
||||
(void)dev->d_txavail(dev);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
197
net/recvfrom.c
197
net/recvfrom.c
@@ -59,22 +59,32 @@
|
||||
|
||||
#define TCP_TIMEO 10 /* Deciseconds after data received before recv() returns */
|
||||
|
||||
#define UDPBUF ((struct uip_udpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
#define TCPBUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
struct recvfrom_s
|
||||
{
|
||||
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
|
||||
FAR struct socket *rf_sock; /* The parent socket structure */
|
||||
uint32 rf_starttime; /* rcv start time for determining timeout */
|
||||
FAR struct socket *rf_sock; /* The parent socket structure */
|
||||
uint32 rf_starttime; /* rcv start time for determining timeout */
|
||||
#endif
|
||||
sem_t rf_sem; /* Semaphore signals recv completion */
|
||||
size_t rf_buflen; /* Length of receive buffer */
|
||||
char *rf_buffer; /* Pointer to receive buffer */
|
||||
size_t rf_recvlen; /* The received length */
|
||||
int rf_result; /* OK on success, otherwise a negated errno. */
|
||||
sem_t rf_sem; /* Semaphore signals recv completion */
|
||||
size_t rf_buflen; /* Length of receive buffer */
|
||||
char *rf_buffer; /* Pointer to receive buffer */
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct sockaddr_in6 *rf_from; /* Address of sender */
|
||||
#else
|
||||
FAR struct sockaddr_in *rf_from; /* Address of sender */
|
||||
#endif
|
||||
size_t rf_recvlen; /* The received length */
|
||||
int rf_result; /* OK:success, failure:negated errno */
|
||||
};
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -98,6 +108,7 @@ struct recvfrom_s
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate)
|
||||
{
|
||||
size_t recvlen;
|
||||
@@ -128,6 +139,7 @@ static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate
|
||||
|
||||
dev->d_len = 0;
|
||||
}
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_readahead
|
||||
@@ -147,7 +159,7 @@ static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
#if defined(CONFIG_NET_TCP) && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
static inline void recvfrom_readahead(struct recvfrom_s *pstate)
|
||||
{
|
||||
struct uip_conn *conn = (struct uip_conn *)pstate->rf_sock->s_conn;
|
||||
@@ -214,7 +226,7 @@ static inline void recvfrom_readahead(struct recvfrom_s *pstate)
|
||||
}
|
||||
while (readahead && pstate->rf_buflen > 0);
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_timeout
|
||||
@@ -233,6 +245,7 @@ static inline void recvfrom_readahead(struct recvfrom_s *pstate)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
|
||||
static int recvfrom_timeout(struct recvfrom_s *pstate)
|
||||
{
|
||||
@@ -279,6 +292,48 @@ static int recvfrom_timeout(struct recvfrom_s *pstate)
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_tcpsender
|
||||
*
|
||||
* Description:
|
||||
* Getting the sender's address from the UDP packet
|
||||
*
|
||||
* Parameters:
|
||||
* dev - The device driver data structure
|
||||
* pstate - the recvfrom state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Running at the interrupt level
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline void recvfrom_tcpsender(struct uip_driver_s *dev, struct recvfrom_s *pstate)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct sockaddr_in6 *infrom = pstate->rf_from;
|
||||
#else
|
||||
FAR struct sockaddr_in *infrom = pstate->rf_from;
|
||||
#endif
|
||||
|
||||
if (infrom)
|
||||
{
|
||||
infrom->sin_family = AF_INET;
|
||||
infrom->sin_port = TCPBUF->srcport;
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
uip_ipaddr_copy(infrom->sin_addr.s_addr, TCPBUF->srcipaddr);
|
||||
#else
|
||||
uip_ipaddr_copy(infrom->sin_addr.s_addr, uip_ip4addr_conv(TCPBUF->srcipaddr));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_tcpinterrupt
|
||||
@@ -300,6 +355,7 @@ static int recvfrom_timeout(struct recvfrom_s *pstate)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev,
|
||||
struct uip_conn *conn, uint8 flags)
|
||||
{
|
||||
@@ -319,6 +375,10 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev,
|
||||
|
||||
recvfrom_newdata(dev, pstate);
|
||||
|
||||
/* Save the sender's address in the caller's 'from' location */
|
||||
|
||||
recvfrom_tcpsender(dev, pstate);
|
||||
|
||||
/* If the user buffer has been filled, then we are finished. */
|
||||
|
||||
if (pstate->rf_buflen == 0)
|
||||
@@ -406,6 +466,48 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev,
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_udpsender
|
||||
*
|
||||
* Description:
|
||||
* Getting the sender's address from the UDP packet
|
||||
*
|
||||
* Parameters:
|
||||
* dev - The device driver data structure
|
||||
* pstate - the recvfrom state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Running at the interrupt level
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
static inline void recvfrom_udpsender(struct uip_driver_s *dev, struct recvfrom_s *pstate)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct sockaddr_in6 *infrom = pstate->rf_from;
|
||||
#else
|
||||
FAR struct sockaddr_in *infrom = pstate->rf_from;
|
||||
#endif
|
||||
|
||||
if (infrom)
|
||||
{
|
||||
infrom->sin_family = AF_INET;
|
||||
infrom->sin_port = UDPBUF->srcport;
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
uip_ipaddr_copy(infrom->sin_addr.s_addr, UDPBUF->srcipaddr);
|
||||
#else
|
||||
uip_ipaddr_copy(infrom->sin_addr.s_addr, uip_ip4addr_conv(UDPBUF->srcipaddr));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_udpinterrupt
|
||||
@@ -449,13 +551,17 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev,
|
||||
|
||||
/* We are finished. */
|
||||
|
||||
vdbg("UDP resume\n");
|
||||
vdbg("UDP done\n");
|
||||
|
||||
/* Don't allow any further UDP call backs. */
|
||||
|
||||
conn->private = NULL;
|
||||
conn->event = NULL;
|
||||
|
||||
/* Save the sender's address in the caller's 'from' location */
|
||||
|
||||
recvfrom_udpsender(dev, pstate);
|
||||
|
||||
/* Wake up the waiting thread, returning the number of bytes
|
||||
* actually read.
|
||||
*/
|
||||
@@ -508,7 +614,7 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev,
|
||||
#endif /* CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_init
|
||||
@@ -529,7 +635,13 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct sockaddr_in6 *infrom,
|
||||
#else
|
||||
FAR struct sockaddr_in *infrom,
|
||||
#endif
|
||||
struct recvfrom_s *pstate)
|
||||
{
|
||||
/* Initialize the state structure. */
|
||||
@@ -538,6 +650,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
(void)sem_init(&pstate->rf_sem, 0, 0); /* Doesn't really fail */
|
||||
pstate->rf_buflen = len;
|
||||
pstate->rf_buffer = buf;
|
||||
pstate->rf_from = infrom;
|
||||
|
||||
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
|
||||
/* Set up the start time for the timeout */
|
||||
@@ -546,6 +659,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
pstate->rf_starttime = g_system_timer;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: recvfrom_result
|
||||
@@ -564,6 +678,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate)
|
||||
{
|
||||
int save_errno = *get_errno_ptr(); /* In case something we do changes it */
|
||||
@@ -594,6 +709,7 @@ static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate)
|
||||
|
||||
return pstate->rf_recvlen;
|
||||
}
|
||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: udp_recvfrom
|
||||
@@ -618,13 +734,13 @@ static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate)
|
||||
#ifdef CONFIG_NET_UDP
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
FAR const struct sockaddr_in6 *infrom )
|
||||
FAR struct sockaddr_in6 *infrom )
|
||||
#else
|
||||
static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
FAR const struct sockaddr_in *infrom )
|
||||
FAR struct sockaddr_in *infrom )
|
||||
#endif
|
||||
{
|
||||
struct uip_udp_conn *udp_conn;
|
||||
struct uip_udp_conn *udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
||||
struct recvfrom_s state;
|
||||
irqstate_t save;
|
||||
int ret;
|
||||
@@ -637,11 +753,11 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
*/
|
||||
|
||||
save = irqsave();
|
||||
recvfrom_init(psock, buf, len, &state);
|
||||
recvfrom_init(psock, buf, len, infrom, &state);
|
||||
|
||||
/* Setup the UDP socket */
|
||||
/* Setup the UDP remote connection */
|
||||
|
||||
ret = uip_udpconnect(psock->s_conn, NULL);
|
||||
ret = uip_udpconnect(udp_conn, infrom);
|
||||
if (ret < 0)
|
||||
{
|
||||
irqrestore(save);
|
||||
@@ -650,13 +766,12 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
||||
udp_conn->private = (void*)&state;
|
||||
udp_conn->event = recvfrom_udpinterrupt;
|
||||
|
||||
/* Enable the UDP socket */
|
||||
|
||||
uip_udpenable(psock->s_conn);
|
||||
uip_udpenable(udp_conn);
|
||||
|
||||
/* Wait for either the receive to complete or for an error/timeout to occur.
|
||||
* NOTES: (1) sem_wait will also terminate if a signal is received, (2)
|
||||
@@ -668,12 +783,11 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
|
||||
/* Make sure that no further interrupts are processed */
|
||||
|
||||
uip_udpdisable(psock->s_conn);
|
||||
uip_udpdisable(udp_conn);
|
||||
udp_conn->private = NULL;
|
||||
udp_conn->event = NULL;
|
||||
irqrestore(save);
|
||||
|
||||
#warning "Needs to return server address"
|
||||
return recvfrom_result(ret, &state);
|
||||
}
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
@@ -698,12 +812,13 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
FAR const struct sockaddr_in6 *infrom )
|
||||
FAR struct sockaddr_in6 *infrom )
|
||||
#else
|
||||
static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
FAR const struct sockaddr_in *infrom )
|
||||
FAR struct sockaddr_in *infrom )
|
||||
#endif
|
||||
{
|
||||
struct uip_conn *conn;
|
||||
@@ -727,7 +842,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
*/
|
||||
|
||||
save = irqsave();
|
||||
recvfrom_init(psock, buf, len, &state);
|
||||
recvfrom_init(psock, buf, len, infrom, &state);
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
|
||||
@@ -763,9 +878,9 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
}
|
||||
irqrestore(save);
|
||||
|
||||
#warning "Needs to return server address"
|
||||
return recvfrom_result(ret, &state);
|
||||
}
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
@@ -823,15 +938,19 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from,
|
||||
FAR socklen_t *fromlen)
|
||||
ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
|
||||
FAR struct sockaddr *from, FAR socklen_t *fromlen)
|
||||
{
|
||||
FAR struct socket *psock;
|
||||
|
||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR const struct sockaddr_in6 *infrom = (const struct sockaddr_in6 *)from;
|
||||
FAR struct sockaddr_in6 *infrom = (struct sockaddr_in6 *)from;
|
||||
#else
|
||||
FAR const struct sockaddr_in *infrom = (const struct sockaddr_in *)from;
|
||||
FAR struct sockaddr_in *infrom = (struct sockaddr_in *)from;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ssize_t ret;
|
||||
int err;
|
||||
|
||||
@@ -853,17 +972,19 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct so
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* If a 'from' address has been provided, verify that it is valid */
|
||||
/* If a 'from' address has been provided, verify that it is large
|
||||
* enough to hold this address family.
|
||||
*/
|
||||
|
||||
if (from)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (from->sa_family != AF_INET6 || *fromlen < sizeof(struct sockaddr_in6))
|
||||
if (*fromlen < sizeof(struct sockaddr_in6))
|
||||
#else
|
||||
if (from->sa_family != AF_INET || *fromlen < sizeof(struct sockaddr_in))
|
||||
if (*fromlen < sizeof(struct sockaddr_in))
|
||||
#endif
|
||||
{
|
||||
err = EBADF;
|
||||
err = EINVAL;
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
@@ -874,17 +995,21 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct so
|
||||
|
||||
/* Perform the TCP/IP or UDP recv() operation */
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP)
|
||||
if (psock->s_type == SOCK_STREAM)
|
||||
#endif
|
||||
{
|
||||
ret = tcp_recvfrom(psock, buf, len, infrom);
|
||||
}
|
||||
#ifdef CONFIG_NET_UDP
|
||||
else
|
||||
{
|
||||
ret = udp_recvfrom(psock, buf, len, infrom);
|
||||
}
|
||||
#elif defined(CONFIG_NET_TCP)
|
||||
ret = tcp_recvfrom(psock, buf, len, infrom);
|
||||
#elif defined(CONFIG_NET_UDP)
|
||||
ret = udp_recvfrom(psock, buf, len, infrom);
|
||||
#else
|
||||
ret = -ENOSYS;
|
||||
#endif
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
28
net/send.c
28
net/send.c
@@ -38,7 +38,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -304,19 +304,23 @@ ssize_t send(int sockfd, const void *buf, size_t len, int flags)
|
||||
conn->data_private = (void*)&state;
|
||||
conn->data_event = send_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.
|
||||
*/
|
||||
/* Notify the device driver of the availaibilty of TX data */
|
||||
|
||||
ret = sem_wait(&state. snd_sem);
|
||||
netdev_txnotify(&conn->ripaddr);
|
||||
|
||||
/* 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->data_private = NULL;
|
||||
conn->data_event = NULL;
|
||||
}
|
||||
ret = sem_wait(&state. snd_sem);
|
||||
|
||||
/* Make sure that no further interrupts are processed */
|
||||
|
||||
conn->data_private = NULL;
|
||||
conn->data_event = NULL;
|
||||
}
|
||||
|
||||
sem_destroy(&state. snd_sem);
|
||||
irqrestore(save);
|
||||
@@ -354,4 +358,4 @@ errout:
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
26
net/sendto.c
26
net/sendto.c
@@ -95,18 +95,19 @@ void sendto_interrupt(struct uip_driver_s *dev, struct uip_udp_conn *conn, uint8
|
||||
struct sendto_s *pstate = (struct sendto_s *)conn->private;
|
||||
if (pstate)
|
||||
{
|
||||
/* Check if the connectin was rejected */
|
||||
/* Check if the connection was rejected */
|
||||
|
||||
if ((flags & (UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT)) != 0)
|
||||
{
|
||||
/* Yes.. then terminate with an error */
|
||||
|
||||
pstate->st_sndlen = -ENOTCONN;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Copy the user data into d_appdata and send it */
|
||||
/* No.. Copy the user data into d_snddata and send it */
|
||||
|
||||
memcpy(dev->d_appdata, pstate->st_buffer, pstate->st_buflen);
|
||||
uip_send(dev, dev->d_appdata, pstate->st_buflen);
|
||||
uip_send(dev, pstate->st_buffer, pstate->st_buflen);
|
||||
pstate->st_sndlen = pstate->st_buflen;
|
||||
}
|
||||
|
||||
@@ -208,11 +209,18 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
/* If to is NULL or tolen is zero, then this function is same as send */
|
||||
/* If to is NULL or tolen is zero, then this function is same as send (for
|
||||
* connected socket types)
|
||||
*/
|
||||
|
||||
if (!to || !tolen)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
return send(sockfd, buf, len, flags);
|
||||
#else
|
||||
err = EINVAL;
|
||||
goto errout;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Verify that a valid address has been provided */
|
||||
@@ -257,7 +265,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||
* are ready.
|
||||
*/
|
||||
|
||||
save = irqsave();
|
||||
save = irqsave();
|
||||
memset(&state, 0, sizeof(struct sendto_s));
|
||||
sem_init(&state.st_sem, 0, 0);
|
||||
state.st_buflen = len;
|
||||
@@ -275,7 +283,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
||||
udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
||||
udp_conn->private = (void*)&state;
|
||||
udp_conn->event = sendto_interrupt;
|
||||
|
||||
@@ -283,6 +291,10 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||
|
||||
uip_udpenable(psock->s_conn);
|
||||
|
||||
/* Notify the device driver of the availabilty of TX data */
|
||||
|
||||
netdev_txnotify(&udp_conn->ripaddr);
|
||||
|
||||
/* Wait for either the receive to complete or for an error/timeout 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
|
||||
|
||||
67
net/socket.c
67
net/socket.c
@@ -43,6 +43,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
@@ -106,10 +107,12 @@ int socket(int domain, int type, int protocol)
|
||||
|
||||
/* Only SOCK_STREAM and possible SOCK_DRAM are supported */
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP)
|
||||
if (protocol != 0 || (type != SOCK_STREAM && type != SOCK_DGRAM))
|
||||
#else
|
||||
#elif defined(CONFIG_NET_TCP)
|
||||
if (protocol != 0 || type != SOCK_STREAM)
|
||||
#elif defined(CONFIG_NET_UDP)
|
||||
if (protocol != 0 || type != SOCK_DGRAM)
|
||||
#endif
|
||||
{
|
||||
err = EPROTONOSUPPORT;
|
||||
@@ -128,43 +131,49 @@ int socket(int domain, int type, int protocol)
|
||||
/* Initialize the socket structure */
|
||||
|
||||
psock = sockfd_socket(sockfd);
|
||||
if (psock)
|
||||
if (!psock)
|
||||
{
|
||||
/* Save the protocol type */
|
||||
err = ENOSYS; /* should not happen */
|
||||
goto errout;
|
||||
}
|
||||
|
||||
psock->s_type = type;
|
||||
psock->s_conn = NULL;
|
||||
/* Save the protocol type */
|
||||
|
||||
/* Allocate the appropriate connection structure. This reserves the
|
||||
* the connection structure is is unallocated at this point. It will
|
||||
* not actually be initialized until the socket is connected.
|
||||
*/
|
||||
psock->s_type = type;
|
||||
psock->s_conn = NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SOCK_STREAM:
|
||||
psock->s_conn = uip_tcpalloc();
|
||||
break;
|
||||
/* Allocate the appropriate connection structure. This reserves the
|
||||
* the connection structure is is unallocated at this point. It will
|
||||
* not actually be initialized until the socket is connected.
|
||||
*/
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case SOCK_STREAM:
|
||||
psock->s_conn = uip_tcpalloc();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
case SOCK_DGRAM:
|
||||
psock->s_conn = uip_udpalloc();
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
psock->s_conn = uip_udpalloc();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Did we succesfully allocate some kind of connection structure? */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!psock->s_conn)
|
||||
{
|
||||
/* Failed to reserve a connection structure */
|
||||
/* Did we succesfully allocate some kind of connection structure? */
|
||||
|
||||
sockfd_release(sockfd);
|
||||
err = ENFILE;
|
||||
goto errout;
|
||||
}
|
||||
if (!psock->s_conn)
|
||||
{
|
||||
/* Failed to reserve a connection structure */
|
||||
|
||||
sockfd_release(sockfd);
|
||||
err = ENFILE;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
return sockfd;
|
||||
|
||||
@@ -38,10 +38,10 @@ UIP_CSRCS =
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
|
||||
# Common network source files
|
||||
# Common IP source files
|
||||
|
||||
UIP_CSRCS += uip-initialize.c uip-setipid.c uip-arp.c uip-input.c uip-send.c \
|
||||
uip-fw.c uip-split.c uip-poll.c uip-chksum.c
|
||||
uip-poll.c uip-chksum.c
|
||||
|
||||
ifeq ($(CONFIG_NET_IPv6),y)
|
||||
UIP_CSRCS += uip-neighbor.c
|
||||
@@ -49,10 +49,19 @@ endif
|
||||
|
||||
# TCP source files
|
||||
|
||||
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
|
||||
|
||||
# Follow can be used to add support for the "uipsplit uIP TCP throughput booster hack"
|
||||
# but are not currently used
|
||||
|
||||
UIP_CSRCS += uip-fw.c uip-split.c
|
||||
|
||||
endif
|
||||
|
||||
# UDP source files
|
||||
|
||||
ifeq ($(CONFIG_NET_UDP),y)
|
||||
@@ -64,8 +73,11 @@ endif
|
||||
|
||||
#ICMP source files
|
||||
|
||||
ifeq ($(CONFIG_NET_ICMP),y)
|
||||
|
||||
UIP_CSRCS += uip-icmpinput.c
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@@ -364,8 +364,8 @@ void uip_arp_arpin(struct uip_driver_s *dev)
|
||||
uiphdr_ipaddr_copy(ARPBUF->ah_sipaddr, &dev->d_ipaddr);
|
||||
uip_arp_dump(ARPBUF);
|
||||
|
||||
ETHBUF->type = HTONS(UIP_ETHTYPE_ARP);
|
||||
dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN;
|
||||
ETHBUF->type = HTONS(UIP_ETHTYPE_ARP);
|
||||
dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -482,8 +482,6 @@ void uip_arp_out(struct uip_driver_s *dev)
|
||||
uip_arp_dump(ARPBUF);
|
||||
|
||||
ETHBUF->type = HTONS(UIP_ETHTYPE_ARP);
|
||||
|
||||
dev->d_appdata = &dev->d_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
||||
dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
||||
@@ -56,10 +56,7 @@
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
#if UIP_URGDATA > 0
|
||||
void *uip_urgdata; /* urgent data (out-of-band data), if present. */
|
||||
uint16 uip_urglen; /* Length of (received) urgent data */
|
||||
#endif
|
||||
/* IP/TCP/UDP/ICMP statistics for all network interfaces */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct uip_stats uip_stat;
|
||||
@@ -69,16 +66,16 @@ struct uip_stats uip_stat;
|
||||
|
||||
uint16 g_ipid;
|
||||
|
||||
const uip_ipaddr_t all_ones_addr =
|
||||
const uip_ipaddr_t g_alloneaddr =
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
{0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
{0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
|
||||
#else
|
||||
{0xffffffff};
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
#endif
|
||||
|
||||
const uip_ipaddr_t all_zeroes_addr =
|
||||
const uip_ipaddr_t g_allzeroaddr =
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
|
||||
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
|
||||
#else
|
||||
{0x00000000};
|
||||
#endif
|
||||
@@ -119,6 +116,7 @@ void uip_initialize(void)
|
||||
{
|
||||
/* Initialize the listening port structures */
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
uip_listeninit();
|
||||
|
||||
/* Initialize the TCP/IP connection structures */
|
||||
@@ -130,14 +128,13 @@ void uip_initialize(void)
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
uip_tcpreadaheadinit();
|
||||
#endif
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
/* Initialize the UDP connection structures */
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
uip_udpinit();
|
||||
#endif
|
||||
|
||||
/* IPv4 initialization. */
|
||||
}
|
||||
#endif /* CONFIG_NET */
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
|
||||
#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||
#define FBUF ((struct uip_ip_hdr *)&uip_reassbuf[0])
|
||||
|
||||
/* IP fragment re-assembly */
|
||||
|
||||
@@ -294,9 +294,6 @@ nullreturn:
|
||||
|
||||
void uip_input(struct uip_driver_s *dev)
|
||||
{
|
||||
dev->d_snddata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
dev->d_appdata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
|
||||
/* This is where the input processing starts. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
@@ -385,7 +382,7 @@ void uip_input(struct uip_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
if (uip_ipaddr_cmp(dev->d_ipaddr, all_zeroes_addr))
|
||||
if (uip_ipaddr_cmp(dev->d_ipaddr, g_allzeroaddr))
|
||||
{
|
||||
/* If we are configured to use ping IP address configuration and
|
||||
* hasn't been assigned an IP address yet, we accept all ICMP
|
||||
@@ -413,7 +410,7 @@ void uip_input(struct uip_driver_s *dev)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_BROADCAST
|
||||
if (BUF->proto == UIP_PROTO_UDP && uip_ipaddr_cmp(BUF->destipaddr, all_ones_addr)
|
||||
if (BUF->proto == UIP_PROTO_UDP && uip_ipaddr_cmp(BUF->destipaddr, g_alloneaddr)
|
||||
{
|
||||
uip_udpinput(dev);
|
||||
return;
|
||||
@@ -468,9 +465,11 @@ void uip_input(struct uip_driver_s *dev)
|
||||
|
||||
switch (BUF->proto)
|
||||
{
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case UIP_PROTO_TCP: /* TCP input */
|
||||
uip_tcpinput(dev);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
case UIP_PROTO_UDP: /* UDP input */
|
||||
@@ -480,6 +479,7 @@ void uip_input(struct uip_driver_s *dev)
|
||||
|
||||
/* Check for ICMP input */
|
||||
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
#ifndef CONFIG_NET_IPv6
|
||||
case UIP_PROTO_ICMP: /* ICMP input */
|
||||
#else
|
||||
@@ -487,6 +487,7 @@ void uip_input(struct uip_driver_s *dev)
|
||||
#endif
|
||||
uip_icmpinput(dev);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: /* Unrecognized/unsupported protocol */
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern const uip_ipaddr_t all_ones_addr;
|
||||
extern const uip_ipaddr_t all_zeroes_addr;
|
||||
extern const uip_ipaddr_t g_alloneaddr;
|
||||
extern const uip_ipaddr_t g_allzeroaddr;
|
||||
|
||||
/* Increasing number used for the IP ID field. */
|
||||
|
||||
@@ -118,6 +118,7 @@ extern "C" {
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
/* Defined in uip_tcpconn.c *************************************************/
|
||||
|
||||
EXTERN void uip_tcpinit(void);
|
||||
@@ -165,6 +166,16 @@ EXTERN void uip_tcpinput(struct uip_driver_s *dev);
|
||||
EXTERN uint8 uip_tcpcallback(struct uip_driver_s *dev,
|
||||
struct uip_conn *conn, uint8 flags);
|
||||
|
||||
/* Defined in uip-tcpreadahead.c ********************************************/
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
EXTERN void uip_tcpreadaheadinit(void);
|
||||
EXTERN struct uip_readahead_s *uip_tcpreadaheadalloc(void);
|
||||
EXTERN void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */
|
||||
|
||||
#endif /* CONFIG_NET_TCP */
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
/* Defined in uip_udpconn.c *************************************************/
|
||||
|
||||
@@ -190,17 +201,11 @@ EXTERN void uip_udpcallback(struct uip_driver_s *dev,
|
||||
struct uip_udp_conn *conn, uint8 flags);
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
/* Defined in uip-icmpinput.c ***********************************************/
|
||||
|
||||
EXTERN void uip_icmpinput(struct uip_driver_s *dev);
|
||||
|
||||
/* Defined in uip-tcpreadahead.c ********************************************/
|
||||
|
||||
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
EXTERN void uip_tcpreadaheadinit(void);
|
||||
EXTERN struct uip_readahead_s *uip_tcpreadaheadalloc(void);
|
||||
EXTERN void uip_tcpreadaheadrelease(struct uip_readahead_s *buf);
|
||||
#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */
|
||||
#endif /* CONFIG_NET_ICMP */
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
/* The uip_listenports list all currently listening ports. */
|
||||
|
||||
static uint16 uip_listenports[CONFIG_NET_MAX_LISTENPORTS];
|
||||
static struct uip_conn *uip_listenports[CONFIG_NET_MAX_LISTENPORTS];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -84,7 +84,7 @@ void uip_listeninit(void)
|
||||
int ndx;
|
||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||
{
|
||||
uip_listenports[ndx] = 0;
|
||||
uip_listenports[ndx] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ void uip_listeninit(void)
|
||||
* Function: uip_unlisten
|
||||
*
|
||||
* Description:
|
||||
* Stop listening on a port
|
||||
* Stop listening to the port bound to the specified TCP connection
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from normal user code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int uip_unlisten(uint16 port)
|
||||
int uip_unlisten(struct uip_conn *conn)
|
||||
{
|
||||
irqstate_t flags;
|
||||
int ndx;
|
||||
@@ -108,13 +108,14 @@ int uip_unlisten(uint16 port)
|
||||
flags = irqsave();
|
||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||
{
|
||||
if (uip_listenports[ndx] == port)
|
||||
if (uip_listenports[ndx] == conn)
|
||||
{
|
||||
uip_listenports[ndx] = 0;
|
||||
uip_listenports[ndx] = NULL;
|
||||
ret = OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
return ret;
|
||||
}
|
||||
@@ -123,29 +124,58 @@ int uip_unlisten(uint16 port)
|
||||
* Function: uip_listen
|
||||
*
|
||||
* Description:
|
||||
* Start listening on a port
|
||||
* Start listening to the port bound to the specified TCP connection
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from normal user code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int uip_listen(uint16 port)
|
||||
int uip_listen(struct uip_conn *conn)
|
||||
{
|
||||
irqstate_t flags;
|
||||
int ndx;
|
||||
int ret = -ENOBUFS;
|
||||
int ret;
|
||||
|
||||
/* This must be done with interrupts disabled because the listener table
|
||||
* is accessed from interrupt level as well.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||
|
||||
/* First, check if there is already a socket listening on this port */
|
||||
|
||||
if (uip_islistener(conn->lport))
|
||||
{
|
||||
if (uip_listenports[ndx] == 0)
|
||||
/* Yes, then we must refuse this request */
|
||||
|
||||
ret = -EADDRINUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, save a reference to the connection structure in the
|
||||
* "listener" list.
|
||||
*/
|
||||
|
||||
ret = -ENOBUFS; /* Assume failure */
|
||||
|
||||
/* Search all slots until an available slot is found */
|
||||
|
||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||
{
|
||||
uip_listenports[ndx] = port;
|
||||
ret = OK;
|
||||
break;
|
||||
/* Is the next slot available? */
|
||||
|
||||
if (!uip_listenports[ndx])
|
||||
{
|
||||
/* Yes.. we found it */
|
||||
|
||||
uip_listenports[ndx] = conn;
|
||||
ret = OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
return ret;
|
||||
}
|
||||
@@ -164,13 +194,26 @@ int uip_listen(uint16 port)
|
||||
boolean uip_islistener(uint16 portno)
|
||||
{
|
||||
int ndx;
|
||||
|
||||
/* Examine each connection structure in each slot of the listener list */
|
||||
|
||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||
{
|
||||
if (uip_listenports[ndx] == portno)
|
||||
/* Is this slot assigned? If so, does the connection have the same
|
||||
* local port number?
|
||||
*/
|
||||
|
||||
struct uip_conn *conn = uip_listenports[ndx];
|
||||
if (conn && conn->lport == portno)
|
||||
{
|
||||
/* Yes.. we found a listener on this port */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* No listener for this port */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ static int uip_polludpconnections(struct uip_driver_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline int uip_polltcpconnections(struct uip_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
@@ -129,6 +130,9 @@ static inline int uip_polltcpconnections(struct uip_driver_s *dev,
|
||||
|
||||
return bstop;
|
||||
}
|
||||
#else
|
||||
# define uip_polltcpconnections(dev, callback) (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_polltcptimer
|
||||
@@ -143,6 +147,7 @@ static inline int uip_polltcpconnections(struct uip_driver_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline int uip_polltcptimer(struct uip_driver_s *dev,
|
||||
uip_poll_callback_t callback, int hsec)
|
||||
{
|
||||
@@ -164,6 +169,9 @@ static inline int uip_polltcptimer(struct uip_driver_s *dev,
|
||||
|
||||
return bstop;
|
||||
}
|
||||
#else
|
||||
# define uip_polltcptimer(dev, callback, hsec) (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -93,9 +93,13 @@
|
||||
|
||||
void uip_send(struct uip_driver_s *dev, const void *buf, int len)
|
||||
{
|
||||
/* Some sanity checks -- note that the actually available length in the
|
||||
* buffer is considerably less than CONFIG_NET_BUFSIZE.
|
||||
*/
|
||||
|
||||
if (dev && len > 0 && len < CONFIG_NET_BUFSIZE)
|
||||
{
|
||||
memcpy(dev->d_snddata, buf, len);
|
||||
dev->d_sndlen = len;
|
||||
memcpy(dev->d_snddata, buf, len );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
@@ -235,4 +235,4 @@ void uip_tcprexmit(struct uip_driver_s *dev, struct uip_conn *conn, uint8 result
|
||||
dev->d_len = 0;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
@@ -210,4 +210,4 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 fla
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
@@ -304,7 +304,7 @@ void uip_tcpfree(struct uip_conn *conn)
|
||||
{
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
dq_rem(&conn->node, &g_free_tcp_connections);
|
||||
dq_rem(&conn->node, &g_active_tcp_connections);
|
||||
}
|
||||
|
||||
/* Release any read-ahead buffers attached to the connection */
|
||||
@@ -545,10 +545,13 @@ int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in *addr)
|
||||
*/
|
||||
|
||||
conn->lport = addr->sin_port;
|
||||
|
||||
#if 0 /* Not used */
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
uip_ipaddr_copy(conn->lipaddr, addr->sin6_addr.in6_u.u6_addr16);
|
||||
#else
|
||||
uip_ipaddr_copy(conn->lipaddr, addr->sin_addr.s_addr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
@@ -652,4 +655,4 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
@@ -103,6 +103,9 @@ void uip_tcpinput(struct uip_driver_s *dev)
|
||||
int len;
|
||||
int i;
|
||||
|
||||
dev->d_snddata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
dev->d_appdata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
uip_stat.tcp.recv++;
|
||||
#endif
|
||||
@@ -547,32 +550,34 @@ found:
|
||||
}
|
||||
|
||||
/* Check the URG flag. If this is set, the segment carries urgent
|
||||
data that we must pass to the application. */
|
||||
* data that we must pass to the application.
|
||||
*/
|
||||
|
||||
if ((BUF->flags & TCP_URG) != 0)
|
||||
{
|
||||
#if UIP_URGDATA > 0
|
||||
uip_urglen = (BUF->urgp[0] << 8) | BUF->urgp[1];
|
||||
if (uip_urglen > dev->d_len)
|
||||
#ifdef CONFIG_NET_TCPURGDATA
|
||||
dev->d_urglen = (BUF->urgp[0] << 8) | BUF->urgp[1];
|
||||
if (dev->d_urglen > dev->d_len)
|
||||
{
|
||||
/* There is more urgent data in the next segment to come. */
|
||||
|
||||
uip_urglen = dev->d_len;
|
||||
dev->d_urglen = dev->d_len;
|
||||
}
|
||||
|
||||
uip_incr32(conn->rcv_nxt, uip_urglen);
|
||||
dev->d_len -= uip_urglen;
|
||||
uip_urgdata = dev->d_appdata;
|
||||
dev->d_appdata += uip_urglen;
|
||||
uip_incr32(conn->rcv_nxt, dev->d_urglen);
|
||||
dev->d_len -= dev->d_urglen;
|
||||
dev->d_urgdata = dev->d_appdata;
|
||||
dev->d_appdata += dev->d_urglen;
|
||||
}
|
||||
else
|
||||
{
|
||||
uip_urglen = 0;
|
||||
#else /* UIP_URGDATA > 0 */
|
||||
dev->d_urglen = 0;
|
||||
#else /* CONFIG_NET_TCPURGDATA */
|
||||
dev->d_appdata =
|
||||
((uint8*)dev->d_appdata) + ((BUF->urgp[0] << 8) | BUF->urgp[1]);
|
||||
dev->d_len -=
|
||||
(BUF->urgp[0] << 8) | BUF->urgp[1];
|
||||
#endif /* UIP_URGDATA > 0 */
|
||||
#endif /* CONFIG_NET_TCPURGDATA */
|
||||
}
|
||||
|
||||
/* If d_len > 0 we have TCP data in the packet, and we flag this
|
||||
@@ -739,4 +744,4 @@ drop:
|
||||
dev->d_len = 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
@@ -127,4 +127,4 @@ void uip_tcppoll(struct uip_driver_s *dev, struct uip_conn *conn)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <net/uip/uipopt.h>
|
||||
#if defined(CONFIG_NET) && (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0)
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) && (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <queue.h>
|
||||
@@ -129,4 +129,4 @@ void uip_tcpreadaheadrelease(struct uip_readahead_s *buf)
|
||||
sq_addfirst(&buf->rh_node, &g_freebuffers);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_NTCP_READAHEAD_BUFFERS*/
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_NTCP_READAHEAD_BUFFERS*/
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
@@ -362,4 +362,4 @@ void uip_tcpack(struct uip_driver_s *dev, struct uip_conn *conn, uint8 ack)
|
||||
uip_tcpsendcommon(dev, conn);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
@@ -247,4 +247,4 @@ done:
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* uip-udpconn.c
|
||||
* net/uip/uip-udpconn.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -52,6 +52,8 @@
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include <net/uip/uipopt.h>
|
||||
@@ -118,7 +120,7 @@ static inline void _uip_semtake(sem_t *sem)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct uip_udp_conn *uip_find_conn( uint16 portno )
|
||||
static struct uip_udp_conn *uip_find_conn(uint16 portno)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -234,6 +236,7 @@ void uip_udpfree(struct uip_udp_conn *conn)
|
||||
struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf)
|
||||
{
|
||||
struct uip_udp_conn *conn = (struct uip_udp_conn *)g_active_udp_connections.head;
|
||||
|
||||
while (conn)
|
||||
{
|
||||
/* If the local UDP port is non-zero, the connection is considered
|
||||
@@ -247,12 +250,11 @@ struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf)
|
||||
|
||||
if (conn->lport != 0 && buf->destport == conn->lport &&
|
||||
(conn->rport == 0 || buf->srcport == conn->rport) &&
|
||||
(uip_ipaddr_cmp(conn->ripaddr, all_zeroes_addr) ||
|
||||
uip_ipaddr_cmp(conn->ripaddr, all_ones_addr) ||
|
||||
(uip_ipaddr_cmp(conn->ripaddr, g_allzeroaddr) ||
|
||||
uip_ipaddr_cmp(conn->ripaddr, g_alloneaddr) ||
|
||||
uiphdr_ipaddr_cmp(buf->srcipaddr, &conn->ripaddr)))
|
||||
{
|
||||
/* Matching connection found.. return a reference to it */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf)
|
||||
conn = (struct uip_udp_conn *)conn->node.flink;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return conn;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -307,13 +309,29 @@ int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in *addr)
|
||||
#endif
|
||||
{
|
||||
int ret = -EADDRINUSE;
|
||||
irqstate_t flags = irqsave();
|
||||
if (!uip_find_conn(g_last_udp_port))
|
||||
irqstate_t flags;
|
||||
|
||||
/* Never set lport to zero! */
|
||||
|
||||
if (addr->sin_port)
|
||||
{
|
||||
conn->lport = HTONS(g_last_udp_port);
|
||||
ret = OK;
|
||||
/* Interrupts must be disabled while access the UDP connection list */
|
||||
|
||||
flags = irqsave();
|
||||
|
||||
/* Is any other UDP connection bound to this port? */
|
||||
|
||||
if (!uip_find_conn(addr->sin_port))
|
||||
{
|
||||
/* No.. then bind the socket to the port */
|
||||
|
||||
conn->lport = addr->sin_port;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
irqrestore(flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -367,7 +385,7 @@ int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr)
|
||||
g_last_udp_port = 4096;
|
||||
}
|
||||
}
|
||||
while (uip_find_conn(g_last_udp_port));
|
||||
while (uip_find_conn(htons(g_last_udp_port)));
|
||||
|
||||
/* Initialize and return the connection structure, bind it to the
|
||||
* port number
|
||||
@@ -385,7 +403,7 @@ int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr)
|
||||
else
|
||||
{
|
||||
conn->rport = 0;
|
||||
uip_ipaddr_copy(conn->ripaddr, all_zeroes_addr);
|
||||
uip_ipaddr_copy(conn->ripaddr, g_allzeroaddr);
|
||||
}
|
||||
|
||||
conn->ttl = UIP_TTL;
|
||||
@@ -406,7 +424,7 @@ int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr)
|
||||
void uip_udpenable(struct uip_udp_conn *conn)
|
||||
{
|
||||
/* Add the connection structure to the active connectionlist. This list
|
||||
* is modifiable from interrupt level, we we must diable interrupts to
|
||||
* is modifiable from interrupt level, we we must disable interrupts to
|
||||
* access it safely.
|
||||
*/
|
||||
|
||||
@@ -417,8 +435,8 @@ void uip_udpenable(struct uip_udp_conn *conn)
|
||||
|
||||
void uip_udpdisable(struct uip_udp_conn *conn)
|
||||
{
|
||||
/* Remove the connection structure to the active connectionlist. This list
|
||||
* is modifiable from interrupt level, we we must diable interrupts to
|
||||
/* Remove the connection structure from the active connectionlist. This list
|
||||
* is modifiable from interrupt level, we we must disable interrupts to
|
||||
* access it safely.
|
||||
*/
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
|
||||
{
|
||||
if (dev->d_sndlen == 0)
|
||||
if (dev->d_sndlen > 0)
|
||||
{
|
||||
/* The total lenth to send is the size of the application data plus
|
||||
* the IP and UDP headers (and, eventually, the ethernet header)
|
||||
@@ -131,8 +131,8 @@ void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
|
||||
UDPBUF->ipid[1] = g_ipid & 0xff;
|
||||
UDPBUF->ipoffset[0] = 0;
|
||||
UDPBUF->ipoffset[1] = 0;
|
||||
UDPBUF->ttl = conn->ttl;
|
||||
UDPBUF->proto = UIP_PROTO_UDP;
|
||||
UDPBUF->ttl = conn->ttl;
|
||||
UDPBUF->proto = UIP_PROTO_UDP;
|
||||
|
||||
/* Calculate IP checksum. */
|
||||
|
||||
@@ -146,20 +146,21 @@ void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
|
||||
|
||||
/* Initialize the UDP header */
|
||||
|
||||
UDPBUF->srcport = conn->lport;
|
||||
UDPBUF->destport = conn->rport;
|
||||
UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
|
||||
UDPBUF->srcport = conn->lport;
|
||||
UDPBUF->destport = conn->rport;
|
||||
UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
|
||||
|
||||
#ifdef CONFIG_NET_UDP_CHECKSUMS
|
||||
/* Calculate UDP checksum. */
|
||||
|
||||
UDPBUF->udpchksum = ~(uip_udpchksum(dev));
|
||||
UDPBUF->udpchksum = 0;
|
||||
UDPBUF->udpchksum = ~(uip_udpchksum(dev));
|
||||
if (UDPBUF->udpchksum == 0)
|
||||
{
|
||||
UDPBUF->udpchksum = 0xffff;
|
||||
}
|
||||
#else
|
||||
UDPBUF->udpchksum = 0;
|
||||
UDPBUF->udpchksum = 0;
|
||||
#endif
|
||||
|
||||
vdbg("Outgoing UDP packet length: %d (%d)\n",
|
||||
|
||||
@@ -39,15 +39,16 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
include uiplib/Make.defs
|
||||
ifeq ($(CONFIG_NET_TCP),y)
|
||||
include smtp/Make.defs
|
||||
include telnetd/Make.defs
|
||||
include webclient/Make.defs
|
||||
include webserver/Make.defs
|
||||
endif
|
||||
ifeq ($(CONFIG_NET_UDP),y)
|
||||
include dhcpc/Make.defs
|
||||
include resolv/Make.defs
|
||||
endif
|
||||
include Make.str
|
||||
endif
|
||||
|
||||
ASRCS = $(UIPLIB_ASRCS) $(DHCPC_ASRCS) $(RESOLV_ASRCS) $(SMTP_ASRCS) \
|
||||
@@ -79,16 +80,6 @@ $(BIN): $(OBJS)
|
||||
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
|
||||
done ; )
|
||||
|
||||
makestrings$(EXEEXT): uiplib/makestrings.c
|
||||
@gcc -O2 -Wall $< -o $@
|
||||
|
||||
.strings: makestrings$(EXEEXT) uiplib/netutil-strings
|
||||
@./makestrings uiplib/netutil-strings
|
||||
@touch $@
|
||||
|
||||
Make.str: makestrings$(EXEEXT) uiplib/netutil-strings
|
||||
@./makestrings -s uiplib/netutil-strings >Make.str
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
@$(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path smtp --dep-path webclient \
|
||||
@@ -97,7 +88,7 @@ ifeq ($(CONFIG_NET),y)
|
||||
endif
|
||||
@touch $@
|
||||
|
||||
depend: .strings Make.str .depend
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
|
||||
@@ -107,6 +98,5 @@ clean:
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
@rm -f $(STRNG_CSRCS) $(STRNG_ASRCS)
|
||||
@rm -f rm .strings Make.str netutil-strings.h makestrings$(EXEEXT)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
@@ -57,7 +57,9 @@
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/smtp.h>
|
||||
|
||||
#include "netutil-strings.h"
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define SMTP_INPUT_BUFFER_SIZE 512
|
||||
|
||||
@@ -71,6 +73,10 @@
|
||||
#define ISO_4 0x34
|
||||
#define ISO_5 0x35
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure represents the state of a single SMTP transaction */
|
||||
|
||||
struct smtp_state
|
||||
@@ -92,6 +98,25 @@ struct smtp_state
|
||||
char buffer[SMTP_INPUT_BUFFER_SIZE];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char g_smtp220[] = "220";
|
||||
static const char g_smtpcrnlperiodcrnl[] = "\r\n.\r\n";
|
||||
static const char g_smtpdata[] = "DATA\r\n";
|
||||
static const char g_smtpfrom[] = "From: ";
|
||||
static const char g_smtphelo[] = "HELO ";
|
||||
static const char g_smtpmailfrom[] = "MAIL FROM: ";
|
||||
static const char g_smtpquit[] = "QUIT\r\n";
|
||||
static const char g_smtprcptto[] = "RCPT TO: ";
|
||||
static const char g_smtpsubject[] = "Subject: ";
|
||||
static const char g_smtpto[] = "To: ";
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
{
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
@@ -99,12 +124,12 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (strncmp(psmtp->buffer, smtp_220, 3) != 0)
|
||||
if (strncmp(psmtp->buffer, g_smtp220, strlen(g_smtp220)) != 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_helo, psmtp->localhostname);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtphelo, psmtp->localhostname);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -120,7 +145,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_mail_from, psmtp->from);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtpmailfrom, psmtp->from);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -136,7 +161,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_rcpt_to, psmtp->to);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtprcptto, psmtp->to);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -154,7 +179,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
|
||||
if (psmtp->cc != 0)
|
||||
{
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_rcpt_to, psmtp->cc);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtprcptto, psmtp->cc);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -171,7 +196,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
}
|
||||
}
|
||||
|
||||
if (send(sockfd, smtp_data, strlen(smtp_data), 0) < 0)
|
||||
if (send(sockfd, g_smtpdata, strlen(g_smtpdata), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
@@ -186,7 +211,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_to, psmtp->to);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtpto, psmtp->to);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -194,20 +219,20 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
|
||||
if (psmtp->cc != 0)
|
||||
{
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_to, psmtp->cc);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtpto, psmtp->cc);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_from, psmtp->from);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtpfrom, psmtp->from);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", smtp_subject, psmtp->subject);
|
||||
snprintf(psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, "%s%s\r\n", g_smtpsubject, psmtp->subject);
|
||||
if (send(sockfd, psmtp->buffer, strlen(psmtp->buffer), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
@@ -218,7 +243,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (send(sockfd, smtp_crnlperiodcrnl, strlen(smtp_crnlperiodcrnl), 0) < 0)
|
||||
if (send(sockfd, g_smtpcrnlperiodcrnl, strlen(g_smtpcrnlperiodcrnl), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
@@ -233,13 +258,17 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (send(sockfd, smtp_quit, strlen(smtp_quit), 0) < 0)
|
||||
if (send(sockfd, g_smtpquit, strlen(g_smtpquit), 0) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Specificy an SMTP server and hostname.
|
||||
*
|
||||
* This function is used to configure the SMTP module with an SMTP server and
|
||||
|
||||
@@ -1,379 +0,0 @@
|
||||
/****************************************************************************
|
||||
* net/recv.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based loosely on a uIP perl script by Adam Dunkels
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
enum eaction { GENSRC=0, SRCLIST=1 };
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char *g_progname;
|
||||
static const char *g_stringfile;
|
||||
static enum eaction g_action;
|
||||
|
||||
static char g_line[1024];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: parse_stringfile_line
|
||||
****************************************************************************/
|
||||
|
||||
void unescape_value(char *pvalue)
|
||||
{
|
||||
const char *pin;
|
||||
char *pout;
|
||||
|
||||
pin = pvalue;
|
||||
pout = pvalue;
|
||||
while (*pin)
|
||||
{
|
||||
if (*pin == '\\')
|
||||
{
|
||||
pin++;
|
||||
if ( *pin >= 0 && *pin <= 0)
|
||||
{
|
||||
char *pend;
|
||||
unsigned long val = strtoul(pin, &pend, 0);
|
||||
if (pend != pin)
|
||||
{
|
||||
*pout++ = (char)val;
|
||||
pin = pend;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pout++ = '\\';
|
||||
*pout++ = *pin++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (*pin)
|
||||
{
|
||||
case 'a':
|
||||
*pout++ = 0x07;
|
||||
break;
|
||||
case 'b':
|
||||
*pout++ = 0x08;
|
||||
break;
|
||||
case 't':
|
||||
*pout++ = 0x09;
|
||||
break;
|
||||
case 'n':
|
||||
*pout++ = 0x0a;
|
||||
break;
|
||||
case 'v':
|
||||
*pout++ = 0x0b;
|
||||
case 'f':
|
||||
*pout++ = 0x0c;
|
||||
break;
|
||||
case 'r':
|
||||
*pout++ = 0x0d;
|
||||
break;
|
||||
default:
|
||||
*pout++ = *pin;
|
||||
break;
|
||||
}
|
||||
pin++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*pout++ = *pin++;
|
||||
}
|
||||
}
|
||||
*pout = '\0';
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: parse_stringfile_line
|
||||
****************************************************************************/
|
||||
|
||||
int parse_stringfile_line(const char **ppname, const char **ppvalue)
|
||||
{
|
||||
char *ptmp;
|
||||
char *pname;
|
||||
char *pvalue;
|
||||
|
||||
pname = g_line;
|
||||
ptmp = strchr(g_line, ' ');
|
||||
if (ptmp)
|
||||
{
|
||||
*ptmp++ = '\0';
|
||||
pvalue = strchr(ptmp, '"');
|
||||
if (pvalue)
|
||||
{
|
||||
pvalue++;
|
||||
ptmp = strchr(pvalue, '"');
|
||||
if (ptmp)
|
||||
{
|
||||
*ptmp = '\0';
|
||||
unescape_value(pvalue);
|
||||
if (ppname)
|
||||
{
|
||||
*ppname = pname;
|
||||
}
|
||||
if (ppvalue)
|
||||
{
|
||||
*ppvalue = pvalue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: open_stringfile
|
||||
****************************************************************************/
|
||||
|
||||
FILE *open_stringfile(void)
|
||||
{
|
||||
FILE *stream = fopen(g_stringfile, "r");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for reading: %s\n", g_stringfile, strerror(errno));
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: open_outfile
|
||||
****************************************************************************/
|
||||
|
||||
FILE *open_outfile(const char *filename)
|
||||
{
|
||||
FILE *stream = fopen(filename, "w");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for writing: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: generate_mkdefs
|
||||
****************************************************************************/
|
||||
|
||||
int generate_mkdefs(void)
|
||||
{
|
||||
int ret = 1;
|
||||
FILE *stream;
|
||||
|
||||
if (( stream = open_stringfile()))
|
||||
{
|
||||
printf("STRNG_ASRCS =\n");
|
||||
printf("STRNG_CSRCS = ");
|
||||
ret = 0;
|
||||
while (fgets(g_line, 1024, stream) && !ret)
|
||||
{
|
||||
const char *pname;
|
||||
ret = parse_stringfile_line(&pname, NULL);
|
||||
if (!ret)
|
||||
{
|
||||
printf("%s.c ", pname);
|
||||
}
|
||||
}
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: generate_sourcefiles
|
||||
****************************************************************************/
|
||||
|
||||
int generate_sourcefiles(void)
|
||||
{
|
||||
FILE *instream;
|
||||
FILE *hstream;
|
||||
FILE *cstream;
|
||||
const char *pname;
|
||||
const char *pvalue;
|
||||
char *filename;
|
||||
char buffer[512];
|
||||
int len;
|
||||
int ndx;
|
||||
int ret = 1;
|
||||
|
||||
filename = strdup(g_stringfile);
|
||||
if (( instream = open_stringfile()))
|
||||
{
|
||||
snprintf(buffer, 512, "%s.h", basename(filename));
|
||||
hstream = open_outfile(buffer);
|
||||
if (hstream)
|
||||
{
|
||||
fprintf(hstream, "#ifndef __NETUTIL_STRINGS\n#define __NETUTIL_STRINGS\n\n");
|
||||
|
||||
ret = 0;
|
||||
while (fgets(g_line, 1024, instream) && !ret)
|
||||
{
|
||||
ret = parse_stringfile_line(&pname, &pvalue);
|
||||
if (!ret)
|
||||
{
|
||||
len = strlen(pvalue);
|
||||
|
||||
snprintf(buffer, 512, "%s.c", pname);
|
||||
cstream = open_outfile(buffer);
|
||||
if (cstream)
|
||||
{
|
||||
fprintf(cstream, "const char %s[%d] = {", pname, len);
|
||||
for (ndx = 0; ndx < len; ndx++)
|
||||
{
|
||||
if (ndx > 0)
|
||||
{
|
||||
fprintf(cstream, ", ");
|
||||
}
|
||||
fprintf(cstream, "0x%02x", pvalue[ndx]);
|
||||
}
|
||||
fprintf(cstream, "};\n");
|
||||
fclose(cstream);
|
||||
}
|
||||
fprintf(hstream, "extern const char %s[%d];\n", pname, len);
|
||||
}
|
||||
}
|
||||
fprintf(hstream, "\n#endif /* __NETUTIL_STRINGS */\n");
|
||||
fclose(hstream);
|
||||
}
|
||||
fclose(instream);
|
||||
}
|
||||
free(filename);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void show_usage( void )
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [OPTIONS] <string-file>\n\n", g_progname );
|
||||
fprintf(stderr, "Where [OPTIONS] include:\n");
|
||||
fprintf(stderr, "\t-s: Output string source file list on stdout");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void parse_commandline( int argc, char **argv )
|
||||
{
|
||||
int option;
|
||||
g_progname = argv[0];
|
||||
while ((option = getopt(argc, argv, ":s")) >= 0)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 's':
|
||||
g_action = SRCLIST;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fprintf(stderr, "Missing command argument\n");
|
||||
show_usage();
|
||||
break;
|
||||
|
||||
case '?':
|
||||
option = optopt;
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized option: %c\n", option);
|
||||
show_usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
g_stringfile = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Missing <string-file> path\n");
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
fprintf(stderr, "Garbage on command line after <string-file>\n");
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
int ret = 0;
|
||||
parse_commandline(argc, argv);
|
||||
switch (g_action)
|
||||
{
|
||||
case GENSRC:
|
||||
ret = generate_sourcefiles();
|
||||
break;
|
||||
case SRCLIST:
|
||||
ret = generate_mkdefs();
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
http_10 "HTTP/1.0"
|
||||
http_11 "HTTP/1.1"
|
||||
http_200 "200 "
|
||||
http_301 "301 "
|
||||
http_302 "302 "
|
||||
http_404_html "/404.html"
|
||||
http_content_type "content-type: "
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_plain "Content-type: text/plain\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_crnl "\r\n"
|
||||
http_css ".css"
|
||||
http_get "GET "
|
||||
http_gif ".gif"
|
||||
http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
|
||||
http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
|
||||
http_host "host: "
|
||||
http_htm ".htm"
|
||||
http_html ".html"
|
||||
http_http "http://"
|
||||
http_index_html "/index.html"
|
||||
http_jpg ".jpg"
|
||||
http_location "location: "
|
||||
http_png ".png"
|
||||
http_referer "Referer:"
|
||||
http_shtml ".shtml"
|
||||
http_text ".text"
|
||||
http_texthtml "text/html"
|
||||
http_txt ".txt"
|
||||
http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n"
|
||||
smtp_220 "220"
|
||||
smtp_crnl "\r\n"
|
||||
smtp_crnlperiodcrnl "\r\n.\r\n"http_http "http://"
|
||||
smtp_data "DATA\r\n"
|
||||
smtp_from "From: "
|
||||
smtp_helo "HELO "
|
||||
smtp_mail_from "MAIL FROM: "
|
||||
smtp_quit "QUIT\r\n"
|
||||
smtp_rcpt_to "RCPT TO: "
|
||||
smtp_subject "Subject: "
|
||||
smtp_to "To: "
|
||||
@@ -61,6 +61,10 @@
|
||||
|
||||
#include "webclient.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WEBCLIENT_TIMEOUT 100
|
||||
|
||||
#define WEBCLIENT_STATE_STATUSLINE 0
|
||||
@@ -78,104 +82,52 @@
|
||||
#define ISO_cr 0x0d
|
||||
#define ISO_space 0x20
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static uint8 g_return; /* Kludge for now */
|
||||
|
||||
|
||||
static struct webclient_state s;
|
||||
|
||||
char *webclient_mimetype(void)
|
||||
{
|
||||
return s.mimetype;
|
||||
}
|
||||
static const char g_http10[] = "HTTP/1.0";
|
||||
static const char g_http11[] = "HTTP/1.1";
|
||||
static const char g_httpcontenttype[] = "content-type: ";
|
||||
static const char g_httphost[] = "host: ";
|
||||
static const char g_httplocation[] = "location: ";
|
||||
|
||||
char *webclient_filename(void)
|
||||
{
|
||||
return s.file;
|
||||
}
|
||||
static const char g_httpget[] = "GET ";
|
||||
static const char g_httphttp[] = "http://";
|
||||
|
||||
char *webclient_hostname(void)
|
||||
{
|
||||
return s.host;
|
||||
}
|
||||
static const char g_httpuseragentfields[] =
|
||||
"Connection: close\r\n"
|
||||
"User-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n";
|
||||
|
||||
unsigned shortwebclient_port(void)
|
||||
{
|
||||
return s.port;
|
||||
}
|
||||
static const char g_http200[] = "200 ";
|
||||
static const char g_http301[] = "301 ";
|
||||
static const char g_http302[] = "302 ";
|
||||
|
||||
void webclient_init(void)
|
||||
{
|
||||
}
|
||||
static const char g_httpcrnl[] = "\r\n";
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void init_connection(void)
|
||||
{
|
||||
s.state = WEBCLIENT_STATE_STATUSLINE;
|
||||
|
||||
s.getrequestleft = sizeof(http_get) - 1 + 1 +
|
||||
sizeof(http_10) - 1 +
|
||||
sizeof(http_crnl) - 1 +
|
||||
sizeof(http_host) - 1 +
|
||||
sizeof(http_crnl) - 1 +
|
||||
strlen(http_user_agent_fields) +
|
||||
s.getrequestleft = strlen(g_httpget) - 1 + 1 +
|
||||
strlen(g_http10) - 1 +
|
||||
strlen(g_httpcrnl) - 1 +
|
||||
strlen(g_httphost) - 1 +
|
||||
strlen(g_httpcrnl) - 1 +
|
||||
strlen(g_httpuseragentfields) +
|
||||
strlen(s.file) + strlen(s.host);
|
||||
s.getrequestptr = 0;
|
||||
|
||||
s.httpheaderlineptr = 0;
|
||||
}
|
||||
|
||||
void webclient_close(void)
|
||||
{
|
||||
s.state = WEBCLIENT_STATE_CLOSE;
|
||||
}
|
||||
|
||||
unsigned char webclient_get(const char *host, uint16 port, char *file)
|
||||
{
|
||||
uip_ipaddr_t *ipaddr;
|
||||
static uip_ipaddr_t addr;
|
||||
struct sockaddr_in server;
|
||||
int sockfd;
|
||||
|
||||
/* First check if the host is an IP address. */
|
||||
|
||||
ipaddr = &addr;
|
||||
if (uiplib_ipaddrconv(host, (unsigned char *)addr) == 0)
|
||||
{
|
||||
if (resolv_query(host, &ipaddr) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a socket */
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Connect to server. First we have to set some fields in the
|
||||
* 'server' structure. The system will assign me an arbitrary
|
||||
* local port that is not in use.
|
||||
*/
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
memcpy(&server.sin_addr.s_addr, &host, sizeof(in_addr_t));
|
||||
server.sin_port = htons(port);
|
||||
|
||||
if (connect(sockfd, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
s.port = port;
|
||||
strncpy(s.file, file, sizeof(s.file));
|
||||
strncpy(s.host, host, sizeof(s.host));
|
||||
|
||||
init_connection();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static char *copy_string(char *dest, const char *src, int len)
|
||||
{
|
||||
strncpy(dest, src, len);
|
||||
@@ -191,19 +143,19 @@ static void senddata(struct uip_driver_s *dev, struct uip_conn *conn)
|
||||
if (s.getrequestleft > 0) {
|
||||
cptr = getrequest = (char *)dev->d_appdata;
|
||||
|
||||
cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
|
||||
cptr = copy_string(cptr, g_httpget, strlen(g_httpget) - 1);
|
||||
cptr = copy_string(cptr, s.file, strlen(s.file));
|
||||
*cptr++ = ISO_space;
|
||||
cptr = copy_string(cptr, http_10, sizeof(http_10) - 1);
|
||||
cptr = copy_string(cptr, g_http10, strlen(g_http10) - 1);
|
||||
|
||||
cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
|
||||
cptr = copy_string(cptr, g_httpcrnl, strlen(g_httpcrnl) - 1);
|
||||
|
||||
cptr = copy_string(cptr, http_host, sizeof(http_host) - 1);
|
||||
cptr = copy_string(cptr, g_httphost, strlen(g_httphost) - 1);
|
||||
cptr = copy_string(cptr, s.host, strlen(s.host));
|
||||
cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
|
||||
cptr = copy_string(cptr, g_httpcrnl, strlen(g_httpcrnl) - 1);
|
||||
|
||||
cptr = copy_string(cptr, http_user_agent_fields,
|
||||
strlen(http_user_agent_fields));
|
||||
cptr = copy_string(cptr, g_httpuseragentfields,
|
||||
strlen(g_httpuseragentfields));
|
||||
|
||||
len = s.getrequestleft > uip_mss(conn)?
|
||||
uip_mss(conn):
|
||||
@@ -238,18 +190,18 @@ static uint16 parse_statusline(struct uip_driver_s *dev, uint16 len)
|
||||
|
||||
if (s.httpheaderline[s.httpheaderlineptr] == ISO_nl)
|
||||
{
|
||||
if ((strncmp(s.httpheaderline, http_10, sizeof(http_10) - 1) == 0) ||
|
||||
(strncmp(s.httpheaderline, http_11, sizeof(http_11) - 1) == 0))
|
||||
if ((strncmp(s.httpheaderline, g_http10, strlen(g_http10) - 1) == 0) ||
|
||||
(strncmp(s.httpheaderline, g_http11, strlen(g_http11) - 1) == 0))
|
||||
{
|
||||
cptr = &(s.httpheaderline[9]);
|
||||
s.httpflag = HTTPFLAG_NONE;
|
||||
if (strncmp(cptr, http_200, sizeof(http_200) - 1) == 0)
|
||||
if (strncmp(cptr, g_http200, strlen(g_http200) - 1) == 0)
|
||||
{
|
||||
/* 200 OK */
|
||||
s.httpflag = HTTPFLAG_OK;
|
||||
}
|
||||
else if (strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
|
||||
strncmp(cptr, http_302, sizeof(http_302) - 1) == 0)
|
||||
else if (strncmp(cptr, g_http301, strlen(g_http301) - 1) == 0 ||
|
||||
strncmp(cptr, g_http302, strlen(g_http302) - 1) == 0)
|
||||
{
|
||||
/* 301 Moved permanently or 302 Found. Location: header line
|
||||
* will contain thw new location.
|
||||
@@ -337,7 +289,7 @@ static uint16 parse_headers(struct uip_driver_s *dev, uint16 len)
|
||||
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
|
||||
|
||||
/* Check for specific HTTP header fields. */
|
||||
if (casecmp(s.httpheaderline, http_content_type, sizeof(http_content_type) - 1) == 0)
|
||||
if (casecmp(s.httpheaderline, g_httpcontenttype, strlen(g_httpcontenttype) - 1) == 0)
|
||||
{
|
||||
/* Found Content-type field. */
|
||||
cptr = strchr(s.httpheaderline, ';');
|
||||
@@ -345,13 +297,13 @@ static uint16 parse_headers(struct uip_driver_s *dev, uint16 len)
|
||||
{
|
||||
*cptr = 0;
|
||||
}
|
||||
strncpy(s.mimetype, s.httpheaderline + sizeof(http_content_type) - 1, sizeof(s.mimetype));
|
||||
strncpy(s.mimetype, s.httpheaderline + strlen(g_httpcontenttype) - 1, sizeof(s.mimetype));
|
||||
}
|
||||
else if (casecmp(s.httpheaderline, http_location, sizeof(http_location) - 1) == 0)
|
||||
else if (casecmp(s.httpheaderline, g_httplocation, strlen(g_httplocation) - 1) == 0)
|
||||
{
|
||||
cptr = s.httpheaderline + sizeof(http_location) - 1;
|
||||
cptr = s.httpheaderline + strlen(g_httplocation) - 1;
|
||||
|
||||
if (strncmp(cptr, http_http, 7) == 0)
|
||||
if (strncmp(cptr, g_httphttp, strlen(g_httphttp)) == 0)
|
||||
{
|
||||
cptr += 7;
|
||||
for(i = 0; i < s.httpheaderlineptr - 7; ++i)
|
||||
@@ -485,3 +437,85 @@ uint8 uip_interrupt_event(struct uip_driver_s *dev, struct uip_conn *conn, uint8
|
||||
}
|
||||
return g_return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void webclient_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned char webclient_get(const char *host, uint16 port, char *file)
|
||||
{
|
||||
uip_ipaddr_t *ipaddr;
|
||||
static uip_ipaddr_t addr;
|
||||
struct sockaddr_in server;
|
||||
int sockfd;
|
||||
|
||||
/* First check if the host is an IP address. */
|
||||
|
||||
ipaddr = &addr;
|
||||
if (uiplib_ipaddrconv(host, (unsigned char *)addr) == 0)
|
||||
{
|
||||
if (resolv_query(host, &ipaddr) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a socket */
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Connect to server. First we have to set some fields in the
|
||||
* 'server' structure. The system will assign me an arbitrary
|
||||
* local port that is not in use.
|
||||
*/
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
memcpy(&server.sin_addr.s_addr, &host, sizeof(in_addr_t));
|
||||
server.sin_port = htons(port);
|
||||
|
||||
if (connect(sockfd, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
s.port = port;
|
||||
strncpy(s.file, file, sizeof(s.file));
|
||||
strncpy(s.host, host, sizeof(s.host));
|
||||
|
||||
init_connection();
|
||||
return OK;
|
||||
}
|
||||
|
||||
void webclient_close(void)
|
||||
{
|
||||
s.state = WEBCLIENT_STATE_CLOSE;
|
||||
}
|
||||
|
||||
char *webclient_mimetype(void)
|
||||
{
|
||||
return s.mimetype;
|
||||
}
|
||||
|
||||
char *webclient_filename(void)
|
||||
{
|
||||
return s.file;
|
||||
}
|
||||
|
||||
char *webclient_hostname(void)
|
||||
{
|
||||
return s.host;
|
||||
}
|
||||
|
||||
unsigned shortwebclient_port(void)
|
||||
{
|
||||
return s.port;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
#include "netutil-strings.h"
|
||||
|
||||
#define WEBCLIENT_CONF_MAX_URLLEN 100
|
||||
|
||||
struct webclient_state
|
||||
|
||||
@@ -125,7 +125,7 @@ static void file_stats(struct httpd_state *pstate, char *ptr)
|
||||
char buffer[16];
|
||||
char *pcount = strchr(ptr, ' ') + 1;
|
||||
snprintf(buffer, 16, "%5u", httpd_fs_count(pcount));
|
||||
(void)send(pstate->sockfd, buffer, strlen(buffer), 0);
|
||||
(void)send(pstate->ht_sockfd, buffer, strlen(buffer), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -60,23 +60,23 @@ static uint16 count[HTTPD_FS_NUMFILES];
|
||||
|
||||
static uint8 httpd_fs_strcmp(const char *str1, const char *str2)
|
||||
{
|
||||
uint8 i;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
loop:
|
||||
for (;;)
|
||||
{
|
||||
if (str2[i] == 0 || str1[i] == '\r' || str1[i] == '\n')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(str2[i] == 0 ||
|
||||
str1[i] == '\r' ||
|
||||
str1[i] == '\n') {
|
||||
return 0;
|
||||
}
|
||||
if (str1[i] != str2[i])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(str1[i] != str2[i]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
++i;
|
||||
goto loop;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
||||
@@ -88,21 +88,21 @@ int httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
||||
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next)
|
||||
{
|
||||
if (httpd_fs_strcmp(name, f->name) == 0)
|
||||
{
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++count[i];
|
||||
++count[i];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
return 1;
|
||||
}
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++i;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
return 1;
|
||||
}
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++i;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,9 +110,10 @@ void httpd_fs_init(void)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
uint16 i;
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
||||
count[i] = 0;
|
||||
}
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++)
|
||||
{
|
||||
count[i] = 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
}
|
||||
|
||||
@@ -125,13 +126,14 @@ uint16 httpd_fs_count(char *name)
|
||||
i = 0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
return count[i];
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next)
|
||||
{
|
||||
if (httpd_fs_strcmp(name, f->name) == 0)
|
||||
{
|
||||
return count[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
@@ -583,34 +583,34 @@ static const unsigned char data_stats_shtml[] = {
|
||||
0xa, 0};
|
||||
|
||||
const struct httpd_fsdata_file file_processes_shtml[] =
|
||||
{{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
|
||||
{{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 18}};
|
||||
|
||||
const struct httpd_fsdata_file file_404_html[] =
|
||||
{{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
|
||||
{{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_files_shtml[] =
|
||||
{{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
|
||||
{{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 14}};
|
||||
|
||||
const struct httpd_fsdata_file file_footer_html[] =
|
||||
{{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
|
||||
{{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 14}};
|
||||
|
||||
const struct httpd_fsdata_file file_header_html[] =
|
||||
{{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
|
||||
{{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 14}};
|
||||
|
||||
const struct httpd_fsdata_file file_index_html[] =
|
||||
{{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
|
||||
{{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_style_css[] =
|
||||
{{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
|
||||
{{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 12}};
|
||||
|
||||
const struct httpd_fsdata_file file_tcp_shtml[] =
|
||||
{{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
|
||||
{{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 12}};
|
||||
|
||||
const struct httpd_fsdata_file file_fade_png[] =
|
||||
{{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}};
|
||||
{{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_stats_shtml[] =
|
||||
{{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}};
|
||||
{{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 14}};
|
||||
|
||||
#define HTTPD_FS_ROOT file_stats_shtml
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct httpd_fsdata_file
|
||||
{
|
||||
const struct httpd_fsdata_file *next;
|
||||
@@ -59,7 +63,8 @@ struct httpd_fsdata_file
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
struct httpd_fsdata_file_noconst {
|
||||
struct httpd_fsdata_file_noconst
|
||||
{
|
||||
struct httpd_fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
|
||||
#include "httpd.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "netutil-strings.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
@@ -80,13 +79,48 @@
|
||||
#define errno *get_errno_ptr()
|
||||
|
||||
#define CONFIG_NETUTILS_HTTPD_DUMPBUFFER 1
|
||||
#undef CONFIG_NETUTILS_HTTPD_DUMPPSTATE
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char g_httpcontenttypebinary[] = "Content-type: application/octet-stream\r\n\r\n";
|
||||
static const char g_httpcontenttypecss[] = "Content-type: text/css\r\n\r\n";
|
||||
static const char g_httpcontenttypegif[] = "Content-type: image/gif\r\n\r\n";
|
||||
static const char g_httpcontenttypehtml[] = "Content-type: text/html\r\n\r\n";
|
||||
static const char g_httpcontenttypejpg[] = "Content-type: image/jpeg\r\n\r\n";
|
||||
static const char g_httpcontenttypeplain[] = "Content-type: text/plain\r\n\r\n";
|
||||
static const char g_httpcontenttypepng[] = "Content-type: image/png\r\n\r\n";
|
||||
|
||||
static const char g_httpextensionhtml[] = ".html";
|
||||
static const char g_httpextensionshtml[] = ".shtml";
|
||||
static const char g_httpextensioncss[] = ".css";
|
||||
static const char g_httpextensionpng[] = ".png";
|
||||
static const char g_httpextensiongif[] = ".gif";
|
||||
static const char g_httpextensionjpg[] = ".jpg";
|
||||
|
||||
static const char g_http404path[] = "/404.html";
|
||||
static const char g_httpindexpath[] = "/index.html";
|
||||
|
||||
static const char g_httpcmdget[] = "GET ";
|
||||
|
||||
static const char g_httpheader200[] =
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: uIP/1.0 http://www.sics.se/~adam/uip/\r\n"
|
||||
"Connection: close\r\n";
|
||||
|
||||
static const char g_httpheader404[] =
|
||||
"HTTP/1.0 404 Not found\r\n"
|
||||
"Server: uIP/1.0 http://www.sics.se/~adam/uip/\r\n"
|
||||
"Connection: close\r\n";
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETUTILS_HTTPD_DUMPBUFFER
|
||||
static void httpd_dumpbuffer(struct httpd_state *pstate, ssize_t nbytes)
|
||||
static void httpd_dumpbuffer(const char *buffer, ssize_t nbytes)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG
|
||||
char line[128];
|
||||
@@ -101,7 +135,7 @@ static void httpd_dumpbuffer(struct httpd_state *pstate, ssize_t nbytes)
|
||||
{
|
||||
if (i + j < nbytes)
|
||||
{
|
||||
sprintf(&line[strlen(line)], "%02x ", pstate->ht_buffer[i+j] );
|
||||
sprintf(&line[strlen(line)], "%02x ", buffer[i+j] );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,7 +146,7 @@ static void httpd_dumpbuffer(struct httpd_state *pstate, ssize_t nbytes)
|
||||
{
|
||||
if (i + j < nbytes)
|
||||
{
|
||||
ch = pstate->ht_buffer[i+j];
|
||||
ch = buffer[i+j];
|
||||
sprintf(&line[strlen(line)], "%c", ch >= 0x20 && ch <= 0x7e ? ch : '.');
|
||||
}
|
||||
}
|
||||
@@ -121,37 +155,55 @@ static void httpd_dumpbuffer(struct httpd_state *pstate, ssize_t nbytes)
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define httpd_dumpbuffer(pstate,nbytes)
|
||||
# define httpd_dumpbuffer(buffer,nbytes)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NETUTILS_HTTPD_DUMPPSTATE
|
||||
static void httpd_dumppstate(struct httpd_state *pstate, const char *msg)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG
|
||||
dbg("[%d] pstate(%p): [%s]\n", pstate->ht_sockfd, pstate, msg);
|
||||
dbg(" filename: [%s]\n", pstate->ht_filename);
|
||||
dbg(" htfile len: %d\n", pstate->ht_file.len);
|
||||
dbg(" sockfd: %d\n", pstate->ht_sockfd);
|
||||
dbg(" scriptptr: %p\n", pstate->ht_scriptptr);
|
||||
dbg(" scriptlen: %d\n", pstate->ht_scriptlen);
|
||||
dbg(" sndlen: %d\n", pstate->ht_sndlen);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define httpd_dumppstate(pstate, msg)
|
||||
#endif
|
||||
|
||||
static void next_scriptstate(struct httpd_state *pstate)
|
||||
{
|
||||
char *p;
|
||||
p = strchr(pstate->scriptptr, ISO_nl) + 1;
|
||||
pstate->scriptlen -= (unsigned short)(p - pstate->scriptptr);
|
||||
pstate->scriptptr = p;
|
||||
p = strchr(pstate->ht_scriptptr, ISO_nl) + 1;
|
||||
pstate->ht_scriptlen -= (unsigned short)(p - pstate->ht_scriptptr);
|
||||
pstate->ht_scriptptr = p;
|
||||
}
|
||||
|
||||
static void handle_script(struct httpd_state *pstate)
|
||||
static int handle_script(struct httpd_state *pstate)
|
||||
{
|
||||
int len;
|
||||
char *ptr;
|
||||
|
||||
while(pstate->file.len > 0)
|
||||
while(pstate->ht_file.len > 0)
|
||||
{
|
||||
/* Check if we should start executing a script */
|
||||
|
||||
if (*pstate->file.data == ISO_percent && *(pstate->file.data + 1) == ISO_bang)
|
||||
if (*pstate->ht_file.data == ISO_percent && *(pstate->ht_file.data + 1) == ISO_bang)
|
||||
{
|
||||
pstate->scriptptr = pstate->file.data + 3;
|
||||
pstate->scriptlen = pstate->file.len - 3;
|
||||
if (*(pstate->scriptptr - 1) == ISO_colon)
|
||||
pstate->ht_scriptptr = pstate->ht_file.data + 3;
|
||||
pstate->ht_scriptlen = pstate->ht_file.len - 3;
|
||||
if (*(pstate->ht_scriptptr - 1) == ISO_colon)
|
||||
{
|
||||
httpd_fs_open(pstate->scriptptr + 1, &pstate->file);
|
||||
send(pstate->sockfd, pstate->file.data, pstate->file.len, 0);
|
||||
httpd_fs_open(pstate->ht_scriptptr + 1, &pstate->ht_file);
|
||||
send(pstate->ht_sockfd, pstate->ht_file.data, pstate->ht_file.len, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
httpd_cgi(pstate->scriptptr)(pstate, pstate->scriptptr);
|
||||
httpd_cgi(pstate->ht_scriptptr)(pstate, pstate->ht_scriptptr);
|
||||
}
|
||||
next_scriptstate(pstate);
|
||||
|
||||
@@ -159,8 +211,8 @@ static void handle_script(struct httpd_state *pstate)
|
||||
* sending the rest of the file
|
||||
*/
|
||||
|
||||
pstate->file.data = pstate->scriptptr;
|
||||
pstate->file.len = pstate->scriptlen;
|
||||
pstate->ht_file.data = pstate->ht_scriptptr;
|
||||
pstate->ht_file.len = pstate->ht_scriptlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,102 +220,179 @@ static void handle_script(struct httpd_state *pstate)
|
||||
* to be sent
|
||||
*/
|
||||
|
||||
if (pstate->file.len > HTTPD_IOBUFFER_SIZE)
|
||||
if (pstate->ht_file.len > HTTPD_IOBUFFER_SIZE)
|
||||
{
|
||||
pstate->len = HTTPD_IOBUFFER_SIZE;
|
||||
len = HTTPD_IOBUFFER_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pstate->len = pstate->file.len;
|
||||
len = pstate->ht_file.len;
|
||||
}
|
||||
|
||||
if (*pstate->file.data == ISO_percent)
|
||||
if (*pstate->ht_file.data == ISO_percent)
|
||||
{
|
||||
ptr = strchr(pstate->file.data + 1, ISO_percent);
|
||||
ptr = strchr(pstate->ht_file.data + 1, ISO_percent);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = strchr(pstate->file.data, ISO_percent);
|
||||
ptr = strchr(pstate->ht_file.data, ISO_percent);
|
||||
}
|
||||
|
||||
if (ptr != NULL && ptr != pstate->file.data)
|
||||
if (ptr != NULL && ptr != pstate->ht_file.data)
|
||||
{
|
||||
pstate->len = (int)(ptr - pstate->file.data);
|
||||
if (pstate->len >= HTTPD_IOBUFFER_SIZE)
|
||||
len = (int)(ptr - pstate->ht_file.data);
|
||||
if (len >= HTTPD_IOBUFFER_SIZE)
|
||||
{
|
||||
pstate->len = HTTPD_IOBUFFER_SIZE;
|
||||
len = HTTPD_IOBUFFER_SIZE;
|
||||
}
|
||||
}
|
||||
send(pstate->sockfd, pstate->file.data, pstate->len, 0);
|
||||
pstate->file.data += pstate->len;
|
||||
pstate->file.len -= pstate->len;
|
||||
send(pstate->ht_sockfd, pstate->ht_file.data, len, 0);
|
||||
pstate->ht_file.data += len;
|
||||
pstate->ht_file.len -= len;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int send_headers(struct httpd_state *pstate, const char *statushdr)
|
||||
static int httpd_addchunk(struct httpd_state *pstate, const char *buffer, int len)
|
||||
{
|
||||
int newlen;
|
||||
int chunklen;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
/* Determine the size of the next chunk so that it fits into the buffer */
|
||||
|
||||
newlen = pstate->ht_sndlen + len;
|
||||
if (newlen > HTTPD_IOBUFFER_SIZE)
|
||||
{
|
||||
newlen = HTTPD_IOBUFFER_SIZE;
|
||||
chunklen = HTTPD_IOBUFFER_SIZE - pstate->ht_sndlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
chunklen = len;
|
||||
}
|
||||
vdbg("[%d] sndlen=%d len=%d newlen=%d chunklen=%d\n",
|
||||
pstate->ht_sockfd, pstate->ht_sndlen, len, newlen, chunklen);
|
||||
|
||||
/* Copy that chunk into the send buffer */
|
||||
|
||||
memcpy(&pstate->ht_buffer[pstate->ht_sndlen], buffer, chunklen);
|
||||
|
||||
if (newlen >= HTTPD_IOBUFFER_SIZE)
|
||||
{
|
||||
/* The buffer is full.. Send what we have and reset to send again */
|
||||
|
||||
httpd_dumpbuffer(pstate->ht_buffer, newlen);
|
||||
ret = send(pstate->ht_sockfd, pstate->ht_buffer, newlen, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
newlen = 0;
|
||||
}
|
||||
|
||||
pstate->ht_sndlen = newlen;
|
||||
len -= chunklen;
|
||||
buffer += chunklen;
|
||||
}
|
||||
while (len > 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int send_headers(struct httpd_state *pstate, const char *statushdr, int len)
|
||||
{
|
||||
char *ptr;
|
||||
int ret;
|
||||
|
||||
ret = send(pstate->sockfd, statushdr, strlen(statushdr), 0);
|
||||
ret = httpd_addchunk(pstate, statushdr, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ptr = strrchr(pstate->filename, ISO_period);
|
||||
ptr = strrchr(pstate->ht_filename, ISO_period);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_binary, strlen(http_content_type_binary), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypebinary, strlen(g_httpcontenttypebinary));
|
||||
}
|
||||
else if (strncmp(http_html, ptr, 5) == 0 || strncmp(http_shtml, ptr, 6) == 0)
|
||||
else if (strncmp(g_httpextensionhtml, ptr, strlen(g_httpextensionhtml)) == 0 ||
|
||||
strncmp(g_httpextensionshtml, ptr, strlen(g_httpextensionshtml)) == 0)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_html, strlen(http_content_type_html), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypehtml, strlen(g_httpcontenttypehtml));
|
||||
}
|
||||
else if (strncmp(http_css, ptr, 4) == 0)
|
||||
else if (strncmp(g_httpextensioncss, ptr, strlen(g_httpextensioncss)) == 0)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_css, strlen(http_content_type_css), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypecss, strlen(g_httpcontenttypecss));
|
||||
}
|
||||
else if (strncmp(http_png, ptr, 4) == 0)
|
||||
else if (strncmp(g_httpextensionpng, ptr, strlen(g_httpextensionpng)) == 0)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_png, strlen(http_content_type_png), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypepng, strlen(g_httpcontenttypepng));
|
||||
}
|
||||
else if (strncmp(http_gif, ptr, 4) == 0)
|
||||
else if (strncmp(g_httpextensiongif, ptr, strlen(g_httpextensiongif)) == 0)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_gif, strlen(http_content_type_gif), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypegif, strlen(g_httpcontenttypegif));
|
||||
}
|
||||
else if (strncmp(http_jpg, ptr, 4) == 0)
|
||||
else if (strncmp(g_httpextensionjpg, ptr, strlen(g_httpextensionjpg)) == 0)
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_jpg, strlen(http_content_type_jpg), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypejpg, strlen(g_httpcontenttypejpg));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = send(pstate->sockfd, http_content_type_plain, strlen(http_content_type_plain), 0);
|
||||
ret = httpd_addchunk(pstate, g_httpcontenttypeplain, strlen(g_httpcontenttypeplain));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void httpd_sendfile(struct httpd_state *pstate)
|
||||
static int httpd_sendfile(struct httpd_state *pstate)
|
||||
{
|
||||
char *ptr;
|
||||
int ret = ERROR;
|
||||
|
||||
if (!httpd_fs_open(pstate->filename, &pstate->file))
|
||||
pstate->ht_sndlen = 0;
|
||||
|
||||
if (!httpd_fs_open(pstate->ht_filename, &pstate->ht_file))
|
||||
{
|
||||
httpd_fs_open(http_404_html, &pstate->file);
|
||||
strcpy(pstate->filename, http_404_html);
|
||||
send_headers(pstate, http_header_404);
|
||||
send(pstate->sockfd, pstate->file.data, pstate->file.len, 0);
|
||||
memcpy(pstate->ht_filename, g_http404path, strlen(g_http404path));
|
||||
httpd_fs_open(g_http404path, &pstate->ht_file);
|
||||
if (send_headers(pstate, g_httpheader404, strlen(g_httpheader404)) == OK)
|
||||
{
|
||||
ret = httpd_addchunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
send_headers(pstate, http_header_200);
|
||||
ptr = strchr(pstate->filename, ISO_period);
|
||||
if (ptr != NULL && strncmp(ptr, http_shtml, 6) == 0)
|
||||
if (send_headers(pstate, g_httpheader200, strlen(g_httpheader200)) == OK)
|
||||
{
|
||||
handle_script(pstate);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(pstate->sockfd, pstate->file.data, pstate->file.len, 0);
|
||||
ptr = strchr(pstate->ht_filename, ISO_period);
|
||||
if (ptr != NULL &&
|
||||
strncmp(ptr, g_httpextensionshtml, strlen(g_httpextensionshtml)) == 0)
|
||||
{
|
||||
ret = handle_script(pstate);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = httpd_addchunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Send anything remaining in the buffer */
|
||||
|
||||
if (ret == OK && pstate->ht_sndlen > 0)
|
||||
{
|
||||
httpd_dumpbuffer(pstate->ht_buffer, pstate->ht_sndlen);
|
||||
if (send(pstate->ht_sockfd, pstate->ht_buffer, pstate->ht_sndlen, 0) < 0)
|
||||
{
|
||||
ret = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int httpd_cmd(struct httpd_state *pstate)
|
||||
@@ -273,19 +402,19 @@ static inline int httpd_cmd(struct httpd_state *pstate)
|
||||
|
||||
/* Get the next HTTP command. We will handle only GET */
|
||||
|
||||
recvlen = recv(pstate->sockfd, pstate->ht_buffer, HTTPD_IOBUFFER_SIZE, 0);
|
||||
recvlen = recv(pstate->ht_sockfd, pstate->ht_buffer, HTTPD_IOBUFFER_SIZE, 0);
|
||||
if (recvlen < 0)
|
||||
{
|
||||
dbg("recv failed: %d\n", errno);
|
||||
dbg("[%d] recv failed: %d\n", pstate->ht_sockfd, errno);
|
||||
return ERROR;
|
||||
}
|
||||
httpd_dumpbuffer(pstate, recvlen);
|
||||
httpd_dumpbuffer(pstate->ht_buffer, recvlen);
|
||||
|
||||
/* We will handle only GET */
|
||||
|
||||
if (strncmp(pstate->ht_buffer, http_get, 4) != 0)
|
||||
if (strncmp(pstate->ht_buffer, g_httpcmdget, strlen(g_httpcmdget)) != 0)
|
||||
{
|
||||
dbg("Unsupported command\n");
|
||||
dbg("[%d] Unsupported command\n", pstate->ht_sockfd);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@@ -293,25 +422,28 @@ static inline int httpd_cmd(struct httpd_state *pstate)
|
||||
|
||||
if (pstate->ht_buffer[4] != ISO_slash)
|
||||
{
|
||||
dbg("Missing path\n");
|
||||
dbg("[%d] Missing path\n", pstate->ht_sockfd);
|
||||
return ERROR;
|
||||
}
|
||||
else if (pstate->ht_buffer[5] == ISO_space)
|
||||
{
|
||||
strncpy(pstate->filename, http_index_html, sizeof(pstate->filename));
|
||||
strncpy(pstate->ht_filename, g_httpindexpath, strlen(g_httpindexpath));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 5; i < sizeof(pstate->filename) + 5 && pstate->ht_buffer[5] != ISO_space; i++)
|
||||
for (i = 0;
|
||||
i < (HTTPD_MAX_FILENAME-1) && pstate->ht_buffer[i+4] != ISO_space;
|
||||
i++)
|
||||
{
|
||||
pstate->filename[i] = pstate->ht_buffer[i+5];
|
||||
pstate->ht_filename[i] = pstate->ht_buffer[i+4];
|
||||
}
|
||||
pstate->ht_filename[i]='\0';
|
||||
}
|
||||
dbg("[%d] Filename: %s\n", pstate->ht_sockfd, pstate->ht_filename);
|
||||
|
||||
/* Then send the file */
|
||||
|
||||
httpd_sendfile(pstate);
|
||||
return OK;
|
||||
return httpd_sendfile(pstate);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -330,34 +462,34 @@ static void *httpd_handler(void *arg)
|
||||
int sockfd = (int)arg;
|
||||
int ret = ERROR;
|
||||
|
||||
dbg("Started, sd=%d\n", sockfd);
|
||||
dbg("[%d] Started\n", sockfd);
|
||||
|
||||
/* Verify that the state structure was successfully allocated */
|
||||
|
||||
if (pstate)
|
||||
{
|
||||
/* Loop processing each HTTP command */
|
||||
do
|
||||
// do
|
||||
{
|
||||
/* Re-initialize the thread state structure */
|
||||
|
||||
memset(pstate, 0, sizeof(struct httpd_state));
|
||||
pstate->sockfd = sockfd;
|
||||
pstate->ht_sockfd = sockfd;
|
||||
|
||||
/* Then handle the next httpd command */
|
||||
|
||||
ret = httpd_cmd(pstate);
|
||||
}
|
||||
while (ret == OK);
|
||||
// while (ret == OK);
|
||||
|
||||
/* End of command processing -- Clean up and exit */
|
||||
/* End of command processing -- Clean up and exit */
|
||||
|
||||
free(pstate);
|
||||
}
|
||||
free(pstate);
|
||||
}
|
||||
|
||||
/* Exit the task */
|
||||
|
||||
dbg("Exitting\n");
|
||||
dbg("[%d] Exitting\n", sockfd);
|
||||
close(sockfd);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -46,13 +46,29 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define HTTPD_FS_STATISTICS 1
|
||||
#define HTTPD_IOBUFFER_SIZE 512
|
||||
|
||||
/* For efficiency reasons, the size of the IO buffer should be a multiple
|
||||
* of the TCP MSS value. Also, the current design requires that the IO
|
||||
* buffer be sufficiently large to contain the entire GET request.
|
||||
*/
|
||||
|
||||
#define HTTPD_IOBUFFER_SIZE (3*UIP_TCP_MSS)
|
||||
|
||||
/* this is the maximum size of a file path */
|
||||
|
||||
#define HTTPD_MAX_FILENAME 20
|
||||
|
||||
/* As threads are created to handle each request, a stack must be allocated
|
||||
* for the thread. Use a default if the user provided no stacksize.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_UIP_HTTPDSTACKSIZE
|
||||
# define CONFIG_EXAMPLES_UIP_HTTPDSTACKSIZE 4096
|
||||
@@ -70,15 +86,13 @@ struct httpd_fs_file
|
||||
|
||||
struct httpd_state
|
||||
{
|
||||
char ht_buffer[HTTPD_IOBUFFER_SIZE];
|
||||
char filename[20];
|
||||
struct httpd_fs_file file;
|
||||
int sockfd; /* The socket descriptor from accept() */
|
||||
int len;
|
||||
char *scriptptr;
|
||||
int scriptlen;
|
||||
|
||||
unsigned short count;
|
||||
char ht_buffer[HTTPD_IOBUFFER_SIZE]; /* recv()/send() buffer */
|
||||
char ht_filename[HTTPD_MAX_FILENAME]; /* filename from GET command */
|
||||
struct httpd_fs_file ht_file; /* Fake file data to send */
|
||||
int ht_sockfd; /* The socket descriptor from accept() */
|
||||
char *ht_scriptptr;
|
||||
uint16 ht_scriptlen;
|
||||
uint16 ht_sndlen;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -77,7 +77,9 @@
|
||||
|
||||
int sched_setupidlefiles(FAR _TCB *tcb)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_DEV_CONSOLE)
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
/* Allocate file descriptors for the TCB */
|
||||
|
||||
@@ -257,9 +257,11 @@ int main(int argc, char **argv, char **envp)
|
||||
printf("# undef CONFIG_NSOCKET_DESCRIPTORS\n");
|
||||
printf("# define CONFIG_NSOCKET_DESCRIPTORS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* UDP support can only be provided on top of basic network support */\n\n");
|
||||
printf("/* Protocol support can only be provided on top of basic network support */\n\n");
|
||||
printf("#ifndef CONFIG_NET\n");
|
||||
printf("# undef CONFIG_NET_TCP\n");
|
||||
printf("# undef CONFIG_NET_UDP\n");
|
||||
printf("# undef CONFIG_NET_ICMP\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Verbose debug only makes sense if debug is enabled */\n\n");
|
||||
printf("#ifndef CONFIG_DEBUG\n");
|
||||
|
||||
Reference in New Issue
Block a user