OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / system / core / nexus / Supplicant.h
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  */
16
17 #ifndef _SUPPLICANT_H
18 #define _SUPPLICANT_H
19
20 struct wpa_ctrl;
21 class SupplicantListener;
22 class ServiceManager;
23 class Controller;
24 class WifiController;
25 class SupplicantStatus;
26
27 #include <pthread.h>
28
29 #include "WifiNetwork.h"
30 #include "ISupplicantEventHandler.h"
31
32 class Supplicant {
33     struct wpa_ctrl      *mCtrl;
34     struct wpa_ctrl      *mMonitor;
35     SupplicantListener   *mListener;
36     ServiceManager       *mServiceManager;
37     WifiController       *mController;
38     char                 *mInterfaceName;
39
40     WifiNetworkCollection   *mNetworks;
41     pthread_mutex_t         mNetworksLock;
42     ISupplicantEventHandler *mHandlers;
43  
44 public:
45     Supplicant(WifiController *wc, ISupplicantEventHandler *handlers);
46     virtual ~Supplicant();
47
48     int start();
49     int stop();
50     bool isStarted();
51
52     int setScanMode(bool active);
53     int triggerScan();
54
55     WifiNetwork *createNetwork();
56     WifiNetwork *lookupNetwork(int networkId);
57     int removeNetwork(WifiNetwork *net);
58     WifiNetworkCollection *createNetworkList();
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);
65
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
81     SupplicantStatus *getStatus();
82
83     Controller *getController() { return (Controller *) mController; }
84     const char *getInterfaceName() { return mInterfaceName; }
85
86     int sendCommand(const char *cmd, char *reply, size_t *reply_len);
87
88 private:
89     int connectToSupplicant();
90     int setupConfig();
91     int retrieveInterfaceName();
92     WifiNetwork *lookupNetwork_UNLOCKED(int networkId);
93 };
94
95 #endif