Skip to content

Commit

Permalink
Disabled filtering code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Nov 10, 2020
1 parent 0a0888f commit f0be328
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/n2n.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ typedef struct filter_rule
// for impl, see: network_traffic_filter.c
uint8_t process_traffic_filter_rule_str(const char* rule_str, filter_rule_t* rule_struct);

#ifdef FILTER_TRAFFIC
/*
* network traffic filter interface
*/
Expand All @@ -417,6 +418,7 @@ typedef struct network_traffic_filter
n2n_verdict (*filter_packet_from_tap)(struct network_traffic_filter* filter, n2n_edge_t *eee, uint8_t *payload, uint16_t payload_size);

} network_traffic_filter_t;
#endif

/* *************************************************** */

Expand Down Expand Up @@ -516,7 +518,9 @@ struct n2n_edge {

n2n_tuntap_priv_config_t tuntap_priv_conf; /**< Tuntap config */

#ifdef FILTER_TRAFFIC
network_traffic_filter_t *network_traffic_filter;
#endif
};


Expand Down
3 changes: 2 additions & 1 deletion include/network_traffic_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "n2n.h"

#ifdef FILTER_TRAFFIC
/*
* add feature to drop or accept specific packet transmit over edge network interface by rules.
*
Expand All @@ -40,6 +41,6 @@ network_traffic_filter_t* create_network_traffic_filter();
void destroy_network_traffic_filter(network_traffic_filter_t* filter);

void network_traffic_filter_add_rule(network_traffic_filter_t* filter, filter_rule_t* rules);

#endif

#endif //N2N_NETWORK_TRAFFIC_FILTER_H
8 changes: 6 additions & 2 deletions src/edge_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,12 +1180,14 @@ static int handle_PACKET(n2n_edge_t * eee,
}
}

if( eee->network_traffic_filter->filter_packet_from_peer( eee->network_traffic_filter, eee, orig_sender,
#ifdef FILTER_TRAFFIC
if(eee->network_traffic_filter->filter_packet_from_peer( eee->network_traffic_filter, eee, orig_sender,
eth_payload, eth_size ) == N2N_DROP){
traceEvent(TRACE_DEBUG, "Filtered packet %u", (unsigned int)eth_size);
return(0);
}

#endif

if(eee->cb.packet_from_peer) {
uint16_t tmp_eth_size = eth_size;
if(eee->cb.packet_from_peer(eee, orig_sender, eth_payload, &tmp_eth_size) == N2N_DROP) {
Expand Down Expand Up @@ -1736,13 +1738,15 @@ void edge_read_from_tap(n2n_edge_t * eee) {
}
else
{
#ifdef FILTER_TRAFFIC
if(eee->network_traffic_filter) {
if( eee->network_traffic_filter->filter_packet_from_tap( eee->network_traffic_filter, eee, eth_pkt,
len) == N2N_DROP){
traceEvent(TRACE_DEBUG, "Filtered packet %u", (unsigned int)len);
return;
}
}
#endif

if(eee->cb.packet_from_tap) {
uint16_t tmp_len = len;
Expand Down

0 comments on commit f0be328

Please sign in to comment.