# uip/uipopt.h

Go to the documentation of this file.

    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 Most of the configuration options in the uipopt.h should not
    00012  * be changed, but rather the per-project uip-conf.h file.
    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.4 2006/06/12 08:00:31 adam 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 "uip-conf.h"
    00071
    00072 /*------------------------------------------------------------------------------*/
    00073
    00074 /**
    00075  * \name 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  * \name 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  * \name UDP configuration options
    00170  * @{
    00171  */
    00172
    00173 /**
    00174  * Toggles wether UDP support should be compiled in or not.
    00175  *
    00176  * \hideinitializer
    00177  */
    00178 #ifdef UIP_CONF_UDP
    00179 #define UIP_UDP UIP_CONF_UDP
    00180 #else /* UIP_CONF_UDP */
    00181 #define UIP_UDP           0
    00182 #endif /* UIP_CONF_UDP */
    00183
    00184 /**
    00185  * Toggles if UDP checksums should be used or not.
    00186  *
    00187  * \note Support for UDP checksums is currently not included in uIP,
    00188  * so this option has no function.
    00189  *
    00190  * \hideinitializer
    00191  */
    00192 #ifdef UIP_CONF_UDP_CHECKSUMS
    00193 #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
    00194 #else
    00195 #define UIP_UDP_CHECKSUMS 0
    00196 #endif
    00197
    00198 /**
    00199  * The maximum amount of concurrent UDP connections.
    00200  *
    00201  * \hideinitializer
    00202  */
    00203 #ifdef UIP_CONF_UDP_CONNS
    00204 #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
    00205 #else /* UIP_CONF_UDP_CONNS */
    00206 #define UIP_UDP_CONNS    10
    00207 #endif /* UIP_CONF_UDP_CONNS */
    00208
    00209 /**
    00210  * The name of the function that should be called when UDP datagrams arrive.
    00211  *
    00212  * \hideinitializer
    00213  */
    00214
    00215
    00216 /** @} */
    00217 /*------------------------------------------------------------------------------*/
    00218 /**
    00219  * \name TCP configuration options
    00220  * @{
    00221  */
    00222
    00223 /**
    00224  * Determines if support for opening connections from uIP should be
    00225  * compiled in.
    00226  *
    00227  * If the applications that are running on top of uIP for this project
    00228  * do not need to open outgoing TCP connections, this configration
    00229  * option can be turned off to reduce the code size of uIP.
    00230  *
    00231  * \hideinitializer
    00232  */
    00233 #define UIP_ACTIVE_OPEN 1
    00234
    00235 /**
    00236  * The maximum number of simultaneously open TCP connections.
    00237  *
    00238  * Since the TCP connections are statically allocated, turning this
    00239  * configuration knob down results in less RAM used. Each TCP
    00240  * connection requires approximatly 30 bytes of memory.
    00241  *
    00242  * \hideinitializer
    00243  */
    00244 #ifndef UIP_CONF_MAX_CONNECTIONS
    00245 #define UIP_CONNS       10
    00246 #else /* UIP_CONF_MAX_CONNECTIONS */
    00247 #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
    00248 #endif /* UIP_CONF_MAX_CONNECTIONS */
    00249
    00250
    00251 /**
    00252  * The maximum number of simultaneously listening TCP ports.
    00253  *
    00254  * Each listening TCP port requires 2 bytes of memory.
    00255  *
    00256  * \hideinitializer
    00257  */
    00258 #ifndef UIP_CONF_MAX_LISTENPORTS
    00259 #define UIP_LISTENPORTS 20
    00260 #else /* UIP_CONF_MAX_LISTENPORTS */
    00261 #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
    00262 #endif /* UIP_CONF_MAX_LISTENPORTS */
    00263
    00264 /**
    00265  * Determines if support for TCP urgent data notification should be
    00266  * compiled in.
    00267  *
    00268  * Urgent data (out-of-band data) is a rarely used TCP feature that
    00269  * very seldom would be required.
    00270  *
    00271  * \hideinitializer
    00272  */
    00273 #define UIP_URGDATA      0
    00274
    00275 /**
    00276  * The initial retransmission timeout counted in timer pulses.
    00277  *
    00278  * This should not be changed.
    00279  */
    00280 #define UIP_RTO         3
    00281
    00282 /**
    00283  * The maximum number of times a segment should be retransmitted
    00284  * before the connection should be aborted.
    00285  *
    00286  * This should not be changed.
    00287  */
    00288 #define UIP_MAXRTX      8
    00289
    00290 /**
    00291  * The maximum number of times a SYN segment should be retransmitted
    00292  * before a connection request should be deemed to have been
    00293  * unsuccessful.
    00294  *
    00295  * This should not need to be changed.
    00296  */
    00297 #define UIP_MAXSYNRTX      5
    00298
    00299 /**
    00300  * The TCP maximum segment size.
    00301  *
    00302  * This is should not be to set to more than
    00303  * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
    00304  */
    00305 #define UIP_TCP_MSS     (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
    00306
    00307 /**
    00308  * The size of the advertised receiver's window.
    00309  *
    00310  * Should be set low (i.e., to the size of the uip_buf buffer) is the
    00311  * application is slow to process incoming data, or high (32768 bytes)
    00312  * if the application processes data quickly.
    00313  *
    00314  * \hideinitializer
    00315  */
    00316 #ifndef UIP_CONF_RECEIVE_WINDOW
    00317 #define UIP_RECEIVE_WINDOW UIP_TCP_MSS
    00318 #else
    00319 #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
    00320 #endif
    00321
    00322 /**
    00323  * How long a connection should stay in the TIME_WAIT state.
    00324  *
    00325  * This configiration option has no real implication, and it should be
    00326  * left untouched.
    00327  */
    00328 #define UIP_TIME_WAIT_TIMEOUT 120
    00329
    00330
    00331 /** @} */
    00332 /*------------------------------------------------------------------------------*/
    00333 /**
    00334  * \name ARP configuration options
    00335  * @{
    00336  */
    00337
    00338 /**
    00339  * The size of the ARP table.
    00340  *
    00341  * This option should be set to a larger value if this uIP node will
    00342  * have many connections from the local network.
    00343  *
    00344  * \hideinitializer
    00345  */
    00346 #ifdef UIP_CONF_ARPTAB_SIZE
    00347 #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
    00348 #else
    00349 #define UIP_ARPTAB_SIZE 8
    00350 #endif
    00351
    00352 /**
    00353  * The maxium age of ARP table entries measured in 10ths of seconds.
    00354  *
    00355  * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
    00356  * default).
    00357  */
    00358 #define UIP_ARP_MAXAGE 120
    00359
    00360 /** @} */
    00361
    00362 /*------------------------------------------------------------------------------*/
    00363
    00364 /**
    00365  * \name General configuration options
    00366  * @{
    00367  */
    00368
    00369 /**
    00370  * The size of the uIP packet buffer.
    00371  *
    00372  * The uIP packet buffer should not be smaller than 60 bytes, and does
    00373  * not need to be larger than 1500 bytes. Lower size results in lower
    00374  * TCP throughput, larger size results in higher TCP throughput.
    00375  *
    00376  * \hideinitializer
    00377  */
    00378 #ifndef UIP_CONF_BUFFER_SIZE
    00379 #define UIP_BUFSIZE     400
    00380 #else /* UIP_CONF_BUFFER_SIZE */
    00381 #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
    00382 #endif /* UIP_CONF_BUFFER_SIZE */
    00383
    00384
    00385 /**
    00386  * Determines if statistics support should be compiled in.
    00387  *
    00388  * The statistics is useful for debugging and to show the user.
    00389  *
    00390  * \hideinitializer
    00391  */
    00392 #ifndef UIP_CONF_STATISTICS
    00393 #define UIP_STATISTICS  0
    00394 #else /* UIP_CONF_STATISTICS */
    00395 #define UIP_STATISTICS UIP_CONF_STATISTICS
    00396 #endif /* UIP_CONF_STATISTICS */
    00397
    00398 /**
    00399  * Determines if logging of certain events should be compiled in.
    00400  *
    00401  * This is useful mostly for debugging. The function uip_log()
    00402  * must be implemented to suit the architecture of the project, if
    00403  * logging is turned on.
    00404  *
    00405  * \hideinitializer
    00406  */
    00407 #ifndef UIP_CONF_LOGGING
    00408 #define UIP_LOGGING     0
    00409 #else /* UIP_CONF_LOGGING */
    00410 #define UIP_LOGGING     UIP_CONF_LOGGING
    00411 #endif /* UIP_CONF_LOGGING */
    00412
    00413 /**
    00414  * Broadcast support.
    00415  *
    00416  * This flag configures IP broadcast support. This is useful only
    00417  * together with UDP.
    00418  *
    00419  * \hideinitializer
    00420  *
    00421  */
    00422 #ifndef UIP_CONF_BROADCAST
    00423 #define UIP_BROADCAST 0
    00424 #else /* UIP_CONF_BROADCAST */
    00425 #define UIP_BROADCAST UIP_CONF_BROADCAST
    00426 #endif /* UIP_CONF_BROADCAST */
    00427
    00428 /**
    00429  * Print out a uIP log message.
    00430  *
    00431  * This function must be implemented by the module that uses uIP, and
    00432  * is called by uIP whenever a log message is generated.
    00433  */
    00434 void uip_log(char *msg);
    00435
    00436 /**
    00437  * The link level header length.
    00438  *
    00439  * This is the offset into the uip_buf where the IP header can be
    00440  * found. For Ethernet, this should be set to 14. For SLIP, this
    00441  * should be set to 0.
    00442  *
    00443  * \hideinitializer
    00444  */
    00445 #ifdef UIP_CONF_LLH_LEN
    00446 #define UIP_LLH_LEN UIP_CONF_LLH_LEN
    00447 #else /* UIP_CONF_LLH_LEN */
    00448 #define UIP_LLH_LEN     14
    00449 #endif /* UIP_CONF_LLH_LEN */
    00450
    00451 /** @} */
    00452 /*------------------------------------------------------------------------------*/
    00453 /**
    00454  * \name CPU architecture configuration
    00455  * @{
    00456  *
    00457  * The CPU architecture configuration is where the endianess of the
    00458  * CPU on which uIP is to be run is specified. Most CPUs today are
    00459  * little endian, and the most notable exception are the Motorolas
    00460  * which are big endian. The BYTE_ORDER macro should be changed to
    00461  * reflect the CPU architecture on which uIP is to be run.
    00462  */
    00463
    00464 /**
    00465  * The byte order of the CPU architecture on which uIP is to be run.
    00466  *
    00467  * This option can be either BIG_ENDIAN (Motorola byte order) or
    00468  * LITTLE_ENDIAN (Intel byte order).
    00469  *
    00470  * \hideinitializer
    00471  */
    00472 #ifdef UIP_CONF_BYTE_ORDER
    00473 #define UIP_BYTE_ORDER     UIP_CONF_BYTE_ORDER
    00474 #else /* UIP_CONF_BYTE_ORDER */
    00475 #define UIP_BYTE_ORDER     UIP_LITTLE_ENDIAN
    00476 #endif /* UIP_CONF_BYTE_ORDER */
    00477
    00478 /** @} */
    00479 /*------------------------------------------------------------------------------*/
    00480
    00481 /**
    00482  * \name Appication specific configurations
    00483  * @{
    00484  *
    00485  * An uIP application is implemented using a single application
    00486  * function that is called by uIP whenever a TCP/IP event occurs. The
    00487  * name of this function must be registered with uIP at compile time
    00488  * using the UIP_APPCALL definition.
    00489  *
    00490  * uIP applications can store the application state within the
    00491  * uip_conn structure by specifying the type of the application
    00492  * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
    00493  *
    00494  * The file containing the definitions must be included in the
    00495  * uipopt.h file.
    00496  *
    00497  * The following example illustrates how this can look.
    00498  \code
    00499
    00500 void httpd_appcall(void);
    00501 #define UIP_APPCALL     httpd_appcall
    00502
    00503 struct httpd_state {
    00504   u8_t state;
    00505   u16_t count;
    00506   char *dataptr;
    00507   char *script;
    00508 };
    00509 typedef struct httpd_state uip_tcp_appstate_t
    00510  \endcode
    00511  */
    00512
    00513 /**
    00514  * \var #define UIP_APPCALL
    00515  *
    00516  * The name of the application function that uIP should call in
    00517  * response to TCP/IP events.
    00518  *
    00519  */
    00520
    00521 /**
    00522  * \var typedef uip_tcp_appstate_t
    00523  *
    00524  * The type of the application state that is to be stored in the
    00525  * uip_conn structure. This usually is typedef:ed to a struct holding
    00526  * application state information.
    00527  */
    00528
    00529 /**
    00530  * \var typedef uip_udp_appstate_t
    00531  *
    00532  * The type of the application state that is to be stored in the
    00533  * uip_conn structure. This usually is typedef:ed to a struct holding
    00534  * application state information.
    00535  */
    00536 /** @} */
    00537 /** @} */
    00538
    00539 #endif /* __UIPOPT_H__ */