uipopt.h 14 KB

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