Commit 4ba24504 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[master] Merge branch 'nchaigne-master' (Github #1)

parents 59159417 0d966bce
...@@ -226,9 +226,8 @@ PktFilterInet::send(const Iface&, uint16_t sockfd, ...@@ -226,9 +226,8 @@ PktFilterInet::send(const Iface&, uint16_t sockfd,
// Setting the interface is a bit more involved. // Setting the interface is a bit more involved.
// //
// We have to create a "control message", and set that to // We have to create a "control message", and set that to
// define the IPv4 packet information. We could set the // define the IPv4 packet information. We set the source address
// source address if we wanted, but we can safely let the // to handle correctly interfaces with multiple addresses.
// kernel decide what that should be.
m.msg_control = &control_buf_[0]; m.msg_control = &control_buf_[0];
m.msg_controllen = control_buf_len_; m.msg_controllen = control_buf_len_;
struct cmsghdr* cmsg = CMSG_FIRSTHDR(&m); struct cmsghdr* cmsg = CMSG_FIRSTHDR(&m);
...@@ -238,6 +237,7 @@ PktFilterInet::send(const Iface&, uint16_t sockfd, ...@@ -238,6 +237,7 @@ PktFilterInet::send(const Iface&, uint16_t sockfd,
struct in_pktinfo* pktinfo =(struct in_pktinfo *)CMSG_DATA(cmsg); struct in_pktinfo* pktinfo =(struct in_pktinfo *)CMSG_DATA(cmsg);
memset(pktinfo, 0, sizeof(struct in_pktinfo)); memset(pktinfo, 0, sizeof(struct in_pktinfo));
pktinfo->ipi_ifindex = pkt->getIndex(); pktinfo->ipi_ifindex = pkt->getIndex();
pktinfo->ipi_spec_dst.s_addr = htonl(pkt->getLocalAddr()); // set the source IP address
m.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); m.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
#endif #endif
......
Markdown is supported
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