feat: wi-fi - join WPA2/WPA3-PSK networks and carry traffic like ethernet
This commit is contained in:
1 parent
a01e63c717
commit
bbe1df62fd
40 files changed
+5878
-272
No files matched your search
@@ -12,4 +12,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MONTAUK_BUILD_NUMBER 53
|
||||
#define MONTAUK_BUILD_NUMBER 69
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Drivers/USB/Bluetooth/Bluetooth.hpp>
|
||||
#include <Drivers/Net/E1000.hpp>
|
||||
#include <Drivers/Net/E1000E.hpp>
|
||||
#include <Drivers/Net/Wifi/Wifi.hpp>
|
||||
#include <Drivers/Graphics/IntelGPU.hpp>
|
||||
#include <Drivers/Storage/Ahci.hpp>
|
||||
#include <Drivers/Audio/IntelHda.hpp>
|
||||
@@ -127,6 +128,11 @@ namespace montauk::abi {
|
||||
if (Drivers::Net::E1000E::IsInitialized()) {
|
||||
add(5, "Intel E1000E", "Gigabit Ethernet (82574L)");
|
||||
}
|
||||
if (Drivers::Net::Wifi::IsPresent()) {
|
||||
add(5, "Intel Wi-Fi", Drivers::Net::Wifi::IsLinkUp()
|
||||
? "802.11 wireless (connected)"
|
||||
: "802.11 wireless");
|
||||
}
|
||||
|
||||
// Display (category 6)
|
||||
if (Drivers::Graphics::IntelGPU::IsInitialized()) {
|
||||
|
||||
+22
-11
@@ -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();
|
||||
|
||||
@@ -671,6 +671,26 @@ namespace montauk::abi {
|
||||
uint16_t beaconInterval; // TU
|
||||
};
|
||||
|
||||
// Association progress reported in WifiInfo.connState.
|
||||
static constexpr uint32_t WIFI_CONN_IDLE = 0;
|
||||
static constexpr uint32_t WIFI_CONN_CONTEXTS_UP = 1;
|
||||
static constexpr uint32_t WIFI_CONN_AUTHENTICATING = 2;
|
||||
static constexpr uint32_t WIFI_CONN_AUTHENTICATED = 3;
|
||||
static constexpr uint32_t WIFI_CONN_ASSOCIATING = 4;
|
||||
static constexpr uint32_t WIFI_CONN_ASSOCIATED = 5;
|
||||
static constexpr uint32_t WIFI_CONN_HANDSHAKING = 6;
|
||||
static constexpr uint32_t WIFI_CONN_CONNECTED = 7;
|
||||
static constexpr uint32_t WIFI_CONN_FAILED = 8;
|
||||
|
||||
// Negative results from SYS_WIFI_CONNECT.
|
||||
static constexpr int WIFI_ERR_NO_ADAPTER = -1; // no adapter, or not ready
|
||||
static constexpr int WIFI_ERR_NOT_FOUND = -2; // SSID absent from the scan
|
||||
static constexpr int WIFI_ERR_NEED_KEY = -3; // encrypted, no passphrase
|
||||
static constexpr int WIFI_ERR_UNSUPPORTED = -4; // WPA3-SAE, WEP, enterprise
|
||||
static constexpr int WIFI_ERR_AUTH = -5; // key exchange rejected
|
||||
static constexpr int WIFI_ERR_TIMEOUT = -6; // AP never answered
|
||||
static constexpr int WIFI_ERR_FAILED = -7; // anything else
|
||||
|
||||
// Adapter status (returned by SYS_WIFI_INFO).
|
||||
struct WifiInfo {
|
||||
uint8_t mac[6];
|
||||
@@ -682,7 +702,12 @@ namespace montauk::abi {
|
||||
char fwVersion[32];
|
||||
uint64_t rxPackets;
|
||||
uint32_t fwErrors;
|
||||
uint32_t connState; // 0 idle, >0 connection setup in progress
|
||||
uint32_t connState; // WIFI_CONN_*
|
||||
uint64_t txPackets;
|
||||
char ssid[36]; // network joined, empty when disconnected
|
||||
uint8_t bssid[6];
|
||||
uint8_t connected; // 1 once the link can carry IP traffic
|
||||
uint8_t channel;
|
||||
};
|
||||
|
||||
struct ThermalInfo {
|
||||
|
||||
Reference in new issue
Block a user