| 1248 | | /* |
| 1249 | | * This is a big ugly hack, just look away. |
| 1250 | | */ |
| 1251 | | |
| 1252 | | sprintf(cmd, "ifconfig %s down 2>/dev/null", ifname); |
| 1253 | | if( WEXITSTATUS(system(cmd)) ) |
| 1254 | | goto out; |
| 1255 | | |
| 1256 | | sprintf(cmd, "iw phy %s interface add scan.%s " |
| 1257 | | "type station 2>/dev/null", res, ifname); |
| 1258 | | if( WEXITSTATUS(system(cmd)) ) |
| 1259 | | goto out; |
| 1260 | | |
| 1261 | | sprintf(cmd, "ifconfig scan.%s up 2>/dev/null", ifname); |
| 1262 | | if( WEXITSTATUS(system(cmd)) ) |
| 1263 | | goto out; |
| 1264 | | |
| 1265 | | sprintf(cmd, "scan.%s", ifname); |
| 1266 | | wext_get_scanlist(cmd, buf, len); |
| 1267 | | |
| 1268 | | out: |
| 1269 | | sprintf(cmd, "ifconfig scan.%s down 2>/dev/null", ifname); |
| 1270 | | (void) WEXITSTATUS(system(cmd)); |
| 1271 | | |
| 1272 | | sprintf(cmd, "iw dev scan.%s del 2>/dev/null", ifname); |
| 1273 | | (void) WEXITSTATUS(system(cmd)); |
| 1274 | | |
| 1275 | | sprintf(cmd, "ifconfig %s up 2>/dev/null", ifname); |
| 1276 | | (void) WEXITSTATUS(system(cmd)); |
| 1277 | | |
| 1278 | | sprintf(cmd, "killall -HUP hostapd 2>/dev/null"); |
| 1279 | | (void) WEXITSTATUS(system(cmd)); |
| 1280 | | |
| 1281 | | return 0; |
| | 1248 | /* Got a temp interface, don't create yet another one */ |
| | 1249 | if( !strncmp(ifname, "tmp.", 4) ) |
| | 1250 | { |
| | 1251 | sprintf(cmd, "ifconfig %s up 2>/dev/null", ifname); |
| | 1252 | if( WEXITSTATUS(system(cmd)) ) |
| | 1253 | return -1; |
| | 1254 | |
| | 1255 | wext_get_scanlist(ifname, buf, len); |
| | 1256 | |
| | 1257 | sprintf(cmd, "ifconfig %s down 2>/dev/null", ifname); |
| | 1258 | (void) WEXITSTATUS(system(cmd)); |
| | 1259 | |
| | 1260 | return 0; |
| | 1261 | } |
| | 1262 | |
| | 1263 | /* Spawn a new scan interface */ |
| | 1264 | else |
| | 1265 | { |
| | 1266 | sprintf(cmd, "ifconfig %s down 2>/dev/null", ifname); |
| | 1267 | if( WEXITSTATUS(system(cmd)) ) |
| | 1268 | goto out; |
| | 1269 | |
| | 1270 | sprintf(cmd, "iw phy %s interface add scan.%s " |
| | 1271 | "type station 2>/dev/null", res, ifname); |
| | 1272 | if( WEXITSTATUS(system(cmd)) ) |
| | 1273 | goto out; |
| | 1274 | |
| | 1275 | sprintf(cmd, "ifconfig scan.%s up 2>/dev/null", ifname); |
| | 1276 | if( WEXITSTATUS(system(cmd)) ) |
| | 1277 | goto out; |
| | 1278 | |
| | 1279 | sprintf(cmd, "scan.%s", ifname); |
| | 1280 | wext_get_scanlist(cmd, buf, len); |
| | 1281 | |
| | 1282 | out: |
| | 1283 | sprintf(cmd, "ifconfig scan.%s down 2>/dev/null", ifname); |
| | 1284 | (void) WEXITSTATUS(system(cmd)); |
| | 1285 | |
| | 1286 | sprintf(cmd, "iw dev scan.%s del 2>/dev/null", ifname); |
| | 1287 | (void) WEXITSTATUS(system(cmd)); |
| | 1288 | |
| | 1289 | sprintf(cmd, "ifconfig %s up 2>/dev/null", ifname); |
| | 1290 | (void) WEXITSTATUS(system(cmd)); |
| | 1291 | |
| | 1292 | sprintf(cmd, "killall -HUP hostapd 2>/dev/null"); |
| | 1293 | (void) WEXITSTATUS(system(cmd)); |
| | 1294 | |
| | 1295 | return 0; |
| | 1296 | } |