Skip to content

Commit

Permalink
AirportItlwm: Add another hack to fake that the provider is IOSkywalk…
Browse files Browse the repository at this point in the history
…NetworkInterface, to avoid skywalkfamily instance cast panic.
  • Loading branch information
zxystd committed Feb 5, 2024
1 parent 3b8f766 commit 3e1624d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions AirportItlwm/AirportItlwmEthernetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ initWithSkywalkInterfaceAndProvider(IONetworkController *controller, IO80211Skyw
bool ret = super::init(controller);
if (ret)
this->interface = interface;
this->isAttach = false;
return ret;
}

Expand All @@ -44,9 +45,26 @@ attachToDataLinkLayer( IOOptionBits options, void *parameter )
interface->prepareBSDInterface(getIfnet(), 0);
// ret = bpf_attach(getIfnet(), DLT_RAW, 0x48, &AirportItlwmEthernetInterface::bpfOutputPacket, &AirportItlwmEthernetInterface::bpfTap);
}
isAttach = true;
return ret;
}

void AirportItlwmEthernetInterface::
detachFromDataLinkLayer(IOOptionBits options, void *parameter)
{
super::detachFromDataLinkLayer(options, parameter);
isAttach = false;
}

/**
Add another hack to fake that the provider is IOSkywalkNetworkInterface, to avoid skywalkfamily instance cast panic.
*/
IOService *AirportItlwmEthernetInterface::
getProvider() const
{
return isAttach ? this->interface : super::getProvider();
}

errno_t AirportItlwmEthernetInterface::
bpfOutputPacket(ifnet_t interface, u_int32_t data_link_type, mbuf_t packet)
{
Expand Down
6 changes: 6 additions & 0 deletions AirportItlwm/AirportItlwmEthernetInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class AirportItlwmEthernetInterface : public IOEthernetInterface {
virtual IOReturn attachToDataLinkLayer( IOOptionBits options,
void * parameter ) override;

virtual void detachFromDataLinkLayer( IOOptionBits options,
void * parameter ) override;

virtual bool initWithSkywalkInterfaceAndProvider(IONetworkController *controller, IO80211SkywalkInterface *interface);

virtual bool setLinkState(IO80211LinkState state);
Expand All @@ -41,8 +44,11 @@ class AirportItlwmEthernetInterface : public IOEthernetInterface {
IOOptionBits options = 0,
void * param = 0 ) override;

virtual IOService * getProvider( void ) const override;

private:
IO80211SkywalkInterface *interface;
bool isAttach;
};

#endif /* AirportItlwmEthernetInterface_hpp */

0 comments on commit 3e1624d

Please sign in to comment.