tcp: add LWIP_HOOK_TCP_INPACKET_PCB

This hook is called from tcp_input() for all kinds of input pcbs when
selected to receive a pbuf (LISTEN, TIME_WAIT, rest). I can parse or
drop an rx pbuf.

Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
goldsimon
2018-01-26 22:27:26 +01:00
parent 0e85582bc0
commit 77d0ee0961
2 changed files with 54 additions and 2 deletions

View File

@@ -61,6 +61,10 @@
#include <string.h>
#ifdef LWIP_HOOK_FILENAME
#include LWIP_HOOK_FILENAME
#endif
/** Initial CWND calculation as defined RFC 2581 */
#define LWIP_TCP_CALC_INITIAL_CWND(mss) ((tcpwnd_size_t)LWIP_MIN((4U * (mss)), LWIP_MAX((2U * (mss)), 4380U)))
@@ -295,7 +299,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
of the list since we are not very likely to receive that
many segments for connections in TIME-WAIT. */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n"));
tcp_timewait_input(pcb);
#ifdef LWIP_HOOK_TCP_INPACKET_PCB
if (LWIP_HOOK_TCP_INPACKET_PCB(pcb, tcphdr, tcphdr_optlen, tcphdr_opt1len,
tcphdr_opt2, p) == ERR_OK)
#endif
{
tcp_timewait_input(pcb);
}
pbuf_free(p);
return;
}
@@ -361,7 +371,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
}
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));
tcp_listen_input(lpcb);
#ifdef LWIP_HOOK_TCP_INPACKET_PCB
if (LWIP_HOOK_TCP_INPACKET_PCB((struct tcp_pcb *)lpcb, tcphdr, tcphdr_optlen,
tcphdr_opt1len, tcphdr_opt2, p) == ERR_OK)
#endif
{
tcp_listen_input(lpcb);
}
pbuf_free(p);
return;
}
@@ -374,6 +390,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
#endif /* TCP_INPUT_DEBUG */
#ifdef LWIP_HOOK_TCP_INPACKET_PCB
if ((pcb != NULL) && LWIP_HOOK_TCP_INPACKET_PCB(pcb, tcphdr, tcphdr_optlen,
tcphdr_opt1len, tcphdr_opt2, p) != ERR_OK) {
pbuf_free(p);
return;
}
#endif
if (pcb != NULL) {
/* The incoming segment belongs to a connection. */
#if TCP_INPUT_DEBUG