- TCP state cleanup added
This commit is contained in:
parent
66121960d7
commit
b39f302a63
@ -48,6 +48,22 @@ static bool filtTcp(const PcktSieveFilterCondition *filtCond, const PcktProps *c
|
|||||||
return ipProps->Protocol == ETH_TCP_PACKET_CLASS && references_us;
|
return ipProps->Protocol == ETH_TCP_PACKET_CLASS && references_us;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline TcpState * tcps_create() {
|
||||||
|
TcpState * tcps = dynmem_alloc(sizeof(TcpState));
|
||||||
|
tcps->txWin = tcpw_create(ETHLIB_DEF_TCP_WINDOW_SIZE);
|
||||||
|
|
||||||
|
return tcps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tcps_remove_and_cleanup(const TcpState * tcps) {
|
||||||
|
if (tcps == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dynmem_free(tcps->txWin);
|
||||||
|
dynmem_free(tcps);
|
||||||
|
}
|
||||||
|
|
||||||
#define TCP_DEFAULT_MSS (1200)
|
#define TCP_DEFAULT_MSS (1200)
|
||||||
#define TCP_DEFAULT_RETRY_LIMIT (5)
|
#define TCP_DEFAULT_RETRY_LIMIT (5)
|
||||||
#define TCP_DEFAULT_RETRY_TO_HS (100)
|
#define TCP_DEFAULT_RETRY_TO_HS (100)
|
||||||
@ -64,7 +80,6 @@ void tcps_init(TcpState *tcps, uint16_t localPort) {
|
|||||||
tcps->rxAckNum = 0;
|
tcps->rxAckNum = 0;
|
||||||
|
|
||||||
tcps->localWindow = ETHLIB_DEF_TCP_WINDOW_SIZE;
|
tcps->localWindow = ETHLIB_DEF_TCP_WINDOW_SIZE;
|
||||||
tcps->txWin = tcpw_create(ETHLIB_DEF_TCP_WINDOW_SIZE);
|
|
||||||
tcpw_set_seqnum_offset(tcps->txWin, tcps->txSeqNum);
|
tcpw_set_seqnum_offset(tcps->txWin, tcps->txSeqNum);
|
||||||
|
|
||||||
tcps->retryLimit = TCP_DEFAULT_RETRY_LIMIT;
|
tcps->retryLimit = TCP_DEFAULT_RETRY_LIMIT;
|
||||||
@ -263,6 +278,7 @@ int tcp_receive_segment_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
|||||||
// release descriptor if not meaningful anymore
|
// release descriptor if not meaningful anymore
|
||||||
if (ret == SIEVE_LAYER_REMOVE_THIS) {
|
if (ret == SIEVE_LAYER_REMOVE_THIS) {
|
||||||
cbdt_release(E.cbdt, tcps->d); // release descriptor
|
cbdt_release(E.cbdt, tcps->d); // release descriptor
|
||||||
|
tcps_remove_and_cleanup(tcps); // release TCP state
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -330,7 +346,7 @@ static inline cbd tcp_new_connblock_filtcond(EthInterface *intf, ip4_addr ipAddr
|
|||||||
ConnBlock ipConnB = ipv4_new_connblock(intf, ipAddr, NULL); // create new IPv4 connection block
|
ConnBlock ipConnB = ipv4_new_connblock(intf, ipAddr, NULL); // create new IPv4 connection block
|
||||||
|
|
||||||
PcktSieveLayerTag tag; // store TCP state into sieve layer's tag
|
PcktSieveLayerTag tag; // store TCP state into sieve layer's tag
|
||||||
TcpState *tcpState = dynmem_alloc(sizeof(TcpState));
|
TcpState *tcpState = tcps_create();
|
||||||
tcps_init(tcpState, port);
|
tcps_init(tcpState, port);
|
||||||
tcpState->userCb = cbFn;
|
tcpState->userCb = cbFn;
|
||||||
tag.p = tcpState;
|
tag.p = tcpState;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user