blob: 9f88594e745e022d20737960bce48cbe9ccd428f [file] [log] [blame]
adamdunkelsb489e7a2003-10-14 11:12:50 +00001/**
2 * \defgroup uipopt Configuration options for uIP
3 * @{
4 *
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.
10 *
11 * \note Contiki does not use the uipopt.h file to configure uIP, but
12 * uses a per-port uip-conf.h file that should be edited instead.
13 */
14
15/**
16 * \file
17 * Configuration options for uIP.
18 * \author Adam Dunkels <adam@dunkels.com>
19 *
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.
24 */
25
adamdunkelsca9ddcb2003-03-19 14:13:31 +000026/*
adamdunkelsb489e7a2003-10-14 11:12:50 +000027 * Copyright (c) 2001-2003, Adam Dunkels.
adamdunkelsca9ddcb2003-03-19 14:13:31 +000028 * All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
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.
adamdunkelsb489e7a2003-10-14 11:12:50 +000038 * 3. The name of the author may not be used to endorse or promote
adamdunkelsca9ddcb2003-03-19 14:13:31 +000039 * products derived from this software without specific prior
40 * written permission.
41 *
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.
53 *
54 * This file is part of the uIP TCP/IP stack.
55 *
oliverschmidt2e911812005-02-24 22:25:12 +000056 * $Id: uipopt.h,v 1.16 2005/02/24 22:25:12 oliverschmidt Exp $
adamdunkelsca9ddcb2003-03-19 14:13:31 +000057 *
58 */
59
60#ifndef __UIPOPT_H__
61#define __UIPOPT_H__
62
adamdunkels43748a12003-06-30 20:38:05 +000063#ifndef LITTLE_ENDIAN
64#define LITTLE_ENDIAN 3412
65#endif /* LITTLE_ENDIAN */
66#ifndef BIG_ENDIAN
67#define BIG_ENDIAN 1234
68#endif /* BIGE_ENDIAN */
69
70#include "uip-conf.h"
71
adamdunkelsb489e7a2003-10-14 11:12:50 +000072/*------------------------------------------------------------------------------*/
73/**
74 * \defgroup uipopttypedef uIP type definitions
75 * @{
76 */
77
78/**
79 * The 8-bit unsigned data type.
80 *
81 * This may have to be tweaked for your particular compiler. "unsigned
82 * char" works for most compilers.
83 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +000084typedef unsigned char u8_t;
adamdunkelsb489e7a2003-10-14 11:12:50 +000085
86/**
87 * The 16-bit unsigned data type.
88 *
89 * This may have to be tweaked for your particular compiler. "unsigned
90 * short" works for most compilers.
91 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +000092typedef unsigned short u16_t;
adamdunkelsca9ddcb2003-03-19 14:13:31 +000093
adamdunkelsb489e7a2003-10-14 11:12:50 +000094/**
95 * The statistics data type.
96 *
97 * This datatype determines how high the statistics counters are able
98 * to count.
99 */
100typedef unsigned short uip_stats_t;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000101
adamdunkelsb489e7a2003-10-14 11:12:50 +0000102/** @} */
103
adamdunkelsae920f92004-07-04 16:52:30 +0000104#include "tcpip.h"
adamdunkelsb489e7a2003-10-14 11:12:50 +0000105
106/*------------------------------------------------------------------------------*/
107
108/**
109 * \defgroup uipoptstaticconf Static configuration options
110 * @{
111 *
112 * These configuration options can be used for setting the IP address
113 * settings statically, but only if UIP_FIXEDADDR is set to 1. The
114 * configuration options for a specific node includes IP address,
115 * netmask and default router as well as the Ethernet address. The
116 * netmask, default router and Ethernet address are appliciable only
117 * if uIP should be run over Ethernet.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000118 *
119 * All of these should be changed to suit your project.
120*/
adamdunkels033e51d2003-10-01 11:33:43 +0000121
adamdunkelsb489e7a2003-10-14 11:12:50 +0000122/**
123 * Determines if uIP should use a fixed IP address or not.
124 *
125 * If uIP should use a fixed IP address, the settings are set in the
126 * uipopt.h file. If not, the macros uip_sethostaddr(),
127 * uip_setdraddr() and uip_setnetmask() should be used instead.
128 *
129 * \hideinitializer
130 */
131#define UIP_FIXEDADDR 0
132
133/**
134 * Ping IP address asignment.
135 *
136 * uIP uses a "ping" packets for setting its own IP address if this
137 * option is set. If so, uIP will start with an empty IP address and
138 * the destination IP address of the first incoming "ping" (ICMP echo)
139 * packet will be used for setting the hosts IP address.
140 *
141 * \note This works only if UIP_FIXEDADDR is 0.
142 *
143 * \hideinitializer
144 */
adamdunkels033e51d2003-10-01 11:33:43 +0000145#ifdef UIP_CONF_PINGADDRCONF
146#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
147#else /* UIP_CONF_PINGADDRCONF */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000148#define UIP_PINGADDRCONF 0
adamdunkels033e51d2003-10-01 11:33:43 +0000149#endif /* UIP_CONF_PINGADDRCONF */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000150
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000151
adamdunkelsb489e7a2003-10-14 11:12:50 +0000152/**
153 * Specifies if the uIP ARP module should be compiled with a fixed
154 * Ethernet MAC address or not.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000155 *
adamdunkelsb489e7a2003-10-14 11:12:50 +0000156 * If this configuration option is 0, the macro uip_setethaddr() can
157 * be used to specify the Ethernet address at run-time.
158 *
159 * \hideinitializer
160 */
161#define UIP_FIXEDETHADDR 0
162
163/** @} */
164/*------------------------------------------------------------------------------*/
165/**
166 * \defgroup uipoptip IP configuration options
167 * @{
168 *
169 */
170/**
171 * The IP TTL (time to live) of IP packets sent by uIP.
172 *
173 * This should normally not be changed.
174 */
175#define UIP_TTL 255
176
177/**
178 * Turn on support for IP packet reassembly.
179 *
180 * uIP supports reassembly of fragmented IP packets. This features
181 * requires an additonal amount of RAM to hold the reassembly buffer
182 * and the reassembly code size is approximately 700 bytes. The
183 * reassembly buffer is of the same size as the uip_buf buffer
184 * (configured by UIP_BUFSIZE).
185 *
186 * \note IP packet reassembly is not heavily tested.
187 *
188 * \hideinitializer
189 */
190#define UIP_REASSEMBLY 0
191
192/**
193 * The maximum time an IP fragment should wait in the reassembly
194 * buffer before it is dropped.
195 *
196 */
197#define UIP_REASS_MAXAGE 40
198
199/** @} */
200
201/*------------------------------------------------------------------------------*/
202/**
203 * \defgroup uipoptudp UDP configuration options
204 * @{
205 *
206 * \note The UDP support in uIP is still not entirely complete; there
207 * is no support for sending or receiving broadcast or multicast
208 * packets, but it works well enough to support a number of vital
209 * applications such as DNS queries, though
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000210 */
211
adamdunkelsb489e7a2003-10-14 11:12:50 +0000212/**
213 * Toggles wether UDP support should be compiled in or not.
214 *
215 * \hideinitializer
216 */
217#ifdef UIP_CONF_UDP
218#define UIP_UDP UIP_CONF_UDP
219#else /* UIP_CONF_UDP */
220#define UIP_UDP 1
221#endif /* UIP_CONF_UDP */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000222
adamdunkelsb489e7a2003-10-14 11:12:50 +0000223/**
224 * Toggles if UDP checksums should be used or not.
225 *
226 * \note Support for UDP checksums is currently not included in uIP,
227 * so this option has no function.
228 *
229 * \hideinitializer
230 */
adamdunkels7cc06762004-09-18 20:18:59 +0000231#ifdef UIP_CONF_UDP_CHECKSUMS
232#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
233#else
adamdunkelsb489e7a2003-10-14 11:12:50 +0000234#define UIP_UDP_CHECKSUMS 0
adamdunkels7cc06762004-09-18 20:18:59 +0000235#endif
adamdunkelsb489e7a2003-10-14 11:12:50 +0000236
237/**
238 * The maximum amount of concurrent UDP connections.
239 *
240 * \hideinitializer
241 */
adamdunkelsf0626ad2004-03-25 09:46:32 +0000242#ifdef UIP_CONF_UDP_CONNS
243#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
244#else /* UIP_CONF_UDP_CONNS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000245#define UIP_UDP_CONNS 10
adamdunkelsf0626ad2004-03-25 09:46:32 +0000246#endif /* UIP_CONF_UDP_CONNS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000247
248/**
249 * The name of the function that should be called when UDP datagrams arrive.
250 *
251 * \hideinitializer
252 */
adamdunkelsae920f92004-07-04 16:52:30 +0000253
adamdunkelsb489e7a2003-10-14 11:12:50 +0000254
255/** @} */
256/*------------------------------------------------------------------------------*/
257/**
258 * \defgroup uipopttcp TCP configuration options
259 * @{
260 */
261
262/**
263 * Determines if support for opening connections from uIP should be
264 * compiled in.
265 *
266 * If the applications that are running on top of uIP for this project
267 * do not need to open outgoing TCP connections, this configration
268 * option can be turned off to reduce the code size of uIP.
269 *
270 * \hideinitializer
271 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000272#define UIP_ACTIVE_OPEN 1
273
adamdunkelsb489e7a2003-10-14 11:12:50 +0000274/**
275 * The maximum number of simultaneously open TCP connections.
276 *
277 * Since the TCP connections are statically allocated, turning this
278 * configuration knob down results in less RAM used. Each TCP
279 * connection requires approximatly 30 bytes of memory.
280 *
281 * \hideinitializer
282 */
adamdunkels43748a12003-06-30 20:38:05 +0000283#ifndef UIP_CONF_MAX_CONNECTIONS
284#define UIP_CONNS 10
285#else /* UIP_CONF_MAX_CONNECTIONS */
286#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
287#endif /* UIP_CONF_MAX_CONNECTIONS */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000288
adamdunkelsb489e7a2003-10-14 11:12:50 +0000289
290/**
291 * The maximum number of simultaneously listening TCP ports.
292 *
293 * Each listening TCP port requires 2 bytes of memory.
294 *
295 * \hideinitializer
296 */
adamdunkels43748a12003-06-30 20:38:05 +0000297#ifndef UIP_CONF_MAX_LISTENPORTS
298#define UIP_LISTENPORTS 20
299#else /* UIP_CONF_MAX_LISTENPORTS */
300#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
301#endif /* UIP_CONF_MAX_LISTENPORTS */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000302
adamdunkelsb489e7a2003-10-14 11:12:50 +0000303/**
304 * The size of the advertised receiver's window.
305 *
306 * Should be set low (i.e., to the size of the uip_buf buffer) is the
307 * application is slow to process incoming data, or high (32768 bytes)
308 * if the application processes data quickly.
309 *
310 * \hideinitializer
311 */
adamdunkels4735e722003-11-27 15:50:54 +0000312#ifndef UIP_CONF_RECEIVE_WINDOW
oliverschmidt2e911812005-02-24 22:25:12 +0000313#define UIP_RECEIVE_WINDOW 32768U
adamdunkels4735e722003-11-27 15:50:54 +0000314#else
315#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
316#endif
adamdunkelsb489e7a2003-10-14 11:12:50 +0000317
318/**
319 * Determines if support for TCP urgent data notification should be
320 * compiled in.
321 *
322 * Urgent data (out-of-band data) is a rarely used TCP feature that
323 * very seldom would be required.
324 *
325 * \hideinitializer
326 */
adamdunkels3785cbb2004-06-06 06:17:28 +0000327#define UIP_URGDATA 0
adamdunkelsb489e7a2003-10-14 11:12:50 +0000328
329/**
330 * The initial retransmission timeout counted in timer pulses.
331 *
332 * This should not be changed.
333 */
334#define UIP_RTO 3
335
336/**
337 * The maximum number of times a segment should be retransmitted
338 * before the connection should be aborted.
339 *
340 * This should not be changed.
341 */
342#define UIP_MAXRTX 8
343
344/**
345 * The maximum number of times a SYN segment should be retransmitted
346 * before a connection request should be deemed to have been
347 * unsuccessful.
348 *
349 * This should not need to be changed.
350 */
adamdunkels4735e722003-11-27 15:50:54 +0000351#define UIP_MAXSYNRTX 5
adamdunkelsb489e7a2003-10-14 11:12:50 +0000352
353/**
354 * The TCP maximum segment size.
355 *
oliverschmidt37420872005-02-23 22:38:43 +0000356 * This is should not be to set to more than
357 * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000358 */
oliverschmidt37420872005-02-23 22:38:43 +0000359#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
adamdunkelsb489e7a2003-10-14 11:12:50 +0000360
361/**
362 * How long a connection should stay in the TIME_WAIT state.
363 *
364 * This configiration option has no real implication, and it should be
365 * left untouched.
366 */
367#define UIP_TIME_WAIT_TIMEOUT 120
368
369
370/** @} */
371/*------------------------------------------------------------------------------*/
372/**
373 * \defgroup uipoptarp ARP configuration options
374 * @{
375 */
376
377/**
378 * The size of the ARP table.
379 *
380 * This option should be set to a larger value if this uIP node will
381 * have many connections from the local network.
382 *
383 * \hideinitializer
384 */
adamdunkels4b3ba6b2004-08-09 20:10:09 +0000385#ifdef UIP_CONF_ARPTAB_SIZE
386#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
387#else
adamdunkelsb489e7a2003-10-14 11:12:50 +0000388#define UIP_ARPTAB_SIZE 8
adamdunkels4b3ba6b2004-08-09 20:10:09 +0000389#endif
adamdunkelsb489e7a2003-10-14 11:12:50 +0000390
391/**
392 * The maxium age of ARP table entries measured in 10ths of seconds.
393 *
394 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
395 * default).
396 */
397#define UIP_ARP_MAXAGE 120
398
399/** @} */
400
401/*------------------------------------------------------------------------------*/
402
403/**
404 * \defgroup uipoptgeneral General configuration options
405 * @{
406 */
407
408/**
409 * The size of the uIP packet buffer.
410 *
411 * The uIP packet buffer should not be smaller than 60 bytes, and does
412 * not need to be larger than 1500 bytes. Lower size results in lower
413 * TCP throughput, larger size results in higher TCP throughput.
414 *
415 * \hideinitializer
416 */
adamdunkels43748a12003-06-30 20:38:05 +0000417#ifndef UIP_CONF_BUFFER_SIZE
418#define UIP_BUFSIZE 400
419#else /* UIP_CONF_BUFFER_SIZE */
420#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
421#endif /* UIP_CONF_BUFFER_SIZE */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000422
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000423
adamdunkelsb489e7a2003-10-14 11:12:50 +0000424/**
425 * Determines if statistics support should be compiled in.
426 *
427 * The statistics is useful for debugging and to show the user.
428 *
429 * \hideinitializer
430 */
adamdunkels86a4a952004-03-18 21:07:35 +0000431#ifndef UIP_CONF_STATISTICS
432#define UIP_STATISTICS 0
433#else /* UIP_CONF_STATISTICS */
434#define UIP_STATISTICS UIP_CONF_STATISTICS
435#endif /* UIP_CONF_STATISTICS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000436
437/**
438 * Determines if logging of certain events should be compiled in.
439 *
440 * This is useful mostly for debugging. The function uip_log()
441 * must be implemented to suit the architecture of the project, if
442 * logging is turned on.
443 *
444 * \hideinitializer
445 */
adamdunkels86a4a952004-03-18 21:07:35 +0000446#ifndef UIP_CONF_LOGGING
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000447#define UIP_LOGGING 0
adamdunkels86a4a952004-03-18 21:07:35 +0000448#else /* UIP_CONF_LOGGING */
449#define UIP_LOGGING UIP_CONF_LOGGING
450#endif /* UIP_CONF_LOGGING */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000451
adamdunkelsb489e7a2003-10-14 11:12:50 +0000452/**
adamdunkels3785cbb2004-06-06 06:17:28 +0000453 * Broadcast support.
454 *
455 * This flag configures IP broadcast support. This is useful only
456 * together with UDP.
457 *
458 * \hideinitializer
459 *
460 */
461#ifndef UIP_CONF_BROADCAST
462#define UIP_BROADCAST 0
463#else /* UIP_CONF_BROADCAST */
464#define UIP_BROADCAST UIP_CONF_BROADCAST
465#endif /* UIP_CONF_BROADCAST */
466
467/**
adamdunkelsb489e7a2003-10-14 11:12:50 +0000468 * Print out a uIP log message.
469 *
470 * This function must be implemented by the module that uses uIP, and
471 * is called by uIP whenever a log message is generated.
472 */
473void uip_log(char *msg);
474
475/**
476 * The link level header length.
477 *
478 * This is the offset into the uip_buf where the IP header can be
479 * found. For Ethernet, this should be set to 14. For SLIP, this
480 * should be set to 0.
481 *
482 * \hideinitializer
483 */
adamdunkels4735e722003-11-27 15:50:54 +0000484#ifdef UIP_CONF_LLH_LEN
485#define UIP_LLH_LEN UIP_CONF_LLH_LEN
486#else /* UIP_CONF_LLH_LEN */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000487#define UIP_LLH_LEN 14
adamdunkels4735e722003-11-27 15:50:54 +0000488#endif /* UIP_CONF_LLH_LEN */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000489
490/** @} */
491/*------------------------------------------------------------------------------*/
492/**
493 * \defgroup uipoptcpu CPU architecture configuration
494 * @{
495 *
496 * The CPU architecture configuration is where the endianess of the
497 * CPU on which uIP is to be run is specified. Most CPUs today are
498 * little endian, and the most notable exception are the Motorolas
499 * which are big endian. The BYTE_ORDER macro should be changed to
500 * reflect the CPU architecture on which uIP is to be run.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000501 */
502
adamdunkelsb489e7a2003-10-14 11:12:50 +0000503/**
504 * The byte order of the CPU architecture on which uIP is to be run.
505 *
506 * This option can be either BIG_ENDIAN (Motorola byte order) or
507 * LITTLE_ENDIAN (Intel byte order).
508 *
509 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000510 */
adamdunkels43748a12003-06-30 20:38:05 +0000511#ifdef UIP_CONF_BYTE_ORDER
512#define BYTE_ORDER UIP_CONF_BYTE_ORDER
513#else /* UIP_CONF_BYTE_ORDER */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000514#define BYTE_ORDER LITTLE_ENDIAN
adamdunkels43748a12003-06-30 20:38:05 +0000515#endif /* UIP_CONF_BYTE_ORDER */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000516
517
518/** @} */
519/*------------------------------------------------------------------------------*/
520
521/**
522 * \defgroup uipoptapp Appication specific configurations
523 * @{
524 *
525 * An uIP application is implemented using a single application
526 * function that is called by uIP whenever a TCP/IP event occurs. The
527 * name of this function must be registered with uIP at compile time
528 * using the UIP_APPCALL definition.
529 *
530 * uIP applications can store the application state within the
531 * uip_conn structure by specifying the size of the application
532 * structure with the UIP_APPSTATE_SIZE macro.
533 *
534 * The file containing the definitions must be included in the
535 * uipopt.h file.
536 *
537 * The following example illustrates how this can look.
538 \code
539
540void httpd_appcall(void);
541#define UIP_APPCALL httpd_appcall
542
543struct httpd_state {
544 u8_t state;
545 u16_t count;
546 char *dataptr;
547 char *script;
548};
549#define UIP_APPSTATE_SIZE (sizeof(struct httpd_state))
550 \endcode
551 */
552
553/**
554 * \var #define UIP_APPCALL
555 *
556 * The name of the application function that uIP should call in
557 * response to TCP/IP events.
558 *
559 */
560
561/**
562 * \var #define UIP_APPSTATE_SIZE
563 *
564 * The size of the application state that is to be stored in the
565 * uip_conn structure.
566 */
567/** @} */
568
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000569
570#endif /* __UIPOPT_H__ */