当前位置: 首页 > 工具软件 > reason > 使用案例 >

p2p断开的两种情况:WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY(4)和WLAN_REASON_DEAUTH_LEAVING(3)

邓欣可
2023-12-01

events.c

wpas_event_disconnect

流程1: (复现是将p2p client远离GO,知道p2p断开)

reason_code 为WLAN_REASON_DEAUTH_LEAVING,就算设置自动回连,也无法进入自动回连流程

if (deauth && reason_code > 0) {
	if (wpas_p2p_deauth_notif(wpa_s, addr, reason_code, ie, ie_len,
				  locally_generated) > 0) {
		/*
		 * The interface was removed, so cannot continue
		 * processing any additional operations after this.
		 */
		return;
	}
}

wpas_p2p_deauth_notif
    if (reason_code == WLAN_REASON_DEAUTH_LEAVING 
		wpa_printf(MSG_DEBUG, "P2P: GO indicated that the P2P Group "
			   "session is ending");
        wpas_p2p_group_delete
            	if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT {
		            wpa_s->reassociate = 0;
		            wpa_s->disconnected = 1;

此时disconnect设为了1,所以此时,就算设置了sta_autoconnect,这个也无法进入自动连接流程
            
   

对应的wpa_supplicant日志:

Jan 1 00:02:26 Avatar daemon.notice wpa_supplicant[502]: p2p0: CTRL-EVENT-DISCONNECTED bssid=6a:1d:9d:9e:09:35 reason=3 Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: P2P: GO indicated that the P2P Group session is ending Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: p2p0: Request to deauthenticate - bssid=6a:1d:9d:9e:09:35 pending_bssid=00:00:00:00:00:00 reason=3 state=COMPLETED Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: wpa_driver_nl80211_disconnect(reason_code=3) Jan 1 00:02:26 Avatar daemon.notice wpa_supplicant[502]: p2p0: CTRL-EVENT-DISCONNECTED bssid=6a:1d:9d:9e:09:35 reason=3 locally_generated=1 Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: CTRL-DEBUG: ctrl_sock-sendmsg: sock=13 sndbuf=163840 outq=0 send_len=76 Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: CTRL_IFACE monitor sent successfully to /tmp/wpa_ctrl_513-2\x00 Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: p2p0: Auto connect disabled: do not try to re-connect Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: p2p0: Ignore connection failure indication since interface has been put into disconnected state Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: p2p0: WPA: Clear old PMK and PTK Jan 1 00:02:26 Avatar daemon.debug wpa_supplicant[502]: p2p0: Disconnect event - remove keys

流程2:此时reason_code为inactivity

上面如果是reason_code为WLAN_REASON_DEAUTH_LEAVING,导致disconnect为1,所以无法进入自动重连
但是如果是inactivity时就可以进入
wpa_supplicant_event_disassoc_finish
    	if (!wpa_s->disconnected &&
	    (!wpa_s->auto_reconnect_disabled ||
	     wpa_s->key_mgmt == WPA_KEY_MGMT_WPS ||
	     wpas_wps_searching(wpa_s) ||
	     wpas_wps_reenable_networks_pending(wpa_s))) {
		wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
			"reconnect (wps=%d/%d wpa_state=%d)",
			wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
			wpas_wps_searching(wpa_s),
			wpa_s->wpa_state);

/* WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY reason code in
* locally generated disconnection events for cases where the
* AP does not reply anymore. 
*/

对应的日志:

Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: nl80211: Event message available Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: nl80211: Ignored event (cmd=48) for foreign interface (ifindex 4 wdev 0x0) Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: nl80211: Drv Event 48 (NL80211_CMD_DISCONNECT) received for p2p0 Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: nl80211: Disconnect event Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: p2p0: Event DEAUTH (12) received Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: p2p0: Deauthentication notification Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: p2p0: * reason 4 Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: Deauthentication frame IE(s) - hexdump(len=0): [NULL] Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.862851] 8213.860972 : Event: 0x8 Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.862892] wlan: EVENT: Deauthenticated (reason 0x4) Oct 28 12:22:30 Avatar daemon.notice wpa_supplicant[503]: p2p0: CTRL-EVENT-DISCONNECTED bssid=62:1d:9d:c8:44:88 reason=4 Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.862909] wlan: REASON: Disassociated due to inactivity Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: CTRL-DEBUG: ctrl_sock-sendmsg: sock=13 sndbuf=163840 outq=0 send_len=56 Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: CTRL_IFACE monitor sent successfully to /tmp/wpa_ctrl_514-2\x00 Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.862930] Update rxwinsize 0 Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.863000] p2p0: Oct 28 12:22:30 Avatar daemon.debug wpa_supplicant[503]: p2p0: Auto connect enabled: try to reconnect (wps=0/0 wpa_state=9) Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.863004] QUEUE_CMD: cmd=0x16 is queued Oct 28 12:22:30 Avatar user.warn kernel: [ 8213.863029] event id:0x4

 类似资料: