feat: wi-fi - join WPA2/WPA3-PSK networks and carry traffic like ethernet

This commit is contained in:
daniel committed 2026-08-06 19:44:35 +02:00
1 parent a01e63c717
commit bbe1df62fd
40 files changed
+5878 -272

No files matched your search

+22 -11
View File
@@ -15,8 +15,10 @@
#include <Net/Ipv4.hpp>
#include <Net/Socket.hpp>
#include <Net/NetConfig.hpp>
#include <Net/NetIf.hpp>
#include <Drivers/Net/E1000.hpp>
#include <Drivers/Net/E1000E.hpp>
#include <Drivers/Net/Wifi/Wifi.hpp>
#include "Syscall.hpp"
@@ -96,12 +98,9 @@ namespace montauk::abi {
out->subnetMask = Net::GetSubnetMask();
out->gateway = Net::GetGateway();
const uint8_t* mac = nullptr;
if (Drivers::Net::E1000::IsInitialized()) {
mac = Drivers::Net::E1000::GetMacAddress();
} else if (Drivers::Net::E1000E::IsInitialized()) {
mac = Drivers::Net::E1000E::GetMacAddress();
}
// Whichever interface is carrying traffic; on a Wi-Fi link this is the
// adapter's MAC, not an idle Ethernet port's.
const uint8_t* mac = ::Net::NetIf::ActiveMac();
if (mac) {
for (int i = 0; i < 6; i++) out->macAddress[i] = mac[i];
} else {
@@ -122,6 +121,9 @@ namespace montauk::abi {
dst[i] = '\0';
}
// Reports whichever interface is currently carrying traffic, so a machine
// that joined a Wi-Fi network sees the wireless counters here rather than
// an idle Ethernet port.
static void Sys_NetStatus(NetStatus* out) {
if (out == nullptr) return;
@@ -133,15 +135,24 @@ namespace montauk::abi {
out->txPackets = 0;
CopyNetStatusDriver(out->driver, "No adapter");
if (Drivers::Net::E1000::IsInitialized()) {
out->initialized = 1;
out->linkUp = Drivers::Net::E1000::IsLinkUp() ? 1 : 0;
const auto* iface = ::Net::NetIf::Active();
if (iface == nullptr) return;
out->initialized = 1;
out->linkUp = iface->IsLinkUp() ? 1 : 0;
if (iface->Type == ::Net::NetIf::Kind::Wireless) {
WifiInfo wi;
if (Drivers::Net::Wifi::GetInfo(&wi) == 0) {
out->rxPackets = wi.rxPackets;
out->txPackets = wi.txPackets;
}
CopyNetStatusDriver(out->driver, "Intel Wi-Fi (wlan0)");
} else if (Drivers::Net::E1000::IsInitialized()) {
out->rxPackets = Drivers::Net::E1000::GetRxPacketCount();
out->txPackets = Drivers::Net::E1000::GetTxPacketCount();
CopyNetStatusDriver(out->driver, "Intel 82540EM");
} else if (Drivers::Net::E1000E::IsInitialized()) {
out->initialized = 1;
out->linkUp = Drivers::Net::E1000E::IsLinkUp() ? 1 : 0;
out->polling = Drivers::Net::E1000E::RequiresPolling() ? 1 : 0;
out->rxPackets = Drivers::Net::E1000E::GetRxPacketCount();
out->txPackets = Drivers::Net::E1000E::GetTxPacketCount();