shill: IPAddress: Add a few address manipulation utilities

Add a few address operations to test whether one address can
be reached directly from another.

BUG=chromium-os:29416
TEST=New unit tests

Change-Id: I5600a225b44edc1fbacb167488f4187e9aa99937
Reviewed-on: https://gerrit.chromium.org/gerrit/20464
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/byte_string.cc b/byte_string.cc
index 9976e0f..d52c626 100644
--- a/byte_string.cc
+++ b/byte_string.cc
@@ -49,6 +49,16 @@
   return true;
 }
 
+bool ByteString::ApplyMask(const ByteString &b) {
+  if (GetLength() != b.GetLength()) {
+    return false;
+  }
+  for (size_t i = 0; i < GetLength(); ++i) {
+    data_[i] &= b.data_[i];
+  }
+  return true;
+}
+
 bool ByteString::Equals(const ByteString &b) const {
   return data_ == b.data_;
 }