Contiki-NG
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 uipoptstaticconf Static configuration options
80  * @{
81  *
82  * These configuration options can be used for setting the IP address
83  * settings statically, but only if UIP_FIXEDADDR is set to 1. The
84  * configuration options for a specific node includes IP address,
85  * netmask and default router as well as the Ethernet address. The
86  * netmask, default router and Ethernet address are applicable only
87  * if uIP should be run over Ethernet.
88  *
89  * This options are meaningful only for the IPv4 code.
90  *
91  * All of these should be changed to suit your project.
92  */
93 
94 /**
95  * Determines if uIP should use a fixed IP address or not.
96  *
97  * If uIP should use a fixed IP address, the settings are set in the
98  * uipopt.h file. If not, the macros uip_sethostaddr(),
99  * uip_setdraddr() and uip_setnetmask() should be used instead.
100  *
101  * \hideinitializer
102  */
103 #define UIP_FIXEDADDR 0
104 
105 /**
106  * Specifies if the uIP ARP module should be compiled with a fixed
107  * Ethernet MAC address or not.
108  *
109  * If this configuration option is 0, the macro uip_setethaddr() can
110  * be used to specify the Ethernet address at run-time.
111  *
112  * \hideinitializer
113  */
114 #define UIP_FIXEDETHADDR 0
115 
116 /** @} */
117 /*------------------------------------------------------------------------------*/
118 
119 /**
120  * \defgroup uipoptgeneral General configuration options
121  * @{
122  */
123 
124 /**
125  * The link level header length.
126  *
127  * This is the offset into the uip_buf where the IP header can be
128  * found. For Ethernet, this should be set to 14. For SLIP, this
129  * should be set to 0.
130  *
131  * \note we probably won't use this constant for other link layers than
132  * ethernet as they have variable header length (this is due to variable
133  * number and type of address fields and to optional security features)
134  * E.g.: 802.15.4 -> 2 + (1/2*4/8) + 0/5/6/10/14
135  * 802.11 -> 4 + (6*3/4) + 2
136  * \hideinitializer
137  */
138 #ifdef UIP_CONF_LLH_LEN
139 #define UIP_LLH_LEN (UIP_CONF_LLH_LEN)
140 #else /* UIP_LLH_LEN */
141 #define UIP_LLH_LEN 0
142 #endif /* UIP_CONF_LLH_LEN */
143 
144 /**
145  * The size of the uIP packet buffer.
146  *
147  * The uIP packet buffer should not be smaller than 60 bytes, and does
148  * not need to be larger than 1514 bytes. Lower size results in lower
149  * TCP throughput, larger size results in higher TCP throughput.
150  *
151  * \hideinitializer
152  */
153 #ifndef UIP_CONF_BUFFER_SIZE
154 #define UIP_BUFSIZE (UIP_LINK_MTU + UIP_LLH_LEN)
155 #else /* UIP_CONF_BUFFER_SIZE */
156 #define UIP_BUFSIZE (UIP_CONF_BUFFER_SIZE)
157 #endif /* UIP_CONF_BUFFER_SIZE */
158 
159 
160 /**
161  * Determines if statistics support should be compiled in.
162  *
163  * The statistics is useful for debugging and to show the user.
164  *
165  * \hideinitializer
166  */
167 #ifndef UIP_CONF_STATISTICS
168 #define UIP_STATISTICS 0
169 #else /* UIP_CONF_STATISTICS */
170 #define UIP_STATISTICS (UIP_CONF_STATISTICS)
171 #endif /* UIP_CONF_STATISTICS */
172 
173 /**
174  * Broadcast support.
175  *
176  * This flag configures IP broadcast support. This is useful only
177  * together with UDP.
178  *
179  * \hideinitializer
180  *
181  */
182 #ifndef UIP_CONF_BROADCAST
183 #define UIP_BROADCAST 1
184 #else /* UIP_CONF_BROADCAST */
185 #define UIP_BROADCAST (UIP_CONF_BROADCAST)
186 #endif /* UIP_CONF_BROADCAST */
187 
188 /**
189  * Print out a uIP log message.
190  *
191  * This function must be implemented by the module that uses uIP, and
192  * is called by uIP whenever a log message is generated.
193  */
194 void uip_log(char *msg);
195 
196 /** @} */
197 /*------------------------------------------------------------------------------*/
198 /**
199  * \defgroup uipoptip IP configuration options
200  * @{
201  *
202  */
203 /**
204  * The IP TTL (time to live) of IP packets sent by uIP.
205  *
206  * This should normally not be changed.
207  */
208 #ifdef UIP_CONF_TTL
209 #define UIP_TTL UIP_CONF_TTL
210 #else /* UIP_CONF_TTL */
211 #define UIP_TTL 64
212 #endif /* UIP_CONF_TTL */
213 
214 /**
215  * The maximum time an IP fragment should wait in the reassembly
216  * buffer before it is dropped.
217  *
218  */
219 #define UIP_REASS_MAXAGE 60 /*60s*/
220 
221 /**
222  * Turn on support for IP packet reassembly.
223  *
224  * uIP supports reassembly of fragmented IP packets. This features
225  * requires an additional amount of RAM to hold the reassembly buffer
226  * and the reassembly code size is approximately 700 bytes. The
227  * reassembly buffer is of the same size as the uip_buf buffer
228  * (configured by UIP_BUFSIZE).
229  *
230  * \note IP packet reassembly is not heavily tested.
231  *
232  * \hideinitializer
233  */
234 #ifdef UIP_CONF_REASSEMBLY
235 #define UIP_REASSEMBLY (UIP_CONF_REASSEMBLY)
236 #else /* UIP_CONF_REASSEMBLY */
237 #define UIP_REASSEMBLY 0
238 #endif /* UIP_CONF_REASSEMBLY */
239 /** @} */
240 
241 /*------------------------------------------------------------------------------*/
242 /**
243  * \defgroup uipoptipv6 IPv6 configuration options
244  * @{
245  *
246  */
247 
248 /** The maximum transmission unit at the IP Layer*/
249 #define UIP_LINK_MTU 1280
250 
251 #ifndef NETSTACK_CONF_WITH_IPV6
252 /** Do we use IPv6 or not (default: no) */
253 #define NETSTACK_CONF_WITH_IPV6 0
254 #endif
255 
256 #ifndef UIP_CONF_IPV6_QUEUE_PKT
257 /** Do we do per %neighbor queuing during address resolution (default: no) */
258 #define UIP_CONF_IPV6_QUEUE_PKT 0
259 #endif
260 
261 #ifndef UIP_CONF_IPV6_CHECKS
262 /** Do we do IPv6 consistency checks (highly recommended, default: yes) */
263 #define UIP_CONF_IPV6_CHECKS 1
264 #endif
265 
266 #ifndef UIP_CONF_IPV6_REASSEMBLY
267 /** Do we do IPv6 fragmentation (default: no) */
268 #define UIP_CONF_IPV6_REASSEMBLY 0
269 #endif
270 
271 #ifndef UIP_CONF_NETIF_MAX_ADDRESSES
272 /** Default number of IPv6 addresses associated to the node's interface */
273 #define UIP_CONF_NETIF_MAX_ADDRESSES 3
274 #endif
275 
276 #ifndef UIP_CONF_DS6_PREFIX_NBU
277 /** Default number of IPv6 prefixes associated to the node's interface */
278 #define UIP_CONF_DS6_PREFIX_NBU 2
279 #endif
280 
281 #ifndef UIP_CONF_DS6_DEFRT_NBU
282 /** Minimum number of default routers */
283 #define UIP_CONF_DS6_DEFRT_NBU 2
284 #endif
285 /** @} */
286 
287 /*------------------------------------------------------------------------------*/
288 /**
289  * \defgroup uipoptudp UDP configuration options
290  * @{
291  *
292  * \note The UDP support in uIP is still not entirely complete; there
293  * is no support for sending or receiving broadcast or multicast
294  * packets, but it works well enough to support a number of vital
295  * applications such as DNS queries, though
296  */
297 
298 /**
299  * Toggles whether UDP support should be compiled in or not.
300  *
301  * \hideinitializer
302  */
303 #ifdef UIP_CONF_UDP
304 #define UIP_UDP UIP_CONF_UDP
305 #else /* UIP_CONF_UDP */
306 #define UIP_UDP 1
307 #endif /* UIP_CONF_UDP */
308 
309 /**
310  * Toggles if UDP checksums should be used or not.
311  *
312  * \note Support for UDP checksums is currently not included in uIP,
313  * so this option has no function.
314  *
315  * \hideinitializer
316  */
317 #ifdef UIP_CONF_UDP_CHECKSUMS
318 #define UIP_UDP_CHECKSUMS (UIP_CONF_UDP_CHECKSUMS)
319 #else
320 #define UIP_UDP_CHECKSUMS 1
321 #endif
322 
323 /**
324  * The maximum amount of concurrent UDP connections.
325  *
326  * \hideinitializer
327  */
328 #ifdef UIP_CONF_UDP_CONNS
329 #define UIP_UDP_CONNS (UIP_CONF_UDP_CONNS)
330 #else /* UIP_CONF_UDP_CONNS */
331 #define UIP_UDP_CONNS 10
332 #endif /* UIP_CONF_UDP_CONNS */
333 
334 /**
335  * The name of the function that should be called when UDP datagrams arrive.
336  *
337  * \hideinitializer
338  */
339 
340 
341 /** @} */
342 /*------------------------------------------------------------------------------*/
343 /**
344  * \defgroup uipopttcp TCP configuration options
345  * @{
346  */
347 
348 /**
349  * Toggles whether TCP support should be compiled in or not.
350  *
351  * \hideinitializer
352  */
353 #ifdef UIP_CONF_TCP
354 #define UIP_TCP (UIP_CONF_TCP)
355 #else /* UIP_CONF_TCP */
356 #define UIP_TCP 1
357 #endif /* UIP_CONF_TCP */
358 
359 /**
360  * Determines if support for opening connections from uIP should be
361  * compiled in.
362  *
363  * If the applications that are running on top of uIP for this project
364  * do not need to open outgoing TCP connections, this configuration
365  * option can be turned off to reduce the code size of uIP.
366  *
367  * \hideinitializer
368  */
369 #ifndef UIP_CONF_ACTIVE_OPEN
370 #define UIP_ACTIVE_OPEN 1
371 #else /* UIP_CONF_ACTIVE_OPEN */
372 #define UIP_ACTIVE_OPEN (UIP_CONF_ACTIVE_OPEN)
373 #endif /* UIP_CONF_ACTIVE_OPEN */
374 
375 /**
376  * The maximum number of simultaneously open TCP connections.
377  *
378  * Since the TCP connections are statically allocated, turning this
379  * configuration knob down results in less RAM used. Each TCP
380  * connection requires approximately 30 bytes of memory.
381  *
382  * \hideinitializer
383  */
384 #ifndef UIP_CONF_TCP_CONNS
385 #define UIP_TCP_CONNS 10
386 #else /* UIP_CONF_TCP_CONNS */
387 #define UIP_TCP_CONNS (UIP_CONF_TCP_CONNS)
388 #endif /* UIP_CONF_TCP_CONNS */
389 
390 
391 /**
392  * The maximum number of simultaneously listening TCP ports.
393  *
394  * Each listening TCP port requires 2 bytes of memory.
395  *
396  * \hideinitializer
397  */
398 #ifndef UIP_CONF_MAX_LISTENPORTS
399 #define UIP_LISTENPORTS 20
400 #else /* UIP_CONF_MAX_LISTENPORTS */
401 #define UIP_LISTENPORTS (UIP_CONF_MAX_LISTENPORTS)
402 #endif /* UIP_CONF_MAX_LISTENPORTS */
403 
404 /**
405  * Determines if support for TCP urgent data notification should be
406  * compiled in.
407  *
408  * Urgent data (out-of-band data) is a rarely used TCP feature that
409  * very seldom would be required.
410  *
411  * \hideinitializer
412  */
413 #define UIP_URGDATA 0
414 
415 /**
416  * The initial retransmission timeout counted in timer pulses.
417  *
418  * This should not be changed.
419  */
420 #define UIP_RTO 3
421 
422 /**
423  * The maximum number of times a segment should be retransmitted
424  * before the connection should be aborted.
425  *
426  * This should not be changed.
427  */
428 #define UIP_MAXRTX 8
429 
430 /**
431  * The maximum number of times a SYN segment should be retransmitted
432  * before a connection request should be deemed to have been
433  * unsuccessful.
434  *
435  * This should not need to be changed.
436  */
437 #define UIP_MAXSYNRTX 5
438 
439 /**
440  * The TCP maximum segment size.
441  *
442  * This is should not be to set to more than
443  * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
444  */
445 #ifdef UIP_CONF_TCP_MSS
446 #if UIP_CONF_TCP_MSS > (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
447 #error UIP_CONF_TCP_MSS is too large for the current UIP_BUFSIZE
448 #endif /* UIP_CONF_TCP_MSS > (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) */
449 #define UIP_TCP_MSS (UIP_CONF_TCP_MSS)
450 #else /* UIP_CONF_TCP_MSS */
451 #define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
452 #endif /* UIP_CONF_TCP_MSS */
453 
454 /**
455  * The size of the advertised receiver's window.
456  *
457  * Should be set low (i.e., to the size of the uip_buf buffer) if the
458  * application is slow to process incoming data, or high (32768 bytes)
459  * if the application processes data quickly.
460  *
461  * \hideinitializer
462  */
463 #ifndef UIP_CONF_RECEIVE_WINDOW
464 #define UIP_RECEIVE_WINDOW (UIP_TCP_MSS)
465 #else
466 #define UIP_RECEIVE_WINDOW (UIP_CONF_RECEIVE_WINDOW)
467 #endif
468 
469 /**
470  * How long a connection should stay in the TIME_WAIT state.
471  *
472  * This can be reduced for faster entry into power saving modes.
473  */
474 #ifndef UIP_CONF_WAIT_TIMEOUT
475 #define UIP_TIME_WAIT_TIMEOUT 120
476 #else
477 #define UIP_TIME_WAIT_TIMEOUT UIP_CONF_WAIT_TIMEOUT
478 #endif
479 
480 /** @} */
481 /*------------------------------------------------------------------------------*/
482 /**
483  * \defgroup uipoptarp ARP configuration options
484  * @{
485  */
486 
487 /**
488  * The size of the ARP table.
489  *
490  * This option should be set to a larger value if this uIP node will
491  * have many connections from the local network.
492  *
493  * \hideinitializer
494  */
495 #ifdef UIP_CONF_ARPTAB_SIZE
496 #define UIP_ARPTAB_SIZE (UIP_CONF_ARPTAB_SIZE)
497 #else
498 #define UIP_ARPTAB_SIZE 8
499 #endif
500 
501 /**
502  * The maximum age of ARP table entries measured in 10ths of seconds.
503  *
504  * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
505  * default).
506  */
507 #define UIP_ARP_MAXAGE 120
508 
509 
510 /** @} */
511 
512 /*------------------------------------------------------------------------------*/
513 
514 /**
515  * \defgroup uipoptmac layer 2 options (for ipv6)
516  * @{
517  */
518 
519 #define UIP_DEFAULT_PREFIX_LEN 64
520 
521 /**
522  * The MAC-layer transmissons limit is encapslated in "Traffic Class" field
523  *
524  * In Contiki, if the Traffic Class field in the IPv6 header has this bit set,
525  * the low-order bits are used as the MAC-layer transmissons limit.
526  */
527 #define UIP_TC_MAC_TRANSMISSION_COUNTER_BIT 0x40
528 
529 /**
530  * The bits in the "Traffic Class" field that describe the MAC transmission limit
531  */
532 #define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
533 
534 #ifdef UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
535 #define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
536 #else
537 #define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS 0
538 #endif
539 
540 /**
541  * This is the default value of MAC-layer transmissons for uIPv6
542  *
543  * It means that the limit is selected by the MAC protocol instead of uIPv6.
544  */
545 #define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
546 
547 /** @} */
548 
549 /*------------------------------------------------------------------------------*/
550 
551 /**
552  * \defgroup uipoptsics 6lowpan options (for ipv6)
553  * @{
554  */
555 /**
556  * Timeout for packet reassembly at the 6lowpan layer
557  * (should be < 60s)
558  */
559 #ifdef SICSLOWPAN_CONF_MAXAGE
560 #define SICSLOWPAN_REASS_MAXAGE (SICSLOWPAN_CONF_MAXAGE)
561 #else
562 #define SICSLOWPAN_REASS_MAXAGE 8
563 #endif
564 
565 /**
566  * Do we compress the IP header or not
567  */
568 #ifndef SICSLOWPAN_CONF_COMPRESSION
569 #define SICSLOWPAN_COMPRESSION SICSLOWPAN_COMPRESSION_IPHC
570 #else
571 #define SICSLOWPAN_COMPRESSION SICSLOWPAN_CONF_COMPRESSION
572 #endif /* SICSLOWPAN_CONF_COMPRESSION */
573 
574 /**
575  * If we use IPHC compression, how many address contexts do we support
576  */
577 #ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
578 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
579 #endif
580 
581 /**
582  * Do we support 6lowpan fragmentation
583  */
584 #ifndef SICSLOWPAN_CONF_FRAG
585 #define SICSLOWPAN_CONF_FRAG 1
586 #endif
587 
588 /** @} */
589 
590 /*------------------------------------------------------------------------------*/
591 /**
592  * \defgroup uipoptcpu CPU architecture configuration
593  * @{
594  *
595  * The CPU architecture configuration is where the endianess of the
596  * CPU on which uIP is to be run is specified. Most CPUs today are
597  * little endian, and the most notable exception are the Motorolas
598  * which are big endian. The BYTE_ORDER macro should be changed to
599  * reflect the CPU architecture on which uIP is to be run.
600  */
601 
602 /**
603  * The byte order of the CPU architecture on which uIP is to be run.
604  *
605  * This option can be either UIP_BIG_ENDIAN (Motorola byte order) or
606  * UIP_LITTLE_ENDIAN (Intel byte order).
607  *
608  * \hideinitializer
609  */
610 #ifdef UIP_CONF_BYTE_ORDER
611 #define UIP_BYTE_ORDER (UIP_CONF_BYTE_ORDER)
612 #else /* UIP_CONF_BYTE_ORDER */
613 #define UIP_BYTE_ORDER (UIP_LITTLE_ENDIAN)
614 #endif /* UIP_CONF_BYTE_ORDER */
615 
616 /** @} */
617 /*------------------------------------------------------------------------------*/
618 
619 /**
620  * \defgroup uipoptapp Application specific configurations
621  * @{
622  *
623  * An uIP application is implemented using a single application
624  * function that is called by uIP whenever a TCP/IP event occurs. The
625  * name of this function must be registered with uIP at compile time
626  * using the UIP_APPCALL definition.
627  *
628  * uIP applications can store the application state within the
629  * uip_conn structure by specifying the type of the application
630  * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
631  *
632  * The file containing the definitions must be included in the
633  * uipopt.h file.
634  *
635  * The following example illustrates how this can look.
636  \code
637 
638  void httpd_appcall(void);
639  #define UIP_APPCALL httpd_appcall
640 
641  struct httpd_state {
642  uint8_t state;
643  uint16_t count;
644  char *dataptr;
645  char *script;
646  };
647  typedef struct httpd_state uip_tcp_appstate_t
648  \endcode
649 */
650 
651 /**
652  * \var #define UIP_APPCALL
653  *
654  * The name of the application function that uIP should call in
655  * response to TCP/IP events.
656  *
657  */
658 
659 /**
660  * \var typedef uip_tcp_appstate_t
661  *
662  * The type of the application state that is to be stored in the
663  * uip_conn structure. This usually is typedef:ed to a struct holding
664  * application state information.
665  */
666 
667 /**
668  * \var typedef uip_udp_appstate_t
669  *
670  * The type of the application state that is to be stored in the
671  * uip_conn structure. This usually is typedef:ed to a struct holding
672  * application state information.
673  */
674 /** @} */
675 
676 #endif /* UIPOPT_H_ */
677 /** @} */
678 /** @} */
void uip_log(char *msg)
Print out a uIP log message.
Definition: platform.c:333