blob: 1354730075ffd6a644b36978e2b9519bfcb4fd9e [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
22#include "../../../frameworks/base/include/utils/List.h"
23
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
46class PairwiseCipherMask {
47public:
48 static const uint32_t NONE = 0x00;
49 static const uint32_t TKIP = 0x01;
50 static const uint32_t CCMP = 0x02;
51};
52
53class GroupCipherMask {
54public:
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;
62
63class WifiNetwork {
64 Supplicant *mSuppl;
65
66 /*
67 * Unique network id - normally provided by supplicant
68 */
69 int mNetid;
70
71 /*
72 * The networks' SSID. Can either be an ASCII string,
73 * which must be enclosed in double quotation marks
74 * (ie: "MyNetwork"), or a string of hex digits which
75 * are not enclosed in quotes (ie: 01ab7893)
76 */
77 char *mSsid;
78
79 /*
80 * When set, this entry should only be used
81 * when associating with the AP having the specified
82 * BSSID. The value is a string in the format of an
83 * Ethernet MAC address
84 */
85 char *mBssid;
86
87 /*
88 * Pre-shared key for use with WPA-PSK
89 */
90 char *mPsk;
91
92 /*
93 * Up to four WEP keys. Either in ASCII string enclosed in
94 * double quotes, or a string of hex digits
95 */
96 char *mWepKeys[4];
97
98 /*
99 * Default WEP key index, ranging from 0 -> NUM_WEP_KEYS -1
100 */
101 int mDefaultKeyIndex;
102
103 /*
104 * Priority determines the preference given to a network by
105 * supplicant when choosing an access point with which
106 * to associate
107 */
108 int mPriority;
109
110 /*
111 * This is a network that does not broadcast it's SSID, so an
112 * SSID-specific probe request must be used for scans.
113 */
114 char *mHiddenSsid;
115
116 /*
117 * The set of key management protocols supported by this configuration.
118 */
119 uint32_t mAllowedKeyManagement;
120
121 /*
122 * The set of security protocols supported by this configuration.
123 */
124 uint32_t mAllowedProtocols;
125
126 /*
127 * The set of authentication protocols supported by this configuration.
128 */
129 uint32_t mAllowedAuthAlgorithms;
130
131 /*
132 * The set of pairwise ciphers for WPA supported by this configuration.
133 */
134 uint32_t mAllowedPairwiseCiphers;
135
136 /*
137 * The set of group ciphers for WPA supported by this configuration.
138 */
139 uint32_t mAllowedGroupCiphers;
140
141public:
142 WifiNetwork(Supplicant *suppl);
143 virtual ~WifiNetwork();
144
145 int getNetworkId() { return mNetid; }
146 const char *getSsid() { return mSsid; }
147 const char *getBssid() { return mBssid; }
148 const char *getPsk() { return mPsk; }
149 const char *getWepKey(int idx) { return mWepKeys[idx]; }
150 int getDefaultKeyIndex() { return mDefaultKeyIndex; }
151 int getPriority() { return mPriority; }
152 const char *getHiddenSsid() { return mHiddenSsid; }
153 uint32_t getAllowedKeyManagement() { return mAllowedKeyManagement; }
154 uint32_t getAllowedProtocols() { return mAllowedProtocols; }
155 uint32_t getAllowedAuthAlgorithms() { return mAllowedAuthAlgorithms; }
156 uint32_t getAllowedPairwiseCiphers() { return mAllowedPairwiseCiphers; }
157 uint32_t getAllowedGroupCiphers() { return mAllowedGroupCiphers; }
158
159 int setSsid(char *ssid);
160 int setBssid(char *bssid);
161 int setPsk(char *psk);
162 int setWepKey(int idx, char *key);
163 int setDefaultKeyIndex(int idx);
164 int setPriority(int pri);
165 int setHiddenSsid(char *ssid);
166 int setAllowedKeyManagement(uint32_t mask);
167 int setAllowedProtocols(uint32_t mask);
168 int setAllowedPairwiseCiphers(uint32_t mask);
169 int setAllowedGroupCiphers(uint32_t mask);
170};
171
172typedef android::List<WifiNetwork *> WifiNetworkCollection;
173
174#endif