Browse Source

[1238] IfaceMgr::openSocket() is now public method.

Tomek Mrugalski 13 years ago
parent
commit
0b6937d0e0
3 changed files with 16 additions and 20 deletions
  1. 1 1
      src/bin/dhcp6/iface_mgr.cc
  2. 15 13
      src/bin/dhcp6/iface_mgr.h
  3. 0 6
      src/bin/dhcp6/tests/iface_mgr_unittest.cc

+ 1 - 1
src/bin/dhcp6/iface_mgr.cc

@@ -229,7 +229,7 @@ IfaceMgr::getIface(const std::string& ifname) {
     return (NULL); // not found
     return (NULL); // not found
 }
 }
 
 
-int
+uint16_t
 IfaceMgr::openSocket(const std::string& ifname,
 IfaceMgr::openSocket(const std::string& ifname,
                      const IOAddress& addr,
                      const IOAddress& addr,
                      int port) {
                      int port) {

+ 15 - 13
src/bin/dhcp6/iface_mgr.h

@@ -161,6 +161,21 @@ public:
 
 
     boost::shared_ptr<Pkt4> receive4();
     boost::shared_ptr<Pkt4> receive4();
 
 
+    ///
+    /// Opens UDP/IP socket and binds it to address, interface and port.
+    ///
+    /// Specific type of socket (UDP/IPv4 or UDP/IPv6) depends on passed addr
+    /// family.
+    ///
+    /// @param ifname name of the interface
+    /// @param addr address to be bound.
+    /// @param port UDP port.
+    ///
+    /// @return socket descriptor, if socket creation, binding and multicast
+    /// group join were all successful. -1 otherwise.
+    uint16_t openSocket(const std::string& ifname,
+                        const isc::asiolink::IOAddress& addr, int port);
+
     /// Opens sockets on detected interfaces.
     /// Opens sockets on detected interfaces.
     void openSockets();
     void openSockets();
 
 
@@ -191,19 +206,6 @@ protected:
     void
     void
     detectIfaces();
     detectIfaces();
 
 
-    ///
-    /// Opens UDP/IP socket and binds it to address, interface and port.
-    ///
-    /// @param ifname name of the interface
-    /// @param addr address to be bound.
-    /// @param port UDP port.
-    ///
-    /// @return socket descriptor, if socket creation, binding and multicast
-    /// group join were all successful. -1 otherwise.
-    int openSocket(const std::string& ifname,
-                   const isc::asiolink::IOAddress& addr,
-                   int port);
-
     // TODO: having 2 maps (ifindex->iface and ifname->iface would)
     // TODO: having 2 maps (ifindex->iface and ifname->iface would)
     //      probably be better for performance reasons
     //      probably be better for performance reasons
 
 

+ 0 - 6
src/bin/dhcp6/tests/iface_mgr_unittest.cc

@@ -42,12 +42,6 @@ public:
     IfaceCollection & getIfacesLst() { return ifaces_; }
     IfaceCollection & getIfacesLst() { return ifaces_; }
     void setSendSock(int sock) { sendsock_ = sock; }
     void setSendSock(int sock) { sendsock_ = sock; }
     void setRecvSock(int sock) { recvsock_ = sock; }
     void setRecvSock(int sock) { recvsock_ = sock; }
-
-    int openSocket(const std::string& ifname,
-                   const isc::asiolink::IOAddress& addr,
-                   int port) {
-        return IfaceMgr::openSocket(ifname, addr, port);
-    }
 };
 };
 
 
 // dummy class for now, but this will be expanded when needed
 // dummy class for now, but this will be expanded when needed