diff options
author | dzwdz | 2022-08-24 12:42:11 +0200 |
---|---|---|
committer | dzwdz | 2022-08-24 12:42:11 +0200 |
commit | 7944d21846ef288fee087159cb244897d5fff4ba (patch) | |
tree | 6bc179323972e51bab5e074f16c1a7822bf0ec4a | |
parent | 039363ede4b868c8ea5cedce89c16123f91b2c05 (diff) |
user/netstack: take ip as argument when mounting
-rw-r--r-- | src/user/app/init/init.c | 2 | ||||
-rw-r--r-- | src/user/app/netstack/netstack.c | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index 7b7afc4..9c3fa39 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -68,7 +68,7 @@ int main(void) { execv(argv[0], (void*)argv); } MOUNT_AT("/net/") { - const char *argv[] = {"/bin/netstack", "/kdev/eth", NULL}; + const char *argv[] = {"/bin/netstack", "/kdev/eth", "192.168.0.11", NULL}; execv(argv[0], (void*)argv); } diff --git a/src/user/app/netstack/netstack.c b/src/user/app/netstack/netstack.c index 0451511..137d9d9 100644 --- a/src/user/app/netstack/netstack.c +++ b/src/user/app/netstack/netstack.c @@ -10,7 +10,6 @@ struct net_state state = { // TODO dynamically get mac .mac = {0x52, 0x54, 0x00, 0xCA, 0x77, 0x1A}, - .ip = (192 << 24) + (168 << 16) + 11, }; void network_thread(void *arg) { (void)arg; @@ -27,10 +26,14 @@ void network_thread(void *arg) { (void)arg; void fs_thread(void *arg); int main(int argc, char **argv) { - if (argc < 2) { - eprintf("no argument"); + if (argc < 3) { + eprintf("usage: netstack iface ip"); return 1; } + if (ip_parse(argv[2], &state.ip) < 0) { + eprintf("invalid ip"); + return -1; + } state.raw_h = _syscall_open(argv[1], strlen(argv[1]), 0); if (state.raw_h < 0) { eprintf("couldn't open %s", argv[1]); |