blob: bdffa8be61b6681a6e57f04cb7b375ef6cc4565e [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:
26 static const uint32_t NONE = 0;
27 static const uint32_t WPA_PSK = 0x01;
28 static const uint32_t WPA_EAP = 0x02;
29 static const uint32_t IEEE8021X = 0x04;
30 static const uint32_t ALL = WPA_PSK | WPA_EAP | IEEE8021X;
31};
32
33class SecurityProtocolMask {
34public:
35 static const uint32_t WPA = 0x01;
36 static const uint32_t RSN = 0x02;
37};
38
39class AuthenticationAlgorithmMask {
40public:
41 static const uint32_t OPEN = 0x01;
42 static const uint32_t SHARED = 0x02;
43 static const uint32_t LEAP = 0x04;
44};
45
San Mehat3c5a6f02009-05-22 15:36:13 -070046class PairwiseCiphersMask {
San Mehat82a21162009-05-12 17:26:28 -070047public:
48 static const uint32_t NONE = 0x00;
49 static const uint32_t TKIP = 0x01;
50 static const uint32_t CCMP = 0x02;
51};
52
San Mehat3c5a6f02009-05-22 15:36:13 -070053class GroupCiphersMask {
San Mehat82a21162009-05-12 17:26:28 -070054public:
55 static const uint32_t WEP40 = 0x01;
56 static const uint32_t WEP104 = 0x02;
57 static const uint32_t TKIP = 0x04;
58 static const uint32_t CCMP = 0x08;
59};
60
61class Supplicant;
San Mehat3c5a6f02009-05-22 15:36:13 -070062class InterfaceConfig;
63class Controller;
64class WifiController;
San Mehat82a21162009-05-12 17:26:28 -070065
San Mehat3c5a6f02009-05-22 15:36:13 -070066#include "IPropertyProvider.h"
67
68class WifiNetwork : public IPropertyProvider{
69public:
70 static const char *PropertyNames[];
71
72private:
San Mehat82a21162009-05-12 17:26:28 -070073 Supplicant *mSuppl;
San Mehat3c5a6f02009-05-22 15:36:13 -070074 InterfaceConfig *mIfaceCfg;
75 WifiController *mController;
San Mehat82a21162009-05-12 17:26:28 -070076
77 /*
78 * Unique network id - normally provided by supplicant
79 */
80 int mNetid;
81
82 /*
83 * The networks' SSID. Can either be an ASCII string,
84 * which must be enclosed in double quotation marks
85 * (ie: "MyNetwork"), or a string of hex digits which
86 * are not enclosed in quotes (ie: 01ab7893)
87 */
88 char *mSsid;
89
90 /*
91 * When set, this entry should only be used
92 * when associating with the AP having the specified
93 * BSSID. The value is a string in the format of an
94 * Ethernet MAC address
95 */
96 char *mBssid;
97
98 /*
99 * Pre-shared key for use with WPA-PSK
100 */
101 char *mPsk;
102
103 /*
104 * Up to four WEP keys. Either in ASCII string enclosed in
105 * double quotes, or a string of hex digits
106 */
107 char *mWepKeys[4];
108
109 /*
110 * Default WEP key index, ranging from 0 -> NUM_WEP_KEYS -1
111 */
112 int mDefaultKeyIndex;
113
114 /*
115 * Priority determines the preference given to a network by
116 * supplicant when choosing an access point with which
117 * to associate
118 */
119 int mPriority;
120
121 /*
122 * This is a network that does not broadcast it's SSID, so an
123 * SSID-specific probe request must be used for scans.
124 */
125 char *mHiddenSsid;
126
127 /*
128 * The set of key management protocols supported by this configuration.
129 */
130 uint32_t mAllowedKeyManagement;
131
132 /*
133 * The set of security protocols supported by this configuration.
134 */
135 uint32_t mAllowedProtocols;
136
137 /*
138 * The set of authentication protocols supported by this configuration.
139 */
140 uint32_t mAllowedAuthAlgorithms;
141
142 /*
143 * The set of pairwise ciphers for WPA supported by this configuration.
144 */
145 uint32_t mAllowedPairwiseCiphers;
146
147 /*
148 * The set of group ciphers for WPA supported by this configuration.
149 */
150 uint32_t mAllowedGroupCiphers;
151
San Mehat3c5a6f02009-05-22 15:36:13 -0700152 /*
153 * Set if this Network is enabled
154 */
155 bool mEnabled;
156
157private:
158 WifiNetwork();
159 int registerProperties();
160 int unregisterProperties();
161
San Mehat82a21162009-05-12 17:26:28 -0700162public:
San Mehat3c5a6f02009-05-22 15:36:13 -0700163 WifiNetwork(WifiController *c, Supplicant *suppl, int networkId);
164 WifiNetwork(WifiController *c, Supplicant *suppl, const char *data);
165
San Mehat82a21162009-05-12 17:26:28 -0700166 virtual ~WifiNetwork();
167
San Mehat3c5a6f02009-05-22 15:36:13 -0700168 WifiNetwork *clone();
169
San Mehat82a21162009-05-12 17:26:28 -0700170 int getNetworkId() { return mNetid; }
171 const char *getSsid() { return mSsid; }
172 const char *getBssid() { return mBssid; }
173 const char *getPsk() { return mPsk; }
174 const char *getWepKey(int idx) { return mWepKeys[idx]; }
175 int getDefaultKeyIndex() { return mDefaultKeyIndex; }
176 int getPriority() { return mPriority; }
177 const char *getHiddenSsid() { return mHiddenSsid; }
178 uint32_t getAllowedKeyManagement() { return mAllowedKeyManagement; }
179 uint32_t getAllowedProtocols() { return mAllowedProtocols; }
180 uint32_t getAllowedAuthAlgorithms() { return mAllowedAuthAlgorithms; }
181 uint32_t getAllowedPairwiseCiphers() { return mAllowedPairwiseCiphers; }
182 uint32_t getAllowedGroupCiphers() { return mAllowedGroupCiphers; }
San Mehat3c5a6f02009-05-22 15:36:13 -0700183 bool getEnabled() { return mEnabled; }
184 Controller *getController() { return (Controller *) mController; }
San Mehat82a21162009-05-12 17:26:28 -0700185
San Mehat3c5a6f02009-05-22 15:36:13 -0700186 int set(const char *name, const char *value);
187 const char *get(const char *name, char *buffer, size_t maxsize);
188
189// InterfaceConfig *getIfaceCfg() { return mIfaceCfg; }
190
191 int setEnabled(bool enabled);
192 int setSsid(const char *ssid);
193 int setBssid(const char *bssid);
194 int setPsk(const char *psk);
195 int setWepKey(int idx, const char *key);
San Mehat82a21162009-05-12 17:26:28 -0700196 int setDefaultKeyIndex(int idx);
197 int setPriority(int pri);
San Mehat3c5a6f02009-05-22 15:36:13 -0700198 int setHiddenSsid(const char *ssid);
San Mehat82a21162009-05-12 17:26:28 -0700199 int setAllowedKeyManagement(uint32_t mask);
200 int setAllowedProtocols(uint32_t mask);
San Mehat3c5a6f02009-05-22 15:36:13 -0700201 int setAllowedAuthAlgorithms(uint32_t mask);
San Mehat82a21162009-05-12 17:26:28 -0700202 int setAllowedPairwiseCiphers(uint32_t mask);
203 int setAllowedGroupCiphers(uint32_t mask);
San Mehat3c5a6f02009-05-22 15:36:13 -0700204
205 // XXX:Should this really be exposed?.. meh
206 int refresh();
San Mehat82a21162009-05-12 17:26:28 -0700207};
208
209typedef android::List<WifiNetwork *> WifiNetworkCollection;
210
211#endif