You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2015/02/23 18:55:07 UTC
[1/3] mesos git commit: stout: Moved MAC and IP classes to
stout/mac.hpp and stout/ip.hpp
Repository: mesos
Updated Branches:
refs/heads/master 2bf284fce -> 135bc70e8
stout: Moved MAC and IP classes to stout/mac.hpp and stout/ip.hpp
Review: https://reviews.apache.org/r/31000
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4f732e31
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4f732e31
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4f732e31
Branch: refs/heads/master
Commit: 4f732e315932b5870d91ce68ec16145d8b49907e
Parents: 2bf284f
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Mon Feb 23 09:17:46 2015 -0800
Committer: Dominic Hamon <dm...@twitter.com>
Committed: Mon Feb 23 09:18:55 2015 -0800
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/stout/Makefile.am | 3 +-
.../3rdparty/stout/include/stout/ip.hpp | 263 ++++++++++++++
.../3rdparty/stout/include/stout/mac.hpp | 198 ++++++++++
.../3rdparty/stout/include/stout/net.hpp | 359 -------------------
.../3rdparty/stout/tests/ip_tests.cpp | 99 +++++
.../3rdparty/stout/tests/mac_tests.cpp | 56 +++
.../3rdparty/stout/tests/net_tests.cpp | 136 -------
7 files changed, 618 insertions(+), 496 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 8e51957..a522455 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -22,11 +22,12 @@ EXTRA_DIST = \
tests/hashmap_tests.cpp \
tests/hashset_tests.cpp \
tests/interval_tests.cpp \
+ tests/ip_tests.cpp \
tests/json_tests.cpp \
tests/linkedhashmap_tests.cpp \
+ tests/mac_tests.cpp \
tests/main.cpp \
tests/multimap_tests.cpp \
- tests/net_tests.cpp \
tests/none_tests.cpp \
tests/option_tests.cpp \
tests/os_tests.cpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/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
new file mode 100644
index 0000000..3c00536
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
@@ -0,0 +1,263 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_IP_HPP__
+#define __STOUT_IP_HPP__
+
+#if defined(__linux__) || defined(__APPLE__)
+#include <ifaddrs.h>
+#endif
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arpa/inet.h>
+
+#ifdef __APPLE__
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+#include "abort.hpp"
+#include "error.hpp"
+#include "none.hpp"
+#include "numify.hpp"
+#include "option.hpp"
+#include "result.hpp"
+#include "stringify.hpp"
+#include "strings.hpp"
+#include "try.hpp"
+
+
+// Network utilities.
+namespace net {
+
+// Represents an IPv4 address. Besides the actual IP address, we also
+// store additional information about the address such as the netmask
+// which defines the subnet.
+class IP
+{
+public:
+ // Creates an IP from the given string that has the dot-decimal
+ // format (with or without subnet prefix). For example:
+ // 10.0.0.1/8
+ // 192.168.1.100/24
+ // 172.158.1.23
+ static Try<IP> fromDotDecimal(const std::string& value);
+
+ // Creates an IP from the given IP address (in host order) and the
+ // given netmask (in host order). Returns error if the netmask is
+ // not valid (e.g., not contiguous).
+ static Try<IP> fromAddressNetmask(uint32_t address, uint32_t netmask);
+
+ // Creates an IP from a 32-bit address (in host order) and a subnet
+ // prefix (within [0,32]). Returns error if the prefix is not valid.
+ static Try<IP> fromAddressPrefix(uint32_t address, size_t prefix);
+
+ // Constructs an IP with the given IP address (in host order).
+ explicit IP(uint32_t _address) : address_(_address) {}
+
+ // Returns the IP address (in host order).
+ uint32_t address() const { return address_; }
+
+ // Returns the net mask (in host order).
+ Option<uint32_t> netmask() const { return netmask_; }
+
+ // Returns the prefix of the subnet defined by the net mask.
+ Option<size_t> prefix() const
+ {
+ if (netmask_.isNone()) {
+ return None();
+ }
+
+ uint32_t mask = netmask_.get();
+
+ size_t value = 0;
+ while (mask != 0) {
+ value += mask & 1;
+ mask >>= 1;
+ }
+
+ return value;
+ }
+
+ bool operator == (const IP& that) const
+ {
+ return address_ == that.address_ && netmask_ == that.netmask_;
+ }
+
+ bool operator != (const IP& that) const
+ {
+ return !operator == (that);
+ }
+
+private:
+ // Constructs an IP with the given IP address (in host order) and
+ // the given netmask (in host order).
+ IP(uint32_t _address, uint32_t _netmask)
+ : address_(_address), netmask_(_netmask) {}
+
+ // IP address (in host order).
+ uint32_t address_;
+
+ // The optional net mask (in host order).
+ Option<uint32_t> netmask_;
+};
+
+
+inline Try<IP> IP::fromDotDecimal(const std::string& value)
+{
+ std::vector<std::string> tokens = strings::split(value, "/");
+
+ if (tokens.size() > 2) {
+ return Error("More than one '/' detected");
+ }
+
+ struct in_addr in;
+ if (inet_aton(tokens[0].c_str(), &in) == 0) {
+ return Error("Failed to parse the IP address");
+ }
+
+ // Parse the subnet prefix if specified.
+ if (tokens.size() == 2) {
+ Try<size_t> prefix = numify<size_t>(tokens[1]);
+ if (prefix.isError()) {
+ return Error("Subnet prefix is not a number");
+ }
+
+ return fromAddressPrefix(ntohl(in.s_addr), prefix.get());
+ }
+
+ return IP(ntohl(in.s_addr));
+}
+
+
+inline Try<IP> IP::fromAddressNetmask(uint32_t address, uint32_t netmask)
+{
+ if (((~netmask + 1) & (~netmask)) != 0) {
+ return Error("Netmask is not valid");
+ }
+
+ return IP(address, netmask);
+}
+
+
+inline Try<IP> IP::fromAddressPrefix(uint32_t address, size_t prefix)
+{
+ if (prefix > 32) {
+ return Error("Subnet prefix is larger than 32");
+ }
+
+ return IP(address, (0xffffffff << (32 - prefix)));
+}
+
+
+// Returns the string representation of the given IP address using the
+// canonical dot-decimal form with prefix. For example: "10.0.0.1/8".
+inline std::ostream& operator << (std::ostream& stream, const IP& ip)
+{
+ char buffer[INET_ADDRSTRLEN];
+
+ struct in_addr addr;
+ addr.s_addr = htonl(ip.address());
+
+ const char* str = inet_ntop(AF_INET, &addr, buffer, sizeof(buffer));
+ if (str == NULL) {
+ // We do not expect inet_ntop to fail because all parameters
+ // passed in are valid.
+ const char *error_msg = strerror(errno);
+ ABORT("inet_ntop returns error for address " + stringify(ip.address()) +
+ ": " + error_msg);
+ }
+
+ stream << str;
+
+ if (ip.prefix().isSome()) {
+ stream << "/" << ip.prefix().get();
+ }
+
+ return stream;
+}
+
+
+// Returns the first available IPv4 address 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 IPv4 address.
+// TODO(jieyu): It is uncommon, but likely that a link device has
+// multiple IPv4 addresses. In that case, consider returning the
+// primary IP address instead of the first one.
+inline Result<IP> ip(const std::string& name)
+{
+#if !defined(__linux__) && !defined(__APPLE__)
+ return Error("Not implemented");
+#else
+ struct ifaddrs* ifaddr = NULL;
+ if (getifaddrs(&ifaddr) == -1) {
+ return ErrnoError();
+ }
+
+ // Indicates whether the link device is found or not.
+ bool found = false;
+
+ for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_name != NULL && !strcmp(ifa->ifa_name, name.c_str())) {
+ found = true;
+
+ if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_INET) {
+ struct sockaddr_in* addr = (struct sockaddr_in*) ifa->ifa_addr;
+
+ if (ifa->ifa_netmask != NULL &&
+ ifa->ifa_netmask->sa_family == AF_INET) {
+ struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask;
+
+ Try<IP> ip = IP::fromAddressNetmask(
+ ntohl(addr->sin_addr.s_addr),
+ ntohl(netmask->sin_addr.s_addr));
+
+ freeifaddrs(ifaddr);
+
+ if (ip.isError()) {
+ return Error(ip.error());
+ }
+
+ return ip.get();
+ }
+
+ // Note that this is the case where net mask is not specified.
+ // We've seen such cases when VPN is used.
+ IP ip(ntohl(addr->sin_addr.s_addr));
+
+ freeifaddrs(ifaddr);
+ return ip;
+ }
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ if (!found) {
+ return Error("Cannot find the link device");
+ }
+
+ return None();
+#endif
+}
+
+} // namespace net {
+
+#endif // __STOUT_IP_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/3rdparty/libprocess/3rdparty/stout/include/stout/mac.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/mac.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/mac.hpp
new file mode 100644
index 0000000..bac3600
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/mac.hpp
@@ -0,0 +1,198 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_MAC_HPP__
+#define __STOUT_MAC_HPP__
+
+#if defined(__linux__) || defined(__APPLE__)
+#include <ifaddrs.h>
+#endif
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __linux__
+#include <linux/if.h>
+#include <linux/if_packet.h>
+#endif
+
+#include <net/ethernet.h>
+
+#ifdef __APPLE__
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+#include "abort.hpp"
+#include "error.hpp"
+#include "none.hpp"
+#include "result.hpp"
+#include "stringify.hpp"
+#include "try.hpp"
+
+
+// Network utilities.
+namespace net {
+
+// Represents a MAC address. A MAC address is a 48-bit unique
+// identifier assigned to a network interface for communications on
+// the physical network segment. We use a byte array (in transmission
+// order) to represent a MAC address. For example, for a MAC address
+// 01:23:34:67:89:ab, the format is shown as follows:
+//
+// MSB LSB
+// | |
+// v v
+// +--------+--------+--------+--------+--------+--------+
+// |bytes[0]|bytes[1]|bytes[2]|bytes[3]|bytes[4]|bytes[5]|
+// +--------+--------+--------+--------+--------+--------+
+//
+// 01 : 23 : 45 : 67 : 89 : ab
+// NOLINT(readability/ending_punctuation)
+class MAC
+{
+public:
+ // Constructs a MAC address from a byte array.
+ explicit MAC(const uint8_t (&_bytes)[6])
+ {
+ for (size_t i = 0; i < 6; i++) {
+ bytes[i] = _bytes[i];
+ }
+ }
+
+ // Returns the byte at the given index. For example, for a MAC
+ // address 01:23:45:67:89:ab, mac[0] = 01, mac[1] = 23 and etc.
+ uint8_t operator [] (size_t index) const
+ {
+ if (index >= 6) {
+ ABORT("Invalid index specified in MAC::operator []\n");
+ }
+
+ return bytes[index];
+ }
+
+ bool operator == (const MAC& that) const
+ {
+ for (size_t i = 0; i < 6; i++) {
+ if (bytes[i] != that.bytes[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ bool operator != (const MAC& that) const
+ {
+ return !operator == (that);
+ }
+
+private:
+ // Byte array of this MAC address (in transmission order).
+ uint8_t bytes[6];
+};
+
+
+// Returns the standard string format (IEEE 802) of the given MAC
+// address, which contains six groups of two hexadecimal digits,
+// separated by colons, in transmission order (e.g.,
+// 01:23:45:67:89:ab).
+inline std::ostream& operator << (std::ostream& stream, const MAC& mac)
+{
+ char buffer[18];
+
+ sprintf(
+ buffer,
+ "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ mac[0],
+ mac[1],
+ mac[2],
+ mac[3],
+ mac[4],
+ mac[5]);
+
+ return stream << buffer;
+}
+
+
+// Returns the MAC address 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 a MAC address (e.g., loopback).
+inline Result<MAC> mac(const std::string& name)
+{
+#if !defined(__linux__) && !defined(__APPLE__)
+ return Error("Not implemented");
+#else
+ struct ifaddrs* ifaddr = NULL;
+ if (getifaddrs(&ifaddr) == -1) {
+ return ErrnoError();
+ }
+
+ // Indicates whether the link device is found or not.
+ bool found = false;
+
+ for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_name != NULL && !strcmp(ifa->ifa_name, name.c_str())) {
+ found = true;
+
+# if defined(__linux__)
+ if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_PACKET) {
+ struct sockaddr_ll* link = (struct sockaddr_ll*) ifa->ifa_addr;
+
+ if (link->sll_halen == 6) {
+ struct ether_addr* addr = (struct ether_addr*) link->sll_addr;
+ MAC mac(addr->ether_addr_octet);
+
+ // Ignore if the address is 0 so that the results are
+ // consistent on both OSX and Linux.
+ if (stringify(mac) == "00:00:00:00:00:00") {
+ continue;
+ }
+
+ freeifaddrs(ifaddr);
+ return mac;
+ }
+ }
+# elif defined(__APPLE__)
+ if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_LINK) {
+ struct sockaddr_dl* link = (struct sockaddr_dl*) ifa->ifa_addr;
+
+ if (link->sdl_type == IFT_ETHER && link->sdl_alen == 6) {
+ struct ether_addr* addr = (struct ether_addr*) LLADDR(link);
+ MAC mac(addr->octet);
+
+ freeifaddrs(ifaddr);
+ return mac;
+ }
+ }
+# endif
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ if (!found) {
+ return Error("Cannot find the link device");
+ }
+
+ return None();
+#endif
+}
+
+} // namespace net {
+
+#endif // __STOUT_MAC_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
index b464e51..9635bbc 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
@@ -239,365 +239,6 @@ inline Try<std::set<std::string> > links()
#endif
}
-
-// Represents a MAC address. A MAC address is a 48-bit unique
-// identifier assigned to a network interface for communications on
-// the physical network segment. We use a byte array (in transmission
-// order) to represent a MAC address. For example, for a MAC address
-// 01:23:34:67:89:ab, the format is shown as follows:
-//
-// MSB LSB
-// | |
-// v v
-// +--------+--------+--------+--------+--------+--------+
-// |bytes[0]|bytes[1]|bytes[2]|bytes[3]|bytes[4]|bytes[5]|
-// +--------+--------+--------+--------+--------+--------+
-//
-// 01 : 23 : 45 : 67 : 89 : ab
-// NOLINT(readability/ending_punctuation)
-class MAC
-{
-public:
- // Constructs a MAC address from a byte array.
- explicit MAC(const uint8_t (&_bytes)[6])
- {
- for (size_t i = 0; i < 6; i++) {
- bytes[i] = _bytes[i];
- }
- }
-
- // Returns the byte at the given index. For example, for a MAC
- // address 01:23:45:67:89:ab, mac[0] = 01, mac[1] = 23 and etc.
- uint8_t operator [] (size_t index) const
- {
- if (index >= 6) {
- ABORT("Invalid index specified in MAC::operator []\n");
- }
-
- return bytes[index];
- }
-
- bool operator == (const MAC& that) const
- {
- for (size_t i = 0; i < 6; i++) {
- if (bytes[i] != that.bytes[i]) {
- return false;
- }
- }
- return true;
- }
-
- bool operator != (const MAC& that) const
- {
- return !operator == (that);
- }
-
-private:
- // Byte array of this MAC address (in transmission order).
- uint8_t bytes[6];
-};
-
-
-// Returns the standard string format (IEEE 802) of the given MAC
-// address, which contains six groups of two hexadecimal digits,
-// separated by colons, in transmission order (e.g.,
-// 01:23:45:67:89:ab).
-inline std::ostream& operator << (std::ostream& stream, const MAC& mac)
-{
- char buffer[18];
-
- sprintf(
- buffer,
- "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
- mac[0],
- mac[1],
- mac[2],
- mac[3],
- mac[4],
- mac[5]);
-
- return stream << buffer;
-}
-
-
-// Returns the MAC address 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 a MAC address (e.g., loopback).
-inline Result<MAC> mac(const std::string& name)
-{
-#if !defined(__linux__) && !defined(__APPLE__)
- return Error("Not implemented");
-#else
- struct ifaddrs* ifaddr = NULL;
- if (getifaddrs(&ifaddr) == -1) {
- return ErrnoError();
- }
-
- // Indicates whether the link device is found or not.
- bool found = false;
-
- for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
- if (ifa->ifa_name != NULL && !strcmp(ifa->ifa_name, name.c_str())) {
- found = true;
-
-# if defined(__linux__)
- if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_PACKET) {
- struct sockaddr_ll* link = (struct sockaddr_ll*) ifa->ifa_addr;
-
- if (link->sll_halen == 6) {
- struct ether_addr* addr = (struct ether_addr*) link->sll_addr;
- MAC mac(addr->ether_addr_octet);
-
- // Ignore if the address is 0 so that the results are
- // consistent on both OSX and Linux.
- if (stringify(mac) == "00:00:00:00:00:00") {
- continue;
- }
-
- freeifaddrs(ifaddr);
- return mac;
- }
- }
-# elif defined(__APPLE__)
- if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_LINK) {
- struct sockaddr_dl* link = (struct sockaddr_dl*) ifa->ifa_addr;
-
- if (link->sdl_type == IFT_ETHER && link->sdl_alen == 6) {
- struct ether_addr* addr = (struct ether_addr*) LLADDR(link);
- MAC mac(addr->octet);
-
- freeifaddrs(ifaddr);
- return mac;
- }
- }
-# endif
- }
- }
-
- freeifaddrs(ifaddr);
-
- if (!found) {
- return Error("Cannot find the link device");
- }
-
- return None();
-#endif
-}
-
-
-// Represents an IPv4 address. Besides the actual IP address, we also
-// store additional information about the address such as the netmask
-// which defines the subnet.
-class IP
-{
-public:
- // Creates an IP from the given string that has the dot-decimal
- // format (with or without subnet prefix). For example:
- // 10.0.0.1/8
- // 192.168.1.100/24
- // 172.158.1.23
- static Try<IP> fromDotDecimal(const std::string& value);
-
- // Creates an IP from the given IP address (in host order) and the
- // given netmask (in host order). Returns error if the netmask is
- // not valid (e.g., not contiguous).
- static Try<IP> fromAddressNetmask(uint32_t address, uint32_t netmask);
-
- // Creates an IP from a 32-bit address (in host order) and a subnet
- // prefix (within [0,32]). Returns error if the prefix is not valid.
- static Try<IP> fromAddressPrefix(uint32_t address, size_t prefix);
-
- // Constructs an IP with the given IP address (in host order).
- explicit IP(uint32_t _address) : address_(_address) {}
-
- // Returns the IP address (in host order).
- uint32_t address() const { return address_; }
-
- // Returns the net mask (in host order).
- Option<uint32_t> netmask() const { return netmask_; }
-
- // Returns the prefix of the subnet defined by the net mask.
- Option<size_t> prefix() const
- {
- if (netmask_.isNone()) {
- return None();
- }
-
- uint32_t mask = netmask_.get();
-
- size_t value = 0;
- while (mask != 0) {
- value += mask & 1;
- mask >>= 1;
- }
-
- return value;
- }
-
- bool operator == (const IP& that) const
- {
- return address_ == that.address_ && netmask_ == that.netmask_;
- }
-
- bool operator != (const IP& that) const
- {
- return !operator == (that);
- }
-
-private:
- // Constructs an IP with the given IP address (in host order) and
- // the given netmask (in host order).
- IP(uint32_t _address, uint32_t _netmask)
- : address_(_address), netmask_(_netmask) {}
-
- // IP address (in host order).
- uint32_t address_;
-
- // The optional net mask (in host order).
- Option<uint32_t> netmask_;
-};
-
-
-inline Try<IP> IP::fromDotDecimal(const std::string& value)
-{
- std::vector<std::string> tokens = strings::split(value, "/");
-
- if (tokens.size() > 2) {
- return Error("More than one '/' detected");
- }
-
- struct in_addr in;
- if (inet_aton(tokens[0].c_str(), &in) == 0) {
- return Error("Failed to parse the IP address");
- }
-
- // Parse the subnet prefix if specified.
- if (tokens.size() == 2) {
- Try<size_t> prefix = numify<size_t>(tokens[1]);
- if (prefix.isError()) {
- return Error("Subnet prefix is not a number");
- }
-
- return fromAddressPrefix(ntohl(in.s_addr), prefix.get());
- }
-
- return IP(ntohl(in.s_addr));
-}
-
-
-inline Try<IP> IP::fromAddressNetmask(uint32_t address, uint32_t netmask)
-{
- if (((~netmask + 1) & (~netmask)) != 0) {
- return Error("Netmask is not valid");
- }
-
- return IP(address, netmask);
-}
-
-
-inline Try<IP> IP::fromAddressPrefix(uint32_t address, size_t prefix)
-{
- if (prefix > 32) {
- return Error("Subnet prefix is larger than 32");
- }
-
- return IP(address, (0xffffffff << (32 - prefix)));
-}
-
-
-// Returns the string representation of the given IP address using the
-// canonical dot-decimal form with prefix. For example: "10.0.0.1/8".
-inline std::ostream& operator << (std::ostream& stream, const IP& ip)
-{
- char buffer[INET_ADDRSTRLEN];
-
- struct in_addr addr;
- addr.s_addr = htonl(ip.address());
-
- const char* str = inet_ntop(AF_INET, &addr, buffer, sizeof(buffer));
- if (str == NULL) {
- // We do not expect inet_ntop to fail because all parameters
- // passed in are valid.
- const char *error_msg = strerror(errno);
- ABORT("inet_ntop returns error for address " + stringify(ip.address()) +
- ": " + error_msg);
- }
-
- stream << str;
-
- if (ip.prefix().isSome()) {
- stream << "/" << ip.prefix().get();
- }
-
- return stream;
-}
-
-
-// Returns the first available IPv4 address 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 IPv4 address.
-// TODO(jieyu): It is uncommon, but likely that a link device has
-// multiple IPv4 addresses. In that case, consider returning the
-// primary IP address instead of the first one.
-inline Result<IP> ip(const std::string& name)
-{
-#if !defined(__linux__) && !defined(__APPLE__)
- return Error("Not implemented");
-#else
- struct ifaddrs* ifaddr = NULL;
- if (getifaddrs(&ifaddr) == -1) {
- return ErrnoError();
- }
-
- // Indicates whether the link device is found or not.
- bool found = false;
-
- for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
- if (ifa->ifa_name != NULL && !strcmp(ifa->ifa_name, name.c_str())) {
- found = true;
-
- if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_INET) {
- struct sockaddr_in* addr = (struct sockaddr_in*) ifa->ifa_addr;
-
- if (ifa->ifa_netmask != NULL &&
- ifa->ifa_netmask->sa_family == AF_INET) {
- struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask;
-
- Try<IP> ip = IP::fromAddressNetmask(
- ntohl(addr->sin_addr.s_addr),
- ntohl(netmask->sin_addr.s_addr));
-
- freeifaddrs(ifaddr);
-
- if (ip.isError()) {
- return Error(ip.error());
- }
-
- return ip.get();
- }
-
- // Note that this is the case where net mask is not specified.
- // We've seen such cases when VPN is used.
- IP ip(ntohl(addr->sin_addr.s_addr));
-
- freeifaddrs(ifaddr);
- return ip;
- }
- }
- }
-
- freeifaddrs(ifaddr);
-
- if (!found) {
- return Error("Cannot find the link device");
- }
-
- return None();
-#endif
-}
-
} // namespace net {
#endif // __STOUT_NET_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/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
new file mode 100644
index 0000000..0db899e
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp
@@ -0,0 +1,99 @@
+#include <stdio.h>
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include <stout/foreach.hpp>
+#include <stout/gtest.hpp>
+#include <stout/ip.hpp>
+#include <stout/net.hpp>
+#include <stout/numify.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+
+using std::set;
+using std::string;
+using std::vector;
+
+
+TEST(NetTest, ip)
+{
+ Try<set<string> > links = net::links();
+ ASSERT_SOME(links);
+
+ foreach(const string& link, links.get()) {
+ Result<net::IP> ip = net::ip(link);
+ EXPECT_FALSE(ip.isError());
+
+ if (ip.isSome()) {
+ string addr = stringify(ip.get());
+
+ if (ip.get().prefix().isSome()) {
+ string prefix = addr.substr(addr.find("/") + 1);
+ ASSERT_SOME(numify<size_t>(prefix));
+ EXPECT_EQ(ip.get().prefix().get(), numify<size_t>(prefix).get());
+ }
+
+ vector<string> tokens =
+ strings::split(addr.substr(0, addr.find("/")), ".");
+
+ EXPECT_EQ(4u, tokens.size());
+
+ foreach (const string& token, tokens) {
+ ASSERT_SOME(numify<int>(token));
+ EXPECT_LE(0, numify<int>(token).get());
+ EXPECT_GE(255, numify<int>(token).get());
+ }
+ }
+ }
+
+ Result<net::IP> ip = net::ip("non-exist");
+ EXPECT_ERROR(ip);
+}
+
+
+TEST(NetTest, ConstructIP)
+{
+ EXPECT_SOME(net::IP::fromDotDecimal("127.0.0.1"));
+ EXPECT_SOME(net::IP::fromDotDecimal("10.135.0.1/8"));
+ EXPECT_SOME(net::IP::fromDotDecimal("192.168.1.1/16"));
+ EXPECT_SOME(net::IP::fromDotDecimal("01.02.03.04"));
+ EXPECT_SOME(net::IP::fromDotDecimal("172.39.13.123/31"));
+
+ EXPECT_ERROR(net::IP::fromDotDecimal("123.1.1.2//23"));
+ EXPECT_ERROR(net::IP::fromDotDecimal("121.2.3.5/23/"));
+ EXPECT_ERROR(net::IP::fromDotDecimal("12.32.3.5/123"));
+ EXPECT_ERROR(net::IP::fromDotDecimal("12.32.3.a/16"));
+ EXPECT_ERROR(net::IP::fromDotDecimal("hello world"));
+ EXPECT_ERROR(net::IP::fromDotDecimal("hello moto/8"));
+
+ EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xffff0000));
+ EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xf0000000));
+ EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xffffffff));
+ EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0));
+
+ EXPECT_ERROR(net::IP::fromAddressNetmask(0x087654321, 0xff));
+ EXPECT_ERROR(net::IP::fromAddressNetmask(0x087654321, 0xff00ff00));
+
+ EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 16));
+ EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 32));
+ EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 0));
+
+ EXPECT_ERROR(net::IP::fromAddressPrefix(0x12345678, 123));
+
+ uint32_t address = 0x01020304;
+ uint32_t netmask = 0xff000000;
+
+ Try<net::IP> ip1 = net::IP::fromAddressNetmask(address, netmask);
+ ASSERT_SOME(ip1);
+ EXPECT_EQ(address, ip1.get().address());
+ EXPECT_SOME_EQ(netmask, ip1.get().netmask());
+ EXPECT_EQ("1.2.3.4/8", stringify(ip1.get()));
+
+ Try<net::IP> ip2 = net::IP::fromDotDecimal(stringify(ip1.get()));
+ ASSERT_SOME(ip2);
+ EXPECT_EQ(ip1.get(), ip2.get());
+}
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/3rdparty/libprocess/3rdparty/stout/tests/mac_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/mac_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/mac_tests.cpp
new file mode 100644
index 0000000..4dbe4ba
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/tests/mac_tests.cpp
@@ -0,0 +1,56 @@
+#include <stdio.h>
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include <stout/foreach.hpp>
+#include <stout/gtest.hpp>
+#include <stout/mac.hpp>
+#include <stout/net.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+
+using std::set;
+using std::string;
+using std::vector;
+
+
+TEST(NetTest, mac)
+{
+ Try<set<string> > links = net::links();
+ ASSERT_SOME(links);
+
+ foreach(const string& link, links.get()) {
+ Result<net::MAC> mac = net::mac(link);
+ EXPECT_FALSE(mac.isError());
+
+ if (mac.isSome()) {
+ EXPECT_NE("00:00:00:00:00:00", stringify(mac.get()));
+
+ vector<string> tokens = strings::split(stringify(mac.get()), ":");
+ EXPECT_EQ(6u, tokens.size());
+
+ for (size_t i = 0; i < tokens.size(); i++) {
+ EXPECT_EQ(2u, tokens[i].size());
+
+ uint8_t value;
+ ASSERT_EQ(1, sscanf(tokens[i].c_str(), "%hhx", &value));
+ EXPECT_EQ(value, mac.get()[i]);
+ }
+ }
+ }
+
+ Result<net::MAC> mac = net::mac("non-exist");
+ EXPECT_ERROR(mac);
+}
+
+
+TEST(NetTest, ConstructMAC)
+{
+ uint8_t bytes[6] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc};
+
+ EXPECT_EQ("12:34:56:78:9a:bc", stringify(net::MAC(bytes)));
+}
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f732e31/3rdparty/libprocess/3rdparty/stout/tests/net_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/net_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/net_tests.cpp
deleted file mode 100644
index 425132e..0000000
--- a/3rdparty/libprocess/3rdparty/stout/tests/net_tests.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <stdio.h>
-
-#include <set>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#include <stout/foreach.hpp>
-#include <stout/gtest.hpp>
-#include <stout/net.hpp>
-#include <stout/numify.hpp>
-#include <stout/stringify.hpp>
-#include <stout/strings.hpp>
-
-using std::set;
-using std::string;
-using std::vector;
-
-
-TEST(NetTest, mac)
-{
- Try<set<string> > links = net::links();
- ASSERT_SOME(links);
-
- foreach(const string& link, links.get()) {
- Result<net::MAC> mac = net::mac(link);
- EXPECT_FALSE(mac.isError());
-
- if (mac.isSome()) {
- EXPECT_NE("00:00:00:00:00:00", stringify(mac.get()));
-
- vector<string> tokens = strings::split(stringify(mac.get()), ":");
- EXPECT_EQ(6u, tokens.size());
-
- for (size_t i = 0; i < tokens.size(); i++) {
- EXPECT_EQ(2u, tokens[i].size());
-
- uint8_t value;
- ASSERT_EQ(1, sscanf(tokens[i].c_str(), "%hhx", &value));
- EXPECT_EQ(value, mac.get()[i]);
- }
- }
- }
-
- Result<net::MAC> mac = net::mac("non-exist");
- EXPECT_ERROR(mac);
-}
-
-
-TEST(NetTest, ConstructMAC)
-{
- uint8_t bytes[6] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc};
-
- EXPECT_EQ("12:34:56:78:9a:bc", stringify(net::MAC(bytes)));
-}
-
-
-TEST(NetTest, ip)
-{
- Try<set<string> > links = net::links();
- ASSERT_SOME(links);
-
- foreach(const string& link, links.get()) {
- Result<net::IP> ip = net::ip(link);
- EXPECT_FALSE(ip.isError());
-
- if (ip.isSome()) {
- string addr = stringify(ip.get());
-
- if (ip.get().prefix().isSome()) {
- string prefix = addr.substr(addr.find("/") + 1);
- ASSERT_SOME(numify<size_t>(prefix));
- EXPECT_EQ(ip.get().prefix().get(), numify<size_t>(prefix).get());
- }
-
- vector<string> tokens =
- strings::split(addr.substr(0, addr.find("/")), ".");
-
- EXPECT_EQ(4u, tokens.size());
-
- foreach (const string& token, tokens) {
- ASSERT_SOME(numify<int>(token));
- EXPECT_LE(0, numify<int>(token).get());
- EXPECT_GE(255, numify<int>(token).get());
- }
- }
- }
-
- Result<net::IP> ip = net::ip("non-exist");
- EXPECT_ERROR(ip);
-}
-
-
-TEST(NetTest, ConstructIP)
-{
- EXPECT_SOME(net::IP::fromDotDecimal("127.0.0.1"));
- EXPECT_SOME(net::IP::fromDotDecimal("10.135.0.1/8"));
- EXPECT_SOME(net::IP::fromDotDecimal("192.168.1.1/16"));
- EXPECT_SOME(net::IP::fromDotDecimal("01.02.03.04"));
- EXPECT_SOME(net::IP::fromDotDecimal("172.39.13.123/31"));
-
- EXPECT_ERROR(net::IP::fromDotDecimal("123.1.1.2//23"));
- EXPECT_ERROR(net::IP::fromDotDecimal("121.2.3.5/23/"));
- EXPECT_ERROR(net::IP::fromDotDecimal("12.32.3.5/123"));
- EXPECT_ERROR(net::IP::fromDotDecimal("12.32.3.a/16"));
- EXPECT_ERROR(net::IP::fromDotDecimal("hello world"));
- EXPECT_ERROR(net::IP::fromDotDecimal("hello moto/8"));
-
- EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xffff0000));
- EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xf0000000));
- EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0xffffffff));
- EXPECT_SOME(net::IP::fromAddressNetmask(0x12345678, 0));
-
- EXPECT_ERROR(net::IP::fromAddressNetmask(0x087654321, 0xff));
- EXPECT_ERROR(net::IP::fromAddressNetmask(0x087654321, 0xff00ff00));
-
- EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 16));
- EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 32));
- EXPECT_SOME(net::IP::fromAddressPrefix(0x12345678, 0));
-
- EXPECT_ERROR(net::IP::fromAddressPrefix(0x12345678, 123));
-
- uint32_t address = 0x01020304;
- uint32_t netmask = 0xff000000;
-
- Try<net::IP> ip1 = net::IP::fromAddressNetmask(address, netmask);
- ASSERT_SOME(ip1);
- EXPECT_EQ(address, ip1.get().address());
- EXPECT_SOME_EQ(netmask, ip1.get().netmask());
- EXPECT_EQ("1.2.3.4/8", stringify(ip1.get()));
-
- Try<net::IP> ip2 = net::IP::fromDotDecimal(stringify(ip1.get()));
- ASSERT_SOME(ip2);
- EXPECT_EQ(ip1.get(), ip2.get());
-}
[3/3] mesos git commit: libprocess: Moved MAC and IP classes to
stout/mac.hpp and stout/ip.hpp
Posted by dm...@apache.org.
libprocess: Moved MAC and IP classes to stout/mac.hpp and stout/ip.hpp
Review: https://reviews.apache.org/r/31001
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/135bc70e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/135bc70e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/135bc70e
Branch: refs/heads/master
Commit: 135bc70e8aa83d074c1610ce3058d5e56ef5f388
Parents: 628786b
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Mon Feb 23 09:21:17 2015 -0800
Committer: Dominic Hamon <dm...@twitter.com>
Committed: Mon Feb 23 09:22:18 2015 -0800
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/Makefile.am | 3 ++-
3rdparty/libprocess/include/process/http.hpp | 2 +-
3rdparty/libprocess/include/process/socket.hpp | 1 -
3rdparty/libprocess/src/http.cpp | 2 ++
4 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/135bc70e/3rdparty/libprocess/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/Makefile.am b/3rdparty/libprocess/3rdparty/Makefile.am
index 85170a1..e55147a 100644
--- a/3rdparty/libprocess/3rdparty/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/Makefile.am
@@ -155,11 +155,12 @@ stout_tests_SOURCES = \
$(STOUT)/tests/hashmap_tests.cpp \
$(STOUT)/tests/hashset_tests.cpp \
$(STOUT)/tests/interval_tests.cpp \
+ $(STOUT)/tests/ip_tests.cpp \
$(STOUT)/tests/json_tests.cpp \
$(STOUT)/tests/linkedhashmap_tests.cpp \
+ $(STOUT)/tests/mac_tests.cpp \
$(STOUT)/tests/main.cpp \
$(STOUT)/tests/multimap_tests.cpp \
- $(STOUT)/tests/net_tests.cpp \
$(STOUT)/tests/none_tests.cpp \
$(STOUT)/tests/option_tests.cpp \
$(STOUT)/tests/os_tests.cpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/135bc70e/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 523ef7e..10143fd 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -17,8 +17,8 @@
#include <stout/error.hpp>
#include <stout/foreach.hpp>
#include <stout/hashmap.hpp>
+#include <stout/ip.hpp>
#include <stout/json.hpp>
-#include <stout/net.hpp>
#include <stout/none.hpp>
#include <stout/numify.hpp>
#include <stout/option.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/135bc70e/3rdparty/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp
index 426b3fa..2c42587 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -8,7 +8,6 @@
#include <stout/abort.hpp>
#include <stout/nothing.hpp>
-#include <stout/net.hpp>
#include <stout/os.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/135bc70e/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 7503313..f9d9daf 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -13,7 +13,9 @@
#include <process/owned.hpp>
#include <process/socket.hpp>
+#include <stout/ip.hpp>
#include <stout/lambda.hpp>
+#include <stout/net.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
#include <stout/try.hpp>
[2/3] mesos git commit: mesos: Moved MAC and IP classes to
stout/mac.hpp and stout/ip.hpp
Posted by dm...@apache.org.
mesos: Moved MAC and IP classes to stout/mac.hpp and stout/ip.hpp
Review: https://reviews.apache.org/r/30999
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/628786b2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/628786b2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/628786b2
Branch: refs/heads/master
Commit: 628786b2d5c1c7a048c09389ac59da2cfe63e0a8
Parents: 4f732e3
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Mon Feb 23 09:19:55 2015 -0800
Committer: Dominic Hamon <dm...@twitter.com>
Committed: Mon Feb 23 09:21:06 2015 -0800
----------------------------------------------------------------------
src/linux/routing/diagnosis/diagnosis.hpp | 2 +-
src/linux/routing/filter/icmp.hpp | 2 +-
src/linux/routing/filter/ip.hpp | 2 ++
src/linux/routing/link/link.cpp | 1 +
src/linux/routing/link/link.hpp | 2 +-
src/linux/routing/route.hpp | 2 +-
src/master/master.cpp | 1 +
src/sched/sched.cpp | 1 +
src/scheduler/scheduler.cpp | 2 +-
src/slave/containerizer/containerizer.cpp | 1 -
src/slave/containerizer/isolators/network/port_mapping.cpp | 1 +
src/slave/containerizer/isolators/network/port_mapping.hpp | 3 ++-
src/tests/port_mapping_tests.cpp | 2 ++
src/tests/routing_tests.cpp | 2 ++
14 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/diagnosis/diagnosis.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/diagnosis/diagnosis.hpp b/src/linux/routing/diagnosis/diagnosis.hpp
index 9161841..b8ce653 100644
--- a/src/linux/routing/diagnosis/diagnosis.hpp
+++ b/src/linux/routing/diagnosis/diagnosis.hpp
@@ -25,7 +25,7 @@
#include <vector>
-#include <stout/net.hpp>
+#include <stout/ip.hpp>
#include <stout/option.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/filter/icmp.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/icmp.hpp b/src/linux/routing/filter/icmp.hpp
index dc075a7..7b478c4 100644
--- a/src/linux/routing/filter/icmp.hpp
+++ b/src/linux/routing/filter/icmp.hpp
@@ -22,7 +22,7 @@
#include <string>
#include <vector>
-#include <stout/net.hpp>
+#include <stout/ip.hpp>
#include <stout/option.hpp>
#include <stout/result.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/filter/ip.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/ip.hpp b/src/linux/routing/filter/ip.hpp
index 566fd1e..932ed4b 100644
--- a/src/linux/routing/filter/ip.hpp
+++ b/src/linux/routing/filter/ip.hpp
@@ -27,7 +27,9 @@
#include <boost/functional/hash.hpp>
+#include <stout/ip.hpp>
#include <stout/net.hpp>
+#include <stout/mac.hpp>
#include <stout/option.hpp>
#include <stout/result.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/link/link.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/link/link.cpp b/src/linux/routing/link/link.cpp
index 53677cd..6606e4a 100644
--- a/src/linux/routing/link/link.cpp
+++ b/src/linux/routing/link/link.cpp
@@ -43,6 +43,7 @@
#include <stout/error.hpp>
#include <stout/duration.hpp>
#include <stout/lambda.hpp>
+#include <stout/net.hpp>
#include <stout/none.hpp>
#include <stout/os.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/link/link.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/link/link.hpp b/src/linux/routing/link/link.hpp
index 7e5b79e..c2ddd6c 100644
--- a/src/linux/routing/link/link.hpp
+++ b/src/linux/routing/link/link.hpp
@@ -28,7 +28,7 @@
#include <process/future.hpp>
#include <stout/hashmap.hpp>
-#include <stout/net.hpp>
+#include <stout/mac.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
#include <stout/result.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/linux/routing/route.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/route.hpp b/src/linux/routing/route.hpp
index f443e06..9e53391 100644
--- a/src/linux/routing/route.hpp
+++ b/src/linux/routing/route.hpp
@@ -22,7 +22,7 @@
#include <string>
#include <vector>
-#include <stout/net.hpp>
+#include <stout/ip.hpp>
#include <stout/option.hpp>
#include <stout/result.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 57e86ee..713307e 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -45,6 +45,7 @@
#include <stout/check.hpp>
#include <stout/error.hpp>
+#include <stout/ip.hpp>
#include <stout/lambda.hpp>
#include <stout/memory.hpp>
#include <stout/multihashmap.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 61e5d15..0f85703 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -60,6 +60,7 @@
#include <stout/error.hpp>
#include <stout/flags.hpp>
#include <stout/hashmap.hpp>
+#include <stout/ip.hpp>
#include <stout/lambda.hpp>
#include <stout/net.hpp>
#include <stout/option.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/scheduler/scheduler.cpp
----------------------------------------------------------------------
diff --git a/src/scheduler/scheduler.cpp b/src/scheduler/scheduler.cpp
index 66325c5..5ae2796 100644
--- a/src/scheduler/scheduler.cpp
+++ b/src/scheduler/scheduler.cpp
@@ -51,8 +51,8 @@
#include <stout/duration.hpp>
#include <stout/error.hpp>
#include <stout/flags.hpp>
+#include <stout/ip.hpp>
#include <stout/lambda.hpp>
-#include <stout/net.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/slave/containerizer/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.cpp b/src/slave/containerizer/containerizer.cpp
index 3f2ef8b..33f8738 100644
--- a/src/slave/containerizer/containerizer.cpp
+++ b/src/slave/containerizer/containerizer.cpp
@@ -24,7 +24,6 @@
#include <stout/fs.hpp>
#include <stout/hashmap.hpp>
-#include <stout/net.hpp>
#include <stout/stringify.hpp>
#include <stout/strings.hpp>
#include <stout/uuid.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/slave/containerizer/isolators/network/port_mapping.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/network/port_mapping.cpp b/src/slave/containerizer/isolators/network/port_mapping.cpp
index 6210478..ae1a7c6 100644
--- a/src/slave/containerizer/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/isolators/network/port_mapping.cpp
@@ -38,6 +38,7 @@
#include <stout/hashset.hpp>
#include <stout/json.hpp>
#include <stout/lambda.hpp>
+#include <stout/mac.hpp>
#include <stout/numify.hpp>
#include <stout/os.hpp>
#include <stout/option.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/slave/containerizer/isolators/network/port_mapping.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/network/port_mapping.hpp b/src/slave/containerizer/isolators/network/port_mapping.hpp
index 654f55e..8443097 100644
--- a/src/slave/containerizer/isolators/network/port_mapping.hpp
+++ b/src/slave/containerizer/isolators/network/port_mapping.hpp
@@ -37,8 +37,9 @@
#include <stout/bytes.hpp>
#include <stout/hashmap.hpp>
#include <stout/hashset.hpp>
+#include <stout/ip.hpp>
#include <stout/interval.hpp>
-#include <stout/net.hpp>
+#include <stout/mac.hpp>
#include <stout/none.hpp>
#include <stout/option.hpp>
#include <stout/subcommand.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/tests/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/port_mapping_tests.cpp b/src/tests/port_mapping_tests.cpp
index a03de23..9b1b5f1 100644
--- a/src/tests/port_mapping_tests.cpp
+++ b/src/tests/port_mapping_tests.cpp
@@ -29,7 +29,9 @@
#include <stout/bytes.hpp>
#include <stout/gtest.hpp>
+#include <stout/ip.hpp>
#include <stout/json.hpp>
+#include <stout/mac.hpp>
#include <stout/net.hpp>
#include "linux/fs.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/628786b2/src/tests/routing_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/routing_tests.cpp b/src/tests/routing_tests.cpp
index 6809659..3cda6ab 100644
--- a/src/tests/routing_tests.cpp
+++ b/src/tests/routing_tests.cpp
@@ -32,6 +32,8 @@
#include <stout/foreach.hpp>
#include <stout/gtest.hpp>
#include <stout/hashmap.hpp>
+#include <stout/ip.hpp>
+#include <stout/mac.hpp>
#include <stout/net.hpp>
#include <stout/stringify.hpp>