| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Wireless::802_11::WPA::CLI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
30156
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use base 'Error::Helper'; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
873
|
|
|
6
|
1
|
|
|
1
|
|
1360
|
use String::ShellQuote; |
|
|
1
|
|
|
|
|
706
|
|
|
|
1
|
|
|
|
|
3409
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::Wireless::802_11::WPA::CLI - Provides a interface to wpa_cli. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 2.1.0 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '2.1.0'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Net::Wireless::802_11::WPA::CLI; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $foo = Net::Wireless::802_11::WPA::CLI->new(); |
|
26
|
|
|
|
|
|
|
... |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This initializes the object to be used for making use of wpa_cli. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $foo->Net::Wireless::802_11::WPA::CLI->new(); |
|
35
|
|
|
|
|
|
|
if( $foo->error ){ |
|
36
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
|
42
|
0
|
|
|
0
|
1
|
|
my $socket=$_[1]; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $self = { |
|
45
|
|
|
|
|
|
|
status=>undef, |
|
46
|
|
|
|
|
|
|
error=>undef, |
|
47
|
|
|
|
|
|
|
errorString=>'', |
|
48
|
|
|
|
|
|
|
perror=>undef, |
|
49
|
|
|
|
|
|
|
socket=>'', |
|
50
|
|
|
|
|
|
|
module=>'Net-Wireless-802_11-WPA-CLI', |
|
51
|
|
|
|
|
|
|
capabilities=>{ |
|
52
|
|
|
|
|
|
|
eap=>1, |
|
53
|
|
|
|
|
|
|
pairwise=>1, |
|
54
|
|
|
|
|
|
|
group=>1, |
|
55
|
|
|
|
|
|
|
key_mgmt=>1, |
|
56
|
|
|
|
|
|
|
proto=>1, |
|
57
|
|
|
|
|
|
|
auth_alg=>1, |
|
58
|
|
|
|
|
|
|
}, |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
0
|
|
|
|
|
|
bless $self; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if( defined( $socket ) ){ |
|
63
|
0
|
|
|
|
|
|
$self->{socket}='-p '.shell_quote($socket); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#tests if it is usable. |
|
67
|
0
|
|
|
|
|
|
my $command='wpa_cli '.$self->{socket}.' status'; |
|
68
|
0
|
|
|
|
|
|
my $status=`$command`; |
|
69
|
0
|
0
|
|
|
|
|
if (!$? == 0){ |
|
70
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
71
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$command.'" failed with "'.$status.'"'; |
|
72
|
0
|
|
|
|
|
|
$self->warn; |
|
73
|
0
|
|
|
|
|
|
return $self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my %statusH=status_breakdown($status); |
|
77
|
0
|
0
|
|
|
|
|
if ($self->error){ |
|
78
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
79
|
0
|
|
|
|
|
|
return $self; |
|
80
|
|
|
|
|
|
|
}; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$self->{status}=\%statusH; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return $self; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 add_network |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This adds a network. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
No arguments are taken. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The returned value is a the new network ID. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$newNetworkID=$foo->add_network; |
|
96
|
|
|
|
|
|
|
if( $foo->error ){ |
|
97
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub add_network{ |
|
103
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
106
|
0
|
|
|
|
|
|
return undef; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $returned=$self->run_command('add_network'); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#this means there was a error running wpa_cli |
|
112
|
0
|
0
|
|
|
|
|
if($self->error){ |
|
113
|
0
|
|
|
|
|
|
return undef; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#this means it failed |
|
117
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
118
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
119
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
120
|
0
|
|
|
|
|
|
return undef; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#remove the first line. |
|
124
|
0
|
|
|
|
|
|
$returned=~s/.*\n//; |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
chomp($returned); |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $returned; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 bss |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This requests additional information about a AP found in |
|
134
|
|
|
|
|
|
|
scan_results. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
A single argument is required and it is the BSSID. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The returned value is a hash. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head3 returned hash |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head4 bssid |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This is the BSSID in for the base station ID. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head4 freq |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is the frequency in Mhz. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head4 beacon_int |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is the beacon interval. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head4 capabilities |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is the AP capabilities. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head4 qual |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This is the signal quality. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head4 noise |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This is the signal noise level. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head4 level |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This is the RSSI. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head4 tsf |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is the timing syncronization function. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head4 ie |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is what ever the ie value is. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head4 flags |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This is the flags for the AP. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head4 ssid |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This is the SSID for the for AP in question. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my %status=$foo->bss($bssid); |
|
187
|
|
|
|
|
|
|
if( $foo->error ){ |
|
188
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub bss{ |
|
194
|
0
|
|
|
0
|
1
|
|
my ($self, $bssid)= @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
197
|
0
|
|
|
|
|
|
return undef; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
if(! defined( $bssid ) ){ |
|
201
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
202
|
0
|
|
|
|
|
|
$self->{errorString}='No BSSID specified'; |
|
203
|
0
|
|
|
|
|
|
$self->warn; |
|
204
|
0
|
|
|
|
|
|
return undef; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$bssid=lc($bssid); |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
210
|
0
|
|
|
|
|
|
my $macregexp='^[0123456789abcdef][0123456789abcdef]'. |
|
211
|
|
|
|
|
|
|
':[0123456789abcdef][0123456789abcdef]'. |
|
212
|
|
|
|
|
|
|
':[0123456789abcdef][0123456789abcdef]'. |
|
213
|
|
|
|
|
|
|
':[0123456789abcdef][0123456789abcdef]'. |
|
214
|
|
|
|
|
|
|
':[0123456789abcdef][0123456789abcdef]'. |
|
215
|
|
|
|
|
|
|
':[0123456789abcdef][0123456789abcdef]$'; |
|
216
|
|
|
|
|
|
|
; |
|
217
|
0
|
0
|
|
|
|
|
if ($bssid !~ /$macregexp/){ |
|
218
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
219
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$bssid.'" does not appear to be a valid BSSID'; |
|
220
|
0
|
|
|
|
|
|
$self->warn; |
|
221
|
0
|
|
|
|
|
|
return undef; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
my $command='wpa_cli '.$self->{socket}.' bss '.$bssid; |
|
225
|
0
|
|
|
|
|
|
my $status=`$command`; |
|
226
|
0
|
0
|
|
|
|
|
if (!$? == 0){ |
|
227
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
228
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$command.'" failed with "'.$status.'"'; |
|
229
|
0
|
|
|
|
|
|
$self->warn; |
|
230
|
0
|
|
|
|
|
|
return undef; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#this means it failed |
|
234
|
0
|
0
|
|
|
|
|
if ($status =~ /.*\nFAIL\n/){ |
|
235
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
236
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
237
|
0
|
|
|
|
|
|
return undef; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
my %statusH=status_breakdown($status); |
|
241
|
0
|
0
|
|
|
|
|
if ($self->error){ |
|
242
|
0
|
|
|
|
|
|
$self->warnString('status_breakdown failed'); |
|
243
|
0
|
|
|
|
|
|
return undef; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
$self->{status}={%statusH}; |
|
247
|
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
return %statusH; |
|
249
|
|
|
|
|
|
|
} |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 disconnect |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Disconnect and wait for a reassosiate command. |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
No arguments are taken. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
$return=$foo->disconnect; |
|
258
|
|
|
|
|
|
|
if( $foo->error ){ |
|
259
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub disconnect{ |
|
265
|
0
|
|
|
0
|
1
|
|
my ($self, $bssid)= @_; |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
268
|
0
|
|
|
|
|
|
return undef; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
return $self->run_TF_command('disconnect'. 0); |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 disable_network |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
This disables a network ID. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
One argument is required and that is the network ID in question. |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
$foo->disable_network($networkID) |
|
281
|
|
|
|
|
|
|
if( $foo->error ){ |
|
282
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=cut |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub disable_network{ |
|
288
|
0
|
|
|
0
|
1
|
|
my ($self, $nid)= @_; |
|
289
|
|
|
|
|
|
|
|
|
290
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
291
|
0
|
|
|
|
|
|
return undef; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
295
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
296
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
297
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
298
|
0
|
|
|
|
|
|
$self->warn; |
|
299
|
0
|
|
|
|
|
|
return undef; |
|
300
|
|
|
|
|
|
|
} |
|
301
|
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
return $self->run_TF_command('disable_network '.$nid, 0); |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head2 enable_network |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
This enables a network ID. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
One argument is required and that is the network ID to enable. |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
$foo->enable_network($networkID) |
|
313
|
|
|
|
|
|
|
if( $foo->error ){ |
|
314
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub enable_network{ |
|
320
|
0
|
|
|
0
|
1
|
|
my ($self, $nid)= @_; |
|
321
|
|
|
|
|
|
|
|
|
322
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
323
|
0
|
|
|
|
|
|
return undef; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
327
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
328
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
329
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
330
|
0
|
|
|
|
|
|
$self->warn; |
|
331
|
0
|
|
|
|
|
|
return undef; |
|
332
|
|
|
|
|
|
|
} |
|
333
|
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
return $self->run_TF_command('enable_network '.$nid, 0); |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=head2 get_capability |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
This returns the capabilities for the requested item. The capabilities |
|
340
|
|
|
|
|
|
|
that can be requested are as below. |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
eap |
|
343
|
|
|
|
|
|
|
pairwise |
|
344
|
|
|
|
|
|
|
group |
|
345
|
|
|
|
|
|
|
key_mgmt |
|
346
|
|
|
|
|
|
|
proto |
|
347
|
|
|
|
|
|
|
auth_alg |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
No arguments are taken. |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
my @capabilities=$foo->get_capability('eap'); |
|
352
|
|
|
|
|
|
|
if( $foo->error ){ |
|
353
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=cut |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub get_capability{ |
|
359
|
0
|
|
|
0
|
1
|
|
my ($self, $request)= @_; |
|
360
|
|
|
|
|
|
|
|
|
361
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
362
|
0
|
|
|
|
|
|
return undef; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
|
|
365
|
0
|
0
|
|
|
|
|
if(!defined( $request )){ |
|
366
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
367
|
0
|
|
|
|
|
|
$self->{errorString}='No request specified'; |
|
368
|
0
|
|
|
|
|
|
$self->warn; |
|
369
|
0
|
|
|
|
|
|
return undef; |
|
370
|
|
|
|
|
|
|
} |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
373
|
0
|
0
|
|
|
|
|
if(!defined( $self->{capabilities}{$request} )){ |
|
374
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
375
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$request.'" is not a valid capabilities request item'; |
|
376
|
0
|
|
|
|
|
|
$self->warn; |
|
377
|
0
|
|
|
|
|
|
return undef; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
my $returned=$self->run_command('get_capability '.$request); |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
#this means there was a error running wpa_cli |
|
383
|
0
|
0
|
|
|
|
|
if($self->error){ |
|
384
|
0
|
|
|
|
|
|
return undef; |
|
385
|
|
|
|
|
|
|
} |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
#this means it failed |
|
388
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
389
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
390
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
391
|
0
|
|
|
|
|
|
return undef; |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
0
|
|
|
|
|
|
my @capabilities; |
|
395
|
|
|
|
|
|
|
|
|
396
|
0
|
|
|
|
|
|
my @returnedA=split(/\n/, $returned); |
|
397
|
|
|
|
|
|
|
|
|
398
|
0
|
|
|
|
|
|
chomp($returnedA[1]); |
|
399
|
|
|
|
|
|
|
|
|
400
|
0
|
|
|
|
|
|
@capabilities=split(/ /, $returnedA[1]); |
|
401
|
|
|
|
|
|
|
|
|
402
|
0
|
|
|
|
|
|
return @capabilities; |
|
403
|
|
|
|
|
|
|
} |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=head2 get_network |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
This gets a variable for for a specific network ID. |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Two arguments are taken and that is the network ID and variable. |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
$value=$foo->get_network($networkID, $variable); |
|
412
|
|
|
|
|
|
|
if( $foo->error ){ |
|
413
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
414
|
|
|
|
|
|
|
} |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
=cut |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
sub get_network{ |
|
419
|
0
|
|
|
0
|
1
|
|
my ($self, $nid, $variable)= @_; |
|
420
|
|
|
|
|
|
|
|
|
421
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
422
|
0
|
|
|
|
|
|
return undef; |
|
423
|
|
|
|
|
|
|
} |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
426
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
427
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
428
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
429
|
0
|
|
|
|
|
|
$self->warn; |
|
430
|
0
|
|
|
|
|
|
return undef; |
|
431
|
|
|
|
|
|
|
} |
|
432
|
|
|
|
|
|
|
|
|
433
|
0
|
|
|
|
|
|
my $returned=$self->run_command('get_network '.$nid.' '.$variable); |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
#this means there was a error running wpa_cli |
|
436
|
0
|
0
|
|
|
|
|
if(!defined($returned)){ |
|
437
|
0
|
|
|
|
|
|
return undef; |
|
438
|
|
|
|
|
|
|
} |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
#this means it failed |
|
441
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
442
|
0
|
|
|
|
|
|
return undef; |
|
443
|
|
|
|
|
|
|
} |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
#remove the first line. |
|
446
|
0
|
|
|
|
|
|
$returned=~s/.*\n//; |
|
447
|
|
|
|
|
|
|
|
|
448
|
0
|
|
|
|
|
|
return $returned; |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=head2 list_networks |
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
This lists the configured networks. |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
No arguments are taken. |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
The returned value is a hash. |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=head3 returned hash. |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
The keys for the hash is the numeric network ID. Each |
|
462
|
|
|
|
|
|
|
item in the hash is a hash. The keys are listed below. |
|
463
|
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
=head4 ssid |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
This is the SSID of the network in question. |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=head4 bssid |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
This is the BSSID of the network in question. If not specified, |
|
471
|
|
|
|
|
|
|
it will be set to 'any'. |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=head4 flags |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
This is the flags for the network. This key may not be defined. |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
%return=$foo->list_networks; |
|
478
|
|
|
|
|
|
|
if( $foo->error ){ |
|
479
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
480
|
|
|
|
|
|
|
} |
|
481
|
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=cut |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
sub list_networks{ |
|
485
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
486
|
|
|
|
|
|
|
|
|
487
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
488
|
0
|
|
|
|
|
|
return undef; |
|
489
|
|
|
|
|
|
|
} |
|
490
|
|
|
|
|
|
|
|
|
491
|
0
|
|
|
|
|
|
my $returned=$self->run_command('list_networks'); |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
#this means there was a error running wpa_cli |
|
494
|
0
|
0
|
|
|
|
|
if($self->error){ |
|
495
|
0
|
|
|
|
|
|
return undef; |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
#this means it failed |
|
499
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
500
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
501
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
502
|
0
|
|
|
|
|
|
return undef; |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
|
my @returnedA=split(/\n/, $returned); |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
#this will be returned |
|
508
|
0
|
|
|
|
|
|
my %hash=(); |
|
509
|
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
my $returnedAint=2; |
|
511
|
0
|
|
|
|
|
|
while(defined($returnedA[$returnedAint])){ |
|
512
|
0
|
|
|
|
|
|
chomp($returnedA[$returnedAint]); |
|
513
|
|
|
|
|
|
|
|
|
514
|
0
|
|
|
|
|
|
my @linesplit=split(/\t/, $returnedA[$returnedAint]); |
|
515
|
|
|
|
|
|
|
|
|
516
|
0
|
|
|
|
|
|
my $nid=$linesplit[0]; |
|
517
|
|
|
|
|
|
|
|
|
518
|
0
|
|
|
|
|
|
$hash{$nid}={}; |
|
519
|
|
|
|
|
|
|
|
|
520
|
0
|
0
|
|
|
|
|
if(defined( $linesplit[3] )){ |
|
521
|
0
|
|
|
|
|
|
$hash{$nid}{flags}=$linesplit[3]; |
|
522
|
|
|
|
|
|
|
} |
|
523
|
|
|
|
|
|
|
|
|
524
|
0
|
|
|
|
|
|
$hash{$nid}{bssid}=$linesplit[2]; |
|
525
|
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
$hash{$nid}{ssid}=$linesplit[1]; |
|
527
|
|
|
|
|
|
|
|
|
528
|
0
|
|
|
|
|
|
$returnedAint++; |
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
0
|
|
|
|
|
|
return %hash; |
|
532
|
|
|
|
|
|
|
} |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=head2 new_password |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
This sets a new password for a network. |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
Two arguments are taken. The first is the network ID and |
|
539
|
|
|
|
|
|
|
the second is the new password. |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
$return=$foo->new_password($networkID, $newpass); |
|
542
|
|
|
|
|
|
|
if( $foo->error ){ |
|
543
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
544
|
|
|
|
|
|
|
} |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
=cut |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
sub new_password{ |
|
549
|
0
|
|
|
0
|
1
|
|
my ($self, $nid, $value)= @_; |
|
550
|
|
|
|
|
|
|
|
|
551
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
552
|
0
|
|
|
|
|
|
return undef; |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
556
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
557
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
558
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
559
|
0
|
|
|
|
|
|
$self->warn; |
|
560
|
0
|
|
|
|
|
|
return undef; |
|
561
|
|
|
|
|
|
|
} |
|
562
|
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
|
return $self->run_TF_command('new_password '.$nid.' '.$value, 0); |
|
564
|
|
|
|
|
|
|
} |
|
565
|
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=head2 pin |
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
This sets the pin for a network. |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
Two arguments are taken. The first is the network ID and the second is the pin. |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
$foo->pin($networkID, $newpin); |
|
573
|
|
|
|
|
|
|
if( $foo->error ){ |
|
574
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
575
|
|
|
|
|
|
|
} |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=cut |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
sub pin{ |
|
580
|
0
|
|
|
0
|
1
|
|
my ($self, $nid, $value)= @_; |
|
581
|
|
|
|
|
|
|
|
|
582
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
583
|
0
|
|
|
|
|
|
return undef; |
|
584
|
|
|
|
|
|
|
} |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
587
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
588
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
589
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
590
|
0
|
|
|
|
|
|
$self->warn; |
|
591
|
0
|
|
|
|
|
|
return undef; |
|
592
|
|
|
|
|
|
|
} |
|
593
|
|
|
|
|
|
|
|
|
594
|
0
|
|
|
|
|
|
return $self->run_TF_command('pin '.$nid.' '.$value, 0); |
|
595
|
|
|
|
|
|
|
} |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head2 preauthenticate |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
Force preauthentication for a BSSID. |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
One argument is accepted and the is the BSSID in question. |
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
$foo->preauthenticate($BSSID); |
|
604
|
|
|
|
|
|
|
if( $foo->error ){ |
|
605
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
606
|
|
|
|
|
|
|
} |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=cut |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
sub preauthenticate{ |
|
611
|
0
|
|
|
0
|
1
|
|
my ($self, $bssid)= @_; |
|
612
|
|
|
|
|
|
|
|
|
613
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
614
|
0
|
|
|
|
|
|
return undef; |
|
615
|
|
|
|
|
|
|
} |
|
616
|
|
|
|
|
|
|
|
|
617
|
0
|
|
|
|
|
|
return $self->run_TF_command('preauthenticate '.$bssid, 0); |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=head2 reassociate |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
This saves the current configuration. The user requesting this |
|
623
|
|
|
|
|
|
|
does not need write permissions to file being used |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
It takes no arguments. |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
$foo->reassociate; |
|
628
|
|
|
|
|
|
|
if( $foo->error ){ |
|
629
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
630
|
|
|
|
|
|
|
} |
|
631
|
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=cut |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
sub reassociate{ |
|
635
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
636
|
|
|
|
|
|
|
|
|
637
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
638
|
0
|
|
|
|
|
|
return undef; |
|
639
|
|
|
|
|
|
|
} |
|
640
|
|
|
|
|
|
|
|
|
641
|
0
|
|
|
|
|
|
return $self->run_TF_command('reassociate', 0); |
|
642
|
|
|
|
|
|
|
} |
|
643
|
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=head2 reconfigure |
|
645
|
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
This causes wpa_supplicant to reread it's configuration file. |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
No arguments are taken. |
|
649
|
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
$return=$obj->reconfigure; |
|
651
|
|
|
|
|
|
|
if( $foo->error ){ |
|
652
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
653
|
|
|
|
|
|
|
} |
|
654
|
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
=cut |
|
656
|
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
sub reconfigure{ |
|
658
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
659
|
|
|
|
|
|
|
|
|
660
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
661
|
0
|
|
|
|
|
|
return undef; |
|
662
|
|
|
|
|
|
|
} |
|
663
|
|
|
|
|
|
|
|
|
664
|
0
|
|
|
|
|
|
return $self->run_TF_command('reconfigure', 0); |
|
665
|
|
|
|
|
|
|
} |
|
666
|
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=head2 remove_network |
|
668
|
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
This removes the specified network. |
|
670
|
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
One argument is accepted and it the network ID. |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
$return=$foo->remove_network($networkID) |
|
674
|
|
|
|
|
|
|
if( $foo->error ){ |
|
675
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
676
|
|
|
|
|
|
|
} |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=cut |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
sub remove_network{ |
|
681
|
0
|
|
|
0
|
1
|
|
my ($self, $nid)= @_; |
|
682
|
|
|
|
|
|
|
|
|
683
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
684
|
0
|
|
|
|
|
|
return undef; |
|
685
|
|
|
|
|
|
|
} |
|
686
|
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
688
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
689
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
690
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
691
|
0
|
|
|
|
|
|
$self->warn; |
|
692
|
0
|
|
|
|
|
|
return undef; |
|
693
|
|
|
|
|
|
|
} |
|
694
|
|
|
|
|
|
|
|
|
695
|
0
|
|
|
|
|
|
return $self->run_TF_command('remove_network '.$nid, 0); |
|
696
|
|
|
|
|
|
|
} |
|
697
|
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=head2 save_config |
|
699
|
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
This saves the current configuration. The user requesting this |
|
701
|
|
|
|
|
|
|
does not need write permissions to file being used |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
No arguments are taken. |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
my $returned=$foo->save_config; |
|
706
|
|
|
|
|
|
|
if( $foo->error ){ |
|
707
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
708
|
|
|
|
|
|
|
} |
|
709
|
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=cut |
|
711
|
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
sub save_config{ |
|
713
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
714
|
|
|
|
|
|
|
|
|
715
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
716
|
0
|
|
|
|
|
|
return undef; |
|
717
|
|
|
|
|
|
|
} |
|
718
|
|
|
|
|
|
|
|
|
719
|
0
|
|
|
|
|
|
return $self->run_TF_command('save_config'); |
|
720
|
|
|
|
|
|
|
} |
|
721
|
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=head2 scan |
|
723
|
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
This requests a new BSS scan. |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
No arguments are taken. |
|
727
|
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
my $returned=$foo->scan; |
|
729
|
|
|
|
|
|
|
if( $foo->error ){ |
|
730
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
731
|
|
|
|
|
|
|
} |
|
732
|
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
=cut |
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
sub scan{ |
|
736
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
737
|
|
|
|
|
|
|
|
|
738
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
739
|
0
|
|
|
|
|
|
return undef; |
|
740
|
|
|
|
|
|
|
} |
|
741
|
|
|
|
|
|
|
|
|
742
|
0
|
|
|
|
|
|
return $self->run_TF_command('scan'); |
|
743
|
|
|
|
|
|
|
} |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=head2 scan_results |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
This returns the scan results. |
|
748
|
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
No arguments are taken. |
|
750
|
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
The returned value is a hash. |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=head3 returned hash |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
Each keys of the hash is a BSSID. It's value is another hash |
|
756
|
|
|
|
|
|
|
with the keys listed below. |
|
757
|
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
=head4 ssid |
|
759
|
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
This is the SSID for the AP. |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=head4 frequency |
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
This is the frequency of the AP. The value is in Mhz. |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=head4 signallevel |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
This is the signal level of the seen AP. |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
=head4 flags |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
This is the flags for the AP. |
|
773
|
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
my %scan=$foo->scan_results; |
|
775
|
|
|
|
|
|
|
if( $foo->error ){ |
|
776
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
777
|
|
|
|
|
|
|
}else{ |
|
778
|
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
print "BSSID, SSID, FREQ, SIGNAL, FLAGS\n"; |
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
my @keys=keys(%scan); |
|
782
|
|
|
|
|
|
|
my $int=0; |
|
783
|
|
|
|
|
|
|
while( defined( $keys[$int] ) ){ |
|
784
|
|
|
|
|
|
|
print $keys[$int].', '.$scan{$keys[$int]}{ssid}.', '. |
|
785
|
|
|
|
|
|
|
$scan{$keys[$int]}{frequency}.', ' |
|
786
|
|
|
|
|
|
|
.$scan{$keys[$int]}{signal}.', ' |
|
787
|
|
|
|
|
|
|
.$scan{$keys[$int]}{flags}; |
|
788
|
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
$int++; |
|
790
|
|
|
|
|
|
|
} |
|
791
|
|
|
|
|
|
|
} |
|
792
|
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
=cut |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
sub scan_results{ |
|
796
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
797
|
|
|
|
|
|
|
|
|
798
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
799
|
0
|
|
|
|
|
|
return undef; |
|
800
|
|
|
|
|
|
|
} |
|
801
|
|
|
|
|
|
|
|
|
802
|
0
|
|
|
|
|
|
my $returned=$self->run_command('scan_results'); |
|
803
|
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
#this means there was a error running wpa_cli |
|
805
|
0
|
0
|
|
|
|
|
if($self->error){ |
|
806
|
0
|
|
|
|
|
|
return undef; |
|
807
|
|
|
|
|
|
|
} |
|
808
|
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
#this means it failed |
|
810
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
811
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
812
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
813
|
0
|
|
|
|
|
|
return undef; |
|
814
|
|
|
|
|
|
|
} |
|
815
|
|
|
|
|
|
|
|
|
816
|
0
|
|
|
|
|
|
my @returnedA=split(/\n/, $returned); |
|
817
|
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
#this will be returned |
|
819
|
0
|
|
|
|
|
|
my %hash=(); |
|
820
|
|
|
|
|
|
|
|
|
821
|
0
|
|
|
|
|
|
my $returnedAint=2; |
|
822
|
0
|
|
|
|
|
|
while(defined($returnedA[$returnedAint])){ |
|
823
|
0
|
|
|
|
|
|
chomp($returnedA[$returnedAint]); |
|
824
|
|
|
|
|
|
|
|
|
825
|
0
|
|
|
|
|
|
my @linesplit=split(/\t/, $returnedA[$returnedAint]); |
|
826
|
|
|
|
|
|
|
|
|
827
|
0
|
|
|
|
|
|
my $bssid=$linesplit[0]; |
|
828
|
|
|
|
|
|
|
|
|
829
|
0
|
|
|
|
|
|
$hash{$bssid}={}; |
|
830
|
|
|
|
|
|
|
|
|
831
|
0
|
|
|
|
|
|
$hash{$bssid}{frequency}=$linesplit[1]; |
|
832
|
|
|
|
|
|
|
|
|
833
|
0
|
|
|
|
|
|
$hash{$bssid}{signallevel}=$linesplit[2]; |
|
834
|
|
|
|
|
|
|
|
|
835
|
0
|
|
|
|
|
|
$hash{$bssid}{flags}=$linesplit[3]; |
|
836
|
|
|
|
|
|
|
|
|
837
|
0
|
|
|
|
|
|
$hash{$bssid}{ssid}=$linesplit[4]; |
|
838
|
|
|
|
|
|
|
|
|
839
|
0
|
|
|
|
|
|
$returnedAint++; |
|
840
|
|
|
|
|
|
|
} |
|
841
|
|
|
|
|
|
|
|
|
842
|
0
|
|
|
|
|
|
return %hash; |
|
843
|
|
|
|
|
|
|
} |
|
844
|
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=head2 select_network |
|
846
|
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
This is the network ID to select, while disabling the others. |
|
848
|
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
One argument is accepted and it is the network ID to select. |
|
850
|
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
$return=$foo->select_network($networkID) |
|
852
|
|
|
|
|
|
|
if( $foo->error ){ |
|
853
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
854
|
|
|
|
|
|
|
} |
|
855
|
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
=cut |
|
857
|
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
sub select_network{ |
|
859
|
0
|
|
|
0
|
1
|
|
my ($self, $nid)= @_; |
|
860
|
|
|
|
|
|
|
|
|
861
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
862
|
0
|
|
|
|
|
|
return undef; |
|
863
|
|
|
|
|
|
|
} |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
866
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
867
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
868
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
869
|
0
|
|
|
|
|
|
$self->warn; |
|
870
|
0
|
|
|
|
|
|
return undef; |
|
871
|
|
|
|
|
|
|
} |
|
872
|
|
|
|
|
|
|
|
|
873
|
0
|
|
|
|
|
|
return $self->run_TF_command('select_network '.$nid, 0); |
|
874
|
|
|
|
|
|
|
} |
|
875
|
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
=head2 set_network |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
This sets a variable for for a specific network ID. |
|
879
|
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
Three arguments are taken. The first is the network ID, |
|
881
|
|
|
|
|
|
|
the second is the variable to set, and the third is the |
|
882
|
|
|
|
|
|
|
value to set it to. |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
$foo->set_network($networkID, $variable, $value); |
|
885
|
|
|
|
|
|
|
if( $foo->error ){ |
|
886
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
887
|
|
|
|
|
|
|
} |
|
888
|
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
=cut |
|
890
|
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
sub set_network{ |
|
892
|
0
|
|
|
0
|
1
|
|
my ($self, $nid, $variable, $value)= @_; |
|
893
|
|
|
|
|
|
|
|
|
894
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
895
|
0
|
|
|
|
|
|
return undef; |
|
896
|
|
|
|
|
|
|
} |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
#return if the netword ID is not numeric. |
|
899
|
0
|
0
|
|
|
|
|
if ($nid !~ /^[0123456789]*$/){ |
|
900
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
901
|
0
|
|
|
|
|
|
$self->{errorString}='non-numeric network ID used'; |
|
902
|
0
|
|
|
|
|
|
$self->warn; |
|
903
|
0
|
|
|
|
|
|
return undef; |
|
904
|
|
|
|
|
|
|
} |
|
905
|
|
|
|
|
|
|
|
|
906
|
0
|
|
|
|
|
|
return $self->run_TF_command('set_network '.$nid.' '.$variable.' '.$value, 0); |
|
907
|
|
|
|
|
|
|
} |
|
908
|
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
=head2 status |
|
910
|
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
This function gets the current status from wpa_cli. |
|
912
|
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
No arguments are taken. |
|
914
|
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
my %status=$foo->status; |
|
916
|
|
|
|
|
|
|
if( $foo->error ){ |
|
917
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
918
|
|
|
|
|
|
|
} |
|
919
|
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=cut |
|
921
|
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
sub status{ |
|
923
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
924
|
|
|
|
|
|
|
|
|
925
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
926
|
0
|
|
|
|
|
|
return undef; |
|
927
|
|
|
|
|
|
|
} |
|
928
|
|
|
|
|
|
|
|
|
929
|
0
|
|
|
|
|
|
my $command='wpa_cli '.$self->{socket}.' status'; |
|
930
|
0
|
|
|
|
|
|
my $status=`$command`; |
|
931
|
0
|
0
|
|
|
|
|
if (!$? == 0){ |
|
932
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
933
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$command.'" failed with "'.$status.'"'; |
|
934
|
0
|
|
|
|
|
|
$self->warn; |
|
935
|
0
|
|
|
|
|
|
return undef; |
|
936
|
|
|
|
|
|
|
} |
|
937
|
|
|
|
|
|
|
|
|
938
|
0
|
0
|
|
|
|
|
if ($status =~ /.*\nFAIL\n/){ |
|
939
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
940
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
941
|
0
|
|
|
|
|
|
return undef; |
|
942
|
|
|
|
|
|
|
} |
|
943
|
|
|
|
|
|
|
|
|
944
|
0
|
|
|
|
|
|
my %statusH=status_breakdown($status); |
|
945
|
0
|
0
|
|
|
|
|
if ($self->error){ |
|
946
|
0
|
|
|
|
|
|
$self->warnString('status_breakdown failed'); |
|
947
|
0
|
|
|
|
|
|
return undef; |
|
948
|
|
|
|
|
|
|
} |
|
949
|
|
|
|
|
|
|
|
|
950
|
0
|
|
|
|
|
|
$self->{status}={%statusH}; |
|
951
|
|
|
|
|
|
|
|
|
952
|
0
|
|
|
|
|
|
return %statusH; |
|
953
|
|
|
|
|
|
|
} |
|
954
|
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
=head2 mib |
|
956
|
|
|
|
|
|
|
|
|
957
|
|
|
|
|
|
|
This gets the MIB variables (dot1x, dot11). |
|
958
|
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
%return=$foo->mib; |
|
960
|
|
|
|
|
|
|
if( $foo->error ){ |
|
961
|
|
|
|
|
|
|
warn('error:'.$foo->error.': '.$foo->errorString); |
|
962
|
|
|
|
|
|
|
} |
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
=cut |
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
sub mib{ |
|
967
|
0
|
|
|
0
|
1
|
|
my ($self)= @_; |
|
968
|
|
|
|
|
|
|
|
|
969
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
970
|
0
|
|
|
|
|
|
return undef; |
|
971
|
|
|
|
|
|
|
} |
|
972
|
|
|
|
|
|
|
|
|
973
|
0
|
|
|
|
|
|
my $returned=$self->run_command('mib'); |
|
974
|
|
|
|
|
|
|
|
|
975
|
0
|
0
|
|
|
|
|
if($self->error){ |
|
976
|
0
|
|
|
|
|
|
return undef; |
|
977
|
|
|
|
|
|
|
} |
|
978
|
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
#this means it failed |
|
980
|
0
|
0
|
|
|
|
|
if ($returned =~ /.*\nFAIL\n/){ |
|
981
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
982
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
983
|
0
|
|
|
|
|
|
return undef; |
|
984
|
|
|
|
|
|
|
} |
|
985
|
|
|
|
|
|
|
|
|
986
|
0
|
|
|
|
|
|
my %hash=status_breakdown($returned, 'mib'); |
|
987
|
|
|
|
|
|
|
|
|
988
|
0
|
|
|
|
|
|
return %hash; |
|
989
|
|
|
|
|
|
|
} |
|
990
|
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
=head2 run_TF_command |
|
992
|
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
This runs a arbirary command in which the expected values are |
|
994
|
|
|
|
|
|
|
either 'FAIL' or 'OK'. This function is largely intended for internal |
|
995
|
|
|
|
|
|
|
use by this module. |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
It takes two argument. The first is string containing the command and any |
|
998
|
|
|
|
|
|
|
arguments for it. The second is what to return on a unknown return. |
|
999
|
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
A status of 'FAIL' will also set a error of 5. |
|
1001
|
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
A unknown status will also set a error of 6. |
|
1003
|
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
$returned=$foo->run_TF_command($command, 0); |
|
1005
|
|
|
|
|
|
|
if( $foo->error ){ |
|
1006
|
|
|
|
|
|
|
warn('error:'.$foo->error.': '.$foo->errorString); |
|
1007
|
|
|
|
|
|
|
} |
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
=cut |
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
sub run_TF_command{ |
|
1012
|
0
|
|
|
0
|
1
|
|
my ($self, $command, $onend)= @_; |
|
1013
|
|
|
|
|
|
|
|
|
1014
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
1015
|
0
|
|
|
|
|
|
return undef; |
|
1016
|
|
|
|
|
|
|
} |
|
1017
|
|
|
|
|
|
|
|
|
1018
|
0
|
|
|
|
|
|
my $torun='wpa_cli '.$self->{socket}.' '.$command; |
|
1019
|
0
|
|
|
|
|
|
my $status=`$torun`; |
|
1020
|
0
|
0
|
|
|
|
|
if (!$? == 0){ |
|
1021
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
1022
|
0
|
|
|
|
|
|
$self->{errorString}="wpa_cli failed with '".$status."'"."for '".$command."'"; |
|
1023
|
0
|
|
|
|
|
|
$self->warn; |
|
1024
|
0
|
|
|
|
|
|
return undef; |
|
1025
|
|
|
|
|
|
|
} |
|
1026
|
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
#return 0 upon failure |
|
1028
|
0
|
0
|
|
|
|
|
if ($status =~ /.*\nFAIL\n/){ |
|
1029
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
1030
|
0
|
|
|
|
|
|
$self->{errorString}='The commaned outputed a status of FAIL, but exited zero'; |
|
1031
|
0
|
|
|
|
|
|
return 0; |
|
1032
|
|
|
|
|
|
|
} |
|
1033
|
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
#return 1 upon success |
|
1035
|
0
|
0
|
|
|
|
|
if ($status =~ /.*\nOK\n/){ |
|
1036
|
0
|
|
|
|
|
|
return 1; |
|
1037
|
|
|
|
|
|
|
} |
|
1038
|
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
#unknwon so set error 6 |
|
1040
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
1041
|
0
|
|
|
|
|
|
$self->{errorString}='Unknown return of "'.$status.'"'; |
|
1042
|
|
|
|
|
|
|
|
|
1043
|
0
|
|
|
|
|
|
return $onend; |
|
1044
|
|
|
|
|
|
|
} |
|
1045
|
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
=head2 run_command |
|
1047
|
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
This runs a arbirary command in which. This function is largely intended for |
|
1049
|
|
|
|
|
|
|
internal use by this module. |
|
1050
|
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
It takes argument, which is string containing the command and any |
|
1052
|
|
|
|
|
|
|
arguments for it. |
|
1053
|
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
UNDEF is returned upon with running wpa_cli. Otherwise the return is the return |
|
1055
|
|
|
|
|
|
|
from executed command. |
|
1056
|
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
$returned=$foo->run_command($command) |
|
1058
|
|
|
|
|
|
|
if( $foo->error ){ |
|
1059
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
1060
|
|
|
|
|
|
|
} |
|
1061
|
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
=cut |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
sub run_command{ |
|
1065
|
0
|
|
|
0
|
1
|
|
my ($self, $command)= @_; |
|
1066
|
|
|
|
|
|
|
|
|
1067
|
0
|
0
|
|
|
|
|
if(! $self->errorblank){ |
|
1068
|
0
|
|
|
|
|
|
return undef; |
|
1069
|
|
|
|
|
|
|
} |
|
1070
|
|
|
|
|
|
|
|
|
1071
|
0
|
|
|
|
|
|
my $torun='wpa_cli '.$self->{socket}.' '.$command; |
|
1072
|
0
|
|
|
|
|
|
my $status=`$torun`; |
|
1073
|
0
|
0
|
|
|
|
|
if (!$? == 0){ |
|
1074
|
0
|
|
|
|
|
|
warn("wpa_cli failed with '".$status."'"."for '".$command."'"); |
|
1075
|
0
|
|
|
|
|
|
return undef; |
|
1076
|
|
|
|
|
|
|
} |
|
1077
|
|
|
|
|
|
|
|
|
1078
|
0
|
|
|
|
|
|
return $status; |
|
1079
|
|
|
|
|
|
|
} |
|
1080
|
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
=head2 status_breakdown |
|
1082
|
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
This is a internal function. |
|
1084
|
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
=cut |
|
1086
|
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
#this is a internal function used by this module |
|
1088
|
|
|
|
|
|
|
#It breaks down that return from status. |
|
1089
|
|
|
|
|
|
|
sub status_breakdown{ |
|
1090
|
0
|
|
|
0
|
1
|
|
my $statusS=$_[0]; |
|
1091
|
0
|
|
|
|
|
|
my $type=$_[1]; |
|
1092
|
|
|
|
|
|
|
|
|
1093
|
0
|
|
|
|
|
|
my %hash; |
|
1094
|
|
|
|
|
|
|
|
|
1095
|
0
|
|
|
|
|
|
my @statusA=split(/\n/, $statusS); |
|
1096
|
|
|
|
|
|
|
|
|
1097
|
0
|
0
|
|
|
|
|
if (!defined($type)){ |
|
1098
|
0
|
|
|
|
|
|
$type="status" |
|
1099
|
|
|
|
|
|
|
} |
|
1100
|
|
|
|
|
|
|
|
|
1101
|
0
|
0
|
|
|
|
|
if ( $statusA[0] !~ /^Selected interface/){ |
|
1102
|
0
|
|
|
|
|
|
return undef; |
|
1103
|
|
|
|
|
|
|
} |
|
1104
|
|
|
|
|
|
|
|
|
1105
|
0
|
|
|
|
|
|
my @interfaceA=split(/\'/, $statusA[0]); |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
0
|
|
|
|
|
|
$hash{interface}=$interfaceA[1]; |
|
1108
|
|
|
|
|
|
|
|
|
1109
|
0
|
|
|
|
|
|
my $statusAint=1; |
|
1110
|
0
|
|
|
|
|
|
while(defined($statusA[$statusAint])){ |
|
1111
|
0
|
|
|
|
|
|
chomp($statusA[$statusAint]); |
|
1112
|
0
|
|
|
|
|
|
my @linesplit=split(/=/, $statusA[$statusAint]); |
|
1113
|
0
|
|
|
|
|
|
$hash{$linesplit[0]}=$linesplit[1]; |
|
1114
|
|
|
|
|
|
|
|
|
1115
|
0
|
|
|
|
|
|
$statusAint++; |
|
1116
|
|
|
|
|
|
|
} |
|
1117
|
|
|
|
|
|
|
|
|
1118
|
0
|
|
|
|
|
|
return %hash; |
|
1119
|
|
|
|
|
|
|
} |
|
1120
|
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
=head1 NOTES |
|
1122
|
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
This makes use of wpa_cli in a non-interactive form. This means that |
|
1124
|
|
|
|
|
|
|
interface and otp are not usable. |
|
1125
|
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
Better documentation and etc shall be coming shortly. Publishing this and starting work |
|
1127
|
|
|
|
|
|
|
on something that uses it in it's current form. |
|
1128
|
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
1130
|
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
=head2 1 |
|
1132
|
|
|
|
|
|
|
|
|
1133
|
|
|
|
|
|
|
Unable to to initialize the object. A wpa_cli status check failed. |
|
1134
|
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
This error is permanent. |
|
1136
|
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
=head2 2 |
|
1138
|
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
Status breakdown failed because of a unexpected return. |
|
1140
|
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
=head2 3 |
|
1142
|
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
Command failed and exited with a non-zero. |
|
1144
|
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
=head2 4 |
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
Invalid argument supplies. |
|
1148
|
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
=head2 5 |
|
1150
|
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
The executed command exited with zero, but still failed. |
|
1152
|
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
This error code is not warned for. |
|
1154
|
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
=head2 6 |
|
1156
|
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
Unknown return. |
|
1158
|
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1160
|
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
1162
|
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
=head1 BUGS |
|
1164
|
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
1166
|
|
|
|
|
|
|
the web interface at L. I will be |
|
1167
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your bug as I make changes. |
|
1168
|
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
=head1 SUPPORT |
|
1173
|
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
1175
|
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
perldoc Net::Wireless::802_11::WPA::CLI |
|
1177
|
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
You can also look for information at: |
|
1180
|
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
=over 4 |
|
1182
|
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
1184
|
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
L |
|
1186
|
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
1188
|
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
L |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
1192
|
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
L |
|
1194
|
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=item * Search CPAN |
|
1196
|
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
L |
|
1198
|
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
=back |
|
1200
|
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
1203
|
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
1206
|
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
Copyright 2011 Zane C. Bowers-Hadley, all rights reserved. |
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
1210
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
1211
|
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
=cut |
|
1214
|
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
1; # End of Net::Wireless::802_11::WPA::CLI |