From 441e9b8431ad8486ec00e8f810647f1f4a45a3ce Mon Sep 17 00:00:00 2001 From: jani Date: Wed, 19 Mar 2003 11:23:46 +0000 Subject: [PATCH] add tcpip_callback patch from Marc --- src/api/tcpip.c | 17 +++++++++-------- src/include/lwip/tcp.h | 2 +- src/include/lwip/tcpip.h | 8 ++++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 2027cd39..77dc2145 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -78,6 +78,8 @@ tcpip_thread(void *arg) { struct tcpip_msg *msg; + (void)arg; + ip_init(); udp_init(); tcp_init(); @@ -97,9 +99,9 @@ tcpip_thread(void *arg) DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg)); ip_input(msg->msg.inp.p, msg->msg.inp.netif); break; - case TCPIP_MSG_LINK: - DEBUGF(TCPIP_DEBUG, ("tcpip_thread: LINK packet %p\n", (void *)msg)); - msg->msg.inp.netif->input(msg->msg.inp.p, msg->msg.inp.netif); + case TCPIP_MSG_CALLBACK: + DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); + msg->msg.cb.f(msg->msg.cb.ctx); break; default: break; @@ -127,19 +129,18 @@ tcpip_input(struct pbuf *p, struct netif *inp) } /*-----------------------------------------------------------------------------------*/ err_t -tcpip_link_input(struct pbuf *p, struct netif *inp) +tcpip_callback(void (*f)(void *ctx), void *ctx) { struct tcpip_msg *msg; msg = memp_mallocp(MEMP_TCPIP_MSG); if(msg == NULL) { - pbuf_free(p); return ERR_MEM; } - msg->type = TCPIP_MSG_LINK; - msg->msg.inp.p = p; - msg->msg.inp.netif = inp; + msg->type = TCPIP_MSG_CALLBACK; + msg->msg.cb.f = f; + msg->msg.cb.ctx = ctx; sys_mbox_post(mbox, msg); return ERR_OK; } diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 74be892d..b10eb7ea 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -265,7 +265,7 @@ struct tcp_pcb { #endif /* TCP_QUEUE_OOSEQ */ #if LWIP_CALLBACK_API - /* Function to be called when more send buffer space is avaliable. */ + /* Function to be called when more send buffer space is available. */ err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space); /* Function to be called when (in-sequence) data has arrived. */ diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h index f91625c9..7ec59642 100644 --- a/src/include/lwip/tcpip.h +++ b/src/include/lwip/tcpip.h @@ -38,14 +38,14 @@ void tcpip_init(void (* tcpip_init_done)(void *), void *arg); void tcpip_apimsg(struct api_msg *apimsg); err_t tcpip_input(struct pbuf *p, struct netif *inp); -err_t tcpip_link_input(struct pbuf *p, struct netif *inp); +err_t tcpip_callback(void (*f)(void *ctx), void *ctx); void tcpip_tcp_timer_needed(void); enum tcpip_msg_type { TCPIP_MSG_API, TCPIP_MSG_INPUT, - TCPIP_MSG_LINK + TCPIP_MSG_CALLBACK }; struct tcpip_msg { @@ -57,6 +57,10 @@ struct tcpip_msg { struct pbuf *p; struct netif *netif; } inp; + struct { + void (*f)(void *ctx); + void *ctx; + } cb; } msg; };