Contiki-NG
Loading...
Searching...
No Matches
uipopt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001-2003, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior
15 * written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * This file is part of the uIP TCP/IP stack.
30 *
31 *
32 */
33
34/**
35 * \file
36 * Configuration options for uIP.
37 * \author Adam Dunkels <adam@dunkels.com>
38 *
39 * This file is used for tweaking various configuration options for
40 * uIP. You should make a copy of this file into one of your project's
41 * directories instead of editing this example "uipopt.h" file that
42 * comes with the uIP distribution.
43 */
44
45/**
46 * \addtogroup uip
47 * @{
48 */
49
50/**
51 * \defgroup uipopt Configuration options for uIP
52 * @{
53 *
54 * uIP is configured using the per-project configuration file
55 * "uipopt.h". This file contains all compile-time options for uIP and
56 * should be tweaked to match each specific project. The uIP
57 * distribution contains a documented example "uipopt.h" that can be
58 * copied and modified for each project.
59 *
60 * \note Contiki does not use the uipopt.h file to configure uIP, but
61 * uses a per-port uip-conf.h file that should be edited instead.
62 */
63
64#ifndef UIPOPT_H_
65#define UIPOPT_H_
66
67#ifndef UIP_LITTLE_ENDIAN
68#define UIP_LITTLE_ENDIAN 3412
69#endif /* UIP_LITTLE_ENDIAN */
70#ifndef UIP_BIG_ENDIAN
71#define UIP_BIG_ENDIAN 1234
72#endif /* UIP_BIG_ENDIAN */
73
74#include "contiki.h"
75
76/*------------------------------------------------------------------------------*/
77
78/**
79 * \defgroup uipoptgeneral General configuration options
80 * @{
81 */
82
83/**
84 * The size of the uIP packet buffer.
85 *
86 * The uIP packet buffer should not be smaller than 60 bytes, and does
87 * not need to be larger than 1514 bytes. Lower size results in lower
88 * TCP throughput, larger size results in higher TCP throughput.
89 *
90 * \hideinitializer
91 */
92#ifndef UIP_CONF_BUFFER_SIZE
93#define UIP_BUFSIZE (UIP_LINK_MTU)
94#else /* UIP_CONF_BUFFER_SIZE */
95#define UIP_BUFSIZE (UIP_CONF_BUFFER_SIZE)
96#endif /* UIP_CONF_BUFFER_SIZE */
97
98/**
99 * Determines if statistics support should be compiled in.
100 *
101 * The statistics is useful for debugging and to show the user.
102 *
103 * \hideinitializer
104 */
105#ifndef UIP_CONF_STATISTICS
106#define UIP_STATISTICS 0
107#else /* UIP_CONF_STATISTICS */
108#define UIP_STATISTICS (UIP_CONF_STATISTICS)
109#endif /* UIP_CONF_STATISTICS */
110
111/**
112 * Print out a uIP log message.
113 *
114 * This function must be implemented by the module that uses uIP, and
115 * is called by uIP whenever a log message is generated.
116 */
117void uip_log(char *msg);
118
119/** @} */
120/*------------------------------------------------------------------------------*/
121/**
122 * \defgroup uipoptip IP configuration options
123 * @{
124 *
125 */
126/**
127 * The IP TTL (time to live) of IP packets sent by uIP.
128 *
129 * This should normally not be changed.
130 */
131#ifdef UIP_CONF_TTL
132#define UIP_TTL UIP_CONF_TTL
133#else /* UIP_CONF_TTL */
134#define UIP_TTL 64
135#endif /* UIP_CONF_TTL */
136
137/**
138 * The maximum time an IP fragment should wait in the reassembly
139 * buffer before it is dropped.
140 *
141 */
142#define UIP_REASS_MAXAGE 60 /*60s*/
143
144/** @} */
145
146/*------------------------------------------------------------------------------*/
147/**
148 * \defgroup uipoptipv6 IPv6 configuration options
149 * @{
150 *
151 */
152
153/** The maximum transmission unit at the IP Layer*/
154#define UIP_LINK_MTU 1280
155
156#ifndef UIP_CONF_IPV6_QUEUE_PKT
157/** Do we do per %neighbor queuing during address resolution (default: no) */
158#define UIP_CONF_IPV6_QUEUE_PKT 0
159#endif
160
161#ifndef UIP_CONF_IPV6_CHECKS
162/** Do we do IPv6 consistency checks (highly recommended, default: yes) */
163#define UIP_CONF_IPV6_CHECKS 1
164#endif
165
166#ifndef UIP_CONF_IPV6_REASSEMBLY
167/** Do we do IPv6 fragmentation (default: no) */
168#define UIP_CONF_IPV6_REASSEMBLY 0
169#endif
170
171#ifndef UIP_CONF_NETIF_MAX_ADDRESSES
172/** Default number of IPv6 addresses associated to the node's interface */
173#define UIP_CONF_NETIF_MAX_ADDRESSES 3
174#endif
175
176#ifndef UIP_CONF_DS6_PREFIX_NBU
177/** Default number of IPv6 prefixes associated to the node's interface */
178#define UIP_CONF_DS6_PREFIX_NBU 2
179#endif
180
181#ifndef UIP_CONF_DS6_DEFRT_NBU
182/** Minimum number of default routers */
183#define UIP_CONF_DS6_DEFRT_NBU 2
184#endif
185/** @} */
186
187/*------------------------------------------------------------------------------*/
188/**
189 * \defgroup uipoptudp UDP configuration options
190 * @{
191 *
192 * \note The UDP support in uIP is still not entirely complete; there
193 * is no support for sending or receiving broadcast or multicast
194 * packets, but it works well enough to support a number of vital
195 * applications such as DNS queries, though
196 */
197
198/**
199 * Toggles whether UDP support should be compiled in or not.
200 *
201 * \hideinitializer
202 */
203#ifdef UIP_CONF_UDP
204#define UIP_UDP UIP_CONF_UDP
205#else /* UIP_CONF_UDP */
206#define UIP_UDP 1
207#endif /* UIP_CONF_UDP */
208
209/**
210 * Toggles if UDP checksums should be used or not.
211 *
212 * \note Support for UDP checksums is currently not included in uIP,
213 * so this option has no function.
214 *
215 * \hideinitializer
216 */
217#ifdef UIP_CONF_UDP_CHECKSUMS
218#define UIP_UDP_CHECKSUMS (UIP_CONF_UDP_CHECKSUMS)
219#else
220#define UIP_UDP_CHECKSUMS 1
221#endif
222
223/**
224 * The maximum amount of concurrent UDP connections.
225 *
226 * \hideinitializer
227 */
228#ifdef UIP_CONF_UDP_CONNS
229#define UIP_UDP_CONNS (UIP_CONF_UDP_CONNS)
230#else /* UIP_CONF_UDP_CONNS */
231#define UIP_UDP_CONNS 10
232#endif /* UIP_CONF_UDP_CONNS */
233
234/**
235 * The name of the function that should be called when UDP datagrams arrive.
236 *
237 * \hideinitializer
238 */
239
240
241/** @} */
242/*------------------------------------------------------------------------------*/
243/**
244 * \defgroup uipopttcp TCP configuration options
245 * @{
246 */
247
248/**
249 * Toggles whether TCP support should be compiled in or not.
250 *
251 * \hideinitializer
252 */
253#ifdef UIP_CONF_TCP
254#define UIP_TCP (UIP_CONF_TCP)
255#else /* UIP_CONF_TCP */
256#define UIP_TCP 1
257#endif /* UIP_CONF_TCP */
258
259/**
260 * Determines if support for opening connections from uIP should be
261 * compiled in.
262 *
263 * If the applications that are running on top of uIP for this project
264 * do not need to open outgoing TCP connections, this configuration
265 * option can be turned off to reduce the code size of uIP.
266 *
267 * \hideinitializer
268 */
269#ifndef UIP_CONF_ACTIVE_OPEN
270#define UIP_ACTIVE_OPEN 1
271#else /* UIP_CONF_ACTIVE_OPEN */
272#define UIP_ACTIVE_OPEN (UIP_CONF_ACTIVE_OPEN)
273#endif /* UIP_CONF_ACTIVE_OPEN */
274
275/**
276 * The maximum number of simultaneously open TCP connections.
277 *
278 * Since the TCP connections are statically allocated, turning this
279 * configuration knob down results in less RAM used. Each TCP
280 * connection requires approximately 30 bytes of memory.
281 *
282 * \hideinitializer
283 */
284#ifndef UIP_CONF_TCP_CONNS
285#define UIP_TCP_CONNS 10
286#else /* UIP_CONF_TCP_CONNS */
287#define UIP_TCP_CONNS (UIP_CONF_TCP_CONNS)
288#endif /* UIP_CONF_TCP_CONNS */
289
290
291/**
292 * The maximum number of simultaneously listening TCP ports.
293 *
294 * Each listening TCP port requires 2 bytes of memory.
295 *
296 * \hideinitializer
297 */
298#ifndef UIP_CONF_MAX_LISTENPORTS
299#define UIP_LISTENPORTS 20
300#else /* UIP_CONF_MAX_LISTENPORTS */
301#define UIP_LISTENPORTS (UIP_CONF_MAX_LISTENPORTS)
302#endif /* UIP_CONF_MAX_LISTENPORTS */
303
304/**
305 * Determines if support for TCP urgent data notification should be
306 * compiled in.
307 *
308 * Urgent data (out-of-band data) is a rarely used TCP feature that
309 * very seldom would be required.
310 *
311 * \hideinitializer
312 */
313#define UIP_URGDATA 0
314
315/**
316 * The initial retransmission timeout counted in timer pulses.
317 *
318 * This should not be changed.
319 */
320#define UIP_RTO 3
321
322/**
323 * The maximum number of times a segment should be retransmitted
324 * before the connection should be aborted.
325 *
326 * This should not be changed.
327 */
328#define UIP_MAXRTX 8
329
330/**
331 * The maximum number of times a SYN segment should be retransmitted
332 * before a connection request should be deemed to have been
333 * unsuccessful.
334 *
335 * This should not need to be changed.
336 */
337#define UIP_MAXSYNRTX 5
338
339/**
340 * The TCP maximum segment size.
341 *
342 * This is should not be to set to more than
343 * UIP_BUFSIZE - UIP_IPTCPH_LEN.
344 */
345#ifdef UIP_CONF_TCP_MSS
346#if UIP_CONF_TCP_MSS > (UIP_BUFSIZE - UIP_IPTCPH_LEN)
347#error UIP_CONF_TCP_MSS is too large for the current UIP_BUFSIZE
348#endif /* UIP_CONF_TCP_MSS > (UIP_BUFSIZE - UIP_IPTCPH_LEN) */
349#define UIP_TCP_MSS (UIP_CONF_TCP_MSS)
350#else /* UIP_CONF_TCP_MSS */
351#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_IPTCPH_LEN)
352#endif /* UIP_CONF_TCP_MSS */
353
354/**
355 * The size of the advertised receiver's window.
356 *
357 * Should be set low (i.e., to the size of the uip_buf buffer) if the
358 * application is slow to process incoming data, or high (32768 bytes)
359 * if the application processes data quickly.
360 *
361 * \hideinitializer
362 */
363#ifndef UIP_CONF_RECEIVE_WINDOW
364#define UIP_RECEIVE_WINDOW (UIP_TCP_MSS)
365#else
366#define UIP_RECEIVE_WINDOW (UIP_CONF_RECEIVE_WINDOW)
367#endif
368
369/**
370 * How long a connection should stay in the TIME_WAIT state.
371 *
372 * This can be reduced for faster entry into power saving modes.
373 */
374#ifndef UIP_CONF_WAIT_TIMEOUT
375#define UIP_TIME_WAIT_TIMEOUT 120
376#else
377#define UIP_TIME_WAIT_TIMEOUT UIP_CONF_WAIT_TIMEOUT
378#endif
379
380/** @} */
381/*------------------------------------------------------------------------------*/
382/**
383 * \defgroup uipoptarp ARP configuration options
384 * @{
385 */
386
387/**
388 * The size of the ARP table.
389 *
390 * This option should be set to a larger value if this uIP node will
391 * have many connections from the local network.
392 *
393 * \hideinitializer
394 */
395#ifdef UIP_CONF_ARPTAB_SIZE
396#define UIP_ARPTAB_SIZE (UIP_CONF_ARPTAB_SIZE)
397#else
398#define UIP_ARPTAB_SIZE 8
399#endif
400
401/**
402 * The maximum age of ARP table entries measured in 10ths of seconds.
403 *
404 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
405 * default).
406 */
407#define UIP_ARP_MAXAGE 120
408
409
410/** @} */
411
412/*------------------------------------------------------------------------------*/
413
414/**
415 * \defgroup uipoptmac layer 2 options (for ipv6)
416 * @{
417 */
418
419#define UIP_DEFAULT_PREFIX_LEN 64
420
421/**
422 * The MAC-layer transmissons limit is encapslated in "Traffic Class" field
423 *
424 * In Contiki, if the Traffic Class field in the IPv6 header has this bit set,
425 * the low-order bits are used as the MAC-layer transmissons limit.
426 */
427#define UIP_TC_MAC_TRANSMISSION_COUNTER_BIT 0x40
428
429/**
430 * The bits in the "Traffic Class" field that describe the MAC transmission limit
431 */
432#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
433
434#ifdef UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
435#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
436#else
437#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS 0
438#endif
439
440/**
441 * This is the default value of MAC-layer transmissons for uIPv6
442 *
443 * It means that the limit is selected by the MAC protocol instead of uIPv6.
444 */
445#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
446
447/** @} */
448
449/*------------------------------------------------------------------------------*/
450
451/**
452 * \defgroup uipoptsics 6lowpan options (for ipv6)
453 * @{
454 */
455/**
456 * Timeout for packet reassembly at the 6lowpan layer
457 * (should be < 60s)
458 */
459#ifdef SICSLOWPAN_CONF_MAXAGE
460#define SICSLOWPAN_REASS_MAXAGE (SICSLOWPAN_CONF_MAXAGE)
461#else
462#define SICSLOWPAN_REASS_MAXAGE 8
463#endif
464
465/**
466 * Do we compress the IP header or not
467 */
468#ifndef SICSLOWPAN_CONF_COMPRESSION
469#define SICSLOWPAN_COMPRESSION SICSLOWPAN_COMPRESSION_IPHC
470#else
471#define SICSLOWPAN_COMPRESSION SICSLOWPAN_CONF_COMPRESSION
472#endif /* SICSLOWPAN_CONF_COMPRESSION */
473
474/**
475 * If we use IPHC compression, how many address contexts do we support
476 */
477#ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
478#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
479#endif
480
481/**
482 * Do we support 6lowpan fragmentation
483 */
484#ifndef SICSLOWPAN_CONF_FRAG
485#define SICSLOWPAN_CONF_FRAG 1
486#endif
487
488/** @} */
489
490/*------------------------------------------------------------------------------*/
491/**
492 * \defgroup uipoptcpu CPU architecture configuration
493 * @{
494 *
495 * The CPU architecture configuration is where the endianess of the
496 * CPU on which uIP is to be run is specified. Most CPUs today are
497 * little endian, and the most notable exception are the Motorolas
498 * which are big endian. The BYTE_ORDER macro should be changed to
499 * reflect the CPU architecture on which uIP is to be run.
500 */
501
502/**
503 * The byte order of the CPU architecture on which uIP is to be run.
504 *
505 * This option can be either UIP_BIG_ENDIAN (Motorola byte order) or
506 * UIP_LITTLE_ENDIAN (Intel byte order).
507 *
508 * \hideinitializer
509 */
510#ifdef UIP_CONF_BYTE_ORDER
511#define UIP_BYTE_ORDER (UIP_CONF_BYTE_ORDER)
512#else /* UIP_CONF_BYTE_ORDER */
513#define UIP_BYTE_ORDER (UIP_LITTLE_ENDIAN)
514#endif /* UIP_CONF_BYTE_ORDER */
515
516/** @} */
517/*------------------------------------------------------------------------------*/
518
519/**
520 * \defgroup uipoptapp Application specific configurations
521 * @{
522 *
523 * An uIP application is implemented using a single application
524 * function that is called by uIP whenever a TCP/IP event occurs. The
525 * name of this function must be registered with uIP at compile time
526 * using the UIP_APPCALL definition.
527 *
528 * uIP applications can store the application state within the
529 * uip_conn structure by specifying the type of the application
530 * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
531 *
532 * The file containing the definitions must be included in the
533 * uipopt.h file.
534 *
535 * The following example illustrates how this can look.
536 \code
537
538 void httpd_appcall(void);
539 #define UIP_APPCALL httpd_appcall
540
541 struct httpd_state {
542 uint8_t state;
543 uint16_t count;
544 char *dataptr;
545 char *script;
546 };
547 typedef struct httpd_state uip_tcp_appstate_t
548 \endcode
549*/
550
551/**
552 * \var #define UIP_APPCALL
553 *
554 * The name of the application function that uIP should call in
555 * response to TCP/IP events.
556 *
557 */
558
559/**
560 * \var typedef uip_tcp_appstate_t
561 *
562 * The type of the application state that is to be stored in the
563 * uip_conn structure. This usually is typedef:ed to a struct holding
564 * application state information.
565 */
566
567/**
568 * \var typedef uip_udp_appstate_t
569 *
570 * The type of the application state that is to be stored in the
571 * uip_conn structure. This usually is typedef:ed to a struct holding
572 * application state information.
573 */
574/** @} */
575
576#endif /* UIPOPT_H_ */
577/** @} */
578/** @} */
void uip_log(char *msg)
Print out a uIP log message.
Definition platform.c:338