David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/modem.h" |
| 6 | |
| 7 | #include <mm/mm-modem.h> |
| 8 | |
| 9 | #include "shill/cellular.h" |
| 10 | |
| 11 | using std::string; |
| 12 | using std::vector; |
| 13 | |
| 14 | namespace shill { |
| 15 | |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 16 | ModemClassic::ModemClassic(const string &owner, |
| 17 | const string &service, |
| 18 | const string &path, |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 19 | ControlInterface *control_interface, |
| 20 | EventDispatcher *dispatcher, |
| 21 | Metrics *metrics, |
| 22 | Manager *manager, |
| 23 | mobile_provider_db *provider_db) |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 24 | : Modem(owner, service, path, control_interface, dispatcher, metrics, |
| 25 | manager, provider_db) { |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | ModemClassic::~ModemClassic() {} |
| 29 | |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 30 | bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties, |
| 31 | string *name) const { |
| 32 | return DBusProperties::GetString(modem_properties, kPropertyLinkName, name); |
| 33 | } |
| 34 | |
| 35 | void ModemClassic::CreateDeviceClassic( |
| 36 | const DBusPropertiesMap &modem_properties) { |
Eric Shienbrood | 11567d0 | 2012-04-10 18:08:49 -0400 | [diff] [blame] | 37 | Init(); |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 38 | uint32 mm_type = kuint32max; |
| 39 | DBusProperties::GetUint32(modem_properties, kPropertyType, &mm_type); |
| 40 | switch (mm_type) { |
| 41 | case MM_MODEM_TYPE_CDMA: |
| 42 | set_type(Cellular::kTypeCDMA); |
| 43 | break; |
| 44 | case MM_MODEM_TYPE_GSM: |
| 45 | set_type(Cellular::kTypeGSM); |
| 46 | break; |
| 47 | default: |
| 48 | LOG(ERROR) << "Unsupported cellular modem type: " << mm_type; |
| 49 | return; |
| 50 | } |
| 51 | uint32 ip_method = kuint32max; |
| 52 | if (!DBusProperties::GetUint32(modem_properties, |
| 53 | kPropertyIPMethod, |
| 54 | &ip_method) || |
| 55 | ip_method != MM_MODEM_IP_METHOD_DHCP) { |
| 56 | LOG(ERROR) << "Unsupported IP method: " << ip_method; |
| 57 | return; |
| 58 | } |
Ben Chan | 876efd3 | 2012-09-28 15:25:13 -0700 | [diff] [blame] | 59 | |
| 60 | DBusInterfaceToProperties properties; |
| 61 | properties[MM_MODEM_INTERFACE] = modem_properties; |
| 62 | CreateDeviceFromModemProperties(properties); |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 63 | } |
| 64 | |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 65 | string ModemClassic::GetModemInterface(void) const { |
| 66 | return string(MM_MODEM_INTERFACE); |
| 67 | } |
| 68 | |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 69 | } // namespace shill |