Minor fixes

This commit is contained in:
DomySh
2022-07-15 10:17:16 +02:00
parent d254d9f4f9
commit 682cc59eaf
2 changed files with 29 additions and 23 deletions

BIN
backend/nfqueue/nfqueue Executable file

Binary file not shown.

View File

@@ -138,9 +138,14 @@ class NetfilterQueue {
nlh_verdict = nfq_nlmsg_put(buf, NFQNL_MSG_VERDICT, ntohs(nfg->res_id));
#define PKT_OPS \
/*
This define allow to avoid to allocate new heap memory for each packet.
The code under this comment is replicated for ipv6 and ip
Better solutions are welcome. :)
*/
#define PKT_HANDLE \
PDU *transport_layer = find_transport_layer(&packet); \
if(transport_layer->inner_pdu() == nullptr){ \
if(transport_layer->inner_pdu() == nullptr || transport_layer == nullptr){ \
nfq_nlmsg_verdict_put(nlh_verdict, ntohl(ph->packet_id), NF_ACCEPT ); \
}else{ \
int size = transport_layer->inner_pdu()->size(); \
@@ -158,14 +163,15 @@ class NetfilterQueue {
nfq_nlmsg_verdict_put(nlh_verdict, ntohl(ph->packet_id), NF_DROP ); \
} \
} \
}\
}
// Check IP protocol version
if ( (((uint8_t*)payload)[0] & 0xf0) == 0x40 ){
IP packet = IP((uint8_t*)payload,plen);
PKT_OPS
PKT_HANDLE
}else{
IPv6 packet = IPv6((uint8_t*)payload,plen);
PKT_OPS
PKT_HANDLE
}
/* example to set the connmark. First, start NFQA_CT section: */