Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | /*! \file netstack.h \brief Network Stack. */ |
2 | //***************************************************************************** |
||
3 | // |
||
4 | // File Name : 'netstack.h' |
||
5 | // Title : Network Stack |
||
6 | // Author : Pascal Stang |
||
7 | // Created : 6/28/2005 |
||
8 | // Revised : 9/20/2005 |
||
9 | // Version : 0.3 |
||
10 | // Target MCU : Atmel AVR series |
||
11 | // Editor Tabs : 4 |
||
12 | // |
||
13 | /// \ingroup network |
||
14 | /// \defgroup netstack Network Stack (netstack.c) |
||
15 | /// \code #include "net/netstack.h" \endcode |
||
16 | /// \par Description |
||
17 | /// This library co-ordinates the various pieces of a typical IP network |
||
18 | /// stack into one unit. Included are handling for ARP, ICMP, and IP |
||
19 | /// packets. UDP and TCP packets are processed and passed to the user. |
||
20 | /// |
||
21 | /// This is an example of how to use the various network libraries, and |
||
22 | /// is meant to be useful out-of-the-box for most users. However, some |
||
23 | /// users may find it restrictive and write their own handlers instead. |
||
24 | /// This stack implementation is by no means the only way to use the various |
||
25 | /// network libraries. |
||
26 | /// |
||
27 | /// \note This is NOT a full-blown TCP/IP stack. It merely handles lower |
||
28 | /// level stack functions so that UDP and TCP packets can be sent |
||
29 | /// and received easily. End-to-end TCP functionality may be added |
||
30 | /// in a future version. Until then, I can recommend using other embedded |
||
31 | /// TCP/IP stacks like Adam Dunkel's uIP. |
||
32 | // |
||
33 | // This code is distributed under the GNU Public License |
||
34 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
35 | //***************************************************************************** |
||
36 | //@{ |
||
37 | |||
38 | #ifndef NETSTACK_H |
||
39 | #define NETSTACK_H |
||
40 | |||
41 | #include "net.h" |
||
42 | #include "arp.h" |
||
43 | #include "icmp.h" |
||
44 | #include "ip.h" |
||
45 | #include "nic.h" |
||
46 | |||
47 | //#define NETSTACK_DEBUG |
||
48 | |||
49 | /// NET_BUFFERSIZE is the common receive/process/transmit buffer. |
||
50 | /// - You may override the default NET_BUFFERSIZE by defining an alternate value in global.h. |
||
51 | /// - Network packets larger than NET_BUFFERSIZE will not be accepted. |
||
52 | #ifndef NETSTACK_BUFFERSIZE |
||
53 | #define NETSTACK_BUFFERSIZE (576+ETH_HEADER_LEN) |
||
54 | #endif |
||
55 | |||
56 | /// netstackInit prepares the network interface for use and should be called |
||
57 | /// once at the beginning of the user program. |
||
58 | /// \note Use ipSetAddress() to change network parameters in mid-run. |
||
59 | void netstackInit(uint32_t ipaddress, uint32_t netmask, uint32_t gatewayip); |
||
60 | |||
61 | /// netstackGetBuffer returns a pointer to the common receive/process/transmit buffer. |
||
62 | u08* netstackGetBuffer(void); |
||
63 | |||
64 | /// netstackService should be called in the main loop of the user program. |
||
65 | /// The function will process one received network packet per call. |
||
66 | /// The return value is the length of the packet processed, or zero if no |
||
67 | /// packet was processed. |
||
68 | int netstackService(void); |
||
69 | |||
70 | /// netstackIPProcess handles distribution of IP received packets. |
||
71 | /// |
||
72 | void netstackIPProcess(unsigned int len, ip_hdr* packet); |
||
73 | |||
74 | /// This weakly-defined function is the default handler for incoming UDP/IP packets. |
||
75 | /// Users should define this same function in user code (same name and arguments) to |
||
76 | /// override this default handler and get access to the received packets. |
||
77 | void netstackUDPIPProcess(unsigned int len, udpip_hdr* packet) __attribute__ ((weak)); |
||
78 | |||
79 | /// This weakly-defined function is the default handler for incoming TCP/IP packets. |
||
80 | /// Users should define this same function in user code (same name and arguments) to |
||
81 | /// override this default handler and get access to the received packets. |
||
82 | void netstackTCPIPProcess(unsigned int len, tcpip_hdr* packet) __attribute__ ((weak)); |
||
83 | |||
84 | #endif |
||
85 | //@} |
Powered by WebSVN v2.8.3