Author: axeld Date: 2010-02-19 17:44:55 +0100 (Fri, 19 Feb 2010) New Revision: 35522 Changeset: http://dev.haiku-os.org/changeset/35522/haiku Ticket: http://dev.haiku-os.org/ticket/5319 Modified: haiku/trunk/headers/private/kernel/boot/net/IP.h haiku/trunk/src/system/boot/loader/net/IP.cpp haiku/trunk/src/system/boot/platform/openfirmware/network.cpp Log: * Applied patch by Andreas F?\195?\131?\194?\164rber as part of #5319. Modified: haiku/trunk/headers/private/kernel/boot/net/IP.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/net/IP.h 2010-02-19 13:45:33 UTC (rev 35521) +++ haiku/trunk/headers/private/kernel/boot/net/IP.h 2010-02-19 16:44:55 UTC (rev 35522) @@ -59,6 +59,7 @@ }; uint16 ip_checksum(ChainBuffer *buffer); +ip_addr_t ip_parse_address(const char* address); #endif // _BOOT_IP_H Modified: haiku/trunk/src/system/boot/loader/net/IP.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/net/IP.cpp 2010-02-19 13:45:33 UTC (rev 35521) +++ haiku/trunk/src/system/boot/loader/net/IP.cpp 2010-02-19 16:44:55 UTC (rev 35522) @@ -266,3 +266,25 @@ 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; +} Modified: haiku/trunk/src/system/boot/platform/openfirmware/network.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/network.cpp 2010-02-19 13:45:33 UTC (rev 35521) +++ haiku/trunk/src/system/boot/platform/openfirmware/network.cpp 2010-02-19 16:44:55 UTC (rev 35522) @@ -15,6 +15,7 @@ #include <boot/platform.h> #include <boot/net/Ethernet.h> +#include <boot/net/IP.h> #include <boot/net/NetStack.h> #include <platform/openfirmware/openfirmware.h> @@ -76,28 +77,6 @@ #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 @@ 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 @@ 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); } }