Skip to content

Commit

Permalink
macos compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerman committed Sep 19, 2022
1 parent a82907b commit 27d5804
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion llarp/apple/context_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ llarp_apple_init(llarp_apple_config* appleconf)
#ifdef MACOS_SYSTEM_EXTENSION
std::strncpy(
appleconf->dns_bind_ip,
config->dns.m_bind.hostString().c_str(),
config->dns.m_bind.front().hostString().c_str(),
sizeof(appleconf->dns_bind_ip));
#endif

Expand Down
4 changes: 2 additions & 2 deletions llarp/apple/route_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ namespace llarp::apple
trampoline_active = enable;
}

void RouteManager::AddDefaultRouteViaInterface(std::string)
void RouteManager::AddDefaultRouteViaInterface(vpn::NetworkInterface&)
{
check_trampoline(true);
if (callback_context and route_callbacks.add_default_route)
route_callbacks.add_default_route(callback_context);
}

void RouteManager::DelDefaultRouteViaInterface(std::string)
void RouteManager::DelDefaultRouteViaInterface(vpn::NetworkInterface&)
{
check_trampoline(false);
if (callback_context and route_callbacks.del_default_route)
Expand Down
18 changes: 9 additions & 9 deletions llarp/apple/route_manager.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <llarp/router/abstractrouter.hpp>
#include <llarp/ev/vpn.hpp>
#include <llarp/vpn/platform.hpp>
#include "context_wrapper.h"

namespace llarp::apple
Expand All @@ -16,32 +16,32 @@ namespace llarp::apple
/// These are called for poking route holes, but we don't have to do that at all on macos
/// because the appex isn't subject to its own rules.
void
AddRoute(IPVariant_t /*ip*/, IPVariant_t /*gateway*/) override
AddRoute(net::ipaddr_t /*ip*/, net::ipaddr_t /*gateway*/) override
{}

void
DelRoute(IPVariant_t /*ip*/, IPVariant_t /*gateway*/) override
DelRoute(net::ipaddr_t /*ip*/, net::ipaddr_t /*gateway*/) override
{}

void
AddDefaultRouteViaInterface(std::string ifname) override;
AddDefaultRouteViaInterface(vpn::NetworkInterface& vpn) override;

void
DelDefaultRouteViaInterface(std::string ifname) override;
DelDefaultRouteViaInterface(vpn::NetworkInterface& vpn) override;

void
AddRouteViaInterface(vpn::NetworkInterface& vpn, IPRange range) override;

void
DelRouteViaInterface(vpn::NetworkInterface& vpn, IPRange range) override;

std::vector<IPVariant_t>
GetGatewaysNotOnInterface(std::string /*ifname*/) override
std::vector<net::ipaddr_t>
GetGatewaysNotOnInterface(vpn::NetworkInterface& /*vpn*/) override
{
// We can't get this on mac from our sandbox, but we don't actually need it because we
// ignore the gateway for AddRoute/DelRoute anyway, so just return a zero IP.
std::vector<IPVariant_t> ret;
ret.push_back(huint32_t{0});
std::vector<net::ipaddr_t> ret;
ret.emplace_back(net::ipv4addr_t{});
return ret;
}

Expand Down
11 changes: 3 additions & 8 deletions llarp/apple/vpn_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace llarp::apple
packet_write_callback packet_writer,
on_readable_callback on_readable,
AbstractRouter* router)
: m_PacketWriter{std::move(packet_writer)}
: vpn::NetworkInterface{{}}
, m_PacketWriter{std::move(packet_writer)}
, m_OnReadable{std::move(on_readable)}
, _router{router}
{
Expand Down Expand Up @@ -39,12 +40,6 @@ namespace llarp::apple
return -1;
}

std::string
VPNInterface::IfName() const
{
return "";
}

net::IPPacket
VPNInterface::ReadNextPacket()
{
Expand All @@ -58,7 +53,7 @@ namespace llarp::apple
VPNInterface::WritePacket(net::IPPacket pkt)
{
int af_family = pkt.IsV6() ? AF_INET6 : AF_INET;
return m_PacketWriter(af_family, pkt.buf, pkt.sz);
return m_PacketWriter(af_family, pkt.data(), pkt.size());
}

} // namespace llarp::apple
3 changes: 0 additions & 3 deletions llarp/apple/vpn_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ namespace llarp::apple
int
PollFD() const override;

std::string
IfName() const override;

net::IPPacket
ReadNextPacket() override;

Expand Down
2 changes: 1 addition & 1 deletion llarp/apple/vpn_platform.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <llarp/ev/vpn.hpp>
#include <llarp/vpn/platform.hpp>
#include "vpn_interface.hpp"
#include "route_manager.hpp"

Expand Down

0 comments on commit 27d5804

Please sign in to comment.