Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'mtu-osx' of git://github.com/kechagia/cjdns

  • Loading branch information...
commit 1d53d357e3c5a6229e592f2de8222d7e907e1623 2 parents 98ba96d + a1ba996
Caleb James DeLisle authored
Showing with 25 additions and 1 deletion.
  1. +25 −1 interface/TUNConfigurator_OSX.c
View
26 interface/TUNConfigurator_OSX.c
@@ -210,5 +210,29 @@ void TUNConfigurator_setMTU(const char* interfaceName,
struct Log* logger,
struct Except* eh)
{
- Except_raise(eh, TUNConfigurator_setMTU_INTERNAL, "Not implemented in OSX");
+ int s = socket(AF_INET6, SOCK_DGRAM, 0);
+
+ if (s < 0) {
+ Except_raise(eh,
+ TUNConfigurator_setIpAddress_INTERNAL,
+ "socket() failed [%s]",
+ strerror(errno));
+ }
+
+
+ struct ifreq ifRequest;
+
+ strncpy(ifRequest.ifr_name, interfaceName, IFNAMSIZ);
+ ifRequest.ifr_mtu = mtu;
+
+ Log_info(logger, "Setting MTU for device [%s] to [%u] bytes.", interfaceName, mtu);
+
+ if (ioctl(s, SIOCSIFMTU, &ifRequest) < 0) {
+ int err = errno;
+ close(s);
+ Except_raise(eh,
+ TUNConfigurator_setMTU_INTERNAL,
+ "ioctl(SIOCSIFMTU) failed [%s]",
+ strerror(err));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.