Ticket #5189: network-ipaddress-v2.diff
File network-ipaddress-v2.diff, 2.5 KB (added by , 14 years ago) |
---|
-
src/system/boot/platform/openfirmware/network.cpp
diff --git a/src/system/boot/platform/openfirmware/network.cpp b/src/system/boot/platform/openfirmware/network.cpp index 0323546..5ae82d2 100644
a b 1 1 /* 2 2 * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * Copyright 2010, Andreas Faerber <andreas.faerber@web.de> 3 4 * All rights reserved. Distributed under the terms of the MIT License. 4 5 */ 5 6 … … public: 31 32 OFEthernetInterface(); 32 33 virtual ~OFEthernetInterface(); 33 34 34 status_t Init(const char *device );35 status_t Init(const char *device, const char *parameters); 35 36 36 37 virtual mac_addr_t MACAddress() const; 37 38 … … OFEthernetInterface::~OFEthernetInterface() 117 118 118 119 119 120 status_t 120 OFEthernetInterface::Init(const char *device )121 OFEthernetInterface::Init(const char *device, const char *parameters) 121 122 { 122 123 if (!device) 123 124 return B_BAD_VALUE; … … OFEthernetInterface::Init(const char *device) 160 161 if (bytesRead != OF_FAILED && bytesRead == (int)sizeof(dhcpResponse)) { 161 162 SetIPAddress(ntohl(dhcpResponse.ip_address)); 162 163 } else { 163 char saddr[16]; 164 package = of_finddevice("/options"); 165 bytesRead = of_getprop(package, "default-client-ip", saddr, 166 sizeof(saddr)); 167 if (bytesRead != OF_FAILED) { 168 saddr[bytesRead] = '\0'; 169 printf("default-client-ip: %s\n", saddr); 170 ip_addr_t addr = parse_ip_address(saddr); 171 printf("addr = %x\n", (unsigned int)addr); 172 SetIPAddress(addr); 164 // try to read manual client IP from boot path 165 if (parameters != NULL) { 166 char *comma = strrchr(parameters, ','); 167 if (comma != NULL && comma != strchr(parameters, ',')) { 168 SetIPAddress(parse_ip_address(comma + 1)); 169 } 170 } 171 if (fIPAddress == 0) { 172 // try to read default-client-ip setting 173 char defaultClientIP[16]; 174 package = of_finddevice("/options"); 175 bytesRead = of_getprop(package, "default-client-ip", 176 defaultClientIP, sizeof(defaultClientIP) - 1); 177 if (bytesRead != OF_FAILED && bytesRead > 1) { 178 defaultClientIP[bytesRead] = '\0'; 179 ip_addr_t address = parse_ip_address(defaultClientIP); 180 SetIPAddress(address); 181 } 173 182 } 174 183 } 175 184 … … platform_net_stack_init() 278 287 if (!interface) 279 288 return B_NO_MEMORY; 280 289 281 status_t error = interface->Init(bootPath );290 status_t error = interface->Init(bootPath, parameters + 1); 282 291 if (error != B_OK) { 283 292 delete interface; 284 293 return error;