<?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="api__msg_8c" kind="file" language="C++">
    <compoundname>api_msg.c</compoundname>
    <includes refid="opt_8h" local="no">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="1">
        <label>C:/Dev/git/UbixOS/sys/net/api/api_msg.c</label>
        <link refid="api__msg_8c"/>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>net/debug.h</label>
        <link refid="debug_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="9">
        <label>sys/cdefs.h</label>
        <link refid="cdefs_8h"/>
      </node>
      <node id="14">
        <label>ubixos/time.h</label>
        <link refid="time_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="15" relation="include">
        </childnode>
      </node>
      <node id="7">
        <label>sys/_types.h</label>
        <link refid="__types_8h"/>
      </node>
      <node id="10">
        <label>sys/_timespec.h</label>
        <link refid="__timespec_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="11">
        <label>sys/_timeval.h</label>
        <link refid="__timeval_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>Sequential API Internal module </para>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="7"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="8"><highlight class="comment"><sp/>*<sp/>Copyright<sp/>(c)<sp/>2001-2004<sp/>Swedish<sp/>Institute<sp/>of<sp/>Computer<sp/>Science.</highlight></codeline>
<codeline lineno="9"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="10"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="11"><highlight class="comment"><sp/>*<sp/>Redistribution<sp/>and<sp/>use<sp/>in<sp/>source<sp/>and<sp/>binary<sp/>forms,<sp/>with<sp/>or<sp/>without<sp/>modification,</highlight></codeline>
<codeline lineno="12"><highlight class="comment"><sp/>*<sp/>are<sp/>permitted<sp/>provided<sp/>that<sp/>the<sp/>following<sp/>conditions<sp/>are<sp/>met:</highlight></codeline>
<codeline lineno="13"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="14"><highlight class="comment"><sp/>*<sp/>1.<sp/>Redistributions<sp/>of<sp/>source<sp/>code<sp/>must<sp/>retain<sp/>the<sp/>above<sp/>copyright<sp/>notice,</highlight></codeline>
<codeline lineno="15"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer.</highlight></codeline>
<codeline lineno="16"><highlight class="comment"><sp/>*<sp/>2.<sp/>Redistributions<sp/>in<sp/>binary<sp/>form<sp/>must<sp/>reproduce<sp/>the<sp/>above<sp/>copyright<sp/>notice,</highlight></codeline>
<codeline lineno="17"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer<sp/>in<sp/>the<sp/>documentation</highlight></codeline>
<codeline lineno="18"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>and/or<sp/>other<sp/>materials<sp/>provided<sp/>with<sp/>the<sp/>distribution.</highlight></codeline>
<codeline lineno="19"><highlight class="comment"><sp/>*<sp/>3.<sp/>The<sp/>name<sp/>of<sp/>the<sp/>author<sp/>may<sp/>not<sp/>be<sp/>used<sp/>to<sp/>endorse<sp/>or<sp/>promote<sp/>products</highlight></codeline>
<codeline lineno="20"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>derived<sp/>from<sp/>this<sp/>software<sp/>without<sp/>specific<sp/>prior<sp/>written<sp/>permission.</highlight></codeline>
<codeline lineno="21"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="22"><highlight class="comment"><sp/>*<sp/>THIS<sp/>SOFTWARE<sp/>IS<sp/>PROVIDED<sp/>BY<sp/>THE<sp/>AUTHOR<sp/>``AS<sp/>IS&apos;&apos;<sp/>AND<sp/>ANY<sp/>EXPRESS<sp/>OR<sp/>IMPLIED</highlight></codeline>
<codeline lineno="23"><highlight class="comment"><sp/>*<sp/>WARRANTIES,<sp/>INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>THE<sp/>IMPLIED<sp/>WARRANTIES<sp/>OF</highlight></codeline>
<codeline lineno="24"><highlight class="comment"><sp/>*<sp/>MERCHANTABILITY<sp/>AND<sp/>FITNESS<sp/>FOR<sp/>A<sp/>PARTICULAR<sp/>PURPOSE<sp/>ARE<sp/>DISCLAIMED.<sp/>IN<sp/>NO<sp/>EVENT</highlight></codeline>
<codeline lineno="25"><highlight class="comment"><sp/>*<sp/>SHALL<sp/>THE<sp/>AUTHOR<sp/>BE<sp/>LIABLE<sp/>FOR<sp/>ANY<sp/>DIRECT,<sp/>INDIRECT,<sp/>INCIDENTAL,<sp/>SPECIAL,</highlight></codeline>
<codeline lineno="26"><highlight class="comment"><sp/>*<sp/>EXEMPLARY,<sp/>OR<sp/>CONSEQUENTIAL<sp/>DAMAGES<sp/>(INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>PROCUREMENT</highlight></codeline>
<codeline lineno="27"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUBSTITUTE<sp/>GOODS<sp/>OR<sp/>SERVICES;<sp/>LOSS<sp/>OF<sp/>USE,<sp/>DATA,<sp/>OR<sp/>PROFITS;<sp/>OR<sp/>BUSINESS</highlight></codeline>
<codeline lineno="28"><highlight class="comment"><sp/>*<sp/>INTERRUPTION)<sp/>HOWEVER<sp/>CAUSED<sp/>AND<sp/>ON<sp/>ANY<sp/>THEORY<sp/>OF<sp/>LIABILITY,<sp/>WHETHER<sp/>IN</highlight></codeline>
<codeline lineno="29"><highlight class="comment"><sp/>*<sp/>CONTRACT,<sp/>STRICT<sp/>LIABILITY,<sp/>OR<sp/>TORT<sp/>(INCLUDING<sp/>NEGLIGENCE<sp/>OR<sp/>OTHERWISE)<sp/>ARISING</highlight></codeline>
<codeline lineno="30"><highlight class="comment"><sp/>*<sp/>IN<sp/>ANY<sp/>WAY<sp/>OUT<sp/>OF<sp/>THE<sp/>USE<sp/>OF<sp/>THIS<sp/>SOFTWARE,<sp/>EVEN<sp/>IF<sp/>ADVISED<sp/>OF<sp/>THE<sp/>POSSIBILITY</highlight></codeline>
<codeline lineno="31"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="32"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="33"><highlight class="comment"><sp/>*<sp/>This<sp/>file<sp/>is<sp/>part<sp/>of<sp/>the<sp/>lwIP<sp/>TCP/IP<sp/>stack.</highlight></codeline>
<codeline lineno="34"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="35"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Adam<sp/>Dunkels<sp/>&lt;adam@sics.se&gt;</highlight></codeline>
<codeline lineno="36"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="37"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="38"><highlight class="normal"></highlight></codeline>
<codeline lineno="39"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="opt_8h" kindref="compound">net/opt.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN<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="42"><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="api__msg_8h" kindref="compound">net/priv/api_msg.h</ref>&gt;</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/>&lt;<ref refid="ip_8h" kindref="compound">net/ip.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="ip__addr_8h" kindref="compound">net/ip_addr.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="udp_8h" kindref="compound">net/udp.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="tcp_8h" kindref="compound">net/tcp.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="49"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="raw_8h" kindref="compound">net/raw.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="50"><highlight class="normal"></highlight></codeline>
<codeline lineno="51"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="memp_8h" kindref="compound">net/memp.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="52"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="igmp_8h" kindref="compound">net/igmp.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="dns_8h" kindref="compound">net/dns.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="mld6_8h" kindref="compound">net/mld6.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="55"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="tcpip__priv_8h" kindref="compound">net/priv/tcpip_priv.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="56"><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><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="58"><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>netconns<sp/>are<sp/>polled<sp/>once<sp/>per<sp/>second<sp/>(e.g.<sp/>continue<sp/>write<sp/>on<sp/>memory<sp/>error)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="60"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>NETCONN_TCP_POLL_INTERVAL<sp/>2</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight></codeline>
<codeline lineno="62"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SET_NONBLOCKING_CONNECT(conn,<sp/>val)<sp/><sp/>do<sp/>{<sp/>if<sp/>(val)<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="63"><highlight class="preprocessor"><sp/><sp/>(conn)-&gt;flags<sp/>|=<sp/>NETCONN_FLAG_IN_NONBLOCKING_CONNECT;<sp/>\</highlight></codeline>
<codeline lineno="64"><highlight class="preprocessor">}<sp/>else<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="65"><highlight class="preprocessor"><sp/><sp/>(conn)-&gt;flags<sp/>&amp;=<sp/>~<sp/>NETCONN_FLAG_IN_NONBLOCKING_CONNECT;<sp/>}}<sp/>while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="66"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IN_NONBLOCKING_CONNECT(conn)<sp/>(((conn)-&gt;flags<sp/>&amp;<sp/>NETCONN_FLAG_IN_NONBLOCKING_CONNECT)<sp/>!=<sp/>0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="67"><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>forward<sp/>declarations<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="70"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>WRITE_DELAYED<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>,<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>WRITE_DELAYED_PARAM<sp/><sp/><sp/>,<sp/>u8_t<sp/>delayed</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>WRITE_DELAYED</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>WRITE_DELAYED_PARAM</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><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/>lwip_netconn_do_writemore(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn<sp/><sp/>WRITE_DELAYED_PARAM);</highlight></codeline>
<codeline lineno="78"><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/>lwip_netconn_do_close_internal(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn<sp/><sp/>WRITE_DELAYED_PARAM);</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></codeline>
<codeline lineno="81"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCPIP_APIMSG_ACK(m)<sp/><sp/><sp/>NETCONN_SET_SAFE_ERR((m)-&gt;conn,<sp/>(m)-&gt;err)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="83"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="84"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>TCPIP_APIMSG_ACK(m)<sp/><sp/><sp/>do<sp/>{<sp/>NETCONN_SET_SAFE_ERR((m)-&gt;conn,<sp/>(m)-&gt;err);<sp/>sys_sem_signal(LWIP_API_MSG_SEM(m));<sp/>}<sp/>while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></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/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>netconn_aborted;</highlight></codeline>
<codeline lineno="89"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="90"><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="92"><highlight class="normal"></highlight></codeline>
<codeline lineno="99"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref></highlight></codeline>
<codeline lineno="100"><highlight class="normal">recv_raw(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>raw_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="101"><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/>*addr)</highlight></codeline>
<codeline lineno="102"><highlight class="normal">{</highlight></codeline>
<codeline lineno="103"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*q;</highlight></codeline>
<codeline lineno="104"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*<ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline>
<codeline lineno="105"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="106"><highlight class="normal"></highlight></codeline>
<codeline lineno="107"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(addr);</highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="109"><highlight class="normal"></highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/><ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="111"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>recv_avail;</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a0da95147531964d619be7744c7169986" kindref="member">SYS_ARCH_GET</ref>(conn-&gt;recv_avail,<sp/>recv_avail);</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((recv_avail<sp/>+<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)(p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>))<sp/>&gt;<sp/>conn-&gt;recv_bufsize)<sp/>{</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="117"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>the<sp/>whole<sp/>packet<sp/>into<sp/>new<sp/>pbufs<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/>q<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa21116654fbab6d5a4dfeb87a1bb8f0ba" kindref="member">PBUF_RAW</ref>,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="121"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__pbuf_1gaba88511dee3df4b631fde691f421320d" kindref="member">pbuf_copy</ref>(q,<sp/>p)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(q);</highlight></codeline>
<codeline lineno="123"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="125"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="126"><highlight class="normal"></highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len;</highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref><sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_NETBUF);</highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structbuf" kindref="compound">buf</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="131"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(q);</highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="134"><highlight class="normal"></highlight></codeline>
<codeline lineno="135"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;p<sp/>=<sp/>q;</highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;ptr<sp/>=<sp/>q;</highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(<ref refid="structbuf" kindref="compound">buf</ref>-&gt;addr,<sp/>*<ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>());</highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;port<sp/>=<sp/>pcb-&gt;protocol;</highlight></codeline>
<codeline lineno="139"><highlight class="normal"></highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>len<sp/>=<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;recvmbox,<sp/><ref refid="structbuf" kindref="compound">buf</ref>)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_delete(<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="145"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1acc5f7f8cbd020de628d1e9a0443da4c7" kindref="member">SYS_ARCH_INC</ref>(conn-&gt;recv_avail,<sp/>len);</highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>len);</highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="152"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="153"><highlight class="normal"></highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;<sp/></highlight><highlight class="comment">/*<sp/>do<sp/>not<sp/>eat<sp/>the<sp/>packet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="155"><highlight class="normal">}</highlight></codeline>
<codeline lineno="156"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="157"><highlight class="normal"></highlight></codeline>
<codeline lineno="158"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><highlight class="normal"></highlight></codeline>
<codeline lineno="165"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="166"><highlight class="normal">recv_udp(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="167"><highlight class="normal"><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/>*addr,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port)</highlight></codeline>
<codeline lineno="168"><highlight class="normal">{</highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*<ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline>
<codeline lineno="170"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="171"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len;</highlight></codeline>
<codeline lineno="172"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>recv_avail;</highlight></codeline>
<codeline lineno="174"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="175"><highlight class="normal"></highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);<sp/></highlight><highlight class="comment">/*<sp/>only<sp/>used<sp/>for<sp/>asserts...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recv_udp<sp/>must<sp/>have<sp/>a<sp/>pcb<sp/>argument&quot;</highlight><highlight class="normal">,<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recv_udp<sp/>must<sp/>have<sp/>an<sp/>argument&quot;</highlight><highlight class="normal">,<sp/>arg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="180"><highlight class="normal"></highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="185"><highlight class="normal"></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;recv_udp:<sp/>recv<sp/>for<sp/>wrong<sp/>pcb!&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;pcb.udp<sp/>==<sp/>pcb);</highlight></codeline>
<codeline lineno="187"><highlight class="normal"></highlight></codeline>
<codeline lineno="188"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a0da95147531964d619be7744c7169986" kindref="member">SYS_ARCH_GET</ref>(conn-&gt;recv_avail,<sp/>recv_avail);</highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox)<sp/>||</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((recv_avail<sp/>+<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)(p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>))<sp/>&gt;<sp/>conn-&gt;recv_bufsize))<sp/>{</highlight></codeline>
<codeline lineno="192"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/><sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="194"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="195"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="198"><highlight class="normal"></highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref><sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_NETBUF);</highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structbuf" kindref="compound">buf</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;p<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;ptr<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a40db7feae2b92f7a7a01d65a85b06e18" kindref="member">ip_addr_set</ref>(&amp;<ref refid="structbuf" kindref="compound">buf</ref>-&gt;addr,<sp/>addr);</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;port<sp/>=<sp/>port;</highlight></codeline>
<codeline lineno="208"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETBUF_RECVINFO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>UDP<sp/>header<sp/>-<sp/>always<sp/>in<sp/>the<sp/>first<sp/>pbuf,<sp/>ensured<sp/>by<sp/>udp_input<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="211"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref>*<sp/>udphdr<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref>*)ip_next_header_ptr();</highlight></codeline>
<codeline lineno="212"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;flags<sp/>=<sp/>NETBUF_FLAG_DESTADDR;</highlight></codeline>
<codeline lineno="214"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a40db7feae2b92f7a7a01d65a85b06e18" kindref="member">ip_addr_set</ref>(&amp;<ref refid="structbuf" kindref="compound">buf</ref>-&gt;toaddr,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>());</highlight></codeline>
<codeline lineno="216"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>-&gt;toport_chksum<sp/>=<sp/>udphdr-&gt;dest;</highlight></codeline>
<codeline lineno="217"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="218"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETBUF_RECVINFO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="219"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="220"><highlight class="normal"></highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/>len<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="222"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;recvmbox,<sp/><ref refid="structbuf" kindref="compound">buf</ref>)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="223"><highlight class="normal"><sp/><sp/><sp/><sp/>netbuf_delete(<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="224"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="226"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="227"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1acc5f7f8cbd020de628d1e9a0443da4c7" kindref="member">SYS_ARCH_INC</ref>(conn-&gt;recv_avail,<sp/>len);</highlight></codeline>
<codeline lineno="228"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>len);</highlight></codeline>
<codeline lineno="231"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="232"><highlight class="normal">}</highlight></codeline>
<codeline lineno="233"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="234"><highlight class="normal"></highlight></codeline>
<codeline lineno="235"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="236"><highlight class="normal"></highlight></codeline>
<codeline lineno="242"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="243"><highlight class="normal">recv_tcp(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<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="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err)</highlight></codeline>
<codeline lineno="244"><highlight class="normal">{</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len;</highlight></codeline>
<codeline lineno="247"><highlight class="normal"></highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);</highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recv_tcp<sp/>must<sp/>have<sp/>a<sp/>pcb<sp/>argument&quot;</highlight><highlight class="normal">,<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recv_tcp<sp/>must<sp/>have<sp/>an<sp/>argument&quot;</highlight><highlight class="normal">,<sp/>arg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="252"><highlight class="normal"></highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="255"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recv_tcp:<sp/>recv<sp/>for<sp/>wrong<sp/>pcb!&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;pcb.tcp<sp/>==<sp/>pcb);</highlight></codeline>
<codeline lineno="257"><highlight class="normal"></highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>recvmbox<sp/>already<sp/>deleted<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="260"><highlight class="normal"><sp/><sp/><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="261"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_recved(pcb,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>);</highlight></codeline>
<codeline lineno="262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="264"><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="265"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Unlike<sp/>for<sp/>UDP<sp/>or<sp/>RAW<sp/>pcbs,<sp/>don&apos;t<sp/>check<sp/>for<sp/>available<sp/>space</highlight></codeline>
<codeline lineno="267"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>using<sp/>recv_avail<sp/>since<sp/>that<sp/>could<sp/>break<sp/>the<sp/>connection</highlight></codeline>
<codeline lineno="268"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>(data<sp/>is<sp/>already<sp/>ACKed)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="269"><highlight class="normal"></highlight></codeline>
<codeline lineno="270"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>overwrite<sp/>fatal<sp/>errors!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="271"><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="272"><highlight class="normal"><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/>err);</highlight></codeline>
<codeline lineno="273"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="274"><highlight class="normal"></highlight></codeline>
<codeline lineno="275"><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="276"><highlight class="normal"><sp/><sp/><sp/><sp/>len<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="277"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="278"><highlight class="normal"><sp/><sp/><sp/><sp/>len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="279"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="280"><highlight class="normal"></highlight></codeline>
<codeline lineno="281"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;recvmbox,<sp/>p)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="282"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>deallocate<sp/>p:<sp/>it<sp/>is<sp/>presented<sp/>to<sp/>us<sp/>later<sp/>again<sp/>from<sp/>tcp_fasttmr!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="283"><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="284"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="285"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="286"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1acc5f7f8cbd020de628d1e9a0443da4c7" kindref="member">SYS_ARCH_INC</ref>(conn-&gt;recv_avail,<sp/>len);</highlight></codeline>
<codeline lineno="287"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="288"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>len);</highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="291"><highlight class="normal"></highlight></codeline>
<codeline lineno="292"><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="293"><highlight class="normal">}</highlight></codeline>
<codeline lineno="294"><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">poll_tcp(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="308"><highlight class="normal">{</highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="310"><highlight class="normal"></highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);</highlight></codeline>
<codeline lineno="312"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>(conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="313"><highlight class="normal"></highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;state<sp/>==<sp/>NETCONN_WRITE)<sp/>{</highlight></codeline>
<codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/>lwip_netconn_do_writemore(conn<sp/><sp/>WRITE_DELAYED);</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/>(conn-&gt;state<sp/>==<sp/>NETCONN_CLOSE)<sp/>{</highlight></codeline>
<codeline lineno="317"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_SO_SNDTIMEO<sp/>&amp;&amp;<sp/>!LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="318"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;current_msg<sp/>&amp;&amp;<sp/>conn-&gt;current_msg-&gt;msg.sd.polls_left)<sp/>{</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.sd.polls_left--;</highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="321"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>!LWIP_SO_SNDTIMEO<sp/>&amp;&amp;<sp/>!LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/>lwip_netconn_do_close_internal(conn<sp/><sp/>WRITE_DELAYED);</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>implement<sp/>connect<sp/>timeout<sp/>here?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="325"><highlight class="normal"></highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Did<sp/>a<sp/>nonblocking<sp/>write<sp/>fail<sp/>before?<sp/>Then<sp/>check<sp/>available<sp/>write-space.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="327"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;flags<sp/>&amp;<sp/>NETCONN_FLAG_CHECK_WRITESPACE)<sp/>{</highlight></codeline>
<codeline lineno="328"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>queued<sp/>byte-<sp/>or<sp/>pbuf-count<sp/>drops<sp/>below<sp/>the<sp/>configured<sp/>low-water<sp/>limit,</highlight></codeline>
<codeline lineno="329"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>let<sp/>select<sp/>mark<sp/>this<sp/>pcb<sp/>as<sp/>writable<sp/>again.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(tcp_sndbuf(conn-&gt;pcb.tcp)<sp/>&gt;<sp/><ref refid="lwipopts_8h_1ae5c9866d7cd463ac7b36792182145aec" kindref="member">TCP_SNDLOWAT</ref>)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="331"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(tcp_sndqueuelen(conn-&gt;pcb.tcp)<sp/>&lt;<sp/><ref refid="lwipopts_8h_1a75659867592a6b01c198532ed1b65698" kindref="member">TCP_SNDQUEUELOWAT</ref>))<sp/>{</highlight></codeline>
<codeline lineno="332"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;flags<sp/>&amp;=<sp/>~NETCONN_FLAG_CHECK_WRITESPACE;</highlight></codeline>
<codeline lineno="333"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="336"><highlight class="normal"></highlight></codeline>
<codeline lineno="337"><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="338"><highlight class="normal">}</highlight></codeline>
<codeline lineno="339"><highlight class="normal"></highlight></codeline>
<codeline lineno="347"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="348"><highlight class="normal">sent_tcp(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></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/>len)</highlight></codeline>
<codeline lineno="349"><highlight class="normal">{</highlight></codeline>
<codeline lineno="350"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="351"><highlight class="normal"></highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>(conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="354"><highlight class="normal"></highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn)<sp/>{</highlight></codeline>
<codeline lineno="356"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;state<sp/>==<sp/>NETCONN_WRITE)<sp/>{</highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>lwip_netconn_do_writemore(conn<sp/><sp/>WRITE_DELAYED);</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;state<sp/>==<sp/>NETCONN_CLOSE)<sp/>{</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>lwip_netconn_do_close_internal(conn<sp/><sp/>WRITE_DELAYED);</highlight></codeline>
<codeline lineno="360"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="361"><highlight class="normal"></highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>queued<sp/>byte-<sp/>or<sp/>pbuf-count<sp/>drops<sp/>below<sp/>the<sp/>configured<sp/>low-water<sp/>limit,</highlight></codeline>
<codeline lineno="363"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>let<sp/>select<sp/>mark<sp/>this<sp/>pcb<sp/>as<sp/>writable<sp/>again.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(tcp_sndbuf(conn-&gt;pcb.tcp)<sp/>&gt;<sp/><ref refid="lwipopts_8h_1ae5c9866d7cd463ac7b36792182145aec" kindref="member">TCP_SNDLOWAT</ref>)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(tcp_sndqueuelen(conn-&gt;pcb.tcp)<sp/>&lt;<sp/><ref refid="lwipopts_8h_1a75659867592a6b01c198532ed1b65698" kindref="member">TCP_SNDQUEUELOWAT</ref>))<sp/>{</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;flags<sp/>&amp;=<sp/>~NETCONN_FLAG_CHECK_WRITESPACE;</highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>len);</highlight></codeline>
<codeline lineno="368"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="370"><highlight class="normal"></highlight></codeline>
<codeline lineno="371"><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="372"><highlight class="normal">}</highlight></codeline>
<codeline lineno="373"><highlight class="normal"></highlight></codeline>
<codeline lineno="381"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="382"><highlight class="normal">err_tcp(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err)</highlight></codeline>
<codeline lineno="383"><highlight class="normal">{</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="385"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_state<sp/>old_state;</highlight></codeline>
<codeline lineno="386"><highlight class="normal"></highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="388"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>(conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="389"><highlight class="normal"></highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/>conn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="391"><highlight class="normal"></highlight></codeline>
<codeline lineno="392"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>reset<sp/>conn-&gt;state<sp/>now<sp/>before<sp/>waking<sp/>up<sp/>other<sp/>threads<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="393"><highlight class="normal"><sp/><sp/>old_state<sp/>=<sp/>conn-&gt;state;</highlight></codeline>
<codeline lineno="394"><highlight class="normal"><sp/><sp/>conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="395"><highlight class="normal"></highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(old_state<sp/>==<sp/>NETCONN_CLOSE)<sp/>{</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>RST<sp/>during<sp/>close:<sp/>let<sp/>close<sp/>return<sp/>success<sp/>&amp;<sp/>dealloc<sp/>the<sp/>netconn<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="398"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>);</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="401"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>check<sp/>since<sp/>this<sp/>is<sp/>always<sp/>fatal!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="402"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a24ff55288a4d9fa28100c78b2f4612f6" kindref="member">SYS_ARCH_SET</ref>(conn-&gt;last_err,<sp/>err);</highlight></codeline>
<codeline lineno="403"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="404"><highlight class="normal"></highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>the<sp/>type<sp/>of<sp/>NETCONN_EVT<sp/>created<sp/>should<sp/>depend<sp/>on<sp/>&apos;old_state&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="406"><highlight class="normal"></highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Notify<sp/>the<sp/>user<sp/>layer<sp/>about<sp/>a<sp/>connection<sp/>error.<sp/>Used<sp/>to<sp/>signal<sp/>select.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_ERROR,<sp/>0);</highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Try<sp/>to<sp/>release<sp/>selects<sp/>pending<sp/>on<sp/>&apos;read&apos;<sp/>or<sp/>&apos;write&apos;,<sp/>too.</highlight></codeline>
<codeline lineno="410"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>They<sp/>will<sp/>get<sp/>an<sp/>error<sp/>if<sp/>they<sp/>actually<sp/>try<sp/>to<sp/>read<sp/>or<sp/>write.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="413"><highlight class="normal"></highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>pass<sp/>NULL-message<sp/>to<sp/>recvmbox<sp/>to<sp/>wake<sp/>up<sp/>pending<sp/>recv<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>use<sp/>trypost<sp/>to<sp/>prevent<sp/>deadlock<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;recvmbox,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="419"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>pass<sp/>NULL-message<sp/>to<sp/>acceptmbox<sp/>to<sp/>wake<sp/>up<sp/>pending<sp/>accept<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="420"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;acceptmbox))<sp/>{</highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>use<sp/>trypost<sp/>to<sp/>preven<sp/>deadlock<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;acceptmbox,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="423"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="424"><highlight class="normal"></highlight></codeline>
<codeline lineno="425"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((old_state<sp/>==<sp/>NETCONN_WRITE)<sp/>||<sp/>(old_state<sp/>==<sp/>NETCONN_CLOSE)<sp/>||</highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(old_state<sp/>==<sp/>NETCONN_CONNECT))<sp/>{</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>calling<sp/>lwip_netconn_do_writemore/lwip_netconn_do_close_internal<sp/>is<sp/>not<sp/>necessary</highlight></codeline>
<codeline lineno="428"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>since<sp/>the<sp/>pcb<sp/>has<sp/>already<sp/>been<sp/>deleted!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="429"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>was_nonblocking_connect<sp/>=<sp/>IN_NONBLOCKING_CONNECT(conn);</highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/><sp/><sp/>SET_NONBLOCKING_CONNECT(conn,<sp/>0);</highlight></codeline>
<codeline lineno="431"><highlight class="normal"></highlight></codeline>
<codeline lineno="432"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!was_nonblocking_connect)<sp/>{</highlight></codeline>
<codeline lineno="433"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>op_completed_sem;</highlight></codeline>
<codeline lineno="434"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>set<sp/>error<sp/>return<sp/>code<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="435"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;current_msg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="437"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>op_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;inavlid<sp/>op_completed_sem&quot;</highlight><highlight class="normal">,<sp/><ref refid="group__sys__sem_1gac7ff314270976b80559d043f6098817b" kindref="member">sys_sem_valid</ref>(op_completed_sem));</highlight></codeline>
<codeline lineno="439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>wake<sp/>up<sp/>the<sp/>waiting<sp/>task<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="441"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/>err);</highlight></codeline>
<codeline lineno="442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(op_completed_sem);</highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;current_msg<sp/>==<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;current_msg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="447"><highlight class="normal">}</highlight></codeline>
<codeline lineno="448"><highlight class="normal"></highlight></codeline>
<codeline lineno="455"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="456"><highlight class="normal">setup_tcp(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn)</highlight></codeline>
<codeline lineno="457"><highlight class="normal">{</highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb<sp/>*pcb;</highlight></codeline>
<codeline lineno="459"><highlight class="normal"></highlight></codeline>
<codeline lineno="460"><highlight class="normal"><sp/><sp/>pcb<sp/>=<sp/>conn-&gt;pcb.tcp;</highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/>tcp_arg(pcb,<sp/>conn);</highlight></codeline>
<codeline lineno="462"><highlight class="normal"><sp/><sp/>tcp_recv(pcb,<sp/>recv_tcp);</highlight></codeline>
<codeline lineno="463"><highlight class="normal"><sp/><sp/>tcp_sent(pcb,<sp/>sent_tcp);</highlight></codeline>
<codeline lineno="464"><highlight class="normal"><sp/><sp/>tcp_poll(pcb,<sp/>poll_tcp,<sp/>NETCONN_TCP_POLL_INTERVAL);</highlight></codeline>
<codeline lineno="465"><highlight class="normal"><sp/><sp/>tcp_err(pcb,<sp/>err_tcp);</highlight></codeline>
<codeline lineno="466"><highlight class="normal">}</highlight></codeline>
<codeline lineno="467"><highlight class="normal"></highlight></codeline>
<codeline lineno="474"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="475"><highlight class="normal">accept_function(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*newpcb,<sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err)</highlight></codeline>
<codeline lineno="476"><highlight class="normal">{</highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*newconn;</highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="479"><highlight class="normal"></highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="481"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="482"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="483"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;acceptmbox))<sp/>{</highlight></codeline>
<codeline lineno="484"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4279d7ff9f986b2ff3eb068bb012b697" kindref="member">API_MSG_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;accept_function:<sp/>acceptmbox<sp/>already<sp/>deleted\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="485"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="486"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="487"><highlight class="normal"></highlight></codeline>
<codeline lineno="488"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(newpcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="489"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>out-of-pcbs<sp/>during<sp/>connect:<sp/>pass<sp/>on<sp/>this<sp/>error<sp/>to<sp/>the<sp/>application<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="490"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;acceptmbox,<sp/>&amp;netconn_aborted)<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="491"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="492"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="493"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="494"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="495"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="496"><highlight class="normal"></highlight></codeline>
<codeline lineno="497"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a4279d7ff9f986b2ff3eb068bb012b697" kindref="member">API_MSG_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;accept_function:<sp/>newpcb-&gt;tate:<sp/>%s\n&quot;</highlight><highlight class="normal">,<sp/>tcp_debug_state_str(newpcb-&gt;state)));</highlight></codeline>
<codeline lineno="498"><highlight class="normal"></highlight></codeline>
<codeline lineno="499"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>have<sp/>to<sp/>set<sp/>the<sp/>callback<sp/>here<sp/>even<sp/>though</highlight></codeline>
<codeline lineno="500"><highlight class="comment"><sp/><sp/><sp/>*<sp/>the<sp/>new<sp/>socket<sp/>is<sp/>unknown.<sp/>newconn-&gt;socket<sp/>is<sp/>marked<sp/>as<sp/>-1.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="501"><highlight class="normal"><sp/><sp/>newconn<sp/>=<sp/>netconn_alloc(conn-&gt;type,<sp/>conn-&gt;callback);</highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(newconn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>outof<sp/>netconns:<sp/>pass<sp/>on<sp/>this<sp/>error<sp/>to<sp/>the<sp/>application<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;acceptmbox,<sp/>&amp;netconn_aborted)<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="505"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="507"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="508"><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="509"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="510"><highlight class="normal"><sp/><sp/>newconn-&gt;pcb.tcp<sp/>=<sp/>newpcb;</highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/>setup_tcp(newconn);</highlight></codeline>
<codeline lineno="512"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>protection:<sp/>when<sp/>creating<sp/>the<sp/>pcb,<sp/>the<sp/>netconn<sp/>is<sp/>not<sp/>yet<sp/>known</highlight></codeline>
<codeline lineno="513"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>to<sp/>the<sp/>application<sp/>thread<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="514"><highlight class="normal"><sp/><sp/>newconn-&gt;last_err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="515"><highlight class="normal"></highlight></codeline>
<codeline lineno="516"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>handle<sp/>backlog<sp/>counter<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="517"><highlight class="normal"><sp/><sp/>tcp_backlog_delayed(newpcb);</highlight></codeline>
<codeline lineno="518"><highlight class="normal"></highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gacc06f47f34de04084e1d49788ce871b6" kindref="member">sys_mbox_trypost</ref>(&amp;conn-&gt;acceptmbox,<sp/>newconn)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="520"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>When<sp/>returning<sp/>!=<sp/>ERR_OK,<sp/>the<sp/>pcb<sp/>is<sp/>aborted<sp/>in<sp/>tcp_process(),</highlight></codeline>
<codeline lineno="521"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>so<sp/>do<sp/>nothing<sp/>here!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="522"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remove<sp/>all<sp/>references<sp/>to<sp/>this<sp/>netconn<sp/>from<sp/>the<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb*<sp/>pcb<sp/>=<sp/>newconn-&gt;pcb.tcp;</highlight></codeline>
<codeline lineno="524"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_arg(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="525"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_recv(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="526"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_sent(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="527"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_poll(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>0);</highlight></codeline>
<codeline lineno="528"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_err(pcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="529"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remove<sp/>reference<sp/>from<sp/>to<sp/>the<sp/>pcb<sp/>from<sp/>this<sp/>netconn<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="530"><highlight class="normal"><sp/><sp/><sp/><sp/>newconn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="531"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>need<sp/>to<sp/>drain<sp/>since<sp/>we<sp/>know<sp/>the<sp/>recvmbox<sp/>is<sp/>empty.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="532"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gad4a51a28337f89d4b4806e6deb99798d" kindref="member">sys_mbox_free</ref>(&amp;newconn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="533"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1ga64ca1b1ef4c810f4d67595eca4fdfef0" kindref="member">sys_mbox_set_invalid</ref>(&amp;newconn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="534"><highlight class="normal"><sp/><sp/><sp/><sp/>netconn_free(newconn);</highlight></codeline>
<codeline lineno="535"><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="536"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="537"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Register<sp/>event<sp/>with<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="539"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="540"><highlight class="normal"></highlight></codeline>
<codeline lineno="541"><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="542"><highlight class="normal">}</highlight></codeline>
<codeline lineno="543"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="544"><highlight class="normal"></highlight></codeline>
<codeline lineno="551"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="552"><highlight class="normal">pcb_new(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>api_msg<sp/>*msg)</highlight></codeline>
<codeline lineno="553"><highlight class="normal">{</highlight></codeline>
<codeline lineno="554"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/><ref refid="group__ipaddr_1gaf2142f0dfdcc938e2db16aa745ed585c" kindref="member">lwip_ip_addr_type</ref><sp/>iptype<sp/>=<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>;</highlight></codeline>
<codeline lineno="555"><highlight class="normal"></highlight></codeline>
<codeline lineno="556"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb_new:<sp/>pcb<sp/>already<sp/>allocated&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;pcb.tcp<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="557"><highlight class="normal"><sp/></highlight></codeline>
<codeline lineno="558"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="559"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>IPv6:<sp/>Dual-stack<sp/>by<sp/>default,<sp/>unless<sp/>netconn_set_ipv6only()<sp/>is<sp/>called<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(NETCONNTYPE_ISIPV6(netconn_type(msg-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/><sp/><sp/>iptype<sp/>=<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cac6b2c99cf920e08efcb55dc40e42944e" kindref="member">IPADDR_TYPE_ANY</ref>;</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="563"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="564"><highlight class="normal"><sp/><sp/></highlight></codeline>
<codeline lineno="565"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Allocate<sp/>a<sp/>PCB<sp/>for<sp/>this<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="566"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal">(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="567"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="568"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="569"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.raw<sp/>=<sp/>raw_new_ip_type(iptype,<sp/>msg-&gt;msg.n.proto);</highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.raw<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="571"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>ICMPv6<sp/>packets<sp/>should<sp/>always<sp/>have<sp/>checksum<sp/>calculated<sp/>by<sp/>the<sp/>stack<sp/>as<sp/>per<sp/>RFC<sp/>3542<sp/>chapter<sp/>3.1<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="573"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISIPV6(msg-&gt;conn-&gt;type)<sp/>&amp;&amp;<sp/>msg-&gt;conn-&gt;pcb.raw-&gt;protocol<sp/>==<sp/><ref refid="prot_2ip6_8h_1ab277ee09b6e7200fc1cfe28482b886a6" kindref="member">IP6_NEXTH_ICMP6</ref>)<sp/>{</highlight></codeline>
<codeline lineno="574"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.raw-&gt;chksum_reqd<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="575"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.raw-&gt;chksum_offset<sp/>=<sp/>2;</highlight></codeline>
<codeline lineno="576"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="577"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>raw_recv(msg-&gt;conn-&gt;pcb.raw,<sp/>recv_raw,<sp/>msg-&gt;conn);</highlight></codeline>
<codeline lineno="579"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="581"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="582"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="583"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="584"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.udp<sp/>=<sp/>udp_new_ip_type(iptype);</highlight></codeline>
<codeline lineno="585"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.udp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="586"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISUDPLITE(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="588"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(msg-&gt;conn-&gt;pcb.udp,<sp/>UDP_FLAGS_UDPLITE);</highlight></codeline>
<codeline lineno="589"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="590"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDPLITE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="591"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISUDPNOCHKSUM(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(msg-&gt;conn-&gt;pcb.udp,<sp/>UDP_FLAGS_NOCHKSUM);</highlight></codeline>
<codeline lineno="593"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="594"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>udp_recv(msg-&gt;conn-&gt;pcb.udp,<sp/>recv_udp,<sp/>msg-&gt;conn);</highlight></codeline>
<codeline lineno="595"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="596"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="597"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="598"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="599"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="600"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.tcp<sp/>=<sp/>tcp_new_ip_type(iptype);</highlight></codeline>
<codeline lineno="601"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>setup_tcp(msg-&gt;conn);</highlight></codeline>
<codeline lineno="603"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="604"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="605"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="606"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="607"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Unsupported<sp/>netconn<sp/>type,<sp/>e.g.<sp/>protocol<sp/>disabled<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="608"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="609"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="610"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="613"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="614"><highlight class="normal">}</highlight></codeline>
<codeline lineno="615"><highlight class="normal"></highlight></codeline>
<codeline lineno="622"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="623"><highlight class="normal">lwip_netconn_do_newconn(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="624"><highlight class="normal">{</highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="626"><highlight class="normal"></highlight></codeline>
<codeline lineno="627"><highlight class="normal"><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="628"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<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/>pcb_new(msg);</highlight></codeline>
<codeline lineno="630"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="631"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Else?<sp/>This<sp/>&quot;new&quot;<sp/>connection<sp/>already<sp/>has<sp/>a<sp/>PCB<sp/>allocated.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="632"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Is<sp/>this<sp/>an<sp/>error<sp/>condition?<sp/>Should<sp/>it<sp/>be<sp/>deleted?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="633"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>currently<sp/>just<sp/>are<sp/>happy<sp/>and<sp/>return.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="634"><highlight class="normal"></highlight></codeline>
<codeline lineno="635"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="636"><highlight class="normal">}</highlight></codeline>
<codeline lineno="637"><highlight class="normal"></highlight></codeline>
<codeline lineno="647"><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn*</highlight></codeline>
<codeline lineno="648"><highlight class="normal">netconn_alloc(</highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_type<sp/>t,<sp/>netconn_callback<sp/>callback)</highlight></codeline>
<codeline lineno="649"><highlight class="normal">{</highlight></codeline>
<codeline lineno="650"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="651"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>size;</highlight></codeline>
<codeline lineno="652"><highlight class="normal"></highlight></codeline>
<codeline lineno="653"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_NETCONN);</highlight></codeline>
<codeline lineno="654"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="655"><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="656"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="657"><highlight class="normal"></highlight></codeline>
<codeline lineno="658"><highlight class="normal"><sp/><sp/>conn-&gt;last_err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="659"><highlight class="normal"><sp/><sp/>conn-&gt;type<sp/>=<sp/>t;</highlight></codeline>
<codeline lineno="660"><highlight class="normal"><sp/><sp/>conn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="661"><highlight class="normal"></highlight></codeline>
<codeline lineno="662"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>all<sp/>sizes<sp/>are<sp/>the<sp/>same,<sp/>every<sp/>compiler<sp/>should<sp/>optimize<sp/>this<sp/>switch<sp/>to<sp/>nothing<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="663"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal">(NETCONNTYPE_GROUP(t))<sp/>{</highlight></codeline>
<codeline lineno="664"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="666"><highlight class="normal"><sp/><sp/><sp/><sp/>size<sp/>=<sp/><ref refid="lwipopts_8h_1a4ef8f046c957750056131310a1580df7" kindref="member">DEFAULT_RAW_RECVMBOX_SIZE</ref>;</highlight></codeline>
<codeline lineno="667"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="668"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="669"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="670"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="671"><highlight class="normal"><sp/><sp/><sp/><sp/>size<sp/>=<sp/><ref refid="lwipopts_8h_1a09fe785559b3f0cf108da4440489e335" kindref="member">DEFAULT_UDP_RECVMBOX_SIZE</ref>;</highlight></codeline>
<codeline lineno="672"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="673"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="674"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="676"><highlight class="normal"><sp/><sp/><sp/><sp/>size<sp/>=<sp/><ref refid="lwipopts_8h_1a1bd172938b9c8ba63156fcafc87e83c7" kindref="member">DEFAULT_TCP_RECVMBOX_SIZE</ref>;</highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="678"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="680"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;netconn_alloc:<sp/>undefined<sp/>netconn_type&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>free_and_return;</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="683"><highlight class="normal"></highlight></codeline>
<codeline lineno="684"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1ga26c015e64c859c9361a6f75c4e6fa829" kindref="member">sys_mbox_new</ref>(&amp;conn-&gt;recvmbox,<sp/>size)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="685"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>free_and_return;</highlight></codeline>
<codeline lineno="686"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="687"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="688"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__sem_1gadb68acad14b34550b9891bc11bbf4e63" kindref="member">sys_sem_new</ref>(&amp;conn-&gt;op_completed,<sp/>0)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="689"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gad4a51a28337f89d4b4806e6deb99798d" kindref="member">sys_mbox_free</ref>(&amp;conn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="690"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>free_and_return;</highlight></codeline>
<codeline lineno="691"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="692"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="693"><highlight class="normal"></highlight></codeline>
<codeline lineno="694"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="695"><highlight class="normal"><sp/><sp/><ref refid="group__sys__mbox_1ga64ca1b1ef4c810f4d67595eca4fdfef0" kindref="member">sys_mbox_set_invalid</ref>(&amp;conn-&gt;acceptmbox);</highlight></codeline>
<codeline lineno="696"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="697"><highlight class="normal"><sp/><sp/>conn-&gt;state<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="698"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SOCKET</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="699"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>initialize<sp/>socket<sp/>to<sp/>-1<sp/>since<sp/>0<sp/>is<sp/>a<sp/>valid<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="700"><highlight class="normal"><sp/><sp/>conn-&gt;socket<sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="701"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SOCKET<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="702"><highlight class="normal"><sp/><sp/>conn-&gt;callback<sp/><sp/><sp/><sp/><sp/>=<sp/>callback;</highlight></codeline>
<codeline lineno="703"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="704"><highlight class="normal"><sp/><sp/>conn-&gt;current_msg<sp/><sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="705"><highlight class="normal"><sp/><sp/>conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="706"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="707"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="708"><highlight class="normal"><sp/><sp/>conn-&gt;send_timeout<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="709"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_SNDTIMEO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="710"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="711"><highlight class="normal"><sp/><sp/>conn-&gt;recv_timeout<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="712"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVTIMEO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="713"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="714"><highlight class="normal"><sp/><sp/>conn-&gt;recv_bufsize<sp/>=<sp/><ref refid="lwipopts_8h_1a5dbd0a61f30ae6c6bfbda635095f138d" kindref="member">RECV_BUFSIZE_DEFAULT</ref>;</highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/>conn-&gt;recv_avail<sp/><sp/><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="716"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="717"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/>conn-&gt;linger<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="719"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/>conn-&gt;flags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="721"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>conn;</highlight></codeline>
<codeline lineno="722"><highlight class="normal">free_and_return:</highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_NETCONN,<sp/>conn);</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="725"><highlight class="normal">}</highlight></codeline>
<codeline lineno="726"><highlight class="normal"></highlight></codeline>
<codeline lineno="733"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="734"><highlight class="normal">netconn_free(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn)</highlight></codeline>
<codeline lineno="735"><highlight class="normal">{</highlight></codeline>
<codeline lineno="736"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;PCB<sp/>must<sp/>be<sp/>deallocated<sp/>outside<sp/>this<sp/>function&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;pcb.tcp<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;recvmbox<sp/>must<sp/>be<sp/>deallocated<sp/>before<sp/>calling<sp/>this<sp/>function&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/><sp/><sp/>!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox));</highlight></codeline>
<codeline lineno="739"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="740"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;acceptmbox<sp/>must<sp/>be<sp/>deallocated<sp/>before<sp/>calling<sp/>this<sp/>function&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="741"><highlight class="normal"><sp/><sp/><sp/><sp/>!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;acceptmbox));</highlight></codeline>
<codeline lineno="742"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="743"><highlight class="normal"></highlight></codeline>
<codeline lineno="744"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="745"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1ga4d02e29e5dfa092559efc04dee985822" kindref="member">sys_sem_free</ref>(&amp;conn-&gt;op_completed);</highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1ga6b618ddf0c8e73302f1dae7821661457" kindref="member">sys_sem_set_invalid</ref>(&amp;conn-&gt;op_completed);</highlight></codeline>
<codeline lineno="747"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="748"><highlight class="normal"></highlight></codeline>
<codeline lineno="749"><highlight class="normal"><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_NETCONN,<sp/>conn);</highlight></codeline>
<codeline lineno="750"><highlight class="normal">}</highlight></codeline>
<codeline lineno="751"><highlight class="normal"></highlight></codeline>
<codeline lineno="760"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="761"><highlight class="normal">netconn_drain(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn)</highlight></codeline>
<codeline lineno="762"><highlight class="normal">{</highlight></codeline>
<codeline lineno="763"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*<ref refid="structmem" kindref="compound">mem</ref>;</highlight></codeline>
<codeline lineno="764"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="765"><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="766"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="767"><highlight class="normal"></highlight></codeline>
<codeline lineno="768"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>runs<sp/>in<sp/>tcpip_thread,<sp/>so<sp/>we<sp/>don&apos;t<sp/>need<sp/>to<sp/>lock<sp/>against<sp/>rx<sp/>packets<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="769"><highlight class="normal"></highlight></codeline>
<codeline lineno="770"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Delete<sp/>and<sp/>drain<sp/>the<sp/>recvmbox.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="771"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(<ref refid="sys_8h_1ab7841780b31ba9c0a39a440aad1fca13" kindref="member">sys_mbox_tryfetch</ref>(&amp;conn-&gt;recvmbox,<sp/>&amp;<ref refid="structmem" kindref="compound">mem</ref>)<sp/>!=<sp/><ref refid="sys_8h_1ab0571e67edca0132b144106e9b319ef9" kindref="member">SYS_MBOX_EMPTY</ref>)<sp/>{</highlight></codeline>
<codeline lineno="773"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="774"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="775"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structmem" kindref="compound">mem</ref><sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="776"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref>*)<ref refid="structmem" kindref="compound">mem</ref>;</highlight></codeline>
<codeline lineno="777"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>might<sp/>be<sp/>set<sp/>to<sp/>NULL<sp/>already<sp/>by<sp/>err_tcp()<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="778"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="779"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_recved(conn-&gt;pcb.tcp,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>);</highlight></codeline>
<codeline lineno="780"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="781"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="782"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="784"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="785"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="786"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_delete((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>*)<ref refid="structmem" kindref="compound">mem</ref>);</highlight></codeline>
<codeline lineno="787"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gad4a51a28337f89d4b4806e6deb99798d" kindref="member">sys_mbox_free</ref>(&amp;conn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1ga64ca1b1ef4c810f4d67595eca4fdfef0" kindref="member">sys_mbox_set_invalid</ref>(&amp;conn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="791"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="792"><highlight class="normal"></highlight></codeline>
<codeline lineno="793"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Delete<sp/>and<sp/>drain<sp/>the<sp/>acceptmbox.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="794"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;conn-&gt;acceptmbox))<sp/>{</highlight></codeline>
<codeline lineno="796"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(<ref refid="sys_8h_1ab7841780b31ba9c0a39a440aad1fca13" kindref="member">sys_mbox_tryfetch</ref>(&amp;conn-&gt;acceptmbox,<sp/>&amp;<ref refid="structmem" kindref="compound">mem</ref>)<sp/>!=<sp/><ref refid="sys_8h_1ab0571e67edca0132b144106e9b319ef9" kindref="member">SYS_MBOX_EMPTY</ref>)<sp/>{</highlight></codeline>
<codeline lineno="797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structmem" kindref="compound">mem</ref><sp/>!=<sp/>&amp;netconn_aborted)<sp/>{</highlight></codeline>
<codeline lineno="798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*newconn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)<ref refid="structmem" kindref="compound">mem</ref>;</highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Only<sp/>tcp<sp/>pcbs<sp/>have<sp/>an<sp/>acceptmbox,<sp/>so<sp/>no<sp/>need<sp/>to<sp/>check<sp/>conn-&gt;type<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>might<sp/>be<sp/>set<sp/>to<sp/>NULL<sp/>already<sp/>by<sp/>err_tcp()<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>drain<sp/>recvmbox<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_drain(newconn);</highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(newconn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(newconn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>newconn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="806"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="807"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_free(newconn);</highlight></codeline>
<codeline lineno="808"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="809"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="810"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gad4a51a28337f89d4b4806e6deb99798d" kindref="member">sys_mbox_free</ref>(&amp;conn-&gt;acceptmbox);</highlight></codeline>
<codeline lineno="811"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1ga64ca1b1ef4c810f4d67595eca4fdfef0" kindref="member">sys_mbox_set_invalid</ref>(&amp;conn-&gt;acceptmbox);</highlight></codeline>
<codeline lineno="812"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="813"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="814"><highlight class="normal">}</highlight></codeline>
<codeline lineno="815"><highlight class="normal"></highlight></codeline>
<codeline lineno="816"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="817"><highlight class="normal"></highlight></codeline>
<codeline lineno="824"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="825"><highlight class="normal">lwip_netconn_do_close_internal(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn<sp/><sp/>WRITE_DELAYED_PARAM)</highlight></codeline>
<codeline lineno="826"><highlight class="normal">{</highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="828"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>shut,<sp/>shut_rx,<sp/>shut_tx,<sp/><ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>;</highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>close_finished<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="830"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb*<sp/>tpcb;</highlight></codeline>
<codeline lineno="831"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="832"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>linger_wait_required<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="833"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="834"><highlight class="normal"></highlight></codeline>
<codeline lineno="835"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;invalid<sp/>conn&quot;</highlight><highlight class="normal">,<sp/>(conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="836"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;this<sp/>is<sp/>for<sp/>tcp<sp/>netconns<sp/>only&quot;</highlight><highlight class="normal">,<sp/>(NETCONNTYPE_GROUP(conn-&gt;type)<sp/>==<sp/>NETCONN_TCP));</highlight></codeline>
<codeline lineno="837"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn<sp/>must<sp/>be<sp/>in<sp/>state<sp/>NETCONN_CLOSE&quot;</highlight><highlight class="normal">,<sp/>(conn-&gt;state<sp/>==<sp/>NETCONN_CLOSE));</highlight></codeline>
<codeline lineno="838"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pcb<sp/>already<sp/>closed&quot;</highlight><highlight class="normal">,<sp/>(conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;current_msg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="840"><highlight class="normal"></highlight></codeline>
<codeline lineno="841"><highlight class="normal"><sp/><sp/>tpcb<sp/>=<sp/>conn-&gt;pcb.tcp;</highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/>shut<sp/>=<sp/>conn-&gt;current_msg-&gt;msg.sd.shut;</highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/>shut_rx<sp/>=<sp/>shut<sp/>&amp;<sp/>NETCONN_SHUT_RD;</highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/>shut_tx<sp/>=<sp/>shut<sp/>&amp;<sp/>NETCONN_SHUT_WR;</highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>shutting<sp/>down<sp/>both<sp/>ends<sp/>is<sp/>the<sp/>same<sp/>as<sp/>closing</highlight></codeline>
<codeline lineno="846"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>(also<sp/>if<sp/>RD<sp/>or<sp/>WR<sp/>side<sp/>was<sp/>shut<sp/>down<sp/>before<sp/>already)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="847"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut<sp/>==<sp/>NETCONN_SHUT_RDWR)<sp/>{</highlight></codeline>
<codeline lineno="848"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref><sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="849"><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/>(shut_rx<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="850"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((tpcb-&gt;state<sp/>==<sp/>FIN_WAIT_1)<sp/>||</highlight></codeline>
<codeline lineno="851"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(tpcb-&gt;state<sp/>==<sp/>FIN_WAIT_2)<sp/>||</highlight></codeline>
<codeline lineno="852"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(tpcb-&gt;state<sp/>==<sp/>CLOSING)))<sp/>{</highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref><sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="854"><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/>(shut_tx<sp/>&amp;&amp;<sp/>((tpcb-&gt;flags<sp/>&amp;<sp/>TF_RXCLOSED)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref><sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="858"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="859"><highlight class="normal"></highlight></codeline>
<codeline lineno="860"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>back<sp/>some<sp/>callback<sp/>pointers<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="861"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>)<sp/>{</highlight></codeline>
<codeline lineno="862"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_arg(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="863"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="864"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(tpcb-&gt;state<sp/>==<sp/>LISTEN)<sp/>{</highlight></codeline>
<codeline lineno="865"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_accept(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="866"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="867"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>some<sp/>callbacks<sp/>have<sp/>to<sp/>be<sp/>reset<sp/>if<sp/>tcp_close<sp/>is<sp/>not<sp/>successful<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="868"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut_rx)<sp/>{</highlight></codeline>
<codeline lineno="869"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_recv(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="870"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_accept(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="871"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="872"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut_tx)<sp/>{</highlight></codeline>
<codeline lineno="873"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_sent(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="874"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="875"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>)<sp/>{</highlight></codeline>
<codeline lineno="876"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_poll(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>0);</highlight></codeline>
<codeline lineno="877"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_err(tpcb,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="878"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="879"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="880"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Try<sp/>to<sp/>close<sp/>the<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="881"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>)<sp/>{</highlight></codeline>
<codeline lineno="882"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="883"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>linger<sp/>possibilites<sp/>before<sp/>calling<sp/>tcp_close<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="884"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="885"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>linger<sp/>enabled/required<sp/>at<sp/>all?<sp/>(i.e.<sp/>is<sp/>there<sp/>untransmitted<sp/>data<sp/>left?)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="886"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;linger<sp/>&gt;=<sp/>0)<sp/>&amp;&amp;<sp/>(conn-&gt;pcb.tcp-&gt;unsent<sp/>||<sp/>conn-&gt;pcb.tcp-&gt;unacked))<sp/>{</highlight></codeline>
<codeline lineno="887"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;linger<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="888"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>left<sp/>but<sp/>linger<sp/>prevents<sp/>waiting<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="889"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(tpcb);</highlight></codeline>
<codeline lineno="890"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tpcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="891"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;linger<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="892"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>left<sp/>and<sp/>linger<sp/>says<sp/>we<sp/>should<sp/>wait<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="893"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(netconn_is_nonblocking(conn))<sp/>{</highlight></codeline>
<codeline lineno="894"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>left<sp/>on<sp/>a<sp/>nonblocking<sp/>netconn<sp/>-&gt;<sp/>cannot<sp/>linger<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="895"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab9dcf89d46668b072192278fb907b7ad" kindref="member">ERR_WOULDBLOCK</ref>;</highlight></codeline>
<codeline lineno="896"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)(<ref refid="group__sys__time_1ga11316ac1e77418c6fa4ab8869e3fa199" kindref="member">sys_now</ref>()<sp/>-<sp/>conn-&gt;current_msg-&gt;msg.sd.time_started)<sp/>&gt;=</highlight></codeline>
<codeline lineno="897"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(conn-&gt;linger<sp/>*<sp/>1000))<sp/>{</highlight></codeline>
<codeline lineno="898"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>left<sp/>but<sp/>linger<sp/>timeout<sp/>has<sp/>expired<sp/>(this<sp/>happens<sp/>on<sp/>further</highlight></codeline>
<codeline lineno="899"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>calls<sp/>to<sp/>this<sp/>function<sp/>through<sp/>poll_tcp<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="900"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(tpcb);</highlight></codeline>
<codeline lineno="901"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tpcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="902"><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="903"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>data<sp/>left<sp/>-&gt;<sp/>need<sp/>to<sp/>wait<sp/>for<sp/>ACK<sp/>after<sp/>successful<sp/>close<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="904"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>linger_wait_required<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="905"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="906"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="907"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="908"><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/>&amp;&amp;<sp/>(tpcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>))</highlight></codeline>
<codeline lineno="909"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="910"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="911"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>tcp_close(tpcb);</highlight></codeline>
<codeline lineno="912"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="913"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="914"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>tcp_shutdown(tpcb,<sp/>shut_rx,<sp/>shut_tx);</highlight></codeline>
<codeline lineno="915"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="916"><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="917"><highlight class="normal"><sp/><sp/><sp/><sp/>close_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="918"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="919"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(linger_wait_required)<sp/>{</highlight></codeline>
<codeline lineno="920"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>wait<sp/>for<sp/>ACK<sp/>of<sp/>all<sp/>unsent/unacked<sp/>data<sp/>by<sp/>just<sp/>getting<sp/>called<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="921"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>close_finished<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="922"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>;</highlight></codeline>
<codeline lineno="923"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="924"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="925"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="926"><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_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>)<sp/>{</highlight></codeline>
<codeline lineno="927"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Closing<sp/>failed<sp/>because<sp/>of<sp/>memory<sp/>shortage,<sp/>try<sp/>again<sp/>later.<sp/>Even<sp/>for</highlight></codeline>
<codeline lineno="928"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nonblocking<sp/>netconns,<sp/>we<sp/>have<sp/>to<sp/>wait<sp/>since<sp/>no<sp/>standard<sp/>socket<sp/>application</highlight></codeline>
<codeline lineno="929"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>is<sp/>prepared<sp/>for<sp/>close<sp/>failing<sp/>because<sp/>of<sp/>resource<sp/>shortage.</highlight></codeline>
<codeline lineno="930"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Check<sp/>the<sp/>timeout:<sp/>this<sp/>is<sp/>kind<sp/>of<sp/>an<sp/>lwip<sp/>addition<sp/>to<sp/>the<sp/>standard<sp/>sockets:</highlight></codeline>
<codeline lineno="931"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>we<sp/>wait<sp/>for<sp/>some<sp/>time<sp/>when<sp/>failing<sp/>to<sp/>allocate<sp/>a<sp/>segment<sp/>for<sp/>the<sp/>FIN<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="932"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO<sp/>||<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="933"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref><sp/>close_timeout<sp/>=<sp/><ref refid="lwipopts_8h_1a3e7498d5d2921f0df3792de72f384d36" kindref="member">LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT</ref>;</highlight></codeline>
<codeline lineno="934"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="935"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;send_timeout<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="936"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>close_timeout<sp/>=<sp/>conn-&gt;send_timeout;</highlight></codeline>
<codeline lineno="937"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="938"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_SNDTIMEO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="939"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="940"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;linger<sp/>&gt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="941"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>use<sp/>linger<sp/>timeout<sp/>(seconds)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="942"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>close_timeout<sp/>=<sp/>conn-&gt;linger<sp/>*<sp/>1000U;</highlight></codeline>
<codeline lineno="943"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="944"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="945"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)(<ref refid="group__sys__time_1ga11316ac1e77418c6fa4ab8869e3fa199" kindref="member">sys_now</ref>()<sp/>-<sp/>conn-&gt;current_msg-&gt;msg.sd.time_started)<sp/>&gt;=<sp/>close_timeout)<sp/>{</highlight></codeline>
<codeline lineno="946"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_SNDTIMEO<sp/>||<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="947"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;current_msg-&gt;msg.sd.polls_left<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="948"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_SNDTIMEO<sp/>||<sp/>LWIP_SO_LINGER<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="949"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>close_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="950"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>)<sp/>{</highlight></codeline>
<codeline lineno="951"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>in<sp/>this<sp/>case,<sp/>we<sp/>want<sp/>to<sp/>RST<sp/>the<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="952"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_abort(tpcb);</highlight></codeline>
<codeline lineno="953"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="954"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="955"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="956"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="957"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Closing<sp/>failed<sp/>for<sp/>a<sp/>non-memory<sp/>error:<sp/>give<sp/>up<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="958"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>close_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="959"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="960"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="961"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(close_finished)<sp/>{</highlight></codeline>
<codeline lineno="962"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Closing<sp/>done<sp/>(succeeded,<sp/>non-memory<sp/>error,<sp/>nonblocking<sp/>error<sp/>or<sp/>timeout)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="963"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>op_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="964"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="965"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="966"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="967"><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="968"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="descrip_8h_1a39808045c1781393e845fa51fd2db6e0" kindref="member">close</ref>)<sp/>{</highlight></codeline>
<codeline lineno="969"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>back<sp/>some<sp/>callback<sp/>pointers<sp/>as<sp/>conn<sp/>is<sp/>going<sp/>away<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="970"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="971"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Trigger<sp/>select()<sp/>in<sp/>socket<sp/>layer.<sp/>Make<sp/>sure<sp/>everybody<sp/>notices<sp/>activity</highlight></codeline>
<codeline lineno="972"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>on<sp/>the<sp/>connection,<sp/>error<sp/>first!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="973"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_ERROR,<sp/>0);</highlight></codeline>
<codeline lineno="974"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="975"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut_rx)<sp/>{</highlight></codeline>
<codeline lineno="976"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="977"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="978"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut_tx)<sp/>{</highlight></codeline>
<codeline lineno="979"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="980"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="981"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="982"><highlight class="normal"><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/>err);</highlight></codeline>
<codeline lineno="983"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="984"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(delayed)</highlight></codeline>
<codeline lineno="985"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="986"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="987"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>wake<sp/>up<sp/>the<sp/>application<sp/>task<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="988"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(op_completed_sem);</highlight></codeline>
<codeline lineno="989"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="990"><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="991"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="992"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!close_finished)<sp/>{</highlight></codeline>
<codeline lineno="993"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Closing<sp/>failed<sp/>and<sp/>we<sp/>want<sp/>to<sp/>wait:<sp/>restore<sp/>some<sp/>of<sp/>the<sp/>callbacks<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="994"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Closing<sp/>of<sp/>listen<sp/>pcb<sp/>will<sp/>never<sp/>fail!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="995"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;Closing<sp/>a<sp/>listen<sp/>pcb<sp/>may<sp/>not<sp/>fail!&quot;</highlight><highlight class="normal">,<sp/>(tpcb-&gt;state<sp/>!=<sp/>LISTEN));</highlight></codeline>
<codeline lineno="996"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(shut_tx)<sp/>{</highlight></codeline>
<codeline lineno="997"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_sent(tpcb,<sp/>sent_tcp);</highlight></codeline>
<codeline lineno="998"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="999"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>when<sp/>waiting<sp/>for<sp/>close,<sp/>set<sp/>up<sp/>poll<sp/>interval<sp/>to<sp/>500ms<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1000"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_poll(tpcb,<sp/>poll_tcp,<sp/>1);</highlight></codeline>
<codeline lineno="1001"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_err(tpcb,<sp/>err_tcp);</highlight></codeline>
<codeline lineno="1002"><highlight class="normal"><sp/><sp/><sp/><sp/>tcp_arg(tpcb,<sp/>conn);</highlight></codeline>
<codeline lineno="1003"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>restore<sp/>recv<sp/>callback:<sp/>we<sp/>don&apos;t<sp/>want<sp/>to<sp/>receive<sp/>any<sp/>more<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1004"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1005"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>closing<sp/>didn&apos;t<sp/>succeed,<sp/>we<sp/>get<sp/>called<sp/>again<sp/>either</highlight></codeline>
<codeline lineno="1006"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>from<sp/>poll_tcp<sp/>or<sp/>from<sp/>sent_tcp<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1007"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;err<sp/>!=<sp/>ERR_OK&quot;</highlight><highlight class="normal">,<sp/>err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>);</highlight></codeline>
<codeline lineno="1008"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="1009"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1010"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1011"><highlight class="normal"></highlight></codeline>
<codeline lineno="1018"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1019"><highlight class="normal">lwip_netconn_do_delconn(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1020"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1021"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1022"><highlight class="normal"></highlight></codeline>
<codeline lineno="1023"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_state<sp/>state<sp/>=<sp/>msg-&gt;conn-&gt;state;</highlight></codeline>
<codeline lineno="1024"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;netconn<sp/>state<sp/>error&quot;</highlight><highlight class="normal">,<sp/></highlight><highlight class="comment">/*<sp/>this<sp/>only<sp/>happens<sp/>for<sp/>TCP<sp/>netconns<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1025"><highlight class="normal"><sp/><sp/><sp/><sp/>(state<sp/>==<sp/>NETCONN_NONE)<sp/>||<sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP));</highlight></codeline>
<codeline lineno="1026"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_FULLDUPLEX</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1027"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>In<sp/>full<sp/>duplex<sp/>mode,<sp/>blocking<sp/>write/connect<sp/>is<sp/>aborted<sp/>with<sp/>ERR_CLSD<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1028"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(state<sp/>!=<sp/>NETCONN_NONE)<sp/>{</highlight></codeline>
<codeline lineno="1029"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((state<sp/>==<sp/>NETCONN_WRITE)<sp/>||</highlight></codeline>
<codeline lineno="1030"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((state<sp/>==<sp/>NETCONN_CONNECT)<sp/>&amp;&amp;<sp/>!IN_NONBLOCKING_CONNECT(msg-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="1031"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>close<sp/>requested,<sp/>abort<sp/>running<sp/>write/connect<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1032"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>op_completed_sem;</highlight></codeline>
<codeline lineno="1033"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;msg-&gt;conn-&gt;current_msg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1034"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>op_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(msg-&gt;conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="1035"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>;</highlight></codeline>
<codeline lineno="1036"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1037"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1038"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="1039"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(msg-&gt;conn,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>);</highlight></codeline>
<codeline lineno="1040"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(op_completed_sem);</highlight></codeline>
<codeline lineno="1041"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1042"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1043"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_FULLDUPLEX<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1044"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((state<sp/>!=<sp/>NETCONN_NONE)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1045"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(state<sp/>!=<sp/>NETCONN_LISTEN)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1046"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(state<sp/>!=<sp/>NETCONN_CONNECT))<sp/>||</highlight></codeline>
<codeline lineno="1047"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((state<sp/>==<sp/>NETCONN_CONNECT)<sp/>&amp;&amp;<sp/>!IN_NONBLOCKING_CONNECT(msg-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="1048"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>means<sp/>either<sp/>a<sp/>blocking<sp/>write<sp/>or<sp/>blocking<sp/>connect<sp/>is<sp/>running</highlight></codeline>
<codeline lineno="1049"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(nonblocking<sp/>write<sp/>returns<sp/>and<sp/>sets<sp/>state<sp/>to<sp/>NONE)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1050"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>;</highlight></codeline>
<codeline lineno="1051"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1052"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_FULLDUPLEX<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1053"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1054"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;blocking<sp/>connect<sp/>in<sp/>progress&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1055"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(state<sp/>!=<sp/>NETCONN_CONNECT)<sp/>||<sp/>IN_NONBLOCKING_CONNECT(msg-&gt;conn));</highlight></codeline>
<codeline lineno="1056"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1057"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Drain<sp/>and<sp/>delete<sp/>mboxes<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1058"><highlight class="normal"><sp/><sp/><sp/><sp/>netconn_drain(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1059"><highlight class="normal"></highlight></codeline>
<codeline lineno="1060"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1061"><highlight class="normal"></highlight></codeline>
<codeline lineno="1062"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1063"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1064"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="1065"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>raw_remove(msg-&gt;conn-&gt;pcb.raw);</highlight></codeline>
<codeline lineno="1066"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1067"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1068"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1069"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="1070"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.udp-&gt;recv_arg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1071"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_remove(msg-&gt;conn-&gt;pcb.udp);</highlight></codeline>
<codeline lineno="1072"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1073"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1074"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1075"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="1076"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;already<sp/>writing<sp/>or<sp/>closing&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;current_msg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1077"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="1078"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_CLOSE;</highlight></codeline>
<codeline lineno="1079"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;msg.sd.shut<sp/>=<sp/>NETCONN_SHUT_RDWR;</highlight></codeline>
<codeline lineno="1080"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/>msg;</highlight></codeline>
<codeline lineno="1081"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1082"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lwip_netconn_do_close_internal(msg-&gt;conn,<sp/>0)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1083"><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;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_CLOSE);</highlight></codeline>
<codeline lineno="1084"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1085"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(LWIP_API_MSG_SEM(msg),<sp/>0);</highlight></codeline>
<codeline lineno="1086"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1087"><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;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_NONE);</highlight></codeline>
<codeline lineno="1088"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1089"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1090"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lwip_netconn_do_close_internal(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1091"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1092"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>API_EVENT<sp/>is<sp/>called<sp/>inside<sp/>lwip_netconn_do_close_internal,<sp/>before<sp/>releasing</highlight></codeline>
<codeline lineno="1093"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>application<sp/>thread,<sp/>so<sp/>we<sp/>can<sp/>return<sp/>at<sp/>this<sp/>point!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1094"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1095"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1096"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1097"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1098"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1099"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1100"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1101"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>tcp<sp/>netconns<sp/>don&apos;t<sp/>come<sp/>here!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1102"><highlight class="normal"></highlight></codeline>
<codeline lineno="1103"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>this<sp/>lets<sp/>select<sp/>make<sp/>the<sp/>socket<sp/>readable<sp/>and<sp/>writable,</highlight></codeline>
<codeline lineno="1104"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>which<sp/>is<sp/>wrong!<sp/>errfd<sp/>instead?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1105"><highlight class="normal"><sp/><sp/><sp/><sp/>API_EVENT(msg-&gt;conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="1106"><highlight class="normal"><sp/><sp/><sp/><sp/>API_EVENT(msg-&gt;conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="1107"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1108"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__sem_1gac7ff314270976b80559d043f6098817b" kindref="member">sys_sem_valid</ref>(LWIP_API_MSG_SEM(msg)))<sp/>{</highlight></codeline>
<codeline lineno="1109"><highlight class="normal"><sp/><sp/><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1110"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1111"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1112"><highlight class="normal"></highlight></codeline>
<codeline lineno="1120"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1121"><highlight class="normal">lwip_netconn_do_bind(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1122"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1123"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1124"><highlight class="normal"></highlight></codeline>
<codeline lineno="1125"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(msg-&gt;conn-&gt;last_err))<sp/>{</highlight></codeline>
<codeline lineno="1126"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>msg-&gt;conn-&gt;last_err;</highlight></codeline>
<codeline lineno="1127"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1128"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1129"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1131"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1132"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="1133"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>raw_bind(msg-&gt;conn-&gt;pcb.raw,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr));</highlight></codeline>
<codeline lineno="1134"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1135"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1136"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1137"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="1138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_bind(msg-&gt;conn-&gt;pcb.udp,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr),<sp/>msg-&gt;msg.bc.port);</highlight></codeline>
<codeline lineno="1139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1140"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1141"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="1143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>tcp_bind(msg-&gt;conn-&gt;pcb.tcp,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr),<sp/>msg-&gt;msg.bc.port);</highlight></codeline>
<codeline lineno="1144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1145"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1149"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1150"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1151"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1152"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1153"><highlight class="normal"></highlight></codeline>
<codeline lineno="1154"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1155"><highlight class="normal"></highlight></codeline>
<codeline lineno="1161"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="1162"><highlight class="normal">lwip_netconn_do_connected(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>tcp_pcb<sp/>*pcb,<sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err)</highlight></codeline>
<codeline lineno="1163"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1164"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="1165"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>was_blocking;</highlight></codeline>
<codeline lineno="1166"><highlight class="normal"><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>op_completed_sem<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1167"><highlight class="normal"></highlight></codeline>
<codeline lineno="1168"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(pcb);</highlight></codeline>
<codeline lineno="1169"><highlight class="normal"></highlight></codeline>
<codeline lineno="1170"><highlight class="normal"><sp/><sp/>conn<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*)arg;</highlight></codeline>
<codeline lineno="1171"><highlight class="normal"></highlight></codeline>
<codeline lineno="1172"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1173"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1174"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1175"><highlight class="normal"></highlight></codeline>
<codeline lineno="1176"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;state<sp/>==<sp/>NETCONN_CONNECT&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;state<sp/>==<sp/>NETCONN_CONNECT);</highlight></codeline>
<codeline lineno="1177"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;(conn-&gt;current_msg<sp/>!=<sp/>NULL)<sp/>||<sp/>conn-&gt;in_non_blocking_connect&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1178"><highlight class="normal"><sp/><sp/><sp/><sp/>(conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>IN_NONBLOCKING_CONNECT(conn));</highlight></codeline>
<codeline lineno="1179"><highlight class="normal"></highlight></codeline>
<codeline lineno="1180"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1181"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="1182"><highlight class="normal"><sp/><sp/><sp/><sp/>op_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="1183"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1184"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((NETCONNTYPE_GROUP(conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>&amp;&amp;<sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1185"><highlight class="normal"><sp/><sp/><sp/><sp/>setup_tcp(conn);</highlight></codeline>
<codeline lineno="1186"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1187"><highlight class="normal"><sp/><sp/>was_blocking<sp/>=<sp/>!IN_NONBLOCKING_CONNECT(conn);</highlight></codeline>
<codeline lineno="1188"><highlight class="normal"><sp/><sp/>SET_NONBLOCKING_CONNECT(conn,<sp/>0);</highlight></codeline>
<codeline lineno="1189"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;blocking<sp/>connect<sp/>state<sp/>error&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1190"><highlight class="normal"><sp/><sp/><sp/><sp/>(was_blocking<sp/>&amp;&amp;<sp/>op_completed_sem<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||</highlight></codeline>
<codeline lineno="1191"><highlight class="normal"><sp/><sp/><sp/><sp/>(!was_blocking<sp/>&amp;&amp;<sp/>op_completed_sem<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>));</highlight></codeline>
<codeline lineno="1192"><highlight class="normal"><sp/><sp/>conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1193"><highlight class="normal"><sp/><sp/>conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="1194"><highlight class="normal"><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>);</highlight></codeline>
<codeline lineno="1195"><highlight class="normal"><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="1196"><highlight class="normal"></highlight></codeline>
<codeline lineno="1197"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(was_blocking)<sp/>{</highlight></codeline>
<codeline lineno="1198"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(op_completed_sem);</highlight></codeline>
<codeline lineno="1199"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1200"><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="1201"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1202"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1203"><highlight class="normal"></highlight></codeline>
<codeline lineno="1211"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1212"><highlight class="normal">lwip_netconn_do_connect(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1213"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1214"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1215"><highlight class="normal"></highlight></codeline>
<codeline lineno="1216"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1217"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>may<sp/>happen<sp/>when<sp/>calling<sp/>netconn_connect()<sp/>a<sp/>second<sp/>time<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1218"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>;</highlight></codeline>
<codeline lineno="1219"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1220"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1221"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1222"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="1223"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>raw_connect(msg-&gt;conn-&gt;pcb.raw,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr));</highlight></codeline>
<codeline lineno="1224"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1225"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1226"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1227"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="1228"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_connect(msg-&gt;conn-&gt;pcb.udp,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr),<sp/>msg-&gt;msg.bc.port);</highlight></codeline>
<codeline lineno="1229"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1230"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1231"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1232"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="1233"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Prevent<sp/>connect<sp/>while<sp/>doing<sp/>any<sp/>other<sp/>action.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1234"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_CONNECT)<sp/>{</highlight></codeline>
<codeline lineno="1235"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcae6f9c1e4c18ca844f7934307d4cc30e5" kindref="member">ERR_ALREADY</ref>;</highlight></codeline>
<codeline lineno="1236"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;state<sp/>!=<sp/>NETCONN_NONE)<sp/>{</highlight></codeline>
<codeline lineno="1237"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca8543e1d6422fed7b318d97e08dcbaa33" kindref="member">ERR_ISCONN</ref>;</highlight></codeline>
<codeline lineno="1238"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1239"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>setup_tcp(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1240"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>tcp_connect(msg-&gt;conn-&gt;pcb.tcp,<sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.bc.ipaddr),</highlight></codeline>
<codeline lineno="1241"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;msg.bc.port,<sp/>lwip_netconn_do_connected);</highlight></codeline>
<codeline lineno="1242"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1243"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>non_blocking<sp/>=<sp/>netconn_is_nonblocking(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1244"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_CONNECT;</highlight></codeline>
<codeline lineno="1245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SET_NONBLOCKING_CONNECT(msg-&gt;conn,<sp/>non_blocking);</highlight></codeline>
<codeline lineno="1246"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(non_blocking)<sp/>{</highlight></codeline>
<codeline lineno="1247"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>;</highlight></codeline>
<codeline lineno="1248"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1249"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/>msg;</highlight></codeline>
<codeline lineno="1250"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>sys_sem_signal()<sp/>is<sp/>called<sp/>from<sp/>lwip_netconn_do_connected<sp/>(or<sp/>err_tcp()),</highlight></codeline>
<codeline lineno="1251"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>when<sp/>the<sp/>connection<sp/>is<sp/>established!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1252"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1253"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_CONNECT);</highlight></codeline>
<codeline lineno="1254"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1255"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(LWIP_API_MSG_SEM(msg),<sp/>0);</highlight></codeline>
<codeline lineno="1256"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1257"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>!=<sp/>NETCONN_CONNECT);</highlight></codeline>
<codeline lineno="1258"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1259"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1260"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1261"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1264"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1265"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1266"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;Invalid<sp/>netconn<sp/>type&quot;</highlight><highlight class="normal">,<sp/>0,<sp/></highlight><highlight class="keywordflow">do</highlight><highlight class="normal">{<sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;<sp/>}</highlight><highlight class="keywordflow">while</highlight><highlight class="normal">(0));</highlight></codeline>
<codeline lineno="1267"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1268"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1269"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1270"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>For<sp/>all<sp/>other<sp/>protocols,<sp/>netconn_connect()<sp/>calls<sp/>TCPIP_APIMSG(),</highlight></codeline>
<codeline lineno="1271"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>so<sp/>use<sp/>TCPIP_APIMSG_ACK()<sp/>here.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1272"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1273"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1274"><highlight class="normal"></highlight></codeline>
<codeline lineno="1282"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1283"><highlight class="normal">lwip_netconn_do_disconnect(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1284"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1285"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1286"><highlight class="normal"></highlight></codeline>
<codeline lineno="1287"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1288"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="1289"><highlight class="normal"><sp/><sp/><sp/><sp/>udp_disconnect(msg-&gt;conn-&gt;pcb.udp);</highlight></codeline>
<codeline lineno="1290"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1291"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1292"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1293"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1294"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1295"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1296"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1297"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1298"><highlight class="normal"></highlight></codeline>
<codeline lineno="1299"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1300"><highlight class="normal"></highlight></codeline>
<codeline lineno="1306"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1307"><highlight class="normal">lwip_netconn_do_listen(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1308"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1309"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1310"><highlight class="normal"></highlight></codeline>
<codeline lineno="1311"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(msg-&gt;conn-&gt;last_err))<sp/>{</highlight></codeline>
<codeline lineno="1312"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>msg-&gt;conn-&gt;last_err;</highlight></codeline>
<codeline lineno="1313"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1314"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1315"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1316"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1317"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_NONE)<sp/>{</highlight></codeline>
<codeline lineno="1318"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">tcp_pcb*<sp/>lpcb;</highlight></codeline>
<codeline lineno="1319"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>!=<sp/>CLOSED)<sp/>{</highlight></codeline>
<codeline lineno="1320"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>connection<sp/>is<sp/>not<sp/>closed,<sp/>cannot<sp/>listen<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1321"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1322"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>backlog;</highlight></codeline>
<codeline lineno="1325"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1326"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>backlog<sp/>=<sp/>msg-&gt;msg.lb.backlog;</highlight></codeline>
<codeline lineno="1327"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/><sp/></highlight><highlight class="comment">/*<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1328"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>backlog<sp/>=<sp/><ref refid="lwipopts_8h_1a93cce3f47e33df11248c908d1775bacf" kindref="member">TCP_DEFAULT_LISTEN_BACKLOG</ref>;</highlight></codeline>
<codeline lineno="1329"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1330"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1331"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>&quot;Socket<sp/>API<sp/>like&quot;<sp/>dual-stack<sp/>support:<sp/>If<sp/>IP<sp/>to<sp/>listen<sp/>to<sp/>is<sp/>IP6_ADDR_ANY,</highlight></codeline>
<codeline lineno="1332"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>and<sp/>NETCONN_FLAG_IPV6_V6ONLY<sp/>is<sp/>NOT<sp/>set,<sp/>use<sp/>IP_ANY_TYPE<sp/>to<sp/>listen</highlight></codeline>
<codeline lineno="1333"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1334"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;msg-&gt;conn-&gt;pcb.ip-&gt;local_ip,<sp/>IP6_ADDR_ANY)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1335"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(netconn_get_ipv6only(msg-&gt;conn)<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="1336"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>change<sp/>PCB<sp/>type<sp/>to<sp/>IPADDR_TYPE_ANY<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1337"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(msg-&gt;conn-&gt;pcb.tcp-&gt;local_ip,<sp/><sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cac6b2c99cf920e08efcb55dc40e42944e" kindref="member">IPADDR_TYPE_ANY</ref>);</highlight></codeline>
<codeline lineno="1338"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(msg-&gt;conn-&gt;pcb.tcp-&gt;remote_ip,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cac6b2c99cf920e08efcb55dc40e42944e" kindref="member">IPADDR_TYPE_ANY</ref>);</highlight></codeline>
<codeline lineno="1339"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1340"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_IPV6<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1341"><highlight class="normal"></highlight></codeline>
<codeline lineno="1342"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lpcb<sp/>=<sp/>tcp_listen_with_backlog_and_err(msg-&gt;conn-&gt;pcb.tcp,<sp/>backlog,<sp/>&amp;err);</highlight></codeline>
<codeline lineno="1343"><highlight class="normal"></highlight></codeline>
<codeline lineno="1344"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lpcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>in<sp/>this<sp/>case,<sp/>the<sp/>old<sp/>pcb<sp/>is<sp/>still<sp/>allocated<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1346"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="1347"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1348"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>delete<sp/>the<sp/>recvmbox<sp/>and<sp/>allocate<sp/>the<sp/>acceptmbox<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1349"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;msg-&gt;conn-&gt;recvmbox))<sp/>{</highlight></codeline>
<codeline lineno="1351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1gad4a51a28337f89d4b4806e6deb99798d" kindref="member">sys_mbox_free</ref>(&amp;msg-&gt;conn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="1352"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__mbox_1ga64ca1b1ef4c810f4d67595eca4fdfef0" kindref="member">sys_mbox_set_invalid</ref>(&amp;msg-&gt;conn-&gt;recvmbox);</highlight></codeline>
<codeline lineno="1353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1354"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="group__sys__mbox_1gadf4b8fccb41fe2d76e88bef546e8e8bb" kindref="member">sys_mbox_valid</ref>(&amp;msg-&gt;conn-&gt;acceptmbox))<sp/>{</highlight></codeline>
<codeline lineno="1356"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__sys__mbox_1ga26c015e64c859c9361a6f75c4e6fa829" kindref="member">sys_mbox_new</ref>(&amp;msg-&gt;conn-&gt;acceptmbox,<sp/><ref refid="lwipopts_8h_1a5d5a6e04abe2ec233c7acdb09f992461" kindref="member">DEFAULT_ACCEPTMBOX_SIZE</ref>);</highlight></codeline>
<codeline lineno="1357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_LISTEN;</highlight></codeline>
<codeline lineno="1360"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.tcp<sp/>=<sp/>lpcb;</highlight></codeline>
<codeline lineno="1361"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_arg(msg-&gt;conn-&gt;pcb.tcp,<sp/>msg-&gt;conn);</highlight></codeline>
<codeline lineno="1362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_accept(msg-&gt;conn-&gt;pcb.tcp,<sp/>accept_function);</highlight></codeline>
<codeline lineno="1363"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>since<sp/>the<sp/>old<sp/>pcb<sp/>is<sp/>already<sp/>deallocated,<sp/>free<sp/>lpcb<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_close(lpcb);</highlight></codeline>
<codeline lineno="1366"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.tcp<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1367"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1370"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_LISTEN)<sp/>{</highlight></codeline>
<codeline lineno="1371"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>already<sp/>listening,<sp/>allow<sp/>updating<sp/>of<sp/>the<sp/>backlog<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_backlog_set(msg-&gt;conn-&gt;pcb.tcp,<sp/>msg-&gt;msg.lb.backlog);</highlight></codeline>
<codeline lineno="1374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1375"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1376"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>;</highlight></codeline>
<codeline lineno="1377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1378"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1379"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1380"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1381"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1382"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1383"><highlight class="normal"></highlight></codeline>
<codeline lineno="1390"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1391"><highlight class="normal">lwip_netconn_do_send(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1392"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1393"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1394"><highlight class="normal"></highlight></codeline>
<codeline lineno="1395"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(msg-&gt;conn-&gt;last_err))<sp/>{</highlight></codeline>
<codeline lineno="1396"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>msg-&gt;conn-&gt;last_err;</highlight></codeline>
<codeline lineno="1397"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1398"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1399"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1401"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="1403"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;msg-&gt;msg.b-&gt;addr)<sp/>||<sp/><ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(msg-&gt;msg.b-&gt;addr))<sp/>{</highlight></codeline>
<codeline lineno="1404"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>raw_send(msg-&gt;conn-&gt;pcb.raw,<sp/>msg-&gt;msg.b-&gt;p);</highlight></codeline>
<codeline lineno="1405"><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="1406"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>raw_sendto(msg-&gt;conn-&gt;pcb.raw,<sp/>msg-&gt;msg.b-&gt;p,<sp/>&amp;msg-&gt;msg.b-&gt;addr);</highlight></codeline>
<codeline lineno="1407"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1409"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1410"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1411"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="1412"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;msg-&gt;msg.b-&gt;addr)<sp/>||<sp/><ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(msg-&gt;msg.b-&gt;addr))<sp/>{</highlight></codeline>
<codeline lineno="1414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_send_chksum(msg-&gt;conn-&gt;pcb.udp,<sp/>msg-&gt;msg.b-&gt;p,</highlight></codeline>
<codeline lineno="1415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;msg.b-&gt;flags<sp/>&amp;<sp/>NETBUF_FLAG_CHKSUM,<sp/>msg-&gt;msg.b-&gt;toport_chksum);</highlight></codeline>
<codeline lineno="1416"><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="1417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_sendto_chksum(msg-&gt;conn-&gt;pcb.udp,<sp/>msg-&gt;msg.b-&gt;p,</highlight></codeline>
<codeline lineno="1418"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;msg-&gt;msg.b-&gt;addr,<sp/>msg-&gt;msg.b-&gt;port,</highlight></codeline>
<codeline lineno="1419"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;msg.b-&gt;flags<sp/>&amp;<sp/>NETBUF_FLAG_CHKSUM,<sp/>msg-&gt;msg.b-&gt;toport_chksum);</highlight></codeline>
<codeline lineno="1420"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1421"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1acd8f5aa151cff966fd28368b85f38c05" kindref="member">ip_addr_isany_val</ref>(msg-&gt;msg.b-&gt;addr)<sp/>||<sp/><ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(msg-&gt;msg.b-&gt;addr))<sp/>{</highlight></codeline>
<codeline lineno="1423"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_send(msg-&gt;conn-&gt;pcb.udp,<sp/>msg-&gt;msg.b-&gt;p);</highlight></codeline>
<codeline lineno="1424"><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="1425"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>udp_sendto(msg-&gt;conn-&gt;pcb.udp,<sp/>msg-&gt;msg.b-&gt;p,<sp/>&amp;msg-&gt;msg.b-&gt;addr,<sp/>msg-&gt;msg.b-&gt;port);</highlight></codeline>
<codeline lineno="1426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1427"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1428"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1429"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1430"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1433"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1434"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1435"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1436"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1437"><highlight class="normal"></highlight></codeline>
<codeline lineno="1438"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1439"><highlight class="normal"></highlight></codeline>
<codeline lineno="1445"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1446"><highlight class="normal">lwip_netconn_do_recv(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1447"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1448"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1449"><highlight class="normal"></highlight></codeline>
<codeline lineno="1450"><highlight class="normal"><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1451"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1452"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>remaining<sp/>=<sp/>msg-&gt;msg.r.len;</highlight></codeline>
<codeline lineno="1454"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">do</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>recved<sp/>=<sp/>(remaining<sp/>&gt;<sp/>0xffff)<sp/>?<sp/>0xffff<sp/>:<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)remaining;</highlight></codeline>
<codeline lineno="1456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_recved(msg-&gt;conn-&gt;pcb.tcp,<sp/>recved);</highlight></codeline>
<codeline lineno="1457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>remaining<sp/>-=<sp/>recved;</highlight></codeline>
<codeline lineno="1458"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(remaining<sp/>!=<sp/>0);</highlight></codeline>
<codeline lineno="1459"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1460"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1461"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1462"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1463"><highlight class="normal"></highlight></codeline>
<codeline lineno="1464"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>TCP_LISTEN_BACKLOG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1465"><highlight class="normal"></highlight></codeline>
<codeline lineno="1470"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1471"><highlight class="normal">lwip_netconn_do_accepted(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1472"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1473"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1474"><highlight class="normal"></highlight></codeline>
<codeline lineno="1475"><highlight class="normal"><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1476"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1477"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>tcp_backlog_accepted(msg-&gt;conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="1479"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1480"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1481"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1482"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1483"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>TCP_LISTEN_BACKLOG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1484"><highlight class="normal"></highlight></codeline>
<codeline lineno="1496"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="1497"><highlight class="normal">lwip_netconn_do_writemore(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn<sp/><sp/>WRITE_DELAYED_PARAM)</highlight></codeline>
<codeline lineno="1498"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1499"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1500"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*dataptr;</highlight></codeline>
<codeline lineno="1501"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len,<sp/>available;</highlight></codeline>
<codeline lineno="1502"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>write_finished<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1503"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>diff;</highlight></codeline>
<codeline lineno="1504"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>dontblock;</highlight></codeline>
<codeline lineno="1505"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>apiflags;</highlight></codeline>
<codeline lineno="1506"><highlight class="normal"></highlight></codeline>
<codeline lineno="1507"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1508"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;state<sp/>==<sp/>NETCONN_WRITE&quot;</highlight><highlight class="normal">,<sp/>(conn-&gt;state<sp/>==<sp/>NETCONN_WRITE));</highlight></codeline>
<codeline lineno="1509"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;current_msg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1510"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;pcb.tcp<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1511"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;conn-&gt;write_offset<sp/>&lt;<sp/>conn-&gt;current_msg-&gt;msg.w.len&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1512"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;write_offset<sp/>&lt;<sp/>conn-&gt;current_msg-&gt;msg.w.len);</highlight></codeline>
<codeline lineno="1513"><highlight class="normal"></highlight></codeline>
<codeline lineno="1514"><highlight class="normal"><sp/><sp/>apiflags<sp/>=<sp/>conn-&gt;current_msg-&gt;msg.w.apiflags;</highlight></codeline>
<codeline lineno="1515"><highlight class="normal"><sp/><sp/>dontblock<sp/>=<sp/>netconn_is_nonblocking(conn)<sp/>||<sp/>(apiflags<sp/>&amp;<sp/>NETCONN_DONTBLOCK);</highlight></codeline>
<codeline lineno="1516"><highlight class="normal"></highlight></codeline>
<codeline lineno="1517"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1518"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;send_timeout<sp/>!=<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1519"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)(<ref refid="group__sys__time_1ga11316ac1e77418c6fa4ab8869e3fa199" kindref="member">sys_now</ref>()<sp/>-<sp/>conn-&gt;current_msg-&gt;msg.w.time_started)<sp/>&gt;=<sp/>conn-&gt;send_timeout))<sp/>{</highlight></codeline>
<codeline lineno="1520"><highlight class="normal"><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1521"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;write_offset<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1522"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>nothing<sp/>has<sp/>been<sp/>written<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1523"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab9dcf89d46668b072192278fb907b7ad" kindref="member">ERR_WOULDBLOCK</ref>;</highlight></codeline>
<codeline lineno="1524"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1525"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1526"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>partial<sp/>write<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1527"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1528"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>conn-&gt;write_offset;</highlight></codeline>
<codeline lineno="1529"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1530"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1531"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1532"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_SNDTIMEO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1533"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1534"><highlight class="normal"><sp/><sp/><sp/><sp/>dataptr<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)conn-&gt;current_msg-&gt;msg.w.dataptr<sp/>+<sp/>conn-&gt;write_offset;</highlight></codeline>
<codeline lineno="1535"><highlight class="normal"><sp/><sp/><sp/><sp/>diff<sp/>=<sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>-<sp/>conn-&gt;write_offset;</highlight></codeline>
<codeline lineno="1536"><highlight class="normal"><sp/><sp/><sp/><sp/>if<sp/>(diff<sp/>&gt;<sp/>0xffffUL)<sp/>{<sp/></highlight><highlight class="comment">/*<sp/>max_u16_t<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1537"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>len<sp/>=<sp/>0xffff;</highlight></codeline>
<codeline lineno="1538"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>apiflags<sp/>|=<sp/>TCP_WRITE_FLAG_MORE;</highlight></codeline>
<codeline lineno="1539"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1540"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)diff;</highlight></codeline>
<codeline lineno="1541"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1542"><highlight class="normal"><sp/><sp/><sp/><sp/>available<sp/>=<sp/>tcp_sndbuf(conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="1543"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(available<sp/>&lt;<sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="1544"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>try<sp/>to<sp/>write<sp/>more<sp/>than<sp/>sendbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1545"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>len<sp/>=<sp/>available;</highlight></codeline>
<codeline lineno="1546"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(dontblock)<sp/>{</highlight></codeline>
<codeline lineno="1547"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!len)<sp/>{</highlight></codeline>
<codeline lineno="1548"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab9dcf89d46668b072192278fb907b7ad" kindref="member">ERR_WOULDBLOCK</ref>;</highlight></codeline>
<codeline lineno="1549"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>err_mem;</highlight></codeline>
<codeline lineno="1550"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1551"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1552"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>apiflags<sp/>|=<sp/>TCP_WRITE_FLAG_MORE;</highlight></codeline>
<codeline lineno="1553"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1554"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1555"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;lwip_netconn_do_writemore:<sp/>invalid<sp/>length!&quot;</highlight><highlight class="normal">,<sp/>((conn-&gt;write_offset<sp/>+<sp/>len)<sp/>&lt;=<sp/>conn-&gt;current_msg-&gt;msg.w.len));</highlight></codeline>
<codeline lineno="1556"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>tcp_write(conn-&gt;pcb.tcp,<sp/>dataptr,<sp/>len,<sp/>apiflags);</highlight></codeline>
<codeline lineno="1557"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>OK<sp/>or<sp/>memory<sp/>error,<sp/>check<sp/>available<sp/>space<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1558"><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/>||<sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1559"><highlight class="normal">err_mem:</highlight></codeline>
<codeline lineno="1560"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(dontblock<sp/>&amp;&amp;<sp/>(len<sp/>&lt;<sp/>conn-&gt;current_msg-&gt;msg.w.len))<sp/>{</highlight></codeline>
<codeline lineno="1561"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>non-blocking<sp/>write<sp/>did<sp/>not<sp/>write<sp/>everything:<sp/>mark<sp/>the<sp/>pcb<sp/>non-writable</highlight></codeline>
<codeline lineno="1562"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>let<sp/>poll_tcp<sp/>check<sp/>writable<sp/>space<sp/>to<sp/>mark<sp/>the<sp/>pcb<sp/>writable<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1563"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDMINUS,<sp/>len);</highlight></codeline>
<codeline lineno="1564"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;flags<sp/>|=<sp/>NETCONN_FLAG_CHECK_WRITESPACE;</highlight></codeline>
<codeline lineno="1565"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((tcp_sndbuf(conn-&gt;pcb.tcp)<sp/>&lt;=<sp/><ref refid="lwipopts_8h_1ae5c9866d7cd463ac7b36792182145aec" kindref="member">TCP_SNDLOWAT</ref>)<sp/>||</highlight></codeline>
<codeline lineno="1566"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(tcp_sndqueuelen(conn-&gt;pcb.tcp)<sp/>&gt;=<sp/><ref refid="lwipopts_8h_1a75659867592a6b01c198532ed1b65698" kindref="member">TCP_SNDQUEUELOWAT</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1567"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>queued<sp/>byte-<sp/>or<sp/>pbuf-count<sp/>exceeds<sp/>the<sp/>configured<sp/>low-water<sp/>limit,</highlight></codeline>
<codeline lineno="1568"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>let<sp/>select<sp/>mark<sp/>this<sp/>pcb<sp/>as<sp/>non-writable.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1569"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>API_EVENT(conn,<sp/>NETCONN_EVT_SENDMINUS,<sp/>len);</highlight></codeline>
<codeline lineno="1570"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1571"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1572"><highlight class="normal"></highlight></codeline>
<codeline lineno="1573"><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="1574"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>out_err;</highlight></codeline>
<codeline lineno="1575"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;write_offset<sp/>+=<sp/>len;</highlight></codeline>
<codeline lineno="1576"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((conn-&gt;write_offset<sp/>==<sp/>conn-&gt;current_msg-&gt;msg.w.len)<sp/>||<sp/>dontblock)<sp/>{</highlight></codeline>
<codeline lineno="1577"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>return<sp/>sent<sp/>length<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1578"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>conn-&gt;write_offset;</highlight></codeline>
<codeline lineno="1579"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>everything<sp/>was<sp/>written<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1580"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1581"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1582"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out_err<sp/>=<sp/>tcp_output(conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="1583"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(out_err)<sp/>||<sp/>(out_err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1584"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>tcp_output<sp/>fails<sp/>with<sp/>fatal<sp/>error<sp/>or<sp/>no<sp/>route<sp/>is<sp/>found,</highlight></codeline>
<codeline lineno="1585"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>don&apos;t<sp/>try<sp/>writing<sp/>any<sp/>more<sp/>but<sp/>return<sp/>the<sp/>error</highlight></codeline>
<codeline lineno="1586"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>to<sp/>the<sp/>application<sp/>thread.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>out_err;</highlight></codeline>
<codeline lineno="1588"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1589"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1590"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1591"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1592"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>ERR_MEM,<sp/>we<sp/>wait<sp/>for<sp/>sent_tcp<sp/>or<sp/>poll_tcp<sp/>to<sp/>be<sp/>called.</highlight></codeline>
<codeline lineno="1593"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>For<sp/>blocking<sp/>sockets,<sp/>we<sp/>do<sp/>NOT<sp/>return<sp/>to<sp/>the<sp/>application</highlight></codeline>
<codeline lineno="1594"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>thread,<sp/>since<sp/>ERR_MEM<sp/>is<sp/>only<sp/>a<sp/>temporary<sp/>error!<sp/>Non-blocking</highlight></codeline>
<codeline lineno="1595"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>will<sp/>remain<sp/>non-writable<sp/>until<sp/>sent_tcp/poll_tcp<sp/>is<sp/>called<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1596"><highlight class="normal"></highlight></codeline>
<codeline lineno="1597"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>tcp_write<sp/>returned<sp/>ERR_MEM,<sp/>try<sp/>tcp_output<sp/>anyway<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1598"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>out_err<sp/>=<sp/>tcp_output(conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="1599"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(out_err)<sp/>||<sp/>(out_err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1600"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>tcp_output<sp/>fails<sp/>with<sp/>fatal<sp/>error<sp/>or<sp/>no<sp/>route<sp/>is<sp/>found,</highlight></codeline>
<codeline lineno="1601"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>don&apos;t<sp/>try<sp/>writing<sp/>any<sp/>more<sp/>but<sp/>return<sp/>the<sp/>error</highlight></codeline>
<codeline lineno="1602"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>to<sp/>the<sp/>application<sp/>thread.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1603"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>out_err;</highlight></codeline>
<codeline lineno="1604"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1605"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1606"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(dontblock)<sp/>{</highlight></codeline>
<codeline lineno="1607"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>non-blocking<sp/>write<sp/>is<sp/>done<sp/>on<sp/>ERR_MEM<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1608"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab9dcf89d46668b072192278fb907b7ad" kindref="member">ERR_WOULDBLOCK</ref>;</highlight></codeline>
<codeline lineno="1609"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1610"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1611"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1612"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1613"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>On<sp/>errors<sp/>!=<sp/>ERR_MEM,<sp/>we<sp/>don&apos;t<sp/>try<sp/>writing<sp/>any<sp/>more<sp/>but<sp/>return</highlight></codeline>
<codeline lineno="1614"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>error<sp/>to<sp/>the<sp/>application<sp/>thread.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1615"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>write_finished<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1616"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;msg.w.len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1617"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1618"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1619"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(write_finished)<sp/>{</highlight></codeline>
<codeline lineno="1620"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>everything<sp/>was<sp/>written:<sp/>set<sp/>back<sp/>connection<sp/>state</highlight></codeline>
<codeline lineno="1621"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>and<sp/>back<sp/>to<sp/>application<sp/>task<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1622"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>op_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="1623"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;current_msg-&gt;err<sp/>=<sp/>err;</highlight></codeline>
<codeline lineno="1624"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1625"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1626"><highlight class="normal"><sp/><sp/><sp/><sp/>conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="1627"><highlight class="normal"><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(conn,<sp/>err);</highlight></codeline>
<codeline lineno="1628"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1629"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(delayed)</highlight></codeline>
<codeline lineno="1630"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1631"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="1632"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(op_completed_sem);</highlight></codeline>
<codeline lineno="1633"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1634"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1635"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1636"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1637"><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="1638"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1639"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1640"><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="1641"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1642"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1643"><highlight class="normal"></highlight></codeline>
<codeline lineno="1650"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1651"><highlight class="normal">lwip_netconn_do_write(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1652"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1653"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1654"><highlight class="normal"></highlight></codeline>
<codeline lineno="1655"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(msg-&gt;conn-&gt;last_err))<sp/>{</highlight></codeline>
<codeline lineno="1656"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>msg-&gt;conn-&gt;last_err;</highlight></codeline>
<codeline lineno="1657"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1658"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1659"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1660"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;state<sp/>!=<sp/>NETCONN_NONE)<sp/>{</highlight></codeline>
<codeline lineno="1661"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>netconn<sp/>is<sp/>connecting,<sp/>closing<sp/>or<sp/>in<sp/>blocking<sp/>write<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1662"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>;</highlight></codeline>
<codeline lineno="1663"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1664"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_WRITE;</highlight></codeline>
<codeline lineno="1665"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>set<sp/>all<sp/>the<sp/>variables<sp/>used<sp/>by<sp/>lwip_netconn_do_writemore<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1666"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;already<sp/>writing<sp/>or<sp/>closing&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;current_msg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1667"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="1668"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;msg-&gt;msg.w.len<sp/>!=<sp/>0&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;msg.w.len<sp/>!=<sp/>0);</highlight></codeline>
<codeline lineno="1669"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/>msg;</highlight></codeline>
<codeline lineno="1670"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1671"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1672"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lwip_netconn_do_writemore(msg-&gt;conn,<sp/>0)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1673"><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;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_WRITE);</highlight></codeline>
<codeline lineno="1674"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1675"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(LWIP_API_MSG_SEM(msg),<sp/>0);</highlight></codeline>
<codeline lineno="1676"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1677"><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;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>!=<sp/>NETCONN_WRITE);</highlight></codeline>
<codeline lineno="1678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1679"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1680"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lwip_netconn_do_writemore(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1681"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1682"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>for<sp/>both<sp/>cases:<sp/>if<sp/>lwip_netconn_do_writemore<sp/>was<sp/>called,<sp/>don&apos;t<sp/>ACK<sp/>the<sp/>APIMSG</highlight></codeline>
<codeline lineno="1683"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>since<sp/>lwip_netconn_do_writemore<sp/>ACKs<sp/>it!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1684"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1685"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1686"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1687"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1688"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1689"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1690"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1691"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>(LWIP_UDP<sp/>||<sp/>LWIP_RAW)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1692"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1693"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1694"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>(LWIP_UDP<sp/>||<sp/>LWIP_RAW)<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1695"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1696"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1697"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1698"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1699"><highlight class="normal"></highlight></codeline>
<codeline lineno="1706"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1707"><highlight class="normal">lwip_netconn_do_getaddr(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1708"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1709"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1710"><highlight class="normal"></highlight></codeline>
<codeline lineno="1711"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.ip<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1712"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.ad.local)<sp/>{</highlight></codeline>
<codeline lineno="1713"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(<ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.ipaddr),</highlight></codeline>
<codeline lineno="1714"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.ip-&gt;local_ip);</highlight></codeline>
<codeline lineno="1715"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1716"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(<ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.ipaddr),</highlight></codeline>
<codeline lineno="1717"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;pcb.ip-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1718"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1719"><highlight class="normal"></highlight></codeline>
<codeline lineno="1720"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1721"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1722"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1723"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_RAW:</highlight></codeline>
<codeline lineno="1724"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.ad.local)<sp/>{</highlight></codeline>
<codeline lineno="1725"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.port)<sp/>=<sp/>msg-&gt;conn-&gt;pcb.raw-&gt;protocol;</highlight></codeline>
<codeline lineno="1726"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1727"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>return<sp/>an<sp/>error<sp/>as<sp/>connecting<sp/>is<sp/>only<sp/>a<sp/>helper<sp/>for<sp/>upper<sp/>layers<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1728"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1729"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1730"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1731"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1732"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1733"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_UDP:</highlight></codeline>
<codeline lineno="1734"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.ad.local)<sp/>{</highlight></codeline>
<codeline lineno="1735"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.port)<sp/>=<sp/>msg-&gt;conn-&gt;pcb.udp-&gt;local_port;</highlight></codeline>
<codeline lineno="1736"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1737"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((msg-&gt;conn-&gt;pcb.udp-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_CONNECTED)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1738"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1739"><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="1740"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.port)<sp/>=<sp/>msg-&gt;conn-&gt;pcb.udp-&gt;remote_port;</highlight></codeline>
<codeline lineno="1741"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1742"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1743"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1744"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1745"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1746"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_TCP:</highlight></codeline>
<codeline lineno="1747"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((msg-&gt;msg.ad.local<sp/>==<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1748"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((msg-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>==<sp/>CLOSED)<sp/>||<sp/>(msg-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>==<sp/>LISTEN)))<sp/>{</highlight></codeline>
<codeline lineno="1749"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>is<sp/>not<sp/>connected<sp/>and<sp/>remote<sp/>name<sp/>is<sp/>requested<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1750"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1751"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1752"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;msg.ad.port)<sp/>=<sp/>(msg-&gt;msg.ad.local<sp/>?<sp/>msg-&gt;conn-&gt;pcb.tcp-&gt;local_port<sp/>:<sp/>msg-&gt;conn-&gt;pcb.tcp-&gt;remote_port);</highlight></codeline>
<codeline lineno="1753"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1754"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1755"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1756"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1757"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;invalid<sp/>netconn_type&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="1758"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1759"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1760"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1761"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1762"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1763"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1764"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1765"><highlight class="normal"></highlight></codeline>
<codeline lineno="1773"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1774"><highlight class="normal">lwip_netconn_do_close(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1775"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1776"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1777"><highlight class="normal"></highlight></codeline>
<codeline lineno="1778"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1779"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_state<sp/>state<sp/>=<sp/>msg-&gt;conn-&gt;state;</highlight></codeline>
<codeline lineno="1780"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>First<sp/>check<sp/>if<sp/>this<sp/>is<sp/>a<sp/>TCP<sp/>netconn<sp/>and<sp/>if<sp/>it<sp/>is<sp/>in<sp/>a<sp/>correct<sp/>state</highlight></codeline>
<codeline lineno="1781"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/>(LISTEN<sp/>doesn&apos;t<sp/>support<sp/>half<sp/>shutdown)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1782"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_TCP)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1784"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>((msg-&gt;msg.sd.shut<sp/>==<sp/>NETCONN_SHUT_RDWR)<sp/>||<sp/>(state<sp/>!=<sp/>NETCONN_LISTEN)))<sp/>{</highlight></codeline>
<codeline lineno="1785"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>we<sp/>are<sp/>in<sp/>a<sp/>connected<sp/>state<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1786"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(state<sp/>==<sp/>NETCONN_CONNECT)<sp/>{</highlight></codeline>
<codeline lineno="1787"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>TCP<sp/>connect<sp/>in<sp/>progress:<sp/>cannot<sp/>shutdown<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1788"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1789"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(state<sp/>==<sp/>NETCONN_WRITE)<sp/>{</highlight></codeline>
<codeline lineno="1790"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_FULLDUPLEX</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.sd.shut<sp/>&amp;<sp/>NETCONN_SHUT_WR)<sp/>{</highlight></codeline>
<codeline lineno="1792"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>close<sp/>requested,<sp/>abort<sp/>running<sp/>write<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1793"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*<sp/>write_completed_sem;</highlight></codeline>
<codeline lineno="1794"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;msg-&gt;conn-&gt;current_msg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;current_msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>write_completed_sem<sp/>=<sp/>LWIP_API_MSG_SEM(msg-&gt;conn-&gt;current_msg);</highlight></codeline>
<codeline lineno="1796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>;</highlight></codeline>
<codeline lineno="1797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="1800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>state<sp/>=<sp/>NETCONN_NONE;</highlight></codeline>
<codeline lineno="1801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>NETCONN_SET_SAFE_ERR(msg-&gt;conn,<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>);</highlight></codeline>
<codeline lineno="1802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(write_completed_sem);</highlight></codeline>
<codeline lineno="1803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;msg-&gt;msg.sd.shut<sp/>==<sp/>NETCONN_SHUT_RD&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;msg.sd.shut<sp/>==<sp/>NETCONN_SHUT_RD);</highlight></codeline>
<codeline lineno="1805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>In<sp/>this<sp/>case,<sp/>let<sp/>the<sp/>write<sp/>continue<sp/>and<sp/>do<sp/>not<sp/>interfere<sp/>with</highlight></codeline>
<codeline lineno="1806"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;current_msg<sp/>or<sp/>conn-&gt;state!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1807"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>tcp_shutdown(msg-&gt;conn-&gt;pcb.tcp,<sp/>1,<sp/>0);</highlight></codeline>
<codeline lineno="1808"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1809"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1810"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(state<sp/>==<sp/>NETCONN_NONE)<sp/>{</highlight></codeline>
<codeline lineno="1811"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_FULLDUPLEX<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1812"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>;</highlight></codeline>
<codeline lineno="1813"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1814"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_FULLDUPLEX<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1815"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.sd.shut<sp/>&amp;<sp/>NETCONN_SHUT_RD)<sp/>{</highlight></codeline>
<codeline lineno="1816"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Drain<sp/>and<sp/>delete<sp/>mboxes<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1817"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_drain(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1818"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1819"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;already<sp/>writing<sp/>or<sp/>closing&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;current_msg<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1820"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;write_offset<sp/>==<sp/>0);</highlight></codeline>
<codeline lineno="1821"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;state<sp/>=<sp/>NETCONN_CLOSE;</highlight></codeline>
<codeline lineno="1822"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;conn-&gt;current_msg<sp/>=<sp/>msg;</highlight></codeline>
<codeline lineno="1823"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1824"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lwip_netconn_do_close_internal(msg-&gt;conn,<sp/>0)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1825"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_CLOSE);</highlight></codeline>
<codeline lineno="1826"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1827"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(LWIP_API_MSG_SEM(msg),<sp/>0);</highlight></codeline>
<codeline lineno="1828"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1829"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;state!&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;conn-&gt;state<sp/>==<sp/>NETCONN_NONE);</highlight></codeline>
<codeline lineno="1830"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1831"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1832"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>lwip_netconn_do_close_internal(msg-&gt;conn);</highlight></codeline>
<codeline lineno="1833"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1834"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>for<sp/>tcp<sp/>netconns,<sp/>lwip_netconn_do_close_internal<sp/>ACKs<sp/>the<sp/>message<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1835"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1836"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1837"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1838"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1839"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1840"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1841"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1842"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1843"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1844"><highlight class="normal"></highlight></codeline>
<codeline lineno="1845"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP<sp/>||<sp/>(LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1846"><highlight class="normal"></highlight></codeline>
<codeline lineno="1852"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1853"><highlight class="normal">lwip_netconn_do_join_leave_group(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*m)</highlight></codeline>
<codeline lineno="1854"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1855"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">api_msg*)m;</highlight></codeline>
<codeline lineno="1856"><highlight class="normal"></highlight></codeline>
<codeline lineno="1857"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="group__infrastructure__errors_1gac36f9cda08ffce1f67529a432a046248" kindref="member">ERR_IS_FATAL</ref>(msg-&gt;conn-&gt;last_err))<sp/>{</highlight></codeline>
<codeline lineno="1858"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>msg-&gt;conn-&gt;last_err;</highlight></codeline>
<codeline lineno="1859"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1860"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1861"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(msg-&gt;conn-&gt;type)<sp/>==<sp/>NETCONN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="1862"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1863"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1864"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISIPV6(msg-&gt;conn-&gt;type))<sp/>{</highlight></codeline>
<codeline lineno="1865"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.jl.join_or_leave<sp/>==<sp/>NETCONN_JOIN)<sp/>{</highlight></codeline>
<codeline lineno="1866"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>mld6_joingroup(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.netif_addr)),</highlight></codeline>
<codeline lineno="1867"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.multiaddr)));</highlight></codeline>
<codeline lineno="1868"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1869"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>mld6_leavegroup(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.netif_addr)),</highlight></codeline>
<codeline lineno="1870"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.multiaddr)));</highlight></codeline>
<codeline lineno="1871"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1872"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1873"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1874"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1875"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="1876"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1877"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg.jl.join_or_leave<sp/>==<sp/>NETCONN_JOIN)<sp/>{</highlight></codeline>
<codeline lineno="1878"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>igmp_joingroup(ip_2_ip4(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.netif_addr)),</highlight></codeline>
<codeline lineno="1879"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip_2_ip4(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.multiaddr)));</highlight></codeline>
<codeline lineno="1880"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1881"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/>igmp_leavegroup(ip_2_ip4(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.netif_addr)),</highlight></codeline>
<codeline lineno="1882"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip_2_ip4(<ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;msg.jl.multiaddr)));</highlight></codeline>
<codeline lineno="1883"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1884"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IGMP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1885"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1886"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1887"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>(LWIP_TCP<sp/>||<sp/>LWIP_RAW)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1888"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1889"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1890"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>(LWIP_TCP<sp/>||<sp/>LWIP_RAW)<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1891"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1892"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1893"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg-&gt;err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab0036c51817b5200bfe8157cc4115b27" kindref="member">ERR_CONN</ref>;</highlight></codeline>
<codeline lineno="1894"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1895"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1896"><highlight class="normal"><sp/><sp/>TCPIP_APIMSG_ACK(msg);</highlight></codeline>
<codeline lineno="1897"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1898"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IGMP<sp/>||<sp/>(LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD)<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1899"><highlight class="normal"></highlight></codeline>
<codeline lineno="1900"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_DNS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1901"><highlight class="normal"></highlight></codeline>
<codeline lineno="1906"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1907"><highlight class="normal">lwip_netconn_do_dns_found(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*ipaddr,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg)</highlight></codeline>
<codeline lineno="1908"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1909"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">dns_api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">dns_api_msg*)arg;</highlight></codeline>
<codeline lineno="1910"><highlight class="normal"></highlight></codeline>
<codeline lineno="1911"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>we<sp/>trust<sp/>the<sp/>internal<sp/>implementation<sp/>to<sp/>be<sp/>correct<sp/>:-)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1912"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="1913"><highlight class="normal"></highlight></codeline>
<codeline lineno="1914"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipaddr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1915"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>timeout<sp/>or<sp/>memory<sp/>error<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1916"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;err)<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="1917"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1918"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>address<sp/>was<sp/>resolved<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1919"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;err)<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1920"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;addr)<sp/>=<sp/>*ipaddr;</highlight></codeline>
<codeline lineno="1921"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1922"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>wake<sp/>up<sp/>the<sp/>application<sp/>task<sp/>waiting<sp/>in<sp/>netconn_gethostbyname<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1923"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(<ref refid="tcpip__priv_8h_1a91e803b3c3f0ab89b20d7a85e3e92624" kindref="member">API_EXPR_REF_SEM</ref>(msg-&gt;sem));</highlight></codeline>
<codeline lineno="1924"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1925"><highlight class="normal"></highlight></codeline>
<codeline lineno="1932"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1933"><highlight class="normal">lwip_netconn_do_gethostbyname(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg)</highlight></codeline>
<codeline lineno="1934"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1935"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">dns_api_msg<sp/>*msg<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">dns_api_msg*)arg;</highlight></codeline>
<codeline lineno="1936"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>addrtype<sp/>=</highlight></codeline>
<codeline lineno="1937"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1938"><highlight class="normal"><sp/><sp/><sp/><sp/>msg-&gt;dns_addrtype;</highlight></codeline>
<codeline lineno="1939"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1940"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_DNS_ADDRTYPE_DEFAULT;</highlight></codeline>
<codeline lineno="1941"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1942"><highlight class="normal"></highlight></codeline>
<codeline lineno="1943"><highlight class="normal"><sp/><sp/><ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;err)<sp/>=<sp/>dns_gethostbyname_addrtype(msg-&gt;name,</highlight></codeline>
<codeline lineno="1944"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="tcpip__priv_8h_1a1f3c3ae0938b5510978cbd31560a5797" kindref="member">API_EXPR_REF</ref>(msg-&gt;addr),<sp/>lwip_netconn_do_dns_found,<sp/>msg,<sp/>addrtype);</highlight></codeline>
<codeline lineno="1945"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="tcpip__priv_8h_1a4b2322aa0c1906f84f16acf359f06a92" kindref="member">API_EXPR_DEREF</ref>(msg-&gt;err)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca13e1dd0edca8a27b6abdf1524bde7929" kindref="member">ERR_INPROGRESS</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1946"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>on<sp/>error<sp/>or<sp/>immediate<sp/>success,<sp/>wake<sp/>up<sp/>the<sp/>application</highlight></codeline>
<codeline lineno="1947"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>task<sp/>waiting<sp/>in<sp/>netconn_gethostbyname<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1948"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(<ref refid="tcpip__priv_8h_1a91e803b3c3f0ab89b20d7a85e3e92624" kindref="member">API_EXPR_REF_SEM</ref>(msg-&gt;sem));</highlight></codeline>
<codeline lineno="1949"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1950"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1951"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_DNS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1952"><highlight class="normal"></highlight></codeline>
<codeline lineno="1953"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/net/api/api_msg.c"/>
  </compounddef>
</doxygen>
