<?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="sockets_8c" kind="file" language="C++">
    <compoundname>sockets.c</compoundname>
    <includes refid="kprintf_8h" local="no">lib/kprintf.h</includes>
    <includes refid="opt_8h" local="no">net/opt.h</includes>
    <incdepgraph>
      <node id="10">
        <label>stdarg.h</label>
        <link refid="stdarg_8h"/>
      </node>
      <node id="18">
        <label>ubixos/kpanic.h</label>
        <link refid="kpanic_8h"/>
      </node>
      <node id="17">
        <label>sys/io.h</label>
        <link refid="io_8h"/>
      </node>
      <node id="5">
        <label>sys/select.h</label>
        <link refid="select_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="8" relation="include">
        </childnode>
        <childnode refid="9" relation="include">
        </childnode>
      </node>
      <node id="15">
        <label>net/arch/cc.h</label>
        <link refid="cc_8h"/>
        <childnode refid="16" relation="include">
        </childnode>
      </node>
      <node id="9">
        <label>sys/_sigset.h</label>
        <link refid="__sigset_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="12">
        <label>net/lwipopts.h</label>
        <link refid="lwipopts_8h"/>
      </node>
      <node id="3">
        <label>sys/types.h</label>
        <link refid="include_2sys_2types_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="5" relation="include">
        </childnode>
      </node>
      <node id="14">
        <label>net/arch.h</label>
        <link refid="arch_8h"/>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="15" relation="include">
        </childnode>
        <childnode refid="2" relation="include">
        </childnode>
        <childnode refid="18" relation="include">
        </childnode>
      </node>
      <node id="11">
        <label>net/opt.h</label>
        <link refid="opt_8h"/>
        <childnode refid="12" relation="include">
        </childnode>
        <childnode refid="13" relation="include">
        </childnode>
      </node>
      <node id="2">
        <label>lib/kprintf.h</label>
        <link refid="kprintf_8h"/>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>net/debug.h</label>
        <link refid="debug_8h"/>
        <childnode refid="14" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
      </node>
      <node id="1">
        <label>C:/Dev/git/UbixOS/sys/net/api/sockets.c</label>
        <link refid="sockets_8c"/>
        <childnode refid="2" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
      </node>
      <node id="6">
        <label>sys/cdefs.h</label>
        <link refid="cdefs_8h"/>
      </node>
      <node id="16">
        <label>ubixos/time.h</label>
        <link refid="time_8h"/>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="17" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>sys/_types.h</label>
        <link refid="__types_8h"/>
      </node>
      <node id="7">
        <label>sys/_timespec.h</label>
        <link refid="__timespec_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="8">
        <label>sys/_timeval.h</label>
        <link refid="__timeval_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>Sockets BSD-Like API module </para>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="13"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="14"><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="15"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="16"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="17"><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="18"><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="19"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="20"><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="21"><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="22"><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="23"><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="24"><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="25"><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="26"><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="27"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="28"><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="29"><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="30"><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="31"><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="32"><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="33"><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="34"><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="35"><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="36"><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="37"><highlight class="comment"><sp/>*<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="38"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="39"><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="40"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="41"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Adam<sp/>Dunkels<sp/>&lt;adam@sics.se&gt;</highlight></codeline>
<codeline lineno="42"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="43"><highlight class="comment"><sp/>*<sp/>Improved<sp/>by<sp/>Marc<sp/>Boucher<sp/>&lt;marc@mbsi.ca&gt;<sp/>and<sp/>David<sp/>Haas<sp/>&lt;dhaas@alum.rpi.edu&gt;</highlight></codeline>
<codeline lineno="44"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="45"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="kprintf_8h" kindref="compound">lib/kprintf.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><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="49"><highlight class="normal"></highlight></codeline>
<codeline lineno="50"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SOCKET<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="51"><highlight class="normal"></highlight></codeline>
<codeline lineno="52"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="sockets_8h" kindref="compound">net/sockets.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="api_8h" kindref="compound">net/api.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="sys_8h" kindref="compound">net/sys.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="55"><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="56"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="inet_8h" kindref="compound">net/inet.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><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="58"><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="59"><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="60"><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="61"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="pbuf_8h" kindref="compound">net/pbuf.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="62"><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="63"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="64"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="inet__chksum_8h" kindref="compound">net/inet_chksum.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="65"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="66"><highlight class="normal"></highlight></codeline>
<codeline lineno="67"><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="68"><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>If<sp/>the<sp/>netconn<sp/>API<sp/>is<sp/>not<sp/>required<sp/>publicly,<sp/>then<sp/>we<sp/>include<sp/>the<sp/>necessary</highlight></codeline>
<codeline lineno="70"><highlight class="comment"><sp/><sp/><sp/>files<sp/>here<sp/>to<sp/>get<sp/>the<sp/>implementation<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_NETCONN</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="preprocessor">#undef<sp/>LWIP_NETCONN</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_NETCONN<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="api__msg_8c" kindref="compound">api_msg.c</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="api__lib_8c" kindref="compound">api_lib.c</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="netbuf_8c" kindref="compound">netbuf.c</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="normal"></highlight><highlight class="preprocessor">#undef<sp/>LWIP_NETCONN</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_NETCONN<sp/>0</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP4ADDR_PORT_TO_SOCKADDR(sin,<sp/>ipaddr,<sp/>port)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="83"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin)-&gt;sin_len<sp/>=<sp/>sizeof(struct<sp/>sockaddr_in);<sp/>\</highlight></codeline>
<codeline lineno="84"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin)-&gt;sin_family<sp/>=<sp/>AF_INET;<sp/>\</highlight></codeline>
<codeline lineno="85"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin)-&gt;sin_port<sp/>=<sp/>lwip_htons((port));<sp/>\</highlight></codeline>
<codeline lineno="86"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>inet_addr_from_ip4addr(&amp;(sin)-&gt;sin_addr,<sp/>ipaddr);<sp/>\</highlight></codeline>
<codeline lineno="87"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>memset((sin)-&gt;sin_zero,<sp/>0,<sp/>SIN_ZERO_LEN);<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCKADDR4_TO_IP4ADDR_PORT(sin,<sp/>ipaddr,<sp/>port)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="89"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>inet_addr_to_ip4addr(ip_2_ip4(ipaddr),<sp/>&amp;((sin)-&gt;sin_addr));<sp/>\</highlight></codeline>
<codeline lineno="90"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>(port)<sp/>=<sp/>lwip_ntohs((sin)-&gt;sin_port);<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="92"><highlight class="normal"></highlight></codeline>
<codeline lineno="93"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="94"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IP6ADDR_PORT_TO_SOCKADDR(sin6,<sp/>ipaddr,<sp/>port)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="95"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin6)-&gt;sin6_len<sp/>=<sp/>sizeof(struct<sp/>sockaddr_in6);<sp/>\</highlight></codeline>
<codeline lineno="96"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin6)-&gt;sin6_family<sp/>=<sp/>AF_INET6;<sp/>\</highlight></codeline>
<codeline lineno="97"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin6)-&gt;sin6_port<sp/>=<sp/>lwip_htons((port));<sp/>\</highlight></codeline>
<codeline lineno="98"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin6)-&gt;sin6_flowinfo<sp/>=<sp/>0;<sp/>\</highlight></codeline>
<codeline lineno="99"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>inet6_addr_from_ip6addr(&amp;(sin6)-&gt;sin6_addr,<sp/>ipaddr);<sp/>\</highlight></codeline>
<codeline lineno="100"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>(sin6)-&gt;sin6_scope_id<sp/>=<sp/>0;<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="101"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCKADDR6_TO_IP6ADDR_PORT(sin6,<sp/>ipaddr,<sp/>port)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="102"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>inet6_addr_to_ip6addr(ip_2_ip6(ipaddr),<sp/>&amp;((sin6)-&gt;sin6_addr));<sp/>\</highlight></codeline>
<codeline lineno="103"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>(port)<sp/>=<sp/>lwip_ntohs((sin6)-&gt;sin6_port);<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="104"><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="105"><highlight class="normal"></highlight></codeline>
<codeline lineno="106"><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="107"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>sockaddr_to_ipaddr_port(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr*<sp/>sockaddr,<sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref>*<sp/>ipaddr,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>*<sp/>port);</highlight></codeline>
<codeline lineno="108"><highlight class="normal"></highlight></codeline>
<codeline lineno="109"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_LEN_VALID(namelen)<sp/><sp/>(((namelen)<sp/>==<sp/>sizeof(struct<sp/>sockaddr_in))<sp/>||<sp/>\</highlight></codeline>
<codeline lineno="110"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((namelen)<sp/>==<sp/>sizeof(struct<sp/>sockaddr_in6)))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="111"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_TYPE_VALID(name)<sp/><sp/><sp/><sp/>(((name)-&gt;sa_family<sp/>==<sp/>AF_INET)<sp/>||<sp/>\</highlight></codeline>
<codeline lineno="112"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((name)-&gt;sa_family<sp/>==<sp/>AF_INET6))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="113"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCK_ADDR_TYPE_MATCH(name,<sp/>sock)<sp/>\</highlight></codeline>
<codeline lineno="114"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((((name)-&gt;sa_family<sp/>==<sp/>AF_INET)<sp/>&amp;&amp;<sp/>!(NETCONNTYPE_ISIPV6((sock)-&gt;conn-&gt;type)))<sp/>||<sp/>\</highlight></codeline>
<codeline lineno="115"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(((name)-&gt;sa_family<sp/>==<sp/>AF_INET6)<sp/>&amp;&amp;<sp/>(NETCONNTYPE_ISIPV6((sock)-&gt;conn-&gt;type))))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="116"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IPADDR_PORT_TO_SOCKADDR(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="117"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>if<sp/>(IP_IS_V6(ipaddr))<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="118"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>IP6ADDR_PORT_TO_SOCKADDR((struct<sp/>sockaddr_in6*)(void*)(sockaddr),<sp/>ip_2_ip6(ipaddr),<sp/>port);<sp/>\</highlight></codeline>
<codeline lineno="119"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>}<sp/>else<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="120"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/>IP4ADDR_PORT_TO_SOCKADDR((struct<sp/>sockaddr_in*)(void*)(sockaddr),<sp/>ip_2_ip4(ipaddr),<sp/>port);<sp/>\</highlight></codeline>
<codeline lineno="121"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>}<sp/>}<sp/>while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="122"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCKADDR_TO_IPADDR_PORT(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>sockaddr_to_ipaddr_port(sockaddr,<sp/>ipaddr,<sp/>&amp;(port))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="123"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>DOMAIN_TO_NETCONN_TYPE(domain,<sp/>type)<sp/>(((domain)<sp/>==<sp/>AF_INET)<sp/>?<sp/>\</highlight></codeline>
<codeline lineno="124"><highlight class="preprocessor"><sp/><sp/>(type)<sp/>:<sp/>(enum<sp/>netconn_type)((type)<sp/>|<sp/>NETCONN_TYPE_IPV6))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="125"><highlight class="normal"></highlight><highlight class="preprocessor">#elif<sp/>LWIP_IPV6<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="126"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_LEN_VALID(namelen)<sp/><sp/>((namelen)<sp/>==<sp/>sizeof(struct<sp/>sockaddr_in6))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="127"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_TYPE_VALID(name)<sp/><sp/><sp/><sp/>((name)-&gt;sa_family<sp/>==<sp/>AF_INET6)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="128"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCK_ADDR_TYPE_MATCH(name,<sp/>sock)<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="129"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IPADDR_PORT_TO_SOCKADDR(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>\</highlight></codeline>
<codeline lineno="130"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IP6ADDR_PORT_TO_SOCKADDR((struct<sp/>sockaddr_in6*)(void*)(sockaddr),<sp/>ip_2_ip6(ipaddr),<sp/>port)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="131"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCKADDR_TO_IPADDR_PORT(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>\</highlight></codeline>
<codeline lineno="132"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SOCKADDR6_TO_IP6ADDR_PORT((const<sp/>struct<sp/>sockaddr_in6*)(const<sp/>void*)(sockaddr),<sp/>ipaddr,<sp/>port)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="133"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>DOMAIN_TO_NETCONN_TYPE(domain,<sp/>netconn_type)<sp/>(netconn_type)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="134"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*-&gt;<sp/>LWIP_IPV4:<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_IPV6<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="135"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_LEN_VALID(namelen)<sp/><sp/>((namelen)<sp/>==<sp/>sizeof(struct<sp/>sockaddr_in))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="136"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_TYPE_VALID(name)<sp/><sp/><sp/><sp/>((name)-&gt;sa_family<sp/>==<sp/>AF_INET)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="137"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCK_ADDR_TYPE_MATCH(name,<sp/>sock)<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="138"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IPADDR_PORT_TO_SOCKADDR(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>\</highlight></codeline>
<codeline lineno="139"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IP4ADDR_PORT_TO_SOCKADDR((struct<sp/>sockaddr_in*)(void*)(sockaddr),<sp/>ip_2_ip4(ipaddr),<sp/>port)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="140"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCKADDR_TO_IPADDR_PORT(sockaddr,<sp/>ipaddr,<sp/>port)<sp/>\</highlight></codeline>
<codeline lineno="141"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SOCKADDR4_TO_IP4ADDR_PORT((const<sp/>struct<sp/>sockaddr_in*)(const<sp/>void*)(sockaddr),<sp/>ipaddr,<sp/>port)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="142"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>DOMAIN_TO_NETCONN_TYPE(domain,<sp/>netconn_type)<sp/>(netconn_type)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="143"><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="144"><highlight class="normal"></highlight></codeline>
<codeline lineno="145"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_TYPE_VALID_OR_UNSPEC(name)<sp/><sp/><sp/><sp/>(((name)-&gt;sa_family<sp/>==<sp/>AF_UNSPEC)<sp/>||<sp/>\</highlight></codeline>
<codeline lineno="146"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IS_SOCK_ADDR_TYPE_VALID(name))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SOCK_ADDR_TYPE_MATCH_OR_UNSPEC(name,<sp/>sock)<sp/>(((name)-&gt;sa_family<sp/>==<sp/>AF_UNSPEC)<sp/>||<sp/>\</highlight></codeline>
<codeline lineno="148"><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SOCK_ADDR_TYPE_MATCH(name,<sp/>sock))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>IS_SOCK_ADDR_ALIGNED(name)<sp/><sp/><sp/><sp/><sp/><sp/>((((mem_ptr_t)(name))<sp/>%<sp/>4)<sp/>==<sp/>0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="150"><highlight class="normal"></highlight></codeline>
<codeline lineno="151"><highlight class="normal"></highlight></codeline>
<codeline lineno="152"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SOCKOPT_CHECK_OPTLEN(optlen,<sp/>opttype)<sp/>do<sp/>{<sp/>if<sp/>((optlen)<sp/>&lt;<sp/>sizeof(opttype))<sp/>{<sp/>return<sp/>EINVAL;<sp/>}}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="153"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>optlen,<sp/>opttype)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="154"><highlight class="preprocessor"><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN(optlen,<sp/>opttype);<sp/>\</highlight></codeline>
<codeline lineno="155"><highlight class="preprocessor"><sp/><sp/>if<sp/>((sock)-&gt;conn<sp/>==<sp/>NULL)<sp/>{<sp/>return<sp/>EINVAL;<sp/>}<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="156"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/>opttype)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="157"><highlight class="preprocessor"><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN(optlen,<sp/>opttype);<sp/>\</highlight></codeline>
<codeline lineno="158"><highlight class="preprocessor"><sp/><sp/>if<sp/>(((sock)-&gt;conn<sp/>==<sp/>NULL)<sp/>||<sp/>((sock)-&gt;conn-&gt;pcb.tcp<sp/>==<sp/>NULL))<sp/>{<sp/>return<sp/>EINVAL;<sp/>}<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/>opttype,<sp/>netconntype)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="160"><highlight class="preprocessor"><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/>opttype);<sp/>\</highlight></codeline>
<codeline lineno="161"><highlight class="preprocessor"><sp/><sp/>if<sp/>(NETCONNTYPE_GROUP(netconn_type((sock)-&gt;conn))<sp/>!=<sp/>netconntype)<sp/>{<sp/>return<sp/>ENOPROTOOPT;<sp/>}<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="162"><highlight class="normal"></highlight></codeline>
<codeline lineno="163"><highlight class="normal"></highlight></codeline>
<codeline lineno="164"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(name)<sp/><sp/><sp/><sp/><sp/>API_VAR_REF(name)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="165"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_DECLARE(name)<sp/>API_VAR_DECLARE(struct<sp/>lwip_setgetsockopt_data,<sp/>name)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="166"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_FREE(name)<sp/><sp/><sp/><sp/>API_VAR_FREE(MEMP_SOCKET_SETGETSOCKOPT_DATA,<sp/>name)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="167"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="168"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_ALLOC(name,<sp/>sock)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="169"><highlight class="preprocessor"><sp/><sp/>name<sp/>=<sp/>(struct<sp/>lwip_setgetsockopt_data<sp/>*)memp_malloc(MEMP_SOCKET_SETGETSOCKOPT_DATA);<sp/>\</highlight></codeline>
<codeline lineno="170"><highlight class="preprocessor"><sp/><sp/>if<sp/>(name<sp/>==<sp/>NULL)<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="171"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>ENOMEM);<sp/>\</highlight></codeline>
<codeline lineno="172"><highlight class="preprocessor"><sp/><sp/><sp/><sp/>return<sp/>-1;<sp/>\</highlight></codeline>
<codeline lineno="173"><highlight class="preprocessor"><sp/><sp/>}<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="174"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="175"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_ALLOC(name,<sp/>sock)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="176"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="177"><highlight class="normal"></highlight></codeline>
<codeline lineno="178"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDRCVTIMEO_NONSTANDARD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="179"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE<sp/>int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="180"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_SET(optval,<sp/>val)<sp/>(*(int<sp/>*)(optval)<sp/>=<sp/>(val))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="181"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_GET_MS(optval)<sp/><sp/><sp/>((s32_t)*(const<sp/>int*)(optval))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="182"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="183"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE<sp/>struct<sp/>timeval</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="184"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_SET(optval,<sp/>val)<sp/><sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="185"><highlight class="preprocessor"><sp/><sp/>s32_t<sp/>loc<sp/>=<sp/>(val);<sp/>\</highlight></codeline>
<codeline lineno="186"><highlight class="preprocessor"><sp/><sp/>((struct<sp/>timeval<sp/>*)(optval))-&gt;tv_sec<sp/>=<sp/>(loc)<sp/>/<sp/>1000U;<sp/>\</highlight></codeline>
<codeline lineno="187"><highlight class="preprocessor"><sp/><sp/>((struct<sp/>timeval<sp/>*)(optval))-&gt;tv_usec<sp/>=<sp/>((loc)<sp/>%<sp/>1000U)<sp/>*<sp/>1000U;<sp/>}while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="188"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SO_SNDRCVTIMEO_GET_MS(optval)<sp/>((((const<sp/>struct<sp/>timeval<sp/>*)(optval))-&gt;tv_sec<sp/>*<sp/>1000U)<sp/>+<sp/>(((const<sp/>struct<sp/>timeval<sp/>*)(optval))-&gt;tv_usec<sp/>/<sp/>1000U))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="190"><highlight class="normal"></highlight></codeline>
<codeline lineno="191"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>NUM_SOCKETS<sp/>MEMP_NUM_NETCONN</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="192"><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="preprocessor">#ifndef<sp/>SELWAIT_T</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="197"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SELWAIT_T<sp/>u8_t</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="198"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="199"><highlight class="normal"></highlight></codeline>
<codeline lineno="201"><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>{</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*lastdata;</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>lastoffset;</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>rcvevent;</highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>sendevent;</highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>errevent;</highlight></codeline>
<codeline lineno="217"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="219"><highlight class="normal"><sp/><sp/>SELWAIT_T<sp/>select_waiting;</highlight></codeline>
<codeline lineno="220"><highlight class="normal">};</highlight></codeline>
<codeline lineno="221"><highlight class="normal"></highlight></codeline>
<codeline lineno="222"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="223"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SELECT_SEM_T<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sys_sem_t*</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="224"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SELECT_SEM_PTR(sem)<sp/>(sem)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="225"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="226"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SELECT_SEM_T<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sys_sem_t</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="227"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>SELECT_SEM_PTR(sem)<sp/>(&amp;(sem))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="228"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="229"><highlight class="normal"></highlight></codeline>
<codeline lineno="231"><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>{</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>*next;</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>*prev;</highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*readset;</highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*writeset;</highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*exceptset;</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>sem_signalled;</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/>SELECT_SEM_T<sp/>sem;</highlight></codeline>
<codeline lineno="246"><highlight class="normal">};</highlight></codeline>
<codeline lineno="247"><highlight class="normal"></highlight></codeline>
<codeline lineno="251"><highlight class="keyword">union<sp/></highlight><highlight class="normal">sockaddr_aligned<sp/>{</highlight></codeline>
<codeline lineno="252"><highlight class="normal"><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">sockaddr<sp/>sa;</highlight></codeline>
<codeline lineno="253"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">sockaddr_in6<sp/>sin6;</highlight></codeline>
<codeline lineno="255"><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="256"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">sockaddr_in<sp/>sin;</highlight></codeline>
<codeline lineno="258"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="259"><highlight class="normal">};</highlight></codeline>
<codeline lineno="260"><highlight class="normal"></highlight></codeline>
<codeline lineno="261"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="262"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Define<sp/>the<sp/>number<sp/>of<sp/>IPv4<sp/>multicast<sp/>memberships,<sp/>default<sp/>is<sp/>one<sp/>per<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="263"><highlight class="normal"></highlight><highlight class="preprocessor">#ifndef<sp/>LWIP_SOCKET_MAX_MEMBERSHIPS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="264"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>LWIP_SOCKET_MAX_MEMBERSHIPS<sp/>NUM_SOCKETS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="265"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="266"><highlight class="normal"></highlight></codeline>
<codeline lineno="267"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>This<sp/>is<sp/>to<sp/>keep<sp/>track<sp/>of<sp/>IP_ADD_MEMBERSHIP<sp/>calls<sp/>to<sp/>drop<sp/>the<sp/>membership<sp/>when</highlight></codeline>
<codeline lineno="268"><highlight class="comment"><sp/><sp/><sp/>a<sp/>socket<sp/>is<sp/>closed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="269"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_socket_multicast_pair<sp/>{</highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock*<sp/>sock;</highlight></codeline>
<codeline lineno="273"><highlight class="normal"><sp/><sp/>ip4_addr_t<sp/>if_addr;</highlight></codeline>
<codeline lineno="275"><highlight class="normal"><sp/><sp/>ip4_addr_t<sp/>multi_addr;</highlight></codeline>
<codeline lineno="276"><highlight class="normal">};</highlight></codeline>
<codeline lineno="277"><highlight class="normal"></highlight></codeline>
<codeline lineno="278"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_socket_multicast_pair<sp/>socket_ipv4_multicast_memberships[LWIP_SOCKET_MAX_MEMBERSHIPS];</highlight></codeline>
<codeline lineno="279"><highlight class="normal"></highlight></codeline>
<codeline lineno="280"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><sp/>lwip_socket_register_membership(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*if_addr,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*multi_addr);</highlight></codeline>
<codeline lineno="281"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>lwip_socket_unregister_membership(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*if_addr,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*multi_addr);</highlight></codeline>
<codeline lineno="282"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>lwip_socket_drop_registered_memberships(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s);</highlight></codeline>
<codeline lineno="283"><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="284"><highlight class="normal"></highlight></codeline>
<codeline lineno="286"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>sockets[NUM_SOCKETS];</highlight></codeline>
<codeline lineno="288"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>*select_cb_list;</highlight></codeline>
<codeline lineno="291"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">volatile</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>select_cb_ctr;</highlight></codeline>
<codeline lineno="292"><highlight class="normal"></highlight></codeline>
<codeline lineno="293"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SOCKET_SET_ERRNO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="294"><highlight class="normal"></highlight><highlight class="preprocessor">#ifndef<sp/>set_errno</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="295"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>set_errno(err)<sp/>do<sp/>{<sp/>if<sp/>(err)<sp/>{<sp/>errno<sp/>=<sp/>(err);<sp/>}<sp/>}<sp/>while(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="296"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="297"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SOCKET_SET_ERRNO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="298"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>set_errno(err)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="299"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SOCKET_SET_ERRNO<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="300"><highlight class="normal"></highlight></codeline>
<codeline lineno="301"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>sock_set_errno(sk,<sp/>e)<sp/>do<sp/>{<sp/>\</highlight></codeline>
<codeline lineno="302"><highlight class="preprocessor"><sp/><sp/>const<sp/>int<sp/>sockerr<sp/>=<sp/>(e);<sp/>\</highlight></codeline>
<codeline lineno="303"><highlight class="preprocessor"><sp/><sp/>sk-&gt;err<sp/>=<sp/>(u8_t)sockerr;<sp/>\</highlight></codeline>
<codeline lineno="304"><highlight class="preprocessor"><sp/><sp/>set_errno(sockerr);<sp/>\</highlight></codeline>
<codeline lineno="305"><highlight class="preprocessor">}<sp/>while<sp/>(0)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="306"><highlight class="normal"></highlight></codeline>
<codeline lineno="307"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Forward<sp/>declaration<sp/>of<sp/>some<sp/>functions<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="308"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>event_callback(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn,<sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_evt<sp/>evt,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len);</highlight></codeline>
<codeline lineno="309"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="310"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>lwip_getsockopt_callback(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg);</highlight></codeline>
<codeline lineno="311"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>lwip_setsockopt_callback(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg);</highlight></codeline>
<codeline lineno="312"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="313"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>lwip_getsockopt_impl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>*optlen);</highlight></codeline>
<codeline lineno="314"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>lwip_setsockopt_impl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>optlen);</highlight></codeline>
<codeline lineno="315"><highlight class="normal"></highlight></codeline>
<codeline lineno="316"><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="317"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="318"><highlight class="normal">sockaddr_to_ipaddr_port(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr*<sp/>sockaddr,<sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref>*<sp/>ipaddr,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>*<sp/>port)</highlight></codeline>
<codeline lineno="319"><highlight class="normal">{</highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((sockaddr-&gt;sa_family)<sp/>==<sp/>AF_INET6)<sp/>{</highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/>SOCKADDR6_TO_IP6ADDR_PORT((</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr_in6*)(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)(sockaddr),<sp/>ipaddr,<sp/>*port);</highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/>ipaddr-&gt;type<sp/>=<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585caae510fd8ec7fe405b594b57af61f9a02" kindref="member">IPADDR_TYPE_V6</ref>;</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/>SOCKADDR4_TO_IP4ADDR_PORT((</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr_in*)(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)(sockaddr),<sp/>ipaddr,<sp/>*port);</highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/>ipaddr-&gt;type<sp/>=<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>;</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="327"><highlight class="normal">}</highlight></codeline>
<codeline lineno="328"><highlight class="normal"></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="329"><highlight class="normal"></highlight></codeline>
<codeline lineno="331"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="332"><highlight class="normal">lwip_socket_thread_init(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="333"><highlight class="normal">{</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/>netconn_thread_init();</highlight></codeline>
<codeline lineno="335"><highlight class="normal">}</highlight></codeline>
<codeline lineno="336"><highlight class="normal"></highlight></codeline>
<codeline lineno="338"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="339"><highlight class="normal">lwip_socket_thread_cleanup(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="340"><highlight class="normal">{</highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/>netconn_thread_cleanup();</highlight></codeline>
<codeline lineno="342"><highlight class="normal">}</highlight></codeline>
<codeline lineno="343"><highlight class="normal"></highlight></codeline>
<codeline lineno="350"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*</highlight></codeline>
<codeline lineno="351"><highlight class="normal">get_socket(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline>
<codeline lineno="352"><highlight class="normal">{</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="354"><highlight class="normal"></highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/>s<sp/>-=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;</highlight></codeline>
<codeline lineno="356"><highlight class="normal"></highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((s<sp/>&lt;<sp/>0)<sp/>||<sp/>(s<sp/>&gt;=<sp/>NUM_SOCKETS))<sp/>{</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;get_socket(%d):<sp/>invalid\n&quot;</highlight><highlight class="normal">,<sp/>s<sp/>+<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>));</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1ac54507d66b43ad12f9356257323c0018" kindref="member">EBADF</ref>);</highlight></codeline>
<codeline lineno="360"><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="361"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="362"><highlight class="normal"></highlight></codeline>
<codeline lineno="363"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>&amp;sockets[s];</highlight></codeline>
<codeline lineno="364"><highlight class="normal"></highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock-&gt;conn)<sp/>{</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;get_socket(%d):<sp/>not<sp/>active\n&quot;</highlight><highlight class="normal">,<sp/>s<sp/>+<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>));</highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1ac54507d66b43ad12f9356257323c0018" kindref="member">EBADF</ref>);</highlight></codeline>
<codeline lineno="368"><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="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/>sock;</highlight></codeline>
<codeline lineno="372"><highlight class="normal">}</highlight></codeline>
<codeline lineno="373"><highlight class="normal"></highlight></codeline>
<codeline lineno="380"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*</highlight></codeline>
<codeline lineno="381"><highlight class="normal">tryget_socket(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline>
<codeline lineno="382"><highlight class="normal">{</highlight></codeline>
<codeline lineno="383"><highlight class="normal"><sp/><sp/>s<sp/>-=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((s<sp/>&lt;<sp/>0)<sp/>||<sp/>(s<sp/>&gt;=<sp/>NUM_SOCKETS))<sp/>{</highlight></codeline>
<codeline lineno="385"><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="386"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sockets[s].conn)<sp/>{</highlight></codeline>
<codeline lineno="388"><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="389"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>&amp;sockets[s];</highlight></codeline>
<codeline lineno="391"><highlight class="normal">}</highlight></codeline>
<codeline lineno="392"><highlight class="normal"></highlight></codeline>
<codeline lineno="401"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="402"><highlight class="normal">alloc_socket(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*newconn,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>accepted)</highlight></codeline>
<codeline lineno="403"><highlight class="normal">{</highlight></codeline>
<codeline lineno="404"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a945395fa326214fc9736487242710a90" kindref="member">SYS_ARCH_DECL_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="406"><highlight class="normal"></highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>allocate<sp/>a<sp/>new<sp/>socket<sp/>identifier<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>NUM_SOCKETS;<sp/>++i)<sp/>{</highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Protect<sp/>socket<sp/>array<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="410"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sockets[i].conn<sp/>&amp;&amp;<sp/>(sockets[i].select_waiting<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].conn<sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>newconn;</highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>socket<sp/>is<sp/>not<sp/>yet<sp/>known<sp/>to<sp/>anyone,<sp/>so<sp/>no<sp/>need<sp/>to<sp/>protect</highlight></codeline>
<codeline lineno="414"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>after<sp/>having<sp/>marked<sp/>it<sp/>as<sp/>used.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].lastdata<sp/><sp/><sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].lastoffset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].rcvevent<sp/><sp/><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="419"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>TCP<sp/>sendbuf<sp/>is<sp/>empty,<sp/>but<sp/>the<sp/>socket<sp/>is<sp/>not<sp/>yet<sp/>writable<sp/>until<sp/>connected</highlight></codeline>
<codeline lineno="420"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>(unless<sp/>it<sp/>has<sp/>been<sp/>created<sp/>by<sp/>accept()).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].sendevent<sp/><sp/>=<sp/>(NETCONNTYPE_GROUP(newconn-&gt;type)<sp/>==<sp/>NETCONN_TCP<sp/>?<sp/>(accepted<sp/>!=<sp/>0)<sp/>:<sp/>1);</highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].errevent<sp/><sp/><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="423"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sockets[i].err<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>i<sp/>+<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;</highlight></codeline>
<codeline lineno="425"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="428"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="429"><highlight class="normal">}</highlight></codeline>
<codeline lineno="430"><highlight class="normal"></highlight></codeline>
<codeline lineno="437"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="438"><highlight class="normal">free_socket(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>lwip_sock<sp/>*sock,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>is_tcp)</highlight></codeline>
<codeline lineno="439"><highlight class="normal">{</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*lastdata;</highlight></codeline>
<codeline lineno="441"><highlight class="normal"></highlight></codeline>
<codeline lineno="442"><highlight class="normal"><sp/><sp/>lastdata<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>sock-&gt;lastdata;</highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/>sock-&gt;lastdata<sp/><sp/><sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/>sock-&gt;lastoffset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/>sock-&gt;err<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="446"><highlight class="normal"></highlight></codeline>
<codeline lineno="447"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Protect<sp/>socket<sp/>array<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="448"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a24ff55288a4d9fa28100c78b2f4612f6" kindref="member">SYS_ARCH_SET</ref>(sock-&gt;conn,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="449"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>use<sp/>&apos;sock&apos;<sp/>after<sp/>this<sp/>line,<sp/>as<sp/>another<sp/>task<sp/>might<sp/>have<sp/>allocated<sp/>it<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="450"><highlight class="normal"></highlight></codeline>
<codeline lineno="451"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lastdata<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="452"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_tcp)<sp/>{</highlight></codeline>
<codeline lineno="453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*)lastdata);</highlight></codeline>
<codeline lineno="454"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_delete((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>*)lastdata);</highlight></codeline>
<codeline lineno="456"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="457"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="458"><highlight class="normal">}</highlight></codeline>
<codeline lineno="459"><highlight class="normal"></highlight></codeline>
<codeline lineno="460"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Below<sp/>this,<sp/>the<sp/>well-known<sp/>socket<sp/>functions<sp/>are<sp/>implemented.</highlight></codeline>
<codeline lineno="461"><highlight class="comment"><sp/>*<sp/>Use<sp/>google.com<sp/>or<sp/>opengroup.org<sp/>to<sp/>get<sp/>a<sp/>good<sp/>description<sp/>:-)</highlight></codeline>
<codeline lineno="462"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="463"><highlight class="comment"><sp/>*<sp/>Exceptions<sp/>are<sp/>documented!</highlight></codeline>
<codeline lineno="464"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="465"><highlight class="normal"></highlight></codeline>
<codeline lineno="466"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="467"><highlight class="normal">lwip_accept(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*addr,<sp/>socklen_t<sp/>*addrlen)</highlight></codeline>
<codeline lineno="468"><highlight class="normal">{</highlight></codeline>
<codeline lineno="469"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock,<sp/>*nsock;</highlight></codeline>
<codeline lineno="470"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*newconn;</highlight></codeline>
<codeline lineno="471"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>naddr;</highlight></codeline>
<codeline lineno="472"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>newsock;</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a945395fa326214fc9736487242710a90" kindref="member">SYS_ARCH_DECL_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="476"><highlight class="normal"></highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d)...\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="481"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="482"><highlight class="normal"></highlight></codeline>
<codeline lineno="483"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(netconn_is_nonblocking(sock-&gt;conn)<sp/>&amp;&amp;<sp/>(sock-&gt;rcvevent<sp/>&lt;=<sp/>0))<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_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d):<sp/>returning<sp/>EWOULDBLOCK\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="485"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a4a3a0b3605fd3b2336455062ee8e25f0" kindref="member">EWOULDBLOCK</ref>);</highlight></codeline>
<codeline lineno="486"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="487"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="488"><highlight class="normal"></highlight></codeline>
<codeline lineno="489"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>wait<sp/>for<sp/>a<sp/>new<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="490"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_accept(sock-&gt;conn,<sp/>&amp;newconn);</highlight></codeline>
<codeline lineno="491"><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="492"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d):<sp/>netconn_acept<sp/>failed,<sp/>err=%d\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err));</highlight></codeline>
<codeline lineno="493"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="494"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a4b807895c74cea4d0302bf27725d4b9d" kindref="member">EOPNOTSUPP</ref>);</highlight></codeline>
<codeline lineno="495"><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_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>)<sp/>{</highlight></codeline>
<codeline lineno="496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>);</highlight></codeline>
<codeline lineno="497"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="498"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="499"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="500"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="501"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;newconn<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>newconn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="503"><highlight class="normal"></highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/>newsock<sp/>=<sp/>alloc_socket(newconn,<sp/>1);</highlight></codeline>
<codeline lineno="505"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(newsock<sp/>==<sp/>-1)<sp/>{</highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/><sp/><sp/>netconn_delete(newconn);</highlight></codeline>
<codeline lineno="507"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a5554094b3fb4bb6ebeb0157cb3f82a55" kindref="member">ENFILE</ref>);</highlight></codeline>
<codeline lineno="508"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="509"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="510"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;invalid<sp/>socket<sp/>index&quot;</highlight><highlight class="normal">,<sp/>(newsock<sp/>&gt;=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>)<sp/>&amp;&amp;<sp/>(newsock<sp/>&lt;<sp/>NUM_SOCKETS<sp/>+<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>));</highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;newconn-&gt;callback<sp/>==<sp/>event_callback&quot;</highlight><highlight class="normal">,<sp/>newconn-&gt;callback<sp/>==<sp/>event_callback);</highlight></codeline>
<codeline lineno="512"><highlight class="normal"><sp/><sp/>nsock<sp/>=<sp/>&amp;sockets[newsock<sp/>-<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>];</highlight></codeline>
<codeline lineno="513"><highlight class="normal"></highlight></codeline>
<codeline lineno="514"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>See<sp/>event_callback:<sp/>If<sp/>data<sp/>comes<sp/>in<sp/>right<sp/>away<sp/>after<sp/>an<sp/>accept,<sp/>even</highlight></codeline>
<codeline lineno="515"><highlight class="comment"><sp/><sp/><sp/>*<sp/>though<sp/>the<sp/>server<sp/>task<sp/>might<sp/>not<sp/>have<sp/>created<sp/>a<sp/>new<sp/>socket<sp/>yet.</highlight></codeline>
<codeline lineno="516"><highlight class="comment"><sp/><sp/><sp/>*<sp/>In<sp/>that<sp/>case,<sp/>newconn-&gt;socket<sp/>is<sp/>counted<sp/>down<sp/>(newconn-&gt;socket--),</highlight></codeline>
<codeline lineno="517"><highlight class="comment"><sp/><sp/><sp/>*<sp/>so<sp/>nsock-&gt;rcvevent<sp/>is<sp/>&gt;=<sp/>1<sp/>here!</highlight></codeline>
<codeline lineno="518"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="520"><highlight class="normal"><sp/><sp/>nsock-&gt;rcvevent<sp/>+=<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)(-1<sp/>-<sp/>newconn-&gt;socket);</highlight></codeline>
<codeline lineno="521"><highlight class="normal"><sp/><sp/>newconn-&gt;socket<sp/>=<sp/>newsock;</highlight></codeline>
<codeline lineno="522"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="523"><highlight class="normal"></highlight></codeline>
<codeline lineno="524"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Note<sp/>that<sp/>POSIX<sp/>only<sp/>requires<sp/>us<sp/>to<sp/>check<sp/>addr<sp/>is<sp/>non-NULL.<sp/>addrlen<sp/>must</highlight></codeline>
<codeline lineno="525"><highlight class="comment"><sp/><sp/><sp/>*<sp/>not<sp/>be<sp/>NULL<sp/>if<sp/>addr<sp/>is<sp/>valid.</highlight></codeline>
<codeline lineno="526"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="527"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(addr<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="528"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">union<sp/></highlight><highlight class="normal">sockaddr_aligned<sp/>tempaddr;</highlight></codeline>
<codeline lineno="529"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>IP<sp/>address<sp/>and<sp/>port<sp/>of<sp/>the<sp/>remote<sp/>host<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="530"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_peer(newconn,<sp/>&amp;naddr,<sp/>&amp;port);</highlight></codeline>
<codeline lineno="531"><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="532"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d):<sp/>netconn_peer<sp/>failed,<sp/>err=%d\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err));</highlight></codeline>
<codeline lineno="533"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_delete(newconn);</highlight></codeline>
<codeline lineno="534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free_socket(nsock,<sp/>1);</highlight></codeline>
<codeline lineno="535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="536"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="537"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;addr<sp/>valid<sp/>but<sp/>addrlen<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>addrlen<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="539"><highlight class="normal"></highlight></codeline>
<codeline lineno="540"><highlight class="normal"><sp/><sp/><sp/><sp/>IPADDR_PORT_TO_SOCKADDR(&amp;tempaddr,<sp/>&amp;naddr,<sp/>port);</highlight></codeline>
<codeline lineno="541"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*addrlen<sp/>&gt;<sp/>tempaddr.sa.sa_len)<sp/>{</highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*addrlen<sp/>=<sp/>tempaddr.sa.sa_len;</highlight></codeline>
<codeline lineno="543"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="544"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(addr,<sp/>&amp;tempaddr,<sp/>*addrlen);</highlight></codeline>
<codeline lineno="545"><highlight class="normal"></highlight></codeline>
<codeline lineno="546"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d)<sp/>returning<sp/>new<sp/>sock=%d<sp/>addr=&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>newsock));</highlight></codeline>
<codeline lineno="547"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1ac3d7eec8027db2203117e6f30df8fba5" kindref="member">ip_addr_debug_print_val</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>naddr);</highlight></codeline>
<codeline lineno="548"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>port));</highlight></codeline>
<codeline lineno="549"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="550"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_accept(%d)<sp/>returning<sp/>new<sp/>sock=%d&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>newsock));</highlight></codeline>
<codeline lineno="551"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="552"><highlight class="normal"></highlight></codeline>
<codeline lineno="553"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="554"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>newsock;</highlight></codeline>
<codeline lineno="555"><highlight class="normal">}</highlight></codeline>
<codeline lineno="556"><highlight class="normal"></highlight></codeline>
<codeline lineno="557"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="558"><highlight class="normal">lwip_bind(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>socklen_t<sp/>namelen)</highlight></codeline>
<codeline lineno="559"><highlight class="normal">{</highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>local_addr;</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>local_port;</highlight></codeline>
<codeline lineno="563"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="564"><highlight class="normal"></highlight></codeline>
<codeline lineno="565"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="566"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="567"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="568"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="569"><highlight class="normal"></highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!SOCK_ADDR_TYPE_MATCH(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>sock))<sp/>{</highlight></codeline>
<codeline lineno="571"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>sockaddr<sp/>does<sp/>not<sp/>match<sp/>socket<sp/>type<sp/>(IPv4/IPv6)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>));</highlight></codeline>
<codeline lineno="573"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="574"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="575"><highlight class="normal"></highlight></codeline>
<codeline lineno="576"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>size,<sp/>family<sp/>and<sp/>alignment<sp/>of<sp/>&apos;name&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="577"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_bind:<sp/>invalid<sp/>address&quot;</highlight><highlight class="normal">,<sp/>(IS_SOCK_ADDR_LEN_VALID(namelen)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IS_SOCK_ADDR_TYPE_VALID(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)<sp/>&amp;&amp;<sp/>IS_SOCK_ADDR_ALIGNED(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)),</highlight></codeline>
<codeline lineno="579"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(namelen);</highlight></codeline>
<codeline lineno="581"><highlight class="normal"></highlight></codeline>
<codeline lineno="582"><highlight class="normal"><sp/><sp/>SOCKADDR_TO_IPADDR_PORT(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>&amp;local_addr,<sp/>local_port);</highlight></codeline>
<codeline lineno="583"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_bind(%d,<sp/>addr=&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="584"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1ac3d7eec8027db2203117e6f30df8fba5" kindref="member">ip_addr_debug_print_val</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>local_addr);</highlight></codeline>
<codeline lineno="585"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>local_port));</highlight></codeline>
<codeline lineno="586"><highlight class="normal"></highlight></codeline>
<codeline lineno="587"><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="588"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Unmap<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>addresses<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="589"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a1578e34703e86711a7fb7dcc3857004d" kindref="member">IP_IS_V6_VAL</ref>(local_addr)<sp/>&amp;&amp;<sp/>ip6_addr_isipv4mappedipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;local_addr)))<sp/>{</highlight></codeline>
<codeline lineno="590"><highlight class="normal"><sp/><sp/><sp/><sp/>unmap_ipv4_mapped_ipv6(ip_2_ip4(&amp;local_addr),<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;local_addr));</highlight></codeline>
<codeline lineno="591"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(local_addr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>);</highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="593"><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="594"><highlight class="normal"></highlight></codeline>
<codeline lineno="595"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_bind(sock-&gt;conn,<sp/>&amp;local_addr,<sp/>local_port);</highlight></codeline>
<codeline lineno="596"><highlight class="normal"></highlight></codeline>
<codeline lineno="597"><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="598"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_bind(%d)<sp/>failed,<sp/>err=%d\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err));</highlight></codeline>
<codeline lineno="599"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="600"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="601"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="602"><highlight class="normal"></highlight></codeline>
<codeline lineno="603"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_bind(%d)<sp/>succeeded\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="604"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="605"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="606"><highlight class="normal">}</highlight></codeline>
<codeline lineno="607"><highlight class="normal"></highlight></codeline>
<codeline lineno="608"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="609"><highlight class="normal">lwip_close(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline>
<codeline lineno="610"><highlight class="normal">{</highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>is_tcp<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="613"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="614"><highlight class="normal"></highlight></codeline>
<codeline lineno="615"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_close(%d)\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="616"><highlight class="normal"></highlight></codeline>
<codeline lineno="617"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="619"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="620"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="621"><highlight class="normal"></highlight></codeline>
<codeline lineno="622"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/>is_tcp<sp/>=<sp/>NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP;</highlight></codeline>
<codeline lineno="624"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;sock-&gt;lastdata<sp/>==<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>sock-&gt;lastdata<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="626"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="627"><highlight class="normal"></highlight></codeline>
<codeline lineno="628"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>drop<sp/>all<sp/>possibly<sp/>joined<sp/>IGMP<sp/>memberships<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="630"><highlight class="normal"><sp/><sp/>lwip_socket_drop_registered_memberships(s);</highlight></codeline>
<codeline lineno="631"><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="632"><highlight class="normal"></highlight></codeline>
<codeline lineno="633"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_delete(sock-&gt;conn);</highlight></codeline>
<codeline lineno="634"><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="635"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="636"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="638"><highlight class="normal"></highlight></codeline>
<codeline lineno="639"><highlight class="normal"><sp/><sp/>free_socket(sock,<sp/>is_tcp);</highlight></codeline>
<codeline lineno="640"><highlight class="normal"><sp/><sp/>set_errno(0);</highlight></codeline>
<codeline lineno="641"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="642"><highlight class="normal">}</highlight></codeline>
<codeline lineno="643"><highlight class="normal"></highlight></codeline>
<codeline lineno="644"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="645"><highlight class="normal">lwip_connect(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>socklen_t<sp/>namelen)</highlight></codeline>
<codeline lineno="646"><highlight class="normal">{</highlight></codeline>
<codeline lineno="647"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="648"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="649"><highlight class="normal"></highlight></codeline>
<codeline lineno="650"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="651"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="652"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="653"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="654"><highlight class="normal"></highlight></codeline>
<codeline lineno="655"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!SOCK_ADDR_TYPE_MATCH_OR_UNSPEC(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>sock))<sp/>{</highlight></codeline>
<codeline lineno="656"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>sockaddr<sp/>does<sp/>not<sp/>match<sp/>socket<sp/>type<sp/>(IPv4/IPv6)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="657"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>));</highlight></codeline>
<codeline lineno="658"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="659"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="660"><highlight class="normal"></highlight></codeline>
<codeline lineno="661"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(namelen);</highlight></codeline>
<codeline lineno="662"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>-&gt;sa_family<sp/>==<sp/>AF_UNSPEC)<sp/>{</highlight></codeline>
<codeline lineno="663"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_connect(%d,<sp/>AF_UNSPEC)\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="664"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_disconnect(sock-&gt;conn);</highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="666"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>remote_addr;</highlight></codeline>
<codeline lineno="667"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>remote_port;</highlight></codeline>
<codeline lineno="668"><highlight class="normal"></highlight></codeline>
<codeline lineno="669"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>size,<sp/>family<sp/>and<sp/>alignment<sp/>of<sp/>&apos;name&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="670"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_connect:<sp/>invalid<sp/>address&quot;</highlight><highlight class="normal">,<sp/>IS_SOCK_ADDR_LEN_VALID(namelen)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="671"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IS_SOCK_ADDR_TYPE_VALID_OR_UNSPEC(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)<sp/>&amp;&amp;<sp/>IS_SOCK_ADDR_ALIGNED(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>),</highlight></codeline>
<codeline lineno="672"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="673"><highlight class="normal"></highlight></codeline>
<codeline lineno="674"><highlight class="normal"><sp/><sp/><sp/><sp/>SOCKADDR_TO_IPADDR_PORT(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>&amp;remote_addr,<sp/>remote_port);</highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_connect(%d,<sp/>addr=&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="676"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1ac3d7eec8027db2203117e6f30df8fba5" kindref="member">ip_addr_debug_print_val</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>remote_addr);</highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>remote_port));</highlight></codeline>
<codeline lineno="678"><highlight class="normal"></highlight></codeline>
<codeline lineno="679"><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="680"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Unmap<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>addresses<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a1578e34703e86711a7fb7dcc3857004d" kindref="member">IP_IS_V6_VAL</ref>(remote_addr)<sp/>&amp;&amp;<sp/>ip6_addr_isipv4mappedipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;remote_addr)))<sp/>{</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>unmap_ipv4_mapped_ipv6(ip_2_ip4(&amp;remote_addr),<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;remote_addr));</highlight></codeline>
<codeline lineno="683"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(remote_addr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>);</highlight></codeline>
<codeline lineno="684"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="685"><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="686"><highlight class="normal"></highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_connect(sock-&gt;conn,<sp/>&amp;remote_addr,<sp/>remote_port);</highlight></codeline>
<codeline lineno="688"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="689"><highlight class="normal"></highlight></codeline>
<codeline lineno="690"><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="691"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_connect(%d)<sp/>failed,<sp/>err=%d\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err));</highlight></codeline>
<codeline lineno="692"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="693"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="694"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="695"><highlight class="normal"></highlight></codeline>
<codeline lineno="696"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_connect(%d)<sp/>succeeded\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="697"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="698"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="699"><highlight class="normal">}</highlight></codeline>
<codeline lineno="700"><highlight class="normal"></highlight></codeline>
<codeline lineno="709"><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="710"><highlight class="normal">lwip_listen(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>backlog)</highlight></codeline>
<codeline lineno="711"><highlight class="normal">{</highlight></codeline>
<codeline lineno="712"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="713"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="714"><highlight class="normal"></highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_listen(%d,<sp/>backlog=%d)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>backlog));</highlight></codeline>
<codeline lineno="716"><highlight class="normal"></highlight></codeline>
<codeline lineno="717"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="719"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="721"><highlight class="normal"></highlight></codeline>
<codeline lineno="722"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>limit<sp/>the<sp/>&quot;backlog&quot;<sp/>parameter<sp/>to<sp/>fit<sp/>in<sp/>an<sp/>u8_t<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/>backlog<sp/>=<sp/><ref refid="def_8h_1a748f5df614a3fc989e8900fd229d6e4e" kindref="member">LWIP_MIN</ref>(<ref refid="def_8h_1a21ea174d374106caeafb4aa3a24fbd2b" kindref="member">LWIP_MAX</ref>(backlog,<sp/>0),<sp/>0xff);</highlight></codeline>
<codeline lineno="724"><highlight class="normal"></highlight></codeline>
<codeline lineno="725"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_listen_with_backlog(sock-&gt;conn,<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)backlog);</highlight></codeline>
<codeline lineno="726"><highlight class="normal"></highlight></codeline>
<codeline lineno="727"><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="728"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_listen(%d)<sp/>failed,<sp/>err=%d\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err));</highlight></codeline>
<codeline lineno="729"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="730"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a4b807895c74cea4d0302bf27725d4b9d" kindref="member">EOPNOTSUPP</ref>);</highlight></codeline>
<codeline lineno="731"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="734"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="735"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="736"><highlight class="normal"></highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="739"><highlight class="normal">}</highlight></codeline>
<codeline lineno="740"><highlight class="normal"></highlight></codeline>
<codeline lineno="741"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="742"><highlight class="normal">lwip_recvfrom(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*<ref refid="structmem" kindref="compound">mem</ref>,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags,</highlight></codeline>
<codeline lineno="743"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*from,<sp/>socklen_t<sp/>*fromlen)</highlight></codeline>
<codeline lineno="744"><highlight class="normal">{</highlight></codeline>
<codeline lineno="745"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<ref refid="structbuf" kindref="compound">buf</ref><sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/><sp/><sp/><sp/><sp/><sp/>*p;</highlight></codeline>
<codeline lineno="748"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buflen,<sp/>copylen;</highlight></codeline>
<codeline lineno="749"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>off<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="750"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>done<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="751"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err;</highlight></codeline>
<codeline lineno="752"><highlight class="normal"></highlight></codeline>
<codeline lineno="753"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom(%d,<sp/>%p,<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4cd359b6110f318ef71814587e1df029" kindref="member">SZT_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/><ref refid="structmem" kindref="compound">mem</ref>,<sp/><ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref>,<sp/><ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref>));</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="755"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="756"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="757"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="758"><highlight class="normal"></highlight></codeline>
<codeline lineno="759"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">do</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="760"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom:<sp/>top<sp/>while<sp/>sock-&gt;lastdata=%p\n&quot;</highlight><highlight class="normal">,<sp/>sock-&gt;lastdata));</highlight></codeline>
<codeline lineno="761"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>there<sp/>is<sp/>data<sp/>left<sp/>from<sp/>the<sp/>last<sp/>recv<sp/>operation.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="762"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;lastdata)<sp/>{</highlight></codeline>
<codeline lineno="763"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref><sp/>=<sp/>sock-&gt;lastdata;</highlight></codeline>
<codeline lineno="764"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="765"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>non-blocking<sp/>call,<sp/>then<sp/>check<sp/>first<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="766"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>&amp;<sp/>MSG_DONTWAIT)<sp/>||<sp/>netconn_is_nonblocking(sock-&gt;conn))<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="767"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(sock-&gt;rcvevent<sp/>&lt;=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="768"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(off<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="769"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>already<sp/>received<sp/>data,<sp/>return<sp/>that<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="770"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="771"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>off;</highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="773"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom(%d):<sp/>returning<sp/>EWOULDBLOCK\n&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="774"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a4a3a0b3605fd3b2336455062ee8e25f0" kindref="member">EWOULDBLOCK</ref>);</highlight></codeline>
<codeline lineno="775"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="776"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="777"><highlight class="normal"></highlight></codeline>
<codeline lineno="778"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>data<sp/>was<sp/>left<sp/>from<sp/>the<sp/>previous<sp/>operation,<sp/>so<sp/>we<sp/>try<sp/>to<sp/>get</highlight></codeline>
<codeline lineno="779"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>some<sp/>from<sp/>the<sp/>network.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="780"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="781"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_recv_tcp_pbuf(sock-&gt;conn,<sp/>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>**)&amp;<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="782"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_recv(sock-&gt;conn,<sp/>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>**)&amp;<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="784"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="785"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom:<sp/>netconn_recv<sp/>err=%d,<sp/>netbuf=%p\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="786"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err,<sp/><ref refid="structbuf" kindref="compound">buf</ref>));</highlight></codeline>
<codeline lineno="787"><highlight class="normal"></highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(off<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>)<sp/>{</highlight></codeline>
<codeline lineno="791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>closed<sp/>but<sp/>already<sp/>received<sp/>data,<sp/>ensure<sp/>select<sp/>gets<sp/>the<sp/>FIN,<sp/>too<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="792"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>event_callback(sock-&gt;conn,<sp/>NETCONN_EVT_RCVPLUS,<sp/>0);</highlight></codeline>
<codeline lineno="793"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="794"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>already<sp/>received<sp/>data,<sp/>return<sp/>that<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>off;</highlight></codeline>
<codeline lineno="797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>should<sp/>really<sp/>do<sp/>some<sp/>error<sp/>checking<sp/>here.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom(%d):<sp/>buf<sp/>==<sp/>NULL,<sp/>error<sp/>is<sp/>\&quot;%s\&quot;!\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/><ref refid="err_8h_1ab58c2561ad3b133e625183721b25ba27" kindref="member">lwip_strerr</ref>(err)));</highlight></codeline>
<codeline lineno="801"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="802"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa5176d9fecf8ec43d3bc49f4e6c3f7f5" kindref="member">ERR_CLSD</ref>)<sp/>{</highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="804"><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="805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</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/>}</highlight></codeline>
<codeline lineno="808"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;buf<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/><ref refid="structbuf" kindref="compound">buf</ref><sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="809"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastdata<sp/>=<sp/><ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline>
<codeline lineno="810"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="811"><highlight class="normal"></highlight></codeline>
<codeline lineno="812"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="813"><highlight class="normal"><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><sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline>
<codeline lineno="814"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="815"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>)-&gt;p;</highlight></codeline>
<codeline lineno="816"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="817"><highlight class="normal"><sp/><sp/><sp/><sp/>buflen<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="818"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom:<sp/>buflen=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>len=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4cd359b6110f318ef71814587e1df029" kindref="member">SZT_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>off=%d<sp/>sock-&gt;lastoffset=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="819"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>buflen,<sp/>len,<sp/>off,<sp/>sock-&gt;lastoffset));</highlight></codeline>
<codeline lineno="820"><highlight class="normal"></highlight></codeline>
<codeline lineno="821"><highlight class="normal"><sp/><sp/><sp/><sp/>buflen<sp/>-=<sp/>sock-&gt;lastoffset;</highlight></codeline>
<codeline lineno="822"><highlight class="normal"></highlight></codeline>
<codeline lineno="823"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(len<sp/>&gt;<sp/>buflen)<sp/>{</highlight></codeline>
<codeline lineno="824"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>copylen<sp/>=<sp/>buflen;</highlight></codeline>
<codeline lineno="825"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>copylen<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)len;</highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="828"><highlight class="normal"></highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>the<sp/>contents<sp/>of<sp/>the<sp/>received<sp/>buffer<sp/>into</highlight></codeline>
<codeline lineno="830"><highlight class="comment"><sp/><sp/><sp/><sp/>the<sp/>supplied<sp/>memory<sp/>pointer<sp/>mem<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="831"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gac2f1f58fd36042e82af46f5015720899" kindref="member">pbuf_copy_partial</ref>(p,<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)<ref refid="structmem" kindref="compound">mem</ref><sp/>+<sp/>off,<sp/>copylen,<sp/>sock-&gt;lastoffset);</highlight></codeline>
<codeline lineno="832"><highlight class="normal"></highlight></codeline>
<codeline lineno="833"><highlight class="normal"><sp/><sp/><sp/><sp/>off<sp/>+=<sp/>copylen;</highlight></codeline>
<codeline lineno="834"><highlight class="normal"></highlight></codeline>
<codeline lineno="835"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="836"><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/>copylen,<sp/>len<sp/>would<sp/>underflow&quot;</highlight><highlight class="normal">,<sp/>len<sp/>&gt;=<sp/>copylen);</highlight></codeline>
<codeline lineno="837"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>len<sp/>-=<sp/>copylen;</highlight></codeline>
<codeline lineno="838"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((len<sp/>&lt;=<sp/>0)<sp/>||</highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(p-&gt;<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>&amp;<sp/><ref refid="pbuf_8h_1a018a6499e357f8a1373321f802a82930" kindref="member">PBUF_FLAG_PUSH</ref>)<sp/>||</highlight></codeline>
<codeline lineno="840"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(sock-&gt;rcvevent<sp/>&lt;=<sp/>0)<sp/>||</highlight></codeline>
<codeline lineno="841"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/>MSG_PEEK)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>done<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>done<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="846"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="847"><highlight class="normal"></highlight></codeline>
<codeline lineno="848"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>to<sp/>see<sp/>from<sp/>where<sp/>the<sp/>data<sp/>was.*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="849"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(done)<sp/>{</highlight></codeline>
<codeline lineno="850"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!SOCKETS_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="851"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(from<sp/>&amp;&amp;<sp/>fromlen)</highlight></codeline>
<codeline lineno="852"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>!SOCKETS_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="854"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port;</highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>tmpaddr;</highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*fromaddr;</highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">union<sp/></highlight><highlight class="normal">sockaddr_aligned<sp/>saddr;</highlight></codeline>
<codeline lineno="858"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom(%d):<sp/>addr=&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="859"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="860"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fromaddr<sp/>=<sp/>&amp;tmpaddr;</highlight></codeline>
<codeline lineno="861"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_getaddr(sock-&gt;conn,<sp/>fromaddr,<sp/>&amp;port,<sp/>0);</highlight></codeline>
<codeline lineno="862"><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="863"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>port<sp/>=<sp/>netbuf_fromport((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="864"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fromaddr<sp/>=<sp/>netbuf_fromaddr((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="865"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="866"><highlight class="normal"></highlight></codeline>
<codeline lineno="867"><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="868"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Map<sp/>IPv4<sp/>addresses<sp/>to<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="869"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISIPV6(netconn_type(sock-&gt;conn))<sp/>&amp;&amp;<sp/><ref refid="ip__addr_8h_1abee5dab2191bb0f3355d7f30d1496f24" kindref="member">IP_IS_V4</ref>(fromaddr))<sp/>{</highlight></codeline>
<codeline lineno="870"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_2_ipv4_mapped_ipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(fromaddr),<sp/>ip_2_ip4(fromaddr));</highlight></codeline>
<codeline lineno="871"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a4d435d88b2eaebaea1ef75ee586204fd" kindref="member">IP_SET_TYPE</ref>(fromaddr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585caae510fd8ec7fe405b594b57af61f9a02" kindref="member">IPADDR_TYPE_V6</ref>);</highlight></codeline>
<codeline lineno="872"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="873"><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="874"><highlight class="normal"></highlight></codeline>
<codeline lineno="875"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IPADDR_PORT_TO_SOCKADDR(&amp;saddr,<sp/>fromaddr,<sp/>port);</highlight></codeline>
<codeline lineno="876"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>fromaddr);</highlight></codeline>
<codeline lineno="877"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>len=%d\n&quot;</highlight><highlight class="normal">,<sp/>port,<sp/>off));</highlight></codeline>
<codeline lineno="878"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SOCKETS_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="879"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(from<sp/>&amp;&amp;<sp/>fromlen)</highlight></codeline>
<codeline lineno="880"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SOCKETS_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="881"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="882"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*fromlen<sp/>&gt;<sp/>saddr.sa.sa_len)<sp/>{</highlight></codeline>
<codeline lineno="883"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*fromlen<sp/>=<sp/>saddr.sa.sa_len;</highlight></codeline>
<codeline lineno="884"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="885"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(from,<sp/>&amp;saddr,<sp/>*fromlen);</highlight></codeline>
<codeline lineno="886"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="887"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="888"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="889"><highlight class="normal"></highlight></codeline>
<codeline lineno="890"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we<sp/>don&apos;t<sp/>peek<sp/>the<sp/>incoming<sp/>message...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="891"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((flags<sp/>&amp;<sp/>MSG_PEEK)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="892"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>TCP<sp/>socket,<sp/>check<sp/>if<sp/>there<sp/>is<sp/>data<sp/>left<sp/>in<sp/>the</highlight></codeline>
<codeline lineno="893"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buffer.<sp/>If<sp/>so,<sp/>it<sp/>should<sp/>be<sp/>saved<sp/>in<sp/>the<sp/>sock<sp/>structure<sp/>for<sp/>next</highlight></codeline>
<codeline lineno="894"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>time<sp/>around.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="895"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>&amp;&amp;<sp/>(buflen<sp/>-<sp/>copylen<sp/>&gt;<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="896"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastdata<sp/>=<sp/><ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline>
<codeline lineno="897"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastoffset<sp/>+=<sp/>copylen;</highlight></codeline>
<codeline lineno="898"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom:<sp/>lastdata<sp/>now<sp/>netbuf=%p\n&quot;</highlight><highlight class="normal">,<sp/><ref refid="structbuf" kindref="compound">buf</ref>));</highlight></codeline>
<codeline lineno="899"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="900"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastdata<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="901"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastoffset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="902"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_recvfrom:<sp/>deleting<sp/>netbuf=%p\n&quot;</highlight><highlight class="normal">,<sp/><ref refid="structbuf" kindref="compound">buf</ref>));</highlight></codeline>
<codeline lineno="903"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="904"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="905"><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="906"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_delete((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netbuf<sp/>*)<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="907"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="908"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref><sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="909"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="910"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="911"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(!done);</highlight></codeline>
<codeline lineno="912"><highlight class="normal"></highlight></codeline>
<codeline lineno="913"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="914"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>off;</highlight></codeline>
<codeline lineno="915"><highlight class="normal">}</highlight></codeline>
<codeline lineno="916"><highlight class="normal"></highlight></codeline>
<codeline lineno="917"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="918"><highlight class="normal">lwip_read(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*<ref refid="structmem" kindref="compound">mem</ref>,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len)</highlight></codeline>
<codeline lineno="919"><highlight class="normal">{</highlight></codeline>
<codeline lineno="920"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_recvfrom(s,<sp/><ref refid="structmem" kindref="compound">mem</ref>,<sp/>len,<sp/>0,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="921"><highlight class="normal">}</highlight></codeline>
<codeline lineno="922"><highlight class="normal"></highlight></codeline>
<codeline lineno="923"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="924"><highlight class="normal">lwip_recv(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*<ref refid="structmem" kindref="compound">mem</ref>,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags)</highlight></codeline>
<codeline lineno="925"><highlight class="normal">{</highlight></codeline>
<codeline lineno="926"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_recvfrom(s,<sp/><ref refid="structmem" kindref="compound">mem</ref>,<sp/>len,<sp/>flags,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="927"><highlight class="normal">}</highlight></codeline>
<codeline lineno="928"><highlight class="normal"></highlight></codeline>
<codeline lineno="929"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="930"><highlight class="normal">lwip_send(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>size,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags)</highlight></codeline>
<codeline lineno="931"><highlight class="normal">{</highlight></codeline>
<codeline lineno="932"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="933"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="934"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>write_flags;</highlight></codeline>
<codeline lineno="935"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>written;</highlight></codeline>
<codeline lineno="936"><highlight class="normal"></highlight></codeline>
<codeline lineno="937"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_send(%d,<sp/>data=%p,<sp/>size=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4cd359b6110f318ef71814587e1df029" kindref="member">SZT_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>flags=0x%x)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="938"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>data,<sp/>size,<sp/>flags));</highlight></codeline>
<codeline lineno="939"><highlight class="normal"></highlight></codeline>
<codeline lineno="940"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="941"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="942"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="943"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="944"><highlight class="normal"></highlight></codeline>
<codeline lineno="945"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="946"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>(LWIP_UDP<sp/>||<sp/>LWIP_RAW)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="947"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_sendto(s,<sp/>data,<sp/>size,<sp/>flags,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/>0);</highlight></codeline>
<codeline lineno="948"><highlight class="normal"></highlight><highlight class="preprocessor">#else<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="949"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));</highlight></codeline>
<codeline lineno="950"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="951"><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="952"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="953"><highlight class="normal"></highlight></codeline>
<codeline lineno="954"><highlight class="normal"><sp/><sp/>write_flags<sp/>=<sp/>NETCONN_COPY<sp/>|</highlight></codeline>
<codeline lineno="955"><highlight class="normal"><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/>MSG_MORE)<sp/><sp/><sp/><sp/><sp/>?<sp/>NETCONN_MORE<sp/><sp/><sp/><sp/><sp/><sp/>:<sp/>0)<sp/>|</highlight></codeline>
<codeline lineno="956"><highlight class="normal"><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/>MSG_DONTWAIT)<sp/>?<sp/>NETCONN_DONTBLOCK<sp/>:<sp/>0);</highlight></codeline>
<codeline lineno="957"><highlight class="normal"><sp/><sp/>written<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="958"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_write_partly(sock-&gt;conn,<sp/>data,<sp/>size,<sp/>write_flags,<sp/>&amp;written);</highlight></codeline>
<codeline lineno="959"><highlight class="normal"></highlight></codeline>
<codeline lineno="960"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_send(%d)<sp/>err=%d<sp/>written=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4cd359b6110f318ef71814587e1df029" kindref="member">SZT_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>err,<sp/>written));</highlight></codeline>
<codeline lineno="961"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="962"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref><sp/>?<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)written<sp/>:<sp/>-1);</highlight></codeline>
<codeline lineno="963"><highlight class="normal">}</highlight></codeline>
<codeline lineno="964"><highlight class="normal"></highlight></codeline>
<codeline lineno="965"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="966"><highlight class="normal">lwip_sendmsg(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>msghdr<sp/>*msg,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags)</highlight></codeline>
<codeline lineno="967"><highlight class="normal">{</highlight></codeline>
<codeline lineno="968"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="969"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="970"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="971"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>write_flags;</highlight></codeline>
<codeline lineno="972"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>written;</highlight></codeline>
<codeline lineno="973"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="974"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>size<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="975"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="976"><highlight class="normal"></highlight></codeline>
<codeline lineno="977"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="978"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="979"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="980"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="981"><highlight class="normal"></highlight></codeline>
<codeline lineno="982"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_sendmsg:<sp/>invalid<sp/>msghdr&quot;</highlight><highlight class="normal">,<sp/>msg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,</highlight></codeline>
<codeline lineno="983"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="984"><highlight class="normal"></highlight></codeline>
<codeline lineno="985"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(msg-&gt;msg_control);</highlight></codeline>
<codeline lineno="986"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(msg-&gt;msg_controllen);</highlight></codeline>
<codeline lineno="987"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(msg-&gt;msg_flags);</highlight></codeline>
<codeline lineno="988"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_sendmsg:<sp/>invalid<sp/>msghdr<sp/>iov&quot;</highlight><highlight class="normal">,<sp/>(msg-&gt;msg_iov<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>msg-&gt;msg_iovlen<sp/>!=<sp/>0),</highlight></codeline>
<codeline lineno="989"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="990"><highlight class="normal"></highlight></codeline>
<codeline lineno="991"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="992"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="993"><highlight class="normal"><sp/><sp/><sp/><sp/>write_flags<sp/>=<sp/>NETCONN_COPY<sp/>|</highlight></codeline>
<codeline lineno="994"><highlight class="normal"><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/>MSG_MORE)<sp/><sp/><sp/><sp/><sp/>?<sp/>NETCONN_MORE<sp/><sp/><sp/><sp/><sp/><sp/>:<sp/>0)<sp/>|</highlight></codeline>
<codeline lineno="995"><highlight class="normal"><sp/><sp/><sp/><sp/>((flags<sp/>&amp;<sp/>MSG_DONTWAIT)<sp/>?<sp/>NETCONN_DONTBLOCK<sp/>:<sp/>0);</highlight></codeline>
<codeline lineno="996"><highlight class="normal"></highlight></codeline>
<codeline lineno="997"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>msg-&gt;msg_iovlen;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="998"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>apiflags<sp/>=<sp/>write_flags;</highlight></codeline>
<codeline lineno="999"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(i<sp/>+<sp/>1<sp/>&lt;<sp/>msg-&gt;msg_iovlen)<sp/>{</highlight></codeline>
<codeline lineno="1000"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>apiflags<sp/>|=<sp/>NETCONN_MORE;</highlight></codeline>
<codeline lineno="1001"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1002"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>written<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1003"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_write_partly(sock-&gt;conn,<sp/>msg-&gt;msg_iov[i].iov_base,<sp/>msg-&gt;msg_iov[i].iov_len,<sp/>write_flags,<sp/>&amp;written);</highlight></codeline>
<codeline lineno="1004"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1005"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>size<sp/>+=<sp/>written;</highlight></codeline>
<codeline lineno="1006"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>that<sp/>the<sp/>entire<sp/>IO<sp/>vector<sp/>was<sp/>accepected,<sp/>if<sp/>not<sp/>return<sp/>a<sp/>partial<sp/>write<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1007"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(written<sp/>!=<sp/>msg-&gt;msg_iov[i].iov_len)</highlight></codeline>
<codeline lineno="1008"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1009"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1010"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>none<sp/>of<sp/>this<sp/>IO<sp/>vector<sp/>was<sp/>accepted,<sp/>but<sp/>previous<sp/>was,<sp/>return<sp/>partial<sp/>write<sp/>and<sp/>conceal<sp/>ERR_WOULDBLOCK<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1011"><highlight class="normal"><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/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab9dcf89d46668b072192278fb907b7ad" kindref="member">ERR_WOULDBLOCK</ref><sp/>&amp;&amp;<sp/>size<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1012"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1013"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>let<sp/>ERR_WOULDBLOCK<sp/>persist<sp/>on<sp/>the<sp/>netconn<sp/>since<sp/>we<sp/>are<sp/>returning<sp/>ERR_OK<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1014"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1015"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1016"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>size<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="1017"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1018"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1019"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1020"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1021"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>size;</highlight></codeline>
<codeline lineno="1022"><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="1023"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));</highlight></codeline>
<codeline lineno="1024"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1025"><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="1026"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1027"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>else,<sp/>UDP<sp/>and<sp/>RAW<sp/>NETCONNs<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1028"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP<sp/>||<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1029"><highlight class="normal"><sp/><sp/>{</highlight></codeline>
<codeline lineno="1030"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*chain_buf;</highlight></codeline>
<codeline lineno="1031"><highlight class="normal"></highlight></codeline>
<codeline lineno="1032"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(flags);</highlight></codeline>
<codeline lineno="1033"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_sendmsg:<sp/>invalid<sp/>msghdr<sp/>name&quot;</highlight><highlight class="normal">,<sp/>(((msg-&gt;msg_name<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(msg-&gt;msg_namelen<sp/>==<sp/>0))<sp/>||</highlight></codeline>
<codeline lineno="1034"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IS_SOCK_ADDR_LEN_VALID(msg-&gt;msg_namelen))<sp/>,</highlight></codeline>
<codeline lineno="1035"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="1036"><highlight class="normal"></highlight></codeline>
<codeline lineno="1037"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>initialize<sp/>chain<sp/>buffer<sp/>with<sp/>destination<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1038"><highlight class="normal"><sp/><sp/><sp/><sp/>chain_buf<sp/>=<sp/>netbuf_new();</highlight></codeline>
<codeline lineno="1039"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!chain_buf)<sp/>{</highlight></codeline>
<codeline lineno="1040"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>));</highlight></codeline>
<codeline lineno="1041"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1042"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1043"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg-&gt;msg_name)<sp/>{</highlight></codeline>
<codeline lineno="1044"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>remote_port;</highlight></codeline>
<codeline lineno="1045"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>SOCKADDR_TO_IPADDR_PORT((</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*)msg-&gt;msg_name,<sp/>&amp;chain_buf-&gt;addr,<sp/>remote_port);</highlight></codeline>
<codeline lineno="1046"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_fromport(chain_buf)<sp/>=<sp/>remote_port;</highlight></codeline>
<codeline lineno="1047"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1048"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1049"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>msg-&gt;msg_iovlen;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1050"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>size<sp/>+=<sp/>msg-&gt;msg_iov[i].iov_len;</highlight></codeline>
<codeline lineno="1051"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1052"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Allocate<sp/>a<sp/>new<sp/>netbuf<sp/>and<sp/>copy<sp/>the<sp/>data<sp/>into<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1053"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(netbuf_alloc(chain_buf,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)size)<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1054"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="1055"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1056"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>flatten<sp/>the<sp/>IO<sp/>vectors<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1057"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>offset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1058"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>msg-&gt;msg_iovlen;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1059"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(&amp;((<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)chain_buf-&gt;p-&gt;payload)[offset],<sp/>msg-&gt;msg_iov[i].iov_base,<sp/>msg-&gt;msg_iov[i].iov_len);</highlight></codeline>
<codeline lineno="1060"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>offset<sp/>+=<sp/>msg-&gt;msg_iov[i].iov_len;</highlight></codeline>
<codeline lineno="1061"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1062"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1063"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="1064"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>can<sp/>be<sp/>improved<sp/>by<sp/>using<sp/>LWIP_CHKSUM_COPY()<sp/>and<sp/>aggregating<sp/>the<sp/>checksum<sp/>for<sp/>each<sp/>IO<sp/>vector<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1065"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum<sp/>=<sp/>~<ref refid="inet__chksum_8h_1ab35967a50418358e194e8f80fdc3c865" kindref="member">inet_chksum_pbuf</ref>(chain_buf-&gt;p);</highlight></codeline>
<codeline lineno="1066"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_set_chksum(chain_buf,<sp/>chksum);</highlight></codeline>
<codeline lineno="1067"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1068"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1069"><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="1070"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1071"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1072"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>create<sp/>a<sp/>chained<sp/>netbuf<sp/>from<sp/>the<sp/>IO<sp/>vectors.<sp/>NOTE:<sp/>we<sp/>assemble<sp/>a<sp/>pbuf<sp/>chain</highlight></codeline>
<codeline lineno="1073"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>manually<sp/>to<sp/>avoid<sp/>having<sp/>to<sp/>allocate,<sp/>chain,<sp/>and<sp/>delete<sp/>a<sp/>netbuf<sp/>for<sp/>each<sp/>iov<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1074"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>msg-&gt;msg_iovlen;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1075"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa2ded3594a3977f8bf9cf09552be327b5" kindref="member">PBUF_TRANSPORT</ref>,<sp/>0,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac9b6ba960fdea6f2e8f35c8313b77e4e" kindref="member">PBUF_REF</ref>);</highlight></codeline>
<codeline lineno="1076"><highlight class="normal"><sp/><sp/><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="1077"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;<sp/></highlight><highlight class="comment">/*<sp/>let<sp/>netbuf_delete()<sp/>cleanup<sp/>chain_buf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1078"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1079"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1080"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref><sp/>=<sp/>msg-&gt;msg_iov[i].iov_base;</highlight></codeline>
<codeline lineno="1081"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;iov_len<sp/>&lt;<sp/>u16_t&quot;</highlight><highlight class="normal">,<sp/>msg-&gt;msg_iov[i].iov_len<sp/>&lt;=<sp/>0xFFFF);</highlight></codeline>
<codeline lineno="1082"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)msg-&gt;msg_iov[i].iov_len;</highlight></codeline>
<codeline lineno="1083"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>netbuf<sp/>empty,<sp/>add<sp/>new<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1084"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(chain_buf-&gt;p<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1085"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chain_buf-&gt;p<sp/>=<sp/>chain_buf-&gt;ptr<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="1086"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>add<sp/>pbuf<sp/>to<sp/>existing<sp/>pbuf<sp/>chain<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1087"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1088"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga82429084fe29015509c9b4a072707cd4" kindref="member">pbuf_cat</ref>(chain_buf-&gt;p,<sp/>p);</highlight></codeline>
<codeline lineno="1089"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1090"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1091"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>save<sp/>size<sp/>of<sp/>total<sp/>chain<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1092"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1093"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>size<sp/>=<sp/>netbuf_len(chain_buf);</highlight></codeline>
<codeline lineno="1094"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1095"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1096"><highlight class="normal"></highlight></codeline>
<codeline lineno="1097"><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="1098"><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="1099"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Unmap<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>addresses<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a1578e34703e86711a7fb7dcc3857004d" kindref="member">IP_IS_V6_VAL</ref>(chain_buf-&gt;addr)<sp/>&amp;&amp;<sp/>ip6_addr_isipv4mappedipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;chain_buf-&gt;addr)))<sp/>{</highlight></codeline>
<codeline lineno="1101"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>unmap_ipv4_mapped_ipv6(ip_2_ip4(&amp;chain_buf-&gt;addr),<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;chain_buf-&gt;addr));</highlight></codeline>
<codeline lineno="1102"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(chain_buf-&gt;addr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>);</highlight></codeline>
<codeline lineno="1103"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1104"><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="1105"><highlight class="normal"></highlight></codeline>
<codeline lineno="1106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>the<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1107"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_send(sock-&gt;conn,<sp/>chain_buf);</highlight></codeline>
<codeline lineno="1108"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1109"><highlight class="normal"></highlight></codeline>
<codeline lineno="1110"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>deallocated<sp/>the<sp/>buffer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1111"><highlight class="normal"><sp/><sp/><sp/><sp/>netbuf_delete(chain_buf);</highlight></codeline>
<codeline lineno="1112"><highlight class="normal"></highlight></codeline>
<codeline lineno="1113"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1114"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref><sp/>?<sp/>size<sp/>:<sp/>-1);</highlight></codeline>
<codeline lineno="1115"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1116"><highlight class="normal"></highlight><highlight class="preprocessor">#else<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="1117"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));</highlight></codeline>
<codeline lineno="1118"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1119"><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="1120"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1121"><highlight class="normal"></highlight></codeline>
<codeline lineno="1122"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1123"><highlight class="normal">lwip_sendto(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>size,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref>,</highlight></codeline>
<codeline lineno="1124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*to,<sp/>socklen_t<sp/>tolen)</highlight></codeline>
<codeline lineno="1125"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1126"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1127"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1128"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>short_size;</highlight></codeline>
<codeline lineno="1129"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>remote_port;</highlight></codeline>
<codeline lineno="1130"><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="1131"><highlight class="normal"></highlight></codeline>
<codeline lineno="1132"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="1133"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1134"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1135"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1136"><highlight class="normal"></highlight></codeline>
<codeline lineno="1137"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>==<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1138"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1139"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_send(s,<sp/>data,<sp/>size,<sp/>flags);</highlight></codeline>
<codeline lineno="1140"><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="1141"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(flags);</highlight></codeline>
<codeline lineno="1142"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));</highlight></codeline>
<codeline lineno="1143"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1144"><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="1145"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1146"><highlight class="normal"></highlight></codeline>
<codeline lineno="1147"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>split<sp/>into<sp/>multiple<sp/>sendto&apos;s?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1148"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;lwip_sendto:<sp/>size<sp/>must<sp/>fit<sp/>in<sp/>u16_t&quot;</highlight><highlight class="normal">,<sp/>size<sp/>&lt;=<sp/>0xffff);</highlight></codeline>
<codeline lineno="1149"><highlight class="normal"><sp/><sp/>short_size<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)size;</highlight></codeline>
<codeline lineno="1150"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a827bc03cd7889e7c007df39d33b33d18" kindref="member">LWIP_ERROR</ref>(</highlight><highlight class="stringliteral">&quot;lwip_sendto:<sp/>invalid<sp/>address&quot;</highlight><highlight class="normal">,<sp/>(((to<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(tolen<sp/>==<sp/>0))<sp/>||</highlight></codeline>
<codeline lineno="1151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(IS_SOCK_ADDR_LEN_VALID(tolen)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>IS_SOCK_ADDR_TYPE_VALID(to)<sp/>&amp;&amp;<sp/>IS_SOCK_ADDR_ALIGNED(to))),</highlight></codeline>
<codeline lineno="1153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(<ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcab508ce0ebdf3ca735208b00a80a45c91" kindref="member">ERR_ARG</ref>));<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;);</highlight></codeline>
<codeline lineno="1154"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(tolen);</highlight></codeline>
<codeline lineno="1155"><highlight class="normal"></highlight></codeline>
<codeline lineno="1156"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>initialize<sp/>a<sp/>buffer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1157"><highlight class="normal"><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>.p<sp/>=<sp/><ref refid="structbuf" kindref="compound">buf</ref>.ptr<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1158"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1159"><highlight class="normal"><sp/><sp/><ref refid="structbuf" kindref="compound">buf</ref>.flags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1160"><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="1161"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(to)<sp/>{</highlight></codeline>
<codeline lineno="1162"><highlight class="normal"><sp/><sp/><sp/><sp/>SOCKADDR_TO_IPADDR_PORT(to,<sp/>&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr,<sp/>remote_port);</highlight></codeline>
<codeline lineno="1163"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1164"><highlight class="normal"><sp/><sp/><sp/><sp/>remote_port<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1165"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a8853fce54b1816dca3af90b48677e673" kindref="member">ip_addr_set_any</ref>(NETCONNTYPE_ISIPV6(netconn_type(sock-&gt;conn)),<sp/>&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr);</highlight></codeline>
<codeline lineno="1166"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1167"><highlight class="normal"><sp/><sp/>netbuf_fromport(&amp;<ref refid="structbuf" kindref="compound">buf</ref>)<sp/>=<sp/>remote_port;</highlight></codeline>
<codeline lineno="1168"><highlight class="normal"></highlight></codeline>
<codeline lineno="1169"><highlight class="normal"></highlight></codeline>
<codeline lineno="1170"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_sendto(%d,<sp/>data=%p,<sp/>short_size=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;,<sp/>flags=0x%x<sp/>to=&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1171"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>data,<sp/>short_size,<sp/>flags));</highlight></codeline>
<codeline lineno="1172"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr);</highlight></codeline>
<codeline lineno="1173"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>remote_port));</highlight></codeline>
<codeline lineno="1174"><highlight class="normal"></highlight></codeline>
<codeline lineno="1175"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>make<sp/>the<sp/>buffer<sp/>point<sp/>to<sp/>the<sp/>data<sp/>that<sp/>should<sp/>be<sp/>sent<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1176"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETIF_TX_SINGLE_PBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1177"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Allocate<sp/>a<sp/>new<sp/>netbuf<sp/>and<sp/>copy<sp/>the<sp/>data<sp/>into<sp/>it.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1178"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(netbuf_alloc(&amp;<ref refid="structbuf" kindref="compound">buf</ref>,<sp/>short_size)<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1179"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="1180"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1181"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1182"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_RAW)<sp/>{</highlight></codeline>
<codeline lineno="1183"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum<sp/>=<sp/>LWIP_CHKSUM_COPY(<ref refid="structbuf" kindref="compound">buf</ref>.p-&gt;payload,<sp/>data,<sp/>short_size);</highlight></codeline>
<codeline lineno="1184"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netbuf_set_chksum(&amp;<ref refid="structbuf" kindref="compound">buf</ref>,<sp/>chksum);</highlight></codeline>
<codeline lineno="1185"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1186"><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="1187"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="1188"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(<ref refid="structbuf" kindref="compound">buf</ref>.p-&gt;payload,<sp/>data,<sp/>short_size);</highlight></codeline>
<codeline lineno="1189"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1190"><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="1191"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1192"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1193"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netbuf_ref(&amp;<ref refid="structbuf" kindref="compound">buf</ref>,<sp/>data,<sp/>short_size);</highlight></codeline>
<codeline lineno="1194"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETIF_TX_SINGLE_PBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1195"><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="1196"><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="1197"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Unmap<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>addresses<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1198"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a1578e34703e86711a7fb7dcc3857004d" kindref="member">IP_IS_V6_VAL</ref>(<ref refid="structbuf" kindref="compound">buf</ref>.addr)<sp/>&amp;&amp;<sp/>ip6_addr_isipv4mappedipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr)))<sp/>{</highlight></codeline>
<codeline lineno="1199"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>unmap_ipv4_mapped_ipv6(ip_2_ip4(&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr),<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;<ref refid="structbuf" kindref="compound">buf</ref>.addr));</highlight></codeline>
<codeline lineno="1200"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(<ref refid="structbuf" kindref="compound">buf</ref>.addr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585cace47fa82608deeb1c1c7c2c891eb5049" kindref="member">IPADDR_TYPE_V4</ref>);</highlight></codeline>
<codeline lineno="1201"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1202"><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="1203"><highlight class="normal"></highlight></codeline>
<codeline lineno="1204"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>the<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1205"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_send(sock-&gt;conn,<sp/>&amp;<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="1206"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1207"><highlight class="normal"></highlight></codeline>
<codeline lineno="1208"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>deallocated<sp/>the<sp/>buffer<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1209"><highlight class="normal"><sp/><sp/>netbuf_free(&amp;<ref refid="structbuf" kindref="compound">buf</ref>);</highlight></codeline>
<codeline lineno="1210"><highlight class="normal"></highlight></codeline>
<codeline lineno="1211"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1212"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref><sp/>?<sp/>short_size<sp/>:<sp/>-1);</highlight></codeline>
<codeline lineno="1213"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1214"><highlight class="normal"></highlight></codeline>
<codeline lineno="1215"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1216"><highlight class="normal">lwip_socket(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>domain,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>type,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>protocol)</highlight></codeline>
<codeline lineno="1217"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1218"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netconn<sp/>*conn;</highlight></codeline>
<codeline lineno="1219"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="1220"><highlight class="normal"></highlight></codeline>
<codeline lineno="1221"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(domain);<sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>check<sp/>this<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1222"><highlight class="normal"></highlight></codeline>
<codeline lineno="1223"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>create<sp/>a<sp/>netconn<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1224"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(type)<sp/>{</highlight></codeline>
<codeline lineno="1225"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SOCK_RAW:</highlight></codeline>
<codeline lineno="1226"><highlight class="normal"><sp/><sp/><sp/><sp/>conn<sp/>=<sp/>netconn_new_with_proto_and_callback(DOMAIN_TO_NETCONN_TYPE(domain,<sp/>NETCONN_RAW),</highlight></codeline>
<codeline lineno="1227"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)protocol,<sp/>event_callback);</highlight></codeline>
<codeline lineno="1228"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_socket(%s,<sp/>SOCK_RAW,<sp/>%d)<sp/>=<sp/>&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1229"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>domain<sp/>==<sp/>PF_INET<sp/>?<sp/></highlight><highlight class="stringliteral">&quot;PF_INET&quot;</highlight><highlight class="normal"><sp/>:<sp/></highlight><highlight class="stringliteral">&quot;UNKNOWN&quot;</highlight><highlight class="normal">,<sp/>protocol));</highlight></codeline>
<codeline lineno="1230"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1231"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SOCK_DGRAM:</highlight></codeline>
<codeline lineno="1232"><highlight class="normal"><sp/><sp/><sp/><sp/>conn<sp/>=<sp/>netconn_new_with_callback(DOMAIN_TO_NETCONN_TYPE(domain,</highlight></codeline>
<codeline lineno="1233"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((protocol<sp/>==<sp/>IPPROTO_UDPLITE)<sp/>?<sp/>NETCONN_UDPLITE<sp/>:<sp/>NETCONN_UDP))<sp/>,</highlight></codeline>
<codeline lineno="1234"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>event_callback);</highlight></codeline>
<codeline lineno="1235"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_socket(%s,<sp/>SOCK_DGRAM,<sp/>%d)<sp/>=<sp/>&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1236"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>domain<sp/>==<sp/>PF_INET<sp/>?<sp/></highlight><highlight class="stringliteral">&quot;PF_INET&quot;</highlight><highlight class="normal"><sp/>:<sp/></highlight><highlight class="stringliteral">&quot;UNKNOWN&quot;</highlight><highlight class="normal">,<sp/>protocol));</highlight></codeline>
<codeline lineno="1237"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1238"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SOCK_STREAM:</highlight></codeline>
<codeline lineno="1239"><highlight class="normal"><sp/><sp/><sp/><sp/>conn<sp/>=<sp/>netconn_new_with_callback(DOMAIN_TO_NETCONN_TYPE(domain,<sp/>NETCONN_TCP),<sp/>event_callback);</highlight></codeline>
<codeline lineno="1240"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_socket(%s,<sp/>SOCK_STREAM,<sp/>%d)<sp/>=<sp/>&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1241"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>domain<sp/>==<sp/>PF_INET<sp/>?<sp/></highlight><highlight class="stringliteral">&quot;PF_INET&quot;</highlight><highlight class="normal"><sp/>:<sp/></highlight><highlight class="stringliteral">&quot;UNKNOWN&quot;</highlight><highlight class="normal">,<sp/>protocol));</highlight></codeline>
<codeline lineno="1242"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1243"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1244"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_socket(%d,<sp/>%d/UNKNOWN,<sp/>%d)<sp/>=<sp/>-1\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>domain,<sp/>type,<sp/>protocol));</highlight></codeline>
<codeline lineno="1246"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>);</highlight></codeline>
<codeline lineno="1247"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1248"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1249"><highlight class="normal"></highlight></codeline>
<codeline lineno="1250"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!conn)<sp/>{</highlight></codeline>
<codeline lineno="1251"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;-1<sp/>/<sp/>ENOBUFS<sp/>(could<sp/>not<sp/>create<sp/>netconn)\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1252"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a9e655f47bfd914a1174f281fc31cf63d" kindref="member">ENOBUFS</ref>);</highlight></codeline>
<codeline lineno="1253"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1254"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1255"><highlight class="normal"></highlight></codeline>
<codeline lineno="1256"><highlight class="normal"><sp/><sp/>i<sp/>=<sp/>alloc_socket(conn,<sp/>0);</highlight></codeline>
<codeline lineno="1257"><highlight class="normal"></highlight></codeline>
<codeline lineno="1258"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(i<sp/>==<sp/>-1)<sp/>{</highlight></codeline>
<codeline lineno="1259"><highlight class="normal"><sp/><sp/><sp/><sp/>netconn_delete(conn);</highlight></codeline>
<codeline lineno="1260"><highlight class="normal"><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a5554094b3fb4bb6ebeb0157cb3f82a55" kindref="member">ENFILE</ref>);</highlight></codeline>
<codeline lineno="1261"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1262"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1263"><highlight class="normal"><sp/><sp/>conn-&gt;socket<sp/>=<sp/>i;</highlight></codeline>
<codeline lineno="1264"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;%d\n&quot;</highlight><highlight class="normal">,<sp/>i));</highlight></codeline>
<codeline lineno="1265"><highlight class="normal"><sp/><sp/>set_errno(0);</highlight></codeline>
<codeline lineno="1266"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="1267"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1268"><highlight class="normal"></highlight></codeline>
<codeline lineno="1269"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1270"><highlight class="normal">lwip_write(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>size)</highlight></codeline>
<codeline lineno="1271"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1272"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_send(s,<sp/>data,<sp/>size,<sp/>0);</highlight></codeline>
<codeline lineno="1273"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1274"><highlight class="normal"></highlight></codeline>
<codeline lineno="1275"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1276"><highlight class="normal">lwip_writev(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>iovec<sp/>*iov,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>iovcnt)</highlight></codeline>
<codeline lineno="1277"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1278"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">msghdr<sp/>msg;</highlight></codeline>
<codeline lineno="1279"><highlight class="normal"></highlight></codeline>
<codeline lineno="1280"><highlight class="normal"><sp/><sp/>msg.msg_name<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1281"><highlight class="normal"><sp/><sp/>msg.msg_namelen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1282"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Hack:<sp/>we<sp/>have<sp/>to<sp/>cast<sp/>via<sp/>number<sp/>to<sp/>cast<sp/>from<sp/>&apos;const&apos;<sp/>pointer<sp/>to<sp/>non-const.</highlight></codeline>
<codeline lineno="1283"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>Blame<sp/>the<sp/>opengroup<sp/>standard<sp/>for<sp/>this<sp/>inconsistency.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1284"><highlight class="normal"><sp/><sp/>msg.msg_iov<sp/>=<sp/><ref refid="group__compiler__abstraction_1gaa0dd3f76dd9a837feaac61fedc0dbe72" kindref="member">LWIP_CONST_CAST</ref>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>iovec<sp/>*,<sp/>iov);</highlight></codeline>
<codeline lineno="1285"><highlight class="normal"><sp/><sp/>msg.msg_iovlen<sp/>=<sp/>iovcnt;</highlight></codeline>
<codeline lineno="1286"><highlight class="normal"><sp/><sp/>msg.msg_control<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1287"><highlight class="normal"><sp/><sp/>msg.msg_controllen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1288"><highlight class="normal"><sp/><sp/>msg.msg_flags<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1289"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_sendmsg(s,<sp/>&amp;msg,<sp/>0);</highlight></codeline>
<codeline lineno="1290"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1291"><highlight class="normal"></highlight></codeline>
<codeline lineno="1306"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1307"><highlight class="normal">lwip_selscan(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>maxfdp1,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*readset_in,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*writeset_in,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*exceptset_in,</highlight></codeline>
<codeline lineno="1308"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*readset_out,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*writeset_out,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*exceptset_out)</highlight></codeline>
<codeline lineno="1309"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1310"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i,<sp/>nready<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1311"><highlight class="normal"><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>lreadset,<sp/>lwriteset,<sp/>lexceptset;</highlight></codeline>
<codeline lineno="1312"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1313"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a945395fa326214fc9736487242710a90" kindref="member">SYS_ARCH_DECL_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1314"><highlight class="normal"></highlight></codeline>
<codeline lineno="1315"><highlight class="normal"><sp/><sp/><ref refid="select_8h_1a23c97009457b26f0e96afc9d0e10876b" kindref="member">FD_ZERO</ref>(&amp;lreadset);</highlight></codeline>
<codeline lineno="1316"><highlight class="normal"><sp/><sp/><ref refid="select_8h_1a23c97009457b26f0e96afc9d0e10876b" kindref="member">FD_ZERO</ref>(&amp;lwriteset);</highlight></codeline>
<codeline lineno="1317"><highlight class="normal"><sp/><sp/><ref refid="select_8h_1a23c97009457b26f0e96afc9d0e10876b" kindref="member">FD_ZERO</ref>(&amp;lexceptset);</highlight></codeline>
<codeline lineno="1318"><highlight class="normal"></highlight></codeline>
<codeline lineno="1319"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Go<sp/>through<sp/>each<sp/>socket<sp/>in<sp/>each<sp/>list<sp/>to<sp/>count<sp/>number<sp/>of<sp/>sockets<sp/>which</highlight></codeline>
<codeline lineno="1320"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>currently<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1321"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;<sp/>i<sp/>&lt;<sp/>maxfdp1;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1322"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>this<sp/>FD<sp/>is<sp/>not<sp/>in<sp/>the<sp/>set,<sp/>continue<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1323"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!(readset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>readset_in))<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>!(writeset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>writeset_in))<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1325"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>!(exceptset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>exceptset_in)))<sp/>{</highlight></codeline>
<codeline lineno="1326"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">continue</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1327"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1328"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>First<sp/>get<sp/>the<sp/>socket&apos;s<sp/>status<sp/>(protected)...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1329"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1330"><highlight class="normal"><sp/><sp/><sp/><sp/>sock<sp/>=<sp/>tryget_socket(i);</highlight></codeline>
<codeline lineno="1331"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1332"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*<sp/>lastdata<sp/>=<sp/>sock-&gt;lastdata;</highlight></codeline>
<codeline lineno="1333"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>rcvevent<sp/>=<sp/>sock-&gt;rcvevent;</highlight></codeline>
<codeline lineno="1334"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>sendevent<sp/>=<sp/>sock-&gt;sendevent;</highlight></codeline>
<codeline lineno="1335"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>errevent<sp/>=<sp/>sock-&gt;errevent;</highlight></codeline>
<codeline lineno="1336"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1337"><highlight class="normal"></highlight></codeline>
<codeline lineno="1338"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>...<sp/>then<sp/>examine<sp/>it:<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1339"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>See<sp/>if<sp/>netconn<sp/>of<sp/>this<sp/>socket<sp/>is<sp/>ready<sp/>for<sp/>read<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1340"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(readset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>readset_in)<sp/>&amp;&amp;<sp/>((lastdata<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(rcvevent<sp/>&gt;<sp/>0)))<sp/>{</highlight></codeline>
<codeline lineno="1341"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="select_8h_1ad97013c4b9982b36a8308917d5c22c52" kindref="member">FD_SET</ref>(i,<sp/>&amp;lreadset);</highlight></codeline>
<codeline lineno="1342"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_selscan:<sp/>fd=%d<sp/>ready<sp/>for<sp/>reading\n&quot;</highlight><highlight class="normal">,<sp/>i));</highlight></codeline>
<codeline lineno="1343"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nready++;</highlight></codeline>
<codeline lineno="1344"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>See<sp/>if<sp/>netconn<sp/>of<sp/>this<sp/>socket<sp/>is<sp/>ready<sp/>for<sp/>write<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1346"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(writeset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>writeset_in)<sp/>&amp;&amp;<sp/>(sendevent<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="1347"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="select_8h_1ad97013c4b9982b36a8308917d5c22c52" kindref="member">FD_SET</ref>(i,<sp/>&amp;lwriteset);</highlight></codeline>
<codeline lineno="1348"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_selscan:<sp/>fd=%d<sp/>ready<sp/>for<sp/>writing\n&quot;</highlight><highlight class="normal">,<sp/>i));</highlight></codeline>
<codeline lineno="1349"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nready++;</highlight></codeline>
<codeline lineno="1350"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>See<sp/>if<sp/>netconn<sp/>of<sp/>this<sp/>socket<sp/>had<sp/>an<sp/>error<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1352"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(exceptset_in<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>exceptset_in)<sp/>&amp;&amp;<sp/>(errevent<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="1353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="select_8h_1ad97013c4b9982b36a8308917d5c22c52" kindref="member">FD_SET</ref>(i,<sp/>&amp;lexceptset);</highlight></codeline>
<codeline lineno="1354"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_selscan:<sp/>fd=%d<sp/>ready<sp/>for<sp/>exception\n&quot;</highlight><highlight class="normal">,<sp/>i));</highlight></codeline>
<codeline lineno="1355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nready++;</highlight></codeline>
<codeline lineno="1356"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1357"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>continue<sp/>on<sp/>to<sp/>next<sp/>FD<sp/>in<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1360"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1361"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1362"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>local<sp/>sets<sp/>to<sp/>the<sp/>ones<sp/>provided<sp/>as<sp/>arguments<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1363"><highlight class="normal"><sp/><sp/>*readset_out<sp/>=<sp/>lreadset;</highlight></codeline>
<codeline lineno="1364"><highlight class="normal"><sp/><sp/>*writeset_out<sp/>=<sp/>lwriteset;</highlight></codeline>
<codeline lineno="1365"><highlight class="normal"><sp/><sp/>*exceptset_out<sp/>=<sp/>lexceptset;</highlight></codeline>
<codeline lineno="1366"><highlight class="normal"></highlight></codeline>
<codeline lineno="1367"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;nready<sp/>&gt;=<sp/>0&quot;</highlight><highlight class="normal">,<sp/>nready<sp/>&gt;=<sp/>0);</highlight></codeline>
<codeline lineno="1368"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>nready;</highlight></codeline>
<codeline lineno="1369"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1370"><highlight class="normal"></highlight></codeline>
<codeline lineno="1371"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>lwip_select(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>maxfdp1,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*readset,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*writeset,<sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>*exceptset,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structtimeval" kindref="compound">timeval</ref><sp/>*timeout)<sp/>{</highlight></codeline>
<codeline lineno="1372"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>waitres<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1373"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nready;</highlight></codeline>
<codeline lineno="1374"><highlight class="normal"><sp/><sp/><ref refid="structfd__set" kindref="compound">fd_set</ref><sp/>lreadset,<sp/>lwriteset,<sp/>lexceptset;</highlight></codeline>
<codeline lineno="1375"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>msectimeout;</highlight></codeline>
<codeline lineno="1376"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>select_cb;</highlight></codeline>
<codeline lineno="1377"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="1378"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>maxfdp2;</highlight></codeline>
<codeline lineno="1379"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1380"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>waited<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1381"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1382"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a945395fa326214fc9736487242710a90" kindref="member">SYS_ARCH_DECL_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1383"><highlight class="normal"></highlight></codeline>
<codeline lineno="1384"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_select(%d,<sp/>%p,<sp/>%p,<sp/>%p,<sp/>tvsec=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4b1eca99bc81e248c7074ea87fc9ca63" kindref="member">S32_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>tvusec=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga4b1eca99bc81e248c7074ea87fc9ca63" kindref="member">S32_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1385"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>maxfdp1,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)readset,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)<sp/>writeset,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)<sp/>exceptset,</highlight></codeline>
<codeline lineno="1386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>timeout<sp/>?<sp/>(<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)timeout-&gt;<ref refid="structtimeval_1aef6ddab1064c430758f9f913b7e4a21e" kindref="member">tv_sec</ref><sp/>:<sp/>(<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)-1,</highlight></codeline>
<codeline lineno="1387"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>timeout<sp/>?<sp/>(<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)timeout-&gt;<ref refid="structtimeval_1a810bf8fcd58e255a5c1896d19538b86a" kindref="member">tv_usec</ref><sp/>:<sp/>(<ref refid="group__compiler__abstraction_1ga10f9a3d7baef58ccc23228c3bd29c1fb" kindref="member">s32_t</ref>)-1));</highlight></codeline>
<codeline lineno="1388"><highlight class="normal"></highlight></codeline>
<codeline lineno="1389"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Go<sp/>through<sp/>each<sp/>socket<sp/>in<sp/>each<sp/>list<sp/>to<sp/>count<sp/>number<sp/>of<sp/>sockets<sp/>which</highlight></codeline>
<codeline lineno="1390"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>currently<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1391"><highlight class="normal"><sp/><sp/>nready<sp/>=<sp/>lwip_selscan(maxfdp1,<sp/>readset,<sp/>writeset,<sp/>exceptset,<sp/>&amp;lreadset,<sp/>&amp;lwriteset,<sp/>&amp;lexceptset);</highlight></codeline>
<codeline lineno="1392"><highlight class="normal"></highlight></codeline>
<codeline lineno="1393"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>we<sp/>don&apos;t<sp/>have<sp/>any<sp/>current<sp/>events,<sp/>then<sp/>suspend<sp/>if<sp/>we<sp/>are<sp/>supposed<sp/>to<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1394"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!nready)<sp/>{</highlight></codeline>
<codeline lineno="1395"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(timeout<sp/>&amp;&amp;<sp/>timeout-&gt;<ref refid="structtimeval_1aef6ddab1064c430758f9f913b7e4a21e" kindref="member">tv_sec</ref><sp/>==<sp/>0<sp/>&amp;&amp;<sp/>timeout-&gt;<ref refid="structtimeval_1a810bf8fcd58e255a5c1896d19538b86a" kindref="member">tv_usec</ref><sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_select:<sp/>no<sp/>timeout,<sp/>returning<sp/>0\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>is<sp/>OK<sp/>as<sp/>the<sp/>local<sp/>fdsets<sp/>are<sp/>empty<sp/>and<sp/>nready<sp/>is<sp/>zero,</highlight></codeline>
<codeline lineno="1398"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>or<sp/>we<sp/>would<sp/>have<sp/>returned<sp/>earlier.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1399"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>return_copy_fdsets;</highlight></codeline>
<codeline lineno="1400"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1401"><highlight class="normal"></highlight></codeline>
<codeline lineno="1402"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>None<sp/>ready:<sp/>add<sp/>our<sp/>semaphore<sp/>to<sp/>list:</highlight></codeline>
<codeline lineno="1403"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>We<sp/>don&apos;t<sp/>actually<sp/>need<sp/>any<sp/>dynamic<sp/>memory.<sp/>Our<sp/>entry<sp/>on<sp/>the</highlight></codeline>
<codeline lineno="1404"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>list<sp/>is<sp/>only<sp/>valid<sp/>while<sp/>we<sp/>are<sp/>in<sp/>this<sp/>function,<sp/>so<sp/>it&apos;s<sp/>ok</highlight></codeline>
<codeline lineno="1405"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>to<sp/>use<sp/>local<sp/>variables.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1406"><highlight class="normal"></highlight></codeline>
<codeline lineno="1407"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.next<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1408"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="1409"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.readset<sp/>=<sp/>readset;</highlight></codeline>
<codeline lineno="1410"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.writeset<sp/>=<sp/>writeset;</highlight></codeline>
<codeline lineno="1411"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.exceptset<sp/>=<sp/>exceptset;</highlight></codeline>
<codeline lineno="1412"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.sem_signalled<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1413"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1414"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.sem<sp/>=<sp/>LWIP_NETCONN_THREAD_SEM_GET();</highlight></codeline>
<codeline lineno="1415"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1416"><highlight class="normal"><sp/><sp/><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;select_cb.sem,<sp/>0)<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>failed<sp/>to<sp/>create<sp/>semaphore<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1418"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1a6a05c923dad0c1208043e9c20a58c8e5" kindref="member">ENOMEM</ref>);</highlight></codeline>
<codeline lineno="1419"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1420"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1421"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1422"><highlight class="normal"></highlight></codeline>
<codeline lineno="1423"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Protect<sp/>the<sp/>select_cb_list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1424"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1425"><highlight class="normal"></highlight></codeline>
<codeline lineno="1426"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Put<sp/>this<sp/>select_cb<sp/>on<sp/>top<sp/>of<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1427"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb.next<sp/>=<sp/>select_cb_list;</highlight></codeline>
<codeline lineno="1428"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(select_cb_list<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1429"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>select_cb_list-&gt;prev<sp/>=<sp/>&amp;select_cb;</highlight></codeline>
<codeline lineno="1430"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1431"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb_list<sp/>=<sp/>&amp;select_cb;</highlight></codeline>
<codeline lineno="1432"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Increasing<sp/>this<sp/>counter<sp/>tells<sp/>event_callback<sp/>that<sp/>the<sp/>list<sp/>has<sp/>changed.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1433"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb_ctr++;</highlight></codeline>
<codeline lineno="1434"><highlight class="normal"></highlight></codeline>
<codeline lineno="1435"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Now<sp/>we<sp/>can<sp/>safely<sp/>unprotect<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1436"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1437"><highlight class="normal"></highlight></codeline>
<codeline lineno="1438"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Increase<sp/>select_waiting<sp/>for<sp/>each<sp/>socket<sp/>we<sp/>are<sp/>interested<sp/>in<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1439"><highlight class="normal"><sp/><sp/><sp/><sp/>maxfdp2<sp/>=<sp/>maxfdp1;</highlight></codeline>
<codeline lineno="1440"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;<sp/>i<sp/>&lt;<sp/>maxfdp1;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1441"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((readset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>readset))<sp/>||</highlight></codeline>
<codeline lineno="1442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(writeset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>writeset))<sp/>||</highlight></codeline>
<codeline lineno="1443"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(exceptset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>exceptset)))<sp/>{</highlight></codeline>
<codeline lineno="1444"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1445"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1446"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock<sp/>=<sp/>tryget_socket(i);</highlight></codeline>
<codeline lineno="1447"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;select_waiting++;</highlight></codeline>
<codeline lineno="1449"><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;sock-&gt;select_waiting<sp/>&gt;<sp/>0&quot;</highlight><highlight class="normal">,<sp/>sock-&gt;select_waiting<sp/>&gt;<sp/>0);</highlight></codeline>
<codeline lineno="1450"><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="1451"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Not<sp/>a<sp/>valid<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1452"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nready<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="1453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>maxfdp2<sp/>=<sp/>i;</highlight></codeline>
<codeline lineno="1454"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1458"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1459"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1460"><highlight class="normal"></highlight></codeline>
<codeline lineno="1461"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(nready<sp/>&gt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1462"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Call<sp/>lwip_selscan<sp/>again:<sp/>there<sp/>could<sp/>have<sp/>been<sp/>events<sp/>between</highlight></codeline>
<codeline lineno="1463"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>the<sp/>last<sp/>scan<sp/>(without<sp/>us<sp/>on<sp/>the<sp/>list)<sp/>and<sp/>putting<sp/>us<sp/>on<sp/>the<sp/>list!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1464"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>nready<sp/>=<sp/>lwip_selscan(maxfdp1,<sp/>readset,<sp/>writeset,<sp/>exceptset,<sp/>&amp;lreadset,<sp/>&amp;lwriteset,<sp/>&amp;lexceptset);</highlight></codeline>
<codeline lineno="1465"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!nready)<sp/>{</highlight></codeline>
<codeline lineno="1466"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Still<sp/>none<sp/>ready,<sp/>just<sp/>wait<sp/>to<sp/>be<sp/>woken<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1467"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(timeout<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1468"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Wait<sp/>forever<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1469"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msectimeout<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1470"><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="1471"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msectimeout<sp/>=<sp/><sp/>((timeout-&gt;<ref refid="structtimeval_1aef6ddab1064c430758f9f913b7e4a21e" kindref="member">tv_sec</ref><sp/>*<sp/>1000)<sp/>+<sp/>((timeout-&gt;<ref refid="structtimeval_1a810bf8fcd58e255a5c1896d19538b86a" kindref="member">tv_usec</ref><sp/>+<sp/>500)/1000));</highlight></codeline>
<codeline lineno="1472"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msectimeout<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1473"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Wait<sp/>1ms<sp/>at<sp/>least<sp/>(0<sp/>means<sp/>wait<sp/>forever)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1474"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>msectimeout<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1475"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1476"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1477"><highlight class="normal"></highlight></codeline>
<codeline lineno="1478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>waitres<sp/>=<sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(SELECT_SEM_PTR(select_cb.sem),<sp/>msectimeout);</highlight></codeline>
<codeline lineno="1479"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1480"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>waited<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1481"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1482"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1483"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1484"><highlight class="normal"></highlight></codeline>
<codeline lineno="1485"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Decrease<sp/>select_waiting<sp/>for<sp/>each<sp/>socket<sp/>we<sp/>are<sp/>interested<sp/>in<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1486"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/><ref refid="lwipopts_8h_1ad0197c845fbb44c920b272f0fef3b57e" kindref="member">LWIP_SOCKET_OFFSET</ref>;<sp/>i<sp/>&lt;<sp/>maxfdp2;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="1487"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((readset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>readset))<sp/>||</highlight></codeline>
<codeline lineno="1488"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(writeset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>writeset))<sp/>||</highlight></codeline>
<codeline lineno="1489"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(exceptset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(i,<sp/>exceptset)))<sp/>{</highlight></codeline>
<codeline lineno="1490"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1491"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1492"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock<sp/>=<sp/>tryget_socket(i);</highlight></codeline>
<codeline lineno="1493"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1494"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>for<sp/>now,<sp/>handle<sp/>select_waiting==0...<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1495"><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;sock-&gt;select_waiting<sp/>&gt;<sp/>0&quot;</highlight><highlight class="normal">,<sp/>sock-&gt;select_waiting<sp/>&gt;<sp/>0);</highlight></codeline>
<codeline lineno="1496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;select_waiting<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1497"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;select_waiting--;</highlight></codeline>
<codeline lineno="1498"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1499"><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="1500"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Not<sp/>a<sp/>valid<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1501"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nready<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="1502"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1503"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1504"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1505"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1506"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Take<sp/>us<sp/>off<sp/>the<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1507"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1508"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(select_cb.next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1509"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>select_cb.next-&gt;prev<sp/>=<sp/>select_cb.prev;</highlight></codeline>
<codeline lineno="1510"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1511"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(select_cb_list<sp/>==<sp/>&amp;select_cb)<sp/>{</highlight></codeline>
<codeline lineno="1512"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;select_cb.prev<sp/>==<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>select_cb.prev<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1513"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>select_cb_list<sp/>=<sp/>select_cb.next;</highlight></codeline>
<codeline lineno="1514"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1515"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;select_cb.prev<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>select_cb.prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1516"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>select_cb.prev-&gt;next<sp/>=<sp/>select_cb.next;</highlight></codeline>
<codeline lineno="1517"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1518"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Increasing<sp/>this<sp/>counter<sp/>tells<sp/>event_callback<sp/>that<sp/>the<sp/>list<sp/>has<sp/>changed.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1519"><highlight class="normal"><sp/><sp/><sp/><sp/>select_cb_ctr++;</highlight></codeline>
<codeline lineno="1520"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1521"><highlight class="normal"></highlight></codeline>
<codeline lineno="1522"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1523"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(select_cb.sem_signalled<sp/>&amp;&amp;<sp/>(!waited<sp/>||<sp/>(waitres<sp/>==<sp/><ref refid="sys_8h_1ac1495030a8ab5e1f3c89e42ced527c5b" kindref="member">SYS_ARCH_TIMEOUT</ref>)))<sp/>{</highlight></codeline>
<codeline lineno="1524"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>leave<sp/>the<sp/>thread-local<sp/>semaphore<sp/>signalled<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1525"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>(select_cb.sem,<sp/>1);</highlight></codeline>
<codeline lineno="1526"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1527"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1528"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1ga4d02e29e5dfa092559efc04dee985822" kindref="member">sys_sem_free</ref>(&amp;select_cb.sem);</highlight></codeline>
<codeline lineno="1529"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_NETCONN_SEM_PER_THREAD<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1530"><highlight class="normal"></highlight></codeline>
<codeline lineno="1531"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(nready<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1532"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>happens<sp/>when<sp/>a<sp/>socket<sp/>got<sp/>closed<sp/>while<sp/>waiting<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1533"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>set_errno(<ref refid="sys_2errno_8h_1ac54507d66b43ad12f9356257323c0018" kindref="member">EBADF</ref>);</highlight></codeline>
<codeline lineno="1534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1535"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1536"><highlight class="normal"></highlight></codeline>
<codeline lineno="1537"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(waitres<sp/>==<sp/><ref refid="sys_8h_1ac1495030a8ab5e1f3c89e42ced527c5b" kindref="member">SYS_ARCH_TIMEOUT</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1538"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Timeout<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1539"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_select:<sp/>timeout<sp/>expired\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1540"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>This<sp/>is<sp/>OK<sp/>as<sp/>the<sp/>local<sp/>fdsets<sp/>are<sp/>empty<sp/>and<sp/>nready<sp/>is<sp/>zero,</highlight></codeline>
<codeline lineno="1541"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>or<sp/>we<sp/>would<sp/>have<sp/>returned<sp/>earlier.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1542"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>return_copy_fdsets;</highlight></codeline>
<codeline lineno="1543"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1544"><highlight class="normal"></highlight></codeline>
<codeline lineno="1545"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>See<sp/>what&apos;s<sp/>set<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1546"><highlight class="normal"><sp/><sp/><sp/><sp/>nready<sp/>=<sp/>lwip_selscan(maxfdp1,<sp/>readset,<sp/>writeset,<sp/>exceptset,<sp/>&amp;lreadset,<sp/>&amp;lwriteset,<sp/>&amp;lexceptset);</highlight></codeline>
<codeline lineno="1547"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1548"><highlight class="normal"></highlight></codeline>
<codeline lineno="1549"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_select:<sp/>nready=%d\n&quot;</highlight><highlight class="normal">,<sp/>nready));</highlight></codeline>
<codeline lineno="1550"><highlight class="normal">return_copy_fdsets:</highlight></codeline>
<codeline lineno="1551"><highlight class="normal"><sp/><sp/>set_errno(0);</highlight></codeline>
<codeline lineno="1552"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(readset)<sp/>{</highlight></codeline>
<codeline lineno="1553"><highlight class="normal"><sp/><sp/><sp/><sp/>*readset<sp/>=<sp/>lreadset;</highlight></codeline>
<codeline lineno="1554"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1555"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(writeset)<sp/>{</highlight></codeline>
<codeline lineno="1556"><highlight class="normal"><sp/><sp/><sp/><sp/>*writeset<sp/>=<sp/>lwriteset;</highlight></codeline>
<codeline lineno="1557"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1558"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(exceptset)<sp/>{</highlight></codeline>
<codeline lineno="1559"><highlight class="normal"><sp/><sp/><sp/><sp/>*exceptset<sp/>=<sp/>lexceptset;</highlight></codeline>
<codeline lineno="1560"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1561"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>nready;</highlight></codeline>
<codeline lineno="1562"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1563"><highlight class="normal"></highlight></codeline>
<codeline lineno="1568"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1569"><highlight class="normal">event_callback(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>netconn<sp/>*conn,<sp/></highlight><highlight class="keyword">enum</highlight><highlight class="normal"><sp/>netconn_evt<sp/>evt,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>len)</highlight></codeline>
<codeline lineno="1570"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1571"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s;</highlight></codeline>
<codeline lineno="1572"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1573"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_select_cb<sp/>*scb;</highlight></codeline>
<codeline lineno="1574"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>last_select_cb_ctr;</highlight></codeline>
<codeline lineno="1575"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a945395fa326214fc9736487242710a90" kindref="member">SYS_ARCH_DECL_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1576"><highlight class="normal"></highlight></codeline>
<codeline lineno="1577"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(len);</highlight></codeline>
<codeline lineno="1578"><highlight class="normal"></highlight></codeline>
<codeline lineno="1579"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Get<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1580"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn)<sp/>{</highlight></codeline>
<codeline lineno="1581"><highlight class="normal"><sp/><sp/><sp/><sp/>s<sp/>=<sp/>conn-&gt;socket;</highlight></codeline>
<codeline lineno="1582"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1583"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Data<sp/>comes<sp/>in<sp/>right<sp/>away<sp/>after<sp/>an<sp/>accept,<sp/>even<sp/>though</highlight></codeline>
<codeline lineno="1584"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>the<sp/>server<sp/>task<sp/>might<sp/>not<sp/>have<sp/>created<sp/>a<sp/>new<sp/>socket<sp/>yet.</highlight></codeline>
<codeline lineno="1585"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>Just<sp/>count<sp/>down<sp/>(or<sp/>up)<sp/>if<sp/>that&apos;s<sp/>the<sp/>case<sp/>and<sp/>we</highlight></codeline>
<codeline lineno="1586"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>will<sp/>use<sp/>the<sp/>data<sp/>later.<sp/>Note<sp/>that<sp/>only<sp/>receive<sp/>events</highlight></codeline>
<codeline lineno="1587"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>can<sp/>happen<sp/>before<sp/>the<sp/>new<sp/>socket<sp/>is<sp/>set<sp/>up.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1588"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1589"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn-&gt;socket<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1590"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(evt<sp/>==<sp/>NETCONN_EVT_RCVPLUS)<sp/>{</highlight></codeline>
<codeline lineno="1591"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn-&gt;socket--;</highlight></codeline>
<codeline lineno="1592"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1593"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1594"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1595"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1596"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>s<sp/>=<sp/>conn-&gt;socket;</highlight></codeline>
<codeline lineno="1597"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1598"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1599"><highlight class="normal"></highlight></codeline>
<codeline lineno="1600"><highlight class="normal"><sp/><sp/><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="1601"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1603"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1604"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1605"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1606"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1607"><highlight class="normal"></highlight></codeline>
<codeline lineno="1608"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1609"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>event<sp/>as<sp/>required<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1610"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(evt)<sp/>{</highlight></codeline>
<codeline lineno="1611"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_EVT_RCVPLUS:</highlight></codeline>
<codeline lineno="1612"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;rcvevent++;</highlight></codeline>
<codeline lineno="1613"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1614"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_EVT_RCVMINUS:</highlight></codeline>
<codeline lineno="1615"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;rcvevent--;</highlight></codeline>
<codeline lineno="1616"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1617"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_EVT_SENDPLUS:</highlight></codeline>
<codeline lineno="1618"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;sendevent<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1619"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1620"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_EVT_SENDMINUS:</highlight></codeline>
<codeline lineno="1621"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;sendevent<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1622"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1623"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>NETCONN_EVT_ERROR:</highlight></codeline>
<codeline lineno="1624"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;errevent<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1625"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1626"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="1627"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;unknown<sp/>event&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="1628"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1629"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1630"><highlight class="normal"></highlight></codeline>
<codeline lineno="1631"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;select_waiting<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1632"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>noone<sp/>is<sp/>waiting<sp/>for<sp/>this<sp/>socket,<sp/>no<sp/>need<sp/>to<sp/>check<sp/>select_cb_list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1633"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1634"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1635"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1636"><highlight class="normal"></highlight></codeline>
<codeline lineno="1637"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Now<sp/>decide<sp/>if<sp/>anyone<sp/>is<sp/>waiting<sp/>for<sp/>this<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1638"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>NOTE:<sp/>This<sp/>code<sp/>goes<sp/>through<sp/>the<sp/>select_cb_list<sp/>list<sp/>multiple<sp/>times</highlight></codeline>
<codeline lineno="1639"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>ONLY<sp/>IF<sp/>a<sp/>select<sp/>was<sp/>actually<sp/>waiting.<sp/>We<sp/>go<sp/>through<sp/>the<sp/>list<sp/>the<sp/>number</highlight></codeline>
<codeline lineno="1640"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>of<sp/>waiting<sp/>select<sp/>calls<sp/>+<sp/>1.<sp/>This<sp/>list<sp/>is<sp/>expected<sp/>to<sp/>be<sp/>small.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1641"><highlight class="normal"></highlight></codeline>
<codeline lineno="1642"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>At<sp/>this<sp/>point,<sp/>SYS_ARCH<sp/>is<sp/>still<sp/>protected!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1643"><highlight class="normal">again:</highlight></codeline>
<codeline lineno="1644"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(scb<sp/>=<sp/>select_cb_list;<sp/>scb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>scb<sp/>=<sp/>scb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1645"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remember<sp/>the<sp/>state<sp/>of<sp/>select_cb_list<sp/>to<sp/>detect<sp/>changes<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1646"><highlight class="normal"><sp/><sp/><sp/><sp/>last_select_cb_ctr<sp/>=<sp/>select_cb_ctr;</highlight></codeline>
<codeline lineno="1647"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(scb-&gt;sem_signalled<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1648"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>semaphore<sp/>not<sp/>signalled<sp/>yet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1649"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>do_signal<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1650"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Test<sp/>this<sp/>select<sp/>call<sp/>for<sp/>our<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1651"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;rcvevent<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1652"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(scb-&gt;readset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(s,<sp/>scb-&gt;readset))<sp/>{</highlight></codeline>
<codeline lineno="1653"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>do_signal<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1654"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1655"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1656"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;sendevent<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1657"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!do_signal<sp/>&amp;&amp;<sp/>scb-&gt;writeset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(s,<sp/>scb-&gt;writeset))<sp/>{</highlight></codeline>
<codeline lineno="1658"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>do_signal<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1659"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1660"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1661"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;errevent<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1662"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!do_signal<sp/>&amp;&amp;<sp/>scb-&gt;exceptset<sp/>&amp;&amp;<sp/><ref refid="select_8h_1a9bc0a7e611c4d98105fdf031d60e29ad" kindref="member">FD_ISSET</ref>(s,<sp/>scb-&gt;exceptset))<sp/>{</highlight></codeline>
<codeline lineno="1663"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>do_signal<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1664"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1665"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1666"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(do_signal)<sp/>{</highlight></codeline>
<codeline lineno="1667"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>scb-&gt;sem_signalled<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1668"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>call<sp/>SYS_ARCH_UNPROTECT()<sp/>before<sp/>signaling<sp/>the<sp/>semaphore,<sp/>as<sp/>this<sp/>might</highlight></codeline>
<codeline lineno="1669"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lead<sp/>to<sp/>the<sp/>select<sp/>thread<sp/>taking<sp/>itself<sp/>off<sp/>the<sp/>list,<sp/>invalidating<sp/>the<sp/>semaphore.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1670"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>(SELECT_SEM_PTR(scb-&gt;sem));</highlight></codeline>
<codeline lineno="1671"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1672"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1673"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>unlock<sp/>interrupts<sp/>with<sp/>each<sp/>step<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1674"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1675"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>makes<sp/>sure<sp/>interrupt<sp/>protection<sp/>time<sp/>is<sp/>short<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1676"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a3d0e48feafd378e9c26c64567ecd8bab" kindref="member">SYS_ARCH_PROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1677"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(last_select_cb_ctr<sp/>!=<sp/>select_cb_ctr)<sp/>{</highlight></codeline>
<codeline lineno="1678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>someone<sp/>has<sp/>changed<sp/>select_cb_list,<sp/>restart<sp/>at<sp/>the<sp/>beginning<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1679"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>again;</highlight></codeline>
<codeline lineno="1680"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1681"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1682"><highlight class="normal"><sp/><sp/><ref refid="sys_8h_1a2f48e97047945642ddeb27e65bf4ffe2" kindref="member">SYS_ARCH_UNPROTECT</ref>(lev);</highlight></codeline>
<codeline lineno="1683"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1684"><highlight class="normal"></highlight></codeline>
<codeline lineno="1688"><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1689"><highlight class="normal">lwip_shutdown(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>how)</highlight></codeline>
<codeline lineno="1690"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1691"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1692"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1693"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>shut_rx<sp/>=<sp/>0,<sp/>shut_tx<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1694"><highlight class="normal"></highlight></codeline>
<codeline lineno="1695"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_shutdown(%d,<sp/>how=%d)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>how));</highlight></codeline>
<codeline lineno="1696"><highlight class="normal"></highlight></codeline>
<codeline lineno="1697"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="1698"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1699"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1700"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1701"><highlight class="normal"></highlight></codeline>
<codeline lineno="1702"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1703"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1704"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a4b807895c74cea4d0302bf27725d4b9d" kindref="member">EOPNOTSUPP</ref>);</highlight></codeline>
<codeline lineno="1705"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1706"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1707"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1708"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1af23e48762a0676f49d480db91cfd5e4b" kindref="member">ENOTCONN</ref>);</highlight></codeline>
<codeline lineno="1709"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1710"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1711"><highlight class="normal"></highlight></codeline>
<codeline lineno="1712"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(how<sp/>==<sp/>SHUT_RD)<sp/>{</highlight></codeline>
<codeline lineno="1713"><highlight class="normal"><sp/><sp/><sp/><sp/>shut_rx<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1714"><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/>(how<sp/>==<sp/>SHUT_WR)<sp/>{</highlight></codeline>
<codeline lineno="1715"><highlight class="normal"><sp/><sp/><sp/><sp/>shut_tx<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1716"><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/>(how<sp/>==<sp/>SHUT_RDWR)<sp/>{</highlight></codeline>
<codeline lineno="1717"><highlight class="normal"><sp/><sp/><sp/><sp/>shut_rx<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1718"><highlight class="normal"><sp/><sp/><sp/><sp/>shut_tx<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1719"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1720"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>);</highlight></codeline>
<codeline lineno="1721"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1722"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1723"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_shutdown(sock-&gt;conn,<sp/>shut_rx,<sp/>shut_tx);</highlight></codeline>
<codeline lineno="1724"><highlight class="normal"></highlight></codeline>
<codeline lineno="1725"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1726"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref><sp/>?<sp/>0<sp/>:<sp/>-1);</highlight></codeline>
<codeline lineno="1727"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1728"><highlight class="normal"></highlight></codeline>
<codeline lineno="1729"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1730"><highlight class="normal">lwip_getaddrname(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>socklen_t<sp/>*namelen,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>local)</highlight></codeline>
<codeline lineno="1731"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1732"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock;</highlight></codeline>
<codeline lineno="1733"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">union<sp/></highlight><highlight class="normal">sockaddr_aligned<sp/>saddr;</highlight></codeline>
<codeline lineno="1734"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>naddr;</highlight></codeline>
<codeline lineno="1735"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port;</highlight></codeline>
<codeline lineno="1736"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1737"><highlight class="normal"></highlight></codeline>
<codeline lineno="1738"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="1739"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1740"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1741"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1742"><highlight class="normal"></highlight></codeline>
<codeline lineno="1743"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>IP<sp/>address<sp/>and<sp/>port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1744"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>netconn_getaddr(sock-&gt;conn,<sp/>&amp;naddr,<sp/>&amp;port,<sp/>local);</highlight></codeline>
<codeline lineno="1745"><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="1746"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1747"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1748"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1749"><highlight class="normal"></highlight></codeline>
<codeline lineno="1750"><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="1751"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>Map<sp/>IPv4<sp/>addresses<sp/>to<sp/>IPv4<sp/>mapped<sp/>IPv6<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1752"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_ISIPV6(netconn_type(sock-&gt;conn))<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="1753"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1ab1a059f07bd9c50aa58447d963b823a1" kindref="member">IP_IS_V4_VAL</ref>(naddr))<sp/>{</highlight></codeline>
<codeline lineno="1754"><highlight class="normal"><sp/><sp/><sp/><sp/>ip4_2_ipv4_mapped_ipv6(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;naddr),<sp/>ip_2_ip4(&amp;naddr));</highlight></codeline>
<codeline lineno="1755"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(naddr,<sp/><ref refid="group__ipaddr_1ggaf2142f0dfdcc938e2db16aa745ed585caae510fd8ec7fe405b594b57af61f9a02" kindref="member">IPADDR_TYPE_V6</ref>);</highlight></codeline>
<codeline lineno="1756"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1757"><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="1758"><highlight class="normal"></highlight></codeline>
<codeline lineno="1759"><highlight class="normal"><sp/><sp/>IPADDR_PORT_TO_SOCKADDR(&amp;saddr,<sp/>&amp;naddr,<sp/>port);</highlight></codeline>
<codeline lineno="1760"><highlight class="normal"></highlight></codeline>
<codeline lineno="1761"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getaddrname(%d,<sp/>addr=&quot;</highlight><highlight class="normal">,<sp/>s));</highlight></codeline>
<codeline lineno="1762"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1ac3d7eec8027db2203117e6f30df8fba5" kindref="member">ip_addr_debug_print_val</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>naddr);</highlight></codeline>
<codeline lineno="1763"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;<sp/>port=%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>port));</highlight></codeline>
<codeline lineno="1764"><highlight class="normal"></highlight></codeline>
<codeline lineno="1765"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*namelen<sp/>&gt;<sp/>saddr.sa.sa_len)<sp/>{</highlight></codeline>
<codeline lineno="1766"><highlight class="normal"><sp/><sp/><sp/><sp/>*namelen<sp/>=<sp/>saddr.sa.sa_len;</highlight></codeline>
<codeline lineno="1767"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1768"><highlight class="normal"><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>&amp;saddr,<sp/>*namelen);</highlight></codeline>
<codeline lineno="1769"><highlight class="normal"></highlight></codeline>
<codeline lineno="1770"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="1771"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="1772"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1773"><highlight class="normal"></highlight></codeline>
<codeline lineno="1774"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1775"><highlight class="normal">lwip_getpeername(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>socklen_t<sp/>*namelen)</highlight></codeline>
<codeline lineno="1776"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1777"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_getaddrname(s,<sp/><ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>namelen,<sp/>0);</highlight></codeline>
<codeline lineno="1778"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1779"><highlight class="normal"></highlight></codeline>
<codeline lineno="1780"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1781"><highlight class="normal">lwip_getsockname(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>sockaddr<sp/>*<ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>socklen_t<sp/>*namelen)</highlight></codeline>
<codeline lineno="1782"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1783"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lwip_getaddrname(s,<sp/><ref refid="pci_8c_1a8f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/>namelen,<sp/>1);</highlight></codeline>
<codeline lineno="1784"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1785"><highlight class="normal"></highlight></codeline>
<codeline lineno="1786"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1787"><highlight class="normal">lwip_getsockopt(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>*optlen)</highlight></codeline>
<codeline lineno="1788"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1789"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="1790"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="1791"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1792"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_DECLARE(data);</highlight></codeline>
<codeline lineno="1793"><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="1794"><highlight class="normal"></highlight></codeline>
<codeline lineno="1795"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1796"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1797"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1798"><highlight class="normal"></highlight></codeline>
<codeline lineno="1799"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((<ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>==<sp/>optval)<sp/>||<sp/>(<ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>==<sp/>optlen))<sp/>{</highlight></codeline>
<codeline lineno="1800"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a3f317946e043623f9d6b93dbf60e6316" kindref="member">EFAULT</ref>);</highlight></codeline>
<codeline lineno="1801"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1802"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1803"><highlight class="normal"></highlight></codeline>
<codeline lineno="1804"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1805"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>core-locking<sp/>can<sp/>just<sp/>call<sp/>the<sp/>-impl<sp/>function<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1806"><highlight class="normal"><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1807"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>lwip_getsockopt_impl(s,<sp/>level,<sp/>optname,<sp/>optval,<sp/>optlen);</highlight></codeline>
<codeline lineno="1808"><highlight class="normal"><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="1809"><highlight class="normal"></highlight></codeline>
<codeline lineno="1810"><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="1811"><highlight class="normal"></highlight></codeline>
<codeline lineno="1812"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1813"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>MPU_COMPATIBLE<sp/>copies<sp/>the<sp/>optval<sp/>data,<sp/>so<sp/>check<sp/>for<sp/>max<sp/>size<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1814"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*optlen<sp/>&gt;<sp/>LWIP_SETGETSOCKOPT_MAXOPTLEN)<sp/>{</highlight></codeline>
<codeline lineno="1815"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a9e655f47bfd914a1174f281fc31cf63d" kindref="member">ENOBUFS</ref>);</highlight></codeline>
<codeline lineno="1816"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1817"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1818"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1819"><highlight class="normal"></highlight></codeline>
<codeline lineno="1820"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_ALLOC(data,<sp/>sock);</highlight></codeline>
<codeline lineno="1821"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).s<sp/>=<sp/>s;</highlight></codeline>
<codeline lineno="1822"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).level<sp/>=<sp/>level;</highlight></codeline>
<codeline lineno="1823"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optname<sp/>=<sp/>optname;</highlight></codeline>
<codeline lineno="1824"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen<sp/>=<sp/>*optlen;</highlight></codeline>
<codeline lineno="1825"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1826"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval.p<sp/>=<sp/>optval;</highlight></codeline>
<codeline lineno="1827"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>!LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1828"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1829"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1830"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem<sp/>=<sp/>LWIP_NETCONN_THREAD_SEM_GET();</highlight></codeline>
<codeline lineno="1831"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1832"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem<sp/>=<sp/>&amp;sock-&gt;conn-&gt;op_completed;</highlight></codeline>
<codeline lineno="1833"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1834"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="tcpip_8h_1a7eb868a1215472ec38f3f2a04d442b9f" kindref="member">tcpip_callback</ref>(lwip_getsockopt_callback,<sp/>&amp;LWIP_SETGETSOCKOPT_DATA_VAR_REF(data));</highlight></codeline>
<codeline lineno="1835"><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="1836"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_FREE(data);</highlight></codeline>
<codeline lineno="1837"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="1838"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="1839"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1840"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>((<ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*)(LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem),<sp/>0);</highlight></codeline>
<codeline lineno="1841"><highlight class="normal"></highlight></codeline>
<codeline lineno="1842"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>write<sp/>back<sp/>optlen<sp/>and<sp/>optval<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1843"><highlight class="normal"><sp/><sp/>*optlen<sp/>=<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen;</highlight></codeline>
<codeline lineno="1844"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1845"><highlight class="normal"><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(optval,<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval,</highlight></codeline>
<codeline lineno="1846"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen);</highlight></codeline>
<codeline lineno="1847"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1848"><highlight class="normal"></highlight></codeline>
<codeline lineno="1849"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>maybe<sp/>lwip_getsockopt_internal<sp/>has<sp/>changed<sp/>err<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1850"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).err;</highlight></codeline>
<codeline lineno="1851"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_FREE(data);</highlight></codeline>
<codeline lineno="1852"><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="1853"><highlight class="normal"></highlight></codeline>
<codeline lineno="1854"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>err);</highlight></codeline>
<codeline lineno="1855"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err<sp/>?<sp/>-1<sp/>:<sp/>0;</highlight></codeline>
<codeline lineno="1856"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1857"><highlight class="normal"></highlight></codeline>
<codeline lineno="1858"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1859"><highlight class="normal"></highlight></codeline>
<codeline lineno="1862"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1863"><highlight class="normal">lwip_getsockopt_callback(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg)</highlight></codeline>
<codeline lineno="1864"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1865"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_setgetsockopt_data<sp/>*data;</highlight></codeline>
<codeline lineno="1866"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;arg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>arg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="1867"><highlight class="normal"><sp/><sp/>data<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_setgetsockopt_data*)arg;</highlight></codeline>
<codeline lineno="1868"><highlight class="normal"></highlight></codeline>
<codeline lineno="1869"><highlight class="normal"><sp/><sp/>data-&gt;err<sp/>=<sp/>lwip_getsockopt_impl(data-&gt;s,<sp/>data-&gt;level,<sp/>data-&gt;optname,</highlight></codeline>
<codeline lineno="1870"><highlight class="normal">#</highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/><ref refid="lwipopts_8h_1ae9afcefa5d233372abb9413188dd98c9" kindref="member">LWIP_MPU_COMPATIBLE</ref></highlight></codeline>
<codeline lineno="1871"><highlight class="normal"><sp/><sp/><sp/><sp/>data-&gt;optval,</highlight></codeline>
<codeline lineno="1872"><highlight class="normal">#</highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1873"><highlight class="normal"><sp/><sp/><sp/><sp/>data-&gt;optval.p,</highlight></codeline>
<codeline lineno="1874"><highlight class="normal">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1875"><highlight class="normal"><sp/><sp/><sp/><sp/>&amp;data-&gt;optlen);</highlight></codeline>
<codeline lineno="1876"><highlight class="normal"></highlight></codeline>
<codeline lineno="1877"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>((<ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*)(data-&gt;completed_sem));</highlight></codeline>
<codeline lineno="1878"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1879"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/><sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1880"><highlight class="normal"></highlight></codeline>
<codeline lineno="1884"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref></highlight></codeline>
<codeline lineno="1885"><highlight class="normal">lwip_getsockopt_impl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>*optlen)</highlight></codeline>
<codeline lineno="1886"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1887"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1888"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>tryget_socket(s);</highlight></codeline>
<codeline lineno="1889"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="1890"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1ac54507d66b43ad12f9356257323c0018" kindref="member">EBADF</ref>;</highlight></codeline>
<codeline lineno="1891"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1892"><highlight class="normal"></highlight></codeline>
<codeline lineno="1893"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(level)<sp/>{</highlight></codeline>
<codeline lineno="1894"><highlight class="normal"></highlight></codeline>
<codeline lineno="1895"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>SOL_SOCKET<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1896"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SOL_SOCKET:</highlight></codeline>
<codeline lineno="1897"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="1898"><highlight class="normal"></highlight></codeline>
<codeline lineno="1899"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1900"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_ACCEPTCONN:</highlight></codeline>
<codeline lineno="1901"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="1902"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(sock-&gt;conn-&gt;type)<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="1903"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="1904"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1905"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((sock-&gt;conn-&gt;pcb.tcp<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>&amp;&amp;<sp/>(sock-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>==<sp/>LISTEN))<sp/>{</highlight></codeline>
<codeline lineno="1906"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1907"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1908"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1909"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1910"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1911"><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="1912"><highlight class="normal"></highlight></codeline>
<codeline lineno="1913"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>option<sp/>flags<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1914"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_BROADCAST:</highlight></codeline>
<codeline lineno="1915"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_KEEPALIVE:</highlight></codeline>
<codeline lineno="1916"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1917"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_REUSEADDR:</highlight></codeline>
<codeline lineno="1918"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1919"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="1920"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/><ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(sock-&gt;conn-&gt;pcb.ip,<sp/>optname);</highlight></codeline>
<codeline lineno="1921"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>SOL_SOCKET,<sp/>optname=0x%x,<sp/>..)<sp/>=<sp/>%s\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1922"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname,<sp/>(*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval?</highlight><highlight class="stringliteral">&quot;on&quot;</highlight><highlight class="normal">:</highlight><highlight class="stringliteral">&quot;off&quot;</highlight><highlight class="normal">)));</highlight></codeline>
<codeline lineno="1923"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1924"><highlight class="normal"></highlight></codeline>
<codeline lineno="1925"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_TYPE:</highlight></codeline>
<codeline lineno="1926"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="1927"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="1928"><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="1929"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>SOCK_RAW;</highlight></codeline>
<codeline lineno="1930"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1931"><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="1932"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>SOCK_STREAM;</highlight></codeline>
<codeline lineno="1933"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1934"><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="1935"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>SOCK_DGRAM;</highlight></codeline>
<codeline lineno="1936"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1937"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:<sp/></highlight><highlight class="comment">/*<sp/>unrecognized<sp/>socket<sp/>type<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1938"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>netconn_type(sock-&gt;conn);</highlight></codeline>
<codeline lineno="1939"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,</highlight></codeline>
<codeline lineno="1940"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>SOL_SOCKET,<sp/>SO_TYPE):<sp/>unrecognized<sp/>socket<sp/>type<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1941"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="1942"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(netconn_type(sock-&gt;conn))<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1943"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>SOL_SOCKET,<sp/>SO_TYPE)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1944"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="1945"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1946"><highlight class="normal"></highlight></codeline>
<codeline lineno="1947"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_ERROR:</highlight></codeline>
<codeline lineno="1948"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN(*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="1949"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>only<sp/>overwrite<sp/>ERR_OK<sp/>or<sp/>temporary<sp/>errors<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1950"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((sock-&gt;err<sp/>==<sp/>0)<sp/>||<sp/>(sock-&gt;err<sp/>==<sp/><ref refid="sys_2errno_8h_1a6c045d5be06e715cc335784a7320714e" kindref="member">EINPROGRESS</ref>))<sp/>&amp;&amp;<sp/>(sock-&gt;conn<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>))<sp/>{</highlight></codeline>
<codeline lineno="1951"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(sock-&gt;conn-&gt;last_err));</highlight></codeline>
<codeline lineno="1952"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1953"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>=<sp/>(sock-&gt;err<sp/>==<sp/>0xFF<sp/>?<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)-1<sp/>:<sp/>(int)sock-&gt;err);</highlight></codeline>
<codeline lineno="1954"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1955"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>SOL_SOCKET,<sp/>SO_ERROR)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1956"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="1957"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1958"><highlight class="normal"></highlight></codeline>
<codeline lineno="1959"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1960"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_SNDTIMEO:</highlight></codeline>
<codeline lineno="1961"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE);</highlight></codeline>
<codeline lineno="1962"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SO_SNDRCVTIMEO_SET(optval,<sp/>netconn_get_sendtimeout(sock-&gt;conn));</highlight></codeline>
<codeline lineno="1963"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1964"><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="1965"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1966"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_RCVTIMEO:</highlight></codeline>
<codeline lineno="1967"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE);</highlight></codeline>
<codeline lineno="1968"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SO_SNDRCVTIMEO_SET(optval,<sp/>netconn_get_recvtimeout(sock-&gt;conn));</highlight></codeline>
<codeline lineno="1969"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1970"><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="1971"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1972"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_RCVBUF:</highlight></codeline>
<codeline lineno="1973"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="1974"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>=<sp/>netconn_get_recvbufsize(sock-&gt;conn);</highlight></codeline>
<codeline lineno="1975"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1976"><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="1977"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1978"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_LINGER:</highlight></codeline>
<codeline lineno="1979"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="1980"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>conn_linger;</highlight></codeline>
<codeline lineno="1981"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">linger*<sp/>linger<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">linger*)optval;</highlight></codeline>
<codeline lineno="1982"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>linger);</highlight></codeline>
<codeline lineno="1983"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>conn_linger<sp/>=<sp/>sock-&gt;conn-&gt;linger;</highlight></codeline>
<codeline lineno="1984"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(conn_linger<sp/>&gt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1985"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>linger-&gt;l_onoff<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="1986"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>linger-&gt;l_linger<sp/>=<sp/>(int)conn_linger;</highlight></codeline>
<codeline lineno="1987"><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="1988"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>linger-&gt;l_onoff<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1989"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>linger-&gt;l_linger<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1990"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1991"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1992"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1993"><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="1994"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1995"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_NO_CHECK:</highlight></codeline>
<codeline lineno="1996"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="1997"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1998"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>&amp;<sp/>UDP_FLAGS_UDPLITE)<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="1999"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>flag<sp/>is<sp/>only<sp/>available<sp/>for<sp/>UDP,<sp/>not<sp/>for<sp/>UDP<sp/>lite<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2000"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a4c3a793b4d51cb7dd020af92e536fe21" kindref="member">EAFNOSUPPORT</ref>;</highlight></codeline>
<codeline lineno="2001"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2002"><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="2003"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>&amp;<sp/>UDP_FLAGS_NOCHKSUM)<sp/>?<sp/>1<sp/>:<sp/>0;</highlight></codeline>
<codeline lineno="2004"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2005"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2006"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2007"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>SOL_SOCKET,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2008"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2009"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2010"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2011"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2012"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2013"><highlight class="normal"></highlight></codeline>
<codeline lineno="2014"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2015"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_IP:</highlight></codeline>
<codeline lineno="2016"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2017"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_TTL:</highlight></codeline>
<codeline lineno="2018"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2019"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>sock-&gt;conn-&gt;pcb.ip-&gt;ttl;</highlight></codeline>
<codeline lineno="2020"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_TTL)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2021"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2022"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2023"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_TOS:</highlight></codeline>
<codeline lineno="2024"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2025"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>sock-&gt;conn-&gt;pcb.ip-&gt;tos;</highlight></codeline>
<codeline lineno="2026"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_TOS)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2027"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2028"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2029"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MULTICAST_TX_OPTIONS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2030"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_TTL:</highlight></codeline>
<codeline lineno="2031"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>);</highlight></codeline>
<codeline lineno="2032"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="2033"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2034"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2035"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)optval<sp/>=<sp/>udp_get_multicast_ttl(sock-&gt;conn-&gt;pcb.udp);</highlight></codeline>
<codeline lineno="2036"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_MULTICAST_TTL)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2037"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2038"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2039"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_IF:</highlight></codeline>
<codeline lineno="2040"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structin__addr" kindref="compound">in_addr</ref>);</highlight></codeline>
<codeline lineno="2041"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="2042"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2043"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2044"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>inet_addr_from_ip4addr((</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structin__addr" kindref="compound">in_addr</ref>*)optval,<sp/>udp_get_multicast_netif_addr(sock-&gt;conn-&gt;pcb.udp));</highlight></codeline>
<codeline lineno="2045"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_MULTICAST_IF)<sp/>=<sp/>0x%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gac219830a93d05c5f18f64ce87a34be14" kindref="member">X32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2046"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>*)optval));</highlight></codeline>
<codeline lineno="2047"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2048"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_LOOP:</highlight></codeline>
<codeline lineno="2049"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>);</highlight></codeline>
<codeline lineno="2050"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((sock-&gt;conn-&gt;pcb.udp-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_MULTICAST_LOOP)<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2051"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)optval<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="2052"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2053"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)optval<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2054"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2055"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_MULTICAST_LOOP)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2056"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2057"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2058"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MULTICAST_TX_OPTIONS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2059"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2060"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IP,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2061"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2062"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2063"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2064"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2065"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2066"><highlight class="normal"></highlight></codeline>
<codeline lineno="2067"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2068"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_TCP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2069"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_TCP:</highlight></codeline>
<codeline lineno="2070"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Special<sp/>case:<sp/>all<sp/>IPPROTO_TCP<sp/>option<sp/>take<sp/>an<sp/>int<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2071"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_TCP);</highlight></codeline>
<codeline lineno="2072"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>==<sp/>LISTEN)<sp/>{</highlight></codeline>
<codeline lineno="2073"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>;</highlight></codeline>
<codeline lineno="2074"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2075"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2076"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_NODELAY:</highlight></codeline>
<codeline lineno="2077"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>tcp_nagle_disabled(sock-&gt;conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="2078"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_NODELAY)<sp/>=<sp/>%s\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2079"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval)?</highlight><highlight class="stringliteral">&quot;on&quot;</highlight><highlight class="normal">:</highlight><highlight class="stringliteral">&quot;off&quot;</highlight><highlight class="normal">)<sp/>);</highlight></codeline>
<codeline lineno="2080"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2081"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPALIVE:</highlight></codeline>
<codeline lineno="2082"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle;</highlight></codeline>
<codeline lineno="2083"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPALIVE)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2084"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2085"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2086"><highlight class="normal"></highlight></codeline>
<codeline lineno="2087"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_KEEPALIVE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2088"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPIDLE:</highlight></codeline>
<codeline lineno="2089"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)(sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle/1000);</highlight></codeline>
<codeline lineno="2090"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPIDLE)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2091"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2092"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2093"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPINTVL:</highlight></codeline>
<codeline lineno="2094"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)(sock-&gt;conn-&gt;pcb.tcp-&gt;keep_intvl/1000);</highlight></codeline>
<codeline lineno="2095"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPINTVL)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2096"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2097"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2098"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPCNT:</highlight></codeline>
<codeline lineno="2099"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)sock-&gt;conn-&gt;pcb.tcp-&gt;keep_cnt;</highlight></codeline>
<codeline lineno="2100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPCNT)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2101"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2102"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2103"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_KEEPALIVE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2104"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2105"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_TCP,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2107"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2108"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2109"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2110"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2111"><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="2112"><highlight class="normal"></highlight></codeline>
<codeline lineno="2113"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2114"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_IPV6<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2115"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_IPV6:</highlight></codeline>
<codeline lineno="2116"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2117"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPV6_V6ONLY:</highlight></codeline>
<codeline lineno="2118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>(netconn_get_ipv6only(sock-&gt;conn)<sp/>?<sp/>1<sp/>:<sp/>0);</highlight></codeline>
<codeline lineno="2120"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IPV6,<sp/>IPV6_V6ONLY)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2121"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval));</highlight></codeline>
<codeline lineno="2122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2123"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_IPV6,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2125"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2126"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2128"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2129"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2130"><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="2131"><highlight class="normal"></highlight></codeline>
<codeline lineno="2132"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP<sp/>&amp;&amp;<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2133"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_UDPLITE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2134"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_UDPLITE:</highlight></codeline>
<codeline lineno="2135"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Special<sp/>case:<sp/>all<sp/>IPPROTO_UDPLITE<sp/>option<sp/>take<sp/>an<sp/>int<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2136"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2137"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>no<sp/>UDP<sp/>lite<sp/>socket,<sp/>ignore<sp/>any<sp/>options.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2138"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!NETCONNTYPE_ISUDPLITE(netconn_type(sock-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="2139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2140"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2141"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2142"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>UDPLITE_SEND_CSCOV:</highlight></codeline>
<codeline lineno="2143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_tx;</highlight></codeline>
<codeline lineno="2144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UDPLITE_SEND_CSCOV)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval))<sp/>);</highlight></codeline>
<codeline lineno="2146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2147"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>UDPLITE_RECV_CSCOV:</highlight></codeline>
<codeline lineno="2148"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>=<sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_rx;</highlight></codeline>
<codeline lineno="2149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UDPLITE_RECV_CSCOV)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval))<sp/>);</highlight></codeline>
<codeline lineno="2151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2152"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2155"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2157"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2158"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2159"><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="2160"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_RAW<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2161"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_RAW:</highlight></codeline>
<codeline lineno="2162"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2163"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2164"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPV6_CHECKSUM:</highlight></codeline>
<codeline lineno="2165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>*optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_RAW);</highlight></codeline>
<codeline lineno="2166"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;conn-&gt;pcb.raw-&gt;chksum_reqd<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2167"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="2168"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2169"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>=<sp/>sock-&gt;conn-&gt;pcb.raw-&gt;chksum_offset;</highlight></codeline>
<codeline lineno="2170"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2171"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_RAW,<sp/>IPV6_CHECKSUM)<sp/>=<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2172"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval))<sp/>);</highlight></codeline>
<codeline lineno="2173"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2174"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2175"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2176"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>IPPROTO_RAW,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2177"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2178"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2179"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2180"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2181"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2182"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2183"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_getsockopt(%d,<sp/>level=0x%x,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2184"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>level,<sp/>optname));</highlight></codeline>
<codeline lineno="2185"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2186"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2187"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(level)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2188"><highlight class="normal"></highlight></codeline>
<codeline lineno="2189"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="2190"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2191"><highlight class="normal"></highlight></codeline>
<codeline lineno="2192"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2193"><highlight class="normal">lwip_setsockopt(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>optlen)</highlight></codeline>
<codeline lineno="2194"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2195"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2196"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2197"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2198"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2199"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_DECLARE(data);</highlight></codeline>
<codeline lineno="2200"><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="2201"><highlight class="normal"></highlight></codeline>
<codeline lineno="2202"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2203"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2204"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2205"><highlight class="normal"></highlight></codeline>
<codeline lineno="2206"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>==<sp/>optval)<sp/>{</highlight></codeline>
<codeline lineno="2207"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a3f317946e043623f9d6b93dbf60e6316" kindref="member">EFAULT</ref>);</highlight></codeline>
<codeline lineno="2208"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2209"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2210"><highlight class="normal"></highlight></codeline>
<codeline lineno="2211"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2212"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2213"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>core-locking<sp/>can<sp/>just<sp/>call<sp/>the<sp/>-impl<sp/>function<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2214"><highlight class="normal"><sp/><sp/><ref refid="tcpip_8h_1a4700525e737fc025fea4887b172e0c95" kindref="member">LOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="2215"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>lwip_setsockopt_impl(s,<sp/>level,<sp/>optname,<sp/>optval,<sp/>optlen);</highlight></codeline>
<codeline lineno="2216"><highlight class="normal"><sp/><sp/><ref refid="tcpip_8h_1a915effea029b9c4891e1ec635eb1826d" kindref="member">UNLOCK_TCPIP_CORE</ref>();</highlight></codeline>
<codeline lineno="2217"><highlight class="normal"></highlight></codeline>
<codeline lineno="2218"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2219"><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="2220"><highlight class="normal"></highlight></codeline>
<codeline lineno="2221"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2222"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2223"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>MPU_COMPATIBLE<sp/>copies<sp/>the<sp/>optval<sp/>data,<sp/>so<sp/>check<sp/>for<sp/>max<sp/>size<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2224"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(optlen<sp/>&gt;<sp/>LWIP_SETGETSOCKOPT_MAXOPTLEN)<sp/>{</highlight></codeline>
<codeline lineno="2225"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a9e655f47bfd914a1174f281fc31cf63d" kindref="member">ENOBUFS</ref>);</highlight></codeline>
<codeline lineno="2226"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2227"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2228"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2229"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2230"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2231"><highlight class="normal"></highlight></codeline>
<codeline lineno="2232"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_ALLOC(data,<sp/>sock);</highlight></codeline>
<codeline lineno="2233"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).s<sp/>=<sp/>s;</highlight></codeline>
<codeline lineno="2234"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).level<sp/>=<sp/>level;</highlight></codeline>
<codeline lineno="2235"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optname<sp/>=<sp/>optname;</highlight></codeline>
<codeline lineno="2236"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen<sp/>=<sp/>optlen;</highlight></codeline>
<codeline lineno="2237"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MPU_COMPATIBLE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2238"><highlight class="normal"><sp/><sp/><ref refid="lwipopts_8h_1aa1dd57a66b6de8c0593e9e3e8d1411f6" kindref="member">MEMCPY</ref>(LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval,<sp/>optval,<sp/>optlen);</highlight></codeline>
<codeline lineno="2239"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2240"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval.pc<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)optval;</highlight></codeline>
<codeline lineno="2241"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2242"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2243"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_NETCONN_SEM_PER_THREAD</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2244"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem<sp/>=<sp/>LWIP_NETCONN_THREAD_SEM_GET();</highlight></codeline>
<codeline lineno="2245"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2246"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem<sp/>=<sp/>&amp;sock-&gt;conn-&gt;op_completed;</highlight></codeline>
<codeline lineno="2247"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2248"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="tcpip_8h_1a7eb868a1215472ec38f3f2a04d442b9f" kindref="member">tcpip_callback</ref>(lwip_setsockopt_callback,<sp/>&amp;LWIP_SETGETSOCKOPT_DATA_VAR_REF(data));</highlight></codeline>
<codeline lineno="2249"><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="2250"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_FREE(data);</highlight></codeline>
<codeline lineno="2251"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="err_8h_1af6382b3192357c2fb582c84c48bdda40" kindref="member">err_to_errno</ref>(err));</highlight></codeline>
<codeline lineno="2252"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2253"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2254"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1ga28aa725e8a36dd0cfde89875af4f3ec9" kindref="member">sys_arch_sem_wait</ref>((<ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*)(LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).completed_sem),<sp/>0);</highlight></codeline>
<codeline lineno="2255"><highlight class="normal"></highlight></codeline>
<codeline lineno="2256"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>maybe<sp/>lwip_getsockopt_internal<sp/>has<sp/>changed<sp/>err<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2257"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).err;</highlight></codeline>
<codeline lineno="2258"><highlight class="normal"><sp/><sp/>LWIP_SETGETSOCKOPT_DATA_VAR_FREE(data);</highlight></codeline>
<codeline lineno="2259"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/><sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2260"><highlight class="normal"></highlight></codeline>
<codeline lineno="2261"><highlight class="normal"><ref refid="kprintf_8h_1a20b56810edb62a6fe59917015c30848f" kindref="member">kprintf</ref>(</highlight><highlight class="stringliteral">&quot;%s:%i:<sp/>%i&quot;</highlight><highlight class="normal">,<sp/>__FILE__,<sp/>__LINE__,<sp/>err);</highlight></codeline>
<codeline lineno="2262"><highlight class="normal"></highlight></codeline>
<codeline lineno="2263"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/>err);</highlight></codeline>
<codeline lineno="2264"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err<sp/>?<sp/>-1<sp/>:<sp/>0;</highlight></codeline>
<codeline lineno="2265"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2266"><highlight class="normal"></highlight></codeline>
<codeline lineno="2267"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>!LWIP_TCPIP_CORE_LOCKING</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2268"><highlight class="normal"></highlight></codeline>
<codeline lineno="2271"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2272"><highlight class="normal">lwip_setsockopt_callback(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*arg)</highlight></codeline>
<codeline lineno="2273"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2274"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_setgetsockopt_data<sp/>*data;</highlight></codeline>
<codeline lineno="2275"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;arg<sp/>!=<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>arg<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="2276"><highlight class="normal"><sp/><sp/>data<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_setgetsockopt_data*)arg;</highlight></codeline>
<codeline lineno="2277"><highlight class="normal"></highlight></codeline>
<codeline lineno="2278"><highlight class="normal"><sp/><sp/>data-&gt;err<sp/>=<sp/>lwip_setsockopt_impl(data-&gt;s,<sp/>data-&gt;level,<sp/>data-&gt;optname,</highlight></codeline>
<codeline lineno="2279"><highlight class="normal">#</highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/><ref refid="lwipopts_8h_1ae9afcefa5d233372abb9413188dd98c9" kindref="member">LWIP_MPU_COMPATIBLE</ref></highlight></codeline>
<codeline lineno="2280"><highlight class="normal"><sp/><sp/><sp/><sp/>data-&gt;optval,</highlight></codeline>
<codeline lineno="2281"><highlight class="normal">#</highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2282"><highlight class="normal"><sp/><sp/><sp/><sp/>data-&gt;optval.pc,</highlight></codeline>
<codeline lineno="2283"><highlight class="normal">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MPU_COMPATIBLE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2284"><highlight class="normal"><sp/><sp/><sp/><sp/>data-&gt;optlen);</highlight></codeline>
<codeline lineno="2285"><highlight class="normal"></highlight></codeline>
<codeline lineno="2286"><highlight class="normal"><sp/><sp/><ref refid="group__sys__sem_1gaff1dd2af219b75ae812e0b1660bd7455" kindref="member">sys_sem_signal</ref>((<ref refid="structsys__sem" kindref="compound">sys_sem_t</ref>*)(data-&gt;completed_sem));</highlight></codeline>
<codeline lineno="2287"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2288"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/><sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCPIP_CORE_LOCKING<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2289"><highlight class="normal"></highlight></codeline>
<codeline lineno="2293"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref></highlight></codeline>
<codeline lineno="2294"><highlight class="normal">lwip_setsockopt_impl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>level,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>optname,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*optval,<sp/>socklen_t<sp/>optlen)</highlight></codeline>
<codeline lineno="2295"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2296"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>err<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2297"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>tryget_socket(s);</highlight></codeline>
<codeline lineno="2298"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2299"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1ac54507d66b43ad12f9356257323c0018" kindref="member">EBADF</ref>;</highlight></codeline>
<codeline lineno="2300"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2301"><highlight class="normal"></highlight></codeline>
<codeline lineno="2302"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(level)<sp/>{</highlight></codeline>
<codeline lineno="2303"><highlight class="normal"></highlight></codeline>
<codeline lineno="2304"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>SOL_SOCKET<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2305"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SOL_SOCKET:</highlight></codeline>
<codeline lineno="2306"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2307"><highlight class="normal"></highlight></codeline>
<codeline lineno="2308"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>SO_ACCEPTCONN<sp/>is<sp/>get-only<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2309"><highlight class="normal"></highlight></codeline>
<codeline lineno="2310"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>option<sp/>flags<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2311"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_BROADCAST:</highlight></codeline>
<codeline lineno="2312"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_KEEPALIVE:</highlight></codeline>
<codeline lineno="2313"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2314"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_REUSEADDR:</highlight></codeline>
<codeline lineno="2315"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2316"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2317"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval)<sp/>{</highlight></codeline>
<codeline lineno="2318"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a13f48cf825c7f074dc05bea54e9d6a93" kindref="member">ip_set_option</ref>(sock-&gt;conn-&gt;pcb.ip,<sp/>optname);</highlight></codeline>
<codeline lineno="2319"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2320"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a441c63f00c4b0cb69fc34ca6b55307cc" kindref="member">ip_reset_option</ref>(sock-&gt;conn-&gt;pcb.ip,<sp/>optname);</highlight></codeline>
<codeline lineno="2321"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2322"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>SOL_SOCKET,<sp/>optname=0x%x,<sp/>..)<sp/>-&gt;<sp/>%s\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname,<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval?</highlight><highlight class="stringliteral">&quot;on&quot;</highlight><highlight class="normal">:</highlight><highlight class="stringliteral">&quot;off&quot;</highlight><highlight class="normal">)));</highlight></codeline>
<codeline lineno="2324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2325"><highlight class="normal"></highlight></codeline>
<codeline lineno="2326"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>SO_TYPE<sp/>is<sp/>get-only<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2327"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>SO_ERROR<sp/>is<sp/>get-only<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2328"><highlight class="normal"></highlight></codeline>
<codeline lineno="2329"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_SNDTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2330"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_SNDTIMEO:</highlight></codeline>
<codeline lineno="2331"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>optlen,<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE);</highlight></codeline>
<codeline lineno="2332"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_sendtimeout(sock-&gt;conn,<sp/>LWIP_SO_SNDRCVTIMEO_GET_MS(optval));</highlight></codeline>
<codeline lineno="2333"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2334"><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="2335"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVTIMEO</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2336"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_RCVTIMEO:</highlight></codeline>
<codeline lineno="2337"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>optlen,<sp/>LWIP_SO_SNDRCVTIMEO_OPTTYPE);</highlight></codeline>
<codeline lineno="2338"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_recvtimeout(sock-&gt;conn,<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)LWIP_SO_SNDRCVTIMEO_GET_MS(optval));</highlight></codeline>
<codeline lineno="2339"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2340"><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="2341"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2342"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_RCVBUF:</highlight></codeline>
<codeline lineno="2343"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2344"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_recvbufsize(sock-&gt;conn,<sp/>*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2346"><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="2347"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_LINGER</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2348"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_LINGER:</highlight></codeline>
<codeline lineno="2349"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="2350"><highlight class="normal"><sp/><sp/><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">linger*<sp/>linger<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">linger*)optval;</highlight></codeline>
<codeline lineno="2351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock,<sp/>optlen,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>linger);</highlight></codeline>
<codeline lineno="2352"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(linger-&gt;l_onoff)<sp/>{</highlight></codeline>
<codeline lineno="2353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>lingersec<sp/>=<sp/>linger-&gt;l_linger;</highlight></codeline>
<codeline lineno="2354"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lingersec<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>;</highlight></codeline>
<codeline lineno="2356"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(lingersec<sp/>&gt;<sp/>0xFFFF)<sp/>{</highlight></codeline>
<codeline lineno="2358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lingersec<sp/>=<sp/>0xFFFF;</highlight></codeline>
<codeline lineno="2359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2360"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;linger<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)lingersec;</highlight></codeline>
<codeline lineno="2361"><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="2362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;linger<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="2363"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2366"><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="2367"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2368"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SO_NO_CHECK:</highlight></codeline>
<codeline lineno="2369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="2370"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2371"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>&amp;<sp/>UDP_FLAGS_UDPLITE)<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>this<sp/>flag<sp/>is<sp/>only<sp/>available<sp/>for<sp/>UDP,<sp/>not<sp/>for<sp/>UDP<sp/>lite<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a4c3a793b4d51cb7dd020af92e536fe21" kindref="member">EAFNOSUPPORT</ref>;</highlight></codeline>
<codeline lineno="2374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2375"><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="2376"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval)<sp/>{</highlight></codeline>
<codeline lineno="2377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(sock-&gt;conn-&gt;pcb.udp,<sp/>udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>|<sp/>UDP_FLAGS_NOCHKSUM);</highlight></codeline>
<codeline lineno="2378"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2379"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(sock-&gt;conn-&gt;pcb.udp,<sp/>udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>&amp;<sp/>~UDP_FLAGS_NOCHKSUM);</highlight></codeline>
<codeline lineno="2380"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2381"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2382"><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="2383"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2384"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>SOL_SOCKET,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2385"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2387"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2388"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2389"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2390"><highlight class="normal"></highlight></codeline>
<codeline lineno="2391"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2392"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_IP:</highlight></codeline>
<codeline lineno="2393"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2394"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_TTL:</highlight></codeline>
<codeline lineno="2395"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.ip-&gt;ttl<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_TTL,<sp/>..)<sp/>-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2398"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.ip-&gt;ttl));</highlight></codeline>
<codeline lineno="2399"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2400"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_TOS:</highlight></codeline>
<codeline lineno="2401"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.ip-&gt;tos<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2403"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_IP,<sp/>IP_TOS,<sp/>..)-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2404"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.ip-&gt;tos));</highlight></codeline>
<codeline lineno="2405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2406"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MULTICAST_TX_OPTIONS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2407"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_TTL:</highlight></codeline>
<codeline lineno="2408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="2409"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>udp_set_multicast_ttl(sock-&gt;conn-&gt;pcb.udp,<sp/>(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)optval));</highlight></codeline>
<codeline lineno="2410"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2411"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_IF:</highlight></codeline>
<codeline lineno="2412"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="2413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_t<sp/>if_addr;</highlight></codeline>
<codeline lineno="2414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structin__addr" kindref="compound">in_addr</ref>,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="2415"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inet_addr_to_ip4addr(&amp;if_addr,<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structin__addr" kindref="compound">in_addr</ref>*)optval);</highlight></codeline>
<codeline lineno="2416"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_set_multicast_netif_addr(sock-&gt;conn-&gt;pcb.udp,<sp/>&amp;if_addr);</highlight></codeline>
<codeline lineno="2417"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2418"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2419"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_MULTICAST_LOOP:</highlight></codeline>
<codeline lineno="2420"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="2421"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref>*)optval)<sp/>{</highlight></codeline>
<codeline lineno="2422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(sock-&gt;conn-&gt;pcb.udp,<sp/>udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>|<sp/>UDP_FLAGS_MULTICAST_LOOP);</highlight></codeline>
<codeline lineno="2423"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_setflags(sock-&gt;conn-&gt;pcb.udp,<sp/>udp_flags(sock-&gt;conn-&gt;pcb.udp)<sp/>&amp;<sp/>~UDP_FLAGS_MULTICAST_LOOP);</highlight></codeline>
<codeline lineno="2425"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2427"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MULTICAST_TX_OPTIONS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2428"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2429"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_ADD_MEMBERSHIP:</highlight></codeline>
<codeline lineno="2430"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IP_DROP_MEMBERSHIP:</highlight></codeline>
<codeline lineno="2431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="2432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>TCP<sp/>or<sp/>a<sp/>RAW<sp/>socket,<sp/>ignore<sp/>these<sp/>options.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2433"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>assign<sp/>membership<sp/>to<sp/>this<sp/>socket<sp/>so<sp/>that<sp/>it<sp/>is<sp/>dropped<sp/>when<sp/>closing<sp/>the<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2434"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>igmp_err;</highlight></codeline>
<codeline lineno="2435"><highlight class="normal"><sp/><sp/><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">ip_mreq<sp/>*imr<sp/>=<sp/>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">ip_mreq<sp/>*)optval;</highlight></codeline>
<codeline lineno="2436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_t<sp/>if_addr;</highlight></codeline>
<codeline lineno="2437"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_t<sp/>multi_addr;</highlight></codeline>
<codeline lineno="2438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>ip_mreq,<sp/>NETCONN_UDP);</highlight></codeline>
<codeline lineno="2439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inet_addr_to_ip4addr(&amp;if_addr,<sp/>&amp;imr-&gt;imr_interface);</highlight></codeline>
<codeline lineno="2440"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inet_addr_to_ip4addr(&amp;multi_addr,<sp/>&amp;imr-&gt;imr_multiaddr);</highlight></codeline>
<codeline lineno="2441"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(optname<sp/>==<sp/>IP_ADD_MEMBERSHIP)<sp/>{</highlight></codeline>
<codeline lineno="2442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!lwip_socket_register_membership(s,<sp/>&amp;if_addr,<sp/>&amp;multi_addr))<sp/>{</highlight></codeline>
<codeline lineno="2443"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>cannot<sp/>track<sp/>membership<sp/>(out<sp/>of<sp/>memory)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2444"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1a6a05c923dad0c1208043e9c20a58c8e5" kindref="member">ENOMEM</ref>;</highlight></codeline>
<codeline lineno="2445"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>igmp_err<sp/>=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="2446"><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="2447"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>igmp_err<sp/>=<sp/>igmp_joingroup(&amp;if_addr,<sp/>&amp;multi_addr);</highlight></codeline>
<codeline lineno="2448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2449"><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="2450"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>igmp_err<sp/>=<sp/>igmp_leavegroup(&amp;if_addr,<sp/>&amp;multi_addr);</highlight></codeline>
<codeline lineno="2451"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lwip_socket_unregister_membership(s,<sp/>&amp;if_addr,<sp/>&amp;multi_addr);</highlight></codeline>
<codeline lineno="2452"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2453"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(igmp_err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="2454"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1a556612e55358838192165684c971a44f" kindref="member">EADDRNOTAVAIL</ref>;</highlight></codeline>
<codeline lineno="2455"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2456"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2457"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2458"><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="2459"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2460"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_IP,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2461"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2462"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2463"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2464"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2465"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2466"><highlight class="normal"></highlight></codeline>
<codeline lineno="2467"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2468"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_TCP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2469"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_TCP:</highlight></codeline>
<codeline lineno="2470"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Special<sp/>case:<sp/>all<sp/>IPPROTO_TCP<sp/>option<sp/>take<sp/>an<sp/>int<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2471"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_TCP);</highlight></codeline>
<codeline lineno="2472"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;conn-&gt;pcb.tcp-&gt;state<sp/>==<sp/>LISTEN)<sp/>{</highlight></codeline>
<codeline lineno="2473"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>;</highlight></codeline>
<codeline lineno="2474"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2475"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2476"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_NODELAY:</highlight></codeline>
<codeline lineno="2477"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval)<sp/>{</highlight></codeline>
<codeline lineno="2478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_nagle_disable(sock-&gt;conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="2479"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2480"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>tcp_nagle_enable(sock-&gt;conn-&gt;pcb.tcp);</highlight></codeline>
<codeline lineno="2481"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2482"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_NODELAY)<sp/>-&gt;<sp/>%s\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2483"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval)?</highlight><highlight class="stringliteral">&quot;on&quot;</highlight><highlight class="normal">:</highlight><highlight class="stringliteral">&quot;off&quot;</highlight><highlight class="normal">)<sp/>);</highlight></codeline>
<codeline lineno="2484"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2485"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPALIVE:</highlight></codeline>
<codeline lineno="2486"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2487"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPALIVE)<sp/>-&gt;<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2488"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle));</highlight></codeline>
<codeline lineno="2489"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2490"><highlight class="normal"></highlight></codeline>
<codeline lineno="2491"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_TCP_KEEPALIVE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2492"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPIDLE:</highlight></codeline>
<codeline lineno="2493"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle<sp/>=<sp/>1000*(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2494"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPIDLE)<sp/>-&gt;<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2495"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_idle));</highlight></codeline>
<codeline lineno="2496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2497"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPINTVL:</highlight></codeline>
<codeline lineno="2498"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_intvl<sp/>=<sp/>1000*(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2499"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPINTVL)<sp/>-&gt;<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2500"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_intvl));</highlight></codeline>
<codeline lineno="2501"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2502"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>TCP_KEEPCNT:</highlight></codeline>
<codeline lineno="2503"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_cnt<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>)(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval);</highlight></codeline>
<codeline lineno="2504"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>TCP_KEEPCNT)<sp/>-&gt;<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gad8b0a364e95b07cb0c47709fdc6037d6" kindref="member">U32_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2505"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.tcp-&gt;keep_cnt));</highlight></codeline>
<codeline lineno="2506"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2507"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP_KEEPALIVE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2508"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2509"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_TCP,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2510"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2511"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2512"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2513"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2514"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2515"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_TCP*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2516"><highlight class="normal"></highlight></codeline>
<codeline lineno="2517"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2518"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_IPV6<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2519"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_IPV6:</highlight></codeline>
<codeline lineno="2520"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2521"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPV6_V6ONLY:</highlight></codeline>
<codeline lineno="2522"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_TCP);</highlight></codeline>
<codeline lineno="2523"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval)<sp/>{</highlight></codeline>
<codeline lineno="2524"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_ipv6only(sock-&gt;conn,<sp/>1);</highlight></codeline>
<codeline lineno="2525"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2526"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_ipv6only(sock-&gt;conn,<sp/>0);</highlight></codeline>
<codeline lineno="2527"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2528"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_IPV6,<sp/>IPV6_V6ONLY,<sp/>..)<sp/>-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2529"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(netconn_get_ipv6only(sock-&gt;conn)<sp/>?<sp/>1<sp/>:<sp/>0)));</highlight></codeline>
<codeline lineno="2530"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2531"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2532"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_IPV6,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2533"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2534"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2536"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2537"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2538"><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="2539"><highlight class="normal"></highlight></codeline>
<codeline lineno="2540"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDP<sp/>&amp;&amp;<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2541"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_UDPLITE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2542"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_UDPLITE:</highlight></codeline>
<codeline lineno="2543"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Special<sp/>case:<sp/>all<sp/>IPPROTO_UDPLITE<sp/>option<sp/>take<sp/>an<sp/>int<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2544"><highlight class="normal"><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="2545"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>no<sp/>UDP<sp/>lite<sp/>socket,<sp/>ignore<sp/>any<sp/>options.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2546"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!NETCONNTYPE_ISUDPLITE(netconn_type(sock-&gt;conn)))<sp/>{</highlight></codeline>
<codeline lineno="2547"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2548"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2549"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2550"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>UDPLITE_SEND_CSCOV:</highlight></codeline>
<codeline lineno="2551"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>!=<sp/>0)<sp/>&amp;&amp;<sp/>((*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>&lt;<sp/>8)<sp/>||<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>&gt;<sp/>0xffff)))<sp/>{</highlight></codeline>
<codeline lineno="2552"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>allow<sp/>illegal<sp/>values!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2553"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_tx<sp/>=<sp/>8;</highlight></codeline>
<codeline lineno="2554"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2555"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_tx<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval;</highlight></codeline>
<codeline lineno="2556"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2557"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UDPLITE_SEND_CSCOV)<sp/>-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2558"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval))<sp/>);</highlight></codeline>
<codeline lineno="2559"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2560"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>UDPLITE_RECV_CSCOV:</highlight></codeline>
<codeline lineno="2561"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>!=<sp/>0)<sp/>&amp;&amp;<sp/>((*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>&lt;<sp/>8)<sp/>||<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval<sp/>&gt;<sp/>0xffff)))<sp/>{</highlight></codeline>
<codeline lineno="2562"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>don&apos;t<sp/>allow<sp/>illegal<sp/>values!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2563"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_rx<sp/>=<sp/>8;</highlight></codeline>
<codeline lineno="2564"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2565"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.udp-&gt;chksum_len_rx<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval;</highlight></codeline>
<codeline lineno="2566"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2567"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UDPLITE_RECV_CSCOV)<sp/>-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2568"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)optval))<sp/>);</highlight></codeline>
<codeline lineno="2569"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2570"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2571"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_UDPLITE,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2572"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2573"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2574"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2575"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2576"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2577"><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="2578"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Level:<sp/>IPPROTO_RAW<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2579"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPPROTO_RAW:</highlight></codeline>
<codeline lineno="2580"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(optname)<sp/>{</highlight></codeline>
<codeline lineno="2581"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_RAW</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2582"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>IPV6_CHECKSUM:</highlight></codeline>
<codeline lineno="2583"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>It<sp/>should<sp/>not<sp/>be<sp/>possible<sp/>to<sp/>disable<sp/>the<sp/>checksum<sp/>generation<sp/>with<sp/>ICMPv6</highlight></codeline>
<codeline lineno="2584"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>as<sp/>per<sp/>RFC<sp/>3542<sp/>chapter<sp/>3.1<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2585"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock-&gt;conn-&gt;pcb.raw-&gt;protocol<sp/>==<sp/>IPPROTO_ICMPV6)<sp/>{</highlight></codeline>
<codeline lineno="2586"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>;</highlight></codeline>
<codeline lineno="2587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2588"><highlight class="normal"></highlight></codeline>
<codeline lineno="2589"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock,<sp/>optlen,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal">,<sp/>NETCONN_RAW);</highlight></codeline>
<codeline lineno="2590"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2591"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.raw-&gt;chksum_reqd<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2592"><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/>(*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval<sp/>&amp;<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="2593"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Per<sp/>RFC3542,<sp/>odd<sp/>offsets<sp/>are<sp/>not<sp/>allowed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2594"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>;</highlight></codeline>
<codeline lineno="2595"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2596"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.raw-&gt;chksum_reqd<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="2597"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;conn-&gt;pcb.raw-&gt;chksum_offset<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)*(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*)optval;</highlight></codeline>
<codeline lineno="2598"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2599"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_RAW,<sp/>IPV6_CHECKSUM,<sp/>..)<sp/>-&gt;<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2600"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>sock-&gt;conn-&gt;pcb.raw-&gt;chksum_reqd));</highlight></codeline>
<codeline lineno="2601"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2602"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_RAW<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2603"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2604"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>IPPROTO_RAW,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2605"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>optname));</highlight></codeline>
<codeline lineno="2606"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2607"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2608"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(optname)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2609"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2610"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2611"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_setsockopt(%d,<sp/>level=0x%x,<sp/>UNIMPL:<sp/>optname=0x%x,<sp/>..)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="2612"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>s,<sp/>level,<sp/>optname));</highlight></codeline>
<codeline lineno="2613"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="sys_2errno_8h_1acd570f8ab92198653b4459773dc3bca3" kindref="member">ENOPROTOOPT</ref>;</highlight></codeline>
<codeline lineno="2614"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2615"><highlight class="normal"><sp/><sp/>}<sp/><sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(level)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2616"><highlight class="normal"></highlight></codeline>
<codeline lineno="2617"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="2618"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2619"><highlight class="normal"></highlight></codeline>
<codeline lineno="2620"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2621"><highlight class="normal">lwip_ioctl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>cmd,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*argp)</highlight></codeline>
<codeline lineno="2622"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2623"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2624"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>val;</highlight></codeline>
<codeline lineno="2625"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2626"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>buflen<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2627"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>recv_avail;</highlight></codeline>
<codeline lineno="2628"><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="2629"><highlight class="normal"></highlight></codeline>
<codeline lineno="2630"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2631"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2632"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2633"><highlight class="normal"></highlight></codeline>
<codeline lineno="2634"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(cmd)<sp/>{</highlight></codeline>
<codeline lineno="2635"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF<sp/>||<sp/>LWIP_FIONREAD_LINUXMODE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2636"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>FIONREAD:</highlight></codeline>
<codeline lineno="2637"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!argp)<sp/>{</highlight></codeline>
<codeline lineno="2638"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a2d1678d5a7cc8ce499643f3b8957def4" kindref="member">EINVAL</ref>);</highlight></codeline>
<codeline lineno="2639"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2640"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2641"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_FIONREAD_LINUXMODE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2642"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="2643"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p;</highlight></codeline>
<codeline lineno="2644"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;lastdata)<sp/>{</highlight></codeline>
<codeline lineno="2645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*)sock-&gt;lastdata)-&gt;p;</highlight></codeline>
<codeline lineno="2646"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>-<sp/>sock-&gt;lastoffset;</highlight></codeline>
<codeline lineno="2647"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2648"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*rxbuf;</highlight></codeline>
<codeline lineno="2649"><highlight class="normal"><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="2650"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;rcvevent<sp/>&lt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2651"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2652"><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="2653"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>err<sp/>=<sp/>netconn_recv(sock-&gt;conn,<sp/>&amp;rxbuf);</highlight></codeline>
<codeline lineno="2654"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>!=<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="2655"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2656"><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="2657"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastdata<sp/>=<sp/>rxbuf;</highlight></codeline>
<codeline lineno="2658"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sock-&gt;lastoffset<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2659"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>=<sp/>rxbuf-&gt;p-&gt;tot_len;</highlight></codeline>
<codeline lineno="2660"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2661"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2662"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2663"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="2664"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2665"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_FIONREAD_LINUXMODE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2666"><highlight class="normal"></highlight></codeline>
<codeline lineno="2667"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_SO_RCVBUF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2668"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>we<sp/>come<sp/>here<sp/>if<sp/>either<sp/>LWIP_FIONREAD_LINUXMODE==0<sp/>or<sp/>this<sp/>is<sp/>a<sp/>TCP<sp/>socket<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2669"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="sys_8h_1a0da95147531964d619be7744c7169986" kindref="member">SYS_ARCH_GET</ref>(sock-&gt;conn-&gt;recv_avail,<sp/>recv_avail);</highlight></codeline>
<codeline lineno="2670"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(recv_avail<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2671"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>recv_avail<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2672"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2673"><highlight class="normal"><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>=<sp/>recv_avail;</highlight></codeline>
<codeline lineno="2674"><highlight class="normal"></highlight></codeline>
<codeline lineno="2675"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>there<sp/>is<sp/>data<sp/>left<sp/>from<sp/>the<sp/>last<sp/>recv<sp/>operation.<sp/>/maq<sp/>041215<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2676"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sock-&gt;lastdata)<sp/>{</highlight></codeline>
<codeline lineno="2677"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*)sock-&gt;lastdata;</highlight></codeline>
<codeline lineno="2678"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(NETCONNTYPE_GROUP(netconn_type(sock-&gt;conn))<sp/>!=<sp/>NETCONN_TCP)<sp/>{</highlight></codeline>
<codeline lineno="2679"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">netbuf<sp/>*)p)-&gt;p;</highlight></codeline>
<codeline lineno="2680"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2681"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>buflen<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="2682"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>buflen<sp/>-=<sp/>sock-&gt;lastoffset;</highlight></codeline>
<codeline lineno="2683"><highlight class="normal"></highlight></codeline>
<codeline lineno="2684"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>*((</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)argp)<sp/>+=<sp/>buflen;</highlight></codeline>
<codeline lineno="2685"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2686"><highlight class="normal"></highlight></codeline>
<codeline lineno="2687"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_ioctl(%d,<sp/>FIONREAD,<sp/>%p)<sp/>=<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>argp,<sp/>*((<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>*)argp)));</highlight></codeline>
<codeline lineno="2688"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="2689"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="2690"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2691"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2692"><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="2693"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SO_RCVBUF<sp/>||<sp/>LWIP_FIONREAD_LINUXMODE<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2694"><highlight class="normal"></highlight></codeline>
<codeline lineno="2695"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>(</highlight><highlight class="keywordtype">long</highlight><highlight class="normal">)FIONBIO:</highlight></codeline>
<codeline lineno="2696"><highlight class="normal"><sp/><sp/><sp/><sp/>val<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2697"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(argp<sp/>&amp;&amp;<sp/>*(<ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref>*)argp)<sp/>{</highlight></codeline>
<codeline lineno="2698"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>val<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="2699"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2700"><highlight class="normal"><sp/><sp/><sp/><sp/>netconn_set_nonblocking(sock-&gt;conn,<sp/>val);</highlight></codeline>
<codeline lineno="2701"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_ioctl(%d,<sp/>FIONBIO,<sp/>%d)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>val));</highlight></codeline>
<codeline lineno="2702"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="2703"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="2704"><highlight class="normal"></highlight></codeline>
<codeline lineno="2705"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2706"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2707"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="comment">/*<sp/>switch<sp/>(cmd)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2708"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_ioctl(%d,<sp/>UNIMPL:<sp/>0x%lx,<sp/>%p)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>cmd,<sp/>argp));</highlight></codeline>
<codeline lineno="2709"><highlight class="normal"><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a43785b9969e0bd1af532dbde06c5540b" kindref="member">ENOSYS</ref>);<sp/></highlight><highlight class="comment">/*<sp/>not<sp/>yet<sp/>implemented<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2710"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2711"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2712"><highlight class="normal"></highlight></codeline>
<codeline lineno="2717"><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2718"><highlight class="normal">lwip_fcntl(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>cmd,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>val)</highlight></codeline>
<codeline lineno="2719"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2720"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2721"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="2722"><highlight class="normal"></highlight></codeline>
<codeline lineno="2723"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2724"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="2725"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2726"><highlight class="normal"></highlight></codeline>
<codeline lineno="2727"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(cmd)<sp/>{</highlight></codeline>
<codeline lineno="2728"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="fcntl_8h_1a025fad21a889c79f02ec53abe3526c32" kindref="member">F_GETFL</ref>:</highlight></codeline>
<codeline lineno="2729"><highlight class="normal"><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>netconn_is_nonblocking(sock-&gt;conn)<sp/>?<sp/><ref refid="fcntl_8h_1a39d33ce33804efd4d52606d59071c6d8" kindref="member">O_NONBLOCK</ref><sp/>:<sp/>0;</highlight></codeline>
<codeline lineno="2730"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="2731"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2732"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="fcntl_8h_1af2939853c650561d3495ed40f68f6249" kindref="member">F_SETFL</ref>:</highlight></codeline>
<codeline lineno="2733"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((val<sp/>&amp;<sp/>~<ref refid="fcntl_8h_1a39d33ce33804efd4d52606d59071c6d8" kindref="member">O_NONBLOCK</ref>)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="2734"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>only<sp/>O_NONBLOCK,<sp/>all<sp/>other<sp/>bits<sp/>are<sp/>zero<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2735"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_set_nonblocking(sock-&gt;conn,<sp/>val<sp/>&amp;<sp/><ref refid="fcntl_8h_1a39d33ce33804efd4d52606d59071c6d8" kindref="member">O_NONBLOCK</ref>);</highlight></codeline>
<codeline lineno="2736"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="2737"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/>0);</highlight></codeline>
<codeline lineno="2738"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="2739"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a43785b9969e0bd1af532dbde06c5540b" kindref="member">ENOSYS</ref>);<sp/></highlight><highlight class="comment">/*<sp/>not<sp/>yet<sp/>implemented<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2740"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2741"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2742"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="2743"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;lwip_fcntl(%d,<sp/>UNIMPL:<sp/>%d,<sp/>%d)\n&quot;</highlight><highlight class="normal">,<sp/>s,<sp/>cmd,<sp/>val));</highlight></codeline>
<codeline lineno="2744"><highlight class="normal"><sp/><sp/><sp/><sp/>sock_set_errno(sock,<sp/><ref refid="sys_2errno_8h_1a43785b9969e0bd1af532dbde06c5540b" kindref="member">ENOSYS</ref>);<sp/></highlight><highlight class="comment">/*<sp/>not<sp/>yet<sp/>implemented<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2745"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2746"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2747"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="2748"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2749"><highlight class="normal"></highlight></codeline>
<codeline lineno="2750"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IGMP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2751"><highlight class="normal"></highlight></codeline>
<codeline lineno="2757"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2758"><highlight class="normal">lwip_socket_register_membership(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*if_addr,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*multi_addr)</highlight></codeline>
<codeline lineno="2759"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2760"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2761"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="2762"><highlight class="normal"></highlight></codeline>
<codeline lineno="2763"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2764"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="2765"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2766"><highlight class="normal"></highlight></codeline>
<codeline lineno="2767"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>LWIP_SOCKET_MAX_MEMBERSHIPS;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="2768"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(socket_ipv4_multicast_memberships[i].sock<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="2769"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>socket_ipv4_multicast_memberships[i].sock<sp/>=<sp/>sock;</highlight></codeline>
<codeline lineno="2770"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_copy(socket_ipv4_multicast_memberships[i].if_addr,<sp/>*if_addr);</highlight></codeline>
<codeline lineno="2771"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_copy(socket_ipv4_multicast_memberships[i].multi_addr,<sp/>*multi_addr);</highlight></codeline>
<codeline lineno="2772"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
<codeline lineno="2773"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2774"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2775"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="2776"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2777"><highlight class="normal"></highlight></codeline>
<codeline lineno="2783"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2784"><highlight class="normal">lwip_socket_unregister_membership(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*if_addr,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>ip4_addr_t<sp/>*multi_addr)</highlight></codeline>
<codeline lineno="2785"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2786"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2787"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="2788"><highlight class="normal"></highlight></codeline>
<codeline lineno="2789"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2790"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2791"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2792"><highlight class="normal"></highlight></codeline>
<codeline lineno="2793"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>LWIP_SOCKET_MAX_MEMBERSHIPS;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="2794"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((socket_ipv4_multicast_memberships[i].sock<sp/>==<sp/>sock)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="2795"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_cmp(&amp;socket_ipv4_multicast_memberships[i].if_addr,<sp/>if_addr)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="2796"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_cmp(&amp;socket_ipv4_multicast_memberships[i].multi_addr,<sp/>multi_addr))<sp/>{</highlight></codeline>
<codeline lineno="2797"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>socket_ipv4_multicast_memberships[i].sock<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="2798"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_set_zero(&amp;socket_ipv4_multicast_memberships[i].if_addr);</highlight></codeline>
<codeline lineno="2799"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_set_zero(&amp;socket_ipv4_multicast_memberships[i].multi_addr);</highlight></codeline>
<codeline lineno="2800"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2801"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2802"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2803"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2804"><highlight class="normal"></highlight></codeline>
<codeline lineno="2809"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2810"><highlight class="normal">lwip_socket_drop_registered_memberships(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline>
<codeline lineno="2811"><highlight class="normal">{</highlight></codeline>
<codeline lineno="2812"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">lwip_sock<sp/>*sock<sp/>=<sp/>get_socket(s);</highlight></codeline>
<codeline lineno="2813"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="2814"><highlight class="normal"></highlight></codeline>
<codeline lineno="2815"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!sock)<sp/>{</highlight></codeline>
<codeline lineno="2816"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="2817"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2818"><highlight class="normal"></highlight></codeline>
<codeline lineno="2819"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>LWIP_SOCKET_MAX_MEMBERSHIPS;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="2820"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(socket_ipv4_multicast_memberships[i].sock<sp/>==<sp/>sock)<sp/>{</highlight></codeline>
<codeline lineno="2821"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>multi_addr,<sp/>if_addr;</highlight></codeline>
<codeline lineno="2822"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip_addr_copy_from_ip4(multi_addr,<sp/>socket_ipv4_multicast_memberships[i].multi_addr);</highlight></codeline>
<codeline lineno="2823"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip_addr_copy_from_ip4(if_addr,<sp/>socket_ipv4_multicast_memberships[i].if_addr);</highlight></codeline>
<codeline lineno="2824"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>socket_ipv4_multicast_memberships[i].sock<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="2825"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_set_zero(&amp;socket_ipv4_multicast_memberships[i].if_addr);</highlight></codeline>
<codeline lineno="2826"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_set_zero(&amp;socket_ipv4_multicast_memberships[i].multi_addr);</highlight></codeline>
<codeline lineno="2827"><highlight class="normal"></highlight></codeline>
<codeline lineno="2828"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>netconn_join_leave_group(sock-&gt;conn,<sp/>&amp;multi_addr,<sp/>&amp;if_addr,<sp/>NETCONN_LEAVE);</highlight></codeline>
<codeline lineno="2829"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="2830"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="2831"><highlight class="normal">}</highlight></codeline>
<codeline lineno="2832"><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="2833"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_SOCKET<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/net/api/sockets.c"/>
  </compounddef>
</doxygen>
