clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.

This commit is contained in:
maksw committed 2026-10-12 18:17:43 +02:00
1 parent 899225f551
commit c0ad63c27f
226 files changed
+6562 -4147

No files matched your search

+29 -28
View File
@@ -1,5 +1,6 @@
// lwIP stack provider glue. This file bridges the kernel network-device model into lwIP.
#include <ntlite/atomic.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
@@ -77,7 +78,7 @@ typedef struct LWIP_ATTACH_CTX {
typedef struct LWIP_RESOLVE_CONTEXT {
SEMAPHORE* Done;
volatile long References;
volatile int32_t References;
err_t Result;
u8_t DnsType;
ip_addr_t Address;
@@ -167,12 +168,12 @@ static KSTATUS LwipErrToStatus(err_t err) {
}
// Implements the ascii Is Digit operation.
static int LwipAsciiIsDigit(char c) {
static bool LwipAsciiIsDigit(char c) {
return c >= '0' && c <= '9';
}
// Parses ipv4 Part.
static int LwipParseIpv4Part(const char** cursor, uint8_t* out) {
static bool LwipParseIpv4Part(const char** cursor, uint8_t* out) {
const char* p = *cursor;
uint32_t value = 0;
uint32_t digits = 0;
@@ -180,37 +181,37 @@ static int LwipParseIpv4Part(const char** cursor, uint8_t* out) {
while (LwipAsciiIsDigit(*p)) {
value = value * 10u + (uint32_t)(*p - '0');
if (value > 255u)
return 0;
return false;
p++;
digits++;
}
if (digits == 0)
return 0;
return false;
*out = (uint8_t)value;
*cursor = p;
return 1;
return true;
}
// Parses ipv4.
static int LwipParseIpv4(const char* text, ip4_addr_t* out) {
static bool LwipParseIpv4(const char* text, ip4_addr_t* out) {
if (!text || !out)
return 0;
return false;
const char* p = text;
uint8_t a = 0, b = 0, c = 0, d = 0;
if (!LwipParseIpv4Part(&p, &a) || *p++ != '.') return 0;
if (!LwipParseIpv4Part(&p, &b) || *p++ != '.') return 0;
if (!LwipParseIpv4Part(&p, &c) || *p++ != '.') return 0;
if (!LwipParseIpv4Part(&p, &d) || *p != '\0') return 0;
if (!LwipParseIpv4Part(&p, &a) || *p++ != '.') return false;
if (!LwipParseIpv4Part(&p, &b) || *p++ != '.') return false;
if (!LwipParseIpv4Part(&p, &c) || *p++ != '.') return false;
if (!LwipParseIpv4Part(&p, &d) || *p != '\0') return false;
IP4_ADDR(out, a, b, c, d);
return 1;
return true;
}
static KSTATUS LwipGetSettingIpv4(const char* section, const char* key,
ip4_addr_t* out, int required) {
ip4_addr_t* out, bool required) {
char value[LWIP_SETTINGS_VALUE_MAX];
KSTATUS st = KeGetSettingString(section, key, value, sizeof(value));
if (st == NTLSTATUS_NOT_FOUND && !required)
@@ -225,7 +226,7 @@ static KSTATUS LwipGetSettingIpv4(const char* section, const char* key,
}
static KSTATUS LwipGetSettingIpv6(const char* section, const char* key,
ip6_addr_t* out, int required) {
ip6_addr_t* out, bool required) {
char value[LWIP_SETTINGS_VALUE_MAX];
KSTATUS st = KeGetSettingString(section, key, value, sizeof(value));
if (st == NTLSTATUS_NOT_FOUND && !required)
@@ -308,13 +309,13 @@ static KSTATUS LwipLoadConfigFromSection(const char* section, LWIP_NETIF_CONFIG*
if (strcmp(mode, "static") == 0) {
cfg->UseDhcp = 0;
st = LwipGetSettingIpv4(section, "address", &cfg->Address, 1);
st = LwipGetSettingIpv4(section, "address", &cfg->Address, true);
if (!KSUCCESS(st)) return st;
st = LwipGetSettingIpv4(section, "netmask", &cfg->Netmask, 1);
st = LwipGetSettingIpv4(section, "netmask", &cfg->Netmask, true);
if (!KSUCCESS(st)) return st;
st = LwipGetSettingIpv4(section, "gateway", &cfg->Gateway, 1);
st = LwipGetSettingIpv4(section, "gateway", &cfg->Gateway, true);
if (!KSUCCESS(st)) return st;
st = LwipGetSettingIpv4(section, "dns", &cfg->Dns4, 1);
st = LwipGetSettingIpv4(section, "dns", &cfg->Dns4, true);
if (!KSUCCESS(st)) return st;
cfg->HasDns4 = 1;
return LwipLoadIpv6Config(section, cfg);
@@ -322,7 +323,7 @@ static KSTATUS LwipLoadConfigFromSection(const char* section, LWIP_NETIF_CONFIG*
if (strcmp(mode, "dhcp") == 0) {
cfg->UseDhcp = 1;
st = LwipGetSettingIpv4(section, "dns", &cfg->Dns4, 0);
st = LwipGetSettingIpv4(section, "dns", &cfg->Dns4, false);
if (KSUCCESS(st))
cfg->HasDns4 = 1;
else if (st != NTLSTATUS_NOT_FOUND)
@@ -449,7 +450,7 @@ static KSTATUS LwipSocketAllocateWithConn(uint32_t domain, uint32_t type, uint32
// Returns whether the IRP cancel token has been set by SysCancelIo.
static int LwipSocketCancelRequested(volatile uint8_t* cancelRequested) {
static bool LwipSocketCancelRequested(volatile uint8_t* cancelRequested) {
return cancelRequested && *cancelRequested;
}
@@ -552,22 +553,22 @@ static KSTATUS LwipSocketWaitAccept(LWIP_PROVIDER_SOCKET* s,
}
}
static int LwipSocketAddressValid(const SYS_SOCKET_ADDRESS_K* address, size_t addressSize) {
static bool LwipSocketAddressValid(const SYS_SOCKET_ADDRESS_K* address, size_t addressSize) {
if (!address || addressSize != sizeof(SYS_SOCKET_ADDRESS_K))
return 0;
return false;
if (address->Size != sizeof(SYS_SOCKET_ADDRESS_K))
return 0;
return false;
return address->Family == SYS_AF_INET || address->Family == SYS_AF_INET6;
}
static int LwipSocketFamilyMatches(const LWIP_PROVIDER_SOCKET* s, const SYS_SOCKET_ADDRESS_K* address) {
static bool LwipSocketFamilyMatches(const LWIP_PROVIDER_SOCKET* s, const SYS_SOCKET_ADDRESS_K* address) {
if (!s || !address)
return 0;
return false;
if (s->Domain == SYS_AF_INET)
return address->Family == SYS_AF_INET;
if (s->Domain == SYS_AF_INET6)
return address->Family == SYS_AF_INET6;
return 0;
return false;
}
// Implements the socket Make Ip operation.
@@ -1613,7 +1614,7 @@ static void LwipResolveRelease(LWIP_RESOLVE_CONTEXT* context) {
if (!context)
return;
if (_InterlockedDecrement(&context->References) != 0)
if (NtlAtomicDecrement32(&context->References) != 0)
return;
if (context->Done)