Minor fixes
This commit is contained in:
BIN
backend/nfqueue/nfqueue
Executable file
BIN
backend/nfqueue/nfqueue
Executable file
Binary file not shown.
@@ -138,9 +138,14 @@ class NetfilterQueue {
|
|||||||
|
|
||||||
nlh_verdict = nfq_nlmsg_put(buf, NFQNL_MSG_VERDICT, ntohs(nfg->res_id));
|
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); \
|
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 ); \
|
nfq_nlmsg_verdict_put(nlh_verdict, ntohl(ph->packet_id), NF_ACCEPT ); \
|
||||||
}else{ \
|
}else{ \
|
||||||
int size = transport_layer->inner_pdu()->size(); \
|
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 ); \
|
nfq_nlmsg_verdict_put(nlh_verdict, ntohl(ph->packet_id), NF_DROP ); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}\
|
}
|
||||||
|
|
||||||
|
// Check IP protocol version
|
||||||
if ( (((uint8_t*)payload)[0] & 0xf0) == 0x40 ){
|
if ( (((uint8_t*)payload)[0] & 0xf0) == 0x40 ){
|
||||||
IP packet = IP((uint8_t*)payload,plen);
|
IP packet = IP((uint8_t*)payload,plen);
|
||||||
PKT_OPS
|
PKT_HANDLE
|
||||||
}else{
|
}else{
|
||||||
IPv6 packet = IPv6((uint8_t*)payload,plen);
|
IPv6 packet = IPv6((uint8_t*)payload,plen);
|
||||||
PKT_OPS
|
PKT_HANDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/* example to set the connmark. First, start NFQA_CT section: */
|
/* example to set the connmark. First, start NFQA_CT section: */
|
||||||
|
|||||||
Reference in New Issue
Block a user