[shill] Use flimflam-esque storage ids
Devices:
device_<MAC>
IPConfig:
ipconfig_<MAC of associated device>_0
Services:
ethernet_<MAC of associated device>
wifi_<MAC of associated device>_<SSID>_<mode>_<security>
cellular_<MAC of associated device>_<Network_name>
BUG=chromium-os:17744
TEST=unit
Change-Id: Ibf061f9c184e7c86f5afcf97d48e321fc74bde1c
Reviewed-on: http://gerrit.chromium.org/gerrit/6412
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/ipconfig.cc b/ipconfig.cc
index 8b45703..63e453d 100644
--- a/ipconfig.cc
+++ b/ipconfig.cc
@@ -72,9 +72,12 @@
return adaptor_->GetRpcIdentifier();
}
-string IPConfig::GetStorageIdentifier() {
+string IPConfig::GetStorageIdentifier(const string &id_suffix) {
string id = GetRpcIdentifier();
ControlInterface::RpcIdToStorageId(&id);
+ size_t needle = id.find('_');
+ LOG_IF(ERROR, needle == string::npos) << "No _ in storage id?!?!";
+ id.replace(id.begin() + needle + 1, id.end(), id_suffix);
return id;
}
@@ -90,8 +93,8 @@
return false;
}
-bool IPConfig::Load(StoreInterface *storage) {
- const string id = GetStorageIdentifier();
+bool IPConfig::Load(StoreInterface *storage, const string &id_suffix) {
+ const string id = GetStorageIdentifier(id_suffix);
if (!storage->ContainsGroup(id)) {
LOG(WARNING) << "IPConfig is not available in the persistent store: " << id;
return false;
@@ -101,8 +104,8 @@
return local_type == type();
}
-bool IPConfig::Save(StoreInterface *storage) {
- const string id = GetStorageIdentifier();
+bool IPConfig::Save(StoreInterface *storage, const string &id_suffix) {
+ const string id = GetStorageIdentifier(id_suffix);
storage->SetString(id, kStorageType, type());
return true;
}