From f5c69d4eee675b64cd7c19aee8826f3ebc556ac0 Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Wed, 8 Aug 2018 23:17:02 +0200 Subject: [PATCH] Fix route adding on FreeBSD --- network_bsd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/network_bsd.cpp b/network_bsd.cpp index b617835..72bb353 100644 --- a/network_bsd.cpp +++ b/network_bsd.cpp @@ -523,9 +523,9 @@ static bool GetDefaultRoute(char *iface, size_t iface_size, uint32 *gw_addr) { if (len > rep.buf + 512 - pos) break; // invalid // RINFO("rtm %d %d", i, ((struct sockaddr*)pos)->sa_len); - if (i == RTA_IFP && ((struct sockaddr*)pos)->sa_len == sizeof(struct sockaddr_dl)) { + if (i == RTA_IFP && ((struct sockaddr*)pos)->sa_len >= sizeof(struct sockaddr_dl)) { ifp = (struct sockaddr_dl *)pos; - } else if (i == RTA_GATEWAY && ((struct sockaddr*)pos)->sa_len == sizeof(struct sockaddr_in)) { + } else if (i == RTA_GATEWAY && ((struct sockaddr*)pos)->sa_len >= sizeof(struct sockaddr_in)) { gw = (struct sockaddr_in *)pos; } @@ -596,7 +596,7 @@ static void AddOrRemoveRoute(const RouteInfo &cd, bool remove) { } else { RunCommand("/sbin/route %s -net inet6 %s gw %s", cmd, buf1, buf2); } -#elif defined(OS_MACOSX) +#elif defined(OS_MACOSX) || defined(OS_FREEBSD) const char *cmd = remove ? "delete" : "add"; if (cd.family == AF_INET) { RunCommand("/sbin/route -q %s %s %s", cmd, buf1, buf2);