Package: guessnet Version: 0.38-1 Severity: wishlist
Hi, enclosed you will find a test I called "test-wpacli" that I think is useful for those who are using wpa_supplicant to connect to an access point. It is based on test-wireless but does not need to bring an interface up. Instead it uses wpa_cli (included in the wpasupplicant package) to check for the ssid and bssid of the AP wpa_supplicant has connected to. wpa_cli -i$IFACE status has output like this: Selected interface 'wlan' bssid=00:01:02:03:04:05 ssid=your-network-name pairwise_cipher=TKIP group_cipher=TKIP key_mgmt=WPA-PSK wpa_state=COMPLETED This is used in the test to check for the actual SSID/BSSID. I've included 1. "test-wpacli" which can be used just as test-wireless (using bssid instead of mac and ssid instead of essid; BSSID has to be lowercase) 2. "test-command-wpacli" which is essentially the same but is designed to be used with a 'test-command' directive, i.e. expects $IFACE to be set. I think this should go into examples/ 3. Patches for IfaceParser.cc and GuessnetParser.cc in order to make test-wpacli work 4. A patch for the man page as well The patches have been generated against the current Debian package 0.38-1. Thanks and kind regards, Felix
--- guessnet.8-original 2006-05-03 21:08:29.000000000 +0200 +++ guessnet.8 2006-05-03 21:08:46.000000000 +0200 @@ -348,7 +348,42 @@ the wireless network adapter to keep it associated to an access point. .sp Note that the \fBwireless\fP test is not yet implemented cleanly. - +.SS wpacli +.TP +.B Test description file syntax: +\fIprofile\fP \fBwpacli\fP [\fBbssid\fP \fIBSSID\fP] [\fBssid\fP \fISSID\fP] +.TP +.B Ifupdown mode syntax: +\fBtest wpacli\fP [\fBbssid\fP \fIBSSID\fP] [\fBssid\fP \fISSID\fP] +.TP +.B Description: +When +.BR wpa_supplicant (8) +is used to associate with an access point (AP), this +tests the BSSID and/or the SSID of the associated AP. +If both are given then \fIBSSID\fP must precede \fISSID\fP. +.sp +Blanks may be included in the SSID. +For example, +.nf + prof1 wpacli ssid My LAN +.fi +tests for an SSID of "My LAN". +.sp +Since the test is using +.BR wpa_cli (8) +the \fIBSSID\fP +has to be given in lower case letters. +.sp +Note that the \fBwpacli\fP test does not attempt +to change these properties; it only examines them. +This test is designed to work with and depends on +.BR wpa_supplicant (8) +which independently and dynamically manages +the wireless network adapter +to keep it associated to an access point. +.sp +Note that the \fBwpacli\fP test is not tested thoroughly. .P Note that if one of several tests terminates successfully then any other tests still running will be terminated with the KILL signal. @@ -375,7 +410,9 @@ Currently \fBguessnet\fP only supports s .BR sh (1), .BR pppoe (8), .BR ifplugd (8), -.BR waproamd (8). +.BR waproamd (8), +.BR wpa_supplicant (8), +.BR wpa_cli (8). .SH AUTHOR \fBGuessnet\fP was written by Enrico Zini <[EMAIL PROTECTED]> with contributions from Thomas Hood.
--- GuessnetParser.cc-original 2006-05-03 21:06:43.000000000 +0200 +++ GuessnetParser.cc 2006-05-03 21:06:28.000000000 +0200 @@ -82,6 +82,18 @@ void GuessnetParser::parse(FILE* input, "^[[:blank:]]*" "([^[:blank:]]+)[[:blank:]]+" "wireless[[:blank:]]+essid[[:blank:]](.+)$", 3); + ExtendedRegexp wpacli_bssid_ssid_line( + "^[[:blank:]]*" + "([^[:blank:]]+)[[:blank:]]+" + "wpacli[[:blank:]]+bssid[[:blank:]]+([^[:blank:]]+)[[:blank:]]+ssid[[:blank:]](.+)$", 4); + ExtendedRegexp wpacli_bssid_line( + "^[[:blank:]]*" + "([^[:blank:]]+)[[:blank:]]+" + "wpacli[[:blank:]]+bssid[[:blank:]]+([^[:blank:]]+)[[:blank:]]*$", 3); + ExtendedRegexp wpacli_ssid_line( + "^[[:blank:]]*" + "([^[:blank:]]+)[[:blank:]]+" + "wpacli[[:blank:]]+ssid[[:blank:]](.+)$", 3); ExtendedRegexp old_input_line( "^[[:blank:]]*(" IPPATTERN ")[[:blank:]]+" "(" MACPATTERN ")" @@ -200,6 +212,24 @@ void GuessnetParser::parse(FILE* input, sc.handleScan(new ScriptScan(name, string(SCRIPTDIR "/test-wireless ") + Environment::get().iface() + " essid \"" + wireless_essid_line[2] + "\"" )); found++; } + else if (wireless_mac_essid_line.match(line)) + { + string name = wpacli_bssid_ssid_line[1]; + sc.handleScan(new ScriptScan(name, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " bssid " + wpacli_bssid_ssid_line[2] + " ssid \"" + wpacli_bssid_ssid_line[3] + "\"" )); + found++; + } + else if (wpacli_bssid_line.match(line)) + { + string name = wpacli_bssid_line[1]; + sc.handleScan(new ScriptScan(name, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " bssid " + wpacli_bssid_line[2] )); + found++; + } + else if (wpacli_ssid_line.match(line)) + { + string name = wpacli_ssid_line[1]; + sc.handleScan(new ScriptScan(name, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " ssid \"" + wpacli_ssid_line[2] + "\"" )); + found++; + } else { warning("Parse error at line %d: line ignored\n", linenum);
--- IfaceParser.cc-original 2006-05-03 21:05:38.000000000 +0200 +++ IfaceParser.cc 2006-05-03 21:05:47.000000000 +0200 @@ -94,6 +94,12 @@ void IfaceParser::parse(FILE* input, Sca ATLINESTART "wireless[[:blank:]]+mac[[:blank:]]+([^[:blank:]]+)[[:blank:]]*$", 4); ExtendedRegexp wireless_essid_line( ATLINESTART "wireless[[:blank:]]+essid[[:blank:]](.+)$", 4); + ExtendedRegexp wpacli_bssid_ssid_line( + ATLINESTART "wpacli[[:blank:]]+bssid[[:blank:]]+([^[:blank:]]+)[[:blank:]]+ssid[[:blank:]](.+)$", 5); + ExtendedRegexp wpacli_bssid_line( + ATLINESTART "wpacli[[:blank:]]+bssid[[:blank:]]+([^[:blank:]]+)[[:blank:]]*$", 4); + ExtendedRegexp wpacli_ssid_line( + ATLINESTART "wpacli[[:blank:]]+ssid[[:blank:]](.+)$", 4); ExtendedRegexp old_default_line( "^[[:blank:]]*guessnet[[:blank:]]+" "default[[:blank:]]*$"); @@ -259,6 +265,30 @@ void IfaceParser::parse(FILE* input, Sca found++; } } + else if (wpacli_bssid_ssid_line.match(line)) + { + if (profileName.size()) + { + sc.handleScan(new ScriptScan(profileName, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " bssid " + wpacli_bssid_ssid_line[3] + " ssid \"" + wpacli_bssid_ssid_line[4] + "\"" )); + found++; + } + } + else if (wpacli_bssid_line.match(line)) + { + if (profileName.size()) + { + sc.handleScan(new ScriptScan(profileName, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " bssid " + wpacli_bssid_line[3] )); + found++; + } + } + else if (wpacli_ssid_line.match(line)) + { + if (profileName.size()) + { + sc.handleScan(new ScriptScan(profileName, string(SCRIPTDIR "/test-wpacli ") + Environment::get().iface() + " ssid \"" + wpacli_ssid_line[3] + "\"" )); + found++; + } + } else if (old_default_line.match(line)) { warning("line %d: Use of \"guessnet default\" lines is obsolete and will be discontinued in the future. Use \"map default: profile\" in the \"mapping\" section instead.\n", linenum);
test-wpacli
Description: application/shellscript
test-command-wpacli
Description: application/shellscript