Net_Wifi
[ class tree: Net_Wifi ] [ index: Net_Wifi ] [ all elements ]

Source for file Wifi.php

Documentation is available at Wifi.php

  1. <?php
  2. /**
  3.  * Configuration settings of a wifi network interface.
  4.  *
  5.  * PHP Versions 4 and 5
  6.  *
  7.  * @category Networking
  8.  * @package  Net_Wifi
  9.  * @author   Christian Weiske <cweiske@php.net>
  10.  * @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  11.  * @version  CVS: $Id$
  12.  * @link     http://pear.php.net/package/Net_Wifi
  13.  */
  14.  
  15. require_once 'Net/Wifi/Cell.php';
  16. require_once 'Net/Wifi/Config.php';
  17. //required for System::which() functionality
  18. require_once 'System.php';
  19.  
  20. /**
  21. * A class for scanning wireless networks and identifying
  22. * local wireless network interfaces.
  23. *
  24. @category Networking
  25. @package  Net_Wifi
  26. @author   Christian Weiske <cweiske@php.net>
  27. @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  28. @link     http://pear.php.net/package/Net_Wifi
  29. */
  30. class Net_Wifi
  31. {
  32.     var $REG_ACCESS_POINT         = '/Access Point: ([0-9:A-F]{17})/';
  33.     var $REG_BIT_RATE             = '/Bit Rate[:=]([0-9.]+) [mk]b\\/s/i';
  34.     var $REG_ESSID                = '/ESSID:"([^"]+)"/';
  35.     var $REG_INVALID_MISC         = '/Invalid misc[:=](-?[0-9]+)/';
  36.     var $REG_MISSED_BEACON        = '/Missed beacon[:=](-?[0-9]+)/';
  37.     var $REG_NICKNAME             = '/Nickname:"([^"]+)"/';
  38.     var $REG_NOISE_LEVEL          = '/Noise level[:=](-?[0-9]+) dBm/';
  39.     var $REG_POWER                = '/Power[:=]([0-9]+) dBm/';
  40.     var $REG_PROTOCOL_1           = '/IEEE ([0-9.]+[a-z])/';
  41.     var $REG_PROTOCOL_2           = '/([0-9.]+[a-z])\s+linked\s+ESSID/';
  42.     var $REG_RATES                = '|([0-9.]+) Mb/s|';
  43.     var $REG_GROUP_CIPHER         = '|Group Cipher : (.*)|';
  44.     var $REG_PAIRWISE_CIPHERS     = '|Pairwise Ciphers \([0-9]+\) : (.*)|';
  45.     var $REG_AUTH_SUITES          = '|Authentication Suites \([0-9]+\) : (.*)|';
  46.     var $REG_RX_INVALID_CRYPT     = '/Rx invalid crypt[:=](-?[0-9]+)/';
  47.     var $REG_RX_INVALID_FRAG      = '/Rx invalid frag[:=](-?[0-9]+)/';
  48.     var $REG_RX_INVALID_NWID      = '/Rx invalid nwid[:=](-?[0-9]+)/';
  49.     var $REG_SIGNAL_LEVEL         = '/Signal level[:=](-?[0-9]+) dBm/';
  50.     var $REG_TX_EXCESSIVE_RETRIES = '/Tx excessive retries[:=](-?[0-9]+)/';
  51.     var $REG_WPA_IE_STRING        = 'WPA Version 1';
  52.     var $REG_WPA2_IE_STRING       = 'IEEE 802.11i/WPA2 Version 1';
  53.  
  54.     /**
  55.     * Various locations of programs
  56.     * @var array 
  57.     */
  58.     var $arFileLocation = array(
  59.         'iwconfig'           => '/usr/sbin/iwconfig',
  60.         'iwlist'             => '/usr/sbin/iwlist',
  61.         '/proc/net/wireless' => '/proc/net/wireless'
  62.     );
  63.  
  64.     /**
  65.      * How to handle unknown lines in iwconfig output
  66.      * - 'echo':  Echo to stderr
  67.      * - $object: Log to object with debug priority.
  68.      *            assume 'Log' instance
  69.      * - null:    Ignore unknowns
  70.      *
  71.      * @var string 
  72.      */
  73.     var $unknowns = null;
  74.  
  75.  
  76.  
  77.     /**
  78.     * Constructor which tries to guess the paths of the tools
  79.     */
  80.     function Net_Wifi()
  81.     {
  82.         //try to find the paths
  83.         $iwconfig = System::which('iwconfig');
  84.         if ($iwconfig !== false{
  85.             $this->setPathIwconfig($iwconfig);
  86.         else if (file_exists('/sbin/iwconfig')) {
  87.             $this->setPathIwconfig('/sbin/iwconfig');
  88.         }
  89.  
  90.         $iwlist = System::which('iwlist');
  91.         if ($iwlist !== false{
  92.             $this->setPathIwlist($iwlist);
  93.         else if (file_exists('/sbin/iwlist')) {
  94.             $this->setPathIwlist('/sbin/iwlist');
  95.         }
  96.     }//function Net_Wifi()
  97.  
  98.  
  99.  
  100.     /**
  101.     * Returns an object with the current state of the interface
  102.     * (connected/not connected, AP,...).
  103.     *
  104.     * @param string $strInterface The interface to check
  105.     *
  106.     * @return Net_Wifi_Config The state information
  107.     * @access public
  108.     */
  109.     function getCurrentConfig($strInterface)
  110.     {
  111.         //get the plain config
  112.         $arLines = array();
  113.         exec(
  114.             $this->arFileLocation['iwconfig'' '
  115.             . escapeshellarg($strInterface),
  116.             $arLines
  117.         );
  118.         $strAll implode("\n"$arLines);
  119.  
  120.         return $this->parseCurrentConfig($strAll);
  121.     }//function getCurrentConfig(..)
  122.  
  123.  
  124.  
  125.     /**
  126.     * Parses the iwconfig output to collect the current config information.
  127.     *
  128.     * @param string $strAll The iwconfig output to parse
  129.     *
  130.     * @return Net_Wifi_Config  The current config object
  131.     * @access protected
  132.     */
  133.     function parseCurrentConfig($strAll)
  134.     {
  135.         $objConfig = new Net_Wifi_Config();
  136.  
  137.         $arMatches = array();
  138.         if (preg_match($this->REG_ESSID$strAll$arMatches)) {
  139.             $objConfig->ssid = $arMatches[1];
  140.         }
  141.         if (preg_match($this->REG_ACCESS_POINT$strAll$arMatches)) {
  142.             $objConfig->ap = $arMatches[1];
  143.         }
  144.         if (preg_match($this->REG_NICKNAME$strAll$arMatches)) {
  145.             $objConfig->nick = $arMatches[1];
  146.         }
  147.         if (strpos($strAll'Mode:Managed')) {
  148.             $objConfig->mode = 'managed';
  149.         else if (strpos($strAll'Mode:Ad-Hoc')) {
  150.             $objConfig->mode = 'ad-hoc';
  151.         }
  152.         if (preg_match($this->REG_BIT_RATE$strAll$arMatches)) {
  153.             $objConfig->rate = $arMatches[1];
  154.         }
  155.         if (preg_match($this->REG_POWER$strAll$arMatches)) {
  156.             $objConfig->power = $arMatches[1];
  157.         }
  158.         if (preg_match($this->REG_SIGNAL_LEVEL$strAll$arMatches)) {
  159.             $objConfig->rssi = $arMatches[1];
  160.         }
  161.         if (preg_match($this->REG_NOISE_LEVEL$strAll$arMatches)) {
  162.             $objConfig->noise = $arMatches[1];
  163.         }
  164.         if (preg_match($this->REG_PROTOCOL_1$strAll$arMatches)) {
  165.             $objConfig->protocol = $arMatches[1];
  166.         elseif (preg_match($this->REG_PROTOCOL_2$strAll$arMatches)) {
  167.             $objConfig->protocol = $arMatches[1];
  168.         }
  169.  
  170.         if (preg_match($this->REG_RX_INVALID_NWID$strAll$arMatches)) {
  171.             $objConfig->packages_rx_invalid_nwid = $arMatches[1];
  172.         }
  173.         if (preg_match($this->REG_RX_INVALID_CRYPT$strAll$arMatches)) {
  174.             $objConfig->packages_rx_invalid_crypt = $arMatches[1];
  175.         }
  176.         if (preg_match($this->REG_RX_INVALID_FRAG$strAll$arMatches)) {
  177.             $objConfig->packages_rx_invalid_frag = $arMatches[1];
  178.         }
  179.         if (preg_match($this->REG_TX_EXCESSIVE_RETRIES$strAll$arMatches)) {
  180.             $objConfig->packages_tx_excessive_retries = $arMatches[1];
  181.         }
  182.         if (preg_match($this->REG_INVALID_MISC$strAll$arMatches)) {
  183.             $objConfig->packages_invalid_misc = $arMatches[1];
  184.         }
  185.         if (preg_match($this->REG_MISSED_BEACON$strAll$arMatches)) {
  186.             $objConfig->packages_missed_beacon = $arMatches[1];
  187.         }
  188.  
  189.         //available in ipw2200 1.0.3 only
  190.         if (strpos($strAll'radio off')) {
  191.             $objConfig->activated = false;
  192.         }
  193.  
  194.         if (strpos($strAll'unassociated'=== false
  195.             && $objConfig->ap != null && $objConfig->ap != '00:00:00:00:00:00'
  196.         {
  197.             $objConfig->associated = true;
  198.         }
  199.  
  200.         return $objConfig;
  201.     }//function parseCurrentConfig(..)
  202.  
  203.  
  204.  
  205.     /**
  206.     * Checks if a network interface is connected to an access point.
  207.     *
  208.     * @param string $strInterface The network interface to check
  209.     *
  210.     * @return boolean If the interface is connected
  211.     * @access public
  212.     */
  213.     function isConnected($strInterface)
  214.     {
  215.         $objConfig $this->getCurrentConfig($strInterface);
  216.  
  217.         return $objConfig->associated;
  218.     }//function isConnected(..)
  219.  
  220.  
  221.  
  222.     /**
  223.     * Returns an array with the names/device files of
  224.     *  all supported wireless lan devices.
  225.     *
  226.     * @access public
  227.     * @return array   Array with wireless interfaces as values
  228.     */
  229.     function getSupportedInterfaces()
  230.     {
  231.         $arWirelessInterfaces = array();
  232.         if (file_exists($this->arFileLocation['/proc/net/wireless'])) {
  233.             /**
  234.             *   use /proc/net/wireless
  235.             */
  236.             $arLines file($this->arFileLocation['/proc/net/wireless']);
  237.             //begin with 3rd line
  238.             if (count($arLines> 2{
  239.                 for ($nA = 2; $nA count($arLines)$nA++{
  240.                     $nPos         strpos($arLines[$nA]':'0);
  241.                     $strInterface trim(substr($arLines[$nA]0$nPos));
  242.                     //assign interface
  243.                     $arWirelessInterfaces[$strInterface;
  244.                 }
  245.             }//we've got more than 2 lines
  246.         else {
  247.             /**
  248.             *   use iwconfig
  249.             */
  250.             $arLines = array();
  251.             exec($this->arFileLocation['iwconfig']$arLines);
  252.             foreach ($arLines as $strLine{
  253.                 if (trim($strLine[0]!= ''
  254.                     && strpos($strLine'no wireless extensions'=== false
  255.                 {
  256.                     //there is something
  257.                     $arWirelessInterfaces[]
  258.                         = substr($strLine0strpos($strLine' '));
  259.                 }
  260.             }//foreach line
  261.         }//use iwconfig
  262.  
  263.         return $arWirelessInterfaces;
  264.     }//function getSupportedInterfaces()
  265.  
  266.  
  267.  
  268.     /**
  269.     * Scans for access points / ad hoc cells and returns them.
  270.     *
  271.     * @param string $strInterface The interface to use
  272.     *
  273.     * @return array Array with cell information objects (Net_Wifi_Cell)
  274.     * @access public
  275.     */
  276.     function scan($strInterface)
  277.     {
  278.         $arLines = array();
  279.         exec(
  280.             $this->arFileLocation['iwlist'' '
  281.             . escapeshellarg($strInterface' scanning',
  282.             $arLines
  283.         );
  284.  
  285.         return $this->parseScan($arLines);
  286.     }//function scan(..)
  287.  
  288.  
  289.  
  290.     /**
  291.     * Parses the output of iwlist and returns the recognized cells.
  292.     *
  293.     * @param array $arLines Lines of the iwlist output as an array
  294.     *
  295.     * @return array Array with cell information objects
  296.     * @access protected
  297.     */
  298.     function parseScan($arLines)
  299.     {
  300.         if (count($arLines== 1{
  301.             //one line only -> no cells there
  302.             return array();
  303.         }
  304.  
  305.         //if bit rates are alone on lines
  306.         $bStandaloneRates = false;
  307.  
  308.         //split into cells
  309.         $arCells      = array();
  310.         $nCurrentCell = -1;
  311.         $nCount       count($arLines);
  312.         for ($nA = 1; $nA $nCount$nA++{
  313.             $strLine trim($arLines[$nA]);
  314.             if ($strLine == ''{
  315.                 continue;
  316.             }
  317.  
  318.             if (substr($strLine04== 'Cell'{
  319.                 //we've got a new cell
  320.                 $nCurrentCell++;
  321.                 //get cell number
  322.                 $nCell substr($strLine5strpos($strLine' '5- 5);
  323.                 //add new cell
  324.                 $arCells[$nCurrentCell]       = new Net_Wifi_Cell();
  325.                 $arCells[$nCurrentCell]->cell = $nCell;
  326.                 $arCells[$nCurrentCell]->ies = "";
  327.                 $arCells[$nCurrentCell]->wpa = false;
  328.                 $arCells[$nCurrentCell]->wpa2 = false;
  329.                 $arCells[$nCurrentCell]->wpa_group_cipher = array();
  330.                 $arCells[$nCurrentCell]->wpa_pairwise_cipher = array();
  331.                 $arCells[$nCurrentCell]->wpa_auth_suite = array();
  332.                 $arCells[$nCurrentCell]->wpa2_group_cipher = array();
  333.                 $arCells[$nCurrentCell]->wpa2_pairwise_cipher = array();
  334.                 $arCells[$nCurrentCell]->wpa2_auth_suite = array();
  335.  
  336.                 //remove cell information from line for further interpreting
  337.                 $strLine substr($strLinestrpos($strLine'- '+ 2);
  338.             }
  339.  
  340.             $nPos       strpos($strLine':');
  341.             $nPosEquals strpos($strLine'=');
  342.             if ($nPosEquals !== false && ($nPos === false || $nPosEquals $nPos)) {
  343.                 //sometimes there is a "=" instead of a ":"
  344.                 $nPos $nPosEquals;
  345.             }
  346.             $nPos++;
  347.  
  348.             $strId    strtolower(substr($strLine0$nPos - 1));
  349.             $strValue trim(substr($strLine$nPos));
  350.             switch ($strId{
  351.             case 'ie':
  352.                 if ($strValue == $this->REG_WPA_IE_STRING{
  353.                     // WPA1: "WPA Version 1" (multiline with Group Cipher list, Pairwise Ciphers list and Authentication Suites)
  354.                     /*
  355.                     * WPA Version 1
  356.                     *     Group Cipher : TKIP
  357.                     *     Pairwise Ciphers (2) : TKIP CCMP
  358.                     *     Authentication Suites (1) : PSK
  359.                     */
  360.                     $arCells[$nCurrentCell]->wpa = true;
  361.                     $bStandaloneRates = true;
  362.                 }
  363.  
  364.                 if ($strValue == $this->REG_WPA2_IE_STRING{
  365.                     // WPA2: "IEEE 802.11i/WPA2 Version 1" (multiline with Group Cipher list, Pairwise Ciphers list and Authentication Suites)
  366.                     /*
  367.                     * IEEE 802.11i/WPA2 Version 1
  368.                     *     Group Cipher : CCMP
  369.                     *     Pairwise Ciphers (1) : CCMP
  370.                     *     Authentication Suites (1) : PSK
  371.                     */
  372.                     $arCells[$nCurrentCell]->wpa2 = true;
  373.                     $bStandaloneRates = true;
  374.                 }
  375.                 $arCells[$nCurrentCell]->ies[$strValue;
  376.                 $arLines[$nA]     $strValue;
  377.                 $nA--;//go back one so that this line is re-parsed
  378.                 break;
  379.  
  380.             case 'address':
  381.                 $arCells[$nCurrentCell]->mac = $strValue;
  382.                 break;
  383.  
  384.             case 'essid':
  385.                 if ($strValue[0== '"'{
  386.                     //has quotes around
  387.                     $arCells[$nCurrentCell]->ssid = substr($strValue1-1);
  388.                 else {
  389.                     $arCells[$nCurrentCell]->ssid = $strValue;
  390.                 }
  391.                 break;
  392.  
  393.             case 'bit rate':
  394.                 $nRate floatval(substr($strValue0strpos($strValue'Mb/s')));
  395.                 //assign rate.
  396.                 $arCells[$nCurrentCell]->rate    = $nRate;
  397.                 $arCells[$nCurrentCell]->rates[$nRate;
  398.                 break;
  399.  
  400.             case 'bit rates':
  401.                 $bStandaloneRates = true;
  402.                 $arLines[$nA]     $strValue;
  403.                 $nA--;//go back one so that this line is re-parsed
  404.                 break;
  405.  
  406.             case 'protocol':
  407.                 if (substr($strValue05== 'IEEE '{
  408.                     $strValue substr($strValue5);
  409.                 }
  410.                 $arCells[$nCurrentCell]->protocol = $strValue;
  411.                 break;
  412.  
  413.             case 'channel':
  414.                 $arCells[$nCurrentCell]->channel = intval($strValue);
  415.                 break;
  416.  
  417.             case 'encryption key':
  418.                 if ($strValue == 'on'{
  419.                     $arCells[$nCurrentCell]->encryption = true;
  420.                 else {
  421.                     $arCells[$nCurrentCell]->encryption = false;
  422.                 }
  423.                 break;
  424.  
  425.             case 'mode':
  426.                 if (strtolower($strValue== 'master'{
  427.                     $arCells[$nCurrentCell]->mode = 'master';
  428.                 else {
  429.                     $arCells[$nCurrentCell]->mode = 'ad-hoc';
  430.                 }
  431.                 break;
  432.  
  433.             case 'signal level':
  434.                 $arCells[$nCurrentCell]->rssi
  435.                     = substr($strValue0strpos($strValue' '));
  436.                 break;
  437.  
  438.             case 'quality':
  439.                 $arData                          explode('  '$strValue);
  440.                 $arCells[$nCurrentCell]->quality = $arData[0];
  441.                 if (trim($arData[1]!= ''{
  442.                     //bad hack
  443.                     $arLines[$nA$arData[1];
  444.                     $nA--;
  445.                     if (isset($arData[2])) {
  446.                         $arLines[$nA - 1$arData[1];
  447.                         $nA--;
  448.                     }
  449.                 }
  450.                 break;
  451.  
  452.             case 'frequency':
  453.                 $match preg_match(
  454.                     '/([0-9.]+ GHz) \(Channel ([0-9])\)/',
  455.                     $strValue$arMatches
  456.                 );
  457.                 if ($match{
  458.                     $arCells[$nCurrentCell]->frequency = $arMatches[1];
  459.                     $arCells[$nCurrentCell]->channel   = $arMatches[2];
  460.                 else {
  461.                     $arCells[$nCurrentCell]->frequency = $strValue;
  462.                 }
  463.                 break;
  464.  
  465.             case 'extra':
  466.                 $nPos     strpos($strValue':');
  467.                 $strSubId strtolower(trim(substr($strValue0$nPos)));
  468.                 $strValue trim(substr($strValue$nPos + 1));
  469.                 switch ($strSubId{
  470.                 case 'rates (mb/s)':
  471.                     //1 2 5.5 11 54
  472.                     $arRates explode(' '$strValue);
  473.                     //convert to float values
  474.                     foreach ($arRates as $nB => $strRate{
  475.                         $arCells[$nCurrentCell]->rates[$nBfloatval($strRate);
  476.                     }
  477.                     break;
  478.  
  479.                 case 'signal':
  480.                 case 'rssi':
  481.                     //-53 dBm
  482.                     $arCells[$nCurrentCell]->rssi
  483.                         = intval(substr($strValue0strpos($strValue' ')));
  484.                     break;
  485.  
  486.                 case 'last beacon':
  487.                     //25ms ago
  488.                     $arCells[$nCurrentCell]->beacon
  489.                         = intval(substr($strValue0strpos($strValue'ms')));
  490.                     break;
  491.  
  492.                 default:
  493.                     $this->handleUnknown(null$strSubId);
  494.                     break;
  495.                 }
  496.                 break;
  497.  
  498.             default:
  499.                 if ($bStandaloneRates{
  500.                     if (preg_match_all($this->REG_RATES$strLine$arMatches> 0{
  501.                         foreach ($arMatches[1as $nRate{
  502.                             $nRate                           floatval($nRate);
  503.                             $arCells[$nCurrentCell]->rate    = $nRate;
  504.                             $arCells[$nCurrentCell]->rates[$nRate;
  505.                         }
  506.                         break;
  507.                     }
  508.                     if (preg_match_all($this->REG_GROUP_CIPHER$strLine$arMatches> 0{
  509.                         foreach ($arMatches[1as $nCipher{
  510.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA_IE_STRING// WPA1
  511.                                 $arCells[$nCurrentCell]->wpa_group_cipher = explode(' '$nCipher);
  512.                             }
  513.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA2_IE_STRING// WPA2
  514.                                 $arCells[$nCurrentCell]->wpa2_group_cipher = explode(' '$nCipher);
  515.                             }
  516.                         }
  517.                         break;
  518.                     }
  519.                     if (preg_match_all($this->REG_PAIRWISE_CIPHERS$strLine$arMatches> 0{
  520.                         foreach ($arMatches[1as $nCipher{
  521.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA_IE_STRING// WPA1
  522.                                 $arCells[$nCurrentCell]->wpa_pairwise_cipher = explode(' '$nCipher);
  523.                             }
  524.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA2_IE_STRING// WPA2
  525.                                 $arCells[$nCurrentCell]->wpa2_pairwise_cipher = explode(' '$nCipher);
  526.                             }
  527.                         }
  528.                         break;
  529.                     }
  530.                     if (preg_match_all($this->REG_AUTH_SUITES$strLine$arMatches> 0{
  531.                         foreach ($arMatches[1as $nSuite{
  532.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA_IE_STRING// WPA1
  533.                                 $arCells[$nCurrentCell]->wpa_auth_suite = explode(' '$nSuite);
  534.                             }
  535.                             if (end($arCells[$nCurrentCell]->ies== $this->REG_WPA2_IE_STRING// WPA2
  536.                                 $arCells[$nCurrentCell]->wpa2_auth_suite = explode(' '$nSuite);
  537.                             }
  538.                         }
  539.                         break;
  540.                     }
  541.                 }
  542.                 $this->handleUnknown($strIdnull);
  543.                 break;
  544.             }
  545.         }//foreach line
  546.  
  547.  
  548.         //not all outputs are sorted (note the 6)
  549.         //Extra: Rates (Mb/s): 1 2 5.5 9 11 6 12 18 24 36 48 54
  550.         //additionally, some drivers have many single "Bit Rate:"
  551.         // fields instead of one big one
  552.         foreach ($arCells as $nCurrentCell => $arData{
  553.             sort($arCells[$nCurrentCell]->rates);
  554.             $arCells[$nCurrentCell]->rates
  555.                 = array_unique($arCells[$nCurrentCell]->rates);
  556.         }
  557.  
  558.  
  559.         return $arCells;
  560.     }//function parseScan(..)
  561.  
  562.  
  563.  
  564.     /**
  565.     * Tells the driver to use the access point with the given MAC address only.
  566.     *
  567.     * You can use "off" to enable automatic mode again without
  568.     * changing the current AP, or "any" resp. "auto" to force
  569.     * the card to re-associate with the currently best AP
  570.     *
  571.     * EXPERIMENTAL! WILL CHANGE IN FUTURE VERSIONS
  572.     *
  573.     * @param string $strInterface The interface to use
  574.     * @param string $strMac       The mac address of the access point
  575.     *
  576.     * @return boolean True if setting was ok, false if not
  577.     * @access public
  578.     */
  579.     function connectToAccessPoint($strInterface$strMac)
  580.     {
  581.         $arLines    = array();
  582.         $nReturnVar = 0;
  583.         exec(
  584.             $this->arFileLocation['iwconfig'' ' escapeshellarg($strInterface)
  585.             . ' ap ' escapeshellarg($strMac),
  586.             $arLines,
  587.             $nReturnVar
  588.         );
  589.  
  590.         return $nReturnVar == 0;
  591.     }//function connectToAccessPoint(..)
  592.  
  593.  
  594.  
  595.     /**
  596.      * Handle unknown configuration lines.
  597.      *
  598.      * @param string $strId    iwconfig output prefix (i.e. 'frequency')
  599.      * @param string $strSubId iwconfig output value
  600.      *
  601.      * @return void 
  602.      *
  603.      * @uses $unknowns
  604.      */
  605.     function handleUnknown($strId$strSubId)
  606.     {
  607.         if ($this->unknowns === null{
  608.             return;
  609.         }
  610.  
  611.         if ($strId !== null{
  612.             $strMsg 'unknown iwconfig information: ' $strId;
  613.         else {
  614.             $strMsg 'unknown iwconfig extra information: ' $strSubId;
  615.         }
  616.  
  617.         if ($this->unknowns == 'echo'{
  618.             fwrite(STDERR$strMsg "\r\n");
  619.         else if (is_object($this->unknowns)) {
  620.             $this->unknowns->debug($strMsg);
  621.         }
  622.     }//function handleUnknown(..)
  623.  
  624.  
  625.  
  626.     /**
  627.     * and now some dumb getters and setters
  628.     */
  629.  
  630.  
  631.  
  632.     /**
  633.     * Returns the set path to /proc/wireless.
  634.     *
  635.     * @return string The path to "/proc/net/wireless"
  636.     * @access public
  637.     */
  638.     function getPathProcWireless()
  639.     {
  640.         return $this->arFileLocation['/proc/net/wireless'];
  641.     }//function getPathProcWireless()
  642.  
  643.  
  644.  
  645.     /**
  646.     * Set the path to /proc/net/wireless.
  647.     *
  648.     * @param string $strProcWireless The new /proc/net/wireless path
  649.     *
  650.     * @return null 
  651.     * @access public
  652.     */
  653.     function setPathProcWireless($strProcWireless)
  654.     {
  655.         $this->arFileLocation['/proc/net/wireless'$strProcWireless;
  656.     }//function setPathProcWireless(..)
  657.  
  658.  
  659.  
  660.     /**
  661.     * Returns the set path to iwconfig.
  662.     *
  663.     * @return string The path to iwconfig
  664.     * @access public
  665.     */
  666.     function getPathIwconfig()
  667.     {
  668.         return $this->arFileLocation['iwconfig'];
  669.     }//function getPathIwconfig()
  670.  
  671.  
  672.  
  673.     /**
  674.     * Set the path to iwconfig.
  675.     *
  676.     * @param string $strPathIwconfig The new ifwconfig path
  677.     *
  678.     * @return null 
  679.     * @access public
  680.     */
  681.     function setPathIwconfig($strPathIwconfig)
  682.     {
  683.         $this->arFileLocation['iwconfig'$strPathIwconfig;
  684.     }//function setPathIwconfig(..)
  685.  
  686.  
  687.  
  688.     /**
  689.     * Returns the set path to iwlist.
  690.     *
  691.     * @return string The path to iwlist
  692.     *
  693.     * @access public
  694.     */
  695.     function getPathIwlist()
  696.     {
  697.         return $this->arFileLocation['iwlist'];
  698.     }//function getPathIwlist()
  699.  
  700.  
  701.  
  702.     /**
  703.     * Returns the set path to iwlist.
  704.     *
  705.     * @param string $strPathIwlist The new iwlist path
  706.     *
  707.     * @return void 
  708.     * @access public
  709.     */
  710.     function setPathIwlist($strPathIwlist)
  711.     {
  712.         $this->arFileLocation['iwlist'$strPathIwlist;
  713.     }//function setPathIwlist(..)
  714.  
  715.  
  716. }//class Net_Wifi
  717.  
  718. ?>

Documentation generated on Wed, 19 Jun 2013 08:30:02 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.