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, |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 23 | CellularOperatorInfo *cellular_operator_info, |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 24 | mobile_provider_db *provider_db) |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 25 | : Modem(owner, service, path, control_interface, dispatcher, metrics, |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 26 | manager, cellular_operator_info, provider_db) { |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | ModemClassic::~ModemClassic() {} |
| 30 | |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 31 | bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties, |
| 32 | string *name) const { |
| 33 | return DBusProperties::GetString(modem_properties, kPropertyLinkName, name); |
| 34 | } |
| 35 | |
| 36 | void ModemClassic::CreateDeviceClassic( |
| 37 | const DBusPropertiesMap &modem_properties) { |
Eric Shienbrood | 11567d0 | 2012-04-10 18:08:49 -0400 | [diff] [blame] | 38 | Init(); |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 39 | uint32 mm_type = kuint32max; |
| 40 | DBusProperties::GetUint32(modem_properties, kPropertyType, &mm_type); |
| 41 | switch (mm_type) { |
| 42 | case MM_MODEM_TYPE_CDMA: |
| 43 | set_type(Cellular::kTypeCDMA); |
| 44 | break; |
| 45 | case MM_MODEM_TYPE_GSM: |
| 46 | set_type(Cellular::kTypeGSM); |
| 47 | break; |
| 48 | default: |
| 49 | LOG(ERROR) << "Unsupported cellular modem type: " << mm_type; |
| 50 | return; |
| 51 | } |
| 52 | uint32 ip_method = kuint32max; |
| 53 | if (!DBusProperties::GetUint32(modem_properties, |
| 54 | kPropertyIPMethod, |
| 55 | &ip_method) || |
| 56 | ip_method != MM_MODEM_IP_METHOD_DHCP) { |
| 57 | LOG(ERROR) << "Unsupported IP method: " << ip_method; |
| 58 | return; |
| 59 | } |
Ben Chan | 876efd3 | 2012-09-28 15:25:13 -0700 | [diff] [blame] | 60 | |
| 61 | DBusInterfaceToProperties properties; |
| 62 | properties[MM_MODEM_INTERFACE] = modem_properties; |
| 63 | CreateDeviceFromModemProperties(properties); |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 64 | } |
| 65 | |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 66 | string ModemClassic::GetModemInterface(void) const { |
| 67 | return string(MM_MODEM_INTERFACE); |
| 68 | } |
| 69 | |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 70 | } // namespace shill |