如何为 wps 按钮配置 hostapd.conf?

如何为 wps 按钮配置 hostapd.conf?

我有 android6.0.1 我想在热点打开时启用 wps。

任何人都可以给出一些想法并给出我想在其他文件中进行的任何更改吗?

谁能提供wps服务器的应用程序?

谢谢,维诺斯,

答案1

有趣的巧合。我今天也在为 Debian 寻找这个。目前我正在关注:

http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/external/bsd/wpa/dist/hostapd/README-WPS 和一点 https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf

我只需要复制这些行:

wpa_psk_file=/home/<username>/etc/hostapd/hostapd.psk
ctrl_interface=/var/run/hostapd
eap_server=1
wps_state=2
ap_setup_locked=1
wps_pin_requests=/var/run/hostapd.pin-req
device_name=USB2.0 WLAN
manufacturer=ATHEROS
model_name=WAP
model_number=123
serial_number=12345
device_type=6-0050F204-1
os_version=01020300
config_methods=label display push_button keypad

进入我的hostapd.conf文件。我为自己创建了一个自定义的~/etc/hostapd.conf,但通常在 中都有一个/etc/hostapd/hostapd.conf。在你的情况下,你可能必须改变device_type。我尝试主要验证制造商等信息,...但我认为它们并不那么重要。我能够找到manufacturerserial number使用lsusb然后sudo lsusb -v -s 5:7(后面的数字-s是 所示的总线和设备号lsusb

之后我hostapd使用新的配置文件重新启动:

sudo pkill hostapd
sudo bash -c "nohup hostapd '$HOME/etc/hostapd/hostapd.conf' > '$HOME/nohupHostapd.out'" &

快速操作sudo hostapd_cli wps_pbc后就可以使用 WPS 连接打印机。

答案2

需要在以下文件中添加字符串(wps_state, eap_server),

系统/netd/server/SoftapController.cpp

int SoftapController::setSoftap(int argc, char *argv[]) {
int hidden  = 0;
int channel = AP_CHANNEL_DEFAULT;

int wps_state = 2;

if (argc < 5) {
  ALOGE("Softap set is missing arguments. Please use:");
  ALOGE("softap <wlan iface> <SSID> <hidden/broadcast> <channel> <wpa2?-psk|open> <passphrase>");
  return ResponseCode: : CommandSyntaxError;
}

if (!strcasecmp(argv[4], "hidden"))
  hidden = 1;

if (argc >= 5) {
  channel = atoi(argv[5]);
if (channel <= 0)
  channel = AP_CHANNEL_DEFAULT;
}

std::string wbuf(StringPrintf("interface=%s\n"
  "driver=nl80211\n"
  "ctrl_interface=/data/misc/wifi/hostapd\n"
  "ssid=%s\n"
  "channel=%d\n"
  "ieee80211n=1\n"
  "hw_mode=%c\n"
  "ignore_broadcast_ssid=%d, eap_server = 1, wps_state = %d\n",
  argv[2], argv[3], channel, (channel <= 14) ? 'g' : 'a', hidden,wps_state));

std::string fbuf;
if (argc > 7) {
char psk_str[2*SHA256_DIGEST_LENGTH+1];
if (!strcmp(argv[6], "wpa-psk")) {
  if (!generatePsk(argv[3], argv[7], psk_str)) {
    return ResponseCode: : OperationFailed;
  }
  fbuf = StringPrintf("%swpa=3\nwpa_pairwise=TKIP CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str);
  } else if (!strcmp(argv[6], "wpa2-psk")) {
    if (!generatePsk(argv[3], argv[7], psk_str)) {
      return ResponseCode: : OperationFailed;
    }
    fbuf = StringPrintf("%swpa=2\nrsn_pairwise=CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str);
  } else if (!strcmp(argv[6], "open")) {
    fbuf = wbuf;
  }
} else if (argc > 6) {
  if (!strcmp(argv[6], "open")) {
    fbuf = wbuf;
  }
} else {
  fbuf = wbuf;
}

if (!WriteStringToFile(fbuf, HOSTAPD_CONF_FILE, 0660, AID_SYSTEM, AID_WIFI)) {
ALOGE("Cannot write to \"%s\": %s", HOSTAPD_CONF_FILE, strerror(errno));
  return ResponseCode::OperationFailed;
} else {
  return ResponseCode::SoftapStatusResult;
}

测试,

hostapd_cli wps_pbc

相关内容