blob: 7afcbc0c6bb5df4a2dde813a582e4594171f7c1e [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 *
adamdunkelsae920f92004-07-04 16:52:30 +000056 * $Id: uipopt.h,v 1.12 2004/07/04 16:52:30 adamdunkels 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 */
231#define UIP_UDP_CHECKSUMS 0
232
233/**
234 * The maximum amount of concurrent UDP connections.
235 *
236 * \hideinitializer
237 */
adamdunkelsf0626ad2004-03-25 09:46:32 +0000238#ifdef UIP_CONF_UDP_CONNS
239#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
240#else /* UIP_CONF_UDP_CONNS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000241#define UIP_UDP_CONNS 10
adamdunkelsf0626ad2004-03-25 09:46:32 +0000242#endif /* UIP_CONF_UDP_CONNS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000243
244/**
245 * The name of the function that should be called when UDP datagrams arrive.
246 *
247 * \hideinitializer
248 */
adamdunkelsae920f92004-07-04 16:52:30 +0000249
adamdunkelsb489e7a2003-10-14 11:12:50 +0000250
251/** @} */
252/*------------------------------------------------------------------------------*/
253/**
254 * \defgroup uipopttcp TCP configuration options
255 * @{
256 */
257
258/**
259 * Determines if support for opening connections from uIP should be
260 * compiled in.
261 *
262 * If the applications that are running on top of uIP for this project
263 * do not need to open outgoing TCP connections, this configration
264 * option can be turned off to reduce the code size of uIP.
265 *
266 * \hideinitializer
267 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000268#define UIP_ACTIVE_OPEN 1
269
adamdunkelsb489e7a2003-10-14 11:12:50 +0000270/**
271 * The maximum number of simultaneously open TCP connections.
272 *
273 * Since the TCP connections are statically allocated, turning this
274 * configuration knob down results in less RAM used. Each TCP
275 * connection requires approximatly 30 bytes of memory.
276 *
277 * \hideinitializer
278 */
adamdunkels43748a12003-06-30 20:38:05 +0000279#ifndef UIP_CONF_MAX_CONNECTIONS
280#define UIP_CONNS 10
281#else /* UIP_CONF_MAX_CONNECTIONS */
282#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
283#endif /* UIP_CONF_MAX_CONNECTIONS */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000284
adamdunkelsb489e7a2003-10-14 11:12:50 +0000285
286/**
287 * The maximum number of simultaneously listening TCP ports.
288 *
289 * Each listening TCP port requires 2 bytes of memory.
290 *
291 * \hideinitializer
292 */
adamdunkels43748a12003-06-30 20:38:05 +0000293#ifndef UIP_CONF_MAX_LISTENPORTS
294#define UIP_LISTENPORTS 20
295#else /* UIP_CONF_MAX_LISTENPORTS */
296#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
297#endif /* UIP_CONF_MAX_LISTENPORTS */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000298
adamdunkelsb489e7a2003-10-14 11:12:50 +0000299/**
300 * The size of the advertised receiver's window.
301 *
302 * Should be set low (i.e., to the size of the uip_buf buffer) is the
303 * application is slow to process incoming data, or high (32768 bytes)
304 * if the application processes data quickly.
305 *
306 * \hideinitializer
307 */
adamdunkels4735e722003-11-27 15:50:54 +0000308#ifndef UIP_CONF_RECEIVE_WINDOW
adamdunkelsb489e7a2003-10-14 11:12:50 +0000309#define UIP_RECEIVE_WINDOW 32768
adamdunkels4735e722003-11-27 15:50:54 +0000310#else
311#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
312#endif
adamdunkelsb489e7a2003-10-14 11:12:50 +0000313
314/**
315 * Determines if support for TCP urgent data notification should be
316 * compiled in.
317 *
318 * Urgent data (out-of-band data) is a rarely used TCP feature that
319 * very seldom would be required.
320 *
321 * \hideinitializer
322 */
adamdunkels3785cbb2004-06-06 06:17:28 +0000323#define UIP_URGDATA 0
adamdunkelsb489e7a2003-10-14 11:12:50 +0000324
325/**
326 * The initial retransmission timeout counted in timer pulses.
327 *
328 * This should not be changed.
329 */
330#define UIP_RTO 3
331
332/**
333 * The maximum number of times a segment should be retransmitted
334 * before the connection should be aborted.
335 *
336 * This should not be changed.
337 */
338#define UIP_MAXRTX 8
339
340/**
341 * The maximum number of times a SYN segment should be retransmitted
342 * before a connection request should be deemed to have been
343 * unsuccessful.
344 *
345 * This should not need to be changed.
346 */
adamdunkels4735e722003-11-27 15:50:54 +0000347#define UIP_MAXSYNRTX 5
adamdunkelsb489e7a2003-10-14 11:12:50 +0000348
349/**
350 * The TCP maximum segment size.
351 *
352 * This is should not be to set to more than UIP_BUFSIZE - UIP_LLH_LEN - 40.
353 */
adamdunkelsf0626ad2004-03-25 09:46:32 +0000354#define UIP_TCP_MSS (UIP_BUFSIZE - (UIP_LLH_LEN) - 40)
adamdunkelsb489e7a2003-10-14 11:12:50 +0000355
356/**
357 * How long a connection should stay in the TIME_WAIT state.
358 *
359 * This configiration option has no real implication, and it should be
360 * left untouched.
361 */
362#define UIP_TIME_WAIT_TIMEOUT 120
363
364
365/** @} */
366/*------------------------------------------------------------------------------*/
367/**
368 * \defgroup uipoptarp ARP configuration options
369 * @{
370 */
371
372/**
373 * The size of the ARP table.
374 *
375 * This option should be set to a larger value if this uIP node will
376 * have many connections from the local network.
377 *
378 * \hideinitializer
379 */
380#define UIP_ARPTAB_SIZE 8
381
382/**
383 * The maxium age of ARP table entries measured in 10ths of seconds.
384 *
385 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
386 * default).
387 */
388#define UIP_ARP_MAXAGE 120
389
390/** @} */
391
392/*------------------------------------------------------------------------------*/
393
394/**
395 * \defgroup uipoptgeneral General configuration options
396 * @{
397 */
398
399/**
400 * The size of the uIP packet buffer.
401 *
402 * The uIP packet buffer should not be smaller than 60 bytes, and does
403 * not need to be larger than 1500 bytes. Lower size results in lower
404 * TCP throughput, larger size results in higher TCP throughput.
405 *
406 * \hideinitializer
407 */
adamdunkels43748a12003-06-30 20:38:05 +0000408#ifndef UIP_CONF_BUFFER_SIZE
409#define UIP_BUFSIZE 400
410#else /* UIP_CONF_BUFFER_SIZE */
411#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
412#endif /* UIP_CONF_BUFFER_SIZE */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000413
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000414
adamdunkelsb489e7a2003-10-14 11:12:50 +0000415/**
416 * Determines if statistics support should be compiled in.
417 *
418 * The statistics is useful for debugging and to show the user.
419 *
420 * \hideinitializer
421 */
adamdunkels86a4a952004-03-18 21:07:35 +0000422#ifndef UIP_CONF_STATISTICS
423#define UIP_STATISTICS 0
424#else /* UIP_CONF_STATISTICS */
425#define UIP_STATISTICS UIP_CONF_STATISTICS
426#endif /* UIP_CONF_STATISTICS */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000427
428/**
429 * Determines if logging of certain events should be compiled in.
430 *
431 * This is useful mostly for debugging. The function uip_log()
432 * must be implemented to suit the architecture of the project, if
433 * logging is turned on.
434 *
435 * \hideinitializer
436 */
adamdunkels86a4a952004-03-18 21:07:35 +0000437#ifndef UIP_CONF_LOGGING
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000438#define UIP_LOGGING 0
adamdunkels86a4a952004-03-18 21:07:35 +0000439#else /* UIP_CONF_LOGGING */
440#define UIP_LOGGING UIP_CONF_LOGGING
441#endif /* UIP_CONF_LOGGING */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000442
adamdunkelsb489e7a2003-10-14 11:12:50 +0000443/**
adamdunkels3785cbb2004-06-06 06:17:28 +0000444 * Broadcast support.
445 *
446 * This flag configures IP broadcast support. This is useful only
447 * together with UDP.
448 *
449 * \hideinitializer
450 *
451 */
452#ifndef UIP_CONF_BROADCAST
453#define UIP_BROADCAST 0
454#else /* UIP_CONF_BROADCAST */
455#define UIP_BROADCAST UIP_CONF_BROADCAST
456#endif /* UIP_CONF_BROADCAST */
457
458/**
adamdunkelsb489e7a2003-10-14 11:12:50 +0000459 * Print out a uIP log message.
460 *
461 * This function must be implemented by the module that uses uIP, and
462 * is called by uIP whenever a log message is generated.
463 */
464void uip_log(char *msg);
465
466/**
467 * The link level header length.
468 *
469 * This is the offset into the uip_buf where the IP header can be
470 * found. For Ethernet, this should be set to 14. For SLIP, this
471 * should be set to 0.
472 *
473 * \hideinitializer
474 */
adamdunkels4735e722003-11-27 15:50:54 +0000475#ifdef UIP_CONF_LLH_LEN
476#define UIP_LLH_LEN UIP_CONF_LLH_LEN
477#else /* UIP_CONF_LLH_LEN */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000478#define UIP_LLH_LEN 14
adamdunkels4735e722003-11-27 15:50:54 +0000479#endif /* UIP_CONF_LLH_LEN */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000480
481/** @} */
482/*------------------------------------------------------------------------------*/
483/**
484 * \defgroup uipoptcpu CPU architecture configuration
485 * @{
486 *
487 * The CPU architecture configuration is where the endianess of the
488 * CPU on which uIP is to be run is specified. Most CPUs today are
489 * little endian, and the most notable exception are the Motorolas
490 * which are big endian. The BYTE_ORDER macro should be changed to
491 * reflect the CPU architecture on which uIP is to be run.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000492 */
493
adamdunkelsb489e7a2003-10-14 11:12:50 +0000494/**
495 * The byte order of the CPU architecture on which uIP is to be run.
496 *
497 * This option can be either BIG_ENDIAN (Motorola byte order) or
498 * LITTLE_ENDIAN (Intel byte order).
499 *
500 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000501 */
adamdunkels43748a12003-06-30 20:38:05 +0000502#ifdef UIP_CONF_BYTE_ORDER
503#define BYTE_ORDER UIP_CONF_BYTE_ORDER
504#else /* UIP_CONF_BYTE_ORDER */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000505#define BYTE_ORDER LITTLE_ENDIAN
adamdunkels43748a12003-06-30 20:38:05 +0000506#endif /* UIP_CONF_BYTE_ORDER */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000507
508
509/** @} */
510/*------------------------------------------------------------------------------*/
511
512/**
513 * \defgroup uipoptapp Appication specific configurations
514 * @{
515 *
516 * An uIP application is implemented using a single application
517 * function that is called by uIP whenever a TCP/IP event occurs. The
518 * name of this function must be registered with uIP at compile time
519 * using the UIP_APPCALL definition.
520 *
521 * uIP applications can store the application state within the
522 * uip_conn structure by specifying the size of the application
523 * structure with the UIP_APPSTATE_SIZE macro.
524 *
525 * The file containing the definitions must be included in the
526 * uipopt.h file.
527 *
528 * The following example illustrates how this can look.
529 \code
530
531void httpd_appcall(void);
532#define UIP_APPCALL httpd_appcall
533
534struct httpd_state {
535 u8_t state;
536 u16_t count;
537 char *dataptr;
538 char *script;
539};
540#define UIP_APPSTATE_SIZE (sizeof(struct httpd_state))
541 \endcode
542 */
543
544/**
545 * \var #define UIP_APPCALL
546 *
547 * The name of the application function that uIP should call in
548 * response to TCP/IP events.
549 *
550 */
551
552/**
553 * \var #define UIP_APPSTATE_SIZE
554 *
555 * The size of the application state that is to be stored in the
556 * uip_conn structure.
557 */
558/** @} */
559
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000560
561#endif /* __UIPOPT_H__ */