From fd95a7e124618eb249769ce3ff6d7a16aeb873e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 28 Dec 2008 22:18:21 +0000 Subject: [PATCH] * The net_server now accepts messages from the outside that want to configure an interface (I don't remember why I didn't want this earlier, but well). * ifconfig now has an auto-config option that will trigger DHCP. * Also, it will now remove the IFF_AUTO_CONFIGURED and IFF_CONFIGURING flags if an address is specified (any on-going auto-configuration should check for these and abort if they aren't there anymore). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28831 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/network/ifconfig/Jamfile | 6 +- src/bin/network/ifconfig/ifconfig.cpp | 135 +++++++++++++++++++------- src/servers/net/NetServer.cpp | 28 +++--- src/servers/net/NetServer.h | 4 +- 4 files changed, 122 insertions(+), 51 deletions(-) diff --git a/src/bin/network/ifconfig/Jamfile b/src/bin/network/ifconfig/Jamfile index c0890f13e2..bd91da3c02 100644 --- a/src/bin/network/ifconfig/Jamfile +++ b/src/bin/network/ifconfig/Jamfile @@ -6,9 +6,11 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { # Unfortunately we get more than we want, namely all POSIX headers. } +UseHeaders [ FDirName $(HAIKU_TOP) src servers net ] : true ; + BinCommand ifconfig : ifconfig.cpp - : libnetwork.so + : be network ; # Installation -- in the test directory for the time being @@ -16,7 +18,7 @@ HaikuInstall install-networking : [ FDirName $(HAIKU_TEST_DIR) kits net ] : ifconfig ; -HaikuInstall install-userland-networking +HaikuInstall install-userland-networking : [ FDirName $(HAIKU_TEST_DIR) kits net userland ] : ifconfig : installed-userland-networking diff --git a/src/bin/network/ifconfig/ifconfig.cpp b/src/bin/network/ifconfig/ifconfig.cpp index ea13c5612a..021672bf0a 100644 --- a/src/bin/network/ifconfig/ifconfig.cpp +++ b/src/bin/network/ifconfig/ifconfig.cpp @@ -8,7 +8,8 @@ */ -#include +#include +#include #include #include @@ -25,6 +26,8 @@ #include #include +#include + extern const char* __progname; const char* kProgramName = __progname; @@ -63,7 +66,7 @@ inet_parse_address(const char* string, sockaddr* _address) return false; sockaddr_in& address = *(sockaddr_in *)_address; - address.sin_family = AF_INET; + address.sin_family = AF_INET; address.sin_len = sizeof(struct sockaddr_in); address.sin_port = 0; address.sin_addr = inetAddress; @@ -77,7 +80,7 @@ static void inet_print_address(sockaddr* _address) { sockaddr_in& address = *(sockaddr_in *)_address; - + if (address.sin_family != AF_INET) return; @@ -153,7 +156,7 @@ media_parse_subtype(const char* string, int media, int* type) { for (int32 i = 0; kMediaTypes[i].type >= 0; i++) { // only check for generic or correct subtypes - if (kMediaTypes[i].type && + if (kMediaTypes[i].type && kMediaTypes[i].type != media) continue; for (int32 j = 0; kMediaTypes[i].subtypes[j].subtype >= 0; j++) { @@ -174,7 +177,8 @@ media_parse_subtype(const char* string, int media, int* type) void usage(int status) { - printf("usage: %s [ [
] [
[]] [