@@ -32,7 +32,7 @@ const std::string PARAMETER_MAC = "MAC";
3232const std::string PARAMETER_IP = " IP" ;
3333const std::string PARAMETER_PEER = " PEER" ;
3434
35- std::set <std::string> ExtIface::used_ifaces;
35+ std::map <std::string, ExtIface* > ExtIface::used_ifaces;
3636
3737ExtIface::ExtIface (const std::string &iface)
3838 : PeerIface(iface_mutex_),
@@ -43,7 +43,7 @@ ExtIface::ExtIface(const std::string &iface)
4343 throw std::runtime_error (" Iface already in use" );
4444 }
4545
46- used_ifaces.insert (iface);
46+ used_ifaces.insert ({ iface, this } );
4747
4848 // Save the ifindex
4949 ifindex_iface = if_nametoindex (iface.c_str ());
@@ -60,6 +60,14 @@ ExtIface::~ExtIface() {
6060 used_ifaces.erase (iface_);
6161}
6262
63+ ExtIface* ExtIface::get_extiface (const std::string &iface_name) {
64+ if (used_ifaces.count (iface_name) == 0 ) {
65+ return NULL ;
66+ }
67+
68+ return used_ifaces[iface_name];
69+ }
70+
6371uint16_t ExtIface::get_index () const {
6472 return index_;
6573}
@@ -243,12 +251,6 @@ void ExtIface::update_indexes() {
243251 }
244252}
245253
246- // in external ifaces the cubes must be allocated in the inverse order.
247- // first is the one that hits ingress traffic.
248- int ExtIface::calculate_cube_index (int index) {
249- return 0 - index;
250- }
251-
252254bool ExtIface::is_used () const {
253255 std::lock_guard<std::mutex> guard (iface_mutex_);
254256 return cubes_.size () > 0 || peer_ != nullptr ;
0 commit comments