mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
Add generic tcpip_inpkt function that can be called to make last changes really usable
This commit is contained in:
parent
fa6f068fd1
commit
777e667f08
@ -166,24 +166,18 @@ tcpip_thread(void *arg)
|
|||||||
/**
|
/**
|
||||||
* Pass a received packet to tcpip_thread for input processing
|
* Pass a received packet to tcpip_thread for input processing
|
||||||
*
|
*
|
||||||
* @param p the received packet, p->payload pointing to the Ethernet header or
|
* @param p the received packet
|
||||||
* 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
|
* @param inp the network interface on which the packet was received
|
||||||
|
* @param input_fn input function to call
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
tcpip_input(struct pbuf *p, struct netif *inp)
|
tcpip_inpkt(struct pbuf *p, struct netif *inp, tcpip_inpkt_fn input_fn)
|
||||||
{
|
{
|
||||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||||
err_t ret;
|
err_t ret;
|
||||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_input: PACKET %p/%p\n", (void *)p, (void *)inp));
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_inpkt: PACKET %p/%p\n", (void *)p, (void *)inp));
|
||||||
LOCK_TCPIP_CORE();
|
LOCK_TCPIP_CORE();
|
||||||
#if LWIP_ETHERNET
|
ret = input_fn(p, inp);
|
||||||
if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) {
|
|
||||||
ret = ethernet_input(p, inp);
|
|
||||||
} else
|
|
||||||
#endif /* LWIP_ETHERNET */
|
|
||||||
ret = ip_input(p, inp);
|
|
||||||
UNLOCK_TCPIP_CORE();
|
UNLOCK_TCPIP_CORE();
|
||||||
return ret;
|
return ret;
|
||||||
#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
||||||
@ -200,12 +194,7 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
|||||||
msg->type = TCPIP_MSG_INPKT;
|
msg->type = TCPIP_MSG_INPKT;
|
||||||
msg->msg.inp.p = p;
|
msg->msg.inp.p = p;
|
||||||
msg->msg.inp.netif = inp;
|
msg->msg.inp.netif = inp;
|
||||||
#if LWIP_ETHERNET
|
msg->msg.inp.input_fn = input_fn;
|
||||||
if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) {
|
|
||||||
msg->msg.inp.input_fn = ethernet_input;
|
|
||||||
} else
|
|
||||||
#endif /* LWIP_ETHERNET */
|
|
||||||
msg->msg.inp.input_fn = ip_input;
|
|
||||||
if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
|
if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
|
||||||
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
@ -214,6 +203,26 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
|||||||
#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass a received packet to tcpip_thread for input processing with
|
||||||
|
* ethernet_input or ip_input
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
tcpip_input(struct pbuf *p, struct netif *inp)
|
||||||
|
{
|
||||||
|
#if LWIP_ETHERNET
|
||||||
|
if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) {
|
||||||
|
return tcpip_inpkt(p, inp, ethernet_input);
|
||||||
|
} else
|
||||||
|
#endif /* LWIP_ETHERNET */
|
||||||
|
return tcpip_inpkt(p, inp, ip_input);
|
||||||
|
}
|
||||||
|
|
||||||
#if PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE
|
#if PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE
|
||||||
/**
|
/**
|
||||||
* Pass a received packet to tcpip_thread for input processing
|
* Pass a received packet to tcpip_thread for input processing
|
||||||
@ -226,34 +235,7 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
|||||||
err_t
|
err_t
|
||||||
tcpip_pppos_input(struct pbuf *p, struct netif *inp)
|
tcpip_pppos_input(struct pbuf *p, struct netif *inp)
|
||||||
{
|
{
|
||||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
return tcpip_inpkt(p, inp, pppos_input_sys);
|
||||||
err_t ret;
|
|
||||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_pppos_input: PACKET %p/%p\n", (void *)p, (void *)inp));
|
|
||||||
LOCK_TCPIP_CORE();
|
|
||||||
ret = pppos_input_sys(p, inp);
|
|
||||||
UNLOCK_TCPIP_CORE();
|
|
||||||
return ret;
|
|
||||||
#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
|
||||||
struct tcpip_msg *msg;
|
|
||||||
|
|
||||||
if (!sys_mbox_valid_val(mbox)) {
|
|
||||||
return ERR_VAL;
|
|
||||||
}
|
|
||||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT);
|
|
||||||
if (msg == NULL) {
|
|
||||||
return ERR_MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->type = TCPIP_MSG_INPKT;
|
|
||||||
msg->msg.inp.p = p;
|
|
||||||
msg->msg.inp.netif = inp;
|
|
||||||
msg->msg.inp.input_fn = pppos_input_sys;
|
|
||||||
if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
|
|
||||||
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
|
||||||
return ERR_MEM;
|
|
||||||
}
|
|
||||||
return ERR_OK;
|
|
||||||
#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
|
||||||
}
|
}
|
||||||
#endif /* PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE */
|
#endif /* PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE */
|
||||||
|
|
||||||
|
@ -132,13 +132,6 @@ extern sys_mutex_t lock_tcpip_core;
|
|||||||
#define API_EXPR_DEREF(expr) *(expr)
|
#define API_EXPR_DEREF(expr) *(expr)
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
|
|
||||||
/** Function prototype for input functions functions.
|
|
||||||
*
|
|
||||||
* @param p The received packet, copied into a pbuf
|
|
||||||
* @param inp The netif which received the packet
|
|
||||||
*/
|
|
||||||
typedef err_t (*tcpip_inpkt_fn)(struct pbuf *p, struct netif *inp);
|
|
||||||
|
|
||||||
#if LWIP_NETCONN || LWIP_SOCKET
|
#if LWIP_NETCONN || LWIP_SOCKET
|
||||||
err_t tcpip_apimsg(struct api_msg *apimsg);
|
err_t tcpip_apimsg(struct api_msg *apimsg);
|
||||||
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
||||||
|
@ -50,11 +50,19 @@ struct netif;
|
|||||||
typedef void (*tcpip_init_done_fn)(void *arg);
|
typedef void (*tcpip_init_done_fn)(void *arg);
|
||||||
/** Function prototype for functions passed to tcpip_callback() */
|
/** Function prototype for functions passed to tcpip_callback() */
|
||||||
typedef void (*tcpip_callback_fn)(void *ctx);
|
typedef void (*tcpip_callback_fn)(void *ctx);
|
||||||
|
/** Function prototype for input functions functions.
|
||||||
|
*
|
||||||
|
* @param p The received packet, copied into a pbuf
|
||||||
|
* @param inp The netif which received the packet
|
||||||
|
*/
|
||||||
|
typedef err_t (*tcpip_inpkt_fn)(struct pbuf *p, struct netif *inp);
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
struct tcpip_callback_msg;
|
struct tcpip_callback_msg;
|
||||||
|
|
||||||
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
|
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
|
||||||
|
|
||||||
|
err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, tcpip_inpkt_fn input_fn);
|
||||||
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
||||||
|
|
||||||
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
||||||
|
Loading…
Reference in New Issue
Block a user