<?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="udp_8c" kind="file" language="C++">
    <compoundname>udp.c</compoundname>
    <includes refid="opt_8h" local="yes">net/opt.h</includes>
    <incdepgraph>
      <node id="17">
        <label>stdarg.h</label>
        <link refid="stdarg_8h"/>
      </node>
      <node id="18">
        <label>ubixos/kpanic.h</label>
        <link refid="kpanic_8h"/>
      </node>
      <node id="15">
        <label>sys/io.h</label>
        <link refid="io_8h"/>
      </node>
      <node id="8">
        <label>sys/select.h</label>
        <link refid="select_8h"/>
        <childnode refid="9" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>net/arch/cc.h</label>
        <link refid="cc_8h"/>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="12">
        <label>sys/_sigset.h</label>
        <link refid="__sigset_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="3">
        <label>net/lwipopts.h</label>
        <link refid="lwipopts_8h"/>
      </node>
      <node id="6">
        <label>sys/types.h</label>
        <link refid="include_2sys_2types_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="8" relation="include">
        </childnode>
      </node>
      <node id="5">
        <label>net/arch.h</label>
        <link refid="arch_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="13" relation="include">
        </childnode>
        <childnode refid="16" relation="include">
        </childnode>
        <childnode refid="18" relation="include">
        </childnode>
      </node>
      <node id="2">
        <label>net/opt.h</label>
        <link refid="opt_8h"/>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="16">
        <label>lib/kprintf.h</label>
        <link refid="kprintf_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="17" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>net/debug.h</label>
        <link refid="debug_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="9">
        <label>sys/cdefs.h</label>
        <link refid="cdefs_8h"/>
      </node>
      <node id="14">
        <label>ubixos/time.h</label>
        <link refid="time_8h"/>
        <childnode refid="6" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="15" relation="include">
        </childnode>
      </node>
      <node id="7">
        <label>sys/_types.h</label>
        <link refid="__types_8h"/>
      </node>
      <node id="1">
        <label>C:/Dev/git/UbixOS/sys/net/core/udp.c</label>
        <link refid="udp_8c"/>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="10">
        <label>sys/_timespec.h</label>
        <link refid="__timespec_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
      <node id="11">
        <label>sys/_timeval.h</label>
        <link refid="__timeval_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>User Datagram Protocol module<linebreak/>
The code for the User Datagram Protocol UDP &amp; UDPLite (RFC 3828).<linebreak/>
See also <ref refid="group__udp__raw" kindref="compound">UDP</ref> </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/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><highlight class="normal"></highlight></codeline>
<codeline lineno="45"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>@todo<sp/>Check<sp/>the<sp/>use<sp/>of<sp/>&apos;(struct<sp/>udp_pcb).chksum_len_rx&apos;!</highlight></codeline>
<codeline lineno="46"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="opt_8h" kindref="compound">net/opt.h</ref>&quot;</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_UDP<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/>&quot;<ref refid="udp_8h" kindref="compound">net/udp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="def_8h" kindref="compound">net/def.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="memp_8h" kindref="compound">net/memp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="55"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="inet__chksum_8h" kindref="compound">net/inet_chksum.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="56"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip__addr_8h" kindref="compound">net/ip_addr.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip6_8h" kindref="compound">net/ip6.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="ip6__addr_8h" kindref="compound">net/ip6_addr.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="netif_8h" kindref="compound">net/netif.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="60"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="icmp_8h" kindref="compound">net/icmp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="icmp6_8h" kindref="compound">net/icmp6.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="62"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="stats_8h" kindref="compound">net/stats.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="63"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="snmp_8h" kindref="compound">net/snmp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="64"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="dhcp_8h" kindref="compound">net/dhcp.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="65"><highlight class="normal"></highlight></codeline>
<codeline lineno="66"><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="67"><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight><highlight class="preprocessor">#ifndef<sp/>UDP_LOCAL_PORT_RANGE_START</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>From<sp/>http://www.iana.org/assignments/port-numbers:</highlight></codeline>
<codeline lineno="70"><highlight class="comment"><sp/><sp/><sp/>&quot;The<sp/>Dynamic<sp/>and/or<sp/>Private<sp/>Ports<sp/>are<sp/>those<sp/>from<sp/>49152<sp/>through<sp/>65535&quot;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>UDP_LOCAL_PORT_RANGE_START<sp/><sp/>0xc000</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>UDP_LOCAL_PORT_RANGE_END<sp/><sp/><sp/><sp/>0xffff</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>UDP_ENSURE_LOCAL_PORT_RANGE(port)<sp/>((u16_t)(((port)<sp/>&amp;<sp/>~UDP_LOCAL_PORT_RANGE_START)<sp/>+<sp/>UDP_LOCAL_PORT_RANGE_START))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>last<sp/>local<sp/>UDP<sp/>port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>udp_port<sp/>=<sp/>UDP_LOCAL_PORT_RANGE_START;</highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>The<sp/>list<sp/>of<sp/>UDP<sp/>PCBs<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>exported<sp/>in<sp/>udp.h<sp/>(was<sp/>static)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*udp_pcbs;</highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight></codeline>
<codeline lineno="86"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="87"><highlight class="normal">udp_init(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="88"><highlight class="normal">{</highlight></codeline>
<codeline lineno="89"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS<sp/>&amp;&amp;<sp/>defined(LWIP_RAND)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="90"><highlight class="normal"><sp/><sp/>udp_port<sp/>=<sp/>UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND());</highlight></codeline>
<codeline lineno="91"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS<sp/>&amp;&amp;<sp/>defined(LWIP_RAND)<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></codeline>
<codeline lineno="99"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref></highlight></codeline>
<codeline lineno="100"><highlight class="normal">udp_new_port(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="101"><highlight class="normal">{</highlight></codeline>
<codeline lineno="102"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>n<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="103"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*pcb;</highlight></codeline>
<codeline lineno="104"><highlight class="normal"></highlight></codeline>
<codeline lineno="105"><highlight class="normal">again:</highlight></codeline>
<codeline lineno="106"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(udp_port++<sp/>==<sp/>UDP_LOCAL_PORT_RANGE_END)<sp/>{</highlight></codeline>
<codeline lineno="107"><highlight class="normal"><sp/><sp/><sp/><sp/>udp_port<sp/>=<sp/>UDP_LOCAL_PORT_RANGE_START;</highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>all<sp/>PCBs.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(pcb<sp/>=<sp/>udp_pcbs;<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>pcb<sp/>=<sp/>pcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;local_port<sp/>==<sp/>udp_port)<sp/>{</highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(++n<sp/>&gt;<sp/>(UDP_LOCAL_PORT_RANGE_END<sp/>-<sp/>UDP_LOCAL_PORT_RANGE_START))<sp/>{</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>again;</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_port;</highlight></codeline>
<codeline lineno="119"><highlight class="normal">}</highlight></codeline>
<codeline lineno="120"><highlight class="normal"></highlight></codeline>
<codeline lineno="129"><highlight class="keyword">static</highlight><highlight class="normal"><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref></highlight></codeline>
<codeline lineno="130"><highlight class="normal">udp_input_local_match(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*inp,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>broadcast)</highlight></codeline>
<codeline lineno="131"><highlight class="normal">{</highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(inp);<sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>in<sp/>IPv6<sp/>only<sp/>case<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(broadcast);<sp/></highlight><highlight class="comment">/*<sp/>in<sp/>IPv6<sp/>only<sp/>case<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="134"><highlight class="normal"></highlight></codeline>
<codeline lineno="135"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Dual-stack:<sp/>PCBs<sp/>listening<sp/>to<sp/>any<sp/>IP<sp/>type<sp/>also<sp/>listen<sp/>to<sp/>any<sp/>IP<sp/>address<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(pcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="137"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>IP_SOF_BROADCAST_RECV</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((broadcast<sp/>!=<sp/>0)<sp/>&amp;&amp;<sp/>!<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(pcb,<sp/><ref refid="ip_8h_1ac8c7ccdad2d7d3a264bd8cfc57140ca8" kindref="member">SOF_BROADCAST</ref>))<sp/>{</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="141"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>IP_SOF_BROADCAST_RECV<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="144"><highlight class="normal"></highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Only<sp/>need<sp/>to<sp/>check<sp/>PCB<sp/>if<sp/>incoming<sp/>IP<sp/>version<sp/>matches<sp/>PCB<sp/>IP<sp/>version<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a81ed1fbe375d867d6e77c83976c07671" kindref="member">IP_ADDR_PCB_VERSION_MATCH_EXACT</ref>(pcb,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Special<sp/>case:<sp/>IPv4<sp/>broadcast:<sp/>all<sp/>or<sp/>broadcasts<sp/>in<sp/>my<sp/>subnet</highlight></codeline>
<codeline lineno="149"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>Note:<sp/>broadcast<sp/>variable<sp/>can<sp/>only<sp/>be<sp/>1<sp/>if<sp/>it<sp/>is<sp/>an<sp/>IPv4<sp/>broadcast<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(broadcast<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="151"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>IP_SOF_BROADCAST_RECV</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(pcb,<sp/><ref refid="ip_8h_1ac8c7ccdad2d7d3a264bd8cfc57140ca8" kindref="member">SOF_BROADCAST</ref>))</highlight></codeline>
<codeline lineno="153"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>IP_SOF_BROADCAST_RECV<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip4_addr_isany(ip_2_ip4(&amp;pcb-&gt;local_ip))<sp/>||</highlight></codeline>
<codeline lineno="156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((ip4_current_dest_addr()-&gt;addr<sp/>==<sp/>IPADDR_BROADCAST))<sp/>||</highlight></codeline>
<codeline lineno="157"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_netcmp(ip_2_ip4(&amp;pcb-&gt;local_ip),<sp/>ip4_current_dest_addr(),<sp/>netif_ip4_netmask(inp)))<sp/>{</highlight></codeline>
<codeline lineno="158"><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="159"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="161"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="162"><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="163"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Handle<sp/>IPv4<sp/>and<sp/>IPv6:<sp/>all<sp/>or<sp/>exact<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;pcb-&gt;local_ip)<sp/>||<sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;local_ip,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
<codeline lineno="166"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="167"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="168"><highlight class="normal"></highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="170"><highlight class="normal">}</highlight></codeline>
<codeline lineno="171"><highlight class="normal"></highlight></codeline>
<codeline lineno="184"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="185"><highlight class="normal">udp_input(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*inp)</highlight></codeline>
<codeline lineno="186"><highlight class="normal">{</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref><sp/>*udphdr;</highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*pcb,<sp/>*prev;</highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*uncon_pcb;</highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>src,<sp/>dest;</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>broadcast;</highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>for_us<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="193"><highlight class="normal"></highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(inp);</highlight></codeline>
<codeline lineno="195"><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><ref refid="perf_8h_1aa1d6977095e51331f65dcfb2b076da52" kindref="member">PERF_START</ref>;</highlight></codeline>
<codeline lineno="197"><highlight class="normal"></highlight></codeline>
<codeline lineno="198"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.recv);</highlight></codeline>
<codeline lineno="199"><highlight class="normal"></highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>minimum<sp/>length<sp/>(UDP<sp/>header)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&lt;<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>)<sp/>{</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>drop<sp/>short<sp/>packets<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;udp_input:<sp/>short<sp/>UDP<sp/>datagram<sp/>(%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>bytes)<sp/>discarded\n&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.lenerr);</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.drop);</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpinerrors);</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>end;</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="211"><highlight class="normal"></highlight></codeline>
<codeline lineno="212"><highlight class="normal"><sp/><sp/>udphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref><sp/>*)p-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="213"><highlight class="normal"></highlight></codeline>
<codeline lineno="214"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>is<sp/>broadcast<sp/>packet<sp/>?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/>broadcast<sp/>=<sp/><ref refid="ip__addr_8h_1a11275b39f9b8e876e8124a16410e8840" kindref="member">ip_addr_isbroadcast</ref>(<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>(),<sp/><ref refid="ip_8h_1aabecef3c7653a9767c79245c44fcab9f" kindref="member">ip_current_netif</ref>());</highlight></codeline>
<codeline lineno="216"><highlight class="normal"></highlight></codeline>
<codeline lineno="217"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_input:<sp/>received<sp/>datagram<sp/>of<sp/>length<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="218"><highlight class="normal"></highlight></codeline>
<codeline lineno="219"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>convert<sp/>src<sp/>and<sp/>dest<sp/>ports<sp/>to<sp/>host<sp/>byte<sp/>order<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="220"><highlight class="normal"><sp/><sp/>src<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;src);</highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/>dest<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;dest);</highlight></codeline>
<codeline lineno="222"><highlight class="normal"></highlight></codeline>
<codeline lineno="223"><highlight class="normal"><sp/><sp/>udp_debug_print(udphdr);</highlight></codeline>
<codeline lineno="224"><highlight class="normal"></highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>print<sp/>the<sp/>UDP<sp/>source<sp/>and<sp/>destination<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="226"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp<sp/>(&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="227"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>());</highlight></codeline>
<codeline lineno="228"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)<sp/>&lt;--<sp/>(&quot;</highlight><highlight class="normal">,<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;dest)));</highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>());</highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;src)));</highlight></codeline>
<codeline lineno="231"><highlight class="normal"></highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/>pcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/>prev<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/>uncon_pcb<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Iterate<sp/>through<sp/>the<sp/>UDP<sp/>pcb<sp/>list<sp/>for<sp/>a<sp/>matching<sp/>pcb.</highlight></codeline>
<codeline lineno="236"><highlight class="comment"><sp/><sp/><sp/>*<sp/>&apos;Perfect<sp/>match&apos;<sp/>pcbs<sp/>(connected<sp/>to<sp/>the<sp/>remote<sp/>port<sp/>&amp;<sp/>ip<sp/>address)<sp/>are</highlight></codeline>
<codeline lineno="237"><highlight class="comment"><sp/><sp/><sp/>*<sp/>preferred.<sp/>If<sp/>no<sp/>perfect<sp/>match<sp/>is<sp/>found,<sp/>the<sp/>first<sp/>unconnected<sp/>pcb<sp/>that</highlight></codeline>
<codeline lineno="238"><highlight class="comment"><sp/><sp/><sp/>*<sp/>matches<sp/>the<sp/>local<sp/>port<sp/>and<sp/>ip<sp/>address<sp/>gets<sp/>the<sp/>datagram.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(pcb<sp/>=<sp/>udp_pcbs;<sp/>pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>pcb<sp/>=<sp/>pcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>print<sp/>the<sp/>PCB<sp/>local<sp/>and<sp/>remote<sp/>address<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;pcb<sp/>(&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>&amp;pcb-&gt;local_ip);</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)<sp/>&lt;--<sp/>(&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;local_port));</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;remote_port));</highlight></codeline>
<codeline lineno="246"><highlight class="normal"></highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>compare<sp/>PCB<sp/>local<sp/>addr+port<sp/>to<sp/>UDP<sp/>destination<sp/>addr+port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;local_port<sp/>==<sp/>dest)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(udp_input_local_match(pcb,<sp/>inp,<sp/>broadcast)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((pcb-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_CONNECTED)<sp/>==<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>((uncon_pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)</highlight></codeline>
<codeline lineno="252"><highlight class="normal">#</highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/><ref refid="lwipopts_8h_1af3822feed320cf8439b083ee525e4942" kindref="member">SO_REUSE</ref></highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>prefer<sp/>specific<sp/>IPs<sp/>over<sp/>cath-all<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>||<sp/>!<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(&amp;pcb-&gt;local_ip)</highlight></codeline>
<codeline lineno="255"><highlight class="normal">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>))<sp/>{</highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>first<sp/>unconnected<sp/>matching<sp/>PCB<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>uncon_pcb<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="260"><highlight class="normal"></highlight></codeline>
<codeline lineno="261"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>compare<sp/>PCB<sp/>remote<sp/>addr+port<sp/>to<sp/>UDP<sp/>source<sp/>addr+port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="262"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb-&gt;remote_port<sp/>==<sp/>src)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(<ref refid="ip__addr_8h_1acd8f5aa151cff966fd28368b85f38c05" kindref="member">ip_addr_isany_val</ref>(pcb-&gt;remote_ip)<sp/>||</highlight></codeline>
<codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;pcb-&gt;remote_ip,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>())))<sp/>{</highlight></codeline>
<codeline lineno="265"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>the<sp/>first<sp/>fully<sp/>matching<sp/>PCB<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(prev<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="267"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>move<sp/>the<sp/>pcb<sp/>to<sp/>the<sp/>front<sp/>of<sp/>udp_pcbs<sp/>so<sp/>that<sp/>is</highlight></codeline>
<codeline lineno="268"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>found<sp/>faster<sp/>next<sp/>time<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="269"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>prev-&gt;next<sp/>=<sp/>pcb-&gt;next;</highlight></codeline>
<codeline lineno="270"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;next<sp/>=<sp/>udp_pcbs;</highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udp_pcbs<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="272"><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="273"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.cachehit);</highlight></codeline>
<codeline lineno="274"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="275"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="276"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="277"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="278"><highlight class="normal"></highlight></codeline>
<codeline lineno="279"><highlight class="normal"><sp/><sp/><sp/><sp/>prev<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="280"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="281"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>fully<sp/>matching<sp/>pcb<sp/>found?<sp/>then<sp/>look<sp/>for<sp/>an<sp/>unconnected<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="282"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="283"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb<sp/>=<sp/>uncon_pcb;</highlight></codeline>
<codeline lineno="284"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="285"><highlight class="normal"></highlight></codeline>
<codeline lineno="286"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>checksum<sp/>if<sp/>this<sp/>is<sp/>a<sp/>match<sp/>or<sp/>if<sp/>it<sp/>was<sp/>directed<sp/>at<sp/>us.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="287"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="288"><highlight class="normal"><sp/><sp/><sp/><sp/>for_us<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="290"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="291"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip_current_is_v6())<sp/>{</highlight></codeline>
<codeline lineno="292"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>for_us<sp/>=<sp/>netif_get_ip6_addr_match(inp,<sp/>ip6_current_dest_addr())<sp/>&gt;=<sp/>0;</highlight></codeline>
<codeline lineno="293"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="294"><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="295"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!ip_current_is_v6())<sp/>{</highlight></codeline>
<codeline lineno="297"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>for_us<sp/>=<sp/>ip4_addr_cmp(netif_ip4_addr(inp),<sp/>ip4_current_dest_addr());</highlight></codeline>
<codeline lineno="298"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="299"><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="300"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="301"><highlight class="normal"></highlight></codeline>
<codeline lineno="302"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(for_us)<sp/>{</highlight></codeline>
<codeline lineno="303"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_input:<sp/>calculating<sp/>checksum\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="304"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_CHECK_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="305"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(inp,<sp/><ref refid="lwipopts_8h_1a6747f7b72abe544fd4dc184cc7fcad37" kindref="member">CHECKSUM_CHECK_UDP</ref>)<sp/>{</highlight></codeline>
<codeline lineno="306"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="307"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip_current_header_proto()<sp/>==<sp/><ref refid="prot_2ip_8h_1a3ef2b8a1cb4f7acee3142337438dfd0d" kindref="member">IP_PROTO_UDPLITE</ref>)<sp/>{</highlight></codeline>
<codeline lineno="308"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Do<sp/>the<sp/>UDP<sp/>Lite<sp/>checksum<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chklen<sp/>=<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;len);</highlight></codeline>
<codeline lineno="310"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(chklen<sp/>&lt;<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref>))<sp/>{</highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(chklen<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="312"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>For<sp/>UDP-Lite,<sp/>checksum<sp/>length<sp/>of<sp/>0<sp/>means<sp/>checksum</highlight></codeline>
<codeline lineno="313"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>over<sp/>the<sp/>complete<sp/>packet<sp/>(See<sp/>RFC<sp/>3828<sp/>chap.<sp/>3.1)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chklen<sp/>=<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="315"><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="316"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>At<sp/>least<sp/>the<sp/>UDP-Lite<sp/>header<sp/>must<sp/>be<sp/>covered<sp/>by<sp/>the</highlight></codeline>
<codeline lineno="317"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>checksum!<sp/>(Again,<sp/>see<sp/>RFC<sp/>3828<sp/>chap.<sp/>3.1)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="318"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>chkerr;</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="inet__chksum_8h_1acfe7ab6c63ef998210c66bb4822b03b2" kindref="member">ip_chksum_pseudo_partial</ref>(p,<sp/><ref refid="prot_2ip_8h_1a3ef2b8a1cb4f7acee3142337438dfd0d" kindref="member">IP_PROTO_UDPLITE</ref>,</highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,<sp/>chklen,</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>())<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>chkerr;</highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="327"><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="328"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="329"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(udphdr-&gt;chksum<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="inet__chksum_8h_1aa13cda42e7c262f5dee243ff6c28422f" kindref="member">ip_chksum_pseudo</ref>(p,<sp/><ref refid="prot_2ip_8h_1a76212e7ef71a99646040d2e454388bed" kindref="member">IP_PROTO_UDP</ref>,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,</highlight></codeline>
<codeline lineno="331"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),</highlight></codeline>
<codeline lineno="332"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>())<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="333"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>chkerr;</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="336"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="337"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="338"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_CHECK_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="339"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>-<ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>))<sp/>{</highlight></codeline>
<codeline lineno="340"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Can<sp/>we<sp/>cope<sp/>with<sp/>this<sp/>failing?<sp/>Just<sp/>assert<sp/>for<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;pbuf_header<sp/>failed\n&quot;</highlight><highlight class="normal">,<sp/>0);</highlight></codeline>
<codeline lineno="342"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.drop);</highlight></codeline>
<codeline lineno="343"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpinerrors);</highlight></codeline>
<codeline lineno="344"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>end;</highlight></codeline>
<codeline lineno="346"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="347"><highlight class="normal"></highlight></codeline>
<codeline lineno="348"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="349"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpindatagrams);</highlight></codeline>
<codeline lineno="350"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE<sp/>&amp;&amp;<sp/>SO_REUSE_RXTOALL</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(pcb,<sp/><ref refid="ip_8h_1aa40b3366a7939ec3a60e9a7d239575e2" kindref="member">SOF_REUSEADDR</ref>)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(broadcast<sp/>||<sp/><ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>())))<sp/>{</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pass<sp/>broadcast-<sp/>or<sp/>multicast<sp/>packets<sp/>to<sp/>all<sp/>multicast<sp/>pcbs</highlight></codeline>
<codeline lineno="354"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>SOF_REUSEADDR<sp/>is<sp/>set<sp/>on<sp/>the<sp/>first<sp/>match<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*mpcb;</highlight></codeline>
<codeline lineno="356"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>p_header_changed<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref><sp/>hdrs_len<sp/>=<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)(<ref refid="ip_8h_1a2ca15ea285a10982294378cd7b8e83e2" kindref="member">ip_current_header_tot_len</ref>()<sp/>+<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>);</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(mpcb<sp/>=<sp/>udp_pcbs;<sp/>mpcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>mpcb<sp/>=<sp/>mpcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(mpcb<sp/>!=<sp/>pcb)<sp/>{</highlight></codeline>
<codeline lineno="360"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>compare<sp/>PCB<sp/>local<sp/>addr+port<sp/>to<sp/>UDP<sp/>destination<sp/>addr+port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="361"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((mpcb-&gt;local_port<sp/>==<sp/>dest)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(udp_input_local_match(mpcb,<sp/>inp,<sp/>broadcast)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="363"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pass<sp/>a<sp/>copy<sp/>of<sp/>the<sp/>packet<sp/>to<sp/>all<sp/>local<sp/>matches<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(mpcb-&gt;recv<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*q;</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>for<sp/>that,<sp/>move<sp/>payload<sp/>to<sp/>IP<sp/>header<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p_header_changed<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1a27480c41c34021d4417691d327163626" kindref="member">pbuf_header_force</ref>(p,<sp/>hdrs_len);</highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p_header_changed<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfa21116654fbab6d5a4dfeb87a1bb8f0ba" kindref="member">PBUF_RAW</ref>,<sp/>p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err<sp/>=<sp/><ref refid="group__pbuf_1gaba88511dee3df4b631fde691f421320d" kindref="member">pbuf_copy</ref>(q,<sp/>p);</highlight></codeline>
<codeline lineno="374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(err<sp/>==<sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>move<sp/>payload<sp/>to<sp/>UDP<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="376"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(q,<sp/>-hdrs_len);</highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mpcb-&gt;recv(mpcb-&gt;recv_arg,<sp/>mpcb,<sp/>q,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>src);</highlight></codeline>
<codeline lineno="378"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="379"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="380"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="381"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="382"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="383"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p_header_changed)<sp/>{</highlight></codeline>
<codeline lineno="385"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>and<sp/>move<sp/>payload<sp/>to<sp/>UDP<sp/>data<sp/>again<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="386"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/>-hdrs_len);</highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="388"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="389"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>SO_REUSE<sp/>&amp;&amp;<sp/>SO_REUSE_RXTOALL<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>callback<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="391"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;recv<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="392"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>now<sp/>the<sp/>recv<sp/>function<sp/>is<sp/>responsible<sp/>for<sp/>freeing<sp/>p<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="393"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb-&gt;recv(pcb-&gt;recv_arg,<sp/>pcb,<sp/>p,<sp/><ref refid="ip_8h_1a4e35b7692c228c98e738892f0a215647" kindref="member">ip_current_src_addr</ref>(),<sp/>src);</highlight></codeline>
<codeline lineno="394"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>recv<sp/>function<sp/>registered?<sp/>then<sp/>we<sp/>have<sp/>to<sp/>free<sp/>the<sp/>pbuf!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">goto</highlight><highlight class="normal"><sp/>end;</highlight></codeline>
<codeline lineno="398"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_input:<sp/>not<sp/>for<sp/>us.\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="401"><highlight class="normal"></highlight></codeline>
<codeline lineno="402"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_ICMP<sp/>||<sp/>LWIP_ICMP6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="403"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>match<sp/>was<sp/>found,<sp/>send<sp/>ICMP<sp/>destination<sp/>port<sp/>unreachable<sp/>unless</highlight></codeline>
<codeline lineno="404"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>destination<sp/>address<sp/>was<sp/>broadcast/multicast.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!broadcast<sp/>&amp;&amp;<sp/>!<ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(<ref refid="ip_8h_1a9135977868017c3deeec86b525e13997" kindref="member">ip_current_dest_addr</ref>()))<sp/>{</highlight></codeline>
<codeline lineno="406"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>move<sp/>payload<sp/>pointer<sp/>back<sp/>to<sp/>ip<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="pbuf_8h_1a27480c41c34021d4417691d327163626" kindref="member">pbuf_header_force</ref>(p,<sp/>(<ref refid="group__compiler__abstraction_1gacf46f4df0ebab84edebcb69967fdf86b" kindref="member">s16_t</ref>)(<ref refid="ip_8h_1a2ca15ea285a10982294378cd7b8e83e2" kindref="member">ip_current_header_tot_len</ref>()<sp/>+<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>));</highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="icmp_8h_1a8d52f47a3b8237697544280c22f2925e" kindref="member">icmp_port_unreach</ref>(ip_current_is_v6(),<sp/>p);</highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="410"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_ICMP<sp/>||<sp/>LWIP_ICMP6<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.proterr);</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.drop);</highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpnoports);</highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="419"><highlight class="normal">end:</highlight></codeline>
<codeline lineno="420"><highlight class="normal"><sp/><sp/><ref refid="perf_8h_1a8ac3afe5d720793a229fbf70a78eb82f" kindref="member">PERF_STOP</ref>(</highlight><highlight class="stringliteral">&quot;udp_input&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="422"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_CHECK_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="423"><highlight class="normal">chkerr:</highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,</highlight></codeline>
<codeline lineno="425"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;udp_input:<sp/>UDP<sp/>(or<sp/>UDP<sp/>Lite)<sp/>datagram<sp/>discarded<sp/>due<sp/>to<sp/>failing<sp/>checksum\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.chkerr);</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.drop);</highlight></codeline>
<codeline lineno="428"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpinerrors);</highlight></codeline>
<codeline lineno="429"><highlight class="normal"><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(p);</highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/><ref refid="perf_8h_1a8ac3afe5d720793a229fbf70a78eb82f" kindref="member">PERF_STOP</ref>(</highlight><highlight class="stringliteral">&quot;udp_input&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="431"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_CHECK_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="432"><highlight class="normal">}</highlight></codeline>
<codeline lineno="433"><highlight class="normal"></highlight></codeline>
<codeline lineno="454"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="455"><highlight class="normal">udp_send(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p)</highlight></codeline>
<codeline lineno="456"><highlight class="normal">{</highlight></codeline>
<codeline lineno="457"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/><ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(pcb-&gt;remote_ip))<sp/>{</highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="459"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="460"><highlight class="normal"></highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>to<sp/>the<sp/>packet<sp/>using<sp/>remote<sp/>ip<sp/>and<sp/>port<sp/>stored<sp/>in<sp/>the<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="462"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto(pcb,<sp/>p,<sp/>&amp;pcb-&gt;remote_ip,<sp/>pcb-&gt;remote_port);</highlight></codeline>
<codeline lineno="463"><highlight class="normal">}</highlight></codeline>
<codeline lineno="464"><highlight class="normal"></highlight></codeline>
<codeline lineno="465"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="466"><highlight class="normal"></highlight></codeline>
<codeline lineno="469"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="470"><highlight class="normal">udp_send_chksum(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="471"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>have_chksum,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum)</highlight></codeline>
<codeline lineno="472"><highlight class="normal">{</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/><ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(pcb-&gt;remote_ip))<sp/>{</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="476"><highlight class="normal"></highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>to<sp/>the<sp/>packet<sp/>using<sp/>remote<sp/>ip<sp/>and<sp/>port<sp/>stored<sp/>in<sp/>the<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_chksum(pcb,<sp/>p,<sp/>&amp;pcb-&gt;remote_ip,<sp/>pcb-&gt;remote_port,</highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/><sp/><sp/>have_chksum,<sp/>chksum);</highlight></codeline>
<codeline lineno="480"><highlight class="normal">}</highlight></codeline>
<codeline lineno="481"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="482"><highlight class="normal"></highlight></codeline>
<codeline lineno="501"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="502"><highlight class="normal">udp_sendto(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port)</highlight></codeline>
<codeline lineno="504"><highlight class="normal">{</highlight></codeline>
<codeline lineno="505"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_chksum(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/>0,<sp/>0);</highlight></codeline>
<codeline lineno="507"><highlight class="normal">}</highlight></codeline>
<codeline lineno="508"><highlight class="normal"></highlight></codeline>
<codeline lineno="511"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="512"><highlight class="normal">udp_sendto_chksum(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,</highlight></codeline>
<codeline lineno="513"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>have_chksum,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum)</highlight></codeline>
<codeline lineno="514"><highlight class="normal">{</highlight></codeline>
<codeline lineno="515"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="516"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>;</highlight></codeline>
<codeline lineno="517"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip_route<sp/>=<sp/>dst_ip;</highlight></codeline>
<codeline lineno="518"><highlight class="normal"></highlight></codeline>
<codeline lineno="519"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(dst_ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>!<ref refid="ip__addr_8h_1a234cb2e45cd58a80bc3ef433d23f4c57" kindref="member">IP_ADDR_PCB_VERSION_MATCH</ref>(pcb,<sp/>dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="520"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="521"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="522"><highlight class="normal"></highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="524"><highlight class="normal"></highlight></codeline>
<codeline lineno="525"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6<sp/>||<sp/>(LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="526"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(dst_ip_route))<sp/>{</highlight></codeline>
<codeline lineno="527"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="528"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a9bac7e938757f1d24df2404e8b57cb7d" kindref="member">IP_IS_V6</ref>(dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="529"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>For<sp/>multicast,<sp/>find<sp/>a<sp/>netif<sp/>based<sp/>on<sp/>source<sp/>address.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="530"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>dst_ip_route<sp/>=<sp/>&amp;pcb-&gt;local_ip;</highlight></codeline>
<codeline lineno="531"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="532"><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="533"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="534"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>IPv4<sp/>does<sp/>not<sp/>use<sp/>source-based<sp/>routing<sp/>by<sp/>default,<sp/>so<sp/>we<sp/>use<sp/>an</highlight></codeline>
<codeline lineno="536"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>administratively<sp/>selected<sp/>interface<sp/>for<sp/>multicast<sp/>by<sp/>default.</highlight></codeline>
<codeline lineno="537"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>However,<sp/>this<sp/>can<sp/>be<sp/>overridden<sp/>by<sp/>setting<sp/>an<sp/>interface<sp/>address</highlight></codeline>
<codeline lineno="538"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>in<sp/>pcb-&gt;multicast_ip<sp/>that<sp/>is<sp/>used<sp/>for<sp/>routing.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="539"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="ip__addr_8h_1acd8f5aa151cff966fd28368b85f38c05" kindref="member">ip_addr_isany_val</ref>(pcb-&gt;multicast_ip)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="540"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>!ip4_addr_cmp(ip_2_ip4(&amp;pcb-&gt;multicast_ip),<sp/>IP4_ADDR_BROADCAST))<sp/>{</highlight></codeline>
<codeline lineno="541"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>dst_ip_route<sp/>=<sp/>&amp;pcb-&gt;multicast_ip;</highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="543"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="544"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="545"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="546"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>||<sp/>(LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS)<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="547"><highlight class="normal"></highlight></codeline>
<codeline lineno="548"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>find<sp/>the<sp/>outgoing<sp/>network<sp/>interface<sp/>for<sp/>this<sp/>packet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="549"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(<ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(pcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="550"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>call<sp/>ip_route()<sp/>with<sp/>IP_ANY_TYPE<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="551"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(<ref refid="ip__addr_8h_1ae221446ab455b8a1a0d2a4153b9c1bb3" kindref="member">IP46_ADDR_ANY</ref>(<ref refid="ip__addr_8h_1aa2d07afd28376f89da2cdcf5d2497ce7" kindref="member">IP_GET_TYPE</ref>(dst_ip_route)),<sp/>dst_ip_route);</highlight></codeline>
<codeline lineno="552"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="553"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>=<sp/>ip_route(&amp;pcb-&gt;local_ip,<sp/>dst_ip_route);</highlight></codeline>
<codeline lineno="554"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="555"><highlight class="normal"></highlight></codeline>
<codeline lineno="556"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>outgoing<sp/>network<sp/>interface<sp/>could<sp/>be<sp/>found?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="557"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="structnetif" kindref="compound">netif</ref><sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="558"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>No<sp/>route<sp/>to<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="559"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>dst_ip);</highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.rterr);</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="563"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="564"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="565"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if_chksum(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>,<sp/>have_chksum,<sp/>chksum);</highlight></codeline>
<codeline lineno="566"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="567"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="568"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="569"><highlight class="normal">}</highlight></codeline>
<codeline lineno="570"><highlight class="normal"></highlight></codeline>
<codeline lineno="591"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="592"><highlight class="normal">udp_sendto_if(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="593"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>)</highlight></codeline>
<codeline lineno="594"><highlight class="normal">{</highlight></codeline>
<codeline lineno="595"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="596"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if_chksum(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>,<sp/>0,<sp/>0);</highlight></codeline>
<codeline lineno="597"><highlight class="normal">}</highlight></codeline>
<codeline lineno="598"><highlight class="normal"></highlight></codeline>
<codeline lineno="600"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="601"><highlight class="normal">udp_sendto_if_chksum(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,</highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>have_chksum,</highlight></codeline>
<codeline lineno="603"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum)</highlight></codeline>
<codeline lineno="604"><highlight class="normal">{</highlight></codeline>
<codeline lineno="605"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="606"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*src_ip;</highlight></codeline>
<codeline lineno="607"><highlight class="normal"></highlight></codeline>
<codeline lineno="608"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(dst_ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>!<ref refid="ip__addr_8h_1a234cb2e45cd58a80bc3ef433d23f4c57" kindref="member">IP_ADDR_PCB_VERSION_MATCH</ref>(pcb,<sp/>dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="609"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="610"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="611"><highlight class="normal"></highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>PCB<sp/>local<sp/>address<sp/>is<sp/>IP_ANY_ADDR?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="613"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV6</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="614"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a9bac7e938757f1d24df2404e8b57cb7d" kindref="member">IP_IS_V6</ref>(dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="615"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip6_addr_isany(<ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;pcb-&gt;local_ip)))<sp/>{</highlight></codeline>
<codeline lineno="616"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>src_ip<sp/>=<sp/>ip6_select_source_address(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(dst_ip));</highlight></codeline>
<codeline lineno="617"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(src_ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>suitable<sp/>source<sp/>address<sp/>was<sp/>found.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="619"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="620"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="621"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="622"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>use<sp/>UDP<sp/>PCB<sp/>local<sp/>IPv6<sp/>address<sp/>as<sp/>source<sp/>address,<sp/>if<sp/>still<sp/>valid.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(netif_get_ip6_addr_match(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="ip__addr_8h_1a06e75bcd198012b5ba39480c233608bd" kindref="member">ip_2_ip6</ref>(&amp;pcb-&gt;local_ip))<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="624"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Address<sp/>isn&apos;t<sp/>valid<sp/>anymore.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="626"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="627"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>src_ip<sp/>=<sp/>&amp;pcb-&gt;local_ip;</highlight></codeline>
<codeline lineno="628"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="630"><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="631"><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="632"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="633"><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="634"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="635"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ip4_addr_isany(ip_2_ip4(&amp;pcb-&gt;local_ip))<sp/>||</highlight></codeline>
<codeline lineno="636"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ip4_addr_ismulticast(ip_2_ip4(&amp;pcb-&gt;local_ip)))<sp/>{</highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>the<sp/>local_ip<sp/>is<sp/>any<sp/>or<sp/>multicast</highlight></codeline>
<codeline lineno="638"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>use<sp/>the<sp/>outgoing<sp/>network<sp/>interface<sp/>IP<sp/>address<sp/>as<sp/>source<sp/>address<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="639"><highlight class="normal"><sp/><sp/><sp/><sp/>src_ip<sp/>=<sp/>netif_ip_addr4(<ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="640"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="641"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>check<sp/>if<sp/>UDP<sp/>PCB<sp/>local<sp/>IP<sp/>address<sp/>is<sp/>correct</highlight></codeline>
<codeline lineno="642"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>this<sp/>could<sp/>be<sp/>an<sp/>old<sp/>address<sp/>if<sp/>netif-&gt;ip_addr<sp/>has<sp/>changed<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="643"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!ip4_addr_cmp(ip_2_ip4(&amp;(pcb-&gt;local_ip)),<sp/>netif_ip4_addr(<ref refid="structnetif" kindref="compound">netif</ref>)))<sp/>{</highlight></codeline>
<codeline lineno="644"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>local_ip<sp/>doesn&apos;t<sp/>match,<sp/>drop<sp/>the<sp/>packet<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="645"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca9448893187313c0c5a502ca9a9ad1c2a" kindref="member">ERR_RTE</ref>;</highlight></codeline>
<codeline lineno="646"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="647"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>use<sp/>UDP<sp/>PCB<sp/>local<sp/>IP<sp/>address<sp/>as<sp/>source<sp/>address<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="648"><highlight class="normal"><sp/><sp/><sp/><sp/>src_ip<sp/>=<sp/>&amp;pcb-&gt;local_ip;</highlight></codeline>
<codeline lineno="649"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="650"><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="651"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="652"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if_src_chksum(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>,<sp/>have_chksum,<sp/>chksum,<sp/>src_ip);</highlight></codeline>
<codeline lineno="653"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="654"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if_src(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>,<sp/>src_ip);</highlight></codeline>
<codeline lineno="655"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="656"><highlight class="normal">}</highlight></codeline>
<codeline lineno="657"><highlight class="normal"></highlight></codeline>
<codeline lineno="660"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="661"><highlight class="normal">udp_sendto_if_src(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,</highlight></codeline>
<codeline lineno="662"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*src_ip)</highlight></codeline>
<codeline lineno="663"><highlight class="normal">{</highlight></codeline>
<codeline lineno="664"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>udp_sendto_if_src_chksum(pcb,<sp/>p,<sp/>dst_ip,<sp/>dst_port,<sp/><ref refid="structnetif" kindref="compound">netif</ref>,<sp/>0,<sp/>0,<sp/>src_ip);</highlight></codeline>
<codeline lineno="666"><highlight class="normal">}</highlight></codeline>
<codeline lineno="667"><highlight class="normal"></highlight></codeline>
<codeline lineno="669"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="670"><highlight class="normal">udp_sendto_if_src_chksum(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*p,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*dst_ip,</highlight></codeline>
<codeline lineno="671"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>dst_port,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetif" kindref="compound">netif</ref><sp/>*<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>have_chksum,</highlight></codeline>
<codeline lineno="672"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chksum,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*src_ip)</highlight></codeline>
<codeline lineno="673"><highlight class="normal">{</highlight></codeline>
<codeline lineno="674"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_CHECKSUM_ON_COPY<sp/>&amp;&amp;<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref><sp/>*udphdr;</highlight></codeline>
<codeline lineno="676"><highlight class="normal"><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err;</highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structpbuf" kindref="compound">pbuf</ref><sp/>*q;<sp/></highlight><highlight class="comment">/*<sp/>q<sp/>will<sp/>be<sp/>sent<sp/>down<sp/>the<sp/>stack<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="678"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>ip_proto;</highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>ttl;</highlight></codeline>
<codeline lineno="680"><highlight class="normal"></highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(dst_ip<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>!<ref refid="ip__addr_8h_1a234cb2e45cd58a80bc3ef433d23f4c57" kindref="member">IP_ADDR_PCB_VERSION_MATCH</ref>(pcb,<sp/>src_ip)<sp/>||</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>!<ref refid="ip__addr_8h_1a234cb2e45cd58a80bc3ef433d23f4c57" kindref="member">IP_ADDR_PCB_VERSION_MATCH</ref>(pcb,<sp/>dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="683"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="684"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="685"><highlight class="normal"></highlight></codeline>
<codeline lineno="686"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>IP_SOF_BROADCAST</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>broadcast<sp/>filter?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="688"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(pcb,<sp/><ref refid="ip_8h_1ac8c7ccdad2d7d3a264bd8cfc57140ca8" kindref="member">SOF_BROADCAST</ref>)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="689"><highlight class="normal">#</highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/><ref refid="lwipopts_8h_1a872e3bb3fe2212156d66b18fccc9643f" kindref="member">LWIP_IPV6</ref></highlight></codeline>
<codeline lineno="690"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1abee5dab2191bb0f3355d7f30d1496f24" kindref="member">IP_IS_V4</ref>(dst_ip)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="691"><highlight class="normal">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV6<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="692"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a11275b39f9b8e876e8124a16410e8840" kindref="member">ip_addr_isbroadcast</ref>(dst_ip,<sp/><ref refid="structnetif" kindref="compound">netif</ref>))<sp/>{</highlight></codeline>
<codeline lineno="693"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,</highlight></codeline>
<codeline lineno="694"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;udp_sendto_if:<sp/>SOF_BROADCAST<sp/>not<sp/>enabled<sp/>on<sp/>pcb<sp/>%p\n&quot;</highlight><highlight class="normal">,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)pcb));</highlight></codeline>
<codeline lineno="695"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="696"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="697"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_IPV4<sp/>&amp;&amp;<sp/>IP_SOF_BROADCAST<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="698"><highlight class="normal"></highlight></codeline>
<codeline lineno="699"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>the<sp/>PCB<sp/>is<sp/>not<sp/>yet<sp/>bound<sp/>to<sp/>a<sp/>port,<sp/>bind<sp/>it<sp/>here<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="700"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;local_port<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="701"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>not<sp/>yet<sp/>bound<sp/>to<sp/>a<sp/>port,<sp/>binding<sp/>now\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="702"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/>udp_bind(pcb,<sp/>&amp;pcb-&gt;local_ip,<sp/>pcb-&gt;local_port);</highlight></codeline>
<codeline lineno="703"><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="704"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>forced<sp/>port<sp/>bind<sp/>failed\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="705"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="706"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="707"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="708"><highlight class="normal"></highlight></codeline>
<codeline lineno="709"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>not<sp/>enough<sp/>space<sp/>to<sp/>add<sp/>an<sp/>UDP<sp/>header<sp/>to<sp/>first<sp/>pbuf<sp/>in<sp/>given<sp/>p<sp/>chain?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="710"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="pbuf_8h_1aaa17c1951cf2d207b6adfd3947d91f00" kindref="member">pbuf_header</ref>(p,<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>))<sp/>{</highlight></codeline>
<codeline lineno="711"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>allocate<sp/>header<sp/>in<sp/>a<sp/>separate<sp/>new<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="712"><highlight class="normal"><sp/><sp/><sp/><sp/>q<sp/>=<sp/><ref refid="group__pbuf_1gacfcb0a2af918658ba0afe36499c65f47" kindref="member">pbuf_alloc</ref>(<ref refid="group__pbuf_1ggaee1baa59bb2f85ba575b5a8619ac1ebfafcc1e506061ba69dfa142eb6b3da5f13" kindref="member">PBUF_IP</ref>,<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>,<sp/><ref refid="group__pbuf_1ggab7e0e32fcc292c0d7107721766ed92fbac5e9f28455bca98944a030d4b84ecfab" kindref="member">PBUF_RAM</ref>);</highlight></codeline>
<codeline lineno="713"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>new<sp/>header<sp/>pbuf<sp/>could<sp/>not<sp/>be<sp/>allocated?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="714"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga0269bdc51f1e8a5ecf9af72c6e1c996c" kindref="member">LWIP_DBG_LEVEL_SERIOUS</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>could<sp/>not<sp/>allocate<sp/>header\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="716"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaaaeafdbf3aecc46864daa3cd829c7e05" kindref="member">ERR_MEM</ref>;</highlight></codeline>
<codeline lineno="717"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref><sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="719"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>chain<sp/>header<sp/>q<sp/>in<sp/>front<sp/>of<sp/>given<sp/>pbuf<sp/>p<sp/>(only<sp/>if<sp/>p<sp/>contains<sp/>data)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1ga831c9a72bda1d3bd4c7b96f5a0e3b891" kindref="member">pbuf_chain</ref>(q,<sp/>p);</highlight></codeline>
<codeline lineno="721"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="722"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>first<sp/>pbuf<sp/>q<sp/>points<sp/>to<sp/>header<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>added<sp/>header<sp/>pbuf<sp/>%p<sp/>before<sp/>given<sp/>pbuf<sp/>%p\n&quot;</highlight><highlight class="normal">,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)q,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)p));</highlight></codeline>
<codeline lineno="725"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="726"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>adding<sp/>space<sp/>for<sp/>header<sp/>within<sp/>p<sp/>succeeded<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="727"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>first<sp/>pbuf<sp/>q<sp/>equals<sp/>given<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="728"><highlight class="normal"><sp/><sp/><sp/><sp/>q<sp/>=<sp/>p;</highlight></codeline>
<codeline lineno="729"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>added<sp/>header<sp/>in<sp/>given<sp/>pbuf<sp/>%p\n&quot;</highlight><highlight class="normal">,<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*)p));</highlight></codeline>
<codeline lineno="730"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="731"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a94ad086267808462beae2b38f91996ed" kindref="member">LWIP_ASSERT</ref>(</highlight><highlight class="stringliteral">&quot;check<sp/>that<sp/>first<sp/>pbuf<sp/>can<sp/>hold<sp/>struct<sp/>udp_hdr&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(q-&gt;<ref refid="structpbuf_1a6f82449625e36e294f5d210268c0703f" kindref="member">len</ref><sp/>&gt;=<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref>)));</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>q<sp/>now<sp/>represents<sp/>the<sp/>packet<sp/>to<sp/>be<sp/>sent<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="734"><highlight class="normal"><sp/><sp/>udphdr<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref><sp/>*)q-&gt;<ref refid="structpbuf_1a8d32dc3e964369d4eec638fc37fbc460" kindref="member">payload</ref>;</highlight></codeline>
<codeline lineno="735"><highlight class="normal"><sp/><sp/>udphdr-&gt;src<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(pcb-&gt;local_port);</highlight></codeline>
<codeline lineno="736"><highlight class="normal"><sp/><sp/>udphdr-&gt;dest<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(dst_port);</highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>in<sp/>UDP,<sp/>0<sp/>checksum<sp/>means<sp/>&apos;no<sp/>checksum&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/>udphdr-&gt;chksum<sp/>=<sp/>0x0000;</highlight></codeline>
<codeline lineno="739"><highlight class="normal"></highlight></codeline>
<codeline lineno="740"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Multicast<sp/>Loop?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="741"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>(LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS)<sp/>||<sp/>(LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="742"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(((pcb-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_MULTICAST_LOOP)<sp/>!=<sp/>0)<sp/>&amp;&amp;<sp/><ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(dst_ip))<sp/>{</highlight></codeline>
<codeline lineno="743"><highlight class="normal"><sp/><sp/><sp/><sp/>q-&gt;<ref refid="structpbuf_1aa4d1af2cab3d9280d29212095b5b872a" kindref="member">flags</ref><sp/>|=<sp/><ref refid="pbuf_8h_1ab8ad153151a8c157335d9c0cedc007e6" kindref="member">PBUF_FLAG_MCASTLOOP</ref>;</highlight></codeline>
<codeline lineno="744"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="745"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>(LWIP_IPV4<sp/>&amp;&amp;<sp/>LWIP_MULTICAST_TX_OPTIONS)<sp/>||<sp/>(LWIP_IPV6<sp/>&amp;&amp;<sp/>LWIP_IPV6_MLD)<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="746"><highlight class="normal"></highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>sending<sp/>datagram<sp/>of<sp/>length<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="748"><highlight class="normal"></highlight></codeline>
<codeline lineno="749"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_UDPLITE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="750"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>UDP<sp/>Lite<sp/>protocol?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="751"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_UDPLITE)<sp/>{</highlight></codeline>
<codeline lineno="752"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>chklen,<sp/>chklen_hdr;</highlight></codeline>
<codeline lineno="753"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>UDP<sp/>LITE<sp/>packet<sp/>length<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>set<sp/>UDP<sp/>message<sp/>length<sp/>in<sp/>UDP<sp/>header<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="755"><highlight class="normal"><sp/><sp/><sp/><sp/>chklen_hdr<sp/>=<sp/>chklen<sp/>=<sp/>pcb-&gt;chksum_len_tx;</highlight></codeline>
<codeline lineno="756"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((chklen<sp/>&lt;<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref>))<sp/>||<sp/>(chklen<sp/>&gt;<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>))<sp/>{</highlight></codeline>
<codeline lineno="757"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(chklen<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="758"><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_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>UDP<sp/>LITE<sp/>pcb-&gt;chksum_len<sp/>is<sp/>illegal:<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/>chklen));</highlight></codeline>
<codeline lineno="759"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="760"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>For<sp/>UDP-Lite,<sp/>checksum<sp/>length<sp/>of<sp/>0<sp/>means<sp/>checksum</highlight></codeline>
<codeline lineno="761"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>over<sp/>the<sp/>complete<sp/>packet.<sp/>(See<sp/>RFC<sp/>3828<sp/>chap.<sp/>3.1)</highlight></codeline>
<codeline lineno="762"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>At<sp/>least<sp/>the<sp/>UDP-Lite<sp/>header<sp/>must<sp/>be<sp/>covered<sp/>by<sp/>the</highlight></codeline>
<codeline lineno="763"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>checksum,<sp/>therefore,<sp/>if<sp/>chksum_len<sp/>has<sp/>an<sp/>illegal</highlight></codeline>
<codeline lineno="764"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>value,<sp/>we<sp/>generate<sp/>the<sp/>checksum<sp/>over<sp/>the<sp/>complete</highlight></codeline>
<codeline lineno="765"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>packet<sp/>to<sp/>be<sp/>safe.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="766"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>chklen_hdr<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="767"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>chklen<sp/>=<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>;</highlight></codeline>
<codeline lineno="768"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="769"><highlight class="normal"><sp/><sp/><sp/><sp/>udphdr-&gt;len<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(chklen_hdr);</highlight></codeline>
<codeline lineno="770"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>calculate<sp/>checksum<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="771"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="772"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="773"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="774"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(have_chksum)<sp/>{</highlight></codeline>
<codeline lineno="775"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>chklen<sp/>=<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>;</highlight></codeline>
<codeline lineno="776"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="777"><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="778"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>udphdr-&gt;chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1acfe7ab6c63ef998210c66bb4822b03b2" kindref="member">ip_chksum_pseudo_partial</ref>(q,<sp/><ref refid="prot_2ip_8h_1a3ef2b8a1cb4f7acee3142337438dfd0d" kindref="member">IP_PROTO_UDPLITE</ref>,</highlight></codeline>
<codeline lineno="779"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,<sp/>chklen,<sp/>src_ip,<sp/>dst_ip);</highlight></codeline>
<codeline lineno="780"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="781"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(have_chksum)<sp/>{</highlight></codeline>
<codeline lineno="782"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>acc;</highlight></codeline>
<codeline lineno="783"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acc<sp/>=<sp/>udphdr-&gt;chksum<sp/>+<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)~(chksum);</highlight></codeline>
<codeline lineno="784"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udphdr-&gt;chksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a6ffe83b4bdd1784a0671ee4778966a01" kindref="member">FOLD_U32T</ref>(acc);</highlight></codeline>
<codeline lineno="785"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="786"><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="787"><highlight class="normal"></highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>chksum<sp/>zero<sp/>must<sp/>become<sp/>0xffff,<sp/>as<sp/>zero<sp/>means<sp/>&apos;no<sp/>checksum&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(udphdr-&gt;chksum<sp/>==<sp/>0x0000)<sp/>{</highlight></codeline>
<codeline lineno="790"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udphdr-&gt;chksum<sp/>=<sp/>0xffff;</highlight></codeline>
<codeline lineno="791"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="792"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="793"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="794"><highlight class="normal"></highlight></codeline>
<codeline lineno="795"><highlight class="normal"><sp/><sp/><sp/><sp/>ip_proto<sp/>=<sp/><ref refid="prot_2ip_8h_1a3ef2b8a1cb4f7acee3142337438dfd0d" kindref="member">IP_PROTO_UDPLITE</ref>;</highlight></codeline>
<codeline lineno="796"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="797"><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="798"><highlight class="normal"><sp/><sp/>{<sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>UDP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>UDP<sp/>packet<sp/>length<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>));</highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/><sp/><sp/>udphdr-&gt;len<sp/>=<sp/><ref refid="def_8c_1ad637280639de4066392e6b5614fa3e56" kindref="member">lwip_htons</ref>(q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>);</highlight></codeline>
<codeline lineno="801"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>calculate<sp/>checksum<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="802"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>CHECKSUM_GEN_UDP</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="803"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="netif_8h_1ad968df1b35c2fae368e087966e3bc677" kindref="member">IF__NETIF_CHECKSUM_ENABLED</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>NETIF_CHECKSUM_GEN_UDP)<sp/>{</highlight></codeline>
<codeline lineno="804"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Checksum<sp/>is<sp/>mandatory<sp/>over<sp/>IPv6.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="805"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a9bac7e938757f1d24df2404e8b57cb7d" kindref="member">IP_IS_V6</ref>(dst_ip)<sp/>||<sp/>(pcb-&gt;flags<sp/>&amp;<sp/>UDP_FLAGS_NOCHKSUM)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="806"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>udpchksum;</highlight></codeline>
<codeline lineno="807"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_CHECKSUM_ON_COPY</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="808"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(have_chksum)<sp/>{</highlight></codeline>
<codeline lineno="809"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="group__compiler__abstraction_1ga4c14294869aceba3ef9d4c0c302d0f33" kindref="member">u32_t</ref><sp/>acc;</highlight></codeline>
<codeline lineno="810"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udpchksum<sp/>=<sp/><ref refid="inet__chksum_8h_1acfe7ab6c63ef998210c66bb4822b03b2" kindref="member">ip_chksum_pseudo_partial</ref>(q,<sp/><ref refid="prot_2ip_8h_1a76212e7ef71a99646040d2e454388bed" kindref="member">IP_PROTO_UDP</ref>,</highlight></codeline>
<codeline lineno="811"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,<sp/><ref refid="prot_2udp_8h_1a5e211e5d295f6e70dee42f3083f89e71" kindref="member">UDP_HLEN</ref>,<sp/>src_ip,<sp/>dst_ip);</highlight></codeline>
<codeline lineno="812"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>acc<sp/>=<sp/>udpchksum<sp/>+<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)~(chksum);</highlight></codeline>
<codeline lineno="813"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udpchksum<sp/>=<sp/><ref refid="inet__chksum_8h_1a6ffe83b4bdd1784a0671ee4778966a01" kindref="member">FOLD_U32T</ref>(acc);</highlight></codeline>
<codeline lineno="814"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="815"><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="816"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="817"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udpchksum<sp/>=<sp/><ref refid="inet__chksum_8h_1aa13cda42e7c262f5dee243ff6c28422f" kindref="member">ip_chksum_pseudo</ref>(q,<sp/><ref refid="prot_2ip_8h_1a76212e7ef71a99646040d2e454388bed" kindref="member">IP_PROTO_UDP</ref>,<sp/>q-&gt;<ref refid="structpbuf_1a5259e7ec29bab9c0999b64f2e86b411f" kindref="member">tot_len</ref>,</highlight></codeline>
<codeline lineno="818"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>src_ip,<sp/>dst_ip);</highlight></codeline>
<codeline lineno="819"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="820"><highlight class="normal"></highlight></codeline>
<codeline lineno="821"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>chksum<sp/>zero<sp/>must<sp/>become<sp/>0xffff,<sp/>as<sp/>zero<sp/>means<sp/>&apos;no<sp/>checksum&apos;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="822"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(udpchksum<sp/>==<sp/>0x0000)<sp/>{</highlight></codeline>
<codeline lineno="823"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udpchksum<sp/>=<sp/>0xffff;</highlight></codeline>
<codeline lineno="824"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="825"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>udphdr-&gt;chksum<sp/>=<sp/>udpchksum;</highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="827"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="828"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>CHECKSUM_GEN_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="829"><highlight class="normal"><sp/><sp/><sp/><sp/>ip_proto<sp/>=<sp/><ref refid="prot_2ip_8h_1a76212e7ef71a99646040d2e454388bed" kindref="member">IP_PROTO_UDP</ref>;</highlight></codeline>
<codeline lineno="830"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="831"><highlight class="normal"></highlight></codeline>
<codeline lineno="832"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Determine<sp/>TTL<sp/>to<sp/>use<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="833"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MULTICAST_TX_OPTIONS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="834"><highlight class="normal"><sp/><sp/>ttl<sp/>=<sp/>(<ref refid="ip__addr_8h_1a2170d3ee13dd22722222228e7b1c5752" kindref="member">ip_addr_ismulticast</ref>(dst_ip)<sp/>?<sp/>udp_get_multicast_ttl(pcb)<sp/>:<sp/>pcb-&gt;ttl);</highlight></codeline>
<codeline lineno="835"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*<sp/>LWIP_MULTICAST_TX_OPTIONS<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="836"><highlight class="normal"><sp/><sp/>ttl<sp/>=<sp/>pcb-&gt;ttl;</highlight></codeline>
<codeline lineno="837"><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="838"><highlight class="normal"></highlight></codeline>
<codeline lineno="839"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>UDP<sp/>checksum<sp/>0x%04&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga1418f92673e54a36b6e376109e526382" kindref="member">X16_F</ref></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">,<sp/>udphdr-&gt;chksum));</highlight></codeline>
<codeline lineno="840"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_send:<sp/>ip_output_if<sp/>(,,,,0x%02&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga1418f92673e54a36b6e376109e526382" kindref="member">X16_F</ref></highlight><highlight class="stringliteral">&quot;,)\n&quot;</highlight><highlight class="normal">,<sp/>(<ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref>)ip_proto));</highlight></codeline>
<codeline lineno="841"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>output<sp/>to<sp/>IP<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="842"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/>&amp;(pcb-&gt;addr_hint));</highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/>ip_output_if_src(q,<sp/>src_ip,<sp/>dst_ip,<sp/>ttl,<sp/>pcb-&gt;tos,<sp/>ip_proto,<sp/><ref refid="structnetif" kindref="compound">netif</ref>);</highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/><ref refid="netif_8h_1ae1c22f1dab74a84d9e31316fd5fdfa11" kindref="member">NETIF_SET_HWADDRHINT</ref>(<ref refid="structnetif" kindref="compound">netif</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline>
<codeline lineno="845"><highlight class="normal"></highlight></codeline>
<codeline lineno="846"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>@todo:<sp/>must<sp/>this<sp/>be<sp/>increased<sp/>even<sp/>if<sp/>error<sp/>occurred?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="847"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1a237a8f1e47af42fb612e936e928a9ced" kindref="member">MIB2_STATS_INC</ref>(mib2.udpoutdatagrams);</highlight></codeline>
<codeline lineno="848"><highlight class="normal"></highlight></codeline>
<codeline lineno="849"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>did<sp/>we<sp/>chain<sp/>a<sp/>separate<sp/>header<sp/>pbuf<sp/>earlier?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="850"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(q<sp/>!=<sp/>p)<sp/>{</highlight></codeline>
<codeline lineno="851"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>free<sp/>the<sp/>header<sp/>pbuf<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="852"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__pbuf_1gab0dd696fb4b6bc65e548944584f1738b" kindref="member">pbuf_free</ref>(q);</highlight></codeline>
<codeline lineno="853"><highlight class="normal"><sp/><sp/><sp/><sp/>q<sp/>=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline>
<codeline lineno="854"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>p<sp/>is<sp/>still<sp/>referenced<sp/>by<sp/>the<sp/>caller,<sp/>and<sp/>will<sp/>live<sp/>on<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="856"><highlight class="normal"></highlight></codeline>
<codeline lineno="857"><highlight class="normal"><sp/><sp/><ref refid="stats_8h_1acfc9de2d6edadfa3de3d9dfeb48f76b2" kindref="member">UDP_STATS_INC</ref>(udp.xmit);</highlight></codeline>
<codeline lineno="858"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="859"><highlight class="normal">}</highlight></codeline>
<codeline lineno="860"><highlight class="normal"></highlight></codeline>
<codeline lineno="881"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="882"><highlight class="normal">udp_bind(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*ipaddr,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port)</highlight></codeline>
<codeline lineno="883"><highlight class="normal">{</highlight></codeline>
<codeline lineno="884"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*ipcb;</highlight></codeline>
<codeline lineno="885"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>rebind;</highlight></codeline>
<codeline lineno="886"><highlight class="normal"></highlight></codeline>
<codeline lineno="887"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_IPV4</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="888"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Don&apos;t<sp/>propagate<sp/>NULL<sp/>pointer<sp/>(IPv4<sp/>ANY)<sp/>to<sp/>subsequent<sp/>functions<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="889"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ipaddr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="890"><highlight class="normal"><sp/><sp/><sp/><sp/>ipaddr<sp/>=<sp/>IP4_ADDR_ANY;</highlight></codeline>
<codeline lineno="891"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="892"><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="893"><highlight class="normal"></highlight></codeline>
<codeline lineno="894"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>still<sp/>need<sp/>to<sp/>check<sp/>for<sp/>ipaddr<sp/>==<sp/>NULL<sp/>in<sp/>IPv6<sp/>only<sp/>case<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="895"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(ipaddr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>))<sp/>{</highlight></codeline>
<codeline lineno="896"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="897"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="898"><highlight class="normal"></highlight></codeline>
<codeline lineno="899"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_bind(ipaddr<sp/>=<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="900"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>ipaddr);</highlight></codeline>
<codeline lineno="901"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>port<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/>port));</highlight></codeline>
<codeline lineno="902"><highlight class="normal"></highlight></codeline>
<codeline lineno="903"><highlight class="normal"><sp/><sp/>rebind<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="904"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>for<sp/>double<sp/>bind<sp/>and<sp/>rebind<sp/>of<sp/>the<sp/>same<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="905"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(ipcb<sp/>=<sp/>udp_pcbs;<sp/>ipcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>ipcb<sp/>=<sp/>ipcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="906"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>is<sp/>this<sp/>UDP<sp/>PCB<sp/>already<sp/>on<sp/>active<sp/>list?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="907"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>==<sp/>ipcb)<sp/>{</highlight></codeline>
<codeline lineno="908"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>rebind<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="909"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="910"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="911"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="912"><highlight class="normal"></highlight></codeline>
<codeline lineno="913"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>port<sp/>specified?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="914"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(port<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="915"><highlight class="normal"><sp/><sp/><sp/><sp/>port<sp/>=<sp/>udp_new_port();</highlight></codeline>
<codeline lineno="916"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(port<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="917"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>no<sp/>more<sp/>ports<sp/>available<sp/>in<sp/>local<sp/>range<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="918"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_bind:<sp/>out<sp/>of<sp/>free<sp/>UDP<sp/>ports\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="919"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca4ebdc2aa1dbd75f927845733a3fb1f8b" kindref="member">ERR_USE</ref>;</highlight></codeline>
<codeline lineno="920"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="921"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="922"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(ipcb<sp/>=<sp/>udp_pcbs;<sp/>ipcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>ipcb<sp/>=<sp/>ipcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="923"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/>ipcb)<sp/>{</highlight></codeline>
<codeline lineno="924"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>By<sp/>default,<sp/>we<sp/>don&apos;t<sp/>allow<sp/>to<sp/>bind<sp/>to<sp/>a<sp/>port<sp/>that<sp/>any<sp/>other<sp/>udp</highlight></codeline>
<codeline lineno="925"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>PCB<sp/>is<sp/>already<sp/>bound<sp/>to,<sp/>unless<sp/>*all*<sp/>PCBs<sp/>with<sp/>that<sp/>port<sp/>have<sp/>tha</highlight></codeline>
<codeline lineno="926"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>REUSEADDR<sp/>flag<sp/>set.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="927"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>SO_REUSE</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="928"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(pcb,<sp/><ref refid="ip_8h_1aa40b3366a7939ec3a60e9a7d239575e2" kindref="member">SOF_REUSEADDR</ref>)<sp/>||</highlight></codeline>
<codeline lineno="929"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>!<ref refid="ip_8h_1a26e077f52de4a97ff89c02415c084518" kindref="member">ip_get_option</ref>(ipcb,<sp/><ref refid="ip_8h_1aa40b3366a7939ec3a60e9a7d239575e2" kindref="member">SOF_REUSEADDR</ref>))</highlight></codeline>
<codeline lineno="930"><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="931"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="932"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>port<sp/>matches<sp/>that<sp/>of<sp/>PCB<sp/>in<sp/>list<sp/>and<sp/>REUSEADDR<sp/>not<sp/>set<sp/>-&gt;<sp/>reject<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="933"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((ipcb-&gt;local_port<sp/>==<sp/>port)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="934"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>IP<sp/>address<sp/>matches?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="935"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;ipcb-&gt;local_ip,<sp/>ipaddr))<sp/>{</highlight></codeline>
<codeline lineno="936"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>other<sp/>PCB<sp/>already<sp/>binds<sp/>to<sp/>this<sp/>local<sp/>IP<sp/>and<sp/>port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="937"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,</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/>(</highlight><highlight class="stringliteral">&quot;udp_bind:<sp/>local<sp/>port<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/>already<sp/>bound<sp/>by<sp/>another<sp/>pcb\n&quot;</highlight><highlight class="normal">,<sp/>port));</highlight></codeline>
<codeline lineno="939"><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="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadca4ebdc2aa1dbd75f927845733a3fb1f8b" kindref="member">ERR_USE</ref>;</highlight></codeline>
<codeline lineno="940"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="941"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="942"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="943"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="944"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="945"><highlight class="normal"></highlight></codeline>
<codeline lineno="946"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1aea5e4795598bc33fa2db1773c8e6fbac" kindref="member">ip_addr_set_ipaddr</ref>(&amp;pcb-&gt;local_ip,<sp/>ipaddr);</highlight></codeline>
<codeline lineno="947"><highlight class="normal"></highlight></codeline>
<codeline lineno="948"><highlight class="normal"><sp/><sp/>pcb-&gt;local_port<sp/>=<sp/>port;</highlight></codeline>
<codeline lineno="949"><highlight class="normal"><sp/><sp/><ref refid="snmp_8h_1acfc2d746bbaf82da4c34bbc65122931f" kindref="member">mib2_udp_bind</ref>(pcb);</highlight></codeline>
<codeline lineno="950"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>not<sp/>active<sp/>yet?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="951"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(rebind<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="952"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>place<sp/>the<sp/>PCB<sp/>on<sp/>the<sp/>active<sp/>list<sp/>if<sp/>not<sp/>already<sp/>there<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="953"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;next<sp/>=<sp/>udp_pcbs;</highlight></codeline>
<codeline lineno="954"><highlight class="normal"><sp/><sp/><sp/><sp/>udp_pcbs<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="955"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="956"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_bind:<sp/>bound<sp/>to<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="957"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>&amp;pcb-&gt;local_ip);</highlight></codeline>
<codeline lineno="958"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>port<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;local_port));</highlight></codeline>
<codeline lineno="959"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="960"><highlight class="normal">}</highlight></codeline>
<codeline lineno="961"><highlight class="normal"></highlight></codeline>
<codeline lineno="980"><highlight class="normal"><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref></highlight></codeline>
<codeline lineno="981"><highlight class="normal">udp_connect(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref><sp/>*ipaddr,<sp/><ref refid="group__compiler__abstraction_1ga77570ac4fcab86864fa1916e55676da2" kindref="member">u16_t</ref><sp/>port)</highlight></codeline>
<codeline lineno="982"><highlight class="normal">{</highlight></codeline>
<codeline lineno="983"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*ipcb;</highlight></codeline>
<codeline lineno="984"><highlight class="normal"></highlight></codeline>
<codeline lineno="985"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((pcb<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>||<sp/>(ipaddr<sp/>==<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>))<sp/>{</highlight></codeline>
<codeline lineno="986"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa9a1c5a6fdeed0aad7fe41d538482bbd" kindref="member">ERR_VAL</ref>;</highlight></codeline>
<codeline lineno="987"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="988"><highlight class="normal"></highlight></codeline>
<codeline lineno="989"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb-&gt;local_port<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="990"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="group__infrastructure__errors_1gaf02d9da80fd66b4f986d2c53d7231ddb" kindref="member">err_t</ref><sp/>err<sp/>=<sp/>udp_bind(pcb,<sp/>&amp;pcb-&gt;local_ip,<sp/>pcb-&gt;local_port);</highlight></codeline>
<codeline lineno="991"><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="992"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>err;</highlight></codeline>
<codeline lineno="993"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="994"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="995"><highlight class="normal"></highlight></codeline>
<codeline lineno="996"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1aea5e4795598bc33fa2db1773c8e6fbac" kindref="member">ip_addr_set_ipaddr</ref>(&amp;pcb-&gt;remote_ip,<sp/>ipaddr);</highlight></codeline>
<codeline lineno="997"><highlight class="normal"><sp/><sp/>pcb-&gt;remote_port<sp/>=<sp/>port;</highlight></codeline>
<codeline lineno="998"><highlight class="normal"><sp/><sp/>pcb-&gt;flags<sp/>|=<sp/>UDP_FLAGS_CONNECTED;</highlight></codeline>
<codeline lineno="999"><highlight class="normal"></highlight></codeline>
<codeline lineno="1000"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;udp_connect:<sp/>connected<sp/>to<sp/>&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1001"><highlight class="normal"><sp/><sp/><ref refid="ip__addr_8h_1af7d84bce2fb861a97f3047ecd69ab018" kindref="member">ip_addr_debug_print</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,</highlight></codeline>
<codeline lineno="1002"><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/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1003"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga988147559b78642ac881815b66023646" kindref="member">LWIP_DBG_TRACE</ref><sp/>|<sp/><ref refid="group__debugging__levels_1ga511ee3deb3240635f5ec6a1709c6d741" kindref="member">LWIP_DBG_STATE</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;,<sp/>port<sp/>%&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;)\n&quot;</highlight><highlight class="normal">,<sp/>pcb-&gt;remote_port));</highlight></codeline>
<codeline lineno="1004"><highlight class="normal"></highlight></codeline>
<codeline lineno="1005"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Insert<sp/>UDP<sp/>PCB<sp/>into<sp/>the<sp/>list<sp/>of<sp/>active<sp/>UDP<sp/>PCBs.<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1006"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(ipcb<sp/>=<sp/>udp_pcbs;<sp/>ipcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>ipcb<sp/>=<sp/>ipcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1007"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>==<sp/>ipcb)<sp/>{</highlight></codeline>
<codeline lineno="1008"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>already<sp/>on<sp/>the<sp/>list,<sp/>just<sp/>return<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1009"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1010"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1011"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1012"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>PCB<sp/>not<sp/>yet<sp/>on<sp/>the<sp/>list,<sp/>add<sp/>PCB<sp/>now<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1013"><highlight class="normal"><sp/><sp/>pcb-&gt;next<sp/>=<sp/>udp_pcbs;</highlight></codeline>
<codeline lineno="1014"><highlight class="normal"><sp/><sp/>udp_pcbs<sp/>=<sp/>pcb;</highlight></codeline>
<codeline lineno="1015"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="group__infrastructure__errors_1ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb" kindref="member">ERR_OK</ref>;</highlight></codeline>
<codeline lineno="1016"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1017"><highlight class="normal"></highlight></codeline>
<codeline lineno="1024"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1025"><highlight class="normal">udp_disconnect(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1026"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1027"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>reset<sp/>remote<sp/>address<sp/>association<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1028"><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="1029"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a83b17dbf7d1faf5c8f8c20b039db8bb8" kindref="member">IP_IS_ANY_TYPE_VAL</ref>(pcb-&gt;local_ip))<sp/>{</highlight></codeline>
<codeline lineno="1030"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(pcb-&gt;remote_ip,<sp/>*<ref refid="ip__addr_8h_1abe43b154533b73585c4e58f568370ede" kindref="member">IP_ANY_TYPE</ref>);</highlight></codeline>
<codeline lineno="1031"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1032"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1033"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a8853fce54b1816dca3af90b48677e673" kindref="member">ip_addr_set_any</ref>(<ref refid="ip__addr_8h_1a1578e34703e86711a7fb7dcc3857004d" kindref="member">IP_IS_V6_VAL</ref>(pcb-&gt;remote_ip),<sp/>&amp;pcb-&gt;remote_ip);</highlight></codeline>
<codeline lineno="1034"><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="1035"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1036"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1037"><highlight class="normal"><sp/><sp/>pcb-&gt;remote_port<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="1038"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>mark<sp/>PCB<sp/>as<sp/>unconnected<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1039"><highlight class="normal"><sp/><sp/>pcb-&gt;flags<sp/>&amp;=<sp/>~UDP_FLAGS_CONNECTED;</highlight></codeline>
<codeline lineno="1040"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1041"><highlight class="normal"></highlight></codeline>
<codeline lineno="1052"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1053"><highlight class="normal">udp_recv(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb,<sp/>udp_recv_fn<sp/>recv,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*recv_arg)</highlight></codeline>
<codeline lineno="1054"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1055"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>remember<sp/>recv()<sp/>callback<sp/>and<sp/>user<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1056"><highlight class="normal"><sp/><sp/>pcb-&gt;recv<sp/>=<sp/>recv;</highlight></codeline>
<codeline lineno="1057"><highlight class="normal"><sp/><sp/>pcb-&gt;recv_arg<sp/>=<sp/>recv_arg;</highlight></codeline>
<codeline lineno="1058"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1059"><highlight class="normal"></highlight></codeline>
<codeline lineno="1069"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1070"><highlight class="normal">udp_remove(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb<sp/>*pcb)</highlight></codeline>
<codeline lineno="1071"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1072"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*pcb2;</highlight></codeline>
<codeline lineno="1073"><highlight class="normal"></highlight></codeline>
<codeline lineno="1074"><highlight class="normal"><sp/><sp/><ref refid="snmp_8h_1a701a7670780a5e1663766efb7819a57b" kindref="member">mib2_udp_unbind</ref>(pcb);</highlight></codeline>
<codeline lineno="1075"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>to<sp/>be<sp/>removed<sp/>is<sp/>first<sp/>in<sp/>list?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1076"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(udp_pcbs<sp/>==<sp/>pcb)<sp/>{</highlight></codeline>
<codeline lineno="1077"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>make<sp/>list<sp/>start<sp/>at<sp/>2nd<sp/>pcb<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1078"><highlight class="normal"><sp/><sp/><sp/><sp/>udp_pcbs<sp/>=<sp/>udp_pcbs-&gt;next;</highlight></codeline>
<codeline lineno="1079"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>pcb<sp/>not<sp/>1st<sp/>in<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1080"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="1081"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(pcb2<sp/>=<sp/>udp_pcbs;<sp/>pcb2<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>pcb2<sp/>=<sp/>pcb2-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1082"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>find<sp/>pcb<sp/>in<sp/>udp_pcbs<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1083"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb2-&gt;next<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&amp;&amp;<sp/>pcb2-&gt;next<sp/>==<sp/>pcb)<sp/>{</highlight></codeline>
<codeline lineno="1084"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>remove<sp/>pcb<sp/>from<sp/>list<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1085"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>pcb2-&gt;next<sp/>=<sp/>pcb-&gt;next;</highlight></codeline>
<codeline lineno="1086"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="1087"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1088"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1089"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1090"><highlight class="normal"><sp/><sp/><ref refid="memp_8h_1aecd94926b7c2a0e23ae195f4ae97581f" kindref="member">memp_free</ref>(MEMP_UDP_PCB,<sp/>pcb);</highlight></codeline>
<codeline lineno="1091"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1092"><highlight class="normal"></highlight></codeline>
<codeline lineno="1102"><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*</highlight></codeline>
<codeline lineno="1103"><highlight class="normal">udp_new(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)</highlight></codeline>
<codeline lineno="1104"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1105"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*pcb;</highlight></codeline>
<codeline lineno="1106"><highlight class="normal"><sp/><sp/>pcb<sp/>=<sp/>(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*)<ref refid="memp_8h_1a2b00593d086313c267b54a976bf67aa5" kindref="member">memp_malloc</ref>(MEMP_UDP_PCB);</highlight></codeline>
<codeline lineno="1107"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>could<sp/>allocate<sp/>UDP<sp/>PCB?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1108"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1109"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>UDP<sp/>Lite:<sp/>by<sp/>initializing<sp/>to<sp/>all<sp/>zeroes,<sp/>chksum_len<sp/>is<sp/>set<sp/>to<sp/>0</highlight></codeline>
<codeline lineno="1110"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>which<sp/>means<sp/>checksum<sp/>is<sp/>generated<sp/>over<sp/>the<sp/>whole<sp/>datagram<sp/>per<sp/>default</highlight></codeline>
<codeline lineno="1111"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>*<sp/>(recommended<sp/>as<sp/>default<sp/>by<sp/>RFC<sp/>3828).<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1112"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>initialize<sp/>PCB<sp/>to<sp/>all<sp/>zeroes<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1113"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="string_8h_1ace4b911463887af5e748326323e99a23" kindref="member">memset</ref>(pcb,<sp/>0,<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/>udp_pcb));</highlight></codeline>
<codeline lineno="1114"><highlight class="normal"><sp/><sp/><sp/><sp/>pcb-&gt;ttl<sp/>=<sp/><ref refid="lwipopts_8h_1a97908a317bcba89174b5d1ccbdca0096" kindref="member">UDP_TTL</ref>;</highlight></codeline>
<codeline lineno="1115"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>LWIP_MULTICAST_TX_OPTIONS</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1116"><highlight class="normal"><sp/><sp/><sp/><sp/>udp_set_multicast_ttl(pcb,<sp/><ref refid="lwipopts_8h_1a97908a317bcba89174b5d1ccbdca0096" kindref="member">UDP_TTL</ref>);</highlight></codeline>
<codeline lineno="1117"><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="1118"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1119"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pcb;</highlight></codeline>
<codeline lineno="1120"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1121"><highlight class="normal"></highlight></codeline>
<codeline lineno="1134"><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*</highlight></codeline>
<codeline lineno="1135"><highlight class="normal">udp_new_ip_type(<ref refid="group__compiler__abstraction_1ga4caecabca98b43919dd11be1c0d4cd8e" kindref="member">u8_t</ref><sp/>type)</highlight></codeline>
<codeline lineno="1136"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1137"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb<sp/>*pcb;</highlight></codeline>
<codeline lineno="1138"><highlight class="normal"><sp/><sp/>pcb<sp/>=<sp/>udp_new();</highlight></codeline>
<codeline lineno="1139"><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="1140"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline>
<codeline lineno="1141"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(pcb-&gt;local_ip,<sp/><sp/>type);</highlight></codeline>
<codeline lineno="1142"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1aaa800ce1929a1bb0f3d64bebd44e4051" kindref="member">IP_SET_TYPE_VAL</ref>(pcb-&gt;remote_ip,<sp/>type);</highlight></codeline>
<codeline lineno="1143"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1144"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1145"><highlight class="normal"><sp/><sp/><ref refid="group__compiler__abstraction_1ga70624a5deb8b9199406372a7f3603ecf" kindref="member">LWIP_UNUSED_ARG</ref>(type);</highlight></codeline>
<codeline lineno="1146"><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="1147"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pcb;</highlight></codeline>
<codeline lineno="1148"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1149"><highlight class="normal"></highlight></codeline>
<codeline lineno="1155"><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>udp_netif_ip_addr_changed(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref>*<sp/>old_addr,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="ip__addr_8h_1a88b43639738c4de2d3cd22e3a1fd7696" kindref="member">ip_addr_t</ref>*<sp/>new_addr)</highlight></codeline>
<codeline lineno="1156"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1157"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">udp_pcb*<sp/>upcb;</highlight></codeline>
<codeline lineno="1158"><highlight class="normal"></highlight></codeline>
<codeline lineno="1159"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(old_addr)<sp/>&amp;&amp;<sp/>!<ref refid="ip__addr_8h_1a279118890e6a90aa740051fb8b0cc5f4" kindref="member">ip_addr_isany</ref>(new_addr))<sp/>{</highlight></codeline>
<codeline lineno="1160"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(upcb<sp/>=<sp/>udp_pcbs;<sp/>upcb<sp/>!=<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;<sp/>upcb<sp/>=<sp/>upcb-&gt;next)<sp/>{</highlight></codeline>
<codeline lineno="1161"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>PCB<sp/>bound<sp/>to<sp/>current<sp/>local<sp/>interface<sp/>address?<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1162"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<ref refid="ip__addr_8h_1a008c9c92d770cc030ea054e6b259835a" kindref="member">ip_addr_cmp</ref>(&amp;upcb-&gt;local_ip,<sp/>old_addr))<sp/>{</highlight></codeline>
<codeline lineno="1163"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>The<sp/>PCB<sp/>is<sp/>bound<sp/>to<sp/>the<sp/>old<sp/>ipaddr<sp/>and</highlight></codeline>
<codeline lineno="1164"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>*<sp/>is<sp/>set<sp/>to<sp/>bound<sp/>to<sp/>the<sp/>new<sp/>one<sp/>instead<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="ip__addr_8h_1a77a933975db287f6aa5c2e70249ba18f" kindref="member">ip_addr_copy</ref>(upcb-&gt;local_ip,<sp/>*new_addr);</highlight></codeline>
<codeline lineno="1166"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1167"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="1168"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="1169"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1170"><highlight class="normal"></highlight></codeline>
<codeline lineno="1171"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>UDP_DEBUG</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1172"><highlight class="normal"></highlight></codeline>
<codeline lineno="1177"><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1178"><highlight class="normal">udp_debug_print(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structudp__hdr" kindref="compound">udp_hdr</ref><sp/>*udphdr)</highlight></codeline>
<codeline lineno="1179"><highlight class="normal">{</highlight></codeline>
<codeline lineno="1180"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;UDP<sp/>header:\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1181"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;+-------------------------------+\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1182"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;|<sp/><sp/><sp/><sp/><sp/>%5&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/><sp/><sp/>|<sp/><sp/><sp/><sp/><sp/>%5&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/><sp/><sp/>|<sp/>(src<sp/>port,<sp/>dest<sp/>port)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1183"><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/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;src),<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;dest)));</highlight></codeline>
<codeline lineno="1184"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;+-------------------------------+\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1185"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;|<sp/><sp/><sp/><sp/><sp/>%5&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1gaa9d7f6eb2ee9fcc5eda3545dbb1886e0" kindref="member">U16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/><sp/><sp/>|<sp/><sp/><sp/><sp/><sp/>0x%04&quot;</highlight><highlight class="normal"><ref refid="group__compiler__abstraction_1ga1418f92673e54a36b6e376109e526382" kindref="member">X16_F</ref></highlight><highlight class="stringliteral">&quot;<sp/><sp/><sp/><sp/>|<sp/>(len,<sp/>chksum)\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="1186"><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/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;len),<sp/><ref refid="def_8h_1ac642bf6057869696d7807564d8309ffc" kindref="member">lwip_ntohs</ref>(udphdr-&gt;chksum)));</highlight></codeline>
<codeline lineno="1187"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_1a63a04edf7ff63c951bd8706711956cdb" kindref="member">LWIP_DEBUGF</ref>(<ref refid="lwipopts_8h_1a0393f312c5475a1c649b39ef9cfcaad4" kindref="member">UDP_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">&quot;+-------------------------------+\n&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="1188"><highlight class="normal">}</highlight></codeline>
<codeline lineno="1189"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>UDP_DEBUG<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="1190"><highlight class="normal"></highlight></codeline>
<codeline lineno="1191"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>LWIP_UDP<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/net/core/udp.c"/>
  </compounddef>
</doxygen>
