blob: 360ccc28c89d8e1d8c6e8448744c744539403b69 [file] [log] [blame]
San Mehat82a21162009-05-12 17:26:28 -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 */
16
17#ifndef _WIFI_NETWORK_H
18#define _WIFI_NETWORK_H
19
20#include <sys/types.h>
21
San Mehat3c5a6f02009-05-22 15:36:13 -070022#include <utils/List.h>
San Mehat82a21162009-05-12 17:26:28 -070023
24class KeyManagementMask {
25public:
San Mehat21e90f02009-06-01 10:04:21 -070026 static const uint32_t UNKNOWN = 0;
27 static const uint32_t NONE = 0x01;
28 static const uint32_t WPA_PSK = 0x02;
29 static const uint32_t WPA_EAP = 0x04;
30 static const uint32_t IEEE8021X = 0x08;
San Mehat82a21162009-05-12 17:26:28 -070031 static const uint32_t ALL = WPA_PSK | WPA_EAP | IEEE8021X;
32};
33
34class SecurityProtocolMask {
35public:
36 static const uint32_t WPA = 0x01;
37 static const uint32_t RSN = 0x02;
38};
39
40class AuthenticationAlgorithmMask {
41public:
42 static const uint32_t OPEN = 0x01;
43 static const uint32_t SHARED = 0x02;
44 static const uint32_t LEAP = 0x04;
45};
46
San Mehat3c5a6f02009-05-22 15:36:13 -070047class PairwiseCiphersMask {
San Mehat82a21162009-05-12 17:26:28 -070048public:
49 static const uint32_t NONE = 0x00;
50 static const uint32_t TKIP = 0x01;
51 static const uint32_t CCMP = 0x02;
52};
53
San Mehat3c5a6f02009-05-22 15:36:13 -070054class GroupCiphersMask {
San Mehat82a21162009-05-12 17:26:28 -070055public:
56 static const uint32_t WEP40 = 0x01;
57 static const uint32_t WEP104 = 0x02;
58 static const uint32_t TKIP = 0x04;
59 static const uint32_t CCMP = 0x08;
60};
61
62class Supplicant;
San Mehat3c5a6f02009-05-22 15:36:13 -070063class InterfaceConfig;
64class Controller;
65class WifiController;
San Mehat82a21162009-05-12 17:26:28 -070066
San Mehat3c5a6f02009-05-22 15:36:13 -070067#include "IPropertyProvider.h"
68
69class WifiNetwork : public IPropertyProvider{
70public:
71 static const char *PropertyNames[];
72
73private:
San Mehat82a21162009-05-12 17:26:28 -070074 Supplicant *mSuppl;
San Mehat3c5a6f02009-05-22 15:36:13 -070075 InterfaceConfig *mIfaceCfg;
76 WifiController *mController;
San Mehat82a21162009-05-12 17:26:28 -070077
78 /*
79 * Unique network id - normally provided by supplicant
80 */
81 int mNetid;
82
83 /*
84 * The networks' SSID. Can either be an ASCII string,
85 * which must be enclosed in double quotation marks
86 * (ie: "MyNetwork"), or a string of hex digits which
87 * are not enclosed in quotes (ie: 01ab7893)
88 */
89 char *mSsid;
90
91 /*
92 * When set, this entry should only be used
93 * when associating with the AP having the specified
94 * BSSID. The value is a string in the format of an
95 * Ethernet MAC address
96 */
97 char *mBssid;
98
99 /*
100 * Pre-shared key for use with WPA-PSK
101 */
102 char *mPsk;
103
104 /*
105 * Up to four WEP keys. Either in ASCII string enclosed in
106 * double quotes, or a string of hex digits
107 */
108 char *mWepKeys[4];
109
110 /*
111 * Default WEP key index, ranging from 0 -> NUM_WEP_KEYS -1
112 */
113 int mDefaultKeyIndex;
114
115 /*
116 * Priority determines the preference given to a network by
117 * supplicant when choosing an access point with which
118 * to associate
119 */
120 int mPriority;
121
122 /*
123 * This is a network that does not broadcast it's SSID, so an
124 * SSID-specific probe request must be used for scans.
125 */
126 char *mHiddenSsid;
127
128 /*
129 * The set of key management protocols supported by this configuration.
130 */
131 uint32_t mAllowedKeyManagement;
132
133 /*
134 * The set of security protocols supported by this configuration.
135 */
136 uint32_t mAllowedProtocols;
137
138 /*
139 * The set of authentication protocols supported by this configuration.
140 */
141 uint32_t mAllowedAuthAlgorithms;
142
143 /*
144 * The set of pairwise ciphers for WPA supported by this configuration.
145 */
146 uint32_t mAllowedPairwiseCiphers;
147
148 /*
149 * The set of group ciphers for WPA supported by this configuration.
150 */
151 uint32_t mAllowedGroupCiphers;
152
San Mehat3c5a6f02009-05-22 15:36:13 -0700153 /*
154 * Set if this Network is enabled
155 */
156 bool mEnabled;
157
158private:
159 WifiNetwork();
160 int registerProperties();
161 int unregisterProperties();
162
San Mehat82a21162009-05-12 17:26:28 -0700163public:
San Mehat3c5a6f02009-05-22 15:36:13 -0700164 WifiNetwork(WifiController *c, Supplicant *suppl, int networkId);
165 WifiNetwork(WifiController *c, Supplicant *suppl, const char *data);
166
San Mehat82a21162009-05-12 17:26:28 -0700167 virtual ~WifiNetwork();
168
San Mehat3c5a6f02009-05-22 15:36:13 -0700169 WifiNetwork *clone();
170
San Mehat82a21162009-05-12 17:26:28 -0700171 int getNetworkId() { return mNetid; }
172 const char *getSsid() { return mSsid; }
173 const char *getBssid() { return mBssid; }
174 const char *getPsk() { return mPsk; }
175 const char *getWepKey(int idx) { return mWepKeys[idx]; }
176 int getDefaultKeyIndex() { return mDefaultKeyIndex; }
177 int getPriority() { return mPriority; }
178 const char *getHiddenSsid() { return mHiddenSsid; }
179 uint32_t getAllowedKeyManagement() { return mAllowedKeyManagement; }
180 uint32_t getAllowedProtocols() { return mAllowedProtocols; }
181 uint32_t getAllowedAuthAlgorithms() { return mAllowedAuthAlgorithms; }
182 uint32_t getAllowedPairwiseCiphers() { return mAllowedPairwiseCiphers; }
183 uint32_t getAllowedGroupCiphers() { return mAllowedGroupCiphers; }
San Mehat3c5a6f02009-05-22 15:36:13 -0700184 bool getEnabled() { return mEnabled; }
185 Controller *getController() { return (Controller *) mController; }
San Mehat82a21162009-05-12 17:26:28 -0700186
San Mehat3c5a6f02009-05-22 15:36:13 -0700187 int set(const char *name, const char *value);
188 const char *get(const char *name, char *buffer, size_t maxsize);
189
190// InterfaceConfig *getIfaceCfg() { return mIfaceCfg; }
191
192 int setEnabled(bool enabled);
193 int setSsid(const char *ssid);
194 int setBssid(const char *bssid);
195 int setPsk(const char *psk);
196 int setWepKey(int idx, const char *key);
San Mehat82a21162009-05-12 17:26:28 -0700197 int setDefaultKeyIndex(int idx);
198 int setPriority(int pri);
San Mehat3c5a6f02009-05-22 15:36:13 -0700199 int setHiddenSsid(const char *ssid);
San Mehat82a21162009-05-12 17:26:28 -0700200 int setAllowedKeyManagement(uint32_t mask);
201 int setAllowedProtocols(uint32_t mask);
San Mehat3c5a6f02009-05-22 15:36:13 -0700202 int setAllowedAuthAlgorithms(uint32_t mask);
San Mehat82a21162009-05-12 17:26:28 -0700203 int setAllowedPairwiseCiphers(uint32_t mask);
204 int setAllowedGroupCiphers(uint32_t mask);
San Mehat3c5a6f02009-05-22 15:36:13 -0700205
206 // XXX:Should this really be exposed?.. meh
207 int refresh();
San Mehat82a21162009-05-12 17:26:28 -0700208};
209
210typedef android::List<WifiNetwork *> WifiNetworkCollection;
211
212#endif