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.h b/byte_string.h
index efe94f4..840fc7d 100644
--- a/byte_string.h
+++ b/byte_string.h
@@ -49,7 +49,16 @@
bool ConvertToNetUInt32(uint32 *val) const;
bool IsEmpty() const { return GetLength() == 0; }
+
+ // Returns true if every element of |this| is zero, false otherwise.
bool IsZero() const;
+
+ // Perform an AND operation between each element of |this| with the
+ // corresponding byte of |b|. Returns true if both |this| and |b|
+ // are the same length, and as such the operation succeeds; false
+ // if they are not.
+ bool ApplyMask(const ByteString &b);
+
bool Equals(const ByteString &b) const;
void Append(const ByteString &b);
void Clear() { data_.clear(); }