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