anqputil.h (3312B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2019 Intel Corporation. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 */ 22 23 #include <stdbool.h> 24 #include <stdint.h> 25 26 /* IEEE 802.11-2016 Section 9.4.5 ANQP elements */ 27 enum anqp_element { 28 /* 0-255 reserved */ 29 ANQP_QUERY_LIST = 256, 30 ANQP_CAPABILITY_LIST = 257, 31 ANQP_VENUE_NAME = 258, 32 ANQP_EMERGENCY_CALL_NUMBER = 259, 33 ANQP_NETWORK_AUTH_TYPE = 260, 34 ANQP_ROAMING_CONSORTIUM = 261, 35 ANQP_IP_ADDRESS_TYPE_AVAILABILITY = 262, 36 ANQP_NAI_REALM = 263, 37 ANQP_3GPP_CELLULAR_NETWORK = 264, 38 ANQP_AP_GEOSPATIAL_LOCATION = 265, 39 ANQP_AP_CIVIC_LOCATION = 266, 40 ANQP_AP_LOCATION_PUBLIC_ID = 267, 41 ANQP_DOMAIN_NAME = 268, 42 ANQP_EMERGENCY_ALERT_ID_URI = 269, 43 ANQP_TDLS_CAPABILITY = 270, 44 ANQP_EMERGENCY_NAI = 271, 45 ANQP_NEIGHBOR_REPORT = 272, 46 /* 273-276 reserved */ 47 ANQP_VENUE_URI = 277, 48 ANQP_ADVICE_OF_CHARGE = 278, 49 ANQP_LOCAL_CONTENT = 279, 50 ANQP_NETWORK_AUTH_TYPE_WITH_TIMESTAMP = 280, 51 /* 281-56796 reserved */ 52 ANQP_VENDOR_SPECIFIC = 56797, 53 /* 56798-65535 reserved */ 54 }; 55 56 /* WiFi Alliance Hotspot 2.0 Spec - Section 4 Hotspot 2.0 ANQP-elements */ 57 enum anqp_hs20_element { 58 ANQP_HS20_QUERY_LIST = 1, 59 ANQP_HS20_CAPABILITY_LIST = 2, 60 ANQP_HS20_OPERATOR_FRIENDLY_NAME = 3, 61 ANQP_HS20_WLAN_METRICS = 4, 62 ANQP_HS20_CONNECTION_CAPABILITY = 5, 63 ANQP_HS20_NAI_HOME_REALM_QUERY = 6, 64 ANQP_HS20_OPERATING_CLASS_INDICATION = 7, 65 ANQP_HS20_OSU_PROVIDERS_LIST = 8, 66 /* 9 reserved */ 67 ANQP_HS20_ICON_REQUST = 10, 68 ANQP_HS20_ICON_BINARY_FILE = 11, 69 ANQP_HS20_OPERATOR_ICON_METADATA = 12, 70 ANQP_HS20_OSU_PROVIDERS_NAI_LIST = 13, 71 /* 14 - 255 reserved */ 72 }; 73 74 /* IEEE 802.11-2016 Table 9-275 Authentication Parameter types */ 75 enum anqp_auth_parameter_type { 76 ANQP_AP_EXPANDED_EAP_METHOD = 1, 77 ANQP_AP_NON_INNER_AUTH_EAP = 2, 78 ANQP_AP_INNER_AUTH_EAP = 3, 79 ANQP_AP_EXPANDED_INNER_EAP_METHOD = 4, 80 ANQP_AP_CREDENTIAL = 5, 81 ANQP_AP_TUNNELED_EAP_CREDENTIAL = 6, 82 ANQP_AP_VENDOR_SPECIFIC = 221, 83 }; 84 85 struct anqp_iter { 86 unsigned int max; 87 unsigned int pos; 88 const unsigned char *anqp; 89 90 unsigned int id; 91 unsigned int len; 92 const unsigned char *data; 93 }; 94 95 void anqp_iter_init(struct anqp_iter *iter, const unsigned char *anqp, 96 unsigned int len); 97 bool anqp_iter_next(struct anqp_iter *iter, uint16_t *id, uint16_t *len, 98 const void **data); 99 bool anqp_iter_is_hs20(const struct anqp_iter *iter, uint8_t *stype, 100 unsigned int *len, const unsigned char **data); 101 bool anqp_hs20_parse_osu_provider_nai(const unsigned char *anqp, 102 unsigned int len, const char **nai_out); 103 char **anqp_parse_nai_realms(const unsigned char *anqp, unsigned int len);