Commit 1ca6a3ac authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[2902] Do not use the broadcast address as source in server's response.

parent 8b0cb0de
......@@ -110,6 +110,20 @@ PktFilterLPF::send(const Iface& iface, uint16_t sockfd, const Pkt4Ptr& pkt) {
writeEthernetHeader(iface.getMac(), &dest_addr[0], buf);
// It is likely that the local address in pkt object is set to
// broadcast address. This is the case if server received the
// client's packet on broadcast address. Therefore, we need to
// correct it here and assign the actual source address.
if (pkt->getLocalAddr().toText() == "") {
const Iface::SocketCollection& sockets = iface.getSockets();
for (Iface::SocketCollection::const_iterator it = sockets.begin();
it != sockets.end(); ++it) {
if (sockfd == it->sockfd_) {
// IP and UDP header
writeIpUdpHeader(pkt, buf);
......@@ -139,7 +139,12 @@ TEST_F(PktFilterLPFTest, DISABLED_send) {
// Set required fields.
// By setting the local address to broadcast we simulate the
// typical scenario when client's request was send to broadcast
// address and server by default used it as a source address
// in its response. The send() function should be able to detect
// it and correct the source address.
pkt->setLocalPort(PORT + 1);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment