"Fossies" - the Fresh Open Source Software Archive

Member "open-iscsi-2.1.0/iscsiuio/src/uip/uipopt.h" (14 Nov 2019, 14463 Bytes) of package /linux/misc/open-iscsi-2.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "uipopt.h" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * \defgroup uipopt Configuration options for uIP
    3  * @{
    4  *
    5  * uIP is configured using the per-project configuration file
    6  * uipopt.h. This file contains all compile-time options for uIP and
    7  * should be tweaked to match each specific project. The uIP
    8  * distribution contains a documented example "uipopt.h" that can be
    9  * copied and modified for each project.
   10  *
   11  * \note Most of the configuration options in the uipopt.h should not
   12  * be changed, but rather the per-project uip-conf.h file.
   13  */
   14 
   15 /**
   16  * \file
   17  * Configuration options for uIP.
   18  * \author Adam Dunkels <adam@dunkels.com>
   19  *
   20  * This file is used for tweaking various configuration options for
   21  * uIP. You should make a copy of this file into one of your project's
   22  * directories instead of editing this example "uipopt.h" file that
   23  * comes with the uIP distribution.
   24  */
   25 
   26 /*
   27  * Copyright (c) 2001-2003, Adam Dunkels.
   28  * All rights reserved.
   29  *
   30  * Redistribution and use in source and binary forms, with or without
   31  * modification, are permitted provided that the following conditions
   32  * are met:
   33  * 1. Redistributions of source code must retain the above copyright
   34  *    notice, this list of conditions and the following disclaimer.
   35  * 2. Redistributions in binary form must reproduce the above copyright
   36  *    notice, this list of conditions and the following disclaimer in the
   37  *    documentation and/or other materials provided with the distribution.
   38  * 3. The name of the author may not be used to endorse or promote
   39  *    products derived from this software without specific prior
   40  *    written permission.
   41  *
   42  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   43  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   44  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   45  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   46  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   47  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   48  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   49  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   50  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   51  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   52  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   53  *
   54  * This file is part of the uIP TCP/IP stack.
   55  *
   56  *
   57  */
   58 
   59 #ifndef __UIPOPT_H__
   60 #define __UIPOPT_H__
   61 
   62 #ifndef UIP_LITTLE_ENDIAN
   63 #define UIP_LITTLE_ENDIAN  3412
   64 #endif /* UIP_LITTLE_ENDIAN */
   65 #ifndef UIP_BIG_ENDIAN
   66 #define UIP_BIG_ENDIAN     1234
   67 #endif /* UIP_BIG_ENDIAN */
   68 
   69 #include "uip-conf.h"
   70 
   71 /*----------------------------------------------------------------------------*/
   72 
   73 /**
   74  * \name Static configuration options
   75  * @{
   76  *
   77  * These configuration options can be used for setting the IP address
   78  * settings statically, but only if UIP_FIXEDADDR is set to 1. The
   79  * configuration options for a specific node includes IP address,
   80  * netmask and default router as well as the Ethernet address. The
   81  * netmask, default router and Ethernet address are appliciable only
   82  * if uIP should be run over Ethernet.
   83  *
   84  * All of these should be changed to suit your project.
   85 */
   86 
   87 /**
   88  * Determines if uIP should use a fixed IP address or not.
   89  *
   90  * If uIP should use a fixed IP address, the settings are set in the
   91  * uipopt.h file. If not, the macros uip_sethostaddr(),
   92  * uip_setdraddr() and uip_setnetmask() should be used instead.
   93  *
   94  * \hideinitializer
   95  */
   96 #define UIP_FIXEDADDR    0
   97 
   98 /**
   99  * Ping IP address asignment.
  100  *
  101  * uIP uses a "ping" packets for setting its own IP address if this
  102  * option is set. If so, uIP will start with an empty IP address and
  103  * the destination IP address of the first incoming "ping" (ICMP echo)
  104  * packet will be used for setting the hosts IP address.
  105  *
  106  * \note This works only if UIP_FIXEDADDR is 0.
  107  *
  108  * \hideinitializer
  109  */
  110 #ifdef UIP_CONF_PINGADDRCONF
  111 #define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
  112 #else /* UIP_CONF_PINGADDRCONF */
  113 #define UIP_PINGADDRCONF 0
  114 #endif /* UIP_CONF_PINGADDRCONF */
  115 
  116 /**
  117  * Specifies if the uIP ARP module should be compiled with a fixed
  118  * Ethernet MAC address or not.
  119  *
  120  * If this configuration option is 0, the macro uip_setethaddr() can
  121  * be used to specify the Ethernet address at run-time.
  122  *
  123  * \hideinitializer
  124  */
  125 #define UIP_FIXEDETHADDR 0
  126 
  127 /** @} */
  128 /*------------------------------------------------------------------------------*/
  129 /**
  130  * \name IP configuration options
  131  * @{
  132  *
  133  */
  134 /**
  135  * The IP TTL (time to live) of IP packets sent by uIP.
  136  *
  137  * This should normally not be changed.
  138  */
  139 #define UIP_TTL         64
  140 
  141 /**
  142  * Turn on support for IP packet reassembly.
  143  *
  144  * uIP supports reassembly of fragmented IP packets. This features
  145  * requires an additonal amount of RAM to hold the reassembly buffer
  146  * and the reassembly code size is approximately 700 bytes.  The
  147  * reassembly buffer is of the same size as the uip_buf buffer
  148  * (configured by UIP_BUFSIZE).
  149  *
  150  * \note IP packet reassembly is not heavily tested.
  151  *
  152  * \hideinitializer
  153  */
  154 #define UIP_REASSEMBLY 0
  155 
  156 /**
  157  * The maximum time an IP fragment should wait in the reassembly
  158  * buffer before it is dropped.
  159  *
  160  */
  161 #define UIP_REASS_MAXAGE 40
  162 
  163 /** @} */
  164 
  165 /*----------------------------------------------------------------------------*/
  166 /**
  167  * \name UDP configuration options
  168  * @{
  169  */
  170 
  171 /**
  172  * Toggles wether UDP support should be compiled in or not.
  173  *
  174  * \hideinitializer
  175  */
  176 #ifdef UIP_CONF_UDP
  177 #define UIP_UDP UIP_CONF_UDP
  178 #else /* UIP_CONF_UDP */
  179 #define UIP_UDP           0
  180 #endif /* UIP_CONF_UDP */
  181 
  182 /**
  183  * Toggles if UDP checksums should be used or not.
  184  *
  185  * \note Support for UDP checksums is currently not included in uIP,
  186  * so this option has no function.
  187  *
  188  * \hideinitializer
  189  */
  190 #ifdef UIP_CONF_UDP_CHECKSUMS
  191 #define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
  192 #else
  193 #define UIP_UDP_CHECKSUMS 0
  194 #endif
  195 
  196 /**
  197  * The maximum amount of concurrent UDP connections.
  198  *
  199  * \hideinitializer
  200  */
  201 #ifdef UIP_CONF_UDP_CONNS
  202 #define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
  203 #else /* UIP_CONF_UDP_CONNS */
  204 #define UIP_UDP_CONNS    10
  205 #endif /* UIP_CONF_UDP_CONNS */
  206 
  207 /**
  208  * The name of the function that should be called when UDP datagrams arrive.
  209  *
  210  * \hideinitializer
  211  */
  212 
  213 /** @} */
  214 /*------------------------------------------------------------------------------*/
  215 /**
  216  * \name TCP configuration options
  217  * @{
  218  */
  219 
  220 /**
  221  * Determines if support for opening connections from uIP should be
  222  * compiled in.
  223  *
  224  * If the applications that are running on top of uIP for this project
  225  * do not need to open outgoing TCP connections, this configration
  226  * option can be turned off to reduce the code size of uIP.
  227  *
  228  * \hideinitializer
  229  */
  230 #define UIP_ACTIVE_OPEN 1
  231 
  232 /**
  233  * The maximum number of simultaneously open TCP connections.
  234  *
  235  * Since the TCP connections are statically allocated, turning this
  236  * configuration knob down results in less RAM used. Each TCP
  237  * connection requires approximatly 30 bytes of memory.
  238  *
  239  * \hideinitializer
  240  */
  241 #ifndef UIP_CONF_MAX_CONNECTIONS
  242 #define UIP_CONNS       10
  243 #else /* UIP_CONF_MAX_CONNECTIONS */
  244 #define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
  245 #endif /* UIP_CONF_MAX_CONNECTIONS */
  246 
  247 /**
  248  * The maximum number of simultaneously listening TCP ports.
  249  *
  250  * Each listening TCP port requires 2 bytes of memory.
  251  *
  252  * \hideinitializer
  253  */
  254 #ifndef UIP_CONF_MAX_LISTENPORTS
  255 #define UIP_LISTENPORTS 20
  256 #else /* UIP_CONF_MAX_LISTENPORTS */
  257 #define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
  258 #endif /* UIP_CONF_MAX_LISTENPORTS */
  259 
  260 /**
  261  * Determines if support for TCP urgent data notification should be
  262  * compiled in.
  263  *
  264  * Urgent data (out-of-band data) is a rarely used TCP feature that
  265  * very seldom would be required.
  266  *
  267  * \hideinitializer
  268  */
  269 #define UIP_URGDATA      0
  270 
  271 /**
  272  * The initial retransmission timeout counted in timer pulses.
  273  *
  274  * This should not be changed.
  275  */
  276 #define UIP_RTO         3
  277 
  278 /**
  279  * The maximum number of times a segment should be retransmitted
  280  * before the connection should be aborted.
  281  *
  282  * This should not be changed.
  283  */
  284 #define UIP_MAXRTX      8
  285 
  286 /**
  287  * The maximum number of times a SYN segment should be retransmitted
  288  * before a connection request should be deemed to have been
  289  * unsuccessful.
  290  *
  291  * This should not need to be changed.
  292  */
  293 #define UIP_MAXSYNRTX      5
  294 
  295 /**
  296  * The TCP maximum segment size.
  297  *
  298  * This is should not be to set to more than
  299  * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
  300  */
  301 #define UIP_TCP_MSS     (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCP_IPv4_HLEN)
  302 
  303 /**
  304  * The size of the advertised receiver's window.
  305  *
  306  * Should be set low (i.e., to the size of the uip_buf buffer) is the
  307  * application is slow to process incoming data, or high (32768 bytes)
  308  * if the application processes data quickly.
  309  *
  310  * \hideinitializer
  311  */
  312 #ifndef UIP_CONF_RECEIVE_WINDOW
  313 #define UIP_RECEIVE_WINDOW UIP_TCP_MSS
  314 #else
  315 #define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
  316 #endif
  317 
  318 /**
  319  * How long a connection should stay in the TIME_WAIT state.
  320  *
  321  * This configiration option has no real implication, and it should be
  322  * left untouched.
  323  */
  324 #define UIP_TIME_WAIT_TIMEOUT 120
  325 
  326 /** @} */
  327 /*------------------------------------------------------------------------------*/
  328 /**
  329  * \name ARP configuration options
  330  * @{
  331  */
  332 
  333 /**
  334  * The size of the ARP table.
  335  *
  336  * This option should be set to a larger value if this uIP node will
  337  * have many connections from the local network.
  338  *
  339  * \hideinitializer
  340  */
  341 #ifdef UIP_CONF_ARPTAB_SIZE
  342 #define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
  343 #else
  344 #define UIP_ARPTAB_SIZE 16
  345 #endif
  346 
  347 /**
  348  * The maxium age of ARP table entries measured in 10ths of seconds.
  349  *
  350  * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
  351  * default).
  352  * Changed the default to 30 which corresponds to 5 minutes (Linux default)
  353  */
  354 #define UIP_ARP_MAXAGE 30
  355 
  356 /** @} */
  357 
  358 /*----------------------------------------------------------------------------*/
  359 
  360 /**
  361  * \name General configuration options
  362  * @{
  363  */
  364 
  365 /**
  366  * The size of the uIP packet buffer.
  367  *
  368  * The uIP packet buffer should not be smaller than 60 bytes, and does
  369  * not need to be larger than 1500 bytes. Lower size results in lower
  370  * TCP throughput, larger size results in higher TCP throughput.
  371  *
  372  * \hideinitializer
  373  */
  374 #ifndef UIP_CONF_BUFFER_SIZE
  375 #define UIP_BUFSIZE     400
  376 #else /* UIP_CONF_BUFFER_SIZE */
  377 #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
  378 #endif /* UIP_CONF_BUFFER_SIZE */
  379 
  380 /**
  381  * Determines if statistics support should be compiled in.
  382  *
  383  * The statistics is useful for debugging and to show the user.
  384  *
  385  * \hideinitializer
  386  */
  387 #ifndef UIP_CONF_STATISTICS
  388 #define UIP_STATISTICS  0
  389 #else /* UIP_CONF_STATISTICS */
  390 #define UIP_STATISTICS UIP_CONF_STATISTICS
  391 #endif /* UIP_CONF_STATISTICS */
  392 
  393 /**
  394  * Determines if logging of certain events should be compiled in.
  395  *
  396  * This is useful mostly for debugging. The function uip_log()
  397  * must be implemented to suit the architecture of the project, if
  398  * logging is turned on.
  399  *
  400  * \hideinitializer
  401  */
  402 #ifndef UIP_CONF_LOGGING
  403 #define UIP_LOGGING     0
  404 #else /* UIP_CONF_LOGGING */
  405 #define UIP_LOGGING     UIP_CONF_LOGGING
  406 #endif /* UIP_CONF_LOGGING */
  407 
  408 /**
  409  * Broadcast support.
  410  *
  411  * This flag configures IP broadcast support. This is useful only
  412  * together with UDP.
  413  *
  414  * \hideinitializer
  415  *
  416  */
  417 #ifndef UIP_CONF_BROADCAST
  418 #define UIP_BROADCAST 0
  419 #else /* UIP_CONF_BROADCAST */
  420 #define UIP_BROADCAST UIP_CONF_BROADCAST
  421 #endif /* UIP_CONF_BROADCAST */
  422 
  423 /**
  424  * Print out a uIP log message.
  425  *
  426  * This function must be implemented by the module that uses uIP, and
  427  * is called by uIP whenever a log message is generated.
  428  */
  429 void uip_log(char *msg);
  430 
  431 /**
  432  * The link level header length.
  433  *
  434  * This is the offset into the uip_buf where the IP header can be
  435  * found. For Ethernet, this should be set to 14. For SLIP, this
  436  * should be set to 0.
  437  *
  438  * \hideinitializer
  439  */
  440 #ifdef UIP_CONF_LLH_LEN
  441 #define UIP_LLH_LEN UIP_CONF_LLH_LEN
  442 #else /* UIP_CONF_LLH_LEN */
  443 #define UIP_LLH_LEN     14
  444 #endif /* UIP_CONF_LLH_LEN */
  445 
  446 #if 0
  447 /** @} */
  448 /*------------------------------------------------------------------------------*/
  449 /**
  450  * \name CPU architecture configuration
  451  * @{
  452  *
  453  * The CPU architecture configuration is where the endianess of the
  454  * CPU on which uIP is to be run is specified. Most CPUs today are
  455  * little endian, and the most notable exception are the Motorolas
  456  * which are big endian. The BYTE_ORDER macro should be changed to
  457  * reflect the CPU architecture on which uIP is to be run.
  458  */
  459 
  460 /**
  461  * The byte order of the CPU architecture on which uIP is to be run.
  462  *
  463  * This option can be either BIG_ENDIAN (Motorola byte order) or
  464  * LITTLE_ENDIAN (Intel byte order).
  465  *
  466  * \hideinitializer
  467  */
  468 #ifdef UIP_CONF_BYTE_ORDER
  469 #define UIP_BYTE_ORDER     UIP_CONF_BYTE_ORDER
  470 #else /* UIP_CONF_BYTE_ORDER */
  471 #define UIP_BYTE_ORDER     UIP_LITTLE_ENDIAN
  472 #endif /* UIP_CONF_BYTE_ORDER */
  473 #endif
  474 
  475 /** @} */
  476 /*------------------------------------------------------------------------------*/
  477 
  478 /**
  479  * \name Appication specific configurations
  480  * @{
  481  *
  482  * An uIP application is implemented using a single application
  483  * function that is called by uIP whenever a TCP/IP event occurs. The
  484  * name of this function must be registered with uIP at compile time
  485  * using the UIP_APPCALL definition.
  486  *
  487  * uIP applications can store the application state within the
  488  * uip_conn structure by specifying the type of the application
  489  * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
  490  *
  491  * The file containing the definitions must be included in the
  492  * uipopt.h file.
  493  *
  494  * The following example illustrates how this can look.
  495  \code
  496 
  497 void httpd_appcall(void);
  498 #define UIP_APPCALL     httpd_appcall
  499 
  500 struct httpd_state {
  501   u8_t state;
  502   u16_t count;
  503   char *dataptr;
  504   char *script;
  505 };
  506 typedef struct httpd_state uip_tcp_appstate_t
  507  \endcode
  508  */
  509 
  510 /**
  511  * \var #define UIP_APPCALL
  512  *
  513  * The name of the application function that uIP should call in
  514  * response to TCP/IP events.
  515  *
  516  */
  517 
  518 /**
  519  * \var typedef uip_tcp_appstate_t
  520  *
  521  * The type of the application state that is to be stored in the
  522  * uip_conn structure. This usually is typedef:ed to a struct holding
  523  * application state information.
  524  */
  525 
  526 /**
  527  * \var typedef uip_udp_appstate_t
  528  *
  529  * The type of the application state that is to be stored in the
  530  * uip_conn structure. This usually is typedef:ed to a struct holding
  531  * application state information.
  532  */
  533 /** @} */
  534 /** @} */
  535 
  536 #endif /* __UIPOPT_H__ */