diff options
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | kernel/features/net.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aab5676..c844724 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,3 +23,5 @@ jobs: run: sh run cross -y - name: Build run: sh run build -y + - name: Test everything + run: sh run test -y diff --git a/kernel/features/net.c b/kernel/features/net.c index 3c1d620..eb22afc 100644 --- a/kernel/features/net.c +++ b/kernel/features/net.c @@ -10,6 +10,7 @@ #include <print.h> #include <rtl8139.h> #include <str.h> +#include <timer.h> static u32 current_ip_addr = ip(10, 0, 2, 15); static u32 gateway_addr = 0; @@ -630,8 +631,11 @@ int net_connect(struct socket *socket, u32 ip_addr, u16 dst_port) tcp_send_packet(socket, TCP_FLAG_SYN, NULL, 0); struct tcp_socket *tcp = &socket->prot.tcp; sti(); - while (tcp->state != 3 && tcp->state != 5) - ; // TODO: Timeout + u32 time = timer_get(); + while (tcp->state != 3 && tcp->state != 5 && timer_get() - time < 1000) + ; + if (tcp->state != 3 && tcp->state != 5) + return 0; } else { return 0; } @@ -668,7 +672,7 @@ void net_install(void) if (net_connect(socket, ip(10, 0, 0, 33), 80)) net_send(socket, strdup(http_req), strlen(http_req)); else - print("Something went wrong!\n"); + print("Couldn't connect!\n"); // Server // TODO: Serve using sockets /* struct socket *socket2 = net_open(S_TCP); */ |