00001 /** 00002 * \defgroup uipopt Configuration options for uIP 00003 * @{ 00004 * 00005 * uIP is configured using the per-project configuration file 00006 * "uipopt.h". This file contains all compile-time options for uIP and 00007 * should be tweaked to match each specific project. The uIP 00008 * distribution contains a documented example "uipopt.h" that can be 00009 * copied and modified for each project. 00010 * 00011 * \note Contiki does not use the uipopt.h file to configure uIP, but 00012 * uses a per-port uip-conf.h file that should be edited instead. 00013 */ 00014 00015 /** 00016 * \file 00017 * Configuration options for uIP. 00018 * \author Adam Dunkels <adam@dunkels.com> 00019 * 00020 * This file is used for tweaking various configuration options for 00021 * uIP. You should make a copy of this file into one of your project's 00022 * directories instead of editing this example "uipopt.h" file that 00023 * comes with the uIP distribution. 00024 */ 00025 00026 /* 00027 * Copyright (c) 2001-2003, Adam Dunkels. 00028 * All rights reserved. 00029 * 00030 * Redistribution and use in source and binary forms, with or without 00031 * modification, are permitted provided that the following conditions 00032 * are met: 00033 * 1. Redistributions of source code must retain the above copyright 00034 * notice, this list of conditions and the following disclaimer. 00035 * 2. Redistributions in binary form must reproduce the above copyright 00036 * notice, this list of conditions and the following disclaimer in the 00037 * documentation and/or other materials provided with the distribution. 00038 * 3. The name of the author may not be used to endorse or promote 00039 * products derived from this software without specific prior 00040 * written permission. 00041 * 00042 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00043 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00044 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00045 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00046 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00047 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00048 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00049 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00050 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00051 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00052 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00053 * 00054 * This file is part of the uIP TCP/IP stack. 00055 * 00056 * $Id: uipopt.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $ 00057 * 00058 */ 00059 00060 #ifndef __UIPOPT_H__ 00061 #define __UIPOPT_H__ 00062 00063 #ifndef UIP_LITTLE_ENDIAN 00064 #define UIP_LITTLE_ENDIAN 3412 00065 #endif /* UIP_LITTLE_ENDIAN */ 00066 #ifndef UIP_BIG_ENDIAN 00067 #define UIP_BIG_ENDIAN 1234 00068 #endif /* UIP_BIG_ENDIAN */ 00069 00070 #include "contiki-conf.h" 00071 00072 /*------------------------------------------------------------------------------*/ 00073 00074 /** 00075 * \defgroup uipoptstaticconf Static configuration options 00076 * @{ 00077 * 00078 * These configuration options can be used for setting the IP address 00079 * settings statically, but only if UIP_FIXEDADDR is set to 1. The 00080 * configuration options for a specific node includes IP address, 00081 * netmask and default router as well as the Ethernet address. The 00082 * netmask, default router and Ethernet address are appliciable only 00083 * if uIP should be run over Ethernet. 00084 * 00085 * All of these should be changed to suit your project. 00086 */ 00087 00088 /** 00089 * Determines if uIP should use a fixed IP address or not. 00090 * 00091 * If uIP should use a fixed IP address, the settings are set in the 00092 * uipopt.h file. If not, the macros uip_sethostaddr(), 00093 * uip_setdraddr() and uip_setnetmask() should be used instead. 00094 * 00095 * \hideinitializer 00096 */ 00097 #define UIP_FIXEDADDR 0 00098 00099 /** 00100 * Ping IP address asignment. 00101 * 00102 * uIP uses a "ping" packets for setting its own IP address if this 00103 * option is set. If so, uIP will start with an empty IP address and 00104 * the destination IP address of the first incoming "ping" (ICMP echo) 00105 * packet will be used for setting the hosts IP address. 00106 * 00107 * \note This works only if UIP_FIXEDADDR is 0. 00108 * 00109 * \hideinitializer 00110 */ 00111 #ifdef UIP_CONF_PINGADDRCONF 00112 #define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF 00113 #else /* UIP_CONF_PINGADDRCONF */ 00114 #define UIP_PINGADDRCONF 0 00115 #endif /* UIP_CONF_PINGADDRCONF */ 00116 00117 00118 /** 00119 * Specifies if the uIP ARP module should be compiled with a fixed 00120 * Ethernet MAC address or not. 00121 * 00122 * If this configuration option is 0, the macro uip_setethaddr() can 00123 * be used to specify the Ethernet address at run-time. 00124 * 00125 * \hideinitializer 00126 */ 00127 #define UIP_FIXEDETHADDR 0 00128 00129 /** @} */ 00130 /*------------------------------------------------------------------------------*/ 00131 /** 00132 * \defgroup uipoptip IP configuration options 00133 * @{ 00134 * 00135 */ 00136 /** 00137 * The IP TTL (time to live) of IP packets sent by uIP. 00138 * 00139 * This should normally not be changed. 00140 */ 00141 #define UIP_TTL 64 00142 00143 /** 00144 * Turn on support for IP packet reassembly. 00145 * 00146 * uIP supports reassembly of fragmented IP packets. This features 00147 * requires an additonal amount of RAM to hold the reassembly buffer 00148 * and the reassembly code size is approximately 700 bytes. The 00149 * reassembly buffer is of the same size as the uip_buf buffer 00150 * (configured by UIP_BUFSIZE). 00151 * 00152 * \note IP packet reassembly is not heavily tested. 00153 * 00154 * \hideinitializer 00155 */ 00156 #define UIP_REASSEMBLY 0 00157 00158 /** 00159 * The maximum time an IP fragment should wait in the reassembly 00160 * buffer before it is dropped. 00161 * 00162 */ 00163 #define UIP_REASS_MAXAGE 40 00164 00165 /** @} */ 00166 00167 /*------------------------------------------------------------------------------*/ 00168 /** 00169 * \defgroup uipoptudp UDP configuration options 00170 * @{ 00171 * 00172 * \note The UDP support in uIP is still not entirely complete; there 00173 * is no support for sending or receiving broadcast or multicast 00174 * packets, but it works well enough to support a number of vital 00175 * applications such as DNS queries, though 00176 */ 00177 00178 /** 00179 * Toggles wether UDP support should be compiled in or not. 00180 * 00181 * \hideinitializer 00182 */ 00183 #ifdef UIP_CONF_UDP 00184 #define UIP_UDP UIP_CONF_UDP 00185 #else /* UIP_CONF_UDP */ 00186 #define UIP_UDP 1 00187 #endif /* UIP_CONF_UDP */ 00188 00189 /** 00190 * Toggles if UDP checksums should be used or not. 00191 * 00192 * \note Support for UDP checksums is currently not included in uIP, 00193 * so this option has no function. 00194 * 00195 * \hideinitializer 00196 */ 00197 #ifdef UIP_CONF_UDP_CHECKSUMS 00198 #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS 00199 #else 00200 #define UIP_UDP_CHECKSUMS 0 00201 #endif 00202 00203 /** 00204 * The maximum amount of concurrent UDP connections. 00205 * 00206 * \hideinitializer 00207 */ 00208 #ifdef UIP_CONF_UDP_CONNS 00209 #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS 00210 #else /* UIP_CONF_UDP_CONNS */ 00211 #define UIP_UDP_CONNS 10 00212 #endif /* UIP_CONF_UDP_CONNS */ 00213 00214 /** 00215 * The name of the function that should be called when UDP datagrams arrive. 00216 * 00217 * \hideinitializer 00218 */ 00219 00220 00221 /** @} */ 00222 /*------------------------------------------------------------------------------*/ 00223 /** 00224 * \defgroup uipopttcp TCP configuration options 00225 * @{ 00226 */ 00227 00228 /** 00229 * Determines if support for opening connections from uIP should be 00230 * compiled in. 00231 * 00232 * If the applications that are running on top of uIP for this project 00233 * do not need to open outgoing TCP connections, this configration 00234 * option can be turned off to reduce the code size of uIP. 00235 * 00236 * \hideinitializer 00237 */ 00238 #define UIP_ACTIVE_OPEN 1 00239 00240 /** 00241 * The maximum number of simultaneously open TCP connections. 00242 * 00243 * Since the TCP connections are statically allocated, turning this 00244 * configuration knob down results in less RAM used. Each TCP 00245 * connection requires approximatly 30 bytes of memory. 00246 * 00247 * \hideinitializer 00248 */ 00249 #ifndef UIP_CONF_MAX_CONNECTIONS 00250 #define UIP_CONNS 10 00251 #else /* UIP_CONF_MAX_CONNECTIONS */ 00252 #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS 00253 #endif /* UIP_CONF_MAX_CONNECTIONS */ 00254 00255 00256 /** 00257 * The maximum number of simultaneously listening TCP ports. 00258 * 00259 * Each listening TCP port requires 2 bytes of memory. 00260 * 00261 * \hideinitializer 00262 */ 00263 #ifndef UIP_CONF_MAX_LISTENPORTS 00264 #define UIP_LISTENPORTS 20 00265 #else /* UIP_CONF_MAX_LISTENPORTS */ 00266 #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS 00267 #endif /* UIP_CONF_MAX_LISTENPORTS */ 00268 00269 /** 00270 * Determines if support for TCP urgent data notification should be 00271 * compiled in. 00272 * 00273 * Urgent data (out-of-band data) is a rarely used TCP feature that 00274 * very seldom would be required. 00275 * 00276 * \hideinitializer 00277 */ 00278 #define UIP_URGDATA 0 00279 00280 /** 00281 * The initial retransmission timeout counted in timer pulses. 00282 * 00283 * This should not be changed. 00284 */ 00285 #define UIP_RTO 3 00286 00287 /** 00288 * The maximum number of times a segment should be retransmitted 00289 * before the connection should be aborted. 00290 * 00291 * This should not be changed. 00292 */ 00293 #define UIP_MAXRTX 8 00294 00295 /** 00296 * The maximum number of times a SYN segment should be retransmitted 00297 * before a connection request should be deemed to have been 00298 * unsuccessful. 00299 * 00300 * This should not need to be changed. 00301 */ 00302 #define UIP_MAXSYNRTX 5 00303 00304 /** 00305 * The TCP maximum segment size. 00306 * 00307 * This is should not be to set to more than 00308 * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN. 00309 */ 00310 #define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) 00311 00312 /** 00313 * The size of the advertised receiver's window. 00314 * 00315 * Should be set low (i.e., to the size of the uip_buf buffer) is the 00316 * application is slow to process incoming data, or high (32768 bytes) 00317 * if the application processes data quickly. 00318 * 00319 * \hideinitializer 00320 */ 00321 #ifndef UIP_CONF_RECEIVE_WINDOW 00322 #define UIP_RECEIVE_WINDOW UIP_TCP_MSS 00323 #else 00324 #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW 00325 #endif 00326 00327 /** 00328 * How long a connection should stay in the TIME_WAIT state. 00329 * 00330 * This configiration option has no real implication, and it should be 00331 * left untouched. 00332 */ 00333 #define UIP_TIME_WAIT_TIMEOUT 120 00334 00335 00336 /** @} */ 00337 /*------------------------------------------------------------------------------*/ 00338 /** 00339 * \defgroup uipoptarp ARP configuration options 00340 * @{ 00341 */ 00342 00343 /** 00344 * The size of the ARP table. 00345 * 00346 * This option should be set to a larger value if this uIP node will 00347 * have many connections from the local network. 00348 * 00349 * \hideinitializer 00350 */ 00351 #ifdef UIP_CONF_ARPTAB_SIZE 00352 #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE 00353 #else 00354 #define UIP_ARPTAB_SIZE 8 00355 #endif 00356 00357 /** 00358 * The maxium age of ARP table entries measured in 10ths of seconds. 00359 * 00360 * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD 00361 * default). 00362 */ 00363 #define UIP_ARP_MAXAGE 120 00364 00365 /** @} */ 00366 00367 /*------------------------------------------------------------------------------*/ 00368 00369 /** 00370 * \defgroup uipoptgeneral General configuration options 00371 * @{ 00372 */ 00373 00374 /** 00375 * The size of the uIP packet buffer. 00376 * 00377 * The uIP packet buffer should not be smaller than 60 bytes, and does 00378 * not need to be larger than 1500 bytes. Lower size results in lower 00379 * TCP throughput, larger size results in higher TCP throughput. 00380 * 00381 * \hideinitializer 00382 */ 00383 #ifndef UIP_CONF_BUFFER_SIZE 00384 #define UIP_BUFSIZE 400 00385 #else /* UIP_CONF_BUFFER_SIZE */ 00386 #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE 00387 #endif /* UIP_CONF_BUFFER_SIZE */ 00388 00389 00390 /** 00391 * Determines if statistics support should be compiled in. 00392 * 00393 * The statistics is useful for debugging and to show the user. 00394 * 00395 * \hideinitializer 00396 */ 00397 #ifndef UIP_CONF_STATISTICS 00398 #define UIP_STATISTICS 0 00399 #else /* UIP_CONF_STATISTICS */ 00400 #define UIP_STATISTICS UIP_CONF_STATISTICS 00401 #endif /* UIP_CONF_STATISTICS */ 00402 00403 /** 00404 * Determines if logging of certain events should be compiled in. 00405 * 00406 * This is useful mostly for debugging. The function uip_log() 00407 * must be implemented to suit the architecture of the project, if 00408 * logging is turned on. 00409 * 00410 * \hideinitializer 00411 */ 00412 #ifndef UIP_CONF_LOGGING 00413 #define UIP_LOGGING 0 00414 #else /* UIP_CONF_LOGGING */ 00415 #define UIP_LOGGING UIP_CONF_LOGGING 00416 #endif /* UIP_CONF_LOGGING */ 00417 00418 /** 00419 * Broadcast support. 00420 * 00421 * This flag configures IP broadcast support. This is useful only 00422 * together with UDP. 00423 * 00424 * \hideinitializer 00425 * 00426 */ 00427 #ifndef UIP_CONF_BROADCAST 00428 #define UIP_BROADCAST 0 00429 #else /* UIP_CONF_BROADCAST */ 00430 #define UIP_BROADCAST UIP_CONF_BROADCAST 00431 #endif /* UIP_CONF_BROADCAST */ 00432 00433 /** 00434 * Print out a uIP log message. 00435 * 00436 * This function must be implemented by the module that uses uIP, and 00437 * is called by uIP whenever a log message is generated. 00438 */ 00439 void uip_log(char *msg); 00440 00441 /** 00442 * The link level header length. 00443 * 00444 * This is the offset into the uip_buf where the IP header can be 00445 * found. For Ethernet, this should be set to 14. For SLIP, this 00446 * should be set to 0. 00447 * 00448 * \hideinitializer 00449 */ 00450 #ifdef UIP_CONF_LLH_LEN 00451 #define UIP_LLH_LEN UIP_CONF_LLH_LEN 00452 #else /* UIP_CONF_LLH_LEN */ 00453 #define UIP_LLH_LEN 14 00454 #endif /* UIP_CONF_LLH_LEN */ 00455 00456 /** @} */ 00457 /*------------------------------------------------------------------------------*/ 00458 /** 00459 * \defgroup uipoptcpu CPU architecture configuration 00460 * @{ 00461 * 00462 * The CPU architecture configuration is where the endianess of the 00463 * CPU on which uIP is to be run is specified. Most CPUs today are 00464 * little endian, and the most notable exception are the Motorolas 00465 * which are big endian. The BYTE_ORDER macro should be changed to 00466 * reflect the CPU architecture on which uIP is to be run. 00467 */ 00468 00469 /** 00470 * The byte order of the CPU architecture on which uIP is to be run. 00471 * 00472 * This option can be either BIG_ENDIAN (Motorola byte order) or 00473 * LITTLE_ENDIAN (Intel byte order). 00474 * 00475 * \hideinitializer 00476 */ 00477 #ifdef UIP_CONF_BYTE_ORDER 00478 #define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER 00479 #else /* UIP_CONF_BYTE_ORDER */ 00480 #define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN 00481 #endif /* UIP_CONF_BYTE_ORDER */ 00482 00483 /** @} */ 00484 /*------------------------------------------------------------------------------*/ 00485 00486 /** 00487 * \defgroup uipoptapp Appication specific configurations 00488 * @{ 00489 * 00490 * An uIP application is implemented using a single application 00491 * function that is called by uIP whenever a TCP/IP event occurs. The 00492 * name of this function must be registered with uIP at compile time 00493 * using the UIP_APPCALL definition. 00494 * 00495 * uIP applications can store the application state within the 00496 * uip_conn structure by specifying the type of the application 00497 * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t. 00498 * 00499 * The file containing the definitions must be included in the 00500 * uipopt.h file. 00501 * 00502 * The following example illustrates how this can look. 00503 \code 00504 00505 void httpd_appcall(void); 00506 #define UIP_APPCALL httpd_appcall 00507 00508 struct httpd_state { 00509 u8_t state; 00510 u16_t count; 00511 char *dataptr; 00512 char *script; 00513 }; 00514 typedef struct httpd_state uip_tcp_appstate_t 00515 \endcode 00516 */ 00517 00518 /** 00519 * \var #define UIP_APPCALL 00520 * 00521 * The name of the application function that uIP should call in 00522 * response to TCP/IP events. 00523 * 00524 */ 00525 00526 /** 00527 * \var typedef uip_tcp_appstate_t 00528 * 00529 * The type of the application state that is to be stored in the 00530 * uip_conn structure. This usually is typedef:ed to a struct holding 00531 * application state information. 00532 */ 00533 00534 /** 00535 * \var typedef uip_udp_appstate_t 00536 * 00537 * The type of the application state that is to be stored in the 00538 * uip_conn structure. This usually is typedef:ed to a struct holding 00539 * application state information. 00540 */ 00541 /** @} */ 00542 00543 #include "net/tcpip.h" 00544 00545 #endif /* __UIPOPT_H__ */ 00546 /** @} */