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