321N/A * Sequential API Main thread module 919N/A * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 919N/A * Redistribution and use in source and binary forms, with or without modification, 919N/A * are permitted provided that the following conditions are met: 919N/A * 1. Redistributions of source code must retain the above copyright notice, 919N/A * this list of conditions and the following disclaimer. 919N/A * 2. Redistributions in binary form must reproduce the above copyright notice, 919N/A * this list of conditions and the following disclaimer in the documentation 919N/A * and/or other materials provided with the distribution. 919N/A * 3. The name of the author may not be used to endorse or promote products 919N/A * derived from this software without specific prior written permission. 919N/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 919N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 919N/A * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 321N/A * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 321N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 321N/A * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321N/A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 493N/A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 321N/A * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 970N/A * Author: Adam Dunkels <adam@sics.se> /** The global semaphore to lock the stack. */ #
endif /* LWIP_TCPIP_CORE_LOCKING */ * The main lwIP thread. This thread has exclusive access to lwIP core functions * (unless access to them is not locked). Other threads communicate with this * thread using message boxes. * It also starts all the timers to make sure they are running in the right * @param arg unused argument while (
1) {
/* MAIN Loop */ /* wait for a message, timeouts are processed while waiting */ #
endif /* LWIP_NETCONN */#
endif /* LWIP_ETHERNET */#
endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */#
endif /* LWIP_NETIF_API */#
endif /* LWIP_TCPIP_TIMEOUT */ /* XXX: TODO: lwip cleanup? */ * Pass a received packet to tcpip_thread for input processing * @param p the received packet, p->payload pointing to the Ethernet header or * to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or * NETIF_FLAG_ETHERNET flags) * @param inp the network interface on which the packet was received #
endif /* LWIP_ETHERNET */#
else /* LWIP_TCPIP_CORE_LOCKING_INPUT */#
endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ * Call a specific function in the thread context of * tcpip_thread for easy access synchronization. * A function called in that way may access lwIP core code * without fearing concurrent access. * @param f the function to call * @param ctx parameter passed to f * @param block 1 to block until the request is posted, 0 to non-blocking mode * @return ERR_OK if the function was called, another err_t if not * call sys_timeout in tcpip_thread * @param msec time in milliseconds for timeout * @param h function to be called on timeout * @param arg argument to pass to timeout function h * @return ERR_MEM on memory error, ERR_OK otherwise * call sys_untimeout in tcpip_thread * @param msec time in milliseconds for timeout * @param h function to be called on timeout * @param arg argument to pass to timeout function h * @return ERR_MEM on memory error, ERR_OK otherwise #
endif /* LWIP_TCPIP_TIMEOUT */ * Call the lower part of a netconn_* function * This function is then running in the thread context * of tcpip_thread and has exclusive access to lwIP core code. * @param apimsg a struct containing the function to call and its parameters * @return ERR_OK if the function was called, another err_t if not /* catch functions that don't set err */ #
endif /* LWIP_NETCONN */ * Much like tcpip_apimsg, but calls the lower part of a netifapi_* * @param netifapimsg a struct containing the function to call and its parameters * @return error code given back by the function that was called #
else /* !LWIP_TCPIP_CORE_LOCKING */ * Call the lower part of a netifapi_* function * This function has exclusive access to lwIP core code by locking it * before the function is called. * @param netifapimsg a struct containing the function to call and its parameters * @return ERR_OK (only for compatibility fo tcpip_netifapi()) #
endif /* !LWIP_TCPIP_CORE_LOCKING */#
endif /* LWIP_NETIF_API */ * Allocate a structure for a static callback message and initialize it. * This is intended to be used to send "static" messages from interrupt context. * @param function the function to call * @param ctx parameter passed to function * @return a struct pointer to pass to tcpip_trycallback(). * Free a callback message allocated by tcpip_callbackmsg_new(). * @param msg the message to free * Try to post a callback-message to the tcpip_thread mbox * This is intended to be used to send "static" messages from interrupt context. * @param msg pointer to the message to post * @return sys_mbox_trypost() return code * Post a callback-message to the tcpip_thread mbox. * This is used to send "static" messages. Not necessarily "from * interrupt context" - avoiding unnecessary malloc() is always good. * To prevent confusion and to provide API symmetry there's a * counterpart macro tcpip_trycallbackmsg() that aliases * tcpip_trycallback() above. * @param msg pointer to the message to post * @return sys_mbox_trypost() return code * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc #
endif /* LWIP_TCPIP_CORE_LOCKING */ * Simple callback function used with tcpip_callback to free a pbuf * (pbuf_free has a wrong signature for tcpip_callback) * @param p The pbuf (chain) to be dereferenced. * A simple wrapper function that allows you to free a pbuf from interrupt context. * @param p The pbuf (chain) to be dereferenced. * @return ERR_OK if callback could be enqueued, an err_t if not * A simple wrapper function that allows you to free heap memory from * @param m the heap memory to free * @return ERR_OK if callback could be enqueued, an err_t if not