San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 1 | /* |
| 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 Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 16 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 17 | #ifndef _SUPPLICANT_H |
| 18 | #define _SUPPLICANT_H |
| 19 | |
| 20 | struct wpa_ctrl; |
| 21 | class SupplicantListener; |
San Mehat | 5d6d417 | 2009-05-14 15:00:06 -0700 | [diff] [blame] | 22 | class ServiceManager; |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 23 | class Controller; |
| 24 | class WifiController; |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 25 | class SupplicantStatus; |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 26 | |
| 27 | #include <pthread.h> |
| 28 | |
San Mehat | 82a2116 | 2009-05-12 17:26:28 -0700 | [diff] [blame] | 29 | #include "WifiNetwork.h" |
San Mehat | 78828ff | 2009-06-01 08:38:45 -0700 | [diff] [blame] | 30 | #include "ISupplicantEventHandler.h" |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 31 | |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 32 | class Supplicant { |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 33 | struct wpa_ctrl *mCtrl; |
| 34 | struct wpa_ctrl *mMonitor; |
| 35 | SupplicantListener *mListener; |
San Mehat | 5d6d417 | 2009-05-14 15:00:06 -0700 | [diff] [blame] | 36 | ServiceManager *mServiceManager; |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 37 | WifiController *mController; |
| 38 | char *mInterfaceName; |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 39 | |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 40 | WifiNetworkCollection *mNetworks; |
| 41 | pthread_mutex_t mNetworksLock; |
| 42 | ISupplicantEventHandler *mHandlers; |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 43 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 44 | public: |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 45 | Supplicant(WifiController *wc, ISupplicantEventHandler *handlers); |
San Mehat | 5d6d417 | 2009-05-14 15:00:06 -0700 | [diff] [blame] | 46 | virtual ~Supplicant(); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 47 | |
San Mehat | e67651c | 2009-05-12 15:50:49 -0700 | [diff] [blame] | 48 | int start(); |
| 49 | int stop(); |
| 50 | bool isStarted(); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 51 | |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 52 | int setScanMode(bool active); |
| 53 | int triggerScan(); |
San Mehat | 82a2116 | 2009-05-12 17:26:28 -0700 | [diff] [blame] | 54 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 55 | WifiNetwork *createNetwork(); |
| 56 | WifiNetwork *lookupNetwork(int networkId); |
| 57 | int removeNetwork(WifiNetwork *net); |
San Mehat | 82a2116 | 2009-05-12 17:26:28 -0700 | [diff] [blame] | 58 | WifiNetworkCollection *createNetworkList(); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 59 | 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 Mehat | e67651c | 2009-05-12 15:50:49 -0700 | [diff] [blame] | 65 | |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 66 | 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 Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 81 | SupplicantStatus *getStatus(); |
| 82 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 83 | Controller *getController() { return (Controller *) mController; } |
| 84 | const char *getInterfaceName() { return mInterfaceName; } |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 85 | |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 86 | int sendCommand(const char *cmd, char *reply, size_t *reply_len); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 87 | |
San Mehat | 78828ff | 2009-06-01 08:38:45 -0700 | [diff] [blame] | 88 | private: |
| 89 | int connectToSupplicant(); |
San Mehat | 78828ff | 2009-06-01 08:38:45 -0700 | [diff] [blame] | 90 | int setupConfig(); |
| 91 | int retrieveInterfaceName(); |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 92 | WifiNetwork *lookupNetwork_UNLOCKED(int networkId); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | #endif |