Skip to content

Commit

Permalink
Merge pull request #195 from QuantumEntangledAndy/master
Browse files Browse the repository at this point in the history
Use -inet6 or -inet for /sbin/route on macos
  • Loading branch information
s-vincent authored Jun 4, 2019
2 parents 8402cee + 3e04b9e commit 7f6c0c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/asiotap/src/posix/posix_route_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ namespace asiotap
posix_route_manager::route_type posix_route_manager::get_route_for(const boost::asio::ip::address& host)
{
#ifdef MACINTOSH
const std::vector<std::string> real_args { "/sbin/route", "-n", "get", boost::lexical_cast<std::string>(host) };
const std::string inet = host.is_v6() ? "-inet6" : "-inet";
const std::vector<std::string> real_args { "/sbin/route", "-n", "get", inet, boost::lexical_cast<std::string>(host) };

std::stringstream ss;
executeplus::checked_execute(real_args, executeplus::get_current_environment(), &ss);
Expand Down Expand Up @@ -197,7 +198,8 @@ namespace asiotap
const std::string net_host = is_unicast(dest) ? "-host" : "-net";
#ifdef MACINTOSH
const std::string command = action == route_action::add ? "add" : "delete";
const std::vector<std::string> real_args { "/sbin/route", "-n", command, net_host, boost::lexical_cast<std::string>(dest), "-interface", interface };
const std::string inet = boost::apply_visitor(ip_network_address_ip_address_visitor(), dest).is_v6() ? "-inet6" : "-inet";
const std::vector<std::string> real_args { "/sbin/route", "-n", command, net_host, inet, boost::lexical_cast<std::string>(dest), "-interface", interface };
#else
const std::string command = action == route_action::add ? "add" : "del";
const std::vector<std::string> real_args { "/sbin/route", "-n", command, net_host, boost::lexical_cast<std::string>(dest), "dev", interface };
Expand Down

0 comments on commit 7f6c0c0

Please sign in to comment.