<?xml version='1.0' encoding='iso-8859-1' standalone='no'?> <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.4.7"> <compounddef id="sockets_8c" kind="file"> <compoundname>sockets.c</compoundname> <includes refid="types_8h" local="no">ubixos/types.h</includes> <includes refid="debug_8h" local="yes">net/debug.h</includes> <includes refid="api_8h" local="yes">net/api.h</includes> <includes refid="sockets_8h" local="yes">net/sockets.h</includes> <incdepgraph> <node id="3887"> <label>net/ipv4/ip.h</label> <link refid="ipv4_2ip_8h"/> <childnode refid="3882" relation="include"> </childnode> <childnode refid="3888" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3890" relation="include"> </childnode> <childnode refid="3891" relation="include"> </childnode> <childnode refid="3892" relation="include"> </childnode> </node> <node id="3889"> <label>arch/lib.h</label> <link refid="lib_8h"/> </node> <node id="3891"> <label>net/netif.h</label> <link refid="netif_8h"/> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3892" relation="include"> </childnode> <childnode refid="3890" relation="include"> </childnode> <childnode refid="3893" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> </node> <node id="3894"> <label>net/udp.h</label> <link refid="udp_8h"/> <childnode refid="3882" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3893" relation="include"> </childnode> <childnode refid="3887" relation="include"> </childnode> <childnode refid="3892" relation="include"> </childnode> </node> <node id="3883"> <label>arch/cpu.h</label> <link refid="cpu_8h"/> </node> <node id="3886"> <label>arch/sys_arch.h</label> <link refid="sys__arch_8h"/> </node> <node id="3895"> <label>net/tcp.h</label> <link refid="tcp_8h"/> <childnode refid="3885" relation="include"> </childnode> <childnode refid="3896" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3887" relation="include"> </childnode> <childnode refid="3897" relation="include"> </childnode> <childnode refid="3892" relation="include"> </childnode> </node> <node id="3875"> <label>ubixos/types.h</label> <link refid="types_8h"/> <childnode refid="3876" relation="include"> </childnode> </node> <node id="3876"> <label>sys/_types.h</label> <link refid="__types_8h"/> </node> <node id="3882"> <label>net/arch.h</label> <link refid="arch_8h"/> <childnode refid="3883" relation="include"> </childnode> <childnode refid="3884" relation="include"> </childnode> </node> <node id="3897"> <label>net/ipv4/icmp.h</label> <link refid="ipv4_2icmp_8h"/> <childnode refid="3882" relation="include"> </childnode> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3891" relation="include"> </childnode> </node> <node id="3880"> <label>net/lwipopts.h</label> <link refid="lwipopts_8h"/> </node> <node id="3888"> <label>net/def.h</label> <link refid="def_8h"/> <childnode refid="3889" relation="include"> </childnode> </node> <node id="3896"> <label>net/mem.h</label> <link refid="mem_8h"/> <childnode refid="3875" relation="include"> </childnode> <childnode refid="3877" relation="include"> </childnode> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3882" relation="include"> </childnode> </node> <node id="3890"> <label>net/ipv4/ip_addr.h</label> <link refid="ipv4_2ip__addr_8h"/> <childnode refid="3882" relation="include"> </childnode> </node> <node id="3892"> <label>net/err.h</label> <link refid="err_8h"/> <childnode refid="3875" relation="include"> </childnode> <childnode refid="3877" relation="include"> </childnode> <childnode refid="3884" relation="include"> </childnode> </node> <node id="3878"> <label>net/api.h</label> <link refid="api_8h"/> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3885" relation="include"> </childnode> <childnode refid="3887" relation="include"> </childnode> <childnode refid="3894" relation="include"> </childnode> <childnode refid="3895" relation="include"> </childnode> <childnode refid="3892" relation="include"> </childnode> </node> <node id="3898"> <label>net/sockets.h</label> <link refid="sockets_8h"/> <childnode refid="3875" relation="include"> </childnode> </node> <node id="3879"> <label>net/opt.h</label> <link refid="opt_8h"/> <childnode refid="3880" relation="include"> </childnode> </node> <node id="3885"> <label>net/sys.h</label> <link refid="sys_8h"/> <childnode refid="3884" relation="include"> </childnode> <childnode refid="3886" relation="include"> </childnode> </node> <node id="3874"> <label>src/sys/net/api/sockets.c</label> <link refid="sockets.c"/> <childnode refid="3875" relation="include"> </childnode> <childnode refid="3877" relation="include"> </childnode> <childnode refid="3878" relation="include"> </childnode> <childnode refid="3898" relation="include"> </childnode> </node> <node id="3881"> <label>net/pbuf.h</label> <link refid="pbuf_8h"/> <childnode refid="3877" relation="include"> </childnode> <childnode refid="3882" relation="include"> </childnode> </node> <node id="3877"> <label>net/debug.h</label> <link refid="debug_8h"/> </node> <node id="3893"> <label>net/ipv4/inet.h</label> <link refid="ipv4_2inet_8h"/> <childnode refid="3882" relation="include"> </childnode> <childnode refid="3879" relation="include"> </childnode> <childnode refid="3881" relation="include"> </childnode> <childnode refid="3890" relation="include"> </childnode> </node> <node id="3884"> <label>arch/cc.h</label> <link refid="cc_8h"/> </node> </incdepgraph> <innerclass refid="structlwip__socket" prot="public">lwip_socket</innerclass> <sectiondef kind="define"> <memberdef kind="define" id="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" prot="public" static="no"> <name>NUM_SOCKETS</name> <initializer>10</initializer> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="43" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="43" bodyend="-1"/> <referencedby refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" compoundref="sockets_8c" startline="74" endline="88">alloc_socket</referencedby> <referencedby refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</referencedby> </memberdef> </sectiondef> <sectiondef kind="func"> <memberdef kind="function" id="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" prot="public" static="yes" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>static int alloc_socket</definition> <argsstring>(struct netconn *newconn)</argsstring> <name>alloc_socket</name> <param> <type>struct <ref refid="structnetconn" kindref="compound">netconn</ref> *</type> <declname>newconn</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="75" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="74" bodyend="88"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" compoundref="sockets_8c" startline="47">lwip_socket::lastdata</references> <references refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" compoundref="sockets_8c" startline="48">lwip_socket::lastoffset</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" compoundref="sockets_8c" startline="43">NUM_SOCKETS</references> <references refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" compoundref="sockets_8c" startline="51">sockets</references> <referencedby refid="sockets_8c_1f32c7d1377562b7b35fdd0535f6fa952" compoundref="sockets_8c" startline="91" endline="118">lwip_accept</referencedby> <referencedby refid="sockets_8c_1d1afafec89b608d54649d7d02117d17c" compoundref="sockets_8c" startline="383" endline="414">lwip_socket</referencedby> </memberdef> <memberdef kind="function" id="sockets_8c_12c14650cba5521231ebeefa1ae807e67" prot="public" static="yes" const="no" explicit="no" inline="no" virt="non-virtual"> <type>struct <ref refid="structlwip__socket" kindref="compound">lwip_socket</ref> *</type> <definition>static struct lwip_socket* get_socket</definition> <argsstring>(int s)</argsstring> <name>get_socket</name> <param> <type>int</type> <declname>s</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="56" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="55" bodyend="71"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" compoundref="sockets_8c" startline="43">NUM_SOCKETS</references> <references refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" compoundref="sockets_8c" startline="51">sockets</references> <referencedby refid="sockets_8c_1f32c7d1377562b7b35fdd0535f6fa952" compoundref="sockets_8c" startline="91" endline="118">lwip_accept</referencedby> <referencedby refid="sockets_8c_11675042812d3bc6d5f9eeaa28c8f37a7" compoundref="sockets_8c" startline="121" endline="144">lwip_bind</referencedby> <referencedby refid="sockets_8c_1fd0897a2e23d99a5dffcc976c7e5d72c" compoundref="sockets_8c" startline="147" endline="166">lwip_close</referencedby> <referencedby refid="sockets_8c_19688d733f4d571cef85948fe74e0f6c7" compoundref="sockets_8c" startline="169" endline="192">lwip_connect</referencedby> <referencedby refid="sockets_8c_1bee6ee286147cf334a1ba19f19b2e08b" compoundref="sockets_8c" startline="195" endline="213">lwip_listen</referencedby> <referencedby refid="sockets_8c_1a433d1ebe9c87f57160c0d260e225705" compoundref="sockets_8c" startline="216" endline="290">lwip_recvfrom</referencedby> <referencedby refid="sockets_8c_1cb3ba0c7f21116c629f116e15e40ce2b" compoundref="sockets_8c" startline="305" endline="351">lwip_send</referencedby> <referencedby refid="sockets_8c_18dba95d254d6cb221ba4039ad8f3337b" compoundref="sockets_8c" startline="354" endline="380">lwip_sendto</referencedby> <referencedby refid="sockets_8c_1e3d92ccb1ddfafe7df89185dbc881ec2" compoundref="sockets_8c" startline="417" endline="445">lwip_write</referencedby> </memberdef> <memberdef kind="function" id="sockets_8c_1f32c7d1377562b7b35fdd0535f6fa952" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_accept</definition> <argsstring>(int s, struct sockaddr *addr, int *addrlen)</argsstring> <name>lwip_accept</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>struct <ref refid="structsockaddr" kindref="compound">sockaddr</ref> *</type> <declname>addr</declname> </param> <param> <type>int *</type> <declname>addrlen</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="92" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="91" bodyend="118"/> <references refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" compoundref="ipv6_2ip__addr_8h" startline="43">ip_addr::addr</references> <references refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" compoundref="sockets_8c" startline="74" endline="88">alloc_socket</references> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="api_8h_1b1ef5f260ad8147a3b5b70b317b489d2" compoundref="api__lib_8c" startline="416" endline="427">netconn_accept</references> <references refid="api_8h_1b411221f912a6d9e4c82ac3963989403" compoundref="api__lib_8c" startline="227" endline="278">netconn_delete</references> <references refid="api_8h_1afa4042fd63fd78a440006eb4da36eeb" compoundref="api__lib_8c" startline="287" endline="303">netconn_peer</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> </memberdef> <memberdef kind="function" id="sockets_8c_11675042812d3bc6d5f9eeaa28c8f37a7" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_bind</definition> <argsstring>(int s, struct sockaddr *name, int namelen)</argsstring> <name>lwip_bind</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>struct <ref refid="structsockaddr" kindref="compound">sockaddr</ref> *</type> <declname>name</declname> </param> <param> <type>int</type> <declname>namelen</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="122" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="121" bodyend="144"/> <references refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" compoundref="ipv6_2ip__addr_8h" startline="43">ip_addr::addr</references> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" compoundref="err_8h" startline="48">ERR_OK</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" compoundref="pci_8c" startline="39">name</references> <references refid="api_8h_1dc842fc0f1de512895ef3cc9c657272a" compoundref="api__lib_8c" startline="325" endline="352">netconn_bind</references> <references refid="ipv4_2inet_8h_1118e9d76568ab81ad97f138d4ea1ddd2" compoundref="ipv4_2inet_8h" startline="81">ntohs</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> </memberdef> <memberdef kind="function" id="sockets_8c_1fd0897a2e23d99a5dffcc976c7e5d72c" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_close</definition> <argsstring>(int s)</argsstring> <name>lwip_close</name> <param> <type>int</type> <declname>s</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="148" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="147" bodyend="166"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" compoundref="debug_8h" startline="92">DEBUGF</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" compoundref="sockets_8c" startline="47">lwip_socket::lastdata</references> <references refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" compoundref="sockets_8c" startline="48">lwip_socket::lastoffset</references> <references refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" compoundref="api__lib_8c" startline="66" endline="75">netbuf_delete</references> <references refid="api_8h_1b411221f912a6d9e4c82ac3963989403" compoundref="api__lib_8c" startline="227" endline="278">netconn_delete</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" compoundref="debug_8h" startline="107">SOCKETS_DEBUG</references> </memberdef> <memberdef kind="function" id="sockets_8c_19688d733f4d571cef85948fe74e0f6c7" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_connect</definition> <argsstring>(int s, struct sockaddr *name, int namelen)</argsstring> <name>lwip_connect</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>struct <ref refid="structsockaddr" kindref="compound">sockaddr</ref> *</type> <declname>name</declname> </param> <param> <type>int</type> <declname>namelen</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="170" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="169" bodyend="192"/> <references refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" compoundref="ipv6_2ip__addr_8h" startline="43">ip_addr::addr</references> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" compoundref="err_8h" startline="48">ERR_OK</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" compoundref="pci_8c" startline="39">name</references> <references refid="api_8h_140e08b372ad246ec7d2a7c9b1a2bd8fb" compoundref="api__lib_8c" startline="355" endline="386">netconn_connect</references> <references refid="ipv4_2inet_8h_1118e9d76568ab81ad97f138d4ea1ddd2" compoundref="ipv4_2inet_8h" startline="81">ntohs</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> </memberdef> <memberdef kind="function" id="sockets_8c_1bee6ee286147cf334a1ba19f19b2e08b" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_listen</definition> <argsstring>(int s, int backlog)</argsstring> <name>lwip_listen</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>int</type> <declname>backlog</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="196" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="195" bodyend="213"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" compoundref="err_8h" startline="48">ERR_OK</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="api_8h_1b917e0fc541447d966e5cf712ce24e58" compoundref="api__lib_8c" startline="389" endline="413">netconn_listen</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> </memberdef> <memberdef kind="function" id="sockets_8c_16853356e8156a0b652fa13105dd77397" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_read</definition> <argsstring>(int s, void *mem, int len)</argsstring> <name>lwip_read</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>mem</declname> </param> <param> <type>int</type> <declname>len</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="294" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="293" bodyend="296"/> <references refid="sockets_8h_147db87caa9030759f3ffd872df113661" compoundref="sockets_8c" startline="299" endline="302">lwip_recv</references> </memberdef> <memberdef kind="function" id="sockets_8c_147db87caa9030759f3ffd872df113661" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_recv</definition> <argsstring>(int s, void *mem, int len, unsigned int flags)</argsstring> <name>lwip_recv</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>mem</declname> </param> <param> <type>int</type> <declname>len</declname> </param> <param> <type>unsigned int</type> <declname>flags</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="300" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="299" bodyend="302"/> <references refid="sockets_8h_1a433d1ebe9c87f57160c0d260e225705" compoundref="sockets_8c" startline="216" endline="290">lwip_recvfrom</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <referencedby refid="sockets_8c_16853356e8156a0b652fa13105dd77397" compoundref="sockets_8c" startline="293" endline="296">lwip_read</referencedby> </memberdef> <memberdef kind="function" id="sockets_8c_1a433d1ebe9c87f57160c0d260e225705" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_recvfrom</definition> <argsstring>(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, int *fromlen)</argsstring> <name>lwip_recvfrom</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>mem</declname> </param> <param> <type>int</type> <declname>len</declname> </param> <param> <type>unsigned int</type> <declname>flags</declname> </param> <param> <type>struct <ref refid="structsockaddr" kindref="compound">sockaddr</ref> *</type> <declname>from</declname> </param> <param> <type>int *</type> <declname>fromlen</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="218" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="216" bodyend="290"/> <references refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" compoundref="ipv6_2ip__addr_8h" startline="43">ip_addr::addr</references> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="ipv4_2inet_8h_1b7fffd06ef1d1a7d34f99eedbb9f44dd" compoundref="ipv4_2inet_8h" startline="66">htons</references> <references refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" compoundref="sockets_8c" startline="47">lwip_socket::lastdata</references> <references refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" compoundref="sockets_8c" startline="48">lwip_socket::lastoffset</references> <references refid="api_8h_19a5f4f669674daa2f3b7b303d7cea915" compoundref="api__lib_8c" startline="158" endline="183">netbuf_copy_partial</references> <references refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" compoundref="api__lib_8c" startline="66" endline="75">netbuf_delete</references> <references refid="api_8h_18dd3c0551aa79d162b224ea5cd815b55" compoundref="api__lib_8c" startline="192" endline="195">netbuf_fromaddr</references> <references refid="api_8h_16294b37d1aba1478329e1f084f39db5d" compoundref="api__lib_8c" startline="198" endline="201">netbuf_fromport</references> <references refid="api_8h_16d20eca8f0316e4e71980108c1563581" compoundref="api__lib_8c" startline="122" endline="125">netbuf_len</references> <references refid="api_8h_1cbd0b5a0344c2c3fffe5a02445a2c2b3" compoundref="api__lib_8c" startline="430" endline="506">netconn_recv</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a">NETCONN_TCP</references> <references refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" compoundref="api__lib_8c" startline="281" endline="284">netconn_type</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <referencedby refid="sockets_8c_147db87caa9030759f3ffd872df113661" compoundref="sockets_8c" startline="299" endline="302">lwip_recv</referencedby> </memberdef> <memberdef kind="function" id="sockets_8c_1cb3ba0c7f21116c629f116e15e40ce2b" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_send</definition> <argsstring>(int s, void *data, int size, unsigned int flags)</argsstring> <name>lwip_send</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>data</declname> </param> <param> <type>int</type> <declname>size</declname> </param> <param> <type>unsigned int</type> <declname>flags</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="306" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="305" bodyend="351"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" compoundref="debug_8h" startline="92">DEBUGF</references> <references refid="structnetbuf_1efd0b92792db1bdb3547d1f1d3212f67" compoundref="api_8h" startline="72">netbuf::err</references> <references refid="err_8h_18700518a3e3d0c7a4439a37dcbcf2143" compoundref="err_8h" startline="60">ERR_ARG</references> <references refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" compoundref="err_8h" startline="48">ERR_OK</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" compoundref="api__lib_8c" startline="66" endline="75">netbuf_delete</references> <references refid="api_8h_1aba704cd963e35e71145de9f5112991d" compoundref="api__lib_8c" startline="51" endline="63">netbuf_new</references> <references refid="api_8h_1f038b56dbdd67a6e48bf0125c8ef61ba" compoundref="api__lib_8c" startline="102" endline="111">netbuf_ref</references> <references refid="api_8h_1482106705a409ffb01daa6b18c159e5f" compoundref="api_8h" startline="50">NETCONN_COPY</references> <references refid="api_8h_1c4d4d10153d47c80a783c34b27c66238" compoundref="api__lib_8c" startline="509" endline="534">netconn_send</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a">NETCONN_TCP</references> <references refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" compoundref="api__lib_8c" startline="281" endline="284">netconn_type</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636">NETCONN_UDP</references> <references refid="api_8h_19363929b6c680bc1dd3f302885128959" compoundref="api__lib_8c" startline="537" endline="609">netconn_write</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" compoundref="debug_8h" startline="107">SOCKETS_DEBUG</references> <referencedby refid="sockets_8c_18dba95d254d6cb221ba4039ad8f3337b" compoundref="sockets_8c" startline="354" endline="380">lwip_sendto</referencedby> <referencedby refid="sockets_8c_1e3d92ccb1ddfafe7df89185dbc881ec2" compoundref="sockets_8c" startline="417" endline="445">lwip_write</referencedby> </memberdef> <memberdef kind="function" id="sockets_8c_18dba95d254d6cb221ba4039ad8f3337b" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_sendto</definition> <argsstring>(int s, void *data, int size, unsigned int flags, struct sockaddr *to, int tolen)</argsstring> <name>lwip_sendto</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>data</declname> </param> <param> <type>int</type> <declname>size</declname> </param> <param> <type>unsigned int</type> <declname>flags</declname> </param> <param> <type>struct <ref refid="structsockaddr" kindref="compound">sockaddr</ref> *</type> <declname>to</declname> </param> <param> <type>int</type> <declname>tolen</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="356" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="354" bodyend="380"/> <references refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" compoundref="ipv6_2ip__addr_8h" startline="43">ip_addr::addr</references> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="sockets_8h_1a36cb527b3501bc2ce42f7283a010e7a" compoundref="sockets_8c" startline="305" endline="351">lwip_send</references> <references refid="api_8h_140e08b372ad246ec7d2a7c9b1a2bd8fb" compoundref="api__lib_8c" startline="355" endline="386">netconn_connect</references> <references refid="api_8h_1afa4042fd63fd78a440006eb4da36eeb" compoundref="api__lib_8c" startline="287" endline="303">netconn_peer</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> </memberdef> <memberdef kind="function" id="sockets_8c_1d1afafec89b608d54649d7d02117d17c" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_socket</definition> <argsstring>(int domain, int type, int protocol)</argsstring> <name>lwip_socket</name> <param> <type>int</type> <declname>domain</declname> </param> <param> <type>int</type> <declname>type</declname> </param> <param> <type>int</type> <declname>protocol</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="384" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="383" bodyend="414"/> <references refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" compoundref="sockets_8c" startline="74" endline="88">alloc_socket</references> <references refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" compoundref="debug_8h" startline="92">DEBUGF</references> <references refid="api_8h_1b411221f912a6d9e4c82ac3963989403" compoundref="api__lib_8c" startline="227" endline="278">netconn_delete</references> <references refid="api_8h_1935860c5a91e85457369b6f558e638fd" compoundref="api__lib_8c" startline="204" endline="224">netconn_new</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a">NETCONN_TCP</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636">NETCONN_UDP</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="sockets_8h_14db8b9a846c67404db0b6f014f9a9fdf" compoundref="sockets_8h" startline="62">SOCK_DGRAM</references> <references refid="sockets_8h_1249394484f9410a2e3f8eba24657feb9" compoundref="sockets_8h" startline="61">SOCK_STREAM</references> <references refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" compoundref="debug_8h" startline="107">SOCKETS_DEBUG</references> </memberdef> <memberdef kind="function" id="sockets_8c_1e3d92ccb1ddfafe7df89185dbc881ec2" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> <type>int</type> <definition>int lwip_write</definition> <argsstring>(int s, void *data, int size)</argsstring> <name>lwip_write</name> <param> <type>int</type> <declname>s</declname> </param> <param> <type>void *</type> <declname>data</declname> </param> <param> <type>int</type> <declname>size</declname> </param> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="418" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="417" bodyend="445"/> <references refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" compoundref="sockets_8c" startline="46">lwip_socket::conn</references> <references refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" compoundref="debug_8h" startline="92">DEBUGF</references> <references refid="err_8h_18700518a3e3d0c7a4439a37dcbcf2143" compoundref="err_8h" startline="60">ERR_ARG</references> <references refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" compoundref="err_8h" startline="48">ERR_OK</references> <references refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</references> <references refid="sockets_8h_1a36cb527b3501bc2ce42f7283a010e7a" compoundref="sockets_8c" startline="305" endline="351">lwip_send</references> <references refid="api_8h_1482106705a409ffb01daa6b18c159e5f" compoundref="api_8h" startline="50">NETCONN_COPY</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a">NETCONN_TCP</references> <references refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" compoundref="api__lib_8c" startline="281" endline="284">netconn_type</references> <references refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636">NETCONN_UDP</references> <references refid="api_8h_19363929b6c680bc1dd3f302885128959" compoundref="api__lib_8c" startline="537" endline="609">netconn_write</references> <references refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="def_8h" startline="41">NULL</references> <references refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" compoundref="debug_8h" startline="107">SOCKETS_DEBUG</references> </memberdef> </sectiondef> <sectiondef kind="var"> <memberdef kind="variable" id="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" prot="public" static="yes" mutable="no"> <type>struct <ref refid="structlwip__socket" kindref="compound">lwip_socket</ref></type> <definition>struct lwip_socket sockets[NUM_SOCKETS]</definition> <argsstring>[NUM_SOCKETS]</argsstring> <name>sockets</name> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <inbodydescription> </inbodydescription> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" line="51" bodyfile="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c" bodystart="51" bodyend="-1"/> <referencedby refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" compoundref="sockets_8c" startline="74" endline="88">alloc_socket</referencedby> <referencedby refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" compoundref="sockets_8c" startline="55" endline="71">get_socket</referencedby> </memberdef> </sectiondef> <briefdescription> </briefdescription> <detaileddescription> </detaileddescription> <programlisting> <codeline lineno="1"><highlight class="comment">/*</highlight></codeline> <codeline lineno="2"><highlight class="comment"><sp/>*<sp/>Copyright<sp/>(c)<sp/>2001,<sp/>Swedish<sp/>Institute<sp/>of<sp/>Computer<sp/>Science.</highlight></codeline> <codeline lineno="3"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.<sp/></highlight></codeline> <codeline lineno="4"><highlight class="comment"><sp/>*</highlight></codeline> <codeline lineno="5"><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/></highlight></codeline> <codeline lineno="6"><highlight class="comment"><sp/>*<sp/>modification,<sp/>are<sp/>permitted<sp/>provided<sp/>that<sp/>the<sp/>following<sp/>conditions<sp/></highlight></codeline> <codeline lineno="7"><highlight class="comment"><sp/>*<sp/>are<sp/>met:<sp/></highlight></codeline> <codeline lineno="8"><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/></highlight></codeline> <codeline lineno="9"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>notice,<sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer.<sp/></highlight></codeline> <codeline lineno="10"><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/></highlight></codeline> <codeline lineno="11"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>notice,<sp/>this<sp/>list<sp/>of<sp/>conditions<sp/>and<sp/>the<sp/>following<sp/>disclaimer<sp/>in<sp/>the<sp/></highlight></codeline> <codeline lineno="12"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>documentation<sp/>and/or<sp/>other<sp/>materials<sp/>provided<sp/>with<sp/>the<sp/>distribution.<sp/></highlight></codeline> <codeline lineno="13"><highlight class="comment"><sp/>*<sp/>3.<sp/>Neither<sp/>the<sp/>name<sp/>of<sp/>the<sp/>Institute<sp/>nor<sp/>the<sp/>names<sp/>of<sp/>its<sp/>contributors<sp/></highlight></codeline> <codeline lineno="14"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>may<sp/>be<sp/>used<sp/>to<sp/>endorse<sp/>or<sp/>promote<sp/>products<sp/>derived<sp/>from<sp/>this<sp/>software<sp/></highlight></codeline> <codeline lineno="15"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>without<sp/>specific<sp/>prior<sp/>written<sp/>permission.<sp/></highlight></codeline> <codeline lineno="16"><highlight class="comment"><sp/>*</highlight></codeline> <codeline lineno="17"><highlight class="comment"><sp/>*<sp/>THIS<sp/>SOFTWARE<sp/>IS<sp/>PROVIDED<sp/>BY<sp/>THE<sp/>INSTITUTE<sp/>AND<sp/>CONTRIBUTORS<sp/>``AS<sp/>IS''<sp/>AND<sp/></highlight></codeline> <codeline lineno="18"><highlight class="comment"><sp/>*<sp/>ANY<sp/>EXPRESS<sp/>OR<sp/>IMPLIED<sp/>WARRANTIES,<sp/>INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>THE<sp/></highlight></codeline> <codeline lineno="19"><highlight class="comment"><sp/>*<sp/>IMPLIED<sp/>WARRANTIES<sp/>OF<sp/>MERCHANTABILITY<sp/>AND<sp/>FITNESS<sp/>FOR<sp/>A<sp/>PARTICULAR<sp/>PURPOSE<sp/></highlight></codeline> <codeline lineno="20"><highlight class="comment"><sp/>*<sp/>ARE<sp/>DISCLAIMED.<sp/><sp/>IN<sp/>NO<sp/>EVENT<sp/>SHALL<sp/>THE<sp/>INSTITUTE<sp/>OR<sp/>CONTRIBUTORS<sp/>BE<sp/>LIABLE<sp/></highlight></codeline> <codeline lineno="21"><highlight class="comment"><sp/>*<sp/>FOR<sp/>ANY<sp/>DIRECT,<sp/>INDIRECT,<sp/>INCIDENTAL,<sp/>SPECIAL,<sp/>EXEMPLARY,<sp/>OR<sp/>CONSEQUENTIAL<sp/></highlight></codeline> <codeline lineno="22"><highlight class="comment"><sp/>*<sp/>DAMAGES<sp/>(INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>PROCUREMENT<sp/>OF<sp/>SUBSTITUTE<sp/>GOODS<sp/></highlight></codeline> <codeline lineno="23"><highlight class="comment"><sp/>*<sp/>OR<sp/>SERVICES;<sp/>LOSS<sp/>OF<sp/>USE,<sp/>DATA,<sp/>OR<sp/>PROFITS;<sp/>OR<sp/>BUSINESS<sp/>INTERRUPTION)<sp/></highlight></codeline> <codeline lineno="24"><highlight class="comment"><sp/>*<sp/>HOWEVER<sp/>CAUSED<sp/>AND<sp/>ON<sp/>ANY<sp/>THEORY<sp/>OF<sp/>LIABILITY,<sp/>WHETHER<sp/>IN<sp/>CONTRACT,<sp/>STRICT<sp/></highlight></codeline> <codeline lineno="25"><highlight class="comment"><sp/>*<sp/>LIABILITY,<sp/>OR<sp/>TORT<sp/>(INCLUDING<sp/>NEGLIGENCE<sp/>OR<sp/>OTHERWISE)<sp/>ARISING<sp/>IN<sp/>ANY<sp/>WAY<sp/></highlight></codeline> <codeline lineno="26"><highlight class="comment"><sp/>*<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<sp/>OF<sp/></highlight></codeline> <codeline lineno="27"><highlight class="comment"><sp/>*<sp/>SUCH<sp/>DAMAGE.<sp/></highlight></codeline> <codeline lineno="28"><highlight class="comment"><sp/>*</highlight></codeline> <codeline lineno="29"><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="30"><highlight class="comment"><sp/>*<sp/></highlight></codeline> <codeline lineno="31"><highlight class="comment"><sp/>*<sp/>Author:<sp/>Adam<sp/>Dunkels<sp/><adam@sics.se></highlight></codeline> <codeline lineno="32"><highlight class="comment"><sp/>*</highlight></codeline> <codeline lineno="33"><highlight class="comment"><sp/>*<sp/>$Id: sockets_8c.xml 88 2016-01-12 00:11:29Z reddawg $</highlight></codeline> <codeline lineno="34"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="35"><highlight class="normal"></highlight></codeline> <codeline lineno="36"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/><<ref refid="types_8h" kindref="compound">ubixos/types.h</ref>></highlight><highlight class="normal"></highlight></codeline> <codeline lineno="37"><highlight class="normal"></highlight></codeline> <codeline lineno="38"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"<ref refid="debug_8h" kindref="compound">net/debug.h</ref>"</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="39"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"<ref refid="api_8h" kindref="compound">net/api.h</ref>"</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="40"><highlight class="normal"></highlight></codeline> <codeline lineno="41"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"<ref refid="sockets_8h" kindref="compound">net/sockets.h</ref>"</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="42"><highlight class="normal"></highlight></codeline> <codeline lineno="43" refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>NUM_SOCKETS<sp/>10</highlight></codeline> <codeline lineno="44"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline> <codeline lineno="45" refid="structlwip__socket" refkind="compound"><highlight class="normal"></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>{</highlight></codeline> <codeline lineno="46" refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetconn" kindref="compound">netconn</ref><sp/>*<ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>;</highlight></codeline> <codeline lineno="47" refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetbuf" kindref="compound">netbuf</ref><sp/>*<ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref>;</highlight></codeline> <codeline lineno="48" refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" refkind="member"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref>;</highlight></codeline> <codeline lineno="49"><highlight class="normal">};</highlight></codeline> <codeline lineno="50"><highlight class="normal"></highlight></codeline> <codeline lineno="51" refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" refkind="member"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/><ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[<ref refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" kindref="member">NUM_SOCKETS</ref>];</highlight></codeline> <codeline lineno="52"><highlight class="normal"></highlight></codeline> <codeline lineno="53"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="54"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*</highlight></codeline> <codeline lineno="55" refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" refkind="member"><highlight class="normal"><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline> <codeline lineno="56"><highlight class="normal">{</highlight></codeline> <codeline lineno="57"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="58"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="59"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(s<sp/>><sp/><ref refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" kindref="member">NUM_SOCKETS</ref>)<sp/>{</highlight></codeline> <codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>EBADF;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="62"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="63"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="64"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/>&<ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[s];</highlight></codeline> <codeline lineno="65"><highlight class="normal"></highlight></codeline> <codeline lineno="66"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref><sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>EBADF;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="69"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="70"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>sock;</highlight></codeline> <codeline lineno="71"><highlight class="normal">}</highlight></codeline> <codeline lineno="72"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="73"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="74" refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" refkind="member"><highlight class="normal"><ref refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" kindref="member">alloc_socket</ref>(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structnetconn" kindref="compound">netconn</ref><sp/>*newconn)</highlight></codeline> <codeline lineno="75"><highlight class="normal">{</highlight></codeline> <codeline lineno="76"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline> <codeline lineno="77"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="78"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>allocate<sp/>a<sp/>new<sp/>socket<sp/>identifier<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="79"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(i<sp/>=<sp/>0;<sp/>i<sp/><<sp/><ref refid="sockets_8c_11c803e4ececfb47d2791c9283c85eb00" kindref="member">NUM_SOCKETS</ref>;<sp/>++i)<sp/>{</highlight></codeline> <codeline lineno="80"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(<ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[i].<ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref><sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="81"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[i].<ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref><sp/>=<sp/>newconn;</highlight></codeline> <codeline lineno="82"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[i].<ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="83"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="sockets_8c_1f7251745bb404cb82fd45c10982fb9f8" kindref="member">sockets</ref>[i].<ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref><sp/>=<sp/>0;</highlight></codeline> <codeline lineno="84"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>i;</highlight></codeline> <codeline lineno="85"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline> <codeline lineno="86"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="87"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="88"><highlight class="normal">}</highlight></codeline> <codeline lineno="89"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="90"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="91" refid="sockets_8c_1f32c7d1377562b7b35fdd0535f6fa952" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1f32c7d1377562b7b35fdd0535f6fa952" kindref="member">lwip_accept</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structsockaddr" kindref="compound">sockaddr</ref><sp/>*addr,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*addrlen)</highlight></codeline> <codeline lineno="92"><highlight class="normal">{</highlight></codeline> <codeline lineno="93"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="94"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetconn" kindref="compound">netconn</ref><sp/>*newconn;</highlight></codeline> <codeline lineno="95"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__addr" kindref="compound">ip_addr</ref><sp/>*naddr;</highlight></codeline> <codeline lineno="96"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>port;</highlight></codeline> <codeline lineno="97"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>newsock;</highlight></codeline> <codeline lineno="98"><highlight class="normal"></highlight></codeline> <codeline lineno="99"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="100"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="101"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="102"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="103"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="104"><highlight class="normal"><sp/><sp/>newconn<sp/>=<sp/><ref refid="api_8h_1b1ef5f260ad8147a3b5b70b317b489d2" kindref="member">netconn_accept</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>);</highlight></codeline> <codeline lineno="105"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="106"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>IP<sp/>address<sp/>and<sp/>port<sp/>of<sp/>the<sp/>remote<sp/>host<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="107"><highlight class="normal"><sp/><sp/><ref refid="api_8h_1afa4042fd63fd78a440006eb4da36eeb" kindref="member">netconn_peer</ref>(newconn,<sp/>&naddr,<sp/>&port);</highlight></codeline> <codeline lineno="108"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="109"><highlight class="normal"><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)addr)->sin_addr.s_addr<sp/>=<sp/>naddr-><ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref>;</highlight></codeline> <codeline lineno="110"><highlight class="normal"><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)addr)->sin_port<sp/>=<sp/>port;</highlight></codeline> <codeline lineno="111"><highlight class="normal"></highlight></codeline> <codeline lineno="112"><highlight class="normal"><sp/><sp/>newsock<sp/>=<sp/><ref refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" kindref="member">alloc_socket</ref>(newconn);</highlight></codeline> <codeline lineno="113"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(newsock<sp/>==<sp/>-1)<sp/>{<sp/><sp/></highlight></codeline> <codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_1b411221f912a6d9e4c82ac3963989403" kindref="member">netconn_delete</ref>(newconn);</highlight></codeline> <codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>ENOBUFS;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="116"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="117"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>newsock;</highlight></codeline> <codeline lineno="118"><highlight class="normal">}</highlight></codeline> <codeline lineno="119"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="120"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="121" refid="sockets_8c_11675042812d3bc6d5f9eeaa28c8f37a7" refkind="member"><highlight class="normal"><ref refid="sockets_8h_11675042812d3bc6d5f9eeaa28c8f37a7" kindref="member">lwip_bind</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structsockaddr" kindref="compound">sockaddr</ref><sp/>*<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>namelen)</highlight></codeline> <codeline lineno="122"><highlight class="normal">{</highlight></codeline> <codeline lineno="123"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="124"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__addr" kindref="compound">ip_addr</ref><sp/>remote_addr;</highlight></codeline> <codeline lineno="125"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>remote_port;</highlight></codeline> <codeline lineno="126"><highlight class="normal"><sp/><sp/><ref refid="err_8h_1b7190f3da5c85931fc059e0312bc1407" kindref="member">err_t</ref><sp/>err;</highlight></codeline> <codeline lineno="127"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="128"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="129"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="131"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="132"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="133"><highlight class="normal"><sp/><sp/>remote_addr.<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref><sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)->sin_addr.s_addr;</highlight></codeline> <codeline lineno="134"><highlight class="normal"><sp/><sp/>remote_port<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)->sin_port;</highlight></codeline> <codeline lineno="135"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="136"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_1dc842fc0f1de512895ef3cc9c657272a" kindref="member">netconn_bind</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>&remote_addr,<sp/><ref refid="ipv4_2inet_8h_1118e9d76568ab81ad97f138d4ea1ddd2" kindref="member">ntohs</ref>(remote_port));</highlight></codeline> <codeline lineno="137"><highlight class="normal"></highlight></codeline> <codeline lineno="138"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(err<sp/>!=<sp/><ref refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline> <codeline lineno="139"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="141"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="142"><highlight class="normal"></highlight></codeline> <codeline lineno="143"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline> <codeline lineno="144"><highlight class="normal">}</highlight></codeline> <codeline lineno="145"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="146"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="147" refid="sockets_8c_1fd0897a2e23d99a5dffcc976c7e5d72c" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1fd0897a2e23d99a5dffcc976c7e5d72c" kindref="member">lwip_close</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s)</highlight></codeline> <codeline lineno="148"><highlight class="normal">{</highlight></codeline> <codeline lineno="149"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="150"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="151"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" kindref="member">DEBUGF</ref>(<ref refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">"close:<sp/>socket<sp/>%d\n"</highlight><highlight class="normal">,<sp/>s));</highlight></codeline> <codeline lineno="152"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="153"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="155"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="156"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="157"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="158"><highlight class="normal"><sp/><sp/><ref refid="api_8h_1b411221f912a6d9e4c82ac3963989403" kindref="member">netconn_delete</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>);</highlight></codeline> <codeline lineno="159"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>!=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="160"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" kindref="member">netbuf_delete</ref>(sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref>);</highlight></codeline> <codeline lineno="161"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="162"><highlight class="normal"><sp/><sp/>sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="163"><highlight class="normal"><sp/><sp/>sock-><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref><sp/>=<sp/>0;</highlight></codeline> <codeline lineno="164"><highlight class="normal"><sp/><sp/>sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref><sp/>=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="165"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline> <codeline lineno="166"><highlight class="normal">}</highlight></codeline> <codeline lineno="167"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="168"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="169" refid="sockets_8c_19688d733f4d571cef85948fe74e0f6c7" refkind="member"><highlight class="normal"><ref refid="sockets_8h_19688d733f4d571cef85948fe74e0f6c7" kindref="member">lwip_connect</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structsockaddr" kindref="compound">sockaddr</ref><sp/>*<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>namelen)</highlight></codeline> <codeline lineno="170"><highlight class="normal">{</highlight></codeline> <codeline lineno="171"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="172"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__addr" kindref="compound">ip_addr</ref><sp/>remote_addr;</highlight></codeline> <codeline lineno="173"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>remote_port;</highlight></codeline> <codeline lineno="174"><highlight class="normal"><sp/><sp/><ref refid="err_8h_1b7190f3da5c85931fc059e0312bc1407" kindref="member">err_t</ref><sp/>err;</highlight></codeline> <codeline lineno="175"><highlight class="normal"></highlight></codeline> <codeline lineno="176"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="177"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="178"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="179"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="180"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="181"><highlight class="normal"><sp/><sp/>remote_addr.<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref><sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)->sin_addr.s_addr;</highlight></codeline> <codeline lineno="182"><highlight class="normal"><sp/><sp/>remote_port<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)<ref refid="pci_8c_18f8f80d37794cde9472343e4487ba3eb" kindref="member">name</ref>)->sin_port;</highlight></codeline> <codeline lineno="183"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="184"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_140e08b372ad246ec7d2a7c9b1a2bd8fb" kindref="member">netconn_connect</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>&remote_addr,<sp/><ref refid="ipv4_2inet_8h_1118e9d76568ab81ad97f138d4ea1ddd2" kindref="member">ntohs</ref>(remote_port));</highlight></codeline> <codeline lineno="185"><highlight class="normal"></highlight></codeline> <codeline lineno="186"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(err<sp/>!=<sp/><ref refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline> <codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="188"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="189"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="190"><highlight class="normal"></highlight></codeline> <codeline lineno="191"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline> <codeline lineno="192"><highlight class="normal">}</highlight></codeline> <codeline lineno="193"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="194"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="195" refid="sockets_8c_1bee6ee286147cf334a1ba19f19b2e08b" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1bee6ee286147cf334a1ba19f19b2e08b" kindref="member">lwip_listen</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>backlog)</highlight></codeline> <codeline lineno="196"><highlight class="normal">{</highlight></codeline> <codeline lineno="197"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;<sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="198"><highlight class="normal"><sp/><sp/><ref refid="err_8h_1b7190f3da5c85931fc059e0312bc1407" kindref="member">err_t</ref><sp/>err;</highlight></codeline> <codeline lineno="199"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="200"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="201"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="203"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="204"><highlight class="normal"><sp/></highlight></codeline> <codeline lineno="205"><highlight class="normal"><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_1b917e0fc541447d966e5cf712ce24e58" kindref="member">netconn_listen</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>);</highlight></codeline> <codeline lineno="206"><highlight class="normal"></highlight></codeline> <codeline lineno="207"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(err<sp/>!=<sp/><ref refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline> <codeline lineno="208"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="209"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</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/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline> <codeline lineno="213"><highlight class="normal">}</highlight></codeline> <codeline lineno="214"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="215"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="216" refid="sockets_8c_1a433d1ebe9c87f57160c0d260e225705" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1a433d1ebe9c87f57160c0d260e225705" kindref="member">lwip_recvfrom</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*mem,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>len,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags,</highlight></codeline> <codeline lineno="217"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structsockaddr" kindref="compound">sockaddr</ref><sp/>*from,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*fromlen)</highlight></codeline> <codeline lineno="218"><highlight class="normal">{</highlight></codeline> <codeline lineno="219"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="220"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetbuf" kindref="compound">netbuf</ref><sp/>*<ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline> <codeline lineno="221"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>buflen,<sp/>copylen;</highlight></codeline> <codeline lineno="222"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__addr" kindref="compound">ip_addr</ref><sp/>*<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref>;</highlight></codeline> <codeline lineno="223"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>port;</highlight></codeline> <codeline lineno="224"><highlight class="normal"></highlight></codeline> <codeline lineno="225"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="226"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="227"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="228"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="229"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="230"><highlight class="normal"></highlight></codeline> <codeline lineno="231"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>if<sp/>there<sp/>is<sp/>data<sp/>left<sp/>from<sp/>the<sp/>last<sp/>recv<sp/>operation.<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="232"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>!=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{<sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="233"><highlight class="normal"><sp/><sp/><sp/><sp/>buf<sp/>=<sp/>sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref>;</highlight></codeline> <codeline lineno="234"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline> <codeline lineno="235"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>No<sp/>data<sp/>was<sp/>left<sp/>from<sp/>the<sp/>previous<sp/>operation,<sp/>so<sp/>we<sp/>try<sp/>to<sp/>get</highlight></codeline> <codeline lineno="236"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>some<sp/>from<sp/>the<sp/>network.<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="237"><highlight class="normal"><sp/><sp/><sp/><sp/>buf<sp/>=<sp/><ref refid="api_8h_1cbd0b5a0344c2c3fffe5a02445a2c2b3" kindref="member">netconn_recv</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>);</highlight></codeline> <codeline lineno="238"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="239"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(buf<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="240"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>We<sp/>should<sp/>really<sp/>do<sp/>some<sp/>error<sp/>checking<sp/>here.<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline> <codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline> <codeline lineno="243"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="244"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="245"><highlight class="normal"><sp/><sp/>buflen<sp/>=<sp/><ref refid="api_8h_16d20eca8f0316e4e71980108c1563581" kindref="member">netbuf_len</ref>(buf);</highlight></codeline> <codeline lineno="246"><highlight class="normal"></highlight></codeline> <codeline lineno="247"><highlight class="normal"><sp/><sp/>buflen<sp/>-=<sp/>sock-><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref>;</highlight></codeline> <codeline lineno="248"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="249"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(len<sp/>><sp/>buflen)<sp/>{</highlight></codeline> <codeline lineno="250"><highlight class="normal"><sp/><sp/><sp/><sp/>copylen<sp/>=<sp/>buflen;</highlight></codeline> <codeline lineno="251"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline> <codeline lineno="252"><highlight class="normal"><sp/><sp/><sp/><sp/>copylen<sp/>=<sp/>len;</highlight></codeline> <codeline lineno="253"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="254"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="255"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>copy<sp/>the<sp/>contents<sp/>of<sp/>the<sp/>received<sp/>buffer<sp/>into</highlight></codeline> <codeline lineno="256"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>the<sp/>supplied<sp/>memory<sp/>pointer<sp/>mem<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="257"><highlight class="normal"><sp/><sp/><ref refid="api_8h_19a5f4f669674daa2f3b7b303d7cea915" kindref="member">netbuf_copy_partial</ref>(buf,<sp/>mem,<sp/>copylen,<sp/>sock-><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref>);</highlight></codeline> <codeline lineno="258"><highlight class="normal"></highlight></codeline> <codeline lineno="259"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>TCP<sp/>socket,<sp/>check<sp/>if<sp/>there<sp/>is<sp/>data<sp/>left<sp/>in<sp/>the</highlight></codeline> <codeline lineno="260"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>buffer.<sp/>If<sp/>so,<sp/>it<sp/>should<sp/>be<sp/>saved<sp/>in<sp/>the<sp/>sock<sp/>structure<sp/>for<sp/>next</highlight></codeline> <codeline lineno="261"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>time<sp/>around.<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="262"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(<ref refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" kindref="member">netconn_type</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>)<sp/>==<sp/><ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a" kindref="member">NETCONN_TCP</ref><sp/>&&<sp/>buflen<sp/>-<sp/>copylen<sp/>><sp/>0)<sp/>{</highlight></codeline> <codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/>sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>=<sp/>buf;</highlight></codeline> <codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/>sock-><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref><sp/>=<sp/>buflen<sp/>-<sp/>copylen;</highlight></codeline> <codeline lineno="265"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline> <codeline lineno="266"><highlight class="normal"><sp/><sp/><sp/><sp/>sock-><ref refid="structlwip__socket_1f648ad335e1a066b00801f992d0de3a8" kindref="member">lastdata</ref><sp/>=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>;</highlight></codeline> <codeline lineno="267"><highlight class="normal"><sp/><sp/><sp/><sp/>sock-><ref refid="structlwip__socket_1548897cb34e4f6254c0d466af80596ae" kindref="member">lastoffset</ref><sp/>=<sp/>0;</highlight></codeline> <codeline lineno="268"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" kindref="member">netbuf_delete</ref>(buf);</highlight></codeline> <codeline lineno="269"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="270"><highlight class="normal"></highlight></codeline> <codeline lineno="271"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Check<sp/>to<sp/>see<sp/>from<sp/>where<sp/>the<sp/>data<sp/>was.<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="272"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(from<sp/>!=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref><sp/>&&<sp/>fromlen<sp/>!=<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="273"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref><sp/>=<sp/><ref refid="api_8h_18dd3c0551aa79d162b224ea5cd815b55" kindref="member">netbuf_fromaddr</ref>(buf);</highlight></codeline> <codeline lineno="274"><highlight class="normal"><sp/><sp/><sp/><sp/>port<sp/>=<sp/><ref refid="ipv4_2inet_8h_1b7fffd06ef1d1a7d34f99eedbb9f44dd" kindref="member">htons</ref>(<ref refid="api_8h_16294b37d1aba1478329e1f084f39db5d" kindref="member">netbuf_fromport</ref>(buf));<sp/><sp/></highlight></codeline> <codeline lineno="275"><highlight class="normal"><sp/><sp/><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)from)->sin_addr.s_addr<sp/>=<sp/>addr-><ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref>;</highlight></codeline> <codeline lineno="276"><highlight class="normal"><sp/><sp/><sp/><sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)from)->sin_port<sp/>=<sp/>port;</highlight></codeline> <codeline lineno="277"><highlight class="normal"><sp/><sp/><sp/><sp/>*fromlen<sp/>=<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref>);</highlight></codeline> <codeline lineno="278"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="279"><highlight class="normal"></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/>if<sp/>the<sp/>length<sp/>of<sp/>the<sp/>received<sp/>data<sp/>is<sp/>larger<sp/>than</highlight></codeline> <codeline lineno="282"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>len,<sp/>this<sp/>data<sp/>is<sp/>discarded<sp/>and<sp/>we<sp/>return<sp/>len.</highlight></codeline> <codeline lineno="283"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>otherwise<sp/>we<sp/>return<sp/>the<sp/>actual<sp/>length<sp/>of<sp/>the<sp/>received</highlight></codeline> <codeline lineno="284"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="285"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(len<sp/>><sp/>copylen)<sp/>{</highlight></codeline> <codeline lineno="286"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>copylen;</highlight></codeline> <codeline lineno="287"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline> <codeline lineno="288"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>len;</highlight></codeline> <codeline lineno="289"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="290"><highlight class="normal">}</highlight></codeline> <codeline lineno="291"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="292"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="293" refid="sockets_8c_16853356e8156a0b652fa13105dd77397" refkind="member"><highlight class="normal"><ref refid="sockets_8h_16853356e8156a0b652fa13105dd77397" kindref="member">lwip_read</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*mem,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>len)</highlight></codeline> <codeline lineno="294"><highlight class="normal">{</highlight></codeline> <codeline lineno="295"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sockets_8h_147db87caa9030759f3ffd872df113661" kindref="member">lwip_recv</ref>(s,<sp/>mem,<sp/>len,<sp/>0);</highlight></codeline> <codeline lineno="296"><highlight class="normal">}</highlight></codeline> <codeline lineno="297"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="298"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="299" refid="sockets_8c_147db87caa9030759f3ffd872df113661" refkind="member"><highlight class="normal"><ref refid="sockets_8h_147db87caa9030759f3ffd872df113661" kindref="member">lwip_recv</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*mem,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>len,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags)</highlight></codeline> <codeline lineno="300"><highlight class="normal">{</highlight></codeline> <codeline lineno="301"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sockets_8h_1a433d1ebe9c87f57160c0d260e225705" kindref="member">lwip_recvfrom</ref>(s,<sp/>mem,<sp/>len,<sp/>flags,<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>);</highlight></codeline> <codeline lineno="302"><highlight class="normal">}</highlight></codeline> <codeline lineno="303"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="304"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="305" refid="sockets_8c_1cb3ba0c7f21116c629f116e15e40ce2b" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1a36cb527b3501bc2ce42f7283a010e7a" kindref="member">lwip_send</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>size,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags)</highlight></codeline> <codeline lineno="306"><highlight class="normal">{</highlight></codeline> <codeline lineno="307"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="308"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetbuf" kindref="compound">netbuf</ref><sp/>*<ref refid="structbuf" kindref="compound">buf</ref>;</highlight></codeline> <codeline lineno="309"><highlight class="normal"><sp/><sp/><ref refid="err_8h_1b7190f3da5c85931fc059e0312bc1407" kindref="member">err_t</ref><sp/><ref refid="structnetbuf_1efd0b92792db1bdb3547d1f1d3212f67" kindref="member">err</ref>;</highlight></codeline> <codeline lineno="310"><highlight class="normal"></highlight></codeline> <codeline lineno="311"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" kindref="member">DEBUGF</ref>(<ref refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">"send:<sp/>socket<sp/>%d,<sp/>size<sp/>%d\n"</highlight><highlight class="normal">,<sp/>s,<sp/>size));</highlight></codeline> <codeline lineno="312"><highlight class="normal"></highlight></codeline> <codeline lineno="313"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="314"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="316"><highlight class="normal"><sp/><sp/>}<sp/><sp/></highlight></codeline> <codeline lineno="317"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="318"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal">(<ref refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" kindref="member">netconn_type</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>))<sp/>{</highlight></codeline> <codeline lineno="319"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636" kindref="member">NETCONN_UDP</ref>:</highlight></codeline> <codeline lineno="320"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>create<sp/>a<sp/>buffer<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/>buf<sp/>=<sp/><ref refid="api_8h_1aba704cd963e35e71145de9f5112991d" kindref="member">netbuf_new</ref>();</highlight></codeline> <codeline lineno="322"><highlight class="normal"></highlight></codeline> <codeline lineno="323"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(buf<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>ENOBUFS;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="326"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline> <codeline lineno="327"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="328"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>make<sp/>the<sp/>buffer<sp/>point<sp/>to<sp/>the<sp/>data<sp/>that<sp/>should</highlight></codeline> <codeline lineno="329"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/><sp/><sp/>be<sp/>sent<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="330"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_1f038b56dbdd67a6e48bf0125c8ef61ba" kindref="member">netbuf_ref</ref>(buf,<sp/>data,<sp/>size);</highlight></codeline> <codeline lineno="331"><highlight class="normal"></highlight></codeline> <codeline lineno="332"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>send<sp/>the<sp/>data<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="333"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_1c4d4d10153d47c80a783c34b27c66238" kindref="member">netconn_send</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>buf);</highlight></codeline> <codeline lineno="334"><highlight class="normal"></highlight></codeline> <codeline lineno="335"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>deallocated<sp/>the<sp/>buffer<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="336"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_19dfd3ddfe0ec65009cb140c68404b09d" kindref="member">netbuf_delete</ref>(buf);</highlight></codeline> <codeline lineno="337"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="338"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a" kindref="member">NETCONN_TCP</ref>:</highlight></codeline> <codeline lineno="339"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_19363929b6c680bc1dd3f302885128959" kindref="member">netconn_write</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>data,<sp/>size,<sp/><ref refid="api_8h_1482106705a409ffb01daa6b18c159e5f" kindref="member">NETCONN_COPY</ref>);</highlight></codeline> <codeline lineno="340"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="341"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline> <codeline lineno="342"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="err_8h_18700518a3e3d0c7a4439a37dcbcf2143" kindref="member">ERR_ARG</ref>;</highlight></codeline> <codeline lineno="343"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="344"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="345"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(err<sp/>!=<sp/><ref refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline> <codeline lineno="346"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="347"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;<sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="348"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="349"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="350"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>size;</highlight></codeline> <codeline lineno="351"><highlight class="normal">}</highlight></codeline> <codeline lineno="352"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="353"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="354" refid="sockets_8c_18dba95d254d6cb221ba4039ad8f3337b" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1a8c27aa2c136dc815369a23d29e4f904" kindref="member">lwip_sendto</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>size,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>flags,</highlight></codeline> <codeline lineno="355"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structsockaddr" kindref="compound">sockaddr</ref><sp/>*to,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>tolen)</highlight></codeline> <codeline lineno="356"><highlight class="normal">{</highlight></codeline> <codeline lineno="357"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="358"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structip__addr" kindref="compound">ip_addr</ref><sp/>remote_addr,<sp/>*<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref>;</highlight></codeline> <codeline lineno="359"><highlight class="normal"><sp/><sp/><ref refid="types_8h_13b65128d2644e9b80cec9a69bfa7e094" kindref="member">uInt16</ref><sp/>remote_port,<sp/>port;</highlight></codeline> <codeline lineno="360"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret;</highlight></codeline> <codeline lineno="361"><highlight class="normal"></highlight></codeline> <codeline lineno="362"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="363"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="365"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="366"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="367"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>get<sp/>the<sp/>peer<sp/>if<sp/>currently<sp/>connected<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="368"><highlight class="normal"><sp/><sp/><ref refid="api_8h_1afa4042fd63fd78a440006eb4da36eeb" kindref="member">netconn_peer</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>&<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref>,<sp/>&port);</highlight></codeline> <codeline lineno="369"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="370"><highlight class="normal"><sp/><sp/>remote_addr.<ref refid="structip__addr_1aca6b7136a4c4efb4e0da1384d76f4b5" kindref="member">addr</ref><sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)to)->sin_addr.s_addr;</highlight></codeline> <codeline lineno="371"><highlight class="normal"><sp/><sp/>remote_port<sp/>=<sp/>((</highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structsockaddr__in" kindref="compound">sockaddr_in</ref><sp/>*)to)->sin_port;</highlight></codeline> <codeline lineno="372"><highlight class="normal"><sp/><sp/><ref refid="api_8h_140e08b372ad246ec7d2a7c9b1a2bd8fb" kindref="member">netconn_connect</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>&remote_addr,<sp/>remote_port);</highlight></codeline> <codeline lineno="373"><highlight class="normal"><sp/><sp/></highlight></codeline> <codeline lineno="374"><highlight class="normal"><sp/><sp/>ret<sp/>=<sp/><ref refid="sockets_8h_1a36cb527b3501bc2ce42f7283a010e7a" kindref="member">lwip_send</ref>(s,<sp/>data,<sp/>size,<sp/>flags);</highlight></codeline> <codeline lineno="375"><highlight class="normal"></highlight></codeline> <codeline lineno="376"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>reset<sp/>the<sp/>remote<sp/>address<sp/>and<sp/>port<sp/>number</highlight></codeline> <codeline lineno="377"><highlight class="comment"><sp/><sp/><sp/><sp/><sp/>of<sp/>the<sp/>connection<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="378"><highlight class="normal"><sp/><sp/><ref refid="api_8h_140e08b372ad246ec7d2a7c9b1a2bd8fb" kindref="member">netconn_connect</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>addr,<sp/>port);</highlight></codeline> <codeline lineno="379"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline> <codeline lineno="380"><highlight class="normal">}</highlight></codeline> <codeline lineno="381"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="382"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="383" refid="sockets_8c_1d1afafec89b608d54649d7d02117d17c" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1d1afafec89b608d54649d7d02117d17c" kindref="member">lwip_socket</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>domain,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>type,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>protocol)</highlight></codeline> <codeline lineno="384"><highlight class="normal">{</highlight></codeline> <codeline lineno="385"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structnetconn" kindref="compound">netconn</ref><sp/>*conn;</highlight></codeline> <codeline lineno="386"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline> <codeline lineno="387"><highlight class="normal"></highlight></codeline> <codeline lineno="388"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>create<sp/>a<sp/>netconn<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="389"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal">(type)<sp/>{</highlight></codeline> <codeline lineno="390"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="sockets_8h_14db8b9a846c67404db0b6f014f9a9fdf" kindref="member">SOCK_DGRAM</ref>:</highlight></codeline> <codeline lineno="391"><highlight class="normal"><sp/><sp/><sp/><sp/>conn<sp/>=<sp/><ref refid="api_8h_1935860c5a91e85457369b6f558e638fd" kindref="member">netconn_new</ref>(<ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636" kindref="member">NETCONN_UDP</ref>);</highlight></codeline> <codeline lineno="392"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="393"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="sockets_8h_1249394484f9410a2e3f8eba24657feb9" kindref="member">SOCK_STREAM</ref>:</highlight></codeline> <codeline lineno="394"><highlight class="normal"><sp/><sp/><sp/><sp/>conn<sp/>=<sp/><ref refid="api_8h_1935860c5a91e85457369b6f558e638fd" kindref="member">netconn_new</ref>(<ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a" kindref="member">NETCONN_TCP</ref>);</highlight></codeline> <codeline lineno="395"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="396"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline> <codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="398"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="399"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="400"><highlight class="normal"></highlight></codeline> <codeline lineno="401"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(conn<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="402"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" kindref="member">DEBUGF</ref>(<ref refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">"socket:<sp/>could<sp/>not<sp/>create<sp/>netconn.\n"</highlight><highlight class="normal">));</highlight></codeline> <codeline lineno="403"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>ENOBUFS;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="404"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="405"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="406"><highlight class="normal"></highlight></codeline> <codeline lineno="407"><highlight class="normal"><sp/><sp/>i<sp/>=<sp/><ref refid="sockets_8c_1cfcb93611c8f8e67e69d87561a72c3ee" kindref="member">alloc_socket</ref>(conn);</highlight></codeline> <codeline lineno="408"><highlight class="normal"></highlight></codeline> <codeline lineno="409"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(i<sp/>==<sp/>-1)<sp/>{</highlight></codeline> <codeline lineno="410"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>ENOBUFS;<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="api_8h_1b411221f912a6d9e4c82ac3963989403" kindref="member">netconn_delete</ref>(conn);</highlight></codeline> <codeline lineno="412"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="413"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>i;</highlight></codeline> <codeline lineno="414"><highlight class="normal">}</highlight></codeline> <codeline lineno="415"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="416"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="417" refid="sockets_8c_1e3d92ccb1ddfafe7df89185dbc881ec2" refkind="member"><highlight class="normal"><ref refid="sockets_8h_1a5c59086cba10ace01715c8fa7348239" kindref="member">lwip_write</ref>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s,<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>size)</highlight></codeline> <codeline lineno="418"><highlight class="normal">{</highlight></codeline> <codeline lineno="419"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structlwip__socket" kindref="compound">lwip_socket</ref><sp/>*sock;</highlight></codeline> <codeline lineno="420"><highlight class="normal"><sp/><sp/><ref refid="err_8h_1b7190f3da5c85931fc059e0312bc1407" kindref="member">err_t</ref><sp/>err;</highlight></codeline> <codeline lineno="421"><highlight class="normal"></highlight></codeline> <codeline lineno="422"><highlight class="normal"><sp/><sp/><ref refid="debug_8h_18b52c1fca5671ffbfe068c8d50ca0065" kindref="member">DEBUGF</ref>(<ref refid="debug_8h_1509594f3ba7d8b1356628b50b55a0934" kindref="member">SOCKETS_DEBUG</ref>,<sp/>(</highlight><highlight class="stringliteral">"write:<sp/>socket<sp/>%d,<sp/>size<sp/>%d\n"</highlight><highlight class="normal">,<sp/>s,<sp/>size));</highlight></codeline> <codeline lineno="423"><highlight class="normal"></highlight></codeline> <codeline lineno="424"><highlight class="normal"><sp/><sp/>sock<sp/>=<sp/><ref refid="sockets_8c_12c14650cba5521231ebeefa1ae807e67" kindref="member">get_socket</ref>(s);</highlight></codeline> <codeline lineno="425"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(sock<sp/>==<sp/><ref refid="def_8h_1070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>)<sp/>{</highlight></codeline> <codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="427"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="428"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> <codeline lineno="429"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal">(<ref refid="api_8h_15ab1d6bb5e45b28125312f1b3c840853" kindref="member">netconn_type</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>))<sp/>{</highlight></codeline> <codeline lineno="430"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d916b8ec191d69f7e639f4ab40779069636" kindref="member">NETCONN_UDP</ref>:</highlight></codeline> <codeline lineno="431"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="sockets_8h_1a36cb527b3501bc2ce42f7283a010e7a" kindref="member">lwip_send</ref>(s,<sp/>data,<sp/>size,<sp/>0);</highlight></codeline> <codeline lineno="432"><highlight class="normal"></highlight></codeline> <codeline lineno="433"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/><ref refid="api_8h_1aba260d28d105fb4bce9185fd0300d9175d14318b91af7a452230189f47e5e1a" kindref="member">NETCONN_TCP</ref>:</highlight></codeline> <codeline lineno="434"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="api_8h_19363929b6c680bc1dd3f302885128959" kindref="member">netconn_write</ref>(sock-><ref refid="structlwip__socket_1cc08f8cc9af8dc159e035769a2f70013" kindref="member">conn</ref>,<sp/>data,<sp/>size,<sp/><ref refid="api_8h_1482106705a409ffb01daa6b18c159e5f" kindref="member">NETCONN_COPY</ref>);</highlight></codeline> <codeline lineno="435"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="436"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline> <codeline lineno="437"><highlight class="normal"><sp/><sp/><sp/><sp/>err<sp/>=<sp/><ref refid="err_8h_18700518a3e3d0c7a4439a37dcbcf2143" kindref="member">ERR_ARG</ref>;</highlight></codeline> <codeline lineno="438"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline> <codeline lineno="439"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="440"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(err<sp/>!=<sp/><ref refid="err_8h_198c763adfeea8e9831c46ec269e47ae9" kindref="member">ERR_OK</ref>)<sp/>{</highlight></codeline> <codeline lineno="441"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>errno<sp/>=<sp/>...<sp/>*/</highlight><highlight class="normal"></highlight></codeline> <codeline lineno="442"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline> <codeline lineno="443"><highlight class="normal"><sp/><sp/>}</highlight></codeline> <codeline lineno="444"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>size;</highlight></codeline> <codeline lineno="445"><highlight class="normal">}</highlight></codeline> <codeline lineno="446"><highlight class="normal"></highlight><highlight class="comment">/*-----------------------------------------------------------------------------------*/</highlight><highlight class="normal"></highlight></codeline> </programlisting> <location file="/usr/home/reddawg/source/ubix2/src/sys/net/api/sockets.c"/> </compounddef> </doxygen>