Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

uipopt.h 16KB

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