blob: e5c11c0957914b6a3a36c9f6cf8579fe41b875b7 [file] [log] [blame]
Thieu Le3426c8f2012-01-11 17:35:11 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Paul Stewartf1ce5d22011-05-19 13:10:20 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Darin Petkovafa6fc42011-06-21 16:21:08 -07005#include "shill/ethernet_service.h"
6
Paul Stewartf1ce5d22011-05-19 13:10:20 -07007#include <time.h>
8#include <stdio.h>
9#include <netinet/ether.h>
10#include <linux/if.h>
11
12#include <string>
13
14#include <base/logging.h>
Chris Masone34af2182011-08-22 11:59:36 -070015#include <base/stringprintf.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070016#include <chromeos/dbus/service_constants.h>
Paul Stewartf1ce5d22011-05-19 13:10:20 -070017
18#include "shill/control_interface.h"
19#include "shill/device.h"
20#include "shill/device_info.h"
Darin Petkovafa6fc42011-06-21 16:21:08 -070021#include "shill/ethernet.h"
Paul Stewart26b327e2011-10-19 11:38:09 -070022#include "shill/event_dispatcher.h"
Paul Stewartf1ce5d22011-05-19 13:10:20 -070023#include "shill/manager.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070024#include "shill/profile.h"
Paul Stewartf1ce5d22011-05-19 13:10:20 -070025
Paul Stewartf1ce5d22011-05-19 13:10:20 -070026using std::string;
27
28namespace shill {
Darin Petkovafa6fc42011-06-21 16:21:08 -070029
Chris Masone34af2182011-08-22 11:59:36 -070030// static
31const char EthernetService::kServiceType[] = "ethernet";
32
Paul Stewartf1ce5d22011-05-19 13:10:20 -070033EthernetService::EthernetService(ControlInterface *control_interface,
34 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -080035 Metrics *metrics,
Chris Masone6791a432011-07-12 13:23:19 -070036 Manager *manager,
mukesh agrawal51a7e932011-07-27 16:18:26 -070037 const EthernetRefPtr &device)
Thieu Le3426c8f2012-01-11 17:35:11 -080038 : Service(control_interface, dispatcher, metrics, manager,
39 Technology::kEthernet),
mukesh agrawal7a4e4002011-09-06 11:26:05 -070040 ethernet_(device) {
Gaurav Shah435de2c2011-11-17 19:01:07 -080041 set_connectable(true);
Darin Petkovafa6fc42011-06-21 16:21:08 -070042 set_auto_connect(true);
Paul Stewart0ad019a2012-04-19 11:06:43 -070043 set_friendly_name("Ethernet");
mukesh agrawal8f3f7752012-02-17 19:42:09 -080044 SetStrength(kStrengthMax);
Paul Stewartf1ce5d22011-05-19 13:10:20 -070045}
46
47EthernetService::~EthernetService() { }
48
Paul Stewart22aa71b2011-09-16 12:15:11 -070049bool EthernetService::TechnologyIs(const Technology::Identifier type) const {
50 return ethernet_->TechnologyIs(type);
51}
52
Gaurav Shah1b7a6162011-11-09 11:41:01 -080053std::string EthernetService::GetDeviceRpcId(Error */*error*/) {
Chris Masone95207da2011-06-29 16:50:49 -070054 return ethernet_->GetRpcIdentifier();
55}
56
Chris Masone6515aab2011-10-12 16:19:09 -070057string EthernetService::GetStorageIdentifier() const {
Chris Masone9d779932011-08-25 16:33:41 -070058 return base::StringPrintf("%s_%s",
59 kServiceType, ethernet_->address().c_str());
Chris Masone34af2182011-08-22 11:59:36 -070060}
61
Paul Stewartf1ce5d22011-05-19 13:10:20 -070062} // namespace shill