Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple pmp patch #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions getgateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ POSSIBILITY OF SUCH DAMAGE.

#ifdef __APPLE__
#undef USE_PROC_NET_ROUTE
#undef USE_SOCKET_ROUTE
#define USE_SYSCTL_NET_ROUTE
#define USE_SOCKET_ROUTE
#undef USE_SYSCTL_NET_ROUTE
#endif

#if (defined(sun) && defined(__SVR4))
Expand Down Expand Up @@ -106,6 +106,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/socket.h>
#include <net/if.h>
#include <net/route.h>
#include <arpa/inet.h>
#endif

#ifdef USE_WIN32_CODE
Expand Down Expand Up @@ -259,8 +260,14 @@ int getdefaultgateway(in_addr_t *addr)
seq = 0;
rtm_addrs = RTA_DST | RTA_NETMASK;

memset(&so_dst, 0, sizeof(so_dst));
memset(&so_mask, 0, sizeof(so_mask));
/*
* Using a reserved "this" network destination for the lookup of the
* the default route (see RFC 1122 section 3.2.1.3) to resolve the
* default route longest match prefix resolution correctly also VPNs
* such a openvpn which installs a /1 route.
*/
inet_pton(AF_INET, "0.0.0.1", &so_dst);
inet_pton(AF_INET, "255.255.255.255", &so_mask);
memset(&rtm, 0, sizeof(struct rt_msghdr));

rtm.rtm_type = RTM_GET;
Expand Down