blob: 95778c89c5c734e78414f8b07193deb58528d0dc [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,
23 mobile_provider_db *provider_db)
Jason Glasgowa585fc32012-06-06 11:04:09 -040024 : Modem(owner, service, path, control_interface, dispatcher, metrics,
25 manager, provider_db) {
David Rochbergfa1d31d2012-03-20 10:38:07 -040026}
27
28ModemClassic::~ModemClassic() {}
29
David Rochbergfa1d31d2012-03-20 10:38:07 -040030bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties,
31 string *name) const {
32 return DBusProperties::GetString(modem_properties, kPropertyLinkName, name);
33}
34
35void ModemClassic::CreateDeviceClassic(
36 const DBusPropertiesMap &modem_properties) {
Eric Shienbrood11567d02012-04-10 18:08:49 -040037 Init();
David Rochbergfa1d31d2012-03-20 10:38:07 -040038 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 }
Eric Shienbrood11567d02012-04-10 18:08:49 -040059 CreateDeviceFromModemProperties(modem_properties);
David Rochbergfa1d31d2012-03-20 10:38:07 -040060}
61
Jason Glasgow4c0724a2012-04-17 15:47:40 -040062string ModemClassic::GetModemInterface(void) const {
63 return string(MM_MODEM_INTERFACE);
64}
65
David Rochbergfa1d31d2012-03-20 10:38:07 -040066} // namespace shill