Begin of json rpc API and ... making openwrt module work

Openwrt module was broken reworking all module !
This commit is contained in:
Philippe Caseiro 2018-09-24 17:38:17 +02:00 committed by William Petit
parent 1694111ed5
commit 6a316c53ee
21 changed files with 2128 additions and 554 deletions

View File

@ -1,29 +1,54 @@
package rpc package rpc
import ( import (
"fmt"
"net/http" "net/http"
"forge.cadoles.com/Pyxis/orion/openwrt"
"github.com/gorilla/rpc" "github.com/gorilla/rpc"
"github.com/gorilla/rpc/json" "github.com/gorilla/rpc/json"
) )
// OrionService is the JSON-RPC API // OrionService is the JSON-RPC API
type OrionService struct{} type OrionService struct {
UCI *openwrt.UCI
// HelloArgs is the arguments expected by the Hello method
type HelloArgs struct {
Who string
} }
// HelloResponse is the response returned from the Hello method // NewOrionService create a new OrionService !
type HelloResponse struct { func NewOrionService() *OrionService {
Message string uci := openwrt.NewUCI()
return &OrionService{
UCI: uci,
}
} }
// Hello is a demo RPC method fro the OrionService // UCIArgs argument structure for exported method OwrtListWifiDevices
func (o *OrionService) Hello(r *http.Request, args *HelloArgs, reply *HelloResponse) error { type UCIArgs struct{}
reply.Message = fmt.Sprintf("hello %s", args.Who)
// UCIResponse is the response structure for exposed method OwrtListWifiDevices
type UCIResponse struct {
Devices []map[string]string
}
// OwrtListWifiDevices offers an RPC Method to list Wifi nics in a OpenWRT device.
func (o *OrionService) OwrtListWifiDevices(r *http.Request, args *UCIArgs, reply *UCIResponse) error {
o.UCI.LoadWirelessConf()
devs := o.UCI.GetWifiDevices()
reply.Devices = devs
return nil
}
// ListIfaceArgs argument structure for exported method OwrtListWifiDevices
type ListIfaceArgs struct{}
// ListIfaceResponse is the response structure for exposed method OwrtListWifiDevices
type ListIfaceResponse struct {
Interfaces []*openwrt.UCIWirelessInterface
}
// OwrtListWifiInterfaces offers an RPC Method to list wifi interfaces in a OpenWRT device.
func (o *OrionService) OwrtListWifiInterfaces(r *http.Request, args *ListIfaceArgs, reply *ListIfaceResponse) error {
o.UCI.LoadWirelessConf()
reply.Interfaces = o.UCI.GetWifiIfaces()
return nil return nil
} }

View File

@ -2,7 +2,6 @@ package openwrt
import ( import (
"bytes" "bytes"
"fmt"
"log" "log"
"os/exec" "os/exec"
"syscall" "syscall"
@ -25,34 +24,22 @@ type localExecutor struct{}
func (e *localExecutor) Run(command string, params ...string) *CommandResult { func (e *localExecutor) Run(command string, params ...string) *CommandResult {
var out bytes.Buffer var out bytes.Buffer
var stderr bytes.Buffer var outerr bytes.Buffer
var exitCode int var exitCode int
defaultFailedCode := 255
exe := exec.Command(command, params...) exe := exec.Command(command, params...)
exe.Stdout = &out exe.Stdout = &out
exe.Stderr = &stderr exe.Stderr = &outerr
err := exe.Run() err := exe.Run()
if err != nil { if err != nil {
// try to get the exit code
if exitError, ok := err.(*exec.ExitError); ok { if exitError, ok := err.(*exec.ExitError); ok {
ws := exitError.Sys().(syscall.WaitStatus) ws := exitError.Sys().(syscall.WaitStatus)
exitCode = ws.ExitStatus() exitCode = ws.ExitStatus()
} else { } else {
// This will happen (in OSX) if `name` is not available in $PATH,
// in this situation, exit code could not be get, and stderr will be
// empty string very likely, so we use the default fail code, and format err
// to string and set to stderr
log.Printf("Could not get exit code for failed program: %v, %v", command, params) log.Printf("Could not get exit code for failed program: %v, %v", command, params)
exitCode = defaultFailedCode
} }
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
log.Fatal(err)
}
if err != nil {
// try to get the exit code
} else { } else {
// success, exitCode should be 0 if go is ok // success, exitCode should be 0 if go is ok
ws := exe.ProcessState.Sys().(syscall.WaitStatus) ws := exe.ProcessState.Sys().(syscall.WaitStatus)
@ -61,7 +48,7 @@ func (e *localExecutor) Run(command string, params ...string) *CommandResult {
return &CommandResult{ return &CommandResult{
Stdout: out.String(), Stdout: out.String(),
Stderr: stderr.String(), Stderr: outerr.String(),
ReturnCode: exitCode, ReturnCode: exitCode,
} }
} }

View File

@ -12,7 +12,7 @@ type Network struct {
exec Executor exec Executor
} }
// NewNetwork return an UCI instance to interact with UCI // NewNetwork return an Network instance to interact with OpenWRT Network components
func NewNetwork() *Network { func NewNetwork() *Network {
exec := &localExecutor{} exec := &localExecutor{}
return &Network{exec} return &Network{exec}
@ -57,7 +57,11 @@ func (n *Network) ListWirelessInterfaces(wifiFile string) []net.Interface {
continue continue
} else { } else {
name := strings.Split(line, ":")[0] name := strings.Split(line, ":")[0]
ifaceNames = append(ifaceNames, name) if name != "" {
// remove damened whitespaces
name = strings.Replace(name, " ", "", -1)
ifaceNames = append(ifaceNames, name)
}
} }
} }
@ -66,12 +70,14 @@ func (n *Network) ListWirelessInterfaces(wifiFile string) []net.Interface {
fmt.Print(fmt.Errorf("error listing network interfaces : %+v", err.Error())) fmt.Print(fmt.Errorf("error listing network interfaces : %+v", err.Error()))
return nil return nil
} }
for _, i := range ifaces {
for _, name := range ifaceNames { for _, name := range ifaceNames {
if name == i.Name { for _, iface := range ifaces {
result = append(result, i) if name == iface.Name {
result = append(result, iface)
} }
} }
} }
return result return result
} }

View File

@ -16,7 +16,11 @@ func TestNetworkListInterfaces(t *testing.T) {
func TestListWirelessInterfaces(t *testing.T) { func TestListWirelessInterfaces(t *testing.T) {
net := NewNetwork() net := NewNetwork()
res := net.ListWirelessInterfaces("./testdata/proc_net_wireless.txt") res := net.ListWirelessInterfaces("./testdata/proc_net_wireless.txt")
if len(res) != 0 {
t.Error("The wireless interfaces list is not empty !!")
}
for _, el := range res { for _, el := range res {
fmt.Printf("%s\n", el.Name) fmt.Printf("[%s]\n", el.Name)
} }
} }

24
openwrt/testdata/uci_show_wireless.txt vendored Normal file
View File

@ -0,0 +1,24 @@
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.channel='36'
wireless.radio0.hwmode='11a'
wireless.radio0.htmode='VHT80'
wireless.radio0.country='DE'
wireless.radio0.path='soc/soc:pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.macaddr='5a:ef:68:b5:f5:1a'
wireless.default_radio0.ssid='DonDuSang'
wireless.default_radio0.encryption='psk2'
wireless.default_radio0.key='cadoles;21'
wireless.radio1=wifi-device
wireless.radio1.type='mac80211'
wireless.radio1.hwmode='11g'
wireless.radio1.htmode='HT20'
wireless.radio1.country='FR'
wireless.radio1.path='soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
wireless.radio1.channel='1'
wireless.radio1.legacy_rates='1'
wireless.radio1.disabled='0'

View File

@ -0,0 +1,30 @@
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.channel='36'
wireless.radio0.hwmode='11a'
wireless.radio0.htmode='VHT80'
wireless.radio0.country='DE'
wireless.radio0.path='soc/soc:pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.macaddr='5a:ef:68:b5:f5:1a'
wireless.default_radio0.ssid='DonDuSang'
wireless.default_radio0.encryption='psk2'
wireless.default_radio0.key='free_wifi!'
wireless.radio1=wifi-device
wireless.radio1.type='mac80211'
wireless.radio1.hwmode='11g'
wireless.radio1.htmode='HT20'
wireless.radio1.country='FR'
wireless.radio1.path='soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
wireless.radio1.channel='1'
wireless.radio1.legacy_rates='1'
wireless.radio1.disabled='0'
wireless.@wifi-iface[1]=wifi-iface
wireless.@wifi-iface[1].device='radio1'
wireless.@wifi-iface[1].mode='ap'
wireless.@wifi-iface[1].ssid='Pyxis2'
wireless.@wifi-iface[1].encryption='psk2'
wireless.@wifi-iface[1].key='free_wifi!'

View File

@ -0,0 +1,31 @@
BSS 7c:26:64:66:cc:44(on wlan1)
TSF: 85238642066 usec (0d, 23:40:38)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -63.00 dBm
last seen: 1500 ms ago
Information elements from Probe Response frame:
SSID: Livebox-32c8
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-23
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)

View File

@ -1,17 +1,88 @@
Cell 40 - Address: 68:A3:78:6E:D9:24 BSS 74:3e:2b:08:41:1c(on wlan1)
ESSID: "PyxisWifi" TSF: 85238642066 usec (0d, 23:40:38)
Mode: Master Channel: 3 freq: 2412
Signal: -90 dBm Quality: 20/70 beacon interval: 100 TUs
Encryption: none capability: ESS (0x0431)
signal: -63.00 dBm
Cell 41 - Address: B0:39:56:92:59:E2 last seen: 1500 ms ago
ESSID: "NET17" Information elements from Probe Response frame:
Mode: Master Channel: 4 SSID: PyxisWifi
Signal: -88 dBm Quality: 22/70 HT capabilities:
Encryption: WPA2 PSK (CCMP) Capabilities: 0x1ad
RX LDPC
Cell 42 - Address: 0C:F4:D5:16:AA:18 HT20
ESSID: "DIJON-METROPOLE-WIFI" SM Power Save disabled
Mode: Master Channel: 13 RX HT20 SGI
Signal: -90 dBm Quality: 20/70 TX STBC
Encryption: none RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-23
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 7e:26:64:66:cc:44(on wlan1)
TSF: 85238646001 usec (0d, 23:40:38)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0421)
signal: -66.00 dBm
last seen: 1500 ms ago
Information elements from Probe Response frame:
SSID: orange
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-23
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 20:47:da:b7:0e:5c(on wlan1)
TSF: 2161066518436 usec (25d, 00:17:46)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -58.00 dBm
last seen: 1640 ms ago
Information elements from Probe Response frame:
SSID: Livebox-596a
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-23
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)

View File

@ -1,293 +1,1152 @@
Cell 01 - Address: 0C:8D:DB:C4:A0:34 BSS 7c:26:64:66:cc:44(on wlan1)
ESSID: "pfPauvres" TSF: 85238642066 usec (0d, 23:40:38)
Mode: Master Channel: 11 freq: 2412
Signal: -50 dBm Quality: 60/70 beacon interval: 100 TUs
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) capability: ESS (0x0431)
signal: -63.00 dBm
Cell 02 - Address: 40:5A:9B:ED:BA:F0 last seen: 1500 ms ago
ESSID: "Cadoles" Information elements from Probe Response frame:
Mode: Master Channel: 6 SSID: Livebox-32c8
Signal: -36 dBm Quality: 70/70 HT capabilities:
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) Capabilities: 0x1ad
RX LDPC
Cell 03 - Address: A0:04:60:B2:8A:C8 HT20
ESSID: "Cadoles Formations (N)" SM Power Save disabled
Mode: Master Channel: 13 RX HT20 SGI
Signal: -32 dBm Quality: 70/70 TX STBC
Encryption: WPA2 PSK (CCMP) RX STBC 1-stream
Max AMSDU length: 3839 bytes
Cell 04 - Address: B0:39:56:D8:38:ED No DSSS/CCK HT40
ESSID: "Frate Dijon EXT" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Mode: Master Channel: 11 Minimum RX AMPDU time spacing: 8 usec (0x06)
Signal: -57 dBm Quality: 53/70 HT TX/RX MCS rate indexes supported: 0-23
Encryption: WPA2 PSK (CCMP) HT operation:
* primary channel: 1
Cell 05 - Address: 00:A6:CA:10:DF:00 * secondary channel offset: no secondary
ESSID: unknown * STA channel width: 20 MHz
Mode: Master Channel: 6 RSN: * Version: 1
Signal: -80 dBm Quality: 30/70 * Group cipher: TKIP
Encryption: WPA2 802.1X (CCMP) * Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
Cell 06 - Address: AC:84:C9:2F:59:6E * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
ESSID: "Livebox-596a" BSS 7e:26:64:66:cc:44(on wlan1)
Mode: Master Channel: 1 TSF: 85238646001 usec (0d, 23:40:38)
Signal: -62 dBm Quality: 48/70 freq: 2412
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) beacon interval: 100 TUs
capability: ESS (0x0421)
Cell 07 - Address: 00:A6:CA:10:DF:01 signal: -66.00 dBm
ESSID: "EFF-Mobility" last seen: 1500 ms ago
Mode: Master Channel: 6 Information elements from Probe Response frame:
Signal: -74 dBm Quality: 36/70 SSID: orange
Encryption: WPA2 PSK (CCMP) HT capabilities:
Capabilities: 0x1ad
Cell 08 - Address: A0:1B:29:BE:98:26 RX LDPC
ESSID: "Livebox-9822" HT20
Mode: Master Channel: 6 SM Power Save disabled
Signal: -81 dBm Quality: 29/70 RX HT20 SGI
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) TX STBC
RX STBC 1-stream
Cell 09 - Address: 7C:26:64:66:CC:44 Max AMSDU length: 3839 bytes
ESSID: "Livebox-32c8" No DSSS/CCK HT40
Mode: Master Channel: 1 Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Signal: -74 dBm Quality: 36/70 Minimum RX AMPDU time spacing: 8 usec (0x06)
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) HT TX/RX MCS rate indexes supported: 0-23
HT operation:
Cell 10 - Address: 00:A6:CA:10:DF:02 * primary channel: 1
ESSID: "Keo-HotSpot" * secondary channel offset: no secondary
Mode: Master Channel: 6 * STA channel width: 20 MHz
Signal: -79 dBm Quality: 31/70 BSS ac:84:c9:2f:59:6e(on wlan1)
Encryption: none TSF: 2161066518436 usec (25d, 00:17:46)
freq: 2412
Cell 11 - Address: 7E:26:64:66:CC:44 beacon interval: 100 TUs
ESSID: "orange" capability: ESS (0x0431)
Mode: Master Channel: 1 signal: -58.00 dBm
Signal: -73 dBm Quality: 37/70 last seen: 1640 ms ago
Encryption: none Information elements from Probe Response frame:
SSID: Livebox-596a
Cell 12 - Address: 3C:52:82:FC:5E:21 HT capabilities:
ESSID: "DIRECT-20-HP DeskJet 3630 series" Capabilities: 0x1ad
Mode: Master Channel: 6 RX LDPC
Signal: -78 dBm Quality: 32/70 HT20
Encryption: WPA2 PSK (CCMP) SM Power Save disabled
RX HT20 SGI
Cell 13 - Address: E4:9E:12:8B:EF:73 TX STBC
ESSID: "Freebox-8BEF72" RX STBC 1-stream
Mode: Master Channel: 9 Max AMSDU length: 3839 bytes
Signal: -79 dBm Quality: 31/70 No DSSS/CCK HT40
Encryption: WPA2 PSK (CCMP) Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
Cell 14 - Address: 40:4A:03:05:D2:68 HT TX/RX MCS rate indexes supported: 0-23
ESSID: "ZyXEL" HT operation:
Mode: Master Channel: 11 * primary channel: 1
Signal: -71 dBm Quality: 39/70 * secondary channel offset: no secondary
Encryption: WPA2 PSK (CCMP) * STA channel width: 20 MHz
RSN: * Version: 1
Cell 15 - Address: 5C:C3:07:7E:39:D4 * Group cipher: TKIP
ESSID: "pfP Xa" * Pairwise ciphers: CCMP TKIP
Mode: Master Channel: 1 * Authentication suites: PSK
Signal: -65 dBm Quality: 45/70 * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
Encryption: WPA2 PSK (CCMP) BSS b0:39:56:d8:38:ed(on wlan1)
TSF: 1037415177423 usec (12d, 00:10:15)
Cell 16 - Address: AC:84:C9:1D:C6:7C freq: 2422
ESSID: "Frate Djon" beacon interval: 100 TUs
Mode: Master Channel: 1 capability: ESS (0x0c11)
Signal: -79 dBm Quality: 31/70 signal: -51.00 dBm
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) last seen: 1220 ms ago
Information elements from Probe Response frame:
Cell 17 - Address: 00:17:33:9F:4D:80 SSID: Frate Dijon EXT
ESSID: "NEUF_4D7C" HT capabilities:
Mode: Master Channel: 11 Capabilities: 0x11ee
Signal: -83 dBm Quality: 27/70 HT20/HT40
Encryption: WPA PSK (TKIP, CCMP) SM Power Save disabled
RX HT20 SGI
Cell 18 - Address: A2:17:33:9F:4D:81 RX HT40 SGI
ESSID: "SFR WiFi FON" TX STBC
Mode: Master Channel: 11 RX STBC 1-stream
Signal: -85 dBm Quality: 25/70 Max AMSDU length: 3839 bytes
Encryption: none DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Cell 19 - Address: BC:F6:85:FE:6D:46 Minimum RX AMPDU time spacing: 4 usec (0x05)
ESSID: "Dlink" HT RX MCS rate indexes supported: 0-15, 32
Mode: Master Channel: 12 HT TX MCS rate indexes are undefined
Signal: -70 dBm Quality: 40/70 HT operation:
Encryption: WPA2 PSK (CCMP) * primary channel: 3
* secondary channel offset: no secondary
Cell 20 - Address: 30:7C:B2:D1:0B:0D * STA channel width: 20 MHz
ESSID: "Livebox-0b09" RSN: * Version: 1
Mode: Master Channel: 11 * Group cipher: CCMP
Signal: -81 dBm Quality: 29/70 * Pairwise ciphers: CCMP
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) * Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
Cell 21 - Address: A2:17:33:9F:4D:83 BSS 40:5a:9b:ed:ba:f0(on wlan1)
ESSID: "SFR WiFi Mobile" TSF: 3568958658654 usec (41d, 07:22:38)
Mode: Master Channel: 11 freq: 2437
Signal: -85 dBm Quality: 25/70 beacon interval: 100 TUs
Encryption: WPA2 802.1X (CCMP) capability: ESS (0x0431)
signal: -46.00 dBm
Cell 22 - Address: 90:4D:4A:F7:B9:70 last seen: 740 ms ago
ESSID: "Livebox-B970" Information elements from Probe Response frame:
Mode: Master Channel: 11 SSID: Cadoles
Signal: -84 dBm Quality: 26/70 HT capabilities:
Encryption: WPA2 PSK (CCMP) Capabilities: 0x1ad
RX LDPC
Cell 23 - Address: 90:4D:4A:F7:B9:71 HT20
ESSID: "orange" SM Power Save disabled
Mode: Master Channel: 11 RX HT20 SGI
Signal: -89 dBm Quality: 21/70 TX STBC
Encryption: none RX STBC 1-stream
Max AMSDU length: 3839 bytes
Cell 24 - Address: 00:22:6B:86:5B:71 No DSSS/CCK HT40
ESSID: "linksys" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Mode: Master Channel: 11 Minimum RX AMPDU time spacing: 8 usec (0x06)
Signal: -86 dBm Quality: 24/70 HT TX/RX MCS rate indexes supported: 0-15
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) HT operation:
* primary channel: 6
Cell 25 - Address: 68:A3:78:6E:D9:25 * secondary channel offset: no secondary
ESSID: "FreeWifi_secure" * STA channel width: 20 MHz
Mode: Master Channel: 3 RSN: * Version: 1
Signal: -86 dBm Quality: 24/70 * Group cipher: TKIP
Encryption: WPA2 802.1X (TKIP, CCMP) * Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
Cell 26 - Address: 6C:38:A1:62:1B:28 * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
ESSID: "Bbox-1B7889A9" BSS 00:a6:ca:10:df:01(on wlan1)
Mode: Master Channel: 1 TSF: 1018905678733 usec (11d, 19:01:45)
Signal: -90 dBm Quality: 20/70 freq: 2437
Encryption: mixed WPA/WPA2 PSK (CCMP) beacon interval: 102 TUs
capability: ESS (0x1431)
Cell 27 - Address: 78:81:02:5E:B7:14 signal: -80.00 dBm
ESSID: "Livebox-B714" last seen: 820 ms ago
Mode: Master Channel: 6 Information elements from Probe Response frame:
Signal: -86 dBm Quality: 24/70 SSID: EFF-Mobility
Encryption: WPA2 PSK (CCMP) HT capabilities:
Capabilities: 0x19ac
Cell 28 - Address: F4:CA:E5:98:3B:DC HT20
ESSID: "Freebox-5D2400" SM Power Save disabled
Mode: Master Channel: 11 RX HT20 SGI
Signal: -84 dBm Quality: 26/70 TX STBC
Encryption: WPA PSK (CCMP) RX STBC 1-stream
Max AMSDU length: 7935 bytes
Cell 29 - Address: 8C:DC:D4:93:69:17 DSSS/CCK HT40
ESSID: "HP-Print-17-Photosmart 5520" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Mode: Master Channel: 11 Minimum RX AMPDU time spacing: 8 usec (0x06)
Signal: -87 dBm Quality: 23/70 HT RX MCS rate indexes supported: 0-23
Encryption: none HT TX MCS rate indexes are undefined
RSN: * Version: 1
Cell 30 - Address: 44:CE:7D:20:5C:A4 * Group cipher: CCMP
ESSID: "SFR_5CA0" * Pairwise ciphers: CCMP
Mode: Master Channel: 6 * Authentication suites: PSK
Signal: -86 dBm Quality: 24/70 * Capabilities: 4-PTKSA-RC 4-GTKSA-RC (0x0028)
Encryption: WPA PSK (TKIP, CCMP) HT operation:
* primary channel: 6
Cell 31 - Address: F4:CA:E5:98:3B:DE * secondary channel offset: no secondary
ESSID: "FreeWifi_secure" * STA channel width: 20 MHz
Mode: Master Channel: 11 BSS a0:04:60:b2:8a:c8(on wlan1)
Signal: -72 dBm Quality: 38/70 TSF: 23484334090837 usec (271d, 19:25:34)
Encryption: WPA2 802.1X (TKIP, CCMP) freq: 2472
beacon interval: 100 TUs
Cell 32 - Address: 70:0B:01:C0:B3:E0 capability: ESS (0x0411)
ESSID: "Livebox-B3E0" signal: -44.00 dBm
Mode: Master Channel: 11 last seen: 40 ms ago
Signal: -80 dBm Quality: 30/70 Information elements from Probe Response frame:
Encryption: WPA2 PSK (CCMP) SSID: Cadoles Formations (N)
HT capabilities:
Cell 33 - Address: D2:CE:7D:20:5C:A7 Capabilities: 0x11ec
ESSID: "SFR WiFi Mobile" HT20
Mode: Master Channel: 6 SM Power Save disabled
Signal: -85 dBm Quality: 25/70 RX HT20 SGI
Encryption: WPA2 802.1X (CCMP) RX HT40 SGI
TX STBC
Cell 34 - Address: 68:A3:78:0D:B6:51 RX STBC 1-stream
ESSID: "Freebox-0DB650" Max AMSDU length: 3839 bytes
Mode: Master Channel: 1 DSSS/CCK HT40
Signal: -92 dBm Quality: 18/70 Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Encryption: WPA2 PSK (CCMP) Minimum RX AMPDU time spacing: 4 usec (0x05)
HT RX MCS rate indexes supported: 0-15, 32
Cell 35 - Address: F8:AB:05:1D:6A:E0 HT TX MCS rate indexes are undefined
ESSID: "Bbox-8CE43C68" HT operation:
Mode: Master Channel: 6 * primary channel: 13
Signal: -88 dBm Quality: 22/70 * secondary channel offset: no secondary
Encryption: mixed WPA/WPA2 PSK (CCMP) * STA channel width: 20 MHz
RSN: * Version: 1
Cell 36 - Address: F4:CA:E5:98:3B:DD * Group cipher: CCMP
ESSID: "FreeWifi" * Pairwise ciphers: CCMP
Mode: Master Channel: 11 * Authentication suites: PSK
Signal: -87 dBm Quality: 23/70 * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
Encryption: none BSS bc:f6:85:fe:6d:46(on wlan1)
TSF: 5185428505884 usec (60d, 00:23:48)
Cell 37 - Address: 14:0C:76:79:C0:D9 freq: 2467
ESSID: "freebox_ZFSFUA" beacon interval: 100 TUs
Mode: Master Channel: 4 capability: ESS (0x0c11)
Signal: -88 dBm Quality: 22/70 signal: -76.00 dBm
Encryption: WPA PSK (TKIP, CCMP) last seen: 30 ms ago
Information elements from Probe Response frame:
Cell 38 - Address: 68:15:90:36:63:60 SSID: Dlink
ESSID: "Livebox-6360" HT capabilities:
Mode: Master Channel: 1 Capabilities: 0x11ee
Signal: -81 dBm Quality: 29/70 HT20/HT40
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) SM Power Save disabled
RX HT20 SGI
Cell 39 - Address: 64:7C:34:29:2B:7C RX HT40 SGI
ESSID: "Bbox-D646CB51" TX STBC
Mode: Master Channel: 1 RX STBC 1-stream
Signal: -90 dBm Quality: 20/70 Max AMSDU length: 3839 bytes
Encryption: mixed WPA/WPA2 PSK (CCMP) DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Cell 40 - Address: 68:A3:78:6E:D9:24 Minimum RX AMPDU time spacing: 2 usec (0x04)
ESSID: "FreeWifi" HT RX MCS rate indexes supported: 0-15, 32
Mode: Master Channel: 3 HT TX MCS rate indexes are undefined
Signal: -90 dBm Quality: 20/70 HT operation:
Encryption: none * primary channel: 12
* secondary channel offset: no secondary
Cell 41 - Address: B0:39:56:92:59:E2 * STA channel width: 20 MHz
ESSID: "NETGEAR17" Secondary Channel Offset: no secondary (0)
Mode: Master Channel: 4 RSN: * Version: 1
Signal: -88 dBm Quality: 22/70 * Group cipher: CCMP
Encryption: WPA2 PSK (CCMP) * Pairwise ciphers: CCMP
* Authentication suites: PSK
Cell 42 - Address: 0C:F4:D5:16:AA:18 * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
ESSID: "DIJON-METROPOLE-WIFI" BSS 90:4d:4a:f7:b9:71(on wlan1)
Mode: Master Channel: 13 TSF: 4721041865203 usec (54d, 15:24:01)
Signal: -90 dBm Quality: 20/70 freq: 2462
Encryption: none beacon interval: 100 TUs
capability: ESS (0x0001)
Cell 43 - Address: D2:CE:7D:20:5C:A5 signal: -82.00 dBm
ESSID: "SFR WiFi FON" last seen: 300 ms ago
Mode: Master Channel: 6 Information elements from Probe Response frame:
Signal: -81 dBm Quality: 29/70 SSID: orange
Encryption: none HT capabilities:
Capabilities: 0x1ad
Cell 44 - Address: 34:27:92:42:CD:72 RX LDPC
ESSID: "Freebox-42CD71" HT20
Mode: Master Channel: 8 SM Power Save disabled
Signal: -88 dBm Quality: 22/70 RX HT20 SGI
Encryption: WPA2 PSK (CCMP) TX STBC
RX STBC 1-stream
Cell 45 - Address: 72:5D:51:78:4C:87 Max AMSDU length: 3839 bytes
ESSID: "SFR WiFi FON" No DSSS/CCK HT40
Mode: Master Channel: 11 Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Signal: -87 dBm Quality: 23/70 Minimum RX AMPDU time spacing: 4 usec (0x05)
Encryption: none HT Max RX data rate: 384 Mbps
HT RX MCS rate indexes supported: 0-23
Cell 46 - Address: 68:A3:78:6E:D9:23 HT TX MCS rate indexes are undefined
ESSID: "Freebox-6ED922" HT operation:
Mode: Master Channel: 3 * primary channel: 11
Signal: -76 dBm Quality: 34/70 * secondary channel offset: no secondary
Encryption: WPA2 PSK (CCMP) * STA channel width: 20 MHz
BSS e4:9e:12:8b:ef:73(on wlan1)
Cell 47 - Address: 00:19:70:4F:DE:F2 TSF: 7952485362135 usec (92d, 01:01:25)
ESSID: "Livebox-45cc" freq: 2452
Mode: Master Channel: 6 beacon interval: 96 TUs
Signal: -78 dBm Quality: 32/70 capability: ESS (0x0411)
Encryption: mixed WPA/WPA2 PSK (TKIP, CCMP) signal: -80.00 dBm
last seen: 430 ms ago
Cell 48 - Address: AC:84:C9:CC:AE:90 Information elements from Probe Response frame:
ESSID: "Livebox-AE90" SSID: Freebox-8BEF72
Mode: Master Channel: 11 RSN: * Version: 1
Signal: -81 dBm Quality: 29/70 * Group cipher: CCMP
Encryption: WPA2 PSK (CCMP) * Pairwise ciphers: CCMP
* Authentication suites: PSK
Cell 49 - Address: 00:07:7D:89:81:B0 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
ESSID: "orange" HT capabilities:
Mode: Master Channel: 6 Capabilities: 0xec
Signal: -85 dBm Quality: 25/70 HT20
Encryption: none SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 9
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 90:4d:4a:f7:b9:70(on wlan1)
TSF: 4721041856992 usec (54d, 15:24:01)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0011)
signal: -78.00 dBm
last seen: 310 ms ago
Information elements from Probe Response frame:
SSID: Livebox-B970
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT Max RX data rate: 384 Mbps
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 3c:52:82:fc:5e:21(on wlan1)
TSF: 6735883434375 usec (77d, 23:04:43)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0511)
signal: -79.00 dBm
last seen: 970 ms ago
Information elements from Probe Response frame:
SSID: DIRECT-20-HP DeskJet 3630 series
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x20
HT20
Static SM Power Save
RX HT20 SGI
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 32767 bytes (exponent: 0x002)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-7
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 00:a6:ca:10:df:02(on wlan1)
TSF: 1018894510847 usec (11d, 19:01:34)
freq: 2437
beacon interval: 102 TUs
capability: ESS (0x1421)
signal: -73.00 dBm
last seen: 1040 ms ago
Information elements from Probe Response frame:
SSID: Keo-HotSpot
HT capabilities:
Capabilities: 0x19ac
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS a2:17:33:9f:4d:81(on wlan1)
TSF: 3050426691569 usec (35d, 07:20:26)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0401)
signal: -82.00 dBm
last seen: 310 ms ago
Information elements from Probe Response frame:
SSID: SFR WiFi FON
BSS ac:84:c9:1d:c6:7c(on wlan1)
TSF: 2491424200041 usec (28d, 20:03:44)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -80.00 dBm
last seen: 1480 ms ago
Information elements from Probe Response frame:
SSID: Frate Djon
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 78:81:02:5e:b7:15(on wlan1)
TSF: 4786879928619 usec (55d, 09:41:19)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0401)
signal: -83.00 dBm
last seen: 950 ms ago
Information elements from Probe Response frame:
SSID: orange
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT Max RX data rate: 384 Mbps
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 00:a6:ca:10:df:00(on wlan1)
TSF: 1018905280864 usec (11d, 19:01:45)
freq: 2437
beacon interval: 102 TUs
capability: ESS (0x1431)
signal: -76.00 dBm
last seen: 1170 ms ago
Information elements from Probe Response frame:
SSID: \x00
HT capabilities:
Capabilities: 0x19ac
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: IEEE 802.1X
* Capabilities: 4-PTKSA-RC 4-GTKSA-RC (0x0028)
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS a0:1b:29:be:98:26(on wlan1)
TSF: 2931892990829 usec (33d, 22:24:52)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -64.00 dBm
last seen: 970 ms ago
Information elements from Probe Response frame:
SSID: Livebox-9822
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-15
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 40:4a:03:05:d2:68(on wlan1)
TSF: 57377785 usec (0d, 00:00:57)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -76.00 dBm
last seen: 240 ms ago
Information elements from Probe Response frame:
SSID: ZyXEL
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
HT capabilities:
Capabilities: 0x104e
HT20/HT40
SM Power Save disabled
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 11
* secondary channel offset: below
* STA channel width: any
BSS f4:ca:e5:98:3b:de(on wlan1)
TSF: 502449932512 usec (5d, 19:34:09)
freq: 2462
beacon interval: 96 TUs
capability: ESS (0x0411)
signal: -86.00 dBm
last seen: 11400 ms ago
Information elements from Probe Response frame:
SSID: FreeWifi_secure
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: IEEE 802.1X
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x6c
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 00:17:33:9f:4d:80(on wlan1)
TSF: 3050426716298 usec (35d, 07:20:26)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -79.00 dBm
last seen: 290 ms ago
Information elements from Probe Response frame:
SSID: NEUF_4D7C
BSS a2:17:33:9f:4d:83(on wlan1)
TSF: 3050426718113 usec (35d, 07:20:26)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -80.00 dBm
last seen: 290 ms ago
Information elements from Probe Response frame:
SSID: SFR WiFi Mobile
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: IEEE 802.1X
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
BSS 30:7c:b2:d1:0b:0d(on wlan1)
TSF: 1059959180138 usec (12d, 06:25:59)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -80.00 dBm
last seen: 11200 ms ago
Information elements from Probe Response frame:
SSID: Livebox-0b09
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-15
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 68:a3:78:0d:b6:51(on wlan1)
TSF: 136373797215 usec (1d, 13:52:53)
freq: 2462
beacon interval: 96 TUs
capability: ESS (0x0411)
signal: -88.00 dBm
last seen: 11230 ms ago
Information elements from Probe Response frame:
SSID: Freebox-0DB650
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0xec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 68:15:90:36:63:60(on wlan1)
TSF: 308936601984 usec (3d, 13:48:56)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -88.00 dBm
last seen: 12650 ms ago
Information elements from Probe Response frame:
SSID: Livebox-6360
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
BSS 0c:8d:db:c4:a0:34(on wlan1)
TSF: 372485216298 usec (4d, 07:28:05)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x1431)
signal: -56.00 dBm
last seen: 1540 ms ago
Information elements from Probe Response frame:
SSID: pfPauvres
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
HT capabilities:
Capabilities: 0x9ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 7935 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-15
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
VHT capabilities:
VHT Capabilities (0x338959b2):
Max MPDU length: 11454
Supported Channel Width: neither 160 nor 80+80
RX LDPC
short GI (80 MHz)
TX STBC
SU Beamformer
SU Beamformee
MU Beamformer
RX antenna pattern consistency
TX antenna pattern consistency
VHT RX MCS set:
1 streams: MCS 0-9
2 streams: MCS 0-9
3 streams: not supported
4 streams: not supported
5 streams: not supported
6 streams: not supported
7 streams: not supported
8 streams: not supported
VHT RX highest supported: 0 Mbps
VHT TX MCS set:
1 streams: MCS 0-9
2 streams: MCS 0-9
3 streams: not supported
4 streams: not supported
5 streams: not supported
6 streams: not supported
7 streams: not supported
8 streams: not supported
VHT TX highest supported: 0 Mbps
VHT operation:
* channel width: 0 (20 or 40 MHz)
* center freq segment 1: 0
* center freq segment 2: 0
* VHT basic MCS set: 0xfffc
BSS ac:3b:77:6a:24:e0(on wlan1)
TSF: 741652789170 usec (8d, 14:00:52)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -87.00 dBm
last seen: 1700 ms ago
Information elements from Probe Response frame:
SSID: Grosorboul
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x18fc
HT20
SM Power Save disabled
RX Greenfield
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 68:a3:78:6e:d9:24(on wlan1)
TSF: 85494694239 usec (0d, 23:44:54)
freq: 2422
beacon interval: 96 TUs
capability: ESS (0x0401)
signal: -87.00 dBm
last seen: 1340 ms ago
Information elements from Probe Response frame:
SSID: FreeWifi
HT capabilities:
Capabilities: 0xec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 3
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 14:0c:76:79:c0:d9(on wlan1)
TSF: 572290498911 usec (6d, 14:58:10)
freq: 2427
beacon interval: 96 TUs
capability: ESS (0x0411)
signal: -86.00 dBm
last seen: 1300 ms ago
Information elements from Probe Response frame:
SSID: freebox_ZFSFUA
HT capabilities:
Capabilities: 0x6c
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 4
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 78:81:02:5e:b7:14(on wlan1)
TSF: 4786879917067 usec (55d, 09:41:19)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -84.00 dBm
last seen: 960 ms ago
SSID: Livebox-B714
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT Max RX data rate: 384 Mbps
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS d6:38:9c:67:00:7a(on wlan1)
TSF: 52271652256 usec (0d, 14:31:11)
freq: 2442
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -75.00 dBm
last seen: 680 ms ago
Information elements from Probe Response frame:
SSID: \xc5\xa4\xc3\xa3h\xc3\xae\xc5\x99
HT capabilities:
Capabilities: 0x130
HT20
Static SM Power Save
RX Greenfield
RX HT20 SGI
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-7
HT operation:
* primary channel: 7
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
BSS 00:19:70:4f:de:f2(on wlan1)
TSF: 223832269184 usec (2d, 14:10:32)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -86.00 dBm
last seen: 11260 ms ago
Information elements from Probe Response frame:
SSID: Livebox-45cc
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
HT capabilities:
Capabilities: 0x100c
HT20
SM Power Save disabled
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 6c:38:a1:62:1b:28(on wlan1)
TSF: 2704292761929 usec (31d, 07:11:32)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0c11)
signal: -86.00 dBm
last seen: 1660 ms ago
Information elements from Probe Response frame:
SSID: Bbox-1B7889A9
HT capabilities:
Capabilities: 0x1ec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT RX MCS rate indexes supported: 0-23
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 1
* secondary channel offset: above
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 68:a3:78:6e:d9:25(on wlan1)
TSF: 85494497631 usec (0d, 23:44:54)
freq: 2422
beacon interval: 96 TUs
capability: ESS (0x0411)
signal: -85.00 dBm
last seen: 1500 ms ago
Information elements from Probe Response frame:
SSID: FreeWifi_secure
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: IEEE 802.1X
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0xec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 3
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 56:62:21:de:de:70(on wlan1)
TSF: 5762545254750 usec (66d, 16:42:25)
freq: 2422
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -88.00 dBm
last seen: 1430 ms ago
Information elements from Probe Response frame:
SSID: FREEBOX_JOSIANNE_46
HT capabilities:
Capabilities: 0x106e
HT20/HT40
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT RX MCS rate indexes supported: 0-15, 32
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 3
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 56:62:21:de:de:71(on wlan1)
TSF: 5762545257087 usec (66d, 16:42:25)
freq: 2422
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -86.00 dBm
last seen: 1430 ms ago
Information elements from Probe Response frame:
SSID:
HT capabilities:
Capabilities: 0x106e
HT20/HT40
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT RX MCS rate indexes supported: 0-15, 32
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 3
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 68:a3:78:6e:d9:23(on wlan1)
TSF: 85494792543 usec (0d, 23:44:54)
freq: 2422
beacon interval: 96 TUs
capability: ESS (0x0411)
signal: -86.00 dBm
last seen: 1270 ms ago
Information elements from Probe Response frame:
SSID: Freebox-6ED922
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0xec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT TX/RX MCS rate indexes supported: 0-23, 32
HT operation:
* primary channel: 3
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 44:ce:7d:20:5c:a4(on wlan1)
TSF: 2322036531897 usec (26d, 21:00:36)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -82.00 dBm
last seen: 1030 ms ago
Information elements from Probe Response frame:
SSID: SFR_5CA0
HT capabilities:
Capabilities: 0x18ec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS d2:ce:7d:20:5c:a7(on wlan1)
TSF: 2322036535330 usec (26d, 21:00:36)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -87.00 dBm
last seen: 1030 ms ago
Information elements from Probe Response frame:
SSID: SFR WiFi Mobile
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: IEEE 802.1X
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x18ec
HT20
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 00:22:6b:86:5b:71(on wlan1)
TSF: 13910494312595 usec (161d, 00:01:34)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -88.00 dBm
last seen: 350 ms ago
Information elements from Probe Response frame:
SSID: linksys
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)

View File

@ -12,26 +12,28 @@ type Action struct {
// UCI "Object" // UCI "Object"
type UCI struct { type UCI struct {
exec Executor exec Executor
Wireless *UCIWirelessConf
} }
// NewUCI return an UCI instance to interact with UCI // NewUCI return an UCI instance to interact with UCI
func NewUCI() *UCI { func NewUCI() *UCI {
exec := &localExecutor{} exec := &localExecutor{}
return &UCI{exec} wireless := &UCIWirelessConf{}
return &UCI{exec, wireless}
} }
// NewUCIWithExecutor returns a UCI Instance an gives you the ability to provide // NewUCIWithExecutor returns a UCI Instance an gives you the ability to provide
// a different command executor than the default one. // a different command executor than the default one.
func NewUCIWithExecutor(exec Executor) *UCI { func NewUCIWithExecutor(exec Executor) *UCI {
return &UCI{exec} wireless := &UCIWirelessConf{}
return &UCI{exec, wireless}
} }
// uciRun, private method to run the UCI command // uciRun, private method to run the UCI command
func (u *UCI) uciRun(uciAction string, param string) *Action { func (u *UCI) uciRun(param ...string) *Action {
cmd := "uci" cmd := "/sbin/uci"
res := u.exec.Run(cmd, param...)
res := u.exec.Run(cmd, uciAction, param)
return &Action{res} return &Action{res}
} }
@ -53,7 +55,8 @@ func (u *UCI) Set(entry string, value string) *Action {
// Commit the recent actions to UCI // Commit the recent actions to UCI
func (u *UCI) Commit() *Action { func (u *UCI) Commit() *Action {
return u.uciRun("commit", "") res := u.uciRun("commit")
return res
} }
// Reload reload uci configuration // Reload reload uci configuration
@ -65,8 +68,39 @@ func (u *UCI) Reload() *Action {
return &Action{cmdResult} return &Action{cmdResult}
} }
// Show returns the output of uci show command
func (u *UCI) Show(target string) *Action {
cmdRes := u.uciRun("show", target)
return cmdRes
}
// AddWireless Create a new Wireless entry in UCI configuration // AddWireless Create a new Wireless entry in UCI configuration
func (u *UCI) AddWireless(name string) *Action { func (u *UCI) AddWireless() *Action {
res := u.Add("wireless", name) res := u.uciRun("add", "wireless", "wifi-iface")
return res return res
} }
// LoadWirelessConf scan UCI configuration and loads saved Wireless configuration
func (u *UCI) LoadWirelessConf() {
u.Wireless = NewUCIWirelessConf(u)
u.Wireless.Load()
}
// GetWifiIface returns the system name of the Interface
func (u *UCI) GetWifiIface(idx int) *UCIWirelessInterface {
ifaces := u.Wireless.Interfaces
if len(ifaces) < idx {
return nil
}
return ifaces[idx]
}
// GetWifiIfaces wifi interfaces in configuration
func (u *UCI) GetWifiIfaces() []*UCIWirelessInterface {
return u.Wireless.Interfaces
}
// GetWifiDevices returns the wifi devices in configuration
func (u *UCI) GetWifiDevices() []map[string]string {
return u.Wireless.Devices
}

View File

@ -0,0 +1,177 @@
package openwrt
import (
"fmt"
"regexp"
"strconv"
"strings"
)
// UCIWirelessConf is the representation of UCI Wireless Configuration
type UCIWirelessConf struct {
uciClient *UCI
Devices []map[string]string
DefaultInterface map[string]string
Interfaces []*UCIWirelessInterface
}
// NewUCIWirelessConf builds a new UCIWirelessConf instance
func NewUCIWirelessConf(uci *UCI) *UCIWirelessConf {
return &UCIWirelessConf{
uciClient: uci,
Devices: []map[string]string{}, //, 10),
DefaultInterface: map[string]string{},
Interfaces: []*UCIWirelessInterface{}, //, 10),
}
}
// parse wireless.default_radio[0-9] section of UCI Configuration
func (wc *UCIWirelessConf) parseDefaultInterface(lines []string) int {
matches := map[string]string{
"Name": "default_radio0=",
"Type": "default_radio0.type=",
"Channel": "default_radio0.channel=",
"Hwmode": "default_radio0.hwmode=",
"Htmode": "default_radio0.htmode=",
"Country": "default_radio0.country=",
"Path": "default_radio0.path=",
}
for _, line := range lines {
for key, value := range matches {
if strings.Contains(line, value) {
wc.DefaultInterface[key] = strings.Split(line, "=")[1]
}
}
}
return 0
}
func (wc *UCIWirelessConf) parseInterfaces(lines []string) int {
matches := map[string]*regexp.Regexp{
"Name": regexp.MustCompile(`@wifi-iface\[[0-9]\]=`),
"Device": regexp.MustCompile(`@wifi-iface\[[0-9]\].device=`),
"Mode": regexp.MustCompile(`@wifi-iface\[[0-9]\].mode=`),
"Ssid": regexp.MustCompile(`@wifi-iface\[[0-9]\].ssid=`),
"Encryption": regexp.MustCompile(`@wifi-iface\[[0-9]\].encryption=`),
"Key": regexp.MustCompile(`@wifi-iface\[[0-9]\].key=`),
}
for _, li := range lines {
var idx int
sIdx := strings.Split(li, "[")[1]
sIdx = strings.Split(sIdx, "]")[0]
if s, err := strconv.ParseInt(sIdx, 10, 32); err == nil {
idx = int(s)
}
if idx >= len(wc.Interfaces) {
for i := 0; i <= idx; i++ {
wc.Interfaces = append(wc.Interfaces, NewUCIWirelessInterface())
}
}
if wc.Interfaces[idx] == nil {
wc.Interfaces[idx] = NewUCIWirelessInterface()
wc.Interfaces[idx].Index = idx
}
for key, expr := range matches {
if expr.MatchString(li) {
value := strings.Split(li, "=")[1]
if key == "Name" {
wc.Interfaces[idx].Name = value
}
if key == "Device" {
wc.Interfaces[idx].Device = value
}
if key == "Mode" {
wc.Interfaces[idx].Mode = value
}
if key == "Ssid" {
wc.Interfaces[idx].Ssid = value
}
if key == "Encryption" {
wc.Interfaces[idx].Encryption = value
}
if key == "Key" {
wc.Interfaces[idx].Key = value
}
}
}
}
return 0
}
func (wc *UCIWirelessConf) parseDevicesConf(lines []string) int {
matches := map[string]string{
"Name": "radio[0-9]=",
"Type": "radio[0-9].type=",
"Channel": "radio[0-9].channel=",
"Hwmode": "radio[0-9].hwmode=",
"Htmode": "radio[0-9].htmode=",
"Country": "radio[0-9].country=",
"Path": "radio[0-9].path=",
}
for _, line := range lines {
var idx int
re := regexp.MustCompile("[0-9]")
rIdx := re.FindString(line)
if s, err := strconv.ParseInt(rIdx, 10, 32); err == nil {
idx = int(s)
}
if len(wc.Devices) == 0 {
wc.Devices = append(wc.Devices, make(map[string]string))
}
if idx >= len(wc.Devices) {
for i := 0; i < idx; i++ {
wc.Devices = append(wc.Devices, make(map[string]string))
}
}
if wc.Devices[idx] == nil {
wc.Devices[idx] = make(map[string]string)
}
for key, expr := range matches {
re := regexp.MustCompile(expr)
if re.MatchString(line) {
value := strings.Split(line, "=")[1]
value = strings.Trim(value, "'")
if key == "Name" {
wc.Devices[idx]["Device"] = fmt.Sprintf("radio%d", idx)
}
wc.Devices[idx][key] = value
}
}
}
return 0
}
func grep(lines string, pattern string) []string {
var res []string
for _, line := range strings.Split(strings.TrimSuffix(lines, "\n"), "\n") {
re := regexp.MustCompile(pattern)
if re.MatchString(line) {
res = append(res, line)
}
}
return res
}
// Load return the Wireless Configuration
func (wc *UCIWirelessConf) Load() *UCIWirelessConf {
conf := wc.uciClient.Show("wireless")
fmt.Println(conf.Stdout)
wc.parseDevicesConf(grep(conf.Stdout, "wireless.radio"))
wc.parseDefaultInterface(grep(conf.Stdout, "wireless.default_radio0"))
fmt.Println(grep(conf.Stdout, "wireless.@wifi-iface"))
wc.parseInterfaces(grep(conf.Stdout, "wireless.@wifi-iface"))
return wc
}

View File

@ -0,0 +1,30 @@
package openwrt
import (
"io/ioutil"
"testing"
)
func TestUCIGetWirelessConf(t *testing.T) {
config, err := ioutil.ReadFile("./testdata/uci_show_wireless.txt")
if err != nil {
t.Fatal(err)
}
exec := createMockExecutor(string(config), "", 0)
uci := NewUCIWithExecutor(exec)
uci.LoadWirelessConf()
if g, e := uci.Wireless.DefaultInterface["Name"], "wifi-iface"; g != e {
t.Fatalf("DefaultDevice.Name is expected to be [%s] and we have [%s]", e, g)
}
config, err = ioutil.ReadFile("./testdata/uci_show_wireless_2_cards.txt")
if err != nil {
t.Fatal(err)
}
exec = createMockExecutor(string(config), "", 0)
uci = NewUCIWithExecutor(exec)
uci.LoadWirelessConf()
if g, e := uci.Wireless.Interfaces[1].Name, "wifi-iface"; g != e {
t.Fatalf("DefaultDevice.Name is expected to be [%s] and we have [%s]", e, g)
}
}

View File

@ -0,0 +1,185 @@
package openwrt
import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
)
// UCIWirelessInterface is the description of an Wireless interface (cf Openwrt doc) on top of an Wireless Device
type UCIWirelessInterface struct {
Name string
Index int
Device string
DevicePath string
SysDevName string
Mode string
Disabled bool
Ssid string
Bssid string
Network string
Encryption string
Key string
}
// NewUCIWirelessInterface builds a new UCIWirelessInterface instance
func NewUCIWirelessInterface() *UCIWirelessInterface {
return &UCIWirelessInterface{}
}
// GetSysDevName looks for the system name of Wireless Interface
func (wi *UCIWirelessInterface) GetSysDevName(sysDir string) string {
var found string
if wi.SysDevName != "" {
return wi.SysDevName
}
if sysDir == "" {
sysDir = "/sys/devices/platform"
}
if _, err := os.Stat(sysDir); os.IsNotExist(err) {
return "ERROR123-FILE-DONES-NOT-EXIST"
}
filepath.Walk(sysDir, func(path string, f os.FileInfo, _ error) error {
patt := fmt.Sprintf("%s/%s/.*/address", wi.DevicePath, "net")
fmt.Println(wi.DevicePath)
fmt.Println(patt)
r, err := regexp.MatchString(patt, path)
if err == nil && r {
fmt.Println(path)
res := strings.Split(path, "/")
idx := len(res) - 2
found = res[idx]
}
return nil
})
fmt.Println(found)
wi.SysDevName = found
return found
}
// Create add a new entry for wifi interface in UCI Configuration
func (wi *UCIWirelessInterface) Create(uci *UCI) *Action {
addRes := uci.AddWireless()
if addRes.ReturnCode != 0 {
return addRes
}
confPrefix := fmt.Sprintf("wireless.@wifi-iface[%d]", wi.Index)
conf := make(map[string][]string)
conf["network"] = append(conf["network"], fmt.Sprintf("%s.network", confPrefix), wi.Network)
conf["ssid"] = append(conf["ssid"], fmt.Sprintf("%s.ssid", confPrefix), wi.Ssid)
conf["enc"] = append(conf["enc"], fmt.Sprintf("%s.encryption", confPrefix), wi.Encryption)
conf["device"] = append(conf["device"], fmt.Sprintf("%s.device", confPrefix), wi.Device)
conf["mode"] = append(conf["mode"], fmt.Sprintf("%s.mode", confPrefix), wi.Mode)
conf["bssid"] = append(conf["bssid"], fmt.Sprintf("%s.bssid", confPrefix), wi.Bssid)
conf["key"] = append(conf["key"], fmt.Sprintf("%s.key", confPrefix), wi.Key)
for _, value := range conf {
if value[1] != "" {
result := uci.Set(value[0], value[1])
if result.ReturnCode != 0 {
return result
}
}
}
return &Action{
CommandResult: &CommandResult{
Stdout: "",
Stderr: "",
ReturnCode: 0,
},
}
}
// Save commit and relaod configuration (writes it to files !)
func (wi *UCIWirelessInterface) Save(uci *UCI) *Action {
commitRes := uci.Commit()
if commitRes.ReturnCode != 0 {
return commitRes
}
reload := uci.Reload()
return reload
}
// SysAdd creates the interface in the system using iw command
func (wi *UCIWirelessInterface) SysAdd(uci *UCI) *Action {
cmd := "iw"
opt := "phy"
phydev := fmt.Sprintf("phy%d", wi.Index)
what := "interface"
act := "add"
tpe := "managed"
if wi.SysDevName == "" {
wi.SysDevName = fmt.Sprintf("tmp.radio%d", wi.Index)
}
res := uci.exec.Run(cmd, opt, phydev, what, act, wi.SysDevName, "type", tpe)
return &Action{
CommandResult: res,
}
}
// Up brings the interface up in the system using ip command
func (wi *UCIWirelessInterface) Up(uci *UCI) *Action {
cmd := "ip"
opt := "link"
act := "set"
wht := "dev"
res := uci.exec.Run(cmd, opt, act, wht, wi.SysDevName, "up")
return &Action{
CommandResult: res,
}
}
// Delete remove wifi interface from UCI Configuration
func (wi *UCIWirelessInterface) Delete(uci *UCI) *Action {
toDelete := fmt.Sprintf("wireless.@wifi-iface[%d]", wi.Index)
del := uci.Delete(toDelete)
if del.ReturnCode != 0 {
return del
}
return uci.Commit()
}
// Update add a new entry for wifi interface in UCI Configuration
func (wi *UCIWirelessInterface) Update(uci *UCI) *Action {
wi.Delete(uci)
create := wi.Create(uci)
if create.ReturnCode != 0 {
return create
}
return uci.Commit()
}
// Scan starts a scan for wifi networks with this device
func (wi *UCIWirelessInterface) Scan() []*WifiCell {
var devName string
devName = wi.GetSysDevName("")
wifi := NewWifiScanner(devName)
return wifi.Scan()
}
// Connect updates configuration to connect to the WifiCell
func (wi *UCIWirelessInterface) Connect(uci *UCI, cell *WifiCell, secret string) *Action {
wi.Ssid = cell.Ssid
wi.Bssid = cell.MacAddress
wi.Encryption = cell.Encryption
wi.Mode = "sta"
wi.Key = secret
res := wi.Update(uci)
if res.ReturnCode != 0 {
return res
}
return wi.Save(uci)
}

View File

@ -0,0 +1,115 @@
package openwrt
import (
"testing"
)
func TestGetSysDevName(t *testing.T) {
iface := NewUCIWirelessInterface()
iface.Name = "Test"
iface.Index = 1
iface.Device = "radioX"
iface.DevicePath = "soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0"
iface.SysDevName = "wlanX"
iface.Mode = "ap"
iface.Ssid = "PyxisWifi"
iface.Bssid = "00:00:00:00:00"
iface.Network = "Pyxis"
iface.Encryption = "psk"
iface.Key = "qsmdflkjqslmdfkjqslmfkdj"
if iface.GetSysDevName("testdata/sys/") != "wlan1" {
t.Fatalf("UCIWirelessInterface.GetDeviceSysName() failed !")
}
}
func TestCreate(t *testing.T) {
exec := createMockExecutor("", "", 0)
uci := NewUCIWithExecutor(exec)
iface := NewUCIWirelessInterface()
iface.Name = "Test"
iface.Device = "radioX"
iface.Mode = "ap"
iface.Ssid = "PyxisWifi"
iface.Bssid = "00:00:00:00:00"
iface.Network = "Pyxis"
iface.Encryption = "psk"
iface.Key = "qsmdflkjqslmdfkjqslmfkdj"
if iface.Create(uci).ReturnCode != 0 {
t.Fatalf("UCIWirelessInterface.Create() failed !")
}
}
func TestUpdate(t *testing.T) {
exec := createMockExecutor("", "", 0)
uci := NewUCIWithExecutor(exec)
iface := NewUCIWirelessInterface()
iface.Name = "Test"
iface.Index = 1
iface.Device = "radioX"
iface.SysDevName = "wlanX"
iface.Mode = "ap"
iface.Ssid = "PyxisWifi"
iface.Bssid = "00:00:00:00:00"
iface.Network = "Pyxis"
iface.Encryption = "psk"
iface.Key = "qsmdflkjqslmdfkjqslmfkdj"
if iface.Create(uci).ReturnCode != 0 {
t.Fatalf("UCIWirelessInterface.Create() failed !")
}
iface.Name = "Tutu"
if iface.Update(uci).ReturnCode != 0 {
t.Fatalf("UCIWirelessInterface.Update() failed !")
}
}
func TestDelete(t *testing.T) {
exec := createMockExecutor("", "", 0)
uci := NewUCIWithExecutor(exec)
iface := NewUCIWirelessInterface()
iface.Name = "Test"
iface.Index = 1
iface.Device = "radioX"
iface.SysDevName = "wlanX"
iface.Mode = "ap"
iface.Ssid = "PyxisWifi"
iface.Bssid = "00:00:00:00:00"
iface.Network = "Pyxis"
iface.Encryption = "psk"
iface.Key = "qsmdflkjqslmdfkjqslmfkdj"
if iface.Delete(uci).ReturnCode != 0 {
t.Fatalf("UCIWirelessInterface.Delete() failed !")
}
}
func TestConnect(t *testing.T) {
exec := createMockExecutor("", "", 0)
uci := NewUCIWithExecutor(exec)
iface := NewUCIWirelessInterface()
iface.Name = "Test"
iface.Index = 1
iface.Device = "radioX"
iface.SysDevName = "wlanX"
iface.Mode = "ap"
iface.Ssid = "PyxisWifi"
iface.Bssid = "00:00:00:00:00"
iface.Network = "Pyxis"
iface.Encryption = "psk"
iface.Key = "qsmdflkjqslmdfkjqslmfkdj"
wifiCell := NewWifiCell("PyxisWifi", "01:01:01:01:01", "psk")
if iface.Connect(uci, wifiCell, "Toto").ReturnCode != 0 {
t.Fatalf("UCIWirelessInterface.Delete() failed !")
}
}

View File

@ -1,91 +0,0 @@
package openwrt
import (
"log"
"strings"
"time"
)
// Wifi gives access to al OpenWRT Wifi operations
type Wifi struct {
exec Executor
iface string
Cells []*WifiCell
}
// NewWifi return an UCI instance to interact with UCI
func NewWifi(wIface string) *Wifi {
exec := &localExecutor{}
iface := wIface
return &Wifi{exec, iface, nil}
}
// NewWifiWithExecutor returns a Wifi Instance an gives you the ability to provide
// a different command executor than the default one.
func NewWifiWithExecutor(exec Executor, wIface string) *Wifi {
return &Wifi{exec, wIface, nil}
}
func (w *Wifi) getEncryption(line string) string {
enc := "unkn"
if strings.Contains(line, "WPA2 PSK") {
enc = "psk"
} else if strings.Contains(line, "none") {
enc = "none"
}
return enc
}
func (w *Wifi) parseWifiCells(stdout string) int {
new := false
mac, ssid, enc := "", "", ""
for _, line := range strings.Split(strings.TrimSuffix(stdout, "\n"), "\n") {
if strings.HasPrefix(line, "Cell") && new == false {
new = true
mac = strings.Split(line, " ")[4]
}
if strings.Contains(line, "ESSID:") {
ssid = strings.Split(line, " ")[1]
ssid = strings.Trim(ssid, "\"")
}
if strings.Contains(line, "Encryption:") {
enc = w.getEncryption(line)
}
if len(mac) > 0 && len(ssid) > 0 && len(enc) > 0 {
cell := NewWifiCell(ssid, mac, enc)
w.Cells = append(w.Cells, cell)
ssid, mac, enc = "", "", ""
new = false
}
}
return 0
}
// GetWifiCells retrieves all available wifi cells for a card !
func (w *Wifi) GetWifiCells() int {
res := w.exec.Run("iwinfo", w.iface, "scan")
if res.ReturnCode != 0 {
log.Fatal(res.Stderr)
return res.ReturnCode
}
for res.Stdout == "Scanning not possible" {
time.Sleep(time.Second)
res = w.exec.Run("iwinfo", w.iface, "scan")
if res.ReturnCode != 0 {
log.Fatal(res.Stderr)
return res.ReturnCode
}
}
return w.parseWifiCells(res.Stdout)
}
// GetCell retreives an WifiCell by SSID provided in parameter
func (w *Wifi) GetCell(ssid string) *WifiCell {
for _, v := range w.Cells {
if v.Ssid == ssid {
return v
}
}
return nil
}

View File

@ -1,11 +1,9 @@
package openwrt package openwrt
import "time"
// WifiCell reprensents wifi network Cell // WifiCell reprensents wifi network Cell
type WifiCell struct { type WifiCell struct {
Ssid string Ssid string
MacAdress string MacAddress string
Encryption string Encryption string
} }
@ -13,81 +11,7 @@ type WifiCell struct {
func NewWifiCell(ssid string, mac string, encrypt string) *WifiCell { func NewWifiCell(ssid string, mac string, encrypt string) *WifiCell {
return &WifiCell{ return &WifiCell{
Ssid: ssid, Ssid: ssid,
MacAdress: mac, MacAddress: mac,
Encryption: encrypt, Encryption: encrypt,
} }
} }
func (cell *WifiCell) uciWifiConfigure(uci *UCI, secret string) *Action {
setRes := uci.Set("wireless.@wifi-iface[1].network", "PyxisNetwork")
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].ssid", cell.Ssid)
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].encryption", cell.Encryption)
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].device", "radio1")
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].mode", "sta")
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].bssid", cell.MacAdress)
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Set("wireless.@wifi-iface[1].key", secret)
if setRes.ReturnCode != 0 {
return setRes
}
return &Action{
&CommandResult{
Stdout: "",
Stderr: "",
ReturnCode: 0,
},
}
}
// Connect to wifi Cell
func (cell *WifiCell) Connect(uci *UCI, secret string) *Action {
delRes := uci.Delete("wireless.@wifi-iface[1]")
if delRes.ReturnCode != 0 {
return delRes
}
addRes := uci.AddWireless("wifi-iface")
if addRes.ReturnCode != 0 {
return addRes
}
setRes := cell.uciWifiConfigure(uci, secret)
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Commit()
if setRes.ReturnCode != 0 {
return setRes
}
setRes = uci.Reload()
if setRes.ReturnCode != 0 {
return setRes
}
time.Sleep(20 * time.Second)
return &Action{
&CommandResult{
Stdout: "",
Stderr: "",
ReturnCode: 0,
},
}
}

View File

@ -1,21 +0,0 @@
package openwrt
import "testing"
func TestWifiCellConnection(t *testing.T) {
uexec := createMockExecutor("", "", 0)
uci := NewUCIWithExecutor(uexec)
cellList := `Cell 40 - Address: 68:A3:78:6E:D9:24
ESSID: "PyxisWifi"
Mode: Master Channel: 3
Signal: -90 dBm Quality: 20/70
Encryption: WPA2 PSK (CCMP)`
exec := createMockExecutor(cellList, "", 0)
wifi := NewWifiWithExecutor(exec, "wlan1")
_ = wifi.GetWifiCells()
cell := wifi.GetCell("PyxisWifi")
cell.Connect(uci, "secret")
}

126
openwrt/wifi_scanner.go Normal file
View File

@ -0,0 +1,126 @@
package openwrt
import (
"regexp"
"strings"
"time"
)
// NONE contains the string for "none"
const NONE = "none"
// WifiScanner gives access to al OpenWRT Wifi Scan operations
type WifiScanner struct {
exec Executor
iface string
Cells []*WifiCell
}
// NewWifiScanner return an UCI instance to interact with UCI
func NewWifiScanner(wIface string) *WifiScanner {
exec := &localExecutor{}
iface := wIface
Cells := []*WifiCell{}
return &WifiScanner{exec, iface, Cells}
}
// NewWifiWithExecutor returns a Wifi Instance an gives you the ability to provide
// a different command executor than the default one.
func NewWifiWithExecutor(exec Executor, wIface string) *WifiScanner {
return &WifiScanner{exec, wIface, nil}
}
func (w *WifiScanner) getEncryption(line string) string {
var enc string
if strings.Contains(line, "PSK") {
enc = "psk"
} else if strings.Contains(line, NONE) {
enc = NONE
} else {
enc = "unkn"
}
return enc
}
func (w *WifiScanner) parseWifiCells(stdout string) int {
mac, ssid, enc := "", "", ""
encOff := false
macExpr := `([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])`
for _, line := range strings.Split(strings.TrimSuffix(stdout, "\n"), "\n") {
expr := regexp.MustCompile("^BSS")
if expr.MatchString(line) {
if len(mac) != 0 && len(ssid) != 0 && len(enc) == 0 {
enc = NONE
cell := NewWifiCell(ssid, mac, enc)
w.Cells = append(w.Cells, cell)
ssid, mac, enc = "", "", ""
}
macRegexp := regexp.MustCompile(macExpr)
mac = macRegexp.FindString(line)
}
if strings.Contains(line, "SSID:") {
ssid = strings.Split(line, ":")[1]
ssid = strings.Trim(ssid, "\"")
ssid = strings.Trim(ssid, " ")
if ssid == "" {
ssid = " "
}
}
if strings.Contains(line, "Encryption key:off") {
encOff = true
}
if strings.Contains(line, "Authentication suites") {
enc = w.getEncryption(line)
}
if len(mac) > 0 && len(ssid) > 0 && (len(enc) > 0 || encOff) {
if encOff {
enc = NONE
encOff = false
}
cell := NewWifiCell(ssid, mac, enc)
w.Cells = append(w.Cells, cell)
ssid, mac, enc = "", "", ""
}
}
return 0
}
// GetWifiCells retrieves all available wifi cells for a card !
func (w *WifiScanner) GetWifiCells() int {
var res *CommandResult
for try := 0; try != 20; try++ {
res = w.exec.Run("iw", w.iface, "scan")
if res.ReturnCode == 0 {
parsing := w.parseWifiCells(res.Stdout)
if parsing == 0 {
if len(w.Cells) == 0 {
return 242
}
}
return parsing
}
time.Sleep(time.Second * 2)
}
return res.ReturnCode
}
// GetCell retreives an WifiCell by SSID provided in parameter
func (w *WifiScanner) GetCell(ssid string) *WifiCell {
for _, v := range w.Cells {
if v.Ssid == ssid {
return v
}
}
return nil
}
// Scan retreives a list of available wifi cells
func (w *WifiScanner) Scan() []*WifiCell {
_ = w.GetWifiCells()
return w.Cells
}

View File

@ -25,19 +25,19 @@ func TestGetWifiCells(t *testing.T) {
t.Errorf("The first Cell have a bad SSID !\n %s is expected and we have %s", e, g) t.Errorf("The first Cell have a bad SSID !\n %s is expected and we have %s", e, g)
} }
if g, e := wifi.Cells[0].MacAdress, "68:A3:78:6E:D9:24"; g != e { if g, e := wifi.Cells[0].MacAddress, "74:3e:2b:08:41:1c"; g != e {
t.Errorf("The first Cell have a bad MAC !\n %s is expected and we have %s", e, g) t.Errorf("The first Cell have a bad MAC !\n [%s] is expected and we have [%s]", e, g)
} }
if g, e := wifi.Cells[0].Encryption, "none"; g != e { if g, e := wifi.Cells[1].Encryption, "none"; g != e {
t.Errorf("The first Cell have a bad Encryption!\n %s is expected and we have %s", e, g) t.Errorf("The first Cell have a bad Encryption!\n %s is expected and we have %s", e, g)
} }
if g, e := wifi.Cells[1].Encryption, "psk"; g != e { if g, e := wifi.Cells[2].Encryption, "psk"; g != e {
t.Errorf("The second Cell have a bad Encryption!\n %s is expected and we have %s", e, g) t.Errorf("The last Cell have a bad Encryption!\n %s is expected and we have %s", e, g)
} }
if g, e := wifi.Cells[2].MacAdress, "0C:F4:D5:16:AA:18"; g != e { if g, e := wifi.Cells[2].MacAddress, "20:47:da:b7:0e:5c"; g != e {
t.Errorf("The last Cell have a bad MAC !\n %s is expected and we have %s", e, g) t.Errorf("The last Cell have a bad MAC !\n %s is expected and we have %s", e, g)
} }
} }
@ -64,8 +64,8 @@ func TestGetWifiCellsLarge(t *testing.T) {
exec := createMockExecutor(string(cellList), "", 0) exec := createMockExecutor(string(cellList), "", 0)
wifi := NewWifiWithExecutor(exec, "wlan1") wifi := NewWifiWithExecutor(exec, "wlan1")
_ = wifi.GetWifiCells() _ = wifi.GetWifiCells()
if len(wifi.Cells) != 49 { if len(wifi.Cells) != 40 {
fmt.Printf("Size of wifi.Cells is %d and not 49 !!!\n", len(wifi.Cells)) fmt.Printf("Size of wifi.Cells is %d and not 40 !!!\n", len(wifi.Cells))
t.Error("Cell list is empty ... This can not append !! Fix your code Dummy !") t.Error("Cell list is empty ... This can not append !! Fix your code Dummy !")
} }
} }

57
use.go Normal file
View File

@ -0,0 +1,57 @@
package main
import (
"forge.cadoles.com/Pyxis/orion/openwrt"
)
func main() {
uci := openwrt.NewUCI()
uci.LoadWirelessConf()
wifaces := uci.GetWifiIfaces()
wDevices := uci.GetWifiDevices()
PyxisDevice := wDevices[0]
ClientDevice := wDevices[1]
for _, iface := range wifaces {
iface.Delete(uci)
}
// Main Pyxis Interface
pyxis := openwrt.NewUCIWirelessInterface()
pyxis.Name = "Pyxis-Network"
pyxis.Network = "pyxis"
pyxis.Index = 0
pyxis.Ssid = "Pyxis"
pyxis.SysDevName = "wlan0"
pyxis.Encryption = "psk2"
pyxis.Key = "xxxxxxxxx"
pyxis.Device = PyxisDevice["Device"]
pyxis.DevicePath = PyxisDevice["Path"]
pyxis.Mode = "ap"
_ = pyxis.Create(uci)
_ = pyxis.Save(uci)
// Client Interface
client := openwrt.NewUCIWirelessInterface()
client.Name = "Client-Network"
client.Index = 1
client.SysDevName = "wlan1"
client.Device = ClientDevice["Device"]
client.DevicePath = ClientDevice["Path"]
client.Mode = "sta"
_ = client.Create(uci)
_ = client.SysAdd(uci)
_ = client.Up(uci)
scan := client.Scan()
for _, elm := range scan {
if elm.Ssid == "Cadoles" {
client.Connect(uci, elm, "xxxxxx")
}
}
dhcp := openwrt.NewDhcpClient(client.SysDevName)
dhcp.AskForIP()
return
}