23bce28a313c2e8c1cbf479594ea18c9b270f58b
7 * \defgroup uipopt Configuration options for uIP
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.
19 * Configuration options for uIP.
20 * \author Adam Dunkels <adam@dunkels.com>
22 * This file is used for tweaking various configuration options for
23 * uIP. You should make a copy of this file into one of your project's
24 * directories instead of editing this example "uipopt.h" file that
25 * comes with the uIP distribution.
29 * Copyright (c) 2001-2003, Adam Dunkels.
30 * All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. The name of the author may not be used to endorse or promote
41 * products derived from this software without specific prior
44 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
45 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
46 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
48 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
50 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
52 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
53 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
54 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 * This file is part of the uIP TCP/IP stack.
58 * $Id: uipopt.h,v 1.11 2009/04/10 00:37:48 adamdunkels Exp $
65 #ifndef UIP_LITTLE_ENDIAN
66 #define UIP_LITTLE_ENDIAN 3412
67 #endif /* UIP_LITTLE_ENDIAN */
68 #ifndef UIP_BIG_ENDIAN
69 #define UIP_BIG_ENDIAN 1234
70 #endif /* UIP_BIG_ENDIAN */
72 /*------------------------------------------------------------------------------*/
75 * \defgroup uipoptstaticconf Static configuration options
78 * These configuration options can be used for setting the IP address
79 * settings statically, but only if UIP_FIXEDADDR is set to 1. The
80 * configuration options for a specific node includes IP address,
81 * netmask and default router as well as the Ethernet address. The
82 * netmask, default router and Ethernet address are applicable only
83 * if uIP should be run over Ethernet.
85 * This options are meaningful only for the IPv4 code.
87 * All of these should be changed to suit your project.
91 * Determines if uIP should use a fixed IP address or not.
93 * If uIP should use a fixed IP address, the settings are set in the
94 * uipopt.h file. If not, the macros uip_sethostaddr(),
95 * uip_setdraddr() and uip_setnetmask() should be used instead.
99 #define UIP_FIXEDADDR 0
102 * Ping IP address assignment.
104 * uIP uses a "ping" packets for setting its own IP address if this
105 * option is set. If so, uIP will start with an empty IP address and
106 * the destination IP address of the first incoming "ping" (ICMP echo)
107 * packet will be used for setting the hosts IP address.
109 * \note This works only if UIP_FIXEDADDR is 0.
113 #ifdef UIP_CONF_PINGADDRCONF
114 #define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
115 #else /* UIP_CONF_PINGADDRCONF */
116 #define UIP_PINGADDRCONF 0
117 #endif /* UIP_CONF_PINGADDRCONF */
121 * Specifies if the uIP ARP module should be compiled with a fixed
122 * Ethernet MAC address or not.
124 * If this configuration option is 0, the macro uip_setethaddr() can
125 * be used to specify the Ethernet address at run-time.
129 #define UIP_FIXEDETHADDR 0
132 /*------------------------------------------------------------------------------*/
134 * \defgroup uipoptip IP configuration options
139 * The IP TTL (time to live) of IP packets sent by uIP.
141 * This should normally not be changed.
146 * The maximum time an IP fragment should wait in the reassembly
147 * buffer before it is dropped.
150 #define UIP_REASS_MAXAGE 60 /*60s*/
153 * Turn on support for IP packet reassembly.
155 * uIP supports reassembly of fragmented IP packets. This features
156 * requires an additional amount of RAM to hold the reassembly buffer
157 * and the reassembly code size is approximately 700 bytes. The
158 * reassembly buffer is of the same size as the uip_buf buffer
159 * (configured by UIP_BUFSIZE).
161 * \note IP packet reassembly is not heavily tested.
165 #ifdef UIP_CONF_REASSEMBLY
166 #define UIP_REASSEMBLY UIP_CONF_REASSEMBLY
167 #else /* UIP_CONF_REASSEMBLY */
168 #define UIP_REASSEMBLY 0
169 #endif /* UIP_CONF_REASSEMBLY */
172 /*------------------------------------------------------------------------------*/
174 * \defgroup uipoptipv6 IPv6 configuration options
179 /** The maximum transmission unit at the IP Layer*/
180 #define UIP_LINK_MTU 1280
182 #ifndef UIP_CONF_IPV6
183 /** Do we use IPv6 or not (default: no) */
184 #define UIP_CONF_IPV6 0
187 #ifndef UIP_CONF_IPV6_QUEUE_PKT
188 /** Do we do per %neighbor queuing during address resolution (default: no) */
189 #define UIP_CONF_IPV6_QUEUE_PKT 0
192 #ifndef UIP_CONF_IPV6_CHECKS
193 /** Do we do IPv6 consistency checks (highly recommended, default: yes) */
194 #define UIP_CONF_IPV6_CHECKS 1
197 #ifndef UIP_CONF_IPV6_REASSEMBLY
198 /** Do we do IPv6 fragmentation (default: no) */
199 #define UIP_CONF_IPV6_REASSEMBLY 0
202 #ifndef UIP_CONF_NETIF_MAX_ADDRESSES
203 /** Default number of IPv6 addresses associated to the node's interface */
204 #define UIP_CONF_NETIF_MAX_ADDRESSES 3
207 #ifndef UIP_CONF_ND6_MAX_PREFIXES
208 /** Default number of IPv6 prefixes associated to the node's interface */
209 #define UIP_CONF_ND6_MAX_PREFIXES 3
212 #ifndef UIP_CONF_ND6_MAX_NEIGHBORS
213 /** Default number of neighbors that can be stored in the %neighbor cache */
214 #define UIP_CONF_ND6_MAX_NEIGHBORS 4
217 #ifndef UIP_CONF_ND6_MAX_DEFROUTERS
218 /** Minimum number of default routers */
219 #define UIP_CONF_ND6_MAX_DEFROUTERS 2
223 /*------------------------------------------------------------------------------*/
225 * \defgroup uipoptudp UDP configuration options
228 * \note The UDP support in uIP is still not entirely complete; there
229 * is no support for sending or receiving broadcast or multicast
230 * packets, but it works well enough to support a number of vital
231 * applications such as DNS queries, though
235 * Toggles whether UDP support should be compiled in or not.
240 #define UIP_UDP UIP_CONF_UDP
241 #else /* UIP_CONF_UDP */
243 #endif /* UIP_CONF_UDP */
246 * Toggles if UDP checksums should be used or not.
248 * \note Support for UDP checksums is currently not included in uIP,
249 * so this option has no function.
253 #ifdef UIP_CONF_UDP_CHECKSUMS
254 #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
256 #define UIP_UDP_CHECKSUMS 0
260 * The maximum amount of concurrent UDP connections.
264 #ifdef UIP_CONF_UDP_CONNS
265 #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
266 #else /* UIP_CONF_UDP_CONNS */
267 #define UIP_UDP_CONNS 10
268 #endif /* UIP_CONF_UDP_CONNS */
271 * The name of the function that should be called when UDP datagrams arrive.
278 /*------------------------------------------------------------------------------*/
280 * \defgroup uipopttcp TCP configuration options
285 * Toggles whether UDP support should be compiled in or not.
290 #define UIP_TCP UIP_CONF_TCP
291 #else /* UIP_CONF_UDP */
293 #endif /* UIP_CONF_UDP */
296 * Determines if support for opening connections from uIP should be
299 * If the applications that are running on top of uIP for this project
300 * do not need to open outgoing TCP connections, this configuration
301 * option can be turned off to reduce the code size of uIP.
305 #ifndef UIP_CONF_ACTIVE_OPEN
306 #define UIP_ACTIVE_OPEN 1
307 #else /* UIP_CONF_ACTIVE_OPEN */
308 #define UIP_ACTIVE_OPEN UIP_CONF_ACTIVE_OPEN
309 #endif /* UIP_CONF_ACTIVE_OPEN */
312 * The maximum number of simultaneously open TCP connections.
314 * Since the TCP connections are statically allocated, turning this
315 * configuration knob down results in less RAM used. Each TCP
316 * connection requires approximately 30 bytes of memory.
320 #ifndef UIP_CONF_MAX_CONNECTIONS
322 #else /* UIP_CONF_MAX_CONNECTIONS */
323 #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
324 #endif /* UIP_CONF_MAX_CONNECTIONS */
328 * The maximum number of simultaneously listening TCP ports.
330 * Each listening TCP port requires 2 bytes of memory.
334 #ifndef UIP_CONF_MAX_LISTENPORTS
335 #define UIP_LISTENPORTS 20
336 #else /* UIP_CONF_MAX_LISTENPORTS */
337 #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
338 #endif /* UIP_CONF_MAX_LISTENPORTS */
341 * Determines if support for TCP urgent data notification should be
344 * Urgent data (out-of-band data) is a rarely used TCP feature that
345 * very seldom would be required.
349 #define UIP_URGDATA 0
352 * The initial retransmission timeout counted in timer pulses.
354 * This should not be changed.
359 * The maximum number of times a segment should be retransmitted
360 * before the connection should be aborted.
362 * This should not be changed.
367 * The maximum number of times a SYN segment should be retransmitted
368 * before a connection request should be deemed to have been
371 * This should not need to be changed.
373 #define UIP_MAXSYNRTX 5
376 * The TCP maximum segment size.
378 * This is should not be to set to more than
379 * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
381 #ifdef UIP_CONF_TCP_MSS
382 #define UIP_TCP_MSS UIP_CONF_TCP_MSS
384 #define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
388 * The size of the advertised receiver's window.
390 * Should be set low (i.e., to the size of the uip_buf buffer) if the
391 * application is slow to process incoming data, or high (32768 bytes)
392 * if the application processes data quickly.
396 #ifndef UIP_CONF_RECEIVE_WINDOW
397 #define UIP_RECEIVE_WINDOW UIP_TCP_MSS
399 #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
403 * How long a connection should stay in the TIME_WAIT state.
405 * This configuration option has no real implication, and it should be
408 #define UIP_TIME_WAIT_TIMEOUT 120
412 /*------------------------------------------------------------------------------*/
414 * \defgroup uipoptarp ARP configuration options
419 * The size of the ARP table.
421 * This option should be set to a larger value if this uIP node will
422 * have many connections from the local network.
426 #ifdef UIP_CONF_ARPTAB_SIZE
427 #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
429 #define UIP_ARPTAB_SIZE 8
433 * The maximum age of ARP table entries measured in 10ths of seconds.
435 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
438 #define UIP_ARP_MAXAGE 120
443 /*------------------------------------------------------------------------------*/
446 * \defgroup uipoptmac layer 2 options (for ipv6)
450 #define UIP_DEFAULT_PREFIX_LEN 64
454 /*------------------------------------------------------------------------------*/
457 * \defgroup uipoptsics 6lowpan options (for ipv6)
461 * Timeout for packet reassembly at the 6lowpan layer
464 #ifdef SICSLOWPAN_CONF_MAXAGE
465 #define SICSLOWPAN_REASS_MAXAGE SICSLOWPAN_CONF_MAXAGE
467 #define SICSLOWPAN_REASS_MAXAGE 20
471 * Do we compress the IP header or not (default: no)
473 #ifndef SICSLOWPAN_CONF_COMPRESSION
474 #define SICSLOWPAN_CONF_COMPRESSION 0
478 * If we use IPHC compression, how many address contexts do we support
480 #ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
481 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
485 * Do we support 6lowpan fragmentation
487 #ifndef SICSLOWPAN_CONF_FRAG
488 #define SICSLOWPAN_CONF_FRAG 0
493 /*------------------------------------------------------------------------------*/
496 * \defgroup uipoptgeneral General configuration options
501 * The size of the uIP packet buffer.
503 * The uIP packet buffer should not be smaller than 60 bytes, and does
504 * not need to be larger than 1514 bytes. Lower size results in lower
505 * TCP throughput, larger size results in higher TCP throughput.
509 #ifndef UIP_CONF_BUFFER_SIZE
510 #define UIP_BUFSIZE UIP_LINK_MTU + UIP_LLH_LEN
511 #else /* UIP_CONF_BUFFER_SIZE */
512 #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
513 #endif /* UIP_CONF_BUFFER_SIZE */
517 * Determines if statistics support should be compiled in.
519 * The statistics is useful for debugging and to show the user.
523 #ifndef UIP_CONF_STATISTICS
524 #define UIP_STATISTICS 0
525 #else /* UIP_CONF_STATISTICS */
526 #define UIP_STATISTICS UIP_CONF_STATISTICS
527 #endif /* UIP_CONF_STATISTICS */
530 * Determines if logging of certain events should be compiled in.
532 * This is useful mostly for debugging. The function uip_log()
533 * must be implemented to suit the architecture of the project, if
534 * logging is turned on.
538 #ifndef UIP_CONF_LOGGING
539 #define UIP_LOGGING 0
540 #else /* UIP_CONF_LOGGING */
541 #define UIP_LOGGING UIP_CONF_LOGGING
542 #endif /* UIP_CONF_LOGGING */
547 * This flag configures IP broadcast support. This is useful only
553 #ifndef UIP_CONF_BROADCAST
554 #define UIP_BROADCAST 0
555 #else /* UIP_CONF_BROADCAST */
556 #define UIP_BROADCAST UIP_CONF_BROADCAST
557 #endif /* UIP_CONF_BROADCAST */
560 * Print out a uIP log message.
562 * This function must be implemented by the module that uses uIP, and
563 * is called by uIP whenever a log message is generated.
565 void uip_log(char *msg
);
568 * The link level header length.
570 * This is the offset into the uip_buf where the IP header can be
571 * found. For Ethernet, this should be set to 14. For SLIP, this
572 * should be set to 0.
574 * \note we probably won't use this constant for other link layers than
575 * ethernet as they have variable header length (this is due to variable
576 * number and type of address fields and to optional security features)
577 * E.g.: 802.15.4 -> 2 + (1/2*4/8) + 0/5/6/10/14
578 * 802.11 -> 4 + (6*3/4) + 2
581 #ifdef UIP_CONF_LLH_LEN
582 #define UIP_LLH_LEN UIP_CONF_LLH_LEN
583 #else /* UIP_LLH_LEN */
584 #define UIP_LLH_LEN 14
585 #endif /* UIP_CONF_LLH_LEN */
588 /*------------------------------------------------------------------------------*/
590 * \defgroup uipoptcpu CPU architecture configuration
593 * The CPU architecture configuration is where the endianess of the
594 * CPU on which uIP is to be run is specified. Most CPUs today are
595 * little endian, and the most notable exception are the Motorolas
596 * which are big endian. The BYTE_ORDER macro should be changed to
597 * reflect the CPU architecture on which uIP is to be run.
601 * The byte order of the CPU architecture on which uIP is to be run.
603 * This option can be either UIP_BIG_ENDIAN (Motorola byte order) or
604 * UIP_LITTLE_ENDIAN (Intel byte order).
608 #ifdef UIP_CONF_BYTE_ORDER
609 #define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER
610 #else /* UIP_CONF_BYTE_ORDER */
611 #define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN
612 #endif /* UIP_CONF_BYTE_ORDER */
615 /*------------------------------------------------------------------------------*/
621 typedef uint8_t u8_t
;
622 typedef uint16_t u16_t
;
623 typedef uint32_t u32_t
;
624 typedef uint32_t uip_stats_t
;
627 * \defgroup uipoptapp Application specific configurations
630 * An uIP application is implemented using a single application
631 * function that is called by uIP whenever a TCP/IP event occurs. The
632 * name of this function must be registered with uIP at compile time
633 * using the UIP_APPCALL definition.
635 * uIP applications can store the application state within the
636 * uip_conn structure by specifying the type of the application
637 * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
639 * The file containing the definitions must be included in the
642 * The following example illustrates how this can look.
645 void httpd_appcall(void);
646 #define UIP_APPCALL httpd_appcall
654 typedef struct httpd_state uip_tcp_appstate_t
657 #define UIP_UDP_APPCALL DHCPApp_Callback
658 void UIP_UDP_APPCALL(void);
661 * \var #define UIP_APPCALL
663 * The name of the application function that uIP should call in
664 * response to TCP/IP events.
667 #define UIP_APPCALL HTTPServerApp_Callback
668 void UIP_APPCALL(void);
671 * \var typedef uip_tcp_appstate_t
673 * The type of the application state that is to be stored in the
674 * uip_conn structure. This usually is typedef:ed to a struct holding
675 * application state information.
679 uint8_t CurrentState
;
685 uint32_t ACKedFilePos
;
686 uint16_t SentChunkSize
;
687 } uip_tcp_appstate_t
;
690 * \var typedef uip_udp_appstate_t
692 * The type of the application state that is to be stored in the
693 * uip_conn structure. This usually is typedef:ed to a struct holding
694 * application state information.
698 uint8_t CurrentState
;
699 struct uip_udp_conn
* Connection
;
703 uint8_t AllocatedIP
[4];
705 uint8_t GatewayIP
[4];
708 } uip_udp_appstate_t
;
711 #endif /* __UIPOPT_H__ */