blob: c42699ff5b4d0f58fc16e6325a6ca638e2b4e8b3 [file] [log] [blame]
Ben Chan99c8a4d2012-05-01 08:11:53 -07001// 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#ifndef SHILL_WIMAX_H_
6#define SHILL_WIMAX_H_
7
Darin Petkovc63dcf02012-05-24 11:51:43 +02008#include <set>
9
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020010#include <chromeos/dbus/service_constants.h>
Darin Petkovb72b62e2012-05-15 16:55:36 +020011#include <gtest/gtest_prod.h> // for FRIEND_TEST
12
Ben Chan99c8a4d2012-05-01 08:11:53 -070013#include "shill/device.h"
14
15namespace shill {
16
Darin Petkovb72b62e2012-05-15 16:55:36 +020017class ProxyFactory;
18class WiMaxDeviceProxyInterface;
19
Ben Chan99c8a4d2012-05-01 08:11:53 -070020class WiMax : public Device {
21 public:
22 WiMax(ControlInterface *control,
23 EventDispatcher *dispatcher,
24 Metrics *metrics,
25 Manager *manager,
26 const std::string &link_name,
Ben Chan4e64d2d2012-05-16 00:02:25 -070027 const std::string &address,
Darin Petkovb72b62e2012-05-15 16:55:36 +020028 int interface_index,
29 const RpcIdentifier &path);
Ben Chan99c8a4d2012-05-01 08:11:53 -070030
31 virtual ~WiMax();
32
Darin Petkov9893d9c2012-05-17 15:27:31 -070033 // Inherited from Device.
Ben Chan99c8a4d2012-05-01 08:11:53 -070034 virtual void Start(Error *error, const EnabledStateChangedCallback &callback);
35 virtual void Stop(Error *error, const EnabledStateChangedCallback &callback);
Ben Chan99c8a4d2012-05-01 08:11:53 -070036 virtual bool TechnologyIs(const Technology::Identifier type) const;
Darin Petkov9893d9c2012-05-17 15:27:31 -070037 virtual void Scan(Error *error);
Ben Chan99c8a4d2012-05-01 08:11:53 -070038
Darin Petkov9893d9c2012-05-17 15:27:31 -070039 virtual void ConnectTo(const WiMaxServiceRefPtr &service, Error *error);
Darin Petkovc63dcf02012-05-24 11:51:43 +020040 virtual void DisconnectFrom(const ServiceRefPtr &service, Error *error);
Ben Chan99c8a4d2012-05-01 08:11:53 -070041
Darin Petkovc63dcf02012-05-24 11:51:43 +020042 // Signaled by |service| when stopped.
43 virtual void OnServiceStopped(const WiMaxServiceRefPtr &service);
Darin Petkovd1cd7972012-05-22 15:26:15 +020044
Darin Petkovb96a4512012-06-04 11:02:49 +020045 // Signaled by WiMaxProvider when the RPC device disappears. The provider will
46 // deregister and destroy the device after invoking this method.
47 virtual void OnDeviceVanished();
48
Darin Petkovb72b62e2012-05-15 16:55:36 +020049 const RpcIdentifier &path() const { return path_; }
Darin Petkov9893d9c2012-05-17 15:27:31 -070050 bool scanning() const { return scanning_; }
Darin Petkovc63dcf02012-05-24 11:51:43 +020051 const std::set<RpcIdentifier> &networks() const { return networks_; }
Darin Petkovb72b62e2012-05-15 16:55:36 +020052
Ben Chan99c8a4d2012-05-01 08:11:53 -070053 private:
Darin Petkovb72b62e2012-05-15 16:55:36 +020054 friend class WiMaxTest;
Darin Petkovc63dcf02012-05-24 11:51:43 +020055 FRIEND_TEST(WiMaxProviderTest, OnNetworksChanged);
Darin Petkovb96a4512012-06-04 11:02:49 +020056 FRIEND_TEST(WiMaxTest, DropService);
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020057 FRIEND_TEST(WiMaxTest, OnConnectComplete);
Darin Petkovb96a4512012-06-04 11:02:49 +020058 FRIEND_TEST(WiMaxTest, OnDeviceVanished);
Darin Petkov9893d9c2012-05-17 15:27:31 -070059 FRIEND_TEST(WiMaxTest, OnNetworksChanged);
Darin Petkovc63dcf02012-05-24 11:51:43 +020060 FRIEND_TEST(WiMaxTest, OnServiceStopped);
Darin Petkova3f9f772012-05-31 12:11:28 +020061 FRIEND_TEST(WiMaxTest, OnStatusChanged);
Darin Petkovb72b62e2012-05-15 16:55:36 +020062 FRIEND_TEST(WiMaxTest, StartStop);
63
Darin Petkov912f0de2012-05-16 14:12:14 +020064 static const int kTimeoutDefault;
65
Darin Petkov9893d9c2012-05-17 15:27:31 -070066 void OnScanNetworksComplete(const Error &error);
Darin Petkov912f0de2012-05-16 14:12:14 +020067 void OnConnectComplete(const Error &error);
68 void OnDisconnectComplete(const Error &error);
69 void OnEnableComplete(const EnabledStateChangedCallback &callback,
70 const Error &error);
71 void OnDisableComplete(const EnabledStateChangedCallback &callback,
72 const Error &error);
73
Darin Petkov9893d9c2012-05-17 15:27:31 -070074 void OnNetworksChanged(const RpcIdentifiers &networks);
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020075 void OnStatusChanged(wimax_manager::DeviceStatus status);
Darin Petkov9893d9c2012-05-17 15:27:31 -070076
Darin Petkovb96a4512012-06-04 11:02:49 +020077 void DropService(Service::ConnectState state);
Darin Petkovc63dcf02012-05-24 11:51:43 +020078 void DropConnection();
Darin Petkov9893d9c2012-05-17 15:27:31 -070079
Darin Petkovb72b62e2012-05-15 16:55:36 +020080 const RpcIdentifier path_;
81
82 scoped_ptr<WiMaxDeviceProxyInterface> proxy_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070083 bool scanning_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070084 WiMaxServiceRefPtr pending_service_;
Darin Petkovc63dcf02012-05-24 11:51:43 +020085 std::set<RpcIdentifier> networks_;
Darin Petkovb72b62e2012-05-15 16:55:36 +020086
87 ProxyFactory *proxy_factory_;
88
Ben Chan99c8a4d2012-05-01 08:11:53 -070089 DISALLOW_COPY_AND_ASSIGN(WiMax);
90};
91
92} // namespace shill
93
94#endif // SHILL_WIMAX_H_