- TCP option release added

This commit is contained in:
Wiesner András 2023-11-09 08:01:00 +01:00
parent b39f302a63
commit f0ddddefad
3 changed files with 20 additions and 0 deletions

View File

@ -275,6 +275,11 @@ int tcp_receive_segment_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
// maintain retry counter
tcps->retries = willRetry ? (tcps->retries + 1) : 0;
// release options if not NULL
if (tcpProps->options != NULL) {
tcpopt_chain_free(tcpProps->options);
}
// release descriptor if not meaningful anymore
if (ret == SIEVE_LAYER_REMOVE_THIS) {
cbdt_release(E.cbdt, tcps->d); // release descriptor

View File

@ -205,4 +205,13 @@ TcpOption *tcpopt_new(uint32_t kind, uint32_t size) {
return opt;
}
void tcpopt_chain_free(const TcpOption * opt) {
const TcpOption * iter = opt, *next;
while (iter) {
next = iter->next;
dynmem_free(iter);
iter = next;
}
}

View File

@ -36,6 +36,12 @@ typedef struct TcpOption_ {
*/
TcpOption * tcpopt_new(uint32_t kind, uint32_t size);
/**
* Release a chain of TCP options
* @param opt pointer to the chain's first element to release
*/
void tcpopt_chain_free(const TcpOption * opt);
/**
* TCP segment properties.
*/