blob: 2d55e3afbafa2888146abaf4253be847b07edef7 [file] [log] [blame]
David Rochbergfa1d31d2012-03-20 10:38:07 -04001// 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
11using std::string;
12using std::vector;
13
14namespace shill {
15
Jason Glasgowa585fc32012-06-06 11:04:09 -040016ModemClassic::ModemClassic(const string &owner,
17 const string &service,
18 const string &path,
David Rochbergfa1d31d2012-03-20 10:38:07 -040019 ControlInterface *control_interface,
20 EventDispatcher *dispatcher,
21 Metrics *metrics,
22 Manager *manager,
Ben Chan62028b22012-11-05 11:20:02 -080023 CellularOperatorInfo *cellular_operator_info,
David Rochbergfa1d31d2012-03-20 10:38:07 -040024 mobile_provider_db *provider_db)
Jason Glasgowa585fc32012-06-06 11:04:09 -040025 : Modem(owner, service, path, control_interface, dispatcher, metrics,
Ben Chan62028b22012-11-05 11:20:02 -080026 manager, cellular_operator_info, provider_db) {
David Rochbergfa1d31d2012-03-20 10:38:07 -040027}
28
29ModemClassic::~ModemClassic() {}
30
David Rochbergfa1d31d2012-03-20 10:38:07 -040031bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties,
32 string *name) const {
33 return DBusProperties::GetString(modem_properties, kPropertyLinkName, name);
34}
35
36void ModemClassic::CreateDeviceClassic(
37 const DBusPropertiesMap &modem_properties) {
Eric Shienbrood11567d02012-04-10 18:08:49 -040038 Init();
David Rochbergfa1d31d2012-03-20 10:38:07 -040039 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 Chan876efd32012-09-28 15:25:13 -070060
61 DBusInterfaceToProperties properties;
62 properties[MM_MODEM_INTERFACE] = modem_properties;
63 CreateDeviceFromModemProperties(properties);
David Rochbergfa1d31d2012-03-20 10:38:07 -040064}
65
Jason Glasgow4c0724a2012-04-17 15:47:40 -040066string ModemClassic::GetModemInterface(void) const {
67 return string(MM_MODEM_INTERFACE);
68}
69
David Rochbergfa1d31d2012-03-20 10:38:07 -040070} // namespace shill