shill: Allow service override of DHCP-derived IP parameters

Create new class StaticIPParameters which encapsulates all of the
property handling for RPC and storage, as well as applying parameters
to an IPConfig::Properties element.  When a DHCP request succeeds
these parameters are used to selectively override values gained from
DHCP with those specified on the service.

BUG=chromium-os:23930
TEST=New unit tests -- manual testing is pending

Change-Id: I3b784f897ec6ffe0c78f2efe615d07d8f8924add
Reviewed-on: https://gerrit.chromium.org/gerrit/21448
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/key_value_store.cc b/key_value_store.cc
index 2d88a57..8fb2139 100644
--- a/key_value_store.cc
+++ b/key_value_store.cc
@@ -18,6 +18,10 @@
   return ContainsKey(bool_properties_, name);
 }
 
+bool KeyValueStore::ContainsInt(const string &name) const {
+  return ContainsKey(int_properties_, name);
+}
+
 bool KeyValueStore::ContainsString(const string &name) const {
   return ContainsKey(string_properties_, name);
 }
@@ -32,6 +36,12 @@
   return it->second;
 }
 
+int32 KeyValueStore::GetInt(const string &name) const {
+  map<string, int32>::const_iterator it(int_properties_.find(name));
+  CHECK(it != int_properties_.end()) << "for int property " << name;
+  return it->second;
+}
+
 const string &KeyValueStore::GetString(const string &name) const {
   map<string, string>::const_iterator it(string_properties_.find(name));
   CHECK(it != string_properties_.end()) << "for string property " << name;
@@ -48,6 +58,10 @@
   bool_properties_[name] = value;
 }
 
+void KeyValueStore::SetInt(const string &name, int32 value) {
+  int_properties_[name] = value;
+}
+
 void KeyValueStore::SetString(const string &name, const string &value) {
   string_properties_[name] = value;
 }
@@ -60,6 +74,10 @@
   string_properties_.erase(name);
 }
 
+void KeyValueStore::RemoveInt(const string &name) {
+  int_properties_.erase(name);
+}
+
 bool KeyValueStore::LookupBool(const string &name, bool default_value) const {
   map<string, bool>::const_iterator it(bool_properties_.find(name));
   return it == bool_properties_.end() ? default_value : it->second;