if (client_id) {
answer->addOption(client_id);
}
+
+ // If src/dest HW addresses are used by the packet filtering class
+ // we need to copy them as well.
+ HWAddrPtr src_hw_addr = question->getLocalHWAddr();
+ HWAddrPtr dst_hw_addr = question->getRemoteHWAddr();
+ if (src_hw_addr) {
+ answer->setRemoteHWAddr(src_hw_addr);
+ }
+ if (dst_hw_addr) {
+ answer->setLocalHWAddr(dst_hw_addr);
+ }
}
void
EXPECT_EQ(q->getIface(), a->getIface());
EXPECT_EQ(q->getIndex(), a->getIndex());
EXPECT_EQ(q->getGiaddr(), a->getGiaddr());
+ // When processing an incoming packet the remote address
+ // is copied as a src address, and the source address is
+ // copied as a remote address to the response.
+ EXPECT_TRUE(q->getLocalHWAddr() == a->getRemoteHWAddr());
+ EXPECT_TRUE(q->getRemoteHWAddr() == a->getLocalHWAddr());
// Check that bare minimum of required options are there.
// We don't check options requested by a client. Those
mac[i] = i*10;
}
+ vector<uint8_t> dst_mac(6);
+ for (int i = 0; i < 6; i++) {
+ dst_mac[i] = i * 20;
+ }
+
boost::shared_ptr<Pkt4> req(new Pkt4(msg_type, 1234));
boost::shared_ptr<Pkt4> rsp;
req->setIface("eth0");
req->setIndex(17);
+ req->setRemoteHWAddr(1, 6, dst_mac);
req->setHWAddr(1, 6, mac);
+ req->setLocalHWAddr(1, 6, mac);
req->setRemoteAddr(IOAddress(client_addr));
req->setGiaddr(relay_addr);
pkt->setRemoteAddr(dummy_pkt->getRemoteAddr());
pkt->setLocalPort(dummy_pkt->getLocalPort());
pkt->setRemotePort(dummy_pkt->getRemotePort());
+ pkt->setLocalHWAddr(dummy_pkt->getLocalHWAddr());
+ pkt->setRemoteHWAddr(dummy_pkt->getRemoteHWAddr());
return (pkt);
}
OutputBuffer buf(14);
// Ethernet frame header
- std::vector<uint8_t> dest_addr = pkt->getHWAddr()->hwaddr_;
- if (dest_addr.empty()) {
+ HWAddrPtr hwaddr = pkt->getRemoteHWAddr();
+ std::vector<uint8_t> dest_addr;
+ if (!hwaddr) {
dest_addr.resize(HWAddr::ETHERNET_HWADDR_LEN);
+ } else {
+ dest_addr = pkt->getRemoteHWAddr()->hwaddr_;
}
writeEthernetHeader(iface.getMac(), &dest_addr[0], buf);