blob: 01e9f4e613f7c39fce473ffd24f97eefb1d76c49 [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
16ModemClassic::ModemClassic(const std::string &owner,
17 const std::string &path,
18 ControlInterface *control_interface,
19 EventDispatcher *dispatcher,
20 Metrics *metrics,
21 Manager *manager,
22 mobile_provider_db *provider_db)
23 : Modem(owner, path, control_interface, dispatcher, metrics, manager,
24 provider_db) {
25}
26
27ModemClassic::~ModemClassic() {}
28
David Rochbergfa1d31d2012-03-20 10:38:07 -040029bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties,
30 string *name) const {
31 return DBusProperties::GetString(modem_properties, kPropertyLinkName, name);
32}
33
34void ModemClassic::CreateDeviceClassic(
35 const DBusPropertiesMap &modem_properties) {
Eric Shienbrood11567d02012-04-10 18:08:49 -040036 Init();
David Rochbergfa1d31d2012-03-20 10:38:07 -040037 uint32 mm_type = kuint32max;
38 DBusProperties::GetUint32(modem_properties, kPropertyType, &mm_type);
39 switch (mm_type) {
40 case MM_MODEM_TYPE_CDMA:
41 set_type(Cellular::kTypeCDMA);
42 break;
43 case MM_MODEM_TYPE_GSM:
44 set_type(Cellular::kTypeGSM);
45 break;
46 default:
47 LOG(ERROR) << "Unsupported cellular modem type: " << mm_type;
48 return;
49 }
50 uint32 ip_method = kuint32max;
51 if (!DBusProperties::GetUint32(modem_properties,
52 kPropertyIPMethod,
53 &ip_method) ||
54 ip_method != MM_MODEM_IP_METHOD_DHCP) {
55 LOG(ERROR) << "Unsupported IP method: " << ip_method;
56 return;
57 }
Eric Shienbrood11567d02012-04-10 18:08:49 -040058 CreateDeviceFromModemProperties(modem_properties);
David Rochbergfa1d31d2012-03-20 10:38:07 -040059}
60
Jason Glasgow4c0724a2012-04-17 15:47:40 -040061string ModemClassic::GetModemInterface(void) const {
62 return string(MM_MODEM_INTERFACE);
63}
64
David Rochbergfa1d31d2012-03-20 10:38:07 -040065} // namespace shill