blob: 52e3929bc8c29ab994be79a4163e279a9904ae49 [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,
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070019 ModemInfo *modem_info)
20 : Modem(owner, service, path, modem_info) {}
David Rochbergfa1d31d2012-03-20 10:38:07 -040021
22ModemClassic::~ModemClassic() {}
23
David Rochbergfa1d31d2012-03-20 10:38:07 -040024bool ModemClassic::GetLinkName(const DBusPropertiesMap& modem_properties,
25 string *name) const {
26 return DBusProperties::GetString(modem_properties, kPropertyLinkName, name);
27}
28
29void ModemClassic::CreateDeviceClassic(
30 const DBusPropertiesMap &modem_properties) {
Eric Shienbrood11567d02012-04-10 18:08:49 -040031 Init();
David Rochbergfa1d31d2012-03-20 10:38:07 -040032 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 Chan876efd32012-09-28 15:25:13 -070053
54 DBusInterfaceToProperties properties;
55 properties[MM_MODEM_INTERFACE] = modem_properties;
56 CreateDeviceFromModemProperties(properties);
David Rochbergfa1d31d2012-03-20 10:38:07 -040057}
58
Jason Glasgow4c0724a2012-04-17 15:47:40 -040059string ModemClassic::GetModemInterface(void) const {
60 return string(MM_MODEM_INTERFACE);
61}
62
David Rochbergfa1d31d2012-03-20 10:38:07 -040063} // namespace shill