blob: 3900f4f7fb12cdd66f3d5c92e4577d18246875a4 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
San Mehat3c5a6f02009-05-22 15:36:13 -070016
San Mehatdc266072009-05-06 11:16:52 -070017#ifndef _SUPPLICANT_H
18#define _SUPPLICANT_H
19
20struct wpa_ctrl;
21class SupplicantListener;
San Mehat5d6d4172009-05-14 15:00:06 -070022class ServiceManager;
San Mehat3c5a6f02009-05-22 15:36:13 -070023class Controller;
24class WifiController;
San Mehat3aff2d12009-06-15 14:10:44 -070025class SupplicantStatus;
San Mehatdc266072009-05-06 11:16:52 -070026
27#include <pthread.h>
28
San Mehat82a21162009-05-12 17:26:28 -070029#include "WifiNetwork.h"
San Mehat78828ff2009-06-01 08:38:45 -070030#include "ISupplicantEventHandler.h"
San Mehatdc266072009-05-06 11:16:52 -070031
San Mehat3aff2d12009-06-15 14:10:44 -070032class Supplicant {
San Mehatdc266072009-05-06 11:16:52 -070033 struct wpa_ctrl *mCtrl;
34 struct wpa_ctrl *mMonitor;
35 SupplicantListener *mListener;
San Mehat5d6d4172009-05-14 15:00:06 -070036 ServiceManager *mServiceManager;
San Mehat3c5a6f02009-05-22 15:36:13 -070037 WifiController *mController;
38 char *mInterfaceName;
San Mehatdc266072009-05-06 11:16:52 -070039
San Mehat3aff2d12009-06-15 14:10:44 -070040 WifiNetworkCollection *mNetworks;
41 pthread_mutex_t mNetworksLock;
42 ISupplicantEventHandler *mHandlers;
San Mehat3c5a6f02009-05-22 15:36:13 -070043
San Mehatdc266072009-05-06 11:16:52 -070044public:
San Mehat3aff2d12009-06-15 14:10:44 -070045 Supplicant(WifiController *wc, ISupplicantEventHandler *handlers);
San Mehat5d6d4172009-05-14 15:00:06 -070046 virtual ~Supplicant();
San Mehatdc266072009-05-06 11:16:52 -070047
San Mehate67651c2009-05-12 15:50:49 -070048 int start();
49 int stop();
50 bool isStarted();
San Mehatdc266072009-05-06 11:16:52 -070051
San Mehatc4a895b2009-06-23 21:10:57 -070052 int setScanMode(bool active);
53 int triggerScan();
San Mehat82a21162009-05-12 17:26:28 -070054
San Mehat3c5a6f02009-05-22 15:36:13 -070055 WifiNetwork *createNetwork();
56 WifiNetwork *lookupNetwork(int networkId);
57 int removeNetwork(WifiNetwork *net);
San Mehat82a21162009-05-12 17:26:28 -070058 WifiNetworkCollection *createNetworkList();
San Mehat3c5a6f02009-05-22 15:36:13 -070059 int refreshNetworkList();
60
61 int setNetworkVar(int networkId, const char *var, const char *value);
62 const char *getNetworkVar(int networkid, const char *var, char *buffer,
63 size_t max);
64 int enableNetwork(int networkId, bool enabled);
San Mehate67651c2009-05-12 15:50:49 -070065
San Mehatc4a895b2009-06-23 21:10:57 -070066 int disconnect();
67 int reconnect();
68 int reassociate();
69 int setApScanMode(int mode);
70 int enablePacketFilter();
71 int disablePacketFilter();
72 int setBluetoothCoexistenceMode(int mode);
73 int enableBluetoothCoexistenceScan();
74 int disableBluetoothCoexistenceScan();
75 int stopDriver();
76 int startDriver();
77 int getRssi(int *buffer);
78 int getLinkSpeed();
79 int getNetworkCount();
80
San Mehat3aff2d12009-06-15 14:10:44 -070081 SupplicantStatus *getStatus();
82
San Mehat3c5a6f02009-05-22 15:36:13 -070083 Controller *getController() { return (Controller *) mController; }
84 const char *getInterfaceName() { return mInterfaceName; }
San Mehatdc266072009-05-06 11:16:52 -070085
San Mehat3aff2d12009-06-15 14:10:44 -070086 int sendCommand(const char *cmd, char *reply, size_t *reply_len);
San Mehatdc266072009-05-06 11:16:52 -070087
San Mehat78828ff2009-06-01 08:38:45 -070088private:
89 int connectToSupplicant();
San Mehat78828ff2009-06-01 08:38:45 -070090 int setupConfig();
91 int retrieveInterfaceName();
San Mehat3aff2d12009-06-15 14:10:44 -070092 WifiNetwork *lookupNetwork_UNLOCKED(int networkId);
San Mehatdc266072009-05-06 11:16:52 -070093};
94
95#endif