Completes coding of the PWM module

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4200 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2011-12-19 19:24:09 +00:00
commit add995c32e
4394 changed files with 1077774 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
/****************************************************************************
* include/net/ethernet.h
*
* Copyright (C) 2007-2009 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.
*
****************************************************************************/
#ifndef __NET_ETHERNET_H
#define __NET_ETHERNET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#define ETHER_ADDR_LEN 6
/****************************************************************************
* Public Type Definitions
****************************************************************************/
struct ether_addr
{
uint8_t ether_addr_octet[6]; /* 48-bit Ethernet address */
};
struct ether_header
{
uint8_t ether_dhost[ETHER_ADDR_LEN]; /* Destination Ethernet address */
uint8_t ether_shost[ETHER_ADDR_LEN]; /* Source Ethernet address */
uint16_t ether_type; /* Ethernet packet type*/
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#endif /* __NET_ETHERNET_H */
+85
View File
@@ -0,0 +1,85 @@
/****************************************************************************
* include/net/if.h
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* 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.
*
****************************************************************************/
#ifndef __NET_IF_H
#define __NET_IF_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/socket.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Sizing parameters */
#define IFNAMSIZ 6
#define IFHWADDRLEN 6
/****************************************************************************
* Public Type Definitions
****************************************************************************/
struct ifreq
{
char ifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */
union
{
struct sockaddr ifru_addr; /* IP Address */
struct sockaddr ifru_dstaddr; /* P-to-P Address */
struct sockaddr ifru_broadaddr; /* Broadcast address */
struct sockaddr ifru_netmask; /* Netmask */
struct sockaddr ifru_hwaddr; /* MAC address */
int ifru_count; /* Number of devices */
int ifru_mtu; /* MTU size */
} ifr_ifru;
};
#define ifr_addr ifr_ifru.ifru_addr /* IP address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* P-to-P Address */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* Broadcast address */
#define ifr_netmask ifr_ifru.ifru_netmask /* Interface net mask */
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_mtu ifr_ifru.ifru_mtu /* MTU */
#define ifr_count ifr_ifru.ifru_count /* Number of devices */
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#endif /* __NET_IF_H */
+143
View File
@@ -0,0 +1,143 @@
/****************************************************************************
* include/net/ioctls.h
*
* Copyright (C) 2007-2008, 2010-2011 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 __NET_IOCTLS_H
#define __NET_IOCTLS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/ioctl.h> /* _SIOCBASE, etc. */
/****************************************************************************
* Definitions
****************************************************************************/
/* These are ioctl commands to use with a socket FD. At present, commands
* are accepted only to set/get IP addresses, broadcast address, network
* masks, and hardware address, and a few others
*/
#define _SIOCVALID(c) (_IOC_TYPE(c)==_SIOCBASE)
#define _SIOC(nr) _IOC(_SIOCBASE,nr)
#define SIOCGIFADDR _SIOC(0x0001) /* Get IP address */
#define SIOCSIFADDR _SIOC(0x0002) /* Set IP address */
#define SIOCGIFDSTADDR _SIOC(0x0003) /* Get P-to-P address */
#define SIOCSIFDSTADDR _SIOC(0x0004) /* Set P-to-P address */
#define SIOCGIFBRDADDR _SIOC(0x0005) /* Get broadcast IP address */
#define SIOCSIFBRDADDR _SIOC(0x0006) /* Set broadcast IP address */
#define SIOCGIFNETMASK _SIOC(0x0007) /* Get network mask */
#define SIOCSIFNETMASK _SIOC(0x0008) /* Set network mask */
#define SIOCGIFMTU _SIOC(0x0009) /* Get MTU size */
#define SIOCGIFHWADDR _SIOC(0x000a) /* Get hardware address */
#define SIOCSIFHWADDR _SIOC(0x000b) /* Set hardware address */
#define SIOCDIFADDR _SIOC(0x000c) /* Delete IP address */
#define SIOCGIFCOUNT _SIOC(0x000d) /* Get number of devices */
#define SIOCGIPMSFILTER _SIOC(0x000e) /* Retrieve source filter addresses */
#define SIOCSIPMSFILTER _SIOC(0x000f) /* Set source filter content */
/* Wireless ioctl commands **************************************************/
#define SIOCSIWCOMMIT _SIOC(0x0010) /* Commit pending changes to driver */
#define SIOCGIWNAME _SIOC(0x0011) /* Get name of wireless protocol */
#define SIOCSIWNWID _SIOC(0x0012) /* Set network ID (pre-802.11) */
#define SIOCGIWNWID _SIOC(0x0013) /* Get network ID (the cell) */
#define SIOCSIWFREQ _SIOC(0x0014) /* Set channel/frequency (Hz) */
#define SIOCGIWFREQ _SIOC(0x0015) /* Get channel/frequency (Hz) */
#define SIOCSIWMODE _SIOC(0x0016) /* Set operation mode */
#define SIOCGIWMODE _SIOC(0x0017) /* Get operation mode */
#define SIOCSIWSENS _SIOC(0x0018) /* Set sensitivity (dBm) */
#define SIOCGIWSENS _SIOC(0x0019) /* Get sensitivity (dBm) */
#define SIOCGIWRANGE _SIOC(0x001a) /* Get range of parameters */
#define SIOCGIWPRIV _SIOC(0x001b) /* Get private ioctl interface info */
#define SIOCGIWSTATS _SIOC(0x001c) /* Get wireless stats */
#define SIOCSIWSPY _SIOC(0x001d) /* Set spy addresses */
#define SIOCGIWSPY _SIOC(0x001e) /* Get spy info (quality of link) */
#define SIOCSIWTHRSPY _SIOC(0x001f) /* Set spy threshold (spy event) */
#define SIOCGIWTHRSPY _SIOC(0x0020) /* Get spy threshold */
#define SIOCSIWAP _SIOC(0x0021) /* Set access point MAC addresses */
#define SIOCGIWAP _SIOC(0x0022) /* Get access point MAC addresses */
#define SIOCGIWAPLIST _SIOC(0x0023) /* Deprecated in favor of scanning */
#define SIOCSIWSCAN _SIOC(0x0024) /* Trigger scanning (list cells) */
#define SIOCGIWSCAN _SIOC(0x0025) /* Get scanning results */
#define SIOCSIWESSID _SIOC(0x0026) /* Set ESSID (network name) */
#define SIOCGIWESSID _SIOC(0x0027) /* Get ESSID */
#define SIOCSIWNICKN _SIOC(0x0028) /* Set node name/nickname */
#define SIOCGIWNICKN _SIOC(0x0029) /* Get node name/nickname */
#define SIOCSIWRATE _SIOC(0x002a) /* Set default bit rate (bps) */
#define SIOCGIWRATE _SIOC(0x002b) /* Get default bit rate (bps) */
#define SIOCSIWRTS _SIOC(0x002c) /* Set RTS/CTS threshold (bytes) */
#define SIOCGIWRTS _SIOC(0x002d) /* Get RTS/CTS threshold (bytes) */
#define SIOCSIWFRAG _SIOC(0x002e) /* Set fragmentation thr (bytes) */
#define SIOCGIWFRAG _SIOC(0x002f) /* Get fragmentation thr (bytes) */
#define SIOCSIWTXPOW _SIOC(0x0030) /* Set transmit power (dBm) */
#define SIOCGIWTXPOW _SIOC(0x0031) /* Get transmit power (dBm) */
#define SIOCSIWRETRY _SIOC(0x0032) /* Set retry limits and lifetime */
#define SIOCGIWRETRY _SIOC(0x0033) /* Get retry limits and lifetime */
#define SIOCSIWPOWER _SIOC(0x0034) /* Set Power Management settings */
#define SIOCGIWPOWER _SIOC(0x0035) /* Get Power Management settings */
#define SIOCSIWGENIE _SIOC(0x0030) /* Set generic IE */
#define SIOCGIWGENIE _SIOC(0x0031) /* Get generic IE */
#define SIOCSIWMLME _SIOC(0x0016) /* Request MLME operation */
#define SIOCSIWAUTH _SIOC(0x0032) /* Set authentication mode params */
#define SIOCGIWAUTH _SIOC(0x0033) /* Get authentication mode params */
#define SIOCSIWENCODEEXT _SIOC(0x0034) /* Set encoding token & mode */
#define SIOCGIWENCODEEXT _SIOC(0x0035) /* Get encoding token & mode */
#define SIOCSIWPMKSA _SIOC(0x0036) /* PMKSA cache operation */
/****************************************************************************
* Type Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#endif /* __NET_IOCTLS_H */
+370
View File
@@ -0,0 +1,370 @@
/****************************************************************************
* uip-arch.h
* Defines architecture-specific device driver interfaces to uIP
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Derived largely from portions of uIP with has a similar BSD-styple license:
*
* 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. 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.
*
****************************************************************************/
#ifndef __UIP_ARCH_H
#define __UIP_ARCH_H
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <net/if.h>
#include <net/uip/uip.h>
#ifdef CONFIG_NET_IGMP
# include <net/uip/uip-igmp.h>
#endif
/****************************************************************************
* Included Files
****************************************************************************/
#include <net/uip/uipopt.h>
#include <net/ethernet.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/* This structure collects information that is specific to a specific network
* interface driver. If the hardware platform supports only a single instance
* of this structure.
*/
struct uip_driver_s
{
/* This link is used to maintain a single-linked list of ethernet drivers.
* Must be the first field in the structure due to blink type casting.
*/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
FAR struct uip_driver_s *flink;
/* This is the name of network device assigned when netdev_register was called.
* This name is only used to support socket ioctl lookups by device name
* Examples: "eth0"
*/
char d_ifname[IFNAMSIZ];
#endif
/* Ethernet device identity */
#ifdef CONFIG_NET_ETHERNET
struct ether_addr d_mac; /* Device MAC address */
#endif
/* Network identity */
uip_ipaddr_t d_ipaddr; /* Host IP address assigned to the network interface */
uip_ipaddr_t d_draddr; /* Default router IP address */
uip_ipaddr_t d_netmask; /* Network subnet mask */
/* The d_buf array is used to hold incoming and outgoing packets. The device
* driver should place incoming data into this buffer. When sending data,
* the device driver should read the link level headers and the TCP/IP
* headers from this buffer. The size of the link level headers is
* configured by the UIP_LLH_LEN define.
*
* uIP will handle only a single buffer for both incoming and outgoing
* packets. However, the drive design may be concurrently send and
* filling separate, break-off buffers if CONFIG_NET_MULTIBUFFER is
* defined. That buffer management must be controlled by the driver.
*/
#ifdef CONFIG_NET_MULTIBUFFER
uint8_t *d_buf;
#else
uint8_t d_buf[CONFIG_NET_BUFSIZE + CONFIG_NET_GUARDSIZE];
#endif
/* d_appdata points to the location where application data can be read from
* or written into a packet.
*/
uint8_t *d_appdata;
/* This is a pointer into d_buf where a user application may append
* data to be sent.
*/
uint8_t *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_t *d_urgdata;
/* Length of the (received) urgent data */
uint16_t d_urglen;
#endif
/* The length of the packet in the d_buf buffer.
*
* Holds the length of the packet in the d_buf buffer.
*
* When the network device driver calls the uIP input function,
* d_len should be set to the length of the packet in the d_buf
* buffer.
*
* When sending packets, the device driver should use the contents of
* the d_len variable to determine the length of the outgoing
* packet.
*/
uint16_t d_len;
/* When d_buf contains outgoing xmit data, xmtlen is nonzero and represents
* the amount of appllcation data after d_snddata
*/
uint16_t d_sndlen;
/* IGMP group list */
#ifdef CONFIG_NET_IGMP
sq_queue_t grplist;
#endif
/* Driver callbacks */
int (*d_ifup)(struct uip_driver_s *dev);
int (*d_ifdown)(struct uip_driver_s *dev);
int (*d_txavail)(struct uip_driver_s *dev);
#ifdef CONFIG_NET_IGMP
int (*d_addmac)(struct uip_driver_s *dev, FAR const uint8_t *mac);
int (*d_rmmac)(struct uip_driver_s *dev, FAR const uint8_t *mac);
#endif
/* Drivers may attached device-specific, private information */
void *d_private;
};
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* uIP device driver functions
*
* These functions are used by a network device driver for interacting
* with uIP.
*
* Process an incoming packet.
*
* This function should be called when the device driver has received
* a packet from the network. The packet from the device driver must
* be present in the d_buf buffer, and the length of the packet
* should be placed in the d_len field.
*
* When the function returns, there may be an outbound packet placed
* in the d_buf packet buffer. If so, the d_len field is set to
* the length of the packet. If no packet is to be sent out, the
* d_len field is set to 0.
*
* The usual way of calling the function is presented by the source
* code below.
*
* dev->d_len = devicedriver_poll();
* if(dev->d_len > 0) {
* uip_input(dev);
* if(dev->d_len > 0) {
* devicedriver_send();
* }
* }
*
* Note: If you are writing a uIP device driver that needs ARP
* (Address Resolution Protocol), e.g., when running uIP over
* Ethernet, you will need to call the uIP ARP code before calling
* this function:
*
* #define BUF ((struct uip_eth_hdr *)&dev->d_buf[0])
* dev->d_len = ethernet_devicedrver_poll();
* if(dev->d_len > 0) {
* if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
* uip_arp_ipin();
* uip_input(dev);
* if(dev->d_len > 0) {
* uip_arp_out();
* devicedriver_send();
* }
* } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
* uip_arp_arpin();
* if(dev->d_len > 0) {
* devicedriver_send();
* }
* }
*/
extern void uip_input(struct uip_driver_s *dev);
/* Polling of connections
*
* These functions will traverse each active uIP connection structure and
* perform appropriate operatios: uip_timer() will perform TCP timer
* operations (and UDP polling operations); uip_poll() will perform TCP
* and UDP polling operations. The CAN driver MUST implement logic to
* periodically call uip_timer(); uip_poll() may be called asychronously
* from the network driver can accept another outgoing packet.
*
* In both cases, these functions will call the provided callback function
* for every active connection. Polling will continue until all connections
* have been polled or until the user-suplied function returns a non-zero
* value (which it should do only if it cannot accept further write data).
*
* When the callback function is called, there may be an outbound packet
* waiting for service in the uIP packet buffer, and if so the d_len field
* is set to a value larger than zero. The device driver should then send
* out the packet.
*
* Example:
* int driver_callback(struct uip_driver_dev *dev)
* {
* if (dev->d_len > 0)
* {
* devicedriver_send();
* return 1; <-- Terminates polling if necessary
* }
* return 0;
* }
*
* ...
* uip_poll(dev, driver_callback);
*
* Note: If you are writing a uIP device driver that needs ARP (Address
* Resolution Protocol), e.g., when running uIP over Ethernet, you will
* need to call the uip_arp_out() function in the callback function
* before sending the packet:
*
* int driver_callback(struct uip_driver_dev *dev)
* {
* if (dev->d_len > 0)
* {
* uip_arp_out();
* devicedriver_send();
* return 1; <-- Terminates polling if necessary
* }
* return 0;
* }
*/
typedef int (*uip_poll_callback_t)(struct uip_driver_s *dev);
extern int uip_poll(struct uip_driver_s *dev, uip_poll_callback_t callback);
extern int uip_timer(struct uip_driver_s *dev, uip_poll_callback_t callback, int hsec);
/* By defining UIP_ARCH_CHKSUM, the architecture can replace up_incr32
* with hardware assisted solutions.
*/
/* Carry out a 32-bit addition.
*
* op32 - A pointer to a 4-byte array representing a 32-bit
* integer in network byte order (big endian). This value may not
* be word aligned. The value pointed to by op32 is modified in place
*
* op16 - A 16-bit integer in host byte order.
*/
extern void uip_incr32(uint8_t *op32, uint16_t op16);
/* Calculate the Internet checksum over a buffer.
*
* The Internet checksum is the one's complement of the one's
* complement sum of all 16-bit words in the buffer.
*
* See RFC1071.
*
* Note: This function is not called in the current version of uIP,
* but future versions might make use of it.
*
* buf A pointer to the buffer over which the checksum is to be
* computed.
*
* len The length of the buffer over which the checksum is to
* be computed.
*
* Return: The Internet checksum of the buffer.
*/
extern uint16_t uip_chksum(uint16_t *buf, uint16_t len);
/* Calculate the IP header checksum of the packet header in d_buf.
*
* The IP header checksum is the Internet checksum of the 20 bytes of
* the IP header.
*
* Return: The IP header checksum of the IP header in the d_buf
* buffer.
*/
extern uint16_t uip_ipchksum(struct uip_driver_s *dev);
/* Calculate the TCP checksum of the packet in d_buf and d_appdata.
*
* The TCP checksum is the Internet checksum of data contents of the
* TCP segment, and a pseudo-header as defined in RFC793.
*
* Note: The d_appdata pointer that points to the packet data may
* point anywhere in memory, so it is not possible to simply calculate
* the Internet checksum of the contents of the d_buf buffer.
*
* Return: The TCP checksum of the TCP segment in d_buf and pointed
* to by d_appdata.
*/
extern uint16_t uip_tcpchksum(struct uip_driver_s *dev);
extern uint16_t uip_udpchksum(struct uip_driver_s *dev);
extern uint16_t uip_icmpchksum(struct uip_driver_s *dev, int len);
#endif /* __UIP_ARCH_H */
+262
View File
@@ -0,0 +1,262 @@
/****************************************************************************
* include/net/uip/uip-arch.h
* Macros and definitions for the ARP module.
*
* Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Derived from uIP with has a similar BSD-styple 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 __UIP_ARP_H__
#define __UIP_ARP_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include <net/ethernet.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Recognized values of the type bytes in the Ethernet header */
#define UIP_ETHTYPE_ARP 0x0806
#define UIP_ETHTYPE_IP 0x0800
#define UIP_ETHTYPE_IP6 0x86dd
/****************************************************************************
* Public Types
****************************************************************************/
/* The Ethernet header -- 14 bytes. The first two fields are type 'struct
* ether_addr but are represented as a simple byte array here because
* some compilers refuse to pack 6 byte structures.
*/
struct uip_eth_hdr
{
uint8_t dest[6]; /* Ethernet destination address (6 bytes) */
uint8_t src[6]; /* Ethernet source address (6 bytes) */
uint16_t type; /* Type code (2 bytes) */
};
/* One entry in the ARP table (volatile!) */
struct arp_entry
{
in_addr_t at_ipaddr; /* IP address */
struct ether_addr at_ethaddr; /* Hardware address */
uint8_t at_time;
};
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_NET_ARP
/****************************************************************************
* Name: uip_arp_init
*
* Description:
* Initialize the ARP module. This function must be called before any of
* the other ARP functions.
*
****************************************************************************/
EXTERN void uip_arp_init(void);
/****************************************************************************
* Name: uip_arp_ipin
*
* Description:
* The uip_arp_ipin() function should be called whenever an IP packet
* arrives from the Ethernet. This function refreshes the ARP table or
* inserts a new mapping if none exists. The function assumes that an
* IP packet with an Ethernet header is present in the d_buf buffer
* and that the length of the packet is in the d_len field.
*
****************************************************************************/
#ifdef CONFIG_NET_ARP_IPIN
EXTERN void uip_arp_ipin(struct uip_driver_s *dev);
#else
# define uip_arp_ipin(dev)
#endif
/****************************************************************************
* Name: uip_arp_arpin
*
* Description:
* The uip_arp_arpin() should be called when an ARP packet is received
* by the Ethernet driver. This function also assumes that the
* Ethernet frame is present in the d_buf buffer. When the
* uip_arp_arpin() function returns, the contents of the d_buf
* buffer should be sent out on the Ethernet if the d_len field
* is > 0.
*
****************************************************************************/
EXTERN void uip_arp_arpin(struct uip_driver_s *dev);
/****************************************************************************
* Name: uip_arp_arpin
*
* Description:
* The uip_arp_out() function should be called when an IP packet
* should be sent out on the Ethernet. This function creates an
* Ethernet header before the IP header in the d_buf buffer. The
* Ethernet header will have the correct Ethernet MAC destination
* address filled in if an ARP table entry for the destination IP
* address (or the IP address of the default router) is present. If no
* such table entry is found, the IP packet is overwritten with an ARP
* request and we rely on TCP to retransmit the packet that was
* overwritten. In any case, the d_len field holds the length of
* the Ethernet frame that should be transmitted.
*
****************************************************************************/
EXTERN void uip_arp_out(struct uip_driver_s *dev);
/****************************************************************************
* Name: uip_arp_timer
*
* Description:
* This function performs periodic timer processing in the ARP module
* and should be called at regular intervals. The recommended interval
* is 10 seconds between the calls. It is responsible for flushing old
* entries in the ARP table.
*
****************************************************************************/
EXTERN void uip_arp_timer(void);
/****************************************************************************
* Name: uip_arp_update
*
* Description:
* Add the IP/HW address mapping to the ARP table -OR- change the IP
* address of an existing association.
*
* Input parameters:
* pipaddr - Refers to an IP address uint16_t[2] in network order
* ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN]
*
* Assumptions
* Interrupts are disabled
*
****************************************************************************/
EXTERN void uip_arp_update(uint16_t *pipaddr, uint8_t *ethaddr);
/****************************************************************************
* Name: uip_arp_find
*
* Description:
* Find the ARP entry corresponding to this IP address.
*
* Input parameters:
* ipaddr - Refers to an IP address in network order
*
* Assumptions
* Interrupts are disabled; Returned value will become unstable when
* interrupts are re-enabled or if any other uIP APIs are called.
*
****************************************************************************/
EXTERN struct arp_entry *uip_arp_find(in_addr_t ipaddr);
/****************************************************************************
* Name: uip_arp_delete
*
* Description:
* Remove an IP association from the ARP table
*
* Input parameters:
* ipaddr - Refers to an IP address in network order
*
* Assumptions
* Interrupts are disabled
*
****************************************************************************/
#define uip_arp_delete(ipaddr) \
{ \
struct arp_entry *tabptr = uip_arp_find(ipaddr); \
if (tabptr) \
{ \
tabptr->at_ipaddr = 0; \
} \
}
#else /* CONFIG_NET_ARP */
/* If ARP is disabled, stub out all ARP interfaces */
# define uip_arp_init()
# define uip_arp_ipin(dev)
# define uip_arp_arpin(dev)
# define uip_arp_out(dev)
# define uip_arp_timer()
# define uip_arp_update(pipaddr,ethaddr)
# define uip_arp_find(ipaddr) NULL
# define uip_arp_delete(ipaddr)
#endif /* CONFIG_NET_ARP */
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __UIP_ARP_H__ */
+211
View File
@@ -0,0 +1,211 @@
/****************************************************************************
* net/uip/uip-icmp.h
* Header file for the uIP ICMP stack.
*
* Copyright (C) 2007-2009 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 <stdint.h>
#include <net/uip/uipopt.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* ICMP/ICMP6 definitions */
/* ICMP/ICMP6 Message Types */
#define ICMP_ECHO_REPLY 0 /* RFC 792 */
#define ICMP_DEST_UNREACHABLE 3 /* RFC 792 */
#define ICMP_SRC_QUENCH 4 /* RFC 792 */
#define ICMP_REDIRECT 5 /* RFC 792 */
#define ICMP_ALT_HOST_ADDRESS 6
#define ICMP_ECHO_REQUEST 8 /* RFC 792 */
#define ICMP_ROUTER_ADVERTISEMENT 9 /* RFC 1256 */
#define ICMP_ROUTER_SOLICITATION 10 /* RFC 1256 */
#define ICMP_TIME_EXCEEDED 11 /* RFC 792 */
#define ICMP_PARAMETER_PROBLEM 12
#define ICMP_TIMESTAMP_REQUEST 13
#define ICMP_TIMESTAMP_REPLY 14
#define ICMP_INFORMATION_REQUEST 15
#define ICMP_INFORMATION_REPLY 16
#define ICMP_ADDRESS_MASK_REQUEST 17
#define ICMP_ADDRESS_MASK_REPLY 18
#define ICMP_TRACEROUTE 30
#define ICMP_CONVERSION_ERROR 31
#define ICMP_MOBILE_HOST_REDIRECT 32
#define ICMP_IPV6_WHEREAREYOU 33
#define ICMP_IPV6_IAMHERE 34
#define ICMP_MOBILE_REGIS_REQUEST 35
#define ICMP_MOBILE_REGIS_REPLY 36
#define ICMP_DOMAIN_NAME_REQUEST 37
#define ICMP_DOMAIN_NAME_REPLY 38
#define ICMP_SKIP_DISCOVERY_PROTO 39
#define ICMP_PHOTURIS_SECURITY_FAIL 40
#define ICMP_EXP_MOBILE_PROTO 41 /* RFC 4065 */
/* ICMP6 Message Types */
#define ICMP6_ECHO_REPLY 129
#define ICMP6_ECHO_REQUEST 128
#define ICMP6_NEIGHBOR_SOLICITATION 135
#define ICMP6_NEIGHBOR_ADVERTISEMENT 136
#define ICMP6_FLAG_S (1 << 6)
#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1
#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2
/* Header sizes */
#define UIP_ICMPH_LEN 4 /* Size of ICMP header */
#define UIP_IPICMPH_LEN (UIP_ICMPH_LEN + UIP_IPH_LEN) /* Size of IP + ICMP header */
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* The ICMP and IP headers */
struct uip_icmpip_hdr
{
#ifdef CONFIG_NET_IPv6
/* IPv6 Ip header */
uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
uint8_t 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_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
uint8_t len[2]; /* 16-bit Total length */
uint8_t ipid[2]; /* 16-bit Identification */
uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
uint8_t ttl; /* 8-bit Time to Live */
uint8_t proto; /* 8-bit Protocol */
uint16_t ipchksum; /* 16-bit Header checksum */
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
#endif /* CONFIG_NET_IPv6 */
/* ICMP header */
uint8_t type; /* Defines the format of the ICMP message */
uint8_t icode; /* Further qualifies the ICMP messsage */
uint16_t icmpchksum; /* Checksum of ICMP header and data */
/* Data following the ICMP header contains the data specific to the
* message type indicated by the Type and Code fields.
*/
#ifndef CONFIG_NET_IPv6
/* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */
uint16_t id; /* Used to match requests with replies */
uint16_t seqno; /* " " "" " " " " " " " " */
#else /* !CONFIG_NET_IPv6 */
/* ICMP6_ECHO_REQUEST and ICMP6_ECHO_REPLY data */
uint8_t flags;
uint8_t reserved1;
uint8_t reserved2;
uint8_t reserved3;
uint8_t icmp6data[16];
uint8_t 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
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, int dsecs);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __NET_UIP_UIP_ICMP_H */
+258
View File
@@ -0,0 +1,258 @@
/****************************************************************************
* net/uip/uip-igmp.h
* The definitions in this header file are intended only for internal use
* by the NuttX port of the uIP stack.
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* 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 CITEL Technologies Ltd 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 CITEL TECHNOLOGIES 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 CITEL TECHNOLOGIES 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 __NET_UIP_IGMP_H
#define __NET_UIP_IGMP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
#include <netinet/in.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NET_IPv6
# error "IGMP for IPv6 not supported"
#endif
/* IGMP packet types */
#define IGMP_MEMBERSHIP_QUERY 0x11 /* Membership Query */
#define IGMPv1_MEMBERSHIP_REPORT 0x12 /* IGMP Ver. 1 Membership Report */
#define IGMPv2_MEMBERSHIP_REPORT 0x16 /* IGMP Ver. 2 Membership Report */
#define IGMPv3_MEMBERSHIP_REPORT 0x22 /* IGMP Ver. 3 Membership Report */
#define IGMP_LEAVE_GROUP 0x17 /* Leave Group */
/* Header sizes:
*
* UIP_IGMPH_LEN - Size of IGMP header in bytes
* UIP_IPIGMPH_LEN - Size of IP + Size of IGMP header + Size of router alert
*/
#define UIP_IGMPH_LEN 8
#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN + 4)
/* Group flags */
#define IGMP_PREALLOCATED (1 << 0)
#define IGMP_LASTREPORT (1 << 1)
#define IGMP_IDLEMEMBER (1 << 2)
#define IGMP_SCHEDMSG (1 << 3)
#define IGMP_WAITMSG (1 << 4)
#define SET_PREALLOCATED(f) do { (f) |= IGMP_PREALLOCATED; } while (0)
#define SET_LASTREPORT(f) do { (f) |= IGMP_LASTREPORT; } while (0)
#define SET_IDLEMEMBER(f) do { (f) |= IGMP_IDLEMEMBER; } while (0)
#define SET_SCHEDMSG(f) do { (f) |= IGMP_SCHEDMSG; } while (0)
#define SET_WAITMSG(f) do { (f) |= IGMP_WAITMSG; } while (0)
#define CLR_PREALLOCATED(f) do { (f) &= ~IGMP_PREALLOCATED; } while (0)
#define CLR_LASTREPORT(f) do { (f) &= ~IGMP_LASTREPORT; } while (0)
#define CLR_IDLEMEMBER(f) do { (f) &= ~IGMP_IDLEMEMBER; } while (0)
#define CLR_SCHEDMSG(f) do { (f) &= ~IGMP_SCHEDMSG; } while (0)
#define CLR_WAITMSG(f) do { (f) &= ~IGMP_WAITMSG; } while (0)
#define IS_PREALLOCATED(f) (((f) & IGMP_PREALLOCATED) != 0)
#define IS_LASTREPORT(f) (((f) & IGMP_LASTREPORT) != 0)
#define IS_IDLEMEMBER(f) (((f) & IGMP_IDLEMEMBER) != 0)
#define IS_SCHEDMSG(f) (((f) & IGMP_SCHEDMSG) != 0)
#define IS_WAITMSG(f) (((f) & IGMP_WAITMSG) != 0)
#define IGMP_TTL 1
/****************************************************************************
* Public Types
****************************************************************************/
/* IGMPv2 packet structure as defined by RFC 2236.
*
* The Max Respone Time (maxresp) specifies the time limit for the
* corresponding report. The field has a resolution of 100 miliseconds, the
* value is taken directly. This field is meaningful only in Membership Query
* (0x11); in other messages it is set to 0 and ignored by the receiver.
*/
struct uip_igmphdr_s
{
#ifdef CONFIG_NET_IPv6
/* IPv6 Ip header */
uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
uint8_t 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_t vhl; /* 8-bit Version (4) and header length (6 with Router Alert) */
uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
uint8_t len[2]; /* 16-bit Total length */
uint8_t ipid[2]; /* 16-bit Identification */
uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
uint8_t ttl; /* 8-bit Time to Live */
uint8_t proto; /* 8-bit Protocol */
uint16_t ipchksum; /* 16-bit Header checksum */
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
#endif /* CONFIG_NET_IPv6 */
/* Router Alert IP header option */
uint16_t ra[2];
/* IGMPv2 header:
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type | Max Resp Time | Checksum |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Group Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
uint8_t type; /* 8-bit IGMP packet type */
uint8_t maxresp; /* 8-bit Max response time */
uint16_t chksum; /* 16-bit Checksum */
uint16_t grpaddr[2]; /* 32-bit Group address */
};
#ifdef CONFIG_NET_STATISTICS
struct uip_igmp_stats_s
{
uint32_t length_errors;
uint32_t chksum_errors;
uint32_t v1_received;
uint32_t joins;
uint32_t leaves;
uint32_t leave_sched;
uint32_t report_sched;
uint32_t poll_send;
uint32_t ucast_query;
uint32_t query_received;
uint32_t report_received;
};
# define IGMP_STATINCR(p) ((p)++)
#else
# define IGMP_STATINCR(p)
#endif
/* This structure represents one group member. There is a list of groups
* for each device interface structure.
*
* There will be a group for the all systems group address but this
* will not run the state machine as it is used to kick off reports
* from all the other groups
*/
typedef FAR struct wdog_s *WDOG_ID;
struct igmp_group_s
{
struct igmp_group_s *next; /* Implements a singly-linked list */
uip_ipaddr_t grpaddr; /* Group IP address */
WDOG_ID wdog; /* WDOG used to detect timeouts */
sem_t sem; /* Used to wait for message transmission */
volatile uint8_t flags; /* See IGMP_ flags definitions */
uint8_t msgid; /* Pending message ID (if non-zero) */
};
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN uip_ipaddr_t g_allsystems;
EXTERN uip_ipaddr_t g_allrouters;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: uip_igmpdevinit
*
* Description:
* Called when a new network device is registered to configure that device
* for IGMP support.
*
****************************************************************************/
EXTERN void uip_igmpdevinit(struct uip_driver_s *dev);
EXTERN int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr);
EXTERN int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_NET_IGMP */
#endif /* __NET_UIP_IGMP_H */
+251
View File
@@ -0,0 +1,251 @@
/************************************************************************************************************
* net/uip/uip-ipopt.h
*
* Defines values for the IP header options
*
* Copyright (C) 2010 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.
*
************************************************************************************************************/
#ifndef __NET_UIP_UIP_IPOPT_H
#define __NET_UIP_UIP_IPOPT_H
/************************************************************************************************************
* Included Files
************************************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************************************
* Pre-processor Definitions
************************************************************************************************************/
/* IP Header Options:
*
* The basic 20-byte IP header can be extended by up to another 40 bytes
* (in units of 4 bytes) to provide IP options. The format of a single IP
* option is as follows:
*
* Single byte options:
*
* Type: 8-bits
*
* Multi-byte options:
*
* Type: 8-bits
* Length: 8-bits
* Pointer: 8-bits:
* Option Data: (depends on Length)
*
* The IP Option Type byte consists of the following subfields:
*/
#define IPOPT_TYPE_OPTION_SHIFT (0) /* Bits 0-5: Option number*/
#define IPOPT_TYPE_OPTION_MASK (0x1f << IPOPT_TYPE_OPTION_SHIFT)
# define IPOPT_TYPE_OPTION_END (0 << IPOPT_TYPE_OPTION_SHIFT) /* End of options list (RFC 791) */
# define IPOPT_TYPE_OPTION_NOOP (1 << IPOPT_TYPE_OPTION_SHIFT) /* No operation (RFC 791) */
# define IPOPT_TYPE_OPTION_SEC (2 << IPOPT_TYPE_OPTION_SHIFT) /* Security (RFC 791, 1108) */
# define IPOPT_TYPE_OPTION_LSRR (3 << IPOPT_TYPE_OPTION_SHIFT) /* Loose source and record route (RFC 791) */
# define IPOPT_TYPE_OPTION_TIMESTAMP (4 << IPOPT_TYPE_OPTION_SHIFT) /* Timestamp (RFC 781, 791) */
# define IPOPT_TYPE_OPTION_EXTSEC (5 << IPOPT_TYPE_OPTION_SHIFT) /* Extended security (RFC 1108) */
# define IPOPT_TYPE_OPTION_COMMSEC (6 << IPOPT_TYPE_OPTION_SHIFT) /* Commercial security */
# define IPOPT_TYPE_OPTION_RR (7 << IPOPT_TYPE_OPTION_SHIFT) /* Record route (RFC 791) */
# define IPOPT_TYPE_OPTION_SSID (8 << IPOPT_TYPE_OPTION_SHIFT) /* Stream ID (RFC 791, 1122) */
# define IPOPT_TYPE_OPTION_SSRR (9 << IPOPT_TYPE_OPTION_SHIFT) /* Strict source and record route (RFC 791) */
# define IPOPT_TYPE_OPTION_EXPMEAS (10 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental measurement */
# define IPOPT_TYPE_OPTION_MTUPROBE (11 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Probe (RFC 1063) */
# define IPOPT_TYPE_OPTION_MTUREPLY (12 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Reply (RFC 1063) */
# define IPOPT_TYPE_OPTION_EXPFC (13 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental flow control */
# define IPOPT_TYPE_OPTION_EXPAC (14 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental access control */
# define IPOPT_TYPE_OPTION_ENCODE (15 << IPOPT_TYPE_OPTION_SHIFT) /* ENCODE */
# define IPOPT_TYPE_OPTION_IMITD (16 << IPOPT_TYPE_OPTION_SHIFT) /* IMI traffic descriptor */
# define IPOPT_TYPE_OPTION_EXTIP (17 << IPOPT_TYPE_OPTION_SHIFT) /* Extended IP (RFC 1385) */
# define IPOPT_TYPE_OPTION_TR (18 << IPOPT_TYPE_OPTION_SHIFT) /* Traceroute (RFC 1393) */
# define IPOPT_TYPE_OPTION_ADDREXT (19 << IPOPT_TYPE_OPTION_SHIFT) /* Address extension (RFC 1475) */
# define IPOPT_TYPE_OPTION_RA (20 << IPOPT_TYPE_OPTION_SHIFT) /* Router alert (RFC 2113) */
# define IPOPT_TYPE_OPTION_SDBM (21 << IPOPT_TYPE_OPTION_SHIFT) /* Selective direct broadcast mode (RFC 1770) */
# define IPOPT_TYPE_OPTION_DPS (23 << IPOPT_TYPE_OPTION_SHIFT) /* Dynamic packet state */
# define IPOPT_TYPE_OPTION_UMP (24 << IPOPT_TYPE_OPTION_SHIFT) /* Upstream multicast packet */
# define IPOPT_TYPE_OPTION_QS (25 << IPOPT_TYPE_OPTION_SHIFT) /* Quick start (RFC 4782) */
# define IPOPT_TYPE_OPTION_EXP3692 (30 << IPOPT_TYPE_OPTION_SHIFT) /* RFC 3692-style experiment (RFC 4782) */
#define IPOPT_TYPE_CLASS_SHIFT (5) /* Bits 5-6: Class */
#define IPOPT_TYPE_CLASS_MASK (3 << IPOPT_TYPE_CLASS_SHIFT)
# define IPOPT_TYPE_CLASS_CTRL (0 << IPOPT_TYPE_CLASS_SHIFT) /* Control */
# define IPOPT_TYPE_CLASS_MEASURE (2 << IPOPT_TYPE_CLASS_SHIFT) /* Debugging and measurement */
#define IPOPT_TYPE_COPIED (1 << 7) /* Bit 7: IP layer must copy option to each fragment */
#define IPOPT_TYPE_NOTCOPIED (0)
/* IP Option encoding macros */
#define IPOPT_MKTYPE(copied,class,option) (copied|class|option)
#define IPOPT_MKOPTION8(copied,class,option) \
((uint8_t)IPOPT_MKTYPE(copied,class,option))
#define IPOPT_MKOPTION32(type,len,ptr,data) \
((uint32_t)(type) << 24 | (uint32_t)(len) << 16 | \
(uint32_t)(ptr) << 8 | (uint32_t)(data))
/* Option Copy Class Length Description References
* ------ ---- ----- --------- ------------------------------------------------
* 0 0 0 1 End of options list (RFC 791)
* 1 0 0 1 NOP (RFC 791
* 2 1 0 11 Security (RFC 791, RFC 1108)
* 3 1 0 variable Loose Source Route (RFC 791)
* 4 0 2 variable Time stamp (RFC 781, RFC 791)
* 5 1 0 3-31 Extended Security (RFC 1108)
* 6 1 0 Commercial Security
* 7 0 0 variable Record Route (RFC 791)
* 8 1 0 4 Stream Identifier (RFC 791, RFC 1122)
* 9 1 0 variable Strict Source Route (RFC 791)
* 10 0 0 Experimental Measurement
* 11 0 0 4 MTU Probe (obsolete) (RFC 1063)
* 12 0 0 4 MTU Reply (obsolete) (RFC 1063)
* 13 1 2 Experimental Flow Control
* 14 1 0 Experimental Access Control
* 15 0 0 ENCODE
* 16 1 0 IMI Traffic Descriptor
* 17 1 0 variable Extended Internet Protocol (RFC 1385)
* 18 0 2 12 Traceroute (RFC 1393)
* 19 1 0 10 Address Extension (RFC 1475)
* 20 1 0 4 Router Alert (RFC 2113)
* 21 1 0 6-38 Selective Directed Broadcast Mode (RFC 1770)
* 22 1 0
* 23 1 0 Dynamic Packet State
* 24 1 0 Upstream Multicast Packet
* 25 0 0 QS, Quick-Start (RFC 4782)
* 26
* -
* 29
* 30 0 0 EXP - RFC3692-style Experiment (RFC 4727)
* 30 0 2 EXP - RFC3692-style Experiment (RFC 4727)
* 30 1 0 EXP - RFC3692-style Experiment RFC 4727)
* 30 1 2 EXP - RFC3692-style Experiment (RFC 4727)
* 31
*/
#define IPOTR_END_LEN 1
#define IPOPT_END_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_END)
#define IPOTR_NOOP_LEN 1
#define IPOPT_NOOP_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_NOOP)
#define IPOPT_SEC_LEN 11
#define IPOPT_SEC_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SEC)
#define IPOPT_LSRR_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_LSRR)
#define IPOPT_TIMESTAMP_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TIMESTAMP)
#define IPOPT_EXTSEC_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTSEC)
#define IPOPT_COMMSEC_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_COMMSEC)
#define IPOPT_RR_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RR)
#define IPOPT_SSID_LEN 4
#define IPOPT_SSID_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSID)
#define IPOPT_SSRR_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSRR)
#define IPOPT_EXPMEAS_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPMEAS)
#define IPOPT_MTUPROBE_LEN 4
#define IPOPT_MTUPROBE_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUPROBE)
#define IPOPT_MTUREPLY_LEN 4
#define IPOPT_MTUREPLY_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUREPLY)
#define IPOPT_EXPFC_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_EXPFC)
#define IPOPT_EXPAC_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPAC)
#define IPOPT_ENCODE_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ENCODE)
#define IPOPT_IMITD_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_IMITD)
#define IPOPT_EXTIP_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTIP)
#define IPOPT_TR_LEN 12
#define IPOPT_TR_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TR)
#define IPOPT_ADDREXT_LEN 10
#define IPOPT_ADDREXT_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ADDREXT)
#define IPOPT_RA_LEN 4
#define IPOPT_RA_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RA)
#define IPOPT_RA \
IPOPT_MKOPTION32(IPOPT_RA_TYPE, 4, 0, 0)
#define IPOPT_SDBM_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SDBM)
#define IPOPT_DPS_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_DPS)
#define IPOPT_UMP_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_UMP)
#define IPOPT_QS_TYPE \
IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_QS)
/************************************************************************************************************
* Public Type Definitions
************************************************************************************************************/
/************************************************************************************************************
* Public Data
************************************************************************************************************/
/************************************************************************************************************
* Public Function Prototypes
************************************************************************************************************/
#endif /* __NET_UIP_UIP_IPOPT_H */
+460
View File
@@ -0,0 +1,460 @@
/****************************************************************************
* 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, 2009-2010 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 <stdint.h>
#include <stdbool.h>
#include <net/uip/uipopt.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* TCP definitions */
#define TCP_FIN 0x01
#define TCP_SYN 0x02
#define TCP_RST 0x04
#define TCP_PSH 0x08
#define TCP_ACK 0x10
#define TCP_URG 0x20
#define TCP_CTL 0x3f
#define TCP_OPT_END 0 /* End of TCP options list */
#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */
#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */
#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */
/* The TCP states used in the struct uip_conn tcpstateflags field */
#define UIP_TS_MASK 0x0f /* Bits 0-3: TCP state */
#define UIP_CLOSED 0x00 /* The connection is not in use and available */
#define UIP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */
#define UIP_SYN_RCVD 0x02
#define UIP_SYN_SENT 0x03
#define UIP_ESTABLISHED 0x04
#define UIP_FIN_WAIT_1 0x05
#define UIP_FIN_WAIT_2 0x06
#define UIP_CLOSING 0x07
#define UIP_TIME_WAIT 0x08
#define UIP_LAST_ACK 0x09
#define UIP_STOPPED 0x10 /* Bit 4: stopped */
/* Bit 5-7: Unused, but not available */
/* Flag bits in 16-bit flags+ipoffset IPv4 TCP header field */
#define UIP_TCPFLAG_RESERVED 0x8000
#define UIP_TCPFLAG_DONTFRAG 0x4000
#define UIP_TCPFLAG_MOREFRAGS 0x2000
/* TCP 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_callback_s; /* Forward reference */
struct uip_backlog_s; /* Forward reference */
struct uip_conn
{
dq_entry_t node; /* Implements a doubly linked list */
uip_ipaddr_t ripaddr; /* The IP address of the remote host */
uint16_t lport; /* The local TCP port, in network byte order */
uint16_t rport; /* The remoteTCP port, in network byte order */
uint8_t rcvseq[4]; /* The sequence number that we expect to
* receive next */
uint8_t sndseq[4]; /* The sequence number that was last sent by us */
uint16_t unacked; /* Number bytes sent but not yet ACKed */
uint16_t mss; /* Current maximum segment size for the
* connection */
uint16_t initialmss; /* Initial maximum segment size for the
* connection */
uint8_t crefs; /* Reference counts on this instance */
uint8_t sa; /* Retransmission time-out calculation state
* variable */
uint8_t sv; /* Retransmission time-out calculation state
* variable */
uint8_t rto; /* Retransmission time-out */
uint8_t tcpstateflags; /* TCP state and flags */
uint8_t timer; /* The retransmission timer (units: half-seconds) */
uint8_t nrtx; /* The number of retransmissions for the last
* segment sent */
/* Read-ahead buffering.
*
* readahead - A singly linked list of type struct uip_readahead_s
* where the TCP/IP read-ahead data is retained.
*/
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
sq_queue_t readahead; /* Read-ahead buffering */
#endif
/* Listen backlog support
*
* blparent - The backlog parent. If this connection is backlogged,
* this field will be non-null and will refer to the TCP connection
* structure in which this connection is backlogged.
* backlog - The pending connection backlog. If this connection is
* configured as a listener with backlog, then this refers to the
* struct uip_backlog_s tear-off structure that manages that backlog.
*/
#ifdef CONFIG_NET_TCPBACKLOG
struct uip_conn *blparent;
struct uip_backlog_s *backlog;
#endif
/* Application callbacks:
*
* Data transfer events are retained in 'list'. Event handlers in 'list'
* are called for events specified in the flags set within struct
* uip_callback_s
*
* When an callback is executed from 'list', the input flags are normally
* returned, however, the implementation 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.
*
* And/Or set/clear the following:
*
* UIP_NEWDATA - May be cleared to indicate that the data was consumed
* and that no further process of the new data should be
* attempted.
* UIP_SNDACK - If UIP_NEWDATA is cleared, then UIP_SNDACK may be set
* to indicate that an ACK should be included in the response.
* (In UIP_NEWDATA is cleared bu UIP_SNDACK is not set, then
* dev->d_len should also be cleared).
*/
struct uip_callback_s *list;
/* accept() is called when the TCP logic has created a connection */
FAR void *accept_private;
int (*accept)(FAR struct uip_conn *listener, struct uip_conn *conn);
/* connection_event() is called on any of the subset of connection-related events */
FAR void *connection_private;
void (*connection_event)(FAR struct uip_conn *conn, uint16_t 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_t rh_nbytes; /* Number of bytes available in this buffer */
uint8_t rh_buffer[CONFIG_NET_TCP_READAHEAD_BUFSIZE];
};
#endif
/* Support for listen backlog:
*
* struct uip_blcontainer_s describes one backlogged connection
* struct uip_backlog_s is a "tear-off" describing all backlog for a
* listener connection
*/
#ifdef CONFIG_NET_TCPBACKLOG
struct uip_blcontainer_s
{
sq_entry_t bc_node; /* Implements a singly linked list */
FAR struct uip_conn *bc_conn; /* Holds reference to the new connection structure */
};
struct uip_backlog_s
{
sq_queue_t bl_free; /* Implements a singly-linked list of free containers */
sq_queue_t bl_pending; /* Implements a singly-linked list of pending connections */
};
#endif
/* 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 received 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_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
uint8_t 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_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
uint8_t len[2]; /* 16-bit Total length */
uint8_t ipid[2]; /* 16-bit Identification */
uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
uint8_t ttl; /* 8-bit Time to Live */
uint8_t proto; /* 8-bit Protocol */
uint16_t ipchksum; /* 16-bit Header checksum */
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
#endif /* CONFIG_NET_IPv6 */
/* TCP header */
uint16_t srcport;
uint16_t destport;
uint8_t seqno[4];
uint8_t ackno[4];
uint8_t tcpoffset;
uint8_t flags;
uint8_t wnd[2];
uint16_t tcpchksum;
uint8_t urgp[2];
uint8_t 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);
/* Allocate a new TCP data callback */
#define uip_tcpcallbackalloc(conn) uip_callbackalloc(&conn->list)
#define uip_tcpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list)
/* 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);
/* 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 */
/* Backlog support */
#ifdef CONFIG_NET_TCPBACKLOG
/* APIs to create and terminate TCP backlog support */
extern int uip_backlogcreate(FAR struct uip_conn *conn, int nblg);
extern int uip_backlogdestroy(FAR struct uip_conn *conn);
/* APIs to manage individual backlog actions */
extern int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn);
#ifndef CONFIG_DISABLE_POLL
extern bool uip_backlogavailable(FAR struct uip_conn *conn);
#else
# define uip_backlogavailable(conn) (false);
#endif
extern FAR struct uip_conn *uip_backlogremove(FAR struct uip_conn *conn);
extern int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn);
#else
# define uip_backlogcreate(conn,nblg) (-ENOSYS)
# define uip_backlogdestroy(conn) (-ENOSYS)
# define uip_backlogadd(conn,blconn) (-ENOSYS)
# define uip_backlogavailable(conn) (false);
# define uip_backlogremove(conn) (NULL)
#endif
/* Tell the sending host to stop sending data.
*
* This function will close our receiver's window so that we stop
* 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 maximum 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 */
+206
View File
@@ -0,0 +1,206 @@
/****************************************************************************
* 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, 2009 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 <stdint.h>
#include <net/uip/uipopt.h>
/****************************************************************************
* Pre-processor 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_callback_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_t lport; /* The local port number in network byte order */
uint16_t rport; /* The remote port number in network byte order */
uint8_t ttl; /* Default time-to-live */
uint8_t crefs; /* Reference counts on this instance */
/* Defines the list of UDP callbacks */
struct uip_callback_s *list;
};
/* The UDP and IP headers */
struct uip_udpip_hdr
{
#ifdef CONFIG_NET_IPv6
/* IPv6 Ip header */
uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
uint8_t 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_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
uint8_t len[2]; /* 16-bit Total length */
uint8_t ipid[2]; /* 16-bit Identification */
uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
uint8_t ttl; /* 8-bit Time to Live */
uint8_t proto; /* 8-bit Protocol */
uint16_t ipchksum; /* 16-bit Header checksum */
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
#endif /* CONFIG_NET_IPv6 */
/* UDP header */
uint16_t srcport;
uint16_t destport;
uint16_t udplen;
uint16_t 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);
/* Allocate a new TCP data callback */
#define uip_udpcallbackalloc(conn) uip_callbackalloc(&conn->list)
#define uip_udpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list)
/* 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 */
+568
View File
@@ -0,0 +1,568 @@
/****************************************************************************
* net/uip/uip.h
*
* 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-2011 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_H
#define __NET_UIP_UIP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <queue.h>
#ifdef CONFIG_NET_NOINTS
# include <semaphore.h>
#endif
#include <arpa/inet.h>
#include <net/uip/uipopt.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The following flags may be set in the set of flags before calling the
* application callback. The UIP_ACKDATA, UIP_NEWDATA, and UIP_CLOSE flags
* may be set at the same time, whereas the others are mutualy exclusive.
*
* UIP_ACKDATA IN: Signifies that the outstanding data was acked and
* the application should send out new data instead
* of retransmitting the last data (TCP only)
* OUT: Input state must be preserved on output.
* UIP_NEWDATA IN: Set to indicate that the peer has sent us new data.
* OUT: Cleared (only) by the application logic to indicate
* that the new data was consumed, suppressing further
* attempts to process the new data.
* UIP_SNDACK IN: Not used; always zero
* OUT: Set by the application if the new data was consumed
* and an ACK should be sent in the response. (TCP only)
* UIP_REXMIT IN: Tells the application to retransmit the data that
* was last sent. (TCP only)
* OUT: Not used
* UIP_POLL IN: Used for polling the application. This is provided
* periodically from the drivers to support (1) timed
* operations, and (2) to check if the application has
* data that it wants to send
* OUT: Not used
* UIP_BACKLOG IN: There is a new connection in the backlog list set
* up by the listen() command. (TCP only)
* OUT: Not used
* UIP_CLOSE IN: The remote host has closed the connection, thus the
* connection has gone away. (TCP only)
* OUT: The application signals that it wants to close the
* connection. (TCP only)
* UIP_ABORT IN: The remote host has aborted the connection, thus the
* connection has gone away. (TCP only)
* OUT: The application signals that it wants to abort the
* connection. (TCP only)
* UIP_CONNECTED IN: We have got a connection from a remote host and have
* set up a new connection for it, or an active connection
* has been successfully established. (TCP only)
* OUT: Not used
* UIP_TIMEDOUT IN: The connection has been aborted due to too many
* retransmissions. (TCP only)
* OUT: Not used
* UIP_ECHOREPLY IN: An ICMP Echo Reply has been received. Used to support
* ICMP ping from applications. (ICMP only)
* OUT: Cleared (only) by the application logic to indicate
* that the reply was processed, suppressing further
* attempts to process the reply.
*/
#define UIP_ACKDATA (1 << 0)
#define UIP_NEWDATA (1 << 1)
#define UIP_SNDACK (1 << 2)
#define UIP_REXMIT (1 << 3)
#define UIP_POLL (1 << 4)
#define UIP_BACKLOG (1 << 5)
#define UIP_CLOSE (1 << 6)
#define UIP_ABORT (1 << 7)
#define UIP_CONNECTED (1 << 8)
#define UIP_TIMEDOUT (1 << 9)
#define UIP_ECHOREPLY (1 << 10)
#define UIP_CONN_EVENTS (UIP_CLOSE|UIP_ABORT|UIP_CONNECTED|UIP_TIMEDOUT)
/* The buffer size available for user data in the d_buf buffer.
*
* This macro holds the available size for user data in the
* d_buf buffer. The macro is intended to be used for checking
* bounds of available user data.
*
* Example:
*
* snprintf(dev->d_appdata, UIP_APPDATA_SIZE, "%u\n", i);
*/
#define UIP_APPDATA_SIZE (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
#define UIP_PROTO_ICMP 1
#define UIP_PROTO_IGMP 2
#define UIP_PROTO_TCP 6
#define UIP_PROTO_UDP 17
#define UIP_PROTO_ICMP6 58
/* Header sizes */
#ifdef CONFIG_NET_IPv6
# define UIP_IPH_LEN 40 /* Size of IP header */
#else
# define UIP_IPH_LEN 20 /* Size of IP header */
#endif
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* Representation of an IP address */
typedef in_addr_t uip_ip4addr_t;
typedef uint16_t uip_ip6addr_t[8];
#ifdef CONFIG_NET_IPv6
typedef uip_ip6addr_t uip_ipaddr_t;
#else
typedef uip_ip4addr_t uip_ipaddr_t;
#endif
/* The IP header */
struct uip_ip_hdr
{
#ifdef CONFIG_NET_IPv6
/* IPv6 Ip header */
uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
uint8_t 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_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
uint8_t len[2]; /* 16-bit Total length */
uint8_t ipid[2]; /* 16-bit Identification */
uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
uint8_t ttl; /* 8-bit Time to Live */
uint8_t proto; /* 8-bit Protocol */
uint16_t ipchksum; /* 16-bit Header checksum */
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
#endif /* CONFIG_NET_IPv6 */
};
/* Describes a uIP callback
*
* flink - Supports a singly linked list
* event - Provides the address of the callback function entry point.
* pvconn is a pointer to one of struct uip_conn or struct uip_udp_conn.
* priv - Holds a reference to application specific data that will
* provided
* flags - Set by the application to inform the uIP layer which flags
* are and are not handled by the callback.
*/
struct uip_driver_s; /* Forward reference */
struct uip_callback_s
{
FAR struct uip_callback_s *flink;
uint16_t (*event)(struct uip_driver_s *dev, void *pvconn, void *pvpriv, uint16_t flags);
void *priv;
uint16_t flags;
};
/* Protocol-specific support */
#ifdef CONFIG_NET_TCP
# include <net/uip/uip-tcp.h>
#endif
#ifdef CONFIG_NET_UDP
# include <net/uip/uip-udp.h>
#endif
#ifdef CONFIG_NET_ICMP
# include <net/uip/uip-icmp.h>
#endif
#ifdef CONFIG_NET_IGMP
# include <net/uip/uip-igmp.h>
#endif
/* 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_ip_stats_s ip; /* IP statistics */
#ifdef CONFIG_NET_ICMP
struct uip_icmp_stats_s icmp; /* ICMP statistics */
#endif
#ifdef CONFIG_NET_IGMP
struct uip_igmp_stats_s igmp; /* IGMP statistics */
#endif
#ifdef CONFIG_NET_TCP
struct uip_tcp_stats_s tcp; /* TCP statistics */
#endif
#ifdef CONFIG_NET_UDP
struct uip_udp_stats_s udp; /* UDP statistics */
#endif
};
#endif /* CONFIG_NET_STATISTICS */
/****************************************************************************
* Public Data
****************************************************************************/
/* 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 initialization functions
*
* The uIP initialization functions are used for booting uIP.
*
* This function should be called at boot up to initilize the uIP
* TCP/IP stack.
*/
extern void uip_initialize(void);
/* This function may be used at boot time to set the initial ip_id.*/
extern void uip_setipid(uint16_t id);
/* Critical section management. The NuttX configuration setting
* CONFIG_NET_NOINT indicates that uIP not called from the interrupt level.
* If CONFIG_NET_NOINTS is defined, then these will map to semaphore
* controls. Otherwise, it assumed that uIP will be called from interrupt
* level handling and these will map to interrupt enable/disable controls.
*/
#ifdef CONFIG_NET_NOINTS
/* Semaphore based locking for non-interrupt based logic.
*
* uip_lock_t -- Not used. Only for compatibility
* uip_lockinit() -- Initializes an underlying semaphore/mutex
* uip_lock() -- Takes the semaphore(). Implements a re-entrant mutex.
* uip_unlock() -- Gives the semaphore().
* uip_lockedwait() -- Like pthread_cond_wait(); releases the semaphore
* momemtarily to wait on another semaphore()
*/
typedef uint8_t uip_lock_t; /* Not really used */
extern void uip_lockinit(void);
extern uip_lock_t uip_lock(void);
extern void uip_unlock(uip_lock_t flags);
extern int uip_lockedwait(sem_t *sem);
#else
/* Enable/disable locking for interrupt based logic:
*
* uip_lock_t -- The processor specific representation of interrupt state.
* uip_lockinit() -- (Does not exist).
* uip_lock() -- Disables interrupts.
* uip_unlock() -- Conditionally restores interrupts.
* uip_lockedwait() -- Just wait for the semaphore.
*/
# define uip_lock_t irqstate_t
# define uip_lockinit()
# define uip_lock() irqsave()
# define uip_unlock(f) irqrestore(f)
# define uip_lockedwait(s) sem_wait(s)
#endif
/* 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.
*/
/* Send data on the current connection.
*
* This function is used to send out a single segment of TCP
* data. Only applications that have been invoked by uIP for event
* processing can send data.
*
* The amount of data that actually is sent out after a call to this
* funcion is determined by the maximum amount of data TCP allows. uIP
* will automatically crop the data so that only the appropriate
* amount of data is sent. The function uip_mss() can be used to query
* uIP for the amount of data that actually will be sent.
*
* Note: This function does not guarantee that the sent data will
* arrive at the destination. If the data is lost in the network, the
* application will be invoked with the UIP_REXMIT flag set. The
* application will then have to resend the data using this function.
*
* data A pointer to the data which is to be sent.
*
* len The maximum amount of data bytes to be sent.
*/
extern void uip_send(struct uip_driver_s *dev, const void *buf, int len);
/* uIP convenience and converting functions.
*
* These functions can be used for converting between different data
* formats used by uIP.
*
* Construct an IP address from four bytes.
*
* This function constructs an IPv4 address in network byte order.
*
* 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) \
do { \
addr = HTONL((addr0) << 24 | (addr1) << 16 | (addr2) << 8 | (addr3)); \
} while(0)
/* Convert an IPv4 address of the form uint16_t[2] to an in_addr_t */
#ifdef CONFIG_ENDIAN_BIG
# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[0] << 16) | (in_addr_t)((uint16_t*)addr)[1])
#else
# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[1] << 16) | (in_addr_t)((uint16_t*)addr)[0])
#endif
/* Extract individual bytes from a 32-bit IPv4 IP address that is in network byte order */
#ifdef CONFIG_ENDIAN_BIG
/* Big-endian byte order: 11223344 */
# define ip4_addr1(ipaddr) (((ipaddr) >> 24) & 0xff)
# define ip4_addr2(ipaddr) (((ipaddr) >> 16) & 0xff)
# define ip4_addr3(ipaddr) (((ipaddr) >> 8) & 0xff)
# define ip4_addr4(ipaddr) ((ipaddr) & 0xff)
#else
/* Little endian byte order: 44223311 */
# define ip4_addr1(ipaddr) ((ipaddr) & 0xff)
# define ip4_addr2(ipaddr) (((ipaddr) >> 8) & 0xff)
# define ip4_addr3(ipaddr) (((ipaddr) >> 16) & 0xff)
# define ip4_addr4(ipaddr) (((ipaddr) >> 24) & 0xff)
#endif
/* Construct an IPv6 address from eight 16-bit words.
*
* This function constructs an IPv6 address.
*/
#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) \
do { \
((uint16_t*)(addr))[0] = HTONS((addr0)); \
((uint16_t*)(addr))[1] = HTONS((addr1)); \
((uint16_t*)(addr))[2] = HTONS((addr2)); \
((uint16_t*)(addr))[3] = HTONS((addr3)); \
((uint16_t*)(addr))[4] = HTONS((addr4)); \
((uint16_t*)(addr))[5] = HTONS((addr5)); \
((uint16_t*)(addr))[6] = HTONS((addr6)); \
((uint16_t*)(addr))[7] = HTONS((addr7)); \
} while(0)
/* Copy an IP address to another IP address.
*
* Copies an IP address from one place to another.
*
* Example:
*
* uip_ipaddr_t ipaddr1, ipaddr2;
*
* uip_ipaddr(&ipaddr1, 192,16,1,2);
* uip_ipaddr_copy(&ipaddr2, &ipaddr1);
*
* dest The destination for the copy.
* src The source from where to copy.
*/
#ifndef CONFIG_NET_IPv6
# define uip_ipaddr_copy(dest, src) \
do { \
(dest) = (in_addr_t)(src); \
} while(0)
# define uiphdr_ipaddr_copy(dest, src) \
do { \
((uint16_t*)(dest))[0] = ((uint16_t*)(src))[0]; \
((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \
} while(0)
#else /* !CONFIG_NET_IPv6 */
# define uip_ipaddr_copy(dest, src) memcpy(&dest, &src, sizeof(uip_ip6addr_t))
# define uiphdr_ipaddr_copy(dest, src) uip_ipaddr_copy(dest, src)
#endif /* !CONFIG_NET_IPv6 */
/* Compare two IP addresses
*
* Example:
*
* uip_ipaddr_t ipaddr1, ipaddr2;
*
* uip_ipaddr(&ipaddr1, 192,16,1,2);
* if(uip_ipaddr_cmp(ipaddr2, ipaddr1)) {
* printf("They are the same");
* }
*
* addr1 The first IP address.
* addr2 The second IP address.
*/
#ifndef CONFIG_NET_IPv6
# define uip_ipaddr_cmp(addr1, addr2) (addr1 == addr2)
# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(uip_ip4addr_conv(addr1), uip_ip4addr_conv(addr2))
#else /* !CONFIG_NET_IPv6 */
# define uip_ipaddr_cmp(addr1, addr2) (memcmp(&addr1, &addr2, sizeof(uip_ip6addr_t)) == 0)
# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(addr, addr2)
#endif /* !CONFIG_NET_IPv6 */
/* Compare two IP addresses with netmasks
*
* Compares two IP addresses with netmasks. The masks are used to mask
* out the bits that are to be compared.
*
* Example:
*
* uip_ipaddr_t ipaddr1, ipaddr2, mask;
*
* 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");
* }
*
* addr1 The first IP address.
* addr2 The second IP address.
* mask The netmask.
*/
#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
extern bool uip_ipaddr_maskcmp(uip_ipaddr_t addr1, uip_ipaddr_t addr2,
uip_ipaddr_t mask);
#endif
/* Mask out the network part of an IP address.
*
* Masks out the network part of an IP address, given the address and
* the netmask.
*
* Example:
*
* uip_ipaddr_t ipaddr1, ipaddr2, netmask;
*
* uip_ipaddr(&ipaddr1, 192,16,1,2);
* uip_ipaddr(&netmask, 255,255,255,0);
* uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask);
*
* In the example above, the variable "ipaddr2" will contain the IP
* address 192.168.1.0.
*
* dest Where the result is to be placed.
* src The IP address.
* mask The netmask.
*/
#define uip_ipaddr_mask(dest, src, mask) \
do { \
(in_addr_t)(dest) = (in_addr_t)(src) & (in_addr_t)(mask); \
} while(0)
#endif /* __NET_UIP_UIP_H */
+314
View File
@@ -0,0 +1,314 @@
/****************************************************************************
* uipopt.h
* Configuration options for uIP.
*
* This file is used for tweaking various configuration options for
* uIP. You should make a copy of this file into one of your project's
* directories instead of editing this example "uipopt.h" file that
* comes with the uIP distribution.
*
* uIP is configured using the per-project configuration file
* uipopt.h. This file contains all compile-time options for uIP and
* should be tweaked to match each specific project. The uIP
* distribution contains a documented example "uipopt.h" that can be
* copied and modified for each project.
*
* Note: Most of the configuration options in the uipopt.h should not
* be changed, but rather the per-project defconfig file.
*
* Copyright (C) 2007, 2011 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 __UIPOPT_H__
#define __UIPOPT_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
#include <nuttx/config.h>
/****************************************************************************
* Public Definitions
****************************************************************************/
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* Layer 2 Configuration Options ********************************************/
/* The default data link layer for uIP is Ethernet. If CONFIG_NET_SLIP is
* defined in the NuttX header file, then SLIP will be supported. The basic
* differences between the SLIP and Ethernet configurations is that when SLIP
* is selected:
*
* - The link level header (that comes before the IP header) is omitted.
* - All MAC address processing is suppressed.
* - ARP is disabled.
*
* If CONFIG_NET_SLIP is not supported, then Ethernet will be used (there is
* no need to define anything special in the configuration file to use
* Ethernet -- it is the default).
*
* The "link level header" is the offset into the d_buf where the IP header
* can be found. For Ethernet, this should be set to 14. For SLIP, this
* should be set to 0.
*/
#undef CONFIG_NET_ETHERNET
#undef CONFIG_NET_ARP
#ifdef CONFIG_NET_SLIP
# ifdef CONFIG_NET_IPv6
# error "SLIP is not implemented for IPv6"
# endif
# define UIP_LLH_LEN 0
#else
# define CONFIG_NET_ETHERNET 1
# define CONFIG_NET_ARP 1
# define UIP_LLH_LEN 14
#endif
/* Layer 3/4 Configuration Options ******************************************/
/* IP configuration options */
/* The IP TTL (time to live) of IP packets sent by uIP.
*
* This should normally not be changed.
*/
#define UIP_TTL 64
/* Turn on support for IP packet reassembly.
*
* uIP supports reassembly of fragmented IP packets. This features
* requires an additonal amount of RAM to hold the reassembly buffer
* and the reassembly code size is approximately 700 bytes. The
* reassembly buffer is of the same size as the d_buf buffer
* (configured by CONFIG_NET_BUFSIZE).
*
* Note: IP packet reassembly is not heavily tested.
*/
#define UIP_REASSEMBLY 0
/* The maximum time an IP fragment should wait in the reassembly
* buffer before it is dropped. Units are deci-seconds, the range
* of the timer is 8-bits.
*/
#define UIP_REASS_MAXAGE (20*10) /* 20 seconds */
/* Network drivers often receive packets with garbage at the end
* and are longer than the size of packet in the TCP header. The
* following "fudge" factor increases the size of the I/O buffering
* by a small amount to allocate slightly oversize packets. After
* receipt, the packet size will be chopped down to the size indicated
* in the TCP header.
*/
#ifndef CONFIG_NET_GUARDSIZE
# define CONFIG_NET_GUARDSIZE 2
#endif
/* ICMP configuration options */
#if !defined(CONFIG_NET_ICMP) || defined(CONFIG_DISABLE_CLOCK)
# undef CONFIG_NET_ICMP_PING
#endif
/* UDP configuration options */
/* The maximum amount of concurrent UDP connection, Default: 10 */
#ifndef CONFIG_NET_UDP_CONNS
# ifdef CONFIG_NET_UDP
# define CONFIG_NET_UDP_CONNS 10
# else
# define CONFIG_NET_UDP_CONNS 0
# endif
#endif
/* The UDP maximum packet size. This is should not be to set to more
* than CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN.
*/
#define UIP_UDP_MSS (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN)
/* TCP configuration options */
/* The maximum number of simultaneously open TCP connections.
*
* Since the TCP connections are statically allocated, turning this
* configuration knob down results in less RAM used. Each TCP
* connection requires approximatly 30 bytes of memory.
*/
#ifndef CONFIG_NET_TCP_CONNS
# ifdef CONFIG_NET_TCP
# define CONFIG_NET_TCP_CONNS 10
# else
# define CONFIG_NET_TCP_CONNS 0
# endif
#endif
/* The maximum number of simultaneously listening TCP ports.
*
* Each listening TCP port requires 2 bytes of memory.
*/
#ifndef CONFIG_NET_MAX_LISTENPORTS
# define CONFIG_NET_MAX_LISTENPORTS 20
#endif
/* Define the maximum number of concurrently active UDP and TCP
* ports. This number must be greater than the number of open
* sockets in order to support multi-threaded read/write operations.
*/
#ifndef CONFIG_NET_NACTIVESOCKETS
# define CONFIG_NET_NACTIVESOCKETS (CONFIG_NET_TCP_CONNS + CONFIG_NET_UDP_CONNS)
#endif
/* The initial retransmission timeout counted in timer pulses.
*
* This should not be changed.
*/
#define UIP_RTO 3
/* The maximum number of times a segment should be retransmitted
* before the connection should be aborted.
*
* This should not be changed.
*/
#define UIP_MAXRTX 8
/* The maximum number of times a SYN segment should be retransmitted
* before a connection request should be deemed to have been
* unsuccessful.
*
* This should not need to be changed.
*/
#define UIP_MAXSYNRTX 5
/* The TCP maximum segment size. This is should not be set to more
* than CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
*/
#define UIP_TCP_MSS (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
/* The size of the advertised receiver's window.
*
* Should be set low (i.e., to the size of the d_buf buffer) is the
* application is slow to process incoming data, or high (32768 bytes)
* if the application processes data quickly.
*/
#ifndef CONFIG_NET_RECEIVE_WINDOW
# define CONFIG_NET_RECEIVE_WINDOW UIP_TCP_MSS
#endif
/* How long a connection should stay in the TIME_WAIT state.
*
* This configiration option has no real implication, and it should be
* left untouched. Units: half second.
*/
#define UIP_TIME_WAIT_TIMEOUT (60*2)
/* ARP configuration options */
/* The size of the ARP table.
*
* This option should be set to a larger value if this uIP node will
* have many connections from the local network.
*/
#ifndef CONFIG_NET_ARPTAB_SIZE
# define CONFIG_NET_ARPTAB_SIZE 8
#endif
/* The maxium age of ARP table entries measured in 10ths of seconds.
*
* An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
* default).
*/
#define UIP_ARP_MAXAGE 120
/* General configuration options */
/* The size of the uIP packet buffer.
*
* The uIP packet buffer should not be smaller than 60 bytes, and does
* not need to be larger than 1500 bytes. Lower size results in lower
* TCP throughput, larger size results in higher TCP throughput.
*/
#ifndef CONFIG_NET_BUFSIZE
# define CONFIG_NET_BUFSIZE 400
#endif
/* Number of TCP read-ahead buffers (may be zero) */
#ifndef CONFIG_NET_NTCP_READAHEAD_BUFFERS
# define CONFIG_NET_NTCP_READAHEAD_BUFFERS 4
#endif
/* The size of the TCP read buffer size */
#ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE
# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
#endif
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* Statistics datatype
*
* This typedef defines the dataype used for keeping statistics in
* uIP.
*/
typedef uint16_t uip_stats_t;
#endif /* __UIPOPT_H__ */