Mbed library for ENC28J60 Ethernet modules. Full support for TCP/IP and UDP Server, Client and HTTP server (webserver). DHCP and DNS is included.
Dependents: mBuino_ENC28_MQTT Nucleo_Web_ENC28J60 Nucleo_Web_ENC28J60_ADC Serial_over_Ethernet ... more
Library for ENC28J60 Ethernet modules.
Ported to mbed from Norbert Truchsess's UIPEthernet library for Arduino. Thank you Norbert!
- Full support for persistent (streaming) TCP/IP and UDP connections Client and Server each, ARP, ICMP, DHCP and DNS.
- Works with both Mbed OS 2 and Mbed OS 5.
Usage:
- Import the library into your project.
- Add
#include "UipEthernet.h"
tomain.cpp
- Create one instance of the UipEthernet class initialized with the MAC address you'd like to use and SPI pins of the connected Mbed board.
Example programs:
Import programWebSwitch_ENC28J60
HTTP Server serving a simple webpage which enables to remotely turn a digital output on/off. Compile, download, run and type 'IP_address/secret/' (don't forget the last '/') into your web browser and hit ENTER.
Import programHTTPServer_Echo_ENC28J60
A simple HTTP server echoing received requests. Ethernet connection is over an ENC28J60 board. Usage: Type the server's IP address into you web browser and hit <ENTER>.
Import programTcpServer_ENC28J60
Simple TCP/IP Server using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programTcpClient_ENC28J60
Simple TCP/IP Client using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programUdpServer_ENC28J60
Simple UDP Server using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programUdpClient_ENC28J60
Simple UDP Client using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programMQTT_Hello_ENC28J60
MQTT Client example program. Ethernet connection is via an ENC28J60 module.
uitility/uipopt.h@0:5350a66d5279, 2014-09-15 (annotated)
- Committer:
- hudakz
- Date:
- Mon Sep 15 11:12:30 2014 +0000
- Revision:
- 0:5350a66d5279
rev. 00
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 0:5350a66d5279 | 1 | /** |
hudakz | 0:5350a66d5279 | 2 | * \defgroup uipopt Configuration options for uIP |
hudakz | 0:5350a66d5279 | 3 | * @{ |
hudakz | 0:5350a66d5279 | 4 | * |
hudakz | 0:5350a66d5279 | 5 | * uIP is configured using the per-project configuration file |
hudakz | 0:5350a66d5279 | 6 | * uipopt.h. This file contains all compile-time options for uIP and |
hudakz | 0:5350a66d5279 | 7 | * should be tweaked to match each specific project. The uIP |
hudakz | 0:5350a66d5279 | 8 | * distribution contains a documented example "uipopt.h" that can be |
hudakz | 0:5350a66d5279 | 9 | * copied and modified for each project. |
hudakz | 0:5350a66d5279 | 10 | * |
hudakz | 0:5350a66d5279 | 11 | * \note Most of the configuration options in the uipopt.h should not |
hudakz | 0:5350a66d5279 | 12 | * be changed, but rather the per-project uip-conf.h file. |
hudakz | 0:5350a66d5279 | 13 | */ |
hudakz | 0:5350a66d5279 | 14 | /** |
hudakz | 0:5350a66d5279 | 15 | * \file |
hudakz | 0:5350a66d5279 | 16 | * Configuration options for uIP. |
hudakz | 0:5350a66d5279 | 17 | * \author Adam Dunkels <adam@dunkels.com> |
hudakz | 0:5350a66d5279 | 18 | * |
hudakz | 0:5350a66d5279 | 19 | * This file is used for tweaking various configuration options for |
hudakz | 0:5350a66d5279 | 20 | * uIP. You should make a copy of this file into one of your project's |
hudakz | 0:5350a66d5279 | 21 | * directories instead of editing this example "uipopt.h" file that |
hudakz | 0:5350a66d5279 | 22 | * comes with the uIP distribution. |
hudakz | 0:5350a66d5279 | 23 | */ |
hudakz | 0:5350a66d5279 | 24 | /* |
hudakz | 0:5350a66d5279 | 25 | * Copyright (c) 2001-2003, Adam Dunkels. |
hudakz | 0:5350a66d5279 | 26 | * All rights reserved. |
hudakz | 0:5350a66d5279 | 27 | * |
hudakz | 0:5350a66d5279 | 28 | * Redistribution and use in source and binary forms, with or without |
hudakz | 0:5350a66d5279 | 29 | * modification, are permitted provided that the following conditions |
hudakz | 0:5350a66d5279 | 30 | * are met: |
hudakz | 0:5350a66d5279 | 31 | * 1. Redistributions of source code must retain the above copyright |
hudakz | 0:5350a66d5279 | 32 | * notice, this list of conditions and the following disclaimer. |
hudakz | 0:5350a66d5279 | 33 | * 2. Redistributions in binary form must reproduce the above copyright |
hudakz | 0:5350a66d5279 | 34 | * notice, this list of conditions and the following disclaimer in the |
hudakz | 0:5350a66d5279 | 35 | * documentation and/or other materials provided with the distribution. |
hudakz | 0:5350a66d5279 | 36 | * 3. The name of the author may not be used to endorse or promote |
hudakz | 0:5350a66d5279 | 37 | * products derived from this software without specific prior |
hudakz | 0:5350a66d5279 | 38 | * written permission. |
hudakz | 0:5350a66d5279 | 39 | * |
hudakz | 0:5350a66d5279 | 40 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
hudakz | 0:5350a66d5279 | 41 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
hudakz | 0:5350a66d5279 | 42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
hudakz | 0:5350a66d5279 | 43 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
hudakz | 0:5350a66d5279 | 44 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
hudakz | 0:5350a66d5279 | 45 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
hudakz | 0:5350a66d5279 | 46 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
hudakz | 0:5350a66d5279 | 47 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
hudakz | 0:5350a66d5279 | 48 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
hudakz | 0:5350a66d5279 | 49 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
hudakz | 0:5350a66d5279 | 50 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
hudakz | 0:5350a66d5279 | 51 | * |
hudakz | 0:5350a66d5279 | 52 | * This file is part of the uIP TCP/IP stack. |
hudakz | 0:5350a66d5279 | 53 | * |
hudakz | 0:5350a66d5279 | 54 | * $Id: uipopt.h,v 1.4 2006/06/12 08:00:31 adam Exp $ |
hudakz | 0:5350a66d5279 | 55 | * |
hudakz | 0:5350a66d5279 | 56 | */ |
hudakz | 0:5350a66d5279 | 57 | #ifndef __UIPOPT_H__ |
hudakz | 0:5350a66d5279 | 58 | #define __UIPOPT_H__ |
hudakz | 0:5350a66d5279 | 59 | |
hudakz | 0:5350a66d5279 | 60 | #ifndef UIP_LITTLE_ENDIAN |
hudakz | 0:5350a66d5279 | 61 | #define UIP_LITTLE_ENDIAN 3412 |
hudakz | 0:5350a66d5279 | 62 | #endif /* UIP_LITTLE_ENDIAN */ |
hudakz | 0:5350a66d5279 | 63 | |
hudakz | 0:5350a66d5279 | 64 | #ifndef UIP_BIG_ENDIAN |
hudakz | 0:5350a66d5279 | 65 | #define UIP_BIG_ENDIAN 1234 |
hudakz | 0:5350a66d5279 | 66 | #endif /* UIP_BIG_ENDIAN */ |
hudakz | 0:5350a66d5279 | 67 | |
hudakz | 0:5350a66d5279 | 68 | #include "uip-conf.h" |
hudakz | 0:5350a66d5279 | 69 | |
hudakz | 0:5350a66d5279 | 70 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 71 | |
hudakz | 0:5350a66d5279 | 72 | /** |
hudakz | 0:5350a66d5279 | 73 | * \name Static configuration options |
hudakz | 0:5350a66d5279 | 74 | * @{ |
hudakz | 0:5350a66d5279 | 75 | * |
hudakz | 0:5350a66d5279 | 76 | * These configuration options can be used for setting the IP address |
hudakz | 0:5350a66d5279 | 77 | * settings statically, but only if UIP_FIXEDADDR is set to 1. The |
hudakz | 0:5350a66d5279 | 78 | * configuration options for a specific node includes IP address, |
hudakz | 0:5350a66d5279 | 79 | * netmask and default router as well as the Ethernet address. The |
hudakz | 0:5350a66d5279 | 80 | * netmask, default router and Ethernet address are appliciable only |
hudakz | 0:5350a66d5279 | 81 | * if uIP should be run over Ethernet. |
hudakz | 0:5350a66d5279 | 82 | * |
hudakz | 0:5350a66d5279 | 83 | * All of these should be changed to suit your project. |
hudakz | 0:5350a66d5279 | 84 | */ |
hudakz | 0:5350a66d5279 | 85 | /** |
hudakz | 0:5350a66d5279 | 86 | * Determines if uIP should use a fixed IP address or not. |
hudakz | 0:5350a66d5279 | 87 | * |
hudakz | 0:5350a66d5279 | 88 | * If uIP should use a fixed IP address, the settings are set in the |
hudakz | 0:5350a66d5279 | 89 | * uipopt.h file. If not, the macros uip_sethostaddr(), |
hudakz | 0:5350a66d5279 | 90 | * uip_setdraddr() and uip_setnetmask() should be used instead. |
hudakz | 0:5350a66d5279 | 91 | * |
hudakz | 0:5350a66d5279 | 92 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 93 | */ |
hudakz | 0:5350a66d5279 | 94 | #define UIP_FIXEDADDR 0 |
hudakz | 0:5350a66d5279 | 95 | |
hudakz | 0:5350a66d5279 | 96 | /** |
hudakz | 0:5350a66d5279 | 97 | * Ping IP address asignment. |
hudakz | 0:5350a66d5279 | 98 | * |
hudakz | 0:5350a66d5279 | 99 | * uIP uses a "ping" packets for setting its own IP address if this |
hudakz | 0:5350a66d5279 | 100 | * option is set. If so, uIP will start with an empty IP address and |
hudakz | 0:5350a66d5279 | 101 | * the destination IP address of the first incoming "ping" (ICMP echo) |
hudakz | 0:5350a66d5279 | 102 | * packet will be used for setting the hosts IP address. |
hudakz | 0:5350a66d5279 | 103 | * |
hudakz | 0:5350a66d5279 | 104 | * \note This works only if UIP_FIXEDADDR is 0. |
hudakz | 0:5350a66d5279 | 105 | * |
hudakz | 0:5350a66d5279 | 106 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 107 | */ |
hudakz | 0:5350a66d5279 | 108 | |
hudakz | 0:5350a66d5279 | 109 | #ifdef UIP_CONF_PINGADDRCONF |
hudakz | 0:5350a66d5279 | 110 | #define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF |
hudakz | 0:5350a66d5279 | 111 | #else /* UIP_CONF_PINGADDRCONF */ |
hudakz | 0:5350a66d5279 | 112 | |
hudakz | 0:5350a66d5279 | 113 | #define UIP_PINGADDRCONF 0 |
hudakz | 0:5350a66d5279 | 114 | #endif /* UIP_CONF_PINGADDRCONF */ |
hudakz | 0:5350a66d5279 | 115 | |
hudakz | 0:5350a66d5279 | 116 | /** |
hudakz | 0:5350a66d5279 | 117 | * Specifies if the uIP ARP module should be compiled with a fixed |
hudakz | 0:5350a66d5279 | 118 | * Ethernet MAC address or not. |
hudakz | 0:5350a66d5279 | 119 | * |
hudakz | 0:5350a66d5279 | 120 | * If this configuration option is 0, the macro uip_setethaddr() can |
hudakz | 0:5350a66d5279 | 121 | * be used to specify the Ethernet address at run-time. |
hudakz | 0:5350a66d5279 | 122 | * |
hudakz | 0:5350a66d5279 | 123 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 124 | */ |
hudakz | 0:5350a66d5279 | 125 | |
hudakz | 0:5350a66d5279 | 126 | #define UIP_FIXEDETHADDR 0 |
hudakz | 0:5350a66d5279 | 127 | |
hudakz | 0:5350a66d5279 | 128 | /** @} */ |
hudakz | 0:5350a66d5279 | 129 | |
hudakz | 0:5350a66d5279 | 130 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 131 | /** |
hudakz | 0:5350a66d5279 | 132 | * \name IP configuration options |
hudakz | 0:5350a66d5279 | 133 | * @{ |
hudakz | 0:5350a66d5279 | 134 | * |
hudakz | 0:5350a66d5279 | 135 | */ |
hudakz | 0:5350a66d5279 | 136 | /** |
hudakz | 0:5350a66d5279 | 137 | * The IP TTL (time to live) of IP packets sent by uIP. |
hudakz | 0:5350a66d5279 | 138 | * |
hudakz | 0:5350a66d5279 | 139 | * This should normally not be changed. |
hudakz | 0:5350a66d5279 | 140 | */ |
hudakz | 0:5350a66d5279 | 141 | #define UIP_TTL 64 |
hudakz | 0:5350a66d5279 | 142 | |
hudakz | 0:5350a66d5279 | 143 | /** |
hudakz | 0:5350a66d5279 | 144 | * Turn on support for IP packet reassembly. |
hudakz | 0:5350a66d5279 | 145 | * |
hudakz | 0:5350a66d5279 | 146 | * uIP supports reassembly of fragmented IP packets. This features |
hudakz | 0:5350a66d5279 | 147 | * requires an additonal amount of RAM to hold the reassembly buffer |
hudakz | 0:5350a66d5279 | 148 | * and the reassembly code size is approximately 700 bytes. The |
hudakz | 0:5350a66d5279 | 149 | * reassembly buffer is of the same size as the uip_buf buffer |
hudakz | 0:5350a66d5279 | 150 | * (configured by UIP_BUFSIZE). |
hudakz | 0:5350a66d5279 | 151 | * |
hudakz | 0:5350a66d5279 | 152 | * \note IP packet reassembly is not heavily tested. |
hudakz | 0:5350a66d5279 | 153 | * |
hudakz | 0:5350a66d5279 | 154 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 155 | */ |
hudakz | 0:5350a66d5279 | 156 | |
hudakz | 0:5350a66d5279 | 157 | #define UIP_REASSEMBLY 0 |
hudakz | 0:5350a66d5279 | 158 | |
hudakz | 0:5350a66d5279 | 159 | /** |
hudakz | 0:5350a66d5279 | 160 | * The maximum time an IP fragment should wait in the reassembly |
hudakz | 0:5350a66d5279 | 161 | * buffer before it is dropped. |
hudakz | 0:5350a66d5279 | 162 | * |
hudakz | 0:5350a66d5279 | 163 | */ |
hudakz | 0:5350a66d5279 | 164 | |
hudakz | 0:5350a66d5279 | 165 | #define UIP_REASS_MAXAGE 40 |
hudakz | 0:5350a66d5279 | 166 | |
hudakz | 0:5350a66d5279 | 167 | /** @} */ |
hudakz | 0:5350a66d5279 | 168 | |
hudakz | 0:5350a66d5279 | 169 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 170 | /** |
hudakz | 0:5350a66d5279 | 171 | * \name UDP configuration options |
hudakz | 0:5350a66d5279 | 172 | * @{ |
hudakz | 0:5350a66d5279 | 173 | */ |
hudakz | 0:5350a66d5279 | 174 | /** |
hudakz | 0:5350a66d5279 | 175 | * Toggles wether UDP support should be compiled in or not. |
hudakz | 0:5350a66d5279 | 176 | * |
hudakz | 0:5350a66d5279 | 177 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 178 | */ |
hudakz | 0:5350a66d5279 | 179 | #ifdef UIP_CONF_UDP |
hudakz | 0:5350a66d5279 | 180 | #define UIP_UDP UIP_CONF_UDP |
hudakz | 0:5350a66d5279 | 181 | #else /* UIP_CONF_UDP */ |
hudakz | 0:5350a66d5279 | 182 | |
hudakz | 0:5350a66d5279 | 183 | #define UIP_UDP 0 |
hudakz | 0:5350a66d5279 | 184 | #endif /* UIP_CONF_UDP */ |
hudakz | 0:5350a66d5279 | 185 | |
hudakz | 0:5350a66d5279 | 186 | /** |
hudakz | 0:5350a66d5279 | 187 | * Toggles if UDP checksums should be used or not. |
hudakz | 0:5350a66d5279 | 188 | * |
hudakz | 0:5350a66d5279 | 189 | * \note Support for UDP checksums is currently not included in uIP, |
hudakz | 0:5350a66d5279 | 190 | * so this option has no function. |
hudakz | 0:5350a66d5279 | 191 | * |
hudakz | 0:5350a66d5279 | 192 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 193 | */ |
hudakz | 0:5350a66d5279 | 194 | |
hudakz | 0:5350a66d5279 | 195 | #ifdef UIP_CONF_UDP_CHECKSUMS |
hudakz | 0:5350a66d5279 | 196 | #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS |
hudakz | 0:5350a66d5279 | 197 | #else |
hudakz | 0:5350a66d5279 | 198 | #define UIP_UDP_CHECKSUMS 0 |
hudakz | 0:5350a66d5279 | 199 | #endif |
hudakz | 0:5350a66d5279 | 200 | /** |
hudakz | 0:5350a66d5279 | 201 | * The maximum amount of concurrent UDP connections. |
hudakz | 0:5350a66d5279 | 202 | * |
hudakz | 0:5350a66d5279 | 203 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 204 | */ |
hudakz | 0:5350a66d5279 | 205 | |
hudakz | 0:5350a66d5279 | 206 | #ifdef UIP_CONF_UDP_CONNS |
hudakz | 0:5350a66d5279 | 207 | #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS |
hudakz | 0:5350a66d5279 | 208 | #else /* UIP_CONF_UDP_CONNS */ |
hudakz | 0:5350a66d5279 | 209 | |
hudakz | 0:5350a66d5279 | 210 | #define UIP_UDP_CONNS 10 |
hudakz | 0:5350a66d5279 | 211 | #endif /* UIP_CONF_UDP_CONNS */ |
hudakz | 0:5350a66d5279 | 212 | |
hudakz | 0:5350a66d5279 | 213 | /** |
hudakz | 0:5350a66d5279 | 214 | * The name of the function that should be called when UDP datagrams arrive. |
hudakz | 0:5350a66d5279 | 215 | * |
hudakz | 0:5350a66d5279 | 216 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 217 | */ |
hudakz | 0:5350a66d5279 | 218 | |
hudakz | 0:5350a66d5279 | 219 | /** @} */ |
hudakz | 0:5350a66d5279 | 220 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 221 | /** |
hudakz | 0:5350a66d5279 | 222 | * \name TCP configuration options |
hudakz | 0:5350a66d5279 | 223 | * @{ |
hudakz | 0:5350a66d5279 | 224 | */ |
hudakz | 0:5350a66d5279 | 225 | /** |
hudakz | 0:5350a66d5279 | 226 | * Determines if support for opening connections from uIP should be |
hudakz | 0:5350a66d5279 | 227 | * compiled in. |
hudakz | 0:5350a66d5279 | 228 | * |
hudakz | 0:5350a66d5279 | 229 | * If the applications that are running on top of uIP for this project |
hudakz | 0:5350a66d5279 | 230 | * do not need to open outgoing TCP connections, this configration |
hudakz | 0:5350a66d5279 | 231 | * option can be turned off to reduce the code size of uIP. |
hudakz | 0:5350a66d5279 | 232 | * |
hudakz | 0:5350a66d5279 | 233 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 234 | */ |
hudakz | 0:5350a66d5279 | 235 | #define UIP_ACTIVE_OPEN 1 |
hudakz | 0:5350a66d5279 | 236 | |
hudakz | 0:5350a66d5279 | 237 | /** |
hudakz | 0:5350a66d5279 | 238 | * The maximum number of simultaneously open TCP connections. |
hudakz | 0:5350a66d5279 | 239 | * |
hudakz | 0:5350a66d5279 | 240 | * Since the TCP connections are statically allocated, turning this |
hudakz | 0:5350a66d5279 | 241 | * configuration knob down results in less RAM used. Each TCP |
hudakz | 0:5350a66d5279 | 242 | * connection requires approximatly 30 bytes of memory. |
hudakz | 0:5350a66d5279 | 243 | * |
hudakz | 0:5350a66d5279 | 244 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 245 | */ |
hudakz | 0:5350a66d5279 | 246 | |
hudakz | 0:5350a66d5279 | 247 | #ifndef UIP_CONF_MAX_CONNECTIONS |
hudakz | 0:5350a66d5279 | 248 | #define UIP_CONNS 10 |
hudakz | 0:5350a66d5279 | 249 | #else /* UIP_CONF_MAX_CONNECTIONS */ |
hudakz | 0:5350a66d5279 | 250 | |
hudakz | 0:5350a66d5279 | 251 | #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS |
hudakz | 0:5350a66d5279 | 252 | #endif /* UIP_CONF_MAX_CONNECTIONS */ |
hudakz | 0:5350a66d5279 | 253 | |
hudakz | 0:5350a66d5279 | 254 | /** |
hudakz | 0:5350a66d5279 | 255 | * The maximum number of simultaneously listening TCP ports. |
hudakz | 0:5350a66d5279 | 256 | * |
hudakz | 0:5350a66d5279 | 257 | * Each listening TCP port requires 2 bytes of memory. |
hudakz | 0:5350a66d5279 | 258 | * |
hudakz | 0:5350a66d5279 | 259 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 260 | */ |
hudakz | 0:5350a66d5279 | 261 | |
hudakz | 0:5350a66d5279 | 262 | #ifndef UIP_CONF_MAX_LISTENPORTS |
hudakz | 0:5350a66d5279 | 263 | #define UIP_LISTENPORTS 20 |
hudakz | 0:5350a66d5279 | 264 | #else /* UIP_CONF_MAX_LISTENPORTS */ |
hudakz | 0:5350a66d5279 | 265 | |
hudakz | 0:5350a66d5279 | 266 | #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS |
hudakz | 0:5350a66d5279 | 267 | #endif /* UIP_CONF_MAX_LISTENPORTS */ |
hudakz | 0:5350a66d5279 | 268 | |
hudakz | 0:5350a66d5279 | 269 | /** |
hudakz | 0:5350a66d5279 | 270 | * Determines if support for TCP urgent data notification should be |
hudakz | 0:5350a66d5279 | 271 | * compiled in. |
hudakz | 0:5350a66d5279 | 272 | * |
hudakz | 0:5350a66d5279 | 273 | * Urgent data (out-of-band data) is a rarely used TCP feature that |
hudakz | 0:5350a66d5279 | 274 | * very seldom would be required. |
hudakz | 0:5350a66d5279 | 275 | * |
hudakz | 0:5350a66d5279 | 276 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 277 | */ |
hudakz | 0:5350a66d5279 | 278 | |
hudakz | 0:5350a66d5279 | 279 | #define UIP_URGDATA 0 |
hudakz | 0:5350a66d5279 | 280 | |
hudakz | 0:5350a66d5279 | 281 | /** |
hudakz | 0:5350a66d5279 | 282 | * The initial retransmission timeout counted in timer pulses. |
hudakz | 0:5350a66d5279 | 283 | * |
hudakz | 0:5350a66d5279 | 284 | * This should not be changed. |
hudakz | 0:5350a66d5279 | 285 | */ |
hudakz | 0:5350a66d5279 | 286 | |
hudakz | 0:5350a66d5279 | 287 | #define UIP_RTO 3 |
hudakz | 0:5350a66d5279 | 288 | |
hudakz | 0:5350a66d5279 | 289 | /** |
hudakz | 0:5350a66d5279 | 290 | * The maximum number of times a segment should be retransmitted |
hudakz | 0:5350a66d5279 | 291 | * before the connection should be aborted. |
hudakz | 0:5350a66d5279 | 292 | * |
hudakz | 0:5350a66d5279 | 293 | * This should not be changed. |
hudakz | 0:5350a66d5279 | 294 | */ |
hudakz | 0:5350a66d5279 | 295 | |
hudakz | 0:5350a66d5279 | 296 | #define UIP_MAXRTX 8 |
hudakz | 0:5350a66d5279 | 297 | |
hudakz | 0:5350a66d5279 | 298 | /** |
hudakz | 0:5350a66d5279 | 299 | * The maximum number of times a SYN segment should be retransmitted |
hudakz | 0:5350a66d5279 | 300 | * before a connection request should be deemed to have been |
hudakz | 0:5350a66d5279 | 301 | * unsuccessful. |
hudakz | 0:5350a66d5279 | 302 | * |
hudakz | 0:5350a66d5279 | 303 | * This should not need to be changed. |
hudakz | 0:5350a66d5279 | 304 | */ |
hudakz | 0:5350a66d5279 | 305 | |
hudakz | 0:5350a66d5279 | 306 | #define UIP_MAXSYNRTX 5 |
hudakz | 0:5350a66d5279 | 307 | |
hudakz | 0:5350a66d5279 | 308 | /** |
hudakz | 0:5350a66d5279 | 309 | * The TCP maximum segment size. |
hudakz | 0:5350a66d5279 | 310 | * |
hudakz | 0:5350a66d5279 | 311 | * This is should not be to set to more than |
hudakz | 0:5350a66d5279 | 312 | * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN. |
hudakz | 0:5350a66d5279 | 313 | */ |
hudakz | 0:5350a66d5279 | 314 | |
hudakz | 0:5350a66d5279 | 315 | #ifndef UIP_CONF_TCP_MSS |
hudakz | 0:5350a66d5279 | 316 | #define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) |
hudakz | 0:5350a66d5279 | 317 | #else |
hudakz | 0:5350a66d5279 | 318 | #define UIP_TCP_MSS UIP_CONF_TCP_MSS |
hudakz | 0:5350a66d5279 | 319 | #endif |
hudakz | 0:5350a66d5279 | 320 | /** |
hudakz | 0:5350a66d5279 | 321 | * The size of the advertised receiver's window. |
hudakz | 0:5350a66d5279 | 322 | * |
hudakz | 0:5350a66d5279 | 323 | * Should be set low (i.e., to the size of the uip_buf buffer) is the |
hudakz | 0:5350a66d5279 | 324 | * application is slow to process incoming data, or high (32768 bytes) |
hudakz | 0:5350a66d5279 | 325 | * if the application processes data quickly. |
hudakz | 0:5350a66d5279 | 326 | * |
hudakz | 0:5350a66d5279 | 327 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 328 | */ |
hudakz | 0:5350a66d5279 | 329 | |
hudakz | 0:5350a66d5279 | 330 | #ifndef UIP_CONF_RECEIVE_WINDOW |
hudakz | 0:5350a66d5279 | 331 | #define UIP_RECEIVE_WINDOW UIP_TCP_MSS |
hudakz | 0:5350a66d5279 | 332 | #else |
hudakz | 0:5350a66d5279 | 333 | #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW |
hudakz | 0:5350a66d5279 | 334 | #endif |
hudakz | 0:5350a66d5279 | 335 | /** |
hudakz | 0:5350a66d5279 | 336 | * How long a connection should stay in the TIME_WAIT state. |
hudakz | 0:5350a66d5279 | 337 | * |
hudakz | 0:5350a66d5279 | 338 | * This configiration option has no real implication, and it should be |
hudakz | 0:5350a66d5279 | 339 | * left untouched. |
hudakz | 0:5350a66d5279 | 340 | */ |
hudakz | 0:5350a66d5279 | 341 | |
hudakz | 0:5350a66d5279 | 342 | #define UIP_TIME_WAIT_TIMEOUT 120 |
hudakz | 0:5350a66d5279 | 343 | |
hudakz | 0:5350a66d5279 | 344 | /** @} */ |
hudakz | 0:5350a66d5279 | 345 | |
hudakz | 0:5350a66d5279 | 346 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 347 | /** |
hudakz | 0:5350a66d5279 | 348 | * \name ARP configuration options |
hudakz | 0:5350a66d5279 | 349 | * @{ |
hudakz | 0:5350a66d5279 | 350 | */ |
hudakz | 0:5350a66d5279 | 351 | /** |
hudakz | 0:5350a66d5279 | 352 | * The size of the ARP table. |
hudakz | 0:5350a66d5279 | 353 | * |
hudakz | 0:5350a66d5279 | 354 | * This option should be set to a larger value if this uIP node will |
hudakz | 0:5350a66d5279 | 355 | * have many connections from the local network. |
hudakz | 0:5350a66d5279 | 356 | * |
hudakz | 0:5350a66d5279 | 357 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 358 | */ |
hudakz | 0:5350a66d5279 | 359 | #ifdef UIP_CONF_ARPTAB_SIZE |
hudakz | 0:5350a66d5279 | 360 | #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE |
hudakz | 0:5350a66d5279 | 361 | #else |
hudakz | 0:5350a66d5279 | 362 | #define UIP_ARPTAB_SIZE 8 |
hudakz | 0:5350a66d5279 | 363 | #endif |
hudakz | 0:5350a66d5279 | 364 | /** |
hudakz | 0:5350a66d5279 | 365 | * The maxium age of ARP table entries measured in 10ths of seconds. |
hudakz | 0:5350a66d5279 | 366 | * |
hudakz | 0:5350a66d5279 | 367 | * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD |
hudakz | 0:5350a66d5279 | 368 | * default). |
hudakz | 0:5350a66d5279 | 369 | */ |
hudakz | 0:5350a66d5279 | 370 | |
hudakz | 0:5350a66d5279 | 371 | #define UIP_ARP_MAXAGE 120 |
hudakz | 0:5350a66d5279 | 372 | |
hudakz | 0:5350a66d5279 | 373 | /** @} */ |
hudakz | 0:5350a66d5279 | 374 | |
hudakz | 0:5350a66d5279 | 375 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 376 | /** |
hudakz | 0:5350a66d5279 | 377 | * \name General configuration options |
hudakz | 0:5350a66d5279 | 378 | * @{ |
hudakz | 0:5350a66d5279 | 379 | */ |
hudakz | 0:5350a66d5279 | 380 | /** |
hudakz | 0:5350a66d5279 | 381 | * The size of the uIP packet buffer. |
hudakz | 0:5350a66d5279 | 382 | * |
hudakz | 0:5350a66d5279 | 383 | * The uIP packet buffer should not be smaller than 60 bytes, and does |
hudakz | 0:5350a66d5279 | 384 | * not need to be larger than 1500 bytes. Lower size results in lower |
hudakz | 0:5350a66d5279 | 385 | * TCP throughput, larger size results in higher TCP throughput. |
hudakz | 0:5350a66d5279 | 386 | * |
hudakz | 0:5350a66d5279 | 387 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 388 | */ |
hudakz | 0:5350a66d5279 | 389 | #ifndef UIP_CONF_BUFFER_SIZE |
hudakz | 0:5350a66d5279 | 390 | #define UIP_BUFSIZE 400 |
hudakz | 0:5350a66d5279 | 391 | #else /* UIP_CONF_BUFFER_SIZE */ |
hudakz | 0:5350a66d5279 | 392 | |
hudakz | 0:5350a66d5279 | 393 | #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE |
hudakz | 0:5350a66d5279 | 394 | #endif /* UIP_CONF_BUFFER_SIZE */ |
hudakz | 0:5350a66d5279 | 395 | |
hudakz | 0:5350a66d5279 | 396 | /** |
hudakz | 0:5350a66d5279 | 397 | * Determines if statistics support should be compiled in. |
hudakz | 0:5350a66d5279 | 398 | * |
hudakz | 0:5350a66d5279 | 399 | * The statistics is useful for debugging and to show the user. |
hudakz | 0:5350a66d5279 | 400 | * |
hudakz | 0:5350a66d5279 | 401 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 402 | */ |
hudakz | 0:5350a66d5279 | 403 | |
hudakz | 0:5350a66d5279 | 404 | #ifndef UIP_CONF_STATISTICS |
hudakz | 0:5350a66d5279 | 405 | #define UIP_STATISTICS 0 |
hudakz | 0:5350a66d5279 | 406 | #else /* UIP_CONF_STATISTICS */ |
hudakz | 0:5350a66d5279 | 407 | |
hudakz | 0:5350a66d5279 | 408 | #define UIP_STATISTICS UIP_CONF_STATISTICS |
hudakz | 0:5350a66d5279 | 409 | #endif /* UIP_CONF_STATISTICS */ |
hudakz | 0:5350a66d5279 | 410 | |
hudakz | 0:5350a66d5279 | 411 | /** |
hudakz | 0:5350a66d5279 | 412 | * Determines if logging of certain events should be compiled in. |
hudakz | 0:5350a66d5279 | 413 | * |
hudakz | 0:5350a66d5279 | 414 | * This is useful mostly for debugging. The function uip_log() |
hudakz | 0:5350a66d5279 | 415 | * must be implemented to suit the architecture of the project, if |
hudakz | 0:5350a66d5279 | 416 | * logging is turned on. |
hudakz | 0:5350a66d5279 | 417 | * |
hudakz | 0:5350a66d5279 | 418 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 419 | */ |
hudakz | 0:5350a66d5279 | 420 | |
hudakz | 0:5350a66d5279 | 421 | #ifndef UIP_CONF_LOGGING |
hudakz | 0:5350a66d5279 | 422 | #define UIP_LOGGING 0 |
hudakz | 0:5350a66d5279 | 423 | #else /* UIP_CONF_LOGGING */ |
hudakz | 0:5350a66d5279 | 424 | |
hudakz | 0:5350a66d5279 | 425 | #define UIP_LOGGING UIP_CONF_LOGGING |
hudakz | 0:5350a66d5279 | 426 | #endif /* UIP_CONF_LOGGING */ |
hudakz | 0:5350a66d5279 | 427 | |
hudakz | 0:5350a66d5279 | 428 | /** |
hudakz | 0:5350a66d5279 | 429 | * Broadcast support. |
hudakz | 0:5350a66d5279 | 430 | * |
hudakz | 0:5350a66d5279 | 431 | * This flag configures IP broadcast support. This is useful only |
hudakz | 0:5350a66d5279 | 432 | * together with UDP. |
hudakz | 0:5350a66d5279 | 433 | * |
hudakz | 0:5350a66d5279 | 434 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 435 | * |
hudakz | 0:5350a66d5279 | 436 | */ |
hudakz | 0:5350a66d5279 | 437 | |
hudakz | 0:5350a66d5279 | 438 | #if UIP_UDP && UIP_CONF_BROADCAST |
hudakz | 0:5350a66d5279 | 439 | #define UIP_BROADCAST UIP_CONF_BROADCAST |
hudakz | 0:5350a66d5279 | 440 | #else /* UIP_CONF_BROADCAST */ |
hudakz | 0:5350a66d5279 | 441 | |
hudakz | 0:5350a66d5279 | 442 | #define UIP_BROADCAST 0 |
hudakz | 0:5350a66d5279 | 443 | #endif /* UIP_CONF_BROADCAST */ |
hudakz | 0:5350a66d5279 | 444 | |
hudakz | 0:5350a66d5279 | 445 | /** |
hudakz | 0:5350a66d5279 | 446 | * Print out a uIP log message. |
hudakz | 0:5350a66d5279 | 447 | * |
hudakz | 0:5350a66d5279 | 448 | * This function must be implemented by the module that uses uIP, and |
hudakz | 0:5350a66d5279 | 449 | * is called by uIP whenever a log message is generated. |
hudakz | 0:5350a66d5279 | 450 | */ |
hudakz | 0:5350a66d5279 | 451 | void uip_log(char* msg); |
hudakz | 0:5350a66d5279 | 452 | |
hudakz | 0:5350a66d5279 | 453 | /** |
hudakz | 0:5350a66d5279 | 454 | * The link level header length. |
hudakz | 0:5350a66d5279 | 455 | * |
hudakz | 0:5350a66d5279 | 456 | * This is the offset into the uip_buf where the IP header can be |
hudakz | 0:5350a66d5279 | 457 | * found. For Ethernet, this should be set to 14. For SLIP, this |
hudakz | 0:5350a66d5279 | 458 | * should be set to 0. |
hudakz | 0:5350a66d5279 | 459 | * |
hudakz | 0:5350a66d5279 | 460 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 461 | */ |
hudakz | 0:5350a66d5279 | 462 | |
hudakz | 0:5350a66d5279 | 463 | #ifdef UIP_CONF_LLH_LEN |
hudakz | 0:5350a66d5279 | 464 | #define UIP_LLH_LEN UIP_CONF_LLH_LEN |
hudakz | 0:5350a66d5279 | 465 | #else /* UIP_CONF_LLH_LEN */ |
hudakz | 0:5350a66d5279 | 466 | |
hudakz | 0:5350a66d5279 | 467 | #define UIP_LLH_LEN 14 |
hudakz | 0:5350a66d5279 | 468 | #endif /* UIP_CONF_LLH_LEN */ |
hudakz | 0:5350a66d5279 | 469 | |
hudakz | 0:5350a66d5279 | 470 | /** @} */ |
hudakz | 0:5350a66d5279 | 471 | |
hudakz | 0:5350a66d5279 | 472 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 473 | /** |
hudakz | 0:5350a66d5279 | 474 | * \name CPU architecture configuration |
hudakz | 0:5350a66d5279 | 475 | * @{ |
hudakz | 0:5350a66d5279 | 476 | * |
hudakz | 0:5350a66d5279 | 477 | * The CPU architecture configuration is where the endianess of the |
hudakz | 0:5350a66d5279 | 478 | * CPU on which uIP is to be run is specified. Most CPUs today are |
hudakz | 0:5350a66d5279 | 479 | * little endian, and the most notable exception are the Motorolas |
hudakz | 0:5350a66d5279 | 480 | * which are big endian. The BYTE_ORDER macro should be changed to |
hudakz | 0:5350a66d5279 | 481 | * reflect the CPU architecture on which uIP is to be run. |
hudakz | 0:5350a66d5279 | 482 | */ |
hudakz | 0:5350a66d5279 | 483 | /** |
hudakz | 0:5350a66d5279 | 484 | * The byte order of the CPU architecture on which uIP is to be run. |
hudakz | 0:5350a66d5279 | 485 | * |
hudakz | 0:5350a66d5279 | 486 | * This option can be either BIG_ENDIAN (Motorola byte order) or |
hudakz | 0:5350a66d5279 | 487 | * LITTLE_ENDIAN (Intel byte order). |
hudakz | 0:5350a66d5279 | 488 | * |
hudakz | 0:5350a66d5279 | 489 | * \hideinitializer |
hudakz | 0:5350a66d5279 | 490 | */ |
hudakz | 0:5350a66d5279 | 491 | #ifdef UIP_CONF_BYTE_ORDER |
hudakz | 0:5350a66d5279 | 492 | #define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER |
hudakz | 0:5350a66d5279 | 493 | #else /* UIP_CONF_BYTE_ORDER */ |
hudakz | 0:5350a66d5279 | 494 | |
hudakz | 0:5350a66d5279 | 495 | #define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN |
hudakz | 0:5350a66d5279 | 496 | #endif /* UIP_CONF_BYTE_ORDER */ |
hudakz | 0:5350a66d5279 | 497 | |
hudakz | 0:5350a66d5279 | 498 | /** @} */ |
hudakz | 0:5350a66d5279 | 499 | |
hudakz | 0:5350a66d5279 | 500 | /*------------------------------------------------------------------------------*/ |
hudakz | 0:5350a66d5279 | 501 | /** |
hudakz | 0:5350a66d5279 | 502 | * \name Appication specific configurations |
hudakz | 0:5350a66d5279 | 503 | * @{ |
hudakz | 0:5350a66d5279 | 504 | * |
hudakz | 0:5350a66d5279 | 505 | * An uIP application is implemented using a single application |
hudakz | 0:5350a66d5279 | 506 | * function that is called by uIP whenever a TCP/IP event occurs. The |
hudakz | 0:5350a66d5279 | 507 | * name of this function must be registered with uIP at compile time |
hudakz | 0:5350a66d5279 | 508 | * using the UIP_APPCALL definition. |
hudakz | 0:5350a66d5279 | 509 | * |
hudakz | 0:5350a66d5279 | 510 | * uIP applications can store the application state within the |
hudakz | 0:5350a66d5279 | 511 | * uip_conn structure by specifying the type of the application |
hudakz | 0:5350a66d5279 | 512 | * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t. |
hudakz | 0:5350a66d5279 | 513 | * |
hudakz | 0:5350a66d5279 | 514 | * The file containing the definitions must be included in the |
hudakz | 0:5350a66d5279 | 515 | * uipopt.h file. |
hudakz | 0:5350a66d5279 | 516 | * |
hudakz | 0:5350a66d5279 | 517 | * The following example illustrates how this can look. |
hudakz | 0:5350a66d5279 | 518 | \code |
hudakz | 0:5350a66d5279 | 519 | |
hudakz | 0:5350a66d5279 | 520 | void httpd_appcall(void); |
hudakz | 0:5350a66d5279 | 521 | #define UIP_APPCALL httpd_appcall |
hudakz | 0:5350a66d5279 | 522 | |
hudakz | 0:5350a66d5279 | 523 | struct httpd_state { |
hudakz | 0:5350a66d5279 | 524 | u8_t state; |
hudakz | 0:5350a66d5279 | 525 | u16_t count; |
hudakz | 0:5350a66d5279 | 526 | char *dataptr; |
hudakz | 0:5350a66d5279 | 527 | char *script; |
hudakz | 0:5350a66d5279 | 528 | }; |
hudakz | 0:5350a66d5279 | 529 | typedef struct httpd_state uip_tcp_appstate_t |
hudakz | 0:5350a66d5279 | 530 | \endcode |
hudakz | 0:5350a66d5279 | 531 | */ |
hudakz | 0:5350a66d5279 | 532 | /** |
hudakz | 0:5350a66d5279 | 533 | * \var #define UIP_APPCALL |
hudakz | 0:5350a66d5279 | 534 | * |
hudakz | 0:5350a66d5279 | 535 | * The name of the application function that uIP should call in |
hudakz | 0:5350a66d5279 | 536 | * response to TCP/IP events. |
hudakz | 0:5350a66d5279 | 537 | * |
hudakz | 0:5350a66d5279 | 538 | */ |
hudakz | 0:5350a66d5279 | 539 | /** |
hudakz | 0:5350a66d5279 | 540 | * \var typedef uip_tcp_appstate_t |
hudakz | 0:5350a66d5279 | 541 | * |
hudakz | 0:5350a66d5279 | 542 | * The type of the application state that is to be stored in the |
hudakz | 0:5350a66d5279 | 543 | * uip_conn structure. This usually is typedef:ed to a struct holding |
hudakz | 0:5350a66d5279 | 544 | * application state information. |
hudakz | 0:5350a66d5279 | 545 | */ |
hudakz | 0:5350a66d5279 | 546 | /** |
hudakz | 0:5350a66d5279 | 547 | * \var typedef uip_udp_appstate_t |
hudakz | 0:5350a66d5279 | 548 | * |
hudakz | 0:5350a66d5279 | 549 | * The type of the application state that is to be stored in the |
hudakz | 0:5350a66d5279 | 550 | * uip_conn structure. This usually is typedef:ed to a struct holding |
hudakz | 0:5350a66d5279 | 551 | * application state information. |
hudakz | 0:5350a66d5279 | 552 | */ |
hudakz | 0:5350a66d5279 | 553 | /** @} */ |
hudakz | 0:5350a66d5279 | 554 | /** @} */ |
hudakz | 0:5350a66d5279 | 555 | #endif /* __UIPOPT_H__ */ |