<?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__out_8c" kind="file" language="C++">
    <compoundname>tcp_out.c</compoundname>
    <includes refid="opt_8h" local="yes">net/opt.h</includes>
    <incdepgraph>
      <node id="17">
        <label>stdarg.h</label>
        <link refid="stdarg_8h"/>
      </node>
      <node id="18">
        <label>ubixos/kpanic.h</label>
        <link refid="kpanic_8h"/>
      </node>
      <node id="15">
        <label>sys/io.h</label>
        <link refid="io_8h"/>
      </node>
      <node id="8">
        <label>sys/select.h</label>
        <link refid="select_8h"/>
        <childnode refid="9" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>net/arch/cc.h</label>
        <link refid="cc_8h"/>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="12">
        <label>sys/_sigset.h</label>
        <link refid="__sigset_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="3">
        <label>net/lwipopts.h</label>
        <link refid="lwipopts_8h"/>
      </node>
      <node id="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="1">
        <label>C:/Dev/git/UbixOS/sys/net/core/tcp_out.c</label>
        <link refid="tcp__out_8c"/>
        <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, outgoing traffic</para>
<para>The output functions of TCP. </para>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="9"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="10"><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="11"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="12"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="13"><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="14"><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="15"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="16"><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="17"><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="18"><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="19"><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="20"><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="21"><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="22"><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="23"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="24"><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="25"><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="26"><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="27"><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="28"><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="29"><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="30"><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="31"><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="32"><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="33"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="34"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="35"><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="36"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="37"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Adam<sp/>Dunkels<sp/>&lt;adam@sics.se&gt;</highlight></codeline>
<codeline lineno="38"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="39"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="opt_8h" kindref="compound">net/opt.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="42"><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_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="44"><highlight class="normal"></highlight></codeline>
<codeline lineno="45"><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="46"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="def_8h" kindref="compound">net/def.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="mem_8h" kindref="compound">net/mem.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><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="49"><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="50"><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="51"><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="52"><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="53"><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="54"><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="55"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="56"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="sys_8h" kindref="compound">net/sys.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="string_8h" kindref="compound">string.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="60"><highlight class="normal"></highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Define<sp/>some<sp/>copy-macros<sp/>for<sp/>checksum-on-copy<sp/>so<sp/>that<sp/>the<sp/>code<sp/>looks</highlight></codeline>
<codeline lineno="62"><highlight class="comment"><sp/><sp/><sp/>nicer<sp/>by<sp/>preventing<sp/>too<sp/>many<sp/>ifdef&apos;s.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="63"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="64"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_DATA_COPY(dst,<sp/>src,<sp/>len,<sp/>seg)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="65"><highlight class="preprocessor"><sp/><sp/>tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst,<sp/>src,<sp/>len),<sp/>\</highlight></codeline>
<codeline lineno="66"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>len,<sp/>&amp;seg-&gt;chksum,<sp/>&amp;seg-&gt;chksum_swapped);<sp/>\</highlight></codeline>
<codeline lineno="67"><highlight class="preprocessor"><sp/><sp/>seg-&gt;flags<sp/>|=<sp/>TF_SEG_DATA_CHECKSUMMED;<sp/>}<sp/>while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_DATA_COPY2(dst,<sp/>src,<sp/>len,<sp/>chksum,<sp/>chksum_swapped)<sp/><sp/>\</highlight></codeline>
<codeline lineno="69"><highlight class="preprocessor"><sp/><sp/>tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst,<sp/>src,<sp/>len),<sp/>len,<sp/>chksum,<sp/>chksum_swapped);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="70"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_DATA_COPY(dst,<sp/>src,<sp/>len,<sp/>seg)<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>MEMCPY(dst,<sp/>src,<sp/>len)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_DATA_COPY2(dst,<sp/>src,<sp/>len,<sp/>chksum,<sp/>chksum_swapped)<sp/>MEMCPY(dst,<sp/>src,<sp/>len)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="preprocessor">#ifndef<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK<sp/><sp/><sp/>0</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Allow<sp/>to<sp/>override<sp/>the<sp/>failure<sp/>of<sp/>sanity<sp/>check<sp/>from<sp/>warning<sp/>to<sp/>e.g.<sp/>hard<sp/>failure<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight><highlight class="preprocessor">#ifndef<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK_FAIL</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="83"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK_FAIL(msg)<sp/>LWIP_DEBUGF(TCP_DEBUG<sp/>|<sp/>LWIP_DBG_LEVEL_WARNING,<sp/>msg)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="84"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="86"><highlight class="normal"></highlight></codeline>
<codeline lineno="87"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"></highlight></codeline>
<codeline lineno="89"><highlight class="preprocessor">#ifndef<sp/>TCP_OVERSIZE_CALC_LENGTH</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="90"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCP_OVERSIZE_CALC_LENGTH(length)<sp/>((length)<sp/>+<sp/>TCP_OVERSIZE)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="92"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="93"><highlight class="normal"></highlight></codeline>
<codeline lineno="94"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Forward<sp/>declarations.*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="95"><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_output_segment(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_seg<sp/>*seg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="96"><highlight class="normal"></highlight></codeline>
<codeline lineno="107"><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/>*</highlight></codeline>
<codeline lineno="108"><highlight class="normal">tcp_output_alloc_header(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>optlen,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>datalen,</highlight></codeline>
<codeline lineno="109"><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__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>seqno_be<sp/></highlight><highlight class="comment">/*<sp/>already<sp/>in<sp/>network<sp/>byte<sp/>order<sp/>*/</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="110"><highlight class="normal">{</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><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="112"><highlight class="normal"><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="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfafcc1e506061ba69dfa142eb6b3da5f13" kindref="member">PBUF_IP</ref>,<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref><sp/>+<sp/>optlen<sp/>+<sp/>datalen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;check<sp/>that<sp/>first<sp/>pbuf<sp/>can<sp/>hold<sp/>struct<sp/>tcp_hdr&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref><sp/>+<sp/>optlen));</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/><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="117"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;src<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(pcb-&gt;local_port);</highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;dest<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(pcb-&gt;remote_port);</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;seqno<sp/>=<sp/>seqno_be;</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;ackno<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(pcb-&gt;rcv_nxt);</highlight></codeline>
<codeline lineno="121"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a57fb29aed8df21ccff4481612ee40407" kindref="member">TCPH_HDRLEN_FLAGS_SET</ref>(tcphdr,<sp/>(5<sp/>+<sp/>optlen<sp/>/<sp/>4),<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>);</highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(TCPWND_MIN16(RCV_WND_SCALE(pcb,<sp/>pcb-&gt;rcv_ann_wnd)));</highlight></codeline>
<codeline lineno="123"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="124"><highlight class="normal"><sp/><sp/><sp/><sp/>tcphdr-&gt;urgp<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="125"><highlight class="normal"></highlight></codeline>
<codeline lineno="126"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we&apos;re<sp/>sending<sp/>a<sp/>packet,<sp/>update<sp/>the<sp/>announced<sp/>right<sp/>window<sp/>edge<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;rcv_ann_right_edge<sp/>=<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_ann_wnd;</highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>p;</highlight></codeline>
<codeline lineno="130"><highlight class="normal">}</highlight></codeline>
<codeline lineno="131"><highlight class="normal"></highlight></codeline>
<codeline lineno="138"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="139"><highlight class="normal">tcp_send_fin(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="140"><highlight class="normal">{</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>first,<sp/>try<sp/>to<sp/>add<sp/>the<sp/>fin<sp/>to<sp/>the<sp/>last<sp/>unsent<sp/>segment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="142"><highlight class="normal"><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="143"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*last_unsent;</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(last_unsent<sp/>=<sp/>pcb-&gt;unsent;<sp/>last_unsent-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>last_unsent<sp/>=<sp/>last_unsent-&gt;next);</highlight></codeline>
<codeline lineno="146"><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><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>(last_unsent-&gt;tcphdr)<sp/>&amp;<sp/>(<ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>))<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>SYN/FIN/RST<sp/>flag<sp/>in<sp/>the<sp/>header,<sp/>we<sp/>can<sp/>add<sp/>the<sp/>FIN<sp/>flag<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a42432f2dde6716ecb0087ccbc47cc75b" kindref="member">TCPH_SET_FLAG</ref>(last_unsent-&gt;tcphdr,<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_FIN;</highlight></codeline>
<codeline lineno="151"><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="152"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="153"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>data,<sp/>no<sp/>length,<sp/>flags,<sp/>copy=1,<sp/>no<sp/>optdata<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>tcp_enqueue_flags(pcb,<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="156"><highlight class="normal">}</highlight></codeline>
<codeline lineno="157"><highlight class="normal"></highlight></codeline>
<codeline lineno="172"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*</highlight></codeline>
<codeline lineno="173"><highlight class="normal">tcp_create_segment(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>flags,<sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>seqno,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optflags)</highlight></codeline>
<codeline lineno="174"><highlight class="normal">{</highlight></codeline>
<codeline lineno="175"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg;</highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optlen<sp/>=<sp/>LWIP_TCP_OPT_LENGTH(optflags);</highlight></codeline>
<codeline lineno="177"><highlight class="normal"></highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((seg<sp/>=<sp/>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_seg<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_TCP_SEG))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_create_segment:<sp/>no<sp/>memory.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/>seg-&gt;flags<sp/>=<sp/>optflags;</highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/>seg-&gt;next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/>seg-&gt;p<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;p-&gt;tot_len<sp/>&gt;=<sp/>optlen&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>&gt;=<sp/>optlen);</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/>seg-&gt;len<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>-<sp/>optlen;</highlight></codeline>
<codeline lineno="188"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/>seg-&gt;oversize_left<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="190"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="191"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/>seg-&gt;chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/>seg-&gt;chksum_swapped<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>optflags<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="195"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;invalid<sp/>optflags<sp/>passed:<sp/>TF_SEG_DATA_CHECKSUMMED&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(optflags<sp/>&amp;<sp/>TF_SEG_DATA_CHECKSUMMED)<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="197"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="198"><highlight class="normal"></highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>build<sp/>TCP<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="200"><highlight class="normal"><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="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>))<sp/>{</highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_create_segment:<sp/>no<sp/>room<sp/>for<sp/>TCP<sp/>header<sp/>in<sp/>pbuf.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.err);</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_seg_free(seg);</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structtcp__hdr" kindref="compound">tcp_hdr</ref><sp/>*)seg-&gt;p-&gt;payload;</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;src<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(pcb-&gt;local_port);</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;dest<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(pcb-&gt;remote_port);</highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;seqno<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(seqno);</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>ackno<sp/>is<sp/>set<sp/>in<sp/>tcp_output<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="211"><highlight class="normal"><sp/><sp/><ref refid="prot_2tcp_8h_1a57fb29aed8df21ccff4481612ee40407" kindref="member">TCPH_HDRLEN_FLAGS_SET</ref>(seg-&gt;tcphdr,<sp/>(5<sp/>+<sp/>optlen<sp/>/<sp/>4),<sp/>flags);</highlight></codeline>
<codeline lineno="212"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>wnd<sp/>and<sp/>chksum<sp/>are<sp/>set<sp/>in<sp/>tcp_output<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;urgp<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="214"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>seg;</highlight></codeline>
<codeline lineno="215"><highlight class="normal">}</highlight></codeline>
<codeline lineno="216"><highlight class="normal"></highlight></codeline>
<codeline lineno="231"><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="232"><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/>*</highlight></codeline>
<codeline lineno="233"><highlight class="normal">tcp_pbuf_prealloc(<ref refid="group__pbuf_1gaee1baa59bb2f85ba575b5a8619ac1ebf" kindref="member">pbuf_layer</ref><sp/>layer,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>length,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>max_length,</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>*oversize,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>apiflags,</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>first_seg)</highlight></codeline>
<codeline lineno="236"><highlight class="normal">{</highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="238"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>alloc<sp/>=<sp/>length;</highlight></codeline>
<codeline lineno="239"><highlight class="normal"></highlight></codeline>
<codeline lineno="240"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(max_length);</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(apiflags);</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(first_seg);</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/>alloc<sp/>=<sp/>max_length;</highlight></codeline>
<codeline lineno="246"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(length<sp/>&lt;<sp/>max_length)<sp/>{</highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Should<sp/>we<sp/>allocate<sp/>an<sp/>oversized<sp/>pbuf,<sp/>or<sp/>just<sp/>the<sp/>minimum</highlight></codeline>
<codeline lineno="249"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>length<sp/>required?<sp/>If<sp/>tcp_write<sp/>is<sp/>going<sp/>to<sp/>be<sp/>called<sp/>again</highlight></codeline>
<codeline lineno="250"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>before<sp/>this<sp/>segment<sp/>is<sp/>transmitted,<sp/>we<sp/>want<sp/>the<sp/>oversized</highlight></codeline>
<codeline lineno="251"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>buffer.<sp/>If<sp/>the<sp/>segment<sp/>will<sp/>be<sp/>transmitted<sp/>immediately,<sp/>we<sp/>can</highlight></codeline>
<codeline lineno="252"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>save<sp/>memory<sp/>by<sp/>allocating<sp/>only<sp/>length.<sp/>We<sp/>use<sp/>a<sp/>simple</highlight></codeline>
<codeline lineno="253"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>heuristic<sp/>based<sp/>on<sp/>the<sp/>following<sp/>information:</highlight></codeline>
<codeline lineno="254"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="255"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Did<sp/>the<sp/>user<sp/>set<sp/>TCP_WRITE_FLAG_MORE?</highlight></codeline>
<codeline lineno="256"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="257"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Will<sp/>the<sp/>Nagle<sp/>algorithm<sp/>defer<sp/>transmission<sp/>of<sp/>this<sp/>segment?</highlight></codeline>
<codeline lineno="258"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((apiflags<sp/>&amp;<sp/>TCP_WRITE_FLAG_MORE)<sp/>||</highlight></codeline>
<codeline lineno="260"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(!(pcb-&gt;flags<sp/>&amp;<sp/>TF_NODELAY)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="261"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(!first_seg<sp/>||</highlight></codeline>
<codeline lineno="262"><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="263"><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/>{</highlight></codeline>
<codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>alloc<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(max_length,<sp/><ref refid="group__compiler__abstraction_1gaef204be511fd32f681b55abc08e9ae18" kindref="member">LWIP_MEM_ALIGN_SIZE</ref>(TCP_OVERSIZE_CALC_LENGTH(length)));</highlight></codeline>
<codeline lineno="265"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="267"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="268"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(layer,<sp/>alloc,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="269"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="270"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="272"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;need<sp/>unchained<sp/>pbuf&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="273"><highlight class="normal"><sp/><sp/>*oversize<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>-<sp/>length;</highlight></codeline>
<codeline lineno="274"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>trim<sp/>p-&gt;len<sp/>to<sp/>the<sp/>currently<sp/>used<sp/>size<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="275"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>=<sp/>length;</highlight></codeline>
<codeline lineno="276"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>p;</highlight></codeline>
<codeline lineno="277"><highlight class="normal">}</highlight></codeline>
<codeline lineno="278"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="279"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>tcp_pbuf_prealloc(layer,<sp/>length,<sp/>mx,<sp/>os,<sp/>pcb,<sp/>api,<sp/>fst)<sp/>pbuf_alloc((layer),<sp/>(length),<sp/>PBUF_RAM)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="280"><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="281"><highlight class="normal"></highlight></codeline>
<codeline lineno="282"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="283"><highlight class="normal"></highlight></codeline>
<codeline lineno="284"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="285"><highlight class="normal">tcp_seg_add_chksum(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>*seg_chksum,</highlight></codeline>
<codeline lineno="286"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*seg_chksum_swapped)</highlight></codeline>
<codeline lineno="287"><highlight class="normal">{</highlight></codeline>
<codeline lineno="288"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>helper;</highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>add<sp/>chksum<sp/>to<sp/>old<sp/>chksum<sp/>and<sp/>fold<sp/>to<sp/>u16_t<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/>helper<sp/>=<sp/>chksum<sp/>+<sp/>*seg_chksum;</highlight></codeline>
<codeline lineno="291"><highlight class="normal"><sp/><sp/>chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a6ffe83b4bdd1784a0671ee4778966a01" kindref="member">FOLD_U32T</ref>(helper);</highlight></codeline>
<codeline lineno="292"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&amp;<sp/>1)<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="293"><highlight class="normal"><sp/><sp/><sp/><sp/>*seg_chksum_swapped<sp/>=<sp/>1<sp/>-<sp/>*seg_chksum_swapped;</highlight></codeline>
<codeline lineno="294"><highlight class="normal"><sp/><sp/><sp/><sp/>chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a0196bd603262882d16b5264b52eafe18" kindref="member">SWAP_BYTES_IN_WORD</ref>(chksum);</highlight></codeline>
<codeline lineno="295"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/>*seg_chksum<sp/>=<sp/>chksum;</highlight></codeline>
<codeline lineno="297"><highlight class="normal">}</highlight></codeline>
<codeline lineno="298"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="299"><highlight class="normal"></highlight></codeline>
<codeline lineno="306"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="307"><highlight class="normal">tcp_write_checks(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>)</highlight></codeline>
<codeline lineno="308"><highlight class="normal">{</highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>connection<sp/>is<sp/>in<sp/>invalid<sp/>state<sp/>for<sp/>data<sp/>transmission?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="310"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;state<sp/>!=<sp/>ESTABLISHED)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;state<sp/>!=<sp/>CLOSE_WAIT)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="312"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;state<sp/>!=<sp/>SYN_SENT)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="313"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(pcb-&gt;state<sp/>!=<sp/>SYN_RCVD))<sp/>{</highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1gaab41143277cd38047b6660d90e9cec3b" kindref="member">LWIP_DBG_LEVEL_SEVERE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write()<sp/>called<sp/>in<sp/>invalid<sp/>state\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="316"><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/>(<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="317"><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="318"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="319"><highlight class="normal"></highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>fail<sp/>on<sp/>too<sp/>much<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;<sp/>pcb-&gt;snd_buf)<sp/>{</highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1gaab41143277cd38047b6660d90e9cec3b" kindref="member">LWIP_DBG_LEVEL_SEVERE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>too<sp/>much<sp/>data<sp/>(len=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>&gt;<sp/>snd_buf=%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>,<sp/>pcb-&gt;snd_buf));</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="327"><highlight class="normal"></highlight></codeline>
<codeline lineno="328"><highlight class="normal"><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_write:<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="329"><highlight class="normal"></highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>total<sp/>number<sp/>of<sp/>pbufs<sp/>on<sp/>the<sp/>unsent/unacked<sp/>queues<sp/>exceeds<sp/>the</highlight></codeline>
<codeline lineno="331"><highlight class="comment"><sp/><sp/><sp/>*<sp/>configured<sp/>maximum,<sp/>return<sp/>an<sp/>error<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="332"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>for<sp/>configured<sp/>max<sp/>queuelen<sp/>and<sp/>possible<sp/>overflow<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="333"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;snd_queuelen<sp/>&gt;=<sp/><ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>)<sp/>||<sp/>(pcb-&gt;snd_queuelen<sp/>&gt;<sp/>TCP_SNDQUEUELEN_OVERFLOW))<sp/>{</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1gaab41143277cd38047b6660d90e9cec3b" kindref="member">LWIP_DBG_LEVEL_SEVERE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>too<sp/>long<sp/>queue<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(max<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">,</highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_queuelen,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)<ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>));</highlight></codeline>
<codeline lineno="336"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</highlight></codeline>
<codeline lineno="337"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="338"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="339"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="340"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>pbufs<sp/>on<sp/>queue<sp/>=&gt;<sp/>at<sp/>least<sp/>one<sp/>queue<sp/>non-empty&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="342"><highlight class="normal"><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="343"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="344"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>no<sp/>pbufs<sp/>on<sp/>queue<sp/>=&gt;<sp/>both<sp/>queues<sp/>empty&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>pcb-&gt;unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="346"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="347"><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="348"><highlight class="normal">}</highlight></codeline>
<codeline lineno="349"><highlight class="normal"></highlight></codeline>
<codeline lineno="367"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="368"><highlight class="normal">tcp_write(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>apiflags)</highlight></codeline>
<codeline lineno="369"><highlight class="normal">{</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*concat_p<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*last_unsent<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>*seg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>*prev_seg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>*queue<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>pos<sp/>=<sp/>0;<sp/></highlight><highlight class="comment">/*<sp/>position<sp/>in<sp/>&apos;arg&apos;<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>queuelen;</highlight></codeline>
<codeline lineno="374"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optlen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optflags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="376"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>oversize<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="378"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>oversize_used<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="379"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="380"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>oversize_add<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="381"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="382"><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="383"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>extendlen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="384"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="385"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>concat_chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="386"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>concat_chksum_swapped<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>concat_chksummed<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="388"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="389"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>allocate<sp/>segments<sp/>bigger<sp/>than<sp/>half<sp/>the<sp/>maximum<sp/>window<sp/>we<sp/>ever<sp/>received<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="391"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>mss_local<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(pcb-&gt;mss,<sp/>TCPWND_MIN16(pcb-&gt;snd_wnd_max/2));</highlight></codeline>
<codeline lineno="392"><highlight class="normal"><sp/><sp/>mss_local<sp/>=<sp/>mss_local<sp/>?<sp/>mss_local<sp/>:<sp/>pcb-&gt;mss;</highlight></codeline>
<codeline lineno="393"><highlight class="normal"></highlight></codeline>
<codeline lineno="394"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Always<sp/>copy<sp/>to<sp/>try<sp/>to<sp/>create<sp/>single<sp/>pbufs<sp/>for<sp/>TX<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/>apiflags<sp/>|=<sp/>TCP_WRITE_FLAG_COPY;</highlight></codeline>
<codeline lineno="397"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="398"><highlight class="normal"></highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write(pcb=%p,<sp/>data=%p,<sp/>len=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>apiflags=%&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">,</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/><sp/><sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)pcb,<sp/>arg,<sp/>len,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)apiflags));</highlight></codeline>
<codeline lineno="401"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>arg<sp/>==<sp/>NULL<sp/>(programmer<sp/>violates<sp/>API)&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>arg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>;);</highlight></codeline>
<codeline lineno="403"><highlight class="normal"></highlight></codeline>
<codeline lineno="404"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>tcp_write_checks(pcb,<sp/>len);</highlight></codeline>
<codeline lineno="405"><highlight class="normal"><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="406"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/>queuelen<sp/>=<sp/>pcb-&gt;snd_queuelen;</highlight></codeline>
<codeline lineno="409"><highlight class="normal"></highlight></codeline>
<codeline lineno="410"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;flags<sp/>&amp;<sp/>TF_TIMESTAMP))<sp/>{</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Make<sp/>sure<sp/>the<sp/>timestamp<sp/>option<sp/>is<sp/>only<sp/>included<sp/>in<sp/>data<sp/>segments<sp/>if<sp/>we</highlight></codeline>
<codeline lineno="413"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>agreed<sp/>about<sp/>it<sp/>with<sp/>the<sp/>remote<sp/>host.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/><sp/><sp/>optflags<sp/>=<sp/>TF_SEG_OPTS_TS;</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/>optlen<sp/>=<sp/>LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS);</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>ensure<sp/>that<sp/>segments<sp/>can<sp/>hold<sp/>at<sp/>least<sp/>one<sp/>data<sp/>byte...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/>mss_local<sp/>=<sp/><ref refid="def_8h_1a21ea174d374106caeafb4aa3a24fbd2b" kindref="member">LWIP_MAX</ref>(mss_local,<sp/>LWIP_TCP_OPT_LEN_TS<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="419"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_TIMESTAMPS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="420"><highlight class="normal"></highlight></codeline>
<codeline lineno="421"><highlight class="normal"></highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="423"><highlight class="comment"><sp/><sp/><sp/>*<sp/>TCP<sp/>segmentation<sp/>is<sp/>done<sp/>in<sp/>three<sp/>phases<sp/>with<sp/>increasing<sp/>complexity:</highlight></codeline>
<codeline lineno="424"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="425"><highlight class="comment"><sp/><sp/><sp/>*<sp/>1.<sp/>Copy<sp/>data<sp/>directly<sp/>into<sp/>an<sp/>oversized<sp/>pbuf.</highlight></codeline>
<codeline lineno="426"><highlight class="comment"><sp/><sp/><sp/>*<sp/>2.<sp/>Chain<sp/>a<sp/>new<sp/>pbuf<sp/>to<sp/>the<sp/>end<sp/>of<sp/>pcb-&gt;unsent.</highlight></codeline>
<codeline lineno="427"><highlight class="comment"><sp/><sp/><sp/>*<sp/>3.<sp/>Create<sp/>new<sp/>segments.</highlight></codeline>
<codeline lineno="428"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="429"><highlight class="comment"><sp/><sp/><sp/>*<sp/>We<sp/>may<sp/>run<sp/>out<sp/>of<sp/>memory<sp/>at<sp/>any<sp/>point.<sp/>In<sp/>that<sp/>case<sp/>we<sp/>must</highlight></codeline>
<codeline lineno="430"><highlight class="comment"><sp/><sp/><sp/>*<sp/>return<sp/>ERR_MEM<sp/>and<sp/>not<sp/>change<sp/>anything<sp/>in<sp/>pcb.<sp/>Therefore,<sp/>all</highlight></codeline>
<codeline lineno="431"><highlight class="comment"><sp/><sp/><sp/>*<sp/>changes<sp/>are<sp/>recorded<sp/>in<sp/>local<sp/>variables<sp/>and<sp/>committed<sp/>at<sp/>the<sp/>end</highlight></codeline>
<codeline lineno="432"><highlight class="comment"><sp/><sp/><sp/>*<sp/>of<sp/>the<sp/>function.<sp/>Some<sp/>pcb<sp/>fields<sp/>are<sp/>maintained<sp/>in<sp/>local<sp/>copies:</highlight></codeline>
<codeline lineno="433"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="434"><highlight class="comment"><sp/><sp/><sp/>*<sp/>queuelen<sp/>=<sp/>pcb-&gt;snd_queuelen</highlight></codeline>
<codeline lineno="435"><highlight class="comment"><sp/><sp/><sp/>*<sp/>oversize<sp/>=<sp/>pcb-&gt;unsent_oversize</highlight></codeline>
<codeline lineno="436"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="437"><highlight class="comment"><sp/><sp/><sp/>*<sp/>These<sp/>variables<sp/>are<sp/>set<sp/>consistently<sp/>by<sp/>the<sp/>phases:</highlight></codeline>
<codeline lineno="438"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="439"><highlight class="comment"><sp/><sp/><sp/>*<sp/>seg<sp/>points<sp/>to<sp/>the<sp/>last<sp/>segment<sp/>tampered<sp/>with.</highlight></codeline>
<codeline lineno="440"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="441"><highlight class="comment"><sp/><sp/><sp/>*<sp/>pos<sp/>records<sp/>progress<sp/>as<sp/>data<sp/>is<sp/>segmented.</highlight></codeline>
<codeline lineno="442"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="443"><highlight class="normal"></highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Find<sp/>the<sp/>tail<sp/>of<sp/>the<sp/>unsent<sp/>queue.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>space;</highlight></codeline>
<codeline lineno="447"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>unsent_optlen;</highlight></codeline>
<codeline lineno="448"><highlight class="normal"></highlight></codeline>
<codeline lineno="449"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>this<sp/>could<sp/>be<sp/>sped<sp/>up<sp/>by<sp/>keeping<sp/>last_unsent<sp/>in<sp/>the<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="450"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(last_unsent<sp/>=<sp/>pcb-&gt;unsent;<sp/>last_unsent-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="451"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>last_unsent<sp/>=<sp/>last_unsent-&gt;next);</highlight></codeline>
<codeline lineno="452"><highlight class="normal"></highlight></codeline>
<codeline lineno="453"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Usable<sp/>space<sp/>at<sp/>the<sp/>end<sp/>of<sp/>the<sp/>last<sp/>unsent<sp/>segment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="454"><highlight class="normal"><sp/><sp/><sp/><sp/>unsent_optlen<sp/>=<sp/>LWIP_TCP_OPT_LENGTH(last_unsent-&gt;flags);</highlight></codeline>
<codeline lineno="455"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;mss_local<sp/>is<sp/>too<sp/>small&quot;</highlight><highlight class="normal">,<sp/>mss_local<sp/>&gt;=<sp/>last_unsent-&gt;len<sp/>+<sp/>unsent_optlen);</highlight></codeline>
<codeline lineno="456"><highlight class="normal"><sp/><sp/><sp/><sp/>space<sp/>=<sp/>mss_local<sp/>-<sp/>(last_unsent-&gt;len<sp/>+<sp/>unsent_optlen);</highlight></codeline>
<codeline lineno="457"><highlight class="normal"></highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="459"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Phase<sp/>1:<sp/>Copy<sp/>data<sp/>directly<sp/>into<sp/>an<sp/>oversized<sp/>pbuf.</highlight></codeline>
<codeline lineno="460"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="461"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>The<sp/>number<sp/>of<sp/>bytes<sp/>copied<sp/>is<sp/>recorded<sp/>in<sp/>the<sp/>oversize_used</highlight></codeline>
<codeline lineno="462"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>variable.<sp/>The<sp/>actual<sp/>copying<sp/>is<sp/>done<sp/>at<sp/>the<sp/>bottom<sp/>of<sp/>the</highlight></codeline>
<codeline lineno="463"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>function.</highlight></codeline>
<codeline lineno="464"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="465"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="466"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="467"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>that<sp/>pcb-&gt;unsent_oversize<sp/>matches<sp/>last_unsent-&gt;oversize_left<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="468"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;unsent_oversize<sp/>mismatch<sp/>(pcb<sp/>vs.<sp/>last_unsent)&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="469"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>==<sp/>last_unsent-&gt;oversize_left);</highlight></codeline>
<codeline lineno="470"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="471"><highlight class="normal"><sp/><sp/><sp/><sp/>oversize<sp/>=<sp/>pcb-&gt;unsent_oversize;</highlight></codeline>
<codeline lineno="472"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(oversize<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;inconsistent<sp/>oversize<sp/>vs.<sp/>space&quot;</highlight><highlight class="normal">,<sp/>oversize<sp/>&lt;=<sp/>space);</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg<sp/>=<sp/>last_unsent;</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>oversize_used<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(space,<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(oversize,<sp/>len));</highlight></codeline>
<codeline lineno="476"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pos<sp/>+=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>oversize<sp/>-=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>space<sp/>-=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>now<sp/>we<sp/>are<sp/>either<sp/>finished<sp/>or<sp/>oversize<sp/>is<sp/>zero<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="481"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;inconsistent<sp/>oversize<sp/>vs.<sp/>len&quot;</highlight><highlight class="normal">,<sp/>(oversize<sp/>==<sp/>0)<sp/>||<sp/>(pos<sp/>==<sp/>len));</highlight></codeline>
<codeline lineno="482"><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="483"><highlight class="normal"></highlight></codeline>
<codeline lineno="484"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="485"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Phase<sp/>2:<sp/>Chain<sp/>a<sp/>new<sp/>pbuf<sp/>to<sp/>the<sp/>end<sp/>of<sp/>pcb-&gt;unsent.</highlight></codeline>
<codeline lineno="486"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="487"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>As<sp/>an<sp/>exception<sp/>when<sp/>NOT<sp/>copying<sp/>the<sp/>data,<sp/>if<sp/>the<sp/>given<sp/>data<sp/>buffer</highlight></codeline>
<codeline lineno="488"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>directly<sp/>follows<sp/>the<sp/>last<sp/>unsent<sp/>data<sp/>buffer<sp/>in<sp/>memory,<sp/>extend<sp/>the<sp/>last</highlight></codeline>
<codeline lineno="489"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>ROM<sp/>pbuf<sp/>reference<sp/>to<sp/>the<sp/>buffer,<sp/>thus<sp/>saving<sp/>a<sp/>ROM<sp/>pbuf<sp/>allocation.</highlight></codeline>
<codeline lineno="490"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="491"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>We<sp/>don&apos;t<sp/>extend<sp/>segments<sp/>containing<sp/>SYN/FIN<sp/>flags<sp/>or<sp/>options</highlight></codeline>
<codeline lineno="492"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>(len==0).<sp/>The<sp/>new<sp/>pbuf<sp/>is<sp/>kept<sp/>in<sp/>concat_p<sp/>and<sp/>pbuf_cat&apos;ed<sp/>at</highlight></codeline>
<codeline lineno="493"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>the<sp/>end.</highlight></codeline>
<codeline lineno="494"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="495"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pos<sp/>&lt;<sp/>len)<sp/>&amp;&amp;<sp/>(space<sp/>&gt;<sp/>0)<sp/>&amp;&amp;<sp/>(last_unsent-&gt;len<sp/>&gt;<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>seglen<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(space,<sp/>len<sp/>-<sp/>pos);</highlight></codeline>
<codeline lineno="497"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg<sp/>=<sp/>last_unsent;</highlight></codeline>
<codeline lineno="498"><highlight class="normal"></highlight></codeline>
<codeline lineno="499"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Create<sp/>a<sp/>pbuf<sp/>with<sp/>a<sp/>copy<sp/>or<sp/>reference<sp/>to<sp/>seglen<sp/>bytes.<sp/>We</highlight></codeline>
<codeline lineno="500"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>can<sp/>use<sp/>PBUF_RAW<sp/>here<sp/>since<sp/>the<sp/>data<sp/>appears<sp/>in<sp/>the<sp/>middle<sp/>of</highlight></codeline>
<codeline lineno="501"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>a<sp/>segment.<sp/>A<sp/>header<sp/>will<sp/>never<sp/>be<sp/>prepended.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(apiflags<sp/>&amp;<sp/>TCP_WRITE_FLAG_COPY)<sp/>{</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Data<sp/>is<sp/>copied<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((concat_p<sp/>=<sp/>tcp_pbuf_prealloc(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa21116654fbab6d5a4dfeb87a1bb8f0ba" kindref="member">PBUF_RAW</ref>,<sp/>seglen,<sp/>space,<sp/>&amp;oversize,<sp/>pcb,<sp/>apiflags,<sp/>1))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="505"><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_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,</highlight></codeline>
<codeline lineno="506"><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_write<sp/>:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>pbuf<sp/>copy<sp/>size<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">,</highlight></codeline>
<codeline lineno="507"><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/>seglen));</highlight></codeline>
<codeline lineno="508"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="509"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="510"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>oversize_add<sp/>=<sp/>oversize;</highlight></codeline>
<codeline lineno="512"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="513"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_DATA_COPY2(concat_p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>,<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos,<sp/>seglen,<sp/>&amp;concat_chksum,<sp/>&amp;concat_chksum_swapped);</highlight></codeline>
<codeline lineno="514"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="515"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>concat_chksummed<sp/>+=<sp/>seglen;</highlight></codeline>
<codeline lineno="516"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="517"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>queuelen<sp/>+=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(concat_p);</highlight></codeline>
<codeline lineno="518"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Data<sp/>is<sp/>not<sp/>copied<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="520"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>last<sp/>unsent<sp/>pbuf<sp/>is<sp/>of<sp/>type<sp/>PBUF_ROM,<sp/>try<sp/>to<sp/>extend<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="521"><highlight class="normal"><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;</highlight></codeline>
<codeline lineno="522"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(p<sp/>=<sp/>last_unsent-&gt;p;<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref><sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>p<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>);</highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1afd7bff5210a022424caa97d2f25fe8e6" kindref="member">type</ref><sp/>==<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac120b0fe39efe35bb682e4aa3b82e2c9" kindref="member">PBUF_ROM</ref><sp/>&amp;&amp;<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>+<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>==<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*)arg)<sp/>{</highlight></codeline>
<codeline lineno="524"><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_write:<sp/>ROM<sp/>pbufs<sp/>cannot<sp/>be<sp/>oversized&quot;</highlight><highlight class="normal">,<sp/>pos<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="525"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>extendlen<sp/>=<sp/>seglen;</highlight></codeline>
<codeline lineno="526"><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="527"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((concat_p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa21116654fbab6d5a4dfeb87a1bb8f0ba" kindref="member">PBUF_RAW</ref>,<sp/>seglen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac120b0fe39efe35bb682e4aa3b82e2c9" kindref="member">PBUF_ROM</ref>))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="528"><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_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,</highlight></codeline>
<codeline lineno="529"><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_write:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>zero-copy<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="530"><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/>memerr;</highlight></codeline>
<codeline lineno="531"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="532"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>reference<sp/>the<sp/>non-volatile<sp/>payload<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="533"><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__rom" kindref="compound">pbuf_rom</ref>*)concat_p)-&gt;payload<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos;</highlight></codeline>
<codeline lineno="534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>queuelen<sp/>+=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(concat_p);</highlight></codeline>
<codeline lineno="535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="536"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="537"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>calculate<sp/>the<sp/>checksum<sp/>of<sp/>nocopy-data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_add_chksum(~<ref refid="inet__chksum_8h_1a34f1aa1587562a09e11b704b51bab043" kindref="member">inet_chksum</ref>((</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos,<sp/>seglen),<sp/>seglen,</highlight></codeline>
<codeline lineno="539"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;concat_chksum,<sp/>&amp;concat_chksum_swapped);</highlight></codeline>
<codeline lineno="540"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>concat_chksummed<sp/>+=<sp/>seglen;</highlight></codeline>
<codeline lineno="541"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="543"><highlight class="normal"></highlight></codeline>
<codeline lineno="544"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pos<sp/>+=<sp/>seglen;</highlight></codeline>
<codeline lineno="545"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="546"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="547"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="548"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;unsent_oversize<sp/>mismatch<sp/>(pcb-&gt;unsent<sp/>is<sp/>NULL)&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="549"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="550"><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="551"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="552"><highlight class="normal"></highlight></codeline>
<codeline lineno="553"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="554"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Phase<sp/>3:<sp/>Create<sp/>new<sp/>segments.</highlight></codeline>
<codeline lineno="555"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="556"><highlight class="comment"><sp/><sp/><sp/>*<sp/>The<sp/>new<sp/>segments<sp/>are<sp/>chained<sp/>together<sp/>in<sp/>the<sp/>local<sp/>&apos;queue&apos;</highlight></codeline>
<codeline lineno="557"><highlight class="comment"><sp/><sp/><sp/>*<sp/>variable,<sp/>ready<sp/>to<sp/>be<sp/>appended<sp/>to<sp/>pcb-&gt;unsent.</highlight></codeline>
<codeline lineno="558"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="559"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(pos<sp/>&lt;<sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>left<sp/>=<sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>-<sp/>pos;</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>max_len<sp/>=<sp/>mss_local<sp/>-<sp/>optlen;</highlight></codeline>
<codeline lineno="563"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>seglen<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(left,<sp/>max_len);</highlight></codeline>
<codeline lineno="564"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="565"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="566"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>chksum_swapped<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="567"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="568"><highlight class="normal"></highlight></codeline>
<codeline lineno="569"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(apiflags<sp/>&amp;<sp/>TCP_WRITE_FLAG_COPY)<sp/>{</highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>copy<sp/>is<sp/>set,<sp/>memory<sp/>should<sp/>be<sp/>allocated<sp/>and<sp/>data<sp/>copied</highlight></codeline>
<codeline lineno="571"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>into<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((p<sp/>=<sp/>tcp_pbuf_prealloc(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa2ded3594a3977f8bf9cf09552be327b5" kindref="member">PBUF_TRANSPORT</ref>,<sp/>seglen<sp/>+<sp/>optlen,<sp/>mss_local,<sp/>&amp;oversize,<sp/>pcb,<sp/>apiflags,<sp/>queue<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="573"><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_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write<sp/>:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>pbuf<sp/>copy<sp/>size<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/>seglen));</highlight></codeline>
<codeline lineno="574"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="575"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="576"><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_write:<sp/>check<sp/>that<sp/>first<sp/>pbuf<sp/>can<sp/>hold<sp/>the<sp/>complete<sp/>seglen&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="577"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/>seglen));</highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_DATA_COPY2((</highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>+<sp/>optlen,<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos,<sp/>seglen,<sp/>&amp;chksum,<sp/>&amp;chksum_swapped);</highlight></codeline>
<codeline lineno="579"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Copy<sp/>is<sp/>not<sp/>set:<sp/>First<sp/>allocate<sp/>a<sp/>pbuf<sp/>for<sp/>holding<sp/>the<sp/>data.</highlight></codeline>
<codeline lineno="581"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>Since<sp/>the<sp/>referenced<sp/>data<sp/>is<sp/>available<sp/>at<sp/>least<sp/>until<sp/>it<sp/>is</highlight></codeline>
<codeline lineno="582"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>sent<sp/>out<sp/>on<sp/>the<sp/>link<sp/>(as<sp/>it<sp/>has<sp/>to<sp/>be<sp/>ACKed<sp/>by<sp/>the<sp/>remote</highlight></codeline>
<codeline lineno="583"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>party)<sp/>we<sp/>can<sp/>safely<sp/>use<sp/>PBUF_ROM<sp/>instead<sp/>of<sp/>PBUF_REF<sp/>here.</highlight></codeline>
<codeline lineno="584"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="585"><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/>*p2;</highlight></codeline>
<codeline lineno="586"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;oversize<sp/>==<sp/>0&quot;</highlight><highlight class="normal">,<sp/>oversize<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="588"><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="589"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((p2<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa2ded3594a3977f8bf9cf09552be327b5" kindref="member">PBUF_TRANSPORT</ref>,<sp/>seglen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac120b0fe39efe35bb682e4aa3b82e2c9" kindref="member">PBUF_ROM</ref>))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="590"><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_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>zero-copy<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="591"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="593"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="594"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>calculate<sp/>the<sp/>checksum<sp/>of<sp/>nocopy-data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="595"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>chksum<sp/>=<sp/>~<ref refid="inet__chksum_8h_1a34f1aa1587562a09e11b704b51bab043" kindref="member">inet_chksum</ref>((</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos,<sp/>seglen);</highlight></codeline>
<codeline lineno="596"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seglen<sp/>&amp;<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="597"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chksum_swapped<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="598"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a0196bd603262882d16b5264b52eafe18" kindref="member">SWAP_BYTES_IN_WORD</ref>(chksum);</highlight></codeline>
<codeline lineno="599"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="600"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="601"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>reference<sp/>the<sp/>non-volatile<sp/>payload<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf__rom" kindref="compound">pbuf_rom</ref>*)p2)-&gt;payload<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)arg<sp/>+<sp/>pos;</highlight></codeline>
<codeline lineno="603"><highlight class="normal"></highlight></codeline>
<codeline lineno="604"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Second,<sp/>allocate<sp/>a<sp/>pbuf<sp/>for<sp/>the<sp/>headers.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="605"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa2ded3594a3977f8bf9cf09552be327b5" kindref="member">PBUF_TRANSPORT</ref>,<sp/>optlen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="606"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>allocation<sp/>fails,<sp/>we<sp/>have<sp/>to<sp/>deallocate<sp/>the<sp/>data<sp/>pbuf<sp/>as</highlight></codeline>
<codeline lineno="607"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>well.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="608"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p2);</highlight></codeline>
<codeline lineno="609"><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_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>header<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="610"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Concatenate<sp/>the<sp/>headers<sp/>and<sp/>data<sp/>pbufs<sp/>together.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="613"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(p</highlight><highlight class="comment">/*header*/</highlight><highlight class="normal">,<sp/>p2</highlight><highlight class="comment">/*data*/</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="614"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="615"><highlight class="normal"></highlight></codeline>
<codeline lineno="616"><highlight class="normal"><sp/><sp/><sp/><sp/>queuelen<sp/>+=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(p);</highlight></codeline>
<codeline lineno="617"><highlight class="normal"></highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Now<sp/>that<sp/>there<sp/>are<sp/>more<sp/>segments<sp/>queued,<sp/>we<sp/>check<sp/>again<sp/>if<sp/>the</highlight></codeline>
<codeline lineno="619"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>length<sp/>of<sp/>the<sp/>queue<sp/>exceeds<sp/>the<sp/>configured<sp/>maximum<sp/>or</highlight></codeline>
<codeline lineno="620"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>overflows.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="621"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((queuelen<sp/>&gt;<sp/><ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>)<sp/>||<sp/>(queuelen<sp/>&gt;<sp/>TCP_SNDQUEUELEN_OVERFLOW))<sp/>{</highlight></codeline>
<codeline lineno="622"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>queue<sp/>too<sp/>long<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(%d)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>queuelen,<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)<ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>));</highlight></codeline>
<codeline lineno="624"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="626"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="627"><highlight class="normal"></highlight></codeline>
<codeline lineno="628"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((seg<sp/>=<sp/>tcp_create_segment(pcb,<sp/>p,<sp/>0,<sp/>pcb-&gt;snd_lbb<sp/>+<sp/>pos,<sp/>optflags))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>memerr;</highlight></codeline>
<codeline lineno="630"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="631"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="632"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;oversize_left<sp/>=<sp/>oversize;</highlight></codeline>
<codeline lineno="633"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="634"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="635"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;chksum<sp/>=<sp/>chksum;</highlight></codeline>
<codeline lineno="636"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;chksum_swapped<sp/>=<sp/>chksum_swapped;</highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;flags<sp/>|=<sp/>TF_SEG_DATA_CHECKSUMMED;</highlight></codeline>
<codeline lineno="638"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<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/></highlight><highlight class="comment">/*<sp/>first<sp/>segment<sp/>of<sp/>to-be-queued<sp/>data?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="641"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(queue<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="642"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>queue<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="643"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="644"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Attach<sp/>the<sp/>segment<sp/>to<sp/>the<sp/>end<sp/>of<sp/>the<sp/>queued<sp/>segments<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;prev_seg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>prev_seg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="646"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>prev_seg-&gt;next<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="647"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="648"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remember<sp/>last<sp/>segment<sp/>of<sp/>to-be-queued<sp/>data<sp/>for<sp/>next<sp/>iteration<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="649"><highlight class="normal"><sp/><sp/><sp/><sp/>prev_seg<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="650"><highlight class="normal"></highlight></codeline>
<codeline lineno="651"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>queueing<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="652"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno),</highlight></codeline>
<codeline lineno="653"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>TCP_TCPLEN(seg)));</highlight></codeline>
<codeline lineno="654"><highlight class="normal"></highlight></codeline>
<codeline lineno="655"><highlight class="normal"><sp/><sp/><sp/><sp/>pos<sp/>+=<sp/>seglen;</highlight></codeline>
<codeline lineno="656"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="657"><highlight class="normal"></highlight></codeline>
<codeline lineno="658"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="659"><highlight class="comment"><sp/><sp/><sp/>*<sp/>All<sp/>three<sp/>segmentation<sp/>phases<sp/>were<sp/>successful.<sp/>We<sp/>can<sp/>commit<sp/>the</highlight></codeline>
<codeline lineno="660"><highlight class="comment"><sp/><sp/><sp/>*<sp/>transaction.</highlight></codeline>
<codeline lineno="661"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="662"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="663"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((last_unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(oversize_add<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="664"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;oversize_left<sp/>+=<sp/>oversize_add;</highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="666"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="667"><highlight class="normal"></highlight></codeline>
<codeline lineno="668"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="669"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Phase<sp/>1:<sp/>If<sp/>data<sp/>has<sp/>been<sp/>added<sp/>to<sp/>the<sp/>preallocated<sp/>tail<sp/>of</highlight></codeline>
<codeline lineno="670"><highlight class="comment"><sp/><sp/><sp/>*<sp/>last_unsent,<sp/>we<sp/>update<sp/>the<sp/>length<sp/>fields<sp/>of<sp/>the<sp/>pbuf<sp/>chain.</highlight></codeline>
<codeline lineno="671"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="672"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="673"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(oversize_used<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="674"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Bump<sp/>tot_len<sp/>of<sp/>whole<sp/>chain,<sp/>len<sp/>of<sp/>tail<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="676"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(p<sp/>=<sp/>last_unsent-&gt;p;<sp/>p;<sp/>p<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>)<sp/>{</highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>+=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</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>)<sp/>{</highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_DATA_COPY((</highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>+<sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>,<sp/>arg,<sp/>oversize_used,<sp/>last_unsent);</highlight></codeline>
<codeline lineno="680"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>+=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="683"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;len<sp/>+=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="684"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="685"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;last_unsent-&gt;oversize_left<sp/>&gt;=<sp/>oversize_used&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="686"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>last_unsent-&gt;oversize_left<sp/>&gt;=<sp/>oversize_used);</highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;oversize_left<sp/>-=<sp/>oversize_used;</highlight></codeline>
<codeline lineno="688"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="689"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="690"><highlight class="normal"><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>oversize;</highlight></codeline>
<codeline lineno="691"><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="692"><highlight class="normal"></highlight></codeline>
<codeline lineno="693"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="694"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Phase<sp/>2:<sp/>concat_p<sp/>can<sp/>be<sp/>concatenated<sp/>onto<sp/>last_unsent-&gt;p,<sp/>unless<sp/>we</highlight></codeline>
<codeline lineno="695"><highlight class="comment"><sp/><sp/><sp/>*<sp/>determined<sp/>that<sp/>the<sp/>last<sp/>ROM<sp/>pbuf<sp/>can<sp/>be<sp/>extended<sp/>to<sp/>include<sp/>the<sp/>new<sp/>data.</highlight></codeline>
<codeline lineno="696"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="697"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(concat_p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="698"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>cannot<sp/>concatenate<sp/>when<sp/>pcb-&gt;unsent<sp/>is<sp/>empty&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="699"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(last_unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="700"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(last_unsent-&gt;p,<sp/>concat_p);</highlight></codeline>
<codeline lineno="701"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;len<sp/>+=<sp/>concat_p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="702"><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/>(extendlen<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="703"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="704"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>extension<sp/>of<sp/>reference<sp/>requires<sp/>reference&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="705"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>last_unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>last_unsent-&gt;p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="706"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(p<sp/>=<sp/>last_unsent-&gt;p;<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref><sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>p<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5e5763c94fd18d78937b0b58ce7df341" kindref="member">next</ref>)<sp/>{</highlight></codeline>
<codeline lineno="707"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>+=<sp/>extendlen;</highlight></codeline>
<codeline lineno="708"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="709"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>+=<sp/>extendlen;</highlight></codeline>
<codeline lineno="710"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>+=<sp/>extendlen;</highlight></codeline>
<codeline lineno="711"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;len<sp/>+=<sp/>extendlen;</highlight></codeline>
<codeline lineno="712"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="713"><highlight class="normal"></highlight></codeline>
<codeline lineno="714"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(concat_chksummed)<sp/>{</highlight></codeline>
<codeline lineno="716"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>concat<sp/>checksum<sp/>needs<sp/>concatenated<sp/>data&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="717"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>concat_p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>||<sp/>extendlen<sp/>&gt;<sp/>0);</highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*if<sp/>concat<sp/>checksumm<sp/>swapped<sp/>-<sp/>swap<sp/>it<sp/>back<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="719"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(concat_chksum_swapped)<sp/>{</highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>concat_chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a0196bd603262882d16b5264b52eafe18" kindref="member">SWAP_BYTES_IN_WORD</ref>(concat_chksum);</highlight></codeline>
<codeline lineno="721"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="722"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_seg_add_chksum(concat_chksum,<sp/>concat_chksummed,<sp/>&amp;last_unsent-&gt;chksum,</highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>&amp;last_unsent-&gt;chksum_swapped);</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;flags<sp/>|=<sp/>TF_SEG_DATA_CHECKSUMMED;</highlight></codeline>
<codeline lineno="725"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="726"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="727"><highlight class="normal"></highlight></codeline>
<codeline lineno="728"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="729"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Phase<sp/>3:<sp/>Append<sp/>queue<sp/>to<sp/>pcb-&gt;unsent.<sp/>Queue<sp/>may<sp/>be<sp/>NULL,<sp/>but<sp/>that</highlight></codeline>
<codeline lineno="730"><highlight class="comment"><sp/><sp/><sp/>*<sp/>is<sp/>harmless</highlight></codeline>
<codeline lineno="731"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(last_unsent<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>queue;</highlight></codeline>
<codeline lineno="734"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="735"><highlight class="normal"><sp/><sp/><sp/><sp/>last_unsent-&gt;next<sp/>=<sp/>queue;</highlight></codeline>
<codeline lineno="736"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="737"><highlight class="normal"></highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
<codeline lineno="739"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Finally<sp/>update<sp/>the<sp/>pcb<sp/>state.</highlight></codeline>
<codeline lineno="740"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="741"><highlight class="normal"><sp/><sp/>pcb-&gt;snd_lbb<sp/>+=<sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>;</highlight></codeline>
<codeline lineno="742"><highlight class="normal"><sp/><sp/>pcb-&gt;snd_buf<sp/>-=<sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>;</highlight></codeline>
<codeline lineno="743"><highlight class="normal"><sp/><sp/>pcb-&gt;snd_queuelen<sp/>=<sp/>queuelen;</highlight></codeline>
<codeline lineno="744"><highlight class="normal"></highlight></codeline>
<codeline lineno="745"><highlight class="normal"><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_write:<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac05a82d37afb251470f5e17ca15ab6e9" kindref="member">S16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(after<sp/>enqueued)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="748"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>valid<sp/>queue<sp/>length&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="749"><highlight class="normal"><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><sp/>||<sp/>pcb-&gt;unsent<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="750"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="751"><highlight class="normal"></highlight></codeline>
<codeline lineno="752"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>the<sp/>PSH<sp/>flag<sp/>in<sp/>the<sp/>last<sp/>segment<sp/>that<sp/>we<sp/>enqueued.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="753"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>seg-&gt;tcphdr<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>((apiflags<sp/>&amp;<sp/>TCP_WRITE_FLAG_MORE)==0))<sp/>{</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a42432f2dde6716ecb0087ccbc47cc75b" kindref="member">TCPH_SET_FLAG</ref>(seg-&gt;tcphdr,<sp/><ref refid="prot_2tcp_8h_1a1320fd0006a2f70138bc2d0018dda829" kindref="member">TCP_PSH</ref>);</highlight></codeline>
<codeline lineno="755"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="756"><highlight class="normal"></highlight></codeline>
<codeline lineno="757"><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="758"><highlight class="normal">memerr:</highlight></codeline>
<codeline lineno="759"><highlight class="normal"><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="760"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</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/>(concat_p<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="763"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(concat_p);</highlight></codeline>
<codeline lineno="764"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="765"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(queue<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="766"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_segs_free(queue);</highlight></codeline>
<codeline lineno="767"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="768"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="769"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_write:<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="770"><highlight class="normal"><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="771"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1ae7980c7f8eb45cd411bf410ff0a3fc55" kindref="member">TCP_QLEN_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_write:<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac05a82d37afb251470f5e17ca15ab6e9" kindref="member">S16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(with<sp/>mem<sp/>err)\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="773"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="774"><highlight class="normal">}</highlight></codeline>
<codeline lineno="775"><highlight class="normal"></highlight></codeline>
<codeline lineno="784"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="785"><highlight class="normal">tcp_enqueue_flags(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/><ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref>)</highlight></codeline>
<codeline lineno="786"><highlight class="normal">{</highlight></codeline>
<codeline lineno="787"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg;</highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optflags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optlen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="791"><highlight class="normal"></highlight></codeline>
<codeline lineno="792"><highlight class="normal"><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_enqueue_flags:<sp/>queuelen:<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>)pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="793"><highlight class="normal"></highlight></codeline>
<codeline lineno="794"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>need<sp/>either<sp/>TCP_SYN<sp/>or<sp/>TCP_FIN<sp/>in<sp/>flags<sp/>(programmer<sp/>violates<sp/>API)&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(flags<sp/>&amp;<sp/>(<ref refid="prot_2tcp_8h_1a6020613f5062417d9811cfa837215c83" kindref="member">TCP_SYN</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>))<sp/>!=<sp/>0);</highlight></codeline>
<codeline lineno="796"><highlight class="normal"></highlight></codeline>
<codeline lineno="797"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>for<sp/>configured<sp/>max<sp/>queuelen<sp/>and<sp/>possible<sp/>overflow<sp/>(FIN<sp/>flag<sp/>should<sp/>always<sp/>come<sp/>through!)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="798"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((pcb-&gt;snd_queuelen<sp/>&gt;=<sp/><ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>)<sp/>||<sp/>(pcb-&gt;snd_queuelen<sp/>&gt;<sp/>TCP_SNDQUEUELEN_OVERFLOW))<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1gaab41143277cd38047b6660d90e9cec3b" kindref="member">LWIP_DBG_LEVEL_SEVERE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>too<sp/>long<sp/>queue<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(max<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">,</highlight></codeline>
<codeline lineno="801"><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/><sp/>pcb-&gt;snd_queuelen,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)<ref refid="lwipopts_8h_1a9beaa47832ead4180981bfbf71074904" kindref="member">TCP_SND_QUEUELEN</ref>));</highlight></codeline>
<codeline lineno="802"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="804"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="805"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="806"><highlight class="normal"></highlight></codeline>
<codeline lineno="807"><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="808"><highlight class="normal"><sp/><sp/><sp/><sp/>optflags<sp/>=<sp/>TF_SEG_OPTS_MSS;</highlight></codeline>
<codeline lineno="809"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="810"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;state<sp/>!=<sp/>SYN_RCVD)<sp/>||<sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_WND_SCALE))<sp/>{</highlight></codeline>
<codeline lineno="811"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>In<sp/>a<sp/>&lt;SYN,ACK&gt;<sp/>(sent<sp/>in<sp/>state<sp/>SYN_RCVD),<sp/>the<sp/>window<sp/>scale<sp/>option<sp/>may<sp/>only</highlight></codeline>
<codeline lineno="812"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>be<sp/>sent<sp/>if<sp/>we<sp/>received<sp/>a<sp/>window<sp/>scale<sp/>option<sp/>from<sp/>the<sp/>remote<sp/>host.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="813"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>optflags<sp/>|=<sp/>TF_SEG_OPTS_WND_SCALE;</highlight></codeline>
<codeline lineno="814"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="815"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="816"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="817"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="818"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;flags<sp/>&amp;<sp/>TF_TIMESTAMP))<sp/>{</highlight></codeline>
<codeline lineno="819"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Make<sp/>sure<sp/>the<sp/>timestamp<sp/>option<sp/>is<sp/>only<sp/>included<sp/>in<sp/>data<sp/>segments<sp/>if<sp/>we</highlight></codeline>
<codeline lineno="820"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>agreed<sp/>about<sp/>it<sp/>with<sp/>the<sp/>remote<sp/>host.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="821"><highlight class="normal"><sp/><sp/><sp/><sp/>optflags<sp/>|=<sp/>TF_SEG_OPTS_TS;</highlight></codeline>
<codeline lineno="822"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="823"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_TIMESTAMPS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="824"><highlight class="normal"><sp/><sp/>optlen<sp/>=<sp/>LWIP_TCP_OPT_LENGTH(optflags);</highlight></codeline>
<codeline lineno="825"><highlight class="normal"></highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Allocate<sp/>pbuf<sp/>with<sp/>room<sp/>for<sp/>TCP<sp/>header<sp/>+<sp/>options<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa2ded3594a3977f8bf9cf09552be327b5" kindref="member">PBUF_TRANSPORT</ref>,<sp/>optlen,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="828"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</highlight></codeline>
<codeline lineno="830"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="831"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="832"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>check<sp/>that<sp/>first<sp/>pbuf<sp/>can<sp/>hold<sp/>optlen&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="833"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/>optlen));</highlight></codeline>
<codeline lineno="834"><highlight class="normal"></highlight></codeline>
<codeline lineno="835"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Allocate<sp/>memory<sp/>for<sp/>tcp_seg,<sp/>and<sp/>fill<sp/>in<sp/>fields.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="836"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((seg<sp/>=<sp/>tcp_create_segment(pcb,<sp/>p,<sp/>flags,<sp/>pcb-&gt;snd_lbb,<sp/>optflags))<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="837"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="838"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.memerr);</highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="840"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="841"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;seg-&gt;tcphdr<sp/>not<sp/>aligned&quot;</highlight><highlight class="normal">,<sp/>((<ref refid="group__compiler__abstraction_1gaf019cbb71af10dcfda7758b21e655307" kindref="member">mem_ptr_t</ref>)seg-&gt;tcphdr<sp/>%<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(<ref refid="lwipopts_8h_1a97343214666ee6dcb18c0bd77b441ea7" kindref="member">MEM_ALIGNMENT</ref>,<sp/>4))<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>invalid<sp/>segment<sp/>length&quot;</highlight><highlight class="normal">,<sp/>seg-&gt;len<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="843"><highlight class="normal"></highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,</highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>queueing<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/>(0x%&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="846"><highlight class="normal"><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>(seg-&gt;tcphdr-&gt;seqno),</highlight></codeline>
<codeline lineno="847"><highlight class="normal"><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>(seg-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>TCP_TCPLEN(seg),</highlight></codeline>
<codeline lineno="848"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)flags));</highlight></codeline>
<codeline lineno="849"><highlight class="normal"></highlight></codeline>
<codeline lineno="850"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Now<sp/>append<sp/>seg<sp/>to<sp/>pcb-&gt;unsent<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="851"><highlight class="normal"><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="852"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="854"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*useg;</highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(useg<sp/>=<sp/>pcb-&gt;unsent;<sp/>useg-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>useg<sp/>=<sp/>useg-&gt;next);</highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/><sp/><sp/>useg-&gt;next<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="858"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="859"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>new<sp/>unsent<sp/>tail<sp/>has<sp/>no<sp/>space<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="860"><highlight class="normal"><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="861"><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="862"><highlight class="normal"></highlight></codeline>
<codeline lineno="863"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>SYN<sp/>and<sp/>FIN<sp/>bump<sp/>the<sp/>sequence<sp/>number<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="864"><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/>||<sp/>(flags<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>))<sp/>{</highlight></codeline>
<codeline lineno="865"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;snd_lbb++;</highlight></codeline>
<codeline lineno="866"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>optlen<sp/>does<sp/>not<sp/>influence<sp/>snd_buf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="867"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="868"><highlight class="normal"><sp/><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="869"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_FIN;</highlight></codeline>
<codeline lineno="870"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="871"><highlight class="normal"></highlight></codeline>
<codeline lineno="872"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>update<sp/>number<sp/>of<sp/>segments<sp/>on<sp/>the<sp/>queues<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="873"><highlight class="normal"><sp/><sp/>pcb-&gt;snd_queuelen<sp/>+=<sp/><ref refid="pbuf_8h_1a5df7ac5ae59012fe9aeddba375a72190" kindref="member">pbuf_clen</ref>(seg-&gt;p);</highlight></codeline>
<codeline lineno="874"><highlight class="normal"><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_enqueue_flags:<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac05a82d37afb251470f5e17ca15ab6e9" kindref="member">S16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>(after<sp/>enqueued)\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;snd_queuelen));</highlight></codeline>
<codeline lineno="875"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;snd_queuelen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="876"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;tcp_enqueue_flags:<sp/>invalid<sp/>queue<sp/>length&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="877"><highlight class="normal"><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="878"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="879"><highlight class="normal"></highlight></codeline>
<codeline lineno="880"><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="881"><highlight class="normal">}</highlight></codeline>
<codeline lineno="882"><highlight class="normal"></highlight></codeline>
<codeline lineno="883"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="884"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Build<sp/>a<sp/>timestamp<sp/>option<sp/>(12<sp/>bytes<sp/>long)<sp/>at<sp/>the<sp/>specified<sp/>options<sp/>pointer)</highlight></codeline>
<codeline lineno="885"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="886"><highlight class="comment"><sp/>*<sp/>@param<sp/>pcb<sp/>tcp_pcb</highlight></codeline>
<codeline lineno="887"><highlight class="comment"><sp/>*<sp/>@param<sp/>opts<sp/>option<sp/>pointer<sp/>where<sp/>to<sp/>store<sp/>the<sp/>timestamp<sp/>option</highlight></codeline>
<codeline lineno="888"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="889"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="890"><highlight class="normal">tcp_build_timestamp_option(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*opts)</highlight></codeline>
<codeline lineno="891"><highlight class="normal">{</highlight></codeline>
<codeline lineno="892"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Pad<sp/>with<sp/>two<sp/>NOP<sp/>options<sp/>to<sp/>make<sp/>everything<sp/>nicely<sp/>aligned<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="893"><highlight class="normal"><sp/><sp/>opts[0]<sp/>=<sp/><ref refid="def_8h_1afea9c21aa1f56180cdf6fb42ef14a294" kindref="member">PP_HTONL</ref>(0x0101080A);</highlight></codeline>
<codeline lineno="894"><highlight class="normal"><sp/><sp/>opts[1]<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(<ref refid="group__sys__time_1ga11316ac1e77418c6fa4ab8869e3fa199" kindref="member">sys_now</ref>());</highlight></codeline>
<codeline lineno="895"><highlight class="normal"><sp/><sp/>opts[2]<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(pcb-&gt;ts_recent);</highlight></codeline>
<codeline lineno="896"><highlight class="normal">}</highlight></codeline>
<codeline lineno="897"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="898"><highlight class="normal"></highlight></codeline>
<codeline lineno="899"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="900"><highlight class="normal"></highlight></codeline>
<codeline lineno="904"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="905"><highlight class="normal">tcp_build_wnd_scale_option(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*opts)</highlight></codeline>
<codeline lineno="906"><highlight class="normal">{</highlight></codeline>
<codeline lineno="907"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Pad<sp/>with<sp/>one<sp/>NOP<sp/>option<sp/>to<sp/>make<sp/>everything<sp/>nicely<sp/>aligned<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="908"><highlight class="normal"><sp/><sp/>opts[0]<sp/>=<sp/><ref refid="def_8h_1afea9c21aa1f56180cdf6fb42ef14a294" kindref="member">PP_HTONL</ref>(0x01030300<sp/>|<sp/><ref refid="group__lwip__opts__tcp_1ga768765a2c678fefeca6c89aae0cf629f" kindref="member">TCP_RCV_SCALE</ref>);</highlight></codeline>
<codeline lineno="909"><highlight class="normal">}</highlight></codeline>
<codeline lineno="910"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="911"><highlight class="normal"></highlight></codeline>
<codeline lineno="917"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="918"><highlight class="normal">tcp_send_empty_ack(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="919"><highlight class="normal">{</highlight></codeline>
<codeline lineno="920"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="921"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="922"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>optlen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="923"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="924"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS<sp/>||<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="925"><highlight class="normal"><sp/><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="926"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_TIMESTAMPS<sp/>||<sp/>CHECKSUM_GEN_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="927"><highlight class="normal"></highlight></codeline>
<codeline lineno="928"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="929"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_TIMESTAMP)<sp/>{</highlight></codeline>
<codeline lineno="930"><highlight class="normal"><sp/><sp/><sp/><sp/>optlen<sp/>=<sp/>LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS);</highlight></codeline>
<codeline lineno="931"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="932"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="933"><highlight class="normal"></highlight></codeline>
<codeline lineno="934"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/>tcp_output_alloc_header(pcb,<sp/>optlen,<sp/>0,<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(pcb-&gt;snd_nxt));</highlight></codeline>
<codeline lineno="935"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="936"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>let<sp/>tcp_fasttmr<sp/>retry<sp/>sending<sp/>this<sp/>ACK<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="937"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>(TF_ACK_DELAY<sp/>|<sp/>TF_ACK_NOW);</highlight></codeline>
<codeline lineno="938"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output:<sp/>(ACK)<sp/>could<sp/>not<sp/>allocate<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="939"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca05c91366f1b5203a5db9a241b415cd63" kindref="member">ERR_BUF</ref>;</highlight></codeline>
<codeline lineno="940"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="941"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS<sp/>||<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="942"><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="943"><highlight class="normal">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_TIMESTAMPS<sp/>||<sp/>CHECKSUM_GEN_TCP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="944"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref>,</highlight></codeline>
<codeline lineno="945"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output:<sp/>sending<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;\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;rcv_nxt));</highlight></codeline>
<codeline lineno="946"><highlight class="normal"></highlight></codeline>
<codeline lineno="947"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>NB.<sp/>MSS<sp/>and<sp/>window<sp/>scale<sp/>options<sp/>are<sp/>only<sp/>sent<sp/>on<sp/>SYNs,<sp/>so<sp/>ignore<sp/>them<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="948"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="949"><highlight class="normal"><sp/><sp/>pcb-&gt;ts_lastacksent<sp/>=<sp/>pcb-&gt;rcv_nxt;</highlight></codeline>
<codeline lineno="950"><highlight class="normal"></highlight></codeline>
<codeline lineno="951"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_TIMESTAMP)<sp/>{</highlight></codeline>
<codeline lineno="952"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_build_timestamp_option(pcb,<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*)(tcphdr<sp/>+<sp/>1));</highlight></codeline>
<codeline lineno="953"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="954"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="955"><highlight class="normal"></highlight></codeline>
<codeline lineno="956"><highlight class="normal"><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="957"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="958"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="959"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="960"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="961"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="962"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcphdr-&gt;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="963"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="964"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="965"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="966"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;(pcb-&gt;addr_hint));</highlight></codeline>
<codeline lineno="967"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>ip_output_if(p,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip,</highlight></codeline>
<codeline lineno="968"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ttl,<sp/>pcb-&gt;tos,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="969"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="970"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="971"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="972"><highlight class="normal"></highlight></codeline>
<codeline lineno="973"><highlight class="normal"><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="974"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>let<sp/>tcp_fasttmr<sp/>retry<sp/>sending<sp/>this<sp/>ACK<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="975"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>(TF_ACK_DELAY<sp/>|<sp/>TF_ACK_NOW);</highlight></codeline>
<codeline lineno="976"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="977"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remove<sp/>ACK<sp/>flags<sp/>from<sp/>the<sp/>PCB,<sp/>as<sp/>we<sp/>sent<sp/>an<sp/>empty<sp/>ACK<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="978"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~(TF_ACK_DELAY<sp/>|<sp/>TF_ACK_NOW);</highlight></codeline>
<codeline lineno="979"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="980"><highlight class="normal"></highlight></codeline>
<codeline lineno="981"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="982"><highlight class="normal">}</highlight></codeline>
<codeline lineno="983"><highlight class="normal"></highlight></codeline>
<codeline lineno="992"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="993"><highlight class="normal">tcp_output(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="994"><highlight class="normal">{</highlight></codeline>
<codeline lineno="995"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg,<sp/>*useg;</highlight></codeline>
<codeline lineno="996"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>wnd,<sp/>snd_nxt;</highlight></codeline>
<codeline lineno="997"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="998"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="999"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CWND_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1000"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>i<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1001"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CWND_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1002"><highlight class="normal"></highlight></codeline>
<codeline lineno="1003"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb-&gt;state<sp/>LISTEN<sp/>not<sp/>allowed<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1004"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;don&apos;t<sp/>call<sp/>tcp_output<sp/>for<sp/>listen-pcbs&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1005"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;state<sp/>!=<sp/>LISTEN);</highlight></codeline>
<codeline lineno="1006"><highlight class="normal"></highlight></codeline>
<codeline lineno="1007"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>First,<sp/>check<sp/>if<sp/>we<sp/>are<sp/>invoked<sp/>by<sp/>the<sp/>TCP<sp/>input<sp/>processing</highlight></codeline>
<codeline lineno="1008"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>code.<sp/>If<sp/>so,<sp/>we<sp/>do<sp/>not<sp/>output<sp/>anything.<sp/>Instead,<sp/>we<sp/>rely<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1009"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>input<sp/>processing<sp/>code<sp/>to<sp/>call<sp/>us<sp/>when<sp/>input<sp/>processing<sp/>is<sp/>done</highlight></codeline>
<codeline lineno="1010"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>with.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1011"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tcp_input_pcb<sp/>==<sp/>pcb)<sp/>{</highlight></codeline>
<codeline lineno="1012"><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="1013"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1014"><highlight class="normal"></highlight></codeline>
<codeline lineno="1015"><highlight class="normal"><sp/><sp/>wnd<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(pcb-&gt;snd_wnd,<sp/>pcb-&gt;cwnd);</highlight></codeline>
<codeline lineno="1016"><highlight class="normal"></highlight></codeline>
<codeline lineno="1017"><highlight class="normal"><sp/><sp/>seg<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="1018"><highlight class="normal"></highlight></codeline>
<codeline lineno="1019"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>TF_ACK_NOW<sp/>flag<sp/>is<sp/>set<sp/>and<sp/>no<sp/>data<sp/>will<sp/>be<sp/>sent<sp/>(either</highlight></codeline>
<codeline lineno="1020"><highlight class="comment"><sp/><sp/><sp/>*<sp/>because<sp/>the<sp/>-&gt;unsent<sp/>queue<sp/>is<sp/>empty<sp/>or<sp/>because<sp/>the<sp/>window<sp/>does</highlight></codeline>
<codeline lineno="1021"><highlight class="comment"><sp/><sp/><sp/>*<sp/>not<sp/>allow<sp/>it),<sp/>construct<sp/>an<sp/>empty<sp/>ACK<sp/>segment<sp/>and<sp/>send<sp/>it.</highlight></codeline>
<codeline lineno="1022"><highlight class="comment"><sp/><sp/><sp/>*</highlight></codeline>
<codeline lineno="1023"><highlight class="comment"><sp/><sp/><sp/>*<sp/>If<sp/>data<sp/>is<sp/>to<sp/>be<sp/>sent,<sp/>we<sp/>will<sp/>just<sp/>piggyback<sp/>the<sp/>ACK<sp/>(see<sp/>below).</highlight></codeline>
<codeline lineno="1024"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1025"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>TF_ACK_NOW<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1026"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/>(seg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>||</highlight></codeline>
<codeline lineno="1027"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>-<sp/>pcb-&gt;lastack<sp/>+<sp/>seg-&gt;len<sp/>&gt;<sp/>wnd))<sp/>{</highlight></codeline>
<codeline lineno="1028"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>tcp_send_empty_ack(pcb);</highlight></codeline>
<codeline lineno="1029"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1030"><highlight class="normal"></highlight></codeline>
<codeline lineno="1031"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>useg<sp/>should<sp/>point<sp/>to<sp/>last<sp/>segment<sp/>on<sp/>unacked<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1032"><highlight class="normal"><sp/><sp/>useg<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="1033"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(useg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1034"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(;<sp/>useg-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>useg<sp/>=<sp/>useg-&gt;next);</highlight></codeline>
<codeline lineno="1035"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1036"><highlight class="normal"></highlight></codeline>
<codeline lineno="1037"><highlight class="normal"><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1038"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1039"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="1040"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1041"><highlight class="normal"></highlight></codeline>
<codeline lineno="1042"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we<sp/>don&apos;t<sp/>have<sp/>a<sp/>local<sp/>IP<sp/>address,<sp/>we<sp/>get<sp/>one<sp/>from<sp/>netif<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1043"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;pcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="1044"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*local_ip<sp/>=<sp/>ip_netif_get_local_ip(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1045"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(local_ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1046"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="1047"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1048"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(pcb-&gt;local_ip,<sp/>*local_ip);</highlight></codeline>
<codeline lineno="1049"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1050"><highlight class="normal"></highlight></codeline>
<codeline lineno="1051"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OUTPUT_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1052"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1053"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output:<sp/>nothing<sp/>to<sp/>send<sp/>(%p)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1054"><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="keywordtype">void</highlight><highlight class="normal">*)pcb-&gt;unsent));</highlight></codeline>
<codeline lineno="1055"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1056"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OUTPUT_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1057"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CWND_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1058"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1059"><highlight class="normal"><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_output:<sp/>snd_wnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight></codeline>
<codeline lineno="1060"><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;,<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;,<sp/>wnd<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight></codeline>
<codeline lineno="1061"><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;,<sp/>seg<sp/>==<sp/>NULL,<sp/>ack<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="1062"><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/>pcb-&gt;snd_wnd,<sp/>pcb-&gt;cwnd,<sp/>wnd,<sp/>pcb-&gt;lastack));</highlight></codeline>
<codeline lineno="1063"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1064"><highlight class="normal"><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>,</highlight></codeline>
<codeline lineno="1065"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output:<sp/>snd_wnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;,<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;,<sp/>wnd<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></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/></highlight><highlight class="stringliteral">&quot;,<sp/>effwnd<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>seq<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>ack<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="1067"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_wnd,<sp/>pcb-&gt;cwnd,<sp/>wnd,</highlight></codeline>
<codeline lineno="1068"><highlight class="normal"><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>(seg-&gt;tcphdr-&gt;seqno)<sp/>-<sp/>pcb-&gt;lastack<sp/>+<sp/>seg-&gt;len,</highlight></codeline>
<codeline lineno="1069"><highlight class="normal"><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>(seg-&gt;tcphdr-&gt;seqno),<sp/>pcb-&gt;lastack));</highlight></codeline>
<codeline lineno="1070"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1071"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CWND_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1072"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>we<sp/>need<sp/>to<sp/>start<sp/>the<sp/>persistent<sp/>timer<sp/>when<sp/>the<sp/>next<sp/>unsent<sp/>segment</highlight></codeline>
<codeline lineno="1073"><highlight class="comment"><sp/><sp/><sp/>*<sp/>does<sp/>not<sp/>fit<sp/>within<sp/>the<sp/>remaining<sp/>send<sp/>window<sp/>and<sp/>RTO<sp/>timer<sp/>is<sp/>not<sp/>running<sp/>(we</highlight></codeline>
<codeline lineno="1074"><highlight class="comment"><sp/><sp/><sp/>*<sp/>have<sp/>no<sp/>in-flight<sp/>data).<sp/>A<sp/>traditional<sp/>approach<sp/>would<sp/>fill<sp/>the<sp/>remaining<sp/>window</highlight></codeline>
<codeline lineno="1075"><highlight class="comment"><sp/><sp/><sp/>*<sp/>with<sp/>part<sp/>of<sp/>the<sp/>unsent<sp/>segment<sp/>(which<sp/>will<sp/>engage<sp/>zero-window<sp/>probing<sp/>upon</highlight></codeline>
<codeline lineno="1076"><highlight class="comment"><sp/><sp/><sp/>*<sp/>reception<sp/>of<sp/>the<sp/>zero<sp/>window<sp/>update<sp/>from<sp/>the<sp/>receiver).<sp/>This<sp/>ensures<sp/>the</highlight></codeline>
<codeline lineno="1077"><highlight class="comment"><sp/><sp/><sp/>*<sp/>subsequent<sp/>window<sp/>update<sp/>is<sp/>reliably<sp/>received.<sp/>With<sp/>the<sp/>goal<sp/>of<sp/>being<sp/>lightweight,</highlight></codeline>
<codeline lineno="1078"><highlight class="comment"><sp/><sp/><sp/>*<sp/>we<sp/>avoid<sp/>splitting<sp/>the<sp/>unsent<sp/>segment<sp/>and<sp/>treat<sp/>the<sp/>window<sp/>as<sp/>already<sp/>zero.</highlight></codeline>
<codeline lineno="1079"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1080"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1081"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>-<sp/>pcb-&gt;lastack<sp/>+<sp/>seg-&gt;len<sp/>&gt;<sp/>wnd<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1082"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>wnd<sp/>&gt;<sp/>0<sp/>&amp;&amp;<sp/>wnd<sp/>==<sp/>pcb-&gt;snd_wnd<sp/>&amp;&amp;<sp/>pcb-&gt;unacked<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1083"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Start<sp/>the<sp/>persist<sp/>timer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1084"><highlight class="normal"><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="1085"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;persist_cnt<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1086"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;persist_backoff<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1087"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1088"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>output_done;</highlight></codeline>
<codeline lineno="1089"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1090"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>available<sp/>and<sp/>window<sp/>allows<sp/>it<sp/>to<sp/>be<sp/>sent?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1091"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(seg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1092"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>-<sp/>pcb-&gt;lastack<sp/>+<sp/>seg-&gt;len<sp/>&lt;=<sp/>wnd)<sp/>{</highlight></codeline>
<codeline lineno="1093"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;RST<sp/>not<sp/>expected<sp/>here!&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1094"><highlight class="normal"><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>(seg-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref>)<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="1095"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Stop<sp/>sending<sp/>if<sp/>the<sp/>nagle<sp/>algorithm<sp/>would<sp/>prevent<sp/>it</highlight></codeline>
<codeline lineno="1096"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Don&apos;t<sp/>stop:</highlight></codeline>
<codeline lineno="1097"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>-<sp/>if<sp/>tcp_write<sp/>had<sp/>a<sp/>memory<sp/>error<sp/>before<sp/>(prevent<sp/>delayed<sp/>ACK<sp/>timeout)<sp/>or</highlight></codeline>
<codeline lineno="1098"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>-<sp/>if<sp/>FIN<sp/>was<sp/>already<sp/>enqueued<sp/>for<sp/>this<sp/>PCB<sp/>(SYN<sp/>is<sp/>always<sp/>alone<sp/>in<sp/>a<sp/>segment<sp/>-</highlight></codeline>
<codeline lineno="1099"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/><sp/><sp/>either<sp/>seg-&gt;next<sp/>!=<sp/>NULL<sp/>or<sp/>pcb-&gt;unacked<sp/>==<sp/>NULL;</highlight></codeline>
<codeline lineno="1100"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/><sp/><sp/>RST<sp/>is<sp/>no<sp/>sent<sp/>using<sp/>tcp_write/tcp_output.</highlight></codeline>
<codeline lineno="1101"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1102"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcp_do_output_nagle(pcb)<sp/>==<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1103"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((pcb-&gt;flags<sp/>&amp;<sp/>(TF_NAGLEMEMERR<sp/>|<sp/>TF_FIN))<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="1104"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1105"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1106"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CWND_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1107"><highlight class="normal"><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_output:<sp/>snd_wnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;,<sp/>cwnd<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight><highlight class="stringliteral">&quot;,<sp/>wnd<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>effwnd<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>seq<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>ack<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>i<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac05a82d37afb251470f5e17ca15ab6e9" kindref="member">S16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1108"><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/>pcb-&gt;snd_wnd,<sp/>pcb-&gt;cwnd,<sp/>wnd,</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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>seg-&gt;len<sp/>-</highlight></codeline>
<codeline lineno="1110"><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/>pcb-&gt;lastack,</highlight></codeline>
<codeline lineno="1111"><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/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno),<sp/>pcb-&gt;lastack,<sp/>i));</highlight></codeline>
<codeline lineno="1112"><highlight class="normal"><sp/><sp/><sp/><sp/>++i;</highlight></codeline>
<codeline lineno="1113"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CWND_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1114"><highlight class="normal"></highlight></codeline>
<codeline lineno="1115"><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="1116"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1a42432f2dde6716ecb0087ccbc47cc75b" kindref="member">TCPH_SET_FLAG</ref>(seg-&gt;tcphdr,<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>);</highlight></codeline>
<codeline lineno="1117"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1118"><highlight class="normal"></highlight></codeline>
<codeline lineno="1119"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1120"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;oversize_left<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1121"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1122"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>tcp_output_segment(seg,<sp/>pcb,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="1123"><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_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>segment<sp/>could<sp/>not<sp/>be<sp/>sent,<sp/>for<sp/>whatever<sp/>reason<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1125"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="1126"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="1127"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1128"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>seg-&gt;next;</highlight></codeline>
<codeline lineno="1129"><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="1130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~(TF_ACK_DELAY<sp/>|<sp/>TF_ACK_NOW);</highlight></codeline>
<codeline lineno="1131"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1132"><highlight class="normal"><sp/><sp/><sp/><sp/>snd_nxt<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>TCP_TCPLEN(seg);</highlight></codeline>
<codeline lineno="1133"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LT(pcb-&gt;snd_nxt,<sp/>snd_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1134"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;snd_nxt<sp/>=<sp/>snd_nxt;</highlight></codeline>
<codeline lineno="1135"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1136"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>put<sp/>segment<sp/>on<sp/>unacknowledged<sp/>list<sp/>if<sp/>length<sp/>&gt;<sp/>0<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1137"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_TCPLEN(seg)<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>unacked<sp/>list<sp/>is<sp/>empty?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1140"><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="1141"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;unacked<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="1142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>useg<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="1143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>unacked<sp/>list<sp/>is<sp/>not<sp/>empty?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>In<sp/>the<sp/>case<sp/>of<sp/>fast<sp/>retransmit,<sp/>the<sp/>packet<sp/>should<sp/>not<sp/>go<sp/>to<sp/>the<sp/>tail</highlight></codeline>
<codeline lineno="1146"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>of<sp/>the<sp/>unacked<sp/>queue,<sp/>but<sp/>rather<sp/>somewhere<sp/>before<sp/>it.<sp/>We<sp/>need<sp/>to<sp/>check<sp/>for</highlight></codeline>
<codeline lineno="1147"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>this<sp/>case.<sp/>-STJ<sp/>Jul<sp/>27,<sp/>2004<sp/>*/</highlight><highlight class="normal"></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/>(TCP_SEQ_LT(<ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno),<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(useg-&gt;tcphdr-&gt;seqno)))<sp/>{</highlight></codeline>
<codeline lineno="1149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>add<sp/>segment<sp/>to<sp/>before<sp/>tail<sp/>of<sp/>unacked<sp/>list,<sp/>keeping<sp/>the<sp/>list<sp/>sorted<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>**cur_seg<sp/>=<sp/>&amp;(pcb-&gt;unacked);</highlight></codeline>
<codeline lineno="1151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(*cur_seg<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>TCP_SEQ_LT(<ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>((*cur_seg)-&gt;tcphdr-&gt;seqno),<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)))<sp/>{</highlight></codeline>
<codeline lineno="1153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cur_seg<sp/>=<sp/>&amp;((*cur_seg)-&gt;next<sp/>);</highlight></codeline>
<codeline lineno="1154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1155"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;next<sp/>=<sp/>(*cur_seg);</highlight></codeline>
<codeline lineno="1156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(*cur_seg)<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="1157"><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="1158"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>add<sp/>segment<sp/>to<sp/>tail<sp/>of<sp/>unacked<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1159"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>useg-&gt;next<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="1160"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>useg<sp/>=<sp/>useg-&gt;next;</highlight></codeline>
<codeline lineno="1161"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1162"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1163"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>do<sp/>not<sp/>queue<sp/>empty<sp/>segments<sp/>on<sp/>the<sp/>unacked<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1164"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_seg_free(seg);</highlight></codeline>
<codeline lineno="1166"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1167"><highlight class="normal"><sp/><sp/><sp/><sp/>seg<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="1168"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1169"><highlight class="normal">output_done:</highlight></codeline>
<codeline lineno="1170"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1171"><highlight class="normal"><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="1172"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>last<sp/>unsent<sp/>has<sp/>been<sp/>removed,<sp/>reset<sp/>unsent_oversize<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1173"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1174"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1175"><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="1176"><highlight class="normal"></highlight></codeline>
<codeline lineno="1177"><highlight class="normal"><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~TF_NAGLEMEMERR;</highlight></codeline>
<codeline lineno="1178"><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="1179"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1180"><highlight class="normal"></highlight></codeline>
<codeline lineno="1188"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="1189"><highlight class="normal">tcp_output_segment(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_seg<sp/>*seg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>)</highlight></codeline>
<codeline lineno="1190"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1191"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1192"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len;</highlight></codeline>
<codeline lineno="1193"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*opts;</highlight></codeline>
<codeline lineno="1194"><highlight class="normal"></highlight></codeline>
<codeline lineno="1195"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;p-&gt;ref<sp/>!=<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="1196"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>can<sp/>happen<sp/>if<sp/>the<sp/>pbuf<sp/>of<sp/>this<sp/>segment<sp/>is<sp/>still<sp/>referenced<sp/>by<sp/>the</highlight></codeline>
<codeline lineno="1197"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netif<sp/>driver<sp/>due<sp/>to<sp/>deferred<sp/>transmission.<sp/>Since<sp/>this<sp/>function<sp/>modifies</highlight></codeline>
<codeline lineno="1198"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;len,<sp/>we<sp/>must<sp/>not<sp/>continue<sp/>in<sp/>this<sp/>case.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1199"><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="1200"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1201"><highlight class="normal"></highlight></codeline>
<codeline lineno="1202"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>TCP<sp/>header<sp/>has<sp/>already<sp/>been<sp/>constructed,<sp/>but<sp/>the<sp/>ackno<sp/>and</highlight></codeline>
<codeline lineno="1203"><highlight class="comment"><sp/><sp/><sp/>wnd<sp/>fields<sp/>remain.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1204"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;ackno<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(pcb-&gt;rcv_nxt);</highlight></codeline>
<codeline lineno="1205"><highlight class="normal"></highlight></codeline>
<codeline lineno="1206"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>advertise<sp/>our<sp/>receive<sp/>window<sp/>size<sp/>in<sp/>this<sp/>TCP<sp/>segment<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1207"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1208"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;flags<sp/>&amp;<sp/>TF_SEG_OPTS_WND_SCALE)<sp/>{</highlight></codeline>
<codeline lineno="1209"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>Window<sp/>field<sp/>in<sp/>a<sp/>SYN<sp/>segment<sp/>itself<sp/>(the<sp/>only<sp/>type<sp/>where<sp/>we<sp/>send</highlight></codeline>
<codeline lineno="1210"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>window<sp/>scale<sp/>option)<sp/>is<sp/>never<sp/>scaled.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1211"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(TCPWND_MIN16(pcb-&gt;rcv_ann_wnd));</highlight></codeline>
<codeline lineno="1212"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1213"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_WND_SCALE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1214"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1215"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(TCPWND_MIN16(RCV_WND_SCALE(pcb,<sp/>pcb-&gt;rcv_ann_wnd)));</highlight></codeline>
<codeline lineno="1216"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1217"><highlight class="normal"></highlight></codeline>
<codeline lineno="1218"><highlight class="normal"><sp/><sp/>pcb-&gt;rcv_ann_right_edge<sp/>=<sp/>pcb-&gt;rcv_nxt<sp/>+<sp/>pcb-&gt;rcv_ann_wnd;</highlight></codeline>
<codeline lineno="1219"><highlight class="normal"></highlight></codeline>
<codeline lineno="1220"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Add<sp/>any<sp/>requested<sp/>options.<sp/><sp/>NB<sp/>MSS<sp/>option<sp/>is<sp/>only<sp/>set<sp/>on<sp/>SYN</highlight></codeline>
<codeline lineno="1221"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>packets,<sp/>so<sp/>ignore<sp/>it<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1222"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>cast<sp/>through<sp/>void*<sp/>to<sp/>get<sp/>rid<sp/>of<sp/>alignment<sp/>warnings<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1223"><highlight class="normal"><sp/><sp/>opts<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*)(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)(seg-&gt;tcphdr<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="1224"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;flags<sp/>&amp;<sp/>TF_SEG_OPTS_MSS)<sp/>{</highlight></codeline>
<codeline lineno="1225"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>mss;</highlight></codeline>
<codeline lineno="1226"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CALCULATE_EFF_SEND_MSS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1227"><highlight class="normal"><sp/><sp/><sp/><sp/>mss<sp/>=<sp/>tcp_eff_send_mss(<ref refid="lwipopts_8h_1af1ab7bb27860aa3677c387a2f3ba317b" kindref="member">TCP_MSS</ref>,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1228"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>TCP_CALCULATE_EFF_SEND_MSS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1229"><highlight class="normal"><sp/><sp/><sp/><sp/>mss<sp/>=<sp/><ref refid="lwipopts_8h_1af1ab7bb27860aa3677c387a2f3ba317b" kindref="member">TCP_MSS</ref>;</highlight></codeline>
<codeline lineno="1230"><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="1231"><highlight class="normal"><sp/><sp/><sp/><sp/>*opts<sp/>=<sp/>TCP_BUILD_MSS_OPTION(mss);</highlight></codeline>
<codeline lineno="1232"><highlight class="normal"><sp/><sp/><sp/><sp/>opts<sp/>+=<sp/>1;</highlight></codeline>
<codeline lineno="1233"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1234"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_TIMESTAMPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1235"><highlight class="normal"><sp/><sp/>pcb-&gt;ts_lastacksent<sp/>=<sp/>pcb-&gt;rcv_nxt;</highlight></codeline>
<codeline lineno="1236"><highlight class="normal"></highlight></codeline>
<codeline lineno="1237"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;flags<sp/>&amp;<sp/>TF_SEG_OPTS_TS)<sp/>{</highlight></codeline>
<codeline lineno="1238"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_build_timestamp_option(pcb,<sp/>opts);</highlight></codeline>
<codeline lineno="1239"><highlight class="normal"><sp/><sp/><sp/><sp/>opts<sp/>+=<sp/>3;</highlight></codeline>
<codeline lineno="1240"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1241"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1242"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1243"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;flags<sp/>&amp;<sp/>TF_SEG_OPTS_WND_SCALE)<sp/>{</highlight></codeline>
<codeline lineno="1244"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_build_wnd_scale_option(opts);</highlight></codeline>
<codeline lineno="1245"><highlight class="normal"><sp/><sp/><sp/><sp/>opts<sp/>+=<sp/>1;</highlight></codeline>
<codeline lineno="1246"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1247"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1248"><highlight class="normal"></highlight></codeline>
<codeline lineno="1249"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>retransmission<sp/>timer<sp/>running<sp/>if<sp/>it<sp/>is<sp/>not<sp/>currently<sp/>enabled</highlight></codeline>
<codeline lineno="1250"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>This<sp/>must<sp/>be<sp/>set<sp/>before<sp/>checking<sp/>the<sp/>route.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1251"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rtime<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1252"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1253"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1254"><highlight class="normal"></highlight></codeline>
<codeline lineno="1255"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;rttest<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1256"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;rttest<sp/>=<sp/>tcp_ticks;</highlight></codeline>
<codeline lineno="1257"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;rtseq<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="1258"><highlight class="normal"></highlight></codeline>
<codeline lineno="1259"><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_output_segment:<sp/>rtseq<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/>pcb-&gt;rtseq));</highlight></codeline>
<codeline lineno="1260"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1261"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a9f70601fdc1feee490772bf7fcdb74fb" kindref="member">TCP_OUTPUT_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output_segment:<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="1262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(seg-&gt;tcphdr-&gt;seqno),<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>+</highlight></codeline>
<codeline lineno="1263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;len));</highlight></codeline>
<codeline lineno="1264"><highlight class="normal"></highlight></codeline>
<codeline lineno="1265"><highlight class="normal"><sp/><sp/>len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)((<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*)seg-&gt;tcphdr<sp/>-<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>*)seg-&gt;p-&gt;payload);</highlight></codeline>
<codeline lineno="1266"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(len<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1268"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpoutsegs);</highlight></codeline>
<codeline lineno="1269"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1270"><highlight class="normal"></highlight></codeline>
<codeline lineno="1271"><highlight class="normal"><sp/><sp/>seg-&gt;p-&gt;len<sp/>-=<sp/>len;</highlight></codeline>
<codeline lineno="1272"><highlight class="normal"><sp/><sp/>seg-&gt;p-&gt;tot_len<sp/>-=<sp/>len;</highlight></codeline>
<codeline lineno="1273"><highlight class="normal"></highlight></codeline>
<codeline lineno="1274"><highlight class="normal"><sp/><sp/>seg-&gt;p-&gt;payload<sp/>=<sp/>seg-&gt;tcphdr;</highlight></codeline>
<codeline lineno="1275"><highlight class="normal"></highlight></codeline>
<codeline lineno="1276"><highlight class="normal"><sp/><sp/>seg-&gt;tcphdr-&gt;chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1277"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1278"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1279"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1280"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>acc;</highlight></codeline>
<codeline lineno="1281"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1282"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum_slow<sp/>=<sp/><ref refid="inet__chksum_8h_1aa13cda42e7c262f5dee243ff6c28422f" kindref="member">ip_chksum_pseudo</ref>(seg-&gt;p,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,</highlight></codeline>
<codeline lineno="1283"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;p-&gt;tot_len,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1284"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1285"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((seg-&gt;flags<sp/>&amp;<sp/>TF_SEG_DATA_CHECKSUMMED)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1286"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;data<sp/>included<sp/>but<sp/>not<sp/>checksummed&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1287"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;p-&gt;tot_len<sp/>==<sp/>(<ref refid="prot_2tcp_8h_1a5b97d3b7e68c20eb3eab87a61d779223" kindref="member">TCPH_HDRLEN</ref>(seg-&gt;tcphdr)<sp/>*<sp/>4));</highlight></codeline>
<codeline lineno="1288"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1289"><highlight class="normal"></highlight></codeline>
<codeline lineno="1290"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>rebuild<sp/>TCP<sp/>header<sp/>checksum<sp/>(TCP<sp/>header<sp/>changes<sp/>for<sp/>retransmissions!)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1291"><highlight class="normal"><sp/><sp/><sp/><sp/>acc<sp/>=<sp/><ref refid="inet__chksum_8h_1acfe7ab6c63ef998210c66bb4822b03b2" kindref="member">ip_chksum_pseudo_partial</ref>(seg-&gt;p,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,</highlight></codeline>
<codeline lineno="1292"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;p-&gt;tot_len,<sp/><ref refid="prot_2tcp_8h_1a5b97d3b7e68c20eb3eab87a61d779223" kindref="member">TCPH_HDRLEN</ref>(seg-&gt;tcphdr)<sp/>*<sp/>4,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1293"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>add<sp/>payload<sp/>checksum<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1294"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;chksum_swapped)<sp/>{</highlight></codeline>
<codeline lineno="1295"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a0196bd603262882d16b5264b52eafe18" kindref="member">SWAP_BYTES_IN_WORD</ref>(seg-&gt;chksum);</highlight></codeline>
<codeline lineno="1296"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;chksum_swapped<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1297"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1298"><highlight class="normal"><sp/><sp/><sp/><sp/>acc<sp/>+=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)~(seg-&gt;chksum);</highlight></codeline>
<codeline lineno="1299"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a6ffe83b4bdd1784a0671ee4778966a01" kindref="member">FOLD_U32T</ref>(acc);</highlight></codeline>
<codeline lineno="1300"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1301"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(chksum_slow<sp/>!=<sp/>seg-&gt;tcphdr-&gt;chksum)<sp/>{</highlight></codeline>
<codeline lineno="1302"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK_FAIL(</highlight></codeline>
<codeline lineno="1303"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_output_segment:<sp/>calculated<sp/>checksum<sp/>is<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga1418f92673e54a36b6e376109e526382" kindref="member">X16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>instead<sp/>of<sp/>%&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="1304"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;chksum,<sp/>chksum_slow));</highlight></codeline>
<codeline lineno="1305"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;chksum<sp/>=<sp/>chksum_slow;</highlight></codeline>
<codeline lineno="1306"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1307"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY_SANITY_CHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1308"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1309"><highlight class="normal"><sp/><sp/><sp/><sp/>seg-&gt;tcphdr-&gt;chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1aa13cda42e7c262f5dee243ff6c28422f" kindref="member">ip_chksum_pseudo</ref>(seg-&gt;p,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,</highlight></codeline>
<codeline lineno="1310"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>seg-&gt;p-&gt;tot_len,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1311"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1312"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1313"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1314"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.xmit);</highlight></codeline>
<codeline lineno="1315"><highlight class="normal"></highlight></codeline>
<codeline lineno="1316"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;(pcb-&gt;addr_hint));</highlight></codeline>
<codeline lineno="1317"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>ip_output_if(seg-&gt;p,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip,<sp/>pcb-&gt;ttl,</highlight></codeline>
<codeline lineno="1318"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;tos,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="1319"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1320"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="1321"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1322"><highlight class="normal"></highlight></codeline>
<codeline lineno="1343"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1344"><highlight class="normal">tcp_rst(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>seqno,<sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>ackno,</highlight></codeline>
<codeline lineno="1345"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*local_ip,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*remote_ip,</highlight></codeline>
<codeline lineno="1346"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>local_port,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>remote_port)</highlight></codeline>
<codeline lineno="1347"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1348"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="1349"><highlight class="normal"><sp/><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="1350"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="1351"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfafcc1e506061ba69dfa142eb6b3da5f13" kindref="member">PBUF_IP</ref>,<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="1352"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1353"><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_rst:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1354"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1355"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1356"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;check<sp/>that<sp/>first<sp/>pbuf<sp/>can<sp/>hold<sp/>struct<sp/>tcp_hdr&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structtcp__hdr" kindref="compound">tcp_hdr</ref>)));</highlight></codeline>
<codeline lineno="1358"><highlight class="normal"></highlight></codeline>
<codeline lineno="1359"><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="1360"><highlight class="normal"><sp/><sp/>tcphdr-&gt;src<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(local_port);</highlight></codeline>
<codeline lineno="1361"><highlight class="normal"><sp/><sp/>tcphdr-&gt;dest<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(remote_port);</highlight></codeline>
<codeline lineno="1362"><highlight class="normal"><sp/><sp/>tcphdr-&gt;seqno<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(seqno);</highlight></codeline>
<codeline lineno="1363"><highlight class="normal"><sp/><sp/>tcphdr-&gt;ackno<sp/>=<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(ackno);</highlight></codeline>
<codeline lineno="1364"><highlight class="normal"><sp/><sp/><ref refid="prot_2tcp_8h_1a57fb29aed8df21ccff4481612ee40407" kindref="member">TCPH_HDRLEN_FLAGS_SET</ref>(tcphdr,<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>/4,<sp/><ref refid="prot_2tcp_8h_1a5ca559def464ef20d8b1f7d32f2f160d" kindref="member">TCP_RST</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref>);</highlight></codeline>
<codeline lineno="1365"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_WND_SCALE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1366"><highlight class="normal"><sp/><sp/>tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8h_1a0dfd02d7c09f9c698a5a7ecc0b7287ad" kindref="member">PP_HTONS</ref>(((<ref refid="lwipopts_8h_1a7f535a6efb5cdf86c3210e35ece1d6a7" kindref="member">TCP_WND</ref><sp/>&gt;&gt;<sp/><ref refid="group__lwip__opts__tcp_1ga768765a2c678fefeca6c89aae0cf629f" kindref="member">TCP_RCV_SCALE</ref>)<sp/>&amp;<sp/>0xFFFF));</highlight></codeline>
<codeline lineno="1367"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1368"><highlight class="normal"><sp/><sp/>tcphdr-&gt;wnd<sp/>=<sp/><ref refid="def_8h_1a0dfd02d7c09f9c698a5a7ecc0b7287ad" kindref="member">PP_HTONS</ref>(<ref refid="lwipopts_8h_1a7f535a6efb5cdf86c3210e35ece1d6a7" kindref="member">TCP_WND</ref>);</highlight></codeline>
<codeline lineno="1369"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1370"><highlight class="normal"><sp/><sp/>tcphdr-&gt;chksum<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1371"><highlight class="normal"><sp/><sp/>tcphdr-&gt;urgp<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1372"><highlight class="normal"></highlight></codeline>
<codeline lineno="1373"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.xmit);</highlight></codeline>
<codeline lineno="1374"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpoutrsts);</highlight></codeline>
<codeline lineno="1375"><highlight class="normal"></highlight></codeline>
<codeline lineno="1376"><highlight class="normal"><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(local_ip,<sp/>remote_ip);</highlight></codeline>
<codeline lineno="1377"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1378"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1379"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1380"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcphdr-&gt;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="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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>local_ip,<sp/>remote_ip);</highlight></codeline>
<codeline lineno="1382"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1383"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1384"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Send<sp/>output<sp/>with<sp/>hardcoded<sp/>TTL/HL<sp/>since<sp/>we<sp/>have<sp/>no<sp/>access<sp/>to<sp/>the<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1385"><highlight class="normal"><sp/><sp/><sp/><sp/>ip_output_if(p,<sp/>local_ip,<sp/>remote_ip,<sp/><ref refid="lwipopts_8h_1acd5b25ea81d2894790d25da5393cdab4" kindref="member">TCP_TTL</ref>,<sp/>0,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="1386"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1387"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="1388"><highlight class="normal"><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_rst:<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/>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">,<sp/>seqno,<sp/>ackno));</highlight></codeline>
<codeline lineno="1389"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1390"><highlight class="normal"></highlight></codeline>
<codeline lineno="1398"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1399"><highlight class="normal">tcp_rexmit_rto(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1400"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1401"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg;</highlight></codeline>
<codeline lineno="1402"><highlight class="normal"></highlight></codeline>
<codeline lineno="1403"><highlight class="normal"><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="1404"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1405"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1406"><highlight class="normal"></highlight></codeline>
<codeline lineno="1407"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Move<sp/>all<sp/>unacked<sp/>segments<sp/>to<sp/>the<sp/>head<sp/>of<sp/>the<sp/>unsent<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1408"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(seg<sp/>=<sp/>pcb-&gt;unacked;<sp/>seg-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>seg<sp/>=<sp/>seg-&gt;next);</highlight></codeline>
<codeline lineno="1409"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>concatenate<sp/>unsent<sp/>queue<sp/>after<sp/>unacked<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1410"><highlight class="normal"><sp/><sp/>seg-&gt;next<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="1411"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE_DBGCHECK</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1412"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>last<sp/>unsent<sp/>changed,<sp/>we<sp/>need<sp/>to<sp/>update<sp/>unsent_oversize<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1413"><highlight class="normal"><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="1414"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>seg-&gt;oversize_left;</highlight></codeline>
<codeline lineno="1415"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1416"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_OVERSIZE_DBGCHECK<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1417"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>unsent<sp/>queue<sp/>is<sp/>the<sp/>concatenated<sp/>queue<sp/>(of<sp/>unacked,<sp/>unsent)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1418"><highlight class="normal"><sp/><sp/>pcb-&gt;unsent<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="1419"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>unacked<sp/>queue<sp/>is<sp/>now<sp/>empty<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1420"><highlight class="normal"><sp/><sp/>pcb-&gt;unacked<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1421"><highlight class="normal"></highlight></codeline>
<codeline lineno="1422"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>increment<sp/>number<sp/>of<sp/>retransmissions<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1423"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;nrtx<sp/>&lt;<sp/>0xFF)<sp/>{</highlight></codeline>
<codeline lineno="1424"><highlight class="normal"><sp/><sp/><sp/><sp/>++pcb-&gt;nrtx;</highlight></codeline>
<codeline lineno="1425"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1426"><highlight class="normal"></highlight></codeline>
<codeline lineno="1427"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>take<sp/>any<sp/>RTT<sp/>measurements<sp/>after<sp/>retransmitting.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1428"><highlight class="normal"><sp/><sp/>pcb-&gt;rttest<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1429"><highlight class="normal"></highlight></codeline>
<codeline lineno="1430"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>the<sp/>actual<sp/>retransmission<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1431"><highlight class="normal"><sp/><sp/>tcp_output(pcb);</highlight></codeline>
<codeline lineno="1432"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1433"><highlight class="normal"></highlight></codeline>
<codeline lineno="1441"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1442"><highlight class="normal">tcp_rexmit(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1443"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1444"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg;</highlight></codeline>
<codeline lineno="1445"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>**cur_seg;</highlight></codeline>
<codeline lineno="1446"><highlight class="normal"></highlight></codeline>
<codeline lineno="1447"><highlight class="normal"><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="1448"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1449"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1450"><highlight class="normal"></highlight></codeline>
<codeline lineno="1451"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Move<sp/>the<sp/>first<sp/>unacked<sp/>segment<sp/>to<sp/>the<sp/>unsent<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1452"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Keep<sp/>the<sp/>unsent<sp/>queue<sp/>sorted.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1453"><highlight class="normal"><sp/><sp/>seg<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="1454"><highlight class="normal"><sp/><sp/>pcb-&gt;unacked<sp/>=<sp/>seg-&gt;next;</highlight></codeline>
<codeline lineno="1455"><highlight class="normal"></highlight></codeline>
<codeline lineno="1456"><highlight class="normal"><sp/><sp/>cur_seg<sp/>=<sp/>&amp;(pcb-&gt;unsent);</highlight></codeline>
<codeline lineno="1457"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(*cur_seg<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1458"><highlight class="normal"><sp/><sp/><sp/><sp/>TCP_SEQ_LT(<ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>((*cur_seg)-&gt;tcphdr-&gt;seqno),<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)))<sp/>{</highlight></codeline>
<codeline lineno="1459"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cur_seg<sp/>=<sp/>&amp;((*cur_seg)-&gt;next<sp/>);</highlight></codeline>
<codeline lineno="1460"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1461"><highlight class="normal"><sp/><sp/>seg-&gt;next<sp/>=<sp/>*cur_seg;</highlight></codeline>
<codeline lineno="1462"><highlight class="normal"><sp/><sp/>*cur_seg<sp/>=<sp/>seg;</highlight></codeline>
<codeline lineno="1463"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_OVERSIZE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1464"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg-&gt;next<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1465"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>retransmitted<sp/>segment<sp/>is<sp/>last<sp/>in<sp/>unsent,<sp/>so<sp/>reset<sp/>unsent_oversize<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1466"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;unsent_oversize<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1467"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1468"><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="1469"><highlight class="normal"></highlight></codeline>
<codeline lineno="1470"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;nrtx<sp/>&lt;<sp/>0xFF)<sp/>{</highlight></codeline>
<codeline lineno="1471"><highlight class="normal"><sp/><sp/><sp/><sp/>++pcb-&gt;nrtx;</highlight></codeline>
<codeline lineno="1472"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1473"><highlight class="normal"></highlight></codeline>
<codeline lineno="1474"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>take<sp/>any<sp/>rtt<sp/>measurements<sp/>after<sp/>retransmitting.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1475"><highlight class="normal"><sp/><sp/>pcb-&gt;rttest<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1476"><highlight class="normal"></highlight></codeline>
<codeline lineno="1477"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>the<sp/>actual<sp/>retransmission.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1478"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.tcpretranssegs);</highlight></codeline>
<codeline lineno="1479"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>need<sp/>to<sp/>call<sp/>tcp_output:<sp/>we<sp/>are<sp/>always<sp/>called<sp/>from<sp/>tcp_input()</highlight></codeline>
<codeline lineno="1480"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>and<sp/>thus<sp/>tcp_output<sp/>directly<sp/>returns.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1481"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1482"><highlight class="normal"></highlight></codeline>
<codeline lineno="1483"><highlight class="normal"></highlight></codeline>
<codeline lineno="1489"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1490"><highlight class="normal">tcp_rexmit_fast(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1491"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1492"><highlight class="normal"><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/>&amp;&amp;<sp/>!(pcb-&gt;flags<sp/>&amp;<sp/>TF_INFR))<sp/>{</highlight></codeline>
<codeline lineno="1493"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>is<sp/>fast<sp/>retransmit.<sp/>Retransmit<sp/>the<sp/>first<sp/>unacked<sp/>segment.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1494"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a5895bee26e8e1a0b89d597e0f2580b23" kindref="member">TCP_FR_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1495"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_receive:<sp/>dupacks<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_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight></codeline>
<codeline lineno="1496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;),<sp/>fast<sp/>retransmit<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="1497"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)pcb-&gt;dupacks,<sp/>pcb-&gt;lastack,</highlight></codeline>
<codeline lineno="1498"><highlight class="normal"><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="1499"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_rexmit(pcb);</highlight></codeline>
<codeline lineno="1500"><highlight class="normal"></highlight></codeline>
<codeline lineno="1501"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>ssthresh<sp/>to<sp/>half<sp/>of<sp/>the<sp/>minimum<sp/>of<sp/>the<sp/>current</highlight></codeline>
<codeline lineno="1502"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>cwnd<sp/>and<sp/>the<sp/>advertised<sp/>window<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1503"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;ssthresh<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(pcb-&gt;cwnd,<sp/>pcb-&gt;snd_wnd)<sp/>/<sp/>2;</highlight></codeline>
<codeline lineno="1504"><highlight class="normal"></highlight></codeline>
<codeline lineno="1505"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>minimum<sp/>value<sp/>for<sp/>ssthresh<sp/>should<sp/>be<sp/>2<sp/>MSS<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1506"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;ssthresh<sp/>&lt;<sp/>(2U<sp/>*<sp/>pcb-&gt;mss))<sp/>{</highlight></codeline>
<codeline lineno="1507"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a5895bee26e8e1a0b89d597e0f2580b23" kindref="member">TCP_FR_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1508"><highlight class="normal"><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/>The<sp/>minimum<sp/>value<sp/>for<sp/>ssthresh<sp/>%&quot;</highlight><highlight class="normal">TCPWNDSIZE_F</highlight></codeline>
<codeline lineno="1509"><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="stringliteral">&quot;<sp/>should<sp/>be<sp/>min<sp/>2<sp/>mss<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">,</highlight></codeline>
<codeline lineno="1510"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ssthresh,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)(2*pcb-&gt;mss)));</highlight></codeline>
<codeline lineno="1511"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;ssthresh<sp/>=<sp/>2*pcb-&gt;mss;</highlight></codeline>
<codeline lineno="1512"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1513"><highlight class="normal"></highlight></codeline>
<codeline lineno="1514"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;cwnd<sp/>=<sp/>pcb-&gt;ssthresh<sp/>+<sp/>3<sp/>*<sp/>pcb-&gt;mss;</highlight></codeline>
<codeline lineno="1515"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>TF_INFR;</highlight></codeline>
<codeline lineno="1516"><highlight class="normal"></highlight></codeline>
<codeline lineno="1517"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Reset<sp/>the<sp/>retransmission<sp/>timer<sp/>to<sp/>prevent<sp/>immediate<sp/>rto<sp/>retransmissions<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1518"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;rtime<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1519"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1520"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1521"><highlight class="normal"></highlight></codeline>
<codeline lineno="1522"><highlight class="normal"></highlight></codeline>
<codeline lineno="1531"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="1532"><highlight class="normal">tcp_keepalive(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1533"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1534"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1535"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="1536"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="1537"><highlight class="normal"></highlight></codeline>
<codeline lineno="1538"><highlight class="normal"><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_keepalive:<sp/>sending<sp/>KEEPALIVE<sp/>probe<sp/>to<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1539"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1540"><highlight class="normal"><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;\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1541"><highlight class="normal"></highlight></codeline>
<codeline lineno="1542"><highlight class="normal"><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_keepalive:<sp/>tcp_ticks<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/>pcb-&gt;tmr<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;keep_cnt_sent<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">,</highlight></codeline>
<codeline lineno="1543"><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/>tcp_ticks,<sp/>pcb-&gt;tmr,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)pcb-&gt;keep_cnt_sent));</highlight></codeline>
<codeline lineno="1544"><highlight class="normal"></highlight></codeline>
<codeline lineno="1545"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/>tcp_output_alloc_header(pcb,<sp/>0,<sp/>0,<sp/><ref refid="def_8c_1a14f94347a5b9b9e3602705b75b7ae524" kindref="member">lwip_htonl</ref>(pcb-&gt;snd_nxt<sp/>-<sp/>1));</highlight></codeline>
<codeline lineno="1546"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1547"><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>,</highlight></codeline>
<codeline lineno="1548"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_keepalive:<sp/>could<sp/>not<sp/>allocate<sp/>memory<sp/>for<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1549"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="1550"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1551"><highlight class="normal"><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1552"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1553"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="1554"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1555"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1556"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1557"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structtcp__hdr" kindref="compound">tcp_hdr</ref><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="1558"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcphdr-&gt;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="1559"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1560"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1561"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1562"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.xmit);</highlight></codeline>
<codeline lineno="1563"><highlight class="normal"></highlight></codeline>
<codeline lineno="1564"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Send<sp/>output<sp/>to<sp/>IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1565"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;(pcb-&gt;addr_hint));</highlight></codeline>
<codeline lineno="1566"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>ip_output_if(p,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip,<sp/>pcb-&gt;ttl,<sp/>0,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="1567"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1568"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1569"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="1570"><highlight class="normal"></highlight></codeline>
<codeline lineno="1571"><highlight class="normal"><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_keepalive:<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/>ackno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>err<sp/>%d.\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1572"><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/>pcb-&gt;snd_nxt<sp/>-<sp/>1,<sp/>pcb-&gt;rcv_nxt,<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)err));</highlight></codeline>
<codeline lineno="1573"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="1574"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1575"><highlight class="normal"></highlight></codeline>
<codeline lineno="1576"><highlight class="normal"></highlight></codeline>
<codeline lineno="1585"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="1586"><highlight class="normal">tcp_zero_window_probe(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1587"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1588"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1589"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="1590"><highlight class="normal"><sp/><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="1591"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_seg<sp/>*seg;</highlight></codeline>
<codeline lineno="1592"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len;</highlight></codeline>
<codeline lineno="1593"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>is_fin;</highlight></codeline>
<codeline lineno="1594"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>snd_nxt;</highlight></codeline>
<codeline lineno="1595"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="1596"><highlight class="normal"></highlight></codeline>
<codeline lineno="1597"><highlight class="normal"><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_zero_window_probe:<sp/>sending<sp/>ZERO<sp/>WINDOW<sp/>probe<sp/>to<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1598"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a4f43bb8a430c7a52a1ad5086d3f2803c" kindref="member">TCP_DEBUG</ref>,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1599"><highlight class="normal"><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;\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1600"><highlight class="normal"></highlight></codeline>
<codeline lineno="1601"><highlight class="normal"><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="1602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;tcp_zero_window_probe:<sp/>tcp_ticks<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight></codeline>
<codeline lineno="1603"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/>pcb-&gt;tmr<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;keep_cnt_sent<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">,</highlight></codeline>
<codeline lineno="1604"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_ticks,<sp/>pcb-&gt;tmr,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)pcb-&gt;keep_cnt_sent));</highlight></codeline>
<codeline lineno="1605"><highlight class="normal"></highlight></codeline>
<codeline lineno="1606"><highlight class="normal"><sp/><sp/>seg<sp/>=<sp/>pcb-&gt;unacked;</highlight></codeline>
<codeline lineno="1607"><highlight class="normal"></highlight></codeline>
<codeline lineno="1608"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1609"><highlight class="normal"><sp/><sp/><sp/><sp/>seg<sp/>=<sp/>pcb-&gt;unsent;</highlight></codeline>
<codeline lineno="1610"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1611"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(seg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1612"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>nothing<sp/>to<sp/>send,<sp/>zero<sp/>window<sp/>probe<sp/>not<sp/>needed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1613"><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="1614"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1615"><highlight class="normal"></highlight></codeline>
<codeline lineno="1616"><highlight class="normal"><sp/><sp/>is_fin<sp/>=<sp/>((<ref refid="prot_2tcp_8h_1ad5de3cf876b2c7f6835f44132fe0e9d5" kindref="member">TCPH_FLAGS</ref>(seg-&gt;tcphdr)<sp/>&amp;<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>)<sp/>!=<sp/>0)<sp/>&amp;&amp;<sp/>(seg-&gt;len<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="1617"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>we<sp/>want<sp/>to<sp/>send<sp/>one<sp/>seqno:<sp/>either<sp/>FIN<sp/>or<sp/>data<sp/>(no<sp/>options)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1618"><highlight class="normal"><sp/><sp/>len<sp/>=<sp/>is_fin<sp/>?<sp/>0<sp/>:<sp/>1;</highlight></codeline>
<codeline lineno="1619"><highlight class="normal"></highlight></codeline>
<codeline lineno="1620"><highlight class="normal"><sp/><sp/>p<sp/>=<sp/>tcp_output_alloc_header(pcb,<sp/>0,<sp/>len,<sp/>seg-&gt;tcphdr-&gt;seqno);</highlight></codeline>
<codeline lineno="1621"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1622"><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_zero_window_probe:<sp/>no<sp/>memory<sp/>for<sp/>pbuf\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1623"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="1624"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1625"><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="1626"><highlight class="normal"></highlight></codeline>
<codeline lineno="1627"><highlight class="normal"><sp/><sp/>if<sp/>(is_fin)<sp/>{</highlight></codeline>
<codeline lineno="1628"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>FIN<sp/>segment,<sp/>no<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1629"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="prot_2tcp_8h_1afe7c917080459557c65071c4b13c8e12" kindref="member">TCPH_FLAGS_SET</ref>(tcphdr,<sp/><ref refid="prot_2tcp_8h_1a44b3b1ab31a403ba28ec135adfcbefef" kindref="member">TCP_ACK</ref><sp/>|<sp/><ref refid="prot_2tcp_8h_1a88e60aa2cf23e1c65d630701db08c743" kindref="member">TCP_FIN</ref>);</highlight></codeline>
<codeline lineno="1630"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1631"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Data<sp/>segment,<sp/>copy<sp/>in<sp/>one<sp/>byte<sp/>from<sp/>the<sp/>head<sp/>of<sp/>the<sp/>unacked<sp/>queue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1632"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*d<sp/>=<sp/>((</highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>+<sp/><ref refid="prot_2tcp_8h_1a5758db371d6daa394d178429b7c94c2a" kindref="member">TCP_HLEN</ref>);</highlight></codeline>
<codeline lineno="1633"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Depending<sp/>on<sp/>whether<sp/>the<sp/>segment<sp/>has<sp/>already<sp/>been<sp/>sent<sp/>(unacked)<sp/>or<sp/>not</highlight></codeline>
<codeline lineno="1634"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(unsent),<sp/>seg-&gt;p-&gt;payload<sp/>points<sp/>to<sp/>the<sp/>IP<sp/>header<sp/>or<sp/>TCP<sp/>header.</highlight></codeline>
<codeline lineno="1635"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ensure<sp/>we<sp/>copy<sp/>the<sp/>first<sp/>TCP<sp/>data<sp/>byte:<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1636"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gac2f1f58fd36042e82af46f5015720899" kindref="member">pbuf_copy_partial</ref>(seg-&gt;p,<sp/>d,<sp/>1,<sp/>seg-&gt;p-&gt;tot_len<sp/>-<sp/>seg-&gt;len);</highlight></codeline>
<codeline lineno="1637"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1638"><highlight class="normal"></highlight></codeline>
<codeline lineno="1639"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>byte<sp/>may<sp/>be<sp/>acknowledged<sp/>without<sp/>the<sp/>window<sp/>being<sp/>opened.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1640"><highlight class="normal"><sp/><sp/>snd_nxt<sp/>=<sp/><ref refid="def_8h_1a56098407d66feb75806f655bafbee81d" kindref="member">lwip_ntohl</ref>(seg-&gt;tcphdr-&gt;seqno)<sp/>+<sp/>1;</highlight></codeline>
<codeline lineno="1641"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(TCP_SEQ_LT(pcb-&gt;snd_nxt,<sp/>snd_nxt))<sp/>{</highlight></codeline>
<codeline lineno="1642"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;snd_nxt<sp/>=<sp/>snd_nxt;</highlight></codeline>
<codeline lineno="1643"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1644"><highlight class="normal"></highlight></codeline>
<codeline lineno="1645"><highlight class="normal"><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1646"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1647"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="1648"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1649"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1650"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1651"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcphdr-&gt;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="1652"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1653"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1654"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1655"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a33fdaa705af04fb9a82f1cf0ba21091d" kindref="member">TCP_STATS_INC</ref>(tcp.xmit);</highlight></codeline>
<codeline lineno="1656"><highlight class="normal"></highlight></codeline>
<codeline lineno="1657"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Send<sp/>output<sp/>to<sp/>IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1658"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;(pcb-&gt;addr_hint));</highlight></codeline>
<codeline lineno="1659"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>ip_output_if(p,<sp/>&amp;pcb-&gt;local_ip,<sp/>&amp;pcb-&gt;remote_ip,<sp/>pcb-&gt;ttl,</highlight></codeline>
<codeline lineno="1660"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>0,<sp/><ref refid="prot_2ip_8h_1a634284ee3a136d6ad61bc5d917ebb82f" kindref="member">IP_PROTO_TCP</ref>,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="1661"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1662"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1663"><highlight class="normal"></highlight></codeline>
<codeline lineno="1664"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="1665"><highlight class="normal"></highlight></codeline>
<codeline lineno="1666"><highlight class="normal"><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_zero_window_probe:<sp/>seqno<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight></codeline>
<codeline lineno="1667"><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/></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;<sp/>err<sp/>%d.\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1668"><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/>pcb-&gt;snd_nxt<sp/>-<sp/>1,<sp/>pcb-&gt;rcv_nxt,<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)err));</highlight></codeline>
<codeline lineno="1669"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="1670"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1671"><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_out.c"/>
  </compounddef>
</doxygen>
