Commit 6841a49f authored by Aurélien Delrieu's avatar Aurélien Delrieu

Merge adaptation of the OpenBACH output to new Collect Agent

parents 0e079b11 a3a5ba56
2018-01-28 opensand-5.1.1
2019-04-04 opensand-5.1.2
* Release 5.1.2
* Update OpenBACH output to new collect agent
2019-01-28 opensand-5.1.1
* Release 5.1.1
* Fix float probe sending
......
......@@ -9,7 +9,7 @@ from setuptools import setup, find_packages
setup(
name="opensand-collector",
version="5.1.1",
version="5.1.2",
author="Vincent Duvert",
author_email="vduvert@toulouse.viveris.com",
description=("Statistics and events collector for OpenSAND platform"),
......
#!/bin/bash
# Process this file with autoconf to produce a configure script.
AC_INIT(opensand-conf, 5.1.1, [http://opensand.org])
AC_INIT(opensand-conf, 5.1.2, [http://opensand.org])
AC_CONFIG_SRCDIR([src])
AM_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
......@@ -40,7 +40,7 @@ AC_SUBST(AM_CPPFLAGS, "$LIBXMLXX_CFLAGS")
PKG_PROG_PKG_CONFIG
# check for opensand-output library
PKG_CHECK_MODULES([OPENSAND_OUTPUT], [opensand_output = 5.1.1])
PKG_CHECK_MODULES([OPENSAND_OUTPUT], [opensand_output = 5.1.2])
LIBS="$OPENSAND_OUTPUT_LIBS $LIBS"
AC_SUBST(AM_CPPFLAGS, "$OPENSAND_OUTPUT_CFLAGS $AM_CPPFLAGS")
......
#!/bin/bash
# Process this file with autoconf to produce a configure script.
AC_INIT(opensand-core, 5.1.1, [http://opensand.org])
AC_INIT(opensand-core, 5.1.2, [http://opensand.org])
AC_CONFIG_SRCDIR([src])
AM_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
......@@ -46,17 +46,17 @@ AC_CHECK_PROG(pkg_config, pkg-config, [yes], [AC_MSG_ERROR([pkg-config not found
# check for opensand-conf library
PKG_CHECK_MODULES([OPENSAND_CONF], [opensand_conf = 5.1.1])
PKG_CHECK_MODULES([OPENSAND_CONF], [opensand_conf = 5.1.2])
LIBS="$OPENSAND_CONF_LIBS $LIBS"
AC_SUBST(AM_CPPFLAGS, "$OPENSAND_CONF_CFLAGS $AM_CPPFLAGS")
# check for opensand-output library
PKG_CHECK_MODULES([OPENSAND_OUTPUT], [opensand_output = 5.1.1])
PKG_CHECK_MODULES([OPENSAND_OUTPUT], [opensand_output = 5.1.2])
LIBS="$OPENSAND_OUTPUT_LIBS $LIBS"
AC_SUBST(AM_CPPFLAGS, "$OPENSAND_OUTPUT_CFLAGS $AM_CPPFLAGS")
# check for opensand-rt library
PKG_CHECK_MODULES([OPENSAND_RT], [opensand_rt = 5.1.1])
PKG_CHECK_MODULES([OPENSAND_RT], [opensand_rt = 5.1.2])
LIBS="$OPENSAND_RT_LIBS $LIBS"
AC_SUBST(AM_CPPFLAGS, "$OPENSAND_RT_CFLAGS $AM_CPPFLAGS")
......
......@@ -53,7 +53,6 @@
* @param channelID the Id of the new channel
* @param input true if the channel accept incoming data
* @param output true if channel send data
* @param local_interface_name.c_str() the name of the local network interface to use
* @param port the port on which the channel is bind
* @param multicast true is this is a multicast channel
* @param local_ip_addr the host IP address
......@@ -70,7 +69,6 @@ UdpChannel::UdpChannel(string name,
unsigned int channel_id,
bool input,
bool output,
const string local_interface_name,
unsigned short port,
bool multicast,
const string local_ip_addr,
......@@ -88,7 +86,6 @@ UdpChannel::UdpChannel(string name,
stacked_ip(""),
max_stack(stack)
{
int ifIndex;
struct ip_mreq imr;
unsigned char ttl = 1;
int one = 1;
......@@ -122,17 +119,6 @@ UdpChannel::UdpChannel(string name,
goto error;
}
// get the index of the network interface
ifIndex = this->getIfIndex(local_interface_name.c_str());
if(ifIndex < 0)
{
LOG(this->log_init, LEVEL_ERROR,
"cannot get the index for %s\n",
local_interface_name.c_str());
goto error;
}
// Set destination characteristics to send the datagramms
if(this->isOutputOk())
{
......@@ -315,46 +301,6 @@ bool UdpChannel::isOutputOk()
return (m_output);
}
/**
* Get the index of a network interface
* @param name the name of the interface
* @return the index of the interface if successful, -1 otherwise
*/
int UdpChannel::getIfIndex(const char *name)
{
int sock;
ifreq ifr;
int index = -1;
// open the network interface socket
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if(sock < 0)
{
LOG(this->log_sat_carrier, LEVEL_ERROR,
"cannot create an INET socket: "
"(%s:%d)\n", strerror(errno), errno);
goto exit;
}
// get the network interface index
bzero(&ifr, sizeof(ifreq));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1);
if(ioctl(sock, SIOGIFINDEX, &ifr) < 0)
{
LOG(this->log_sat_carrier, LEVEL_ERROR,
"cannot get the network interface "
"index: %s (%d)\n", strerror(errno), errno);
goto close;
}
index = ifr.ifr_ifindex;
close:
close(sock);
exit:
return index;
}
/**
* Return the network socket of the udp channel
* @return the network socket of the udp channel
......
......@@ -65,7 +65,6 @@ class UdpChannel
spot_id_t s_id,
unsigned int channel_id,
bool input, bool output,
const string local_interface_name,
unsigned short port,
bool multicast,
const string local_ip_addr,
......@@ -95,8 +94,6 @@ class UdpChannel
int receive(NetSocketEvent *const event,
unsigned char **buf, size_t &data_len);
int getIfIndex(const char *name);
int getChannelFd();
spot_id_t getSpotId();
......
......@@ -46,7 +46,6 @@
struct ic_specific
{
string interconnect_iface; // Interconnect interface name
string interconnect_addr; // Interconnect interface IP address
};
......@@ -77,7 +76,6 @@ class BlockInterconnectDownward: public Block
Upward(const string &name, struct ic_specific specific):
RtUpward(name),
InterconnectChannelReceiver(name + ".Upward",
specific.interconnect_iface,
specific.interconnect_addr)
{};
......@@ -93,7 +91,6 @@ class BlockInterconnectDownward: public Block
Downward(const string &name, struct ic_specific specific):
RtDownward(name),
InterconnectChannelSender(name + ".Downward",
specific.interconnect_iface,
specific.interconnect_addr)
{};
......@@ -142,7 +139,6 @@ class BlockInterconnectUpward: public Block
Upward(const string &name, struct ic_specific specific):
RtUpward(name),
InterconnectChannelSender(name + ".Upward",
specific.interconnect_iface,
specific.interconnect_addr)
{};
......@@ -158,7 +154,6 @@ class BlockInterconnectUpward: public Block
Downward(const string &name, struct ic_specific specific):
RtDownward(name),
InterconnectChannelReceiver(name + ".Downward",
specific.interconnect_iface,
specific.interconnect_addr)
{};
......
......@@ -48,7 +48,6 @@ void InterconnectChannelSender::initUdpChannels(unsigned int data_port, unsigned
0, // no use for the spot ID
false,
true,
this->interconnect_iface,
data_port,
false, // this socket is not multicast
this->interconnect_addr,
......@@ -61,7 +60,6 @@ void InterconnectChannelSender::initUdpChannels(unsigned int data_port, unsigned
0, // no use for the spot ID
false,
true,
this->interconnect_iface,
sig_port,
false, // this socket is not multicast
this->interconnect_addr,
......@@ -174,7 +172,6 @@ void InterconnectChannelReceiver::initUdpChannels(unsigned int data_port, unsign
0, // no use for the spot ID
true,
false,
this->interconnect_iface,
data_port,
false, // this socket is not multicast
this->interconnect_addr,
......@@ -187,7 +184,6 @@ void InterconnectChannelReceiver::initUdpChannels(unsigned int data_port, unsign
0, // no use for the spot ID
true,
false,
this->interconnect_iface,
sig_port,
false, // this socket is not multicast
this->interconnect_addr,
......
......@@ -59,9 +59,8 @@ typedef struct
class InterconnectChannel
{
public:
InterconnectChannel(string name, string iface_name, string iface_addr):
InterconnectChannel(string name, string iface_addr):
name(name),
interconnect_iface(iface_name),
interconnect_addr(iface_addr),
data_channel(NULL),
sig_channel(NULL)
......@@ -96,8 +95,6 @@ class InterconnectChannel
unsigned int wmem) = 0;
/// This blocks name
string name;
/// The interconnect interface name
string interconnect_iface;
/// The interconnect interface IP address
string interconnect_addr;
/// The data channel
......@@ -111,8 +108,8 @@ class InterconnectChannel
class InterconnectChannelSender: public InterconnectChannel
{
public:
InterconnectChannelSender(string name, string iface_name, string iface_addr):
InterconnectChannel(name, iface_name, iface_addr)
InterconnectChannelSender(string name, string iface_addr):
InterconnectChannel(name, iface_addr)
{
};
......@@ -170,8 +167,8 @@ class InterconnectChannelSender: public InterconnectChannel
class InterconnectChannelReceiver: public InterconnectChannel
{
public:
InterconnectChannelReceiver(string name, string iface_name, string iface_addr):
InterconnectChannel(name, iface_name, iface_addr)
InterconnectChannelReceiver(string name, string iface_addr):
InterconnectChannel(name, iface_addr)
{
};
......
......@@ -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>
......@@ -57,9 +52,9 @@ extern "C"
/**
* constructor
*/
BlockLanAdaptation::BlockLanAdaptation(const string &name, string lan_iface):
BlockLanAdaptation::BlockLanAdaptation(const string &name, struct la_specific specific):
Block(name),
lan_iface(lan_iface),
tuntap_iface(specific.tuntap_iface),
is_tap(false)
{
}
......@@ -69,10 +64,6 @@ BlockLanAdaptation::BlockLanAdaptation(const string &name, string lan_iface):
*/
BlockLanAdaptation::~BlockLanAdaptation()
{
if(this->is_tap)
{
this->delFromBridge();
}
}
bool BlockLanAdaptation::Downward::onEvent(const RtEvent *const event)
......@@ -455,15 +446,11 @@ bool BlockLanAdaptation::allocTunTap(int &fd)
/* create TUN or TAP interface */
LOG(this->log_init, LEVEL_INFO,
"create interface opensand_%s\n",
(this->is_tap ? "tap" : "tun"));
snprintf(ifr.ifr_name, IFNAMSIZ, "opensand_%s",
(this->is_tap ? "tap" : "tun"));
"create %s interface %s\n",
this->is_tap ? "TAP" : "TUN",
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)
......@@ -480,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", br);
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(br, 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;
}
......@@ -51,6 +51,10 @@
using std::string;
struct la_specific
{
string tuntap_iface;
};
/**
* @class BlockLanAdaptation
......@@ -60,7 +64,7 @@ class BlockLanAdaptation: public Block
{
public:
BlockLanAdaptation(const string &name, string lan_iface);
BlockLanAdaptation(const string &name, struct la_specific specific);
~BlockLanAdaptation();
// initialization method
......@@ -69,7 +73,7 @@ class BlockLanAdaptation: public Block
class Upward: public RtUpward
{
public:
Upward(const string &name, string UNUSED(lan_iface)):
Upward(const string &name, struct la_specific UNUSED(specific)):
RtUpward(name),
sarp_table(),
contexts(),
......@@ -135,7 +139,7 @@ class BlockLanAdaptation: public Block
class Downward: public RtDownward
{
public:
Downward(const string &name, string UNUSED(lan_iface)):
Downward(const string &name, struct la_specific UNUSED(specific)):
RtDownward(name),
stats_period_ms(),
contexts(),
......@@ -190,8 +194,8 @@ class BlockLanAdaptation: public Block
private:
/// The LAN interface name
string lan_iface;
/// The TUN/TAP interface name
string tuntap_iface;
/// whether we handle a TAP interface or a TUN interface
bool is_tap;
......@@ -203,22 +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();
bool tunConfiguration();
};
#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) \
......
......@@ -161,8 +161,7 @@ bool BlockSatCarrier::Upward::onInit(void)
UdpChannel *channel;
// initialize all channels from the configuration file
if(!this->in_channel_set.readInConfig(this->ip_addr,
this->interface_name))
if(!this->in_channel_set.readInConfig(this->ip_addr))
{
LOG(this->log_init, LEVEL_ERROR,
"Wrong channel set configuration\n");
......@@ -194,8 +193,7 @@ bool BlockSatCarrier::Upward::onInit(void)
bool BlockSatCarrier::Downward::onInit()
{
// initialize all channels from the configuration file
if(!this->out_channel_set.readOutConfig(this->ip_addr,
this->interface_name))
if(!this->out_channel_set.readOutConfig(this->ip_addr))
{
LOG(this->log_init, LEVEL_ERROR,
"Wrong channel set configuration\n");
......
......@@ -46,7 +46,6 @@ struct sc_specific
{
tal_id_t tal_id; ///< the terminal id for terminal
string ip_addr; ///< the IP address for emulation
string emu_iface; ///< the name of the emulation interface
};
/**
......@@ -74,7 +73,6 @@ class BlockSatCarrier: public Block
Upward(const string &name, struct sc_specific specific):
RtUpward(name),
ip_addr(specific.ip_addr),
interface_name(specific.emu_iface),
tal_id(specific.tal_id),
in_channel_set(specific.tal_id)
{};
......@@ -85,8 +83,6 @@ class BlockSatCarrier: public Block
private:
/// the IP address for emulation newtork
string ip_addr;
/// the interface name for emulation newtork
string interface_name;
/// the terminal id for the emulation newtork
tal_id_t tal_id;
/// List of input channels
......@@ -111,7 +107,6 @@ class BlockSatCarrier: public Block
Downward(const string &name, struct sc_specific specific):
RtDownward(name),
ip_addr(specific.ip_addr),
interface_name(specific.emu_iface),
tal_id(specific.tal_id),
out_channel_set(specific.tal_id)
{};
......@@ -122,8 +117,6 @@ class BlockSatCarrier: public Block
private:
/// the IP address for emulation newtork
string ip_addr;
/// the interface name for emulation newtork
string interface_name;
/// the terminal id for the emulation newtork
tal_id_t tal_id;
/// List of output channels
......
......@@ -59,7 +59,6 @@ sat_carrier_channel_set::~sat_carrier_channel_set()
bool sat_carrier_channel_set::readConfig(const string local_ip_addr,
const string interface_name,
bool in)
{
......@@ -355,7 +354,6 @@ bool sat_carrier_channel_set::readConfig(const string local_ip_addr,
carrier_id,
is_input,
is_output,
interface_name,
carrier_port,
carrier_multicast,
local_ip_addr,
......@@ -379,16 +377,14 @@ error:
return false;
}
bool sat_carrier_channel_set::readInConfig(const string local_ip_addr,
const string interface_name)
bool sat_carrier_channel_set::readInConfig(const string local_ip_addr)
{
return this->readConfig(local_ip_addr, interface_name, true);
return this->readConfig(local_ip_addr, true);
}
bool sat_carrier_channel_set::readOutConfig(const string local_ip_addr,
const string interface_name)
bool sat_carrier_channel_set::readOutConfig(const string local_ip_addr)
{
return this->readConfig(local_ip_addr, interface_name, false);
return this->readConfig(local_ip_addr, false);
}
bool sat_carrier_channel_set::send(uint8_t carrier_id,
......
......@@ -61,21 +61,17 @@ class sat_carrier_channel_set: public std::vector < UdpChannel * >
* Read data from the configuration file and create input channels
*
* @param local_ip_addr The IP address for emulation network
* @param interface_name The interface name for emulation network
* @return true on success, false otherwise
*/
bool readInConfig(const string local_ip_addr,
const string interface_name);
bool readInConfig(const string local_ip_addr);
/**
* Read data from the configuration file and create output channels
*
* @param local_ip_addr The IP address for emulation network
* @param interface_name The interface name for emulation network
* @return true on success, false otherwise
*/
bool readOutConfig(const string local_ip_addr,
const string interface_name);
bool readOutConfig(const string local_ip_addr);
/**
* @brief Send data on a satellite carrier
......@@ -115,12 +111,10 @@ class sat_carrier_channel_set: public std::vector < UdpChannel * >
* Read data from the configuration file and create channels
*
* @param local_ip_addr The IP address for emulation network
* @param interface_name The interface name for emulation network
* @param in Whether we want input or output channels
* @return true on success, false otherwise
*/
bool readConfig(const string local_ip_addr,
const string interface_name,
bool in);
/// The terminal ID
......
......@@ -267,8 +267,7 @@ bool TestSatCarriers::Upward::onInit(void)
UdpChannel *channel;
// initialize all channels from the configuration file
if(!this->in_channel_set.readInConfig(this->ip_addr,
this->interface_name))
if(!this->in_channel_set.readInConfig(this->ip_addr))
{
fprintf(stderr, "Wrong channel set configuration\n");
return false;
......@@ -297,8 +296,7 @@ bool TestSatCarriers::Upward::onInit(void)
bool TestSatCarriers::Downward::onInit()
{
// initialize all channels from the configuration file
if(!this->out_channel_set.readOutConfig(this->ip_addr,
this->interface_name))
if(!this->out_channel_set.readOutConfig(this->ip_addr))
{
fprintf(stderr, "Wrong channel set configuration\n");
return false;
......
......@@ -46,7 +46,6 @@ struct sc_specific
{
tal_id_t tal_id;
string ip_addr; ///< the IP address for emulation
string emu_iface; ///< the name of the emulation interface
};
/**
......@@ -71,8 +70,7 @@ class TestSatCarriers: public Block
Upward(const string &name, struct sc_specific specific):
RtUpward(name),
in_channel_set(specific.tal_id),
ip_addr(specific.ip_addr),
interface_name(specific.emu_iface)
ip_addr(specific.ip_addr)
{};
......@@ -91,8 +89,6 @@ class TestSatCarriers: public Block
sat_carrier_channel_set in_channel_set;
/// the IP address for emulation newtork
string ip_addr;
/// the interface name for emulation newtork
string interface_name;
};
class Downward: public RtDownward
......@@ -101,8 +97,7 @@ class TestSatCarriers: public Block
Downward(const string &name, struct sc_specific specific):
RtDownward(name),
out_channel_set(specific.tal_id),
ip_addr(specific.ip_addr),
interface_name(specific.emu_iface)
ip_addr(specific.ip_addr)
{};
bool onInit(void);
......@@ -120,8 +115,6 @@ class TestSatCarriers: public Block
sat_carrier_channel_set out_channel_set;
/// the IP address for emulation newtork
string ip_addr;
/// the interface name for emulation newtork
string interface_name;
/// The tun output file descriptor
int fd;
};
......
......@@ -51,7 +51,7 @@
/**
* Argument treatment
*/
bool init_process(int argc, char **argv, string &ip_addr, string &iface_name)
bool init_process(int argc, char **argv, string &ip_addr)
{
int opt;