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/rtnl_message_unittest.cc b/rtnl_message_unittest.cc
index 4ba5876..cae6ae1 100644
--- a/rtnl_message_unittest.cc
+++ b/rtnl_message_unittest.cc
@@ -261,6 +261,7 @@
 
 const int kDelRouteIPV6InterfaceIndex = 2;
 const char kDelRouteIPV6Address[] = "ff02::1:ffa0:688";
+const int kDelRouteIPV6Prefix = 128;
 const int kDelRouteIPV6Metric = 0;
 
 const unsigned char kDelRouteIPV6[] = {
@@ -377,7 +378,6 @@
                         RTNLMessage::MessageMode mode,
                         int interface_index,
                         const IPAddress &address,
-                        int prefix,
                         unsigned char scope) {
     RTNLMessage msg;
 
@@ -388,14 +388,14 @@
     EXPECT_EQ(address.family(), msg.family());
 
     RTNLMessage::AddressStatus status = msg.address_status();
-    EXPECT_EQ(prefix, status.prefix_len);
     EXPECT_EQ(scope, status.scope);
 
     EXPECT_TRUE(msg.HasAttribute(IFA_LOCAL));
     EXPECT_EQ(address.GetLength(), msg.GetAttribute(IFA_LOCAL).GetLength());
     EXPECT_TRUE(
         IPAddress(address.family(),
-            msg.GetAttribute(IFA_LOCAL)).Equals(address));
+                  msg.GetAttribute(IFA_LOCAL),
+                  status.prefix_len).Equals(address));
   }
 
   void TestParseRoute(const ByteString &packet,
@@ -403,9 +403,7 @@
                       IPAddress::Family family,
                       int interface_index,
                       const IPAddress &dst,
-                      int dst_prefix,
                       const IPAddress &src,
-                      int src_prefix,
                       const IPAddress &gateway,
                       unsigned char table,
                       int protocol,
@@ -427,12 +425,16 @@
 
     if (!dst.IsDefault()) {
       EXPECT_TRUE(msg.HasAttribute(RTA_DST));
-      EXPECT_TRUE(IPAddress(family, msg.GetAttribute(RTA_DST)).Equals(dst));
+      EXPECT_TRUE(IPAddress(family,
+                            msg.GetAttribute(RTA_DST),
+                            status.dst_prefix).Equals(dst));
     }
 
     if (!src.IsDefault()) {
       EXPECT_TRUE(msg.HasAttribute(RTA_SRC));
-      EXPECT_TRUE(IPAddress(family, msg.GetAttribute(RTA_SRC)).Equals(src));
+      EXPECT_TRUE(IPAddress(family,
+                            msg.GetAttribute(RTA_SRC),
+                            status.src_prefix).Equals(src));
     }
 
     if (!gateway.IsDefault()) {
@@ -491,11 +493,11 @@
   IPAddress addr(IPAddress::kAddressFamilyIPv4);
 
   EXPECT_TRUE(addr.SetAddressFromString(kNewAddrIPV4Address));
+  addr.set_prefix(kNewAddrIPV4AddressPrefix);
   TestParseAddress(ByteString(kNewAddrIPV4, sizeof(kNewAddrIPV4)),
                    RTNLMessage::kMessageModeAdd,
                    kNewAddrIPV4InterfaceIndex,
                    addr,
-                   kNewAddrIPV4AddressPrefix,
                    kNewAddrIPV4Scope);
 }
 
@@ -505,6 +507,7 @@
   IPAddress gateway(IPAddress::kAddressFamilyIPv6);
 
   EXPECT_TRUE(dst.SetAddressFromString(kDelRouteIPV6Address));
+  dst.set_prefix(kDelRouteIPV6Prefix);
   src.SetAddressToDefault();
   EXPECT_TRUE(gateway.SetAddressFromString(kDelRouteIPV6Address));
 
@@ -513,9 +516,7 @@
                  IPAddress::kAddressFamilyIPv6,
                  kDelRouteIPV6InterfaceIndex,
                  dst,
-                 0,
                  src,
-                 0,
                  gateway,
                  RT_TABLE_MAIN,
                  RTPROT_UNSPEC,
@@ -538,9 +539,7 @@
                  IPAddress::kAddressFamilyIPv4,
                  kAddRouteIPV4InterfaceIndex,
                  dst,
-                 0,
                  src,
-                 0,
                  gateway,
                  RT_TABLE_MAIN,
                  RTPROT_BOOT,
@@ -590,9 +589,7 @@
                  IPAddress::kAddressFamilyIPv4,
                  12,
                  dst,
-                 0,
                  src,
-                 0,
                  gateway,
                  RT_TABLE_MAIN,
                  RTPROT_BOOT,