| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Wifi::WpaCtrl; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 949 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 5 | 1 |  |  | 1 |  | 6 | use DynaLoader; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 167 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our @ISA = qw( DynaLoader ); | 
| 8 |  |  |  |  |  |  | our $VERSION = 0.02; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 | 1 | 344 | sub dl_load_flags { 0x01 } | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | bootstrap Wifi::WpaCtrl $VERSION; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub DESTROY { | 
| 15 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 16 | 0 |  |  |  |  |  | $self->close(); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | 1; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =pod | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =head1 NAME | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | Wifi::WpaCtrl - wpa_supplicant/hostapd control interface library | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | use Wifi::WpaCtrl; | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | $wpa = Wifi::WpaCtrl->new('/path/to/socket') or die; | 
| 32 |  |  |  |  |  |  | $reply = $wpa->request('PING'); | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | This module is a wrapper around wpa_ctrl.[ch] supplied by | 
| 37 |  |  |  |  |  |  | wpa_supplicant. It may be used to communicate with | 
| 38 |  |  |  |  |  |  | wpa_supplicant/hostapd in various ways. | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =head1 METHODS | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head2 new | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | $wpa = Wifi::WpaCtrl->new('/path/to/socket'); | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | This class method tries to open a control interface connection to | 
| 47 |  |  |  |  |  |  | wpa_supplicant/hostap. The first argument is the path to the socket to | 
| 48 |  |  |  |  |  |  | connect to (usually /var/run/wpa_supplicant or /var/run/hostap). This | 
| 49 |  |  |  |  |  |  | argument may be omited if UDP sockets are used (Win32). It returns a | 
| 50 |  |  |  |  |  |  | new Wifi::WpaCtrl instance on success or undef on failure. | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =head2 close | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | $wpa->close(); | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | Closes the control interface. Returns nothing useful. You don't need | 
| 57 |  |  |  |  |  |  | to call this method yourself usually. It'll get executed automatically | 
| 58 |  |  |  |  |  |  | when Perl tries to free the Wifi::WpaCtrl instance when it leaves its | 
| 59 |  |  |  |  |  |  | scope. | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head2 request | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | my $reply = $wpa->request('PING'); | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | This method send a command which is given as the first argument to | 
| 66 |  |  |  |  |  |  | wpa_supplicant/hostapd. On success it returns the recieved reply. It | 
| 67 |  |  |  |  |  |  | may also return undef on error (send or recieve failed). On timeout (2 | 
| 68 |  |  |  |  |  |  | seconds) it croaks. This should never happen, though, as the | 
| 69 |  |  |  |  |  |  | only reason for that may be wpa_supplicant/hostapd sending a message | 
| 70 |  |  |  |  |  |  | at the same time the B method is called. This could happen if | 
| 71 |  |  |  |  |  |  | you have used B on the same Wifi::WpaCtrl instance to register | 
| 72 |  |  |  |  |  |  | it as a monitor for event messages. You should never do that. Instead | 
| 73 |  |  |  |  |  |  | you can create two Wifi::WpaCtrl instances. One for sending requests | 
| 74 |  |  |  |  |  |  | and one for recieving events. | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head2 attach | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | $wpa->attach(); | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | Register as an event monitor for the control interface. Returns 1 on | 
| 81 |  |  |  |  |  |  | success, 0 on failure or undef on timeout. | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head2 detach | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | $wpa->detach(); | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | Unregister event monitor from the control interface. Returns 1 on success, 0 on failure or undef on timeout. | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head2 recv | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | my $reply = $wpa->recv(); | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | Receive a pending control interface message. Returns the recieved message on success or undef on failure. | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =head2 pending | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | $is_pending = $wpa->pending(); | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | Check whether there are pending event messages. Returns non-zero if there are pending messages. | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | =head2 get_fd | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | my $fd = $wpa->get_fd(); | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | Get file descriptor used by the control interface. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 AUTHOR | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | Florian Ragwitz Erafl@debian.orgE | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | Copyright (C) 2006, Florian Ragwitz | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 116 |  |  |  |  |  |  | it under the same terms as Perl itself, either Perl version 5.8.8 or, | 
| 117 |  |  |  |  |  |  | at your option, any later version of Perl 5 you may have available. | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =cut |