Skip to content

Commit

Permalink
Merge branch 'mtu-osx' of git://github.com/kechagia/cjdns
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb James DeLisle committed Aug 10, 2012
2 parents 98ba96d + a1ba996 commit 1d53d35
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion interface/TUNConfigurator_OSX.c
Expand Up @@ -210,5 +210,29 @@ void TUNConfigurator_setMTU(const char* interfaceName,
struct Log* logger, struct Log* logger,
struct Except* eh) 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));
}
} }

0 comments on commit 1d53d35

Please sign in to comment.