9
0
Fork 0

Removed unused uIP files

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@403 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2007-11-23 21:16:43 +00:00
parent 6dad5fb314
commit d1fbff3aaf
11 changed files with 28 additions and 927 deletions

View File

@ -246,3 +246,5 @@
0.3.3 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Removed unused uIP files

View File

@ -725,6 +725,8 @@ Other memory:
<pre><ul>
0.3.3 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Removed unused uIP files
</pre></ul>
<table width ="100%">

View File

@ -38,7 +38,8 @@ o Network
- Should implement SOCK_RAW
- Performance Improvements (uIP is not very fast):
Need to extend logic so that uIP can have more than on packet in flight and to
handle deferred acknowledgements.
handle deferred acknowledgements. This is supposed to improve send performance by
an order of magnitude.
- 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

View File

@ -75,7 +75,10 @@
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
{
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
int i;
#endif
dbg(" TCB=%p name=%s\n", tcb, tcb->argv[0]);
#if CONFIG_NFILE_DESCRIPTORS > 0

View File

@ -49,7 +49,7 @@
****************************************************************************/
/* This macro to convert a 16/32-bit constant values quantity from host byte
* order to network byte order. The 16-bit version of this macro is require
* order to network byte order. The 16-bit version of this macro is required
* for uIP:
*
* Author Adam Dunkels <adam@dunkels.com>

View File

@ -370,25 +370,14 @@ extern void uip_send(struct uip_driver_s *dev, const void *buf, int len);
*
* Construct an IP address from four bytes.
*
* This function constructs an IP address of the type that uIP handles
* internally from four bytes. The function is handy for specifying IP
* addresses to use with e.g. the uip_connect() function.
* This function constructs an IPv4 address in network byte order.
*
* Example:
*
* uip_ipaddr_t ipaddr;
* struct uip_conn *c;
*
* uip_ipaddr(&ipaddr, 192,168,1,2);
* c = uip_connect(&ipaddr, HTONS(80));
*
* addr A pointer to a uip_ipaddr_t variable that will be
* filled in with the IP address.
*
* addr0 The first octet of the IP address.
* addr1 The second octet of the IP address.
* addr2 The third octet of the IP address.
* addr3 The forth octet of the IP address.
* addr A pointer to a uip_ipaddr_t variable that will be
* filled in with the IPv4 address.
* addr0 The first octet of the IPv4 address.
* addr1 The second octet of the IPv4 address.
* addr2 The third octet of the IPv4 address.
* addr3 The forth octet of the IPv4 address.
*/
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3) \
@ -409,16 +398,17 @@ extern void uip_send(struct uip_driver_s *dev, const void *buf, int len);
* This function constructs an IPv6 address.
*/
#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \
((uint16*)(addr))[0] = HTONS((addr0)); \
((uint16*)(addr))[1] = HTONS((addr1)); \
((uint16*)(addr))[2] = HTONS((addr2)); \
((uint16*)(addr))[3] = HTONS((addr3)); \
((uint16*)(addr))[4] = HTONS((addr4)); \
((uint16*)(addr))[5] = HTONS((addr5)); \
((uint16*)(addr))[6] = HTONS((addr6)); \
((uint16*)(addr))[7] = HTONS((addr7)); \
} while(0)
#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) \
do { \
((uint16*)(addr))[0] = HTONS((addr0)); \
((uint16*)(addr))[1] = HTONS((addr1)); \
((uint16*)(addr))[2] = HTONS((addr2)); \
((uint16*)(addr))[3] = HTONS((addr3)); \
((uint16*)(addr))[4] = HTONS((addr4)); \
((uint16*)(addr))[5] = HTONS((addr5)); \
((uint16*)(addr))[6] = HTONS((addr6)); \
((uint16*)(addr))[7] = HTONS((addr7)); \
} while(0)
/* Copy an IP address to another IP address.
*

View File

@ -55,11 +55,6 @@ 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

View File

@ -1,508 +0,0 @@
/* uip-fw.c
* uIP packet forwarding.
* Author: Adam Dunkels <adam@sics.se>
*
* This file implements a number of simple functions which do packet
* forwarding over multiple network interfaces with uIP.
*
* Copyright (c) 2004, Swedish Institute of Computer Science.
* 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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 <nuttx/config.h>
#include <debug.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#include "uip-fw.h"
#include <string.h> /* for memcpy() */
/* The list of registered network interfaces. */
static struct uip_fw_netif *netifs = NULL;
/* A pointer to the default network interface. */
static struct uip_fw_netif *defaultnetif = NULL;
struct tcpip_hdr
{
/* IP header */
uint8 vhl;
uint8 tos;
uint16 len;
uint16 ipid;
uint16 ipoffset;
uint8 ttl;
uint8 proto;
uint16 ipchksum;
in_addr_t srcipaddr;
in_addr_t destipaddr;
/* 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];
};
struct icmpip_hdr
{
/* IP header */
uint8 vhl;
uint8 tos;
uint8 len[2];
uint8 ipid[2];
uint8 ipoffset[2];
uint8 ttl;
uint8 proto;
uint16 ipchksum;
in_addr_t srcipaddr;
in_addr_t destipaddr;
/* ICMP (echo) header */
uint8 type, icode;
uint16 icmpchksum;
uint16 id, seqno;
uint8 payload[1];
};
/* ICMP ECHO. */
#define ICMP_ECHO 8
/* ICMP TIME-EXCEEDED. */
#define ICMP_TE 11
/* Pointer to the TCP/IP headers of the packet in the d_buf buffer. */
#define BUF ((struct tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
/* Pointer to the ICMP/IP headers of the packet in the d_buf buffer. */
#define ICMPBUF ((struct icmpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
/* Certain fields of an IP packet that are used for identifying
* duplicate packets.
*/
struct fwcache_entry
{
uint16 timer;
in_addr_t srcipaddr;
in_addr_t destipaddr;
uint16 ipid;
uint8 proto;
uint8 unused;
#if notdef
uint16 payload[2];
#endif
#if UIP_REASSEMBLY > 0
uint16 len, offset;
#endif
};
/* The number of packets to remember when looking for duplicates. */
#ifdef CONFIG_NET_FWCACHE_SIZE
# define FWCACHE_SIZE CONFIG_NET_FWCACHE_SIZE
#else
# define FWCACHE_SIZE 2
#endif
/* A cache of packet header fields which are used for
* identifying duplicate packets.
*/
static struct fwcache_entry fwcache[FWCACHE_SIZE];
/* The time that a packet cache is active. */
#define FW_TIME 20
/* Initialize the uIP packet forwarding module. */
void uip_fw_init(void)
{
struct uip_fw_netif *t;
defaultnetif = NULL;
while(netifs != NULL)
{
t = netifs;
netifs = netifs->next;
t->next = NULL;
}
}
/* Send out an ICMP TIME-EXCEEDED message.
*
* This function replaces the packet in the d_buf buffer with the
* ICMP packet.
*/
static void time_exceeded(struct uip_driver_s *dev)
{
in_addr_t tmp_addr;
/* We don't send out ICMP errors for ICMP messages. */
if (ICMPBUF->proto == UIP_PROTO_ICMP)
{
dev->d_len = 0;
return;
}
/* Copy fields from packet header into payload of this ICMP packet. */
memcpy(&(ICMPBUF->payload[0]), ICMPBUF, 28);
/* Set the ICMP type and code. */
ICMPBUF->type = ICMP_TE;
ICMPBUF->icode = 0;
/* Calculate the ICMP checksum. */
ICMPBUF->icmpchksum = 0;
ICMPBUF->icmpchksum = ~uip_chksum((uint16 *)&(ICMPBUF->type), 36);
/* Set the IP destination address to be the source address of the
* original packet.
*/
tmp_addr = BUF->destipaddr;
BUF->destipaddr = BUF->srcipaddr;
BUF->srcipaddr = tmp_addr;
/* Set our IP address as the source address. */
BUF->srcipaddr = dev->d_ipaddr;
/* The size of the ICMP time exceeded packet is 36 + the size of the
* IP header (20) = 56.
*/
dev->d_len = 56;
ICMPBUF->len[0] = 0;
ICMPBUF->len[1] = dev->d_len;
/* Fill in the other fields in the IP header. */
ICMPBUF->vhl = 0x45;
ICMPBUF->tos = 0;
ICMPBUF->ipoffset[0] = ICMPBUF->ipoffset[1] = 0;
ICMPBUF->ttl = UIP_TTL;
ICMPBUF->proto = UIP_PROTO_ICMP;
/* Calculate IP checksum. */
ICMPBUF->ipchksum = 0;
ICMPBUF->ipchksum = ~(uip_ipchksum(dev));
}
/* Register a packet in the forwarding cache so that it won't be
* forwarded again.
*/
static void fwcache_register(struct uip_driver_s *dev)
{
struct fwcache_entry *fw;
int i, oldest;
oldest = FW_TIME;
fw = NULL;
/* Find the oldest entry in the cache. */
for (i = 0; i < FWCACHE_SIZE; ++i)
{
if (fwcache[i].timer == 0)
{
fw = &fwcache[i];
break;
}
else if (fwcache[i].timer <= oldest)
{
fw = &fwcache[i];
oldest = fwcache[i].timer;
}
}
fw->timer = FW_TIME;
fw->ipid = BUF->ipid;
fw->srcipaddr = BUF->srcipaddr;
fw->destipaddr = BUF->destipaddr;
fw->proto = BUF->proto;
#if notdef
fw->payload[0] = BUF->srcport;
fw->payload[1] = BUF->destport;
#endif
#if UIP_REASSEMBLY > 0
fw->len = BUF->len;
fw->offset = BUF->ipoffset;
#endif
}
/* Find a network interface for the IP packet in d_buf. */
static struct uip_fw_netif *find_netif (struct uip_driver_s *dev)
{
struct uip_fw_netif *netif;
/* Walk through every network interface to check for a match. */
for (netif = netifs; netif != NULL; netif = netif->next)
{
if (uip_ipaddr_maskcmp(BUF->destipaddr, netif->ipaddr, netif->netmask))
{
/* If there was a match, we break the loop. */
return netif;
}
}
/* If no matching netif was found, we use default netif. */
return defaultnetif;
}
/* Output an IP packet on the correct network interface.
*
* The IP packet should be present in the d_buf buffer and its
* length in the d_len field.
*
* Return: UIP_FW_ZEROLEN Indicates that a zero-length packet
* transmission was attempted and that no packet was sent.
*
* Return: UIP_FW_NOROUTE No suitable network interface could be found
* for the outbound packet, and the packet was not sent.
*
* Return: The return value from the actual network interface output
* function is passed unmodified as a return value.
*/
uint8 uip_fw_output(struct uip_driver_s *dev)
{
struct uip_fw_netif *netif;
if (dev->d_len == 0)
{
return UIP_FW_ZEROLEN;
}
fwcache_register(dev);
#ifdef CONFIG_NET_BROADCAST
/* Link local broadcasts go out on all interfaces. */
if (/*BUF->proto == UIP_PROTO_UDP &&*/
BUF->destipaddr[0] == 0xffff &&
BUF->destipaddr[1] == 0xffff)
{
if (defaultnetif != NULL)
{
defaultnetif->output();
}
for (netif = netifs; netif != NULL; netif = netif->next)
{
netif->output();
}
return UIP_FW_OK;
}
#endif
netif = find_netif (dev);
dbg("netif: %p output: %p len: %d\n", netif, netif->output, dev->d_len);
if (netif == NULL)
{
return UIP_FW_NOROUTE;
}
/* If we now have found a suitable network interface, we call its
* output function to send out the packet.
*/
return netif->output();
}
/* Forward an IP packet in the d_buf buffer.
*
* Return: UIP_FW_FORWARDED if the packet was forwarded, UIP_FW_LOCAL if
* the packet should be processed locally.
*/
uint8 uip_fw_forward(struct uip_driver_s *dev)
{
struct fwcache_entry *fw;
/* First check if the packet is destined for ourselves and return 0
* to indicate that the packet should be processed locally.
*/
if (BUF->destipaddr == dev->d_ipaddr)
{
return UIP_FW_LOCAL;
}
/* If we use ping IP address configuration, and our IP address is
* not yet configured, we should intercept all ICMP echo packets.
*/
#ifdef CONFIG_NET_PINGADDRCONF
if (dev->d_ipaddr == 0 && BUF->proto == UIP_PROTO_ICMP && ICMPBUF->type == ICMP_ECHO)
{
return UIP_FW_LOCAL;
}
#endif
/* Check if the packet is in the forwarding cache already, and if so
we drop it. */
for (fw = fwcache; fw < &fwcache[FWCACHE_SIZE]; ++fw)
{
if (fw->timer != 0 &&
#if UIP_REASSEMBLY > 0
fw->len == BUF->len &&
fw->offset == BUF->ipoffset &&
#endif
fw->ipid == BUF->ipid &&
fw->srcipaddr == BUF->srcipaddr &&
fw->destipaddr == BUF->destipaddr &&
#if notdef
fw->payload[0] == BUF->srcport &&
fw->payload[1] == BUF->destport &&
#endif
fw->proto == BUF->proto)
{
/* Drop packet. */
return UIP_FW_FORWARDED;
}
}
/* If the TTL reaches zero we produce an ICMP time exceeded message
* in the d_buf buffer and forward that packet back to the sender
* of the packet.
*/
if (BUF->ttl <= 1)
{
/* No time exceeded for broadcasts and multicasts! */
if (BUF->destipaddr == 0xffffffff)
{
return UIP_FW_LOCAL;
}
time_exceeded(dev);
}
/* Decrement the TTL (time-to-live) value in the IP header */
BUF->ttl = BUF->ttl - 1;
/* Update the IP checksum. */
if (BUF->ipchksum >= HTONS(0xffff - 0x0100))
{
BUF->ipchksum = BUF->ipchksum + HTONS(0x0100) + 1;
}
else
{
BUF->ipchksum = BUF->ipchksum + HTONS(0x0100);
}
if (dev->d_len > 0)
{
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN];
uip_fw_output(dev);
}
#ifdef CONFIG_NET_BROADCAST
if (BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff)
{
return UIP_FW_LOCAL;
}
#endif
/* Return non-zero to indicate that the packet was forwarded and that no
* other processing should be made.
*/
return UIP_FW_FORWARDED;
}
/* Register a network interface with the forwarding module.
*
* netif A pointer to the network interface that is to be
* registered.
*/
void uip_fw_register(struct uip_fw_netif *netif)
{
netif->next = netifs;
netifs = netif;
}
/* Register a default network interface.
*
* All packets that don't go out on any of the other interfaces will
* be routed to the default interface.
*
* netif A pointer to the network interface that is to be
* registered.
*/
void uip_fw_default(struct uip_fw_netif *netif)
{
defaultnetif = netif;
}
/* Perform periodic processing. */
void uip_fw_periodic(void)
{
struct fwcache_entry *fw;
for (fw = fwcache; fw < &fwcache[FWCACHE_SIZE]; ++fw)
{
if (fw->timer > 0)
{
--fw->timer;
}
}
}

View File

@ -1,151 +0,0 @@
/****************************************************************************
* net/uip/uip-fw.h
* uIP packet forwarding header file.
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2004, Swedish Institute of Computer Science.
* 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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 __UIP_FW_H__
#define __UIP_FW_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <net/uip/uip.h>
/* Representation of a uIP network interface. */
struct uip_fw_netif
{
struct uip_fw_netif *next; /**< Pointer to the next interface when
linked in a list. */
uint16 ipaddr[2]; /**< The IP address of this interface. */
uint16 netmask[2]; /**< The netmask of the interface. */
uint8 (* output)(void);
/**< A pointer to the function that
sends a packet. */
};
/* Intantiating macro for a uIP network interface.
*
* Example:
*
* struct uip_fw_netif slipnetif =
* {UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};
*
* ip1,ip2,ip3,ip4 The IP address of the network interface.
*
* nm1,nm2,nm3,nm4 The netmask of the network interface.
*
* outputfunc A pointer to the output function of the network interface.
*/
#define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \
NULL, \
{HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \
{HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \
outputfunc
/* Set the IP address of a network interface.
*
* netif A pointer to the uip_fw_netif structure for the network interface.
*
* addr A pointer to an IP address.
*/
#define uip_fw_setipaddr(netif, addr) \
do { (netif)->ipaddr[0] = ((uint16 *)(addr))[0]; \
(netif)->ipaddr[1] = ((uint16 *)(addr))[1]; } while(0)
/* Set the netmask of a network interface.
*
* netif A pointer to the uip_fw_netif structure for the network interface.
*
* addr A pointer to an IP address representing the netmask.
*/
#define uip_fw_setnetmask(netif, addr) \
do { (netif)->netmask[0] = ((uint16 *)(addr))[0]; \
(netif)->netmask[1] = ((uint16 *)(addr))[1]; } while(0)
void uip_fw_init(void);
uint8 uip_fw_forward(struct uip_driver_s *dev);
uint8 uip_fw_output(struct uip_driver_s *dev);
void uip_fw_register(struct uip_fw_netif *netif);
void uip_fw_default(struct uip_fw_netif *netif);
void uip_fw_periodic(void);
/* A non-error message that indicates that a packet should be
* processed locally.
*/
#define UIP_FW_LOCAL 0
/* A non-error message that indicates that something went OK. */
#define UIP_FW_OK 0
/* A non-error message that indicates that a packet was forwarded. */
#define UIP_FW_FORWARDED 1
/* A non-error message that indicates that a zero-length packet
* transmission was attempted, and that no packet was sent.
*/
#define UIP_FW_ZEROLEN 2
/* An error message that indicates that a packet that was too large
* for the outbound network interface was detected.
*/
#define UIP_FW_TOOLARGE 3
/* An error message that indicates that no suitable interface could be
* found for an outbound packet.
*/
#define UIP_FW_NOROUTE 4
/* An error message that indicates that a packet that should be
* forwarded or output was dropped.
*/
#define UIP_FW_DROPPED 5
#endif /* __UIP_FW_H__ */

View File

@ -1,144 +0,0 @@
/* uip-split.c
* Author: Adam Dunkels <adam@sics.se>
*
* Copyright (c) 2004, Swedish Institute of Computer Science.
* 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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 <nuttx/config.h>
#include <string.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#include "uip-split.h"
#include "uip-fw.h"
#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
void uip_split_output(struct uip_driver_s *dev)
{
uint16 tcplen;
uint16 len1;
uint16 len2;
/* We only try to split maximum sized TCP segments. */
if (BUF->proto == UIP_PROTO_TCP &&
dev->d_len == CONFIG_NET_BUFSIZE - UIP_LLH_LEN)
{
tcplen = dev->d_len - UIP_TCPIP_HLEN;
/* Split the segment in two. If the original packet length was
* odd, we make the second packet one byte larger.
*/
len1 = len2 = tcplen / 2;
if (len1 + len2 < tcplen)
{
++len2;
}
/* Create the first packet. This is done by altering the length
* field of the IP header and updating the checksums.
*/
dev->d_len = len1 + UIP_TCPIP_HLEN;
#ifdef CONFIG_NET_IPv6
/* For IPv6, the IP length field does not include the IPv6 IP header
* length.
*/
BUF->len[0] = ((dev->d_len - UIP_IPH_LEN) >> 8);
BUF->len[1] = ((dev->d_len - UIP_IPH_LEN) & 0xff);
#else /* CONFIG_NET_IPv6 */
BUF->len[0] = dev->d_len >> 8;
BUF->len[1] = dev->d_len & 0xff;
#endif /* CONFIG_NET_IPv6 */
/* Recalculate the TCP checksum. */
BUF->tcpchksum = 0;
BUF->tcpchksum = ~(uip_tcpchksum(dev));
#ifndef CONFIG_NET_IPv6
/* Recalculate the IP checksum. */
BUF->ipchksum = 0;
BUF->ipchksum = ~(uip_ipchksum(dev));
#endif /* CONFIG_NET_IPv6 */
/* Transmit the first packet. */
/* uip_fw_output();*/
tcpip_output();
/* Now, create the second packet. To do this, it is not enough to
* just alter the length field, but we must also update the TCP
* sequence number and point the d_appdata to a new place in
* memory. This place is detemined by the length of the first
* packet (len1).
*/
dev->d_len = len2 + UIP_TCPIP_HLEN;
#ifdef CONFIG_NET_IPv6
/* For IPv6, the IP length field does not include the IPv6 IP header
* length.
*/
BUF->len[0] = ((dev->d_len - UIP_IPH_LEN) >> 8);
BUF->len[1] = ((dev->d_len - UIP_IPH_LEN) & 0xff);
#else /* CONFIG_NET_IPv6 */
BUF->len[0] = dev->d_len >> 8;
BUF->len[1] = dev->d_len & 0xff;
#endif /* CONFIG_NET_IPv6 */
/* dev->d_appdata += len1;*/
memcpy(dev->d_appdata, dev->d_appdata + len1, len2);
uip_incr32(BUF->seqno, len1);
/* Recalculate the TCP checksum. */
BUF->tcpchksum = 0;
BUF->tcpchksum = ~(uip_tcpchksum(dev));
#ifndef CONFIG_NET_IPv6
/* Recalculate the IP checksum. */
BUF->ipchksum = 0;
BUF->ipchksum = ~(uip_ipchksum(dev));
#endif /* CONFIG_NET_IPv6 */
/* Transmit the second packet. */
/* uip_fw_output();*/
tcpip_output();
}
else
{
/* uip_fw_output();*/
tcpip_output();
}
}

View File

@ -1,89 +0,0 @@
/****************************************************************************
* net/uip/uip-split.h
* Module for splitting outbound TCP segments in two to avoid the
* delayed ACK throughput degradation.
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2004, Swedish Institute of Computer Science.
* 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*
****************************************************************************/
/* uipsplit uIP TCP throughput booster hack
*
* The basic uIP TCP implementation only allows each TCP connection to
* have a single TCP segment in flight at any given time. Because of
* the delayed ACK algorithm employed by most TCP receivers, uIP's
* limit on the amount of in-flight TCP segments seriously reduces the
* maximum achievable throughput for sending data from uIP.
*
* The uip-split module is a hack which tries to remedy this
* situation. By splitting maximum sized outgoing TCP segments into
* two, the delayed ACK algorithm is not invoked at TCP
* receivers. This improves the throughput when sending data from uIP
* by orders of magnitude.
*
* The uip-split module uses the uip-fw module (uIP IP packet
* forwarding) for sending packets. Therefore, the uip-fw module must
* be set up with the appropriate network interfaces for this module
* to work.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#ifndef __UIP_SPLIT_H__
#define __UIP_SPLIT_H__
/* Handle outgoing packets.
*
* This function inspects an outgoing packet in the d_buf buffer and
* sends it out using the uip_fw_output() function. If the packet is a
* full-sized TCP segment it will be split into two segments and
* transmitted separately. This function should be called instead of
* the actual device driver output function, or the uip_fw_output()
* function.
*
* The headers of the outgoing packet is assumed to be in the d_buf
* buffer and the payload is assumed to be wherever d_appdata
* points. The length of the outgoing packet is assumed to be in the
* d_len field.
*/
void uip_split_output(struct uip_driver_s *dev);
#endif /* __UIP_SPLIT_H__ */
/** @} */
/** @} */