scan: parse Proxy ARP bit from extended capabilities
James Prestwood
PATCH 1/5 scan: parse Proxy ARP bit from extended capabilities
--- src/scan.c | 17 +++++++++++++++++ src/scan.h | 1 + 2 files changed, 18 insertions(+)
src/scan.c +17 -0
@@ -1252,6 +1252,23 @@ static bool scan_parse_bss_information_elements(struct scan_bss *bss, bss->rc_ie =l_memdup (iter.data -2 , iter.len +2 );break ; + +case IE_TYPE_EXTENDED_CAPABILITIES : +/* 802.11-2020 9.4.2.26 +* +* "The length of the Extended Capabilities field is +* variable. If fewer bits are received in an Extended +* Capabilities field than shown in Table 9-153, the +* rest of the Extended Capabilities field bits are +* assumed to be zero" +* +* Currently only Proxy ARP bit (12) is checked, and if +* not found, this is not a fatal error. +*/ +if (iter.len <2 ) +break ; + + bss->proxy_arp =test_bit (iter.data,12 ); } }
src/scan.h +1 -0
@@ -86,6 +86,7 @@ struct scan_bss { bool anqp_capable : 1; bool hs20_capable : 1; bool force_default_sae_group : 1; + bool proxy_arp : 1; uint8_t cost_level : 3; uint8_t cost_flags : 4; };
Signature · 1 line
2.31.1
James Prestwood
PATCH 2/5 ie: parse DGAF Disable bit from HS20 indication element
--- src/ie.c | 11 ++++++++--- src/ie.h | 5 +++-- src/scan.c | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-)
src/ie.c +8 -3
@@ -2035,7 +2035,8 @@ int ie_build_roaming_consortium(const uint8_t *rc, size_t rc_len, uint8_t *to) }int ie_parse_hs20_indication (struct ie_tlv_iter *iter,uint8_t *version_out, -uint16_t *pps_mo_id_out,uint8_t *domain_id_out) +uint16_t *pps_mo_id_out,uint8_t *domain_id_out, +bool *dgaf_disable_out) {unsigned int len =ie_tlv_iter_get_length (iter);const uint8_t *data =ie_tlv_iter_get_data (iter);
@@ -2060,6 +2061,9 @@ int ie_parse_hs20_indication(struct ie_tlv_iter *iter, uint8_t *version_out,if (pps_mo_present && domain_id_present)return -EPROTOTYPE ; +if (dgaf_disable_out) + *dgaf_disable_out =test_bit (&hs20_config,0 ); +if (version_out) *version_out =bit_field (hs20_config,4 ,4 );
@@ -2087,7 +2091,7 @@ int ie_parse_hs20_indication(struct ie_tlv_iter *iter, uint8_t *version_out,int ie_parse_hs20_indication_from_data (const uint8_t *data,size_t len,uint8_t *version,uint16_t *pps_mo_id, -uint8_t *domain_id) +uint8_t *domain_id,bool *dgaf_disable) {struct ie_tlv_iter iter;
@@ -2099,7 +2103,8 @@ int ie_parse_hs20_indication_from_data(const uint8_t *data, size_t len,if (ie_tlv_iter_get_tag (&iter) !=IE_TYPE_VENDOR_SPECIFIC )return -EPROTOTYPE ; -return ie_parse_hs20_indication (&iter, version, pps_mo_id, domain_id); +return ie_parse_hs20_indication (&iter, version, pps_mo_id, domain_id, + dgaf_disable); }/*
src/ie.h +3 -2
@@ -616,10 +616,11 @@ int ie_parse_roaming_consortium_from_data(const uint8_t *data, size_t len,int ie_build_roaming_consortium (const uint8_t *rc,size_t rc_len,uint8_t *to);int ie_parse_hs20_indication (struct ie_tlv_iter *iter,uint8_t *version, -uint16_t *pps_mo_id,uint8_t *domain_id); +uint16_t *pps_mo_id,uint8_t *domain_id, +bool *dgaf_disable);int ie_parse_hs20_indication_from_data (const uint8_t *data,size_t len,uint8_t *version,uint16_t *pps_mo_id, -uint8_t *domain_id); +uint8_t *domain_id,bool *dgaf_disable);int ie_build_hs20_indication (uint8_t version,uint8_t *to);enum ie_rsnx_capability {
src/scan.c +2 -1
@@ -1071,7 +1071,8 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data,if (is_ie_wfa_ie (data, len,IE_WFA_OI_HS20_INDICATION )) {if (ie_parse_hs20_indication_from_data (data -2 , len +2 , - &bss->hs20_version,NULL ,NULL ) <0 ) + &bss->hs20_version,NULL ,NULL , +NULL ) <0 )return ; bss->hs20_capable = true;
Signature · 1 line
2.31.1
James Prestwood
PATCH 3/5 scan: keep track of HS20 DGAF Disable bit in scan_bss
In reply to James Prestwood--- src/scan.c | 4 +++- src/scan.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
src/scan.c +3 -1
@@ -1058,6 +1058,7 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data, {uint16_t cost_level;uint16_t cost_flags; +bool dgaf_disable;if (!bss->wpa &&is_ie_wpa_ie (data, len)) { bss->wpa =l_memdup (data -2 , len +2 );
@@ -1072,9 +1073,10 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data,if (is_ie_wfa_ie (data, len,IE_WFA_OI_HS20_INDICATION )) {if (ie_parse_hs20_indication_from_data (data -2 , len +2 , &bss->hs20_version,NULL ,NULL , -NULL ) <0 ) + &dgaf_disable) <0 )return ; + bss->hs20_dgaf_disable = dgaf_disable; bss->hs20_capable = true;return ; }
src/scan.h +1 -0
@@ -87,6 +87,7 @@ struct scan_bss { bool hs20_capable : 1; bool force_default_sae_group : 1; bool proxy_arp : 1; + bool hs20_dgaf_disable : 1; uint8_t cost_level : 3; uint8_t cost_flags : 4; };
Signature · 1 line
2.31.1
James Prestwood
PATCH 4/5 station: set sysfs options required by HS2.0 spec
In reply to James PrestwoodThe Hotspot 2.0 spec has some requirements that IWD was missing depending on a few bits in extended capabilities and the HS2.0 indication element. These requirements correspond to a few sysfs options that can be set in the kernel which are now set on CONNECTED and unset on DISCONNECTED.
--- src/station.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-)
src/station.c +51 -1
@@ -1400,6 +1400,31 @@ static void station_set_evict_nocarrier(struct station *station, bool value) "ndisc_evict_nocarrier", v); } +/* +* Handles dropping ARP (IPv4) and neighbor advertisements (IPv6) settings. +*/ +static void station_set_drop_neighbor_discovery (struct station *station, +bool value) +{ +char *v = value ?"1" :"0" ; + +sysfs_write_ipv4_setting (netdev_get_name (station->netdev), +"drop_gratuitous_arp" , v); +sysfs_write_ipv6_setting (netdev_get_name (station->netdev), +"drop_unsolicited_na" , v); +} + +static void station_set_drop_unicast_l2_multicast (struct station *station, +bool value) +{ +char *v = value ?"1" :"0" ; + +sysfs_write_ipv4_setting (netdev_get_name (station->netdev), +"drop_unicast_in_l2_multicast" , v); +sysfs_write_ipv6_setting (netdev_get_name (station->netdev), +"drop_unicast_in_l2_multicast" , v); +} +static void station_enter_state (struct station *station,enum station_state state) {
@@ -1452,11 +1477,36 @@ static void station_enter_state(struct station *station,netdev_get_path (station->netdev),IWD_STATION_DIAGNOSTIC_INTERFACE , station); -/* Fall through */ +periodic_scan_stop (station); + +station_set_evict_nocarrier (station, true); + +/* +* Hotspot Specification 2.0 - Section 6.5 +* +* " - Shall drop all received {gratuitous ARP, unsolicited +* Neighbor Advertisement} messages when the Proxy ARP field +* is set to 1 in the Extended Capabilities element of the +* serving AP. +* +* - When the serving AP transmits frames containing an HS2.0 +* Indication element in which the value of the DGAF Disable +* bit subfield is set to 0, the mobile device should +* discard all received unicast IP packets that were +* decrypted using the GTK" +*/ +if (station->connected_bss->proxy_arp) +station_set_drop_neighbor_discovery (station, true); +if (station->connected_bss->hs20_dgaf_disable) +station_set_drop_unicast_l2_multicast (station, true); + +break ;case STATION_STATE_DISCONNECTED :periodic_scan_stop (station);station_set_evict_nocarrier (station, true); +station_set_drop_neighbor_discovery (station, false); +station_set_drop_unicast_l2_multicast (station, false);break ;case STATION_STATE_DISCONNECTING :break ;
Signature · 1 line
2.31.1
James Prestwood
PATCH 5/5 auto-t: add a DGAF Disable hotspot test
In reply to James Prestwood--- autotests/testHotspot/hotspot_test.py | 31 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
autotests/testHotspot/hotspot_test.py +25 -6
@@ -14,11 +14,7 @@ import testutil class Test(unittest.TestCase): - def test_connection_success(self): - wd = self.wd - - hapd = HostapdCLI(config='ssidHotspot.conf') - + def validate_connection(self, wd, hapd, dgaf_disable=False): psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) wd.register_psk_agent(psk_agent)
@@ -38,7 +34,16 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() - testutil.test_ifaces_connected(device.name, hapd.ifname) + + if not dgaf_disable: + testutil.test_ifaces_connected(device.name, hapd.ifname) + else: + # This is expected to fail with group traffic + with self.assertRaises(Exception): + testutil.test_ifaces_connected(device.name, hapd.ifname, expect_fail=True) + + # Now try again without testing group traffic + testutil.test_ifaces_connected(device.name, hapd.ifname, group=False) device.disconnect()
@@ -47,6 +52,20 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) + def test_hotspot(self): + hapd = HostapdCLI(config='ssidHotspot.conf') + hapd.set_value('disable_dgaf', '0') + hapd.reload() + + self.validate_connection(self.wd, hapd) + + def test_dgaf_disabled(self): + hapd = HostapdCLI(config='ssidHotspot.conf') + hapd.set_value('disable_dgaf', '1') + hapd.reload() + + self.validate_connection(self.wd, hapd, dgaf_disable=True) + @classmethod def setUpClass(cls): IWD.copy_to_hotspot('example.conf')
Signature · 1 line
2.31.1
Denis Kenzior
Hi James,
Quoted 4 lines · James Prestwood
--- src/scan.c | 17 +++++++++++++++++ src/scan.h | 1 + 2 files changed, 18 insertions(+)
All applied, thanks.
Regards,
-Denis