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
+98
-30
@@ -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;
|
||||
@@ -97,21 +132,54 @@ static bool parse_port(const char* s, uint16_t* out) {
|
||||
// Implements the usage operation.
|
||||
static void usage(void) {
|
||||
print("usage:\n");
|
||||
print(" udp.exe send <ipv4> <port> [message]\n");
|
||||
print(" udp.exe listen <port>\n");
|
||||
print(" udp.exe send <host|address> <port> [message]\n");
|
||||
print(" udp.exe listen [-4|-6] <port>\n");
|
||||
print("examples:\n");
|
||||
print(" udp.exe send 10.0.2.2 9999 hello\n");
|
||||
print(" udp.exe listen 9999\n");
|
||||
print(" udp.exe send ::1 9999 hello\n");
|
||||
print(" udp.exe listen -6 9999\n");
|
||||
}
|
||||
|
||||
// Resolves an IPv4 or IPv6 destination.
|
||||
static uint32_t resolve_address(const char* text, SYS_SOCKET_ADDRESS* out) {
|
||||
uint8_t ip[4];
|
||||
if (parse_ipv4(text, ip)) {
|
||||
memset(out, 0, sizeof(*out));
|
||||
out->Size = sizeof(*out);
|
||||
out->Family = SYS_AF_INET;
|
||||
memcpy(out->Address, ip, 4);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SYS_RESOLVE_HOST_REQUEST req;
|
||||
size_t addressSize = sizeof(*out);
|
||||
memset(out, 0, sizeof(*out));
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.Name = SysSvFromCstr(text);
|
||||
req.Family = SYS_AF_INET6;
|
||||
req.AddressOut = out;
|
||||
req.AddressSizeInOut = &addressSize;
|
||||
|
||||
uint32_t status = SysResolveHost(&req);
|
||||
if (status == STATUS_SUCCESS)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
addressSize = sizeof(*out);
|
||||
memset(out, 0, sizeof(*out));
|
||||
req.Family = SYS_AF_INET;
|
||||
return SysResolveHost(&req);
|
||||
}
|
||||
|
||||
// Runs send.
|
||||
static int run_send(const char* cmd) {
|
||||
char tok[256];
|
||||
uint8_t ip[4];
|
||||
SYS_SOCKET_ADDRESS remote;
|
||||
uint16_t port = 0;
|
||||
|
||||
cmd = next_token(cmd, tok, sizeof(tok));
|
||||
if (!tok[0] || !parse_ipv4(tok, ip)) { usage(); return 1; }
|
||||
if (!tok[0]) { usage(); return 1; }
|
||||
uint32_t status = resolve_address(tok, &remote);
|
||||
if (status != STATUS_SUCCESS) { print("udp: resolve failed "); print_u64(status); print("\n"); return 1; }
|
||||
cmd = next_token(cmd, tok, sizeof(tok));
|
||||
if (!tok[0] || !parse_port(tok, &port)) { usage(); return 1; }
|
||||
|
||||
@@ -128,20 +196,13 @@ static int run_send(const char* cmd) {
|
||||
}
|
||||
|
||||
uint32_t sock = 0;
|
||||
uint32_t st = SysCreateSocket(SYS_AF_INET, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &sock);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
uint32_t st = SysCreateSocket(remote.Family, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &sock);
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("udp: SysCreateSocket failed "); print_u64(st); print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
SYS_SOCKET_ADDRESS_IPV4 remote;
|
||||
memset(&remote, 0, sizeof(remote));
|
||||
remote.Family = SYS_AF_INET;
|
||||
remote.Port = port;
|
||||
remote.Address[0] = ip[0];
|
||||
remote.Address[1] = ip[1];
|
||||
remote.Address[2] = ip[2];
|
||||
remote.Address[3] = ip[3];
|
||||
|
||||
size_t sent = 0;
|
||||
SYS_SOCKET_SEND_TO_REQUEST req;
|
||||
@@ -154,12 +215,12 @@ static int run_send(const char* cmd) {
|
||||
|
||||
st = SysSendToSocket(sock, &req);
|
||||
SysCloseHandle(sock);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("udp: SysSendToSocket failed "); print_u64(st); print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
print("udp: sent "); print_u64(sent); print(" bytes to "); print_ipv4(ip); print(":"); print_u64(port); print("\n");
|
||||
print("udp: sent "); print_u64(sent); print(" bytes to "); print_socket_address(&remote); print("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -167,33 +228,44 @@ static int run_send(const char* cmd) {
|
||||
static int run_listen(const char* cmd) {
|
||||
char tok[64];
|
||||
uint16_t port = 0;
|
||||
uint32_t family = SYS_AF_INET;
|
||||
|
||||
(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;
|
||||
if (rest)
|
||||
(void)next_token(rest, tok, sizeof(tok));
|
||||
else
|
||||
tok[0] = 0;
|
||||
}
|
||||
if (!tok[0] || !parse_port(tok, &port)) { usage(); return 1; }
|
||||
|
||||
uint32_t sock = 0;
|
||||
uint32_t st = SysCreateSocket(SYS_AF_INET, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &sock);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
uint32_t st = SysCreateSocket(family, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &sock);
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("udp: SysCreateSocket failed "); print_u64(st); print("\n");
|
||||
return 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;
|
||||
|
||||
st = SysBindSocket(sock, &bindAddr, sizeof(bindAddr));
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("udp: SysBindSocket failed "); print_u64(st); print("\n");
|
||||
SysCloseHandle(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
print("udp: listening on 0.0.0.0:"); print_u64(port); print(" for one datagram\n");
|
||||
print("udp: listening on ");
|
||||
if (family == SYS_AF_INET6) print("[::]:"); else print("0.0.0.0:");
|
||||
print_u64(port); print(" for one datagram\n");
|
||||
|
||||
char buf[1025];
|
||||
SYS_SOCKET_ADDRESS_IPV4 remote;
|
||||
SYS_SOCKET_ADDRESS remote;
|
||||
size_t remoteSize = sizeof(remote);
|
||||
size_t got = 0;
|
||||
SYS_SOCKET_RECV_FROM_REQUEST req;
|
||||
@@ -206,18 +278,14 @@ static int run_listen(const char* cmd) {
|
||||
|
||||
st = SysRecvFromSocket(sock, &req);
|
||||
SysCloseHandle(sock);
|
||||
if (st != SYS_STATUS_SUCCESS) {
|
||||
if (st != STATUS_SUCCESS) {
|
||||
print("udp: SysRecvFromSocket failed "); print_u64(st); print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf[got] = 0;
|
||||
print("udp: received "); print_u64(got); print(" bytes 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");
|
||||
print(buf);
|
||||
if (got && buf[got - 1] != '\n') print("\n");
|
||||
|
||||
Reference in new issue
Block a user