shill: Make IPAddress copiable and with prefix

We are finally in a place where it is painful to continue to avoid
using an IPAddress in an STL datatype, since we're going to be
holding on the the list of IP addresses that a given device has.
The RoutingTable code did a bit of gymnastics to get around the
non-copyable hurdle, so clear those now.

Also, in many cases IP addresses are specified with a bit prefix
indicating what portion of the address common to the broadcast
domain for that network.  Allow this to be specified.  Push this
change forward into all the unit tests.

BUG=chromium-os:19744
TEST=Reran unit tests

Change-Id: Iee2f84a5126b4a1162b5d9e0fc416207ba185be0
Reviewed-on: http://gerrit.chromium.org/gerrit/7024
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/ip_address.h b/ip_address.h
index 763522d..8ae07be 100644
--- a/ip_address.h
+++ b/ip_address.h
@@ -20,8 +20,21 @@
 
   explicit IPAddress(Family family);
   IPAddress(Family family, const ByteString &address);
+  IPAddress(Family family, const ByteString &address, unsigned int prefix);
   ~IPAddress();
 
+  // Since this is a copyable datatype...
+  IPAddress(const IPAddress &b)
+    : family_(b.family_),
+      address_(b.address_),
+      prefix_(b.prefix_) {}
+  IPAddress &operator=(const IPAddress &b) {
+    family_ = b.family_;
+    address_ = b.address_;
+    prefix_ = b.prefix_;
+    return *this;
+  }
+
   // Static utilities
   // Get the length in bytes of addresses of the given family
   static int GetAddressLength(Family family);
@@ -29,6 +42,8 @@
   // Getters and Setters
   Family family() const { return family_; }
   const ByteString &address() const { return address_; }
+  unsigned int prefix() const { return prefix_; }
+  void set_prefix(unsigned int prefix) { prefix_ = prefix; }
   const unsigned char *GetConstData() const { return address_.GetConstData(); }
   int GetLength() const { return address_.GetLength(); }
   bool IsDefault() const { return address_.IsZero(); }
@@ -44,18 +59,15 @@
   void SetAddressToDefault();
 
   bool Equals(const IPAddress &b) const {
-    return family_ == b.family_ && address_.Equals(b.address_);
-  }
-
-  void Clone(const IPAddress &b) {
-    family_ = b.family_;
-    address_ = b.address_;
+    return family_ == b.family_ && address_.Equals(b.address_) &&
+        prefix_ == b.prefix_;
   }
 
  private:
   Family family_;
   ByteString address_;
-  DISALLOW_COPY_AND_ASSIGN(IPAddress);
+  unsigned int prefix_;
+  // NO DISALLOW_COPY_AND_ASSIGN -- we assign IPAddresses in STL datatypes
 };
 
 }  // namespace shill