add ntfs.sys standalone driver target, change default usb vhd layout formatting to ntfs, implement Fat32CreateDir for directory creation support in the fat32 file system driver, add a dedicated HAL serial output endpoint for COM1 writes in hal_serial.c and subscribe serial to HAL text streams, introduce waitable kernel timers with KeTimerCreate, KeTimerSet, and KeTimerCancel alongside spinlock-protected global timer list initialization and scheduler tick tracking, implement SyscallWriteFileAsync system call for asynchronous non-blocking file writes, refactor NetSocketConnect and NetSocketSendTo to use generic SYS_SOCKET_ADDRESS_K structures instead of being hardcoded to IPv4, update gethostbyname and DNS name resolution to support IPv6 parsing via ResolveNameFamily, update tcpserve.exe with -4 and -6 command-line flags to accept and display IPv6 addresses, append size and version headers to all kernel telemetry and statistics structures including SYS_PMM_STATS, SYS_CPU_STATS, and SYS_SCHEDULER_STATS, update winmm timeGetTime to look up high-resolution hardware frequencies via SysGetTickFrequency, integrate 14 native smoke test applications.
This commit is contained in:
1 parent
2c4a68a75f
commit
ed3d065abd
156 files changed
+10509
-2643
No files matched your search
@@ -35,6 +35,41 @@ static void print_ipv4(const uint8_t ip[4]) {
|
||||
print_u64(ip[2]); print("."); print_u64(ip[3]);
|
||||
}
|
||||
|
||||
// Prints ipv6.
|
||||
static void print_ipv6(const uint8_t ip[16]) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
uint16_t word = ((uint16_t)ip[i * 2] << 8) | ip[i * 2 + 1];
|
||||
int started = 0;
|
||||
for (int shift = 12; shift >= 0; shift -= 4) {
|
||||
unsigned nibble = (word >> shift) & 0xfu;
|
||||
if (nibble || started || shift == 0) {
|
||||
char c = hex[nibble];
|
||||
print_char(c);
|
||||
started = 1;
|
||||
}
|
||||
}
|
||||
if (i != 7) print(":");
|
||||
}
|
||||
}
|
||||
|
||||
// Prints socket address.
|
||||
static void print_socket_address(const SYS_SOCKET_ADDRESS* address) {
|
||||
if (!address) return;
|
||||
if (address->Family == SYS_AF_INET) {
|
||||
print_ipv4(address->Address);
|
||||
print(":");
|
||||
print_u64(address->Port);
|
||||
} else if (address->Family == SYS_AF_INET6) {
|
||||
print("[");
|
||||
print_ipv6(address->Address);
|
||||
print("]:");
|
||||
print_u64(address->Port);
|
||||
} else {
|
||||
print("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the next token operation.
|
||||
static const char* next_token(const char* s, char* out, size_t outSize) {
|
||||
if (!s || !out || outSize == 0) return NULL;
|
||||
@@ -66,19 +101,28 @@ static bool parse_port(const char* s, uint16_t* out) {
|
||||
|
||||
// Implements the usage operation.
|
||||
static void usage(void) {
|
||||
print("usage: tcpserve.exe [port]\n");
|
||||
print("usage: tcpserve.exe [-4|-6] [port]\n");
|
||||
print("default: tcpserve.exe 8080\n");
|
||||
}
|
||||
|
||||
// Runs the requested operation.
|
||||
int main(void) {
|
||||
uint16_t port = 8080;
|
||||
uint32_t family = SYS_AF_INET;
|
||||
|
||||
const char* cmd = SysGetPeb()->CommandLine.Data;
|
||||
char tok[64];
|
||||
cmd = next_token(cmd, tok, sizeof(tok)); // program path
|
||||
if (cmd) {
|
||||
(void)next_token(cmd, tok, sizeof(tok));
|
||||
const char* rest = next_token(cmd, tok, sizeof(tok));
|
||||
if (strcmp(tok, "-4") == 0 || strcmp(tok, "-6") == 0) {
|
||||
family = strcmp(tok, "-6") == 0 ? SYS_AF_INET6 : SYS_AF_INET;
|
||||
cmd = rest;
|
||||
if (cmd)
|
||||
(void)next_token(cmd, tok, sizeof(tok));
|
||||
else
|
||||
tok[0] = 0;
|
||||
}
|
||||
if (tok[0] && !parse_port(tok, &port)) {
|
||||
usage();
|
||||
SysExitProcess(1);
|
||||
@@ -86,61 +130,55 @@ int main(void) {
|
||||
}
|
||||
|
||||
uint32_t listener = 0;
|
||||
uint32_t st = SysCreateSocket(SYS_AF_INET, SYS_SOCK_STREAM, SYS_IPPROTO_TCP, &listener);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
uint32_t st = SysCreateSocket(family, SYS_SOCK_STREAM, SYS_IPPROTO_TCP, &listener);
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("tcpserve: SysCreateSocket failed "); print_u64(st); print("\n");
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
SYS_SOCKET_ADDRESS_IPV4 bindAddr;
|
||||
SYS_SOCKET_ADDRESS bindAddr;
|
||||
memset(&bindAddr, 0, sizeof(bindAddr));
|
||||
bindAddr.Family = SYS_AF_INET;
|
||||
bindAddr.Size = sizeof(bindAddr);
|
||||
bindAddr.Family = family;
|
||||
bindAddr.Port = port;
|
||||
bindAddr.Address[0] = 0;
|
||||
bindAddr.Address[1] = 0;
|
||||
bindAddr.Address[2] = 0;
|
||||
bindAddr.Address[3] = 0;
|
||||
|
||||
st = SysBindSocket(listener, &bindAddr, sizeof(bindAddr));
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("tcpserve: SysBindSocket failed "); print_u64(st); print("\n");
|
||||
SysCloseHandle(listener);
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
st = SysListenSocket(listener, 4);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("tcpserve: SysListenSocket failed "); print_u64(st); print("\n");
|
||||
SysCloseHandle(listener);
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
print("tcpserve: listening on 0.0.0.0:"); print_u64(port); print("\n");
|
||||
print("tcpserve: listening on ");
|
||||
if (family == SYS_AF_INET6) print("[::]:"); else print("0.0.0.0:");
|
||||
print_u64(port); print("\n");
|
||||
print("tcpserve: accepting one connection...\n");
|
||||
|
||||
SYS_SOCKET_ADDRESS_IPV4 remote;
|
||||
SYS_SOCKET_ADDRESS remote;
|
||||
size_t remoteSize = sizeof(remote);
|
||||
uint32_t client = 0;
|
||||
st = SysAcceptSocket(listener, &remote, &remoteSize, &client);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("tcpserve: SysAcceptSocket failed "); print_u64(st); print("\n");
|
||||
SysCloseHandle(listener);
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
print("tcpserve: accepted from ");
|
||||
if (remote.Family == SYS_AF_INET) {
|
||||
print_ipv4(remote.Address);
|
||||
print(":"); print_u64(remote.Port);
|
||||
} else {
|
||||
print("unknown");
|
||||
}
|
||||
print_socket_address(&remote);
|
||||
print("\n");
|
||||
|
||||
char request[1025];
|
||||
size_t got = 0;
|
||||
st = SysRecvSocket(client, request, sizeof(request) - 1, 0, &got);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("tcpserve: SysRecvSocket failed "); print_u64(st); print("\n");
|
||||
SysCloseHandle(client);
|
||||
SysCloseHandle(listener);
|
||||
@@ -179,9 +217,9 @@ int main(void) {
|
||||
|
||||
size_t sent = 0;
|
||||
st = SysSendSocket(client, response, off, 0, &sent);
|
||||
if (st == SYS_STATUS_SUCCESS)
|
||||
if (st == STATUS_SUCCESS)
|
||||
st = SysSendSocket(client, body, sizeof(body) - 1, 0, &sent);
|
||||
if (st != SYS_STATUS_SUCCESS)
|
||||
if (st != STATUS_SUCCESS)
|
||||
print("tcpserve: SysSendSocket failed "), print_u64(st), print("\n");
|
||||
|
||||
SysShutdownSocket(client, SYS_SHUTDOWN_BOTH);
|
||||
|
||||
Reference in new issue
Block a user