net.nut 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. --
  2. -- Copyright (C) 2004-2007 by egnite Software GmbH. All rights reserved.
  3. --
  4. -- Redistribution and use in source and binary forms, with or without
  5. -- modification, are permitted provided that the following conditions
  6. -- are met:
  7. --
  8. -- 1. Redistributions of source code must retain the above copyright
  9. -- notice, this list of conditions and the following disclaimer.
  10. -- 2. Redistributions in binary form must reproduce the above copyright
  11. -- notice, this list of conditions and the following disclaimer in the
  12. -- documentation and/or other materials provided with the distribution.
  13. -- 3. Neither the name of the copyright holders nor the names of
  14. -- contributors may be used to endorse or promote products derived
  15. -- from this software without specific prior written permission.
  16. --
  17. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. -- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. -- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. -- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. -- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. -- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. -- SUCH DAMAGE.
  29. --
  30. -- For additional information see http://www.ethernut.de/
  31. --
  32. -- Operating system functions
  33. --
  34. -- $Log$
  35. --
  36. -- Revision 1.16 2010/10/27 12:22:44 ulrichprinz
  37. -- 2010-10-27 Ulrich Prinz <uprinz2@netscape.net>
  38. -- Added configuration support for unified PHY support package.
  39. --
  40. -- Revision 1.15 2009/02/22 12:22:44 olereinhardt
  41. -- 2009-02-22 Ole Reinhardt <ole.reinhardt@thermotemp.de>
  42. -- Added NUT_UDP_ICMP_SUPPORT (ICMP support on UDP sockets)
  43. --
  44. -- Revision 1.14 2009/02/16 03:10:50 thiagocorrea
  45. -- Fix small typo in text, hardly worth mentioning in the Changelog.
  46. --
  47. -- Revision 1.13 2008/08/20 06:56:59 haraldkipp
  48. -- Implemented IP demultiplexer.
  49. --
  50. -- Revision 1.12 2008/08/11 17:38:27 haraldkipp
  51. -- Added an Ethernet protocol demultiplexer.
  52. --
  53. -- Revision 1.11 2008/07/27 11:43:22 haraldkipp
  54. -- Configurable TCP retransmissions.
  55. --
  56. -- Revision 1.10 2007/05/02 11:18:32 haraldkipp
  57. -- IGMP support added. Incomplete.
  58. --
  59. -- Revision 1.9 2007/03/23 12:41:37 haraldkipp
  60. -- Added more detailed information about the ARP method.
  61. --
  62. -- Revision 1.8 2006/09/05 12:35:39 haraldkipp
  63. -- DHCP servers may probe an IP/MAC relationship by sending an
  64. -- ICMP request. This triggered the Nut/Net ARP method and
  65. -- terminated the DHCP client, leaving the system with default
  66. -- configurations of the network mask (255.255.255.0) and
  67. -- default gateway (none). The rarely used ARP method is now
  68. -- disabled by default.
  69. --
  70. -- Revision 1.7 2006/08/01 07:41:01 haraldkipp
  71. -- New functions ether_aton() and ether_ntoa() added. They convert the ASCII
  72. -- representation of an Ethernet MAC address to its binary form and vice versa.
  73. --
  74. -- Revision 1.6 2006/01/23 17:30:25 haraldkipp
  75. -- Configurable offset into non-volatile memory for network parameters.
  76. --
  77. -- Revision 1.5 2005/04/05 17:44:56 haraldkipp
  78. -- Made stack space configurable.
  79. --
  80. -- Revision 1.4 2005/02/04 15:05:59 haraldkipp
  81. -- ARP configuration added.
  82. --
  83. -- Revision 1.3 2005/01/13 18:47:31 haraldkipp
  84. -- Network dependencies added.
  85. --
  86. -- Revision 1.2 2004/08/18 13:46:09 haraldkipp
  87. -- Fine with avr-gcc
  88. --
  89. -- Revision 1.1 2004/06/07 16:38:43 haraldkipp
  90. -- First release
  91. --
  92. --
  93. nutnet =
  94. {
  95. {
  96. name = "nutnet_tcp",
  97. brief = "TCP",
  98. requires = { "NET_IP", "NET_ICMP", "NUT_EVENT" },
  99. provides = { "NET_TCP", "DEV_READ", "DEV_WRITE" },
  100. sources =
  101. {
  102. "tcpin.c",
  103. "tcpout.c",
  104. "tcpsm.c",
  105. "tcpsock.c",
  106. "tcputil.c"
  107. },
  108. options =
  109. {
  110. {
  111. macro = "NUT_THREAD_TCPSMSTACK",
  112. brief = "State Machine Stack",
  113. description = "Number of bytes to be allocated for the stack of the TCP state machine thread.",
  114. flavor = "booldata",
  115. file = "include/cfg/tcp.h"
  116. },
  117. {
  118. macro = "TCP_RETRIES_MAX",
  119. brief = "Max. Retransmissions",
  120. description = "Maximum number of retries before aborting a connection. "..
  121. "Increase this value if connections are dropped prematurely. "..
  122. "On reliable networks you may reduce this value to discover broken "..
  123. "connections earlier.",
  124. default = "7",
  125. file = "include/cfg/tcp.h"
  126. },
  127. {
  128. macro = "TCP_RTTO_MIN",
  129. brief = "Min. Retransmission Time",
  130. description = "Lower bound of the retransmission timeout, given in milliseconds. "..
  131. "Increase this value if connections are dropped prematurely or if "..
  132. "retransmissions cause too much traffic."..
  133. "On reliable networks you may reduce this value to recover from "..
  134. "casual packet loss earlier.",
  135. default = "200",
  136. file = "include/cfg/tcp.h"
  137. },
  138. {
  139. macro = "TCP_RTTO_MAX",
  140. brief = "Max. Retransmission Time",
  141. description = "Lower bound of the retransmission timeout, given in milliseconds. "..
  142. "On reliable networks you may reduce this value to discover broken "..
  143. "connections earlier.",
  144. default = "20000",
  145. file = "include/cfg/tcp.h"
  146. },
  147. {
  148. macro = "TCP_COLLECT_INADV",
  149. brief = "Segment Collection",
  150. description = "TCP segments received in advance are stored in a special queue "..
  151. " with complete headers. Due to this overhead, available memory may "..
  152. "become exhausted when the remote sends many small segments after one "..
  153. "segment got lost.\n\n"..
  154. "When the number of segments received in advance reaches the given "..
  155. "value, the stack will collect all consecutive small segments in the "..
  156. "buffer, removing the headers from all collected segments.\n\n"..
  157. "Increasing this value will increase memory requirements, but "..
  158. "give better performance on unreliable connections.",
  159. default = "8",
  160. file = "include/cfg/tcp.h"
  161. },
  162. {
  163. macro = "TCP_COLLECT_SLIMIT",
  164. brief = "Segment Collection Limit",
  165. description = "When the number of segments received in advance reaches the value "..
  166. "given by TCP_COLLECT_INADV, the stack will collect all consecutive "..
  167. "small segments.\n\n"..
  168. "This option specifies the limit, below which segments are conidered "..
  169. "small. Segments equal or larger in size will not be collected.",
  170. default = "256",
  171. file = "include/cfg/tcp.h"
  172. },
  173. {
  174. macro = "TCP_BACKLOG_MAX",
  175. brief = "Backlog Buffer Size",
  176. description = "The backlog buffers incoming TCP connections for which no server "..
  177. "thread is currently listening. It simply delays the reject in the "..
  178. "hope that a thread will become available soon.\n\n"..
  179. "Earlier versions of the stack immediately rejected incoming SYN "..
  180. "segments if no socket was listening on the specific port. Setting "..
  181. "this option to zero will keep this behaviour. Otherwise "..
  182. "this parameter specifies the maximum number of connection "..
  183. "attempts being stored in the backlog buffer.\n\n"..
  184. "If this option is not set to zero, then NutTcpAccept() will now "..
  185. "honor the TCP receive timeout, which may break existing applications.",
  186. default = "8",
  187. file = "include/cfg/tcp.h"
  188. },
  189. {
  190. macro = "TCP_BACKLOG_TIME",
  191. brief = "Max. Backlog Time",
  192. description = "In the current implementation there is no exact configuration for the "..
  193. "maximum time that a connection attempt is kept in the backlog buffer. "..
  194. "Multiplying this value by 200ms provides a rough approximation, but "..
  195. "the timeout may be significantly shorter with many incoming packets.\n\n"..
  196. "When the time elapses without any socket becoming ready to serve "..
  197. "the connection, then the connection attempt is rejected.\n\n"..
  198. "Furthermore, if the remote sends a second SYN packet for the same "..
  199. "connection, then the previous one is removed from the backlog and "..
  200. "the new attempt is rejected immediately.\n\n"..
  201. "This option is ignored, if TCP_BACKLOG_MAX is zero.",
  202. default = "5",
  203. file = "include/cfg/tcp.h"
  204. }
  205. }
  206. },
  207. {
  208. name = "nutnet_udp",
  209. brief = "UDP",
  210. requires = { "NET_IP", "NUT_EVENT" },
  211. provides = { "NET_UDP" },
  212. sources =
  213. {
  214. "udpin.c",
  215. "udpout.c",
  216. "udpsock.c"
  217. },
  218. options =
  219. {
  220. {
  221. macro = "NUT_UDP_ICMP_EXCLUDE",
  222. brief = "Disable ICMP support for UDP sockets for backwards compatibility",
  223. requires = { "NET_ICMP" },
  224. description = "ICMP support for UDP sockets allows error reporting on UDP sockets. "..
  225. "e.g. ICMP destination unreachable, ICMP host unreachable etc. "..
  226. "This will trigger errors on UDP send / receive functions. Unfortunately"..
  227. "changes to the old API were necessary and therefor you can disable ICMP"..
  228. "support for UDP sockets here.",
  229. flavor = "boolean",
  230. file = "include/cfg/udp.h"
  231. }
  232. }
  233. },
  234. {
  235. name = "nutnet_ip",
  236. brief = "IP",
  237. requires = { "NET_LINK" },
  238. provides = { "NET_IP" },
  239. sources =
  240. {
  241. "ipcsum.c",
  242. "ipin.c",
  243. "ipout.c",
  244. "ipdemux.c",
  245. "route.c"
  246. },
  247. options =
  248. {
  249. {
  250. macro = "NUT_IP_FORWARDING",
  251. brief = "IP Forwarding",
  252. description = "If enabled, incoming IP datagrams to other destinations are forwarded "..
  253. "to the most specific route.\n",
  254. flavor = "boolean",
  255. file = "include/cfg/ip.h"
  256. }
  257. }
  258. },
  259. {
  260. name = "nutnet_icmp",
  261. brief = "ICMP",
  262. requires = { "NET_LINK" },
  263. provides = { "NET_ICMP" },
  264. sources =
  265. {
  266. "icmpin.c",
  267. "icmpout.c"
  268. }
  269. },
  270. {
  271. name = "nutnet_igmp",
  272. brief = "IGMP",
  273. requires = { "NET_LINK" },
  274. provides = { "NET_IGMP" },
  275. sources =
  276. {
  277. "igmp.c",
  278. "igmpin.c",
  279. "igmpout.c"
  280. }
  281. },
  282. {
  283. name = "nutnet_inet",
  284. brief = "INET",
  285. description = "IP helper routines",
  286. sources = { "inet.c" }
  287. },
  288. {
  289. name = "nutnet_arp",
  290. brief = "ARP",
  291. description = "Address Resolution Protocol, translates a "..
  292. "32-bit IP address into a 48-bit Ethernet address.",
  293. requires = { "NUT_EVENT", "NET_MAC" },
  294. provides = { "NET_ARP" },
  295. sources =
  296. {
  297. "arpcache.c",
  298. "arpin.c",
  299. "arpout.c"
  300. },
  301. options =
  302. {
  303. {
  304. macro = "MAX_ARPAGE",
  305. brief = "Max. ARP Age",
  306. description = "Maximum age of an entry in the ARP cache in minutes. "..
  307. "Default is 9 minutes.",
  308. flavor = "booldata",
  309. file = "include/cfg/arp.h"
  310. },
  311. {
  312. macro = "MAX_ARPREQUESTS",
  313. brief = "Max. ARP Requests",
  314. description = "Maximum number of ARP requests generated per query. "..
  315. "Default is 4.",
  316. flavor = "booldata",
  317. file = "include/cfg/arp.h"
  318. },
  319. {
  320. macro = "MIN_ARPWAIT",
  321. brief = "Min. ARP Wait",
  322. description = "Minimum number of milliseconds to wait before sending "..
  323. "out a new ARP request. Default is 500 milliseconds.",
  324. flavor = "booldata",
  325. file = "include/cfg/arp.h"
  326. },
  327. }
  328. },
  329. {
  330. name = "nutnet_ethernet",
  331. brief = "Ethernet",
  332. requires = { "NET_ARP" },
  333. provides = { "NET_LINK" },
  334. sources =
  335. {
  336. "ethin.c",
  337. "ethout.c",
  338. "ethdemux.c",
  339. "ether_addr.c"
  340. }
  341. },
  342. {
  343. name = "nutnet_ppp",
  344. brief = "PPP",
  345. requires = {
  346. "NET_PPPAUTH", "NUT_EVENT", "PROTO_HDLC", "DEV_FILE", "DEV_READ", "DEV_WRITE"
  347. },
  348. provides = { "NET_PPP", "NET_LINK" },
  349. sources =
  350. {
  351. "pppin.c",
  352. "pppout.c",
  353. "pppsm.c",
  354. "ipcpin.c",
  355. "ipcpout.c",
  356. "lcpin.c",
  357. "lcpout.c"
  358. },
  359. options =
  360. {
  361. {
  362. macro = "NUT_THREAD_PPPSMSTACK",
  363. brief = "State Machine Stack",
  364. description = "Number of bytes to be allocated for the stack of the PPP state machine thread.",
  365. flavor = "booldata",
  366. file = "include/cfg/ppp.h"
  367. }
  368. }
  369. },
  370. {
  371. name = "nutnet_pap",
  372. brief = "PPP PAP",
  373. requires = { "NET_PPP" },
  374. provides = { "NET_PPPAUTH" },
  375. sources = { "papin.c", "papout.c" }
  376. },
  377. {
  378. name = "nutnet_ifconfig",
  379. brief = "Network interface",
  380. requires = { "NUT_EVENT", "NET_LINK" },
  381. sources = { "ifconfig.c" }
  382. },
  383. {
  384. name = "nutnet_conf",
  385. brief = "Network Configuration",
  386. description = "Initial network settings may be stored in non volatile memory "..
  387. "or may be hardcoded.",
  388. provides = { "NET_PARMS" },
  389. sources = { "confnet.c" },
  390. options =
  391. {
  392. {
  393. macro = "CONFNET_NVMEM",
  394. brief = "Use Non-Volatile Memory",
  395. description = "Initial network settings are stored in non volatile memory."..
  396. "The current version uses 10 bytes for validity check, 6 bytes "..
  397. "for the MAC address and 16 bytes for the IP configuration.\n\n"..
  398. "The length of the host name is configurable.\n\n"..
  399. "This item is disabled if the system doesn't offer any "..
  400. "non-volatile memory. Check the non-volatile memory"..
  401. "module in the device driver section.",
  402. requires = { "DEV_NVMEM" },
  403. provides = { "CONFNET_INIT_IN_NVMEM" },
  404. flavor = "boolean",
  405. exclusivity = { "CONFNET_NVMEM", "CONFNET_HARDCODED" },
  406. file = "include/cfg/eeprom.h"
  407. },
  408. {
  409. macro = "CONFNET_HARDCODED",
  410. brief = "Use Hard-Coded Values",
  411. description = "Initial network settings are hard-coded. When changed, you need to "..
  412. "re-compile the Nut/OS libraries.\n\n"..
  413. "Applications may handle the network configuration in a very "..
  414. "special way, which is not covered by the standard API. "..
  415. "Using hard-coded values will be also useful as a temporary "..
  416. "solution when porting Nut/Net to a new platform.",
  417. provides = { "CONFNET_INIT_IN_CODE" },
  418. flavor = "boolean",
  419. exclusivity = { "CONFNET_NVMEM", "CONFNET_HARDCODED" },
  420. file = "include/cfg/eeprom.h"
  421. },
  422. {
  423. macro = "CONFNET_EE_OFFSET",
  424. brief = "Location",
  425. description = "This is the non-volatile memory address offset, where Nut/Net "..
  426. "expects its configuration.\n\n"..
  427. "Note, that changing this value will invalidate previously "..
  428. "stored setting after upgrading to this new version. You must "..
  429. "also make sure, that this memory area will not conflict with "..
  430. "others, specifically the system configuration.",
  431. requires = { "CONFNET_INIT_IN_NVMEM" },
  432. default = "64",
  433. type = "integer",
  434. file = "include/cfg/eeprom.h"
  435. },
  436. {
  437. macro = "CONFNET_VIRGIN_MAC",
  438. brief = "Initial MAC Address",
  439. description = "Ethernet MAC address. "..
  440. "The given default is a locally administered address.",
  441. requires = { "CONFNET_INIT_IN_CODE" },
  442. default = "\"02:00:00:00:00:00\"",
  443. file = "include/cfg/eeprom.h"
  444. },
  445. {
  446. macro = "CONFNET_VIRGIN_IP",
  447. brief = "Initial IP Address",
  448. description = "When set to 0.0.0.0, Nut/Net will request an IP address from the DHCP "..
  449. "server during network initialization.",
  450. requires = { "CONFNET_INIT_IN_CODE" },
  451. default = "\"0.0.0.0\"",
  452. file = "include/cfg/eeprom.h"
  453. },
  454. {
  455. macro = "CONFNET_VIRGIN_NETMASK",
  456. brief = "Initial IP Mask",
  457. description = "If the initial IP address is 0.0.0.0, this will be overridden by DHCP. ",
  458. requires = { "CONFNET_INIT_IN_CODE" },
  459. default = "\"255.255.255.0\"",
  460. file = "include/cfg/eeprom.h"
  461. },
  462. {
  463. macro = "CONFNET_VIRGIN_GATE",
  464. brief = "Initial IP Gate",
  465. description = "IP address of the default gateway, may be 0.0.0.0 if routing to other "..
  466. "networks is not required. If the initial IP address is 0.0.0.0, this "..
  467. "will be overridden by DHCP.",
  468. requires = { "CONFNET_INIT_IN_CODE" },
  469. default = "\"0.0.0.0\"",
  470. file = "include/cfg/eeprom.h"
  471. }
  472. }
  473. },
  474. {
  475. name = "nutnet_debug",
  476. brief = "Network debug",
  477. requires = { "DEV_WRITE", "NET_LINK" },
  478. sources = { "netdebug.c" }
  479. },
  480. {
  481. name = "nutnet_debug_ppp",
  482. brief = "PPP debug",
  483. requires = { "DEV_WRITE", "NET_PPP" },
  484. sources = { "pppdebug.c" }
  485. }
  486. }