📄 netstack_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon AVRlib: net/netstack.h Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div><div class="nav"><a class="el" href="dir_000001.html">net</a></div><h1>netstack.h</h1><a href="netstack_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file netstack.h \brief Network Stack. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'netstack.h'</span>00005 <span class="comment">// Title : Network Stack</span>00006 <span class="comment">// Author : Pascal Stang</span>00007 <span class="comment">// Created : 6/28/2005</span>00008 <span class="comment">// Revised : 9/20/2005</span>00009 <span class="comment">// Version : 0.3</span>00010 <span class="comment">// Target MCU : Atmel AVR series</span>00011 <span class="comment">// Editor Tabs : 4</span>00012 <span class="comment">//</span><span class="comment"></span>00013 <span class="comment">/// \ingroup network</span>00014 <span class="comment">/// \defgroup netstack Network Stack (netstack.c)</span>00015 <span class="comment">/// \code #include "net/netstack.h" \endcode</span>00016 <span class="comment">/// \par Description</span>00017 <span class="comment">/// This library co-ordinates the various pieces of a typical IP network</span>00018 <span class="comment">/// stack into one unit. Included are handling for ARP, ICMP, and IP</span>00019 <span class="comment">/// packets. UDP and TCP packets are processed and passed to the user.</span>00020 <span class="comment">///</span>00021 <span class="comment">/// This is an example of how to use the various network libraries, and</span>00022 <span class="comment">/// is meant to be useful out-of-the-box for most users. However, some</span>00023 <span class="comment">/// users may find it restrictive and write their own handlers instead.</span>00024 <span class="comment">/// This stack implementation is by no means the only way to use the various</span>00025 <span class="comment">/// network libraries.</span>00026 <span class="comment">///</span>00027 <span class="comment">/// \note This is NOT a full-blown TCP/IP stack. It merely handles lower</span>00028 <span class="comment">/// level stack functions so that UDP and TCP packets can be sent</span>00029 <span class="comment">/// and received easily. End-to-end TCP functionality may be added</span>00030 <span class="comment">/// in a future version. Until then, I can recommend using other embedded</span>00031 <span class="comment">/// TCP/IP stacks like Adam Dunkel's uIP.</span>00032 <span class="comment"></span><span class="comment">//</span>00033 <span class="comment">// This code is distributed under the GNU Public License</span>00034 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>00035 <span class="comment">//*****************************************************************************</span><span class="comment"></span>00036 <span class="comment">//@{</span>00037 <span class="comment"></span>00038 <span class="preprocessor">#ifndef NETSTACK_H</span>00039 <span class="preprocessor"></span><span class="preprocessor">#define NETSTACK_H</span>00040 <span class="preprocessor"></span>00041 <span class="preprocessor">#include "<a class="code" href="net_8h.html">net.h</a>"</span>00042 <span class="preprocessor">#include "<a class="code" href="arp_8h.html">arp.h</a>"</span>00043 <span class="preprocessor">#include "<a class="code" href="icmp_8h.html">icmp.h</a>"</span>00044 <span class="preprocessor">#include "<a class="code" href="ip_8h.html">ip.h</a>"</span>00045 <span class="preprocessor">#include "<a class="code" href="nic_8h.html">nic.h</a>"</span>00046 00047 <span class="comment">//#define NETSTACK_DEBUG</span>00048 <span class="comment"></span>00049 <span class="comment">/// NET_BUFFERSIZE is the common receive/process/transmit buffer.</span>00050 <span class="comment">/// - You may override the default NET_BUFFERSIZE by defining an alternate value in global.h.</span>00051 <span class="comment">/// - Network packets larger than NET_BUFFERSIZE will not be accepted.</span>00052 <span class="comment"></span><span class="preprocessor">#ifndef NETSTACK_BUFFERSIZE</span><a name="l00053"></a><a class="code" href="group__netstack.html#ga6">00053</a> <span class="preprocessor"></span><span class="preprocessor">#define NETSTACK_BUFFERSIZE (576+ETH_HEADER_LEN)</span>00054 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00055 <span class="preprocessor"></span><span class="comment"></span>00056 <span class="comment">/// netstackInit prepares the network interface for use and should be called</span>00057 <span class="comment">/// once at the beginning of the user program.</span>00058 <span class="comment">/// \note Use ipSetAddress() to change network parameters in mid-run.</span>00059 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__netstack.html#ga0">netstackInit</a>(uint32_t ipaddress, uint32_t netmask, uint32_t gatewayip);00060 <span class="comment"></span>00061 <span class="comment">/// netstackGetBuffer returns a pointer to the common receive/process/transmit buffer.</span>00062 <span class="comment"></span>u08* <a class="code" href="group__netstack.html#ga1">netstackGetBuffer</a>(<span class="keywordtype">void</span>);00063 <span class="comment"></span>00064 <span class="comment">/// netstackService should be called in the main loop of the user program.</span>00065 <span class="comment">/// The function will process one received network packet per call.</span>00066 <span class="comment">/// The return value is the length of the packet processed, or zero if no</span>00067 <span class="comment">/// packet was processed.</span>00068 <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="group__netstack.html#ga2">netstackService</a>(<span class="keywordtype">void</span>);00069 <span class="comment"></span>00070 <span class="comment">/// netstackIPProcess handles distribution of IP received packets.</span>00071 <span class="comment">///</span>00072 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__netstack.html#ga3">netstackIPProcess</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, ip_hdr* packet);00073 <span class="comment"></span>00074 <span class="comment">/// This weakly-defined function is the default handler for incoming UDP/IP packets.</span>00075 <span class="comment">/// Users should define this same function in user code (same name and arguments) to</span>00076 <span class="comment">/// override this default handler and get access to the received packets.</span>00077 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__netstack.html#ga4">netstackUDPIPProcess</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, udpip_hdr* packet) __attribute__ ((weak));00078 <span class="comment"></span>00079 <span class="comment">/// This weakly-defined function is the default handler for incoming TCP/IP packets.</span>00080 <span class="comment">/// Users should define this same function in user code (same name and arguments) to</span>00081 <span class="comment">/// override this default handler and get access to the received packets.</span>00082 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__netstack.html#ga5">netstackTCPIPProcess</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, tcpip_hdr* packet) __attribute__ ((weak));00083 00084 <span class="preprocessor">#endif</span>00085 <span class="preprocessor"></span><span class="comment">//@}</span></span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -