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