/a00425_source.html
HTML | 2258 lines | 2257 code | 0 blank | 1 comment | 0 complexity | 3af8a923dfb86a3e41ca95c813e6644b MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <title>Contiki 2.5: core/net/uip6.c Source File</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <link href="doxygen.css" rel="stylesheet" type="text/css"/>
- </head>
- <body>
- <!-- Generated by Doxygen 1.6.1 -->
- <div class="navigation" id="top">
- <div class="tabs">
- <ul>
- <li><a href="main.html"><span>Main Page</span></a></li>
- <li><a href="pages.html"><span>Related Pages</span></a></li>
- <li><a href="modules.html"><span>Modules</span></a></li>
- <li><a href="annotated.html"><span>Data Structures</span></a></li>
- <li class="current"><a href="files.html"><span>Files</span></a></li>
- <li><a href="dirs.html"><span>Directories</span></a></li>
- <li><a href="examples.html"><span>Examples</span></a></li>
- </ul>
- </div>
- <div class="tabs">
- <ul>
- <li><a href="files.html"><span>File List</span></a></li>
- <li><a href="globals.html"><span>Globals</span></a></li>
- </ul>
- </div>
- <div class="navpath"><a class="el" href="dir_783dcb2b4bcfa12326370fa26c216025.html">core</a> » <a class="el" href="dir_0966c75b31335e5cb5b37dbb7a80da85.html">net</a>
- </div>
- </div>
- <div class="contents">
- <h1>uip6.c</h1><a href="a00425.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
- <a name="l00002"></a>00002 <span class="comment"> * \addtogroup uip6</span>
- <a name="l00003"></a>00003 <span class="comment"> * @{</span>
- <a name="l00004"></a>00004 <span class="comment"> */</span>
- <a name="l00005"></a>00005 <span class="comment"></span>
- <a name="l00006"></a>00006 <span class="comment">/**</span>
- <a name="l00007"></a>00007 <span class="comment"> * \file</span>
- <a name="l00008"></a>00008 <span class="comment"> * The uIP TCP/IPv6 stack code.</span>
- <a name="l00009"></a>00009 <span class="comment"> *</span>
- <a name="l00010"></a>00010 <span class="comment"> * \author Adam Dunkels <adam@sics.se></span>
- <a name="l00011"></a>00011 <span class="comment"> * \author Julien Abeille <jabeille@cisco.com> (IPv6 related code)</span>
- <a name="l00012"></a>00012 <span class="comment"> * \author Mathilde Durvy <mdurvy@cisco.com> (IPv6 related code)</span>
- <a name="l00013"></a>00013 <span class="comment"> */</span>
- <a name="l00014"></a>00014 <span class="comment">/*</span>
- <a name="l00015"></a>00015 <span class="comment"> * Copyright (c) 2001-2003, Adam Dunkels.</span>
- <a name="l00016"></a>00016 <span class="comment"> * All rights reserved.</span>
- <a name="l00017"></a>00017 <span class="comment"> *</span>
- <a name="l00018"></a>00018 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
- <a name="l00019"></a>00019 <span class="comment"> * modification, are permitted provided that the following conditions</span>
- <a name="l00020"></a>00020 <span class="comment"> * are met:</span>
- <a name="l00021"></a>00021 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
- <a name="l00022"></a>00022 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
- <a name="l00023"></a>00023 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
- <a name="l00024"></a>00024 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
- <a name="l00025"></a>00025 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
- <a name="l00026"></a>00026 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
- <a name="l00027"></a>00027 <span class="comment"> * products derived from this software without specific prior</span>
- <a name="l00028"></a>00028 <span class="comment"> * written permission.</span>
- <a name="l00029"></a>00029 <span class="comment"> *</span>
- <a name="l00030"></a>00030 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
- <a name="l00031"></a>00031 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
- <a name="l00032"></a>00032 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
- <a name="l00033"></a>00033 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
- <a name="l00034"></a>00034 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
- <a name="l00035"></a>00035 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
- <a name="l00036"></a>00036 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
- <a name="l00037"></a>00037 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
- <a name="l00038"></a>00038 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
- <a name="l00039"></a>00039 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
- <a name="l00040"></a>00040 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
- <a name="l00041"></a>00041 <span class="comment"> *</span>
- <a name="l00042"></a>00042 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
- <a name="l00043"></a>00043 <span class="comment"> *</span>
- <a name="l00044"></a>00044 <span class="comment"> * $Id: uip6.c,v 1.25 2011/01/04 22:11:37 joxe Exp $</span>
- <a name="l00045"></a>00045 <span class="comment"> *</span>
- <a name="l00046"></a>00046 <span class="comment"> */</span>
- <a name="l00047"></a>00047
- <a name="l00048"></a>00048 <span class="comment">/*</span>
- <a name="l00049"></a>00049 <span class="comment"> * uIP is a small implementation of the IP, UDP and TCP protocols (as</span>
- <a name="l00050"></a>00050 <span class="comment"> * well as some basic ICMP stuff). The implementation couples the IP,</span>
- <a name="l00051"></a>00051 <span class="comment"> * UDP, TCP and the application layers very tightly. To keep the size</span>
- <a name="l00052"></a>00052 <span class="comment"> * of the compiled code down, this code frequently uses the goto</span>
- <a name="l00053"></a>00053 <span class="comment"> * statement. While it would be possible to break the uip_process()</span>
- <a name="l00054"></a>00054 <span class="comment"> * function into many smaller functions, this would increase the code</span>
- <a name="l00055"></a>00055 <span class="comment"> * size because of the overhead of parameter passing and the fact that</span>
- <a name="l00056"></a>00056 <span class="comment"> * the optimier would not be as efficient.</span>
- <a name="l00057"></a>00057 <span class="comment"> *</span>
- <a name="l00058"></a>00058 <span class="comment"> * The principle is that we have a small buffer, called the uip_buf,</span>
- <a name="l00059"></a>00059 <span class="comment"> * in which the device driver puts an incoming packet. The TCP/IP</span>
- <a name="l00060"></a>00060 <span class="comment"> * stack parses the headers in the packet, and calls the</span>
- <a name="l00061"></a>00061 <span class="comment"> * application. If the remote host has sent data to the application,</span>
- <a name="l00062"></a>00062 <span class="comment"> * this data is present in the uip_buf and the application read the</span>
- <a name="l00063"></a>00063 <span class="comment"> * data from there. It is up to the application to put this data into</span>
- <a name="l00064"></a>00064 <span class="comment"> * a byte stream if needed. The application will not be fed with data</span>
- <a name="l00065"></a>00065 <span class="comment"> * that is out of sequence.</span>
- <a name="l00066"></a>00066 <span class="comment"> *</span>
- <a name="l00067"></a>00067 <span class="comment"> * If the application whishes to send data to the peer, it should put</span>
- <a name="l00068"></a>00068 <span class="comment"> * its data into the uip_buf. The uip_appdata pointer points to the</span>
- <a name="l00069"></a>00069 <span class="comment"> * first available byte. The TCP/IP stack will calculate the</span>
- <a name="l00070"></a>00070 <span class="comment"> * checksums, and fill in the necessary header fields and finally send</span>
- <a name="l00071"></a>00071 <span class="comment"> * the packet back to the peer.</span>
- <a name="l00072"></a>00072 <span class="comment"> */</span>
- <a name="l00073"></a>00073
- <a name="l00074"></a>00074 <span class="preprocessor">#include "<a class="code" href="a00424.html" title="Header file for the uIP TCP/IP stack.">net/uip.h</a>"</span>
- <a name="l00075"></a>00075 <span class="preprocessor">#include "<a class="code" href="a00431.html" title="Configuration options for uIP.">net/uipopt.h</a>"</span>
- <a name="l00076"></a>00076 <span class="preprocessor">#include "<a class="code" href="a00410.html" title="ICMPv6 echo request and error messages (RFC 4443).">net/uip-icmp6.h</a>"</span>
- <a name="l00077"></a>00077 <span class="preprocessor">#include "<a class="code" href="a00412.html" title="Neighbor discovery (RFC 4861).">net/uip-nd6.h</a>"</span>
- <a name="l00078"></a>00078 <span class="preprocessor">#include "<a class="code" href="a00404.html" title="Network interface and stateless autoconfiguration (RFC 4862).">net/uip-ds6.h</a>"</span>
- <a name="l00079"></a>00079
- <a name="l00080"></a>00080 <span class="preprocessor">#include <string.h></span>
- <a name="l00081"></a>00081
- <a name="l00082"></a>00082 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00083"></a>00083 <span class="comment">/* For Debug, logging, statistics */</span>
- <a name="l00084"></a>00084 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00085"></a>00085
- <a name="l00086"></a>00086 <span class="preprocessor">#define DEBUG 0</span>
- <a name="l00087"></a>00087 <span class="preprocessor"></span><span class="preprocessor">#if DEBUG</span>
- <a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#include <stdio.h></span>
- <a name="l00089"></a>00089 <span class="preprocessor">#define PRINTF(...) printf(__VA_ARGS__)</span>
- <a name="l00090"></a>00090 <span class="preprocessor"></span><span class="preprocessor">#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((u8_t *)addr)[0], ((u8_t *)addr)[1], ((u8_t *)addr)[2], ((u8_t *)addr)[3], ((u8_t *)addr)[4], ((u8_t *)addr)[5], ((u8_t *)addr)[6], ((u8_t *)addr)[7], ((u8_t *)addr)[8], ((u8_t *)addr)[9], ((u8_t *)addr)[10], ((u8_t *)addr)[11], ((u8_t *)addr)[12], ((u8_t *)addr)[13], ((u8_t *)addr)[14], ((u8_t *)addr)[15])</span>
- <a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",lladdr->addr[0], lladdr->addr[1], lladdr->addr[2], lladdr->addr[3],lladdr->addr[4], lladdr->addr[5])</span>
- <a name="l00092"></a>00092 <span class="preprocessor"></span><span class="preprocessor">#else</span>
- <a name="l00093"></a>00093 <span class="preprocessor"></span><span class="preprocessor">#define PRINTF(...)</span>
- <a name="l00094"></a>00094 <span class="preprocessor"></span><span class="preprocessor">#define PRINT6ADDR(addr)</span>
- <a name="l00095"></a>00095 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
- <a name="l00096"></a>00096 <span class="preprocessor"></span>
- <a name="l00097"></a>00097 <span class="preprocessor">#if UIP_CONF_IPV6_RPL</span>
- <a name="l00098"></a>00098 <span class="preprocessor"></span><span class="keywordtype">void</span> uip_rpl_input(<span class="keywordtype">void</span>);
- <a name="l00099"></a>00099 <span class="preprocessor">#endif </span><span class="comment">/* UIP_CONF_IPV6_RPL */</span>
- <a name="l00100"></a>00100
- <a name="l00101"></a>00101 <span class="preprocessor">#if UIP_LOGGING == 1</span>
- <a name="l00102"></a>00102 <span class="preprocessor"></span><span class="preprocessor">#include <stdio.h></span>
- <a name="l00103"></a>00103 <span class="keywordtype">void</span> <a class="code" href="a01589.html#gab58e1ceb7cb73ca2bcd73146b6c1b4e7" title="Print out a uIP log message.">uip_log</a>(<span class="keywordtype">char</span> *msg);
- <a name="l00104"></a>00104 <span class="preprocessor">#define UIP_LOG(m) uip_log(m)</span>
- <a name="l00105"></a>00105 <span class="preprocessor"></span><span class="preprocessor">#else</span>
- <a name="l00106"></a>00106 <span class="preprocessor"></span><span class="preprocessor">#define UIP_LOG(m)</span>
- <a name="l00107"></a>00107 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* UIP_LOGGING == 1 */</span>
- <a name="l00108"></a>00108
- <a name="l00109"></a>00109 <span class="preprocessor">#if UIP_STATISTICS == 1</span>
- <a name="l00110"></a>00110 <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="a00118.html" title="The structure holding the TCP/IP statistics that are gathered if UIP_STATISTICS is...">uip_stats</a> uip_stat;
- <a name="l00111"></a>00111 <span class="preprocessor">#endif </span><span class="comment">/* UIP_STATISTICS == 1 */</span>
- <a name="l00112"></a>00112
- <a name="l00113"></a>00113
- <a name="l00114"></a>00114 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00115"></a>00115 <span class="comment">/** @{ \name Layer 2 variables */</span>
- <a name="l00116"></a>00116 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00117"></a>00117 <span class="comment">/** Host L2 address */</span>
- <a name="l00118"></a>00118 <span class="preprocessor">#if UIP_CONF_LL_802154</span>
- <a name="l00119"></a>00119 <span class="preprocessor"></span><a class="code" href="a00102.html" title="802.3 address">uip_lladdr_t</a> <a class="code" href="a01684.html#ga89bf167a9f1014d2d78754742eb7e06d" title="Host L2 address.">uip_lladdr</a>;
- <a name="l00120"></a>00120 <span class="preprocessor">#else </span><span class="comment">/*UIP_CONF_LL_802154*/</span>
- <a name="l00121"></a><a class="code" href="a01685.html#ga4084552512a9e2a0678f6a17fefb1a60">00121</a> <a class="code" href="a00102.html" title="802.3 address">uip_lladdr_t</a> <a class="code" href="a01684.html#ga89bf167a9f1014d2d78754742eb7e06d" title="Host L2 address.">uip_lladdr</a> = {{0x00,0x06,0x98,0x00,0x02,0x32}};
- <a name="l00122"></a>00122 <span class="preprocessor">#endif </span><span class="comment">/*UIP_CONF_LL_802154*/</span>
- <a name="l00123"></a>00123 <span class="comment">/** @} */</span>
- <a name="l00124"></a>00124
- <a name="l00125"></a>00125 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00126"></a>00126 <span class="comment">/** @{ \name Layer 3 variables */</span>
- <a name="l00127"></a>00127 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00128"></a>00128 <span class="comment">/**</span>
- <a name="l00129"></a>00129 <span class="comment"> * \brief Type of the next header in IPv6 header or extension headers</span>
- <a name="l00130"></a>00130 <span class="comment"> *</span>
- <a name="l00131"></a>00131 <span class="comment"> * Can be the next header field in the IPv6 header or in an extension header.</span>
- <a name="l00132"></a>00132 <span class="comment"> * When doing fragment reassembly, we must change the value of the next header</span>
- <a name="l00133"></a>00133 <span class="comment"> * field in the header before the fragmentation header, hence we need a pointer</span>
- <a name="l00134"></a>00134 <span class="comment"> * to this field.</span>
- <a name="l00135"></a>00135 <span class="comment"> */</span>
- <a name="l00136"></a><a class="code" href="a01685.html#gaa605d238ba40e21d7200fe94d6abc46d">00136</a> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *<a class="code" href="a01685.html#gaa605d238ba40e21d7200fe94d6abc46d" title="Type of the next header in IPv6 header or extension headers.">uip_next_hdr</a>;<span class="comment"></span>
- <a name="l00137"></a>00137 <span class="comment">/** \brief bitmap we use to record which IPv6 headers we have already seen */</span>
- <a name="l00138"></a><a class="code" href="a01685.html#ga7d944013e7b02d0a5bcba53bf624aaef">00138</a> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> <a class="code" href="a01685.html#ga7d944013e7b02d0a5bcba53bf624aaef" title="bitmap we use to record which IPv6 headers we have already seen">uip_ext_bitmap</a> = 0;<span class="comment"></span>
- <a name="l00139"></a>00139 <span class="comment">/**</span>
- <a name="l00140"></a>00140 <span class="comment"> * \brief length of the extension headers read. updated each time we process</span>
- <a name="l00141"></a>00141 <span class="comment"> * a header</span>
- <a name="l00142"></a>00142 <span class="comment"> */</span>
- <a name="l00143"></a><a class="code" href="a01685.html#ga1c9ed2d0cf3e1b814dc19b76487bed50">00143</a> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> <a class="code" href="a01577.html#ga1c9ed2d0cf3e1b814dc19b76487bed50" title="The length of the extension headers.">uip_ext_len</a> = 0;<span class="comment"></span>
- <a name="l00144"></a>00144 <span class="comment">/** \brief length of the header options read */</span>
- <a name="l00145"></a><a class="code" href="a01685.html#ga03780ccf09de63153b3b10c5d11875ab">00145</a> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> <a class="code" href="a01685.html#ga03780ccf09de63153b3b10c5d11875ab" title="length of the header options read">uip_ext_opt_offset</a> = 0;<span class="comment"></span>
- <a name="l00146"></a>00146 <span class="comment">/** @} */</span>
- <a name="l00147"></a>00147
- <a name="l00148"></a>00148 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00149"></a>00149 <span class="comment">/* Buffers */</span>
- <a name="l00150"></a>00150 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00151"></a>00151 <span class="comment">/** \name Buffer defines</span>
- <a name="l00152"></a>00152 <span class="comment"> * @{</span>
- <a name="l00153"></a>00153 <span class="comment"> */</span>
- <a name="l00154"></a>00154 <span class="preprocessor">#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])</span>
- <a name="l00155"></a>00155 <span class="preprocessor"></span><span class="preprocessor">#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])</span>
- <a name="l00156"></a>00156 <span class="preprocessor"></span><span class="preprocessor">#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00157"></a>00157 <span class="preprocessor"></span><span class="preprocessor">#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00158"></a>00158 <span class="preprocessor"></span><span class="preprocessor">#define UIP_TCP_BUF ((struct uip_tcp_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00159"></a>00159 <span class="preprocessor"></span><span class="preprocessor">#define UIP_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00160"></a>00160 <span class="preprocessor"></span><span class="preprocessor">#define UIP_ROUTING_BUF ((struct uip_routing_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00161"></a>00161 <span class="preprocessor"></span><span class="preprocessor">#define UIP_FRAG_BUF ((struct uip_frag_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00162"></a>00162 <span class="preprocessor"></span><span class="preprocessor">#define UIP_HBHO_BUF ((struct uip_hbho_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00163"></a>00163 <span class="preprocessor"></span><span class="preprocessor">#define UIP_DESTO_BUF ((struct uip_desto_hdr *)&uip_buf[uip_l2_l3_hdr_len])</span>
- <a name="l00164"></a>00164 <span class="preprocessor"></span><span class="preprocessor">#define UIP_EXT_HDR_OPT_BUF ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])</span>
- <a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">#define UIP_EXT_HDR_OPT_PADN_BUF ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])</span>
- <a name="l00166"></a>00166 <span class="preprocessor"></span><span class="preprocessor">#define UIP_ICMP6_ERROR_BUF ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len])</span>
- <a name="l00167"></a>00167 <span class="preprocessor"></span><span class="comment">/** @} */</span><span class="comment"></span>
- <a name="l00168"></a>00168 <span class="comment">/** \name Buffer variables</span>
- <a name="l00169"></a>00169 <span class="comment"> * @{</span>
- <a name="l00170"></a>00170 <span class="comment"> */</span><span class="comment"></span>
- <a name="l00171"></a>00171 <span class="comment">/** Packet buffer for incoming and outgoing packets */</span>
- <a name="l00172"></a>00172 <span class="preprocessor">#ifndef UIP_CONF_EXTERNAL_BUFFER</span>
- <a name="l00173"></a><a class="code" href="a01685.html#gae7f37f0b1fb5172aad84a32067c4ccc7">00173</a> <span class="preprocessor"></span><a class="code" href="a00091.html" title="The uIP packet buffer.">uip_buf_t</a> uip_aligned_buf;
- <a name="l00174"></a>00174 <span class="preprocessor">#endif </span><span class="comment">/* UIP_CONF_EXTERNAL_BUFFER */</span>
- <a name="l00175"></a>00175
- <a name="l00176"></a>00176 <span class="comment">/* The uip_appdata pointer points to application data. */</span>
- <a name="l00177"></a><a class="code" href="a01685.html#ga561b8eda32e059d4e7397f776268cc63">00177</a> <span class="keywordtype">void</span> *<a class="code" href="a01684.html#ga561b8eda32e059d4e7397f776268cc63" title="Pointer to the application data in the packet buffer.">uip_appdata</a>;
- <a name="l00178"></a>00178 <span class="comment">/* The uip_appdata pointer points to the application data which is to be sent*/</span>
- <a name="l00179"></a>00179 <span class="keywordtype">void</span> *uip_sappdata;
- <a name="l00180"></a>00180
- <a name="l00181"></a>00181 <span class="preprocessor">#if UIP_URGDATA > 0</span>
- <a name="l00182"></a>00182 <span class="preprocessor"></span><span class="comment">/* The uip_urgdata pointer points to urgent data (out-of-band data), if present */</span>
- <a name="l00183"></a>00183 <span class="keywordtype">void</span> *uip_urgdata;
- <a name="l00184"></a>00184 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> uip_urglen, uip_surglen;
- <a name="l00185"></a>00185 <span class="preprocessor">#endif </span><span class="comment">/* UIP_URGDATA > 0 */</span>
- <a name="l00186"></a>00186
- <a name="l00187"></a>00187 <span class="comment">/* The uip_len is either 8 or 16 bits, depending on the maximum packet size.*/</span>
- <a name="l00188"></a><a class="code" href="a01685.html#ga12a33f0c09711167bdf3dd7d7cf8c5a1">00188</a> <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> <a class="code" href="a01684.html#ga12a33f0c09711167bdf3dd7d7cf8c5a1" title="The length of the packet in the uip_buf buffer.">uip_len</a>, uip_slen;<span class="comment"></span>
- <a name="l00189"></a>00189 <span class="comment">/** @} */</span>
- <a name="l00190"></a>00190
- <a name="l00191"></a>00191 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00192"></a>00192 <span class="comment">/** @{ \name General variables */</span>
- <a name="l00193"></a>00193 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00194"></a>00194
- <a name="l00195"></a>00195 <span class="comment">/* The uip_flags variable is used for communication between the TCP/IP stack</span>
- <a name="l00196"></a>00196 <span class="comment">and the application program. */</span>
- <a name="l00197"></a>00197 <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> uip_flags;
- <a name="l00198"></a>00198
- <a name="l00199"></a>00199 <span class="comment">/* uip_conn always points to the current connection (set to NULL for UDP). */</span>
- <a name="l00200"></a><a class="code" href="a01685.html#ga788ffac72342f6172343d7f8099cbe1a">00200</a> <span class="keyword">struct </span><a class="code" href="a00092.html" title="Representation of a uIP TCP connection.">uip_conn</a> *<a class="code" href="a00092.html" title="Representation of a uIP TCP connection.">uip_conn</a>;
- <a name="l00201"></a>00201
- <a name="l00202"></a>00202 <span class="comment">/* Temporary variables. */</span>
- <a name="l00203"></a>00203 <span class="preprocessor">#if (UIP_TCP || UIP_UDP)</span>
- <a name="l00204"></a>00204 <span class="preprocessor"></span><span class="keyword">static</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> c;
- <a name="l00205"></a>00205 <span class="preprocessor">#endif</span>
- <a name="l00206"></a>00206 <span class="preprocessor"></span>
- <a name="l00207"></a>00207 <span class="preprocessor">#if UIP_ACTIVE_OPEN || UIP_UDP</span>
- <a name="l00208"></a>00208 <span class="preprocessor"></span><span class="comment">/* Keeps track of the last port used for a new connection. */</span>
- <a name="l00209"></a>00209 <span class="keyword">static</span> <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> lastport;
- <a name="l00210"></a>00210 <span class="preprocessor">#endif </span><span class="comment">/* UIP_ACTIVE_OPEN || UIP_UDP */</span>
- <a name="l00211"></a>00211 <span class="comment">/** @} */</span>
- <a name="l00212"></a>00212
- <a name="l00213"></a>00213 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00214"></a>00214 <span class="comment">/* TCP */</span>
- <a name="l00215"></a>00215 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00216"></a>00216 <span class="comment">/** \name TCP defines</span>
- <a name="l00217"></a>00217 <span class="comment"> *@{</span>
- <a name="l00218"></a>00218 <span class="comment"> */</span>
- <a name="l00219"></a>00219 <span class="comment">/* Structures and definitions. */</span>
- <a name="l00220"></a>00220 <span class="preprocessor">#define TCP_FIN 0x01</span>
- <a name="l00221"></a>00221 <span class="preprocessor"></span><span class="preprocessor">#define TCP_SYN 0x02</span>
- <a name="l00222"></a>00222 <span class="preprocessor"></span><span class="preprocessor">#define TCP_RST 0x04</span>
- <a name="l00223"></a>00223 <span class="preprocessor"></span><span class="preprocessor">#define TCP_PSH 0x08</span>
- <a name="l00224"></a>00224 <span class="preprocessor"></span><span class="preprocessor">#define TCP_ACK 0x10</span>
- <a name="l00225"></a>00225 <span class="preprocessor"></span><span class="preprocessor">#define TCP_URG 0x20</span>
- <a name="l00226"></a>00226 <span class="preprocessor"></span><span class="preprocessor">#define TCP_CTL 0x3f</span>
- <a name="l00227"></a>00227 <span class="preprocessor"></span>
- <a name="l00228"></a>00228 <span class="preprocessor">#define TCP_OPT_END 0 </span><span class="comment">/* End of TCP options list */</span>
- <a name="l00229"></a>00229 <span class="preprocessor">#define TCP_OPT_NOOP 1 </span><span class="comment">/* "No-operation" TCP option */</span>
- <a name="l00230"></a>00230 <span class="preprocessor">#define TCP_OPT_MSS 2 </span><span class="comment">/* Maximum segment size TCP option */</span>
- <a name="l00231"></a>00231
- <a name="l00232"></a>00232 <span class="preprocessor">#define TCP_OPT_MSS_LEN 4 </span><span class="comment">/* Length of TCP MSS option. */</span>
- <a name="l00233"></a>00233 <span class="comment">/** @} */</span><span class="comment"></span>
- <a name="l00234"></a>00234 <span class="comment">/** \name TCP variables</span>
- <a name="l00235"></a>00235 <span class="comment"> *@{</span>
- <a name="l00236"></a>00236 <span class="comment"> */</span>
- <a name="l00237"></a>00237 <span class="preprocessor">#if UIP_TCP</span>
- <a name="l00238"></a>00238 <span class="preprocessor"></span><span class="comment">/* The uip_conns array holds all TCP connections. */</span>
- <a name="l00239"></a>00239 <span class="keyword">struct </span>uip_conn uip_conns[<a class="code" href="a01585.html#gaf5fe83be78b78b9e7d9e7f1e34ab1cc5" title="The maximum number of simultaneously open TCP connections.">UIP_CONNS</a>];
- <a name="l00240"></a>00240
- <a name="l00241"></a>00241 <span class="comment">/* The uip_listenports list all currently listning ports. */</span>
- <a name="l00242"></a>00242 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> uip_listenports[<a class="code" href="a01585.html#ga8f4ebd8ef6c0ea665ed351d87fec09fd" title="The maximum number of simultaneously listening TCP ports.">UIP_LISTENPORTS</a>];
- <a name="l00243"></a>00243
- <a name="l00244"></a>00244 <span class="comment">/* The iss variable is used for the TCP initial sequence number. */</span>
- <a name="l00245"></a>00245 <span class="keyword">static</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> iss[4];
- <a name="l00246"></a>00246
- <a name="l00247"></a>00247 <span class="comment">/* Temporary variables. */</span>
- <a name="l00248"></a>00248 <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> <a class="code" href="a01684.html#ga2a0cf5d86c58fab216414ce59bf1fea1" title="4-byte array used for the 32-bit sequence number calculations.">uip_acc32</a>[4];
- <a name="l00249"></a>00249 <span class="keyword">static</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> opt;
- <a name="l00250"></a>00250 <span class="keyword">static</span> <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> tmp16;
- <a name="l00251"></a>00251 <span class="preprocessor">#endif </span><span class="comment">/* UIP_TCP */</span>
- <a name="l00252"></a>00252 <span class="comment">/** @} */</span>
- <a name="l00253"></a>00253
- <a name="l00254"></a>00254 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00255"></a>00255 <span class="comment">/** @{ \name UDP variables */</span>
- <a name="l00256"></a>00256 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00257"></a>00257 <span class="preprocessor">#if UIP_UDP</span>
- <a name="l00258"></a><a class="code" href="a01685.html#ga210f227119fc972e6222c9cb452e15a9">00258</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="a00119.html" title="Representation of a uIP UDP connection.">uip_udp_conn</a> *<a class="code" href="a00119.html" title="Representation of a uIP UDP connection.">uip_udp_conn</a>;
- <a name="l00259"></a>00259 <span class="keyword">struct </span>uip_udp_conn uip_udp_conns[<a class="code" href="a01584.html#ga196379ceb1219a99f4495e41ccc9bbfb" title="The maximum amount of concurrent UDP connections.">UIP_UDP_CONNS</a>];
- <a name="l00260"></a>00260 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span>
- <a name="l00261"></a>00261 <span class="comment">/** @} */</span>
- <a name="l00262"></a>00262
- <a name="l00263"></a>00263 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
- <a name="l00264"></a>00264 <span class="comment">/** @{ \name ICMPv6 variables */</span>
- <a name="l00265"></a>00265 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00266"></a>00266 <span class="preprocessor">#if UIP_CONF_ICMP6</span>
- <a name="l00267"></a>00267 <span class="preprocessor"></span><span class="comment">/** single possible icmpv6 "connection" */</span>
- <a name="l00268"></a>00268 <span class="keyword">struct </span>uip_icmp6_conn uip_icmp6_conns;
- <a name="l00269"></a>00269 <span class="preprocessor">#endif </span><span class="comment">/*UIP_CONF_ICMP6*/</span>
- <a name="l00270"></a>00270 <span class="comment">/** @} */</span>
- <a name="l00271"></a>00271
- <a name="l00272"></a>00272 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00273"></a>00273 <span class="comment">/* Functions */</span>
- <a name="l00274"></a>00274 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00275"></a>00275 <span class="preprocessor">#if (!UIP_ARCH_ADD32 && UIP_TCP)</span>
- <a name="l00276"></a>00276 <span class="preprocessor"></span><span class="keywordtype">void</span>
- <a name="l00277"></a>00277 <a class="code" href="a01684.html#ga6832e4d2d046536b6472f7ac92340f68" title="Carry out a 32-bit addition.">uip_add32</a>(<a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *op32, <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> op16)
- <a name="l00278"></a>00278 {
- <a name="l00279"></a>00279 <a class="code" href="a01684.html#ga2a0cf5d86c58fab216414ce59bf1fea1" title="4-byte array used for the 32-bit sequence number calculations.">uip_acc32</a>[3] = op32[3] + (op16 & 0xff);
- <a name="l00280"></a>00280 <a class="code" href="a01684.html#ga2a0cf5d86c58fab216414ce59bf1fea1" title="4-byte array used for the 32-bit sequence number calculations.">uip_acc32</a>[2] = op32[2] + (op16 >> 8);
- <a name="l00281"></a>00281 uip_acc32[1] = op32[1];
- <a name="l00282"></a>00282 uip_acc32[0] = op32[0];
- <a name="l00283"></a>00283
- <a name="l00284"></a>00284 <span class="keywordflow">if</span>(uip_acc32[2] < (op16 >> 8)) {
- <a name="l00285"></a>00285 ++uip_acc32[1];
- <a name="l00286"></a>00286 <span class="keywordflow">if</span>(uip_acc32[1] == 0) {
- <a name="l00287"></a>00287 ++uip_acc32[0];
- <a name="l00288"></a>00288 }
- <a name="l00289"></a>00289 }
- <a name="l00290"></a>00290
- <a name="l00291"></a>00291
- <a name="l00292"></a>00292 <span class="keywordflow">if</span>(uip_acc32[3] < (op16 & 0xff)) {
- <a name="l00293"></a>00293 ++uip_acc32[2];
- <a name="l00294"></a>00294 <span class="keywordflow">if</span>(uip_acc32[2] == 0) {
- <a name="l00295"></a>00295 ++uip_acc32[1];
- <a name="l00296"></a>00296 <span class="keywordflow">if</span>(uip_acc32[1] == 0) {
- <a name="l00297"></a>00297 ++uip_acc32[0];
- <a name="l00298"></a>00298 }
- <a name="l00299"></a>00299 }
- <a name="l00300"></a>00300 }
- <a name="l00301"></a>00301 }
- <a name="l00302"></a>00302
- <a name="l00303"></a>00303 <span class="preprocessor">#endif </span><span class="comment">/* UIP_ARCH_ADD32 && UIP_TCP */</span>
- <a name="l00304"></a>00304
- <a name="l00305"></a>00305 <span class="preprocessor">#if ! UIP_ARCH_CHKSUM</span>
- <a name="l00306"></a>00306 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00307"></a>00307 <span class="keyword">static</span> <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00308"></a>00308 chksum(<a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> sum, <span class="keyword">const</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *data, <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> len)
- <a name="l00309"></a>00309 {
- <a name="l00310"></a>00310 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> t;
- <a name="l00311"></a>00311 <span class="keyword">const</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *dataptr;
- <a name="l00312"></a>00312 <span class="keyword">const</span> <a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *last_byte;
- <a name="l00313"></a>00313
- <a name="l00314"></a>00314 dataptr = data;
- <a name="l00315"></a>00315 last_byte = data + len - 1;
- <a name="l00316"></a>00316
- <a name="l00317"></a>00317 <span class="keywordflow">while</span>(dataptr < last_byte) { <span class="comment">/* At least two more bytes */</span>
- <a name="l00318"></a>00318 t = (dataptr[0] << 8) + dataptr[1];
- <a name="l00319"></a>00319 sum += t;
- <a name="l00320"></a>00320 <span class="keywordflow">if</span>(sum < t) {
- <a name="l00321"></a>00321 sum++; <span class="comment">/* carry */</span>
- <a name="l00322"></a>00322 }
- <a name="l00323"></a>00323 dataptr += 2;
- <a name="l00324"></a>00324 }
- <a name="l00325"></a>00325
- <a name="l00326"></a>00326 <span class="keywordflow">if</span>(dataptr == last_byte) {
- <a name="l00327"></a>00327 t = (dataptr[0] << 8) + 0;
- <a name="l00328"></a>00328 sum += t;
- <a name="l00329"></a>00329 <span class="keywordflow">if</span>(sum < t) {
- <a name="l00330"></a>00330 sum++; <span class="comment">/* carry */</span>
- <a name="l00331"></a>00331 }
- <a name="l00332"></a>00332 }
- <a name="l00333"></a>00333
- <a name="l00334"></a>00334 <span class="comment">/* Return sum in host byte order. */</span>
- <a name="l00335"></a>00335 <span class="keywordflow">return</span> sum;
- <a name="l00336"></a>00336 }
- <a name="l00337"></a>00337 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00338"></a>00338 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00339"></a><a class="code" href="a01578.html#gab6683dd83fe1c8de9a24086d4b69e907">00339</a> <a class="code" href="a01684.html#gab6683dd83fe1c8de9a24086d4b69e907" title="Calculate the Internet checksum over a buffer.">uip_chksum</a>(<a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> *data, <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> len)
- <a name="l00340"></a>00340 {
- <a name="l00341"></a>00341 <span class="keywordflow">return</span> <a class="code" href="a01684.html#gae4394b6b3cd81f73b0e64a93e0558e00" title="Convert 16-bit quantity from host byte order to network byte order.">uip_htons</a>(chksum(0, (<a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *)data, len));
- <a name="l00342"></a>00342 }
- <a name="l00343"></a>00343 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00344"></a>00344 <span class="preprocessor">#ifndef UIP_ARCH_IPCHKSUM</span>
- <a name="l00345"></a>00345 <span class="preprocessor"></span><a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00346"></a><a class="code" href="a01578.html#ga2addf34c7d457c1a7899a7e2171ef1e9">00346</a> <a class="code" href="a01684.html#ga2addf34c7d457c1a7899a7e2171ef1e9" title="Calculate the IP header checksum of the packet header in uip_buf.">uip_ipchksum</a>(<span class="keywordtype">void</span>)
- <a name="l00347"></a>00347 {
- <a name="l00348"></a>00348 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> sum;
- <a name="l00349"></a>00349
- <a name="l00350"></a>00350 sum = chksum(0, &uip_buf[<a class="code" href="a01589.html#gae6f4a2453dbd8bc60e6a82774552366a" title="The link level header length.">UIP_LLH_LEN</a>], UIP_IPH_LEN);
- <a name="l00351"></a>00351 PRINTF(<span class="stringliteral">"uip_ipchksum: sum 0x%04x\n"</span>, sum);
- <a name="l00352"></a>00352 <span class="keywordflow">return</span> (sum == 0) ? 0xffff : <a class="code" href="a01684.html#gae4394b6b3cd81f73b0e64a93e0558e00" title="Convert 16-bit quantity from host byte order to network byte order.">uip_htons</a>(sum);
- <a name="l00353"></a>00353 }
- <a name="l00354"></a>00354 <span class="preprocessor">#endif</span>
- <a name="l00355"></a>00355 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00356"></a>00356 <span class="keyword">static</span> <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00357"></a>00357 upper_layer_chksum(<a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> proto)
- <a name="l00358"></a>00358 {
- <a name="l00359"></a>00359 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> upper_layer_len;
- <a name="l00360"></a>00360 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a> sum;
- <a name="l00361"></a>00361
- <a name="l00362"></a>00362 upper_layer_len = (((<a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>)(<a class="code" href="a01685.html#gaf966537cf73ee5973da59bba6b21b731" title="Pointer to IP header.">UIP_IP_BUF</a>->len[0]) << 8) + <a class="code" href="a01685.html#gaf966537cf73ee5973da59bba6b21b731" title="Pointer to IP header.">UIP_IP_BUF</a>->len[1] - <a class="code" href="a01577.html#ga1c9ed2d0cf3e1b814dc19b76487bed50" title="The length of the extension headers.">uip_ext_len</a>) ;
- <a name="l00363"></a>00363
- <a name="l00364"></a>00364 <span class="comment">/* First sum pseudoheader. */</span>
- <a name="l00365"></a>00365 <span class="comment">/* IP protocol and length fields. This addition cannot carry. */</span>
- <a name="l00366"></a>00366 sum = upper_layer_len + proto;
- <a name="l00367"></a>00367 <span class="comment">/* Sum IP source and destination addresses. */</span>
- <a name="l00368"></a>00368 sum = chksum(sum, (<a class="code" href="a01668.html#ga4caecabca98b43919dd11be1c0d4cd8e" title="The 8-bit unsigned data type.">u8_t</a> *)&<a class="code" href="a01685.html#gaf966537cf73ee5973da59bba6b21b731" title="Pointer to IP header.">UIP_IP_BUF</a>->srcipaddr, 2 * <span class="keyword">sizeof</span>(<a class="code" href="a00106.html" title="Representation of an IP address.">uip_ipaddr_t</a>));
- <a name="l00369"></a>00369
- <a name="l00370"></a>00370 <span class="comment">/* Sum TCP header and data. */</span>
- <a name="l00371"></a>00371 sum = chksum(sum, &uip_buf[UIP_IPH_LEN + <a class="code" href="a01589.html#gae6f4a2453dbd8bc60e6a82774552366a" title="The link level header length.">UIP_LLH_LEN</a> + <a class="code" href="a01577.html#ga1c9ed2d0cf3e1b814dc19b76487bed50" title="The length of the extension headers.">uip_ext_len</a>],
- <a name="l00372"></a>00372 upper_layer_len);
- <a name="l00373"></a>00373
- <a name="l00374"></a>00374 <span class="keywordflow">return</span> (sum == 0) ? 0xffff : <a class="code" href="a01684.html#gae4394b6b3cd81f73b0e64a93e0558e00" title="Convert 16-bit quantity from host byte order to network byte order.">uip_htons</a>(sum);
- <a name="l00375"></a>00375 }
- <a name="l00376"></a>00376 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00377"></a>00377 <a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00378"></a><a class="code" href="a01685.html#ga5e6741b8bd3e0961fb87e3f85da27a7f">00378</a> <a class="code" href="a01684.html#ga5e6741b8bd3e0961fb87e3f85da27a7f" title="Calculate the ICMP checksum of the packet in uip_buf.">uip_icmp6chksum</a>(<span class="keywordtype">void</span>)
- <a name="l00379"></a>00379 {
- <a name="l00380"></a>00380 <span class="keywordflow">return</span> upper_layer_chksum(UIP_PROTO_ICMP6);
- <a name="l00381"></a>00381
- <a name="l00382"></a>00382 }
- <a name="l00383"></a>00383 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00384"></a>00384 <span class="preprocessor">#if UIP_TCP</span>
- <a name="l00385"></a>00385 <span class="preprocessor"></span><a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00386"></a>00386 <a class="code" href="a01684.html#ga85b65e38aa74eba18979156f97a94a87" title="Calculate the TCP checksum of the packet in uip_buf and uip_appdata.">uip_tcpchksum</a>(<span class="keywordtype">void</span>)
- <a name="l00387"></a>00387 {
- <a name="l00388"></a>00388 <span class="keywordflow">return</span> upper_layer_chksum(UIP_PROTO_TCP);
- <a name="l00389"></a>00389 }
- <a name="l00390"></a>00390 <span class="preprocessor">#endif </span><span class="comment">/* UIP_TCP */</span>
- <a name="l00391"></a>00391 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00392"></a>00392 <span class="preprocessor">#if UIP_UDP && UIP_UDP_CHECKSUMS</span>
- <a name="l00393"></a>00393 <span class="preprocessor"></span><a class="code" href="a01668.html#ga77570ac4fcab86864fa1916e55676da2" title="The 16-bit unsigned data type.">u16_t</a>
- <a name="l00394"></a>00394 <a class="code" href="a01684.html#ga7023a34ba9e9d03b5fbedbcb32924453" title="Calculate the UDP checksum of the packet in uip_buf and uip_appdata.">uip_udpchksum</a>(<span class="keywordtype">void</span>)
- <a name="l00395"></a>00395 {
- <a name="l00396"></a>00396 <span class="keywordflow">return</span> upper_layer_chksum(UIP_PROTO_UDP);
- <a name="l00397"></a>00397 }
- <a name="l00398"></a>00398 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP && UIP_UDP_CHECKSUMS */</span>
- <a name="l00399"></a>00399 <span class="preprocessor">#endif </span><span class="comment">/* UIP_ARCH_CHKSUM */</span>
- <a name="l00400"></a>00400 <span class="comment">/*---------------------------------------------------------------------------*/</span>
- <a name="l00401"></a>00401 <span class="keywordtype">void</span>
- <a name="l00402"></a><a class="code" href="a01685.html#gac48ed5f0d27721ef62a3ed02a5ad8d2e">00402</a> <a class="code" href="a01684.html#gac48ed5f0d27721ef62a3ed02a5ad8d2e" title="uIP initialization function.">uip_init</a>(<span class="keywordtype">void</span>)
- <a name="l00403"></a>00403 {
- <a name="l00404"></a>00404
- <a name="l00405"></a>00405 <a class="code" href="a01685.html#ga5527d94e75153109f16a3fb59491a7bb" title="Initialize data structures.">uip_ds6_init</a>();
- <a name="l00406"></a>00406
- <a name="l00407"></a>00407 <span class="preprocessor">#if UIP_TCP</span>
- <a name="l00408"></a>00408 <span class="preprocessor"></span> <span class="keywordflow">for</span>(c = 0; c < <a class="code" href="a01585.html#ga8f4ebd8ef6c0ea665ed351d87fec09fd" title="The maximum number of simultaneously listening TCP ports.">UIP_LISTENPORTS</a>; ++c) {
- <a name="l00409"></a>00409 uip_listenports[c] = 0;
- <a name="l00410"></a>00410 }
- <a name="l00411"></a>00411 <span class="keywordflow">for</span>(c = 0; c < <a class="code" href="a01585.html#gaf5fe83be78b78b9e7d9e7f1e34ab1cc5" title="The maximum number of simultan…
Large files files are truncated, but you can click here to view the full file