Commit a28db6e9 authored by Francklin Simo's avatar Francklin Simo

Remove lan_iface from BlockLanAdaptation

parent 4974c609
......@@ -19,4 +19,5 @@ test_tap_CPPFLAGS = \
test_tap_LDFLAGS =
test_tap_LDADD = \
$(top_builddir)/src/lan_adaptation/libopensand_lan_adaptation.la \
$(top_builddir)/src/lan_adaptation/libopensand_bridge.la \
-lpcap
......@@ -38,11 +38,6 @@
#include "NetBurst.h"
#include "OpenSandFrames.h"
extern "C"
{
#include "bridge_utils.h"
}
#include <cstdio>
#include <sys/ioctl.h>
#include <fcntl.h>
......@@ -60,7 +55,6 @@ extern "C"
BlockLanAdaptation::BlockLanAdaptation(const string &name, struct la_specific specific):
Block(name),
tuntap_iface(specific.tuntap_iface),
lan_iface(specific.lan_iface),
is_tap(false)
{
}
......@@ -70,10 +64,6 @@ BlockLanAdaptation::BlockLanAdaptation(const string &name, struct la_specific sp
*/
BlockLanAdaptation::~BlockLanAdaptation()
{
if(this->is_tap)
{
this->delFromBridge();
}
}
bool BlockLanAdaptation::Downward::onEvent(const RtEvent *const event)
......@@ -461,10 +451,6 @@ bool BlockLanAdaptation::allocTunTap(int &fd)
this->tuntap_iface.c_str());
snprintf(ifr.ifr_name, IFNAMSIZ, this->tuntap_iface.c_str());
ifr.ifr_flags = (this->is_tap ? IFF_TAP : IFF_TUN);
if(this->is_tap && !this->addInBridge())
{
return false;
}
err = ioctl(fd, TUNSETIFF, (void *) &ifr);
if(err < 0)
......@@ -481,73 +467,3 @@ bool BlockLanAdaptation::allocTunTap(int &fd)
return true;
}
bool BlockLanAdaptation::addInBridge()
{
struct ifreq ifr_br;
const char *br = "opensand_br";
int err = -1;
memset(&ifr_br, 0, sizeof(ifr_br));
snprintf(ifr_br.ifr_name, IFNAMSIZ, "%s", this->tuntap_iface.c_str());
err = br_init();
if(err)
{
LOG(this->log_init, LEVEL_ERROR,
"Failed to init bridge: %s\n", strerror(errno));
return false;
}
// remove interface if it is in bridge to avoid error when adding it
br_del_interface(br, this->lan_iface.c_str());
err = br_add_interface(br, this->lan_iface.c_str());
if(err)
{
LOG(this->log_init, LEVEL_ERROR,
"Failed to add %s interface in bridge: %s\n",
this->lan_iface.c_str(), strerror(errno));
br_shutdown();
return false;
}
br_shutdown();
// wait for bridge to be ready
LOG(this->log_init, LEVEL_INFO,
"Wait for bridge to be ready\n");
sleep(10);
return true;
}
bool BlockLanAdaptation::delFromBridge()
{
struct ifreq ifr_br;
const char *br = "opensand_br";
int err = -1;
memset(&ifr_br, 0, sizeof(ifr_br));
snprintf(ifr_br.ifr_name, IFNAMSIZ, "%s", br);
err = br_init();
if(err)
{
LOG(this->log_init, LEVEL_ERROR,
"Failed to init bridge: %s\n", strerror(errno));
return false;
}
err = br_del_interface(this->tuntap_iface.c_str(), this->lan_iface.c_str());
if(err)
{
LOG(this->log_init, LEVEL_ERROR,
"Failed to remove %s interface from bridge: %s\n",
this->lan_iface.c_str(), strerror(errno));
br_shutdown();
return false;
}
br_shutdown();
return true;
}
......@@ -54,7 +54,6 @@ using std::string;
struct la_specific
{
string tuntap_iface;
string lan_iface;
};
/**
......@@ -197,8 +196,6 @@ class BlockLanAdaptation: public Block
/// The TUN/TAP interface name
string tuntap_iface;
/// The LAN interface name
string lan_iface;
/// whether we handle a TAP interface or a TUN interface
bool is_tap;
......@@ -210,20 +207,6 @@ class BlockLanAdaptation: public Block
* @return true on success, false otherwise
*/
bool allocTunTap(int &fd);
/**
* @brief add LAN interface in bridge
*
* return true on success, false otherwise
*/
bool addInBridge();
/**
* @brief remove LAN interface from bridge
*
* return true on success, false otherwise
*/
bool delFromBridge();
};
#endif
......@@ -23,8 +23,8 @@ libopensand_lan_adaptation_la_SOURCES = \
$(libopensand_lan_adaptation_la_cpp) \
$(libopensand_lan_adaptation_la_h)
libopensand_lan_adaptation_la_LIBADD = \
libopensand_bridge.la
#libopensand_lan_adaptation_la_LIBADD = \
# libopensand_bridge.la
libopensand_lan_adaptation_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment