summaryrefslogtreecommitdiff
path: root/src/user/app/ethdump/ethdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/ethdump/ethdump.c')
-rw-r--r--src/user/app/ethdump/ethdump.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/user/app/ethdump/ethdump.c b/src/user/app/ethdump/ethdump.c
index 4047962..17592a1 100644
--- a/src/user/app/ethdump/ethdump.c
+++ b/src/user/app/ethdump/ethdump.c
@@ -5,6 +5,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+#include <user/lib/thread.h>
struct net_state state = {
// TODO dynamically get mac
@@ -12,23 +13,29 @@ struct net_state state = {
.ip = (192 << 24) + (168 << 16) + 11,
};
-int main(void) {
- const char *path = "/kdev/eth";
- state.raw_h = _syscall_open(path, strlen(path), 0);
- if (state.raw_h < 0) {
- eprintf("couldn't open %s", path);
- return 1;
- }
-
+void network_thread(void *arg) { (void)arg;
const size_t buflen = 4096;
char *buf = malloc(buflen);
for (;;) {
long ret = _syscall_read(state.raw_h, buf, buflen, -1);
if (ret < 0) break;
- printf("\npacket of length %u\n", ret);
- hexdump(buf, ret);
ether_parse((void*)buf, ret);
}
free(buf);
+}
+
+void fs_thread(void *arg);
+
+int main(void) {
+ const char *path = "/kdev/eth";
+ state.raw_h = _syscall_open(path, strlen(path), 0);
+ if (state.raw_h < 0) {
+ eprintf("couldn't open %s", path);
+ return 1;
+ }
+
+ thread_create(0, network_thread, NULL);
+ thread_create(0, fs_thread, NULL);
+ _syscall_await();
return 0;
}