Skip to content

Commit

Permalink
Be more strict about MTU; OS X's bridge interface can pave over it wi…
Browse files Browse the repository at this point in the history
…th 1500 otherwise, wreaking havoc.
  • Loading branch information
jwise committed Feb 27, 2013
1 parent 22b6a51 commit b6b8275
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions HoRNDIS.cpp
Expand Up @@ -235,13 +235,23 @@ bool HoRNDIS::openInterfaces() {
/* We need our own createInterface (overriding the one in IOEthernetController) because we need our own subclass of IOEthernetInterface. Why's that, you say? Well, we need that because that's the only way to set a different default MTU. Sigh... */

bool HoRNDISInterface::init(IONetworkController * controller, int mtu) {
maxmtu = mtu;
if (IOEthernetInterface::init(controller) == false)
return false;
LOG(V_NOTE, "starting up with MTU %d", mtu);
setMaxTransferUnit(mtu);
return true;
}

bool HoRNDISInterface::setMaxTransferUnit(UInt32 mtu) {
if (mtu > maxmtu) {
LOG(V_NOTE, "Excuse me, but I said you could have an MTU of %u, and you just tried to set an MTU of %d. Good try, buddy.", maxmtu, mtu);
return false;
}
IOEthernetInterface::setMaxTransferUnit(mtu);
return true;
}

/* Overrides IOEthernetController::createInterface */
IONetworkInterface *HoRNDIS::createInterface() {
HoRNDISInterface * netif = new HoRNDISInterface;
Expand Down
2 changes: 2 additions & 0 deletions HoRNDIS.h
Expand Up @@ -307,6 +307,8 @@ class HoRNDISUSBInterface : public HoRNDIS {

class HoRNDISInterface : public IOEthernetInterface {
OSDeclareDefaultStructors(HoRNDISInterface);
int maxmtu;
public:
virtual bool init(IONetworkController * controller, int mtu);
virtual bool setMaxTransferUnit(UInt32 mtu);
};

0 comments on commit b6b8275

Please sign in to comment.