-
-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1443 from RaspAP/feat/iw-parser
Refactor ISO countries + create IW parsing class
- Loading branch information
Showing
15 changed files
with
290 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,14 @@ | ||
<?php | ||
|
||
require '../../includes/csrf.php'; | ||
require_once '../../includes/config.php'; | ||
require_once '../../includes/locale.php'; | ||
require '../../src/RaspAP/Parsers/IwParser.php'; | ||
|
||
if (isset($_POST['interface'])) { | ||
|
||
define( 'NL80211_BAND_24GHZ', 0x1 ); | ||
define( 'NL80211_BAND_5GHZ', 0x2 ); | ||
$iface = escapeshellcmd($_POST['interface']); | ||
$flags = 0; | ||
$parser = new \RaspAP\Parsers\IwParser($iface); | ||
$supportedFrequencies = $parser->parseIwInfo($iface); | ||
|
||
// get physical device for selected interface | ||
exec("iw dev | awk -v iface=".$iface." '/^phy#/ { phy = $0 } $1 == \"Interface\" { interface = $2 } interface == iface { print phy }'", $return); | ||
$phy = $return[0]; | ||
|
||
// get frequencies supported by device | ||
exec('iw '.$phy.' info | sed -rn "s/^.*\*\s([0-9]{4})\sMHz.*/\1/p"', $frequencies); | ||
|
||
if (count(preg_grep('/^24[0-9]{2}/i', $frequencies)) >0) { | ||
$flags += NL80211_BAND_24GHZ; | ||
} | ||
if (count(preg_grep('/^5[0-9]{3}/i', $frequencies)) >0) { | ||
$flags += NL80211_BAND_5GHZ; | ||
} | ||
|
||
switch ($flags) { | ||
case NL80211_BAND_24GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for the 2.4 GHz wireless band only."), $iface); | ||
break; | ||
case NL80211_BAND_5GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for the 5 GHz wireless band only."), $iface); | ||
break; | ||
case NL80211_BAND_24GHZ | NL80211_BAND_5GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for both the 2.4 and 5 GHz wireless bands."), $iface); | ||
break; | ||
default: | ||
$msg = sprintf(_("The selected interface (%s) does not support wireless mode operation."), $iface); | ||
} | ||
echo json_encode($msg); | ||
echo json_encode($supportedFrequencies); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
require '../../includes/csrf.php'; | ||
require_once '../../includes/config.php'; | ||
require_once '../../includes/locale.php'; | ||
|
||
if (isset($_POST['interface'])) { | ||
|
||
define( 'NL80211_BAND_24GHZ', 0x1 ); | ||
define( 'NL80211_BAND_5GHZ', 0x2 ); | ||
$iface = escapeshellcmd($_POST['interface']); | ||
$flags = 0; | ||
|
||
// get physical device for selected interface | ||
exec("iw dev | awk -v iface=".$iface." '/^phy#/ { phy = $0 } $1 == \"Interface\" { interface = $2 } interface == iface { print phy }'", $return); | ||
$phy = $return[0]; | ||
|
||
// get frequencies supported by device | ||
exec('iw '.$phy.' info | sed -rn "s/^.*\*\s([0-9]{4})\sMHz.*/\1/p"', $frequencies); | ||
|
||
if (count(preg_grep('/^24[0-9]{2}/i', $frequencies)) >0) { | ||
$flags += NL80211_BAND_24GHZ; | ||
} | ||
if (count(preg_grep('/^5[0-9]{3}/i', $frequencies)) >0) { | ||
$flags += NL80211_BAND_5GHZ; | ||
} | ||
|
||
switch ($flags) { | ||
case NL80211_BAND_24GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for the 2.4 GHz wireless band only."), $iface); | ||
break; | ||
case NL80211_BAND_5GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for the 5 GHz wireless band only."), $iface); | ||
break; | ||
case NL80211_BAND_24GHZ | NL80211_BAND_5GHZ: | ||
$msg = sprintf(_("The selected interface (%s) has support for both the 2.4 and 5 GHz wireless bands."), $iface); | ||
break; | ||
default: | ||
$msg = sprintf(_("The selected interface (%s) does not support wireless mode operation."), $iface); | ||
} | ||
echo json_encode($msg); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.