mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
add tcpip_callback patch from Marc
This commit is contained in:
parent
f9f21934ab
commit
441e9b8431
@ -78,6 +78,8 @@ tcpip_thread(void *arg)
|
|||||||
{
|
{
|
||||||
struct tcpip_msg *msg;
|
struct tcpip_msg *msg;
|
||||||
|
|
||||||
|
(void)arg;
|
||||||
|
|
||||||
ip_init();
|
ip_init();
|
||||||
udp_init();
|
udp_init();
|
||||||
tcp_init();
|
tcp_init();
|
||||||
@ -97,9 +99,9 @@ tcpip_thread(void *arg)
|
|||||||
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg));
|
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg));
|
||||||
ip_input(msg->msg.inp.p, msg->msg.inp.netif);
|
ip_input(msg->msg.inp.p, msg->msg.inp.netif);
|
||||||
break;
|
break;
|
||||||
case TCPIP_MSG_LINK:
|
case TCPIP_MSG_CALLBACK:
|
||||||
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: LINK packet %p\n", (void *)msg));
|
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg));
|
||||||
msg->msg.inp.netif->input(msg->msg.inp.p, msg->msg.inp.netif);
|
msg->msg.cb.f(msg->msg.cb.ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -127,19 +129,18 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
|||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
tcpip_link_input(struct pbuf *p, struct netif *inp)
|
tcpip_callback(void (*f)(void *ctx), void *ctx)
|
||||||
{
|
{
|
||||||
struct tcpip_msg *msg;
|
struct tcpip_msg *msg;
|
||||||
|
|
||||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||||
if(msg == NULL) {
|
if(msg == NULL) {
|
||||||
pbuf_free(p);
|
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->type = TCPIP_MSG_LINK;
|
msg->type = TCPIP_MSG_CALLBACK;
|
||||||
msg->msg.inp.p = p;
|
msg->msg.cb.f = f;
|
||||||
msg->msg.inp.netif = inp;
|
msg->msg.cb.ctx = ctx;
|
||||||
sys_mbox_post(mbox, msg);
|
sys_mbox_post(mbox, msg);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ struct tcp_pcb {
|
|||||||
#endif /* TCP_QUEUE_OOSEQ */
|
#endif /* TCP_QUEUE_OOSEQ */
|
||||||
|
|
||||||
#if LWIP_CALLBACK_API
|
#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);
|
err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space);
|
||||||
|
|
||||||
/* Function to be called when (in-sequence) data has arrived. */
|
/* Function to be called when (in-sequence) data has arrived. */
|
||||||
|
@ -38,14 +38,14 @@
|
|||||||
void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
|
void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
|
||||||
void tcpip_apimsg(struct api_msg *apimsg);
|
void tcpip_apimsg(struct api_msg *apimsg);
|
||||||
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
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);
|
void tcpip_tcp_timer_needed(void);
|
||||||
|
|
||||||
enum tcpip_msg_type {
|
enum tcpip_msg_type {
|
||||||
TCPIP_MSG_API,
|
TCPIP_MSG_API,
|
||||||
TCPIP_MSG_INPUT,
|
TCPIP_MSG_INPUT,
|
||||||
TCPIP_MSG_LINK
|
TCPIP_MSG_CALLBACK
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tcpip_msg {
|
struct tcpip_msg {
|
||||||
@ -57,6 +57,10 @@ struct tcpip_msg {
|
|||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
} inp;
|
} inp;
|
||||||
|
struct {
|
||||||
|
void (*f)(void *ctx);
|
||||||
|
void *ctx;
|
||||||
|
} cb;
|
||||||
} msg;
|
} msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user