IPv4 send_routed_data() can now also work with a route whose address is NULL; this

is useful for bringing up (and using) an unconfigured interface. Specifically, DHCP
will be using this method to get the broadcast out.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19435 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-12-06 18:38:08 +00:00
parent f17a85d17d
commit 4818d3b627

View File

@ -859,7 +859,7 @@ ipv4_send_routed_data(net_protocol *_protocol, struct net_route *route,
TRACE(("someone tries to send some actual routed data!\n"));
sockaddr_in &source = *(sockaddr_in *)&buffer->source;
if (source.sin_addr.s_addr == INADDR_ANY) {
if (source.sin_addr.s_addr == INADDR_ANY && route->interface->address != NULL) {
// replace an unbound source address with the address of the interface
// TODO: couldn't we replace all addresses here?
source.sin_addr.s_addr = ((sockaddr_in *)route->interface->address)->sin_addr.s_addr;
@ -883,8 +883,12 @@ ipv4_send_routed_data(net_protocol *_protocol, struct net_route *route,
header.time_to_live = 254;
header.protocol = protocol ? protocol->socket->protocol : buffer->protocol;
header.checksum = 0;
header.source = ((sockaddr_in *)route->interface->address)->sin_addr.s_addr;
// always use the actual used source address
if (route->interface->address != NULL) {
header.source = ((sockaddr_in *)route->interface->address)->sin_addr.s_addr;
// always use the actual used source address
} else
header.source = 0;
header.destination = ((sockaddr_in *)&buffer->destination)->sin_addr.s_addr;
header.checksum = gBufferModule->checksum(buffer, 0, sizeof(ipv4_header), true);