From 63b69bec3cbe0b379687dbf80cd1f7c740755a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 19 Feb 2010 16:44:55 +0000 Subject: [PATCH] =?UTF-8?q?*=20Applied=20patch=20by=20Andreas=20F=C3=83?= =?UTF-8?q?=C2=A4rber=20as=20part=20of=20#5319.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35522 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/net/IP.h | 1 + src/system/boot/loader/net/IP.cpp | 22 +++++++++++++++ .../boot/platform/openfirmware/network.cpp | 27 +++---------------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/headers/private/kernel/boot/net/IP.h b/headers/private/kernel/boot/net/IP.h index cc6a38e91e..46d5ae6633 100644 --- a/headers/private/kernel/boot/net/IP.h +++ b/headers/private/kernel/boot/net/IP.h @@ -59,6 +59,7 @@ private: }; uint16 ip_checksum(ChainBuffer *buffer); +ip_addr_t ip_parse_address(const char* address); #endif // _BOOT_IP_H diff --git a/src/system/boot/loader/net/IP.cpp b/src/system/boot/loader/net/IP.cpp index 807fb346b4..0c43f4bcb1 100644 --- a/src/system/boot/loader/net/IP.cpp +++ b/src/system/boot/loader/net/IP.cpp @@ -266,3 +266,25 @@ ip_checksum(ChainBuffer *buffer) return ~checksum; } + + +ip_addr_t +ip_parse_address(const char *string) +{ + ip_addr_t address = 0; + int components = 0; + + // TODO: Handles only IPv4 addresses for now. + while (components < 4) { + address |= strtol(string, NULL, 0) << ((4 - components - 1) * 8); + + const char *dot = strchr(string, '.'); + if (dot == NULL) + break; + + string = dot + 1; + components++; + } + + return address; +} diff --git a/src/system/boot/platform/openfirmware/network.cpp b/src/system/boot/platform/openfirmware/network.cpp index 4702bae5a2..4320963e6f 100644 --- a/src/system/boot/platform/openfirmware/network.cpp +++ b/src/system/boot/platform/openfirmware/network.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -76,28 +77,6 @@ hex_dump(const void *_data, int length) #endif // !TRACE_NETWORK -static ip_addr_t -parse_ip_address(const char *string) -{ - ip_addr_t address = 0; - int components = 0; - - // TODO: Handles only IPv4 addresses for now. - while (components < 4) { - address |= strtol(string, NULL, 0) << ((4 - components - 1) * 8); - - const char *dot = strchr(string, '.'); - if (dot == NULL) - break; - - string = dot + 1; - components++; - } - - return address; -} - - // #pragma mark - @@ -165,7 +144,7 @@ OFEthernetInterface::Init(const char *device, const char *parameters) if (parameters != NULL) { char *comma = strrchr(parameters, ','); if (comma != NULL && comma != strchr(parameters, ',')) { - SetIPAddress(parse_ip_address(comma + 1)); + SetIPAddress(ip_parse_address(comma + 1)); } } if (fIPAddress == 0) { @@ -176,7 +155,7 @@ OFEthernetInterface::Init(const char *device, const char *parameters) defaultClientIP, sizeof(defaultClientIP) - 1); if (bytesRead != OF_FAILED && bytesRead > 1) { defaultClientIP[bytesRead] = '\0'; - ip_addr_t address = parse_ip_address(defaultClientIP); + ip_addr_t address = ip_parse_address(defaultClientIP); SetIPAddress(address); } }