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/routing_table.cc b/routing_table.cc
index 25b9b8f..f7edf03 100644
--- a/routing_table.cc
+++ b/routing_table.cc
@@ -148,9 +148,7 @@
return AddRoute(interface_index,
RoutingTableEntry(default_address,
- 0,
default_address,
- 0,
gateway_address,
metric,
RT_SCOPE_UNIVERSE,
@@ -242,10 +240,8 @@
}
RoutingTableEntry entry(
- IPAddress(msg.family(), dst_bytes),
- route_status.dst_prefix,
- IPAddress(msg.family(), src_bytes),
- route_status.src_prefix,
+ IPAddress(msg.family(), dst_bytes, route_status.dst_prefix),
+ IPAddress(msg.family(), src_bytes, route_status.src_prefix),
IPAddress(msg.family(), gateway_bytes),
metric,
route_status.scope,
@@ -255,9 +251,7 @@
vector<RoutingTableEntry>::iterator nent;
for (nent = table.begin(); nent != table.end(); ++nent) {
if (nent->dst.Equals(entry.dst) &&
- nent->dst_prefix == entry.dst_prefix &&
nent->src.Equals(entry.src) &&
- nent->src_prefix == entry.src_prefix &&
nent->gateway.Equals(entry.gateway) &&
nent->scope == entry.scope) {
if (msg.mode() == RTNLMessage::kMessageModeDelete) {
@@ -292,8 +286,8 @@
entry.dst.family());
msg.set_route_status(RTNLMessage::RouteStatus(
- entry.dst_prefix,
- entry.src_prefix,
+ entry.dst.prefix(),
+ entry.src.prefix(),
RT_TABLE_MAIN,
RTPROT_BOOT,
entry.scope,