+3XX. [func] tomek
+ libdhcp++: Interface detection in Linux implemented. libdhcp++
+ if now able to detect available network interfaces, its link-layer
+ addresses, flags and configured IPv4 and IPv6 addresses.
+ (Trac #1237, git TBD)
+
+ 3XX. [func] tomek
+ libdhcp++: Transmission and reception of DHCPv4 packets is now
+ implemented. Low-level hacks are not implemented for transmission
+ to hosts that don't have IPv4 address yet, so currently the code
+ is usable for communication with relays only, not hosts on the
+ same link.
+ (Trac #1239, #1240, git TBD)
+
349. [bug] dvv
resolver: If an upstream server responds with FORMERR to an EDNS query,
try querying it without EDNS.
/// @todo: instantiate LeaseMgr here once it is imlpemented.
IfaceMgr::instance().printIfaces();
- #if 0
+ // uncomment this once #1238, #992 and #1239 are merged
IfaceMgr::instance().openSockets4(port);
- #endif
setServerID();
using namespace isc::asiolink;
Dhcpv6Srv::Dhcpv6Srv(uint16_t port) {
-
-//void Dhcpv6Srv::Dhcpv6Srv_impl(uint16_t port) {
cout << "Initialization" << endl;
- // First call to instance() will create IfaceMgr (it's a singleton).
- // It may throw something if things go wrong.
- IfaceMgr::instance();
+ // first call to instance() will create IfaceMgr (it's a singleton)
+ // it may throw something if things go wrong
+ try {
+ IfaceMgr::instance();
+ } catch (const std::exception &e) {
+ cout << "Failed to instantiate InterfaceManager:" << e.what() << ". Aborting." << endl;
+ shutdown = true;
+ }
+
+ if (IfaceMgr::instance().countIfaces() == 0) {
+ cout << "Failed to detect any network interfaces. Aborting." << endl;
+ shutdown = true;
+ }
// Now try to open IPv6 sockets on detected interfaces.
- cout << "Opening sockets on port " << port << endl;
- #if 0
- // uncomment this once #1238, #992 and #1239 are merged
IfaceMgr::instance().openSockets6(port);
- #endif
/// @todo: instantiate LeaseMgr here once it is imlpemented.
}
}
- void IfaceMgr::openSockets6(uint16_t port) {
- int sock1, sock2;
+#if !defined(OS_LINUX) && !defined(OS_BSD)
+void IfaceMgr::detectIfaces() {
+ stubDetectIfaces();
+}
+#endif
+
+ bool IfaceMgr::openSockets4(uint16_t port) {
+ int sock;
+ int count = 0;
- for (IfaceCollection::iterator iface = ifaces_.begin();
- iface != ifaces_.end(); ++iface) {
+ for (IfaceCollection::iterator iface=ifaces_.begin();
+ iface!=ifaces_.end();
+ ++iface) {
+
+ cout << "Trying interface " << iface->getFullName() << endl;
+
-#if 0
+ if (iface->flag_loopback_ ||
+ !iface->flag_up_ ||
+ !iface->flag_running_) {
+ continue;
+ }
-#endif
AddressCollection addrs = iface->getAddresses();
int openSocket(const std::string& ifname,
const isc::asiolink::IOAddress& addr, int port);
- /// Opens IPv4 sockets on detected interfaces.
- /// Opens IPv6 sockets on detected interfaces.
-- ///
-- /// Will throw exception if socket creation fails.
- ///
+ /// @param port specifies port number (usually DHCP6_SERVER_PORT)
///
- /// @param port specifies port number (usually DHCP4_SERVER_PORT)
- void openSockets4(uint16_t port);
-
+ /// @return true if any sockets were open
+ bool openSockets6(uint16_t port = DHCP6_SERVER_PORT);
/// @brief Closes all open sockets.
/// Is used in destructor, but also from Dhcpv4_srv and Dhcpv6_srv classes.
void closeSockets();
- /// @param port specifies port number (usually DHCP6_SERVER_PORT)
+ /// @brief returns number of detected interfaces
+ ///
+ /// @return number of detected interfaces
+ uint16_t countIfaces() { return ifaces_.size(); }
+
+ /// Opens IPv4 sockets on detected interfaces.
+ /// Will throw exception if socket creation fails.
+ ///
++ /// @param port specifies port number (usually DHCP4_SERVER_PORT)
+ ///
+ /// @return true if any sockets were open
+ bool openSockets4(uint16_t port = DHCP4_SERVER_PORT);
+
// don't use private, we need derived classes in tests
protected:
EXPECT_EQ(static_cast<void*>(NULL), ifacemgr->getIface("wifi0") );
delete ifacemgr;
+
}
-TEST_F(IfaceMgrTest, detectIfaces) {
+#if !defined(OS_LINUX)
+TEST_F(IfaceMgrTest, detectIfaces_stub) {
// test detects that interfaces can be detected
// there is no code for that now, but interfaces are