2 * \defgroup uipopt Configuration options for uIP
5 * uIP is configured using the per-project configuration file
6 * uipopt.h. This file contains all compile-time options for uIP and
7 * should be tweaked to match each specific project. The uIP
8 * distribution contains a documented example "uipopt.h" that can be
9 * copied and modified for each project.
11 * \note Most of the configuration options in the uipopt.h should not
12 * be changed, but rather the per-project uip-conf.h file.
17 * Configuration options for uIP.
18 * \author Adam Dunkels <adam@dunkels.com>
20 * This file is used for tweaking various configuration options for
21 * uIP. You should make a copy of this file into one of your project's
22 * directories instead of editing this example "uipopt.h" file that
23 * comes with the uIP distribution.
27 * Copyright (c) 2001-2003, Adam Dunkels.
28 * All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. The name of the author may not be used to endorse or promote
39 * products derived from this software without specific prior
42 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
43 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
44 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
46 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
48 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
51 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
52 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 * This file is part of the uIP TCP/IP stack.
56 * $Id: uipopt.h,v 1.3 2008/08/13 20:12:18 andrewlxia Exp $
63 #ifndef UIP_LITTLE_ENDIAN
64 #define UIP_LITTLE_ENDIAN 3412
65 #endif /* UIP_LITTLE_ENDIAN */
66 #ifndef UIP_BIG_ENDIAN
67 #define UIP_BIG_ENDIAN 1234
68 #endif /* UIP_BIG_ENDIAN */
70 #include <uip/uip-conf.h>
72 /*------------------------------------------------------------------------------*/
75 * \name Static configuration options
78 * These configuration options can be used for setting the IP address
79 * settings statically, but only if UIP_FIXEDADDR is set to 1. The
80 * configuration options for a specific node includes IP address,
81 * netmask and default router as well as the Ethernet address. The
82 * netmask, default router and Ethernet address are appliciable only
83 * if uIP should be run over Ethernet.
85 * All of these should be changed to suit your project.
89 * Determines if uIP should use a fixed IP address or not.
91 * If uIP should use a fixed IP address, the settings are set in the
92 * uipopt.h file. If not, the macros uip_sethostaddr(),
93 * uip_setdraddr() and uip_setnetmask() should be used instead.
97 #define UIP_FIXEDADDR 0
100 * Ping IP address asignment.
102 * uIP uses a "ping" packets for setting its own IP address if this
103 * option is set. If so, uIP will start with an empty IP address and
104 * the destination IP address of the first incoming "ping" (ICMP echo)
105 * packet will be used for setting the hosts IP address.
107 * \note This works only if UIP_FIXEDADDR is 0.
111 #ifdef UIP_CONF_PINGADDRCONF
112 #define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
113 #else /* UIP_CONF_PINGADDRCONF */
114 #define UIP_PINGADDRCONF 0
115 #endif /* UIP_CONF_PINGADDRCONF */
119 * Specifies if the uIP ARP module should be compiled with a fixed
120 * Ethernet MAC address or not.
122 * If this configuration option is 0, the macro uip_setethaddr() can
123 * be used to specify the Ethernet address at run-time.
127 #define UIP_FIXEDETHADDR 0
130 /*------------------------------------------------------------------------------*/
132 * \name IP configuration options
137 * The IP TTL (time to live) of IP packets sent by uIP.
139 * This should normally not be changed.
144 * Turn on support for IP packet reassembly.
146 * uIP supports reassembly of fragmented IP packets. This features
147 * requires an additonal amount of RAM to hold the reassembly buffer
148 * and the reassembly code size is approximately 700 bytes. The
149 * reassembly buffer is of the same size as the uip_buf buffer
150 * (configured by UIP_BUFSIZE).
152 * \note IP packet reassembly is not heavily tested.
156 #define UIP_REASSEMBLY 0
159 * The maximum time an IP fragment should wait in the reassembly
160 * buffer before it is dropped.
163 #define UIP_REASS_MAXAGE 40
167 /*------------------------------------------------------------------------------*/
169 * \name UDP configuration options
174 * Toggles wether UDP support should be compiled in or not.
179 #define UIP_UDP UIP_CONF_UDP
180 #else /* UIP_CONF_UDP */
182 #endif /* UIP_CONF_UDP */
185 * Toggles if UDP checksums should be used or not.
187 * \note Support for UDP checksums is currently not included in uIP,
188 * so this option has no function.
192 #ifdef UIP_CONF_UDP_CHECKSUMS
193 #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
195 #define UIP_UDP_CHECKSUMS 0
199 * The maximum amount of concurrent UDP connections.
203 #ifdef UIP_CONF_UDP_CONNS
204 #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
205 #else /* UIP_CONF_UDP_CONNS */
206 #define UIP_UDP_CONNS 10
207 #endif /* UIP_CONF_UDP_CONNS */
210 * The name of the function that should be called when UDP datagrams arrive.
217 /*------------------------------------------------------------------------------*/
219 * \name TCP configuration options
224 * Determines if support for opening connections from uIP should be
227 * If the applications that are running on top of uIP for this project
228 * do not need to open outgoing TCP connections, this configration
229 * option can be turned off to reduce the code size of uIP.
233 #define UIP_ACTIVE_OPEN 1
236 * The maximum number of simultaneously open TCP connections.
238 * Since the TCP connections are statically allocated, turning this
239 * configuration knob down results in less RAM used. Each TCP
240 * connection requires approximatly 30 bytes of memory.
244 #ifndef UIP_CONF_MAX_CONNECTIONS
246 #else /* UIP_CONF_MAX_CONNECTIONS */
247 #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
248 #endif /* UIP_CONF_MAX_CONNECTIONS */
252 * The maximum number of simultaneously listening TCP ports.
254 * Each listening TCP port requires 2 bytes of memory.
258 #ifndef UIP_CONF_MAX_LISTENPORTS
259 #define UIP_LISTENPORTS 20
260 #else /* UIP_CONF_MAX_LISTENPORTS */
261 #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
262 #endif /* UIP_CONF_MAX_LISTENPORTS */
265 * Determines if support for TCP urgent data notification should be
268 * Urgent data (out-of-band data) is a rarely used TCP feature that
269 * very seldom would be required.
273 #define UIP_URGDATA 0
276 * The initial retransmission timeout counted in timer pulses.
278 * This should not be changed.
283 * The maximum number of times a segment should be retransmitted
284 * before the connection should be aborted.
286 * This should not be changed.
291 * The maximum number of times a SYN segment should be retransmitted
292 * before a connection request should be deemed to have been
295 * This should not need to be changed.
297 #define UIP_MAXSYNRTX 5
300 * The TCP maximum segment size.
302 * This is should not be to set to more than
303 * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
305 #define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
308 * The size of the advertised receiver's window.
310 * Should be set low (i.e., to the size of the uip_buf buffer) is the
311 * application is slow to process incoming data, or high (32768 bytes)
312 * if the application processes data quickly.
316 #ifndef UIP_CONF_RECEIVE_WINDOW
317 #define UIP_RECEIVE_WINDOW UIP_TCP_MSS
319 #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
323 * How long a connection should stay in the TIME_WAIT state.
325 * This configiration option has no real implication, and it should be
328 #define UIP_TIME_WAIT_TIMEOUT 120
332 /*------------------------------------------------------------------------------*/
334 * \name ARP configuration options
339 * The size of the ARP table.
341 * This option should be set to a larger value if this uIP node will
342 * have many connections from the local network.
346 #ifdef UIP_CONF_ARPTAB_SIZE
347 #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
349 #define UIP_ARPTAB_SIZE 8
353 * The maxium age of ARP table entries measured in 10ths of seconds.
355 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
358 #define UIP_ARP_MAXAGE 120
362 /*------------------------------------------------------------------------------*/
365 * \name General configuration options
370 * The size of the uIP packet buffer.
372 * The uIP packet buffer should not be smaller than 60 bytes, and does
373 * not need to be larger than 1500 bytes. Lower size results in lower
374 * TCP throughput, larger size results in higher TCP throughput.
378 #ifndef UIP_CONF_BUFFER_SIZE
379 #define UIP_BUFSIZE 400
380 #else /* UIP_CONF_BUFFER_SIZE */
381 #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
382 #endif /* UIP_CONF_BUFFER_SIZE */
386 * Determines if statistics support should be compiled in.
388 * The statistics is useful for debugging and to show the user.
392 #ifndef UIP_CONF_STATISTICS
393 #define UIP_STATISTICS 0
394 #else /* UIP_CONF_STATISTICS */
395 #define UIP_STATISTICS UIP_CONF_STATISTICS
396 #endif /* UIP_CONF_STATISTICS */
399 * Determines if logging of certain events should be compiled in.
401 * This is useful mostly for debugging. The function uip_log()
402 * must be implemented to suit the architecture of the project, if
403 * logging is turned on.
407 #ifndef UIP_CONF_LOGGING
408 #define UIP_LOGGING 0
409 #else /* UIP_CONF_LOGGING */
410 #define UIP_LOGGING UIP_CONF_LOGGING
411 #endif /* UIP_CONF_LOGGING */
416 * This flag configures IP broadcast support. This is useful only
422 #ifndef UIP_CONF_BROADCAST
423 #define UIP_BROADCAST 0
424 #else /* UIP_CONF_BROADCAST */
425 #define UIP_BROADCAST UIP_CONF_BROADCAST
426 #endif /* UIP_CONF_BROADCAST */
429 * Print out a uIP log message.
431 * This function must be implemented by the module that uses uIP, and
432 * is called by uIP whenever a log message is generated.
434 extern void uip_log(char *msg); //you should replace this by your own log function
437 * The link level header length.
439 * This is the offset into the uip_buf where the IP header can be
440 * found. For Ethernet, this should be set to 14. For SLIP, this
441 * should be set to 0.
445 #ifdef UIP_CONF_LLH_LEN
446 #define UIP_LLH_LEN UIP_CONF_LLH_LEN
447 #else /* UIP_CONF_LLH_LEN */
448 #define UIP_LLH_LEN 14
449 #endif /* UIP_CONF_LLH_LEN */
452 /*------------------------------------------------------------------------------*/
454 * \name CPU architecture configuration
457 * The CPU architecture configuration is where the endianess of the
458 * CPU on which uIP is to be run is specified. Most CPUs today are
459 * little endian, and the most notable exception are the Motorolas
460 * which are big endian. The BYTE_ORDER macro should be changed to
461 * reflect the CPU architecture on which uIP is to be run.
465 * The byte order of the CPU architecture on which uIP is to be run.
467 * This option can be either BIG_ENDIAN (Motorola byte order) or
468 * LITTLE_ENDIAN (Intel byte order).
472 #ifdef UIP_CONF_BYTE_ORDER
473 #define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER
474 #else /* UIP_CONF_BYTE_ORDER */
475 #define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN
476 #endif /* UIP_CONF_BYTE_ORDER */
479 /*------------------------------------------------------------------------------*/
482 * \name Appication specific configurations
485 * An uIP application is implemented using a single application
486 * function that is called by uIP whenever a TCP/IP event occurs. The
487 * name of this function must be registered with uIP at compile time
488 * using the UIP_APPCALL definition.
490 * uIP applications can store the application state within the
491 * uip_conn structure by specifying the type of the application
492 * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
494 * The file containing the definitions must be included in the
497 * The following example illustrates how this can look.
500 void httpd_appcall(void);
501 #define UIP_APPCALL httpd_appcall
509 typedef struct httpd_state uip_tcp_appstate_t
514 * \var #define UIP_APPCALL
516 * The name of the application function that uIP should call in
517 * response to TCP/IP events.
522 * \var typedef uip_tcp_appstate_t
524 * The type of the application state that is to be stored in the
525 * uip_conn structure. This usually is typedef:ed to a struct holding
526 * application state information.
530 * \var typedef uip_udp_appstate_t
532 * The type of the application state that is to be stored in the
533 * uip_conn structure. This usually is typedef:ed to a struct holding
534 * application state information.
539 #endif /* __UIPOPT_H__ */