Repository: mesos
Updated Branches:
  refs/heads/master 079fc0a97 -> 3febf57dd


Made fromLinkDevice a member of the IPNetwork class in stout.

Review: https://reviews.apache.org/r/31472


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1b391223
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1b391223
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1b391223

Branch: refs/heads/master
Commit: 1b391223207ab41c7204f852e755ecf9c0f3e224
Parents: 079fc0a
Author: Evelina Dumitrescu <[email protected]>
Authored: Tue Mar 10 11:17:24 2015 -0700
Committer: Jie Yu <[email protected]>
Committed: Tue Mar 10 11:19:08 2015 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/ip.hpp         | 21 ++++++++++++--------
 .../3rdparty/stout/tests/ip_tests.cpp           |  6 ++++--
 2 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1b391223/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
index 6fbbb4d..e4e86de 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
@@ -277,7 +277,17 @@ public:
   // Returns error if the prefix is not valid.
   static Try<IPNetwork> create(const IP& address, int prefix);
 
+  // Returns the first available IP network of a given link device.
+  // The link device is specified using its name (e.g., eth0). Returns
+  // error if the link device is not found. Returns none if the link
+  // device is found, but does not have an IP network.
+  // TODO(jieyu): It is uncommon, but likely that a link device has
+  // multiple IP networks. In that case, consider returning the
+  // primary IP network instead of the first one.
+  static Result<IPNetwork> fromLinkDevice(const std::string& name, int family);
+
   IP address() const { return address_; }
+
   IP netmask() const { return netmask_; }
 
   // Returns the prefix of the subnet defined by the IP netmask.
@@ -398,14 +408,9 @@ inline Try<IPNetwork> IPNetwork::create(const IP& address, 
int prefix)
 }
 
 
-// Returns the first available IP network of a given link device. The
-// link device is specified using its name (e.g., eth0). Returns error
-// if the link device is not found. Returns none if the link device is
-// found, but does not have an IP network.
-// TODO(jieyu): It is uncommon, but likely that a link device has
-// multiple IP networks. In that case, consider returning the primary
-// IP network instead of the first one.
-inline Result<IPNetwork> fromLinkDevice(const std::string& name, int family)
+inline Result<IPNetwork> IPNetwork::fromLinkDevice(
+    const std::string& name,
+    int family)
 {
 #if !defined(__linux__) && !defined(__APPLE__)
   return Error("Not implemented");

http://git-wip-us.apache.org/repos/asf/mesos/blob/1b391223/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp 
b/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp
index 165e29d..c50480b 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp
@@ -25,7 +25,9 @@ TEST(NetTest, LinkDevice)
   ASSERT_SOME(links);
 
   foreach(const string& link, links.get()) {
-    Result<net::IPNetwork> network = net::fromLinkDevice(link, AF_INET);
+    Result<net::IPNetwork> network =
+      net::IPNetwork::fromLinkDevice(link, AF_INET);
+
     EXPECT_FALSE(network.isError());
 
     if (network.isSome()) {
@@ -47,7 +49,7 @@ TEST(NetTest, LinkDevice)
     }
   }
 
-  EXPECT_ERROR(net::fromLinkDevice("non-exist", AF_INET));
+  EXPECT_ERROR(net::IPNetwork::fromLinkDevice("non-exist", AF_INET));
 }
 
 

Reply via email to