From 4818d3b627706446f8800f46d344653a9d64f92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 6 Dec 2006 18:38:08 +0000 Subject: [PATCH] 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 --- src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp index 8cc747bbf7..aa02c1c2ac 100644 --- a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp +++ b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp @@ -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);