tcpip.c: Moved call to ip_init(), udp_init() and tcp_init() from tcpip_thread() to tcpip_init()

This commit is contained in:
goldsimon 2007-03-03 16:22:38 +00:00
parent e075581d76
commit bb8522b737
2 changed files with 35 additions and 30 deletions

View File

@ -42,6 +42,12 @@ HISTORY
++ Bug fixes: ++ Bug fixes:
2007-03-02 Simon Goldschmidt
* tcpip.c: Moved call to ip_init(), udp_init() and tcp_init() from
tcpip_thread() to tcpip_init(). This way, raw API connections can be
initialized before tcpip_thread is running (e.g. before OS is started)
=======
2007-03-02 Frédéric Bernon 2007-03-02 Frédéric Bernon
* rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call interval. * rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call interval.

View File

@ -1,8 +1,8 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
@ -11,21 +11,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
@ -97,15 +97,6 @@ tcpip_thread(void *arg)
{ {
struct tcpip_msg *msg; struct tcpip_msg *msg;
(void)arg;
ip_init();
#if LWIP_UDP
udp_init();
#endif
#if LWIP_TCP
tcp_init();
#endif
#if IP_REASSEMBLY #if IP_REASSEMBLY
sys_timeout(1000, ip_timer, NULL); sys_timeout(1000, ip_timer, NULL);
#endif #endif
@ -139,13 +130,13 @@ err_t
tcpip_input(struct pbuf *p, struct netif *inp) tcpip_input(struct pbuf *p, struct netif *inp)
{ {
struct tcpip_msg *msg; struct tcpip_msg *msg;
msg = memp_malloc(MEMP_TCPIP_MSG); msg = memp_malloc(MEMP_TCPIP_MSG);
if (msg == NULL) { if (msg == NULL) {
pbuf_free(p); pbuf_free(p);
return ERR_MEM; return ERR_MEM;
} }
msg->type = TCPIP_MSG_INPUT; msg->type = TCPIP_MSG_INPUT;
msg->msg.inp.p = p; msg->msg.inp.p = p;
msg->msg.inp.netif = inp; msg->msg.inp.netif = inp;
@ -157,12 +148,12 @@ err_t
tcpip_callback(void (*f)(void *ctx), void *ctx) tcpip_callback(void (*f)(void *ctx), void *ctx)
{ {
struct tcpip_msg *msg; struct tcpip_msg *msg;
msg = memp_malloc(MEMP_TCPIP_MSG); msg = memp_malloc(MEMP_TCPIP_MSG);
if (msg == NULL) { if (msg == NULL) {
return ERR_MEM; return ERR_MEM;
} }
msg->type = TCPIP_MSG_CALLBACK; msg->type = TCPIP_MSG_CALLBACK;
msg->msg.cb.f = f; msg->msg.cb.f = f;
msg->msg.cb.ctx = ctx; msg->msg.cb.ctx = ctx;
@ -186,6 +177,14 @@ tcpip_apimsg(struct api_msg *apimsg)
void void
tcpip_init(void (* initfunc)(void *), void *arg) tcpip_init(void (* initfunc)(void *), void *arg)
{ {
ip_init();
#if LWIP_UDP
udp_init();
#endif
#if LWIP_TCP
tcp_init();
#endif
tcpip_init_done = initfunc; tcpip_init_done = initfunc;
tcpip_init_done_arg = arg; tcpip_init_done_arg = arg;
mbox = sys_mbox_new(); mbox = sys_mbox_new();