From 57423405f69da850d10a6fbd4b4cade9b422e886 Mon Sep 17 00:00:00 2001 From: Sebastien Vincent Date: Sun, 16 Dec 2018 16:56:58 +0100 Subject: [PATCH] [FREELAN] When switch mode is used, avoid to relay to same host as source. --- libs/freelan/include/freelan/port_index.hpp | 15 +++++++++++++++ libs/freelan/src/switch.cpp | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/freelan/include/freelan/port_index.hpp b/libs/freelan/include/freelan/port_index.hpp index e112381e..57caa324 100644 --- a/libs/freelan/include/freelan/port_index.hpp +++ b/libs/freelan/include/freelan/port_index.hpp @@ -81,6 +81,11 @@ namespace freelan return true; } + friend bool operator!=(const null_port_index_type&, const null_port_index_type&) + { + return false; + } + friend std::ostream& operator<<(std::ostream& os, const null_port_index_type&) { return os << "null()"; @@ -124,6 +129,11 @@ namespace freelan return (lhs.m_tap_adapter == rhs.m_tap_adapter); } + friend bool operator!=(const tap_adapter_port_index_type& lhs, const tap_adapter_port_index_type& rhs) + { + return !(lhs.m_tap_adapter == rhs.m_tap_adapter); + } + friend std::ostream& operator<<(std::ostream& os, const tap_adapter_port_index_type& idx) { return os << "tap_adapter(" << *idx.m_tap_adapter << ")"; @@ -161,6 +171,11 @@ namespace freelan return (lhs.m_ep == rhs.m_ep); } + friend bool operator!=(const endpoint_port_index_type& lhs, const endpoint_port_index_type& rhs) + { + return !(lhs.m_ep == rhs.m_ep); + } + friend std::ostream& operator<<(std::ostream& os, const endpoint_port_index_type& idx) { return os << "endpoint(" << idx.m_ep << ")"; diff --git a/libs/freelan/src/switch.cpp b/libs/freelan/src/switch.cpp index 748fd35b..b998e368 100644 --- a/libs/freelan/src/switch.cpp +++ b/libs/freelan/src/switch.cpp @@ -139,7 +139,16 @@ namespace freelan std::cerr << index << "-> " << target << std::endl; #endif - m_ports[target].async_write(data, boost::bind(&results_gatherer_type::gather, rg, target, _1)); + if(index != target) + { + m_ports[target].async_write(data, boost::bind(&results_gatherer_type::gather, rg, target, _1)); + } +#if FREELAN_DEBUG + else + { + std::cerr << "Index matching target forbidden (" << index << "-> " << target << ")" << std::endl; + } +#endif } }