add tcpip_callback patch from Marc

This commit is contained in:
jani 2003-03-19 11:23:46 +00:00
parent f9f21934ab
commit 441e9b8431
3 changed files with 16 additions and 11 deletions

View File

@ -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;
}

View File

@ -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. */

View File

@ -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;
};