From eece6fc684f7bcfb33ec521dc14a85deb923bddd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 1 Jun 2021 19:46:13 +0200 Subject: [PATCH] wifi: fix parsing Microsoft Network Cost IE https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/734 Fixes: 5307b1ed733f ('wifi: guess metered flag based on Network Cost information element') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/879 (cherry picked from commit 8327312c518baa4d17cb348c1a4a129c27f72332) (cherry picked from commit a4d2106ace073c69db52e4fb9ad71bd50e8bf606) --- src/nm-core-utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 3e4bb1294d..ca855ce20c 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -5070,9 +5070,12 @@ nm_wifi_utils_parse_ies(const guint8 *bytes, case WLAN_EID_VENDOR_SPECIFIC: if (len == 8 && bytes[0] == 0x00 /* OUI: Microsoft */ && bytes[1] == 0x50 && bytes[2] == 0xf2 - && bytes[3] == 0x11) /* OUI type: Network cost */ - NM_SET_OUT(out_metered, (bytes[7] > 1)); /* Cost level > 1 */ - if (elem_len >= 10 && bytes[0] == 0x50 /* OUI: WiFi Alliance */ + && bytes[3] == 0x11) /* OUI type: Network cost */ + { + /* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nct/ */ + NM_SET_OUT(out_metered, (bytes[4] > 1)); /* Cost level > 1 */ + } + if (elem_len >= 10 && bytes[0] == 0x50 /* OUI: WiFi Alliance */ && bytes[1] == 0x6f && bytes[2] == 0x9a && bytes[3] == 0x1c) /* OUI type: OWE Transition Mode */ NM_SET_OUT(out_owe_transition_mode, TRUE);