Permalink
Browse files

"Fixed" iptunnel on OS X more.

  • Loading branch information...
jercos committed Feb 7, 2013
1 parent b0aa959 commit 1888d956970bf186541ba52f72d91257e607b71a
Showing with 8 additions and 5 deletions.
  1. +1 −4 interface/TUNConfigurator_OSX.c
  2. +7 −1 tunnel/IpTunnel.c
@@ -176,12 +176,9 @@ void TUNConfigurator_addIp6Address(const char* interfaceName,
struct sockaddr_in6* mask = &in6_addreq.ifra_prefixmask;
mask->sin6_len = sizeof(*mask);
- if (prefixLen == 128) {
+ if (prefixLen >= 128 || prefixLen <= 0) {
memset(&mask->sin6_addr, 0xff, sizeof(struct in6_addr));
} else {
- if (prefixLen < 1) {
- prefixLen = 1;
- }
memset((void *)&mask->sin6_addr, 0x00, sizeof(mask->sin6_addr));
memset((void *)&mask->sin6_addr, 0xff, prefixLen>>3);
((uint8_t*)&mask->sin6_addr)[prefixLen>>3] = 0xff << (8 - (prefixLen%8));
View
@@ -366,6 +366,12 @@ static void addAddressCallback(Dict* responseMessage, void* vcontext)
static void addAddress(char* printedAddr, struct IpTunnel_pvt* ctx)
{
+#ifdef OSX
+ int prefixLen = 3;
+#else
+ int prefixLen = 0;
+#endif
+// Apple doesn't handle prefix length of 1 properly
if (!ctx->ifName) {
Log_error(ctx->logger, "Failed to set IP address because TUN interface is not setup");
return;
@@ -375,7 +381,7 @@ static void addAddress(char* printedAddr, struct IpTunnel_pvt* ctx)
Dict args = Dict_CONST(
String_CONST("address"), String_OBJ(String_CONST(printedAddr)), Dict_CONST(
String_CONST("interfaceName"), String_OBJ(ctx->ifName), Dict_CONST(
- String_CONST("prefixLen"), Int_OBJ(0), NULL
+ String_CONST("prefixLen"), Int_OBJ(prefixLen), NULL
)));
Dict msg = Dict_CONST(
String_CONST("args"), Dict_OBJ(&args), Dict_CONST(

0 comments on commit 1888d95

Please sign in to comment.