BIND 10 trac1238, updated. cbe600decbef4db82cb3b070e03b5702540af4aa [1238] IPv4 socket cleanup in IfaceMgr
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Nov 30 17:12:35 UTC 2011
The branch, trac1238 has been updated
via cbe600decbef4db82cb3b070e03b5702540af4aa (commit)
from 936511f6e114f26bf86497466a7f61ef467bf5ad (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cbe600decbef4db82cb3b070e03b5702540af4aa
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Wed Nov 30 18:12:05 2011 +0100
[1238] IPv4 socket cleanup in IfaceMgr
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/iface_mgr.cc | 46 +++++++++-------------------
src/bin/dhcp6/tests/iface_mgr_unittest.cc | 5 ++-
2 files changed, 18 insertions(+), 33 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/iface_mgr.cc b/src/bin/dhcp6/iface_mgr.cc
index f1eb834..e523eb2 100644
--- a/src/bin/dhcp6/iface_mgr.cc
+++ b/src/bin/dhcp6/iface_mgr.cc
@@ -300,42 +300,16 @@ IfaceMgr::openSocket4(Iface& iface, const IOAddress& addr, int port) {
<< "/port=" << port);
}
-#if defined(SO_BINDTODEVICE)
-#if 0
- /// For some reason that doesn't work. It's not a big deal as this is
- /// Linux only feature. We can use IP_PKTINFO to check that we received
- /// packet over proper interface.
-
- // Bind this socket to this interface.
- const char* ifname = iface.getName().c_str();
- int len = strlen(ifname);
- if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
- ifname, len) < 0) {
- isc_throw(Unexpected, "setsockopt: SO_BINDTODEVICE failed.");
- }
-#endif
-#endif
-
+ // if there is no support for IP_PKTINFO, we are really out of luck
+ // it will be difficult to undersand, where this packet came from
+#if defined(IP_PKTINFO)
int flag = 1;
-#ifdef IP_RECVPKTINFO
- if (setsockopt(sock, IPPROTO_IP, IP_RECVPKTINFO,
- &flag, sizeof(flag)) != 0) {
- close(sock);
- isc_throw(Unexpected, "setsockopt: IP_RECVPKTINFO failed.")
- }
-#elif defined(IP_PKTINFO)
- /* RFC2292 - an old way */
- if (setsockopt(sock, IPPROTO_IP, IP_PKTINFO,
- &flag, sizeof(flag)) != 0) {
+ if (setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &flag, sizeof(flag)) != 0) {
close(sock);
isc_throw(Unexpected, "setsockopt: IP_PKTINFO: failed.");
}
-#else
- // "Neither IP_RECVPKTINFO nor IP_PKTINFO defined. Cannot continue"
- flag = 1; // just to avoid compilation warnings about unused flag variable
#endif
-
cout << "Created socket " << sock << " on " << iface.getName() << "/" <<
addr.toText() << "/port=" << port << endl;
@@ -528,9 +502,19 @@ IfaceMgr::send(boost::shared_ptr<Pkt6>& pkt) {
return (result);
}
+bool
+IfaceMgr::send(boost::shared_ptr<Pkt4>& )
+{
+ /// TODO: Implement this (ticket #1240)
+ isc_throw(Unexpected, "Pkt4 send not implemented yet.");
+}
+
+
boost::shared_ptr<Pkt4>
IfaceMgr::receive4() {
- // TODO: To be implemented
+ isc_throw(Unexpected, "Pkt4 reception not implemented yet.");
+
+ // TODO: To be implemented (ticket #1239)
return (boost::shared_ptr<Pkt4>()); // NULL
}
diff --git a/src/bin/dhcp6/tests/iface_mgr_unittest.cc b/src/bin/dhcp6/tests/iface_mgr_unittest.cc
index 047f00f..67e0ed6 100644
--- a/src/bin/dhcp6/tests/iface_mgr_unittest.cc
+++ b/src/bin/dhcp6/tests/iface_mgr_unittest.cc
@@ -371,9 +371,9 @@ TEST_F(IfaceMgrTest, socket4) {
createLoInterfacesTxt();
NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
- // let's assume that every supported OS have lo interface
+ // Let's assume that every supported OS have lo interface.
IOAddress loAddr("127.0.0.1");
- // use unprivileged port (it's convenient for running tests as non-root)
+ // Use unprivileged port (it's convenient for running tests as non-root).
int socket1 = 0;
EXPECT_NO_THROW(
@@ -385,6 +385,7 @@ TEST_F(IfaceMgrTest, socket4) {
Pkt4 pkt(DHCPDISCOVER, 1234);
pkt.setIface(LOOPBACK);
+ // Expect that we get the socket that we just opened.
EXPECT_EQ(socket1, ifacemgr->getSocket(pkt));
close(socket1);
More information about the bind10-changes
mailing list