Skip to content

Commit

Permalink
Fixes compilation issues with g++-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-vincent committed Jul 8, 2018
1 parent 0dd37d7 commit eb67225
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
6 changes: 3 additions & 3 deletions libs/asiotap/include/asiotap/osi/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ namespace asiotap
m_parent(_parent)
{
typedef _filter<OSIFrameType, ParentFilterType> filter_type;
typedef typename ParentFilterType::frame_type frame_type;
typedef typename ParentFilterType::frame_type parent_frame_type;

const auto mutable_parse = static_cast<void (filter_type::*)(mutable_helper<frame_type>) const>(&filter_type::parse);
const auto const_parse = static_cast<void (filter_type::*)(const_helper<frame_type>) const>(&filter_type::parse);
const auto mutable_parse = static_cast<void (filter_type::*)(mutable_helper<parent_frame_type>) const>(&filter_type::parse);
const auto const_parse = static_cast<void (filter_type::*)(const_helper<parent_frame_type>) const>(&filter_type::parse);

m_parent.add_handler(boost::bind(mutable_parse, this, _1));
m_parent.add_const_handler(boost::bind(const_parse, this, _1));
Expand Down
16 changes: 13 additions & 3 deletions libs/asiotap/src/posix/posix_tap_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ namespace asiotap
if (!_name.empty())
{
strncpy(ifr.ifr_name, _name.c_str(), IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = 0x00;
}

// Set the parameters on the tun device.
Expand All @@ -307,6 +308,7 @@ namespace asiotap
struct ifreq netifr {};

std::strncpy(netifr.ifr_name, ifr.ifr_name, IFNAMSIZ);
netifr.ifr_name[IFNAMSIZ - 1] = 0x00;

#if defined(IFF_ONE_QUEUE) && defined(SIOCSIFTXQLEN)

Expand All @@ -323,6 +325,7 @@ namespace asiotap
netifr = {};

std::strncpy(netifr.ifr_name, ifr.ifr_name, IFNAMSIZ);
netifr.ifr_name[IFNAMSIZ - 1] = 0x00;
#endif

// Get the interface hwaddr
Expand Down Expand Up @@ -504,6 +507,7 @@ namespace asiotap
struct ifreq ifr {};

strncpy(ifr.ifr_name, name().c_str(), IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = 0x00;

// Destroy the virtual tap device
if (ioctl(socket.native_handle(), SIOCIFDESTROY, &ifr) < 0)
Expand All @@ -522,6 +526,7 @@ namespace asiotap
struct ifreq netifr {};

strncpy(netifr.ifr_name, name().c_str(), IFNAMSIZ);
netifr.ifr_name[IFNAMSIZ - 1] = 0x00;

// Get the interface flags
if (::ioctl(socket.native_handle(), SIOCGIFFLAGS, static_cast<void*>(&netifr)) < 0)
Expand Down Expand Up @@ -667,6 +672,7 @@ namespace asiotap
struct ifreq netifr {};

strncpy(netifr.ifr_name, name().c_str(), IFNAMSIZ);
netifr.ifr_name[IFNAMSIZ - 1] = 0x00;

if (::ioctl(socket.native_handle(), SIOCGIFMTU, (void*)&netifr) >= 0)
{
Expand All @@ -685,6 +691,7 @@ namespace asiotap
struct ifreq netifr {};

strncpy(netifr.ifr_name, name().c_str(), IFNAMSIZ);
netifr.ifr_name[IFNAMSIZ - 1] = 0x00;

netifr.ifr_mtu = _mtu;

Expand All @@ -705,7 +712,8 @@ namespace asiotap

ifreq ifr_a {};

std::strncpy(ifr_a.ifr_name, name().c_str(), IFNAMSIZ - 1);
std::strncpy(ifr_a.ifr_name, name().c_str(), IFNAMSIZ);
ifr_a.ifr_name[IFNAMSIZ - 1] = 0x00;

sockaddr_in* ifr_a_addr = reinterpret_cast<sockaddr_in*>(&ifr_a.ifr_addr);
ifr_a_addr->sin_family = AF_INET;
Expand All @@ -730,7 +738,8 @@ namespace asiotap
{
ifreq ifr_n {};

std::strncpy(ifr_n.ifr_name, name().c_str(), IFNAMSIZ - 1);
std::strncpy(ifr_n.ifr_name, name().c_str(), IFNAMSIZ);
ifr_n.ifr_name[IFNAMSIZ - 1] = 0x00;
sockaddr_in* ifr_n_addr = reinterpret_cast<sockaddr_in*>(&ifr_n.ifr_addr);
ifr_n_addr->sin_family = AF_INET;
#ifdef BSD
Expand Down Expand Up @@ -828,7 +837,8 @@ namespace asiotap

ifreq ifr_d {};

std::strncpy(ifr_d.ifr_name, name().c_str(), IFNAMSIZ - 1);
std::strncpy(ifr_d.ifr_name, name().c_str(), IFNAMSIZ);
ifr_d.ifr_name[IFNAMSIZ - 1] = 0x00;
sockaddr_in* ifr_dst_addr = reinterpret_cast<sockaddr_in*>(&ifr_d.ifr_dstaddr);
ifr_dst_addr->sin_family = AF_INET;
#ifdef BSD
Expand Down
18 changes: 9 additions & 9 deletions libs/freelan/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2730,14 +2730,14 @@ namespace freelan
{
std::ostringstream oss;

for (auto&& endpoint : public_endpoints)
for (auto&& ep : public_endpoints)
{
if (!oss.str().empty())
{
oss << ", ";
}

oss << endpoint;
oss << ep;
}

m_logger(fscp::log_level::information) << "Setting contact information on the web server with " << public_endpoints.size() << " public endpoint(s) (" << oss.str() << ")...";
Expand Down Expand Up @@ -2769,14 +2769,14 @@ namespace freelan
{
std::ostringstream oss;

for (auto&& endpoint : accepted_endpoints)
for (auto&& ep : accepted_endpoints)
{
if (!oss.str().empty())
{
oss << ", ";
}

oss << endpoint;
oss << ep;
}

m_logger(fscp::log_level::information) << "Server will advertise the following endpoints: " << oss.str();
Expand All @@ -2786,14 +2786,14 @@ namespace freelan
{
std::ostringstream oss;

for (auto&& endpoint : rejected_endpoints)
for (auto&& ep : rejected_endpoints)
{
if (!oss.str().empty())
{
oss << ", ";
}

oss << endpoint;
oss << ep;
}

m_logger(fscp::log_level::warning) << "Server refused to advertise the following endpoints: " << oss.str();
Expand Down Expand Up @@ -2865,16 +2865,16 @@ namespace freelan
{
std::ostringstream oss;

for (auto&& endpoint : contact.second)
for (auto&& ep : contact.second)
{
async_contact(endpoint);
async_contact(ep);

if (!oss.str().empty())
{
oss << ", ";
}

oss << endpoint;
oss << ep;
}

m_logger(fscp::log_level::information) << "Contact information for " << contact.first << ": " << oss.str();
Expand Down

0 comments on commit eb67225

Please sign in to comment.