<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.16">
  <compounddef id="ip4__frag_8c" kind="file" language="C++">
    <compoundname>ip4_frag.c</compoundname>
    <includes refid="opt_8h" local="yes">net/opt.h</includes>
    <incdepgraph>
      <node id="17">
        <label>stdarg.h</label>
        <link refid="stdarg_8h"/>
      </node>
      <node id="18">
        <label>ubixos/kpanic.h</label>
        <link refid="kpanic_8h"/>
      </node>
      <node id="15">
        <label>sys/io.h</label>
        <link refid="io_8h"/>
      </node>
      <node id="8">
        <label>sys/select.h</label>
        <link refid="select_8h"/>
        <childnode refid="9" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>net/arch/cc.h</label>
        <link refid="cc_8h"/>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="12">
        <label>sys/_sigset.h</label>
        <link refid="__sigset_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="3">
        <label>net/lwipopts.h</label>
        <link refid="lwipopts_8h"/>
      </node>
      <node id="1">
        <label>C:/Dev/git/UbixOS/sys/net/core/ipv4/ip4_frag.c</label>
        <link refid="ip4__frag_8c"/>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="6">
        <label>sys/types.h</label>
        <link refid="include_2sys_2types_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="8" relation="include">
        </childnode>
      </node>
      <node id="5">
        <label>net/arch.h</label>
        <link refid="arch_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="13" relation="include">
        </childnode>
        <childnode refid="16" relation="include">
        </childnode>
        <childnode refid="18" relation="include">
        </childnode>
      </node>
      <node id="2">
        <label>net/opt.h</label>
        <link refid="opt_8h"/>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="16">
        <label>lib/kprintf.h</label>
        <link refid="kprintf_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="17" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>net/debug.h</label>
        <link refid="debug_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="9">
        <label>sys/cdefs.h</label>
        <link refid="cdefs_8h"/>
      </node>
      <node id="14">
        <label>ubixos/time.h</label>
        <link refid="time_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="15" relation="include">
        </childnode>
      </node>
      <node id="7">
        <label>sys/_types.h</label>
        <link refid="__types_8h"/>
      </node>
      <node id="10">
        <label>sys/_timespec.h</label>
        <link refid="__timespec_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="11">
        <label>sys/_timeval.h</label>
        <link refid="__timeval_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>This is the IPv4 packet segmentation and reassembly implementation. </para>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="7"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="8"><highlight class="comment"><sp/>*<sp/>Copyright<sp/>(c)<sp/>2001-2004<sp/>Swedish<sp/>Institute<sp/>of<sp/>Computer<sp/>Science.</highlight></codeline>
<codeline lineno="9"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="10"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="11"><highlight class="comment"><sp/>*<sp/>Redistribution<sp/>and<sp/>use<sp/>in<sp/>source<sp/>and<sp/>binary<sp/>forms,<sp/>with<sp/>or<sp/>without<sp/>modification,</highlight></codeline>
<codeline lineno="12"><highlight class="comment"><sp/>*<sp/>are<sp/>permitted<sp/>provided<sp/>that<sp/>the<sp/>following<sp/>conditions<sp/>are<sp/>met:</highlight></codeline>
<codeline lineno="13"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="14"><highlight class="comment"><sp/>*<sp/>1.<sp/>Redistributions<sp/>of<sp/>source<sp/>code<sp/>must<sp/>retain<sp/>the<sp/>above<sp/>copyright<sp/>notice,</highlight></codeline>
<codeline lineno="15"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer.</highlight></codeline>
<codeline lineno="16"><highlight class="comment"><sp/>*<sp/>2.<sp/>Redistributions<sp/>in<sp/>binary<sp/>form<sp/>must<sp/>reproduce<sp/>the<sp/>above<sp/>copyright<sp/>notice,</highlight></codeline>
<codeline lineno="17"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer<sp/>in<sp/>the<sp/>documentation</highlight></codeline>
<codeline lineno="18"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>and/or<sp/>other<sp/>materials<sp/>provided<sp/>with<sp/>the<sp/>distribution.</highlight></codeline>
<codeline lineno="19"><highlight class="comment"><sp/>*<sp/>3.<sp/>The<sp/>name<sp/>of<sp/>the<sp/>author<sp/>may<sp/>not<sp/>be<sp/>used<sp/>to<sp/>endorse<sp/>or<sp/>promote<sp/>products</highlight></codeline>
<codeline lineno="20"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>derived<sp/>from<sp/>this<sp/>software<sp/>without<sp/>specific<sp/>prior<sp/>written<sp/>permission.</highlight></codeline>
<codeline lineno="21"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="22"><highlight class="comment"><sp/>*<sp/>THIS<sp/>SOFTWARE<sp/>IS<sp/>PROVIDED<sp/>BY<sp/>THE<sp/>AUTHOR<sp/>``AS<sp/>IS&apos;&apos;<sp/>AND<sp/>ANY<sp/>EXPRESS<sp/>OR<sp/>IMPLIED</highlight></codeline>
<codeline lineno="23"><highlight class="comment"><sp/>*<sp/>WARRANTIES,<sp/>INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>THE<sp/>IMPLIED<sp/>WARRANTIES<sp/>OF</highlight></codeline>
<codeline lineno="24"><highlight class="comment"><sp/>*<sp/>MERCHANTABILITY<sp/>AND<sp/>FITNESS<sp/>FOR<sp/>A<sp/>PARTICULAR<sp/>PURPOSE<sp/>ARE<sp/>DISCLAIMED.<sp/>IN<sp/>NO<sp/>EVENT</highlight></codeline>
<codeline lineno="25"><highlight class="comment"><sp/>*<sp/>SHALL<sp/>THE<sp/>AUTHOR<sp/>BE<sp/>LIABLE<sp/>FOR<sp/>ANY<sp/>DIRECT,<sp/>INDIRECT,<sp/>INCIDENTAL,<sp/>SPECIAL,</highlight></codeline>
<codeline lineno="26"><highlight class="comment"><sp/>*<sp/>EXEMPLARY,<sp/>OR<sp/>CONSEQUENTIAL<sp/>DAMAGES<sp/>(INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>PROCUREMENT</highlight></codeline>
<codeline lineno="27"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUBSTITUTE<sp/>GOODS<sp/>OR<sp/>SERVICES;<sp/>LOSS<sp/>OF<sp/>USE,<sp/>DATA,<sp/>OR<sp/>PROFITS;<sp/>OR<sp/>BUSINESS</highlight></codeline>
<codeline lineno="28"><highlight class="comment"><sp/>*<sp/>INTERRUPTION)<sp/>HOWEVER<sp/>CAUSED<sp/>AND<sp/>ON<sp/>ANY<sp/>THEORY<sp/>OF<sp/>LIABILITY,<sp/>WHETHER<sp/>IN</highlight></codeline>
<codeline lineno="29"><highlight class="comment"><sp/>*<sp/>CONTRACT,<sp/>STRICT<sp/>LIABILITY,<sp/>OR<sp/>TORT<sp/>(INCLUDING<sp/>NEGLIGENCE<sp/>OR<sp/>OTHERWISE)<sp/>ARISING</highlight></codeline>
<codeline lineno="30"><highlight class="comment"><sp/>*<sp/>IN<sp/>ANY<sp/>WAY<sp/>OUT<sp/>OF<sp/>THE<sp/>USE<sp/>OF<sp/>THIS<sp/>SOFTWARE,<sp/>EVEN<sp/>IF<sp/>ADVISED<sp/>OF<sp/>THE<sp/>POSSIBILITY</highlight></codeline>
<codeline lineno="31"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="32"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="33"><highlight class="comment"><sp/>*<sp/>This<sp/>file<sp/>is<sp/>part<sp/>of<sp/>the<sp/>lwIP<sp/>TCP/IP<sp/>stack.</highlight></codeline>
<codeline lineno="34"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="35"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Jani<sp/>Monoses<sp/>&lt;jani@iv.ro&gt;</highlight></codeline>
<codeline lineno="36"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Simon<sp/>Goldschmidt</highlight></codeline>
<codeline lineno="37"><highlight class="comment"><sp/>*<sp/>original<sp/>reassembly<sp/>code<sp/>by<sp/>Adam<sp/>Dunkels<sp/>&lt;adam@sics.se&gt;</highlight></codeline>
<codeline lineno="38"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="39"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="opt_8h" kindref="compound">net/opt.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="42"><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><highlight class="normal"></highlight></codeline>
<codeline lineno="45"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip4__frag_8h" kindref="compound">net/ip4_frag.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="def_8h" kindref="compound">net/def.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="inet__chksum_8h" kindref="compound">net/inet_chksum.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="netif_8h" kindref="compound">net/netif.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="49"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="stats_8h" kindref="compound">net/stats.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="50"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="icmp_8h" kindref="compound">net/icmp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="51"><highlight class="normal"></highlight></codeline>
<codeline lineno="52"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="string_8h" kindref="compound">string.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASSEMBLY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="55"><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="preprocessor">#ifndef<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_CHECK_OVERLAP<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="70"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="preprocessor">#ifndef<sp/>IP_REASS_FREE_OLDEST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_FREE_OLDEST<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_FREE_OLDEST<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_FLAG_LASTFRAG<sp/>0x01</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_VALIDATE_TELEGRAM_FINISHED<sp/><sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="83"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_VALIDATE_PBUF_QUEUED<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="84"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_REASS_VALIDATE_PBUF_DROPPED<sp/><sp/><sp/><sp/><sp/><sp/><sp/>-1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight></codeline>
<codeline lineno="94"><highlight class="preprocessor">#ifdef<sp/>PACK_STRUCT_USE_INCLUDES</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="95"><highlight class="normal"></highlight><highlight class="preprocessor">#<sp/><sp/>include<sp/>&quot;arch/bpstruct.h&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="96"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="97"><highlight class="normal"><ref refid="cc_8h_1a73199061891adf1b912d20835c7d5e96" kindref="member">PACK_STRUCT_BEGIN</ref></highlight></codeline>
<codeline lineno="98"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>{</highlight></codeline>
<codeline lineno="99"><highlight class="normal"><sp/><sp/><ref refid="cc_8h_1aab0b988124e37a978d9a88e7c1c778e0" kindref="member">PACK_STRUCT_FIELD</ref>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*next_pbuf);</highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/><ref refid="cc_8h_1aab0b988124e37a978d9a88e7c1c778e0" kindref="member">PACK_STRUCT_FIELD</ref>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>start);</highlight></codeline>
<codeline lineno="101"><highlight class="normal"><sp/><sp/><ref refid="cc_8h_1aab0b988124e37a978d9a88e7c1c778e0" kindref="member">PACK_STRUCT_FIELD</ref>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>end);</highlight></codeline>
<codeline lineno="102"><highlight class="normal">}<sp/><ref refid="cc_8h_1a9ebc500530d0d9e6cd0b81969f48bbc8" kindref="member">PACK_STRUCT_STRUCT</ref>;</highlight></codeline>
<codeline lineno="103"><highlight class="normal"><ref refid="cc_8h_1a465fef70f294e21cbf4ea51fc342f20e" kindref="member">PACK_STRUCT_END</ref></highlight></codeline>
<codeline lineno="104"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>PACK_STRUCT_USE_INCLUDES</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="105"><highlight class="normal"></highlight><highlight class="preprocessor">#<sp/><sp/>include<sp/>&quot;arch/epstruct.h&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="106"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="107"><highlight class="normal"></highlight></codeline>
<codeline lineno="108"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP_ADDRESSES_AND_ID_MATCH(iphdrA,<sp/>iphdrB)<sp/><sp/>\</highlight></codeline>
<codeline lineno="109"><highlight class="preprocessor"><sp/><sp/>(ip4_addr_cmp(&amp;(iphdrA)-&gt;src,<sp/>&amp;(iphdrB)-&gt;src)<sp/>&amp;&amp;<sp/>\</highlight></codeline>
<codeline lineno="110"><highlight class="preprocessor"><sp/><sp/><sp/>ip4_addr_cmp(&amp;(iphdrA)-&gt;dest,<sp/>&amp;(iphdrB)-&gt;dest)<sp/>&amp;&amp;<sp/>\</highlight></codeline>
<codeline lineno="111"><highlight class="preprocessor"><sp/><sp/><sp/>IPH_ID(iphdrA)<sp/>==<sp/>IPH_ID(iphdrB))<sp/>?<sp/>1<sp/>:<sp/>0</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><highlight class="normal"></highlight></codeline>
<codeline lineno="113"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>global<sp/>variables<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="114"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*reassdatagrams;</highlight></codeline>
<codeline lineno="115"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>ip_reass_pbufcount;</highlight></codeline>
<codeline lineno="116"><highlight class="normal"></highlight></codeline>
<codeline lineno="117"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>function<sp/>prototypes<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="118"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>ip_reass_dequeue_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*ipr,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*prev);</highlight></codeline>
<codeline lineno="119"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ip_reass_free_complete_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*ipr,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*prev);</highlight></codeline>
<codeline lineno="120"><highlight class="normal"></highlight></codeline>
<codeline lineno="127"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="128"><highlight class="normal">ip_reass_tmr(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="129"><highlight class="normal">{</highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*r,<sp/>*prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="131"><highlight class="normal"></highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/>r<sp/>=<sp/>reassdatagrams;</highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(r<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="134"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Decrement<sp/>the<sp/>timer.<sp/>Once<sp/>it<sp/>reaches<sp/>0,</highlight></codeline>
<codeline lineno="135"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>clean<sp/>up<sp/>the<sp/>incomplete<sp/>fragment<sp/>assembly<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(r-&gt;timer<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>r-&gt;timer--;</highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;ip_reass_tmr:<sp/>timer<sp/>dec<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)r-&gt;timer));</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>r;</highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>r<sp/>=<sp/>r-&gt;next;</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>reassembly<sp/>timed<sp/>out<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*tmp;</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;ip_reass_tmr:<sp/>timer<sp/>timed<sp/>out\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tmp<sp/>=<sp/>r;</highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>next<sp/>pointer<sp/>before<sp/>freeing<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>r<sp/>=<sp/>r-&gt;next;</highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>free<sp/>the<sp/>helper<sp/>struct<sp/>and<sp/>all<sp/>enqueued<sp/>pbufs<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip_reass_free_complete_datagram(tmp,<sp/>prev);</highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="152"><highlight class="normal">}</highlight></codeline>
<codeline lineno="153"><highlight class="normal"></highlight></codeline>
<codeline lineno="163"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="164"><highlight class="normal">ip_reass_free_complete_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*ipr,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*prev)</highlight></codeline>
<codeline lineno="165"><highlight class="normal">{</highlight></codeline>
<codeline lineno="166"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>pbufs_freed<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="167"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>clen;</highlight></codeline>
<codeline lineno="168"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>*iprh;</highlight></codeline>
<codeline lineno="170"><highlight class="normal"></highlight></codeline>
<codeline lineno="171"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;prev<sp/>!=<sp/>ipr&quot;</highlight><highlight class="normal">,<sp/>prev<sp/>!=<sp/>ipr);</highlight></codeline>
<codeline lineno="172"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;prev-&gt;next<sp/>==<sp/>ipr&quot;</highlight><highlight class="normal">,<sp/>prev-&gt;next<sp/>==<sp/>ipr);</highlight></codeline>
<codeline lineno="174"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="175"><highlight class="normal"></highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.ipreasmfails);</highlight></codeline>
<codeline lineno="177"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_ICMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/>iprh<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>*)ipr-&gt;p-&gt;payload;</highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/>if<sp/>(iprh-&gt;start<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>first<sp/>fragment<sp/>was<sp/>received,<sp/>send<sp/>ICMP<sp/>time<sp/>exceeded.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>First,<sp/>de-queue<sp/>the<sp/>first<sp/>pbuf<sp/>from<sp/>r-&gt;p.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/><sp/><sp/>p<sp/>=<sp/>ipr-&gt;p;</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/>ipr-&gt;p<sp/>=<sp/>iprh-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Then,<sp/>copy<sp/>the<sp/>original<sp/>header<sp/>into<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>,<sp/>&amp;ipr-&gt;iphdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/><sp/><sp/>icmp_time_exceeded(p,<sp/><ref refid="icmp_8h_1a058d0a0769bd38db99fc6fd1dad1324aa4d351874c3e2d4a4cf46569df28cd796" kindref="member">ICMP_TE_FRAG</ref>);</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/>clen<sp/>=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(p);</highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pbufs_freed<sp/>+<sp/>clen<sp/>&lt;=<sp/>0xffff&quot;</highlight><highlight class="normal">,<sp/>pbufs_freed<sp/>+<sp/>clen<sp/>&lt;=<sp/>0xffff);</highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><sp/><sp/>pbufs_freed<sp/>+=<sp/>clen;</highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="192"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_ICMP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="193"><highlight class="normal"></highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>First,<sp/>free<sp/>all<sp/>received<sp/>pbufs.<sp/><sp/>The<sp/>individual<sp/>pbufs<sp/>need<sp/>to<sp/>be<sp/>released</highlight></codeline>
<codeline lineno="195"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>separately<sp/>as<sp/>they<sp/>have<sp/>not<sp/>yet<sp/>been<sp/>chained<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/>ipr-&gt;p;</highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="198"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*pcur;</highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/><sp/><sp/>iprh<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/><sp/><sp/>pcur<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>next<sp/>pointer<sp/>before<sp/>freeing<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/>p<sp/>=<sp/>iprh-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/>clen<sp/>=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(pcur);</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pbufs_freed<sp/>+<sp/>clen<sp/>&lt;=<sp/>0xffff&quot;</highlight><highlight class="normal">,<sp/>pbufs_freed<sp/>+<sp/>clen<sp/>&lt;=<sp/>0xffff);</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/><sp/><sp/>pbufs_freed<sp/>+=<sp/>clen;</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(pcur);</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Then,<sp/>unchain<sp/>the<sp/>struct<sp/>ip_reassdata<sp/>from<sp/>the<sp/>list<sp/>and<sp/>free<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/>ip_reass_dequeue_datagram(ipr,<sp/>prev);</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;ip_reass_pbufcount<sp/>&gt;=<sp/>clen&quot;</highlight><highlight class="normal">,<sp/>ip_reass_pbufcount<sp/>&gt;=<sp/>pbufs_freed);</highlight></codeline>
<codeline lineno="211"><highlight class="normal"><sp/><sp/>ip_reass_pbufcount<sp/>-=<sp/>pbufs_freed;</highlight></codeline>
<codeline lineno="212"><highlight class="normal"></highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pbufs_freed;</highlight></codeline>
<codeline lineno="214"><highlight class="normal">}</highlight></codeline>
<codeline lineno="215"><highlight class="normal"></highlight></codeline>
<codeline lineno="216"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_FREE_OLDEST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="217"><highlight class="normal"></highlight></codeline>
<codeline lineno="226"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="227"><highlight class="normal">ip_reass_remove_oldest_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*fraghdr,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>pbufs_needed)</highlight></codeline>
<codeline lineno="228"><highlight class="normal">{</highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo<sp/>Can&apos;t<sp/>we<sp/>simply<sp/>remove<sp/>the<sp/>last<sp/>datagram<sp/>in<sp/>the</highlight></codeline>
<codeline lineno="230"><highlight class="comment"><sp/><sp/><sp/>*<sp/><sp/><sp/><sp/><sp/><sp/><sp/>linked<sp/>list<sp/>behind<sp/>reassdatagrams?</highlight></codeline>
<codeline lineno="231"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*r,<sp/>*oldest,<sp/>*prev,<sp/>*oldest_prev;</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>pbufs_freed<sp/>=<sp/>0,<sp/>pbufs_freed_current;</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>other_datagrams;</highlight></codeline>
<codeline lineno="235"><highlight class="normal"></highlight></codeline>
<codeline lineno="236"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Free<sp/>datagrams<sp/>until<sp/>being<sp/>allowed<sp/>to<sp/>enqueue<sp/>&apos;pbufs_needed&apos;<sp/>pbufs,</highlight></codeline>
<codeline lineno="237"><highlight class="comment"><sp/><sp/><sp/>*<sp/>but<sp/>don&apos;t<sp/>free<sp/>the<sp/>datagram<sp/>that<sp/>&apos;fraghdr&apos;<sp/>belongs<sp/>to!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="238"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">do</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/><sp/><sp/>oldest<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/>oldest_prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/>other_datagrams<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><sp/><sp/>r<sp/>=<sp/>reassdatagrams;</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(r<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!IP_ADDRESSES_AND_ID_MATCH(&amp;r-&gt;iphdr,<sp/>fraghdr))<sp/>{</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Not<sp/>the<sp/>same<sp/>datagram<sp/>as<sp/>fraghdr<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>other_datagrams++;</highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(oldest<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oldest<sp/>=<sp/>r;</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oldest_prev<sp/>=<sp/>prev;</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(r-&gt;timer<sp/>&lt;=<sp/>oldest-&gt;timer)<sp/>{</highlight></codeline>
<codeline lineno="252"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>older<sp/>than<sp/>the<sp/>previous<sp/>oldest<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oldest<sp/>=<sp/>r;</highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oldest_prev<sp/>=<sp/>prev;</highlight></codeline>
<codeline lineno="255"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(r-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>r;</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="260"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>r<sp/>=<sp/>r-&gt;next;</highlight></codeline>
<codeline lineno="261"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="262"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(oldest<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pbufs_freed_current<sp/>=<sp/>ip_reass_free_complete_datagram(oldest,<sp/>oldest_prev);</highlight></codeline>
<codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pbufs_freed<sp/>+=<sp/>pbufs_freed_current;</highlight></codeline>
<codeline lineno="265"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>((pbufs_freed<sp/>&lt;<sp/>pbufs_needed)<sp/>&amp;&amp;<sp/>(other_datagrams<sp/>&gt;<sp/>1));</highlight></codeline>
<codeline lineno="267"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pbufs_freed;</highlight></codeline>
<codeline lineno="268"><highlight class="normal">}</highlight></codeline>
<codeline lineno="269"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_FREE_OLDEST<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="270"><highlight class="normal"></highlight></codeline>
<codeline lineno="277"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata*</highlight></codeline>
<codeline lineno="278"><highlight class="normal">ip_reass_enqueue_new_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*fraghdr,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>clen)</highlight></codeline>
<codeline lineno="279"><highlight class="normal">{</highlight></codeline>
<codeline lineno="280"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata*<sp/>ipr;</highlight></codeline>
<codeline lineno="281"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!<sp/>IP_REASS_FREE_OLDEST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="282"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(clen);</highlight></codeline>
<codeline lineno="283"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="284"><highlight class="normal"></highlight></codeline>
<codeline lineno="285"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>matching<sp/>previous<sp/>fragment<sp/>found,<sp/>allocate<sp/>a<sp/>new<sp/>reassdata<sp/>struct<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="286"><highlight class="normal"><sp/><sp/>ipr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_REASSDATA);</highlight></codeline>
<codeline lineno="287"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="288"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_FREE_OLDEST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip_reass_remove_oldest_datagram(fraghdr,<sp/>clen)<sp/>&gt;=<sp/>clen)<sp/>{</highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ipr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_REASSDATA);</highlight></codeline>
<codeline lineno="291"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="292"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)</highlight></codeline>
<codeline lineno="293"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_FREE_OLDEST<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="294"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="295"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.memerr);</highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,(</highlight><highlight class="stringliteral">&quot;Failed<sp/>to<sp/>alloc<sp/>reassdata<sp/>struct\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="297"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="298"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="299"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="300"><highlight class="normal"><sp/><sp/><ref refid="string_8h_1ace4b911463887af5e748326323e99a23" kindref="member">memset</ref>(ipr,<sp/>0,<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata));</highlight></codeline>
<codeline lineno="301"><highlight class="normal"><sp/><sp/>ipr-&gt;timer<sp/>=<sp/><ref refid="lwipopts_8h_1ad41122bd0b5485a18a4415c8f953727b" kindref="member">IP_REASS_MAXAGE</ref>;</highlight></codeline>
<codeline lineno="302"><highlight class="normal"></highlight></codeline>
<codeline lineno="303"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>enqueue<sp/>the<sp/>new<sp/>structure<sp/>to<sp/>the<sp/>front<sp/>of<sp/>the<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="304"><highlight class="normal"><sp/><sp/>ipr-&gt;next<sp/>=<sp/>reassdatagrams;</highlight></codeline>
<codeline lineno="305"><highlight class="normal"><sp/><sp/>reassdatagrams<sp/>=<sp/>ipr;</highlight></codeline>
<codeline lineno="306"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>the<sp/>ip<sp/>header<sp/>for<sp/>later<sp/>tests<sp/>and<sp/>input<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="307"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>no<sp/>ip<sp/>options<sp/>supported?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="308"><highlight class="normal"><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(&amp;(ipr-&gt;iphdr),<sp/>fraghdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ipr;</highlight></codeline>
<codeline lineno="310"><highlight class="normal">}</highlight></codeline>
<codeline lineno="311"><highlight class="normal"></highlight></codeline>
<codeline lineno="316"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="317"><highlight class="normal">ip_reass_dequeue_datagram(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*ipr,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*prev)</highlight></codeline>
<codeline lineno="318"><highlight class="normal">{</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>dequeue<sp/>the<sp/>reass<sp/>struct<sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(reassdatagrams<sp/>==<sp/>ipr)<sp/>{</highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>it<sp/>was<sp/>the<sp/>first<sp/>in<sp/>the<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/>reassdatagrams<sp/>=<sp/>ipr-&gt;next;</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>it<sp/>wasn&apos;t<sp/>the<sp/>first,<sp/>so<sp/>it<sp/>must<sp/>have<sp/>a<sp/>valid<sp/>&apos;prev&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;sanity<sp/>check<sp/>linked<sp/>list&quot;</highlight><highlight class="normal">,<sp/>prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/>ipr-&gt;next;</highlight></codeline>
<codeline lineno="327"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="328"><highlight class="normal"></highlight></codeline>
<codeline lineno="329"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>now<sp/>we<sp/>can<sp/>free<sp/>the<sp/>ip_reassdata<sp/>struct<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_REASSDATA,<sp/>ipr);</highlight></codeline>
<codeline lineno="331"><highlight class="normal">}</highlight></codeline>
<codeline lineno="332"><highlight class="normal"></highlight></codeline>
<codeline lineno="343"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="344"><highlight class="normal">ip_reass_chain_frag_into_datagram_and_validate(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reassdata<sp/>*ipr,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*new_p,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>is_last)</highlight></codeline>
<codeline lineno="345"><highlight class="normal">{</highlight></codeline>
<codeline lineno="346"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>*iprh,<sp/>*iprh_tmp,<sp/>*iprh_prev=<ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="347"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*q;</highlight></codeline>
<codeline lineno="348"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>offset,<sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>;</highlight></codeline>
<codeline lineno="349"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*fraghdr;</highlight></codeline>
<codeline lineno="350"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>valid<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="351"><highlight class="normal"></highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Extract<sp/>length<sp/>and<sp/>fragment<sp/>offset<sp/>from<sp/>current<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/>fraghdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref>*)new_p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="354"><highlight class="normal"><sp/><sp/>len<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1aec0328fe4711b8c1ef4dd6709e4fd6d5" kindref="member">IPH_LEN</ref>(fraghdr))<sp/>-<sp/><ref refid="prot_2ip4_8h_1a7c60caeb708571a07a44309c10ec3a01" kindref="member">IPH_HL</ref>(fraghdr)<sp/>*<sp/>4;</highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/>offset<sp/>=<sp/>(<ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(fraghdr))<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref>)<sp/>*<sp/>8;</highlight></codeline>
<codeline lineno="356"><highlight class="normal"></highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>overwrite<sp/>the<sp/>fragment&apos;s<sp/>ip<sp/>header<sp/>from<sp/>the<sp/>pbuf<sp/>with<sp/>our<sp/>helper<sp/>struct,</highlight></codeline>
<codeline lineno="358"><highlight class="comment"><sp/><sp/><sp/>*<sp/>and<sp/>setup<sp/>the<sp/>embedded<sp/>helper<sp/>structure.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>make<sp/>sure<sp/>the<sp/>struct<sp/>ip_reass_helper<sp/>fits<sp/>into<sp/>the<sp/>IP<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="360"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;sizeof(struct<sp/>ip_reass_helper)<sp/>&lt;=<sp/>IP_HLEN&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="361"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reass_helper)<sp/>&lt;=<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/>iprh<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper*)new_p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="363"><highlight class="normal"><sp/><sp/>iprh-&gt;next_pbuf<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/>iprh-&gt;start<sp/>=<sp/>offset;</highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/>iprh-&gt;end<sp/>=<sp/>offset<sp/>+<sp/>len;</highlight></codeline>
<codeline lineno="366"><highlight class="normal"></highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Iterate<sp/>through<sp/>until<sp/>we<sp/>either<sp/>get<sp/>to<sp/>the<sp/>end<sp/>of<sp/>the<sp/>list<sp/>(append),</highlight></codeline>
<codeline lineno="368"><highlight class="comment"><sp/><sp/><sp/>*<sp/>or<sp/>we<sp/>find<sp/>one<sp/>with<sp/>a<sp/>larger<sp/>offset<sp/>(insert).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/>for<sp/>(q<sp/>=<sp/>ipr-&gt;p;<sp/>q<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;)<sp/>{</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/><sp/><sp/>iprh_tmp<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper*)q-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/><sp/><sp/>if<sp/>(iprh-&gt;start<sp/>&lt;<sp/>iprh_tmp-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>new<sp/>pbuf<sp/>should<sp/>be<sp/>inserted<sp/>before<sp/>this<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>iprh-&gt;next_pbuf<sp/>=<sp/>q;</highlight></codeline>
<codeline lineno="374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>not<sp/>the<sp/>fragment<sp/>with<sp/>the<sp/>lowest<sp/>offset<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="376"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((iprh-&gt;start<sp/>&lt;<sp/>iprh_prev-&gt;end)<sp/>||<sp/>(iprh-&gt;end<sp/>&gt;<sp/>iprh_tmp-&gt;start))<sp/>{</highlight></codeline>
<codeline lineno="378"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>fragment<sp/>overlaps<sp/>with<sp/>previous<sp/>or<sp/>following,<sp/>throw<sp/>away<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="379"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>freepbuf;</highlight></codeline>
<codeline lineno="380"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="381"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="382"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>iprh_prev-&gt;next_pbuf<sp/>=<sp/>new_p;</highlight></codeline>
<codeline lineno="383"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev-&gt;end<sp/>!=<sp/>iprh-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>There<sp/>is<sp/>a<sp/>fragment<sp/>missing<sp/>between<sp/>the<sp/>current</highlight></codeline>
<codeline lineno="385"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>and<sp/>the<sp/>previous<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>valid<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="388"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="389"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh-&gt;end<sp/>&gt;<sp/>iprh_tmp-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="391"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>fragment<sp/>overlaps<sp/>with<sp/>following,<sp/>throw<sp/>away<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="392"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>freepbuf;</highlight></codeline>
<codeline lineno="393"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="394"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>fragment<sp/>with<sp/>the<sp/>lowest<sp/>offset<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ipr-&gt;p<sp/>=<sp/>new_p;</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="398"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh-&gt;start<sp/>==<sp/>iprh_tmp-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>received<sp/>the<sp/>same<sp/>datagram<sp/>twice:<sp/>no<sp/>need<sp/>to<sp/>keep<sp/>the<sp/>datagram<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="401"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>freepbuf;</highlight></codeline>
<codeline lineno="402"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="403"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh-&gt;start<sp/>&lt;<sp/>iprh_tmp-&gt;end)<sp/>{</highlight></codeline>
<codeline lineno="404"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>overlap:<sp/>no<sp/>need<sp/>to<sp/>keep<sp/>the<sp/>new<sp/>datagram<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>freepbuf;</highlight></codeline>
<codeline lineno="406"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>the<sp/>fragments<sp/>received<sp/>so<sp/>far<sp/>have<sp/>no<sp/>holes.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="410"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev-&gt;end<sp/>!=<sp/>iprh_tmp-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>There<sp/>is<sp/>a<sp/>fragment<sp/>missing<sp/>between<sp/>the<sp/>current</highlight></codeline>
<codeline lineno="412"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>and<sp/>the<sp/>previous<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>valid<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/>q<sp/>=<sp/>iprh_tmp-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/><sp/><sp/>iprh_prev<sp/>=<sp/>iprh_tmp;</highlight></codeline>
<codeline lineno="419"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="420"><highlight class="normal"></highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>q<sp/>is<sp/>NULL,<sp/>then<sp/>we<sp/>made<sp/>it<sp/>to<sp/>the<sp/>end<sp/>of<sp/>the<sp/>list.<sp/>Determine<sp/>what<sp/>to<sp/>do<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="423"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>is<sp/>(for<sp/>now),<sp/>the<sp/>fragment<sp/>with<sp/>the<sp/>highest<sp/>offset:</highlight></codeline>
<codeline lineno="425"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>chain<sp/>it<sp/>to<sp/>the<sp/>last<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="426"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;check<sp/>fragments<sp/>don&apos;t<sp/>overlap&quot;</highlight><highlight class="normal">,<sp/>iprh_prev-&gt;end<sp/>&lt;=<sp/>iprh-&gt;start);</highlight></codeline>
<codeline lineno="428"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="429"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>iprh_prev-&gt;next_pbuf<sp/>=<sp/>new_p;</highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iprh_prev-&gt;end<sp/>!=<sp/>iprh-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>valid<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="433"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="434"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="435"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;no<sp/>previous<sp/>fragment,<sp/>this<sp/>must<sp/>be<sp/>the<sp/>first<sp/>fragment!&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ipr-&gt;p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="437"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>is<sp/>the<sp/>first<sp/>fragment<sp/>we<sp/>ever<sp/>received<sp/>for<sp/>this<sp/>ip<sp/>datagram<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ipr-&gt;p<sp/>=<sp/>new_p;</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="441"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="442"><highlight class="normal"></highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>At<sp/>this<sp/>point,<sp/>the<sp/>validation<sp/>part<sp/>begins:<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we<sp/>already<sp/>received<sp/>the<sp/>last<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_last<sp/>||<sp/>((ipr-&gt;flags<sp/>&amp;<sp/>IP_REASS_FLAG_LASTFRAG)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>and<sp/>had<sp/>no<sp/>holes<sp/>so<sp/>far<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="447"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(valid)<sp/>{</highlight></codeline>
<codeline lineno="448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>then<sp/>check<sp/>if<sp/>the<sp/>rest<sp/>of<sp/>the<sp/>fragments<sp/>is<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="449"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>the<sp/>queue<sp/>starts<sp/>with<sp/>the<sp/>first<sp/>datagram<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="450"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((ipr-&gt;p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reass_helper*)ipr-&gt;p-&gt;payload)-&gt;start<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="451"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>valid<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="452"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>and<sp/>check<sp/>that<sp/>there<sp/>are<sp/>no<sp/>holes<sp/>after<sp/>this<sp/>datagram<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="454"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>iprh_prev<sp/>=<sp/>iprh;</highlight></codeline>
<codeline lineno="455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q<sp/>=<sp/>iprh-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(q<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>iprh<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper*)q-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(iprh_prev-&gt;end<sp/>!=<sp/>iprh-&gt;start)<sp/>{</highlight></codeline>
<codeline lineno="459"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>valid<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="460"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="462"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>iprh_prev<sp/>=<sp/>iprh;</highlight></codeline>
<codeline lineno="463"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q<sp/>=<sp/>iprh-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="464"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="465"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>still<sp/>valid,<sp/>all<sp/>fragments<sp/>are<sp/>received</highlight></codeline>
<codeline lineno="466"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>(because<sp/>to<sp/>the<sp/>MF==0<sp/>already<sp/>arrived<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="467"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(valid)<sp/>{</highlight></codeline>
<codeline lineno="468"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;sanity<sp/>check&quot;</highlight><highlight class="normal">,<sp/>ipr-&gt;p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="469"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;sanity<sp/>check&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="470"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_reass_helper*)ipr-&gt;p-&gt;payload)<sp/>!=<sp/>iprh);</highlight></codeline>
<codeline lineno="471"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;validate_datagram:next_pbuf!=NULL&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="472"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>iprh-&gt;next_pbuf<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="476"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>valid<sp/>is<sp/>0<sp/>here,<sp/>there<sp/>are<sp/>some<sp/>fragments<sp/>missing<sp/>in<sp/>the<sp/>middle</highlight></codeline>
<codeline lineno="477"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>(since<sp/>MF<sp/>==<sp/>0<sp/>has<sp/>already<sp/>arrived).<sp/>Such<sp/>datagrams<sp/>simply<sp/>time<sp/>out<sp/>if</highlight></codeline>
<codeline lineno="478"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>no<sp/>more<sp/>fragments<sp/>are<sp/>received...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>valid<sp/>?<sp/>IP_REASS_VALIDATE_TELEGRAM_FINISHED<sp/>:<sp/>IP_REASS_VALIDATE_PBUF_QUEUED;</highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="481"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we<sp/>come<sp/>here,<sp/>not<sp/>all<sp/>fragments<sp/>were<sp/>received,<sp/>yet!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="482"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>IP_REASS_VALIDATE_PBUF_QUEUED;<sp/></highlight><highlight class="comment">/*<sp/>not<sp/>yet<sp/>valid!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="483"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_CHECK_OVERLAP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="484"><highlight class="normal">freepbuf:</highlight></codeline>
<codeline lineno="485"><highlight class="normal"><sp/><sp/>ip_reass_pbufcount<sp/>-=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(new_p);</highlight></codeline>
<codeline lineno="486"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(new_p);</highlight></codeline>
<codeline lineno="487"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>IP_REASS_VALIDATE_PBUF_DROPPED;</highlight></codeline>
<codeline lineno="488"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_CHECK_OVERLAP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="489"><highlight class="normal">}</highlight></codeline>
<codeline lineno="490"><highlight class="normal"></highlight></codeline>
<codeline lineno="497"><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*</highlight></codeline>
<codeline lineno="498"><highlight class="normal">ip4_reass(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p)</highlight></codeline>
<codeline lineno="499"><highlight class="normal">{</highlight></codeline>
<codeline lineno="500"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*r;</highlight></codeline>
<codeline lineno="501"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*fraghdr;</highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*ipr;</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper<sp/>*iprh;</highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>offset,<sp/>len,<sp/>clen;</highlight></codeline>
<codeline lineno="505"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>valid;</highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>is_last;</highlight></codeline>
<codeline lineno="507"><highlight class="normal"></highlight></codeline>
<codeline lineno="508"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.recv);</highlight></codeline>
<codeline lineno="509"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.ipreasmreqds);</highlight></codeline>
<codeline lineno="510"><highlight class="normal"></highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/>fraghdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="512"><highlight class="normal"></highlight></codeline>
<codeline lineno="513"><highlight class="normal"><sp/><sp/>if<sp/>((<ref refid="prot_2ip4_8h_1a7c60caeb708571a07a44309c10ec3a01" kindref="member">IPH_HL</ref>(fraghdr)<sp/>*<sp/>4)<sp/>!=<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="514"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,(</highlight><highlight class="stringliteral">&quot;ip4_reass:<sp/>IP<sp/>options<sp/>currently<sp/>not<sp/>supported!\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="515"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.err);</highlight></codeline>
<codeline lineno="516"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>nullreturn;</highlight></codeline>
<codeline lineno="517"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="518"><highlight class="normal"></highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/>offset<sp/>=<sp/>(<ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(fraghdr))<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref>)<sp/>*<sp/>8;</highlight></codeline>
<codeline lineno="520"><highlight class="normal"><sp/><sp/>len<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1aec0328fe4711b8c1ef4dd6709e4fd6d5" kindref="member">IPH_LEN</ref>(fraghdr))<sp/>-<sp/><ref refid="prot_2ip4_8h_1a7c60caeb708571a07a44309c10ec3a01" kindref="member">IPH_HL</ref>(fraghdr)<sp/>*<sp/>4;</highlight></codeline>
<codeline lineno="521"><highlight class="normal"></highlight></codeline>
<codeline lineno="522"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>we<sp/>are<sp/>allowed<sp/>to<sp/>enqueue<sp/>more<sp/>datagrams.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/>clen<sp/>=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(p);</highlight></codeline>
<codeline lineno="524"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((ip_reass_pbufcount<sp/>+<sp/>clen)<sp/>&gt;<sp/><ref refid="lwipopts_8h_1a29084a46d7d4be30e8029d356bca0394" kindref="member">IP_REASS_MAX_PBUFS</ref>)<sp/>{</highlight></codeline>
<codeline lineno="525"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_REASS_FREE_OLDEST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="526"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!ip_reass_remove_oldest_datagram(fraghdr,<sp/>clen)<sp/>||</highlight></codeline>
<codeline lineno="527"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((ip_reass_pbufcount<sp/>+<sp/>clen)<sp/>&gt;<sp/><ref refid="lwipopts_8h_1a29084a46d7d4be30e8029d356bca0394" kindref="member">IP_REASS_MAX_PBUFS</ref>))</highlight></codeline>
<codeline lineno="528"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASS_FREE_OLDEST<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="529"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="530"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>datagram<sp/>could<sp/>be<sp/>freed<sp/>and<sp/>still<sp/>too<sp/>many<sp/>pbufs<sp/>enqueued<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="531"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,(</highlight><highlight class="stringliteral">&quot;ip4_reass:<sp/>Overflow<sp/>condition:<sp/>pbufct=%d,<sp/>clen=%d,<sp/>MAX=%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="532"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip_reass_pbufcount,<sp/>clen,<sp/><ref refid="lwipopts_8h_1a29084a46d7d4be30e8029d356bca0394" kindref="member">IP_REASS_MAX_PBUFS</ref>));</highlight></codeline>
<codeline lineno="533"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.memerr);</highlight></codeline>
<codeline lineno="534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>send<sp/>ICMP<sp/>time<sp/>exceeded<sp/>here?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>drop<sp/>this<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="536"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>nullreturn;</highlight></codeline>
<codeline lineno="537"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="539"><highlight class="normal"></highlight></codeline>
<codeline lineno="540"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Look<sp/>for<sp/>the<sp/>datagram<sp/>the<sp/>fragment<sp/>belongs<sp/>to<sp/>in<sp/>the<sp/>current<sp/>datagram<sp/>queue,</highlight></codeline>
<codeline lineno="541"><highlight class="comment"><sp/><sp/><sp/>*<sp/>remembering<sp/>the<sp/>previous<sp/>in<sp/>the<sp/>queue<sp/>for<sp/>later<sp/>dequeueing.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(ipr<sp/>=<sp/>reassdatagrams;<sp/>ipr<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>ipr<sp/>=<sp/>ipr-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="543"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>the<sp/>incoming<sp/>fragment<sp/>matches<sp/>the<sp/>one<sp/>currently<sp/>present</highlight></codeline>
<codeline lineno="544"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>the<sp/>reassembly<sp/>buffer.<sp/>If<sp/>so,<sp/>we<sp/>proceed<sp/>with<sp/>copying<sp/>the</highlight></codeline>
<codeline lineno="545"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fragment<sp/>into<sp/>the<sp/>buffer.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="546"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(IP_ADDRESSES_AND_ID_MATCH(&amp;ipr-&gt;iphdr,<sp/>fraghdr))<sp/>{</highlight></codeline>
<codeline lineno="547"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;ip4_reass:<sp/>matching<sp/>previous<sp/>fragment<sp/>ID=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga1418f92673e54a36b6e376109e526382" kindref="member">X16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="548"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1ae79eaecc0bf9e4dbb9e47ea56ad2157a" kindref="member">IPH_ID</ref>(fraghdr))));</highlight></codeline>
<codeline lineno="549"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.cachehit);</highlight></codeline>
<codeline lineno="550"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="551"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="552"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="553"><highlight class="normal"></highlight></codeline>
<codeline lineno="554"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="555"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Enqueue<sp/>a<sp/>new<sp/>datagram<sp/>into<sp/>the<sp/>datagram<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="556"><highlight class="normal"><sp/><sp/><sp/><sp/>ipr<sp/>=<sp/>ip_reass_enqueue_new_datagram(fraghdr,<sp/>clen);</highlight></codeline>
<codeline lineno="557"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Bail<sp/>if<sp/>unable<sp/>to<sp/>enqueue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="558"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="559"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>nullreturn;</highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((<ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(fraghdr))<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref>)<sp/>==<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="563"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((<ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(&amp;ipr-&gt;iphdr))<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref>)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="564"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>ipr-&gt;iphdr<sp/>is<sp/>not<sp/>the<sp/>header<sp/>from<sp/>the<sp/>first<sp/>fragment,<sp/>but<sp/>fraghdr<sp/>is</highlight></codeline>
<codeline lineno="565"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>-&gt;<sp/>copy<sp/>fraghdr<sp/>into<sp/>ipr-&gt;iphdr<sp/>since<sp/>we<sp/>want<sp/>to<sp/>have<sp/>the<sp/>header</highlight></codeline>
<codeline lineno="566"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>of<sp/>the<sp/>first<sp/>fragment<sp/>(for<sp/>ICMP<sp/>time<sp/>exceeded<sp/>and<sp/>later,<sp/>for<sp/>copying</highlight></codeline>
<codeline lineno="567"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>all<sp/>options,<sp/>if<sp/>supported)*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="568"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(&amp;ipr-&gt;iphdr,<sp/>fraghdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="569"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="571"><highlight class="normal"></highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>At<sp/>this<sp/>point,<sp/>we<sp/>have<sp/>either<sp/>created<sp/>a<sp/>new<sp/>entry<sp/>or<sp/>pointing</highlight></codeline>
<codeline lineno="573"><highlight class="comment"><sp/><sp/><sp/>*<sp/>to<sp/>an<sp/>existing<sp/>one<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="574"><highlight class="normal"></highlight></codeline>
<codeline lineno="575"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>for<sp/>&apos;no<sp/>more<sp/>fragments&apos;,<sp/>and<sp/>update<sp/>queue<sp/>entry*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="576"><highlight class="normal"><sp/><sp/>is_last<sp/>=<sp/>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(fraghdr)<sp/>&amp;<sp/><ref refid="def_8h_1a7d17b88eabf7766c0bfa89d8f965f67e" kindref="member">PP_NTOHS</ref>(<ref refid="prot_2ip4_8h_1ae8afe1e04bb9bad791443556c3b2cd73" kindref="member">IP_MF</ref>))<sp/>==<sp/>0;</highlight></codeline>
<codeline lineno="577"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_last)<sp/>{</highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>datagram_len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(offset<sp/>+<sp/>len);</highlight></codeline>
<codeline lineno="579"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((datagram_len<sp/>&lt;<sp/>offset)<sp/>||<sp/>(datagram_len<sp/>&gt;<sp/>(0xFFFF<sp/>-<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>)))<sp/>{</highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>u16_t<sp/>overflow,<sp/>cannot<sp/>handle<sp/>this<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="581"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>nullreturn;</highlight></codeline>
<codeline lineno="582"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="583"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="584"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>find<sp/>the<sp/>right<sp/>place<sp/>to<sp/>insert<sp/>this<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="585"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>trim<sp/>pbufs<sp/>if<sp/>fragments<sp/>are<sp/>overlapping<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="586"><highlight class="normal"><sp/><sp/>valid<sp/>=<sp/>ip_reass_chain_frag_into_datagram_and_validate(ipr,<sp/>p,<sp/>is_last);</highlight></codeline>
<codeline lineno="587"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(valid<sp/>==<sp/>IP_REASS_VALIDATE_PBUF_DROPPED)<sp/>{</highlight></codeline>
<codeline lineno="588"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>nullreturn;</highlight></codeline>
<codeline lineno="589"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="590"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>we<sp/>come<sp/>here,<sp/>the<sp/>pbuf<sp/>has<sp/>been<sp/>enqueued<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="591"><highlight class="normal"></highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Track<sp/>the<sp/>current<sp/>number<sp/>of<sp/>pbufs<sp/>current<sp/>&apos;in-flight&apos;,<sp/>in<sp/>order<sp/>to<sp/>limit</highlight></codeline>
<codeline lineno="593"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>the<sp/>number<sp/>of<sp/>fragments<sp/>that<sp/>may<sp/>be<sp/>enqueued<sp/>at<sp/>any<sp/>one<sp/>time</highlight></codeline>
<codeline lineno="594"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>(overflow<sp/>checked<sp/>by<sp/>testing<sp/>against<sp/>IP_REASS_MAX_PBUFS)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="595"><highlight class="normal"><sp/><sp/>ip_reass_pbufcount<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(ip_reass_pbufcount<sp/>+<sp/>clen);</highlight></codeline>
<codeline lineno="596"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_last)<sp/>{</highlight></codeline>
<codeline lineno="597"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>datagram_len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(offset<sp/>+<sp/>len);</highlight></codeline>
<codeline lineno="598"><highlight class="normal"><sp/><sp/><sp/><sp/>ipr-&gt;datagram_len<sp/>=<sp/>datagram_len;</highlight></codeline>
<codeline lineno="599"><highlight class="normal"><sp/><sp/><sp/><sp/>ipr-&gt;flags<sp/>|=<sp/>IP_REASS_FLAG_LASTFRAG;</highlight></codeline>
<codeline lineno="600"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,</highlight></codeline>
<codeline lineno="601"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;ip4_reass:<sp/>last<sp/>fragment<sp/>seen,<sp/>total<sp/>len<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac05a82d37afb251470f5e17ca15ab6e9" kindref="member">S16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ipr-&gt;datagram_len));</highlight></codeline>
<codeline lineno="603"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="604"><highlight class="normal"></highlight></codeline>
<codeline lineno="605"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(valid<sp/>==<sp/>IP_REASS_VALIDATE_TELEGRAM_FINISHED)<sp/>{</highlight></codeline>
<codeline lineno="606"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reassdata<sp/>*ipr_prev;</highlight></codeline>
<codeline lineno="607"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>totally<sp/>last<sp/>fragment<sp/>(flag<sp/>more<sp/>fragments<sp/>=<sp/>0)<sp/>was<sp/>received<sp/>at<sp/>least</highlight></codeline>
<codeline lineno="608"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>once<sp/>AND<sp/>all<sp/>fragments<sp/>are<sp/>received<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="609"><highlight class="normal"><sp/><sp/><sp/><sp/>ipr-&gt;datagram_len<sp/>+=<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>;</highlight></codeline>
<codeline lineno="610"><highlight class="normal"></highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>save<sp/>the<sp/>second<sp/>pbuf<sp/>before<sp/>copying<sp/>the<sp/>header<sp/>over<sp/>the<sp/>pointer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/><sp/><sp/>r<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper*)ipr-&gt;p-&gt;payload)-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="613"><highlight class="normal"></highlight></codeline>
<codeline lineno="614"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>the<sp/>original<sp/>ip<sp/>header<sp/>back<sp/>to<sp/>the<sp/>first<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="615"><highlight class="normal"><sp/><sp/><sp/><sp/>fraghdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref>*)(ipr-&gt;p-&gt;payload);</highlight></codeline>
<codeline lineno="616"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(fraghdr,<sp/>&amp;ipr-&gt;iphdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="617"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1a069cb9b3765c4bdd63d13efb2df0206e" kindref="member">IPH_LEN_SET</ref>(fraghdr,<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(ipr-&gt;datagram_len));</highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1a4c2189e1400dca1c0f785de96ceda2b6" kindref="member">IPH_OFFSET_SET</ref>(fraghdr,<sp/>0);</highlight></codeline>
<codeline lineno="619"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1aec30403fb98b013bd094688de55cdaef" kindref="member">IPH_CHKSUM_SET</ref>(fraghdr,<sp/>0);</highlight></codeline>
<codeline lineno="620"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>do<sp/>we<sp/>need<sp/>to<sp/>set/calculate<sp/>the<sp/>correct<sp/>checksum?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="621"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_IP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="622"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="ip_8h_1ae214afa9d3f1b26fc8d538436b8fa3c4" kindref="member">ip_current_input_netif</ref>(),<sp/>NETIF_CHECKSUM_GEN_IP)<sp/>{</highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1aec30403fb98b013bd094688de55cdaef" kindref="member">IPH_CHKSUM_SET</ref>(fraghdr,<sp/><ref refid="inet__chksum_8h_1a34f1aa1587562a09e11b704b51bab043" kindref="member">inet_chksum</ref>(fraghdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>));</highlight></codeline>
<codeline lineno="624"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="625"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_IP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="626"><highlight class="normal"></highlight></codeline>
<codeline lineno="627"><highlight class="normal"><sp/><sp/><sp/><sp/>p<sp/>=<sp/>ipr-&gt;p;</highlight></codeline>
<codeline lineno="628"><highlight class="normal"></highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>chain<sp/>together<sp/>the<sp/>pbufs<sp/>contained<sp/>within<sp/>the<sp/>reass_data<sp/>list.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="630"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(r<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="631"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>iprh<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_reass_helper*)r-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="632"><highlight class="normal"></highlight></codeline>
<codeline lineno="633"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>hide<sp/>the<sp/>ip<sp/>header<sp/>for<sp/>every<sp/>succeeding<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="634"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(r,<sp/>-<ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="635"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(p,<sp/>r);</highlight></codeline>
<codeline lineno="636"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>r<sp/>=<sp/>iprh-&gt;next_pbuf;</highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="638"><highlight class="normal"></highlight></codeline>
<codeline lineno="639"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>find<sp/>the<sp/>previous<sp/>entry<sp/>in<sp/>the<sp/>linked<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="640"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr<sp/>==<sp/>reassdatagrams)<sp/>{</highlight></codeline>
<codeline lineno="641"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ipr_prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="642"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="643"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(ipr_prev<sp/>=<sp/>reassdatagrams;<sp/>ipr_prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>ipr_prev<sp/>=<sp/>ipr_prev-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="644"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipr_prev-&gt;next<sp/>==<sp/>ipr)<sp/>{</highlight></codeline>
<codeline lineno="645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="646"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="647"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="648"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="649"><highlight class="normal"></highlight></codeline>
<codeline lineno="650"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>release<sp/>the<sp/>sources<sp/>allocate<sp/>for<sp/>the<sp/>fragment<sp/>queue<sp/>entry<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="651"><highlight class="normal"><sp/><sp/><sp/><sp/>ip_reass_dequeue_datagram(ipr,<sp/>ipr_prev);</highlight></codeline>
<codeline lineno="652"><highlight class="normal"></highlight></codeline>
<codeline lineno="653"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>and<sp/>adjust<sp/>the<sp/>number<sp/>of<sp/>pbufs<sp/>currently<sp/>queued<sp/>for<sp/>reassembly.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="654"><highlight class="normal"><sp/><sp/><sp/><sp/>ip_reass_pbufcount<sp/>-=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(p);</highlight></codeline>
<codeline lineno="655"><highlight class="normal"></highlight></codeline>
<codeline lineno="656"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.ipreasmoks);</highlight></codeline>
<codeline lineno="657"><highlight class="normal"></highlight></codeline>
<codeline lineno="658"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Return<sp/>the<sp/>pbuf<sp/>chain<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="659"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>p;</highlight></codeline>
<codeline lineno="660"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="661"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>datagram<sp/>is<sp/>not<sp/>(yet?)<sp/>reassembled<sp/>completely<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="662"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,(</highlight><highlight class="stringliteral">&quot;ip_reass_pbufcount:<sp/>%d<sp/>out\n&quot;</highlight><highlight class="normal">,<sp/>ip_reass_pbufcount));</highlight></codeline>
<codeline lineno="663"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="664"><highlight class="normal"></highlight></codeline>
<codeline lineno="665"><highlight class="normal">nullreturn:</highlight></codeline>
<codeline lineno="666"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4cdc3e9a4a1c01d1f7f0e723a1b2ec33" kindref="member">IP_REASS_DEBUG</ref>,(</highlight><highlight class="stringliteral">&quot;ip4_reass:<sp/>nullreturn\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="667"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.drop);</highlight></codeline>
<codeline lineno="668"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="669"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="670"><highlight class="normal">}</highlight></codeline>
<codeline lineno="671"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_REASSEMBLY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="672"><highlight class="normal"></highlight></codeline>
<codeline lineno="673"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_FRAG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="674"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="675"><highlight class="normal"></highlight></codeline>
<codeline lineno="676"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">pbuf_custom_ref*</highlight></codeline>
<codeline lineno="677"><highlight class="normal">ip_frag_alloc_pbuf_custom_ref(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="678"><highlight class="normal">{</highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>pbuf_custom_ref*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_FRAG_PBUF);</highlight></codeline>
<codeline lineno="680"><highlight class="normal">}</highlight></codeline>
<codeline lineno="681"><highlight class="normal"></highlight></codeline>
<codeline lineno="683"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="684"><highlight class="normal">ip_frag_free_pbuf_custom_ref(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>pbuf_custom_ref*<sp/>p)</highlight></codeline>
<codeline lineno="685"><highlight class="normal">{</highlight></codeline>
<codeline lineno="686"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;p<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_FRAG_PBUF,<sp/>p);</highlight></codeline>
<codeline lineno="688"><highlight class="normal">}</highlight></codeline>
<codeline lineno="689"><highlight class="normal"></highlight></codeline>
<codeline lineno="692"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="693"><highlight class="normal">ipfrag_free_pbuf_custom(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p)</highlight></codeline>
<codeline lineno="694"><highlight class="normal">{</highlight></codeline>
<codeline lineno="695"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">pbuf_custom_ref<sp/>*pcr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">pbuf_custom_ref*)p;</highlight></codeline>
<codeline lineno="696"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcr<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>pcr<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="697"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcr<sp/>==<sp/>p&quot;</highlight><highlight class="normal">,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)pcr<sp/>==<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)p);</highlight></codeline>
<codeline lineno="698"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcr-&gt;original<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="699"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(pcr-&gt;original);</highlight></codeline>
<codeline lineno="700"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="701"><highlight class="normal"><sp/><sp/>ip_frag_free_pbuf_custom_ref(pcr);</highlight></codeline>
<codeline lineno="702"><highlight class="normal">}</highlight></codeline>
<codeline lineno="703"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>!LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="704"><highlight class="normal"></highlight></codeline>
<codeline lineno="717"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="718"><highlight class="normal">ip4_frag(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*dest)</highlight></codeline>
<codeline lineno="719"><highlight class="normal">{</highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*rambuf;</highlight></codeline>
<codeline lineno="721"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="722"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*newpbuf;</highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>newpbuflen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>left_to_copy;</highlight></codeline>
<codeline lineno="725"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="726"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*original_iphdr;</highlight></codeline>
<codeline lineno="727"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*iphdr;</highlight></codeline>
<codeline lineno="728"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>nfb<sp/>=<sp/>(<ref refid="structnetif" kindref="compound">netif</ref>-&gt;<ref refid="structnetif_1aca7d56b4e0f822b0ced2885f222b8d48" kindref="member">mtu</ref><sp/>-<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>)<sp/>/<sp/>8;</highlight></codeline>
<codeline lineno="729"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>left,<sp/>fragsize;</highlight></codeline>
<codeline lineno="730"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>ofo;</highlight></codeline>
<codeline lineno="731"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>last;</highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>poff<sp/>=<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>;</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>tmp;</highlight></codeline>
<codeline lineno="734"><highlight class="normal"></highlight></codeline>
<codeline lineno="735"><highlight class="normal"><sp/><sp/>original_iphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="736"><highlight class="normal"><sp/><sp/>iphdr<sp/>=<sp/>original_iphdr;</highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;ip4_frag()<sp/>does<sp/>not<sp/>support<sp/>IP<sp/>options&quot;</highlight><highlight class="normal">,<sp/><ref refid="prot_2ip4_8h_1a7c60caeb708571a07a44309c10ec3a01" kindref="member">IPH_HL</ref>(iphdr)<sp/>*<sp/>4<sp/>==<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>,<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>);</highlight></codeline>
<codeline lineno="738"><highlight class="normal"></highlight></codeline>
<codeline lineno="739"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Save<sp/>original<sp/>offset<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="740"><highlight class="normal"><sp/><sp/>tmp<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(<ref refid="prot_2ip4_8h_1a559dce3878f1d6a46bcb4cb312962397" kindref="member">IPH_OFFSET</ref>(iphdr));</highlight></codeline>
<codeline lineno="741"><highlight class="normal"><sp/><sp/>ofo<sp/>=<sp/>tmp<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref>;</highlight></codeline>
<codeline lineno="742"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;ip_frag():<sp/>MF<sp/>already<sp/>set&quot;</highlight><highlight class="normal">,<sp/>(tmp<sp/>&amp;<sp/><ref refid="prot_2ip4_8h_1ae8afe1e04bb9bad791443556c3b2cd73" kindref="member">IP_MF</ref>)<sp/>==<sp/>0,<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>);</highlight></codeline>
<codeline lineno="743"><highlight class="normal"></highlight></codeline>
<codeline lineno="744"><highlight class="normal"><sp/><sp/>left<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>-<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>;</highlight></codeline>
<codeline lineno="745"><highlight class="normal"></highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(left)<sp/>{</highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Fill<sp/>this<sp/>fragment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="748"><highlight class="normal"><sp/><sp/><sp/><sp/>fragsize<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(left,<sp/>nfb<sp/>*<sp/>8);</highlight></codeline>
<codeline lineno="749"><highlight class="normal"></highlight></codeline>
<codeline lineno="750"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="751"><highlight class="normal"><sp/><sp/><sp/><sp/>rambuf<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfafcc1e506061ba69dfa142eb6b3da5f13" kindref="member">PBUF_IP</ref>,<sp/>fragsize,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="752"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rambuf<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="753"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="755"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;this<sp/>needs<sp/>a<sp/>pbuf<sp/>in<sp/>one<sp/>piece!&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="756"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(rambuf-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>==<sp/>rambuf-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>)<sp/>&amp;&amp;<sp/>(rambuf-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="757"><highlight class="normal"><sp/><sp/><sp/><sp/>poff<sp/>+=<sp/><ref refid="group__pbuf_1gac2f1f58fd36042e82af46f5015720899" kindref="member">pbuf_copy_partial</ref>(p,<sp/>rambuf-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>,<sp/>fragsize,<sp/>poff);</highlight></codeline>
<codeline lineno="758"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>make<sp/>room<sp/>for<sp/>the<sp/>IP<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="759"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(rambuf,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>))<sp/>{</highlight></codeline>
<codeline lineno="760"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rambuf);</highlight></codeline>
<codeline lineno="761"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="762"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="763"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>fill<sp/>in<sp/>the<sp/>IP<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="764"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(rambuf-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>,<sp/>original_iphdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="765"><highlight class="normal"><sp/><sp/><sp/><sp/>iphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref>*)rambuf-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="766"><highlight class="normal">#</highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="767"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>When<sp/>not<sp/>using<sp/>a<sp/>static<sp/>buffer,<sp/>create<sp/>a<sp/>chain<sp/>of<sp/>pbufs.</highlight></codeline>
<codeline lineno="768"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>The<sp/>first<sp/>will<sp/>be<sp/>a<sp/>PBUF_RAM<sp/>holding<sp/>the<sp/>link<sp/>and<sp/>IP<sp/>header.</highlight></codeline>
<codeline lineno="769"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>The<sp/>rest<sp/>will<sp/>be<sp/>PBUF_REFs<sp/>mirroring<sp/>the<sp/>pbuf<sp/>chain<sp/>to<sp/>be<sp/>fragged,</highlight></codeline>
<codeline lineno="770"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>but<sp/>limited<sp/>to<sp/>the<sp/>size<sp/>of<sp/>an<sp/>mtu.</highlight></codeline>
<codeline lineno="771"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/><sp/><sp/>rambuf<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfab4de441e737330558b609a990cd17346" kindref="member">PBUF_LINK</ref>,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="773"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rambuf<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="774"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="775"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="776"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;this<sp/>needs<sp/>a<sp/>pbuf<sp/>in<sp/>one<sp/>piece!&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="777"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/>(<ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>)));</highlight></codeline>
<codeline lineno="778"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1a8c6e3c1e4f74acb16376188dbf8909ec" kindref="member">SMEMCPY</ref>(rambuf-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>,<sp/>original_iphdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="779"><highlight class="normal"><sp/><sp/><sp/><sp/>iphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__hdr" kindref="compound">ip_hdr</ref><sp/>*)rambuf-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="780"><highlight class="normal"></highlight></codeline>
<codeline lineno="781"><highlight class="normal"><sp/><sp/><sp/><sp/>left_to_copy<sp/>=<sp/>fragsize;</highlight></codeline>
<codeline lineno="782"><highlight class="normal"><sp/><sp/><sp/><sp/>while<sp/>(left_to_copy)<sp/>{</highlight></codeline>
<codeline lineno="783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">pbuf_custom_ref<sp/>*pcr;</highlight></codeline>
<codeline lineno="784"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>plen<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>-<sp/>poff;</highlight></codeline>
<codeline lineno="785"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>newpbuflen<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(left_to_copy,<sp/>plen);</highlight></codeline>
<codeline lineno="786"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Is<sp/>this<sp/>pbuf<sp/>already<sp/>empty?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="787"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!newpbuflen)<sp/>{</highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>poff<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>;</highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">continue</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="792"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcr<sp/>=<sp/>ip_frag_alloc_pbuf_custom_ref();</highlight></codeline>
<codeline lineno="793"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="794"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rambuf);</highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Mirror<sp/>this<sp/>pbuf,<sp/>although<sp/>we<sp/>might<sp/>not<sp/>need<sp/>all<sp/>of<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>newpbuf<sp/>=<sp/>pbuf_alloced_custom(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa21116654fbab6d5a4dfeb87a1bb8f0ba" kindref="member">PBUF_RAW</ref>,<sp/>newpbuflen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac9b6ba960fdea6f2e8f35c8313b77e4e" kindref="member">PBUF_REF</ref>,<sp/>&amp;pcr-&gt;pc,</highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>+<sp/>poff,<sp/>newpbuflen);</highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(newpbuf<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip_frag_free_pbuf_custom_ref(pcr);</highlight></codeline>
<codeline lineno="802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rambuf);</highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga77f6bbd69e45e542014d9c547c7da74e" kindref="member">pbuf_ref</ref>(p);</highlight></codeline>
<codeline lineno="806"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcr-&gt;original<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="807"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcr-&gt;pc.custom_free_function<sp/>=<sp/>ipfrag_free_pbuf_custom;</highlight></codeline>
<codeline lineno="808"><highlight class="normal"></highlight></codeline>
<codeline lineno="809"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Add<sp/>it<sp/>to<sp/>end<sp/>of<sp/>rambuf&apos;s<sp/>chain,<sp/>but<sp/>using<sp/>pbuf_cat,<sp/>not<sp/>pbuf_chain</highlight></codeline>
<codeline lineno="810"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>so<sp/>that<sp/>it<sp/>is<sp/>removed<sp/>when<sp/>pbuf_dechain<sp/>is<sp/>later<sp/>called<sp/>on<sp/>rambuf.</highlight></codeline>
<codeline lineno="811"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="812"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(rambuf,<sp/>newpbuf);</highlight></codeline>
<codeline lineno="813"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>left_to_copy<sp/>-=<sp/>newpbuflen;</highlight></codeline>
<codeline lineno="814"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(left_to_copy)<sp/>{</highlight></codeline>
<codeline lineno="815"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>poff<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="816"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>;</highlight></codeline>
<codeline lineno="817"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="818"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="819"><highlight class="normal"><sp/><sp/><sp/><sp/>poff<sp/>+=<sp/>newpbuflen;</highlight></codeline>
<codeline lineno="820"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="821"><highlight class="normal"></highlight></codeline>
<codeline lineno="822"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Correct<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="823"><highlight class="normal"><sp/><sp/><sp/><sp/>last<sp/>=<sp/>(left<sp/>&lt;=<sp/><ref refid="structnetif" kindref="compound">netif</ref>-&gt;<ref refid="structnetif_1aca7d56b4e0f822b0ced2885f222b8d48" kindref="member">mtu</ref><sp/>-<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>);</highlight></codeline>
<codeline lineno="824"><highlight class="normal"></highlight></codeline>
<codeline lineno="825"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>new<sp/>offset<sp/>and<sp/>MF<sp/>flag<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/><sp/><sp/>tmp<sp/>=<sp/>(<ref refid="prot_2ip4_8h_1ad059798b16d1f615b5af8770175121ba" kindref="member">IP_OFFMASK</ref><sp/>&amp;<sp/>(ofo));</highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!last)<sp/>{</highlight></codeline>
<codeline lineno="828"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tmp<sp/>=<sp/>tmp<sp/>|<sp/><ref refid="prot_2ip4_8h_1ae8afe1e04bb9bad791443556c3b2cd73" kindref="member">IP_MF</ref>;</highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="830"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1a4c2189e1400dca1c0f785de96ceda2b6" kindref="member">IPH_OFFSET_SET</ref>(iphdr,<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(tmp));</highlight></codeline>
<codeline lineno="831"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1a069cb9b3765c4bdd63d13efb2df0206e" kindref="member">IPH_LEN_SET</ref>(iphdr,<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(fragsize<sp/>+<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>));</highlight></codeline>
<codeline lineno="832"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1aec30403fb98b013bd094688de55cdaef" kindref="member">IPH_CHKSUM_SET</ref>(iphdr,<sp/>0);</highlight></codeline>
<codeline lineno="833"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_IP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="834"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_IP)<sp/>{</highlight></codeline>
<codeline lineno="835"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2ip4_8h_1aec30403fb98b013bd094688de55cdaef" kindref="member">IPH_CHKSUM_SET</ref>(iphdr,<sp/><ref refid="inet__chksum_8h_1a34f1aa1587562a09e11b704b51bab043" kindref="member">inet_chksum</ref>(iphdr,<sp/><ref refid="prot_2ip4_8h_1ad76777d4d34f33ab5f715f9ca15503c3" kindref="member">IP_HLEN</ref>));</highlight></codeline>
<codeline lineno="836"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="837"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_IP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="838"><highlight class="normal"></highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>need<sp/>for<sp/>separate<sp/>header<sp/>pbuf<sp/>-<sp/>we<sp/>allowed<sp/>room<sp/>for<sp/>it<sp/>in<sp/>rambuf</highlight></codeline>
<codeline lineno="840"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>when<sp/>allocated.</highlight></codeline>
<codeline lineno="841"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref>-&gt;output(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>rambuf,<sp/>dest);</highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a2eb4cc22608c8abe8595e90efd56ae81" kindref="member">IPFRAG_STATS_INC</ref>(ip_frag.xmit);</highlight></codeline>
<codeline lineno="844"><highlight class="normal"></highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Unfortunately<sp/>we<sp/>can&apos;t<sp/>reuse<sp/>rambuf<sp/>-<sp/>the<sp/>hardware<sp/>may<sp/>still<sp/>be</highlight></codeline>
<codeline lineno="846"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>using<sp/>the<sp/>buffer.<sp/>Instead<sp/>we<sp/>free<sp/>it<sp/>(and<sp/>the<sp/>ensuing<sp/>chain)<sp/>and</highlight></codeline>
<codeline lineno="847"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>recreate<sp/>it<sp/>next<sp/>time<sp/>round<sp/>the<sp/>loop.<sp/>If<sp/>we&apos;re<sp/>lucky<sp/>the<sp/>hardware</highlight></codeline>
<codeline lineno="848"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>will<sp/>have<sp/>already<sp/>sent<sp/>the<sp/>packet,<sp/>the<sp/>free<sp/>will<sp/>really<sp/>free,<sp/>and</highlight></codeline>
<codeline lineno="849"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>there<sp/>will<sp/>be<sp/>zero<sp/>memory<sp/>penalty.</highlight></codeline>
<codeline lineno="850"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="851"><highlight class="normal"></highlight></codeline>
<codeline lineno="852"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rambuf);</highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/><sp/><sp/>left<sp/>-=<sp/>fragsize;</highlight></codeline>
<codeline lineno="854"><highlight class="normal"><sp/><sp/><sp/><sp/>ofo<sp/>+=<sp/>nfb;</highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.ipfragoks);</highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="858"><highlight class="normal">memerr:</highlight></codeline>
<codeline lineno="859"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.ipfragfails);</highlight></codeline>
<codeline lineno="860"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="861"><highlight class="normal">}</highlight></codeline>
<codeline lineno="862"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_FRAG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="863"><highlight class="normal"></highlight></codeline>
<codeline lineno="864"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/net/core/ipv4/ip4_frag.c"/>
  </compounddef>
</doxygen>
