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