<?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="tcp__in_8c" kind="file" language="C++">
    <compoundname>tcp_in.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="1">
        <label>C:/Dev/git/UbixOS/sys/net/core/tcp_in.c</label>
        <link refid="tcp__in_8c"/>
        <childnode refid="2" 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="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>Transmission Control Protocol, incoming traffic</para>
<para>The input processing functions of the TCP layer.</para>
<para>These functions are generally called in the order (ip_input() -&gt;) tcp_input() -&gt; * tcp_process() -&gt; tcp_receive() (-&gt; application). </para>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="12"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="13"><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="14"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="15"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="16"><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="17"><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="18"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="19"><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="20"><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="21"><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="22"><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="23"><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="24"><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="25"><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="26"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="27"><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="28"><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="29"><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="30"><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="31"><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="32"><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="33"><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="34"><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="35"><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="36"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="37"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="38"><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="39"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="40"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Adam<sp/>Dunkels<sp/>&lt;adam@sics.se&gt;</highlight></codeline>
<codeline lineno="41"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="42"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><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="45"><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP<sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>build<sp/>if<sp/>not<sp/>configured<sp/>for<sp/>use<sp/>in<sp/>lwipopts.h<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="tcp__priv_8h" kindref="compound">net/priv/tcp_priv.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="49"><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="50"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip__addr_8h" kindref="compound">net/ip_addr.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="51"><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="52"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="mem_8h" kindref="compound">net/mem.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="memp_8h" kindref="compound">net/memp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><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="55"><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="56"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip6_8h" kindref="compound">net/ip6.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip6__addr_8h" kindref="compound">net/ip6_addr.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="nd6_8h" kindref="compound">net/nd6.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="60"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight></codeline>
<codeline lineno="63"><highlight class="preprocessor">#define<sp/>LWIP_TCP_CALC_INITIAL_CWND(mss)<sp/>LWIP_MIN((4U<sp/>*<sp/>(mss)),<sp/>LWIP_MAX((2U<sp/>*<sp/>(mss)),<sp/>4380U));</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="64"><highlight class="normal"></highlight></codeline>
<codeline lineno="65"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>These<sp/>variables<sp/>are<sp/>global<sp/>to<sp/>all<sp/>functions<sp/>involved<sp/>in<sp/>the<sp/>input</highlight></codeline>
<codeline lineno="66"><highlight class="comment"><sp/><sp/><sp/>processing<sp/>of<sp/>TCP<sp/>segments.<sp/>They<sp/>are<sp/>set<sp/>by<sp/>the<sp/>tcp_input()</highlight></codeline>
<codeline lineno="67"><highlight class="comment"><sp/><sp/><sp/>function.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>inseg;</highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structtcp__hdr" kindref="compound">tcp_hdr</ref><sp/>*tcphdr;</highlight></codeline>
<codeline lineno="70"><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/>tcphdr_optlen;</highlight></codeline>
<codeline lineno="71"><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/>tcphdr_opt1len;</highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*<sp/>tcphdr_opt2;</highlight></codeline>
<codeline lineno="73"><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/>tcp_optidx;</highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>seqno,<sp/>ackno;</highlight></codeline>
<codeline lineno="75"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/>tcpwnd_size_t<sp/>recv_acked;</highlight></codeline>
<codeline lineno="76"><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/>tcplen;</highlight></codeline>
<codeline lineno="77"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>flags;</highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>recv_flags;</highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*recv_data;</highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*tcp_input_pcb;</highlight></codeline>
<codeline lineno="83"><highlight class="normal"></highlight></codeline>
<codeline lineno="84"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Forward<sp/>declarations.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>tcp_process(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb);</highlight></codeline>
<codeline lineno="86"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>tcp_receive(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb);</highlight></codeline>
<codeline lineno="87"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>tcp_parseopt(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb);</highlight></codeline>
<codeline lineno="88"><highlight class="normal"></highlight></codeline>
<codeline lineno="89"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>tcp_listen_input(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb_listen<sp/>*pcb);</highlight></codeline>
<codeline lineno="90"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>tcp_timewait_input(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb);</highlight></codeline>
<codeline lineno="91"><highlight class="normal"></highlight></codeline>
<codeline lineno="92"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>tcp_input_delayed_close(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb);</highlight></codeline>
<codeline lineno="93"><highlight class="normal"></highlight></codeline>
<codeline lineno="103"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="104"><highlight class="normal">tcp_input(</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/>*inp)</highlight></codeline>
<codeline lineno="105"><highlight class="normal">{</highlight></codeline>
<codeline lineno="106"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*pcb,<sp/>*prev;</highlight></codeline>
<codeline lineno="107"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb_listen<sp/>*lpcb;</highlight></codeline>
<codeline lineno="108"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*lpcb_prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb_listen<sp/>*lpcb_any<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="111"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>hdrlen_bytes;</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="114"><highlight class="normal"></highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(inp);</highlight></codeline>
<codeline lineno="116"><highlight class="normal"></highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/><ref refid="perf_8h_1aa1d6977095e51331f65dcfb2b076da52" kindref="member">PERF_START</ref>;</highlight></codeline>
<codeline lineno="118"><highlight class="normal"></highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.recv);</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpinsegs);</highlight></codeline>
<codeline lineno="121"><highlight class="normal"></highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/>tcphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structtcp__hdr" kindref="compound">tcp_hdr</ref><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="123"><highlight class="normal"></highlight></codeline>
<codeline lineno="124"><highlight class="normal">#</highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/><ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref></highlight></codeline>
<codeline lineno="125"><highlight class="normal"><sp/><sp/>tcp_debug_print(tcphdr);</highlight></codeline>
<codeline lineno="126"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="127"><highlight class="normal"></highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>that<sp/>TCP<sp/>header<sp/>fits<sp/>in<sp/>payload<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&lt;<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>drop<sp/>short<sp/>packets<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="131"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>short<sp/>packet<sp/>(%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>bytes)<sp/>discarded\n&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.lenerr);</highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>dropped;</highlight></codeline>
<codeline lineno="134"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="135"><highlight class="normal"></highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>even<sp/>process<sp/>incoming<sp/>broadcasts/multicasts.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a11275b39f9b8e876e8124a16410e8840" kindref="member">ip_addr_isbroadcast</ref>(<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),<sp/><ref refid="ip_8h_1aabecef3c7653a9767c79245c44fcab9f" kindref="member">ip_current_netif</ref>())<sp/>||</highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.proterr);</highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>dropped;</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="142"><highlight class="normal"></highlight></codeline>
<codeline lineno="143"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_CHECK_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(inp,<sp/>NETIF_CHECKSUM_CHECK_TCP)<sp/>{</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Verify<sp/>TCP<sp/>checksum.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1aa13cda42e7c262f5dee243ff6c28422f" kindref="member">ip_chksum_pseudo</ref>(p,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,</highlight></codeline>
<codeline lineno="147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>());</highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(chksum<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>packet<sp/>discarded<sp/>due<sp/>to<sp/>failing<sp/>checksum<sp/>0x%04&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="150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chksum));</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_debug_print(tcphdr);</highlight></codeline>
<codeline lineno="152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.chkerr);</highlight></codeline>
<codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>dropped;</highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="156"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_CHECK_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="157"><highlight class="normal"></highlight></codeline>
<codeline lineno="158"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>sanity-check<sp/>header<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><highlight class="normal"><sp/><sp/>hdrlen_bytes<sp/>=<sp/><ref refid="prot_2tcp_8h_1a5b97d3b7e68c20eb3eab87a61d779223" kindref="member">TCPH_HDRLEN</ref>(tcphdr)<sp/>*<sp/>4;</highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((hdrlen_bytes<sp/>&lt;<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>)<sp/>||<sp/>(hdrlen_bytes<sp/>&gt;<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>))<sp/>{</highlight></codeline>
<codeline lineno="161"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>invalid<sp/>header<sp/>length<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">,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)hdrlen_bytes));</highlight></codeline>
<codeline lineno="162"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.lenerr);</highlight></codeline>
<codeline lineno="163"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>dropped;</highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="165"><highlight class="normal"></highlight></codeline>
<codeline lineno="166"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Move<sp/>the<sp/>payload<sp/>pointer<sp/>in<sp/>the<sp/>pbuf<sp/>so<sp/>that<sp/>it<sp/>points<sp/>to<sp/>the</highlight></codeline>
<codeline lineno="167"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>TCP<sp/>data<sp/>instead<sp/>of<sp/>the<sp/>TCP<sp/>header.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="168"><highlight class="normal"><sp/><sp/>tcphdr_optlen<sp/>=<sp/>hdrlen_bytes<sp/>-<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>;</highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/>tcphdr_opt2<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="170"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/>hdrlen_bytes)<sp/>{</highlight></codeline>
<codeline lineno="171"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>all<sp/>options<sp/>are<sp/>in<sp/>the<sp/>first<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="172"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr_opt1len<sp/>=<sp/>tcphdr_optlen;</highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>-(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)hdrlen_bytes);<sp/></highlight><highlight class="comment">/*<sp/>cannot<sp/>fail<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="174"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="175"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>opt2len;</highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>TCP<sp/>header<sp/>fits<sp/>into<sp/>first<sp/>pbuf,<sp/>options<sp/>don&apos;t<sp/>-<sp/>data<sp/>is<sp/>in<sp/>the<sp/>next<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>there<sp/>must<sp/>be<sp/>a<sp/>next<sp/>pbuf,<sp/>due<sp/>to<sp/>hdrlen_bytes<sp/>sanity<sp/>check<sp/>above<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;p-&gt;next<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>p-&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="179"><highlight class="normal"></highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>advance<sp/>over<sp/>the<sp/>TCP<sp/>header<sp/>(cannot<sp/>fail)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>-<ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>);</highlight></codeline>
<codeline lineno="182"><highlight class="normal"></highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>determine<sp/>how<sp/>long<sp/>the<sp/>first<sp/>and<sp/>second<sp/>parts<sp/>of<sp/>the<sp/>options<sp/>are<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr_opt1len<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>;</highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/><sp/><sp/>opt2len<sp/>=<sp/>tcphdr_optlen<sp/>-<sp/>tcphdr_opt1len;</highlight></codeline>
<codeline lineno="186"><highlight class="normal"></highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>options<sp/>continue<sp/>in<sp/>the<sp/>next<sp/>pbuf:<sp/>set<sp/>p<sp/>to<sp/>zero<sp/>length<sp/>and<sp/>hide<sp/>the</highlight></codeline>
<codeline lineno="188"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>options<sp/>in<sp/>the<sp/>next<sp/>pbuf<sp/>(adjusting<sp/>p-&gt;tot_len)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>-(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)tcphdr_opt1len);</highlight></codeline>
<codeline lineno="190"><highlight class="normal"></highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>that<sp/>the<sp/>options<sp/>fit<sp/>in<sp/>the<sp/>second<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(opt2len<sp/>&gt;<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>)<sp/>{</highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>drop<sp/>short<sp/>packets<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>options<sp/>overflow<sp/>second<sp/>pbuf<sp/>(%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>bytes)\n&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>));</highlight></codeline>
<codeline lineno="195"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.lenerr);</highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>dropped;</highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="198"><highlight class="normal"></highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remember<sp/>the<sp/>pointer<sp/>to<sp/>the<sp/>second<sp/>part<sp/>of<sp/>the<sp/>options<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr_opt2<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="201"><highlight class="normal"></highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>advance<sp/>p-&gt;next<sp/>to<sp/>point<sp/>after<sp/>the<sp/>options,<sp/>and<sp/>manually</highlight></codeline>
<codeline lineno="203"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>adjust<sp/>p-&gt;tot_len<sp/>to<sp/>keep<sp/>it<sp/>consistent<sp/>with<sp/>the<sp/>changed<sp/>p-&gt;next<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>,<sp/>-(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)opt2len);</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>-=<sp/>opt2len;</highlight></codeline>
<codeline lineno="206"><highlight class="normal"></highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;p-&gt;len<sp/>==<sp/>0&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;p-&gt;tot_len<sp/>==<sp/>p-&gt;next-&gt;tot_len&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>==<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>);</highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="210"><highlight class="normal"></highlight></codeline>
<codeline lineno="211"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Convert<sp/>fields<sp/>in<sp/>TCP<sp/>header<sp/>to<sp/>host<sp/>byte<sp/>order.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="212"><highlight class="normal"><sp/><sp/>tcphdr-&gt;src<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/>tcphdr-&gt;dest<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(tcphdr-&gt;dest);</highlight></codeline>
<codeline lineno="214"><highlight class="normal"><sp/><sp/>seqno<sp/>=<sp/>tcphdr-&gt;seqno<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/>ackno<sp/>=<sp/>tcphdr-&gt;ackno<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(tcphdr-&gt;ackno);</highlight></codeline>
<codeline lineno="216"><highlight class="normal"><sp/><sp/>tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(tcphdr-&gt;wnd);</highlight></codeline>
<codeline lineno="217"><highlight class="normal"></highlight></codeline>
<codeline lineno="218"><highlight class="normal"><sp/><sp/>flags<sp/>=<sp/><ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(tcphdr);</highlight></codeline>
<codeline lineno="219"><highlight class="normal"><sp/><sp/>tcplen<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>+<sp/>((flags<sp/>&amp;<sp/>(<ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>))<sp/>?<sp/>1<sp/>:<sp/>0);</highlight></codeline>
<codeline lineno="220"><highlight class="normal"></highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Demultiplex<sp/>an<sp/>incoming<sp/>segment.<sp/>First,<sp/>we<sp/>check<sp/>if<sp/>it<sp/>is<sp/>destined</highlight></codeline>
<codeline lineno="222"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>for<sp/>an<sp/>active<sp/>connection.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="223"><highlight class="normal"><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="224"><highlight class="normal"></highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(pcb<sp/>=<sp/>tcp_active_pcbs;<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>pcb<sp/>=<sp/>pcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="226"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>active<sp/>pcb-&gt;state<sp/>!=<sp/>CLOSED&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>!=<sp/>CLOSED);</highlight></codeline>
<codeline lineno="227"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>active<sp/>pcb-&gt;state<sp/>!=<sp/>TIME-WAIT&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>!=<sp/>TIME_WAIT);</highlight></codeline>
<codeline lineno="228"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>active<sp/>pcb-&gt;state<sp/>!=<sp/>LISTEN&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>!=<sp/>LISTEN);</highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;remote_port<sp/>==<sp/>tcphdr-&gt;src<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;local_port<sp/>==<sp/>tcphdr-&gt;dest<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="231"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;remote_ip,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>())<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;local_ip,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Move<sp/>this<sp/>PCB<sp/>to<sp/>the<sp/>front<sp/>of<sp/>the<sp/>list<sp/>so<sp/>that<sp/>subsequent</highlight></codeline>
<codeline lineno="234"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lookups<sp/>will<sp/>be<sp/>faster<sp/>(we<sp/>exploit<sp/>locality<sp/>in<sp/>TCP<sp/>segment</highlight></codeline>
<codeline lineno="235"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>arrivals).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="236"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>pcb-&gt;next<sp/>!=<sp/>pcb<sp/>(before<sp/>cache)&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;next<sp/>!=<sp/>pcb);</highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/><sp/><sp/><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="238"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/>pcb-&gt;next;</highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;next<sp/>=<sp/>tcp_active_pcbs;</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_active_pcbs<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.cachehit);</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>pcb-&gt;next<sp/>!=<sp/>pcb<sp/>(after<sp/>cache)&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;next<sp/>!=<sp/>pcb);</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="249"><highlight class="normal"></highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>it<sp/>did<sp/>not<sp/>go<sp/>to<sp/>an<sp/>active<sp/>connection,<sp/>we<sp/>check<sp/>the<sp/>connections</highlight></codeline>
<codeline lineno="252"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>the<sp/>TIME-WAIT<sp/>state.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(pcb<sp/>=<sp/>tcp_tw_pcbs;<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>pcb<sp/>=<sp/>pcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>TIME-WAIT<sp/>pcb-&gt;state<sp/>==<sp/>TIME-WAIT&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>==<sp/>TIME_WAIT);</highlight></codeline>
<codeline lineno="255"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;remote_port<sp/>==<sp/>tcphdr-&gt;src<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;local_port<sp/>==<sp/>tcphdr-&gt;dest<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;remote_ip,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>())<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;local_ip,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>don&apos;t<sp/>really<sp/>care<sp/>enough<sp/>to<sp/>move<sp/>this<sp/>PCB<sp/>to<sp/>the<sp/>front</highlight></codeline>
<codeline lineno="260"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>of<sp/>the<sp/>list<sp/>since<sp/>we<sp/>are<sp/>not<sp/>very<sp/>likely<sp/>to<sp/>receive<sp/>that</highlight></codeline>
<codeline lineno="261"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>many<sp/>segments<sp/>for<sp/>connections<sp/>in<sp/>TIME-WAIT.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>packed<sp/>for<sp/>TIME_WAITing<sp/>connection.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_timewait_input(pcb);</highlight></codeline>
<codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="265"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="267"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="268"><highlight class="normal"></highlight></codeline>
<codeline lineno="269"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Finally,<sp/>if<sp/>we<sp/>still<sp/>did<sp/>not<sp/>get<sp/>a<sp/>match,<sp/>we<sp/>check<sp/>all<sp/>PCBs<sp/>that</highlight></codeline>
<codeline lineno="270"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>are<sp/>LISTENing<sp/>for<sp/>incoming<sp/>connections.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="272"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(lpcb<sp/>=<sp/>tcp_listen_pcbs.listen_pcbs;<sp/>lpcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>lpcb<sp/>=<sp/>lpcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="273"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lpcb-&gt;local_port<sp/>==<sp/>tcphdr-&gt;dest)<sp/>{</highlight></codeline>
<codeline lineno="274"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(lpcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="275"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>found<sp/>an<sp/>ANY<sp/>TYPE<sp/>(IPv4/IPv6)<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="276"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="277"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb_any<sp/>=<sp/>lpcb;</highlight></codeline>
<codeline lineno="278"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb_prev<sp/>=<sp/>prev;</highlight></codeline>
<codeline lineno="279"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="280"><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="281"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="282"><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/>(<ref refid="ip__addr_8h_1a81ed1fbe375d867d6e77c83976c07671" kindref="member">IP_ADDR_PCB_VERSION_MATCH_EXACT</ref>(lpcb,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="283"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;lpcb-&gt;local_ip,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="284"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>found<sp/>an<sp/>exact<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="285"><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="286"><highlight class="normal"><sp/><sp/><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/>(<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;lpcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="287"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>found<sp/>an<sp/>ANY-match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="288"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb_any<sp/>=<sp/>lpcb;</highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb_prev<sp/>=<sp/>prev;</highlight></codeline>
<codeline lineno="291"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="292"><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="293"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/>#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="294"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="295"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="297"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*)lpcb;</highlight></codeline>
<codeline lineno="298"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="299"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="300"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>first<sp/>try<sp/>specific<sp/>local<sp/>IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="301"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lpcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="302"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>only<sp/>pass<sp/>to<sp/>ANY<sp/>if<sp/>no<sp/>specific<sp/>local<sp/>IP<sp/>has<sp/>been<sp/>found<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="303"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>lpcb<sp/>=<sp/>lpcb_any;</highlight></codeline>
<codeline lineno="304"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>lpcb_prev;</highlight></codeline>
<codeline lineno="305"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="306"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="307"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lpcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="308"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Move<sp/>this<sp/>PCB<sp/>to<sp/>the<sp/>front<sp/>of<sp/>the<sp/>list<sp/>so<sp/>that<sp/>subsequent</highlight></codeline>
<codeline lineno="309"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lookups<sp/>will<sp/>be<sp/>faster<sp/>(we<sp/>exploit<sp/>locality<sp/>in<sp/>TCP<sp/>segment</highlight></codeline>
<codeline lineno="310"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>arrivals).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><sp/><sp/><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="312"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb_listen<sp/>*)prev)-&gt;next<sp/>=<sp/>lpcb-&gt;next;</highlight></codeline>
<codeline lineno="313"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>our<sp/>successor<sp/>is<sp/>the<sp/>remainder<sp/>of<sp/>the<sp/>listening<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb-&gt;next<sp/>=<sp/>tcp_listen_pcbs.listen_pcbs;</highlight></codeline>
<codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>put<sp/>this<sp/>listening<sp/>pcb<sp/>at<sp/>the<sp/>head<sp/>of<sp/>the<sp/>listening<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="316"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_listen_pcbs.listen_pcbs<sp/>=<sp/>lpcb;</highlight></codeline>
<codeline lineno="317"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="318"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.cachehit);</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="320"><highlight class="normal"></highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>packed<sp/>for<sp/>LISTENing<sp/>connection.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_listen_input(lpcb);</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="327"><highlight class="normal"></highlight></codeline>
<codeline lineno="328"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_INPUT_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="329"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;+-+-+-+-+-+-+-+-+-+-+-+-+-+-<sp/>tcp_input:<sp/>flags<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/>tcp_debug_print_flags(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(tcphdr));</highlight></codeline>
<codeline lineno="331"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="332"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_INPUT_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="333"><highlight class="normal"></highlight></codeline>
<codeline lineno="334"><highlight class="normal"></highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="336"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>incoming<sp/>segment<sp/>belongs<sp/>to<sp/>a<sp/>connection.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="337"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_INPUT_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="338"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_debug_print_state(pcb-&gt;state);</highlight></codeline>
<codeline lineno="339"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_INPUT_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="340"><highlight class="normal"></highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>up<sp/>a<sp/>tcp_seg<sp/>structure.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="342"><highlight class="normal"><sp/><sp/><sp/><sp/>inseg.next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="343"><highlight class="normal"><sp/><sp/><sp/><sp/>inseg.len<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="344"><highlight class="normal"><sp/><sp/><sp/><sp/>inseg.p<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="345"><highlight class="normal"><sp/><sp/><sp/><sp/>inseg.tcphdr<sp/>=<sp/>tcphdr;</highlight></codeline>
<codeline lineno="346"><highlight class="normal"></highlight></codeline>
<codeline lineno="347"><highlight class="normal"><sp/><sp/><sp/><sp/>recv_data<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="348"><highlight class="normal"><sp/><sp/><sp/><sp/>recv_flags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="349"><highlight class="normal"><sp/><sp/><sp/><sp/>recv_acked<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="350"><highlight class="normal"></highlight></codeline>
<codeline lineno="351"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a1320fd0006a2f70138bc2d0018dda829" kindref="member">TCP_PSH</ref>)<sp/>{</highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>|=<sp/><ref refid="pbuf_8h_1a018a6499e357f8a1373321f802a82930" kindref="member">PBUF_FLAG_PUSH</ref>;</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="354"><highlight class="normal"></highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>there<sp/>is<sp/>data<sp/>which<sp/>was<sp/>previously<sp/>&quot;refused&quot;<sp/>by<sp/>upper<sp/>layer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="356"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;refused_data<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcp_process_refused_data(pcb)<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>||</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((pcb-&gt;refused_data<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(tcplen<sp/>&gt;<sp/>0)))<sp/>{</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>has<sp/>been<sp/>aborted<sp/>or<sp/>refused<sp/>data<sp/>is<sp/>still<sp/>refused<sp/>and<sp/>the<sp/>new</highlight></codeline>
<codeline lineno="360"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment<sp/>contains<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="361"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rcv_ann_wnd<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>is<sp/>a<sp/>zero-window<sp/>probe,<sp/>we<sp/>respond<sp/>to<sp/>it<sp/>with<sp/>current<sp/>RCV.NXT</highlight></codeline>
<codeline lineno="363"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>drop<sp/>the<sp/>data<sp/>segment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_send_empty_ack(pcb);</highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.drop);</highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpinerrs);</highlight></codeline>
<codeline lineno="368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_input_pcb<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>tcp_process(pcb);</highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>A<sp/>return<sp/>value<sp/>of<sp/>ERR_ABRT<sp/>means<sp/>that<sp/>tcp_abort()<sp/>was<sp/>called</highlight></codeline>
<codeline lineno="374"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>that<sp/>the<sp/>pcb<sp/>has<sp/>been<sp/>freed.<sp/>If<sp/>so,<sp/>we<sp/>don&apos;t<sp/>do<sp/>anything.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="376"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_RESET)<sp/>{</highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>TF_RESET<sp/>means<sp/>that<sp/>the<sp/>connection<sp/>was<sp/>reset<sp/>by<sp/>the<sp/>other</highlight></codeline>
<codeline lineno="378"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>end.<sp/>We<sp/>then<sp/>call<sp/>the<sp/>error<sp/>callback<sp/>to<sp/>inform<sp/>the</highlight></codeline>
<codeline lineno="379"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>application<sp/>that<sp/>the<sp/>connection<sp/>is<sp/>dead<sp/>before<sp/>we</highlight></codeline>
<codeline lineno="380"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>deallocate<sp/>the<sp/>PCB.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="381"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_ERR(pcb-&gt;state,<sp/>pcb-&gt;errf,<sp/>pcb-&gt;callback_arg,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca759030525f1768a23dc086a5fd45b4e5" kindref="member">ERR_RST</ref>);</highlight></codeline>
<codeline lineno="382"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_pcb_remove(&amp;tcp_active_pcbs,<sp/>pcb);</highlight></codeline>
<codeline lineno="383"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_TCP_PCB,<sp/>pcb);</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="385"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>application<sp/>has<sp/>registered<sp/>a<sp/>&quot;sent&quot;<sp/>function<sp/>to<sp/>be</highlight></codeline>
<codeline lineno="387"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>called<sp/>when<sp/>new<sp/>send<sp/>buffer<sp/>space<sp/>is<sp/>available,<sp/>we<sp/>call<sp/>it</highlight></codeline>
<codeline lineno="388"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>now.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="389"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_acked<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>acked16;</highlight></codeline>
<codeline lineno="391"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</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="comment">/*<sp/>recv_acked<sp/>is<sp/>u32_t<sp/>but<sp/>the<sp/>sent<sp/>callback<sp/>only<sp/>takes<sp/>a<sp/>u16_t,</highlight></codeline>
<codeline lineno="393"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>so<sp/>we<sp/>might<sp/>have<sp/>to<sp/>call<sp/>it<sp/>multiple<sp/>times.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="394"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>acked<sp/>=<sp/>recv_acked;</highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(acked<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acked16<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)<ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(acked,<sp/>0xffffu);</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acked<sp/>-=<sp/>acked16;</highlight></codeline>
<codeline lineno="398"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acked16<sp/>=<sp/>recv_acked;</highlight></codeline>
<codeline lineno="401"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_SENT(pcb,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)acked16,<sp/>err);</highlight></codeline>
<codeline lineno="403"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="404"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="406"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_acked<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_input_delayed_close(pcb))<sp/>{</highlight></codeline>
<codeline lineno="410"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="412"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(recv_data<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*rest<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pbuf_split_64k(recv_data,<sp/>&amp;rest);</highlight></codeline>
<codeline lineno="416"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_data<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="418"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="419"><highlight class="normal"></highlight></codeline>
<codeline lineno="420"><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;pcb-&gt;refused_data<sp/>==<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;refused_data<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_RXCLOSED)<sp/>{</highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>received<sp/>data<sp/>although<sp/>already<sp/>closed<sp/>-&gt;<sp/>abort<sp/>(send<sp/>RST)<sp/>to</highlight></codeline>
<codeline lineno="423"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>notify<sp/>the<sp/>remote<sp/>host<sp/>that<sp/>not<sp/>all<sp/>data<sp/>has<sp/>been<sp/>processed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(recv_data);</highlight></codeline>
<codeline lineno="425"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rest<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rest);</highlight></codeline>
<codeline lineno="428"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="429"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(pcb);</highlight></codeline>
<codeline lineno="431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="433"><highlight class="normal"></highlight></codeline>
<codeline lineno="434"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Notify<sp/>application<sp/>that<sp/>data<sp/>has<sp/>been<sp/>received.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="435"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_RECV(pcb,<sp/>recv_data,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>,<sp/>err);</highlight></codeline>
<codeline lineno="436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="437"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rest<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(rest);</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="441"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="444"><highlight class="normal"></highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>upper<sp/>layer<sp/>can&apos;t<sp/>receive<sp/>this<sp/>data,<sp/>store<sp/>it<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="447"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rest<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="449"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(recv_data,<sp/>rest);</highlight></codeline>
<codeline lineno="450"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="451"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="452"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;refused_data<sp/>=<sp/>recv_data;</highlight></codeline>
<codeline lineno="453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>keep<sp/>incoming<sp/>packet,<sp/>because<sp/>pcb<sp/>is<sp/>\&quot;full\&quot;\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="454"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="455"><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="456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Upper<sp/>layer<sp/>received<sp/>the<sp/>data,<sp/>go<sp/>on<sp/>with<sp/>the<sp/>rest<sp/>if<sp/>&gt;<sp/>64K<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_data<sp/>=<sp/>rest;</highlight></codeline>
<codeline lineno="459"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>&amp;&amp;<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="460"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="462"><highlight class="normal"></highlight></codeline>
<codeline lineno="463"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>a<sp/>FIN<sp/>segment<sp/>was<sp/>received,<sp/>we<sp/>call<sp/>the<sp/>callback</highlight></codeline>
<codeline lineno="464"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>function<sp/>with<sp/>a<sp/>NULL<sp/>buffer<sp/>to<sp/>indicate<sp/>EOF.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="465"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_GOT_FIN)<sp/>{</highlight></codeline>
<codeline lineno="466"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;refused_data<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="467"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Delay<sp/>this<sp/>if<sp/>we<sp/>have<sp/>refused<sp/>data.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="468"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;refused_data-&gt;<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>|=<sp/><ref refid="pbuf_8h_1a36a915aa2f6a188baa2862881407971e" kindref="member">PBUF_FLAG_TCP_FIN</ref>;</highlight></codeline>
<codeline lineno="469"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="470"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>correct<sp/>rcv_wnd<sp/>as<sp/>the<sp/>application<sp/>won&apos;t<sp/>call<sp/>tcp_recved()</highlight></codeline>
<codeline lineno="471"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>for<sp/>the<sp/>FIN&apos;s<sp/>seqno<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="472"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rcv_wnd<sp/>!=<sp/>TCP_WND_MAX(pcb))<sp/>{</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_wnd++;</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_CLOSED(pcb,<sp/>err);</highlight></codeline>
<codeline lineno="476"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="481"><highlight class="normal"></highlight></codeline>
<codeline lineno="482"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_input_pcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="483"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_input_delayed_close(pcb))<sp/>{</highlight></codeline>
<codeline lineno="484"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>aborted;</highlight></codeline>
<codeline lineno="485"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="486"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Try<sp/>to<sp/>send<sp/>something<sp/>out.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="487"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_output(pcb);</highlight></codeline>
<codeline lineno="488"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_INPUT_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="489"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="490"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_debug_print_state(pcb-&gt;state);</highlight></codeline>
<codeline lineno="491"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="492"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_INPUT_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="493"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="494"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="495"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Jump<sp/>target<sp/>if<sp/>pcb<sp/>has<sp/>been<sp/>aborted<sp/>in<sp/>a<sp/>callback<sp/>(by<sp/>calling<sp/>tcp_abort()).</highlight></codeline>
<codeline lineno="496"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Below<sp/>this<sp/>line,<sp/>&apos;pcb&apos;<sp/>may<sp/>not<sp/>be<sp/>dereferenced!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="497"><highlight class="normal">aborted:</highlight></codeline>
<codeline lineno="498"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_input_pcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="499"><highlight class="normal"><sp/><sp/><sp/><sp/>recv_data<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="500"><highlight class="normal"></highlight></codeline>
<codeline lineno="501"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>give<sp/>up<sp/>our<sp/>reference<sp/>to<sp/>inseg.p<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(inseg.p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(inseg.p);</highlight></codeline>
<codeline lineno="505"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>inseg.p<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="507"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="508"><highlight class="normal"></highlight></codeline>
<codeline lineno="509"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>no<sp/>matching<sp/>PCB<sp/>was<sp/>found,<sp/>send<sp/>a<sp/>TCP<sp/>RST<sp/>(reset)<sp/>to<sp/>the</highlight></codeline>
<codeline lineno="510"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sender.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a37596f7bbb9b7663826244ba54486679" kindref="member">TCP_RST_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>no<sp/>PCB<sp/>match<sp/>found,<sp/>resetting.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="512"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>))<sp/>{</highlight></codeline>
<codeline lineno="513"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.proterr);</highlight></codeline>
<codeline lineno="514"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.drop);</highlight></codeline>
<codeline lineno="515"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rst(ackno,<sp/>seqno<sp/>+<sp/>tcplen,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),</highlight></codeline>
<codeline lineno="516"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>tcphdr-&gt;dest,<sp/>tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="517"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="518"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="520"><highlight class="normal"></highlight></codeline>
<codeline lineno="521"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>tcp_pcbs_sane()&quot;</highlight><highlight class="normal">,<sp/>tcp_pcbs_sane());</highlight></codeline>
<codeline lineno="522"><highlight class="normal"><sp/><sp/><ref refid="perf_8h_1a8ac3afe5d720793a229fbf70a78eb82f" kindref="member">PERF_STOP</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="524"><highlight class="normal">dropped:</highlight></codeline>
<codeline lineno="525"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.drop);</highlight></codeline>
<codeline lineno="526"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpinerrs);</highlight></codeline>
<codeline lineno="527"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="528"><highlight class="normal">}</highlight></codeline>
<codeline lineno="529"><highlight class="normal"></highlight></codeline>
<codeline lineno="535"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="536"><highlight class="normal">tcp_input_delayed_close(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="537"><highlight class="normal">{</highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_CLOSED)<sp/>{</highlight></codeline>
<codeline lineno="539"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>connection<sp/>has<sp/>been<sp/>closed<sp/>and<sp/>we<sp/>will<sp/>deallocate<sp/>the</highlight></codeline>
<codeline lineno="540"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>PCB.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="541"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!(pcb-&gt;flags<sp/>&amp;<sp/>TF_RXCLOSED))<sp/>{</highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Connection<sp/>closed<sp/>although<sp/>the<sp/>application<sp/>has<sp/>only<sp/>shut<sp/>down<sp/>the</highlight></codeline>
<codeline lineno="543"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tx<sp/>side:<sp/>call<sp/>the<sp/>PCB&apos;s<sp/>err<sp/>callback<sp/>and<sp/>indicate<sp/>the<sp/>closure<sp/>to</highlight></codeline>
<codeline lineno="544"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ensure<sp/>the<sp/>application<sp/>doesn&apos;t<sp/>continue<sp/>using<sp/>the<sp/>PCB.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="545"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_ERR(pcb-&gt;state,<sp/>pcb-&gt;errf,<sp/>pcb-&gt;callback_arg,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>);</highlight></codeline>
<codeline lineno="546"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="547"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_pcb_remove(&amp;tcp_active_pcbs,<sp/>pcb);</highlight></codeline>
<codeline lineno="548"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_TCP_PCB,<sp/>pcb);</highlight></codeline>
<codeline lineno="549"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
<codeline lineno="550"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="551"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="552"><highlight class="normal">}</highlight></codeline>
<codeline lineno="553"><highlight class="normal"></highlight></codeline>
<codeline lineno="563"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="564"><highlight class="normal">tcp_listen_input(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb_listen<sp/>*pcb)</highlight></codeline>
<codeline lineno="565"><highlight class="normal">{</highlight></codeline>
<codeline lineno="566"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*npcb;</highlight></codeline>
<codeline lineno="567"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>iss;</highlight></codeline>
<codeline lineno="568"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>rc;</highlight></codeline>
<codeline lineno="569"><highlight class="normal"></highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>)<sp/>{</highlight></codeline>
<codeline lineno="571"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>An<sp/>incoming<sp/>RST<sp/>should<sp/>be<sp/>ignored.<sp/>Return.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="573"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="574"><highlight class="normal"></highlight></codeline>
<codeline lineno="575"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>In<sp/>the<sp/>LISTEN<sp/>state,<sp/>we<sp/>check<sp/>for<sp/>incoming<sp/>SYN<sp/>segments,</highlight></codeline>
<codeline lineno="576"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>creates<sp/>a<sp/>new<sp/>PCB,<sp/>and<sp/>responds<sp/>with<sp/>a<sp/>SYN|ACK.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="577"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>For<sp/>incoming<sp/>segments<sp/>with<sp/>the<sp/>ACK<sp/>flag<sp/>set,<sp/>respond<sp/>with<sp/>a</highlight></codeline>
<codeline lineno="579"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>RST.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a37596f7bbb9b7663826244ba54486679" kindref="member">TCP_RST_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_listen_input:<sp/>ACK<sp/>in<sp/>LISTEN,<sp/>sending<sp/>reset\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="581"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_rst(ackno,<sp/>seqno<sp/>+<sp/>tcplen,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),</highlight></codeline>
<codeline lineno="582"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>tcphdr-&gt;dest,<sp/>tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="583"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="584"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>request<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>tcphdr-&gt;src,<sp/>tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="585"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="586"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;accepts_pending<sp/>&gt;=<sp/>pcb-&gt;backlog)<sp/>{</highlight></codeline>
<codeline lineno="587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_listen_input:<sp/>listen<sp/>backlog<sp/>exceeded<sp/>for<sp/>port<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">,<sp/>tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="588"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="589"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="590"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="591"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb<sp/>=<sp/>tcp_alloc(pcb-&gt;prio);</highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>a<sp/>new<sp/>PCB<sp/>could<sp/>not<sp/>be<sp/>created<sp/>(probably<sp/>due<sp/>to<sp/>lack<sp/>of<sp/>memory),</highlight></codeline>
<codeline lineno="593"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>we<sp/>don&apos;t<sp/>do<sp/>anything,<sp/>but<sp/>rely<sp/>on<sp/>the<sp/>sender<sp/>will<sp/>retransmit<sp/>the</highlight></codeline>
<codeline lineno="594"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SYN<sp/>at<sp/>a<sp/>time<sp/>when<sp/>we<sp/>have<sp/>more<sp/>memory<sp/>available.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="595"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(npcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="596"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="597"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_listen_input:<sp/>could<sp/>not<sp/>allocate<sp/>PCB\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="598"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</highlight></codeline>
<codeline lineno="599"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_ACCEPT(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>pcb-&gt;callback_arg,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>,<sp/>err);</highlight></codeline>
<codeline lineno="600"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(err);<sp/></highlight><highlight class="comment">/*<sp/>err<sp/>not<sp/>useful<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="601"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="603"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="604"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;accepts_pending++;</highlight></codeline>
<codeline lineno="605"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;flags<sp/>|=<sp/>TF_BACKLOGPEND;</highlight></codeline>
<codeline lineno="606"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="607"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>up<sp/>the<sp/>new<sp/>PCB.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="608"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(npcb-&gt;local_ip,<sp/>*<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>());</highlight></codeline>
<codeline lineno="609"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(npcb-&gt;remote_ip,<sp/>*<ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>());</highlight></codeline>
<codeline lineno="610"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;local_port<sp/>=<sp/>pcb-&gt;local_port;</highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;remote_port<sp/>=<sp/>tcphdr-&gt;src;</highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;state<sp/>=<sp/>SYN_RCVD;</highlight></codeline>
<codeline lineno="613"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;rcv_nxt<sp/>=<sp/>seqno<sp/>+<sp/>1;</highlight></codeline>
<codeline lineno="614"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;rcv_ann_right_edge<sp/>=<sp/>npcb-&gt;rcv_nxt;</highlight></codeline>
<codeline lineno="615"><highlight class="normal"><sp/><sp/><sp/><sp/>iss<sp/>=<sp/>tcp_next_iss(npcb);</highlight></codeline>
<codeline lineno="616"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_wl2<sp/>=<sp/>iss;</highlight></codeline>
<codeline lineno="617"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_nxt<sp/>=<sp/>iss;</highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;lastack<sp/>=<sp/>iss;</highlight></codeline>
<codeline lineno="619"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_lbb<sp/>=<sp/>iss;</highlight></codeline>
<codeline lineno="620"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_wl1<sp/>=<sp/>seqno<sp/>-<sp/>1;</highlight><highlight class="comment">/*<sp/>initialise<sp/>to<sp/>seqno-1<sp/>to<sp/>force<sp/>window<sp/>update<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="621"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;callback_arg<sp/>=<sp/>pcb-&gt;callback_arg;</highlight></codeline>
<codeline lineno="622"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CALLBACK_API<sp/>||<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;listener<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="624"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CALLBACK_API<sp/>||<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>inherit<sp/>socket<sp/>options<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="626"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;so_options<sp/>=<sp/>pcb-&gt;so_options<sp/>&amp;<sp/><ref refid="ip_8h_1ae4bbdf8a2e757d758ec0e1c91b58893f" kindref="member">SOF_INHERITED</ref>;</highlight></codeline>
<codeline lineno="627"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>the<sp/>new<sp/>PCB<sp/>so<sp/>that<sp/>we<sp/>can<sp/>begin<sp/>receiving<sp/>segments</highlight></codeline>
<codeline lineno="628"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>for<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/><sp/><sp/>TCP_REG_ACTIVE(npcb);</highlight></codeline>
<codeline lineno="630"><highlight class="normal"></highlight></codeline>
<codeline lineno="631"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Parse<sp/>any<sp/>options<sp/>in<sp/>the<sp/>SYN.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="632"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_parseopt(npcb);</highlight></codeline>
<codeline lineno="633"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_wnd<sp/>=<sp/>tcphdr-&gt;wnd;</highlight></codeline>
<codeline lineno="634"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;snd_wnd_max<sp/>=<sp/>npcb-&gt;snd_wnd;</highlight></codeline>
<codeline lineno="635"><highlight class="normal"></highlight></codeline>
<codeline lineno="636"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CALCULATE_EFF_SEND_MSS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/><sp/><sp/>npcb-&gt;mss<sp/>=<sp/>tcp_eff_send_mss(npcb-&gt;mss,<sp/>&amp;npcb-&gt;local_ip,<sp/>&amp;npcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="638"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CALCULATE_EFF_SEND_MSS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="639"><highlight class="normal"></highlight></codeline>
<codeline lineno="640"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcppassiveopens);</highlight></codeline>
<codeline lineno="641"><highlight class="normal"></highlight></codeline>
<codeline lineno="642"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Send<sp/>a<sp/>SYN|ACK<sp/>together<sp/>with<sp/>the<sp/>MSS<sp/>option.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="643"><highlight class="normal"><sp/><sp/><sp/><sp/>rc<sp/>=<sp/>tcp_enqueue_flags(npcb,<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>);</highlight></codeline>
<codeline lineno="644"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rc<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abandon(npcb,<sp/>0);</highlight></codeline>
<codeline lineno="646"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="647"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="648"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_output(npcb);</highlight></codeline>
<codeline lineno="649"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="650"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="651"><highlight class="normal">}</highlight></codeline>
<codeline lineno="652"><highlight class="normal"></highlight></codeline>
<codeline lineno="662"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="663"><highlight class="normal">tcp_timewait_input(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="664"><highlight class="normal">{</highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>RFC<sp/>1337:<sp/>in<sp/>TIME_WAIT,<sp/>ignore<sp/>RST<sp/>and<sp/>ACK<sp/>FINs<sp/>+<sp/>any<sp/>&apos;acceptable&apos;<sp/>segments<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="666"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>RFC<sp/>793<sp/>3.9<sp/>Event<sp/>Processing<sp/>-<sp/>Segment<sp/>Arrives:</highlight></codeline>
<codeline lineno="667"><highlight class="comment"><sp/><sp/><sp/>*<sp/>-<sp/>first<sp/>check<sp/>sequence<sp/>number<sp/>-<sp/>we<sp/>skip<sp/>that<sp/>one<sp/>in<sp/>TIME_WAIT<sp/>(always</highlight></codeline>
<codeline lineno="668"><highlight class="comment"><sp/><sp/><sp/>*<sp/><sp/><sp/>acceptable<sp/>since<sp/>we<sp/>only<sp/>send<sp/>ACKs)</highlight></codeline>
<codeline lineno="669"><highlight class="comment"><sp/><sp/><sp/>*<sp/>-<sp/>second<sp/>check<sp/>the<sp/>RST<sp/>bit<sp/>(...<sp/>return)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="670"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>)<sp/>{</highlight></codeline>
<codeline lineno="671"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="672"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="673"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>-<sp/>fourth,<sp/>check<sp/>the<sp/>SYN<sp/>bit,<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="674"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>an<sp/>incoming<sp/>segment<sp/>is<sp/>not<sp/>acceptable,<sp/>an<sp/>acknowledgment</highlight></codeline>
<codeline lineno="676"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>should<sp/>be<sp/>sent<sp/>in<sp/>reply<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(seqno,<sp/>pcb-&gt;rcv_nxt,<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd))<sp/>{</highlight></codeline>
<codeline lineno="678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>SYN<sp/>is<sp/>in<sp/>the<sp/>window<sp/>it<sp/>is<sp/>an<sp/>error,<sp/>send<sp/>a<sp/>reset<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rst(ackno,<sp/>seqno<sp/>+<sp/>tcplen,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),</highlight></codeline>
<codeline lineno="680"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>tcphdr-&gt;dest,<sp/>tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="683"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="684"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>-<sp/>eighth,<sp/>check<sp/>the<sp/>FIN<sp/>bit:<sp/>Remain<sp/>in<sp/>the<sp/>TIME-WAIT<sp/>state.</highlight></codeline>
<codeline lineno="685"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Restart<sp/>the<sp/>2<sp/>MSL<sp/>time-wait<sp/>timeout.*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="686"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;tmr<sp/>=<sp/>tcp_ticks;</highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="688"><highlight class="normal"></highlight></codeline>
<codeline lineno="689"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcplen<sp/>&gt;<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="690"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Acknowledge<sp/>data,<sp/>FIN<sp/>or<sp/>out-of-window<sp/>SYN<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="691"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_ACK_NOW;</highlight></codeline>
<codeline lineno="692"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_output(pcb);</highlight></codeline>
<codeline lineno="693"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="694"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="695"><highlight class="normal">}</highlight></codeline>
<codeline lineno="696"><highlight class="normal"></highlight></codeline>
<codeline lineno="708"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="709"><highlight class="normal">tcp_process(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="710"><highlight class="normal">{</highlight></codeline>
<codeline lineno="711"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*rseg;</highlight></codeline>
<codeline lineno="712"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>acceptable<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="713"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="714"><highlight class="normal"></highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="716"><highlight class="normal"></highlight></codeline>
<codeline lineno="717"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Process<sp/>incoming<sp/>RST<sp/>segments.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>)<sp/>{</highlight></codeline>
<codeline lineno="719"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>First,<sp/>determine<sp/>if<sp/>the<sp/>reset<sp/>is<sp/>acceptable.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;state<sp/>==<sp/>SYN_SENT)<sp/>{</highlight></codeline>
<codeline lineno="721"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>&quot;In<sp/>the<sp/>SYN-SENT<sp/>state<sp/>(a<sp/>RST<sp/>received<sp/>in<sp/>response<sp/>to<sp/>an<sp/>initial<sp/>SYN),</highlight></codeline>
<codeline lineno="722"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>RST<sp/>is<sp/>acceptable<sp/>if<sp/>the<sp/>ACK<sp/>field<sp/>acknowledges<sp/>the<sp/>SYN.&quot;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ackno<sp/>==<sp/>pcb-&gt;snd_nxt)<sp/>{</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acceptable<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="725"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="726"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="727"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>&quot;In<sp/>all<sp/>states<sp/>except<sp/>SYN-SENT,<sp/>all<sp/>reset<sp/>(RST)<sp/>segments<sp/>are<sp/>validated</highlight></codeline>
<codeline lineno="728"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>by<sp/>checking<sp/>their<sp/>SEQ-fields.&quot;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="729"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seqno<sp/>==<sp/>pcb-&gt;rcv_nxt)<sp/>{</highlight></codeline>
<codeline lineno="730"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acceptable<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="731"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(seqno,<sp/>pcb-&gt;rcv_nxt,</highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd))<sp/>{</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>sequence<sp/>number<sp/>is<sp/>inside<sp/>the<sp/>window,<sp/>we<sp/>only<sp/>send<sp/>an<sp/>ACK</highlight></codeline>
<codeline lineno="734"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>wait<sp/>for<sp/>a<sp/>re-send<sp/>with<sp/>matching<sp/>sequence<sp/>number.</highlight></codeline>
<codeline lineno="735"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>This<sp/>violates<sp/>RFC<sp/>793,<sp/>but<sp/>is<sp/>required<sp/>to<sp/>protection<sp/>against</highlight></codeline>
<codeline lineno="736"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>CVE-2004-0230<sp/>(RST<sp/>spoofing<sp/>attack).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="739"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="740"><highlight class="normal"></highlight></codeline>
<codeline lineno="741"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(acceptable)<sp/>{</highlight></codeline>
<codeline lineno="742"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process:<sp/>Connection<sp/>RESET\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="743"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_input:<sp/>pcb-&gt;state<sp/>!=<sp/>CLOSED&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>!=<sp/>CLOSED);</highlight></codeline>
<codeline lineno="744"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>recv_flags<sp/>|=<sp/>TF_RESET;</highlight></codeline>
<codeline lineno="745"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~TF_ACK_DELAY;</highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca759030525f1768a23dc086a5fd45b4e5" kindref="member">ERR_RST</ref>;</highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="748"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process:<sp/>unacceptable<sp/>reset<sp/>seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>rcv_nxt<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="749"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seqno,<sp/>pcb-&gt;rcv_nxt));</highlight></codeline>
<codeline lineno="750"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process:<sp/>unacceptable<sp/>reset<sp/>seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>rcv_nxt<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="751"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seqno,<sp/>pcb-&gt;rcv_nxt));</highlight></codeline>
<codeline lineno="752"><highlight class="normal"><sp/><sp/><sp/><sp/><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="753"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="755"><highlight class="normal"></highlight></codeline>
<codeline lineno="756"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>&amp;&amp;<sp/>(pcb-&gt;state<sp/>!=<sp/>SYN_SENT<sp/>&amp;&amp;<sp/>pcb-&gt;state<sp/>!=<sp/>SYN_RCVD))<sp/>{</highlight></codeline>
<codeline lineno="757"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Cope<sp/>with<sp/>new<sp/>connection<sp/>attempt<sp/>after<sp/>remote<sp/>end<sp/>crashed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="758"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="759"><highlight class="normal"><sp/><sp/><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="760"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="761"><highlight class="normal"></highlight></codeline>
<codeline lineno="762"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;flags<sp/>&amp;<sp/>TF_RXCLOSED)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="763"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Update<sp/>the<sp/>PCB<sp/>(in)activity<sp/>timer<sp/>unless<sp/>rx<sp/>is<sp/>closed<sp/>(see<sp/>tcp_shutdown)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="764"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;tmr<sp/>=<sp/>tcp_ticks;</highlight></codeline>
<codeline lineno="765"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="766"><highlight class="normal"><sp/><sp/>pcb-&gt;keep_cnt_sent<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="767"><highlight class="normal"></highlight></codeline>
<codeline lineno="768"><highlight class="normal"><sp/><sp/>tcp_parseopt(pcb);</highlight></codeline>
<codeline lineno="769"><highlight class="normal"></highlight></codeline>
<codeline lineno="770"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>different<sp/>things<sp/>depending<sp/>on<sp/>the<sp/>TCP<sp/>state.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="771"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(pcb-&gt;state)<sp/>{</highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SYN_SENT:</highlight></codeline>
<codeline lineno="773"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;SYN-SENT:<sp/>ackno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>pcb-&gt;snd_nxt<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>unacked<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>ackno,</highlight></codeline>
<codeline lineno="774"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_nxt,<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno)));</highlight></codeline>
<codeline lineno="775"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>received<sp/>SYN<sp/>ACK<sp/>with<sp/>expected<sp/>sequence<sp/>number?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="776"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>&amp;&amp;<sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)</highlight></codeline>
<codeline lineno="777"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;&amp;<sp/>(ackno<sp/>==<sp/>pcb-&gt;lastack<sp/>+<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="778"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_nxt<sp/>=<sp/>seqno<sp/>+<sp/>1;</highlight></codeline>
<codeline lineno="779"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_ann_right_edge<sp/>=<sp/>pcb-&gt;rcv_nxt;</highlight></codeline>
<codeline lineno="780"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;lastack<sp/>=<sp/>ackno;</highlight></codeline>
<codeline lineno="781"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wnd<sp/>=<sp/>tcphdr-&gt;wnd;</highlight></codeline>
<codeline lineno="782"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wnd_max<sp/>=<sp/>pcb-&gt;snd_wnd;</highlight></codeline>
<codeline lineno="783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wl1<sp/>=<sp/>seqno<sp/>-<sp/>1;<sp/></highlight><highlight class="comment">/*<sp/>initialise<sp/>to<sp/>seqno<sp/>-<sp/>1<sp/>to<sp/>force<sp/>window<sp/>update<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="784"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>ESTABLISHED;</highlight></codeline>
<codeline lineno="785"><highlight class="normal"></highlight></codeline>
<codeline lineno="786"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CALCULATE_EFF_SEND_MSS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="787"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;mss<sp/>=<sp/>tcp_eff_send_mss(pcb-&gt;mss,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="788"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CALCULATE_EFF_SEND_MSS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="789"><highlight class="normal"></highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>=<sp/>LWIP_TCP_CALC_INITIAL_CWND(pcb-&gt;mss);</highlight></codeline>
<codeline lineno="791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a66df03d8192cd978d3321a9d68bf5411" kindref="member">TCP_CWND_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process<sp/>(SENT):<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight></codeline>
<codeline lineno="792"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;<sp/>ssthresh<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="793"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd,<sp/>pcb-&gt;ssthresh));</highlight></codeline>
<codeline lineno="794"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb-&gt;snd_queuelen<sp/>&gt;<sp/>0&quot;</highlight><highlight class="normal">,<sp/>(pcb-&gt;snd_queuelen<sp/>&gt;<sp/>0));</highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>--pcb-&gt;snd_queuelen;</highlight></codeline>
<codeline lineno="796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process:<sp/>SYN-SENT<sp/>--queuelen<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>(tcpwnd_size_t)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>rseg<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rseg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>might<sp/>happen<sp/>if<sp/>tcp_output<sp/>fails<sp/>in<sp/>tcp_rexmit_rto()</highlight></codeline>
<codeline lineno="800"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>which<sp/>case<sp/>the<sp/>segment<sp/>is<sp/>on<sp/>the<sp/>unsent<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rseg<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;no<sp/>segment<sp/>to<sp/>free&quot;</highlight><highlight class="normal">,<sp/>rseg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>rseg-&gt;next;</highlight></codeline>
<codeline lineno="804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>=<sp/>rseg-&gt;next;</highlight></codeline>
<codeline lineno="806"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="807"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(rseg);</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/>If<sp/>there&apos;s<sp/>nothing<sp/>left<sp/>to<sp/>acknowledge,<sp/>stop<sp/>the<sp/>retransmit</highlight></codeline>
<codeline lineno="810"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>timer,<sp/>otherwise<sp/>reset<sp/>it<sp/>to<sp/>start<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="811"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;unacked<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="812"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="813"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="814"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="815"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;nrtx<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="816"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="817"><highlight class="normal"></highlight></codeline>
<codeline lineno="818"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Call<sp/>the<sp/>user<sp/>specified<sp/>function<sp/>to<sp/>call<sp/>when<sp/>successfully</highlight></codeline>
<codeline lineno="819"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>connected.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="820"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_CONNECTED(pcb,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>,<sp/>err);</highlight></codeline>
<codeline lineno="821"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="822"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>;</highlight></codeline>
<codeline lineno="823"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="824"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="825"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>received<sp/>ACK?<sp/>possibly<sp/>a<sp/>half-open<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="828"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>a<sp/>RST<sp/>to<sp/>bring<sp/>the<sp/>other<sp/>side<sp/>in<sp/>a<sp/>non-synchronized<sp/>state.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rst(ackno,<sp/>seqno<sp/>+<sp/>tcplen,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),</highlight></codeline>
<codeline lineno="830"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>tcphdr-&gt;dest,<sp/>tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="831"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Resend<sp/>SYN<sp/>immediately<sp/>(don&apos;t<sp/>wait<sp/>for<sp/>rto<sp/>timeout)<sp/>to<sp/>establish</highlight></codeline>
<codeline lineno="832"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>connection<sp/>faster,<sp/>but<sp/>do<sp/>not<sp/>send<sp/>more<sp/>SYNs<sp/>than<sp/>we<sp/>otherwise<sp/>would</highlight></codeline>
<codeline lineno="833"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>have,<sp/>or<sp/>we<sp/>might<sp/>get<sp/>caught<sp/>in<sp/>a<sp/>loop<sp/>on<sp/>loopback<sp/>interfaces.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="834"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;nrtx<sp/>&lt;<sp/><ref refid="lwipopts_8h_1a50b434a8541a4813f7b27f576c05d1b6" kindref="member">TCP_SYNMAXRTX</ref>)<sp/>{</highlight></codeline>
<codeline lineno="835"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="836"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rexmit_rto(pcb);</highlight></codeline>
<codeline lineno="837"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="838"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="840"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SYN_RCVD:</highlight></codeline>
<codeline lineno="841"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>expected<sp/>ACK<sp/>number?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(ackno,<sp/>pcb-&gt;lastack+1,<sp/>pcb-&gt;snd_nxt))<sp/>{</highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>ESTABLISHED;</highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>established<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>inseg.tcphdr-&gt;src,<sp/>inseg.tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="846"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CALLBACK_API<sp/>||<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="847"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CALLBACK_API</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="848"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb-&gt;listener-&gt;accept<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="849"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;listener<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(pcb-&gt;listener-&gt;accept<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="850"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="851"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;listener<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="852"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>listen<sp/>pcb<sp/>might<sp/>be<sp/>closed<sp/>by<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="854"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="855"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CALLBACK_API<sp/>||<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_backlog_accepted(pcb);</highlight></codeline>
<codeline lineno="858"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Call<sp/>the<sp/>accept<sp/>function.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="859"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_EVENT_ACCEPT(pcb-&gt;listener,<sp/>pcb,<sp/>pcb-&gt;callback_arg,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>,<sp/>err);</highlight></codeline>
<codeline lineno="860"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="861"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="862"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>accept<sp/>function<sp/>returns<sp/>with<sp/>an<sp/>error,<sp/>we<sp/>abort</highlight></codeline>
<codeline lineno="863"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>the<sp/>connection.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="864"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Already<sp/>aborted?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="865"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="866"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(pcb);</highlight></codeline>
<codeline lineno="867"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="868"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaf316b2c5eee4079820f7100849115142" kindref="member">ERR_ABRT</ref>;</highlight></codeline>
<codeline lineno="869"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="870"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>there<sp/>was<sp/>any<sp/>data<sp/>contained<sp/>within<sp/>this<sp/>ACK,</highlight></codeline>
<codeline lineno="871"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>we&apos;d<sp/>better<sp/>pass<sp/>it<sp/>on<sp/>to<sp/>the<sp/>application<sp/>as<sp/>well.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="872"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="873"><highlight class="normal"></highlight></codeline>
<codeline lineno="874"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Prevent<sp/>ACK<sp/>for<sp/>SYN<sp/>to<sp/>generate<sp/>a<sp/>sent<sp/>event<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="875"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_acked<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="876"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_acked--;</highlight></codeline>
<codeline lineno="877"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="878"><highlight class="normal"></highlight></codeline>
<codeline lineno="879"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>=<sp/>LWIP_TCP_CALC_INITIAL_CWND(pcb-&gt;mss);</highlight></codeline>
<codeline lineno="880"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a66df03d8192cd978d3321a9d68bf5411" kindref="member">TCP_CWND_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_process<sp/>(SYN_RCVD):<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight></codeline>
<codeline lineno="881"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;<sp/>ssthresh<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="882"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd,<sp/>pcb-&gt;ssthresh));</highlight></codeline>
<codeline lineno="883"><highlight class="normal"></highlight></codeline>
<codeline lineno="884"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_GOT_FIN)<sp/>{</highlight></codeline>
<codeline lineno="885"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="886"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>CLOSE_WAIT;</highlight></codeline>
<codeline lineno="887"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="888"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="889"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>incorrect<sp/>ACK<sp/>number,<sp/>send<sp/>RST<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="890"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rst(ackno,<sp/>seqno<sp/>+<sp/>tcplen,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),</highlight></codeline>
<codeline lineno="891"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>tcphdr-&gt;dest,<sp/>tcphdr-&gt;src);</highlight></codeline>
<codeline lineno="892"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="893"><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/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>&amp;&amp;<sp/>(seqno<sp/>==<sp/>pcb-&gt;rcv_nxt<sp/>-<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="894"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Looks<sp/>like<sp/>another<sp/>copy<sp/>of<sp/>the<sp/>SYN<sp/>-<sp/>retransmit<sp/>our<sp/>SYN-ACK<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="895"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rexmit(pcb);</highlight></codeline>
<codeline lineno="896"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="897"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="898"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>CLOSE_WAIT:</highlight></codeline>
<codeline lineno="899"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>FALLTHROUGH<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="900"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>ESTABLISHED:</highlight></codeline>
<codeline lineno="901"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="902"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_GOT_FIN)<sp/>{<sp/></highlight><highlight class="comment">/*<sp/>passive<sp/>close<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="903"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="904"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>CLOSE_WAIT;</highlight></codeline>
<codeline lineno="905"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="906"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="907"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>FIN_WAIT_1:</highlight></codeline>
<codeline lineno="908"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="909"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_GOT_FIN)<sp/>{</highlight></codeline>
<codeline lineno="910"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>&amp;&amp;<sp/>(ackno<sp/>==<sp/>pcb-&gt;snd_nxt)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="911"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="912"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,</highlight></codeline>
<codeline lineno="913"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>closed:<sp/>FIN_WAIT_1<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>inseg.tcphdr-&gt;src,<sp/>inseg.tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="914"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="915"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_pcb_purge(pcb);</highlight></codeline>
<codeline lineno="916"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_RMV_ACTIVE(pcb);</highlight></codeline>
<codeline lineno="917"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>TIME_WAIT;</highlight></codeline>
<codeline lineno="918"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_REG(&amp;tcp_tw_pcbs,<sp/>pcb);</highlight></codeline>
<codeline lineno="919"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="920"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="921"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>CLOSING;</highlight></codeline>
<codeline lineno="922"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="923"><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/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>&amp;&amp;<sp/>(ackno<sp/>==<sp/>pcb-&gt;snd_nxt)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="924"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="925"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>FIN_WAIT_2;</highlight></codeline>
<codeline lineno="926"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="927"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="928"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>FIN_WAIT_2:</highlight></codeline>
<codeline lineno="929"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="930"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_flags<sp/>&amp;<sp/>TF_GOT_FIN)<sp/>{</highlight></codeline>
<codeline lineno="931"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>closed:<sp/>FIN_WAIT_2<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>inseg.tcphdr-&gt;src,<sp/>inseg.tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="932"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="933"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_pcb_purge(pcb);</highlight></codeline>
<codeline lineno="934"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_RMV_ACTIVE(pcb);</highlight></codeline>
<codeline lineno="935"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>TIME_WAIT;</highlight></codeline>
<codeline lineno="936"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_REG(&amp;tcp_tw_pcbs,<sp/>pcb);</highlight></codeline>
<codeline lineno="937"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="938"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="939"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>CLOSING:</highlight></codeline>
<codeline lineno="940"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="941"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>&amp;&amp;<sp/>ackno<sp/>==<sp/>pcb-&gt;snd_nxt<sp/>&amp;&amp;<sp/>pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="942"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>closed:<sp/>CLOSING<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>inseg.tcphdr-&gt;src,<sp/>inseg.tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="943"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_pcb_purge(pcb);</highlight></codeline>
<codeline lineno="944"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_RMV_ACTIVE(pcb);</highlight></codeline>
<codeline lineno="945"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>TIME_WAIT;</highlight></codeline>
<codeline lineno="946"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_REG(&amp;tcp_tw_pcbs,<sp/>pcb);</highlight></codeline>
<codeline lineno="947"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="948"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="949"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LAST_ACK:</highlight></codeline>
<codeline lineno="950"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_receive(pcb);</highlight></codeline>
<codeline lineno="951"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>&amp;&amp;<sp/>ackno<sp/>==<sp/>pcb-&gt;snd_nxt<sp/>&amp;&amp;<sp/>pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="952"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;TCP<sp/>connection<sp/>closed:<sp/>LAST_ACK<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>-&gt;<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">,<sp/>inseg.tcphdr-&gt;src,<sp/>inseg.tcphdr-&gt;dest));</highlight></codeline>
<codeline lineno="953"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>bugfix<sp/>#21699:<sp/>don&apos;t<sp/>set<sp/>pcb-&gt;state<sp/>to<sp/>CLOSED<sp/>here<sp/>or<sp/>we<sp/>risk<sp/>leaking<sp/>segments<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="954"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>recv_flags<sp/>|=<sp/>TF_CLOSED;</highlight></codeline>
<codeline lineno="955"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="956"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="957"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="958"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="959"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="960"><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="961"><highlight class="normal">}</highlight></codeline>
<codeline lineno="962"><highlight class="normal"></highlight></codeline>
<codeline lineno="963"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="964"><highlight class="normal"></highlight></codeline>
<codeline lineno="969"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="970"><highlight class="normal">tcp_oos_insert_segment(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_seg<sp/>*cseg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_seg<sp/>*next)</highlight></codeline>
<codeline lineno="971"><highlight class="normal">{</highlight></codeline>
<codeline lineno="972"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*old_seg;</highlight></codeline>
<codeline lineno="973"><highlight class="normal"></highlight></codeline>
<codeline lineno="974"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(cseg-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="975"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>received<sp/>segment<sp/>overlaps<sp/>all<sp/>following<sp/>segments<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="976"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_segs_free(next);</highlight></codeline>
<codeline lineno="977"><highlight class="normal"><sp/><sp/><sp/><sp/>next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="978"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="979"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>delete<sp/>some<sp/>following<sp/>segments</highlight></codeline>
<codeline lineno="980"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oos<sp/>queue<sp/>may<sp/>have<sp/>segments<sp/>with<sp/>FIN<sp/>flag<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="981"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(next<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="982"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_GEQ((seqno<sp/>+<sp/>cseg-&gt;len),</highlight></codeline>
<codeline lineno="983"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(next-&gt;tcphdr-&gt;seqno<sp/>+<sp/>next-&gt;len)))<sp/>{</highlight></codeline>
<codeline lineno="984"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>cseg<sp/>with<sp/>FIN<sp/>already<sp/>processed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="985"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(next-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="986"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a42432f2dde6716ecb0087ccbc47cc75b" kindref="member">TCPH_SET_FLAG</ref>(cseg-&gt;tcphdr,<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="987"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="988"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>old_seg<sp/>=<sp/>next;</highlight></codeline>
<codeline lineno="989"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>next<sp/>=<sp/>next-&gt;next;</highlight></codeline>
<codeline lineno="990"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(old_seg);</highlight></codeline>
<codeline lineno="991"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="992"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(next<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="993"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_GT(seqno<sp/>+<sp/>cseg-&gt;len,<sp/>next-&gt;tcphdr-&gt;seqno))<sp/>{</highlight></codeline>
<codeline lineno="994"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>need<sp/>to<sp/>trim<sp/>the<sp/>incoming<sp/>segment.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="995"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cseg-&gt;len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(next-&gt;tcphdr-&gt;seqno<sp/>-<sp/>seqno);</highlight></codeline>
<codeline lineno="996"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(cseg-&gt;p,<sp/>cseg-&gt;len);</highlight></codeline>
<codeline lineno="997"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="998"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="999"><highlight class="normal"><sp/><sp/>cseg-&gt;next<sp/>=<sp/>next;</highlight></codeline>
<codeline lineno="1000"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1001"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1002"><highlight class="normal"></highlight></codeline>
<codeline lineno="1015"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1016"><highlight class="normal">tcp_receive(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1017"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1018"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*next;</highlight></codeline>
<codeline lineno="1019"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1020"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*prev,<sp/>*cseg;</highlight></codeline>
<codeline lineno="1021"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1022"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref><sp/>off;</highlight></codeline>
<codeline lineno="1023"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>m;</highlight></codeline>
<codeline lineno="1024"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>right_wnd_edge;</highlight></codeline>
<codeline lineno="1025"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>new_tot_len;</highlight></codeline>
<codeline lineno="1026"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>found_dupack<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1027"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OOSEQ_MAX_BYTES<sp/>||<sp/>TCP_OOSEQ_MAX_PBUFS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1028"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>ooseq_blen;</highlight></codeline>
<codeline lineno="1029"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>ooseq_qlen;</highlight></codeline>
<codeline lineno="1030"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OOSEQ_MAX_BYTES<sp/>||<sp/>TCP_OOSEQ_MAX_PBUFS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1031"><highlight class="normal"></highlight></codeline>
<codeline lineno="1032"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>wrong<sp/>state&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;state<sp/>&gt;=<sp/>ESTABLISHED);</highlight></codeline>
<codeline lineno="1033"><highlight class="normal"></highlight></codeline>
<codeline lineno="1034"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1035"><highlight class="normal"><sp/><sp/><sp/><sp/>right_wnd_edge<sp/>=<sp/>pcb-&gt;snd_wnd<sp/>+<sp/>pcb-&gt;snd_wl2;</highlight></codeline>
<codeline lineno="1036"><highlight class="normal"></highlight></codeline>
<codeline lineno="1037"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Update<sp/>window.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1038"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LT(pcb-&gt;snd_wl1,<sp/>seqno)<sp/>||</highlight></codeline>
<codeline lineno="1039"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;snd_wl1<sp/>==<sp/>seqno<sp/>&amp;&amp;<sp/>TCP_SEQ_LT(pcb-&gt;snd_wl2,<sp/>ackno))<sp/>||</highlight></codeline>
<codeline lineno="1040"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;snd_wl2<sp/>==<sp/>ackno<sp/>&amp;&amp;<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)SND_WND_SCALE(pcb,<sp/>tcphdr-&gt;wnd)<sp/>&gt;<sp/>pcb-&gt;snd_wnd))<sp/>{</highlight></codeline>
<codeline lineno="1041"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wnd<sp/>=<sp/>SND_WND_SCALE(pcb,<sp/>tcphdr-&gt;wnd);</highlight></codeline>
<codeline lineno="1042"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>keep<sp/>track<sp/>of<sp/>the<sp/>biggest<sp/>window<sp/>announced<sp/>by<sp/>the<sp/>remote<sp/>host<sp/>to<sp/>calculate</highlight></codeline>
<codeline lineno="1043"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>maximum<sp/>segment<sp/>size<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1044"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_wnd_max<sp/>&lt;<sp/>pcb-&gt;snd_wnd)<sp/>{</highlight></codeline>
<codeline lineno="1045"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wnd_max<sp/>=<sp/>pcb-&gt;snd_wnd;</highlight></codeline>
<codeline lineno="1046"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1047"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wl1<sp/>=<sp/>seqno;</highlight></codeline>
<codeline lineno="1048"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wl2<sp/>=<sp/>ackno;</highlight></codeline>
<codeline lineno="1049"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_wnd<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1050"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;persist_backoff<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1051"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>start<sp/>persist<sp/>timer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1052"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;persist_cnt<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1053"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;persist_backoff<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1054"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1055"><highlight class="normal"><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/>(pcb-&gt;persist_backoff<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1056"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>stop<sp/>persist<sp/>timer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1057"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;persist_backoff<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1058"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1059"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a3704f433e947d6342da77c74e33627e1" kindref="member">TCP_WND_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>window<sp/>update<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;snd_wnd));</highlight></codeline>
<codeline lineno="1060"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_WND_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1061"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1062"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_wnd<sp/>!=<sp/>(tcpwnd_size_t)SND_WND_SCALE(pcb,<sp/>tcphdr-&gt;wnd))<sp/>{</highlight></codeline>
<codeline lineno="1063"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a3704f433e947d6342da77c74e33627e1" kindref="member">TCP_WND_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1064"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>no<sp/>window<sp/>update<sp/>lastack<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>ackno<sp/>%&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1065"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>wl1<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>wl2<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1066"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;lastack,<sp/>ackno,<sp/>pcb-&gt;snd_wl1,<sp/>seqno,<sp/>pcb-&gt;snd_wl2));</highlight></codeline>
<codeline lineno="1067"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1068"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_WND_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1069"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1070"><highlight class="normal"></highlight></codeline>
<codeline lineno="1071"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>(From<sp/>Stevens<sp/>TCP/IP<sp/>Illustrated<sp/>Vol<sp/>II,<sp/>p970.)<sp/>Its<sp/>only<sp/>a</highlight></codeline>
<codeline lineno="1072"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>duplicate<sp/>ack<sp/>if:</highlight></codeline>
<codeline lineno="1073"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>1)<sp/>It<sp/>doesn&apos;t<sp/>ACK<sp/>new<sp/>data</highlight></codeline>
<codeline lineno="1074"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>2)<sp/>length<sp/>of<sp/>received<sp/>packet<sp/>is<sp/>zero<sp/>(i.e.<sp/>no<sp/>payload)</highlight></codeline>
<codeline lineno="1075"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>3)<sp/>the<sp/>advertised<sp/>window<sp/>hasn&apos;t<sp/>changed</highlight></codeline>
<codeline lineno="1076"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>4)<sp/>There<sp/>is<sp/>outstanding<sp/>unacknowledged<sp/>data<sp/>(retransmission<sp/>timer<sp/>running)</highlight></codeline>
<codeline lineno="1077"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>5)<sp/>The<sp/>ACK<sp/>is<sp/>==<sp/>biggest<sp/>ACK<sp/>sequence<sp/>number<sp/>so<sp/>far<sp/>seen<sp/>(snd_una)</highlight></codeline>
<codeline lineno="1078"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="1079"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>If<sp/>it<sp/>passes<sp/>all<sp/>five,<sp/>should<sp/>process<sp/>as<sp/>a<sp/>dupack:</highlight></codeline>
<codeline lineno="1080"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>a)<sp/>dupacks<sp/>&lt;<sp/>3:<sp/>do<sp/>nothing</highlight></codeline>
<codeline lineno="1081"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>b)<sp/>dupacks<sp/>==<sp/>3:<sp/>fast<sp/>retransmit</highlight></codeline>
<codeline lineno="1082"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>c)<sp/>dupacks<sp/>&gt;<sp/>3:<sp/>increase<sp/>cwnd</highlight></codeline>
<codeline lineno="1083"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="1084"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>If<sp/>it<sp/>only<sp/>passes<sp/>1-3,<sp/>should<sp/>reset<sp/>dupack<sp/>counter<sp/>(and<sp/>add<sp/>to</highlight></codeline>
<codeline lineno="1085"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>stats,<sp/>which<sp/>we<sp/>don&apos;t<sp/>do<sp/>in<sp/>lwIP)</highlight></codeline>
<codeline lineno="1086"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="1087"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>If<sp/>it<sp/>only<sp/>passes<sp/>1,<sp/>should<sp/>reset<sp/>dupack<sp/>counter</highlight></codeline>
<codeline lineno="1088"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="1089"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1090"><highlight class="normal"></highlight></codeline>
<codeline lineno="1091"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Clause<sp/>1<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1092"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LEQ(ackno,<sp/>pcb-&gt;lastack))<sp/>{</highlight></codeline>
<codeline lineno="1093"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Clause<sp/>2<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1094"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcplen<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1095"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Clause<sp/>3<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1096"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_wl2<sp/>+<sp/>pcb-&gt;snd_wnd<sp/>==<sp/>right_wnd_edge)<sp/>{</highlight></codeline>
<codeline lineno="1097"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Clause<sp/>4<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1098"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rtime<sp/>&gt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1099"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Clause<sp/>5<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;lastack<sp/>==<sp/>ackno)<sp/>{</highlight></codeline>
<codeline lineno="1101"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>found_dupack<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1102"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)(pcb-&gt;dupacks<sp/>+<sp/>1)<sp/>&gt;<sp/>pcb-&gt;dupacks)<sp/>{</highlight></codeline>
<codeline lineno="1103"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>++pcb-&gt;dupacks;</highlight></codeline>
<codeline lineno="1104"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1105"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;dupacks<sp/>&gt;<sp/>3)<sp/>{</highlight></codeline>
<codeline lineno="1106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Inflate<sp/>the<sp/>congestion<sp/>window,<sp/>but<sp/>not<sp/>if<sp/>it<sp/>means<sp/>that</highlight></codeline>
<codeline lineno="1107"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>value<sp/>overflows.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1108"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcpwnd_size_t)(pcb-&gt;cwnd<sp/>+<sp/>pcb-&gt;mss)<sp/>&gt;<sp/>pcb-&gt;cwnd)<sp/>{</highlight></codeline>
<codeline lineno="1109"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>+=<sp/>pcb-&gt;mss;</highlight></codeline>
<codeline lineno="1110"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1111"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><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/>(pcb-&gt;dupacks<sp/>==<sp/>3)<sp/>{</highlight></codeline>
<codeline lineno="1112"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>fast<sp/>retransmit<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1113"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_rexmit_fast(pcb);</highlight></codeline>
<codeline lineno="1114"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1116"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1117"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>Clause<sp/>(1)<sp/>or<sp/>more<sp/>is<sp/>true,<sp/>but<sp/>not<sp/>a<sp/>duplicate<sp/>ack,<sp/>reset</highlight></codeline>
<codeline lineno="1120"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>count<sp/>of<sp/>consecutive<sp/>duplicate<sp/>acks<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1121"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!found_dupack)<sp/>{</highlight></codeline>
<codeline lineno="1122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;dupacks<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1123"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1124"><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/>(TCP_SEQ_BETWEEN(ackno,<sp/>pcb-&gt;lastack+1,<sp/>pcb-&gt;snd_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1125"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>come<sp/>here<sp/>when<sp/>the<sp/>ACK<sp/>acknowledges<sp/>new<sp/>data.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1126"><highlight class="normal"></highlight></codeline>
<codeline lineno="1127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Reset<sp/>the<sp/>&quot;IN<sp/>Fast<sp/>Retransmit&quot;<sp/>flag,<sp/>since<sp/>we<sp/>are<sp/>no<sp/>longer</highlight></codeline>
<codeline lineno="1128"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>fast<sp/>retransmit.<sp/>Also<sp/>reset<sp/>the<sp/>congestion<sp/>window<sp/>to<sp/>the</highlight></codeline>
<codeline lineno="1129"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>slow<sp/>start<sp/>threshold.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_INFR)<sp/>{</highlight></codeline>
<codeline lineno="1131"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~TF_INFR;</highlight></codeline>
<codeline lineno="1132"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>=<sp/>pcb-&gt;ssthresh;</highlight></codeline>
<codeline lineno="1133"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1134"><highlight class="normal"></highlight></codeline>
<codeline lineno="1135"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Reset<sp/>the<sp/>number<sp/>of<sp/>retransmissions.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1136"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;nrtx<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1137"><highlight class="normal"></highlight></codeline>
<codeline lineno="1138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Reset<sp/>the<sp/>retransmission<sp/>time-out.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rto<sp/>=<sp/>(pcb-&gt;sa<sp/>&gt;&gt;<sp/>3)<sp/>+<sp/>pcb-&gt;sv;</highlight></codeline>
<codeline lineno="1140"><highlight class="normal"></highlight></codeline>
<codeline lineno="1141"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Reset<sp/>the<sp/>fast<sp/>retransmit<sp/>variables.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;dupacks<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;lastack<sp/>=<sp/>ackno;</highlight></codeline>
<codeline lineno="1144"><highlight class="normal"></highlight></codeline>
<codeline lineno="1145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Update<sp/>the<sp/>congestion<sp/>control<sp/>variables<sp/>(cwnd<sp/>and</highlight></codeline>
<codeline lineno="1146"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ssthresh).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(pcb-&gt;state<sp/>&gt;=<sp/>ESTABLISHED)<sp/>{</highlight></codeline>
<codeline lineno="1148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;cwnd<sp/>&lt;<sp/>pcb-&gt;ssthresh)<sp/>{</highlight></codeline>
<codeline lineno="1149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcpwnd_size_t)(pcb-&gt;cwnd<sp/>+<sp/>pcb-&gt;mss)<sp/>&gt;<sp/>pcb-&gt;cwnd)<sp/>{</highlight></codeline>
<codeline lineno="1150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>+=<sp/>pcb-&gt;mss;</highlight></codeline>
<codeline lineno="1151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a66df03d8192cd978d3321a9d68bf5411" kindref="member">TCP_CWND_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>slow<sp/>start<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;cwnd));</highlight></codeline>
<codeline lineno="1153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcpwnd_size_t<sp/>new_cwnd<sp/>=<sp/>(pcb-&gt;cwnd<sp/>+<sp/>pcb-&gt;mss<sp/>*<sp/>pcb-&gt;mss<sp/>/<sp/>pcb-&gt;cwnd);</highlight></codeline>
<codeline lineno="1155"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_cwnd<sp/>&gt;<sp/>pcb-&gt;cwnd)<sp/>{</highlight></codeline>
<codeline lineno="1156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>=<sp/>new_cwnd;</highlight></codeline>
<codeline lineno="1157"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1158"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a66df03d8192cd978d3321a9d68bf5411" kindref="member">TCP_CWND_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>congestion<sp/>avoidance<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;cwnd));</highlight></codeline>
<codeline lineno="1159"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1160"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1161"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>ACK<sp/>for<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>unacked-&gt;seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;:%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1162"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ackno,</highlight></codeline>
<codeline lineno="1163"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>?</highlight></codeline>
<codeline lineno="1164"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno):<sp/>0,</highlight></codeline>
<codeline lineno="1165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>?</highlight></codeline>
<codeline lineno="1166"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>TCP_TCPLEN(pcb-&gt;unacked):<sp/>0));</highlight></codeline>
<codeline lineno="1167"><highlight class="normal"></highlight></codeline>
<codeline lineno="1168"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Remove<sp/>segment<sp/>from<sp/>the<sp/>unacknowledged<sp/>list<sp/>if<sp/>the<sp/>incoming</highlight></codeline>
<codeline lineno="1169"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ACK<sp/>acknowledges<sp/>them.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1170"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(pcb-&gt;unacked<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1171"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_LEQ(<ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno)<sp/>+</highlight></codeline>
<codeline lineno="1172"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_TCPLEN(pcb-&gt;unacked),<sp/>ackno))<sp/>{</highlight></codeline>
<codeline lineno="1173"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>removing<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;:%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>from<sp/>pcb-&gt;unacked\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1174"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno),</highlight></codeline>
<codeline lineno="1175"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unacked-&gt;tcphdr-&gt;seqno)<sp/>+</highlight></codeline>
<codeline lineno="1176"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_TCPLEN(pcb-&gt;unacked)));</highlight></codeline>
<codeline lineno="1177"><highlight class="normal"></highlight></codeline>
<codeline lineno="1178"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="1179"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>=<sp/>pcb-&gt;unacked-&gt;next;</highlight></codeline>
<codeline lineno="1180"><highlight class="normal"></highlight></codeline>
<codeline lineno="1181"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>queuelen<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;<sp/>...<sp/>&quot;</highlight><highlight class="normal">,<sp/>(tcpwnd_size_t)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="1182"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb-&gt;snd_queuelen<sp/>&gt;=<sp/>pbuf_clen(next-&gt;p)&quot;</highlight><highlight class="normal">,<sp/>(pcb-&gt;snd_queuelen<sp/>&gt;=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(next-&gt;p)));</highlight></codeline>
<codeline lineno="1183"><highlight class="normal"></highlight></codeline>
<codeline lineno="1184"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_queuelen<sp/>-=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(next-&gt;p);</highlight></codeline>
<codeline lineno="1185"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_acked<sp/>+=<sp/>next-&gt;len;</highlight></codeline>
<codeline lineno="1186"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(next);</highlight></codeline>
<codeline lineno="1187"><highlight class="normal"></highlight></codeline>
<codeline lineno="1188"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;<sp/>(after<sp/>freeing<sp/>unacked)\n&quot;</highlight><highlight class="normal">,<sp/>(tcpwnd_size_t)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="1189"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1190"><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;tcp_receive:<sp/>valid<sp/>queue<sp/>length&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;unacked<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>||</highlight></codeline>
<codeline lineno="1191"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1192"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1193"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1194"><highlight class="normal"></highlight></codeline>
<codeline lineno="1195"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>there&apos;s<sp/>nothing<sp/>left<sp/>to<sp/>acknowledge,<sp/>stop<sp/>the<sp/>retransmit</highlight></codeline>
<codeline lineno="1196"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>timer,<sp/>otherwise<sp/>reset<sp/>it<sp/>to<sp/>start<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1197"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;unacked<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1198"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="1199"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1200"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1201"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1202"><highlight class="normal"></highlight></codeline>
<codeline lineno="1203"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;polltmr<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1204"><highlight class="normal"></highlight></codeline>
<codeline lineno="1205"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1206"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip_current_is_v6())<sp/>{</highlight></codeline>
<codeline lineno="1207"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Inform<sp/>neighbor<sp/>reachability<sp/>of<sp/>forward<sp/>progress.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1208"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nd6_reachability_hint(ip6_current_src_addr());</highlight></codeline>
<codeline lineno="1209"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1210"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1211"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1212"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Out<sp/>of<sp/>sequence<sp/>ACK,<sp/>didn&apos;t<sp/>really<sp/>ack<sp/>anything<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1213"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_send_empty_ack(pcb);</highlight></codeline>
<codeline lineno="1214"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1215"><highlight class="normal"></highlight></codeline>
<codeline lineno="1216"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>go<sp/>through<sp/>the<sp/>-&gt;unsent<sp/>list<sp/>to<sp/>see<sp/>if<sp/>any<sp/>of<sp/>the<sp/>segments</highlight></codeline>
<codeline lineno="1217"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>on<sp/>the<sp/>list<sp/>are<sp/>acknowledged<sp/>by<sp/>the<sp/>ACK.<sp/>This<sp/>may<sp/>seem</highlight></codeline>
<codeline lineno="1218"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>strange<sp/>since<sp/>an<sp/>&quot;unsent&quot;<sp/>segment<sp/>shouldn&apos;t<sp/>be<sp/>acked.<sp/>The</highlight></codeline>
<codeline lineno="1219"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rationale<sp/>is<sp/>that<sp/>lwIP<sp/>puts<sp/>all<sp/>outstanding<sp/>segments<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1220"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-&gt;unsent<sp/>list<sp/>after<sp/>a<sp/>retransmission,<sp/>so<sp/>these<sp/>segments<sp/>may</highlight></codeline>
<codeline lineno="1221"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>fact<sp/>have<sp/>been<sp/>sent<sp/>once.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1222"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(pcb-&gt;unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1223"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_BETWEEN(ackno,<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unsent-&gt;tcphdr-&gt;seqno)<sp/>+</highlight></codeline>
<codeline lineno="1224"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_TCPLEN(pcb-&gt;unsent),<sp/>pcb-&gt;snd_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1225"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>removing<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;:%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>from<sp/>pcb-&gt;unsent\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1226"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unsent-&gt;tcphdr-&gt;seqno),<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(pcb-&gt;unsent-&gt;tcphdr-&gt;seqno)<sp/>+</highlight></codeline>
<codeline lineno="1227"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_TCPLEN(pcb-&gt;unsent)));</highlight></codeline>
<codeline lineno="1228"><highlight class="normal"></highlight></codeline>
<codeline lineno="1229"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>next<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="1230"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>pcb-&gt;unsent-&gt;next;</highlight></codeline>
<codeline lineno="1231"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1232"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1233"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1234"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1235"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1236"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>queuelen<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;<sp/>...<sp/>&quot;</highlight><highlight class="normal">,<sp/>(tcpwnd_size_t)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="1237"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb-&gt;snd_queuelen<sp/>&gt;=<sp/>pbuf_clen(next-&gt;p)&quot;</highlight><highlight class="normal">,<sp/>(pcb-&gt;snd_queuelen<sp/>&gt;=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(next-&gt;p)));</highlight></codeline>
<codeline lineno="1238"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Prevent<sp/>ACK<sp/>for<sp/>FIN<sp/>to<sp/>generate<sp/>a<sp/>sent<sp/>event<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1239"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_queuelen<sp/>-=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(next-&gt;p);</highlight></codeline>
<codeline lineno="1240"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>recv_acked<sp/>+=<sp/>next-&gt;len;</highlight></codeline>
<codeline lineno="1241"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(next);</highlight></codeline>
<codeline lineno="1242"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;<sp/>(after<sp/>freeing<sp/>unsent)\n&quot;</highlight><highlight class="normal">,<sp/>(tcpwnd_size_t)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="1243"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1244"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>valid<sp/>queue<sp/>length&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>||<sp/>pcb-&gt;unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1246"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1247"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1248"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;snd_buf<sp/>+=<sp/>recv_acked;</highlight></codeline>
<codeline lineno="1249"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>End<sp/>of<sp/>ACK<sp/>for<sp/>new<sp/>data<sp/>processing.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1250"><highlight class="normal"></highlight></codeline>
<codeline lineno="1251"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ad6e52e37415d0d0cbe4931a28f5a9662" kindref="member">TCP_RTO_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>pcb-&gt;rttest<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>rtseq<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>ackno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1252"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rttest,<sp/>pcb-&gt;rtseq,<sp/>ackno));</highlight></codeline>
<codeline lineno="1253"><highlight class="normal"></highlight></codeline>
<codeline lineno="1254"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>RTT<sp/>estimation<sp/>calculations.<sp/>This<sp/>is<sp/>done<sp/>by<sp/>checking<sp/>if<sp/>the</highlight></codeline>
<codeline lineno="1255"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>incoming<sp/>segment<sp/>acknowledges<sp/>the<sp/>segment<sp/>we<sp/>use<sp/>to<sp/>take<sp/>a</highlight></codeline>
<codeline lineno="1256"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>round-trip<sp/>time<sp/>measurement.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1257"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rttest<sp/>&amp;&amp;<sp/>TCP_SEQ_LT(pcb-&gt;rtseq,<sp/>ackno))<sp/>{</highlight></codeline>
<codeline lineno="1258"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>diff<sp/>between<sp/>this<sp/>shouldn&apos;t<sp/>exceed<sp/>32K<sp/>since<sp/>this<sp/>are<sp/>tcp<sp/>timer<sp/>ticks</highlight></codeline>
<codeline lineno="1259"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>a<sp/>round-trip<sp/>shouldn&apos;t<sp/>be<sp/>that<sp/>long...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1260"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>m<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)(tcp_ticks<sp/>-<sp/>pcb-&gt;rttest);</highlight></codeline>
<codeline lineno="1261"><highlight class="normal"></highlight></codeline>
<codeline lineno="1262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ad6e52e37415d0d0cbe4931a28f5a9662" kindref="member">TCP_RTO_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>experienced<sp/>rtt<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>ticks<sp/>(%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>msec).\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>m,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(m<sp/>*<sp/>TCP_SLOW_INTERVAL)));</highlight></codeline>
<codeline lineno="1264"><highlight class="normal"></highlight></codeline>
<codeline lineno="1265"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>is<sp/>taken<sp/>directly<sp/>from<sp/>VJs<sp/>original<sp/>code<sp/>in<sp/>his<sp/>paper<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1266"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>m<sp/>=<sp/>m<sp/>-<sp/>(pcb-&gt;sa<sp/>&gt;&gt;<sp/>3);</highlight></codeline>
<codeline lineno="1267"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;sa<sp/>+=<sp/>m;</highlight></codeline>
<codeline lineno="1268"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(m<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1269"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>m<sp/>=<sp/>-m;</highlight></codeline>
<codeline lineno="1270"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1271"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>m<sp/>=<sp/>m<sp/>-<sp/>(pcb-&gt;sv<sp/>&gt;&gt;<sp/>2);</highlight></codeline>
<codeline lineno="1272"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;sv<sp/>+=<sp/>m;</highlight></codeline>
<codeline lineno="1273"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rto<sp/>=<sp/>(pcb-&gt;sa<sp/>&gt;&gt;<sp/>3)<sp/>+<sp/>pcb-&gt;sv;</highlight></codeline>
<codeline lineno="1274"><highlight class="normal"></highlight></codeline>
<codeline lineno="1275"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ad6e52e37415d0d0cbe4931a28f5a9662" kindref="member">TCP_RTO_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>RTO<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>milliseconds)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1276"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rto,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(pcb-&gt;rto<sp/>*<sp/>TCP_SLOW_INTERVAL)));</highlight></codeline>
<codeline lineno="1277"><highlight class="normal"></highlight></codeline>
<codeline lineno="1278"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rttest<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1279"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1280"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1281"><highlight class="normal"></highlight></codeline>
<codeline lineno="1282"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>incoming<sp/>segment<sp/>contains<sp/>data,<sp/>we<sp/>must<sp/>process<sp/>it</highlight></codeline>
<codeline lineno="1283"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>further<sp/>unless<sp/>the<sp/>pcb<sp/>already<sp/>received<sp/>a<sp/>FIN.</highlight></codeline>
<codeline lineno="1284"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>(RFC<sp/>793,<sp/>chapter<sp/>3.9,<sp/>&quot;SEGMENT<sp/>ARRIVES&quot;<sp/>in<sp/>states<sp/>CLOSE-WAIT,<sp/>CLOSING,</highlight></codeline>
<codeline lineno="1285"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>LAST-ACK<sp/>and<sp/>TIME-WAIT:<sp/>&quot;Ignore<sp/>the<sp/>segment<sp/>text.&quot;)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1286"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcplen<sp/>&gt;<sp/>0)<sp/>&amp;&amp;<sp/>(pcb-&gt;state<sp/>&lt;<sp/>CLOSE_WAIT))<sp/>{</highlight></codeline>
<codeline lineno="1287"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>code<sp/>basically<sp/>does<sp/>three<sp/>things:</highlight></codeline>
<codeline lineno="1288"><highlight class="comment"></highlight></codeline>
<codeline lineno="1289"><highlight class="comment"><sp/><sp/><sp/><sp/>+)<sp/>If<sp/>the<sp/>incoming<sp/>segment<sp/>contains<sp/>data<sp/>that<sp/>is<sp/>the<sp/>next</highlight></codeline>
<codeline lineno="1290"><highlight class="comment"><sp/><sp/><sp/><sp/>in-sequence<sp/>data,<sp/>this<sp/>data<sp/>is<sp/>passed<sp/>to<sp/>the<sp/>application.<sp/>This</highlight></codeline>
<codeline lineno="1291"><highlight class="comment"><sp/><sp/><sp/><sp/>might<sp/>involve<sp/>trimming<sp/>the<sp/>first<sp/>edge<sp/>of<sp/>the<sp/>data.<sp/>The<sp/>rcv_nxt</highlight></codeline>
<codeline lineno="1292"><highlight class="comment"><sp/><sp/><sp/><sp/>variable<sp/>and<sp/>the<sp/>advertised<sp/>window<sp/>are<sp/>adjusted.</highlight></codeline>
<codeline lineno="1293"><highlight class="comment"></highlight></codeline>
<codeline lineno="1294"><highlight class="comment"><sp/><sp/><sp/><sp/>+)<sp/>If<sp/>the<sp/>incoming<sp/>segment<sp/>has<sp/>data<sp/>that<sp/>is<sp/>above<sp/>the<sp/>next</highlight></codeline>
<codeline lineno="1295"><highlight class="comment"><sp/><sp/><sp/><sp/>sequence<sp/>number<sp/>expected<sp/>(-&gt;rcv_nxt),<sp/>the<sp/>segment<sp/>is<sp/>placed<sp/>on</highlight></codeline>
<codeline lineno="1296"><highlight class="comment"><sp/><sp/><sp/><sp/>the<sp/>-&gt;ooseq<sp/>queue.<sp/>This<sp/>is<sp/>done<sp/>by<sp/>finding<sp/>the<sp/>appropriate</highlight></codeline>
<codeline lineno="1297"><highlight class="comment"><sp/><sp/><sp/><sp/>place<sp/>in<sp/>the<sp/>-&gt;ooseq<sp/>queue<sp/>(which<sp/>is<sp/>ordered<sp/>by<sp/>sequence</highlight></codeline>
<codeline lineno="1298"><highlight class="comment"><sp/><sp/><sp/><sp/>number)<sp/>and<sp/>trim<sp/>the<sp/>segment<sp/>in<sp/>both<sp/>ends<sp/>if<sp/>needed.<sp/>An</highlight></codeline>
<codeline lineno="1299"><highlight class="comment"><sp/><sp/><sp/><sp/>immediate<sp/>ACK<sp/>is<sp/>sent<sp/>to<sp/>indicate<sp/>that<sp/>we<sp/>received<sp/>an</highlight></codeline>
<codeline lineno="1300"><highlight class="comment"><sp/><sp/><sp/><sp/>out-of-sequence<sp/>segment.</highlight></codeline>
<codeline lineno="1301"><highlight class="comment"></highlight></codeline>
<codeline lineno="1302"><highlight class="comment"><sp/><sp/><sp/><sp/>+)<sp/>Finally,<sp/>we<sp/>check<sp/>if<sp/>the<sp/>first<sp/>segment<sp/>on<sp/>the<sp/>-&gt;ooseq<sp/>queue</highlight></codeline>
<codeline lineno="1303"><highlight class="comment"><sp/><sp/><sp/><sp/>now<sp/>is<sp/>in<sp/>sequence<sp/>(i.e.,<sp/>if<sp/>rcv_nxt<sp/>&gt;=<sp/>ooseq-&gt;seqno).<sp/>If</highlight></codeline>
<codeline lineno="1304"><highlight class="comment"><sp/><sp/><sp/><sp/>rcv_nxt<sp/>&gt;<sp/>ooseq-&gt;seqno,<sp/>we<sp/>must<sp/>trim<sp/>the<sp/>first<sp/>edge<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="1305"><highlight class="comment"><sp/><sp/><sp/><sp/>segment<sp/>on<sp/>-&gt;ooseq<sp/>before<sp/>we<sp/>adjust<sp/>rcv_nxt.<sp/>The<sp/>data<sp/>in<sp/>the</highlight></codeline>
<codeline lineno="1306"><highlight class="comment"><sp/><sp/><sp/><sp/>segments<sp/>that<sp/>are<sp/>now<sp/>on<sp/>sequence<sp/>are<sp/>chained<sp/>onto<sp/>the</highlight></codeline>
<codeline lineno="1307"><highlight class="comment"><sp/><sp/><sp/><sp/>incoming<sp/>segment<sp/>so<sp/>that<sp/>we<sp/>only<sp/>need<sp/>to<sp/>call<sp/>the<sp/>application</highlight></codeline>
<codeline lineno="1308"><highlight class="comment"><sp/><sp/><sp/><sp/>once.</highlight></codeline>
<codeline lineno="1309"><highlight class="comment"><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1310"><highlight class="normal"></highlight></codeline>
<codeline lineno="1311"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>First,<sp/>we<sp/>check<sp/>if<sp/>we<sp/>must<sp/>trim<sp/>the<sp/>first<sp/>edge.<sp/>We<sp/>have<sp/>to<sp/>do</highlight></codeline>
<codeline lineno="1312"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>this<sp/>if<sp/>the<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>incoming<sp/>segment<sp/>is<sp/>less</highlight></codeline>
<codeline lineno="1313"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>than<sp/>rcv_nxt,<sp/>and<sp/>the<sp/>sequence<sp/>number<sp/>plus<sp/>the<sp/>length<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="1314"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment<sp/>is<sp/>larger<sp/>than<sp/>rcv_nxt.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1315"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/><sp/>if<sp/>(TCP_SEQ_LT(seqno,<sp/>pcb-&gt;rcv_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1316"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(TCP_SEQ_LT(pcb-&gt;rcv_nxt,<sp/>seqno<sp/>+<sp/>tcplen))<sp/>{*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1317"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(pcb-&gt;rcv_nxt,<sp/>seqno<sp/>+<sp/>1,<sp/>seqno<sp/>+<sp/>tcplen<sp/>-<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="1318"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Trimming<sp/>the<sp/>first<sp/>edge<sp/>is<sp/>done<sp/>by<sp/>pushing<sp/>the<sp/>payload</highlight></codeline>
<codeline lineno="1319"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pointer<sp/>in<sp/>the<sp/>pbuf<sp/>downwards.<sp/>This<sp/>is<sp/>somewhat<sp/>tricky<sp/>since</highlight></codeline>
<codeline lineno="1320"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>we<sp/>do<sp/>not<sp/>want<sp/>to<sp/>discard<sp/>the<sp/>full<sp/>contents<sp/>of<sp/>the<sp/>pbuf<sp/>up<sp/>to</highlight></codeline>
<codeline lineno="1321"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>new<sp/>starting<sp/>point<sp/>of<sp/>the<sp/>data<sp/>since<sp/>we<sp/>have<sp/>to<sp/>keep<sp/>the</highlight></codeline>
<codeline lineno="1322"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP<sp/>header<sp/>which<sp/>is<sp/>present<sp/>in<sp/>the<sp/>first<sp/>pbuf<sp/>in<sp/>the<sp/>chain.</highlight></codeline>
<codeline lineno="1323"><highlight class="comment"></highlight></codeline>
<codeline lineno="1324"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>What<sp/>is<sp/>done<sp/>is<sp/>really<sp/>quite<sp/>a<sp/>nasty<sp/>hack:<sp/>the<sp/>first<sp/>pbuf<sp/>in</highlight></codeline>
<codeline lineno="1325"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>pbuf<sp/>chain<sp/>is<sp/>pointed<sp/>to<sp/>by<sp/>inseg.p.<sp/>Since<sp/>we<sp/>need<sp/>to<sp/>be</highlight></codeline>
<codeline lineno="1326"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>able<sp/>to<sp/>deallocate<sp/>the<sp/>whole<sp/>pbuf,<sp/>we<sp/>cannot<sp/>change<sp/>this</highlight></codeline>
<codeline lineno="1327"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.p<sp/>pointer<sp/>to<sp/>point<sp/>to<sp/>any<sp/>of<sp/>the<sp/>later<sp/>pbufs<sp/>in<sp/>the</highlight></codeline>
<codeline lineno="1328"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chain.<sp/>Instead,<sp/>we<sp/>point<sp/>the<sp/>-&gt;payload<sp/>pointer<sp/>in<sp/>the<sp/>first</highlight></codeline>
<codeline lineno="1329"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pbuf<sp/>to<sp/>data<sp/>in<sp/>one<sp/>of<sp/>the<sp/>later<sp/>pbufs.<sp/>We<sp/>also<sp/>set<sp/>the</highlight></codeline>
<codeline lineno="1330"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.data<sp/>pointer<sp/>to<sp/>point<sp/>to<sp/>the<sp/>right<sp/>place.<sp/>This<sp/>way,<sp/>the</highlight></codeline>
<codeline lineno="1331"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-&gt;p<sp/>pointer<sp/>will<sp/>still<sp/>point<sp/>to<sp/>the<sp/>first<sp/>pbuf,<sp/>but<sp/>the</highlight></codeline>
<codeline lineno="1332"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-&gt;p-&gt;payload<sp/>pointer<sp/>will<sp/>point<sp/>to<sp/>data<sp/>in<sp/>another<sp/>pbuf.</highlight></codeline>
<codeline lineno="1333"><highlight class="comment"></highlight></codeline>
<codeline lineno="1334"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>After<sp/>we<sp/>are<sp/>done<sp/>with<sp/>adjusting<sp/>the<sp/>pbuf<sp/>pointers<sp/>we<sp/>must</highlight></codeline>
<codeline lineno="1335"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>adjust<sp/>the<sp/>-&gt;data<sp/>pointer<sp/>in<sp/>the<sp/>seg<sp/>and<sp/>the<sp/>segment</highlight></codeline>
<codeline lineno="1336"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>length.*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1337"><highlight class="normal"></highlight></codeline>
<codeline lineno="1338"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p<sp/>=<sp/>inseg.p;</highlight></codeline>
<codeline lineno="1339"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>off<sp/>=<sp/>pcb-&gt;rcv_nxt<sp/>-<sp/>seqno;</highlight></codeline>
<codeline lineno="1340"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;inseg.p<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>inseg.p);</highlight></codeline>
<codeline lineno="1341"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;insane<sp/>offset!&quot;</highlight><highlight class="normal">,<sp/>(off<sp/>&lt;<sp/>0x7fff));</highlight></codeline>
<codeline lineno="1342"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(inseg.p-&gt;len<sp/>&lt;<sp/>off)<sp/>{</highlight></codeline>
<codeline lineno="1343"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pbuf<sp/>too<sp/>short!&quot;</highlight><highlight class="normal">,<sp/>(((<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)inseg.p-&gt;tot_len)<sp/>&gt;=<sp/>off));</highlight></codeline>
<codeline lineno="1344"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>new_tot_len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(inseg.p-&gt;tot_len<sp/>-<sp/>off);</highlight></codeline>
<codeline lineno="1345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&lt;<sp/>off)<sp/>{</highlight></codeline>
<codeline lineno="1346"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>off<sp/>-=<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>;</highlight></codeline>
<codeline lineno="1347"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>KJM<sp/>following<sp/>line<sp/>changed<sp/>(with<sp/>addition<sp/>of<sp/>new_tot_len<sp/>var)</highlight></codeline>
<codeline lineno="1348"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>to<sp/>fix<sp/>bug<sp/>#9076</highlight></codeline>
<codeline lineno="1349"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.p-&gt;tot_len<sp/>-=<sp/>p-&gt;len;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1350"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>=<sp/>new_tot_len;</highlight></codeline>
<codeline lineno="1351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1352"><highlight class="normal"><sp/><sp/><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="1353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1354"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)-off))<sp/>{</highlight></codeline>
<codeline lineno="1355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>we<sp/>need<sp/>to<sp/>cope<sp/>with<sp/>this<sp/>failing?<sp/><sp/>Assert<sp/>for<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1356"><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;pbuf_header<sp/>failed&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="1357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(inseg.p,<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)-off))<sp/>{</highlight></codeline>
<codeline lineno="1360"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>we<sp/>need<sp/>to<sp/>cope<sp/>with<sp/>this<sp/>failing?<sp/><sp/>Assert<sp/>for<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1361"><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;pbuf_header<sp/>failed&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="1362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1363"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>inseg.len<sp/>-=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(pcb-&gt;rcv_nxt<sp/>-<sp/>seqno);</highlight></codeline>
<codeline lineno="1365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>inseg.tcphdr-&gt;seqno<sp/>=<sp/>seqno<sp/>=<sp/>pcb-&gt;rcv_nxt;</highlight></codeline>
<codeline lineno="1366"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1367"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LT(seqno,<sp/>pcb-&gt;rcv_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>whole<sp/>segment<sp/>is<sp/>&lt;<sp/>rcv_nxt<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1370"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>must<sp/>be<sp/>a<sp/>duplicate<sp/>of<sp/>a<sp/>packet<sp/>that<sp/>has<sp/>already<sp/>been<sp/>correctly<sp/>handled<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1371"><highlight class="normal"></highlight></codeline>
<codeline lineno="1372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>duplicate<sp/>seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>seqno));</highlight></codeline>
<codeline lineno="1373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="1374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1375"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1376"><highlight class="normal"></highlight></codeline>
<codeline lineno="1377"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>sequence<sp/>number<sp/>must<sp/>be<sp/>within<sp/>the<sp/>window<sp/>(above<sp/>rcv_nxt</highlight></codeline>
<codeline lineno="1378"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>below<sp/>rcv_nxt<sp/>+<sp/>rcv_wnd)<sp/>in<sp/>order<sp/>to<sp/>be<sp/>further</highlight></codeline>
<codeline lineno="1379"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>processed.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1380"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(seqno,<sp/>pcb-&gt;rcv_nxt,</highlight></codeline>
<codeline lineno="1381"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd<sp/>-<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="1382"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rcv_nxt<sp/>==<sp/>seqno)<sp/>{</highlight></codeline>
<codeline lineno="1383"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>incoming<sp/>segment<sp/>is<sp/>the<sp/>next<sp/>in<sp/>sequence.<sp/>We<sp/>check<sp/>if</highlight></codeline>
<codeline lineno="1384"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>we<sp/>have<sp/>to<sp/>trim<sp/>the<sp/>end<sp/>of<sp/>the<sp/>segment<sp/>and<sp/>update<sp/>rcv_nxt</highlight></codeline>
<codeline lineno="1385"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>pass<sp/>the<sp/>data<sp/>to<sp/>the<sp/>application.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcplen<sp/>=<sp/>TCP_TCPLEN(&amp;inseg);</highlight></codeline>
<codeline lineno="1387"><highlight class="normal"></highlight></codeline>
<codeline lineno="1388"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcplen<sp/>&gt;<sp/>pcb-&gt;rcv_wnd)<sp/>{</highlight></codeline>
<codeline lineno="1389"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1390"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>other<sp/>end<sp/>overran<sp/>receive<sp/>window&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1391"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>len<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>right<sp/>edge<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1392"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seqno,<sp/>tcplen,<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd));</highlight></codeline>
<codeline lineno="1393"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1394"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Must<sp/>remove<sp/>the<sp/>FIN<sp/>from<sp/>the<sp/>header<sp/>as<sp/>we&apos;re<sp/>trimming</highlight></codeline>
<codeline lineno="1395"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>that<sp/>byte<sp/>of<sp/>sequence-space<sp/>from<sp/>the<sp/>packet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1afe7c917080459557c65071c4b13c8e12" kindref="member">TCPH_FLAGS_SET</ref>(inseg.tcphdr,<sp/><ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/>~(</highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)<ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="1397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1398"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Adjust<sp/>length<sp/>of<sp/>segment<sp/>to<sp/>fit<sp/>in<sp/>the<sp/>window.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1399"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCPWND_CHECK16(pcb-&gt;rcv_wnd);</highlight></codeline>
<codeline lineno="1400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)pcb-&gt;rcv_wnd;</highlight></codeline>
<codeline lineno="1401"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.len<sp/>-=<sp/>1;</highlight></codeline>
<codeline lineno="1403"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1404"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(inseg.p,<sp/>inseg.len);</highlight></codeline>
<codeline lineno="1405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcplen<sp/>=<sp/>TCP_TCPLEN(&amp;inseg);</highlight></codeline>
<codeline lineno="1406"><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;tcp_receive:<sp/>segment<sp/>not<sp/>trimmed<sp/>correctly<sp/>to<sp/>rcv_wnd\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1407"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(seqno<sp/>+<sp/>tcplen)<sp/>==<sp/>(pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd));</highlight></codeline>
<codeline lineno="1408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1409"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1410"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Received<sp/>in-sequence<sp/>data,<sp/>adjust<sp/>ooseq<sp/>data<sp/>if:</highlight></codeline>
<codeline lineno="1411"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-<sp/>FIN<sp/>has<sp/>been<sp/>received<sp/>or</highlight></codeline>
<codeline lineno="1412"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-<sp/>inseq<sp/>overlaps<sp/>with<sp/>ooseq<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;ooseq<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1416"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>received<sp/>in-order<sp/>FIN,<sp/>binning<sp/>ooseq<sp/>queue\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Received<sp/>in-order<sp/>FIN<sp/>means<sp/>anything<sp/>that<sp/>was<sp/>received</highlight></codeline>
<codeline lineno="1418"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>out<sp/>of<sp/>order<sp/>must<sp/>now<sp/>have<sp/>been<sp/>received<sp/>in-order,<sp/>so</highlight></codeline>
<codeline lineno="1419"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>bin<sp/>the<sp/>ooseq<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1420"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(pcb-&gt;ooseq<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1421"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*old_ooseq<sp/>=<sp/>pcb-&gt;ooseq;</highlight></codeline>
<codeline lineno="1422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>pcb-&gt;ooseq-&gt;next;</highlight></codeline>
<codeline lineno="1423"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(old_ooseq);</highlight></codeline>
<codeline lineno="1424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1425"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next<sp/>=<sp/>pcb-&gt;ooseq;</highlight></codeline>
<codeline lineno="1427"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Remove<sp/>all<sp/>segments<sp/>on<sp/>ooseq<sp/>that<sp/>are<sp/>covered<sp/>by<sp/>inseg<sp/>already.</highlight></codeline>
<codeline lineno="1428"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>FIN<sp/>is<sp/>copied<sp/>from<sp/>ooseq<sp/>to<sp/>inseg<sp/>if<sp/>present.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1429"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(next<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1430"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_GEQ(seqno<sp/>+<sp/>tcplen,</highlight></codeline>
<codeline lineno="1431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next-&gt;tcphdr-&gt;seqno<sp/>+<sp/>next-&gt;len))<sp/>{</highlight></codeline>
<codeline lineno="1432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>inseg<sp/>cannot<sp/>have<sp/>FIN<sp/>here<sp/>(already<sp/>processed<sp/>above)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1433"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(next-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>!=<sp/>0<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1434"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1435"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a42432f2dde6716ecb0087ccbc47cc75b" kindref="member">TCPH_SET_FLAG</ref>(inseg.tcphdr,<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="1436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcplen<sp/>=<sp/>TCP_TCPLEN(&amp;inseg);</highlight></codeline>
<codeline lineno="1437"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>next;</highlight></codeline>
<codeline lineno="1439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next<sp/>=<sp/>next-&gt;next;</highlight></codeline>
<codeline lineno="1440"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(prev);</highlight></codeline>
<codeline lineno="1441"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Now<sp/>trim<sp/>right<sp/>side<sp/>of<sp/>inseg<sp/>if<sp/>it<sp/>overlaps<sp/>with<sp/>the<sp/>first</highlight></codeline>
<codeline lineno="1443"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>segment<sp/>on<sp/>ooseq<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1444"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(next<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1445"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_GT(seqno<sp/>+<sp/>tcplen,</highlight></codeline>
<codeline lineno="1446"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next-&gt;tcphdr-&gt;seqno))<sp/>{</highlight></codeline>
<codeline lineno="1447"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>inseg<sp/>cannot<sp/>have<sp/>FIN<sp/>here<sp/>(already<sp/>processed<sp/>above)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(next-&gt;tcphdr-&gt;seqno<sp/>-<sp/>seqno);</highlight></codeline>
<codeline lineno="1449"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1450"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.len<sp/>-=<sp/>1;</highlight></codeline>
<codeline lineno="1451"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1452"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(inseg.p,<sp/>inseg.len);</highlight></codeline>
<codeline lineno="1453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcplen<sp/>=<sp/>TCP_TCPLEN(&amp;inseg);</highlight></codeline>
<codeline lineno="1454"><highlight class="normal"><sp/><sp/><sp/><sp/><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;tcp_receive:<sp/>segment<sp/>not<sp/>trimmed<sp/>correctly<sp/>to<sp/>ooseq<sp/>queue\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(seqno<sp/>+<sp/>tcplen)<sp/>==<sp/>next-&gt;tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="1456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>next;</highlight></codeline>
<codeline lineno="1458"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1459"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1460"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1461"><highlight class="normal"></highlight></codeline>
<codeline lineno="1462"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_nxt<sp/>=<sp/>seqno<sp/>+<sp/>tcplen;</highlight></codeline>
<codeline lineno="1463"><highlight class="normal"></highlight></codeline>
<codeline lineno="1464"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Update<sp/>the<sp/>receiver&apos;s<sp/>(our)<sp/>window.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1465"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>tcplen<sp/>&gt;<sp/>rcv_wnd\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;rcv_wnd<sp/>&gt;=<sp/>tcplen);</highlight></codeline>
<codeline lineno="1466"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_wnd<sp/>-=<sp/>tcplen;</highlight></codeline>
<codeline lineno="1467"><highlight class="normal"></highlight></codeline>
<codeline lineno="1468"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_update_rcv_ann_wnd(pcb);</highlight></codeline>
<codeline lineno="1469"><highlight class="normal"></highlight></codeline>
<codeline lineno="1470"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>there<sp/>is<sp/>data<sp/>in<sp/>the<sp/>segment,<sp/>we<sp/>make<sp/>preparations<sp/>to</highlight></codeline>
<codeline lineno="1471"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pass<sp/>this<sp/>up<sp/>to<sp/>the<sp/>application.<sp/>The<sp/>-&gt;recv_data<sp/>variable</highlight></codeline>
<codeline lineno="1472"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>is<sp/>used<sp/>for<sp/>holding<sp/>the<sp/>pbuf<sp/>that<sp/>goes<sp/>to<sp/>the</highlight></codeline>
<codeline lineno="1473"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>application.<sp/>The<sp/>code<sp/>for<sp/>reassembling<sp/>out-of-sequence<sp/>data</highlight></codeline>
<codeline lineno="1474"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chains<sp/>its<sp/>data<sp/>on<sp/>this<sp/>pbuf<sp/>as<sp/>well.</highlight></codeline>
<codeline lineno="1475"><highlight class="comment"></highlight></codeline>
<codeline lineno="1476"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>If<sp/>the<sp/>segment<sp/>was<sp/>a<sp/>FIN,<sp/>we<sp/>set<sp/>the<sp/>TF_GOT_FIN<sp/>flag<sp/>that<sp/>will</highlight></codeline>
<codeline lineno="1477"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>be<sp/>used<sp/>to<sp/>indicate<sp/>to<sp/>the<sp/>application<sp/>that<sp/>the<sp/>remote<sp/>side<sp/>has</highlight></codeline>
<codeline lineno="1478"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>closed<sp/>its<sp/>end<sp/>of<sp/>the<sp/>connection.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1479"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(inseg.p-&gt;tot_len<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1480"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_data<sp/>=<sp/>inseg.p;</highlight></codeline>
<codeline lineno="1481"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Since<sp/>this<sp/>pbuf<sp/>now<sp/>is<sp/>the<sp/>responsibility<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="1482"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>application,<sp/>we<sp/>delete<sp/>our<sp/>reference<sp/>to<sp/>it<sp/>so<sp/>that<sp/>we<sp/>won&apos;t</highlight></codeline>
<codeline lineno="1483"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(mistakingly)<sp/>deallocate<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1484"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inseg.p<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1485"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1486"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(inseg.tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1487"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>received<sp/>FIN.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1488"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_flags<sp/>|=<sp/>TF_GOT_FIN;</highlight></codeline>
<codeline lineno="1489"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1490"><highlight class="normal"></highlight></codeline>
<codeline lineno="1491"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1492"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>now<sp/>check<sp/>if<sp/>we<sp/>have<sp/>segments<sp/>on<sp/>the<sp/>-&gt;ooseq<sp/>queue<sp/>that</highlight></codeline>
<codeline lineno="1493"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>are<sp/>now<sp/>in<sp/>sequence.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1494"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(pcb-&gt;ooseq<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1495"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq-&gt;tcphdr-&gt;seqno<sp/>==<sp/>pcb-&gt;rcv_nxt)<sp/>{</highlight></codeline>
<codeline lineno="1496"><highlight class="normal"></highlight></codeline>
<codeline lineno="1497"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cseg<sp/>=<sp/>pcb-&gt;ooseq;</highlight></codeline>
<codeline lineno="1498"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seqno<sp/>=<sp/>pcb-&gt;ooseq-&gt;tcphdr-&gt;seqno;</highlight></codeline>
<codeline lineno="1499"><highlight class="normal"></highlight></codeline>
<codeline lineno="1500"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_nxt<sp/>+=<sp/>TCP_TCPLEN(cseg);</highlight></codeline>
<codeline lineno="1501"><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;tcp_receive:<sp/>ooseq<sp/>tcplen<sp/>&gt;<sp/>rcv_wnd\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1502"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_wnd<sp/>&gt;=<sp/>TCP_TCPLEN(cseg));</highlight></codeline>
<codeline lineno="1503"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_wnd<sp/>-=<sp/>TCP_TCPLEN(cseg);</highlight></codeline>
<codeline lineno="1504"><highlight class="normal"></highlight></codeline>
<codeline lineno="1505"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_update_rcv_ann_wnd(pcb);</highlight></codeline>
<codeline lineno="1506"><highlight class="normal"></highlight></codeline>
<codeline lineno="1507"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(cseg-&gt;p-&gt;tot_len<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1508"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Chain<sp/>this<sp/>pbuf<sp/>onto<sp/>the<sp/>pbuf<sp/>that<sp/>we<sp/>will<sp/>pass<sp/>to</highlight></codeline>
<codeline lineno="1509"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>application.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1510"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>With<sp/>window<sp/>scaling,<sp/>this<sp/>can<sp/>overflow<sp/>recv_data-&gt;tot_len,<sp/>but</highlight></codeline>
<codeline lineno="1511"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>that&apos;s<sp/>not<sp/>a<sp/>problem<sp/>since<sp/>we<sp/>explicitly<sp/>fix<sp/>that<sp/>before<sp/>passing</highlight></codeline>
<codeline lineno="1512"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_data<sp/>to<sp/>the<sp/>application.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1513"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_data)<sp/>{</highlight></codeline>
<codeline lineno="1514"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(recv_data,<sp/>cseg-&gt;p);</highlight></codeline>
<codeline lineno="1515"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1516"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_data<sp/>=<sp/>cseg-&gt;p;</highlight></codeline>
<codeline lineno="1517"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1518"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cseg-&gt;p<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1519"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1520"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(cseg-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1521"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>dequeued<sp/>FIN.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1522"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>recv_flags<sp/>|=<sp/>TF_GOT_FIN;</highlight></codeline>
<codeline lineno="1523"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;state<sp/>==<sp/>ESTABLISHED)<sp/>{<sp/></highlight><highlight class="comment">/*<sp/>force<sp/>passive<sp/>close<sp/>or<sp/>we<sp/>can<sp/>move<sp/>to<sp/>active<sp/>close<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1524"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>=<sp/>CLOSE_WAIT;</highlight></codeline>
<codeline lineno="1525"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1526"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1527"><highlight class="normal"></highlight></codeline>
<codeline lineno="1528"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>cseg-&gt;next;</highlight></codeline>
<codeline lineno="1529"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(cseg);</highlight></codeline>
<codeline lineno="1530"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1531"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1532"><highlight class="normal"></highlight></codeline>
<codeline lineno="1533"><highlight class="normal"></highlight></codeline>
<codeline lineno="1534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Acknowledge<sp/>the<sp/>segment(s).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack(pcb);</highlight></codeline>
<codeline lineno="1536"><highlight class="normal"></highlight></codeline>
<codeline lineno="1537"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1538"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip_current_is_v6())<sp/>{</highlight></codeline>
<codeline lineno="1539"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Inform<sp/>neighbor<sp/>reachability<sp/>of<sp/>forward<sp/>progress.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1540"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nd6_reachability_hint(ip6_current_src_addr());</highlight></codeline>
<codeline lineno="1541"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1542"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_ND6_TCP_REACHABILITY_HINTS*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1543"><highlight class="normal"></highlight></codeline>
<codeline lineno="1544"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1545"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>get<sp/>here<sp/>if<sp/>the<sp/>incoming<sp/>segment<sp/>is<sp/>out-of-sequence.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1546"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_send_empty_ack(pcb);</highlight></codeline>
<codeline lineno="1547"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_QUEUE_OOSEQ</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1548"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>queue<sp/>the<sp/>segment<sp/>on<sp/>the<sp/>-&gt;ooseq<sp/>queue.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1549"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;ooseq<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1550"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>tcp_seg_copy(&amp;inseg);</highlight></codeline>
<codeline lineno="1551"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1552"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>queue<sp/>is<sp/>not<sp/>empty,<sp/>we<sp/>walk<sp/>through<sp/>the<sp/>queue<sp/>and</highlight></codeline>
<codeline lineno="1553"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>try<sp/>to<sp/>find<sp/>a<sp/>place<sp/>where<sp/>the<sp/>sequence<sp/>number<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="1554"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>incoming<sp/>segment<sp/>is<sp/>between<sp/>the<sp/>sequence<sp/>numbers<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="1555"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>previous<sp/>and<sp/>the<sp/>next<sp/>segment<sp/>on<sp/>the<sp/>-&gt;ooseq<sp/>queue.<sp/>That<sp/>is</highlight></codeline>
<codeline lineno="1556"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>place<sp/>where<sp/>we<sp/>put<sp/>the<sp/>incoming<sp/>segment.<sp/>If<sp/>needed,<sp/>we</highlight></codeline>
<codeline lineno="1557"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>trim<sp/>the<sp/>second<sp/>edges<sp/>of<sp/>the<sp/>previous<sp/>and<sp/>the<sp/>incoming</highlight></codeline>
<codeline lineno="1558"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment<sp/>so<sp/>that<sp/>it<sp/>will<sp/>fit<sp/>into<sp/>the<sp/>sequence.</highlight></codeline>
<codeline lineno="1559"><highlight class="comment"></highlight></codeline>
<codeline lineno="1560"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>If<sp/>the<sp/>incoming<sp/>segment<sp/>has<sp/>the<sp/>same<sp/>sequence<sp/>number<sp/>as<sp/>a</highlight></codeline>
<codeline lineno="1561"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment<sp/>on<sp/>the<sp/>-&gt;ooseq<sp/>queue,<sp/>we<sp/>discard<sp/>the<sp/>segment<sp/>that</highlight></codeline>
<codeline lineno="1562"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>contains<sp/>less<sp/>data.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1563"><highlight class="normal"></highlight></codeline>
<codeline lineno="1564"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1565"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(next<sp/>=<sp/>pcb-&gt;ooseq;<sp/>next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>next<sp/>=<sp/>next-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1566"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seqno<sp/>==<sp/>next-&gt;tcphdr-&gt;seqno)<sp/>{</highlight></codeline>
<codeline lineno="1567"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>incoming<sp/>segment<sp/>is<sp/>the</highlight></codeline>
<codeline lineno="1568"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>same<sp/>as<sp/>the<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>segment<sp/>on</highlight></codeline>
<codeline lineno="1569"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>-&gt;ooseq.<sp/>We<sp/>check<sp/>the<sp/>lengths<sp/>to<sp/>see<sp/>which<sp/>one<sp/>to</highlight></codeline>
<codeline lineno="1570"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>discard.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1571"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(inseg.len<sp/>&gt;<sp/>next-&gt;len)<sp/>{</highlight></codeline>
<codeline lineno="1572"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>incoming<sp/>segment<sp/>is<sp/>larger<sp/>than<sp/>the<sp/>old</highlight></codeline>
<codeline lineno="1573"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment.<sp/>We<sp/>replace<sp/>some<sp/>segments<sp/>with<sp/>the<sp/>new</highlight></codeline>
<codeline lineno="1574"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>one.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1575"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cseg<sp/>=<sp/>tcp_seg_copy(&amp;inseg);</highlight></codeline>
<codeline lineno="1576"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(cseg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1577"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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="1578"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/>cseg;</highlight></codeline>
<codeline lineno="1579"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1580"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>cseg;</highlight></codeline>
<codeline lineno="1581"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1582"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_oos_insert_segment(cseg,<sp/>next);</highlight></codeline>
<codeline lineno="1583"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1584"><highlight class="normal"><sp/><sp/><sp/><sp/><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="1585"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1586"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Either<sp/>the<sp/>lengths<sp/>are<sp/>the<sp/>same<sp/>or<sp/>the<sp/>incoming</highlight></codeline>
<codeline lineno="1587"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment<sp/>was<sp/>smaller<sp/>than<sp/>the<sp/>old<sp/>one;<sp/>in<sp/>either</highlight></codeline>
<codeline lineno="1588"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>case,<sp/>we<sp/>ditch<sp/>the<sp/>incoming<sp/>segment.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1589"><highlight class="normal"><sp/><sp/><sp/><sp/><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="1590"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1591"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1592"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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="1593"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LT(seqno,<sp/>next-&gt;tcphdr-&gt;seqno))<sp/>{</highlight></codeline>
<codeline lineno="1594"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>incoming<sp/>segment<sp/>is<sp/>lower</highlight></codeline>
<codeline lineno="1595"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>than<sp/>the<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>first<sp/>segment<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1596"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>queue.<sp/>We<sp/>put<sp/>the<sp/>incoming<sp/>segment<sp/>first<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1597"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>queue.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1598"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cseg<sp/>=<sp/>tcp_seg_copy(&amp;inseg);</highlight></codeline>
<codeline lineno="1599"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(cseg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1600"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/>cseg;</highlight></codeline>
<codeline lineno="1601"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_oos_insert_segment(cseg,<sp/>next);</highlight></codeline>
<codeline lineno="1602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1603"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><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="1604"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1605"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1606"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*if<sp/>(TCP_SEQ_LT(prev-&gt;tcphdr-&gt;seqno,<sp/>seqno)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1607"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_LT(seqno,<sp/>next-&gt;tcphdr-&gt;seqno))<sp/>{*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1608"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_BETWEEN(seqno,<sp/>prev-&gt;tcphdr-&gt;seqno+1,<sp/>next-&gt;tcphdr-&gt;seqno-1))<sp/>{</highlight></codeline>
<codeline lineno="1609"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>sequence<sp/>number<sp/>of<sp/>the<sp/>incoming<sp/>segment<sp/>is<sp/>in</highlight></codeline>
<codeline lineno="1610"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>between<sp/>the<sp/>sequence<sp/>numbers<sp/>of<sp/>the<sp/>previous<sp/>and</highlight></codeline>
<codeline lineno="1611"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>next<sp/>segment<sp/>on<sp/>-&gt;ooseq.<sp/>We<sp/>trim<sp/>trim<sp/>the<sp/>previous</highlight></codeline>
<codeline lineno="1612"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>segment,<sp/>delete<sp/>next<sp/>segments<sp/>that<sp/>included<sp/>in<sp/>received<sp/>segment</highlight></codeline>
<codeline lineno="1613"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>trim<sp/>received,<sp/>if<sp/>needed.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1614"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cseg<sp/>=<sp/>tcp_seg_copy(&amp;inseg);</highlight></codeline>
<codeline lineno="1615"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(cseg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1616"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_GT(prev-&gt;tcphdr-&gt;seqno<sp/>+<sp/>prev-&gt;len,<sp/>seqno))<sp/>{</highlight></codeline>
<codeline lineno="1617"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>need<sp/>to<sp/>trim<sp/>the<sp/>prev<sp/>segment.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1618"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(seqno<sp/>-<sp/>prev-&gt;tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="1619"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(prev-&gt;p,<sp/>prev-&gt;len);</highlight></codeline>
<codeline lineno="1620"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1621"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/>cseg;</highlight></codeline>
<codeline lineno="1622"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_oos_insert_segment(cseg,<sp/>next);</highlight></codeline>
<codeline lineno="1623"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1624"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><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="1625"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1626"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1627"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>&quot;next&quot;<sp/>segment<sp/>is<sp/>the<sp/>last<sp/>segment<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1628"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ooseq<sp/>queue,<sp/>we<sp/>add<sp/>the<sp/>incoming<sp/>segment<sp/>to<sp/>the<sp/>end</highlight></codeline>
<codeline lineno="1629"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>of<sp/>the<sp/>list.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1630"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(next-&gt;next<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1631"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_GT(seqno,<sp/>next-&gt;tcphdr-&gt;seqno))<sp/>{</highlight></codeline>
<codeline lineno="1632"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(next-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1633"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>segment<sp/>&quot;next&quot;<sp/>already<sp/>contains<sp/>all<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1634"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><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="1635"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1636"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next-&gt;next<sp/>=<sp/>tcp_seg_copy(&amp;inseg);</highlight></codeline>
<codeline lineno="1637"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(next-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1638"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_GT(next-&gt;tcphdr-&gt;seqno<sp/>+<sp/>next-&gt;len,<sp/>seqno))<sp/>{</highlight></codeline>
<codeline lineno="1639"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>need<sp/>to<sp/>trim<sp/>the<sp/>last<sp/>segment.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1640"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next-&gt;len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(seqno<sp/>-<sp/>next-&gt;tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="1641"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(next-&gt;p,<sp/>next-&gt;len);</highlight></codeline>
<codeline lineno="1642"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1643"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>if<sp/>the<sp/>remote<sp/>side<sp/>overruns<sp/>our<sp/>receive<sp/>window<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1644"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_GT((<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)tcplen<sp/>+<sp/>seqno,<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)pcb-&gt;rcv_wnd))<sp/>{</highlight></codeline>
<codeline lineno="1645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1646"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>other<sp/>end<sp/>overran<sp/>receive<sp/>window&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1647"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>len<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>right<sp/>edge<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1648"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seqno,<sp/>tcplen,<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd));</highlight></codeline>
<codeline lineno="1649"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(next-&gt;next-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1650"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Must<sp/>remove<sp/>the<sp/>FIN<sp/>from<sp/>the<sp/>header<sp/>as<sp/>we&apos;re<sp/>trimming</highlight></codeline>
<codeline lineno="1651"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>that<sp/>byte<sp/>of<sp/>sequence-space<sp/>from<sp/>the<sp/>packet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1652"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1afe7c917080459557c65071c4b13c8e12" kindref="member">TCPH_FLAGS_SET</ref>(next-&gt;next-&gt;tcphdr,<sp/><ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(next-&gt;next-&gt;tcphdr)<sp/>&amp;<sp/>~<ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="1653"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1654"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Adjust<sp/>length<sp/>of<sp/>segment<sp/>to<sp/>fit<sp/>in<sp/>the<sp/>window.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1655"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>next-&gt;next-&gt;len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd<sp/>-<sp/>seqno);</highlight></codeline>
<codeline lineno="1656"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga50abfe830a33a1a47a562febee66015d" kindref="member">pbuf_realloc</ref>(next-&gt;next-&gt;p,<sp/>next-&gt;next-&gt;len);</highlight></codeline>
<codeline lineno="1657"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcplen<sp/>=<sp/>TCP_TCPLEN(next-&gt;next);</highlight></codeline>
<codeline lineno="1658"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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;tcp_receive:<sp/>segment<sp/>not<sp/>trimmed<sp/>correctly<sp/>to<sp/>rcv_wnd\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1659"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(seqno<sp/>+<sp/>tcplen)<sp/>==<sp/>(pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd));</highlight></codeline>
<codeline lineno="1660"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1661"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1662"><highlight class="normal"><sp/><sp/><sp/><sp/><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="1663"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1664"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1665"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>next;</highlight></codeline>
<codeline lineno="1666"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1667"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1668"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OOSEQ_MAX_BYTES<sp/>||<sp/>TCP_OOSEQ_MAX_PBUFS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1669"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>that<sp/>the<sp/>data<sp/>on<sp/>ooseq<sp/>doesn&apos;t<sp/>exceed<sp/>one<sp/>of<sp/>the<sp/>limits</highlight></codeline>
<codeline lineno="1670"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>throw<sp/>away<sp/>everything<sp/>above<sp/>that<sp/>limit.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1671"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ooseq_blen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1672"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ooseq_qlen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1673"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1674"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(next<sp/>=<sp/>pcb-&gt;ooseq;<sp/>next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>prev<sp/>=<sp/>next,<sp/>next<sp/>=<sp/>next-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1675"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p<sp/>=<sp/><ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>-&gt;p;</highlight></codeline>
<codeline lineno="1676"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ooseq_blen<sp/>+=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="1677"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ooseq_qlen<sp/>+=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(p);</highlight></codeline>
<codeline lineno="1678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((ooseq_blen<sp/>&gt;<sp/><ref refid="lwipopts_8h_1a9d6d3219bb5fc0bc760a64114de13c25" kindref="member">TCP_OOSEQ_MAX_BYTES</ref>)<sp/>||</highlight></codeline>
<codeline lineno="1679"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(ooseq_qlen<sp/>&gt;<sp/><ref refid="lwipopts_8h_1a1f57d3859c4556f785708e5dc440617e" kindref="member">TCP_OOSEQ_MAX_PBUFS</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1680"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>too<sp/>much<sp/>ooseq<sp/>data,<sp/>dump<sp/>this<sp/>and<sp/>everything<sp/>after<sp/>it<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1681"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_segs_free(<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>);</highlight></codeline>
<codeline lineno="1682"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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="1683"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>first<sp/>ooseq<sp/>segment<sp/>is<sp/>too<sp/>much,<sp/>dump<sp/>the<sp/>whole<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1684"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ooseq<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1685"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1686"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>just<sp/>dump<sp/>&apos;next&apos;<sp/>and<sp/>everything<sp/>after<sp/>it<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1687"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1688"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1689"><highlight class="normal"><sp/><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="1690"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1691"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1692"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OOSEQ_MAX_BYTES<sp/>||<sp/>TCP_OOSEQ_MAX_PBUFS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1693"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_QUEUE_OOSEQ<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1694"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1695"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1696"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>incoming<sp/>segment<sp/>is<sp/>not<sp/>within<sp/>the<sp/>window.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1697"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_send_empty_ack(pcb);</highlight></codeline>
<codeline lineno="1698"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1699"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1700"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Segments<sp/>with<sp/>length<sp/>0<sp/>is<sp/>taken<sp/>care<sp/>of<sp/>here.<sp/>Segments<sp/>that</highlight></codeline>
<codeline lineno="1701"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fall<sp/>out<sp/>of<sp/>the<sp/>window<sp/>are<sp/>ACKed.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1702"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!TCP_SEQ_BETWEEN(seqno,<sp/>pcb-&gt;rcv_nxt,<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_wnd<sp/>-<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="1703"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ack_now(pcb);</highlight></codeline>
<codeline lineno="1704"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1705"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1706"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1707"><highlight class="normal"></highlight></codeline>
<codeline lineno="1708"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref></highlight></codeline>
<codeline lineno="1709"><highlight class="normal">tcp_getoptbyte(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="1710"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1711"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcphdr_opt2<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(tcp_optidx<sp/>&lt;<sp/>tcphdr_opt1len))<sp/>{</highlight></codeline>
<codeline lineno="1712"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*<sp/>opts<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*)tcphdr<sp/>+<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>;</highlight></codeline>
<codeline lineno="1713"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>opts[tcp_optidx++];</highlight></codeline>
<codeline lineno="1714"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1715"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>idx<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)(tcp_optidx++<sp/>-<sp/>tcphdr_opt1len);</highlight></codeline>
<codeline lineno="1716"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>tcphdr_opt2[idx];</highlight></codeline>
<codeline lineno="1717"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1718"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1719"><highlight class="normal"></highlight></codeline>
<codeline lineno="1728"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1729"><highlight class="normal">tcp_parseopt(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1730"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1731"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>data;</highlight></codeline>
<codeline lineno="1732"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>mss;</highlight></codeline>
<codeline lineno="1733"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1734"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>tsval;</highlight></codeline>
<codeline lineno="1735"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1736"><highlight class="normal"></highlight></codeline>
<codeline lineno="1737"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Parse<sp/>the<sp/>TCP<sp/>MSS<sp/>option,<sp/>if<sp/>present.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1738"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcphdr_optlen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1739"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(tcp_optidx<sp/>=<sp/>0;<sp/>tcp_optidx<sp/>&lt;<sp/>tcphdr_optlen;<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="1740"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>opt<sp/>=<sp/>tcp_getoptbyte();</highlight></codeline>
<codeline lineno="1741"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(opt)<sp/>{</highlight></codeline>
<codeline lineno="1742"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LWIP_TCP_OPT_EOL:</highlight></codeline>
<codeline lineno="1743"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>End<sp/>of<sp/>options.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1744"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>EOL\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1745"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1746"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LWIP_TCP_OPT_NOP:</highlight></codeline>
<codeline lineno="1747"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>NOP<sp/>option.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1748"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>NOP\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1749"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1750"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LWIP_TCP_OPT_MSS:</highlight></codeline>
<codeline lineno="1751"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>MSS\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1752"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_getoptbyte()<sp/>!=<sp/>LWIP_TCP_OPT_LEN_MSS<sp/>||<sp/>(tcp_optidx<sp/>-<sp/>2<sp/>+<sp/>LWIP_TCP_OPT_LEN_MSS)<sp/>&gt;<sp/>tcphdr_optlen)<sp/>{</highlight></codeline>
<codeline lineno="1753"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Bad<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1754"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>bad<sp/>length\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1755"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1756"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1757"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>An<sp/>MSS<sp/>option<sp/>with<sp/>the<sp/>right<sp/>option<sp/>length.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1758"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mss<sp/>=<sp/>(tcp_getoptbyte()<sp/>&lt;&lt;<sp/>8);</highlight></codeline>
<codeline lineno="1759"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mss<sp/>|=<sp/>tcp_getoptbyte();</highlight></codeline>
<codeline lineno="1760"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Limit<sp/>the<sp/>mss<sp/>to<sp/>the<sp/>configured<sp/>TCP_MSS<sp/>and<sp/>prevent<sp/>division<sp/>by<sp/>zero<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1761"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;mss<sp/>=<sp/>((mss<sp/>&gt;<sp/><ref refid="lwipopts_8h_1af1ab7bb27860aa3677c387a2f3ba317b" kindref="member">TCP_MSS</ref>)<sp/>||<sp/>(mss<sp/>==<sp/>0))<sp/>?<sp/><ref refid="lwipopts_8h_1af1ab7bb27860aa3677c387a2f3ba317b" kindref="member">TCP_MSS</ref><sp/>:<sp/>mss;</highlight></codeline>
<codeline lineno="1762"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1763"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1764"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LWIP_TCP_OPT_WS:</highlight></codeline>
<codeline lineno="1765"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>WND_SCALE\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1766"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_getoptbyte()<sp/>!=<sp/>LWIP_TCP_OPT_LEN_WS<sp/>||<sp/>(tcp_optidx<sp/>-<sp/>2<sp/>+<sp/>LWIP_TCP_OPT_LEN_WS)<sp/>&gt;<sp/>tcphdr_optlen)<sp/>{</highlight></codeline>
<codeline lineno="1767"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Bad<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1768"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>bad<sp/>length\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1769"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1770"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1771"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>An<sp/>WND_SCALE<sp/>option<sp/>with<sp/>the<sp/>right<sp/>option<sp/>length.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1772"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>data<sp/>=<sp/>tcp_getoptbyte();</highlight></codeline>
<codeline lineno="1773"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>syn<sp/>was<sp/>received<sp/>with<sp/>wnd<sp/>scale<sp/>option,</highlight></codeline>
<codeline lineno="1774"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>activate<sp/>wnd<sp/>scale<sp/>opt,<sp/>but<sp/>only<sp/>if<sp/>this<sp/>is<sp/>not<sp/>a<sp/>retransmission<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1775"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>&amp;&amp;<sp/>!(pcb-&gt;flags<sp/>&amp;<sp/>TF_WND_SCALE))<sp/>{</highlight></codeline>
<codeline lineno="1776"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_scale<sp/>=<sp/>data;</highlight></codeline>
<codeline lineno="1777"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_scale<sp/>&gt;<sp/>14U)<sp/>{</highlight></codeline>
<codeline lineno="1778"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_scale<sp/>=<sp/>14U;</highlight></codeline>
<codeline lineno="1779"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1780"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_scale<sp/>=<sp/><ref refid="group__lwip__opts__tcp_1ga768765a2c678fefeca6c89aae0cf629f" kindref="member">TCP_RCV_SCALE</ref>;</highlight></codeline>
<codeline lineno="1781"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_WND_SCALE;</highlight></codeline>
<codeline lineno="1782"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>window<sp/>scaling<sp/>is<sp/>enabled,<sp/>we<sp/>can<sp/>use<sp/>the<sp/>full<sp/>receive<sp/>window<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1783"><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;window<sp/>not<sp/>at<sp/>default<sp/>value&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;rcv_wnd<sp/>==<sp/>TCPWND_MIN16(<ref refid="lwipopts_8h_1a7f535a6efb5cdf86c3210e35ece1d6a7" kindref="member">TCP_WND</ref>));</highlight></codeline>
<codeline lineno="1784"><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;window<sp/>not<sp/>at<sp/>default<sp/>value&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;rcv_ann_wnd<sp/>==<sp/>TCPWND_MIN16(<ref refid="lwipopts_8h_1a7f535a6efb5cdf86c3210e35ece1d6a7" kindref="member">TCP_WND</ref>));</highlight></codeline>
<codeline lineno="1785"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;rcv_wnd<sp/>=<sp/>pcb-&gt;rcv_ann_wnd<sp/>=<sp/><ref refid="lwipopts_8h_1a7f535a6efb5cdf86c3210e35ece1d6a7" kindref="member">TCP_WND</ref>;</highlight></codeline>
<codeline lineno="1786"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1787"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1788"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1789"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1790"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>LWIP_TCP_OPT_TS:</highlight></codeline>
<codeline lineno="1791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>TS\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1792"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_getoptbyte()<sp/>!=<sp/>LWIP_TCP_OPT_LEN_TS<sp/>||<sp/>(tcp_optidx<sp/>-<sp/>2<sp/>+<sp/>LWIP_TCP_OPT_LEN_TS)<sp/>&gt;<sp/>tcphdr_optlen)<sp/>{</highlight></codeline>
<codeline lineno="1793"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Bad<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1794"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>bad<sp/>length\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>TCP<sp/>timestamp<sp/>option<sp/>with<sp/>valid<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tsval<sp/>=<sp/>tcp_getoptbyte();</highlight></codeline>
<codeline lineno="1799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tsval<sp/>|=<sp/>(tcp_getoptbyte()<sp/>&lt;&lt;<sp/>8);</highlight></codeline>
<codeline lineno="1800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tsval<sp/>|=<sp/>(tcp_getoptbyte()<sp/>&lt;&lt;<sp/>16);</highlight></codeline>
<codeline lineno="1801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tsval<sp/>|=<sp/>(tcp_getoptbyte()<sp/>&lt;&lt;<sp/>24);</highlight></codeline>
<codeline lineno="1802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ts_recent<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(tsval);</highlight></codeline>
<codeline lineno="1804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Enable<sp/>sending<sp/>timestamps<sp/>in<sp/>every<sp/>segment<sp/>now<sp/>that<sp/>we<sp/>know</highlight></codeline>
<codeline lineno="1805"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>remote<sp/>host<sp/>supports<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1806"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_TIMESTAMP;</highlight></codeline>
<codeline lineno="1807"><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/>(TCP_SEQ_BETWEEN(pcb-&gt;ts_lastacksent,<sp/>seqno,<sp/>seqno+tcplen))<sp/>{</highlight></codeline>
<codeline lineno="1808"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ts_recent<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(tsval);</highlight></codeline>
<codeline lineno="1809"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1810"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Advance<sp/>to<sp/>next<sp/>option<sp/>(6<sp/>bytes<sp/>already<sp/>read)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1811"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_optidx<sp/>+=<sp/>LWIP_TCP_OPT_LEN_TS<sp/>-<sp/>6;</highlight></codeline>
<codeline lineno="1812"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1813"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1814"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1815"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>other\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1816"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>data<sp/>=<sp/>tcp_getoptbyte();</highlight></codeline>
<codeline lineno="1817"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(data<sp/>&lt;<sp/>2)<sp/>{</highlight></codeline>
<codeline lineno="1818"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1af51dc2563536de56470146749f715ba8" kindref="member">TCP_INPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_parseopt:<sp/>bad<sp/>length\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1819"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>length<sp/>field<sp/>is<sp/>zero,<sp/>the<sp/>options<sp/>are<sp/>malformed</highlight></codeline>
<codeline lineno="1820"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>we<sp/>don&apos;t<sp/>process<sp/>them<sp/>further.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1821"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1822"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1823"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>All<sp/>other<sp/>options<sp/>have<sp/>a<sp/>length<sp/>field,<sp/>so<sp/>that<sp/>we<sp/>easily</highlight></codeline>
<codeline lineno="1824"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>can<sp/>skip<sp/>past<sp/>them.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1825"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_optidx<sp/>+=<sp/>data<sp/>-<sp/>2;</highlight></codeline>
<codeline lineno="1826"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1827"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1828"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1829"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1830"><highlight class="normal"></highlight></codeline>
<codeline lineno="1831"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1832"><highlight class="normal">tcp_trigger_input_pcb_close(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="1833"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1834"><highlight class="normal"><sp/><sp/>recv_flags<sp/>|=<sp/>TF_CLOSED;</highlight></codeline>
<codeline lineno="1835"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1836"><highlight class="normal"></highlight></codeline>
<codeline lineno="1837"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/net/core/tcp_in.c"/>
  </compounddef>
</doxygen>
