ieee802_11_parse_elems:
  819|  24.8k|{
  820|  24.8k|	os_memset(elems, 0, sizeof(*elems));
  ------------------
  |  |  529|  24.8k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  821|       |
  822|  24.8k|	return __ieee802_11_parse_elems(start, len, elems, show_errors);
  823|  24.8k|}
ieee802_11_vendor_ie_concat:
 1325|  43.0k|{
 1326|  43.0k|	struct wpabuf *buf;
 1327|  43.0k|	const struct element *elem, *found = NULL;
 1328|       |
 1329|  53.6M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  406|  43.0k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  395|  43.0k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  396|  53.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 53.6M, False: 29.5k]
  |  |  |  |  ------------------
  |  |  |  |  397|  53.7M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  398|  53.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 53.6M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|  53.6M|		(int) element_hdr_size(_elem) &&			\
  |  |  |  |  400|  53.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:7): [True: 53.6M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|  53.6M|		(int) (element_hdr_size(_elem) +			\
  |  |  |  |  402|  53.6M|		       element_datalen(_elem));				\
  |  |  |  |  403|  53.6M|	     _elem = element_next(_elem))
  |  |  ------------------
  |  |  407|  53.6M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (407:7): [True: 835k, False: 52.8M]
  |  |  ------------------
  ------------------
 1330|   835k|		if (elem->datalen >= 4 &&
  ------------------
  |  Branch (1330:7): [True: 398k, False: 436k]
  ------------------
 1331|   398k|		    WPA_GET_BE32(elem->data) == oui_type) {
  ------------------
  |  Branch (1331:7): [True: 13.5k, False: 385k]
  ------------------
 1332|  13.5k|			found = elem;
 1333|  13.5k|			break;
 1334|  13.5k|		}
 1335|   835k|	}
 1336|       |
 1337|  43.0k|	if (!found)
  ------------------
  |  Branch (1337:6): [True: 29.5k, False: 13.5k]
  ------------------
 1338|  29.5k|		return NULL; /* No specified vendor IE found */
 1339|       |
 1340|  13.5k|	buf = wpabuf_alloc(ies_len);
 1341|  13.5k|	if (buf == NULL)
  ------------------
  |  Branch (1341:6): [True: 0, False: 13.5k]
  ------------------
 1342|      0|		return NULL;
 1343|       |
 1344|       |	/*
 1345|       |	 * There may be multiple vendor IEs in the message, so need to
 1346|       |	 * concatenate their data fields.
 1347|       |	 */
 1348|  80.7M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  406|  13.5k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  395|  13.5k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  396|  80.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 80.7M, False: 13.5k]
  |  |  |  |  ------------------
  |  |  |  |  397|  80.7M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  398|  80.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 80.7M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|  80.7M|		(int) element_hdr_size(_elem) &&			\
  |  |  |  |  400|  80.7M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:7): [True: 80.7M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|  80.7M|		(int) (element_hdr_size(_elem) +			\
  |  |  |  |  402|  80.7M|		       element_datalen(_elem));				\
  |  |  |  |  403|  80.7M|	     _elem = element_next(_elem))
  |  |  ------------------
  |  |  407|  80.7M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (407:7): [True: 2.06M, False: 78.6M]
  |  |  ------------------
  ------------------
 1349|  2.06M|		if (elem->datalen >= 4 && WPA_GET_BE32(elem->data) == oui_type)
  ------------------
  |  Branch (1349:7): [True: 809k, False: 1.25M]
  |  Branch (1349:29): [True: 576k, False: 233k]
  ------------------
 1350|   576k|			wpabuf_put_data(buf, elem->data + 4, elem->datalen - 4);
 1351|  2.06M|	}
 1352|       |
 1353|  13.5k|	return buf;
 1354|  13.5k|}
ieee80211_chan_to_freq:
 2187|    562|{
 2188|    562|	int freq;
 2189|       |
 2190|    562|	if (country_match(us_op_class_cc, country)) {
  ------------------
  |  Branch (2190:6): [True: 0, False: 562]
  ------------------
 2191|      0|		freq = ieee80211_chan_to_freq_us(op_class, chan);
 2192|      0|		if (freq > 0)
  ------------------
  |  Branch (2192:7): [True: 0, False: 0]
  ------------------
 2193|      0|			return freq;
 2194|      0|	}
 2195|       |
 2196|    562|	if (country_match(eu_op_class_cc, country)) {
  ------------------
  |  Branch (2196:6): [True: 0, False: 562]
  ------------------
 2197|      0|		freq = ieee80211_chan_to_freq_eu(op_class, chan);
 2198|      0|		if (freq > 0)
  ------------------
  |  Branch (2198:7): [True: 0, False: 0]
  ------------------
 2199|      0|			return freq;
 2200|      0|	}
 2201|       |
 2202|    562|	if (country_match(jp_op_class_cc, country)) {
  ------------------
  |  Branch (2202:6): [True: 0, False: 562]
  ------------------
 2203|      0|		freq = ieee80211_chan_to_freq_jp(op_class, chan);
 2204|      0|		if (freq > 0)
  ------------------
  |  Branch (2204:7): [True: 0, False: 0]
  ------------------
 2205|      0|			return freq;
 2206|      0|	}
 2207|       |
 2208|    562|	if (country_match(cn_op_class_cc, country)) {
  ------------------
  |  Branch (2208:6): [True: 0, False: 562]
  ------------------
 2209|      0|		freq = ieee80211_chan_to_freq_cn(op_class, chan);
 2210|      0|		if (freq > 0)
  ------------------
  |  Branch (2210:7): [True: 0, False: 0]
  ------------------
 2211|      0|			return freq;
 2212|      0|	}
 2213|       |
 2214|    562|	return ieee80211_chan_to_freq_global(op_class, chan);
 2215|    562|}
ieee802_11_common.c:__ieee802_11_parse_elems:
  523|  24.8k|{
  524|  24.8k|	const struct element *elem;
  525|  24.8k|	int unknown = 0;
  526|       |
  527|  24.8k|	if (!start)
  ------------------
  |  Branch (527:6): [True: 0, False: 24.8k]
  ------------------
  528|      0|		return ParseOK;
  529|       |
  530|  51.2M|	for_each_element(elem, start, len) {
  ------------------
  |  |  395|  24.8k|	for (_elem = (const struct element *) (_data);			\
  |  |  396|  51.2M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (396:7): [True: 51.2M, False: 21.7k]
  |  |  ------------------
  |  |  397|  51.2M|		(int) sizeof(*_elem) &&					\
  |  |  398|  51.2M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (398:7): [True: 51.2M, False: 39]
  |  |  ------------------
  |  |  399|  51.2M|		(int) element_hdr_size(_elem) &&			\
  |  |  400|  51.2M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (400:7): [True: 51.2M, False: 3.10k]
  |  |  ------------------
  |  |  401|  51.2M|		(int) (element_hdr_size(_elem) +			\
  |  |  402|  51.2M|		       element_datalen(_elem));				\
  |  |  403|  51.2M|	     _elem = element_next(_elem))
  ------------------
  531|  51.2M|		u8 id = elem->id, elen;
  532|  51.2M|		const u8 *pos;
  533|  51.2M|		size_t *total_len = NULL;
  534|       |
  535|  51.2M|		if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) {
  ------------------
  |  |  503|   102M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (535:7): [True: 1.62M, False: 49.6M]
  |  Branch (535:34): [True: 427k, False: 1.19M]
  ------------------
  536|   427k|			elems->num_frag_elems--;
  537|   427k|			continue;
  538|   427k|		}
  539|       |
  540|  50.8M|		elems->num_frag_elems = 0;
  541|  50.8M|		if (id == WLAN_EID_EXT_LENGTH) {
  ------------------
  |  |  498|  50.8M|#define WLAN_EID_EXT_LENGTH 227
  ------------------
  |  Branch (541:7): [True: 4.49k, False: 50.8M]
  ------------------
  542|  4.49k|			if (ieee802_11_parse_ext_len_elem(
  ------------------
  |  Branch (542:8): [True: 3.05k, False: 1.44k]
  ------------------
  543|  4.49k|				    (const struct ext_len_element *) elem,
  544|  4.49k|				    elems, show_errors))
  545|  3.05k|				unknown++;
  546|  4.49k|			continue;
  547|  4.49k|		}
  548|       |
  549|  50.8M|		elen = elem->datalen;
  550|  50.8M|		pos = elem->data;
  551|       |
  552|  50.8M|		switch (id) {
  553|  46.1M|		case WLAN_EID_SSID:
  ------------------
  |  |  323|  46.1M|#define WLAN_EID_SSID 0
  ------------------
  |  Branch (553:3): [True: 46.1M, False: 4.63M]
  ------------------
  554|  46.1M|			if (elen > SSID_MAX_LEN) {
  ------------------
  |  |  511|  46.1M|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (554:8): [True: 120k, False: 46.0M]
  ------------------
  555|   120k|				wpa_printf(MSG_DEBUG,
  556|   120k|					   "Ignored too long SSID element (elen=%u)",
  557|   120k|					   elen);
  558|   120k|				break;
  559|   120k|			}
  560|  46.0M|			if (elems->ssid) {
  ------------------
  |  Branch (560:8): [True: 46.0M, False: 8.49k]
  ------------------
  561|  46.0M|				wpa_printf(MSG_MSGDUMP,
  562|  46.0M|					   "Ignored duplicated SSID element");
  563|  46.0M|				break;
  564|  46.0M|			}
  565|  8.49k|			elems->ssid = pos;
  566|  8.49k|			elems->ssid_len = elen;
  567|  8.49k|			break;
  568|   129k|		case WLAN_EID_SUPP_RATES:
  ------------------
  |  |  324|   129k|#define WLAN_EID_SUPP_RATES 1
  ------------------
  |  Branch (568:3): [True: 129k, False: 50.6M]
  ------------------
  569|   129k|			elems->supp_rates = pos;
  570|   129k|			elems->supp_rates_len = elen;
  571|   129k|			break;
  572|  18.9k|		case WLAN_EID_DS_PARAMS:
  ------------------
  |  |  325|  18.9k|#define WLAN_EID_DS_PARAMS 3
  ------------------
  |  Branch (572:3): [True: 18.9k, False: 50.7M]
  ------------------
  573|  18.9k|			if (elen < 1)
  ------------------
  |  Branch (573:8): [True: 6.40k, False: 12.5k]
  ------------------
  574|  6.40k|				break;
  575|  12.5k|			elems->ds_params = pos;
  576|  12.5k|			break;
  577|  32.2k|		case WLAN_EID_CF_PARAMS:
  ------------------
  |  |  326|  32.2k|#define WLAN_EID_CF_PARAMS 4
  ------------------
  |  Branch (577:3): [True: 32.2k, False: 50.7M]
  ------------------
  578|  37.9k|		case WLAN_EID_TIM:
  ------------------
  |  |  327|  37.9k|#define WLAN_EID_TIM 5
  ------------------
  |  Branch (578:3): [True: 5.68k, False: 50.7M]
  ------------------
  579|  37.9k|			break;
  580|  24.7k|		case WLAN_EID_CHALLENGE:
  ------------------
  |  |  336|  24.7k|#define WLAN_EID_CHALLENGE 16
  ------------------
  |  Branch (580:3): [True: 24.7k, False: 50.7M]
  ------------------
  581|  24.7k|			elems->challenge = pos;
  582|  24.7k|			elems->challenge_len = elen;
  583|  24.7k|			break;
  584|  10.5k|		case WLAN_EID_ERP_INFO:
  ------------------
  |  |  347|  10.5k|#define WLAN_EID_ERP_INFO 42
  ------------------
  |  Branch (584:3): [True: 10.5k, False: 50.7M]
  ------------------
  585|  10.5k|			if (elen < 1)
  ------------------
  |  Branch (585:8): [True: 8.21k, False: 2.38k]
  ------------------
  586|  8.21k|				break;
  587|  2.38k|			elems->erp_info = pos;
  588|  2.38k|			break;
  589|  2.95k|		case WLAN_EID_EXT_SUPP_RATES:
  ------------------
  |  |  353|  2.95k|#define WLAN_EID_EXT_SUPP_RATES 50
  ------------------
  |  Branch (589:3): [True: 2.95k, False: 50.8M]
  ------------------
  590|  2.95k|			elems->ext_supp_rates = pos;
  591|  2.95k|			elems->ext_supp_rates_len = elen;
  592|  2.95k|			break;
  593|  1.74M|		case WLAN_EID_VENDOR_SPECIFIC:
  ------------------
  |  |  496|  1.74M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (593:3): [True: 1.74M, False: 49.0M]
  ------------------
  594|  1.74M|			if (ieee802_11_parse_vendor_specific(pos, elen,
  ------------------
  |  Branch (594:8): [True: 713k, False: 1.03M]
  ------------------
  595|  1.74M|							     elems,
  596|  1.74M|							     show_errors))
  597|   713k|				unknown++;
  598|  1.74M|			break;
  599|  6.08k|		case WLAN_EID_RSN:
  ------------------
  |  |  352|  6.08k|#define WLAN_EID_RSN 48
  ------------------
  |  Branch (599:3): [True: 6.08k, False: 50.7M]
  ------------------
  600|  6.08k|			elems->rsn_ie = pos;
  601|  6.08k|			elems->rsn_ie_len = elen;
  602|  6.08k|			break;
  603|  1.25k|		case WLAN_EID_RSNX:
  ------------------
  |  |  504|  1.25k|#define WLAN_EID_RSNX 244
  ------------------
  |  Branch (603:3): [True: 1.25k, False: 50.8M]
  ------------------
  604|  1.25k|			elems->rsnxe = pos;
  605|  1.25k|			elems->rsnxe_len = elen;
  606|  1.25k|			break;
  607|  3.61k|		case WLAN_EID_PWR_CAPABILITY:
  ------------------
  |  |  338|  3.61k|#define WLAN_EID_PWR_CAPABILITY 33
  ------------------
  |  Branch (607:3): [True: 3.61k, False: 50.8M]
  ------------------
  608|  3.61k|			if (elen < 2)
  ------------------
  |  Branch (608:8): [True: 1.01k, False: 2.60k]
  ------------------
  609|  1.01k|				break;
  610|  2.60k|			elems->power_capab = pos;
  611|  2.60k|			elems->power_capab_len = elen;
  612|  2.60k|			break;
  613|  7.61k|		case WLAN_EID_SUPPORTED_CHANNELS:
  ------------------
  |  |  341|  7.61k|#define WLAN_EID_SUPPORTED_CHANNELS 36
  ------------------
  |  Branch (613:3): [True: 7.61k, False: 50.7M]
  ------------------
  614|  7.61k|			elems->supp_channels = pos;
  615|  7.61k|			elems->supp_channels_len = elen;
  616|  7.61k|			break;
  617|  2.27k|		case WLAN_EID_MOBILITY_DOMAIN:
  ------------------
  |  |  357|  2.27k|#define WLAN_EID_MOBILITY_DOMAIN 54
  ------------------
  |  Branch (617:3): [True: 2.27k, False: 50.8M]
  ------------------
  618|  2.27k|			if (elen < sizeof(struct rsn_mdie))
  ------------------
  |  Branch (618:8): [True: 442, False: 1.82k]
  ------------------
  619|    442|				break;
  620|  1.82k|			elems->mdie = pos;
  621|  1.82k|			elems->mdie_len = elen;
  622|  1.82k|			break;
  623|  4.42k|		case WLAN_EID_FAST_BSS_TRANSITION:
  ------------------
  |  |  358|  4.42k|#define WLAN_EID_FAST_BSS_TRANSITION 55
  ------------------
  |  Branch (623:3): [True: 4.42k, False: 50.8M]
  ------------------
  624|  4.42k|			if (elen < sizeof(struct rsn_ftie))
  ------------------
  |  Branch (624:8): [True: 2.23k, False: 2.18k]
  ------------------
  625|  2.23k|				break;
  626|  2.18k|			elems->ftie = pos;
  627|  2.18k|			elems->ftie_len = elen;
  628|  2.18k|			elems->fte_defrag_len = elen;
  629|  2.18k|			total_len = &elems->fte_defrag_len;
  630|  2.18k|			break;
  631|  2.13k|		case WLAN_EID_TIMEOUT_INTERVAL:
  ------------------
  |  |  359|  2.13k|#define WLAN_EID_TIMEOUT_INTERVAL 56
  ------------------
  |  Branch (631:3): [True: 2.13k, False: 50.8M]
  ------------------
  632|  2.13k|			if (elen != 5)
  ------------------
  |  Branch (632:8): [True: 1.93k, False: 203]
  ------------------
  633|  1.93k|				break;
  634|    203|			elems->timeout_int = pos;
  635|    203|			break;
  636|  6.84k|		case WLAN_EID_HT_CAP:
  ------------------
  |  |  350|  6.84k|#define WLAN_EID_HT_CAP 45
  ------------------
  |  Branch (636:3): [True: 6.84k, False: 50.7M]
  ------------------
  637|  6.84k|			if (elen < sizeof(struct ieee80211_ht_capabilities))
  ------------------
  |  Branch (637:8): [True: 1.48k, False: 5.36k]
  ------------------
  638|  1.48k|				break;
  639|  5.36k|			elems->ht_capabilities = pos;
  640|  5.36k|			break;
  641|  15.1k|		case WLAN_EID_HT_OPERATION:
  ------------------
  |  |  364|  15.1k|#define WLAN_EID_HT_OPERATION 61
  ------------------
  |  Branch (641:3): [True: 15.1k, False: 50.7M]
  ------------------
  642|  15.1k|			if (elen < sizeof(struct ieee80211_ht_operation))
  ------------------
  |  Branch (642:8): [True: 798, False: 14.3k]
  ------------------
  643|    798|				break;
  644|  14.3k|			elems->ht_operation = pos;
  645|  14.3k|			break;
  646|  1.96k|		case WLAN_EID_MESH_CONFIG:
  ------------------
  |  |  414|  1.96k|#define WLAN_EID_MESH_CONFIG 113
  ------------------
  |  Branch (646:3): [True: 1.96k, False: 50.8M]
  ------------------
  647|  1.96k|			elems->mesh_config = pos;
  648|  1.96k|			elems->mesh_config_len = elen;
  649|  1.96k|			break;
  650|    537|		case WLAN_EID_MESH_ID:
  ------------------
  |  |  415|    537|#define WLAN_EID_MESH_ID 114
  ------------------
  |  Branch (650:3): [True: 537, False: 50.8M]
  ------------------
  651|    537|			elems->mesh_id = pos;
  652|    537|			elems->mesh_id_len = elen;
  653|    537|			break;
  654|  1.87k|		case WLAN_EID_PEER_MGMT:
  ------------------
  |  |  418|  1.87k|#define WLAN_EID_PEER_MGMT 117
  ------------------
  |  Branch (654:3): [True: 1.87k, False: 50.8M]
  ------------------
  655|  1.87k|			elems->peer_mgmt = pos;
  656|  1.87k|			elems->peer_mgmt_len = elen;
  657|  1.87k|			break;
  658|  1.63k|		case WLAN_EID_VHT_CAP:
  ------------------
  |  |  478|  1.63k|#define WLAN_EID_VHT_CAP 191
  ------------------
  |  Branch (658:3): [True: 1.63k, False: 50.8M]
  ------------------
  659|  1.63k|			if (elen < sizeof(struct ieee80211_vht_capabilities))
  ------------------
  |  Branch (659:8): [True: 1.00k, False: 630]
  ------------------
  660|  1.00k|				break;
  661|    630|			elems->vht_capabilities = pos;
  662|    630|			break;
  663|  2.37k|		case WLAN_EID_VHT_OPERATION:
  ------------------
  |  |  479|  2.37k|#define WLAN_EID_VHT_OPERATION 192
  ------------------
  |  Branch (663:3): [True: 2.37k, False: 50.8M]
  ------------------
  664|  2.37k|			if (elen < sizeof(struct ieee80211_vht_operation))
  ------------------
  |  Branch (664:8): [True: 1.13k, False: 1.23k]
  ------------------
  665|  1.13k|				break;
  666|  1.23k|			elems->vht_operation = pos;
  667|  1.23k|			break;
  668|  2.34k|		case WLAN_EID_OPERATING_MODE_NOTIFICATION:
  ------------------
  |  |  486|  2.34k|#define WLAN_EID_OPERATING_MODE_NOTIFICATION 199
  ------------------
  |  Branch (668:3): [True: 2.34k, False: 50.8M]
  ------------------
  669|  2.34k|			if (elen != 1)
  ------------------
  |  Branch (669:8): [True: 2.06k, False: 278]
  ------------------
  670|  2.06k|				break;
  671|    278|			elems->opmode_notif = pos;
  672|    278|			break;
  673|  3.97k|		case WLAN_EID_LINK_ID:
  ------------------
  |  |  403|  3.97k|#define WLAN_EID_LINK_ID 101
  ------------------
  |  Branch (673:3): [True: 3.97k, False: 50.8M]
  ------------------
  674|  3.97k|			if (elen < 18)
  ------------------
  |  Branch (674:8): [True: 1.18k, False: 2.79k]
  ------------------
  675|  1.18k|				break;
  676|  2.79k|			elems->link_id = pos;
  677|  2.79k|			break;
  678|    961|		case WLAN_EID_INTERWORKING:
  ------------------
  |  |  408|    961|#define WLAN_EID_INTERWORKING 107
  ------------------
  |  Branch (678:3): [True: 961, False: 50.8M]
  ------------------
  679|    961|			elems->interworking = pos;
  680|    961|			elems->interworking_len = elen;
  681|    961|			break;
  682|  2.10k|		case WLAN_EID_QOS_MAP_SET:
  ------------------
  |  |  411|  2.10k|#define WLAN_EID_QOS_MAP_SET 110
  ------------------
  |  Branch (682:3): [True: 2.10k, False: 50.8M]
  ------------------
  683|  2.10k|			if (elen < 16)
  ------------------
  |  Branch (683:8): [True: 808, False: 1.30k]
  ------------------
  684|    808|				break;
  685|  1.30k|			elems->qos_map_set = pos;
  686|  1.30k|			elems->qos_map_set_len = elen;
  687|  1.30k|			break;
  688|  4.31k|		case WLAN_EID_EXT_CAPAB:
  ------------------
  |  |  428|  4.31k|#define WLAN_EID_EXT_CAPAB 127
  ------------------
  |  Branch (688:3): [True: 4.31k, False: 50.8M]
  ------------------
  689|  4.31k|			elems->ext_capab = pos;
  690|  4.31k|			elems->ext_capab_len = elen;
  691|  4.31k|			break;
  692|  1.97k|		case WLAN_EID_BSS_MAX_IDLE_PERIOD:
  ------------------
  |  |  392|  1.97k|#define WLAN_EID_BSS_MAX_IDLE_PERIOD 90
  ------------------
  |  Branch (692:3): [True: 1.97k, False: 50.8M]
  ------------------
  693|  1.97k|			if (elen < 3)
  ------------------
  |  Branch (693:8): [True: 589, False: 1.38k]
  ------------------
  694|    589|				break;
  695|  1.38k|			elems->bss_max_idle_period = pos;
  696|  1.38k|			break;
  697|  2.04k|		case WLAN_EID_SSID_LIST:
  ------------------
  |  |  386|  2.04k|#define WLAN_EID_SSID_LIST 84
  ------------------
  |  Branch (697:3): [True: 2.04k, False: 50.8M]
  ------------------
  698|  2.04k|			elems->ssid_list = pos;
  699|  2.04k|			elems->ssid_list_len = elen;
  700|  2.04k|			break;
  701|  3.45k|		case WLAN_EID_AMPE:
  ------------------
  |  |  434|  3.45k|#define WLAN_EID_AMPE 139
  ------------------
  |  Branch (701:3): [True: 3.45k, False: 50.8M]
  ------------------
  702|  3.45k|			elems->ampe = pos;
  703|  3.45k|			elems->ampe_len = elen;
  704|  3.45k|			break;
  705|  3.60k|		case WLAN_EID_MIC:
  ------------------
  |  |  435|  3.60k|#define WLAN_EID_MIC 140
  ------------------
  |  Branch (705:3): [True: 3.60k, False: 50.8M]
  ------------------
  706|  3.60k|			elems->mic = pos;
  707|  3.60k|			elems->mic_len = elen;
  708|  3.60k|			if (elems->stop_at_mic) {
  ------------------
  |  Branch (708:8): [True: 0, False: 3.60k]
  ------------------
  709|       |				/* After MIC everything is encrypted, so stop.
  710|       |				 */
  711|      0|				goto done;
  712|      0|			}
  713|  3.60k|			break;
  714|  3.60k|		case WLAN_EID_MULTI_BAND:
  ------------------
  |  |  450|  1.54k|#define WLAN_EID_MULTI_BAND 158
  ------------------
  |  Branch (714:3): [True: 1.54k, False: 50.8M]
  ------------------
  715|  1.54k|			if (elems->mb_ies.nof_ies >= MAX_NOF_MB_IES_SUPPORTED) {
  ------------------
  |  |   58|  1.54k|#define MAX_NOF_MB_IES_SUPPORTED 5
  ------------------
  |  Branch (715:8): [True: 672, False: 868]
  ------------------
  716|    672|				wpa_printf(MSG_MSGDUMP,
  717|    672|					   "IEEE 802.11 element parse ignored MB IE (id=%d elen=%d)",
  718|    672|					   id, elen);
  719|    672|				break;
  720|    672|			}
  721|       |
  722|    868|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie = pos;
  723|    868|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie_len = elen;
  724|    868|			elems->mb_ies.nof_ies++;
  725|    868|			break;
  726|  7.00k|		case WLAN_EID_SUPPORTED_OPERATING_CLASSES:
  ------------------
  |  |  362|  7.00k|#define WLAN_EID_SUPPORTED_OPERATING_CLASSES 59
  ------------------
  |  Branch (726:3): [True: 7.00k, False: 50.7M]
  ------------------
  727|  7.00k|			elems->supp_op_classes = pos;
  728|  7.00k|			elems->supp_op_classes_len = elen;
  729|  7.00k|			break;
  730|  1.08k|		case WLAN_EID_RRM_ENABLED_CAPABILITIES:
  ------------------
  |  |  373|  1.08k|#define WLAN_EID_RRM_ENABLED_CAPABILITIES 70
  ------------------
  |  Branch (730:3): [True: 1.08k, False: 50.8M]
  ------------------
  731|  1.08k|			elems->rrm_enabled = pos;
  732|  1.08k|			elems->rrm_enabled_len = elen;
  733|  1.08k|			break;
  734|  5.02k|		case WLAN_EID_MULTIPLE_BSSID:
  ------------------
  |  |  374|  5.02k|#define WLAN_EID_MULTIPLE_BSSID 71
  ------------------
  |  Branch (734:3): [True: 5.02k, False: 50.8M]
  ------------------
  735|  5.02k|			if (elen < 1)
  ------------------
  |  Branch (735:8): [True: 950, False: 4.07k]
  ------------------
  736|    950|				break;
  737|  4.07k|			elems->mbssid = pos;
  738|  4.07k|			elems->mbssid_len = elen;
  739|  4.07k|			break;
  740|    954|		case WLAN_EID_CAG_NUMBER:
  ------------------
  |  |  499|    954|#define WLAN_EID_CAG_NUMBER 237
  ------------------
  |  Branch (740:3): [True: 954, False: 50.8M]
  ------------------
  741|    954|			elems->cag_number = pos;
  742|    954|			elems->cag_number_len = elen;
  743|    954|			break;
  744|  2.76k|		case WLAN_EID_AP_CSN:
  ------------------
  |  |  500|  2.76k|#define WLAN_EID_AP_CSN 239
  ------------------
  |  Branch (744:3): [True: 2.76k, False: 50.8M]
  ------------------
  745|  2.76k|			if (elen < 1)
  ------------------
  |  Branch (745:8): [True: 514, False: 2.24k]
  ------------------
  746|    514|				break;
  747|  2.24k|			elems->ap_csn = pos;
  748|  2.24k|			break;
  749|  24.9k|		case WLAN_EID_FILS_INDICATION:
  ------------------
  |  |  501|  24.9k|#define WLAN_EID_FILS_INDICATION 240
  ------------------
  |  Branch (749:3): [True: 24.9k, False: 50.7M]
  ------------------
  750|  24.9k|			if (elen < 2)
  ------------------
  |  Branch (750:8): [True: 23.8k, False: 1.09k]
  ------------------
  751|  23.8k|				break;
  752|  1.09k|			elems->fils_indic = pos;
  753|  1.09k|			elems->fils_indic_len = elen;
  754|  1.09k|			break;
  755|  2.97k|		case WLAN_EID_DILS:
  ------------------
  |  |  502|  2.97k|#define WLAN_EID_DILS 241
  ------------------
  |  Branch (755:3): [True: 2.97k, False: 50.8M]
  ------------------
  756|  2.97k|			if (elen < 2)
  ------------------
  |  Branch (756:8): [True: 1.04k, False: 1.93k]
  ------------------
  757|  1.04k|				break;
  758|  1.93k|			elems->dils = pos;
  759|  1.93k|			elems->dils_len = elen;
  760|  1.93k|			break;
  761|  1.29k|		case WLAN_EID_S1G_CAPABILITIES:
  ------------------
  |  |  495|  1.29k|#define WLAN_EID_S1G_CAPABILITIES 217
  ------------------
  |  Branch (761:3): [True: 1.29k, False: 50.8M]
  ------------------
  762|  1.29k|			if (elen < 15)
  ------------------
  |  Branch (762:8): [True: 362, False: 931]
  ------------------
  763|    362|				break;
  764|    931|			elems->s1g_capab = pos;
  765|    931|			break;
  766|  1.19M|		case WLAN_EID_FRAGMENT:
  ------------------
  |  |  503|  1.19M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (766:3): [True: 1.19M, False: 49.6M]
  ------------------
  767|  1.19M|			wpa_printf(MSG_MSGDUMP,
  768|  1.19M|				   "Fragment without a valid last element - skip");
  769|       |
  770|  1.19M|			break;
  771|  58.9k|		case WLAN_EID_EXTENSION:
  ------------------
  |  |  505|  58.9k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (771:3): [True: 58.9k, False: 50.7M]
  ------------------
  772|  58.9k|			if (ieee802_11_parse_extension(pos, elen, elems, start,
  ------------------
  |  Branch (772:8): [True: 35.4k, False: 23.5k]
  ------------------
  773|  58.9k|						       len, show_errors))
  774|  35.4k|				unknown++;
  775|  58.9k|			break;
  776|  1.28M|		default:
  ------------------
  |  Branch (776:3): [True: 1.28M, False: 49.5M]
  ------------------
  777|  1.28M|			unknown++;
  778|  1.28M|			if (!show_errors)
  ------------------
  |  Branch (778:8): [True: 1.28M, False: 0]
  ------------------
  779|  1.28M|				break;
  780|      0|			wpa_printf(MSG_MSGDUMP, "IEEE 802.11 element parse "
  781|      0|				   "ignored unknown element (id=%d elen=%d)",
  782|      0|				   id, elen);
  783|      0|			break;
  784|  50.8M|		}
  785|       |
  786|  50.8M|		if (elen == 255 && total_len)
  ------------------
  |  Branch (786:7): [True: 41.8k, False: 50.7M]
  |  Branch (786:22): [True: 1.74k, False: 40.0k]
  ------------------
  787|  1.74k|			*total_len += ieee802_11_fragments_length(
  788|  1.74k|				elems, pos + elen,
  789|  1.74k|				(start + len) - (pos + elen));
  790|       |
  791|  50.8M|	}
  792|       |
  793|  24.8k|	if (!for_each_element_completed(elem, start, len)) {
  ------------------
  |  Branch (793:6): [True: 3.30k, False: 21.5k]
  ------------------
  794|  3.30k|		if (show_errors) {
  ------------------
  |  Branch (794:7): [True: 0, False: 3.30k]
  ------------------
  795|      0|			wpa_printf(MSG_DEBUG,
  796|      0|				   "IEEE 802.11 element parse failed @%d",
  797|      0|				   (int) (start + len - (const u8 *) elem));
  798|      0|			wpa_hexdump(MSG_MSGDUMP, "IEs", start, len);
  799|      0|		}
  800|  3.30k|		return ParseFailed;
  801|  3.30k|	}
  802|       |
  803|  21.5k|done:
  804|  21.5k|	return unknown ? ParseUnknown : ParseOK;
  ------------------
  |  Branch (804:9): [True: 8.36k, False: 13.1k]
  ------------------
  805|  24.8k|}
ieee802_11_common.c:ieee802_11_parse_ext_len_elem:
  489|  4.49k|{
  490|  4.49k|	u16 id, info_len;
  491|  4.49k|	const u8 *pos;
  492|       |
  493|  4.49k|	id = le_to_host16(elem->ext_id);
  ------------------
  |  |  175|  4.49k|#define le_to_host16(n) ((__force u16) (le16) (n))
  ------------------
  494|  4.49k|	info_len = le_to_host16(elem->datalen);
  ------------------
  |  |  175|  4.49k|#define le_to_host16(n) ((__force u16) (le16) (n))
  ------------------
  495|  4.49k|	pos = elem->data;
  496|       |
  497|  4.49k|	switch (id) {
  498|  1.44k|	case WLAN_EID_EXT_LEN_PQC_PARAMETER:
  ------------------
  |  |  567|  1.44k|#define WLAN_EID_EXT_LEN_PQC_PARAMETER 0
  ------------------
  |  Branch (498:2): [True: 1.44k, False: 3.05k]
  ------------------
  499|       |		/* The elements contains at least the Security Profile Number
  500|       |		 * and Content Presence fields. */
  501|  1.44k|		if (info_len < 2)
  ------------------
  |  Branch (501:7): [True: 932, False: 511]
  ------------------
  502|    932|			break;
  503|       |
  504|    511|		elems->pqc_parameter = pos;
  505|    511|		elems->pqc_parameter_len = info_len;
  506|    511|		break;
  507|  3.05k|	default:
  ------------------
  |  Branch (507:2): [True: 3.05k, False: 1.44k]
  ------------------
  508|  3.05k|		if (show_errors) {
  ------------------
  |  Branch (508:7): [True: 0, False: 3.05k]
  ------------------
  509|      0|			wpa_printf(MSG_MSGDUMP,
  510|      0|				   "IEEE 802.11 element parsing ignored unknown extended length element (id=%u elen=%u)",
  511|      0|				   id, info_len);
  512|      0|		}
  513|  3.05k|		return -1;
  514|  4.49k|	}
  515|       |
  516|  1.44k|	return 0;
  517|  4.49k|}
ieee802_11_common.c:ieee802_11_parse_vendor_specific:
   23|  1.74M|{
   24|  1.74M|	unsigned int oui;
   25|       |
   26|       |	/* first 3 bytes in vendor specific information element are the IEEE
   27|       |	 * OUI of the vendor. The following byte is used a vendor specific
   28|       |	 * sub-type. */
   29|  1.74M|	if (elen < 4) {
  ------------------
  |  Branch (29:6): [True: 615k, False: 1.12M]
  ------------------
   30|   615k|		if (show_errors) {
  ------------------
  |  Branch (30:7): [True: 0, False: 615k]
  ------------------
   31|      0|			wpa_printf(MSG_MSGDUMP, "short vendor specific "
   32|      0|				   "information element ignored (len=%lu)",
   33|      0|				   (unsigned long) elen);
   34|      0|		}
   35|   615k|		return -1;
   36|   615k|	}
   37|       |
   38|  1.12M|	oui = WPA_GET_BE24(pos);
   39|  1.12M|	switch (oui) {
   40|   519k|	case OUI_MICROSOFT:
  ------------------
  |  | 1569|   519k|#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
  ------------------
  |  Branch (40:2): [True: 519k, False: 610k]
  ------------------
   41|       |		/* Microsoft/Wi-Fi information elements are further typed and
   42|       |		 * subtyped */
   43|   519k|		switch (pos[3]) {
   44|  5.32k|		case 1:
  ------------------
  |  Branch (44:3): [True: 5.32k, False: 513k]
  ------------------
   45|       |			/* Microsoft OUI (00:50:F2) with OUI Type 1:
   46|       |			 * real WPA information element */
   47|  5.32k|			elems->wpa_ie = pos;
   48|  5.32k|			elems->wpa_ie_len = elen;
   49|  5.32k|			break;
   50|  2.88k|		case WMM_OUI_TYPE:
  ------------------
  |  | 1625|  2.88k|#define WMM_OUI_TYPE 2
  ------------------
  |  Branch (50:3): [True: 2.88k, False: 516k]
  ------------------
   51|       |			/* WMM information element */
   52|  2.88k|			if (elen < 5) {
  ------------------
  |  Branch (52:8): [True: 1.61k, False: 1.26k]
  ------------------
   53|  1.61k|				wpa_printf(MSG_MSGDUMP, "short WMM "
   54|  1.61k|					   "information element ignored "
   55|  1.61k|					   "(len=%lu)",
   56|  1.61k|					   (unsigned long) elen);
   57|  1.61k|				return -1;
   58|  1.61k|			}
   59|  1.26k|			switch (pos[4]) {
   60|    459|			case WMM_OUI_SUBTYPE_INFORMATION_ELEMENT:
  ------------------
  |  | 1626|    459|#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  ------------------
  |  Branch (60:4): [True: 459, False: 808]
  ------------------
   61|    782|			case WMM_OUI_SUBTYPE_PARAMETER_ELEMENT:
  ------------------
  |  | 1627|    782|#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  ------------------
  |  Branch (61:4): [True: 323, False: 944]
  ------------------
   62|       |				/*
   63|       |				 * Share same pointer since only one of these
   64|       |				 * is used and they start with same data.
   65|       |				 * Length field can be used to distinguish the
   66|       |				 * IEs.
   67|       |				 */
   68|    782|				elems->wmm = pos;
   69|    782|				elems->wmm_len = elen;
   70|    782|				break;
   71|    230|			case WMM_OUI_SUBTYPE_TSPEC_ELEMENT:
  ------------------
  |  | 1628|    230|#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
  ------------------
  |  Branch (71:4): [True: 230, False: 1.03k]
  ------------------
   72|    230|				elems->wmm_tspec = pos;
   73|    230|				elems->wmm_tspec_len = elen;
   74|    230|				break;
   75|    255|			default:
  ------------------
  |  Branch (75:4): [True: 255, False: 1.01k]
  ------------------
   76|    255|				wpa_printf(MSG_EXCESSIVE, "unknown WMM "
   77|    255|					   "information element ignored "
   78|    255|					   "(subtype=%d len=%lu)",
   79|    255|					   pos[4], (unsigned long) elen);
   80|    255|				return -1;
   81|  1.26k|			}
   82|  1.01k|			break;
   83|   509k|		case 4:
  ------------------
  |  Branch (83:3): [True: 509k, False: 9.53k]
  ------------------
   84|       |			/* Wi-Fi Protected Setup (WPS) IE */
   85|   509k|			elems->wps_ie = pos;
   86|   509k|			elems->wps_ie_len = elen;
   87|   509k|			break;
   88|  1.33k|		default:
  ------------------
  |  Branch (88:3): [True: 1.33k, False: 517k]
  ------------------
   89|  1.33k|			wpa_printf(MSG_EXCESSIVE, "Unknown Microsoft "
   90|  1.33k|				   "information element ignored "
   91|  1.33k|				   "(type=%d len=%lu)",
   92|  1.33k|				   pos[3], (unsigned long) elen);
   93|  1.33k|			return -1;
   94|   519k|		}
   95|   515k|		break;
   96|       |
   97|   515k|	case OUI_WFA:
  ------------------
  |  | 1574|   515k|#define OUI_WFA 0x506f9a
  ------------------
  |  Branch (97:2): [True: 515k, False: 613k]
  ------------------
   98|   515k|		switch (pos[3]) {
   99|   360k|		case P2P_OUI_TYPE:
  ------------------
  |  | 1865|   360k|#define P2P_OUI_TYPE 9
  ------------------
  |  Branch (99:3): [True: 360k, False: 155k]
  ------------------
  100|       |			/* Wi-Fi Alliance - P2P IE */
  101|   360k|			elems->p2p = pos;
  102|   360k|			elems->p2p_len = elen;
  103|   360k|			break;
  104|   146k|		case WFD_OUI_TYPE:
  ------------------
  |  | 1578|   146k|#define WFD_OUI_TYPE 10
  ------------------
  |  Branch (104:3): [True: 146k, False: 369k]
  ------------------
  105|       |			/* Wi-Fi Alliance - WFD IE */
  106|   146k|			elems->wfd = pos;
  107|   146k|			elems->wfd_len = elen;
  108|   146k|			break;
  109|    202|		case HS20_INDICATION_OUI_TYPE:
  ------------------
  |  | 1740|    202|#define HS20_INDICATION_OUI_TYPE 16
  ------------------
  |  Branch (109:3): [True: 202, False: 515k]
  ------------------
  110|       |			/* Hotspot 2.0 */
  111|    202|			elems->hs20 = pos;
  112|    202|			elems->hs20_len = elen;
  113|    202|			break;
  114|    219|		case MBO_OUI_TYPE:
  ------------------
  |  | 1586|    219|#define MBO_OUI_TYPE 22
  ------------------
  |  Branch (114:3): [True: 219, False: 515k]
  ------------------
  115|       |			/* MBO-OCE */
  116|    219|			elems->mbo = pos;
  117|    219|			elems->mbo_len = elen;
  118|    219|			break;
  119|    238|		case HS20_ROAMING_CONS_SEL_OUI_TYPE:
  ------------------
  |  | 1742|    238|#define HS20_ROAMING_CONS_SEL_OUI_TYPE 29
  ------------------
  |  Branch (119:3): [True: 238, False: 515k]
  ------------------
  120|       |			/* Hotspot 2.0 Roaming Consortium Selection */
  121|    238|			elems->roaming_cons_sel = pos;
  122|    238|			elems->roaming_cons_sel_len = elen;
  123|    238|			break;
  124|    238|		case MULTI_AP_OUI_TYPE:
  ------------------
  |  | 1589|    238|#define MULTI_AP_OUI_TYPE 0x1B
  ------------------
  |  Branch (124:3): [True: 238, False: 515k]
  ------------------
  125|    238|			elems->multi_ap = pos;
  126|    238|			elems->multi_ap_len = elen;
  127|    238|			break;
  128|    238|		case OWE_OUI_TYPE:
  ------------------
  |  | 1588|    238|#define OWE_OUI_TYPE 28
  ------------------
  |  Branch (128:3): [True: 238, False: 515k]
  ------------------
  129|       |			/* OWE Transition Mode element */
  130|    238|			break;
  131|    202|		case DPP_CC_OUI_TYPE:
  ------------------
  |  | 1591|    202|#define DPP_CC_OUI_TYPE 0x1e
  ------------------
  |  Branch (131:3): [True: 202, False: 515k]
  ------------------
  132|       |			/* DPP Configurator Connectivity element */
  133|    202|			break;
  134|    280|		case SAE_PK_OUI_TYPE:
  ------------------
  |  | 1593|    280|#define SAE_PK_OUI_TYPE 0x1f
  ------------------
  |  Branch (134:3): [True: 280, False: 515k]
  ------------------
  135|    280|			elems->sae_pk = pos + 4;
  136|    280|			elems->sae_pk_len = elen - 4;
  137|    280|			break;
  138|    559|		case WFA_CAPA_OUI_TYPE:
  ------------------
  |  | 1597|    559|#define WFA_CAPA_OUI_TYPE 0x23
  ------------------
  |  Branch (138:3): [True: 559, False: 515k]
  ------------------
  139|    559|			elems->wfa_capab = pos + 4;
  140|    559|			elems->wfa_capab_len = elen - 4;
  141|    559|			break;
  142|    249|		case WFA_RSNE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1598|    249|#define WFA_RSNE_OVERRIDE_OUI_TYPE 0x29
  ------------------
  |  Branch (142:3): [True: 249, False: 515k]
  ------------------
  143|    249|			elems->rsne_override = pos;
  144|    249|			elems->rsne_override_len = elen;
  145|    249|			break;
  146|    334|		case WFA_RSNE_OVERRIDE_2_OUI_TYPE:
  ------------------
  |  | 1599|    334|#define WFA_RSNE_OVERRIDE_2_OUI_TYPE 0x2a
  ------------------
  |  Branch (146:3): [True: 334, False: 515k]
  ------------------
  147|    334|			elems->rsne_override_2 = pos;
  148|    334|			elems->rsne_override_2_len = elen;
  149|    334|			break;
  150|    223|		case WFA_RSNXE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1600|    223|#define WFA_RSNXE_OVERRIDE_OUI_TYPE 0x2b
  ------------------
  |  Branch (150:3): [True: 223, False: 515k]
  ------------------
  151|    223|			elems->rsnxe_override = pos;
  152|    223|			elems->rsnxe_override_len = elen;
  153|    223|			break;
  154|    575|		case WFA_RSN_SELECTION_OUI_TYPE:
  ------------------
  |  | 1601|    575|#define WFA_RSN_SELECTION_OUI_TYPE 0x2c
  ------------------
  |  Branch (154:3): [True: 575, False: 515k]
  ------------------
  155|    575|			if (elen < 4 + 1) {
  ------------------
  |  Branch (155:8): [True: 299, False: 276]
  ------------------
  156|    299|				wpa_printf(MSG_DEBUG,
  157|    299|					   "Too short RSN Selection element ignored");
  158|    299|				return -1;
  159|    299|			}
  160|    276|			elems->rsn_selection = pos + 4;
  161|    276|			elems->rsn_selection_len = elen - 4;
  162|    276|			break;
  163|  3.76k|		case P2P2_OUI_TYPE:
  ------------------
  |  | 1866|  3.76k|#define P2P2_OUI_TYPE 0x28
  ------------------
  |  Branch (163:3): [True: 3.76k, False: 512k]
  ------------------
  164|       |			/* Wi-Fi Alliance - P2P2 IE */
  165|  3.76k|			elems->p2p2_ie = pos;
  166|  3.76k|			elems->p2p2_ie_len = elen;
  167|  3.76k|			break;
  168|    250|		case PR_OUI_TYPE:
  ------------------
  |  | 1608|    250|#define PR_OUI_TYPE 0x2e
  ------------------
  |  Branch (168:3): [True: 250, False: 515k]
  ------------------
  169|       |			/* Wi-Fi Alliance - Proximity Ranging element */
  170|    250|			elems->proximity_ranging = pos;
  171|    250|			elems->proximity_ranging_len = elen;
  172|    250|			break;
  173|    436|		case NAN_SDF_OUI_TYPE:
  ------------------
  |  | 1582|    436|#define NAN_SDF_OUI_TYPE 0x13
  ------------------
  |  Branch (173:3): [True: 436, False: 515k]
  ------------------
  174|       |			/* Wi-Fi Alliance - NAN IE */
  175|    436|			elems->nan_ie = pos;
  176|    436|			elems->nan_len = elen;
  177|    436|			break;
  178|  1.64k|		default:
  ------------------
  |  Branch (178:3): [True: 1.64k, False: 514k]
  ------------------
  179|  1.64k|			wpa_printf(MSG_MSGDUMP, "Unknown WFA "
  180|  1.64k|				   "information element ignored "
  181|  1.64k|				   "(type=%d len=%lu)",
  182|  1.64k|				   pos[3], (unsigned long) elen);
  183|  1.64k|			return -1;
  184|   515k|		}
  185|   514k|		break;
  186|       |
  187|   514k|	case OUI_BROADCOM:
  ------------------
  |  | 2072|  1.84k|#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
  ------------------
  |  Branch (187:2): [True: 1.84k, False: 1.12M]
  ------------------
  188|  1.84k|		switch (pos[3]) {
  189|    200|		case VENDOR_HT_CAPAB_OUI_TYPE:
  ------------------
  |  | 2077|    200|#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
  ------------------
  |  Branch (189:3): [True: 200, False: 1.64k]
  ------------------
  190|    200|			elems->vendor_ht_cap = pos;
  191|    200|			elems->vendor_ht_cap_len = elen;
  192|    200|			break;
  193|  1.06k|		case VENDOR_VHT_TYPE:
  ------------------
  |  | 2073|  1.06k|#define VENDOR_VHT_TYPE		0x04
  ------------------
  |  Branch (193:3): [True: 1.06k, False: 774]
  ------------------
  194|  1.06k|			if (elen > 4 &&
  ------------------
  |  Branch (194:8): [True: 858, False: 208]
  ------------------
  195|    858|			    (pos[4] == VENDOR_VHT_SUBTYPE ||
  ------------------
  |  | 2074|  1.71k|#define VENDOR_VHT_SUBTYPE	0x08
  ------------------
  |  Branch (195:9): [True: 351, False: 507]
  ------------------
  196|    601|			     pos[4] == VENDOR_VHT_SUBTYPE2)) {
  ------------------
  |  | 2075|    507|#define VENDOR_VHT_SUBTYPE2	0x00
  ------------------
  |  Branch (196:9): [True: 250, False: 257]
  ------------------
  197|    601|				elems->vendor_vht = pos;
  198|    601|				elems->vendor_vht_len = elen;
  199|    601|			} else
  200|    465|				return -1;
  201|    601|			break;
  202|    601|		default:
  ------------------
  |  Branch (202:3): [True: 574, False: 1.26k]
  ------------------
  203|    574|			wpa_printf(MSG_EXCESSIVE, "Unknown Broadcom "
  204|    574|				   "information element ignored "
  205|    574|				   "(type=%d len=%lu)",
  206|    574|				   pos[3], (unsigned long) elen);
  207|    574|			return -1;
  208|  1.84k|		}
  209|    801|		break;
  210|       |
  211|    801|	case OUI_QCA:
  ------------------
  |  |   21|    657|#define OUI_QCA 0x001374
  ------------------
  |  Branch (211:2): [True: 657, False: 1.12M]
  ------------------
  212|    657|		switch (pos[3]) {
  213|    257|		case QCA_VENDOR_ELEM_P2P_PREF_CHAN_LIST:
  ------------------
  |  Branch (213:3): [True: 257, False: 400]
  ------------------
  214|    257|			elems->pref_freq_list = pos;
  215|    257|			elems->pref_freq_list_len = elen;
  216|    257|			break;
  217|    400|		default:
  ------------------
  |  Branch (217:3): [True: 400, False: 257]
  ------------------
  218|    400|			wpa_printf(MSG_EXCESSIVE,
  219|    400|				   "Unknown QCA information element ignored (type=%d len=%lu)",
  220|    400|				   pos[3], (unsigned long) elen);
  221|    400|			return -1;
  222|    657|		}
  223|    257|		break;
  224|       |
  225|  91.6k|	default:
  ------------------
  |  Branch (225:2): [True: 91.6k, False: 1.03M]
  ------------------
  226|  91.6k|		wpa_printf(MSG_EXCESSIVE, "unknown vendor specific "
  227|  91.6k|			   "information element ignored (vendor OUI "
  228|  91.6k|			   "%02x:%02x:%02x len=%lu)",
  229|  91.6k|			   pos[0], pos[1], pos[2], (unsigned long) elen);
  230|  91.6k|		return -1;
  231|  1.12M|	}
  232|       |
  233|  1.03M|	return 0;
  234|  1.12M|}
ieee802_11_common.c:ieee802_11_parse_extension:
  304|  58.9k|{
  305|  58.9k|	u8 ext_id;
  306|  58.9k|	size_t *total_len = NULL;
  307|       |
  308|  58.9k|	if (elen < 1) {
  ------------------
  |  Branch (308:6): [True: 6.04k, False: 52.8k]
  ------------------
  309|  6.04k|		if (show_errors) {
  ------------------
  |  Branch (309:7): [True: 0, False: 6.04k]
  ------------------
  310|      0|			wpa_printf(MSG_MSGDUMP,
  311|      0|				   "short information element (Ext)");
  312|      0|		}
  313|  6.04k|		return -1;
  314|  6.04k|	}
  315|       |
  316|  52.8k|	ext_id = *pos++;
  317|  52.8k|	elen--;
  318|       |
  319|  52.8k|	switch (ext_id) {
  320|    856|	case WLAN_EID_EXT_ASSOC_DELAY_INFO:
  ------------------
  |  |  508|    856|#define WLAN_EID_EXT_ASSOC_DELAY_INFO 1
  ------------------
  |  Branch (320:2): [True: 856, False: 52.0k]
  ------------------
  321|    856|		if (elen != 1)
  ------------------
  |  Branch (321:7): [True: 635, False: 221]
  ------------------
  322|    635|			break;
  323|    221|		elems->assoc_delay_info = pos;
  324|    221|		break;
  325|    681|	case WLAN_EID_EXT_FILS_REQ_PARAMS:
  ------------------
  |  |  509|    681|#define WLAN_EID_EXT_FILS_REQ_PARAMS 2
  ------------------
  |  Branch (325:2): [True: 681, False: 52.2k]
  ------------------
  326|    681|		if (elen < 3)
  ------------------
  |  Branch (326:7): [True: 299, False: 382]
  ------------------
  327|    299|			break;
  328|    382|		elems->fils_req_params = pos;
  329|    382|		elems->fils_req_params_len = elen;
  330|    382|		break;
  331|  1.44k|	case WLAN_EID_EXT_FILS_KEY_CONFIRM:
  ------------------
  |  |  510|  1.44k|#define WLAN_EID_EXT_FILS_KEY_CONFIRM 3
  ------------------
  |  Branch (331:2): [True: 1.44k, False: 51.4k]
  ------------------
  332|  1.44k|		elems->fils_key_confirm = pos;
  333|  1.44k|		elems->fils_key_confirm_len = elen;
  334|  1.44k|		break;
  335|    970|	case WLAN_EID_EXT_FILS_SESSION:
  ------------------
  |  |  511|    970|#define WLAN_EID_EXT_FILS_SESSION 4
  ------------------
  |  Branch (335:2): [True: 970, False: 51.9k]
  ------------------
  336|    970|		if (elen != FILS_SESSION_LEN)
  ------------------
  |  | 1063|    970|#define FILS_SESSION_LEN 8
  ------------------
  |  Branch (336:7): [True: 489, False: 481]
  ------------------
  337|    489|			break;
  338|    481|		elems->fils_session = pos;
  339|    481|		break;
  340|  1.64k|	case WLAN_EID_EXT_FILS_HLP_CONTAINER:
  ------------------
  |  |  512|  1.64k|#define WLAN_EID_EXT_FILS_HLP_CONTAINER 5
  ------------------
  |  Branch (340:2): [True: 1.64k, False: 51.2k]
  ------------------
  341|  1.64k|		if (elen < 2 * ETH_ALEN)
  ------------------
  |  |  344|  1.64k|#define ETH_ALEN 6
  ------------------
  |  Branch (341:7): [True: 677, False: 968]
  ------------------
  342|    677|			break;
  343|    968|		elems->fils_hlp = pos;
  344|    968|		elems->fils_hlp_len = elen;
  345|    968|		total_len = &elems->fils_hlp_len;
  346|    968|		break;
  347|    620|	case WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN:
  ------------------
  |  |  513|    620|#define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6
  ------------------
  |  Branch (347:2): [True: 620, False: 52.2k]
  ------------------
  348|    620|		if (elen < 1)
  ------------------
  |  Branch (348:7): [True: 206, False: 414]
  ------------------
  349|    206|			break;
  350|    414|		elems->fils_ip_addr_assign = pos;
  351|    414|		elems->fils_ip_addr_assign_len = elen;
  352|    414|		break;
  353|  1.79k|	case WLAN_EID_EXT_KEY_DELIVERY:
  ------------------
  |  |  514|  1.79k|#define WLAN_EID_EXT_KEY_DELIVERY 7
  ------------------
  |  Branch (353:2): [True: 1.79k, False: 51.0k]
  ------------------
  354|  1.79k|		if (elen < WPA_KEY_RSC_LEN)
  ------------------
  |  |   24|  1.79k|#define WPA_KEY_RSC_LEN 8
  ------------------
  |  Branch (354:7): [True: 281, False: 1.51k]
  ------------------
  355|    281|			break;
  356|  1.51k|		elems->key_delivery = pos;
  357|  1.51k|		elems->key_delivery_len = elen;
  358|  1.51k|		total_len = &elems->key_delivery_len;
  359|  1.51k|		break;
  360|    857|	case WLAN_EID_EXT_WRAPPED_DATA:
  ------------------
  |  |  515|    857|#define WLAN_EID_EXT_WRAPPED_DATA 8
  ------------------
  |  Branch (360:2): [True: 857, False: 52.0k]
  ------------------
  361|    857|		elems->wrapped_data = pos;
  362|    857|		elems->wrapped_data_len = elen;
  363|    857|		total_len = &elems->wrapped_data_len;
  364|    857|		break;
  365|    618|	case WLAN_EID_EXT_FILS_PUBLIC_KEY:
  ------------------
  |  |  519|    618|#define WLAN_EID_EXT_FILS_PUBLIC_KEY 12
  ------------------
  |  Branch (365:2): [True: 618, False: 52.2k]
  ------------------
  366|    618|		if (elen < 1)
  ------------------
  |  Branch (366:7): [True: 340, False: 278]
  ------------------
  367|    340|			break;
  368|    278|		elems->fils_pk = pos;
  369|    278|		elems->fils_pk_len = elen;
  370|    278|		break;
  371|    619|	case WLAN_EID_EXT_NONCE:
  ------------------
  |  |  520|    619|#define WLAN_EID_EXT_NONCE 13
  ------------------
  |  Branch (371:2): [True: 619, False: 52.2k]
  ------------------
  372|    619|		if (elen < NONCE_LEN)
  ------------------
  |  | 1062|    619|#define NONCE_LEN 16
  ------------------
  |  Branch (372:7): [True: 249, False: 370]
  ------------------
  373|    249|			break;
  374|    370|		elems->nonce = pos;
  375|    370|		elems->nonce_len = elen;
  376|    370|		break;
  377|    453|	case WLAN_EID_EXT_OWE_DH_PARAM:
  ------------------
  |  |  522|    453|#define WLAN_EID_EXT_OWE_DH_PARAM 32
  ------------------
  |  Branch (377:2): [True: 453, False: 52.4k]
  ------------------
  378|    453|		if (elen < 2)
  ------------------
  |  Branch (378:7): [True: 217, False: 236]
  ------------------
  379|    217|			break;
  380|    236|		elems->owe_dh = pos;
  381|    236|		elems->owe_dh_len = elen;
  382|    236|		break;
  383|    296|	case WLAN_EID_EXT_PASSWORD_IDENTIFIER:
  ------------------
  |  |  523|    296|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (383:2): [True: 296, False: 52.5k]
  ------------------
  384|    296|		elems->password_id = pos;
  385|    296|		elems->password_id_len = elen;
  386|    296|		break;
  387|    738|	case WLAN_EID_EXT_HE_CAPABILITIES:
  ------------------
  |  |  524|    738|#define WLAN_EID_EXT_HE_CAPABILITIES 35
  ------------------
  |  Branch (387:2): [True: 738, False: 52.1k]
  ------------------
  388|    738|		if (elen < HE_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2645|    738|#define HE_CAPABILITIES_ELEM_MIN_LEN		21
  ------------------
  |  Branch (388:7): [True: 386, False: 352]
  ------------------
  389|    386|			break;
  390|    352|		elems->he_capabilities = pos;
  391|    352|		elems->he_capabilities_len = elen;
  392|    352|		break;
  393|    564|	case WLAN_EID_EXT_HE_OPERATION:
  ------------------
  |  |  525|    564|#define WLAN_EID_EXT_HE_OPERATION 36
  ------------------
  |  Branch (393:2): [True: 564, False: 52.3k]
  ------------------
  394|    564|		if (elen < HE_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2699|    564|#define HE_OPERATION_ELEM_MIN_LEN				6
  ------------------
  |  Branch (394:7): [True: 245, False: 319]
  ------------------
  395|    245|			break;
  396|    319|		elems->he_operation = pos;
  397|    319|		elems->he_operation_len = elen;
  398|    319|		break;
  399|    228|	case WLAN_EID_EXT_OCV_OCI:
  ------------------
  |  |  530|    228|#define WLAN_EID_EXT_OCV_OCI 54
  ------------------
  |  Branch (399:2): [True: 228, False: 52.6k]
  ------------------
  400|    228|		elems->oci = pos;
  401|    228|		elems->oci_len = elen;
  402|    228|		break;
  403|    308|	case WLAN_EID_EXT_SHORT_SSID_LIST:
  ------------------
  |  |  534|    308|#define WLAN_EID_EXT_SHORT_SSID_LIST 58
  ------------------
  |  Branch (403:2): [True: 308, False: 52.5k]
  ------------------
  404|    308|		elems->short_ssid_list = pos;
  405|    308|		elems->short_ssid_list_len = elen;
  406|    308|		break;
  407|    459|	case WLAN_EID_EXT_HE_6GHZ_BAND_CAP:
  ------------------
  |  |  535|    459|#define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59
  ------------------
  |  Branch (407:2): [True: 459, False: 52.4k]
  ------------------
  408|    459|		if (elen < sizeof(struct ieee80211_he_6ghz_band_cap))
  ------------------
  |  Branch (408:7): [True: 210, False: 249]
  ------------------
  409|    210|			break;
  410|    249|		elems->he_6ghz_band_cap = pos;
  411|    249|		break;
  412|    314|	case WLAN_EID_EXT_PASN_PARAMS:
  ------------------
  |  |  542|    314|#define WLAN_EID_EXT_PASN_PARAMS 100
  ------------------
  |  Branch (412:2): [True: 314, False: 52.5k]
  ------------------
  413|    314|		elems->pasn_params = pos;
  414|    314|		elems->pasn_params_len = elen;
  415|    314|		break;
  416|    576|	case WLAN_EID_EXT_EHT_CAPABILITIES:
  ------------------
  |  |  545|    576|#define WLAN_EID_EXT_EHT_CAPABILITIES 108
  ------------------
  |  Branch (416:2): [True: 576, False: 52.3k]
  ------------------
  417|    576|		if (elen < EHT_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2846|    576|#define EHT_CAPABILITIES_ELEM_MIN_LEN             11
  ------------------
  |  Branch (417:7): [True: 309, False: 267]
  ------------------
  418|    309|			break;
  419|    267|		elems->eht_capabilities = pos;
  420|    267|		elems->eht_capabilities_len = elen;
  421|    267|		break;
  422|  3.44k|	case WLAN_EID_EXT_EHT_OPERATION:
  ------------------
  |  |  543|  3.44k|#define WLAN_EID_EXT_EHT_OPERATION 106
  ------------------
  |  Branch (422:2): [True: 3.44k, False: 49.4k]
  ------------------
  423|  3.44k|		if (elen < EHT_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2808|  3.44k|#define EHT_OPERATION_ELEM_MIN_LEN                       5
  ------------------
  |  Branch (423:7): [True: 3.14k, False: 292]
  ------------------
  424|  3.14k|			break;
  425|    292|		elems->eht_operation = pos;
  426|    292|		elems->eht_operation_len = elen;
  427|    292|		break;
  428|  3.65k|	case WLAN_EID_EXT_MULTI_LINK:
  ------------------
  |  |  544|  3.65k|#define WLAN_EID_EXT_MULTI_LINK 107
  ------------------
  |  Branch (428:2): [True: 3.65k, False: 49.2k]
  ------------------
  429|  3.65k|		if (elen < 2)
  ------------------
  |  Branch (429:7): [True: 256, False: 3.40k]
  ------------------
  430|    256|			break;
  431|  3.40k|		if (ieee802_11_parse_mle(pos, elen, &total_len, elems,
  ------------------
  |  Branch (431:7): [True: 317, False: 3.08k]
  ------------------
  432|  3.40k|					 show_errors))
  433|    317|			return -1;
  434|  3.08k|		break;
  435|  3.08k|	case WLAN_EID_EXT_KNOWN_BSSID:
  ------------------
  |  |  533|    296|#define WLAN_EID_EXT_KNOWN_BSSID 57
  ------------------
  |  Branch (435:2): [True: 296, False: 52.5k]
  ------------------
  436|    296|		elems->mbssid_known_bss = pos;
  437|    296|		elems->mbssid_known_bss_len = elen;
  438|    296|		break;
  439|    212|	case WLAN_EID_EXT_PASN_ENCRYPTED_DATA:
  ------------------
  |  |  552|    212|#define WLAN_EID_EXT_PASN_ENCRYPTED_DATA 140
  ------------------
  |  Branch (439:2): [True: 212, False: 52.6k]
  ------------------
  440|    212|		elems->pasn_encrypted_data = pos;
  441|    212|		elems->pasn_encrypted_data_len = elen;
  442|    212|		break;
  443|    496|	case WLAN_EID_EXT_AKM_SUITE_SELECTOR:
  ------------------
  |  |  549|    496|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (443:2): [True: 496, False: 52.3k]
  ------------------
  444|    496|		if (elen < RSN_SELECTOR_LEN)
  ------------------
  |  |   67|    496|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (444:7): [True: 212, False: 284]
  ------------------
  445|    212|			break;
  446|    284|		elems->akm_suite_selector = pos;
  447|    284|		elems->akm_suite_selector_len = elen;
  448|    284|		break;
  449|    765|	case WLAN_EID_EXT_SUPPORTED_GROUPS:
  ------------------
  |  |  562|    765|#define WLAN_EID_EXT_SUPPORTED_GROUPS 161
  ------------------
  |  Branch (449:2): [True: 765, False: 52.1k]
  ------------------
  450|    765|		if (elen < 2 || elen % 2 != 0)
  ------------------
  |  Branch (450:7): [True: 212, False: 553]
  |  Branch (450:19): [True: 274, False: 279]
  ------------------
  451|    486|			break;
  452|    279|		elems->supported_groups = pos;
  453|    279|		elems->supported_groups_len = elen;
  454|    279|		break;
  455|    230|	case WLAN_EID_EXT_UHR_CAPABILITIES:
  ------------------
  |  |  554|    230|#define WLAN_EID_EXT_UHR_CAPABILITIES 152
  ------------------
  |  Branch (455:2): [True: 230, False: 52.6k]
  ------------------
  456|    230|		elems->uhr_capabilities = pos;
  457|    230|		elems->uhr_capabilities_len = elen;
  458|    230|		break;
  459|    209|	case WLAN_EID_EXT_UHR_OPERATION:
  ------------------
  |  |  553|    209|#define WLAN_EID_EXT_UHR_OPERATION 151
  ------------------
  |  Branch (459:2): [True: 209, False: 52.6k]
  ------------------
  460|    209|		elems->uhr_operation = pos;
  461|    209|		elems->uhr_operation_len = elen;
  462|    209|		break;
  463|    478|	case WLAN_EID_EXT_SECURITY_PROFILE:
  ------------------
  |  |  563|    478|#define WLAN_EID_EXT_SECURITY_PROFILE 162
  ------------------
  |  Branch (463:2): [True: 478, False: 52.4k]
  ------------------
  464|    478|		if (elen < 2)
  ------------------
  |  Branch (464:7): [True: 223, False: 255]
  ------------------
  465|    223|			break;
  466|    255|		elems->security_profile = pos;
  467|    255|		elems->security_profile_len = elen;
  468|    255|		break;
  469|  29.0k|	default:
  ------------------
  |  Branch (469:2): [True: 29.0k, False: 23.8k]
  ------------------
  470|  29.0k|		if (show_errors) {
  ------------------
  |  Branch (470:7): [True: 0, False: 29.0k]
  ------------------
  471|      0|			wpa_printf(MSG_MSGDUMP,
  472|      0|				   "IEEE 802.11 element parsing ignored unknown element extension (ext_id=%u elen=%u)",
  473|      0|				   ext_id, (unsigned int) elen);
  474|      0|		}
  475|  29.0k|		return -1;
  476|  52.8k|	}
  477|       |
  478|  23.5k|	if (elen == 254 && total_len)
  ------------------
  |  Branch (478:6): [True: 2.08k, False: 21.4k]
  |  Branch (478:21): [True: 1.43k, False: 646]
  ------------------
  479|  1.43k|		*total_len += ieee802_11_fragments_length(
  480|  1.43k|			elems, pos + elen, (start + len) - (pos + elen));
  481|       |
  482|  23.5k|	return 0;
  483|  52.8k|}
ieee802_11_common.c:ieee802_11_parse_mle:
  240|  3.40k|{
  241|  3.40k|	u8 mle_type = pos[0] & MULTI_LINK_CONTROL_TYPE_MASK;
  ------------------
  |  | 2923|  3.40k|#define MULTI_LINK_CONTROL_TYPE_MASK			0x07
  ------------------
  242|       |
  243|  3.40k|	switch (mle_type) {
  244|    388|	case MULTI_LINK_CONTROL_TYPE_BASIC:
  ------------------
  |  | 2927|    388|#define MULTI_LINK_CONTROL_TYPE_BASIC			0
  ------------------
  |  Branch (244:2): [True: 388, False: 3.01k]
  ------------------
  245|    388|		elems->basic_mle = pos;
  246|    388|		elems->basic_mle_len = elen;
  247|    388|		*total_len = &elems->basic_mle_len;
  248|    388|		break;
  249|  1.43k|	case MULTI_LINK_CONTROL_TYPE_PROBE_REQ:
  ------------------
  |  | 2928|  1.43k|#define MULTI_LINK_CONTROL_TYPE_PROBE_REQ		1
  ------------------
  |  Branch (249:2): [True: 1.43k, False: 1.97k]
  ------------------
  250|  1.43k|		elems->probe_req_mle = pos;
  251|  1.43k|		elems->probe_req_mle_len = elen;
  252|  1.43k|		*total_len = &elems->probe_req_mle_len;
  253|  1.43k|		break;
  254|    415|	case MULTI_LINK_CONTROL_TYPE_RECONF:
  ------------------
  |  | 2929|    415|#define MULTI_LINK_CONTROL_TYPE_RECONF			2
  ------------------
  |  Branch (254:2): [True: 415, False: 2.98k]
  ------------------
  255|    415|		elems->reconf_mle = pos;
  256|    415|		elems->reconf_mle_len = elen;
  257|    415|		*total_len = &elems->reconf_mle_len;
  258|    415|		break;
  259|    335|	case MULTI_LINK_CONTROL_TYPE_TDLS:
  ------------------
  |  | 2930|    335|#define MULTI_LINK_CONTROL_TYPE_TDLS			3
  ------------------
  |  Branch (259:2): [True: 335, False: 3.06k]
  ------------------
  260|    335|		elems->tdls_mle = pos;
  261|    335|		elems->tdls_mle_len = elen;
  262|    335|		*total_len = &elems->tdls_mle_len;
  263|    335|		break;
  264|    518|	case MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS:
  ------------------
  |  | 2931|    518|#define MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS		4
  ------------------
  |  Branch (264:2): [True: 518, False: 2.88k]
  ------------------
  265|    518|		elems->prior_access_mle = pos;
  266|    518|		elems->prior_access_mle_len = elen;
  267|    518|		*total_len = &elems->prior_access_mle_len;
  268|    518|		break;
  269|    317|	default:
  ------------------
  |  Branch (269:2): [True: 317, False: 3.08k]
  ------------------
  270|    317|		if (show_errors) {
  ------------------
  |  Branch (270:7): [True: 0, False: 317]
  ------------------
  271|      0|			wpa_printf(MSG_MSGDUMP,
  272|      0|				   "Unknown Multi-Link element type %u",
  273|      0|				   mle_type);
  274|      0|		}
  275|    317|		return -1;
  276|  3.40k|	}
  277|       |
  278|  3.08k|	return 0;
  279|  3.40k|}
ieee802_11_common.c:ieee802_11_fragments_length:
  284|  3.17k|{
  285|  3.17k|	const struct element *elem;
  286|  3.17k|	size_t frags_len = 0;
  287|       |
  288|   430k|	for_each_element(elem, start, len) {
  ------------------
  |  |  395|  3.17k|	for (_elem = (const struct element *) (_data);			\
  |  |  396|   430k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (396:7): [True: 430k, False: 84]
  |  |  ------------------
  |  |  397|   430k|		(int) sizeof(*_elem) &&					\
  |  |  398|   430k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (398:7): [True: 430k, False: 19]
  |  |  ------------------
  |  |  399|   430k|		(int) element_hdr_size(_elem) &&			\
  |  |  400|   430k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (400:7): [True: 430k, False: 148]
  |  |  ------------------
  |  |  401|   430k|		(int) (element_hdr_size(_elem) +			\
  |  |  402|   430k|		       element_datalen(_elem));				\
  |  |  403|   427k|	     _elem = element_next(_elem))
  ------------------
  289|   430k|		if (elem->id != WLAN_EID_FRAGMENT)
  ------------------
  |  |  503|   430k|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (289:7): [True: 2.92k, False: 427k]
  ------------------
  290|  2.92k|			break;
  291|       |
  292|   427k|		frags_len += elem->datalen + 2;
  293|   427k|		elems->num_frag_elems++;
  294|   427k|	}
  295|       |
  296|  3.17k|	return frags_len;
  297|  3.17k|}
ieee802_11_common.c:country_match:
 1885|  2.24k|{
 1886|  2.24k|	int i;
 1887|       |
 1888|  2.24k|	if (country == NULL)
  ------------------
  |  Branch (1888:6): [True: 2.24k, False: 0]
  ------------------
 1889|  2.24k|		return 0;
 1890|      0|	for (i = 0; cc[i]; i++) {
  ------------------
  |  Branch (1890:14): [True: 0, False: 0]
  ------------------
 1891|      0|		if (cc[i][0] == country[0] && cc[i][1] == country[1])
  ------------------
  |  Branch (1891:7): [True: 0, False: 0]
  |  Branch (1891:33): [True: 0, False: 0]
  ------------------
 1892|      0|			return 1;
 1893|      0|	}
 1894|       |
 1895|      0|	return 0;
 1896|      0|}
ieee802_11_common.c:ieee80211_chan_to_freq_global:
 2093|    562|{
 2094|       |	/* Table E-4 in IEEE Std 802.11-2020 - Global operating classes */
 2095|    562|	switch (op_class) {
 2096|     47|	case 81:
  ------------------
  |  Branch (2096:2): [True: 47, False: 515]
  ------------------
 2097|       |		/* channels 1..13 */
 2098|     47|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2098:7): [True: 3, False: 44]
  |  Branch (2098:19): [True: 8, False: 36]
  ------------------
 2099|     11|			return -1;
 2100|     36|		return 2407 + 5 * chan;
 2101|     10|	case 82:
  ------------------
  |  Branch (2101:2): [True: 10, False: 552]
  ------------------
 2102|       |		/* channel 14 */
 2103|     10|		if (chan != 14)
  ------------------
  |  Branch (2103:7): [True: 7, False: 3]
  ------------------
 2104|      7|			return -1;
 2105|      3|		return 2414 + 5 * chan;
 2106|     12|	case 83: /* channels 1..9; 40 MHz */
  ------------------
  |  Branch (2106:2): [True: 12, False: 550]
  ------------------
 2107|     24|	case 84: /* channels 5..13; 40 MHz */
  ------------------
  |  Branch (2107:2): [True: 12, False: 550]
  ------------------
 2108|     24|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2108:7): [True: 3, False: 21]
  |  Branch (2108:19): [True: 8, False: 13]
  ------------------
 2109|     11|			return -1;
 2110|     13|		return 2407 + 5 * chan;
 2111|      4|	case 115: /* channels 36,40,44,48; indoor only */
  ------------------
  |  Branch (2111:2): [True: 4, False: 558]
  ------------------
 2112|     13|	case 116: /* channels 36,44; 40 MHz; indoor only */
  ------------------
  |  Branch (2112:2): [True: 9, False: 553]
  ------------------
 2113|     17|	case 117: /* channels 40,48; 40 MHz; indoor only */
  ------------------
  |  Branch (2113:2): [True: 4, False: 558]
  ------------------
 2114|     22|	case 118: /* channels 52,56,60,64; dfs */
  ------------------
  |  Branch (2114:2): [True: 5, False: 557]
  ------------------
 2115|     37|	case 119: /* channels 52,60; 40 MHz; dfs */
  ------------------
  |  Branch (2115:2): [True: 15, False: 547]
  ------------------
 2116|     43|	case 120: /* channels 56,64; 40 MHz; dfs */
  ------------------
  |  Branch (2116:2): [True: 6, False: 556]
  ------------------
 2117|     43|		if (chan < 36 || chan > 64)
  ------------------
  |  Branch (2117:7): [True: 21, False: 22]
  |  Branch (2117:20): [True: 13, False: 9]
  ------------------
 2118|     34|			return -1;
 2119|      9|		return 5000 + 5 * chan;
 2120|      9|	case 121: /* channels 100-144 */
  ------------------
  |  Branch (2120:2): [True: 9, False: 553]
  ------------------
 2121|     22|	case 122: /* channels 100-140; 40 MHz */
  ------------------
  |  Branch (2121:2): [True: 13, False: 549]
  ------------------
 2122|     31|	case 123: /* channels 104-144; 40 MHz */
  ------------------
  |  Branch (2122:2): [True: 9, False: 553]
  ------------------
 2123|     31|		if (chan < 100 || chan > 144)
  ------------------
  |  Branch (2123:7): [True: 8, False: 23]
  |  Branch (2123:21): [True: 8, False: 15]
  ------------------
 2124|     16|			return -1;
 2125|     15|		return 5000 + 5 * chan;
 2126|     23|	case 124: /* channels 149,153,157,161 */
  ------------------
  |  Branch (2126:2): [True: 23, False: 539]
  ------------------
 2127|     23|		if (chan < 149 || chan > 161)
  ------------------
  |  Branch (2127:7): [True: 13, False: 10]
  |  Branch (2127:21): [True: 4, False: 6]
  ------------------
 2128|     17|			return -1;
 2129|      6|		return 5000 + 5 * chan;
 2130|      5|	case 125: /* channels 149,153,157,161,165,169,173,177 */
  ------------------
  |  Branch (2130:2): [True: 5, False: 557]
  ------------------
 2131|     15|	case 126: /* channels 149,157,165,173; 40 MHz */
  ------------------
  |  Branch (2131:2): [True: 10, False: 552]
  ------------------
 2132|     25|	case 127: /* channels 153,161,169,177; 40 MHz */
  ------------------
  |  Branch (2132:2): [True: 10, False: 552]
  ------------------
 2133|     25|		if (chan < 149 || chan > 177)
  ------------------
  |  Branch (2133:7): [True: 8, False: 17]
  |  Branch (2133:21): [True: 6, False: 11]
  ------------------
 2134|     14|			return -1;
 2135|     11|		return 5000 + 5 * chan;
 2136|     20|	case 128: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2136:2): [True: 20, False: 542]
  ------------------
 2137|     31|	case 130: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2137:2): [True: 11, False: 551]
  ------------------
 2138|     31|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2138:7): [True: 7, False: 24]
  |  Branch (2138:20): [True: 5, False: 19]
  ------------------
 2139|     12|			return -1;
 2140|     19|		return 5000 + 5 * chan;
 2141|     20|	case 129: /* center freqs 50, 114, 163; 160 MHz */
  ------------------
  |  Branch (2141:2): [True: 20, False: 542]
  ------------------
 2142|     20|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2142:7): [True: 4, False: 16]
  |  Branch (2142:20): [True: 3, False: 13]
  ------------------
 2143|      7|			return -1;
 2144|     13|		return 5000 + 5 * chan;
 2145|      6|	case 131: /* UHB channels, 20 MHz: 1, 5, 9.. */
  ------------------
  |  Branch (2145:2): [True: 6, False: 556]
  ------------------
 2146|     13|	case 132: /* UHB channels, 40 MHz: 3, 11, 19.. */
  ------------------
  |  Branch (2146:2): [True: 7, False: 555]
  ------------------
 2147|     21|	case 133: /* UHB channels, 80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2147:2): [True: 8, False: 554]
  ------------------
 2148|     27|	case 134: /* UHB channels, 160 MHz: 15, 47, 79.. */
  ------------------
  |  Branch (2148:2): [True: 6, False: 556]
  ------------------
 2149|     34|	case 135: /* UHB channels, 80+80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2149:2): [True: 7, False: 555]
  ------------------
 2150|     42|	case 137: /* UHB channels, 320 MHz: 31, 63, 95, 127, 159, 191 */
  ------------------
  |  Branch (2150:2): [True: 8, False: 554]
  ------------------
 2151|     42|		if (chan < 1 || chan > 233)
  ------------------
  |  Branch (2151:7): [True: 5, False: 37]
  |  Branch (2151:19): [True: 6, False: 31]
  ------------------
 2152|     11|			return -1;
 2153|     31|		return 5950 + chan * 5;
 2154|     14|	case 136: /* UHB channels, 20 MHz: 2 */
  ------------------
  |  Branch (2154:2): [True: 14, False: 548]
  ------------------
 2155|     14|		if (chan == 2)
  ------------------
  |  Branch (2155:7): [True: 6, False: 8]
  ------------------
 2156|      6|			return 5935;
 2157|      8|		return -1;
 2158|     20|	case 180: /* 60 GHz band, channels 1..8 */
  ------------------
  |  Branch (2158:2): [True: 20, False: 542]
  ------------------
 2159|     20|		if (chan < 1 || chan > 8)
  ------------------
  |  Branch (2159:7): [True: 3, False: 17]
  |  Branch (2159:19): [True: 9, False: 8]
  ------------------
 2160|     12|			return -1;
 2161|      8|		return 56160 + 2160 * chan;
 2162|     25|	case 181: /* 60 GHz band, EDMG CB2, channels 9..15 */
  ------------------
  |  Branch (2162:2): [True: 25, False: 537]
  ------------------
 2163|     25|		if (chan < 9 || chan > 15)
  ------------------
  |  Branch (2163:7): [True: 6, False: 19]
  |  Branch (2163:19): [True: 9, False: 10]
  ------------------
 2164|     15|			return -1;
 2165|     10|		return 56160 + 2160 * (chan - 8);
 2166|     42|	case 182: /* 60 GHz band, EDMG CB3, channels 17..22 */
  ------------------
  |  Branch (2166:2): [True: 42, False: 520]
  ------------------
 2167|     42|		if (chan < 17 || chan > 22)
  ------------------
  |  Branch (2167:7): [True: 6, False: 36]
  |  Branch (2167:20): [True: 24, False: 12]
  ------------------
 2168|     30|			return -1;
 2169|     12|		return 56160 + 2160 * (chan - 16);
 2170|     22|	case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */
  ------------------
  |  Branch (2170:2): [True: 22, False: 540]
  ------------------
 2171|     22|		if (chan < 25 || chan > 29)
  ------------------
  |  Branch (2171:7): [True: 8, False: 14]
  |  Branch (2171:20): [True: 7, False: 7]
  ------------------
 2172|     15|			return -1;
 2173|      7|		return 56160 + 2160 * (chan - 24);
 2174|    143|	default:
  ------------------
  |  Branch (2174:2): [True: 143, False: 419]
  ------------------
 2175|    143|		return -1;
 2176|    562|	}
 2177|    562|}

ieee802_11_common.c:element_hdr_size:
   29|   372M|{
   30|   372M|	if (elem->id == WLAN_EID_EXT_LENGTH)
  ------------------
  |  |  498|   372M|#define WLAN_EID_EXT_LENGTH 227
  ------------------
  |  Branch (30:6): [True: 25.1k, False: 372M]
  ------------------
   31|  25.1k|		return sizeof(struct ext_len_element);
   32|   372M|	return sizeof(struct element);
   33|   372M|}
ieee802_11_common.c:element_datalen:
   36|   372M|{
   37|   372M|	if (elem->id == WLAN_EID_EXT_LENGTH)
  ------------------
  |  |  498|   372M|#define WLAN_EID_EXT_LENGTH 227
  ------------------
  |  Branch (37:6): [True: 24.3k, False: 372M]
  ------------------
   38|  24.3k|		return le_to_host16(
  ------------------
  |  |  175|  24.3k|#define le_to_host16(n) ((__force u16) (le16) (n))
  ------------------
   39|   372M|			((const struct ext_len_element *) elem)->datalen);
   40|   372M|	return elem->datalen;
   41|   372M|}
ieee802_11_common.c:element_next:
   51|   186M|{
   52|   186M|	return (const struct element *)(element_data(elem) +
   53|   186M|					element_datalen(elem));
   54|   186M|}
ieee802_11_common.c:element_data:
   44|   186M|{
   45|   186M|	if (elem->id == WLAN_EID_EXT_LENGTH)
  ------------------
  |  |  498|   186M|#define WLAN_EID_EXT_LENGTH 227
  ------------------
  |  Branch (45:6): [True: 11.8k, False: 186M]
  ------------------
   46|  11.8k|		return ((const struct ext_len_element *) elem)->data;
   47|   186M|	return elem->data;
   48|   186M|}
ieee802_11_common.c:for_each_element_completed:
  439|  24.8k|{
  440|  24.8k|	return (const u8 *) element == (const u8 *) data + datalen;
  441|  24.8k|}

sha256_vector:
   27|  6.88k|{
   28|  6.88k|	struct sha256_state ctx;
   29|  6.88k|	size_t i;
   30|       |
   31|  6.88k|	if (TEST_FAIL())
  ------------------
  |  |  727|  6.88k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (727:21): [True: 0, False: 6.88k]
  |  |  ------------------
  ------------------
   32|      0|		return -1;
   33|       |
   34|  6.88k|	sha256_init(&ctx);
   35|  13.7k|	for (i = 0; i < num_elem; i++)
  ------------------
  |  Branch (35:14): [True: 6.88k, False: 6.88k]
  ------------------
   36|  6.88k|		if (sha256_process(&ctx, addr[i], len[i]))
  ------------------
  |  Branch (36:7): [True: 0, False: 6.88k]
  ------------------
   37|      0|			return -1;
   38|  6.88k|	if (sha256_done(&ctx, mac))
  ------------------
  |  Branch (38:6): [True: 0, False: 6.88k]
  ------------------
   39|      0|		return -1;
   40|  6.88k|	return 0;
   41|  6.88k|}
sha256_init:
  125|  6.88k|{
  126|  6.88k|	md->curlen = 0;
  127|  6.88k|	md->length = 0;
  128|  6.88k|	md->state[0] = 0x6A09E667UL;
  129|  6.88k|	md->state[1] = 0xBB67AE85UL;
  130|  6.88k|	md->state[2] = 0x3C6EF372UL;
  131|  6.88k|	md->state[3] = 0xA54FF53AUL;
  132|  6.88k|	md->state[4] = 0x510E527FUL;
  133|  6.88k|	md->state[5] = 0x9B05688CUL;
  134|  6.88k|	md->state[6] = 0x1F83D9ABUL;
  135|  6.88k|	md->state[7] = 0x5BE0CD19UL;
  136|  6.88k|}
sha256_process:
  147|  6.88k|{
  148|  6.88k|	unsigned long n;
  149|       |
  150|  6.88k|	if (md->curlen >= sizeof(md->buf))
  ------------------
  |  Branch (150:6): [True: 0, False: 6.88k]
  ------------------
  151|      0|		return -1;
  152|       |
  153|  13.7k|	while (inlen > 0) {
  ------------------
  |  Branch (153:9): [True: 6.88k, False: 6.88k]
  ------------------
  154|  6.88k|		if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) {
  ------------------
  |  |   12|  6.88k|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (154:7): [True: 6.88k, False: 0]
  |  Branch (154:26): [True: 0, False: 6.88k]
  ------------------
  155|      0|			if (sha256_compress(md, (unsigned char *) in) < 0)
  ------------------
  |  Branch (155:8): [True: 0, False: 0]
  ------------------
  156|      0|				return -1;
  157|      0|			md->length += SHA256_BLOCK_SIZE * 8;
  ------------------
  |  |   12|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  158|      0|			in += SHA256_BLOCK_SIZE;
  ------------------
  |  |   12|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  159|      0|			inlen -= SHA256_BLOCK_SIZE;
  ------------------
  |  |   12|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  160|  6.88k|		} else {
  161|  6.88k|			n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen));
  ------------------
  |  |  468|  6.88k|#define MIN(a, b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (468:20): [True: 6.88k, False: 0]
  |  |  ------------------
  ------------------
  162|  6.88k|			os_memcpy(md->buf + md->curlen, in, n);
  ------------------
  |  |  523|  6.88k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  163|  6.88k|			md->curlen += n;
  164|  6.88k|			in += n;
  165|  6.88k|			inlen -= n;
  166|  6.88k|			if (md->curlen == SHA256_BLOCK_SIZE) {
  ------------------
  |  |   12|  6.88k|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (166:8): [True: 0, False: 6.88k]
  ------------------
  167|      0|				if (sha256_compress(md, md->buf) < 0)
  ------------------
  |  Branch (167:9): [True: 0, False: 0]
  ------------------
  168|      0|					return -1;
  169|      0|				md->length += 8 * SHA256_BLOCK_SIZE;
  ------------------
  |  |   12|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  170|      0|				md->curlen = 0;
  171|      0|			}
  172|  6.88k|		}
  173|  6.88k|	}
  174|       |
  175|  6.88k|	return 0;
  176|  6.88k|}
sha256_done:
  186|  6.88k|{
  187|  6.88k|	int i;
  188|       |
  189|  6.88k|	if (md->curlen >= sizeof(md->buf))
  ------------------
  |  Branch (189:6): [True: 0, False: 6.88k]
  ------------------
  190|      0|		return -1;
  191|       |
  192|       |	/* increase the length of the message */
  193|  6.88k|	md->length += md->curlen * 8;
  194|       |
  195|       |	/* append the '1' bit */
  196|  6.88k|	md->buf[md->curlen++] = (unsigned char) 0x80;
  197|       |
  198|       |	/* if the length is currently above 56 bytes we append zeros
  199|       |	 * then compress.  Then we can fall back to padding zeros and length
  200|       |	 * encoding like normal.
  201|       |	 */
  202|  6.88k|	if (md->curlen > 56) {
  ------------------
  |  Branch (202:6): [True: 0, False: 6.88k]
  ------------------
  203|      0|		while (md->curlen < SHA256_BLOCK_SIZE) {
  ------------------
  |  |   12|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (203:10): [True: 0, False: 0]
  ------------------
  204|      0|			md->buf[md->curlen++] = (unsigned char) 0;
  205|      0|		}
  206|      0|		sha256_compress(md, md->buf);
  207|      0|		md->curlen = 0;
  208|      0|	}
  209|       |
  210|       |	/* pad up to 56 bytes of zeroes */
  211|   288k|	while (md->curlen < 56) {
  ------------------
  |  Branch (211:9): [True: 282k, False: 6.88k]
  ------------------
  212|   282k|		md->buf[md->curlen++] = (unsigned char) 0;
  213|   282k|	}
  214|       |
  215|       |	/* store length */
  216|  6.88k|	WPA_PUT_BE64(md->buf + 56, md->length);
  217|  6.88k|	sha256_compress(md, md->buf);
  218|       |
  219|       |	/* copy output */
  220|  61.9k|	for (i = 0; i < 8; i++)
  ------------------
  |  Branch (220:14): [True: 55.0k, False: 6.88k]
  ------------------
  221|  55.0k|		WPA_PUT_BE32(out + (4 * i), md->state[i]);
  222|       |
  223|  6.88k|	return 0;
  224|  6.88k|}
sha256-internal.c:sha256_compress:
   82|  6.88k|{
   83|  6.88k|	u32 S[8], W[64], t0, t1;
   84|  6.88k|	u32 t;
   85|  6.88k|	int i;
   86|       |
   87|       |	/* copy state into S */
   88|  61.9k|	for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (88:14): [True: 55.0k, False: 6.88k]
  ------------------
   89|  55.0k|		S[i] = md->state[i];
   90|  55.0k|	}
   91|       |
   92|       |	/* copy the state into 512-bits into W[0..15] */
   93|   116k|	for (i = 0; i < 16; i++)
  ------------------
  |  Branch (93:14): [True: 110k, False: 6.88k]
  ------------------
   94|   110k|		W[i] = WPA_GET_BE32(buf + (4 * i));
   95|       |
   96|       |	/* fill W[16..63] */
   97|   337k|	for (i = 16; i < 64; i++) {
  ------------------
  |  Branch (97:15): [True: 330k, False: 6.88k]
  ------------------
   98|   330k|		W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
  ------------------
  |  |   78|   330k|#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   73|   330k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   330k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   330k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   330k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   73|   330k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   330k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   330k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   330k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   74|   330k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
              		W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
  ------------------
  |  |   77|   330k|#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   73|   330k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   330k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   330k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   330k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   73|   330k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   330k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   330k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   330k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   74|   330k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
   99|   330k|			W[i - 16];
  100|   330k|	}
  101|       |
  102|       |	/* Compress */
  103|  6.88k|#define RND(a,b,c,d,e,f,g,h,i)                          \
  104|  6.88k|	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  105|  6.88k|	t1 = Sigma0(a) + Maj(a, b, c);			\
  106|  6.88k|	d += t0;					\
  107|  6.88k|	h  = t0 + t1;
  108|       |
  109|   447k|	for (i = 0; i < 64; ++i) {
  ------------------
  |  Branch (109:14): [True: 440k, False: 6.88k]
  ------------------
  110|   440k|		RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
  ------------------
  |  |  104|   440k|	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  |  |  ------------------
  |  |  |  |   76|   440k|#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  |  |  ------------------
  |  |  |  |   71|   440k|#define Ch(x,y,z)       (z ^ (x & (y ^ z)))
  |  |  ------------------
  |  |  105|   440k|	t1 = Sigma0(a) + Maj(a, b, c);			\
  |  |  ------------------
  |  |  |  |   75|   440k|#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   440k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   440k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   440k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   440k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	t1 = Sigma0(a) + Maj(a, b, c);			\
  |  |  ------------------
  |  |  |  |   72|   440k|#define Maj(x,y,z)      (((x | y) & z) | (x & y))
  |  |  ------------------
  |  |  106|   440k|	d += t0;					\
  |  |  107|   440k|	h  = t0 + t1;
  ------------------
  111|   440k|		t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
  112|   440k|		S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
  113|   440k|	}
  114|       |
  115|       |	/* feedback */
  116|  61.9k|	for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (116:14): [True: 55.0k, False: 6.88k]
  ------------------
  117|  55.0k|		md->state[i] = md->state[i] + S[i];
  118|  55.0k|	}
  119|  6.88k|	return 0;
  120|  6.88k|}

p2p_set_state:
  193|  6.88k|{
  194|  6.88k|	p2p_dbg(p2p, "State %s -> %s",
  195|  6.88k|		p2p_state_txt(p2p->state), p2p_state_txt(new_state));
  196|  6.88k|	p2p->state = new_state;
  197|       |
  198|  6.88k|	if (new_state == P2P_IDLE && p2p->pending_channel) {
  ------------------
  |  Branch (198:6): [True: 6.88k, False: 0]
  |  Branch (198:31): [True: 0, False: 6.88k]
  ------------------
  199|      0|		p2p_dbg(p2p, "Apply change in listen channel");
  200|      0|		p2p->cfg->reg_class = p2p->pending_reg_class;
  201|      0|		p2p->cfg->channel = p2p->pending_channel;
  202|      0|		p2p->pending_reg_class = 0;
  203|      0|		p2p->pending_channel = 0;
  204|      0|	}
  205|  6.88k|}
p2p_clear_timeout:
  218|  6.88k|{
  219|  6.88k|	p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state));
  220|       |	eloop_cancel_timeout(p2p_state_timeout, p2p, NULL);
  221|  6.88k|}
p2p_get_device:
  392|  5.43k|{
  393|  5.43k|	struct p2p_device *dev;
  394|  5.43k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  5.43k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  5.43k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  7.87k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 3.47k, False: 4.39k]
  |  |  ------------------
  |  |   81|  5.43k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  2.43k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  395|  3.47k|		if (ether_addr_equal(dev->info.p2p_device_addr, addr))
  ------------------
  |  Branch (395:7): [True: 1.04k, False: 2.43k]
  ------------------
  396|  1.04k|			return dev;
  397|  3.47k|	}
  398|  4.39k|	return NULL;
  399|  5.43k|}
p2p_update_peer_6ghz_capab:
  653|  2.65k|{
  654|  2.65k|	if (msg->capability &&
  ------------------
  |  Branch (654:6): [True: 277, False: 2.37k]
  ------------------
  655|    277|	    (msg->capability[0] & P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE))
  ------------------
  |  | 1916|    277|#define P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE BIT(6)
  |  |  ------------------
  |  |  |  |  458|    277|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (655:6): [True: 101, False: 176]
  ------------------
  656|    101|		dev->support_6ghz = true;
  657|  2.65k|}
p2p_add_device:
  741|  8.27k|{
  742|  8.27k|	struct p2p_device *dev;
  743|  8.27k|	struct p2p_message msg;
  744|  8.27k|	const u8 *p2p_dev_addr;
  745|  8.27k|	int wfd_changed;
  746|  8.27k|	int dev_name_changed;
  747|  8.27k|	int i;
  748|  8.27k|	struct os_reltime time_now;
  749|       |
  750|  8.27k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  8.27k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  751|  8.27k|	if (p2p_parse_ies(ies, ies_len, &msg)) {
  ------------------
  |  Branch (751:6): [True: 2.47k, False: 5.79k]
  ------------------
  752|  2.47k|		p2p_dbg(p2p, "Failed to parse P2P IE for a device entry");
  753|  2.47k|		p2p_parse_free(&msg);
  754|  2.47k|		return -1;
  755|  2.47k|	}
  756|       |
  757|  5.79k|	if (msg.p2p_device_addr)
  ------------------
  |  Branch (757:6): [True: 509, False: 5.28k]
  ------------------
  758|    509|		p2p_dev_addr = msg.p2p_device_addr;
  759|  5.28k|	else if (msg.device_id)
  ------------------
  |  Branch (759:11): [True: 1.44k, False: 3.83k]
  ------------------
  760|  1.44k|		p2p_dev_addr = msg.device_id;
  761|  3.83k|	else {
  762|  3.83k|		p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id");
  763|  3.83k|		p2p_parse_free(&msg);
  764|  3.83k|		return -1;
  765|  3.83k|	}
  766|       |
  767|  1.95k|	if (!is_zero_ether_addr(p2p->peer_filter) &&
  ------------------
  |  Branch (767:6): [True: 0, False: 1.95k]
  ------------------
  768|      0|	    !ether_addr_equal(p2p_dev_addr, p2p->peer_filter)) {
  ------------------
  |  Branch (768:6): [True: 0, False: 0]
  ------------------
  769|      0|		p2p_dbg(p2p, "Do not add peer filter for " MACSTR
  770|      0|			" due to peer filter", MAC2STR(p2p_dev_addr));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  771|      0|		p2p_parse_free(&msg);
  772|      0|		return 0;
  773|      0|	}
  774|       |
  775|  1.95k|	dev = p2p_create_device(p2p, p2p_dev_addr);
  776|  1.95k|	if (dev == NULL) {
  ------------------
  |  Branch (776:6): [True: 0, False: 1.95k]
  ------------------
  777|      0|		p2p_parse_free(&msg);
  778|      0|		return -1;
  779|      0|	}
  780|       |
  781|  1.95k|	if (rx_time == NULL) {
  ------------------
  |  Branch (781:6): [True: 617, False: 1.34k]
  ------------------
  782|    617|		os_get_reltime(&time_now);
  783|    617|		rx_time = &time_now;
  784|    617|	}
  785|       |
  786|       |	/*
  787|       |	 * Update the device entry only if the new peer
  788|       |	 * entry is newer than the one previously stored, or if
  789|       |	 * the device was previously seen as a P2P Client in a group
  790|       |	 * and the new entry isn't older than a threshold.
  791|       |	 */
  792|  1.95k|	if (dev->last_seen.sec > 0 &&
  ------------------
  |  Branch (792:6): [True: 72, False: 1.88k]
  ------------------
  793|     72|	    os_reltime_before(rx_time, &dev->last_seen) &&
  ------------------
  |  Branch (793:6): [True: 0, False: 72]
  ------------------
  794|      0|	    (!(dev->flags & P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT) ||
  ------------------
  |  |  147|      0|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (794:7): [True: 0, False: 0]
  ------------------
  795|      0|	     os_reltime_expired(&dev->last_seen, rx_time,
  ------------------
  |  Branch (795:7): [True: 0, False: 0]
  ------------------
  796|      0|				P2P_DEV_GROUP_CLIENT_RESP_THRESHOLD))) {
  ------------------
  |  |   22|      0|#define P2P_DEV_GROUP_CLIENT_RESP_THRESHOLD 1
  ------------------
  797|      0|		p2p_dbg(p2p,
  798|      0|			"Do not update peer entry based on old frame (rx_time=%u.%06u last_seen=%u.%06u flags=0x%x)",
  799|      0|			(unsigned int) rx_time->sec,
  800|      0|			(unsigned int) rx_time->usec,
  801|      0|			(unsigned int) dev->last_seen.sec,
  802|      0|			(unsigned int) dev->last_seen.usec,
  803|      0|			dev->flags);
  804|      0|		p2p_parse_free(&msg);
  805|      0|		return -1;
  806|      0|	}
  807|       |
  808|  1.95k|	os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|  1.95k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  809|       |
  810|  1.95k|	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  127|  1.95k|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|  1.95k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|  1.95k|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|  1.95k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  811|  1.95k|			P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT);
  ------------------
  |  |  147|  1.95k|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|  1.95k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  812|       |
  813|  1.95k|	if (!ether_addr_equal(addr, p2p_dev_addr))
  ------------------
  |  Branch (813:6): [True: 1.73k, False: 224]
  ------------------
  814|  1.73k|		os_memcpy(dev->interface_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.73k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  815|  1.95k|	if (msg.ssid &&
  ------------------
  |  Branch (815:6): [True: 815, False: 1.14k]
  ------------------
  816|    815|	    msg.ssid[1] <= sizeof(dev->oper_ssid) &&
  ------------------
  |  Branch (816:6): [True: 815, False: 0]
  ------------------
  817|    815|	    (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1994|  1.63k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (817:7): [True: 532, False: 283]
  ------------------
  818|    283|	     os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    283|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (818:7): [True: 63, False: 220]
  ------------------
  819|    595|	     != 0)) {
  820|    595|		os_memcpy(dev->oper_ssid, msg.ssid + 2, msg.ssid[1]);
  ------------------
  |  |  523|    595|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  821|    595|		dev->oper_ssid_len = msg.ssid[1];
  822|    595|	}
  823|       |
  824|  1.95k|	wpabuf_free(dev->info.p2ps_instance);
  825|  1.95k|	dev->info.p2ps_instance = NULL;
  826|  1.95k|	if (msg.adv_service_instance && msg.adv_service_instance_len)
  ------------------
  |  Branch (826:6): [True: 19, False: 1.93k]
  |  Branch (826:34): [True: 19, False: 0]
  ------------------
  827|     19|		dev->info.p2ps_instance = wpabuf_alloc_copy(
  828|     19|			msg.adv_service_instance, msg.adv_service_instance_len);
  829|       |
  830|  1.95k|	if (freq >= 2412 && freq <= 2484 && msg.ds_params &&
  ------------------
  |  Branch (830:6): [True: 1.95k, False: 0]
  |  Branch (830:22): [True: 1.95k, False: 0]
  |  Branch (830:38): [True: 198, False: 1.75k]
  ------------------
  831|    198|	    *msg.ds_params >= 1 && *msg.ds_params <= 14) {
  ------------------
  |  Branch (831:6): [True: 141, False: 57]
  |  Branch (831:29): [True: 105, False: 36]
  ------------------
  832|    105|		int ds_freq;
  833|    105|		if (*msg.ds_params == 14)
  ------------------
  |  Branch (833:7): [True: 16, False: 89]
  ------------------
  834|     16|			ds_freq = 2484;
  835|     89|		else
  836|     89|			ds_freq = 2407 + *msg.ds_params * 5;
  837|    105|		if (freq != ds_freq) {
  ------------------
  |  Branch (837:7): [True: 89, False: 16]
  ------------------
  838|     89|			p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz",
  839|     89|				freq, ds_freq);
  840|     89|			freq = ds_freq;
  841|     89|		}
  842|    105|	}
  843|       |
  844|  1.95k|	if (dev->listen_freq && dev->listen_freq != freq && scan_res) {
  ------------------
  |  Branch (844:6): [True: 471, False: 1.48k]
  |  Branch (844:26): [True: 58, False: 413]
  |  Branch (844:54): [True: 0, False: 58]
  ------------------
  845|      0|		p2p_dbg(p2p, "Update Listen frequency based on scan results ("
  846|      0|			MACSTR " %d -> %d MHz (DS param %d)",
  847|      0|			MAC2STR(dev->info.p2p_device_addr), dev->listen_freq,
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  848|      0|			freq, msg.ds_params ? *msg.ds_params : -1);
  ------------------
  |  Branch (848:10): [True: 0, False: 0]
  ------------------
  849|      0|	}
  850|  1.95k|	if (scan_res) {
  ------------------
  |  Branch (850:6): [True: 1.34k, False: 617]
  ------------------
  851|  1.34k|		dev->listen_freq = freq;
  852|  1.34k|		if (msg.group_info)
  ------------------
  |  Branch (852:7): [True: 165, False: 1.17k]
  ------------------
  853|    165|			dev->oper_freq = freq;
  854|  1.34k|	}
  855|  1.95k|	dev->info.level = level;
  856|       |
  857|  1.95k|	dev_name_changed = os_strncmp(dev->info.device_name, msg.device_name,
  ------------------
  |  |  559|  1.95k|#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
  ------------------
  858|  1.95k|				      WPS_DEV_NAME_MAX_LEN) != 0;
  859|       |
  860|  1.95k|	p2p_copy_wps_info(p2p, dev, 0, &msg);
  861|       |
  862|  21.5k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  21.5k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (862:14): [True: 19.5k, False: 1.95k]
  ------------------
  863|  19.5k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  864|  19.5k|		dev->info.wps_vendor_ext[i] = NULL;
  865|  19.5k|	}
  866|       |
  867|  2.07k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  2.07k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (867:14): [True: 2.06k, False: 3]
  ------------------
  868|  2.06k|		if (msg.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (868:7): [True: 1.95k, False: 114]
  ------------------
  869|  1.95k|			break;
  870|    114|		dev->info.wps_vendor_ext[i] = wpabuf_alloc_copy(
  871|    114|			msg.wps_vendor_ext[i], msg.wps_vendor_ext_len[i]);
  872|    114|		if (dev->info.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (872:7): [True: 0, False: 114]
  ------------------
  873|      0|			break;
  874|    114|	}
  875|       |
  876|  1.95k|	wfd_changed = p2p_compare_wfd_info(dev, &msg);
  877|       |
  878|  1.95k|	if (wfd_changed) {
  ------------------
  |  Branch (878:6): [True: 401, False: 1.55k]
  ------------------
  879|    401|		wpabuf_free(dev->info.wfd_subelems);
  880|    401|		if (msg.wfd_subelems)
  ------------------
  |  Branch (880:7): [True: 392, False: 9]
  ------------------
  881|    392|			dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
  882|      9|		else
  883|      9|			dev->info.wfd_subelems = NULL;
  884|    401|	}
  885|       |
  886|  1.95k|	if (scan_res) {
  ------------------
  |  Branch (886:6): [True: 1.34k, False: 617]
  ------------------
  887|  1.34k|		p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq,
  888|  1.34k|				      msg.group_info, msg.group_info_len,
  889|  1.34k|				      rx_time);
  890|  1.34k|	}
  891|       |
  892|  1.95k|	p2p_parse_free(&msg);
  893|       |
  894|  1.95k|	p2p_update_peer_vendor_elems(dev, ies, ies_len);
  895|       |
  896|  1.95k|	if (dev->flags & P2P_DEV_REPORTED && !wfd_changed &&
  ------------------
  |  |  128|  1.95k|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|  3.91k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (896:6): [True: 206, False: 1.75k]
  |  Branch (896:39): [True: 196, False: 10]
  ------------------
  897|    196|	    !dev_name_changed &&
  ------------------
  |  Branch (897:6): [True: 49, False: 147]
  ------------------
  898|     49|	    (!msg.adv_service_instance ||
  ------------------
  |  Branch (898:7): [True: 46, False: 3]
  ------------------
  899|      3|	     (dev->flags & P2P_DEV_P2PS_REPORTED)))
  ------------------
  |  |  145|      3|#define P2P_DEV_P2PS_REPORTED BIT(20)
  |  |  ------------------
  |  |  |  |  458|      3|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (899:7): [True: 2, False: 1]
  ------------------
  900|     48|		return 0;
  901|       |
  902|  1.90k|	p2p_dbg(p2p, "Peer found with Listen frequency %d MHz (rx_time=%u.%06u)",
  903|  1.90k|		freq, (unsigned int) rx_time->sec,
  904|  1.90k|		(unsigned int) rx_time->usec);
  905|  1.90k|	if (dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|  1.90k|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|  1.90k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (905:6): [True: 0, False: 1.90k]
  ------------------
  906|      0|		p2p_dbg(p2p, "Do not report rejected device");
  907|      0|		return 0;
  908|      0|	}
  909|       |
  910|  1.90k|	if (dev->info.config_methods == 0 &&
  ------------------
  |  Branch (910:6): [True: 1.35k, False: 558]
  ------------------
  911|  1.35k|	    (freq == 2412 || freq == 2437 || freq == 2462)) {
  ------------------
  |  Branch (911:7): [True: 1.27k, False: 77]
  |  Branch (911:23): [True: 12, False: 65]
  |  Branch (911:39): [True: 7, False: 58]
  ------------------
  912|       |		/*
  913|       |		 * If we have only seen a Beacon frame from a GO, we do not yet
  914|       |		 * know what WPS config methods it supports. Since some
  915|       |		 * applications use config_methods value from P2P-DEVICE-FOUND
  916|       |		 * events, postpone reporting this peer until we've fully
  917|       |		 * discovered its capabilities.
  918|       |		 *
  919|       |		 * At least for now, do this only if the peer was detected on
  920|       |		 * one of the social channels since that peer can be easily be
  921|       |		 * found again and there are no limitations of having to use
  922|       |		 * passive scan on this channels, so this can be done through
  923|       |		 * Probe Response frame that includes the config_methods
  924|       |		 * information.
  925|       |		 */
  926|  1.29k|		p2p_dbg(p2p, "Do not report peer " MACSTR
  927|  1.29k|			" with unknown config methods", MAC2STR(addr));
  ------------------
  |  |  447|  1.29k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  928|  1.29k|		return 0;
  929|  1.29k|	}
  930|       |
  931|    616|	p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info,
  932|    616|			    !(dev->flags & P2P_DEV_REPORTED_ONCE));
  ------------------
  |  |  140|    616|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    616|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  933|    616|	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    616|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    616|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    616|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    616|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  934|       |
  935|    616|	if (msg.adv_service_instance)
  ------------------
  |  Branch (935:6): [True: 5, False: 611]
  ------------------
  936|      5|		dev->flags |= P2P_DEV_P2PS_REPORTED;
  ------------------
  |  |  145|      5|#define P2P_DEV_P2PS_REPORTED BIT(20)
  |  |  ------------------
  |  |  |  |  458|      5|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  937|       |
  938|    616|	return 0;
  939|  1.90k|}
p2p_stop_find_for_freq:
 1350|  6.88k|{
 1351|  6.88k|	p2p_dbg(p2p, "Stopping find");
 1352|  6.88k|	eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
 1353|  6.88k|	p2p_clear_timeout(p2p);
 1354|  6.88k|	if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND)
  ------------------
  |  Branch (1354:6): [True: 0, False: 6.88k]
  |  Branch (1354:34): [True: 0, False: 6.88k]
  ------------------
 1355|      0|		p2p->cfg->find_stopped(p2p->cfg->cb_ctx);
 1356|       |
 1357|  6.88k|	p2p->p2ps_seek_count = 0;
 1358|       |
 1359|  6.88k|	p2p_set_state(p2p, P2P_IDLE);
 1360|  6.88k|	p2p_free_req_dev_types(p2p);
 1361|  6.88k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1362|  6.88k|	if (p2p->go_neg_peer)
  ------------------
  |  Branch (1362:6): [True: 0, False: 6.88k]
  ------------------
 1363|      0|		p2p->go_neg_peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE;
  ------------------
  |  |  133|      0|#define P2P_DEV_PEER_WAITING_RESPONSE BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1364|  6.88k|	p2p->go_neg_peer = NULL;
 1365|  6.88k|	p2p->sd_peer = NULL;
 1366|       |	p2p->invite_peer = NULL;
 1367|  6.88k|	p2p_stop_listen_for_freq(p2p, freq);
 1368|  6.88k|	p2p->send_action_in_progress = 0;
 1369|  6.88k|}
p2p_stop_listen_for_freq:
 1373|  6.88k|{
 1374|  6.88k|	p2p_dbg(p2p,
 1375|  6.88k|		"%s(freq=%d) pending_listen_freq=%d in_listen=%d drv_in_listen=%d",
 1376|  6.88k|		__func__, freq, p2p->pending_listen_freq, p2p->in_listen,
 1377|  6.88k|		p2p->drv_in_listen);
 1378|  6.88k|	if (freq > 0 &&
  ------------------
  |  Branch (1378:6): [True: 0, False: 6.88k]
  ------------------
 1379|      0|	    ((p2p->drv_in_listen == freq && p2p->in_listen) ||
  ------------------
  |  Branch (1379:8): [True: 0, False: 0]
  |  Branch (1379:38): [True: 0, False: 0]
  ------------------
 1380|      0|	     p2p->pending_listen_freq == (unsigned int) freq)) {
  ------------------
  |  Branch (1380:7): [True: 0, False: 0]
  ------------------
 1381|      0|		p2p_dbg(p2p, "Skip stop_listen since we are on correct channel for response");
 1382|      0|		return;
 1383|      0|	}
 1384|  6.88k|	if (p2p->in_listen) {
  ------------------
  |  Branch (1384:6): [True: 0, False: 6.88k]
  ------------------
 1385|      0|		p2p->in_listen = 0;
 1386|      0|		p2p_clear_timeout(p2p);
 1387|      0|	}
 1388|  6.88k|	if (p2p->drv_in_listen) {
  ------------------
  |  Branch (1388:6): [True: 0, False: 6.88k]
  ------------------
 1389|       |		/*
 1390|       |		 * The driver may not deliver callback to p2p_listen_end()
 1391|       |		 * when the operation gets canceled, so clear the internal
 1392|       |		 * variable that is tracking driver state.
 1393|       |		 */
 1394|      0|		p2p_dbg(p2p, "Clear drv_in_listen (%d)", p2p->drv_in_listen);
 1395|      0|		p2p->drv_in_listen = 0;
 1396|      0|	}
 1397|  6.88k|	if (p2p->pending_listen_freq &&
  ------------------
  |  Branch (1397:6): [True: 0, False: 6.88k]
  ------------------
 1398|      0|	    p2p->pending_listen_freq != (unsigned int) freq &&
  ------------------
  |  Branch (1398:6): [True: 0, False: 0]
  ------------------
 1399|      0|	    !p2p->drv_in_listen && p2p->pending_listen_wait_drv) {
  ------------------
  |  Branch (1399:6): [True: 0, False: 0]
  |  Branch (1399:29): [True: 0, False: 0]
  ------------------
 1400|      0|		p2p_dbg(p2p,
 1401|      0|			"Clear pending_listen_freq since the started listen did not complete before being stopped");
 1402|      0|		p2p->pending_listen_freq = 0;
 1403|      0|	}
 1404|  6.88k|	p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 1405|       |	p2p->pending_listen_wait_drv = false;
 1406|  6.88k|}
p2p_stop_find:
 1422|  6.88k|{
 1423|  6.88k|	p2p->pending_listen_freq = 0;
 1424|  6.88k|	p2p_stop_find_for_freq(p2p, 0);
 1425|  6.88k|}
p2p_add_dev_info:
 1815|     18|{
 1816|     18|	os_get_reltime(&dev->last_seen);
 1817|       |
 1818|     18|	p2p_copy_wps_info(p2p, dev, 0, msg);
 1819|       |
 1820|     18|	if (msg->listen_channel) {
  ------------------
  |  Branch (1820:6): [True: 18, False: 0]
  ------------------
 1821|     18|		int freq;
 1822|     18|		freq = p2p_channel_to_freq(msg->listen_channel[3],
 1823|     18|					   msg->listen_channel[4]);
 1824|     18|		if (freq < 0) {
  ------------------
  |  Branch (1824:7): [True: 5, False: 13]
  ------------------
 1825|      5|			p2p_dbg(p2p, "Unknown peer Listen channel: "
 1826|      5|				"country=%c%c(0x%02x) reg_class=%u channel=%u",
 1827|      5|				msg->listen_channel[0],
 1828|      5|				msg->listen_channel[1],
 1829|      5|				msg->listen_channel[2],
 1830|      5|				msg->listen_channel[3],
 1831|      5|				msg->listen_channel[4]);
 1832|     13|		} else {
 1833|     13|			p2p_dbg(p2p, "Update peer " MACSTR
 1834|     13|				" Listen channel: %u -> %u MHz",
 1835|     13|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|     13|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1836|     13|				dev->listen_freq, freq);
 1837|     13|			dev->listen_freq = freq;
 1838|     13|		}
 1839|     18|	}
 1840|       |
 1841|     18|	if (msg->wfd_subelems) {
  ------------------
  |  Branch (1841:6): [True: 1, False: 17]
  ------------------
 1842|      1|		wpabuf_free(dev->info.wfd_subelems);
 1843|      1|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
 1844|      1|	}
 1845|       |
 1846|     18|	if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
  ------------------
  |  |  127|     18|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1846:6): [True: 1, False: 17]
  ------------------
 1847|      1|		dev->flags &= ~P2P_DEV_PROBE_REQ_ONLY;
  ------------------
  |  |  127|      1|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1848|      1|		p2p_dbg(p2p, "Completed device entry based on data from GO Negotiation Request");
 1849|     17|	} else {
 1850|     17|		p2p_dbg(p2p, "Created device entry based on GO Neg Req: "
 1851|     17|			MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
 1852|     17|			"listen_freq=%d",
 1853|     17|			MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|     17|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1854|     17|			dev->info.dev_capab, dev->info.group_capab,
 1855|     17|			dev->info.device_name, dev->listen_freq);
 1856|     17|	}
 1857|       |
 1858|     18|	dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
  ------------------
  |  |  137|     18|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1859|       |
 1860|     18|	if (dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|     18|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1860:6): [True: 0, False: 18]
  ------------------
 1861|      0|		p2p_dbg(p2p, "Do not report rejected device");
 1862|      0|		return;
 1863|      0|	}
 1864|       |
 1865|     18|	p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info,
 1866|     18|			    !(dev->flags & P2P_DEV_REPORTED_ONCE));
  ------------------
  |  |  140|     18|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1867|     18|	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|     18|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|     18|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1868|     18|}
p2p_rx_action:
 2116|  4.63k|{
 2117|  4.63k|	if (category == WLAN_ACTION_PUBLIC) {
  ------------------
  |  |  730|  4.63k|#define WLAN_ACTION_PUBLIC 4
  ------------------
  |  Branch (2117:6): [True: 2.22k, False: 2.41k]
  ------------------
 2118|  2.22k|		p2p_rx_action_public(p2p, da, sa, bssid, data, len, freq);
 2119|  2.22k|		return;
 2120|  2.22k|	}
 2121|       |
 2122|  2.41k|	if (category != WLAN_ACTION_VENDOR_SPECIFIC)
  ------------------
  |  |  764|  2.41k|#define WLAN_ACTION_VENDOR_SPECIFIC 127
  ------------------
  |  Branch (2122:6): [True: 1.63k, False: 779]
  ------------------
 2123|  1.63k|		return;
 2124|       |
 2125|    779|	if (len < 4)
  ------------------
  |  Branch (2125:6): [True: 6, False: 773]
  ------------------
 2126|      6|		return;
 2127|       |
 2128|    773|	if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
  ------------------
  |  | 1575|    773|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (2128:6): [True: 52, False: 721]
  ------------------
 2129|     52|		return;
 2130|    721|	data += 4;
 2131|    721|	len -= 4;
 2132|       |
 2133|       |	/* P2P action frame */
 2134|    721|	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    721|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    721|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2135|    721|	wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Action contents", data, len);
 2136|       |
 2137|    721|	if (len < 1)
  ------------------
  |  Branch (2137:6): [True: 1, False: 720]
  ------------------
 2138|      1|		return;
 2139|    720|	switch (data[0]) {
 2140|      2|	case P2P_NOA:
  ------------------
  |  Branch (2140:2): [True: 2, False: 718]
  ------------------
 2141|      2|		p2p_dbg(p2p, "Received P2P Action - Notice of Absence");
 2142|       |		/* TODO */
 2143|      2|		break;
 2144|      1|	case P2P_PRESENCE_REQ:
  ------------------
  |  Branch (2144:2): [True: 1, False: 719]
  ------------------
 2145|      1|		p2p_process_presence_req(p2p, da, sa, data + 1, len - 1, freq);
 2146|      1|		break;
 2147|    713|	case P2P_PRESENCE_RESP:
  ------------------
  |  Branch (2147:2): [True: 713, False: 7]
  ------------------
 2148|    713|		p2p_process_presence_resp(p2p, da, sa, data + 1, len - 1);
 2149|    713|		break;
 2150|      2|	case P2P_GO_DISC_REQ:
  ------------------
  |  Branch (2150:2): [True: 2, False: 718]
  ------------------
 2151|      2|		p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq);
 2152|      2|		break;
 2153|      2|	default:
  ------------------
  |  Branch (2153:2): [True: 2, False: 718]
  ------------------
 2154|      2|		p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]);
 2155|      2|		break;
 2156|    720|	}
 2157|    720|}
p2p_add_dev_from_go_neg_req:
 2282|     13|{
 2283|     13|	struct p2p_device *dev;
 2284|       |
 2285|     13|	dev = p2p_get_device(p2p, addr);
 2286|     13|	if (dev) {
  ------------------
  |  Branch (2286:6): [True: 0, False: 13]
  ------------------
 2287|      0|		os_get_reltime(&dev->last_seen);
 2288|      0|		return dev; /* already known */
 2289|      0|	}
 2290|       |
 2291|     13|	dev = p2p_create_device(p2p, addr);
 2292|     13|	if (dev == NULL)
  ------------------
  |  Branch (2292:6): [True: 0, False: 13]
  ------------------
 2293|      0|		return NULL;
 2294|       |
 2295|     13|	p2p_add_dev_info(p2p, addr, dev, msg);
 2296|       |
 2297|     13|	return dev;
 2298|     13|}
p2p_build_probe_resp_ies:
 2365|      2|{
 2366|      2|	struct wpabuf *buf;
 2367|      2|	u8 *len;
 2368|      2|	int pw_id = -1;
 2369|      2|	size_t extra = 0;
 2370|       |
 2371|      2|#ifdef CONFIG_WIFI_DISPLAY
 2372|      2|	if (p2p->wfd_ie_probe_resp)
  ------------------
  |  Branch (2372:6): [True: 0, False: 2]
  ------------------
 2373|      0|		extra = wpabuf_len(p2p->wfd_ie_probe_resp);
 2374|      2|#endif /* CONFIG_WIFI_DISPLAY */
 2375|       |
 2376|      2|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P])
  ------------------
  |  Branch (2376:6): [True: 0, False: 2]
  |  Branch (2376:26): [True: 0, False: 0]
  ------------------
 2377|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]);
 2378|       |
 2379|      2|	if (query_count)
  ------------------
  |  Branch (2379:6): [True: 0, False: 2]
  ------------------
 2380|      0|		extra += MAX_SVC_ADV_IE_LEN;
  ------------------
  |  |   31|      0|#define MAX_SVC_ADV_IE_LEN (9 + MAX_SVC_ADV_LEN + (5 * (MAX_SVC_ADV_LEN / 240)))
  |  |  ------------------
  |  |  |  |   30|      0|#define MAX_SVC_ADV_LEN	600
  |  |  ------------------
  |  |               #define MAX_SVC_ADV_IE_LEN (9 + MAX_SVC_ADV_LEN + (5 * (MAX_SVC_ADV_LEN / 240)))
  |  |  ------------------
  |  |  |  |   30|      0|#define MAX_SVC_ADV_LEN	600
  |  |  ------------------
  ------------------
 2381|       |
 2382|      2|	buf = wpabuf_alloc(1000 + extra);
 2383|      2|	if (buf == NULL)
  ------------------
  |  Branch (2383:6): [True: 0, False: 2]
  ------------------
 2384|      0|		return NULL;
 2385|       |
 2386|      2|	if (p2p->go_neg_peer) {
  ------------------
  |  Branch (2386:6): [True: 0, False: 2]
  ------------------
 2387|       |		/* Advertise immediate availability of WPS credential */
 2388|      0|		pw_id = p2p_wps_method_pw_id(p2p->go_neg_peer->wps_method);
 2389|      0|	}
 2390|       |
 2391|      2|	if (p2p_build_wps_ie(p2p, buf, pw_id, 1) < 0) {
  ------------------
  |  Branch (2391:6): [True: 0, False: 2]
  ------------------
 2392|      0|		p2p_dbg(p2p, "Failed to build WPS IE for Probe Response");
 2393|      0|		wpabuf_free(buf);
 2394|      0|		return NULL;
 2395|      0|	}
 2396|       |
 2397|      2|#ifdef CONFIG_WIFI_DISPLAY
 2398|      2|	if (p2p->wfd_ie_probe_resp)
  ------------------
  |  Branch (2398:6): [True: 0, False: 2]
  ------------------
 2399|      0|		wpabuf_put_buf(buf, p2p->wfd_ie_probe_resp);
 2400|      2|#endif /* CONFIG_WIFI_DISPLAY */
 2401|       |
 2402|      2|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P])
  ------------------
  |  Branch (2402:6): [True: 0, False: 2]
  |  Branch (2402:26): [True: 0, False: 0]
  ------------------
 2403|      0|		wpabuf_put_buf(buf,
 2404|      0|			       p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]);
 2405|       |
 2406|       |	/* P2P IE */
 2407|      2|	len = p2p_buf_add_ie_hdr(buf);
 2408|      2|	p2p_buf_add_capability(buf, p2p->dev_capab &
 2409|      2|			       ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 0);
  ------------------
  |  | 1911|      2|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2410|      2|	if (p2p->ext_listen_interval)
  ------------------
  |  Branch (2410:6): [True: 0, False: 2]
  ------------------
 2411|      0|		p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period,
 2412|      0|					      p2p->ext_listen_interval);
 2413|      2|	p2p_buf_add_device_info(buf, p2p, NULL);
 2414|      2|	p2p_buf_update_ie_hdr(buf, len);
 2415|       |
 2416|      2|	if (query_count) {
  ------------------
  |  Branch (2416:6): [True: 0, False: 2]
  ------------------
 2417|      0|		p2p_buf_add_service_instance(buf, p2p, query_count, query_hash,
 2418|      0|					     p2p->p2ps_adv_list);
 2419|      0|	}
 2420|       |
 2421|      2|	return buf;
 2422|      2|}
p2p_probe_req_rx:
 2674|  6.88k|{
 2675|  6.88k|	enum p2p_probe_req_status res;
 2676|       |
 2677|  6.88k|	p2p_add_dev_from_probe_req(p2p, addr, ie, ie_len);
 2678|       |
 2679|  6.88k|	if (p2p_lo_started) {
  ------------------
  |  Branch (2679:6): [True: 0, False: 6.88k]
  ------------------
 2680|      0|		p2p_dbg(p2p,
 2681|      0|			"Probe Response is offloaded, do not reply Probe Request");
 2682|      0|		return P2P_PREQ_PROCESSED;
 2683|      0|	}
 2684|       |
 2685|  6.88k|	res = p2p_reply_probe(p2p, addr, dst, bssid, ie, ie_len, rx_freq);
 2686|  6.88k|	if (res != P2P_PREQ_PROCESSED && res != P2P_PREQ_NOT_PROCESSED)
  ------------------
  |  Branch (2686:6): [True: 6.88k, False: 0]
  |  Branch (2686:35): [True: 4.35k, False: 2.52k]
  ------------------
 2687|  4.35k|		return res;
 2688|       |
 2689|       |	/*
 2690|       |	 * Activate a pending GO Negotiation/Invite flow if a received Probe
 2691|       |	 * Request frame is from an expected peer. Some devices may share the
 2692|       |	 * same address for P2P and non-P2P STA running simultaneously. The
 2693|       |	 * P2P_PREQ_PROCESSED and P2P_PREQ_NOT_PROCESSED p2p_reply_probe()
 2694|       |	 * return values verified above ensure we are handling a Probe Request
 2695|       |	 * frame from a P2P peer.
 2696|       |	 */
 2697|  2.52k|	if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) &&
  ------------------
  |  Branch (2697:7): [True: 0, False: 2.52k]
  |  Branch (2697:36): [True: 0, False: 2.52k]
  ------------------
 2698|      0|	    p2p->go_neg_peer &&
  ------------------
  |  Branch (2698:6): [True: 0, False: 0]
  ------------------
 2699|      0|	    ether_addr_equal(addr, p2p->go_neg_peer->info.p2p_device_addr) &&
  ------------------
  |  Branch (2699:6): [True: 0, False: 0]
  ------------------
 2700|      0|	    !(p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
  ------------------
  |  |  136|      0|#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (2700:6): [True: 0, False: 0]
  ------------------
 2701|       |		/* Received a Probe Request from GO Negotiation peer */
 2702|      0|		p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout");
 2703|      0|		eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
 2704|      0|		eloop_register_timeout(0, 0, p2p_go_neg_start, p2p, NULL);
 2705|      0|		return res;
 2706|      0|	}
 2707|       |
 2708|  2.52k|	if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) &&
  ------------------
  |  Branch (2708:7): [True: 0, False: 2.52k]
  |  Branch (2708:35): [True: 0, False: 2.52k]
  ------------------
 2709|      0|	    p2p->invite_peer &&
  ------------------
  |  Branch (2709:6): [True: 0, False: 0]
  ------------------
 2710|      0|	    (p2p->invite_peer->flags & P2P_DEV_WAIT_INV_REQ_ACK) &&
  ------------------
  |  |  144|      0|#define P2P_DEV_WAIT_INV_REQ_ACK BIT(19)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (2710:6): [True: 0, False: 0]
  ------------------
 2711|      0|	    ether_addr_equal(addr, p2p->invite_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (2711:6): [True: 0, False: 0]
  ------------------
 2712|       |		/* Received a Probe Request from Invite peer */
 2713|      0|		p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout");
 2714|      0|		eloop_cancel_timeout(p2p_invite_start, p2p, NULL);
 2715|      0|		eloop_register_timeout(0, 0, p2p_invite_start, p2p, NULL);
 2716|      0|		return res;
 2717|      0|	}
 2718|       |
 2719|  2.52k|	return res;
 2720|  2.52k|}
p2p_service_p2ps_id:
 2864|      1|{
 2865|      1|	struct p2ps_advertisement *adv_data;
 2866|       |
 2867|      1|	if (!p2p)
  ------------------
  |  Branch (2867:6): [True: 0, False: 1]
  ------------------
 2868|      0|		return NULL;
 2869|       |
 2870|      1|	adv_data = p2p->p2ps_adv_list;
 2871|      1|	while (adv_data) {
  ------------------
  |  Branch (2871:9): [True: 0, False: 1]
  ------------------
 2872|      0|		if (adv_data->id == adv_id)
  ------------------
  |  Branch (2872:7): [True: 0, False: 0]
  ------------------
 2873|      0|			return adv_data;
 2874|      0|		adv_data = adv_data->next;
 2875|      0|	}
 2876|       |
 2877|      1|	return NULL;
 2878|      1|}
p2p_service_flush_asp:
 2996|  6.88k|{
 2997|  6.88k|	struct p2ps_advertisement *adv, *prev;
 2998|       |
 2999|  6.88k|	if (!p2p)
  ------------------
  |  Branch (2999:6): [True: 0, False: 6.88k]
  ------------------
 3000|      0|		return;
 3001|       |
 3002|  6.88k|	adv = p2p->p2ps_adv_list;
 3003|  6.88k|	while (adv) {
  ------------------
  |  Branch (3003:9): [True: 0, False: 6.88k]
  ------------------
 3004|      0|		prev = adv;
 3005|      0|		adv = adv->next;
 3006|      0|		os_free(prev);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
 3007|      0|	}
 3008|       |
 3009|       |	p2p->p2ps_adv_list = NULL;
 3010|  6.88k|	p2ps_prov_free(p2p);
 3011|  6.88k|	p2p_dbg(p2p, "All ASP advertisements flushed");
 3012|  6.88k|}
p2p_init:
 3173|  6.88k|{
 3174|  6.88k|	struct p2p_data *p2p;
 3175|       |
 3176|  6.88k|	if (cfg->max_peers < 1 ||
  ------------------
  |  Branch (3176:6): [True: 0, False: 6.88k]
  ------------------
 3177|  6.88k|	    cfg->passphrase_len < 8 || cfg->passphrase_len > 63)
  ------------------
  |  Branch (3177:6): [True: 0, False: 6.88k]
  |  Branch (3177:33): [True: 0, False: 6.88k]
  ------------------
 3178|      0|		return NULL;
 3179|       |
 3180|  6.88k|	p2p = os_zalloc(sizeof(*p2p) + sizeof(*cfg));
 3181|  6.88k|	if (p2p == NULL)
  ------------------
  |  Branch (3181:6): [True: 0, False: 6.88k]
  ------------------
 3182|      0|		return NULL;
 3183|  6.88k|	p2p->cfg = (struct p2p_config *) (p2p + 1);
 3184|  6.88k|	os_memcpy(p2p->cfg, cfg, sizeof(*cfg));
  ------------------
  |  |  523|  6.88k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3185|  6.88k|	if (cfg->dev_name)
  ------------------
  |  Branch (3185:6): [True: 0, False: 6.88k]
  ------------------
 3186|      0|		p2p->cfg->dev_name = os_strdup(cfg->dev_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3187|  6.88k|	if (cfg->manufacturer)
  ------------------
  |  Branch (3187:6): [True: 0, False: 6.88k]
  ------------------
 3188|      0|		p2p->cfg->manufacturer = os_strdup(cfg->manufacturer);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3189|  6.88k|	if (cfg->model_name)
  ------------------
  |  Branch (3189:6): [True: 0, False: 6.88k]
  ------------------
 3190|      0|		p2p->cfg->model_name = os_strdup(cfg->model_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3191|  6.88k|	if (cfg->model_number)
  ------------------
  |  Branch (3191:6): [True: 0, False: 6.88k]
  ------------------
 3192|      0|		p2p->cfg->model_number = os_strdup(cfg->model_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3193|  6.88k|	if (cfg->serial_number)
  ------------------
  |  Branch (3193:6): [True: 0, False: 6.88k]
  ------------------
 3194|      0|		p2p->cfg->serial_number = os_strdup(cfg->serial_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3195|  6.88k|	if (cfg->pref_chan) {
  ------------------
  |  Branch (3195:6): [True: 0, False: 6.88k]
  ------------------
 3196|      0|		p2p->cfg->pref_chan = os_malloc(cfg->num_pref_chan *
  ------------------
  |  |  505|      0|#define os_malloc(s) malloc((s))
  ------------------
 3197|      0|						sizeof(struct p2p_channel));
 3198|      0|		if (p2p->cfg->pref_chan) {
  ------------------
  |  Branch (3198:7): [True: 0, False: 0]
  ------------------
 3199|      0|			os_memcpy(p2p->cfg->pref_chan, cfg->pref_chan,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3200|      0|				  cfg->num_pref_chan *
 3201|      0|				  sizeof(struct p2p_channel));
 3202|      0|		} else
 3203|      0|			p2p->cfg->num_pref_chan = 0;
 3204|      0|	}
 3205|       |
 3206|  6.88k|	p2ps_gen_hash(p2p, P2PS_WILD_HASH_STR, p2p->wild_card_hash);
  ------------------
  |  |   34|  6.88k|#define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
  ------------------
 3207|       |
 3208|  6.88k|	p2p->min_disc_int = 1;
 3209|  6.88k|	p2p->max_disc_int = 3;
 3210|  6.88k|	p2p->max_disc_tu = -1;
 3211|       |
 3212|  6.88k|	if (os_get_random(&p2p->next_tie_breaker, 1) < 0)
  ------------------
  |  Branch (3212:6): [True: 0, False: 6.88k]
  ------------------
 3213|      0|		p2p->next_tie_breaker = 0;
 3214|  6.88k|	p2p->next_tie_breaker &= 0x01;
 3215|  6.88k|	if (cfg->sd_request)
  ------------------
  |  Branch (3215:6): [True: 0, False: 6.88k]
  ------------------
 3216|      0|		p2p->dev_capab |= P2P_DEV_CAPAB_SERVICE_DISCOVERY;
  ------------------
  |  | 1910|      0|#define P2P_DEV_CAPAB_SERVICE_DISCOVERY BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3217|  6.88k|	p2p->dev_capab |= P2P_DEV_CAPAB_INVITATION_PROCEDURE;
  ------------------
  |  | 1915|  6.88k|#define P2P_DEV_CAPAB_INVITATION_PROCEDURE BIT(5)
  |  |  ------------------
  |  |  |  |  458|  6.88k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3218|  6.88k|	if (cfg->concurrent_operations)
  ------------------
  |  Branch (3218:6): [True: 0, False: 6.88k]
  ------------------
 3219|      0|		p2p->dev_capab |= P2P_DEV_CAPAB_CONCURRENT_OPER;
  ------------------
  |  | 1912|      0|#define P2P_DEV_CAPAB_CONCURRENT_OPER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3220|  6.88k|	p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1911|  6.88k|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|  6.88k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3221|       |
 3222|  6.88k|	dl_list_init(&p2p->devices);
 3223|       |
 3224|  6.88k|	p2p->go_timeout = 100;
 3225|  6.88k|	p2p->client_timeout = 20;
 3226|  6.88k|	p2p->num_p2p_sd_queries = 0;
 3227|       |	/* Default comeback after one second */
 3228|  6.88k|	if (!p2p->cfg->comeback_after)
  ------------------
  |  Branch (3228:6): [True: 6.88k, False: 0]
  ------------------
 3229|  6.88k|		p2p->cfg->comeback_after = 977; /* TUs */
 3230|  6.88k|	p2p_pairing_info_init(p2p);
 3231|       |
 3232|  6.88k|	p2p_dbg(p2p, "initialized");
 3233|  6.88k|	p2p_channels_dump(p2p, "channels", &p2p->cfg->channels);
 3234|  6.88k|	p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels);
 3235|       |
 3236|  6.88k|	return p2p;
 3237|  6.88k|}
p2p_deinit:
 3241|  6.88k|{
 3242|  6.88k|#ifdef CONFIG_WIFI_DISPLAY
 3243|  6.88k|	wpabuf_free(p2p->wfd_ie_beacon);
 3244|  6.88k|	wpabuf_free(p2p->wfd_ie_probe_req);
 3245|  6.88k|	wpabuf_free(p2p->wfd_ie_probe_resp);
 3246|  6.88k|	wpabuf_free(p2p->wfd_ie_assoc_req);
 3247|  6.88k|	wpabuf_free(p2p->wfd_ie_invitation);
 3248|  6.88k|	wpabuf_free(p2p->wfd_ie_prov_disc_req);
 3249|  6.88k|	wpabuf_free(p2p->wfd_ie_prov_disc_resp);
 3250|  6.88k|	wpabuf_free(p2p->wfd_ie_go_neg);
 3251|  6.88k|	wpabuf_free(p2p->wfd_dev_info);
 3252|  6.88k|	wpabuf_free(p2p->wfd_assoc_bssid);
 3253|  6.88k|	wpabuf_free(p2p->wfd_coupled_sink_info);
 3254|  6.88k|	wpabuf_free(p2p->wfd_r2_dev_info);
 3255|  6.88k|#endif /* CONFIG_WIFI_DISPLAY */
 3256|       |
 3257|  6.88k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3258|  6.88k|	eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
 3259|  6.88k|	eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
 3260|  6.88k|	p2p_flush(p2p);
 3261|  6.88k|	p2p_free_req_dev_types(p2p);
 3262|  6.88k|	os_free(p2p->cfg->dev_name);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3263|  6.88k|	os_free(p2p->cfg->manufacturer);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3264|  6.88k|	os_free(p2p->cfg->model_name);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3265|  6.88k|	os_free(p2p->cfg->model_number);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3266|  6.88k|	os_free(p2p->cfg->serial_number);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3267|  6.88k|	os_free(p2p->cfg->pref_chan);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3268|  6.88k|	os_free(p2p->groups);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3269|  6.88k|	p2ps_prov_free(p2p);
 3270|  6.88k|	wpabuf_free(p2p->sd_resp);
 3271|  6.88k|	p2p_remove_wps_vendor_extensions(p2p);
 3272|  6.88k|	os_free(p2p->no_go_freq.range);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3273|  6.88k|	p2p_service_flush_asp(p2p);
 3274|  6.88k|	p2p_pairing_info_deinit(p2p);
 3275|       |
 3276|  6.88k|	os_free(p2p);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 3277|  6.88k|}
p2p_flush:
 3281|  6.88k|{
 3282|  6.88k|	struct p2p_device *dev, *prev;
 3283|       |
 3284|  6.88k|	p2p_ext_listen(p2p, 0, 0);
 3285|  6.88k|	p2p_stop_find(p2p);
 3286|  6.88k|	dl_list_for_each_safe(dev, prev, &p2p->devices, struct p2p_device,
  ------------------
  |  |   84|  6.88k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  6.88k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  8.85k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 1.97k, False: 6.88k]
  |  |  ------------------
  |  |   87|  6.88k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  1.97k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 3287|  6.88k|			      list) {
 3288|  1.97k|		dl_list_del(&dev->list);
 3289|  1.97k|		p2p_device_free(p2p, dev);
 3290|  1.97k|	}
 3291|  6.88k|	p2p_free_sd_queries(p2p);
 3292|  6.88k|	p2p->ssid_set = 0;
 3293|  6.88k|	p2ps_prov_free(p2p);
 3294|  6.88k|	p2p_reset_pending_pd(p2p);
 3295|  6.88k|	p2p->override_pref_op_class = 0;
 3296|  6.88k|	p2p->override_pref_channel = 0;
 3297|  6.88k|}
p2p_remove_wps_vendor_extensions:
 3424|  6.88k|{
 3425|  6.88k|	int i;
 3426|       |
 3427|  75.6k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  75.6k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (3427:14): [True: 68.8k, False: 6.88k]
  ------------------
 3428|  68.8k|		wpabuf_free(p2p->wps_vendor_ext[i]);
 3429|       |		p2p->wps_vendor_ext[i] = NULL;
 3430|  68.8k|	}
 3431|  6.88k|}
p2p_scan_res_handler:
 3742|  6.88k|{
 3743|  6.88k|	if (os_reltime_before(rx_time, &p2p->find_start)) {
  ------------------
  |  Branch (3743:6): [True: 0, False: 6.88k]
  ------------------
 3744|       |		/*
 3745|       |		 * The driver may have cached (e.g., in cfg80211 BSS table) the
 3746|       |		 * scan results for relatively long time. To avoid reporting
 3747|       |		 * stale information, update P2P peers only based on results
 3748|       |		 * that have based on frames received after the last p2p_find
 3749|       |		 * operation was started.
 3750|       |		 */
 3751|      0|		p2p_dbg(p2p, "Ignore old scan result for " MACSTR
 3752|      0|			" (rx_time=%u.%06u find_start=%u.%06u)",
 3753|      0|			MAC2STR(bssid), (unsigned int) rx_time->sec,
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 3754|      0|			(unsigned int) rx_time->usec,
 3755|      0|			(unsigned int) p2p->find_start.sec,
 3756|      0|			(unsigned int) p2p->find_start.usec);
 3757|      0|		return 0;
 3758|      0|	}
 3759|       |
 3760|  6.88k|	p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1);
 3761|       |
 3762|  6.88k|	return 0;
 3763|  6.88k|}
p2p_scan_res_handled:
 3767|  6.88k|{
 3768|  6.88k|	if (!p2p->p2p_scan_running) {
  ------------------
  |  Branch (3768:6): [True: 6.88k, False: 0]
  ------------------
 3769|  6.88k|		p2p_dbg(p2p, "p2p_scan was not running, but scan results received");
 3770|  6.88k|	}
 3771|  6.88k|	p2p->p2p_scan_running = 0;
 3772|       |
 3773|       |	/* Use this delay only when p2p_find doesn't set it */
 3774|  6.88k|	if (!p2p->search_delay)
  ------------------
  |  Branch (3774:6): [True: 6.88k, False: 0]
  ------------------
 3775|  6.88k|		p2p->search_delay = delay;
 3776|       |
 3777|  6.88k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3778|       |
 3779|  6.88k|	if (p2p_run_after_scan(p2p))
  ------------------
  |  Branch (3779:6): [True: 0, False: 6.88k]
  ------------------
 3780|      0|		return;
 3781|  6.88k|	if (p2p->state == P2P_SEARCH)
  ------------------
  |  Branch (3781:6): [True: 0, False: 6.88k]
  ------------------
 3782|      0|		p2p_continue_find(p2p);
 3783|  6.88k|}
p2p_ext_listen:
 4931|  6.88k|{
 4932|  6.88k|	if (period > 65535 || interval > 65535 || period > interval ||
  ------------------
  |  Branch (4932:6): [True: 0, False: 6.88k]
  |  Branch (4932:24): [True: 0, False: 6.88k]
  |  Branch (4932:44): [True: 0, False: 6.88k]
  ------------------
 4933|  6.88k|	    (period == 0 && interval > 0) || (period > 0 && interval == 0)) {
  ------------------
  |  Branch (4933:7): [True: 6.88k, False: 0]
  |  Branch (4933:22): [True: 0, False: 6.88k]
  |  Branch (4933:40): [True: 0, False: 6.88k]
  |  Branch (4933:54): [True: 0, False: 0]
  ------------------
 4934|      0|		p2p_dbg(p2p, "Invalid Extended Listen Timing request: period=%u interval=%u",
 4935|      0|			period, interval);
 4936|      0|		return -1;
 4937|      0|	}
 4938|       |
 4939|  6.88k|	eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL);
 4940|       |
 4941|  6.88k|	if (interval == 0) {
  ------------------
  |  Branch (4941:6): [True: 6.88k, False: 0]
  ------------------
 4942|  6.88k|		p2p_dbg(p2p, "Disabling Extended Listen Timing");
 4943|  6.88k|		p2p->ext_listen_period = 0;
 4944|  6.88k|		p2p->ext_listen_interval = 0;
 4945|  6.88k|		return 0;
 4946|  6.88k|	}
 4947|       |
 4948|      0|	p2p_dbg(p2p, "Enabling Extended Listen Timing: period %u msec, interval %u msec",
 4949|      0|		period, interval);
 4950|      0|	p2p->ext_listen_period = period;
 4951|      0|	p2p->ext_listen_interval = interval;
 4952|      0|	p2p->ext_listen_interval_sec = interval / 1000;
 4953|      0|	p2p->ext_listen_interval_usec = (interval % 1000) * 1000;
 4954|       |
 4955|      0|	eloop_register_timeout(p2p->ext_listen_interval_sec,
 4956|      0|			       p2p->ext_listen_interval_usec,
 4957|      0|			       p2p_ext_listen_timeout, p2p, NULL);
 4958|       |
 4959|      0|	return 0;
 4960|  6.88k|}
p2p_send_action:
 5323|  1.70k|{
 5324|  1.70k|	int res, scheduled;
 5325|       |
 5326|  1.70k|	res = p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid,
 5327|  1.70k|				    buf, len, wait_time, &scheduled);
 5328|  1.70k|	if (res == 0 && scheduled && p2p->in_listen && freq > 0 &&
  ------------------
  |  Branch (5328:6): [True: 1.70k, False: 0]
  |  Branch (5328:18): [True: 0, False: 1.70k]
  |  Branch (5328:31): [True: 0, False: 0]
  |  Branch (5328:49): [True: 0, False: 0]
  ------------------
 5329|      0|	    p2p->drv_in_listen > 0 &&
  ------------------
  |  Branch (5329:6): [True: 0, False: 0]
  ------------------
 5330|      0|	    (unsigned int) p2p->drv_in_listen != freq) {
  ------------------
  |  Branch (5330:6): [True: 0, False: 0]
  ------------------
 5331|      0|		p2p_dbg(p2p,
 5332|      0|			"Stop listen on %d MHz to allow a frame to be sent immediately on %d MHz",
 5333|      0|			p2p->drv_in_listen, freq);
 5334|      0|		p2p_stop_listen_for_freq(p2p, freq);
 5335|      0|	}
 5336|  1.70k|	return res;
 5337|  1.70k|}
p2p_dbg:
 5583|  98.0k|{
 5584|  98.0k|	va_list ap;
 5585|  98.0k|	char buf[500];
 5586|       |
 5587|  98.0k|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5587:6): [True: 0, False: 98.0k]
  ------------------
 5588|      0|		return;
 5589|       |
 5590|  98.0k|	va_start(ap, fmt);
 5591|  98.0k|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5592|  98.0k|	buf[sizeof(buf) - 1] = '\0';
 5593|       |	va_end(ap);
 5594|  98.0k|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf);
 5595|  98.0k|}
p2p_info:
 5599|     64|{
 5600|     64|	va_list ap;
 5601|     64|	char buf[500];
 5602|       |
 5603|     64|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5603:6): [True: 0, False: 64]
  ------------------
 5604|      0|		return;
 5605|       |
 5606|     64|	va_start(ap, fmt);
 5607|     64|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5608|     64|	buf[sizeof(buf) - 1] = '\0';
 5609|       |	va_end(ap);
 5610|     64|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf);
 5611|     64|}
p2p.c:p2p_state_txt:
  111|  20.6k|{
  112|  20.6k|	switch (state) {
  113|  20.6k|	case P2P_IDLE:
  ------------------
  |  Branch (113:2): [True: 20.6k, False: 0]
  ------------------
  114|  20.6k|		return "IDLE";
  115|      0|	case P2P_SEARCH:
  ------------------
  |  Branch (115:2): [True: 0, False: 20.6k]
  ------------------
  116|      0|		return "SEARCH";
  117|      0|	case P2P_CONNECT:
  ------------------
  |  Branch (117:2): [True: 0, False: 20.6k]
  ------------------
  118|      0|		return "CONNECT";
  119|      0|	case P2P_CONNECT_LISTEN:
  ------------------
  |  Branch (119:2): [True: 0, False: 20.6k]
  ------------------
  120|      0|		return "CONNECT_LISTEN";
  121|      0|	case P2P_GO_NEG:
  ------------------
  |  Branch (121:2): [True: 0, False: 20.6k]
  ------------------
  122|      0|		return "GO_NEG";
  123|      0|	case P2P_LISTEN_ONLY:
  ------------------
  |  Branch (123:2): [True: 0, False: 20.6k]
  ------------------
  124|      0|		return "LISTEN_ONLY";
  125|      0|	case P2P_WAIT_PEER_CONNECT:
  ------------------
  |  Branch (125:2): [True: 0, False: 20.6k]
  ------------------
  126|      0|		return "WAIT_PEER_CONNECT";
  127|      0|	case P2P_WAIT_PEER_IDLE:
  ------------------
  |  Branch (127:2): [True: 0, False: 20.6k]
  ------------------
  128|      0|		return "WAIT_PEER_IDLE";
  129|      0|	case P2P_SD_DURING_FIND:
  ------------------
  |  Branch (129:2): [True: 0, False: 20.6k]
  ------------------
  130|      0|		return "SD_DURING_FIND";
  131|      0|	case P2P_PROVISIONING:
  ------------------
  |  Branch (131:2): [True: 0, False: 20.6k]
  ------------------
  132|      0|		return "PROVISIONING";
  133|      0|	case P2P_PD_DURING_FIND:
  ------------------
  |  Branch (133:2): [True: 0, False: 20.6k]
  ------------------
  134|      0|		return "PD_DURING_FIND";
  135|      0|	case P2P_INVITE:
  ------------------
  |  Branch (135:2): [True: 0, False: 20.6k]
  ------------------
  136|      0|		return "INVITE";
  137|      0|	case P2P_INVITE_LISTEN:
  ------------------
  |  Branch (137:2): [True: 0, False: 20.6k]
  ------------------
  138|      0|		return "INVITE_LISTEN";
  139|      0|	default:
  ------------------
  |  Branch (139:2): [True: 0, False: 20.6k]
  ------------------
  140|      0|		return "?";
  141|  20.6k|	}
  142|  20.6k|}
p2p.c:p2p_create_device:
  431|  2.45k|{
  432|  2.45k|	struct p2p_device *dev, *oldest = NULL;
  433|  2.45k|	size_t count = 0;
  434|       |
  435|  2.45k|	dev = p2p_get_device(p2p, addr);
  436|  2.45k|	if (dev)
  ------------------
  |  Branch (436:6): [True: 483, False: 1.97k]
  ------------------
  437|    483|		return dev;
  438|       |
  439|  1.97k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  2.45k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  2.45k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  2.52k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 547, False: 1.97k]
  |  |  ------------------
  |  |   81|  1.97k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|    547|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  440|    547|		count++;
  441|    547|		if (oldest == NULL ||
  ------------------
  |  Branch (441:7): [True: 295, False: 252]
  ------------------
  442|    252|		    os_reltime_before(&dev->last_seen, &oldest->last_seen))
  ------------------
  |  Branch (442:7): [True: 11, False: 241]
  ------------------
  443|    306|			oldest = dev;
  444|    547|	}
  445|  1.97k|	if (count + 1 > p2p->cfg->max_peers && oldest) {
  ------------------
  |  Branch (445:6): [True: 0, False: 1.97k]
  |  Branch (445:41): [True: 0, False: 0]
  ------------------
  446|      0|		p2p_dbg(p2p,
  447|      0|			"Remove oldest peer entry to make room for a new peer "
  448|      0|			MACSTR, MAC2STR(oldest->info.p2p_device_addr));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(oldest->info.p2p_device_addr));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  449|      0|		dl_list_del(&oldest->list);
  450|      0|		p2p_device_free(p2p, oldest);
  451|      0|	}
  452|       |
  453|  1.97k|	dev = os_zalloc(sizeof(*dev));
  454|  1.97k|	if (dev == NULL)
  ------------------
  |  Branch (454:6): [True: 0, False: 1.97k]
  ------------------
  455|      0|		return NULL;
  456|  1.97k|	dl_list_add(&p2p->devices, &dev->list);
  457|  1.97k|	os_memcpy(dev->info.p2p_device_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.97k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  458|  1.97k|	dev->support_6ghz = false;
  459|       |
  460|  1.97k|	return dev;
  461|  1.97k|}
p2p.c:p2p_copy_wps_info:
  564|  2.32k|{
  565|  2.32k|	os_memcpy(dev->info.device_name, msg->device_name,
  ------------------
  |  |  523|  2.32k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  566|  2.32k|		  sizeof(dev->info.device_name));
  567|       |
  568|  2.32k|	if (msg->manufacturer &&
  ------------------
  |  Branch (568:6): [True: 42, False: 2.27k]
  ------------------
  569|     42|	    msg->manufacturer_len < sizeof(dev->info.manufacturer)) {
  ------------------
  |  Branch (569:6): [True: 42, False: 0]
  ------------------
  570|     42|		os_memset(dev->info.manufacturer, 0,
  ------------------
  |  |  529|     42|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  571|     42|			  sizeof(dev->info.manufacturer));
  572|     42|		os_memcpy(dev->info.manufacturer, msg->manufacturer,
  ------------------
  |  |  523|     42|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  573|     42|			  msg->manufacturer_len);
  574|     42|	}
  575|       |
  576|  2.32k|	if (msg->model_name &&
  ------------------
  |  Branch (576:6): [True: 29, False: 2.29k]
  ------------------
  577|     29|	    msg->model_name_len < sizeof(dev->info.model_name)) {
  ------------------
  |  Branch (577:6): [True: 29, False: 0]
  ------------------
  578|     29|		os_memset(dev->info.model_name, 0,
  ------------------
  |  |  529|     29|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  579|     29|			  sizeof(dev->info.model_name));
  580|     29|		os_memcpy(dev->info.model_name, msg->model_name,
  ------------------
  |  |  523|     29|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  581|     29|			  msg->model_name_len);
  582|     29|	}
  583|       |
  584|  2.32k|	if (msg->model_number &&
  ------------------
  |  Branch (584:6): [True: 34, False: 2.28k]
  ------------------
  585|     34|	    msg->model_number_len < sizeof(dev->info.model_number)) {
  ------------------
  |  Branch (585:6): [True: 34, False: 0]
  ------------------
  586|     34|		os_memset(dev->info.model_number, 0,
  ------------------
  |  |  529|     34|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  587|     34|			  sizeof(dev->info.model_number));
  588|     34|		os_memcpy(dev->info.model_number, msg->model_number,
  ------------------
  |  |  523|     34|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  589|     34|			  msg->model_number_len);
  590|     34|	}
  591|       |
  592|  2.32k|	if (msg->serial_number &&
  ------------------
  |  Branch (592:6): [True: 37, False: 2.28k]
  ------------------
  593|     37|	    msg->serial_number_len < sizeof(dev->info.serial_number)) {
  ------------------
  |  Branch (593:6): [True: 37, False: 0]
  ------------------
  594|     37|		os_memset(dev->info.serial_number, 0,
  ------------------
  |  |  529|     37|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  595|     37|			  sizeof(dev->info.serial_number));
  596|     37|		os_memcpy(dev->info.serial_number, msg->serial_number,
  ------------------
  |  |  523|     37|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  597|     37|			  msg->serial_number_len);
  598|     37|	}
  599|       |
  600|  2.32k|	if (msg->pri_dev_type)
  ------------------
  |  Branch (600:6): [True: 539, False: 1.78k]
  ------------------
  601|    539|		os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type,
  ------------------
  |  |  523|    539|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  602|  2.32k|			  sizeof(dev->info.pri_dev_type));
  603|  1.78k|	else if (msg->wps_pri_dev_type)
  ------------------
  |  Branch (603:11): [True: 9, False: 1.77k]
  ------------------
  604|      9|		os_memcpy(dev->info.pri_dev_type, msg->wps_pri_dev_type,
  ------------------
  |  |  523|      9|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  605|  2.32k|			  sizeof(dev->info.pri_dev_type));
  606|       |
  607|  2.32k|	if (msg->wps_sec_dev_type_list) {
  ------------------
  |  Branch (607:6): [True: 6, False: 2.31k]
  ------------------
  608|      6|		os_memcpy(dev->info.wps_sec_dev_type_list,
  ------------------
  |  |  523|      6|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  609|      6|			  msg->wps_sec_dev_type_list,
  610|      6|			  msg->wps_sec_dev_type_list_len);
  611|      6|		dev->info.wps_sec_dev_type_list_len =
  612|      6|			msg->wps_sec_dev_type_list_len;
  613|      6|	}
  614|       |
  615|  2.32k|	if (msg->capability) {
  ------------------
  |  Branch (615:6): [True: 170, False: 2.15k]
  ------------------
  616|       |		/*
  617|       |		 * P2P Client Discoverability bit is reserved in all frames
  618|       |		 * that use this function, so do not change its value here.
  619|       |		 */
  620|    170|		dev->info.dev_capab &= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1911|    170|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    170|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  621|    170|		dev->info.dev_capab |= msg->capability[0] &
  622|    170|			~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1911|    170|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    170|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  623|    170|		dev->info.group_capab = msg->capability[1];
  624|    170|	}
  625|       |
  626|  2.32k|	p2p_update_peer_6ghz_capab(dev, msg);
  627|       |
  628|  2.32k|	if (msg->ext_listen_timing) {
  ------------------
  |  Branch (628:6): [True: 8, False: 2.31k]
  ------------------
  629|      8|		dev->ext_listen_period = WPA_GET_LE16(msg->ext_listen_timing);
  630|      8|		dev->ext_listen_interval =
  631|      8|			WPA_GET_LE16(msg->ext_listen_timing + 2);
  632|      8|	}
  633|       |
  634|  2.32k|	if (!probe_req) {
  ------------------
  |  Branch (634:6): [True: 1.97k, False: 345]
  ------------------
  635|  1.97k|		u16 new_config_methods;
  636|  1.97k|		new_config_methods = msg->config_methods ?
  ------------------
  |  Branch (636:24): [True: 509, False: 1.46k]
  ------------------
  637|  1.46k|			msg->config_methods : msg->wps_config_methods;
  638|  1.97k|		if (new_config_methods &&
  ------------------
  |  Branch (638:7): [True: 605, False: 1.37k]
  ------------------
  639|    605|		    dev->info.config_methods != new_config_methods) {
  ------------------
  |  Branch (639:7): [True: 564, False: 41]
  ------------------
  640|    564|			p2p_dbg(p2p, "Update peer " MACSTR
  641|    564|				" config_methods 0x%x -> 0x%x",
  642|    564|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|    564|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  643|    564|				dev->info.config_methods,
  644|    564|				new_config_methods);
  645|    564|			dev->info.config_methods = new_config_methods;
  646|    564|		}
  647|  1.97k|	}
  648|  2.32k|}
p2p.c:p2p_compare_wfd_info:
  704|  1.95k|{
  705|  1.95k|	if (dev->info.wfd_subelems && msg->wfd_subelems) {
  ------------------
  |  Branch (705:6): [True: 207, False: 1.75k]
  |  Branch (705:32): [True: 198, False: 9]
  ------------------
  706|    198|		if (dev->info.wfd_subelems->used != msg->wfd_subelems->used)
  ------------------
  |  Branch (706:7): [True: 38, False: 160]
  ------------------
  707|     38|			return 1;
  708|       |
  709|    160|		return os_memcmp(dev->info.wfd_subelems->buf,
  ------------------
  |  |  532|    160|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  710|    198|				 msg->wfd_subelems->buf,
  711|    198|				 dev->info.wfd_subelems->used);
  712|    198|	}
  713|  1.75k|	if (dev->info.wfd_subelems || msg->wfd_subelems)
  ------------------
  |  Branch (713:6): [True: 9, False: 1.75k]
  |  Branch (713:32): [True: 236, False: 1.51k]
  ------------------
  714|    245|		return 1;
  715|       |
  716|  1.51k|	return 0;
  717|  1.75k|}
p2p.c:p2p_add_group_clients:
  485|  1.34k|{
  486|  1.34k|	struct p2p_group_info info;
  487|  1.34k|	size_t c;
  488|  1.34k|	struct p2p_device *dev;
  489|       |
  490|  1.34k|	if (gi == NULL)
  ------------------
  |  Branch (490:6): [True: 1.17k, False: 165]
  ------------------
  491|  1.17k|		return 0;
  492|       |
  493|    165|	if (p2p_group_info_parse(gi, gi_len, &info) < 0)
  ------------------
  |  Branch (493:6): [True: 83, False: 82]
  ------------------
  494|     83|		return -1;
  495|       |
  496|       |	/*
  497|       |	 * Clear old data for this group; if the devices are still in the
  498|       |	 * group, the information will be restored in the loop following this.
  499|       |	 */
  500|     82|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|    165|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|    165|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|    164|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 82, False: 82]
  |  |  ------------------
  |  |   81|     82|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|     82|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  501|     82|		if (ether_addr_equal(dev->member_in_go_iface,
  ------------------
  |  Branch (501:7): [True: 0, False: 82]
  ------------------
  502|     82|				     go_interface_addr)) {
  503|      0|			os_memset(dev->member_in_go_iface, 0, ETH_ALEN);
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  504|      0|			os_memset(dev->member_in_go_dev, 0, ETH_ALEN);
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  505|      0|		}
  506|     82|	}
  507|       |
  508|    258|	for (c = 0; c < info.num_clients; c++) {
  ------------------
  |  Branch (508:14): [True: 176, False: 82]
  ------------------
  509|    176|		struct p2p_client_info *cli = &info.client[c];
  510|    176|		if (ether_addr_equal(cli->p2p_device_addr, p2p->cfg->dev_addr))
  ------------------
  |  Branch (510:7): [True: 12, False: 164]
  ------------------
  511|     12|			continue; /* ignore our own entry */
  512|    164|		dev = p2p_get_device(p2p, cli->p2p_device_addr);
  513|    164|		if (dev) {
  ------------------
  |  Branch (513:7): [True: 23, False: 141]
  ------------------
  514|     23|			if (dev->flags & (P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|     23|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|     23|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (514:8): [True: 12, False: 11]
  ------------------
  515|     23|					  P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     23|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     23|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  516|       |				/*
  517|       |				 * Update information since we have not
  518|       |				 * received this directly from the client.
  519|       |				 */
  520|     12|				p2p_copy_client_info(dev, cli);
  521|     12|			} else {
  522|       |				/*
  523|       |				 * Need to update P2P Client Discoverability
  524|       |				 * flag since it is valid only in P2P Group
  525|       |				 * Info attribute.
  526|       |				 */
  527|     11|				dev->info.dev_capab &=
  528|     11|					~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1911|     11|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|     11|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  529|     11|				dev->info.dev_capab |=
  530|     11|					cli->dev_capab &
  531|     11|					P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1911|     11|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|     11|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  532|     11|			}
  533|     23|			if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
  ------------------
  |  |  127|     23|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     23|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (533:8): [True: 0, False: 23]
  ------------------
  534|      0|				dev->flags &= ~P2P_DEV_PROBE_REQ_ONLY;
  ------------------
  |  |  127|      0|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  535|      0|			}
  536|    141|		} else {
  537|    141|			dev = p2p_create_device(p2p, cli->p2p_device_addr);
  538|    141|			if (dev == NULL)
  ------------------
  |  Branch (538:8): [True: 0, False: 141]
  ------------------
  539|      0|				continue;
  540|    141|			dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY;
  ------------------
  |  |  137|    141|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|    141|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  541|    141|			p2p_copy_client_info(dev, cli);
  542|    141|			dev->oper_freq = freq;
  543|    141|			p2p->cfg->dev_found(p2p->cfg->cb_ctx,
  544|    141|					    dev->info.p2p_device_addr,
  545|    141|					    &dev->info, 1);
  546|    141|			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    141|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    141|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    141|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    141|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  547|    141|		}
  548|       |
  549|    164|		os_memcpy(dev->interface_addr, cli->p2p_interface_addr,
  ------------------
  |  |  523|    164|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  550|    164|			  ETH_ALEN);
  551|    164|		os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|    164|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  552|    164|		os_memcpy(dev->member_in_go_dev, go_dev_addr, ETH_ALEN);
  ------------------
  |  |  523|    164|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  553|    164|		os_memcpy(dev->member_in_go_iface, go_interface_addr,
  ------------------
  |  |  523|    164|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  554|    164|			  ETH_ALEN);
  555|    164|		dev->flags |= P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT;
  ------------------
  |  |  147|    164|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|    164|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  556|    164|	}
  557|       |
  558|     82|	return 0;
  559|    165|}
p2p.c:p2p_copy_client_info:
  466|    153|{
  467|    153|	p2p_copy_filter_devname(dev->info.device_name,
  468|    153|				sizeof(dev->info.device_name),
  469|    153|				cli->dev_name, cli->dev_name_len);
  470|    153|	dev->info.dev_capab = cli->dev_capab;
  471|    153|	dev->info.config_methods = cli->config_methods;
  472|    153|	os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);
  ------------------
  |  |  523|    153|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  473|    153|	dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types;
  474|    153|	if (dev->info.wps_sec_dev_type_list_len > WPS_SEC_DEV_TYPE_MAX_LEN)
  ------------------
  |  |   62|    153|#define WPS_SEC_DEV_TYPE_MAX_LEN 128
  ------------------
  |  Branch (474:6): [True: 3, False: 150]
  ------------------
  475|      3|		dev->info.wps_sec_dev_type_list_len = WPS_SEC_DEV_TYPE_MAX_LEN;
  ------------------
  |  |   62|      3|#define WPS_SEC_DEV_TYPE_MAX_LEN 128
  ------------------
  476|    153|	os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types,
  ------------------
  |  |  523|    153|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  477|    153|		  dev->info.wps_sec_dev_type_list_len);
  478|    153|}
p2p.c:p2p_update_peer_vendor_elems:
  662|  1.95k|{
  663|  1.95k|	const u8 *pos, *end;
  664|  1.95k|	u8 id, len;
  665|       |
  666|  1.95k|	wpabuf_free(dev->info.vendor_elems);
  667|  1.95k|	dev->info.vendor_elems = NULL;
  668|       |
  669|  1.95k|	end = ies + ies_len;
  670|       |
  671|  12.2M|	for (pos = ies; end - pos > 1; pos += len) {
  ------------------
  |  Branch (671:18): [True: 12.2M, False: 1.90k]
  ------------------
  672|  12.2M|		id = *pos++;
  673|  12.2M|		len = *pos++;
  674|       |
  675|  12.2M|		if (len > end - pos)
  ------------------
  |  Branch (675:7): [True: 14, False: 12.2M]
  ------------------
  676|     14|			break;
  677|       |
  678|  12.2M|		if (id != WLAN_EID_VENDOR_SPECIFIC || len < 3)
  ------------------
  |  |  496|  24.5M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (678:7): [True: 12.2M, False: 23.1k]
  |  Branch (678:41): [True: 646, False: 22.5k]
  ------------------
  679|  12.2M|			continue;
  680|       |
  681|  22.5k|		if (len >= 4) {
  ------------------
  |  Branch (681:7): [True: 21.6k, False: 912]
  ------------------
  682|  21.6k|			u32 type = WPA_GET_BE32(pos);
  683|       |
  684|  21.6k|			if (type == WPA_IE_VENDOR_TYPE ||
  ------------------
  |  | 1571|  43.2k|#define WPA_IE_VENDOR_TYPE 0x0050f201
  ------------------
  |  Branch (684:8): [True: 995, False: 20.6k]
  ------------------
  685|  20.6k|			    type == WMM_IE_VENDOR_TYPE ||
  ------------------
  |  | 1572|  42.2k|#define WMM_IE_VENDOR_TYPE 0x0050f202
  ------------------
  |  Branch (685:8): [True: 314, False: 20.3k]
  ------------------
  686|  20.3k|			    type == WPS_IE_VENDOR_TYPE ||
  ------------------
  |  | 1573|  41.9k|#define WPS_IE_VENDOR_TYPE 0x0050f204
  ------------------
  |  Branch (686:8): [True: 2.00k, False: 18.3k]
  ------------------
  687|  18.3k|			    type == P2P_IE_VENDOR_TYPE ||
  ------------------
  |  | 1575|  39.9k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (687:8): [True: 7.30k, False: 11.0k]
  ------------------
  688|  11.0k|			    type == WFD_IE_VENDOR_TYPE)
  ------------------
  |  | 1577|  11.0k|#define WFD_IE_VENDOR_TYPE 0x506f9a0a
  ------------------
  |  Branch (688:8): [True: 5.72k, False: 5.30k]
  ------------------
  689|  16.3k|				continue;
  690|  21.6k|		}
  691|       |
  692|       |		/* Unknown vendor element - make raw IE data available */
  693|  6.21k|		if (wpabuf_resize(&dev->info.vendor_elems, 2 + len) < 0)
  ------------------
  |  Branch (693:7): [True: 0, False: 6.21k]
  ------------------
  694|      0|			break;
  695|  6.21k|		wpabuf_put_data(dev->info.vendor_elems, pos - 2, 2 + len);
  696|  6.21k|		if (wpabuf_size(dev->info.vendor_elems) > 2000)
  ------------------
  |  Branch (696:7): [True: 39, False: 6.17k]
  ------------------
  697|     39|			break;
  698|  6.21k|	}
  699|  1.95k|}
p2p.c:p2p_device_free:
  943|  1.97k|{
  944|  1.97k|	int i;
  945|       |
  946|  1.97k|	if (p2p->go_neg_peer == dev) {
  ------------------
  |  Branch (946:6): [True: 0, False: 1.97k]
  ------------------
  947|       |		/*
  948|       |		 * If GO Negotiation is in progress, report that it has failed.
  949|       |		 */
  950|      0|		p2p_go_neg_failed(p2p, -1);
  951|      0|	}
  952|  1.97k|	if (p2p->invite_peer == dev)
  ------------------
  |  Branch (952:6): [True: 0, False: 1.97k]
  ------------------
  953|      0|		p2p->invite_peer = NULL;
  954|  1.97k|	if (p2p->sd_peer == dev)
  ------------------
  |  Branch (954:6): [True: 0, False: 1.97k]
  ------------------
  955|      0|		p2p->sd_peer = NULL;
  956|  1.97k|	if (p2p->pending_client_disc_go == dev)
  ------------------
  |  Branch (956:6): [True: 0, False: 1.97k]
  ------------------
  957|      0|		p2p->pending_client_disc_go = NULL;
  958|       |
  959|       |	/* dev_lost() device, but only if it was previously dev_found() */
  960|  1.97k|	if (dev->flags & P2P_DEV_REPORTED_ONCE)
  ------------------
  |  |  140|  1.97k|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|  1.97k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (960:6): [True: 620, False: 1.35k]
  ------------------
  961|    620|		p2p->cfg->dev_lost(p2p->cfg->cb_ctx,
  962|    620|				   dev->info.p2p_device_addr);
  963|       |
  964|  21.7k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  21.7k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (964:14): [True: 19.7k, False: 1.97k]
  ------------------
  965|  19.7k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  966|  19.7k|		dev->info.wps_vendor_ext[i] = NULL;
  967|  19.7k|	}
  968|       |
  969|  1.97k|	os_free(dev->bootstrap_params);
  ------------------
  |  |  511|  1.97k|#define os_free(p) free((p))
  ------------------
  970|       |
  971|  1.97k|	wpabuf_free(dev->action_frame_wrapper);
  972|       |
  973|       |#ifdef CONFIG_PASN
  974|       |	if (dev->pasn) {
  975|       |		wpa_pasn_reset(dev->pasn);
  976|       |		pasn_data_deinit(dev->pasn);
  977|       |	}
  978|       |#endif /* CONFIG_PASN */
  979|       |
  980|  1.97k|	wpabuf_free(dev->info.wfd_subelems);
  981|  1.97k|	wpabuf_free(dev->info.vendor_elems);
  982|  1.97k|	wpabuf_free(dev->go_neg_conf);
  983|  1.97k|	wpabuf_free(dev->info.p2ps_instance);
  984|       |
  985|  1.97k|	os_free(dev);
  ------------------
  |  |  511|  1.97k|#define os_free(p) free((p))
  ------------------
  986|  1.97k|}
p2p.c:p2p_free_req_dev_types:
 1160|  13.7k|{
 1161|  13.7k|	p2p->num_req_dev_types = 0;
 1162|  13.7k|	os_free(p2p->req_dev_types);
  ------------------
  |  |  511|  13.7k|#define os_free(p) free((p))
  ------------------
 1163|       |	p2p->req_dev_types = NULL;
 1164|  13.7k|}
p2p.c:p2ps_gen_hash:
 1168|  6.88k|{
 1169|  6.88k|	u8 buf[SHA256_MAC_LEN];
 1170|  6.88k|	char str_buf[256];
 1171|  6.88k|	const u8 *adv_array;
 1172|  6.88k|	size_t i, adv_len;
 1173|       |
 1174|  6.88k|	if (!str || !hash)
  ------------------
  |  Branch (1174:6): [True: 0, False: 6.88k]
  |  Branch (1174:14): [True: 0, False: 6.88k]
  ------------------
 1175|      0|		return 0;
 1176|       |
 1177|  6.88k|	if (!str[0]) {
  ------------------
  |  Branch (1177:6): [True: 0, False: 6.88k]
  ------------------
 1178|      0|		os_memcpy(hash, p2p->wild_card_hash, P2PS_HASH_LEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1179|      0|		return 1;
 1180|      0|	}
 1181|       |
 1182|  6.88k|	adv_array = (u8 *) str_buf;
 1183|  6.88k|	adv_len = os_strlen(str);
  ------------------
  |  |  536|  6.88k|#define os_strlen(s) strlen(s)
  ------------------
 1184|  6.88k|	if (adv_len >= sizeof(str_buf))
  ------------------
  |  Branch (1184:6): [True: 0, False: 6.88k]
  ------------------
 1185|      0|		return 0;
 1186|       |
 1187|   103k|	for (i = 0; i < adv_len; i++) {
  ------------------
  |  Branch (1187:14): [True: 96.3k, False: 6.88k]
  ------------------
 1188|  96.3k|		if (str[i] >= 'A' && str[i] <= 'Z')
  ------------------
  |  Branch (1188:7): [True: 75.6k, False: 20.6k]
  |  Branch (1188:24): [True: 0, False: 75.6k]
  ------------------
 1189|      0|			str_buf[i] = str[i] - 'A' + 'a';
 1190|  96.3k|		else
 1191|  96.3k|			str_buf[i] = str[i];
 1192|  96.3k|	}
 1193|       |
 1194|  6.88k|	if (sha256_vector(1, &adv_array, &adv_len, buf))
  ------------------
  |  Branch (1194:6): [True: 0, False: 6.88k]
  ------------------
 1195|      0|		return 0;
 1196|       |
 1197|  6.88k|	os_memcpy(hash, buf, P2PS_HASH_LEN);
  ------------------
  |  |  523|  6.88k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1198|  6.88k|	return 1;
 1199|  6.88k|}
p2p.c:p2p_rx_action_public:
 2079|  2.22k|{
 2080|  2.22k|	if (len < 1)
  ------------------
  |  Branch (2080:6): [True: 4, False: 2.21k]
  ------------------
 2081|      4|		return;
 2082|       |
 2083|  2.21k|	switch (data[0]) {
  ------------------
  |  Branch (2083:10): [True: 2.19k, False: 19]
  ------------------
 2084|  2.16k|	case WLAN_PA_VENDOR_SPECIFIC:
  ------------------
  |  |  777|  2.16k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
  |  Branch (2084:2): [True: 2.16k, False: 50]
  ------------------
 2085|  2.16k|		data++;
 2086|  2.16k|		len--;
 2087|  2.16k|		if (len < 4)
  ------------------
  |  Branch (2087:7): [True: 2, False: 2.16k]
  ------------------
 2088|      2|			return;
 2089|  2.16k|		if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
  ------------------
  |  | 1575|  2.16k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (2089:7): [True: 22, False: 2.14k]
  ------------------
 2090|     22|			return;
 2091|       |
 2092|  2.14k|		data += 4;
 2093|  2.14k|		len -= 4;
 2094|       |
 2095|  2.14k|		p2p_rx_p2p_action(p2p, sa, data, len, freq);
 2096|  2.14k|		break;
 2097|      3|	case WLAN_PA_GAS_INITIAL_REQ:
  ------------------
  |  |  778|      3|#define WLAN_PA_GAS_INITIAL_REQ 10
  ------------------
  |  Branch (2097:2): [True: 3, False: 2.21k]
  ------------------
 2098|      3|		p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq);
 2099|      3|		break;
 2100|      1|	case WLAN_PA_GAS_INITIAL_RESP:
  ------------------
  |  |  779|      1|#define WLAN_PA_GAS_INITIAL_RESP 11
  ------------------
  |  Branch (2100:2): [True: 1, False: 2.21k]
  ------------------
 2101|      1|		p2p_rx_gas_initial_resp(p2p, sa, data + 1, len - 1, freq);
 2102|      1|		break;
 2103|     26|	case WLAN_PA_GAS_COMEBACK_REQ:
  ------------------
  |  |  780|     26|#define WLAN_PA_GAS_COMEBACK_REQ 12
  ------------------
  |  Branch (2103:2): [True: 26, False: 2.19k]
  ------------------
 2104|     26|		p2p_rx_gas_comeback_req(p2p, sa, data + 1, len - 1, freq);
 2105|     26|		break;
 2106|      1|	case WLAN_PA_GAS_COMEBACK_RESP:
  ------------------
  |  |  781|      1|#define WLAN_PA_GAS_COMEBACK_RESP 13
  ------------------
  |  Branch (2106:2): [True: 1, False: 2.21k]
  ------------------
 2107|      1|		p2p_rx_gas_comeback_resp(p2p, sa, data + 1, len - 1, freq);
 2108|      1|		break;
 2109|  2.21k|	}
 2110|  2.21k|}
p2p.c:p2p_rx_p2p_action:
 2033|  2.14k|{
 2034|  2.14k|	p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|  2.14k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|  2.14k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2035|  2.14k|	wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Public Action contents", data, len);
 2036|       |
 2037|  2.14k|	if (len < 1)
  ------------------
  |  Branch (2037:6): [True: 2, False: 2.14k]
  ------------------
 2038|      2|		return;
 2039|       |
 2040|  2.14k|	switch (data[0]) {
 2041|     75|	case P2P_GO_NEG_REQ:
  ------------------
  |  Branch (2041:2): [True: 75, False: 2.06k]
  ------------------
 2042|     75|		p2p_handle_go_neg_req(p2p, sa, data + 1, len - 1, rx_freq);
 2043|     75|		break;
 2044|      3|	case P2P_GO_NEG_RESP:
  ------------------
  |  Branch (2044:2): [True: 3, False: 2.13k]
  ------------------
 2045|      3|		p2p_handle_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq);
 2046|      3|		break;
 2047|      2|	case P2P_GO_NEG_CONF:
  ------------------
  |  Branch (2047:2): [True: 2, False: 2.13k]
  ------------------
 2048|      2|		p2p_handle_go_neg_conf(p2p, sa, data + 1, len - 1, false);
 2049|      2|		break;
 2050|    909|	case P2P_INVITATION_REQ:
  ------------------
  |  Branch (2050:2): [True: 909, False: 1.23k]
  ------------------
 2051|    909|		p2p_handle_invitation_req(p2p, sa, data + 1, len - 1, rx_freq);
 2052|    909|		break;
 2053|      5|	case P2P_INVITATION_RESP:
  ------------------
  |  Branch (2053:2): [True: 5, False: 2.13k]
  ------------------
 2054|      5|		p2p_process_invitation_resp(p2p, sa, data + 1, len - 1);
 2055|      5|		break;
 2056|  1.10k|	case P2P_PROV_DISC_REQ:
  ------------------
  |  Branch (2056:2): [True: 1.10k, False: 1.04k]
  ------------------
 2057|  1.10k|		p2p_handle_prov_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2058|  1.10k|		break;
 2059|     35|	case P2P_PROV_DISC_RESP:
  ------------------
  |  Branch (2059:2): [True: 35, False: 2.10k]
  ------------------
 2060|     35|		p2p_handle_prov_disc_resp(p2p, sa, data + 1, len - 1, rx_freq);
 2061|     35|		break;
 2062|      7|	case P2P_DEV_DISC_REQ:
  ------------------
  |  Branch (2062:2): [True: 7, False: 2.13k]
  ------------------
 2063|      7|		p2p_process_dev_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2064|      7|		break;
 2065|      1|	case P2P_DEV_DISC_RESP:
  ------------------
  |  Branch (2065:2): [True: 1, False: 2.14k]
  ------------------
 2066|      1|		p2p_process_dev_disc_resp(p2p, sa, data + 1, len - 1);
 2067|      1|		break;
 2068|      4|	default:
  ------------------
  |  Branch (2068:2): [True: 4, False: 2.13k]
  ------------------
 2069|      4|		p2p_dbg(p2p, "Unsupported P2P Public Action frame type %d",
 2070|      4|			data[0]);
 2071|      4|		break;
 2072|  2.14k|	}
 2073|  2.14k|}
p2p.c:p2p_add_dev_from_probe_req:
 2199|  6.88k|{
 2200|  6.88k|	struct p2p_message msg;
 2201|  6.88k|	struct p2p_device *dev;
 2202|       |
 2203|  6.88k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2204|  6.88k|	if (p2p_parse_ies(ie, ie_len, &msg) < 0 || msg.p2p_attributes == NULL)
  ------------------
  |  Branch (2204:6): [True: 2.47k, False: 4.40k]
  |  Branch (2204:45): [True: 2.45k, False: 1.94k]
  ------------------
 2205|  4.93k|	{
 2206|  4.93k|		p2p_parse_free(&msg);
 2207|  4.93k|		return; /* not a P2P probe */
 2208|  4.93k|	}
 2209|       |
 2210|  1.94k|	if (msg.ssid == NULL || msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1994|  2.96k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (2210:6): [True: 925, False: 1.01k]
  |  Branch (2210:26): [True: 465, False: 554]
  ------------------
 2211|    554|	    os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    554|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (2211:6): [True: 114, False: 440]
  ------------------
 2212|  1.50k|	    != 0) {
 2213|       |		/* The Probe Request is not part of P2P Device Discovery. It is
 2214|       |		 * not known whether the source address of the frame is the P2P
 2215|       |		 * Device Address or P2P Interface Address. Do not add a new
 2216|       |		 * peer entry based on this frames.
 2217|       |		 */
 2218|  1.50k|		p2p_parse_free(&msg);
 2219|  1.50k|		return;
 2220|  1.50k|	}
 2221|       |
 2222|    440|	dev = p2p_get_device(p2p, addr);
 2223|    440|	if (dev) {
  ------------------
  |  Branch (2223:6): [True: 95, False: 345]
  ------------------
 2224|     95|		if (msg.listen_channel) {
  ------------------
  |  Branch (2224:7): [True: 74, False: 21]
  ------------------
 2225|     74|			int freq;
 2226|       |
 2227|     74|			if (dev->country[0] == 0)
  ------------------
  |  Branch (2227:8): [True: 74, False: 0]
  ------------------
 2228|     74|				os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|     74|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2229|       |
 2230|     74|			freq = p2p_channel_to_freq(msg.listen_channel[3],
 2231|     74|						   msg.listen_channel[4]);
 2232|       |
 2233|     74|			if (freq > 0 && dev->listen_freq != freq) {
  ------------------
  |  Branch (2233:8): [True: 54, False: 20]
  |  Branch (2233:20): [True: 53, False: 1]
  ------------------
 2234|     53|				p2p_dbg(p2p,
 2235|     53|					"Updated peer " MACSTR " Listen channel (Probe Request): %d -> %d MHz",
 2236|     53|					MAC2STR(addr), dev->listen_freq, freq);
  ------------------
  |  |  447|     53|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2237|     53|				dev->listen_freq = freq;
 2238|     53|			}
 2239|     74|		}
 2240|       |
 2241|     95|		p2p_update_peer_6ghz_capab(dev, &msg);
 2242|     95|		os_get_reltime(&dev->last_seen);
 2243|     95|		p2p_parse_free(&msg);
 2244|     95|		return; /* already known */
 2245|     95|	}
 2246|       |
 2247|    345|	dev = p2p_create_device(p2p, addr);
 2248|    345|	if (dev == NULL) {
  ------------------
  |  Branch (2248:6): [True: 0, False: 345]
  ------------------
 2249|      0|		p2p_parse_free(&msg);
 2250|      0|		return;
 2251|      0|	}
 2252|       |
 2253|    345|	os_get_reltime(&dev->last_seen);
 2254|    345|	dev->flags |= P2P_DEV_PROBE_REQ_ONLY;
  ------------------
  |  |  127|    345|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    345|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2255|       |
 2256|    345|	if (msg.listen_channel) {
  ------------------
  |  Branch (2256:6): [True: 261, False: 84]
  ------------------
 2257|    261|		os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|    261|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2258|    261|		dev->listen_freq = p2p_channel_to_freq(msg.listen_channel[3],
 2259|    261|						       msg.listen_channel[4]);
 2260|    261|	}
 2261|       |
 2262|    345|	p2p_copy_wps_info(p2p, dev, 1, &msg);
 2263|       |
 2264|    345|	if (msg.wfd_subelems) {
  ------------------
  |  Branch (2264:6): [True: 34, False: 311]
  ------------------
 2265|     34|		wpabuf_free(dev->info.wfd_subelems);
 2266|     34|		dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 2267|     34|	}
 2268|       |
 2269|    345|	p2p_parse_free(&msg);
 2270|       |
 2271|    345|	p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR
 2272|    345|		" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
 2273|    345|		MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
  ------------------
  |  |  447|    345|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2274|    345|		dev->info.group_capab, dev->info.device_name,
 2275|    345|		dev->listen_freq);
 2276|    345|}
p2p.c:p2p_reply_probe:
 2506|  6.88k|{
 2507|  6.88k|	struct ieee802_11_elems elems;
 2508|  6.88k|	struct wpabuf *buf;
 2509|  6.88k|	struct p2p_message msg;
 2510|  6.88k|	struct wpabuf *ies;
 2511|       |
 2512|  6.88k|	if (ieee802_11_parse_elems((u8 *) ie, ie_len, &elems, 0) ==
  ------------------
  |  Branch (2512:6): [True: 1.05k, False: 5.82k]
  ------------------
 2513|  6.88k|	    ParseFailed) {
 2514|       |		/* Ignore invalid Probe Request frames */
 2515|  1.05k|		p2p_dbg(p2p, "Could not parse Probe Request frame - ignore it");
 2516|  1.05k|		return P2P_PREQ_MALFORMED;
 2517|  1.05k|	}
 2518|       |
 2519|  5.82k|	if (elems.p2p == NULL) {
  ------------------
  |  Branch (2519:6): [True: 3.30k, False: 2.52k]
  ------------------
 2520|       |		/* not a P2P probe - ignore it */
 2521|  3.30k|		p2p_dbg(p2p, "Not a P2P probe - ignore it");
 2522|  3.30k|		return P2P_PREQ_NOT_P2P;
 2523|  3.30k|	}
 2524|       |
 2525|  2.52k|	if (dst && !is_broadcast_ether_addr(dst) &&
  ------------------
  |  Branch (2525:6): [True: 2.52k, False: 0]
  |  Branch (2525:13): [True: 2.52k, False: 0]
  ------------------
 2526|  2.52k|	    !ether_addr_equal(dst, p2p->cfg->dev_addr)) {
  ------------------
  |  Branch (2526:6): [True: 2.52k, False: 0]
  ------------------
 2527|       |		/* Not sent to the broadcast address or our P2P Device Address
 2528|       |		 */
 2529|  2.52k|		p2p_dbg(p2p, "Probe Req DA " MACSTR " not ours - ignore it",
 2530|  2.52k|			MAC2STR(dst));
  ------------------
  |  |  447|  2.52k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2531|  2.52k|		return P2P_PREQ_NOT_PROCESSED;
 2532|  2.52k|	}
 2533|       |
 2534|      0|	if (bssid && !is_broadcast_ether_addr(bssid)) {
  ------------------
  |  Branch (2534:6): [True: 0, False: 0]
  |  Branch (2534:15): [True: 0, False: 0]
  ------------------
 2535|       |		/* Not sent to the Wildcard BSSID */
 2536|      0|		p2p_dbg(p2p, "Probe Req BSSID " MACSTR " not wildcard - ignore it",
 2537|      0|			MAC2STR(bssid));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2538|      0|		return P2P_PREQ_NOT_PROCESSED;
 2539|      0|	}
 2540|       |
 2541|      0|	if (elems.ssid == NULL || elems.ssid_len != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1994|      0|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (2541:6): [True: 0, False: 0]
  |  Branch (2541:28): [True: 0, False: 0]
  ------------------
 2542|      0|	    os_memcmp(elems.ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN) !=
  ------------------
  |  |  532|      0|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (2542:6): [True: 0, False: 0]
  ------------------
 2543|      0|	    0) {
 2544|       |		/* not using P2P Wildcard SSID - ignore */
 2545|      0|		p2p_dbg(p2p, "Probe Req not using P2P Wildcard SSID - ignore it");
 2546|      0|		return P2P_PREQ_NOT_PROCESSED;
 2547|      0|	}
 2548|       |
 2549|      0|	if (supp_rates_11b_only(&elems)) {
  ------------------
  |  Branch (2549:6): [True: 0, False: 0]
  ------------------
 2550|       |		/* Indicates support for 11b rates only */
 2551|      0|		p2p_dbg(p2p, "Probe Req with 11b rates only supported - ignore it");
 2552|      0|		return P2P_PREQ_NOT_P2P;
 2553|      0|	}
 2554|       |
 2555|      0|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2556|      0|	if (p2p_parse_ies(ie, ie_len, &msg) < 0) {
  ------------------
  |  Branch (2556:6): [True: 0, False: 0]
  ------------------
 2557|       |		/* Could not parse P2P attributes */
 2558|      0|		p2p_dbg(p2p, "Could not parse P2P attributes in Probe Req - ignore it");
 2559|      0|		return P2P_PREQ_NOT_P2P;
 2560|      0|	}
 2561|       |
 2562|      0|	if (msg.service_hash && msg.service_hash_count) {
  ------------------
  |  Branch (2562:6): [True: 0, False: 0]
  |  Branch (2562:26): [True: 0, False: 0]
  ------------------
 2563|      0|		const u8 *hash = msg.service_hash;
 2564|      0|		u8 i;
 2565|      0|		int p2ps_svc_found = 0;
 2566|       |
 2567|      0|		p2p_dbg(p2p, "in_listen=%d drv_in_listen=%d when received P2PS Probe Request at %u MHz; own Listen channel %u, pending listen freq %u MHz",
 2568|      0|			p2p->in_listen, p2p->drv_in_listen, rx_freq,
 2569|      0|			p2p->cfg->channel, p2p->pending_listen_freq);
 2570|       |
 2571|      0|		if (!p2p->in_listen && !p2p->drv_in_listen &&
  ------------------
  |  Branch (2571:7): [True: 0, False: 0]
  |  Branch (2571:26): [True: 0, False: 0]
  ------------------
 2572|      0|		    p2p->pending_listen_freq && rx_freq &&
  ------------------
  |  Branch (2572:7): [True: 0, False: 0]
  |  Branch (2572:35): [True: 0, False: 0]
  ------------------
 2573|      0|		    rx_freq != p2p->pending_listen_freq) {
  ------------------
  |  Branch (2573:7): [True: 0, False: 0]
  ------------------
 2574|      0|			p2p_dbg(p2p, "Do not reply to Probe Request frame that was received on %u MHz while waiting to start Listen state on %u MHz",
 2575|      0|				rx_freq, p2p->pending_listen_freq);
 2576|      0|			p2p_parse_free(&msg);
 2577|      0|			return P2P_PREQ_NOT_LISTEN;
 2578|      0|		}
 2579|       |
 2580|      0|		for (i = 0; i < msg.service_hash_count; i++) {
  ------------------
  |  Branch (2580:15): [True: 0, False: 0]
  ------------------
 2581|      0|			if (p2p_service_find_asp(p2p, hash)) {
  ------------------
  |  Branch (2581:8): [True: 0, False: 0]
  ------------------
 2582|      0|				p2p_dbg(p2p, "Service Hash match found: "
 2583|      0|					MACSTR, MAC2STR(hash));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              					MACSTR, MAC2STR(hash));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2584|      0|				p2ps_svc_found = 1;
 2585|      0|				break;
 2586|      0|			}
 2587|      0|			hash += P2PS_HASH_LEN;
  ------------------
  |  |   35|      0|#define P2PS_HASH_LEN 6
  ------------------
 2588|      0|		}
 2589|       |
 2590|       |		/* Probed hash unknown */
 2591|      0|		if (!p2ps_svc_found) {
  ------------------
  |  Branch (2591:7): [True: 0, False: 0]
  ------------------
 2592|      0|			p2p_dbg(p2p, "No Service Hash match found");
 2593|      0|			p2p_parse_free(&msg);
 2594|      0|			return P2P_PREQ_NOT_PROCESSED;
 2595|      0|		}
 2596|      0|	} else {
 2597|       |		/* This is not a P2PS Probe Request */
 2598|      0|		p2p_dbg(p2p, "No P2PS Hash in Probe Request");
 2599|       |
 2600|      0|		if (!p2p->in_listen || !p2p->drv_in_listen) {
  ------------------
  |  Branch (2600:7): [True: 0, False: 0]
  |  Branch (2600:26): [True: 0, False: 0]
  ------------------
 2601|       |			/* not in Listen state - ignore Probe Request */
 2602|      0|			p2p_dbg(p2p, "Not in Listen state (in_listen=%d drv_in_listen=%d) - ignore Probe Request",
 2603|      0|				p2p->in_listen, p2p->drv_in_listen);
 2604|      0|			p2p_parse_free(&msg);
 2605|      0|			return P2P_PREQ_NOT_LISTEN;
 2606|      0|		}
 2607|      0|	}
 2608|       |
 2609|      0|	if (msg.device_id &&
  ------------------
  |  Branch (2609:6): [True: 0, False: 0]
  ------------------
 2610|      0|	    !ether_addr_equal(msg.device_id, p2p->cfg->dev_addr)) {
  ------------------
  |  Branch (2610:6): [True: 0, False: 0]
  ------------------
 2611|       |		/* Device ID did not match */
 2612|      0|		p2p_dbg(p2p, "Probe Req requested Device ID " MACSTR " did not match - ignore it",
 2613|      0|			MAC2STR(msg.device_id));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2614|      0|		p2p_parse_free(&msg);
 2615|      0|		return P2P_PREQ_NOT_PROCESSED;
 2616|      0|	}
 2617|       |
 2618|       |	/* Check Requested Device Type match */
 2619|      0|	if (msg.wps_attributes &&
  ------------------
  |  Branch (2619:6): [True: 0, False: 0]
  ------------------
 2620|      0|	    !p2p_match_dev_type(p2p, msg.wps_attributes)) {
  ------------------
  |  Branch (2620:6): [True: 0, False: 0]
  ------------------
 2621|       |		/* No match with Requested Device Type */
 2622|      0|		p2p_dbg(p2p, "Probe Req requested Device Type did not match - ignore it");
 2623|      0|		p2p_parse_free(&msg);
 2624|      0|		return P2P_PREQ_NOT_PROCESSED;
 2625|      0|	}
 2626|       |
 2627|      0|	if (!p2p->cfg->send_probe_resp) {
  ------------------
  |  Branch (2627:6): [True: 0, False: 0]
  ------------------
 2628|       |		/* Response generated elsewhere */
 2629|      0|		p2p_dbg(p2p, "Probe Resp generated elsewhere - do not generate additional response");
 2630|      0|		p2p_parse_free(&msg);
 2631|      0|		return P2P_PREQ_NOT_PROCESSED;
 2632|      0|	}
 2633|       |
 2634|      0|	p2p_dbg(p2p, "Reply to P2P Probe Request in Listen state");
 2635|       |
 2636|       |	/*
 2637|       |	 * We do not really have a specific BSS that this frame is advertising,
 2638|       |	 * so build a frame that has some information in valid format. This is
 2639|       |	 * really only used for discovery purposes, not to learn exact BSS
 2640|       |	 * parameters.
 2641|       |	 */
 2642|      0|	ies = p2p_build_probe_resp_ies(p2p, msg.service_hash,
 2643|      0|				       msg.service_hash_count);
 2644|      0|	p2p_parse_free(&msg);
 2645|      0|	if (ies == NULL)
  ------------------
  |  Branch (2645:6): [True: 0, False: 0]
  ------------------
 2646|      0|		return P2P_PREQ_NOT_PROCESSED;
 2647|       |
 2648|      0|	buf = wpabuf_alloc(200 + wpabuf_len(ies));
 2649|      0|	if (buf == NULL) {
  ------------------
  |  Branch (2649:6): [True: 0, False: 0]
  ------------------
 2650|      0|		wpabuf_free(ies);
 2651|      0|		return P2P_PREQ_NOT_PROCESSED;
 2652|      0|	}
 2653|       |
 2654|      0|	if (p2p_build_probe_resp_buf(p2p, buf, ies, addr, rx_freq)) {
  ------------------
  |  Branch (2654:6): [True: 0, False: 0]
  ------------------
 2655|      0|		wpabuf_free(ies);
 2656|      0|		wpabuf_free(buf);
 2657|      0|		return P2P_PREQ_NOT_PROCESSED;
 2658|      0|	}
 2659|       |
 2660|      0|	wpabuf_free(ies);
 2661|       |
 2662|      0|	p2p->cfg->send_probe_resp(p2p->cfg->cb_ctx, buf, rx_freq);
 2663|       |
 2664|      0|	wpabuf_free(buf);
 2665|       |
 2666|      0|	return P2P_PREQ_PROCESSED;
 2667|      0|}
p2p.c:p2p_pairing_info_init:
 3135|  6.88k|{
 3136|  6.88k|	struct p2p_pairing_info *pairing_info;
 3137|       |
 3138|  6.88k|	if (p2p->cfg->pairing_config.dik_len > DEVICE_IDENTITY_KEY_MAX_LEN)
  ------------------
  |  |   16|  6.88k|#define DEVICE_IDENTITY_KEY_MAX_LEN 64
  ------------------
  |  Branch (3138:6): [True: 0, False: 6.88k]
  ------------------
 3139|      0|		return -1;
 3140|       |
 3141|  6.88k|	pairing_info = os_zalloc(sizeof(struct p2p_pairing_info));
 3142|  6.88k|	if (!pairing_info)
  ------------------
  |  Branch (3142:6): [True: 0, False: 6.88k]
  ------------------
 3143|      0|		return -1;
 3144|       |
 3145|  6.88k|	pairing_info->enable_pairing_setup =
 3146|  6.88k|		p2p->cfg->pairing_config.enable_pairing_setup;
 3147|  6.88k|	pairing_info->enable_pairing_cache =
 3148|  6.88k|		p2p->cfg->pairing_config.enable_pairing_cache;
 3149|  6.88k|	pairing_info->supported_bootstrap =
 3150|  6.88k|		p2p->cfg->pairing_config.bootstrap_methods;
 3151|       |
 3152|  6.88k|	pairing_info->dev_ik.cipher_version =
 3153|  6.88k|		p2p->cfg->pairing_config.dik_cipher;
 3154|  6.88k|	pairing_info->dev_ik.dik_len = p2p->cfg->pairing_config.dik_len;
 3155|  6.88k|	os_memcpy(pairing_info->dev_ik.dik_data,
  ------------------
  |  |  523|  6.88k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3156|  6.88k|		  p2p->cfg->pairing_config.dik_data,
 3157|  6.88k|		  p2p->cfg->pairing_config.dik_len);
 3158|  6.88k|	pairing_info->dev_ik.expiration = 24; /* hours */
 3159|       |
 3160|  6.88k|	p2p_pairing_info_deinit(p2p);
 3161|       |
 3162|  6.88k|	p2p->pairing_info = pairing_info;
 3163|       |#ifdef CONFIG_PASN
 3164|       |	p2p->initiator_pmksa = pasn_initiator_pmksa_cache_init();
 3165|       |	p2p->responder_pmksa = pasn_responder_pmksa_cache_init();
 3166|       |#endif /* CONFIG_PASN */
 3167|       |
 3168|  6.88k|	return 0;
 3169|  6.88k|}
p2p.c:p2p_pairing_info_deinit:
 3125|  13.7k|{
 3126|       |#ifdef CONFIG_PASN
 3127|       |	pasn_initiator_pmksa_cache_deinit(p2p->initiator_pmksa);
 3128|       |	pasn_responder_pmksa_cache_deinit(p2p->responder_pmksa);
 3129|       |#endif /* CONFIG_PASN */
 3130|  13.7k|	os_free(p2p->pairing_info);
  ------------------
  |  |  511|  13.7k|#define os_free(p) free((p))
  ------------------
 3131|  13.7k|}
p2p.c:p2p_run_after_scan:
 1115|  6.88k|{
 1116|  6.88k|	struct p2p_device *dev;
 1117|  6.88k|	enum p2p_after_scan op;
 1118|       |
 1119|  6.88k|	op = p2p->start_after_scan;
 1120|  6.88k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1121|  6.88k|	switch (op) {
  ------------------
  |  Branch (1121:10): [True: 6.88k, False: 0]
  ------------------
 1122|  6.88k|	case P2P_AFTER_SCAN_NOTHING:
  ------------------
  |  Branch (1122:2): [True: 6.88k, False: 0]
  ------------------
 1123|  6.88k|		break;
 1124|      0|	case P2P_AFTER_SCAN_LISTEN:
  ------------------
  |  Branch (1124:2): [True: 0, False: 6.88k]
  ------------------
 1125|      0|		p2p_dbg(p2p, "Start previously requested Listen state");
 1126|      0|		p2p_listen(p2p, p2p->pending_listen_sec * 1000 +
 1127|      0|			   p2p->pending_listen_usec / 1000);
 1128|      0|		return 1;
 1129|      0|	case P2P_AFTER_SCAN_CONNECT:
  ------------------
  |  Branch (1129:2): [True: 0, False: 6.88k]
  ------------------
 1130|      0|		p2p_dbg(p2p, "Start previously requested connect with " MACSTR,
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1131|      0|			MAC2STR(p2p->after_scan_peer));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1132|      0|		dev = p2p_get_device(p2p, p2p->after_scan_peer);
 1133|      0|		if (dev == NULL) {
  ------------------
  |  Branch (1133:7): [True: 0, False: 0]
  ------------------
 1134|      0|			p2p_dbg(p2p, "Peer not known anymore");
 1135|      0|			break;
 1136|      0|		}
 1137|      0|		p2p_connect_send(p2p, dev);
 1138|      0|		return 1;
 1139|  6.88k|	}
 1140|       |
 1141|  6.88k|	return 0;
 1142|  6.88k|}
p2p.c:p2p_process_presence_req:
 4782|      1|{
 4783|      1|	struct p2p_message msg;
 4784|      1|	u8 status;
 4785|      1|	struct wpabuf *resp;
 4786|      1|	size_t g;
 4787|      1|	struct p2p_group *group = NULL;
 4788|      1|	int parsed = 0;
 4789|      1|	u8 noa[50];
 4790|      1|	int noa_len;
 4791|       |
 4792|      1|	p2p_dbg(p2p, "Received P2P Action - P2P Presence Request");
 4793|       |
 4794|      1|	for (g = 0; g < p2p->num_groups; g++) {
  ------------------
  |  Branch (4794:14): [True: 0, False: 1]
  ------------------
 4795|      0|		if (ether_addr_equal(
  ------------------
  |  Branch (4795:7): [True: 0, False: 0]
  ------------------
 4796|      0|			    da, p2p_group_get_interface_addr(p2p->groups[g]))) {
 4797|      0|			group = p2p->groups[g];
 4798|      0|			break;
 4799|      0|		}
 4800|      0|	}
 4801|      1|	if (group == NULL) {
  ------------------
  |  Branch (4801:6): [True: 1, False: 0]
  ------------------
 4802|      1|		p2p_dbg(p2p, "Ignore P2P Presence Request for unknown group "
 4803|      1|			MACSTR, MAC2STR(da));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(da));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 4804|      1|		return;
 4805|      1|	}
 4806|       |
 4807|      0|	if (p2p_parse(data, len, &msg) < 0) {
  ------------------
  |  Branch (4807:6): [True: 0, False: 0]
  ------------------
 4808|      0|		p2p_dbg(p2p, "Failed to parse P2P Presence Request");
 4809|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 4810|      0|		goto fail;
 4811|      0|	}
 4812|      0|	parsed = 1;
 4813|       |
 4814|      0|	if (msg.noa == NULL) {
  ------------------
  |  Branch (4814:6): [True: 0, False: 0]
  ------------------
 4815|      0|		p2p_dbg(p2p, "No NoA attribute in P2P Presence Request");
 4816|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 4817|      0|		goto fail;
 4818|      0|	}
 4819|       |
 4820|      0|	status = p2p_group_presence_req(group, sa, msg.noa, msg.noa_len);
 4821|       |
 4822|      0|fail:
 4823|      0|	if (p2p->cfg->get_noa)
  ------------------
  |  Branch (4823:6): [True: 0, False: 0]
  ------------------
 4824|      0|		noa_len = p2p->cfg->get_noa(p2p->cfg->cb_ctx, da, noa,
 4825|      0|					    sizeof(noa));
 4826|      0|	else
 4827|      0|		noa_len = -1;
 4828|      0|	resp = p2p_build_presence_resp(status, noa_len > 0 ? noa : NULL,
  ------------------
  |  Branch (4828:41): [True: 0, False: 0]
  ------------------
 4829|      0|				       noa_len > 0 ? noa_len : 0,
  ------------------
  |  Branch (4829:12): [True: 0, False: 0]
  ------------------
 4830|      0|				       msg.dialog_token);
 4831|      0|	if (parsed)
  ------------------
  |  Branch (4831:6): [True: 0, False: 0]
  ------------------
 4832|      0|		p2p_parse_free(&msg);
 4833|      0|	if (resp == NULL)
  ------------------
  |  Branch (4833:6): [True: 0, False: 0]
  ------------------
 4834|      0|		return;
 4835|       |
 4836|      0|	p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 4837|      0|	if (p2p_send_action(p2p, rx_freq, sa, da, da,
  ------------------
  |  Branch (4837:6): [True: 0, False: 0]
  ------------------
 4838|      0|			    wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
 4839|      0|		p2p_dbg(p2p, "Failed to send Action frame");
 4840|      0|	}
 4841|      0|	wpabuf_free(resp);
 4842|      0|}
p2p.c:p2p_process_presence_resp:
 4847|    713|{
 4848|    713|	struct p2p_message msg;
 4849|       |
 4850|    713|	p2p_dbg(p2p, "Received P2P Action - P2P Presence Response");
 4851|       |
 4852|    713|	if (p2p_parse(data, len, &msg) < 0) {
  ------------------
  |  Branch (4852:6): [True: 266, False: 447]
  ------------------
 4853|    266|		p2p_dbg(p2p, "Failed to parse P2P Presence Response");
 4854|    266|		return;
 4855|    266|	}
 4856|       |
 4857|    447|	if (msg.status == NULL || msg.noa == NULL) {
  ------------------
  |  Branch (4857:6): [True: 436, False: 11]
  |  Branch (4857:28): [True: 2, False: 9]
  ------------------
 4858|    438|		p2p_dbg(p2p, "No Status or NoA attribute in P2P Presence Response");
 4859|    438|		p2p_parse_free(&msg);
 4860|    438|		return;
 4861|    438|	}
 4862|       |
 4863|      9|	if (p2p->cfg->presence_resp) {
  ------------------
  |  Branch (4863:6): [True: 0, False: 9]
  ------------------
 4864|      0|		p2p->cfg->presence_resp(p2p->cfg->cb_ctx, sa, *msg.status,
 4865|      0|					msg.noa, msg.noa_len);
 4866|      0|	}
 4867|       |
 4868|      9|	if (*msg.status) {
  ------------------
  |  Branch (4868:6): [True: 8, False: 1]
  ------------------
 4869|      8|		p2p_dbg(p2p, "P2P Presence Request was rejected: status %u",
 4870|      8|			*msg.status);
 4871|      8|		p2p_parse_free(&msg);
 4872|      8|		return;
 4873|      8|	}
 4874|       |
 4875|      1|	p2p_dbg(p2p, "P2P Presence Request was accepted");
 4876|      1|	wpa_hexdump(MSG_DEBUG, "P2P: P2P Presence Response - NoA",
 4877|      1|		    msg.noa, msg.noa_len);
 4878|       |	/* TODO: process NoA */
 4879|      1|	p2p_parse_free(&msg);
 4880|      1|}

p2p_buf_add_public_action_hdr:
   32|  1.70k|{
   33|  1.70k|	wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC);
  ------------------
  |  |  730|  1.70k|#define WLAN_ACTION_PUBLIC 4
  ------------------
   34|  1.70k|	wpabuf_put_u8(buf, WLAN_PA_VENDOR_SPECIFIC);
  ------------------
  |  |  777|  1.70k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
   35|  1.70k|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1575|  1.70k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   36|       |
   37|  1.70k|	wpabuf_put_u8(buf, subtype); /* OUI Subtype */
   38|  1.70k|	wpabuf_put_u8(buf, dialog_token);
   39|  1.70k|	wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", dialog_token);
   40|  1.70k|}
p2p_buf_add_ie_hdr:
   44|    755|{
   45|    755|	u8 *len;
   46|       |
   47|       |	/* P2P IE header */
   48|    755|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|    755|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   49|    755|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   50|    755|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1575|    755|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   51|    755|	wpa_printf(MSG_DEBUG, "P2P: * P2P IE header");
   52|    755|	return len;
   53|    755|}
p2p_buf_update_ie_hdr:
   57|  1.63k|{
   58|       |	/* Update P2P/P2P2 IE Length */
   59|  1.63k|	*len = (u8 *) wpabuf_put(buf, 0) - len - 1;
   60|  1.63k|}
p2p_buf_add_p2p2_ie_hdr:
   64|     50|{
   65|     50|	u8 *len;
   66|       |
   67|       |	/* P2P2 IE header */
   68|     50|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|     50|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   69|     50|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   70|     50|	wpabuf_put_be32(buf, P2P2_IE_VENDOR_TYPE);
  ------------------
  |  | 1576|     50|#define P2P2_IE_VENDOR_TYPE 0x506f9a28
  ------------------
   71|     50|	wpa_printf(MSG_DEBUG, "P2P: * P2P2 IE header");
   72|     50|	return len;
   73|     50|}
p2p_buf_add_capability:
   77|     57|{
   78|       |	/* P2P Capability */
   79|     57|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY);
   80|     57|	wpabuf_put_le16(buf, 2);
   81|     57|	wpabuf_put_u8(buf, dev_capab); /* Device Capabilities */
   82|     57|	wpabuf_put_u8(buf, group_capab); /* Group Capabilities */
   83|     57|	wpa_printf(MSG_DEBUG, "P2P: * Capability dev=%02x group=%02x",
   84|     57|		   dev_capab, group_capab);
   85|     57|}
p2p_buf_add_go_intent:
   89|     55|{
   90|       |	/* Group Owner Intent */
   91|     55|	wpabuf_put_u8(buf, P2P_ATTR_GROUP_OWNER_INTENT);
   92|     55|	wpabuf_put_le16(buf, 1);
   93|     55|	wpabuf_put_u8(buf, go_intent);
   94|     55|	wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u Tie breaker %u",
   95|     55|		   go_intent >> 1, go_intent & 0x01);
   96|     55|}
p2p_buf_add_operating_channel:
  115|     55|{
  116|       |	/* Operating Channel */
  117|     55|	wpabuf_put_u8(buf, P2P_ATTR_OPERATING_CHANNEL);
  118|     55|	wpabuf_put_le16(buf, 5);
  119|     55|	wpabuf_put_data(buf, country, 3);
  120|     55|	wpabuf_put_u8(buf, reg_class); /* Regulatory Class */
  121|     55|	wpabuf_put_u8(buf, channel); /* Channel Number */
  122|     55|	wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: Regulatory Class %u "
  123|     55|		   "Channel %u", reg_class, channel);
  124|     55|}
p2p_buf_add_channel_list:
  169|     55|{
  170|     55|	u8 *len;
  171|     55|	size_t i;
  172|       |
  173|       |	/* Channel List */
  174|     55|	wpabuf_put_u8(buf, P2P_ATTR_CHANNEL_LIST);
  175|     55|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  176|     55|	wpabuf_put_data(buf, country, 3); /* Country String */
  177|       |
  178|     55|	for (i = 0; i < chan->reg_classes; i++) {
  ------------------
  |  Branch (178:14): [True: 0, False: 55]
  ------------------
  179|      0|		struct p2p_reg_class *c = &chan->reg_class[i];
  180|       |
  181|      0|		if (is_6ghz_op_class(c->reg_class) && !is_6ghz_capab)
  ------------------
  |  Branch (181:7): [True: 0, False: 0]
  |  Branch (181:41): [True: 0, False: 0]
  ------------------
  182|      0|			continue;
  183|      0|		wpabuf_put_u8(buf, c->reg_class);
  184|      0|		wpabuf_put_u8(buf, c->channels);
  185|      0|		wpabuf_put_data(buf, c->channel, c->channels);
  186|      0|	}
  187|       |
  188|       |	/* Update attribute length */
  189|     55|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  190|     55|	wpa_hexdump(MSG_DEBUG, "P2P: * Channel List",
  191|     55|		    len + 2, (u8 *) wpabuf_put(buf, 0) - len - 2);
  192|     55|}
p2p_buf_add_status:
  196|  1.65k|{
  197|       |	/* Status */
  198|  1.65k|	wpabuf_put_u8(buf, P2P_ATTR_STATUS);
  199|  1.65k|	wpabuf_put_le16(buf, 1);
  200|  1.65k|	wpabuf_put_u8(buf, status);
  201|  1.65k|	wpa_printf(MSG_DEBUG, "P2P: * Status: %d", status);
  202|  1.65k|}
p2p_buf_add_device_info:
  207|     57|{
  208|     57|	u8 *len;
  209|     57|	u16 methods;
  210|     57|	size_t nlen, i;
  211|       |
  212|       |	/* P2P Device Info */
  213|     57|	wpabuf_put_u8(buf, P2P_ATTR_DEVICE_INFO);
  214|     57|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  215|       |
  216|       |	/* P2P Device address */
  217|     57|	wpabuf_put_data(buf, p2p->cfg->dev_addr, ETH_ALEN);
  ------------------
  |  |  344|     57|#define ETH_ALEN 6
  ------------------
  218|       |
  219|       |	/* Config Methods */
  220|     57|	methods = 0;
  221|     57|	if (peer && peer->wps_method != WPS_NOT_READY) {
  ------------------
  |  Branch (221:6): [True: 34, False: 23]
  |  Branch (221:14): [True: 0, False: 34]
  ------------------
  222|      0|		if (peer->wps_method == WPS_PBC)
  ------------------
  |  Branch (222:7): [True: 0, False: 0]
  ------------------
  223|      0|			methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|      0|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  224|      0|		else if (peer->wps_method == WPS_P2PS)
  ------------------
  |  Branch (224:12): [True: 0, False: 0]
  ------------------
  225|      0|			methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|      0|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  226|      0|		else if (peer->wps_method == WPS_PIN_DISPLAY ||
  ------------------
  |  Branch (226:12): [True: 0, False: 0]
  ------------------
  227|      0|			 peer->wps_method == WPS_PIN_KEYPAD)
  ------------------
  |  Branch (227:5): [True: 0, False: 0]
  ------------------
  228|      0|			methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|      0|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              			methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  229|     57|	} else if (p2p->cfg->config_methods) {
  ------------------
  |  Branch (229:13): [True: 0, False: 57]
  ------------------
  230|      0|		methods |= p2p->cfg->config_methods &
  231|      0|			(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_DISPLAY |
  ------------------
  |  |  255|      0|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
              			(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_DISPLAY |
  ------------------
  |  |  251|      0|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  232|      0|			 WPS_CONFIG_KEYPAD | WPS_CONFIG_P2PS);
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
              			 WPS_CONFIG_KEYPAD | WPS_CONFIG_P2PS);
  ------------------
  |  |  259|      0|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  233|     57|	} else {
  234|     57|		methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|     57|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  235|     57|		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|     57|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|     57|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  236|     57|		methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     57|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  237|     57|	}
  238|     57|	wpabuf_put_be16(buf, methods);
  239|       |
  240|       |	/* Primary Device Type */
  241|     57|	wpabuf_put_data(buf, p2p->cfg->pri_dev_type,
  242|     57|			sizeof(p2p->cfg->pri_dev_type));
  243|       |
  244|       |	/* Number of Secondary Device Types */
  245|     57|	wpabuf_put_u8(buf, p2p->cfg->num_sec_dev_types);
  246|       |
  247|       |	/* Secondary Device Type List */
  248|     57|	for (i = 0; i < p2p->cfg->num_sec_dev_types; i++)
  ------------------
  |  Branch (248:14): [True: 0, False: 57]
  ------------------
  249|      0|		wpabuf_put_data(buf, p2p->cfg->sec_dev_type[i],
  250|      0|				WPS_DEV_TYPE_LEN);
  ------------------
  |  |   60|      0|#define WPS_DEV_TYPE_LEN 8
  ------------------
  251|       |
  252|       |	/* Device Name */
  253|     57|	nlen = p2p->cfg->dev_name ? os_strlen(p2p->cfg->dev_name) : 0;
  ------------------
  |  |  536|      0|#define os_strlen(s) strlen(s)
  ------------------
  |  Branch (253:9): [True: 0, False: 57]
  ------------------
  254|     57|	wpabuf_put_be16(buf, ATTR_DEV_NAME);
  255|     57|	wpabuf_put_be16(buf, nlen);
  256|     57|	wpabuf_put_data(buf, p2p->cfg->dev_name, nlen);
  257|       |
  258|       |	/* Update attribute length */
  259|     57|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  260|     57|	wpa_printf(MSG_DEBUG, "P2P: * Device Info");
  261|     57|}
p2p_buf_add_config_timeout:
  276|    852|{
  277|       |	/* Configuration Timeout */
  278|    852|	wpabuf_put_u8(buf, P2P_ATTR_CONFIGURATION_TIMEOUT);
  279|    852|	wpabuf_put_le16(buf, 2);
  280|    852|	wpabuf_put_u8(buf, go_timeout);
  281|    852|	wpabuf_put_u8(buf, client_timeout);
  282|    852|	wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout: GO %d (*10ms)  "
  283|    852|		   "client %d (*10ms)", go_timeout, client_timeout);
  284|    852|}
p2p_buf_add_intended_addr:
  288|     55|{
  289|       |	/* Intended P2P Interface Address */
  290|     55|	wpabuf_put_u8(buf, P2P_ATTR_INTENDED_INTERFACE_ADDR);
  291|     55|	wpabuf_put_le16(buf, ETH_ALEN);
  ------------------
  |  |  344|     55|#define ETH_ALEN 6
  ------------------
  292|     55|	wpabuf_put_data(buf, interface_addr, ETH_ALEN);
  ------------------
  |  |  344|     55|#define ETH_ALEN 6
  ------------------
  293|     55|	wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address " MACSTR,
  ------------------
  |  |  448|     55|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  294|     55|		   MAC2STR(interface_addr));
  ------------------
  |  |  447|     55|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  295|     55|}
p2p_buf_add_pcea:
  740|     50|{
  741|     50|	u8 *len;
  742|     50|	u16 capability_info = 0;
  743|       |
  744|       |	/* P2P Capability Extension */
  745|     50|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY_EXTENSION);
  746|       |	/* Length to be filled */
  747|     50|	len = wpabuf_put(buf, 2);
  748|       |
  749|     50|	if (!p2p->cfg->p2p_6ghz_disable)
  ------------------
  |  Branch (749:6): [True: 50, False: 0]
  ------------------
  750|     50|		capability_info |= P2P_PCEA_6GHZ;
  ------------------
  |  | 1930|     50|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  751|       |
  752|     50|	if (p2p->cfg->reg_info)
  ------------------
  |  Branch (752:6): [True: 0, False: 50]
  ------------------
  753|      0|		capability_info |= P2P_PCEA_REG_INFO;
  ------------------
  |  | 1931|      0|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  754|       |
  755|     50|	if (p2p->cfg->dfs_owner)
  ------------------
  |  Branch (755:6): [True: 0, False: 50]
  ------------------
  756|      0|		capability_info |= P2P_PCEA_DFS_OWNER;
  ------------------
  |  | 1932|      0|#define P2P_PCEA_DFS_OWNER BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  757|       |
  758|     50|	if (p2p->cfg->chan_switch_req_enable)
  ------------------
  |  Branch (758:6): [True: 0, False: 50]
  ------------------
  759|      0|		capability_info |= P2P_PCEA_CLI_REQ_CS;
  ------------------
  |  | 1933|      0|#define P2P_PCEA_CLI_REQ_CS BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  760|       |
  761|     50|	if (p2p->cfg->pairing_config.pairing_capable)
  ------------------
  |  Branch (761:6): [True: 0, False: 50]
  ------------------
  762|      0|		capability_info |= P2P_PCEA_PAIRING_CAPABLE;
  ------------------
  |  | 1934|      0|#define P2P_PCEA_PAIRING_CAPABLE BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  763|       |
  764|     50|	if (p2p->cfg->pairing_config.enable_pairing_setup)
  ------------------
  |  Branch (764:6): [True: 0, False: 50]
  ------------------
  765|      0|		capability_info |= P2P_PCEA_PAIRING_SETUP_ENABLED;
  ------------------
  |  | 1935|      0|#define P2P_PCEA_PAIRING_SETUP_ENABLED BIT(9)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  766|       |
  767|     50|	if (p2p->cfg->pairing_config.enable_pairing_cache)
  ------------------
  |  Branch (767:6): [True: 0, False: 50]
  ------------------
  768|      0|		capability_info |= P2P_PCEA_PMK_CACHING;
  ------------------
  |  | 1936|      0|#define P2P_PCEA_PMK_CACHING BIT(10)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  769|       |
  770|     50|	if (p2p->cfg->pairing_config.pasn_type)
  ------------------
  |  Branch (770:6): [True: 0, False: 50]
  ------------------
  771|      0|		capability_info |= P2P_PCEA_PASN_TYPE;
  ------------------
  |  | 1937|      0|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  772|       |
  773|     50|	if (p2p->cfg->twt_power_mgmt)
  ------------------
  |  Branch (773:6): [True: 0, False: 50]
  ------------------
  774|      0|		capability_info |= P2P_PCEA_TWT_POWER_MGMT;
  ------------------
  |  | 1938|      0|#define P2P_PCEA_TWT_POWER_MGMT BIT(12)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  775|       |
  776|       |	/* Field length is (n-1), n in octets */
  777|     50|	capability_info |= (2 - 1) & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1929|     50|#define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  778|     50|	wpabuf_put_le16(buf, capability_info);
  779|       |
  780|     50|	if (capability_info & P2P_PCEA_REG_INFO)
  ------------------
  |  | 1931|     50|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (780:6): [True: 0, False: 50]
  ------------------
  781|      0|		wpabuf_put_u8(buf, p2p->cfg->reg_info);
  782|       |
  783|     50|	if (capability_info & P2P_PCEA_PASN_TYPE)
  ------------------
  |  | 1937|     50|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (783:6): [True: 0, False: 50]
  ------------------
  784|      0|		wpabuf_put_u8(buf, p2p->cfg->pairing_config.pasn_type);
  785|       |
  786|       |	/* Update attribute length */
  787|     50|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  788|       |
  789|     50|	wpa_printf(MSG_DEBUG, "P2P: * Capability Extension info=0x%x",
  790|     50|		   capability_info);
  791|     50|}
p2p_buf_add_pbma:
  796|     50|{
  797|     50|	u8 *len;
  798|       |
  799|       |	/* P2P Pairing and Bootstrapping methods */
  800|     50|	wpabuf_put_u8(buf, P2P_ATTR_PAIRING_AND_BOOTSTRAPPING);
  801|       |	/* Length to be filled */
  802|     50|	len = wpabuf_put(buf, 2);
  803|       |
  804|     50|	if (cookie && cookie_len) {
  ------------------
  |  Branch (804:6): [True: 43, False: 7]
  |  Branch (804:16): [True: 43, False: 0]
  ------------------
  805|     43|		if (comeback_after)
  ------------------
  |  Branch (805:7): [True: 43, False: 0]
  ------------------
  806|     43|			wpabuf_put_le16(buf, comeback_after);
  807|     43|		wpabuf_put_u8(buf, cookie_len);
  808|     43|		wpabuf_put_data(buf, cookie, cookie_len);
  809|     43|	}
  810|     50|	wpabuf_put_le16(buf, bootstrap);
  811|       |
  812|       |	/* Update attribute length */
  813|     50|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  814|       |
  815|     50|	wpa_printf(MSG_DEBUG, "P2P: * Bootstrapping method=0x%x",
  816|     50|		   bootstrap);
  817|     50|}
p2p_build_wps_ie:
  878|     36|{
  879|     36|	u8 *len;
  880|     36|	int i;
  881|       |
  882|     36|	if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (882:6): [True: 0, False: 36]
  ------------------
  883|      0|		return -1;
  884|     36|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|     36|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  885|     36|	len = wpabuf_put(buf, 1);
  886|     36|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|     36|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
  887|       |
  888|     36|	if (wps_build_version(buf) < 0)
  ------------------
  |  Branch (888:6): [True: 0, False: 36]
  ------------------
  889|      0|		return -1;
  890|       |
  891|     36|	if (all_attr) {
  ------------------
  |  Branch (891:6): [True: 2, False: 34]
  ------------------
  892|      2|		if (wpabuf_tailroom(buf) < 5)
  ------------------
  |  Branch (892:7): [True: 0, False: 2]
  ------------------
  893|      0|			return -1;
  894|      2|		wpabuf_put_be16(buf, ATTR_WPS_STATE);
  895|      2|		wpabuf_put_be16(buf, 1);
  896|      2|		wpabuf_put_u8(buf, WPS_STATE_NOT_CONFIGURED);
  897|      2|	}
  898|       |
  899|     36|	if (pw_id >= 0) {
  ------------------
  |  Branch (899:6): [True: 34, False: 2]
  ------------------
  900|     34|		if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (900:7): [True: 0, False: 34]
  ------------------
  901|      0|			return -1;
  902|       |		/* Device Password ID */
  903|     34|		wpabuf_put_be16(buf, ATTR_DEV_PASSWORD_ID);
  904|     34|		wpabuf_put_be16(buf, 2);
  905|     34|		wpa_printf(MSG_DEBUG, "P2P: WPS IE Device Password ID: %d",
  906|     34|			   pw_id);
  907|     34|		wpabuf_put_be16(buf, pw_id);
  908|     34|	}
  909|       |
  910|     36|	if (all_attr) {
  ------------------
  |  Branch (910:6): [True: 2, False: 34]
  ------------------
  911|      2|		if (wpabuf_tailroom(buf) < 5)
  ------------------
  |  Branch (911:7): [True: 0, False: 2]
  ------------------
  912|      0|			return -1;
  913|      2|		wpabuf_put_be16(buf, ATTR_RESPONSE_TYPE);
  914|      2|		wpabuf_put_be16(buf, 1);
  915|      2|		wpabuf_put_u8(buf, WPS_RESP_ENROLLEE_INFO);
  916|       |
  917|      2|		if (wps_build_uuid_e(buf, p2p->cfg->uuid) < 0 ||
  ------------------
  |  Branch (917:7): [True: 0, False: 2]
  ------------------
  918|      2|		    p2p_add_wps_string(buf, ATTR_MANUFACTURER,
  ------------------
  |  Branch (918:7): [True: 0, False: 2]
  ------------------
  919|      2|				       p2p->cfg->manufacturer) < 0 ||
  920|      2|		    p2p_add_wps_string(buf, ATTR_MODEL_NAME,
  ------------------
  |  Branch (920:7): [True: 0, False: 2]
  ------------------
  921|      2|				       p2p->cfg->model_name) < 0 ||
  922|      2|		    p2p_add_wps_string(buf, ATTR_MODEL_NUMBER,
  ------------------
  |  Branch (922:7): [True: 0, False: 2]
  ------------------
  923|      2|				       p2p->cfg->model_number) < 0 ||
  924|      2|		    p2p_add_wps_string(buf, ATTR_SERIAL_NUMBER,
  ------------------
  |  Branch (924:7): [True: 0, False: 2]
  ------------------
  925|      2|				       p2p->cfg->serial_number) < 0)
  926|      0|			return -1;
  927|       |
  928|      2|		if (wpabuf_tailroom(buf) < 4 + WPS_DEV_TYPE_LEN)
  ------------------
  |  |   60|      2|#define WPS_DEV_TYPE_LEN 8
  ------------------
  |  Branch (928:7): [True: 0, False: 2]
  ------------------
  929|      0|			return -1;
  930|      2|		wpabuf_put_be16(buf, ATTR_PRIMARY_DEV_TYPE);
  931|      2|		wpabuf_put_be16(buf, WPS_DEV_TYPE_LEN);
  ------------------
  |  |   60|      2|#define WPS_DEV_TYPE_LEN 8
  ------------------
  932|      2|		wpabuf_put_data(buf, p2p->cfg->pri_dev_type, WPS_DEV_TYPE_LEN);
  ------------------
  |  |   60|      2|#define WPS_DEV_TYPE_LEN 8
  ------------------
  933|       |
  934|      2|		if (p2p_add_wps_string(buf, ATTR_DEV_NAME, p2p->cfg->dev_name)
  ------------------
  |  Branch (934:7): [True: 0, False: 2]
  ------------------
  935|      2|		    < 0)
  936|      0|			return -1;
  937|       |
  938|      2|		if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (938:7): [True: 0, False: 2]
  ------------------
  939|      0|			return -1;
  940|      2|		wpabuf_put_be16(buf, ATTR_CONFIG_METHODS);
  941|      2|		wpabuf_put_be16(buf, 2);
  942|      2|		wpabuf_put_be16(buf, p2p->cfg->config_methods);
  943|      2|	}
  944|       |
  945|     36|	if (wps_build_wfa_ext(buf, 0, NULL, 0, 0) < 0)
  ------------------
  |  Branch (945:6): [True: 0, False: 36]
  ------------------
  946|      0|		return -1;
  947|       |
  948|     36|	if (all_attr && p2p->cfg->num_sec_dev_types) {
  ------------------
  |  Branch (948:6): [True: 2, False: 34]
  |  Branch (948:18): [True: 0, False: 2]
  ------------------
  949|      0|		if (wpabuf_tailroom(buf) <
  ------------------
  |  Branch (949:7): [True: 0, False: 0]
  ------------------
  950|      0|		    4 + WPS_DEV_TYPE_LEN * p2p->cfg->num_sec_dev_types)
  ------------------
  |  |   60|      0|#define WPS_DEV_TYPE_LEN 8
  ------------------
  951|      0|			return -1;
  952|      0|		wpabuf_put_be16(buf, ATTR_SECONDARY_DEV_TYPE_LIST);
  953|      0|		wpabuf_put_be16(buf, WPS_DEV_TYPE_LEN *
  ------------------
  |  |   60|      0|#define WPS_DEV_TYPE_LEN 8
  ------------------
  954|      0|				p2p->cfg->num_sec_dev_types);
  955|      0|		wpabuf_put_data(buf, p2p->cfg->sec_dev_type,
  956|      0|				WPS_DEV_TYPE_LEN *
  ------------------
  |  |   60|      0|#define WPS_DEV_TYPE_LEN 8
  ------------------
  957|      0|				p2p->cfg->num_sec_dev_types);
  958|      0|	}
  959|       |
  960|       |	/* Add the WPS vendor extensions */
  961|     36|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|     36|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (961:14): [True: 36, False: 0]
  ------------------
  962|     36|		if (p2p->wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (962:7): [True: 36, False: 0]
  ------------------
  963|     36|			break;
  964|      0|		if (wpabuf_tailroom(buf) <
  ------------------
  |  Branch (964:7): [True: 0, False: 0]
  ------------------
  965|      0|		    4 + wpabuf_len(p2p->wps_vendor_ext[i]))
  966|      0|			continue;
  967|      0|		wpabuf_put_be16(buf, ATTR_VENDOR_EXT);
  968|      0|		wpabuf_put_be16(buf, wpabuf_len(p2p->wps_vendor_ext[i]));
  969|      0|		wpabuf_put_buf(buf, p2p->wps_vendor_ext[i]);
  970|      0|	}
  971|       |
  972|     36|	p2p_buf_update_ie_hdr(buf, len);
  973|       |
  974|     36|	return 0;
  975|     36|}
p2p_encaps_ie:
  979|    852|{
  980|    852|	struct wpabuf *ie;
  981|    852|	const u8 *pos, *end;
  982|    852|	size_t len;
  983|       |
  984|    852|	if (!subelems)
  ------------------
  |  Branch (984:6): [True: 0, False: 852]
  ------------------
  985|      0|		return NULL;
  986|       |
  987|    852|	len = wpabuf_len(subelems) + 1000;
  988|       |
  989|    852|	ie = wpabuf_alloc(len);
  990|    852|	if (!ie)
  ------------------
  |  Branch (990:6): [True: 0, False: 852]
  ------------------
  991|      0|		return NULL;
  992|       |
  993|    852|	pos = wpabuf_head(subelems);
  994|    852|	end = pos + wpabuf_len(subelems);
  995|       |
  996|  1.70k|	while (end > pos) {
  ------------------
  |  Branch (996:9): [True: 852, False: 852]
  ------------------
  997|    852|		size_t frag_len = end - pos;
  998|       |
  999|    852|		if (frag_len > 251)
  ------------------
  |  Branch (999:7): [True: 0, False: 852]
  ------------------
 1000|      0|			frag_len = 251;
 1001|    852|		wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|    852|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
 1002|    852|		wpabuf_put_u8(ie, 4 + frag_len);
 1003|    852|		wpabuf_put_be32(ie, ie_type);
 1004|    852|		wpabuf_put_data(ie, pos, frag_len);
 1005|    852|		pos += frag_len;
 1006|    852|	}
 1007|       |
 1008|    852|	return ie;
 1009|    852|}
p2p_build.c:p2p_add_wps_string:
  848|     10|{
  849|     10|	size_t len;
  850|       |
  851|     10|	len = val ? os_strlen(val) : 0;
  ------------------
  |  |  536|      0|#define os_strlen(s) strlen(s)
  ------------------
  |  Branch (851:8): [True: 0, False: 10]
  ------------------
  852|     10|	if (wpabuf_tailroom(buf) < 4 + len)
  ------------------
  |  Branch (852:6): [True: 0, False: 10]
  ------------------
  853|      0|		return -1;
  854|     10|	wpabuf_put_be16(buf, attr);
  855|     10|#ifndef CONFIG_WPS_STRICT
  856|     10|	if (len == 0) {
  ------------------
  |  Branch (856:6): [True: 10, False: 0]
  ------------------
  857|       |		/*
  858|       |		 * Some deployed WPS implementations fail to parse zeor-length
  859|       |		 * attributes. As a workaround, send a space character if the
  860|       |		 * device attribute string is empty.
  861|       |		 */
  862|     10|		if (wpabuf_tailroom(buf) < 3)
  ------------------
  |  Branch (862:7): [True: 0, False: 10]
  ------------------
  863|      0|			return -1;
  864|     10|		wpabuf_put_be16(buf, 1);
  865|     10|		wpabuf_put_u8(buf, ' ');
  866|     10|		return 0;
  867|     10|	}
  868|      0|#endif /* CONFIG_WPS_STRICT */
  869|      0|	wpabuf_put_be16(buf, len);
  870|      0|	if (val)
  ------------------
  |  Branch (870:6): [True: 0, False: 0]
  ------------------
  871|      0|		wpabuf_put_data(buf, val, len);
  872|      0|	return 0;
  873|     10|}

p2p_process_dev_disc_req:
  163|      7|{
  164|      7|	struct p2p_message msg;
  165|      7|	size_t g;
  166|       |
  167|      7|	p2p_dbg(p2p, "Received Device Discoverability Request from " MACSTR
  168|      7|		" (freq=%d)", MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|      7|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  169|       |
  170|      7|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (170:6): [True: 1, False: 6]
  ------------------
  171|      1|		return;
  172|       |
  173|      6|	if (msg.dialog_token == 0) {
  ------------------
  |  Branch (173:6): [True: 2, False: 4]
  ------------------
  174|      2|		p2p_dbg(p2p, "Invalid Dialog Token 0 (must be nonzero) in Device Discoverability Request");
  175|      2|		p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  176|      2|				       P2P_SC_FAIL_INVALID_PARAMS);
  177|      2|		p2p_parse_free(&msg);
  178|      2|		return;
  179|      2|	}
  180|       |
  181|      4|	if (msg.device_id == NULL) {
  ------------------
  |  Branch (181:6): [True: 3, False: 1]
  ------------------
  182|      3|		p2p_dbg(p2p, "P2P Device ID attribute missing from Device Discoverability Request");
  183|      3|		p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  184|      3|				       P2P_SC_FAIL_INVALID_PARAMS);
  185|      3|		p2p_parse_free(&msg);
  186|      3|		return;
  187|      3|	}
  188|       |
  189|      1|	for (g = 0; g < p2p->num_groups; g++) {
  ------------------
  |  Branch (189:14): [True: 0, False: 1]
  ------------------
  190|      0|		if (p2p_group_go_discover(p2p->groups[g], msg.device_id, sa,
  ------------------
  |  Branch (190:7): [True: 0, False: 0]
  ------------------
  191|      0|					  rx_freq) == 0) {
  192|      0|			p2p_dbg(p2p, "Scheduled GO Discoverability Request for the target device");
  193|       |			/*
  194|       |			 * P2P group code will use a callback to indicate TX
  195|       |			 * status, so that we can reply to the request once the
  196|       |			 * target client has acknowledged the request or it has
  197|       |			 * timed out.
  198|       |			 */
  199|      0|			p2p->pending_dev_disc_dialog_token = msg.dialog_token;
  200|      0|			os_memcpy(p2p->pending_dev_disc_addr, sa, ETH_ALEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  201|      0|			p2p->pending_dev_disc_freq = rx_freq;
  202|      0|			p2p_parse_free(&msg);
  203|      0|			return;
  204|      0|		}
  205|      0|	}
  206|       |
  207|      1|	p2p_dbg(p2p, "Requested client was not found in any group or did not support client discoverability");
  208|      1|	p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  209|      1|			       P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE);
  210|      1|	p2p_parse_free(&msg);
  211|      1|}
p2p_process_dev_disc_resp:
  216|      1|{
  217|      1|	struct p2p_message msg;
  218|      1|	struct p2p_device *go;
  219|      1|	u8 status;
  220|       |
  221|      1|	p2p_dbg(p2p, "Received Device Discoverability Response from " MACSTR,
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  222|      1|		MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  223|       |
  224|      1|	go = p2p->pending_client_disc_go;
  225|      1|	if (go == NULL ||
  ------------------
  |  Branch (225:6): [True: 1, False: 0]
  ------------------
  226|      1|	    !ether_addr_equal(sa, go->info.p2p_device_addr)) {
  ------------------
  |  Branch (226:6): [True: 0, False: 0]
  ------------------
  227|      1|		p2p_dbg(p2p, "Ignore unexpected Device Discoverability Response");
  228|      1|		return;
  229|      1|	}
  230|       |
  231|      0|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (231:6): [True: 0, False: 0]
  ------------------
  232|      0|		return;
  233|       |
  234|      0|	if (msg.status == NULL) {
  ------------------
  |  Branch (234:6): [True: 0, False: 0]
  ------------------
  235|      0|		p2p_parse_free(&msg);
  236|      0|		return;
  237|      0|	}
  238|       |
  239|      0|	if (msg.dialog_token != go->dialog_token) {
  ------------------
  |  Branch (239:6): [True: 0, False: 0]
  ------------------
  240|      0|		p2p_dbg(p2p, "Ignore Device Discoverability Response with unexpected dialog token %u (expected %u)",
  241|      0|			msg.dialog_token, go->dialog_token);
  242|      0|		p2p_parse_free(&msg);
  243|      0|		return;
  244|      0|	}
  245|       |
  246|      0|	status = *msg.status;
  247|      0|	p2p_parse_free(&msg);
  248|       |
  249|      0|	p2p_dbg(p2p, "Device Discoverability Response status %u", status);
  250|       |
  251|      0|	if (p2p->go_neg_peer == NULL ||
  ------------------
  |  Branch (251:6): [True: 0, False: 0]
  ------------------
  252|      0|	    !ether_addr_equal(p2p->pending_client_disc_addr,
  ------------------
  |  Branch (252:6): [True: 0, False: 0]
  ------------------
  253|      0|			      p2p->go_neg_peer->info.p2p_device_addr) ||
  254|      0|	    !ether_addr_equal(p2p->go_neg_peer->member_in_go_dev,
  ------------------
  |  Branch (254:6): [True: 0, False: 0]
  ------------------
  255|      0|			      go->info.p2p_device_addr)) {
  256|      0|		p2p_dbg(p2p, "No pending operation with the client discoverability peer anymore");
  257|      0|		return;
  258|      0|	}
  259|       |
  260|      0|	if (status == 0) {
  ------------------
  |  Branch (260:6): [True: 0, False: 0]
  ------------------
  261|       |		/*
  262|       |		 * Peer is expected to be awake for at least 100 TU; try to
  263|       |		 * connect immediately.
  264|       |		 */
  265|      0|		p2p_dbg(p2p, "Client discoverability request succeeded");
  266|      0|		if (p2p->state == P2P_CONNECT) {
  ------------------
  |  Branch (266:7): [True: 0, False: 0]
  ------------------
  267|       |			/*
  268|       |			 * Change state to force the timeout to start in
  269|       |			 * P2P_CONNECT again without going through the short
  270|       |			 * Listen state.
  271|       |			 */
  272|      0|			p2p_set_state(p2p, P2P_CONNECT_LISTEN);
  273|      0|			p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  274|      0|		}
  275|      0|		p2p_set_timeout(p2p, 0, 0);
  276|      0|	} else {
  277|       |		/*
  278|       |		 * Client discoverability request failed; try to connect from
  279|       |		 * timeout.
  280|       |		 */
  281|      0|		p2p_dbg(p2p, "Client discoverability request failed");
  282|      0|		p2p_set_timeout(p2p, 0, 500000);
  283|      0|	}
  284|       |
  285|      0|}
p2p_process_go_disc_req:
  311|      2|{
  312|      2|	unsigned int tu;
  313|      2|	struct wpabuf *ies;
  314|       |
  315|      2|	p2p_dbg(p2p, "Received GO Discoverability Request - remain awake for 100 TU");
  316|       |
  317|      2|	ies = p2p_build_probe_resp_ies(p2p, NULL, 0);
  318|      2|	if (ies == NULL)
  ------------------
  |  Branch (318:6): [True: 0, False: 2]
  ------------------
  319|      0|		return;
  320|       |
  321|       |	/* Remain awake 100 TU on operating channel */
  322|      2|	p2p->pending_client_disc_freq = rx_freq;
  323|      2|	tu = 100;
  324|      2|	if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, rx_freq, 1024 * tu / 1000,
  ------------------
  |  Branch (324:6): [True: 0, False: 2]
  ------------------
  325|      2|		    ies) < 0) {
  326|      0|		p2p_dbg(p2p, "Failed to start listen mode for client discoverability");
  327|      0|	}
  328|      2|	wpabuf_free(ies);
  329|      2|}
p2p_dev_disc.c:p2p_send_dev_disc_resp:
  139|      6|{
  140|      6|	struct wpabuf *resp;
  141|       |
  142|      6|	resp = p2p_build_dev_disc_resp(dialog_token, status);
  143|      6|	if (resp == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 6]
  ------------------
  144|      0|		return;
  145|       |
  146|      6|	p2p_dbg(p2p, "Sending Device Discoverability Response to " MACSTR
  147|      6|		" (status %u freq %d)",
  148|      6|		MAC2STR(addr), status, freq);
  ------------------
  |  |  447|      6|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  149|       |
  150|      6|	p2p->pending_action_state = P2P_PENDING_DEV_DISC_RESPONSE;
  151|      6|	if (p2p_send_action(p2p, freq, addr, p2p->cfg->dev_addr,
  ------------------
  |  Branch (151:6): [True: 0, False: 6]
  ------------------
  152|      6|			    p2p->cfg->dev_addr,
  153|      6|			    wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
  154|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  155|      0|	}
  156|       |
  157|      6|	wpabuf_free(resp);
  158|      6|}
p2p_dev_disc.c:p2p_build_dev_disc_resp:
  111|      6|{
  112|      6|	struct wpabuf *buf;
  113|      6|	u8 *len;
  114|       |
  115|      6|	buf = wpabuf_alloc(100);
  116|      6|	if (buf == NULL)
  ------------------
  |  Branch (116:6): [True: 0, False: 6]
  ------------------
  117|      0|		return NULL;
  118|       |
  119|      6|	p2p_buf_add_public_action_hdr(buf, P2P_DEV_DISC_RESP, dialog_token);
  120|       |
  121|      6|	len = p2p_buf_add_ie_hdr(buf);
  122|      6|	p2p_buf_add_status(buf, status);
  123|      6|	p2p_buf_update_ie_hdr(buf, len);
  124|       |
  125|      6|	return buf;
  126|      6|}

p2p_peer_channels_check:
   39|    192|{
   40|    192|	const u8 *pos, *end;
   41|    192|	struct p2p_channels *ch;
   42|    192|	u8 channels;
   43|    192|	struct p2p_channels intersection;
   44|       |
   45|    192|	ch = &dev->channels;
   46|    192|	os_memset(ch, 0, sizeof(*ch));
  ------------------
  |  |  529|    192|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   47|    192|	pos = channel_list;
   48|    192|	end = channel_list + channel_list_len;
   49|       |
   50|    192|	if (end - pos < 3)
  ------------------
  |  Branch (50:6): [True: 1, False: 191]
  ------------------
   51|      1|		return -1;
   52|    191|	os_memcpy(dev->country, pos, 3);
  ------------------
  |  |  523|    191|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   53|    191|	wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer country", pos, 3);
   54|    191|	if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) {
  ------------------
  |  |  532|    166|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (54:6): [True: 166, False: 25]
  |  Branch (54:24): [True: 24, False: 142]
  ------------------
   55|     24|		p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)",
   56|     24|			p2p->cfg->country[0], p2p->cfg->country[1],
   57|     24|			pos[0], pos[1]);
   58|     24|		return -1;
   59|     24|	}
   60|    167|	pos += 3;
   61|       |
   62|    817|	while (end - pos > 2) {
  ------------------
  |  Branch (62:9): [True: 662, False: 155]
  ------------------
   63|    662|		struct p2p_reg_class *cl = &ch->reg_class[ch->reg_classes];
   64|    662|		cl->reg_class = *pos++;
   65|    662|		channels = *pos++;
   66|    662|		if (channels > end - pos) {
  ------------------
  |  Branch (66:7): [True: 9, False: 653]
  ------------------
   67|      9|			p2p_info(p2p, "Invalid peer Channel List");
   68|      9|			return -1;
   69|      9|		}
   70|    653|		cl->channels = channels > P2P_MAX_REG_CLASS_CHANNELS ?
  ------------------
  |  |   52|    653|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
  |  Branch (70:18): [True: 12, False: 641]
  ------------------
   71|    641|			P2P_MAX_REG_CLASS_CHANNELS : channels;
  ------------------
  |  |   52|     12|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
   72|    653|		os_memcpy(cl->channel, pos, cl->channels);
  ------------------
  |  |  523|    653|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   73|    653|		pos += channels;
   74|    653|		ch->reg_classes++;
   75|    653|		if (ch->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|    653|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (75:7): [True: 3, False: 650]
  ------------------
   76|      3|			break;
   77|    653|	}
   78|       |
   79|    158|	p2p_channels_intersect(own, &dev->channels, &intersection);
   80|    158|	p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d",
   81|    158|		(int) own->reg_classes,
   82|    158|		(int) dev->channels.reg_classes,
   83|    158|		(int) intersection.reg_classes);
   84|    158|	if (intersection.reg_classes == 0) {
  ------------------
  |  Branch (84:6): [True: 31, False: 127]
  ------------------
   85|     31|		p2p_info(p2p, "No common channels found");
   86|     31|		return -1;
   87|     31|	}
   88|    127|	return 0;
   89|    158|}
p2p_wps_method_pw_id:
  101|     55|{
  102|     55|	switch (wps_method) {
  103|      0|	case WPS_PIN_DISPLAY:
  ------------------
  |  Branch (103:2): [True: 0, False: 55]
  ------------------
  104|      0|		return DEV_PW_REGISTRAR_SPECIFIED;
  105|      0|	case WPS_PIN_KEYPAD:
  ------------------
  |  Branch (105:2): [True: 0, False: 55]
  ------------------
  106|      0|		return DEV_PW_USER_SPECIFIED;
  107|      0|	case WPS_PBC:
  ------------------
  |  Branch (107:2): [True: 0, False: 55]
  ------------------
  108|      0|		return DEV_PW_PUSHBUTTON;
  109|      0|	case WPS_NFC:
  ------------------
  |  Branch (109:2): [True: 0, False: 55]
  ------------------
  110|      0|		return DEV_PW_NFC_CONNECTION_HANDOVER;
  111|      0|	case WPS_P2PS:
  ------------------
  |  Branch (111:2): [True: 0, False: 55]
  ------------------
  112|      0|		return DEV_PW_P2PS_DEFAULT;
  113|     55|	default:
  ------------------
  |  Branch (113:2): [True: 55, False: 0]
  ------------------
  114|     55|		return DEV_PW_DEFAULT;
  115|     55|	}
  116|     55|}
p2p_check_pref_chan:
  719|    127|{
  720|    127|	unsigned int size;
  721|    127|	unsigned int i;
  722|    127|	u8 op_class, op_channel;
  723|    127|	char txt[100], *pos, *end;
  724|    127|	bool is_6ghz_capab;
  725|    127|	int res;
  726|       |
  727|       |	/*
  728|       |	 * Use the preferred channel list from the driver only if there is no
  729|       |	 * forced_freq, e.g., P2P_CONNECT freq=..., and no preferred operating
  730|       |	 * channel hardcoded in the configuration file.
  731|       |	 */
  732|    127|	if (!p2p->cfg->get_pref_freq_list || p2p->cfg->num_pref_chan ||
  ------------------
  |  Branch (732:6): [True: 127, False: 0]
  |  Branch (732:39): [True: 0, False: 0]
  ------------------
  733|      0|	    (dev->flags & P2P_DEV_FORCE_FREQ) || p2p->cfg->cfg_op_channel)
  ------------------
  |  |  138|      0|#define P2P_DEV_FORCE_FREQ BIT(13)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (733:6): [True: 0, False: 0]
  |  Branch (733:43): [True: 0, False: 0]
  ------------------
  734|    127|		return;
  735|       |
  736|       |	/* Obtain our preferred frequency list from driver based on P2P role. */
  737|      0|	size = ARRAY_SIZE(p2p->pref_freq_list);
  ------------------
  |  |  607|      0|#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  738|      0|	if (p2p->cfg->get_pref_freq_list(p2p->cfg->cb_ctx, go,
  ------------------
  |  Branch (738:6): [True: 0, False: 0]
  ------------------
  739|      0|					 &size,
  740|      0|					 p2p->pref_freq_list))
  741|      0|		return;
  742|      0|	p2p->num_pref_freq = size;
  743|      0|	if (!size)
  ------------------
  |  Branch (743:6): [True: 0, False: 0]
  ------------------
  744|      0|		return;
  745|       |	/* Filter out frequencies that are not acceptable for P2P use */
  746|      0|	is_6ghz_capab = is_p2p_6ghz_capable(p2p) &&
  ------------------
  |  Branch (746:18): [True: 0, False: 0]
  ------------------
  747|      0|		p2p_is_peer_6ghz_capab(p2p, dev->info.p2p_device_addr);
  ------------------
  |  Branch (747:3): [True: 0, False: 0]
  ------------------
  748|      0|	i = 0;
  749|      0|	while (i < size) {
  ------------------
  |  Branch (749:9): [True: 0, False: 0]
  ------------------
  750|      0|		bool is_dfs_freq;
  751|       |
  752|      0|		is_dfs_freq = p2p->cfg->is_p2p_dfs_chan(
  753|      0|			p2p->cfg->cb_ctx, p2p->pref_freq_list[i].freq, 0, 0);
  754|      0|		if (p2p_freq_to_channel(p2p->pref_freq_list[i].freq,
  ------------------
  |  Branch (754:7): [True: 0, False: 0]
  ------------------
  755|      0|					&op_class, &op_channel) < 0 ||
  756|      0|		    (!p2p_channels_includes(&p2p->cfg->channels,
  ------------------
  |  Branch (756:8): [True: 0, False: 0]
  ------------------
  757|      0|					    op_class, op_channel) &&
  758|      0|		     (go || !p2p_channels_includes(&p2p->cfg->cli_channels,
  ------------------
  |  Branch (758:9): [True: 0, False: 0]
  |  Branch (758:15): [True: 0, False: 0]
  ------------------
  759|      0|						   op_class, op_channel))) ||
  760|      0|		    (is_6ghz_freq(p2p->pref_freq_list[i].freq) &&
  ------------------
  |  Branch (760:8): [True: 0, False: 0]
  ------------------
  761|      0|		     !is_6ghz_capab) ||
  ------------------
  |  Branch (761:8): [True: 0, False: 0]
  ------------------
  762|      0|		    (is_dfs_freq &&
  ------------------
  |  Branch (762:8): [True: 0, False: 0]
  ------------------
  763|      0|		     !is_dfs_freq_allowed(p2p, go,
  ------------------
  |  Branch (763:8): [True: 0, False: 0]
  ------------------
  764|      0|					  p2p->pref_freq_list[i].freq))) {
  765|      0|			p2p_dbg(p2p,
  766|      0|				"Ignore local driver frequency preference %u MHz since it is not acceptable for P2P use (go=%d)",
  767|      0|				p2p->pref_freq_list[i].freq, go);
  768|      0|			if (size - i - 1 > 0)
  ------------------
  |  Branch (768:8): [True: 0, False: 0]
  ------------------
  769|      0|				os_memmove(&p2p->pref_freq_list[i],
  ------------------
  |  |  526|      0|#define os_memmove(d, s, n) memmove((d), (s), (n))
  ------------------
  770|      0|					   &p2p->pref_freq_list[i + 1],
  771|      0|					   (size - i - 1) *
  772|      0|					   sizeof(struct weighted_pcl));
  773|      0|			size--;
  774|      0|			continue;
  775|      0|		}
  776|       |
  777|       |		/* Preferred frequency is acceptable for P2P use */
  778|      0|		i++;
  779|      0|	}
  780|       |
  781|      0|	pos = txt;
  782|      0|	end = pos + sizeof(txt);
  783|      0|	for (i = 0; i < size; i++) {
  ------------------
  |  Branch (783:14): [True: 0, False: 0]
  ------------------
  784|      0|		res = os_snprintf(pos, end - pos, " %u",
  ------------------
  |  |  572|      0|#define os_snprintf snprintf
  ------------------
  785|      0|				  p2p->pref_freq_list[i].freq);
  786|      0|		if (os_snprintf_error(end - pos, res))
  ------------------
  |  Branch (786:7): [True: 0, False: 0]
  ------------------
  787|      0|			break;
  788|      0|		pos += res;
  789|      0|	}
  790|      0|	*pos = '\0';
  791|      0|	p2p_dbg(p2p, "Local driver frequency preference (size=%u):%s",
  792|      0|		size, txt);
  793|       |
  794|       |	/*
  795|       |	 * Check if peer's preference of operating channel is in our preferred
  796|       |	 * channel list. When local device is GO and assisted DFS is active,
  797|       |	 * also treat the locally connected DFS frequency as a match candidate.
  798|       |	 * The loop scans pref_freq_list[] from the highest to the lowest driver
  799|       |	 * priority and breaks on the first allowed match, so the DFS channel
  800|       |	 * wins over the peer's oper_freq only when the driver ranks it at a
  801|       |	 * lower index (higher preference). If the peer's channel appears first
  802|       |	 * in the list it wins instead, which is correct because the driver
  803|       |	 * explicitly prefers it over the DFS channel in that case.
  804|       |	 */
  805|      0|	for (i = 0; i < size; i++) {
  ------------------
  |  Branch (805:14): [True: 0, False: 0]
  ------------------
  806|      0|		if ((p2p->pref_freq_list[i].freq ==
  ------------------
  |  Branch (806:8): [True: 0, False: 0]
  ------------------
  807|      0|		     (unsigned int) dev->oper_freq ||
  808|      0|		     (go && p2p->dfs_ap_connected &&
  ------------------
  |  Branch (808:9): [True: 0, False: 0]
  |  Branch (808:15): [True: 0, False: 0]
  ------------------
  809|      0|		      p2p->pref_freq_list[i].freq ==
  ------------------
  |  Branch (809:9): [True: 0, False: 0]
  ------------------
  810|      0|		      (unsigned int) p2p->sta_connected_freq)) &&
  811|      0|		    p2p_pref_freq_allowed(&p2p->pref_freq_list[i], go))
  ------------------
  |  Branch (811:7): [True: 0, False: 0]
  ------------------
  812|      0|			break;
  813|      0|	}
  814|      0|	if (i != size &&
  ------------------
  |  Branch (814:6): [True: 0, False: 0]
  ------------------
  815|      0|	    p2p_freq_to_channel(p2p->pref_freq_list[i].freq, &op_class,
  ------------------
  |  Branch (815:6): [True: 0, False: 0]
  ------------------
  816|      0|				&op_channel) == 0) {
  817|       |		/* Peer operating channel preference matches our preference */
  818|      0|		p2p->op_reg_class = op_class;
  819|      0|		p2p->op_channel = op_channel;
  820|      0|		os_memcpy(&p2p->channels, &p2p->cfg->channels,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  821|      0|			  sizeof(struct p2p_channels));
  822|      0|		return;
  823|      0|	}
  824|       |
  825|      0|	p2p_dbg(p2p,
  826|      0|		"Peer operating channel preference: %d MHz is not in our preferred channel list",
  827|      0|		dev->oper_freq);
  828|       |
  829|       |	/*
  830|       |	  Check if peer's preferred channel list is
  831|       |	  * _not_ included in the GO Negotiation Request or Invitation Request.
  832|       |	  */
  833|      0|	if (msg->pref_freq_list_len == 0)
  ------------------
  |  Branch (833:6): [True: 0, False: 0]
  ------------------
  834|      0|		p2p_check_pref_chan_no_recv(p2p, go, dev, msg,
  835|      0|					    p2p->pref_freq_list, size);
  836|      0|	else
  837|      0|		p2p_check_pref_chan_recv(p2p, go, dev, msg,
  838|      0|					 p2p->pref_freq_list, size);
  839|      0|}
p2p_process_go_neg_req:
  845|     75|{
  846|     75|	struct p2p_device *dev = NULL;
  847|     75|	struct wpabuf *resp;
  848|     75|	struct p2p_message msg;
  849|     75|	u8 status = P2P_SC_FAIL_INVALID_PARAMS;
  850|     75|	int tie_breaker = 0;
  851|       |
  852|     75|	p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
  853|     75|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     75|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  854|       |
  855|     75|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (855:6): [True: 20, False: 55]
  ------------------
  856|     20|		return NULL;
  857|       |
  858|     55|	if (!msg.capability) {
  ------------------
  |  Branch (858:6): [True: 52, False: 3]
  ------------------
  859|     52|		p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request");
  860|       |#ifdef CONFIG_P2P_STRICT
  861|       |		goto fail;
  862|       |#endif /* CONFIG_P2P_STRICT */
  863|     52|	}
  864|       |
  865|     55|	if (msg.go_intent)
  ------------------
  |  Branch (865:6): [True: 2, False: 53]
  ------------------
  866|      2|		tie_breaker = *msg.go_intent & 0x01;
  867|     53|	else {
  868|     53|		p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request");
  869|       |#ifdef CONFIG_P2P_STRICT
  870|       |		goto fail;
  871|       |#endif /* CONFIG_P2P_STRICT */
  872|     53|	}
  873|       |
  874|     55|	if (!msg.config_timeout) {
  ------------------
  |  Branch (874:6): [True: 54, False: 1]
  ------------------
  875|     54|		p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request");
  876|       |#ifdef CONFIG_P2P_STRICT
  877|       |		goto fail;
  878|       |#endif /* CONFIG_P2P_STRICT */
  879|     54|	}
  880|       |
  881|     55|	if (!msg.listen_channel) {
  ------------------
  |  Branch (881:6): [True: 12, False: 43]
  ------------------
  882|     12|		p2p_dbg(p2p, "No Listen Channel attribute received");
  883|     12|		goto fail;
  884|     12|	}
  885|     43|	if (!msg.operating_channel) {
  ------------------
  |  Branch (885:6): [True: 1, False: 42]
  ------------------
  886|      1|		p2p_dbg(p2p, "No Operating Channel attribute received");
  887|      1|		goto fail;
  888|      1|	}
  889|     42|	if (!msg.channel_list) {
  ------------------
  |  Branch (889:6): [True: 1, False: 41]
  ------------------
  890|      1|		p2p_dbg(p2p, "No Channel List attribute received");
  891|      1|		goto fail;
  892|      1|	}
  893|     41|	if (!msg.intended_addr) {
  ------------------
  |  Branch (893:6): [True: 1, False: 40]
  ------------------
  894|      1|		p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
  895|      1|		goto fail;
  896|      1|	}
  897|     40|	if (!msg.p2p_device_info) {
  ------------------
  |  Branch (897:6): [True: 1, False: 39]
  ------------------
  898|      1|		p2p_dbg(p2p, "No P2P Device Info attribute received");
  899|      1|		goto fail;
  900|      1|	}
  901|       |
  902|     39|	if (!ether_addr_equal(msg.p2p_device_addr, sa)) {
  ------------------
  |  Branch (902:6): [True: 3, False: 36]
  ------------------
  903|      3|		p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR
  904|      3|			" != dev_addr=" MACSTR,
  ------------------
  |  |  448|      3|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  905|      3|			MAC2STR(sa), MAC2STR(msg.p2p_device_addr));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
              			MAC2STR(sa), MAC2STR(msg.p2p_device_addr));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  906|      3|		goto fail;
  907|      3|	}
  908|       |
  909|     36|	dev = p2p_get_device(p2p, sa);
  910|       |
  911|     36|	if (msg.status && *msg.status) {
  ------------------
  |  Branch (911:6): [True: 5, False: 31]
  |  Branch (911:20): [True: 4, False: 1]
  ------------------
  912|      4|		p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
  913|      4|			*msg.status);
  914|      4|		if (dev && p2p->go_neg_peer == dev &&
  ------------------
  |  Branch (914:7): [True: 2, False: 2]
  |  Branch (914:14): [True: 0, False: 2]
  ------------------
  915|      0|		    *msg.status == P2P_SC_FAIL_REJECTED_BY_USER) {
  ------------------
  |  Branch (915:7): [True: 0, False: 0]
  ------------------
  916|       |			/*
  917|       |			 * This mechanism for using Status attribute in GO
  918|       |			 * Negotiation Request is not compliant with the P2P
  919|       |			 * specification, but some deployed devices use it to
  920|       |			 * indicate rejection of GO Negotiation in a case where
  921|       |			 * they have sent out GO Negotiation Response with
  922|       |			 * status 1. The P2P specification explicitly disallows
  923|       |			 * this. To avoid unnecessary interoperability issues
  924|       |			 * and extra frames, mark the pending negotiation as
  925|       |			 * failed and do not reply to this GO Negotiation
  926|       |			 * Request frame.
  927|       |			 */
  928|      0|			p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  929|      0|			p2p_go_neg_failed(p2p, *msg.status);
  930|      0|			p2p_parse_free(&msg);
  931|      0|			return NULL;
  932|      0|		}
  933|      4|		goto fail;
  934|      4|	}
  935|       |
  936|     32|	if (dev == NULL)
  ------------------
  |  Branch (936:6): [True: 13, False: 19]
  ------------------
  937|     13|		dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg);
  938|     19|	else if ((dev->flags & P2P_DEV_PROBE_REQ_ONLY) ||
  ------------------
  |  |  127|     19|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     19|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (938:11): [True: 1, False: 18]
  ------------------
  939|     18|		  !(dev->flags & P2P_DEV_REPORTED))
  ------------------
  |  |  128|     18|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (939:5): [True: 4, False: 14]
  ------------------
  940|      5|		p2p_add_dev_info(p2p, sa, dev, &msg);
  941|     14|	else if (!dev->listen_freq && !dev->oper_freq) {
  ------------------
  |  Branch (941:11): [True: 5, False: 9]
  |  Branch (941:32): [True: 0, False: 5]
  ------------------
  942|       |		/*
  943|       |		 * This may happen if the peer entry was added based on PD
  944|       |		 * Request and no Probe Request/Response frame has been received
  945|       |		 * from this peer (or that information has timed out).
  946|       |		 */
  947|      0|		p2p_dbg(p2p, "Update peer " MACSTR
  948|      0|			" based on GO Neg Req since listen/oper freq not known",
  949|      0|			MAC2STR(dev->info.p2p_device_addr));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  950|      0|		p2p_add_dev_info(p2p, sa, dev, &msg);
  951|      0|	}
  952|       |
  953|     32|	if (dev)
  ------------------
  |  Branch (953:6): [True: 32, False: 0]
  ------------------
  954|     32|		p2p_update_peer_6ghz_capab(dev, &msg);
  955|       |
  956|     32|	if (p2p->go_neg_peer && p2p->go_neg_peer == dev)
  ------------------
  |  Branch (956:6): [True: 0, False: 32]
  |  Branch (956:26): [True: 0, False: 0]
  ------------------
  957|      0|		eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
  958|       |
  959|     32|	if (dev && dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|     32|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|     32|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (959:6): [True: 32, False: 0]
  |  Branch (959:13): [True: 0, False: 32]
  ------------------
  960|      0|		p2p_dbg(p2p, "User has rejected this peer");
  961|      0|		status = P2P_SC_FAIL_REJECTED_BY_USER;
  962|     32|	} else if (dev == NULL ||
  ------------------
  |  Branch (962:13): [True: 0, False: 32]
  ------------------
  963|     32|		   (dev->wps_method == WPS_NOT_READY && !p2p2 &&
  ------------------
  |  Branch (963:7): [True: 32, False: 0]
  |  Branch (963:43): [True: 32, False: 0]
  ------------------
  964|     32|		    (p2p->authorized_oob_dev_pw_id == 0 ||
  ------------------
  |  Branch (964:8): [True: 32, False: 0]
  ------------------
  965|      0|		     p2p->authorized_oob_dev_pw_id !=
  ------------------
  |  Branch (965:8): [True: 0, False: 0]
  ------------------
  966|     32|		     msg.dev_password_id))) {
  967|     32|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|     32|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  968|     32|			MAC2STR(sa));
  ------------------
  |  |  447|     32|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  969|     32|		status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  970|     32|		p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
  971|     32|					msg.dev_password_id,
  972|     32|					msg.go_intent ? (*msg.go_intent >> 1) :
  ------------------
  |  Branch (972:6): [True: 1, False: 31]
  ------------------
  973|     32|					0);
  974|     32|	} else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) {
  ------------------
  |  Branch (974:13): [True: 0, False: 0]
  |  Branch (974:33): [True: 0, False: 0]
  ------------------
  975|      0|		p2p_dbg(p2p, "Already in Group Formation with another peer");
  976|      0|		status = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
  977|      0|	} else {
  978|      0|		int go;
  979|       |
  980|      0|		if (!p2p->go_neg_peer) {
  ------------------
  |  Branch (980:7): [True: 0, False: 0]
  ------------------
  981|      0|			p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer");
  982|      0|			if (!(dev->flags & P2P_DEV_FORCE_FREQ)) {
  ------------------
  |  |  138|      0|#define P2P_DEV_FORCE_FREQ BIT(13)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (982:8): [True: 0, False: 0]
  ------------------
  983|      0|				p2p_dbg(p2p, "Use default channel settings");
  984|      0|				p2p->op_reg_class = p2p->cfg->op_reg_class;
  985|      0|				p2p->op_channel = p2p->cfg->op_channel;
  986|      0|				os_memcpy(&p2p->channels, &p2p->cfg->channels,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  987|      0|					  sizeof(struct p2p_channels));
  988|      0|			} else {
  989|      0|				p2p_dbg(p2p, "Use previously configured forced channel settings");
  990|      0|			}
  991|      0|		}
  992|       |
  993|      0|		dev->flags &= ~P2P_DEV_NOT_YET_READY;
  ------------------
  |  |  129|      0|#define P2P_DEV_NOT_YET_READY BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  994|       |
  995|      0|		if (!msg.go_intent) {
  ------------------
  |  Branch (995:7): [True: 0, False: 0]
  ------------------
  996|      0|			p2p_dbg(p2p, "No GO Intent attribute received");
  997|      0|			goto fail;
  998|      0|		}
  999|      0|		if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
  ------------------
  |  | 1907|      0|#define P2P_MAX_GO_INTENT 15
  ------------------
  |  Branch (999:7): [True: 0, False: 0]
  ------------------
 1000|      0|			p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
 1001|      0|				*msg.go_intent >> 1);
 1002|      0|			goto fail;
 1003|      0|		}
 1004|       |
 1005|      0|		if (dev->go_neg_req_sent &&
  ------------------
  |  Branch (1005:7): [True: 0, False: 0]
  ------------------
 1006|      0|		    os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) {
  ------------------
  |  |  532|      0|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1006:7): [True: 0, False: 0]
  ------------------
 1007|      0|			p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent");
 1008|      0|			p2p_parse_free(&msg);
 1009|      0|			return NULL;
 1010|      0|		}
 1011|       |
 1012|      0|		if (dev->go_neg_req_sent &&
  ------------------
  |  Branch (1012:7): [True: 0, False: 0]
  ------------------
 1013|      0|		    (dev->flags & P2P_DEV_PEER_WAITING_RESPONSE)) {
  ------------------
  |  |  133|      0|#define P2P_DEV_PEER_WAITING_RESPONSE BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1013:7): [True: 0, False: 0]
  ------------------
 1014|      0|			p2p_dbg(p2p,
 1015|      0|				"Do not reply since peer is waiting for us to start a new GO Negotiation and GO Neg Request already sent");
 1016|      0|			p2p_parse_free(&msg);
 1017|      0|			return NULL;
 1018|      0|		}
 1019|       |
 1020|      0|		go = p2p_go_det(p2p->go_intent, *msg.go_intent);
 1021|      0|		if (go < 0) {
  ------------------
  |  Branch (1021:7): [True: 0, False: 0]
  ------------------
 1022|      0|			p2p_dbg(p2p, "Incompatible GO Intent");
 1023|      0|			status = P2P_SC_FAIL_BOTH_GO_INTENT_15;
 1024|      0|			goto fail;
 1025|      0|		}
 1026|       |
 1027|      0|		if (p2p_peer_channels(p2p, dev, msg.channel_list,
  ------------------
  |  Branch (1027:7): [True: 0, False: 0]
  ------------------
 1028|      0|				      msg.channel_list_len) < 0) {
 1029|      0|			p2p_dbg(p2p, "No common channels found");
 1030|      0|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
 1031|      0|			goto fail;
 1032|      0|		}
 1033|       |
 1034|      0|		if (p2p2)
  ------------------
  |  Branch (1034:7): [True: 0, False: 0]
  ------------------
 1035|      0|			goto skip;
 1036|       |
 1037|      0|		switch (msg.dev_password_id) {
 1038|      0|		case DEV_PW_REGISTRAR_SPECIFIED:
  ------------------
  |  Branch (1038:3): [True: 0, False: 0]
  ------------------
 1039|      0|			p2p_dbg(p2p, "PIN from peer Display");
 1040|      0|			if (dev->wps_method != WPS_PIN_KEYPAD) {
  ------------------
  |  Branch (1040:8): [True: 0, False: 0]
  ------------------
 1041|      0|				p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1042|      0|					p2p_wps_method_str(dev->wps_method));
 1043|      0|				status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1044|      0|				goto fail;
 1045|      0|			}
 1046|      0|			break;
 1047|      0|		case DEV_PW_USER_SPECIFIED:
  ------------------
  |  Branch (1047:3): [True: 0, False: 0]
  ------------------
 1048|      0|			p2p_dbg(p2p, "Peer entered PIN on Keypad");
 1049|      0|			if (dev->wps_method != WPS_PIN_DISPLAY) {
  ------------------
  |  Branch (1049:8): [True: 0, False: 0]
  ------------------
 1050|      0|				p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1051|      0|					p2p_wps_method_str(dev->wps_method));
 1052|      0|				status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1053|      0|				goto fail;
 1054|      0|			}
 1055|      0|			break;
 1056|      0|		case DEV_PW_PUSHBUTTON:
  ------------------
  |  Branch (1056:3): [True: 0, False: 0]
  ------------------
 1057|      0|			p2p_dbg(p2p, "Peer using pushbutton");
 1058|      0|			if (dev->wps_method != WPS_PBC) {
  ------------------
  |  Branch (1058:8): [True: 0, False: 0]
  ------------------
 1059|      0|				p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1060|      0|					p2p_wps_method_str(dev->wps_method));
 1061|      0|				status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1062|      0|				goto fail;
 1063|      0|			}
 1064|      0|			break;
 1065|      0|		case DEV_PW_P2PS_DEFAULT:
  ------------------
  |  Branch (1065:3): [True: 0, False: 0]
  ------------------
 1066|      0|			p2p_dbg(p2p, "Peer using P2PS pin");
 1067|      0|			if (dev->wps_method != WPS_P2PS) {
  ------------------
  |  Branch (1067:8): [True: 0, False: 0]
  ------------------
 1068|      0|				p2p_dbg(p2p,
 1069|      0|					"We have wps_method=%s -> incompatible",
 1070|      0|					p2p_wps_method_str(dev->wps_method));
 1071|      0|				status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1072|      0|				goto fail;
 1073|      0|			}
 1074|      0|			break;
 1075|      0|		default:
  ------------------
  |  Branch (1075:3): [True: 0, False: 0]
  ------------------
 1076|      0|			if (msg.dev_password_id &&
  ------------------
  |  Branch (1076:8): [True: 0, False: 0]
  ------------------
 1077|      0|			    msg.dev_password_id == dev->oob_pw_id) {
  ------------------
  |  Branch (1077:8): [True: 0, False: 0]
  ------------------
 1078|      0|				p2p_dbg(p2p, "Peer using NFC");
 1079|      0|				if (dev->wps_method != WPS_NFC) {
  ------------------
  |  Branch (1079:9): [True: 0, False: 0]
  ------------------
 1080|      0|					p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1081|      0|						p2p_wps_method_str(
 1082|      0|							dev->wps_method));
 1083|      0|					status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1084|      0|					goto fail;
 1085|      0|				}
 1086|      0|				break;
 1087|      0|			}
 1088|      0|#ifdef CONFIG_WPS_NFC
 1089|      0|			if (p2p->authorized_oob_dev_pw_id &&
  ------------------
  |  Branch (1089:8): [True: 0, False: 0]
  ------------------
 1090|      0|			    msg.dev_password_id ==
  ------------------
  |  Branch (1090:8): [True: 0, False: 0]
  ------------------
 1091|      0|			    p2p->authorized_oob_dev_pw_id) {
 1092|      0|				p2p_dbg(p2p, "Using static handover with our device password from NFC Tag");
 1093|      0|				dev->wps_method = WPS_NFC;
 1094|      0|				dev->oob_pw_id = p2p->authorized_oob_dev_pw_id;
 1095|      0|				break;
 1096|      0|			}
 1097|      0|#endif /* CONFIG_WPS_NFC */
 1098|      0|			p2p_dbg(p2p, "Unsupported Device Password ID %d",
 1099|      0|				msg.dev_password_id);
 1100|      0|			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1101|      0|			goto fail;
 1102|      0|		}
 1103|       |
 1104|      0|skip:
 1105|      0|		if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
  ------------------
  |  Branch (1105:7): [True: 0, False: 0]
  |  Branch (1105:13): [True: 0, False: 0]
  ------------------
 1106|      0|			goto fail;
 1107|       |
 1108|      0|		dev->go_state = go ? LOCAL_GO : REMOTE_GO;
  ------------------
  |  Branch (1108:19): [True: 0, False: 0]
  ------------------
 1109|      0|		dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
 1110|      0|						     msg.operating_channel[4]);
 1111|      0|		p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
 1112|      0|			dev->oper_freq);
 1113|       |
 1114|       |		/*
 1115|       |		 * Use the driver preferred frequency list extension if
 1116|       |		 * supported.
 1117|       |		 */
 1118|      0|		p2p_check_pref_chan(p2p, go, dev, &msg);
 1119|       |
 1120|      0|		if (msg.config_timeout) {
  ------------------
  |  Branch (1120:7): [True: 0, False: 0]
  ------------------
 1121|      0|			dev->go_timeout = msg.config_timeout[0];
 1122|      0|			dev->client_timeout = msg.config_timeout[1];
 1123|      0|		}
 1124|       |
 1125|      0|		p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              		p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1126|      0|		if (p2p->state != P2P_IDLE)
  ------------------
  |  Branch (1126:7): [True: 0, False: 0]
  ------------------
 1127|      0|			p2p_stop_find_for_freq(p2p, rx_freq);
 1128|      0|		p2p_set_state(p2p, P2P_GO_NEG);
 1129|      0|		p2p_clear_timeout(p2p);
 1130|      0|		dev->dialog_token = msg.dialog_token;
 1131|      0|		os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1132|      0|		p2p->go_neg_peer = dev;
 1133|      0|		eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
 1134|      0|		status = P2P_SC_SUCCESS;
 1135|      0|	}
 1136|       |
 1137|     55|fail:
 1138|     55|	if (dev)
  ------------------
  |  Branch (1138:6): [True: 34, False: 21]
  ------------------
 1139|     34|		dev->status = status;
 1140|     55|	resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status,
 1141|     55|				     !tie_breaker);
 1142|     55|	p2p_parse_free(&msg);
 1143|     55|	if (resp == NULL)
  ------------------
  |  Branch (1143:6): [True: 0, False: 55]
  ------------------
 1144|      0|		return NULL;
 1145|       |
 1146|     55|	if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1146:6): [True: 0, False: 55]
  ------------------
 1147|      0|		p2p->pending_action_state = P2P_PENDING_GO_NEG_RESPONSE;
 1148|      0|		dev->flags |= P2P_DEV_WAIT_GO_NEG_CONFIRM;
  ------------------
  |  |  136|      0|#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1149|      0|		if (os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) < 0) {
  ------------------
  |  |  532|      0|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1149:7): [True: 0, False: 0]
  ------------------
 1150|       |			/*
 1151|       |			 * Peer has smaller address, so the GO Negotiation
 1152|       |			 * Response from us is expected to complete
 1153|       |			 * negotiation. Ignore a GO Negotiation Response from
 1154|       |			 * the peer if it happens to be received after this
 1155|       |			 * point due to a race condition in GO Negotiation
 1156|       |			 * Request transmission and processing.
 1157|       |			 */
 1158|      0|			dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
  ------------------
  |  |  135|      0|#define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1159|      0|		}
 1160|      0|	} else
 1161|     55|		p2p->pending_action_state =
 1162|     55|			P2P_PENDING_GO_NEG_RESPONSE_FAILURE;
 1163|     55|	return resp;
 1164|     55|}
p2p_handle_go_neg_req:
 1169|     75|{
 1170|     75|	int freq;
 1171|     75|	struct wpabuf *resp;
 1172|       |
 1173|     75|	resp = p2p_process_go_neg_req(p2p, sa, data, len, rx_freq, false);
 1174|     75|	if (!resp)
  ------------------
  |  Branch (1174:6): [True: 20, False: 55]
  ------------------
 1175|     20|		return;
 1176|       |
 1177|     55|	p2p_dbg(p2p, "Sending GO Negotiation Response");
 1178|       |
 1179|     55|	if (rx_freq > 0)
  ------------------
  |  Branch (1179:6): [True: 55, False: 0]
  ------------------
 1180|     55|		freq = rx_freq;
 1181|      0|	else
 1182|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
 1183|      0|					   p2p->cfg->channel);
 1184|     55|	if (freq < 0) {
  ------------------
  |  Branch (1184:6): [True: 0, False: 55]
  ------------------
 1185|      0|		p2p_dbg(p2p, "Unknown regulatory class/channel");
 1186|      0|		wpabuf_free(resp);
 1187|      0|		return;
 1188|      0|	}
 1189|       |
 1190|     55|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (1190:6): [True: 0, False: 55]
  ------------------
 1191|     55|			    p2p->cfg->dev_addr,
 1192|     55|			    wpabuf_head(resp), wpabuf_len(resp), 100) < 0) {
 1193|      0|		p2p_dbg(p2p, "Failed to send Action frame");
 1194|      0|	}
 1195|       |
 1196|     55|	wpabuf_free(resp);
 1197|     55|}
p2p_process_go_neg_resp:
 1286|      3|{
 1287|      3|	struct p2p_device *dev;
 1288|      3|	int go = -1;
 1289|      3|	struct p2p_message msg;
 1290|      3|	u8 status = P2P_SC_SUCCESS;
 1291|      3|	int freq;
 1292|      3|	struct wpabuf *conf = NULL;
 1293|       |
 1294|      3|	p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
 1295|      3|		" (freq=%d)", MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1296|      3|	dev = p2p_get_device(p2p, sa);
 1297|      3|	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
  ------------------
  |  Branch (1297:6): [True: 2, False: 1]
  |  Branch (1297:22): [True: 1, False: 0]
  |  Branch (1297:31): [True: 1, False: 0]
  ------------------
 1298|      3|	    dev != p2p->go_neg_peer) {
  ------------------
  |  Branch (1298:6): [True: 0, False: 0]
  ------------------
 1299|      3|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|      3|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1300|      3|			MAC2STR(sa));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1301|      3|		return NULL;
 1302|      3|	}
 1303|       |
 1304|      0|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (1304:6): [True: 0, False: 0]
  ------------------
 1305|      0|		return NULL;
 1306|       |
 1307|      0|	if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE)) {
  ------------------
  |  |  135|      0|#define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1307:6): [True: 0, False: 0]
  ------------------
 1308|      0|		p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore");
 1309|      0|		p2p_parse_free(&msg);
 1310|      0|		return NULL;
 1311|      0|	}
 1312|      0|	dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
  ------------------
  |  |  135|      0|#define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1313|      0|	p2p_update_peer_6ghz_capab(dev, &msg);
 1314|       |
 1315|      0|	if (msg.dialog_token != dev->dialog_token) {
  ------------------
  |  Branch (1315:6): [True: 0, False: 0]
  ------------------
 1316|      0|		p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
 1317|      0|			msg.dialog_token, dev->dialog_token);
 1318|      0|		p2p_parse_free(&msg);
 1319|      0|		return NULL;
 1320|      0|	}
 1321|       |
 1322|      0|	if (!msg.status) {
  ------------------
  |  Branch (1322:6): [True: 0, False: 0]
  ------------------
 1323|      0|		p2p_dbg(p2p, "No Status attribute received");
 1324|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1325|      0|		goto fail;
 1326|      0|	}
 1327|      0|	if (*msg.status) {
  ------------------
  |  Branch (1327:6): [True: 0, False: 0]
  ------------------
 1328|      0|		p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
 1329|      0|		dev->go_neg_req_sent = 0;
 1330|      0|		if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) {
  ------------------
  |  Branch (1330:7): [True: 0, False: 0]
  ------------------
 1331|      0|			p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation");
 1332|      0|			dev->flags |= P2P_DEV_NOT_YET_READY;
  ------------------
  |  |  129|      0|#define P2P_DEV_NOT_YET_READY BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1333|      0|			eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p,
 1334|      0|					     NULL);
 1335|      0|			eloop_register_timeout(120, 0, p2p_go_neg_wait_timeout,
 1336|      0|					       p2p, NULL);
 1337|      0|			if (p2p->state == P2P_CONNECT_LISTEN)
  ------------------
  |  Branch (1337:8): [True: 0, False: 0]
  ------------------
 1338|      0|				p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT);
 1339|      0|			else
 1340|      0|				p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
 1341|      0|			p2p_set_timeout(p2p, 0, 0);
 1342|      0|		} else {
 1343|      0|			p2p_dbg(p2p, "Stop GO Negotiation attempt");
 1344|      0|			p2p_go_neg_failed(p2p, *msg.status);
 1345|      0|		}
 1346|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 1347|      0|		p2p_parse_free(&msg);
 1348|      0|		return NULL;
 1349|      0|	}
 1350|       |
 1351|      0|	if (!msg.capability) {
  ------------------
  |  Branch (1351:6): [True: 0, False: 0]
  ------------------
 1352|      0|		p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response");
 1353|       |#ifdef CONFIG_P2P_STRICT
 1354|       |		status = P2P_SC_FAIL_INVALID_PARAMS;
 1355|       |		goto fail;
 1356|       |#endif /* CONFIG_P2P_STRICT */
 1357|      0|	}
 1358|       |
 1359|      0|	if (!msg.p2p_device_info) {
  ------------------
  |  Branch (1359:6): [True: 0, False: 0]
  ------------------
 1360|      0|		p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response");
 1361|       |#ifdef CONFIG_P2P_STRICT
 1362|       |		status = P2P_SC_FAIL_INVALID_PARAMS;
 1363|       |		goto fail;
 1364|       |#endif /* CONFIG_P2P_STRICT */
 1365|      0|	}
 1366|       |
 1367|      0|	if (!msg.intended_addr) {
  ------------------
  |  Branch (1367:6): [True: 0, False: 0]
  ------------------
 1368|      0|		p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
 1369|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1370|      0|		goto fail;
 1371|      0|	}
 1372|       |
 1373|      0|	if (!msg.go_intent) {
  ------------------
  |  Branch (1373:6): [True: 0, False: 0]
  ------------------
 1374|      0|		p2p_dbg(p2p, "No GO Intent attribute received");
 1375|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1376|      0|		goto fail;
 1377|      0|	}
 1378|      0|	if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) {
  ------------------
  |  | 1907|      0|#define P2P_MAX_GO_INTENT 15
  ------------------
  |  Branch (1378:6): [True: 0, False: 0]
  ------------------
 1379|      0|		p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
 1380|      0|			*msg.go_intent >> 1);
 1381|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1382|      0|		goto fail;
 1383|      0|	}
 1384|       |
 1385|      0|	go = p2p_go_det(p2p->go_intent, *msg.go_intent);
 1386|      0|	if (go < 0) {
  ------------------
  |  Branch (1386:6): [True: 0, False: 0]
  ------------------
 1387|      0|		p2p_dbg(p2p, "Incompatible GO Intent");
 1388|      0|		status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1389|      0|		goto fail;
 1390|      0|	}
 1391|       |
 1392|      0|	if (!go && msg.group_id) {
  ------------------
  |  Branch (1392:6): [True: 0, False: 0]
  |  Branch (1392:13): [True: 0, False: 0]
  ------------------
 1393|       |		/* Store SSID for Provisioning step */
 1394|      0|		p2p->ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
 1395|      0|		os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1396|      0|	} else if (!go) {
  ------------------
  |  Branch (1396:13): [True: 0, False: 0]
  ------------------
 1397|      0|		p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response");
 1398|      0|		p2p->ssid_len = 0;
 1399|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1400|      0|		goto fail;
 1401|      0|	}
 1402|       |
 1403|      0|	if (!msg.config_timeout) {
  ------------------
  |  Branch (1403:6): [True: 0, False: 0]
  ------------------
 1404|      0|		p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response");
 1405|       |#ifdef CONFIG_P2P_STRICT
 1406|       |		status = P2P_SC_FAIL_INVALID_PARAMS;
 1407|       |		goto fail;
 1408|       |#endif /* CONFIG_P2P_STRICT */
 1409|      0|	} else {
 1410|      0|		dev->go_timeout = msg.config_timeout[0];
 1411|      0|		dev->client_timeout = msg.config_timeout[1];
 1412|      0|	}
 1413|       |
 1414|      0|	if (msg.wfd_subelems) {
  ------------------
  |  Branch (1414:6): [True: 0, False: 0]
  ------------------
 1415|      0|		wpabuf_free(dev->info.wfd_subelems);
 1416|      0|		dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 1417|      0|	}
 1418|       |
 1419|      0|	if (!msg.operating_channel && !go) {
  ------------------
  |  Branch (1419:6): [True: 0, False: 0]
  |  Branch (1419:32): [True: 0, False: 0]
  ------------------
 1420|       |		/*
 1421|       |		 * Note: P2P Client may omit Operating Channel attribute to
 1422|       |		 * indicate it does not have a preference.
 1423|       |		 */
 1424|      0|		p2p_dbg(p2p, "No Operating Channel attribute received");
 1425|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1426|      0|		goto fail;
 1427|      0|	}
 1428|      0|	if (!msg.channel_list) {
  ------------------
  |  Branch (1428:6): [True: 0, False: 0]
  ------------------
 1429|      0|		p2p_dbg(p2p, "No Channel List attribute received");
 1430|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1431|      0|		goto fail;
 1432|      0|	}
 1433|       |
 1434|      0|	if (p2p_peer_channels(p2p, dev, msg.channel_list,
  ------------------
  |  Branch (1434:6): [True: 0, False: 0]
  ------------------
 1435|      0|			      msg.channel_list_len) < 0) {
 1436|      0|		p2p_dbg(p2p, "No common channels found");
 1437|      0|		status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
 1438|      0|		goto fail;
 1439|      0|	}
 1440|       |
 1441|      0|	if (msg.operating_channel) {
  ------------------
  |  Branch (1441:6): [True: 0, False: 0]
  ------------------
 1442|      0|		dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
 1443|      0|						     msg.operating_channel[4]);
 1444|      0|		p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
 1445|      0|			dev->oper_freq);
 1446|      0|	} else
 1447|      0|		dev->oper_freq = 0;
 1448|       |
 1449|      0|	if (p2p2)
  ------------------
  |  Branch (1449:6): [True: 0, False: 0]
  ------------------
 1450|      0|		goto skip;
 1451|       |
 1452|      0|	switch (msg.dev_password_id) {
 1453|      0|	case DEV_PW_REGISTRAR_SPECIFIED:
  ------------------
  |  Branch (1453:2): [True: 0, False: 0]
  ------------------
 1454|      0|		p2p_dbg(p2p, "PIN from peer Display");
 1455|      0|		if (dev->wps_method != WPS_PIN_KEYPAD) {
  ------------------
  |  Branch (1455:7): [True: 0, False: 0]
  ------------------
 1456|      0|			p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1457|      0|				p2p_wps_method_str(dev->wps_method));
 1458|      0|			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1459|      0|			goto fail;
 1460|      0|		}
 1461|      0|		break;
 1462|      0|	case DEV_PW_USER_SPECIFIED:
  ------------------
  |  Branch (1462:2): [True: 0, False: 0]
  ------------------
 1463|      0|		p2p_dbg(p2p, "Peer entered PIN on Keypad");
 1464|      0|		if (dev->wps_method != WPS_PIN_DISPLAY) {
  ------------------
  |  Branch (1464:7): [True: 0, False: 0]
  ------------------
 1465|      0|			p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1466|      0|				p2p_wps_method_str(dev->wps_method));
 1467|      0|			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1468|      0|			goto fail;
 1469|      0|		}
 1470|      0|		break;
 1471|      0|	case DEV_PW_PUSHBUTTON:
  ------------------
  |  Branch (1471:2): [True: 0, False: 0]
  ------------------
 1472|      0|		p2p_dbg(p2p, "Peer using pushbutton");
 1473|      0|		if (dev->wps_method != WPS_PBC) {
  ------------------
  |  Branch (1473:7): [True: 0, False: 0]
  ------------------
 1474|      0|			p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1475|      0|				p2p_wps_method_str(dev->wps_method));
 1476|      0|			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1477|      0|			goto fail;
 1478|      0|		}
 1479|      0|		break;
 1480|      0|	case DEV_PW_P2PS_DEFAULT:
  ------------------
  |  Branch (1480:2): [True: 0, False: 0]
  ------------------
 1481|      0|		p2p_dbg(p2p, "P2P: Peer using P2PS default pin");
 1482|      0|		if (dev->wps_method != WPS_P2PS) {
  ------------------
  |  Branch (1482:7): [True: 0, False: 0]
  ------------------
 1483|      0|			p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1484|      0|				p2p_wps_method_str(dev->wps_method));
 1485|      0|			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1486|      0|			goto fail;
 1487|      0|		}
 1488|      0|		break;
 1489|      0|	default:
  ------------------
  |  Branch (1489:2): [True: 0, False: 0]
  ------------------
 1490|      0|		if (msg.dev_password_id &&
  ------------------
  |  Branch (1490:7): [True: 0, False: 0]
  ------------------
 1491|      0|		    msg.dev_password_id == dev->oob_pw_id) {
  ------------------
  |  Branch (1491:7): [True: 0, False: 0]
  ------------------
 1492|      0|			p2p_dbg(p2p, "Peer using NFC");
 1493|      0|			if (dev->wps_method != WPS_NFC) {
  ------------------
  |  Branch (1493:8): [True: 0, False: 0]
  ------------------
 1494|      0|				p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
 1495|      0|					p2p_wps_method_str(dev->wps_method));
 1496|      0|				status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1497|      0|				goto fail;
 1498|      0|			}
 1499|      0|			break;
 1500|      0|		}
 1501|      0|		p2p_dbg(p2p, "Unsupported Device Password ID %d",
 1502|      0|			msg.dev_password_id);
 1503|      0|		status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 1504|      0|		goto fail;
 1505|      0|	}
 1506|       |
 1507|      0|skip:
 1508|      0|	if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
  ------------------
  |  Branch (1508:6): [True: 0, False: 0]
  |  Branch (1508:12): [True: 0, False: 0]
  ------------------
 1509|      0|		goto fail;
 1510|       |
 1511|       |	/*
 1512|       |	 * Use the driver preferred frequency list extension if local device is
 1513|       |	 * GO.
 1514|       |	 */
 1515|      0|	if (go)
  ------------------
  |  Branch (1515:6): [True: 0, False: 0]
  ------------------
 1516|      0|		p2p_check_pref_chan(p2p, go, dev, &msg);
 1517|       |
 1518|      0|	p2p_set_state(p2p, P2P_GO_NEG);
 1519|      0|	p2p_clear_timeout(p2p);
 1520|       |
 1521|      0|	p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1522|      0|	os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1523|       |
 1524|      0|fail:
 1525|       |	/* Store GO Negotiation Confirmation to allow retransmission */
 1526|      0|	wpabuf_free(dev->go_neg_conf);
 1527|      0|	dev->go_neg_conf = p2p_build_go_neg_conf(p2p, dev, msg.dialog_token,
 1528|      0|						 status, msg.operating_channel,
 1529|      0|						 go);
 1530|      0|	p2p_parse_free(&msg);
 1531|      0|	if (dev->go_neg_conf == NULL)
  ------------------
  |  Branch (1531:6): [True: 0, False: 0]
  ------------------
 1532|      0|		return NULL;
 1533|       |
 1534|      0|	conf = wpabuf_dup(dev->go_neg_conf);
 1535|       |
 1536|      0|	if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1536:6): [True: 0, False: 0]
  ------------------
 1537|      0|		p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM;
 1538|      0|		dev->go_state = go ? LOCAL_GO : REMOTE_GO;
  ------------------
  |  Branch (1538:19): [True: 0, False: 0]
  ------------------
 1539|      0|	} else
 1540|      0|		p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 1541|      0|	if (rx_freq > 0)
  ------------------
  |  Branch (1541:6): [True: 0, False: 0]
  ------------------
 1542|      0|		freq = rx_freq;
 1543|      0|	else
 1544|      0|		freq = dev->listen_freq;
 1545|       |
 1546|      0|	dev->go_neg_conf_freq = freq;
 1547|      0|	dev->go_neg_conf_sent = 0;
 1548|       |
 1549|      0|	if (status != P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1549:6): [True: 0, False: 0]
  ------------------
 1550|      0|		p2p_dbg(p2p, "GO Negotiation failed");
 1551|      0|		dev->status = status;
 1552|      0|	}
 1553|       |
 1554|      0|	return conf;
 1555|      0|}
p2p_handle_go_neg_resp:
 1560|      3|{
 1561|      3|	int freq;
 1562|      3|	struct p2p_device *dev;
 1563|      3|	struct wpabuf *conf;
 1564|       |
 1565|      3|	conf = p2p_process_go_neg_resp(p2p, sa, data, len, rx_freq, false);
 1566|      3|	if (!conf)
  ------------------
  |  Branch (1566:6): [True: 3, False: 0]
  ------------------
 1567|      3|		return;
 1568|      0|	wpabuf_free(conf);
 1569|       |
 1570|      0|	dev = p2p_get_device(p2p, sa);
 1571|      0|	if (!dev)
  ------------------
  |  Branch (1571:6): [True: 0, False: 0]
  ------------------
 1572|      0|		return;
 1573|       |
 1574|      0|	p2p_dbg(p2p, "Sending GO Negotiation Confirm");
 1575|      0|	if (rx_freq > 0)
  ------------------
  |  Branch (1575:6): [True: 0, False: 0]
  ------------------
 1576|      0|		freq = rx_freq;
 1577|      0|	else
 1578|      0|		freq = dev->listen_freq;
 1579|       |
 1580|      0|	if (dev->go_neg_conf &&
  ------------------
  |  Branch (1580:6): [True: 0, False: 0]
  ------------------
 1581|      0|	    p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa,
  ------------------
  |  Branch (1581:6): [True: 0, False: 0]
  ------------------
 1582|      0|			    wpabuf_head(dev->go_neg_conf),
 1583|      0|			    wpabuf_len(dev->go_neg_conf), 50) < 0) {
 1584|      0|		p2p_dbg(p2p, "Failed to send Action frame");
 1585|      0|		p2p_go_neg_failed(p2p, -1);
 1586|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 1587|      0|	} else
 1588|      0|		dev->go_neg_conf_sent++;
 1589|       |
 1590|      0|	if (dev->status != P2P_SC_SUCCESS)
  ------------------
  |  Branch (1590:6): [True: 0, False: 0]
  ------------------
 1591|      0|		p2p_go_neg_failed(p2p, dev->status);
 1592|      0|}
p2p_handle_go_neg_conf:
 1597|      2|{
 1598|      2|	struct p2p_device *dev;
 1599|      2|	struct p2p_message msg;
 1600|       |
 1601|      2|	p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1602|      2|		MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1603|      2|	dev = p2p_get_device(p2p, sa);
 1604|      2|	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
  ------------------
  |  Branch (1604:6): [True: 1, False: 1]
  |  Branch (1604:22): [True: 1, False: 0]
  |  Branch (1604:31): [True: 1, False: 0]
  ------------------
 1605|      2|	    dev != p2p->go_neg_peer) {
  ------------------
  |  Branch (1605:6): [True: 0, False: 0]
  ------------------
 1606|      2|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1607|      2|			MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1608|      2|		return;
 1609|      2|	}
 1610|       |
 1611|      0|	if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) {
  ------------------
  |  Branch (1611:6): [True: 0, False: 0]
  ------------------
 1612|      0|		p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation");
 1613|      0|		p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 1614|      0|	}
 1615|       |
 1616|      0|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (1616:6): [True: 0, False: 0]
  ------------------
 1617|      0|		return;
 1618|       |
 1619|      0|	if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
  ------------------
  |  |  136|      0|#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1619:6): [True: 0, False: 0]
  ------------------
 1620|      0|		p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore");
 1621|      0|		p2p_parse_free(&msg);
 1622|      0|		return;
 1623|      0|	}
 1624|      0|	dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM;
  ------------------
  |  |  136|      0|#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1625|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 1626|       |
 1627|      0|	if (msg.dialog_token != dev->dialog_token) {
  ------------------
  |  Branch (1627:6): [True: 0, False: 0]
  ------------------
 1628|      0|		p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
 1629|      0|			msg.dialog_token, dev->dialog_token);
 1630|      0|		p2p_parse_free(&msg);
 1631|      0|		return;
 1632|      0|	}
 1633|       |
 1634|      0|	if (!msg.status) {
  ------------------
  |  Branch (1634:6): [True: 0, False: 0]
  ------------------
 1635|      0|		p2p_dbg(p2p, "No Status attribute received");
 1636|      0|		p2p_parse_free(&msg);
 1637|      0|		return;
 1638|      0|	}
 1639|      0|	if (*msg.status) {
  ------------------
  |  Branch (1639:6): [True: 0, False: 0]
  ------------------
 1640|      0|		p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
 1641|      0|		p2p_go_neg_failed(p2p, *msg.status);
 1642|      0|		p2p_parse_free(&msg);
 1643|      0|		return;
 1644|      0|	}
 1645|       |
 1646|      0|	p2p_update_peer_6ghz_capab(dev, &msg);
 1647|       |
 1648|      0|	if (dev->go_state == REMOTE_GO && msg.group_id) {
  ------------------
  |  Branch (1648:6): [True: 0, False: 0]
  |  Branch (1648:36): [True: 0, False: 0]
  ------------------
 1649|       |		/* Store SSID for Provisioning step */
 1650|      0|		p2p->ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
 1651|      0|		os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1652|      0|	} else if (dev->go_state == REMOTE_GO) {
  ------------------
  |  Branch (1652:13): [True: 0, False: 0]
  ------------------
 1653|      0|		p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
 1654|      0|		p2p->ssid_len = 0;
 1655|      0|		p2p_go_neg_failed(p2p, P2P_SC_FAIL_INVALID_PARAMS);
 1656|      0|		p2p_parse_free(&msg);
 1657|      0|		return;
 1658|      0|	}
 1659|       |
 1660|      0|	if (!msg.operating_channel) {
  ------------------
  |  Branch (1660:6): [True: 0, False: 0]
  ------------------
 1661|      0|		p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
 1662|       |#ifdef CONFIG_P2P_STRICT
 1663|       |		p2p_parse_free(&msg);
 1664|       |		return;
 1665|       |#endif /* CONFIG_P2P_STRICT */
 1666|      0|	} else if (dev->go_state == REMOTE_GO) {
  ------------------
  |  Branch (1666:13): [True: 0, False: 0]
  ------------------
 1667|      0|		int oper_freq = p2p_channel_to_freq(msg.operating_channel[3],
 1668|      0|						    msg.operating_channel[4]);
 1669|      0|		if (oper_freq != dev->oper_freq) {
  ------------------
  |  Branch (1669:7): [True: 0, False: 0]
  ------------------
 1670|      0|			p2p_dbg(p2p, "Updated peer (GO) operating channel preference from %d MHz to %d MHz",
 1671|      0|				dev->oper_freq, oper_freq);
 1672|      0|			dev->oper_freq = oper_freq;
 1673|      0|		}
 1674|      0|	}
 1675|       |
 1676|      0|	if (!msg.channel_list) {
  ------------------
  |  Branch (1676:6): [True: 0, False: 0]
  ------------------
 1677|      0|		p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
 1678|       |#ifdef CONFIG_P2P_STRICT
 1679|       |		p2p_parse_free(&msg);
 1680|       |		return;
 1681|       |#endif /* CONFIG_P2P_STRICT */
 1682|      0|	}
 1683|       |
 1684|      0|	p2p_parse_free(&msg);
 1685|       |
 1686|      0|	if (dev->go_state == UNKNOWN_GO) {
  ------------------
  |  Branch (1686:6): [True: 0, False: 0]
  ------------------
 1687|       |		/*
 1688|       |		 * This should not happen since GO negotiation has already
 1689|       |		 * been completed.
 1690|       |		 */
 1691|      0|		p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO");
 1692|      0|		return;
 1693|      0|	}
 1694|       |
 1695|       |	/*
 1696|       |	 * The peer could have missed our ctrl::ack frame for GO Negotiation
 1697|       |	 * Confirm and continue retransmitting the frame. To reduce the
 1698|       |	 * likelihood of the peer not getting successful TX status for the
 1699|       |	 * GO Negotiation Confirm frame, wait a short time here before starting
 1700|       |	 * the group so that we will remain on the current channel to
 1701|       |	 * acknowledge any possible retransmission from the peer.
 1702|       |	 */
 1703|      0|	p2p_dbg(p2p, "20 ms wait on current channel before starting group");
 1704|      0|	os_sleep(0, 20000);
 1705|       |
 1706|      0|	p2p_go_complete(p2p, dev);
 1707|      0|}
p2p_go_neg.c:p2p_build_go_neg_resp:
  306|     55|{
  307|     55|	struct wpabuf *buf;
  308|     55|	struct wpabuf *subelems;
  309|     55|	u8 group_capab;
  310|     55|	size_t extra = 0;
  311|     55|	u16 pw_id;
  312|     55|	bool is_6ghz_capab;
  313|     55|	struct p2p_channels pref_chanlist;
  314|       |
  315|     55|	p2p_dbg(p2p, "Building GO Negotiation Response");
  316|       |
  317|     55|#ifdef CONFIG_WIFI_DISPLAY
  318|     55|	if (p2p->wfd_ie_go_neg)
  ------------------
  |  Branch (318:6): [True: 0, False: 55]
  ------------------
  319|      0|		extra = wpabuf_len(p2p->wfd_ie_go_neg);
  320|     55|#endif /* CONFIG_WIFI_DISPLAY */
  321|       |
  322|     55|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
  ------------------
  |  Branch (322:6): [True: 0, False: 55]
  |  Branch (322:26): [True: 0, False: 0]
  ------------------
  323|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
  324|       |
  325|     55|	buf = wpabuf_alloc(1000 + extra);
  326|     55|	if (buf == NULL)
  ------------------
  |  Branch (326:6): [True: 0, False: 55]
  ------------------
  327|      0|		return NULL;
  328|       |
  329|     55|	p2p_buf_add_public_action_hdr(buf, P2P_GO_NEG_RESP, dialog_token);
  330|       |
  331|     55|	subelems = wpabuf_alloc(500);
  332|     55|	if (!subelems) {
  ------------------
  |  Branch (332:6): [True: 0, False: 55]
  ------------------
  333|      0|		wpabuf_free(buf);
  334|      0|		return NULL;
  335|      0|	}
  336|       |
  337|     55|	p2p_buf_add_status(subelems, status);
  338|     55|	group_capab = 0;
  339|     55|	if (peer && peer->go_state == LOCAL_GO) {
  ------------------
  |  Branch (339:6): [True: 34, False: 21]
  |  Branch (339:14): [True: 0, False: 34]
  ------------------
  340|      0|		if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP) {
  ------------------
  |  |  134|      0|#define P2P_DEV_PREFER_PERSISTENT_GROUP BIT(9)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (340:7): [True: 0, False: 0]
  ------------------
  341|      0|			group_capab |= P2P_GROUP_CAPAB_PERSISTENT_GROUP;
  ------------------
  |  | 1920|      0|#define P2P_GROUP_CAPAB_PERSISTENT_GROUP BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  342|      0|			if (peer->flags & P2P_DEV_PREFER_PERSISTENT_RECONN)
  ------------------
  |  |  141|      0|#define P2P_DEV_PREFER_PERSISTENT_RECONN BIT(16)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (342:8): [True: 0, False: 0]
  ------------------
  343|      0|				group_capab |=
  344|      0|					P2P_GROUP_CAPAB_PERSISTENT_RECONN;
  ------------------
  |  | 1924|      0|#define P2P_GROUP_CAPAB_PERSISTENT_RECONN BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  345|      0|		}
  346|      0|		if (p2p->cross_connect)
  ------------------
  |  Branch (346:7): [True: 0, False: 0]
  ------------------
  347|      0|			group_capab |= P2P_GROUP_CAPAB_CROSS_CONN;
  ------------------
  |  | 1923|      0|#define P2P_GROUP_CAPAB_CROSS_CONN BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  348|      0|		if (p2p->cfg->p2p_intra_bss)
  ------------------
  |  Branch (348:7): [True: 0, False: 0]
  ------------------
  349|      0|			group_capab |= P2P_GROUP_CAPAB_INTRA_BSS_DIST;
  ------------------
  |  | 1922|      0|#define P2P_GROUP_CAPAB_INTRA_BSS_DIST BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  350|      0|	}
  351|     55|	p2p_buf_add_capability(subelems, p2p->dev_capab &
  352|     55|			       ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY,
  ------------------
  |  | 1911|     55|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|     55|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  353|     55|			       group_capab);
  354|     55|	p2p_buf_add_go_intent(subelems, (p2p->go_intent << 1) | tie_breaker);
  355|     55|	p2p_buf_add_config_timeout(subelems, p2p->go_timeout,
  356|     55|				   p2p->client_timeout);
  357|     55|	if (p2p->override_pref_op_class) {
  ------------------
  |  Branch (357:6): [True: 0, False: 55]
  ------------------
  358|      0|		p2p_dbg(p2p, "Override operating channel preference");
  359|      0|		p2p_buf_add_operating_channel(subelems, p2p->cfg->country,
  360|      0|					      p2p->override_pref_op_class,
  361|      0|					      p2p->override_pref_channel);
  362|     55|	} else if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
  ------------------
  |  Branch (362:13): [True: 34, False: 21]
  |  Branch (362:21): [True: 0, False: 34]
  |  Branch (362:52): [True: 0, False: 0]
  ------------------
  363|      0|		p2p_dbg(p2p, "Omit Operating Channel attribute");
  364|     55|	} else {
  365|     55|		p2p_buf_add_operating_channel(subelems, p2p->cfg->country,
  366|     55|					      p2p->op_reg_class,
  367|     55|					      p2p->op_channel);
  368|     55|	}
  369|     55|	p2p_buf_add_intended_addr(subelems, p2p->intended_addr);
  370|       |
  371|     55|	if (p2p->num_pref_freq) {
  ------------------
  |  Branch (371:6): [True: 0, False: 55]
  ------------------
  372|      0|		bool go = (peer && peer->go_state == LOCAL_GO) ||
  ------------------
  |  Branch (372:14): [True: 0, False: 0]
  |  Branch (372:22): [True: 0, False: 0]
  ------------------
  373|      0|			p2p->go_intent == 15;
  ------------------
  |  Branch (373:4): [True: 0, False: 0]
  ------------------
  374|       |
  375|      0|		p2p_pref_channel_filter(&p2p->channels, p2p->pref_freq_list,
  376|      0|					p2p->num_pref_freq, &pref_chanlist, go);
  377|      0|		p2p_channels_dump(p2p, "channel list after filtering",
  378|      0|				  &pref_chanlist);
  379|     55|	} else {
  380|     55|		p2p_copy_channels(&pref_chanlist, &p2p->channels,
  381|     55|				  p2p->allow_6ghz);
  382|     55|	}
  383|     55|	if (status || peer == NULL) {
  ------------------
  |  Branch (383:6): [True: 55, False: 0]
  |  Branch (383:16): [True: 0, False: 0]
  ------------------
  384|     55|		p2p_buf_add_channel_list(subelems, p2p->cfg->country,
  385|     55|					 &pref_chanlist, false);
  386|     55|	} else if (peer->go_state == REMOTE_GO) {
  ------------------
  |  Branch (386:13): [True: 0, False: 0]
  ------------------
  387|      0|		is_6ghz_capab = is_p2p_6ghz_capable(p2p) &&
  ------------------
  |  Branch (387:19): [True: 0, False: 0]
  ------------------
  388|      0|			p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr);
  ------------------
  |  Branch (388:4): [True: 0, False: 0]
  ------------------
  389|      0|		p2p_buf_add_channel_list(subelems, p2p->cfg->country,
  390|      0|					 &pref_chanlist, is_6ghz_capab);
  391|      0|	} else {
  392|      0|		struct p2p_channels res;
  393|       |
  394|      0|		is_6ghz_capab = is_p2p_6ghz_capable(p2p) &&
  ------------------
  |  Branch (394:19): [True: 0, False: 0]
  ------------------
  395|      0|			p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr);
  ------------------
  |  Branch (395:4): [True: 0, False: 0]
  ------------------
  396|      0|		p2p_channels_intersect(&pref_chanlist, &peer->channels,
  397|      0|				       &res);
  398|      0|		p2p_buf_add_channel_list(subelems, p2p->cfg->country, &res,
  399|      0|					 is_6ghz_capab);
  400|      0|	}
  401|     55|	p2p_buf_add_device_info(subelems, p2p, peer);
  402|     55|	if (peer && peer->go_state == LOCAL_GO) {
  ------------------
  |  Branch (402:6): [True: 34, False: 21]
  |  Branch (402:14): [True: 0, False: 34]
  ------------------
  403|      0|		p2p_buf_add_group_id(subelems, p2p->cfg->dev_addr, p2p->ssid,
  404|      0|				     p2p->ssid_len);
  405|      0|	}
  406|       |
  407|       |	/* WPS IE with Device Password ID attribute */
  408|     55|	pw_id = p2p_wps_method_pw_id(peer ? peer->wps_method : WPS_NOT_READY);
  ------------------
  |  Branch (408:31): [True: 34, False: 21]
  ------------------
  409|     55|	if (peer && peer->oob_pw_id)
  ------------------
  |  Branch (409:6): [True: 34, False: 21]
  |  Branch (409:14): [True: 0, False: 34]
  ------------------
  410|      0|		pw_id = peer->oob_pw_id;
  411|     55|	if (peer && !peer->p2p2 && p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
  ------------------
  |  Branch (411:6): [True: 34, False: 21]
  |  Branch (411:14): [True: 34, False: 0]
  |  Branch (411:29): [True: 0, False: 34]
  ------------------
  412|      0|		p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Response");
  413|      0|		wpabuf_free(subelems);
  414|      0|		wpabuf_free(buf);
  415|      0|		return NULL;
  416|      0|	}
  417|       |
  418|     55|#ifdef CONFIG_WIFI_DISPLAY
  419|     55|	if (p2p->wfd_ie_go_neg)
  ------------------
  |  Branch (419:6): [True: 0, False: 55]
  ------------------
  420|      0|		wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
  421|     55|#endif /* CONFIG_WIFI_DISPLAY */
  422|       |
  423|     55|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
  ------------------
  |  Branch (423:6): [True: 0, False: 55]
  |  Branch (423:26): [True: 0, False: 0]
  ------------------
  424|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
  425|       |
  426|     55|	buf = wpabuf_concat(buf, p2p_encaps_ie(subelems, P2P_IE_VENDOR_TYPE));
  ------------------
  |  | 1575|     55|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  427|     55|	wpabuf_free(subelems);
  428|     55|	return buf;
  429|     55|}

p2p_process_invitation_req:
  230|    909|{
  231|    909|	struct p2p_device *dev;
  232|    909|	struct p2p_message msg;
  233|    909|	struct wpabuf *resp = NULL;
  234|    909|	u8 status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  235|    909|	int go = 0;
  236|    909|	u8 group_bssid[ETH_ALEN], *bssid;
  237|    909|	int op_freq = 0;
  238|    909|	u8 reg_class = 0, channel = 0;
  239|    909|	const u8 *new_ssid = NULL;
  240|    909|	size_t new_ssid_len = 0;
  241|    909|	struct p2p_channels all_channels, intersection, *channels = NULL;
  242|    909|	int persistent;
  243|       |
  244|    909|	os_memset(group_bssid, 0, sizeof(group_bssid));
  ------------------
  |  |  529|    909|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  245|       |
  246|    909|	p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
  247|    909|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|    909|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  248|       |
  249|    909|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (249:6): [True: 112, False: 797]
  ------------------
  250|    112|		return NULL;
  251|       |
  252|    797|	dev = p2p_get_device(p2p, sa);
  253|    797|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|    199|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    199|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (253:6): [True: 598, False: 199]
  |  Branch (253:21): [True: 5, False: 194]
  ------------------
  254|    603|		p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
  ------------------
  |  |  448|    603|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  255|    603|			MAC2STR(sa));
  ------------------
  |  |  447|    603|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  256|       |
  257|    603|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
  ------------------
  |  Branch (257:7): [True: 421, False: 182]
  ------------------
  258|    603|				   0)) {
  259|    421|			p2p_dbg(p2p, "Invitation Request add device failed "
  260|    421|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    421|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    421|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  261|    421|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  262|    421|			goto fail;
  263|    421|		}
  264|       |
  265|    182|		dev = p2p_get_device(p2p, sa);
  266|    182|		if (dev == NULL) {
  ------------------
  |  Branch (266:7): [True: 178, False: 4]
  ------------------
  267|    178|			p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
  268|    178|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    178|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    178|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  269|    178|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  270|    178|			goto fail;
  271|    178|		}
  272|    182|	}
  273|       |
  274|    198|	if (!msg.group_id || !msg.channel_list) {
  ------------------
  |  Branch (274:6): [True: 4, False: 194]
  |  Branch (274:23): [True: 2, False: 192]
  ------------------
  275|      6|		p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
  276|      6|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      6|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      6|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  277|      6|		status = P2P_SC_FAIL_INVALID_PARAMS;
  278|      6|		goto fail;
  279|      6|	}
  280|       |
  281|    192|	if (msg.invitation_flags)
  ------------------
  |  Branch (281:6): [True: 2, False: 190]
  ------------------
  282|      2|		persistent = *msg.invitation_flags & P2P_INVITATION_FLAGS_TYPE;
  ------------------
  |  | 1963|      2|#define P2P_INVITATION_FLAGS_TYPE BIT(0)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  283|    190|	else {
  284|       |		/* Invitation Flags is a mandatory attribute starting from P2P
  285|       |		 * spec 1.06. As a backwards compatibility mechanism, assume
  286|       |		 * the request was for a persistent group if the attribute is
  287|       |		 * missing.
  288|       |		 */
  289|    190|		p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
  290|    190|		persistent = 1;
  291|    190|	}
  292|       |
  293|    192|	p2p_channels_union(&p2p->cfg->channels, &p2p->cfg->cli_channels,
  294|    192|			   &all_channels);
  295|       |
  296|    192|	if (p2p_peer_channels_check(p2p, &all_channels, dev,
  ------------------
  |  Branch (296:6): [True: 65, False: 127]
  ------------------
  297|    192|				    msg.channel_list, msg.channel_list_len) <
  298|    192|	    0) {
  299|     65|		p2p_dbg(p2p, "No common channels found");
  300|     65|		status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  301|     65|		goto fail;
  302|     65|	}
  303|       |
  304|    127|	p2p_channels_dump(p2p, "own channels", &p2p->cfg->channels);
  305|    127|	p2p_channels_dump(p2p, "own client channels", &all_channels);
  306|    127|	p2p_channels_dump(p2p, "peer channels", &dev->channels);
  307|    127|	p2p_channels_intersect(&all_channels, &dev->channels,
  308|    127|			       &intersection);
  309|    127|	p2p_channels_dump(p2p, "intersection", &intersection);
  310|       |
  311|    127|	if (p2p->cfg->invitation_process) {
  ------------------
  |  Branch (311:6): [True: 0, False: 127]
  ------------------
  312|      0|		status = p2p->cfg->invitation_process(
  313|      0|			p2p->cfg->cb_ctx, sa, msg.group_bssid, msg.group_id,
  314|      0|			msg.group_id + ETH_ALEN, msg.group_id_len - ETH_ALEN,
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
              			msg.group_id + ETH_ALEN, msg.group_id_len - ETH_ALEN,
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  315|      0|			&go, group_bssid, &op_freq, persistent, &intersection,
  316|      0|			msg.dev_password_id_present ? msg.dev_password_id : -1,
  ------------------
  |  Branch (316:4): [True: 0, False: 0]
  ------------------
  317|      0|			p2p2, &new_ssid, &new_ssid_len);
  318|      0|	}
  319|       |
  320|    127|	if (go) {
  ------------------
  |  Branch (320:6): [True: 0, False: 127]
  ------------------
  321|      0|		p2p_channels_intersect(&p2p->cfg->channels, &dev->channels,
  322|      0|				       &intersection);
  323|      0|		p2p_channels_dump(p2p, "intersection(GO)", &intersection);
  324|      0|		if (intersection.reg_classes == 0) {
  ------------------
  |  Branch (324:7): [True: 0, False: 0]
  ------------------
  325|      0|			p2p_dbg(p2p, "No common channels found (GO)");
  326|      0|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  327|      0|			goto fail;
  328|      0|		}
  329|      0|	}
  330|       |
  331|    127|	if (op_freq) {
  ------------------
  |  Branch (331:6): [True: 0, False: 127]
  ------------------
  332|      0|		p2p_dbg(p2p, "Invitation processing forced frequency %d MHz",
  333|      0|			op_freq);
  334|      0|		if (p2p_freq_to_channel(op_freq, &reg_class, &channel) < 0) {
  ------------------
  |  Branch (334:7): [True: 0, False: 0]
  ------------------
  335|      0|			p2p_dbg(p2p, "Unknown forced freq %d MHz from invitation_process()",
  336|      0|				op_freq);
  337|      0|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  338|      0|			goto fail;
  339|      0|		}
  340|       |
  341|      0|		if (!p2p_channels_includes(&intersection, reg_class, channel))
  ------------------
  |  Branch (341:7): [True: 0, False: 0]
  ------------------
  342|      0|		{
  343|      0|			p2p_dbg(p2p, "forced freq %d MHz not in the supported channels intersection",
  344|      0|				op_freq);
  345|      0|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  346|      0|			goto fail;
  347|      0|		}
  348|       |
  349|      0|		if (status == P2P_SC_SUCCESS)
  ------------------
  |  Branch (349:7): [True: 0, False: 0]
  ------------------
  350|      0|			channels = &intersection;
  351|    127|	} else {
  352|    127|		p2p_dbg(p2p, "No forced channel from invitation processing - figure out best one to use");
  353|       |
  354|       |		/* Default to own configuration as a starting point */
  355|    127|		p2p->op_reg_class = p2p->cfg->op_reg_class;
  356|    127|		p2p->op_channel = p2p->cfg->op_channel;
  357|    127|		p2p_dbg(p2p, "Own default op_class %d channel %d",
  358|    127|			p2p->op_reg_class, p2p->op_channel);
  359|       |
  360|       |#ifdef CONFIG_TESTING_OPTIONS
  361|       |		if (p2p->cfg->inv_op_class) {
  362|       |			/* Override configuration as a starting point */
  363|       |			p2p->op_reg_class = p2p->cfg->inv_op_class;
  364|       |			p2p->op_channel = p2p->cfg->inv_op_channel;
  365|       |			p2p_dbg(p2p,
  366|       |				"Override Invitation op_class %d channel %d",
  367|       |				p2p->op_reg_class, p2p->op_channel);
  368|       |		}
  369|       |#endif /* CONFIG_TESTING_OPTIONS */
  370|       |
  371|       |		/* Use peer preference if specified and compatible */
  372|    127|		if (msg.operating_channel) {
  ------------------
  |  Branch (372:7): [True: 81, False: 46]
  ------------------
  373|     81|			int req_freq;
  374|     81|			req_freq = p2p_channel_to_freq(
  375|     81|				msg.operating_channel[3],
  376|     81|				msg.operating_channel[4]);
  377|     81|			p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
  378|     81|				req_freq);
  379|     81|			if (req_freq > 0 &&
  ------------------
  |  Branch (379:8): [True: 45, False: 36]
  ------------------
  380|     45|			    p2p_channels_includes(&intersection,
  ------------------
  |  Branch (380:8): [True: 2, False: 43]
  ------------------
  381|     45|						  msg.operating_channel[3],
  382|     45|						  msg.operating_channel[4])) {
  383|      2|				p2p->op_reg_class = msg.operating_channel[3];
  384|      2|				p2p->op_channel = msg.operating_channel[4];
  385|      2|				p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
  386|      2|					p2p->op_reg_class, p2p->op_channel);
  387|     79|			} else {
  388|     79|				p2p_dbg(p2p, "Cannot use peer channel preference");
  389|     79|			}
  390|     81|		}
  391|       |
  392|       |		/* Reselect the channel only for the case of the GO */
  393|    127|		if (go &&
  ------------------
  |  Branch (393:7): [True: 0, False: 127]
  ------------------
  394|      0|		    !p2p_channels_includes(&intersection, p2p->op_reg_class,
  ------------------
  |  Branch (394:7): [True: 0, False: 0]
  ------------------
  395|      0|					   p2p->op_channel)) {
  396|      0|			p2p_dbg(p2p, "Initially selected channel (op_class %d channel %d) not in channel intersection - try to reselect",
  397|      0|				p2p->op_reg_class, p2p->op_channel);
  398|      0|			p2p_reselect_channel(p2p, &intersection);
  399|      0|			p2p_dbg(p2p, "Re-selection result: op_class %d channel %d",
  400|      0|				p2p->op_reg_class, p2p->op_channel);
  401|      0|			if (!p2p_channels_includes(&intersection,
  ------------------
  |  Branch (401:8): [True: 0, False: 0]
  ------------------
  402|      0|						   p2p->op_reg_class,
  403|      0|						   p2p->op_channel)) {
  404|      0|				p2p_dbg(p2p, "Peer does not support selected operating channel (reg_class=%u channel=%u)",
  405|      0|					p2p->op_reg_class, p2p->op_channel);
  406|      0|				status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  407|      0|				goto fail;
  408|      0|			}
  409|    127|		} else if (go && !(dev->flags & P2P_DEV_FORCE_FREQ) &&
  ------------------
  |  |  138|      0|#define P2P_DEV_FORCE_FREQ BIT(13)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (409:14): [True: 0, False: 127]
  |  Branch (409:20): [True: 0, False: 0]
  ------------------
  410|      0|			   !p2p->cfg->cfg_op_channel) {
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|      0|			p2p_dbg(p2p, "Try to reselect channel selection with peer information received; previously selected op_class %u channel %u",
  412|      0|				p2p->op_reg_class, p2p->op_channel);
  413|      0|			p2p_reselect_channel(p2p, &intersection);
  414|      0|		}
  415|       |
  416|       |		/*
  417|       |		 * Use the driver preferred frequency list extension if
  418|       |		 * supported.
  419|       |		 */
  420|    127|		p2p_check_pref_chan(p2p, go, dev, &msg);
  421|       |
  422|    127|		op_freq = p2p_channel_to_freq(p2p->op_reg_class,
  423|    127|					      p2p->op_channel);
  424|    127|		if (op_freq < 0) {
  ------------------
  |  Branch (424:7): [True: 125, False: 2]
  ------------------
  425|    125|			p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
  426|    125|				p2p->cfg->country[0], p2p->cfg->country[1],
  427|    125|				p2p->op_reg_class, p2p->op_channel);
  428|    125|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  429|    125|			goto fail;
  430|    125|		}
  431|      2|		p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
  432|       |
  433|      2|		if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (433:7): [True: 0, False: 2]
  ------------------
  434|      0|			reg_class = p2p->op_reg_class;
  435|      0|			channel = p2p->op_channel;
  436|      0|			channels = &intersection;
  437|      0|		}
  438|      2|	}
  439|       |
  440|    797|fail:
  441|    797|	if (go && status == P2P_SC_SUCCESS && !is_zero_ether_addr(group_bssid))
  ------------------
  |  Branch (441:6): [True: 0, False: 797]
  |  Branch (441:12): [True: 0, False: 0]
  |  Branch (441:40): [True: 0, False: 0]
  ------------------
  442|      0|		bssid = group_bssid;
  443|    797|	else
  444|    797|		bssid = NULL;
  445|    797|	resp = p2p_build_invitation_resp(p2p, dev, msg.dialog_token, status,
  446|    797|					 bssid, reg_class, channel, channels,
  447|    797|					 new_ssid, new_ssid_len);
  448|       |
  449|       |	/*
  450|       |	 * Store copy of invitation data to be used when processing TX status
  451|       |	 * callback for the Acton frame.
  452|       |	 */
  453|    797|	os_memcpy(p2p->inv_sa, sa, ETH_ALEN);
  ------------------
  |  |  523|    797|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  454|    797|	if (msg.group_bssid) {
  ------------------
  |  Branch (454:6): [True: 4, False: 793]
  ------------------
  455|      4|		os_memcpy(p2p->inv_group_bssid, msg.group_bssid, ETH_ALEN);
  ------------------
  |  |  523|      4|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  456|      4|		p2p->inv_group_bssid_ptr = p2p->inv_group_bssid;
  457|      4|	} else
  458|    793|		p2p->inv_group_bssid_ptr = NULL;
  459|       |
  460|    797|	if (p2p2 && new_ssid_len) {
  ------------------
  |  Branch (460:6): [True: 0, False: 797]
  |  Branch (460:14): [True: 0, False: 0]
  ------------------
  461|      0|		os_memcpy(p2p->inv_ssid, new_ssid, new_ssid_len);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  462|      0|		p2p->inv_ssid_len = new_ssid_len;
  463|      0|		os_memcpy(p2p->inv_go_dev_addr, p2p->cfg->dev_addr, ETH_ALEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  464|    797|	} else if (msg.group_id) {
  ------------------
  |  Branch (464:13): [True: 223, False: 574]
  ------------------
  465|    223|		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  344|    223|#define ETH_ALEN 6
  ------------------
              		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  511|    223|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (465:7): [True: 223, False: 0]
  ------------------
  466|    223|			os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN,
  ------------------
  |  |  523|    223|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  467|    223|				  msg.group_id_len - ETH_ALEN);
  468|    223|			p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|    223|#define ETH_ALEN 6
  ------------------
  469|    223|		}
  470|    223|		os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN);
  ------------------
  |  |  523|    223|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  471|    574|	} else {
  472|    574|		p2p->inv_ssid_len = 0;
  473|    574|		os_memset(p2p->inv_go_dev_addr, 0, ETH_ALEN);
  ------------------
  |  |  529|    574|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  474|    574|	}
  475|    797|	p2p->inv_status = status;
  476|    797|	p2p->inv_op_freq = op_freq;
  477|    797|	p2p_parse_free(&msg);
  478|    797|	return resp;
  479|    127|}
p2p_handle_invitation_req:
  484|    909|{
  485|    909|	int freq;
  486|    909|	struct wpabuf *resp;
  487|       |
  488|    909|	resp = p2p_process_invitation_req(p2p, sa, data, len, rx_freq, false);
  489|    909|	if (!resp)
  ------------------
  |  Branch (489:6): [True: 112, False: 797]
  ------------------
  490|    112|		return;
  491|       |
  492|    797|	if (rx_freq > 0)
  ------------------
  |  Branch (492:6): [True: 797, False: 0]
  ------------------
  493|    797|		freq = rx_freq;
  494|      0|	else
  495|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  496|      0|					   p2p->cfg->channel);
  497|    797|	if (freq < 0)
  ------------------
  |  Branch (497:6): [True: 0, False: 797]
  ------------------
  498|      0|		p2p_dbg(p2p, "Unknown regulatory class/channel");
  499|       |
  500|    797|	p2p->pending_action_state = P2P_PENDING_INVITATION_RESPONSE;
  501|    797|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (501:6): [True: 0, False: 797]
  ------------------
  502|    797|			    p2p->cfg->dev_addr,
  503|    797|			    wpabuf_head(resp), wpabuf_len(resp), 50) < 0) {
  504|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  505|      0|	}
  506|       |
  507|    797|	wpabuf_free(resp);
  508|    797|}
p2p_process_invitation_resp:
  513|      5|{
  514|      5|	struct p2p_device *dev;
  515|      5|	struct p2p_message msg;
  516|      5|	struct p2p_channels intersection, *channels = NULL;
  517|      5|	bool all_channels = false;
  518|      5|	const u8 *go_dev_addr = NULL;
  519|       |
  520|      5|	p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
  ------------------
  |  |  448|      5|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  521|      5|		MAC2STR(sa));
  ------------------
  |  |  447|      5|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  522|       |
  523|      5|	dev = p2p_get_device(p2p, sa);
  524|      5|	if (dev == NULL) {
  ------------------
  |  Branch (524:6): [True: 4, False: 1]
  ------------------
  525|      4|		p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
  526|      4|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      4|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      4|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  527|      4|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  528|      4|		return;
  529|      4|	}
  530|       |
  531|      1|	if (dev != p2p->invite_peer) {
  ------------------
  |  Branch (531:6): [True: 1, False: 0]
  ------------------
  532|      1|		p2p_dbg(p2p, "Ignore unexpected Invitation Response from peer "
  533|      1|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  534|      1|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  535|      1|		return;
  536|      1|	}
  537|       |
  538|      0|	if (p2p_parse(data, len, &msg)) {
  ------------------
  |  Branch (538:6): [True: 0, False: 0]
  ------------------
  539|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  540|      0|		return;
  541|      0|	}
  542|       |
  543|      0|	if (!msg.status) {
  ------------------
  |  Branch (543:6): [True: 0, False: 0]
  ------------------
  544|      0|		p2p_dbg(p2p, "Mandatory Status attribute missing in Invitation Response from "
  545|      0|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  546|      0|		p2p_parse_free(&msg);
  547|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  548|      0|		return;
  549|      0|	}
  550|       |
  551|       |	/*
  552|       |	 * We should not really receive a replayed response twice since
  553|       |	 * duplicate frames are supposed to be dropped. However, not all drivers
  554|       |	 * do that for pre-association frames. We did not use to verify dialog
  555|       |	 * token matches for invitation response frames, but that check can be
  556|       |	 * safely used to drop a replayed response to the previous Invitation
  557|       |	 * Request in case the suggested operating channel was changed. This
  558|       |	 * allows a duplicated reject frame to be dropped with the assumption
  559|       |	 * that the real response follows after it.
  560|       |	 */
  561|      0|	if (*msg.status == P2P_SC_FAIL_NO_COMMON_CHANNELS &&
  ------------------
  |  Branch (561:6): [True: 0, False: 0]
  ------------------
  562|      0|	    p2p->retry_invite_req_sent &&
  ------------------
  |  Branch (562:6): [True: 0, False: 0]
  ------------------
  563|      0|	    msg.dialog_token != dev->dialog_token) {
  ------------------
  |  Branch (563:6): [True: 0, False: 0]
  ------------------
  564|      0|		p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
  565|      0|			msg.dialog_token, dev->dialog_token);
  566|      0|		p2p_parse_free(&msg);
  567|      0|		return;
  568|      0|	}
  569|       |
  570|      0|	if (*msg.status == P2P_SC_FAIL_NO_COMMON_CHANNELS &&
  ------------------
  |  Branch (570:6): [True: 0, False: 0]
  ------------------
  571|      0|	    p2p->retry_invite_req &&
  ------------------
  |  Branch (571:6): [True: 0, False: 0]
  ------------------
  572|      0|	    p2p_channel_random_social(&p2p->cfg->channels, &p2p->op_reg_class,
  ------------------
  |  Branch (572:6): [True: 0, False: 0]
  ------------------
  573|      0|				      &p2p->op_channel, NULL, NULL) == 0) {
  574|      0|		p2p->retry_invite_req = 0;
  575|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  576|       |
  577|      0|		if (p2p->pending_listen_freq) {
  ------------------
  |  Branch (577:7): [True: 0, False: 0]
  ------------------
  578|      0|			p2p_dbg(p2p,
  579|      0|				"Clear pending_listen_freq for p2p_invite");
  580|      0|			p2p->pending_listen_freq = 0;
  581|      0|		}
  582|       |
  583|      0|		p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
  584|      0|		p2p_set_state(p2p, P2P_INVITE);
  585|      0|		p2p_dbg(p2p, "Resend Invitation Request setting op_class %u channel %u as operating channel",
  586|      0|			p2p->op_reg_class, p2p->op_channel);
  587|      0|		p2p->retry_invite_req_sent = 1;
  588|      0|		p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr,
  589|      0|				p2p->invite_dev_pw_id);
  590|      0|		p2p_parse_free(&msg);
  591|      0|		return;
  592|      0|	}
  593|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  594|      0|	p2p->retry_invite_req = 0;
  595|       |
  596|      0|	if (!msg.channel_list && *msg.status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (596:6): [True: 0, False: 0]
  |  Branch (596:27): [True: 0, False: 0]
  ------------------
  597|      0|		p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
  598|      0|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  599|       |#ifdef CONFIG_P2P_STRICT
  600|       |		p2p_parse_free(&msg);
  601|       |		return;
  602|       |#endif /* CONFIG_P2P_STRICT */
  603|       |		/* Try to survive without peer channel list */
  604|      0|		channels = &p2p->channels;
  605|      0|		all_channels = true;
  606|      0|	} else if (!msg.channel_list) {
  ------------------
  |  Branch (606:13): [True: 0, False: 0]
  ------------------
  607|       |		/* Non-success cases are not required to include Channel List */
  608|      0|		channels = &p2p->channels;
  609|      0|		all_channels = true;
  610|      0|	} else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (610:13): [True: 0, False: 0]
  ------------------
  611|      0|					   msg.channel_list,
  612|      0|					   msg.channel_list_len) < 0) {
  613|      0|		p2p_dbg(p2p, "No common channels found");
  614|      0|		p2p_parse_free(&msg);
  615|      0|		dev->inv_reject = true;
  616|      0|		return;
  617|      0|	} else {
  618|      0|		p2p_channels_intersect(&p2p->channels, &dev->channels,
  619|      0|				       &intersection);
  620|      0|		channels = &intersection;
  621|      0|	}
  622|       |
  623|      0|	if (p2p->cfg->invitation_result) {
  ------------------
  |  Branch (623:6): [True: 0, False: 0]
  ------------------
  624|      0|		int peer_oper_freq = 0;
  625|      0|		int freq = p2p_channel_to_freq(p2p->op_reg_class,
  626|      0|					       p2p->op_channel);
  627|      0|		if (freq < 0)
  ------------------
  |  Branch (627:7): [True: 0, False: 0]
  ------------------
  628|      0|			freq = 0;
  629|       |
  630|      0|		if (msg.operating_channel) {
  ------------------
  |  Branch (630:7): [True: 0, False: 0]
  ------------------
  631|      0|			peer_oper_freq = p2p_channel_to_freq(
  632|      0|				msg.operating_channel[3],
  633|      0|				msg.operating_channel[4]);
  634|      0|			if (peer_oper_freq < 0)
  ------------------
  |  Branch (634:8): [True: 0, False: 0]
  ------------------
  635|      0|				peer_oper_freq = 0;
  636|      0|		}
  637|       |
  638|       |		/*
  639|       |		 * Use the driver preferred frequency list extension if
  640|       |		 * supported.
  641|       |		 */
  642|      0|		p2p_check_pref_chan(p2p, 0, dev, &msg);
  643|       |
  644|      0|		if (dev->p2p2) {
  ------------------
  |  Branch (644:7): [True: 0, False: 0]
  ------------------
  645|      0|			dev->inv_freq = freq;
  646|      0|			dev->inv_status = *msg.status;
  647|      0|			dev->inv_all_channels = all_channels;
  648|      0|			dev->inv_peer_oper_freq = peer_oper_freq;
  649|      0|			if (msg.group_bssid)
  ------------------
  |  Branch (649:8): [True: 0, False: 0]
  ------------------
  650|      0|				os_memcpy(dev->inv_bssid, msg.group_bssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  651|      0|					  ETH_ALEN);
  652|      0|			if (msg.group_id) {
  ------------------
  |  Branch (652:8): [True: 0, False: 0]
  ------------------
  653|      0|				dev->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  654|      0|				os_memcpy(dev->inv_ssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  655|      0|					  msg.group_id + ETH_ALEN,
  656|      0|					  dev->inv_ssid_len);
  657|       |
  658|      0|				os_memcpy(p2p->invite_go_dev_addr_buf,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  659|      0|					  msg.group_id, ETH_ALEN);
  660|      0|				p2p->invite_go_dev_addr =
  661|      0|					p2p->invite_go_dev_addr_buf;
  662|      0|				go_dev_addr = p2p->invite_go_dev_addr;
  663|      0|			}
  664|      0|			goto out;
  665|      0|		}
  666|       |
  667|      0|		p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status,
  668|      0|					    NULL, 0,
  669|      0|					    msg.group_bssid, channels, sa,
  670|      0|					    freq, peer_oper_freq, NULL, NULL,
  671|      0|					    0, go_dev_addr);
  672|      0|	}
  673|       |
  674|      0|	p2p_clear_timeout(p2p);
  675|      0|	p2p_set_state(p2p, P2P_IDLE);
  676|      0|	p2p->invite_peer = NULL;
  677|       |
  678|      0|out:
  679|      0|	p2p_parse_free(&msg);
  680|      0|}
p2p_invitation.c:p2p_build_invitation_resp:
  136|    797|{
  137|    797|	struct wpabuf *buf, *elems, *p2p_ie;
  138|    797|	size_t extra = 0;
  139|       |
  140|    797|#ifdef CONFIG_WIFI_DISPLAY
  141|    797|	struct wpabuf *wfd_ie = p2p->wfd_ie_invitation;
  142|    797|	if (wfd_ie && group_bssid) {
  ------------------
  |  Branch (142:6): [True: 0, False: 797]
  |  Branch (142:16): [True: 0, False: 0]
  ------------------
  143|      0|		size_t i;
  144|      0|		for (i = 0; i < p2p->num_groups; i++) {
  ------------------
  |  Branch (144:15): [True: 0, False: 0]
  ------------------
  145|      0|			struct p2p_group *g = p2p->groups[i];
  146|      0|			struct wpabuf *ie;
  147|      0|			if (!ether_addr_equal(p2p_group_get_interface_addr(g),
  ------------------
  |  Branch (147:8): [True: 0, False: 0]
  ------------------
  148|      0|					      group_bssid))
  149|      0|				continue;
  150|      0|			ie = p2p_group_get_wfd_ie(g);
  151|      0|			if (ie) {
  ------------------
  |  Branch (151:8): [True: 0, False: 0]
  ------------------
  152|      0|				wfd_ie = ie;
  153|      0|				break;
  154|      0|			}
  155|      0|		}
  156|      0|	}
  157|    797|	if (wfd_ie)
  ------------------
  |  Branch (157:6): [True: 0, False: 797]
  ------------------
  158|      0|		extra = wpabuf_len(wfd_ie);
  159|    797|#endif /* CONFIG_WIFI_DISPLAY */
  160|       |
  161|    797|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (161:6): [True: 0, False: 797]
  |  Branch (161:26): [True: 0, False: 0]
  ------------------
  162|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  163|       |
  164|    797|	buf = wpabuf_alloc(1000 + extra);
  165|    797|	if (buf == NULL)
  ------------------
  |  Branch (165:6): [True: 0, False: 797]
  ------------------
  166|      0|		return NULL;
  167|       |
  168|    797|	p2p_buf_add_public_action_hdr(buf, P2P_INVITATION_RESP,
  169|    797|				      dialog_token);
  170|       |
  171|    797|	elems = wpabuf_alloc(1000);
  172|    797|	if (!elems) {
  ------------------
  |  Branch (172:6): [True: 0, False: 797]
  ------------------
  173|      0|		wpabuf_free(buf);
  174|      0|		return NULL;
  175|      0|	}
  176|       |
  177|    797|	p2p_buf_add_status(elems, status);
  178|    797|	p2p_buf_add_config_timeout(elems, 0, 0); /* FIX */
  179|    797|	if (reg_class && channel)
  ------------------
  |  Branch (179:6): [True: 0, False: 797]
  |  Branch (179:19): [True: 0, False: 0]
  ------------------
  180|      0|		p2p_buf_add_operating_channel(elems, p2p->cfg->country,
  181|      0|					      reg_class, channel);
  182|    797|	if (group_bssid)
  ------------------
  |  Branch (182:6): [True: 0, False: 797]
  ------------------
  183|      0|		p2p_buf_add_group_bssid(elems, group_bssid);
  184|       |
  185|    797|	if (ssid_len && ssid) {
  ------------------
  |  Branch (185:6): [True: 0, False: 797]
  |  Branch (185:18): [True: 0, False: 0]
  ------------------
  186|      0|		const u8 *dev_addr;
  187|       |
  188|      0|		if (p2p->inv_role == P2P_INVITE_ROLE_CLIENT)
  ------------------
  |  Branch (188:7): [True: 0, False: 0]
  ------------------
  189|      0|			dev_addr = peer->info.p2p_device_addr;
  190|      0|		else
  191|      0|			dev_addr = p2p->cfg->dev_addr;
  192|       |
  193|      0|		p2p_buf_add_group_id(elems, dev_addr, ssid, ssid_len);
  194|      0|	}
  195|       |
  196|    797|	if (channels) {
  ------------------
  |  Branch (196:6): [True: 0, False: 797]
  ------------------
  197|      0|		bool is_6ghz_capab;
  198|       |
  199|      0|		is_6ghz_capab = is_p2p_6ghz_capable(p2p) &&
  ------------------
  |  Branch (199:19): [True: 0, False: 0]
  ------------------
  200|      0|			p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr);
  ------------------
  |  Branch (200:4): [True: 0, False: 0]
  ------------------
  201|      0|		p2p_buf_add_channel_list(elems, p2p->cfg->country, channels,
  202|      0|					 is_6ghz_capab);
  203|      0|	}
  204|       |
  205|    797|	p2p_ie = p2p_encaps_ie(elems, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1575|    797|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  206|    797|	wpabuf_free(elems);
  207|    797|	if (!p2p_ie) {
  ------------------
  |  Branch (207:6): [True: 0, False: 797]
  ------------------
  208|      0|		wpabuf_free(buf);
  209|      0|		return NULL;
  210|      0|	}
  211|       |
  212|    797|	wpabuf_put_buf(buf, p2p_ie);
  213|    797|	wpabuf_free(p2p_ie);
  214|       |
  215|    797|#ifdef CONFIG_WIFI_DISPLAY
  216|    797|	if (wfd_ie)
  ------------------
  |  Branch (216:6): [True: 0, False: 797]
  ------------------
  217|      0|		wpabuf_put_buf(buf, wfd_ie);
  218|    797|#endif /* CONFIG_WIFI_DISPLAY */
  219|       |
  220|    797|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (220:6): [True: 0, False: 797]
  |  Branch (220:26): [True: 0, False: 0]
  ------------------
  221|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  222|       |
  223|    797|	return buf;
  224|    797|}

p2p_copy_filter_devname:
   20|  2.42k|{
   21|  2.42k|	size_t i;
   22|       |
   23|  2.42k|	if (src_len >= dst_len)
  ------------------
  |  Branch (23:6): [True: 0, False: 2.42k]
  ------------------
   24|      0|		src_len = dst_len - 1;
   25|  2.42k|	os_memcpy(dst, src, src_len);
  ------------------
  |  |  523|  2.42k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   26|  2.42k|	dst[src_len] = '\0';
   27|  28.7k|	for (i = 0; i < src_len; i++) {
  ------------------
  |  Branch (27:14): [True: 27.0k, False: 1.73k]
  ------------------
   28|  27.0k|		if (dst[i] == '\0')
  ------------------
  |  Branch (28:7): [True: 687, False: 26.3k]
  ------------------
   29|    687|			break;
   30|  26.3k|		if (is_ctrl_char(dst[i]))
  ------------------
  |  Branch (30:7): [True: 6.01k, False: 20.3k]
  ------------------
   31|  6.01k|			dst[i] = '_';
   32|  26.3k|	}
   33|  2.42k|}
p2p_parse_p2p_ie:
  494|  7.54k|{
  495|  7.54k|	const u8 *pos = wpabuf_head_u8(buf);
  496|  7.54k|	const u8 *end = pos + wpabuf_len(buf);
  497|       |
  498|  7.54k|	wpa_printf(MSG_DEBUG, "P2P: Parsing P2P IE");
  499|       |
  500|  51.5k|	while (pos < end) {
  ------------------
  |  Branch (500:9): [True: 45.3k, False: 6.18k]
  ------------------
  501|  45.3k|		u16 attr_len;
  502|  45.3k|		u8 id;
  503|       |
  504|  45.3k|		if (end - pos < 3) {
  ------------------
  |  Branch (504:7): [True: 117, False: 45.2k]
  ------------------
  505|    117|			wpa_printf(MSG_DEBUG, "P2P: Invalid P2P attribute");
  506|    117|			return -1;
  507|    117|		}
  508|  45.2k|		id = *pos++;
  509|  45.2k|		attr_len = WPA_GET_LE16(pos);
  510|  45.2k|		pos += 2;
  511|  45.2k|		wpa_printf(MSG_DEBUG, "P2P: Attribute %d length %u",
  512|  45.2k|			   id, attr_len);
  513|  45.2k|		if (attr_len > end - pos) {
  ------------------
  |  Branch (513:7): [True: 415, False: 44.8k]
  ------------------
  514|    415|			wpa_printf(MSG_DEBUG, "P2P: Attribute underflow "
  515|    415|				   "(len=%u left=%d)",
  516|    415|				   attr_len, (int) (end - pos));
  517|    415|			wpa_hexdump(MSG_MSGDUMP, "P2P: Data", pos, end - pos);
  518|    415|			return -1;
  519|    415|		}
  520|  44.8k|		if (p2p_parse_attribute(id, pos, attr_len, msg))
  ------------------
  |  Branch (520:7): [True: 834, False: 43.9k]
  ------------------
  521|    834|			return -1;
  522|  43.9k|		pos += attr_len;
  523|  43.9k|	}
  524|       |
  525|  6.18k|	return 0;
  526|  7.54k|}
p2p_parse_ies:
  599|  17.9k|{
  600|  17.9k|	struct ieee802_11_elems elems;
  601|       |
  602|  17.9k|	if (ieee802_11_parse_elems(data, len, &elems, 0) == ParseFailed)
  ------------------
  |  Branch (602:6): [True: 2.24k, False: 15.7k]
  ------------------
  603|  2.24k|		return -1;
  604|       |
  605|  15.7k|	if (elems.ds_params)
  ------------------
  |  Branch (605:6): [True: 823, False: 14.9k]
  ------------------
  606|    823|		msg->ds_params = elems.ds_params;
  607|  15.7k|	if (elems.ssid)
  ------------------
  |  Branch (607:6): [True: 4.82k, False: 10.9k]
  ------------------
  608|  4.82k|		msg->ssid = elems.ssid - 2;
  609|       |
  610|  15.7k|	msg->wps_attributes = ieee802_11_vendor_ie_concat(data, len,
  611|  15.7k|							  WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|  15.7k|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
  612|  15.7k|	if (msg->wps_attributes &&
  ------------------
  |  Branch (612:6): [True: 4.93k, False: 10.8k]
  ------------------
  613|  4.93k|	    p2p_parse_wps_ie(msg->wps_attributes, msg)) {
  ------------------
  |  Branch (613:6): [True: 1.96k, False: 2.96k]
  ------------------
  614|  1.96k|		p2p_parse_free(msg);
  615|  1.96k|		return -1;
  616|  1.96k|	}
  617|       |
  618|  13.7k|	msg->p2p_attributes = ieee802_11_vendor_ie_concat(data, len,
  619|  13.7k|							  P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1575|  13.7k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  620|  13.7k|	if (msg->p2p_attributes &&
  ------------------
  |  Branch (620:6): [True: 6.94k, False: 6.82k]
  ------------------
  621|  6.94k|	    p2p_parse_p2p_ie(msg->p2p_attributes, msg)) {
  ------------------
  |  Branch (621:6): [True: 1.22k, False: 5.71k]
  ------------------
  622|  1.22k|		wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P IE data");
  623|  1.22k|		if (msg->p2p_attributes)
  ------------------
  |  Branch (623:7): [True: 1.22k, False: 0]
  ------------------
  624|  1.22k|			wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P IE data",
  625|  1.22k|					msg->p2p_attributes);
  626|  1.22k|		p2p_parse_free(msg);
  627|  1.22k|		return -1;
  628|  1.22k|	}
  629|       |
  630|  12.5k|	msg->p2p2_attributes = ieee802_11_vendor_ie_concat(data, len,
  631|  12.5k|							   P2P2_IE_VENDOR_TYPE);
  ------------------
  |  | 1576|  12.5k|#define P2P2_IE_VENDOR_TYPE 0x506f9a28
  ------------------
  632|  12.5k|	if (msg->p2p2_attributes &&
  ------------------
  |  Branch (632:6): [True: 606, False: 11.9k]
  ------------------
  633|    606|	    p2p_parse_p2p_ie(msg->p2p2_attributes, msg)) {
  ------------------
  |  Branch (633:6): [True: 142, False: 464]
  ------------------
  634|    142|		wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P2 IE data");
  635|    142|		if (msg->p2p2_attributes)
  ------------------
  |  Branch (635:7): [True: 142, False: 0]
  ------------------
  636|    142|			wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P2 IE data",
  637|    142|					msg->p2p2_attributes);
  638|    142|		p2p_parse_free(msg);
  639|    142|		return -1;
  640|    142|	}
  641|       |
  642|  12.4k|#ifdef CONFIG_WIFI_DISPLAY
  643|  12.4k|	if (elems.wfd) {
  ------------------
  |  Branch (643:6): [True: 1.03k, False: 11.3k]
  ------------------
  644|  1.03k|		msg->wfd_subelems = ieee802_11_vendor_ie_concat(
  645|  1.03k|			data, len, WFD_IE_VENDOR_TYPE);
  ------------------
  |  | 1577|  1.03k|#define WFD_IE_VENDOR_TYPE 0x506f9a0a
  ------------------
  646|  1.03k|	}
  647|  12.4k|#endif /* CONFIG_WIFI_DISPLAY */
  648|       |
  649|  12.4k|	msg->pref_freq_list = elems.pref_freq_list;
  650|  12.4k|	msg->pref_freq_list_len = elems.pref_freq_list_len;
  651|       |
  652|  12.4k|	return 0;
  653|  12.5k|}
p2p_parse:
  667|  2.83k|{
  668|  2.83k|	os_memset(msg, 0, sizeof(*msg));
  ------------------
  |  |  529|  2.83k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  669|  2.83k|	wpa_printf(MSG_DEBUG, "P2P: Parsing the received message");
  670|  2.83k|	if (len < 1) {
  ------------------
  |  Branch (670:6): [True: 6, False: 2.83k]
  ------------------
  671|      6|		wpa_printf(MSG_DEBUG, "P2P: No Dialog Token in the message");
  672|      6|		return -1;
  673|      6|	}
  674|  2.83k|	msg->dialog_token = data[0];
  675|  2.83k|	wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", msg->dialog_token);
  676|       |
  677|  2.83k|	return p2p_parse_ies(data + 1, len - 1, msg);
  678|  2.83k|}
p2p_parse_free:
  713|  20.6k|{
  714|  20.6k|	wpabuf_free(msg->p2p_attributes);
  715|  20.6k|	msg->p2p_attributes = NULL;
  716|  20.6k|	wpabuf_free(msg->p2p2_attributes);
  717|  20.6k|	msg->p2p2_attributes = NULL;
  718|  20.6k|	wpabuf_free(msg->wps_attributes);
  719|  20.6k|	msg->wps_attributes = NULL;
  720|  20.6k|#ifdef CONFIG_WIFI_DISPLAY
  721|  20.6k|	wpabuf_free(msg->wfd_subelems);
  722|       |	msg->wfd_subelems = NULL;
  723|  20.6k|#endif /* CONFIG_WIFI_DISPLAY */
  724|  20.6k|}
p2p_group_info_parse:
  729|    165|{
  730|    165|	const u8 *g, *gend;
  731|       |
  732|    165|	os_memset(info, 0, sizeof(*info));
  ------------------
  |  |  529|    165|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  733|    165|	if (gi == NULL)
  ------------------
  |  Branch (733:6): [True: 0, False: 165]
  ------------------
  734|      0|		return 0;
  735|       |
  736|    165|	g = gi;
  737|    165|	gend = gi + gi_len;
  738|    367|	while (g < gend) {
  ------------------
  |  Branch (738:9): [True: 285, False: 82]
  ------------------
  739|    285|		struct p2p_client_info *cli;
  740|    285|		const u8 *cend;
  741|    285|		u16 count;
  742|    285|		u8 len;
  743|       |
  744|    285|		cli = &info->client[info->num_clients];
  745|    285|		len = *g++;
  746|    285|		if (len > gend - g || len < 2 * ETH_ALEN + 1 + 2 + 8 + 1)
  ------------------
  |  |  344|    275|#define ETH_ALEN 6
  ------------------
  |  Branch (746:7): [True: 10, False: 275]
  |  Branch (746:25): [True: 21, False: 254]
  ------------------
  747|     31|			return -1; /* invalid data */
  748|    254|		cend = g + len;
  749|       |		/* g at start of P2P Client Info Descriptor */
  750|    254|		cli->p2p_device_addr = g;
  751|    254|		g += ETH_ALEN;
  ------------------
  |  |  344|    254|#define ETH_ALEN 6
  ------------------
  752|    254|		cli->p2p_interface_addr = g;
  753|    254|		g += ETH_ALEN;
  ------------------
  |  |  344|    254|#define ETH_ALEN 6
  ------------------
  754|    254|		cli->dev_capab = *g++;
  755|       |
  756|    254|		cli->config_methods = WPA_GET_BE16(g);
  757|    254|		g += 2;
  758|    254|		cli->pri_dev_type = g;
  759|    254|		g += 8;
  760|       |
  761|       |		/* g at Number of Secondary Device Types */
  762|    254|		len = *g++;
  763|    254|		if (8 * len > cend - g)
  ------------------
  |  Branch (763:7): [True: 17, False: 237]
  ------------------
  764|     17|			return -1; /* invalid data */
  765|    237|		cli->num_sec_dev_types = len;
  766|    237|		cli->sec_dev_types = g;
  767|    237|		g += 8 * len;
  768|       |
  769|       |		/* g at Device Name in WPS TLV format */
  770|    237|		if (cend - g < 2 + 2)
  ------------------
  |  Branch (770:7): [True: 3, False: 234]
  ------------------
  771|      3|			return -1; /* invalid data */
  772|    234|		if (WPA_GET_BE16(g) != ATTR_DEV_NAME)
  ------------------
  |  Branch (772:7): [True: 31, False: 203]
  ------------------
  773|     31|			return -1; /* invalid Device Name TLV */
  774|    203|		g += 2;
  775|    203|		count = WPA_GET_BE16(g);
  776|    203|		g += 2;
  777|    203|		if (count > cend - g)
  ------------------
  |  Branch (777:7): [True: 1, False: 202]
  ------------------
  778|      1|			return -1; /* invalid Device Name TLV */
  779|    202|		if (count >= WPS_DEV_NAME_MAX_LEN)
  ------------------
  |  |   48|    202|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  |  Branch (779:7): [True: 5, False: 197]
  ------------------
  780|      5|			count = WPS_DEV_NAME_MAX_LEN;
  ------------------
  |  |   48|      5|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  781|    202|		cli->dev_name = (const char *) g;
  782|    202|		cli->dev_name_len = count;
  783|       |
  784|    202|		g = cend;
  785|       |
  786|    202|		info->num_clients++;
  787|    202|		if (info->num_clients == P2P_MAX_GROUP_ENTRIES)
  ------------------
  |  |  841|    202|#define P2P_MAX_GROUP_ENTRIES 50
  ------------------
  |  Branch (787:7): [True: 0, False: 202]
  ------------------
  788|      0|			return -1;
  789|    202|	}
  790|       |
  791|     82|	return 0;
  792|    165|}
p2p_parse.c:p2p_parse_attribute:
   38|  44.8k|{
   39|  44.8k|	const u8 *pos;
   40|  44.8k|	u16 nlen;
   41|  44.8k|	char devtype[WPS_DEV_TYPE_BUFSIZE];
   42|       |
   43|  44.8k|	switch (id) {
   44|  1.29k|	case P2P_ATTR_CAPABILITY:
  ------------------
  |  Branch (44:2): [True: 1.29k, False: 43.5k]
  ------------------
   45|  1.29k|		if (len < 2) {
  ------------------
  |  Branch (45:7): [True: 7, False: 1.28k]
  ------------------
   46|      7|			wpa_printf(MSG_DEBUG, "P2P: Too short Capability "
   47|      7|				   "attribute (length %d)", len);
   48|      7|			return -1;
   49|      7|		}
   50|  1.28k|		msg->capability = data;
   51|  1.28k|		wpa_printf(MSG_DEBUG, "P2P: * Device Capability %02x "
   52|  1.28k|			   "Group Capability %02x",
   53|  1.28k|			   data[0], data[1]);
   54|  1.28k|		break;
   55|  7.01k|	case P2P_ATTR_DEVICE_ID:
  ------------------
  |  Branch (55:2): [True: 7.01k, False: 37.7k]
  ------------------
   56|  7.01k|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|  7.01k|#define ETH_ALEN 6
  ------------------
  |  Branch (56:7): [True: 14, False: 7.00k]
  ------------------
   57|     14|			wpa_printf(MSG_DEBUG, "P2P: Too short Device ID "
   58|     14|				   "attribute (length %d)", len);
   59|     14|			return -1;
   60|     14|		}
   61|  7.00k|		msg->device_id = data;
   62|  7.00k|		wpa_printf(MSG_DEBUG, "P2P: * Device ID " MACSTR,
  ------------------
  |  |  448|  7.00k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
   63|  7.00k|			   MAC2STR(msg->device_id));
  ------------------
  |  |  447|  7.00k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
   64|  7.00k|		break;
   65|    257|	case P2P_ATTR_GROUP_OWNER_INTENT:
  ------------------
  |  Branch (65:2): [True: 257, False: 44.5k]
  ------------------
   66|    257|		if (len < 1) {
  ------------------
  |  Branch (66:7): [True: 11, False: 246]
  ------------------
   67|     11|			wpa_printf(MSG_DEBUG, "P2P: Too short GO Intent "
   68|     11|				   "attribute (length %d)", len);
   69|     11|			return -1;
   70|     11|		}
   71|    246|		msg->go_intent = data;
   72|    246|		wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u "
   73|    246|			   "Tie breaker %u", data[0] >> 1, data[0] & 0x01);
   74|    246|		break;
   75|    916|	case P2P_ATTR_STATUS:
  ------------------
  |  Branch (75:2): [True: 916, False: 43.8k]
  ------------------
   76|    916|		if (len < 1) {
  ------------------
  |  Branch (76:7): [True: 206, False: 710]
  ------------------
   77|    206|			wpa_printf(MSG_DEBUG, "P2P: Too short Status "
   78|    206|				   "attribute (length %d)", len);
   79|    206|			return -1;
   80|    206|		}
   81|    710|		msg->status = data;
   82|    710|		wpa_printf(MSG_DEBUG, "P2P: * Status: %d", data[0]);
   83|    710|		break;
   84|  4.39k|	case P2P_ATTR_LISTEN_CHANNEL:
  ------------------
  |  Branch (84:2): [True: 4.39k, False: 40.4k]
  ------------------
   85|  4.39k|		if (len == 0) {
  ------------------
  |  Branch (85:7): [True: 204, False: 4.19k]
  ------------------
   86|    204|			wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: Ignore "
   87|    204|				   "null channel");
   88|    204|			break;
   89|    204|		}
   90|  4.19k|		if (len < 5) {
  ------------------
  |  Branch (90:7): [True: 10, False: 4.18k]
  ------------------
   91|     10|			wpa_printf(MSG_DEBUG, "P2P: Too short Listen Channel "
   92|     10|				   "attribute (length %d)", len);
   93|     10|			return -1;
   94|     10|		}
   95|  4.18k|		msg->listen_channel = data;
   96|  4.18k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (96:7): [True: 1.22k, False: 2.96k]
  ------------------
   97|  1.22k|			wpa_printf(MSG_DEBUG,
   98|  1.22k|				   "P2P: * Listen Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
   99|  1.22k|				   data[0], data[1], data[2], data[3], data[4]);
  100|  1.22k|			break;
  101|  1.22k|		}
  102|  2.96k|		wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: "
  103|  2.96k|			   "Country %c%c(0x%02x) Regulatory "
  104|  2.96k|			   "Class %d Channel Number %d", data[0], data[1],
  105|  2.96k|			   data[2], data[3], data[4]);
  106|  2.96k|		break;
  107|  1.65k|	case P2P_ATTR_OPERATING_CHANNEL:
  ------------------
  |  Branch (107:2): [True: 1.65k, False: 43.1k]
  ------------------
  108|  1.65k|		if (len == 0) {
  ------------------
  |  Branch (108:7): [True: 226, False: 1.43k]
  ------------------
  109|    226|			wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
  110|    226|				   "Ignore null channel");
  111|    226|			break;
  112|    226|		}
  113|  1.43k|		if (len < 5) {
  ------------------
  |  Branch (113:7): [True: 12, False: 1.41k]
  ------------------
  114|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Operating "
  115|     12|				   "Channel attribute (length %d)", len);
  116|     12|			return -1;
  117|     12|		}
  118|  1.41k|		msg->operating_channel = data;
  119|  1.41k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (119:7): [True: 565, False: 854]
  ------------------
  120|    565|			wpa_printf(MSG_DEBUG,
  121|    565|				   "P2P: * Operating Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
  122|    565|				   data[0], data[1], data[2], data[3], data[4]);
  123|    565|			break;
  124|    565|		}
  125|    854|		wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
  126|    854|			   "Country %c%c(0x%02x) Regulatory "
  127|    854|			   "Class %d Channel Number %d", data[0], data[1],
  128|    854|			   data[2], data[3], data[4]);
  129|    854|		break;
  130|  1.76k|	case P2P_ATTR_CHANNEL_LIST:
  ------------------
  |  Branch (130:2): [True: 1.76k, False: 43.0k]
  ------------------
  131|  1.76k|		if (len < 3) {
  ------------------
  |  Branch (131:7): [True: 12, False: 1.75k]
  ------------------
  132|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Channel List "
  133|     12|				   "attribute (length %d)", len);
  134|     12|			return -1;
  135|     12|		}
  136|  1.75k|		msg->channel_list = data;
  137|  1.75k|		msg->channel_list_len = len;
  138|  1.75k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (138:7): [True: 1.33k, False: 418]
  ------------------
  139|  1.33k|			wpa_printf(MSG_DEBUG,
  140|  1.33k|				   "P2P: * Channel List: Country String (binary) %02x %02x (0x%02x)",
  141|  1.33k|				   data[0], data[1], data[2]);
  142|  1.33k|		} else {
  143|    418|			wpa_printf(MSG_DEBUG,
  144|    418|				   "P2P: * Channel List: Country String '%c%c(0x%02x)'",
  145|    418|				   data[0], data[1], data[2]);
  146|    418|		}
  147|  1.75k|		wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List",
  148|  1.75k|			    msg->channel_list, msg->channel_list_len);
  149|  1.75k|		break;
  150|    857|	case P2P_ATTR_GROUP_INFO:
  ------------------
  |  Branch (150:2): [True: 857, False: 43.9k]
  ------------------
  151|    857|		msg->group_info = data;
  152|    857|		msg->group_info_len = len;
  153|    857|		wpa_printf(MSG_DEBUG, "P2P: * Group Info");
  154|    857|		break;
  155|  2.46k|	case P2P_ATTR_DEVICE_INFO:
  ------------------
  |  Branch (155:2): [True: 2.46k, False: 42.3k]
  ------------------
  156|  2.46k|		if (len < ETH_ALEN + 2 + 8 + 1) {
  ------------------
  |  |  344|  2.46k|#define ETH_ALEN 6
  ------------------
  |  Branch (156:7): [True: 18, False: 2.44k]
  ------------------
  157|     18|			wpa_printf(MSG_DEBUG, "P2P: Too short Device Info "
  158|     18|				   "attribute (length %d)", len);
  159|     18|			return -1;
  160|     18|		}
  161|  2.44k|		msg->p2p_device_info = data;
  162|  2.44k|		msg->p2p_device_info_len = len;
  163|  2.44k|		pos = data;
  164|  2.44k|		msg->p2p_device_addr = pos;
  165|  2.44k|		pos += ETH_ALEN;
  ------------------
  |  |  344|  2.44k|#define ETH_ALEN 6
  ------------------
  166|  2.44k|		msg->config_methods = WPA_GET_BE16(pos);
  167|  2.44k|		pos += 2;
  168|  2.44k|		msg->pri_dev_type = pos;
  169|  2.44k|		pos += 8;
  170|  2.44k|		msg->num_sec_dev_types = *pos++;
  171|  2.44k|		if (msg->num_sec_dev_types * 8 > data + len - pos) {
  ------------------
  |  Branch (171:7): [True: 41, False: 2.40k]
  ------------------
  172|     41|			wpa_printf(MSG_DEBUG, "P2P: Device Info underflow");
  173|     41|			return -1;
  174|     41|		}
  175|  2.40k|		pos += msg->num_sec_dev_types * 8;
  176|  2.40k|		if (data + len - pos < 4) {
  ------------------
  |  Branch (176:7): [True: 8, False: 2.39k]
  ------------------
  177|      8|			wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
  178|      8|				   "length %d", (int) (data + len - pos));
  179|      8|			return -1;
  180|      8|		}
  181|  2.39k|		if (WPA_GET_BE16(pos) != ATTR_DEV_NAME) {
  ------------------
  |  Branch (181:7): [True: 77, False: 2.32k]
  ------------------
  182|     77|			wpa_hexdump(MSG_DEBUG, "P2P: Unexpected Device Name "
  183|     77|				    "header", pos, 4);
  184|     77|			return -1;
  185|     77|		}
  186|  2.32k|		pos += 2;
  187|  2.32k|		nlen = WPA_GET_BE16(pos);
  188|  2.32k|		pos += 2;
  189|  2.32k|		if (nlen > data + len - pos || nlen > WPS_DEV_NAME_MAX_LEN) {
  ------------------
  |  |   48|  2.28k|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  |  Branch (189:7): [True: 36, False: 2.28k]
  |  Branch (189:34): [True: 12, False: 2.27k]
  ------------------
  190|     48|			wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
  191|     48|				   "length %u (buf len %d)", nlen,
  192|     48|				   (int) (data + len - pos));
  193|     48|			return -1;
  194|     48|		}
  195|  2.27k|		p2p_copy_filter_devname(msg->device_name,
  196|  2.27k|					sizeof(msg->device_name), pos, nlen);
  197|  2.27k|		wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
  198|  2.27k|			   " primary device type %s device name '%s' "
  199|  2.27k|			   "config methods 0x%x",
  200|  2.27k|			   MAC2STR(msg->p2p_device_addr),
  ------------------
  |  |  447|  2.27k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  201|  2.27k|			   wps_dev_type_bin2str(msg->pri_dev_type, devtype,
  202|  2.27k|						sizeof(devtype)),
  203|  2.27k|			   msg->device_name, msg->config_methods);
  204|  2.27k|		break;
  205|    244|	case P2P_ATTR_CONFIGURATION_TIMEOUT:
  ------------------
  |  Branch (205:2): [True: 244, False: 44.5k]
  ------------------
  206|    244|		if (len < 2) {
  ------------------
  |  Branch (206:7): [True: 11, False: 233]
  ------------------
  207|     11|			wpa_printf(MSG_DEBUG, "P2P: Too short Configuration "
  208|     11|				   "Timeout attribute (length %d)", len);
  209|     11|			return -1;
  210|     11|		}
  211|    233|		msg->config_timeout = data;
  212|    233|		wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout");
  213|    233|		break;
  214|    397|	case P2P_ATTR_INTENDED_INTERFACE_ADDR:
  ------------------
  |  Branch (214:2): [True: 397, False: 44.4k]
  ------------------
  215|    397|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|    397|#define ETH_ALEN 6
  ------------------
  |  Branch (215:7): [True: 10, False: 387]
  ------------------
  216|     10|			wpa_printf(MSG_DEBUG, "P2P: Too short Intended P2P "
  217|     10|				   "Interface Address attribute (length %d)",
  218|     10|				   len);
  219|     10|			return -1;
  220|     10|		}
  221|    387|		msg->intended_addr = data;
  222|    387|		wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address: "
  223|    387|			   MACSTR, MAC2STR(msg->intended_addr));
  ------------------
  |  |  448|    387|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			   MACSTR, MAC2STR(msg->intended_addr));
  ------------------
  |  |  447|    387|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  224|    387|		break;
  225|    256|	case P2P_ATTR_GROUP_BSSID:
  ------------------
  |  Branch (225:2): [True: 256, False: 44.5k]
  ------------------
  226|    256|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|    256|#define ETH_ALEN 6
  ------------------
  |  Branch (226:7): [True: 19, False: 237]
  ------------------
  227|     19|			wpa_printf(MSG_DEBUG, "P2P: Too short P2P Group BSSID "
  228|     19|				   "attribute (length %d)", len);
  229|     19|			return -1;
  230|     19|		}
  231|    237|		msg->group_bssid = data;
  232|    237|		wpa_printf(MSG_DEBUG, "P2P: * P2P Group BSSID: " MACSTR,
  ------------------
  |  |  448|    237|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  233|    237|			   MAC2STR(msg->group_bssid));
  ------------------
  |  |  447|    237|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  234|    237|		break;
  235|  7.54k|	case P2P_ATTR_GROUP_ID:
  ------------------
  |  Branch (235:2): [True: 7.54k, False: 37.2k]
  ------------------
  236|  7.54k|		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  15.0k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  7.52k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  511|  7.52k|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (236:7): [True: 16, False: 7.52k]
  |  Branch (236:25): [True: 46, False: 7.47k]
  ------------------
  237|     62|			wpa_printf(MSG_DEBUG, "P2P: Invalid P2P Group ID "
  238|     62|				   "attribute length %d", len);
  239|     62|			return -1;
  240|     62|		}
  241|  7.47k|		msg->group_id = data;
  242|  7.47k|		msg->group_id_len = len;
  243|  7.47k|		wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID: Device Address "
  244|  7.47k|			   MACSTR, MAC2STR(msg->group_id));
  ------------------
  |  |  448|  7.47k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			   MACSTR, MAC2STR(msg->group_id));
  ------------------
  |  |  447|  7.47k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  245|  7.47k|		wpa_hexdump_ascii(MSG_DEBUG, "P2P: * P2P Group ID: SSID",
  246|  7.47k|				  msg->group_id + ETH_ALEN,
  ------------------
  |  |  344|  7.47k|#define ETH_ALEN 6
  ------------------
  247|  7.47k|				  msg->group_id_len - ETH_ALEN);
  ------------------
  |  |  344|  7.47k|#define ETH_ALEN 6
  ------------------
  248|  7.47k|		break;
  249|    223|	case P2P_ATTR_INVITATION_FLAGS:
  ------------------
  |  Branch (249:2): [True: 223, False: 44.5k]
  ------------------
  250|    223|		if (len < 1) {
  ------------------
  |  Branch (250:7): [True: 9, False: 214]
  ------------------
  251|      9|			wpa_printf(MSG_DEBUG, "P2P: Too short Invitation "
  252|      9|				   "Flag attribute (length %d)", len);
  253|      9|			return -1;
  254|      9|		}
  255|    214|		msg->invitation_flags = data;
  256|    214|		wpa_printf(MSG_DEBUG, "P2P: * Invitation Flags: bitmap 0x%x",
  257|    214|			   data[0]);
  258|    214|		break;
  259|    263|	case P2P_ATTR_MANAGEABILITY:
  ------------------
  |  Branch (259:2): [True: 263, False: 44.5k]
  ------------------
  260|    263|		if (len < 1) {
  ------------------
  |  Branch (260:7): [True: 7, False: 256]
  ------------------
  261|      7|			wpa_printf(MSG_DEBUG, "P2P: Too short Manageability "
  262|      7|				   "attribute (length %d)", len);
  263|      7|			return -1;
  264|      7|		}
  265|    256|		msg->manageability = data;
  266|    256|		wpa_printf(MSG_DEBUG, "P2P: * Manageability: bitmap 0x%x",
  267|    256|			   data[0]);
  268|    256|		break;
  269|    301|	case P2P_ATTR_NOTICE_OF_ABSENCE:
  ------------------
  |  Branch (269:2): [True: 301, False: 44.5k]
  ------------------
  270|    301|		if (len < 2) {
  ------------------
  |  Branch (270:7): [True: 8, False: 293]
  ------------------
  271|      8|			wpa_printf(MSG_DEBUG, "P2P: Too short Notice of "
  272|      8|				   "Absence attribute (length %d)", len);
  273|      8|			return -1;
  274|      8|		}
  275|    293|		msg->noa = data;
  276|    293|		msg->noa_len = len;
  277|    293|		wpa_printf(MSG_DEBUG, "P2P: * Notice of Absence");
  278|    293|		break;
  279|    266|	case P2P_ATTR_EXT_LISTEN_TIMING:
  ------------------
  |  Branch (279:2): [True: 266, False: 44.5k]
  ------------------
  280|    266|		if (len < 4) {
  ------------------
  |  Branch (280:7): [True: 14, False: 252]
  ------------------
  281|     14|			wpa_printf(MSG_DEBUG, "P2P: Too short Extended Listen "
  282|     14|				   "Timing attribute (length %d)", len);
  283|     14|			return -1;
  284|     14|		}
  285|    252|		msg->ext_listen_timing = data;
  286|    252|		wpa_printf(MSG_DEBUG, "P2P: * Extended Listen Timing "
  287|    252|			   "(period %u msec  interval %u msec)",
  288|    252|			   WPA_GET_LE16(msg->ext_listen_timing),
  289|    252|			   WPA_GET_LE16(msg->ext_listen_timing + 2));
  290|    252|		break;
  291|    241|	case P2P_ATTR_MINOR_REASON_CODE:
  ------------------
  |  Branch (291:2): [True: 241, False: 44.5k]
  ------------------
  292|    241|		if (len < 1) {
  ------------------
  |  Branch (292:7): [True: 13, False: 228]
  ------------------
  293|     13|			wpa_printf(MSG_DEBUG, "P2P: Too short Minor Reason "
  294|     13|				   "Code attribute (length %d)", len);
  295|     13|			return -1;
  296|     13|		}
  297|    228|		msg->minor_reason_code = data;
  298|    228|		wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u",
  299|    228|			   *msg->minor_reason_code);
  300|    228|		break;
  301|    212|	case P2P_ATTR_OOB_GO_NEG_CHANNEL:
  ------------------
  |  Branch (301:2): [True: 212, False: 44.6k]
  ------------------
  302|    212|		if (len < 6) {
  ------------------
  |  Branch (302:7): [True: 16, False: 196]
  ------------------
  303|     16|			wpa_printf(MSG_DEBUG, "P2P: Too short OOB GO Neg "
  304|     16|				   "Channel attribute (length %d)", len);
  305|     16|			return -1;
  306|     16|		}
  307|    196|		msg->oob_go_neg_channel = data;
  308|    196|		wpa_printf(MSG_DEBUG, "P2P: * OOB GO Neg Channel: "
  309|    196|			   "Country %c%c(0x%02x) Operating Class %d "
  310|    196|			   "Channel Number %d Role %d",
  311|    196|			   data[0], data[1], data[2], data[3], data[4],
  312|    196|			   data[5]);
  313|    196|		break;
  314|    213|	case P2P_ATTR_SERVICE_HASH:
  ------------------
  |  Branch (314:2): [True: 213, False: 44.6k]
  ------------------
  315|    213|		if (len < P2PS_HASH_LEN) {
  ------------------
  |  |   35|    213|#define P2PS_HASH_LEN 6
  ------------------
  |  Branch (315:7): [True: 6, False: 207]
  ------------------
  316|      6|			wpa_printf(MSG_DEBUG,
  317|      6|				   "P2P: Too short Service Hash (length %u)",
  318|      6|				   len);
  319|      6|			return -1;
  320|      6|		}
  321|    207|		msg->service_hash_count = len / P2PS_HASH_LEN;
  ------------------
  |  |   35|    207|#define P2PS_HASH_LEN 6
  ------------------
  322|    207|		msg->service_hash = data;
  323|    207|		wpa_hexdump(MSG_DEBUG, "P2P: * Service Hash(s)", data, len);
  324|    207|		break;
  325|    210|	case P2P_ATTR_SESSION_INFORMATION_DATA:
  ------------------
  |  Branch (325:2): [True: 210, False: 44.6k]
  ------------------
  326|    210|		msg->session_info = data;
  327|    210|		msg->session_info_len = len;
  328|    210|		wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %u bytes - %p",
  329|    210|			   len, data);
  330|    210|		break;
  331|    449|	case P2P_ATTR_CONNECTION_CAPABILITY:
  ------------------
  |  Branch (331:2): [True: 449, False: 44.3k]
  ------------------
  332|    449|		if (len < 1) {
  ------------------
  |  Branch (332:7): [True: 18, False: 431]
  ------------------
  333|     18|			wpa_printf(MSG_DEBUG,
  334|     18|				   "P2P: Too short Connection Capability (length %u)",
  335|     18|				   len);
  336|     18|			return -1;
  337|     18|		}
  338|    431|		msg->conn_cap = data;
  339|    431|		wpa_printf(MSG_DEBUG, "P2P: * Connection Capability: 0x%x",
  340|    431|			   *msg->conn_cap);
  341|    431|		break;
  342|    449|	case P2P_ATTR_ADVERTISEMENT_ID:
  ------------------
  |  Branch (342:2): [True: 449, False: 44.3k]
  ------------------
  343|    449|		if (len < 10) {
  ------------------
  |  Branch (343:7): [True: 19, False: 430]
  ------------------
  344|     19|			wpa_printf(MSG_DEBUG,
  345|     19|				   "P2P: Too short Advertisement ID (length %u)",
  346|     19|				   len);
  347|     19|			return -1;
  348|     19|		}
  349|    430|		msg->adv_id = data;
  350|    430|		msg->adv_mac = &data[sizeof(u32)];
  351|    430|		wpa_printf(MSG_DEBUG, "P2P: * Advertisement ID %x",
  352|    430|			   WPA_GET_LE32(data));
  353|    430|		break;
  354|  2.21k|	case P2P_ATTR_ADVERTISED_SERVICE:
  ------------------
  |  Branch (354:2): [True: 2.21k, False: 42.6k]
  ------------------
  355|  2.21k|		if (len < 8) {
  ------------------
  |  Branch (355:7): [True: 16, False: 2.19k]
  ------------------
  356|     16|			wpa_printf(MSG_DEBUG,
  357|     16|				   "P2P: Too short Service Instance (length %u)",
  358|     16|				   len);
  359|     16|			return -1;
  360|     16|		}
  361|  2.19k|		msg->adv_service_instance = data;
  362|  2.19k|		msg->adv_service_instance_len = len;
  363|  2.19k|		if (len <= 255 + 8) {
  ------------------
  |  Branch (363:7): [True: 1.97k, False: 220]
  ------------------
  364|  1.97k|			char str[256];
  365|  1.97k|			u8 namelen;
  366|       |
  367|  1.97k|			namelen = data[6];
  368|  1.97k|			if (namelen > len - 7)
  ------------------
  |  Branch (368:8): [True: 222, False: 1.75k]
  ------------------
  369|    222|				break;
  370|  1.75k|			os_memcpy(str, &data[7], namelen);
  ------------------
  |  |  523|  1.75k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  371|  1.75k|			str[namelen] = '\0';
  372|  1.75k|			wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %x-%s",
  373|  1.75k|				   WPA_GET_LE32(data), str);
  374|  1.75k|		} else {
  375|    220|			wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %p",
  376|    220|				   data);
  377|    220|		}
  378|  1.97k|		break;
  379|  1.97k|	case P2P_ATTR_SESSION_ID:
  ------------------
  |  Branch (379:2): [True: 446, False: 44.3k]
  ------------------
  380|    446|		if (len < sizeof(u32) + ETH_ALEN) {
  ------------------
  |  |  344|    446|#define ETH_ALEN 6
  ------------------
  |  Branch (380:7): [True: 18, False: 428]
  ------------------
  381|     18|			wpa_printf(MSG_DEBUG,
  382|     18|				   "P2P: Too short Session ID Info (length %u)",
  383|     18|				   len);
  384|     18|			return -1;
  385|     18|		}
  386|    428|		msg->session_id = data;
  387|    428|		msg->session_mac = &data[sizeof(u32)];
  388|    428|		wpa_printf(MSG_DEBUG, "P2P: * Session ID: %x " MACSTR,
  ------------------
  |  |  448|    428|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  389|    428|			   WPA_GET_LE32(data), MAC2STR(msg->session_mac));
  ------------------
  |  |  447|    428|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  390|    428|		break;
  391|    540|	case P2P_ATTR_FEATURE_CAPABILITY:
  ------------------
  |  Branch (391:2): [True: 540, False: 44.2k]
  ------------------
  392|    540|		if (!len) {
  ------------------
  |  Branch (392:7): [True: 6, False: 534]
  ------------------
  393|      6|			wpa_printf(MSG_DEBUG,
  394|      6|				   "P2P: Too short Feature Capability (length %u)",
  395|      6|				   len);
  396|      6|			return -1;
  397|      6|		}
  398|    534|		msg->feature_cap = data;
  399|    534|		msg->feature_cap_len = len;
  400|    534|		wpa_printf(MSG_DEBUG, "P2P: * Feature Cap (length=%u)", len);
  401|    534|		break;
  402|  7.17k|	case P2P_ATTR_PERSISTENT_GROUP:
  ------------------
  |  Branch (402:2): [True: 7.17k, False: 37.6k]
  ------------------
  403|  7.17k|	{
  404|  7.17k|		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  14.3k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  7.16k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  511|  7.16k|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (404:7): [True: 6, False: 7.16k]
  |  Branch (404:25): [True: 51, False: 7.11k]
  ------------------
  405|     57|			wpa_printf(MSG_DEBUG,
  406|     57|				   "P2P: Invalid Persistent Group Info (length %u)",
  407|     57|				   len);
  408|     57|			return -1;
  409|     57|		}
  410|       |
  411|  7.11k|		msg->persistent_dev = data;
  412|  7.11k|		msg->persistent_ssid_len = len - ETH_ALEN;
  ------------------
  |  |  344|  7.11k|#define ETH_ALEN 6
  ------------------
  413|  7.11k|		msg->persistent_ssid = &data[ETH_ALEN];
  ------------------
  |  |  344|  7.11k|#define ETH_ALEN 6
  ------------------
  414|  7.11k|		wpa_printf(MSG_DEBUG, "P2P: * Persistent Group: " MACSTR " %s",
  415|  7.11k|			   MAC2STR(msg->persistent_dev),
  ------------------
  |  |  447|  7.11k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  416|  7.11k|			   wpa_ssid_txt(msg->persistent_ssid,
  417|  7.11k|					msg->persistent_ssid_len));
  418|  7.11k|		break;
  419|  7.17k|	}
  420|    453|	case P2P_ATTR_CAPABILITY_EXTENSION:
  ------------------
  |  Branch (420:2): [True: 453, False: 44.3k]
  ------------------
  421|    453|		if (len < 2) {
  ------------------
  |  Branch (421:7): [True: 17, False: 436]
  ------------------
  422|     17|			wpa_printf(MSG_DEBUG, "P2P: Too short PCEA (length %d)",
  423|     17|				   len);
  424|     17|			return -1;
  425|     17|		}
  426|    436|		msg->pcea_info = data;
  427|    436|		msg->pcea_info_len = len;
  428|    436|		wpa_printf(MSG_DEBUG, "P2P: * PCEA (length=%u)", len);
  429|    436|		break;
  430|    637|	case P2P_ATTR_PAIRING_AND_BOOTSTRAPPING:
  ------------------
  |  Branch (430:2): [True: 637, False: 44.1k]
  ------------------
  431|    637|		if (len < 1) {
  ------------------
  |  Branch (431:7): [True: 9, False: 628]
  ------------------
  432|      9|			wpa_printf(MSG_DEBUG, "P2P: Too short PBMA (length %d)",
  433|      9|				   len);
  434|      9|			return -1;
  435|      9|		}
  436|    628|		msg->pbma_info = data;
  437|    628|		msg->pbma_info_len = len;
  438|    628|		wpa_printf(MSG_DEBUG, "P2P: * PBMA (length=%u)", len);
  439|    628|		break;
  440|    292|	case P2P_ATTR_ACTION_FRAME_WRAPPER:
  ------------------
  |  Branch (440:2): [True: 292, False: 44.5k]
  ------------------
  441|    292|		if (len < 2) {
  ------------------
  |  Branch (441:7): [True: 8, False: 284]
  ------------------
  442|      8|			wpa_printf(MSG_DEBUG,
  443|      8|				   "P2P: Too short Action Frame Wrapper attribute (length %d)",
  444|      8|				   len);
  445|      8|			return -1;
  446|      8|		}
  447|    284|		msg->action_frame_wrapper = data;
  448|    284|		msg->action_frame_wrapper_len = len;
  449|    284|		wpa_printf(MSG_DEBUG, "P2P: * Action frame wrapper (length=%u)",
  450|    284|			   len);
  451|    284|		break;
  452|    231|	case P2P_ATTR_DEVICE_IDENTITY_RESOLUTION:
  ------------------
  |  Branch (452:2): [True: 231, False: 44.5k]
  ------------------
  453|    231|		if (len < 1) {
  ------------------
  |  Branch (453:7): [True: 6, False: 225]
  ------------------
  454|      6|			wpa_printf(MSG_DEBUG, "P2P: Too short DIRA (length %d)",
  455|      6|				   len);
  456|      6|			return -1;
  457|      6|		}
  458|    225|		msg->dira = data;
  459|    225|		msg->dira_len = len;
  460|    225|		wpa_printf(MSG_DEBUG, "P2P: * DIRA (length=%u)", len);
  461|    225|		break;
  462|    244|	case P2P_ATTR_WLAN_AP_INFORMATION:
  ------------------
  |  Branch (462:2): [True: 244, False: 44.5k]
  ------------------
  463|       |		/* One or more AP Info fields (each being 12 octets) is required
  464|       |		 * to be included. */
  465|    244|		if (len < 12) {
  ------------------
  |  Branch (465:7): [True: 21, False: 223]
  ------------------
  466|     21|			wpa_printf(MSG_DEBUG,
  467|     21|				   "P2P: Too short WLAN AP info (length %d)",
  468|     21|				   len);
  469|     21|			return -1;
  470|     21|		}
  471|    223|		msg->wlan_ap_info = data;
  472|    223|		msg->wlan_ap_info_len = len;
  473|    223|		break;
  474|    693|	default:
  ------------------
  |  Branch (474:2): [True: 693, False: 44.1k]
  ------------------
  475|    693|		wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d "
  476|    693|			   "(length %d)", id, len);
  477|    693|		break;
  478|  44.8k|	}
  479|       |
  480|  43.9k|	return 0;
  481|  44.8k|}
p2p_parse.c:p2p_parse_wps_ie:
  530|  4.93k|{
  531|  4.93k|	struct wps_parse_attr attr;
  532|  4.93k|	int i;
  533|       |
  534|  4.93k|	wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE");
  535|  4.93k|	if (wps_parse_msg(buf, &attr))
  ------------------
  |  Branch (535:6): [True: 1.96k, False: 2.96k]
  ------------------
  536|  1.96k|		return -1;
  537|  2.96k|	if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) &&
  ------------------
  |  Branch (537:6): [True: 58, False: 2.90k]
  |  Branch (537:23): [True: 58, False: 0]
  ------------------
  538|     58|	    !msg->device_name[0])
  ------------------
  |  Branch (538:6): [True: 58, False: 0]
  ------------------
  539|     58|		os_memcpy(msg->device_name, attr.dev_name, attr.dev_name_len);
  ------------------
  |  |  523|     58|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  540|  2.96k|	if (attr.config_methods) {
  ------------------
  |  Branch (540:6): [True: 361, False: 2.60k]
  ------------------
  541|    361|		msg->wps_config_methods =
  542|    361|			WPA_GET_BE16(attr.config_methods);
  543|    361|		wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x",
  544|    361|			   msg->wps_config_methods);
  545|    361|	}
  546|  2.96k|	if (attr.dev_password_id) {
  ------------------
  |  Branch (546:6): [True: 24, False: 2.94k]
  ------------------
  547|     24|		msg->dev_password_id = WPA_GET_BE16(attr.dev_password_id);
  548|     24|		wpa_printf(MSG_DEBUG, "P2P: Device Password ID: %d",
  549|     24|			   msg->dev_password_id);
  550|     24|		msg->dev_password_id_present = 1;
  551|     24|	}
  552|  2.96k|	if (attr.primary_dev_type) {
  ------------------
  |  Branch (552:6): [True: 48, False: 2.91k]
  ------------------
  553|     48|		char devtype[WPS_DEV_TYPE_BUFSIZE];
  554|     48|		msg->wps_pri_dev_type = attr.primary_dev_type;
  555|     48|		wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s",
  556|     48|			   wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype,
  557|     48|						sizeof(devtype)));
  558|     48|	}
  559|  2.96k|	if (attr.sec_dev_type_list) {
  ------------------
  |  Branch (559:6): [True: 36, False: 2.92k]
  ------------------
  560|     36|		msg->wps_sec_dev_type_list = attr.sec_dev_type_list;
  561|     36|		msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len;
  562|     36|	}
  563|       |
  564|  32.6k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  32.6k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (564:14): [True: 29.6k, False: 2.96k]
  ------------------
  565|  29.6k|		msg->wps_vendor_ext[i] = attr.vendor_ext[i];
  566|  29.6k|		msg->wps_vendor_ext_len[i] = attr.vendor_ext_len[i];
  567|  29.6k|	}
  568|       |
  569|  2.96k|	msg->manufacturer = attr.manufacturer;
  570|  2.96k|	msg->manufacturer_len = attr.manufacturer_len;
  571|  2.96k|	msg->model_name = attr.model_name;
  572|  2.96k|	msg->model_name_len = attr.model_name_len;
  573|  2.96k|	msg->model_number = attr.model_number;
  574|  2.96k|	msg->model_number_len = attr.model_number_len;
  575|  2.96k|	msg->serial_number = attr.serial_number;
  576|  2.96k|	msg->serial_number_len = attr.serial_number_len;
  577|       |
  578|  2.96k|	msg->oob_dev_password = attr.oob_dev_password;
  579|  2.96k|	msg->oob_dev_password_len = attr.oob_dev_password_len;
  580|       |
  581|  2.96k|	return 0;
  582|  4.93k|}

p2p_process_pcea:
  662|     51|{
  663|     51|	const u8 *pos, *end;
  664|     51|	u8 cap_info_len;
  665|       |
  666|     51|	if (!p2p || !dev || !msg || !msg->pcea_info)
  ------------------
  |  Branch (666:6): [True: 0, False: 51]
  |  Branch (666:14): [True: 0, False: 51]
  |  Branch (666:22): [True: 0, False: 51]
  |  Branch (666:30): [True: 0, False: 51]
  ------------------
  667|      0|		return;
  668|       |
  669|     51|	pos = msg->pcea_info;
  670|     51|	end = pos + msg->pcea_info_len;
  671|     51|	dev->info.pcea_cap_info = WPA_GET_LE16(pos);
  672|     51|	cap_info_len = dev->info.pcea_cap_info & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1929|     51|#define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  673|       |
  674|       |	/* Field length is (n-1), n in octets */
  675|     51|	if (end - pos < cap_info_len + 1)
  ------------------
  |  Branch (675:6): [True: 11, False: 40]
  ------------------
  676|     11|		return;
  677|     40|	pos += cap_info_len + 1;
  678|       |
  679|     40|	if (dev->info.pcea_cap_info & P2P_PCEA_6GHZ)
  ------------------
  |  | 1930|     40|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     40|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (679:6): [True: 22, False: 18]
  ------------------
  680|     22|		dev->support_6ghz = true;
  681|       |
  682|     40|	if (dev->info.pcea_cap_info & P2P_PCEA_REG_INFO) {
  ------------------
  |  | 1931|     40|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     40|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (682:6): [True: 24, False: 16]
  ------------------
  683|     24|		if (end - pos < 1) {
  ------------------
  |  Branch (683:7): [True: 2, False: 22]
  ------------------
  684|      2|			p2p_dbg(p2p, "Truncated PCEA");
  685|      2|			return;
  686|      2|		}
  687|     22|		dev->info.reg_info = *pos++;
  688|     22|	}
  689|       |
  690|     38|	if (dev->info.pcea_cap_info & P2P_PCEA_PASN_TYPE) {
  ------------------
  |  | 1937|     38|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     38|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (690:6): [True: 22, False: 16]
  ------------------
  691|     22|		if (end - pos < 1) {
  ------------------
  |  Branch (691:7): [True: 3, False: 19]
  ------------------
  692|      3|			p2p_dbg(p2p, "Truncated PCEA");
  693|      3|			return;
  694|      3|		}
  695|     19|		dev->info.pairing_config.pasn_type = *pos++;
  696|     19|	}
  697|       |
  698|     35|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_CAPABLE)
  ------------------
  |  | 1934|     35|#define P2P_PCEA_PAIRING_CAPABLE BIT(8)
  |  |  ------------------
  |  |  |  |  458|     35|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (698:6): [True: 12, False: 23]
  ------------------
  699|     12|		dev->info.pairing_config.pairing_capable = true;
  700|       |
  701|     35|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_SETUP_ENABLED)
  ------------------
  |  | 1935|     35|#define P2P_PCEA_PAIRING_SETUP_ENABLED BIT(9)
  |  |  ------------------
  |  |  |  |  458|     35|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (701:6): [True: 16, False: 19]
  ------------------
  702|     16|		dev->info.pairing_config.enable_pairing_setup = true;
  703|       |
  704|     35|	if (dev->info.pcea_cap_info & P2P_PCEA_PMK_CACHING) {
  ------------------
  |  | 1936|     35|#define P2P_PCEA_PMK_CACHING BIT(10)
  |  |  ------------------
  |  |  |  |  458|     35|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (704:6): [True: 14, False: 21]
  ------------------
  705|       |		dev->info.pairing_config.enable_pairing_cache = true;
  706|     14|	}
  707|     35|}
p2p_handle_prov_disc_req:
 1521|  1.10k|{
 1522|  1.10k|	struct p2p_message msg;
 1523|       |
 1524|  1.10k|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (1524:6): [True: 219, False: 881]
  ------------------
 1525|    219|		return;
 1526|       |
 1527|    881|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (1527:6): [True: 56, False: 825]
  |  Branch (1527:23): [True: 55, False: 1]
  ------------------
 1528|     55|		p2p_process_prov_disc_bootstrap_req(p2p, &msg, sa, data + 1,
 1529|     55|						    len - 1, rx_freq);
 1530|    826|	else
 1531|    826|		p2p_process_prov_disc_req(p2p, &msg, sa, data + 1, len - 1,
 1532|    826|					  rx_freq);
 1533|       |
 1534|    881|	p2p_parse_free(&msg);
 1535|    881|}
p2p_handle_prov_disc_resp:
 2054|     35|{
 2055|     35|	struct p2p_message msg;
 2056|       |
 2057|     35|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (2057:6): [True: 14, False: 21]
  ------------------
 2058|     14|		return;
 2059|       |
 2060|     21|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (2060:6): [True: 6, False: 15]
  |  Branch (2060:23): [True: 5, False: 1]
  ------------------
 2061|      5|		p2p_process_prov_disc_bootstrap_resp(p2p, &msg, sa, data + 1,
 2062|      5|						     len - 1, rx_freq);
 2063|     16|	else
 2064|     16|		p2p_process_prov_disc_resp(p2p, &msg, sa, data + 1, len - 1);
 2065|       |
 2066|     21|	p2p_parse_free(&msg);
 2067|     21|}
p2p_reset_pending_pd:
 2250|  6.88k|{
 2251|  6.88k|	struct p2p_device *dev;
 2252|       |
 2253|  6.88k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  6.88k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  6.88k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 0, False: 6.88k]
  |  |  ------------------
  |  |   81|  6.88k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 2254|      0|		if (!ether_addr_equal(p2p->pending_pd_devaddr,
  ------------------
  |  Branch (2254:7): [True: 0, False: 0]
  ------------------
 2255|      0|				      dev->info.p2p_device_addr))
 2256|      0|			continue;
 2257|      0|		if (!dev->req_config_methods)
  ------------------
  |  Branch (2257:7): [True: 0, False: 0]
  ------------------
 2258|      0|			continue;
 2259|      0|		if (dev->flags & P2P_DEV_PD_FOR_JOIN)
  ------------------
  |  |  139|      0|#define P2P_DEV_PD_FOR_JOIN BIT(14)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (2259:7): [True: 0, False: 0]
  ------------------
 2260|      0|			continue;
 2261|       |		/* Reset the config methods of the device */
 2262|      0|		dev->req_config_methods = 0;
 2263|      0|	}
 2264|       |
 2265|  6.88k|	p2p->user_initiated_pd = 0;
 2266|  6.88k|	os_memset(p2p->pending_pd_devaddr, 0, ETH_ALEN);
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2267|  6.88k|	p2p->pd_retries = 0;
 2268|  6.88k|	p2p->pd_force_freq = 0;
 2269|  6.88k|}
p2ps_prov_free:
 2273|  20.7k|{
 2274|  20.7k|	os_free(p2p->p2ps_prov);
  ------------------
  |  |  511|  20.7k|#define os_free(p) free((p))
  ------------------
 2275|       |	p2p->p2ps_prov = NULL;
 2276|  20.7k|}
p2p_pd.c:p2p_process_prov_disc_bootstrap_req:
  714|     55|{
  715|     55|	struct p2p_device *dev;
  716|     55|	int freq;
  717|     55|	struct wpabuf *resp;
  718|     55|	u16 bootstrap;
  719|     55|	size_t cookie_len = 0;
  720|     55|	const u8 *pos, *cookie;
  721|     55|	enum p2p_status_code status = P2P_SC_FAIL_INVALID_PARAMS;
  722|       |
  723|     55|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  724|     55|		" with bootstrapping Attribute (freq=%d)",
  725|     55|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     55|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  726|       |
  727|     55|	dev = p2p_get_device(p2p, sa);
  728|     55|	if (!dev) {
  ------------------
  |  Branch (728:6): [True: 21, False: 34]
  ------------------
  729|     21|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  730|     21|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|     21|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|     21|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  731|       |
  732|     21|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (732:7): [True: 2, False: 19]
  ------------------
  733|      2|			p2p_dbg(p2p,
  734|      2|				"Provision Discovery Request add device failed "
  735|      2|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  736|      2|			return;
  737|      2|		}
  738|       |
  739|     19|		dev = p2p_get_device(p2p, sa);
  740|     19|		if (!dev) {
  ------------------
  |  Branch (740:7): [True: 2, False: 17]
  ------------------
  741|      2|			p2p_dbg(p2p,
  742|      2|				"Provision Discovery device not found "
  743|      2|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  744|      2|			return;
  745|      2|		}
  746|     19|	}
  747|     51|	dev->p2p2 = true;
  748|       |
  749|     51|	if (p2p->send_action_in_progress) {
  ------------------
  |  Branch (749:6): [True: 0, False: 51]
  ------------------
  750|      0|		p2p_dbg(p2p, "Dropping retry frame as response TX pending");
  751|      0|		return;
  752|      0|	}
  753|       |
  754|     51|	p2p_update_peer_6ghz_capab(dev, msg);
  755|       |
  756|     51|	if (msg->pcea_info && msg->pcea_info_len >= 2)
  ------------------
  |  Branch (756:6): [True: 51, False: 0]
  |  Branch (756:24): [True: 51, False: 0]
  ------------------
  757|     51|		p2p_process_pcea(p2p, msg, dev);
  758|       |
  759|     51|	pos = msg->pbma_info;
  760|       |
  761|     51|	if (msg->pbma_info_len > 2 && msg->status &&
  ------------------
  |  Branch (761:6): [True: 37, False: 14]
  |  Branch (761:32): [True: 27, False: 10]
  ------------------
  762|     27|	    *msg->status == P2P_SC_COMEBACK) {
  ------------------
  |  Branch (762:6): [True: 8, False: 19]
  ------------------
  763|       |		/* PBMA comeback request */
  764|      8|		cookie_len = *pos++;
  765|      8|		if (msg->pbma_info_len < 1 + cookie_len) {
  ------------------
  |  Branch (765:7): [True: 1, False: 7]
  ------------------
  766|      1|			p2p_dbg(p2p, "Truncated PBMA");
  767|      1|			return;
  768|      1|		}
  769|      7|		cookie = pos;
  770|       |
  771|      7|		if (!dev->bootstrap_params ||
  ------------------
  |  Branch (771:7): [True: 7, False: 0]
  ------------------
  772|      0|		    dev->bootstrap_params->cookie_len != cookie_len ||
  ------------------
  |  Branch (772:7): [True: 0, False: 0]
  ------------------
  773|      0|		    os_memcmp(cookie, dev->bootstrap_params->cookie,
  ------------------
  |  |  532|      0|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (773:7): [True: 0, False: 0]
  ------------------
  774|      7|			      cookie_len) != 0) {
  775|      7|			status = P2P_SC_FAIL_REJECTED_BY_USER;
  776|      7|			goto out;
  777|      7|		}
  778|       |
  779|      0|		bootstrap = dev->bootstrap_params->bootstrap_method;
  780|       |
  781|      0|		if (!dev->req_bootstrap_method) {
  ------------------
  |  Branch (781:7): [True: 0, False: 0]
  ------------------
  782|      0|			status = P2P_SC_COMEBACK;
  783|      0|			goto out;
  784|      0|		}
  785|     43|	} else {
  786|       |		/* PBMA request */
  787|     43|		bootstrap = WPA_GET_LE16(pos);
  788|       |
  789|     43|		os_free(dev->bootstrap_params);
  ------------------
  |  |  511|     43|#define os_free(p) free((p))
  ------------------
  790|     43|		dev->bootstrap_params = NULL;
  791|       |
  792|     43|		if (!dev->req_bootstrap_method) {
  ------------------
  |  Branch (792:7): [True: 43, False: 0]
  ------------------
  793|     43|			dev->bootstrap_params =
  794|     43|				os_zalloc(sizeof(struct p2p_bootstrap_params));
  795|     43|			if (!dev->bootstrap_params)
  ------------------
  |  Branch (795:8): [True: 0, False: 43]
  ------------------
  796|      0|				return;
  797|     43|			dev->bootstrap_params->bootstrap_method = bootstrap;
  798|     43|			dev->bootstrap_params->cookie_len = 4;
  799|     43|			if (os_get_random(dev->bootstrap_params->cookie,
  ------------------
  |  Branch (799:8): [True: 0, False: 43]
  ------------------
  800|     43|					  dev->bootstrap_params->cookie_len) <
  801|     43|			    0) {
  802|      0|				os_free(dev->bootstrap_params);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  803|      0|				dev->bootstrap_params = NULL;
  804|      0|				return;
  805|      0|			}
  806|     43|			dev->bootstrap_params->comeback_after =
  807|     43|				p2p->cfg->comeback_after;
  808|     43|			status = P2P_SC_COMEBACK;
  809|     43|			if (p2p->cfg->bootstrap_req_rx)
  ------------------
  |  Branch (809:8): [True: 0, False: 43]
  ------------------
  810|      0|				p2p->cfg->bootstrap_req_rx(p2p->cfg->cb_ctx,
  811|      0|							   sa, bootstrap);
  812|     43|			goto out;
  813|     43|		}
  814|     43|	}
  815|       |
  816|      0|	if (bootstrap == P2P_PBMA_PIN_CODE_DISPLAY &&
  ------------------
  |  | 1942|      0|#define P2P_PBMA_PIN_CODE_DISPLAY    BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (816:6): [True: 0, False: 0]
  ------------------
  817|      0|	    dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_KEYPAD)
  ------------------
  |  | 1946|      0|#define P2P_PBMA_PIN_CODE_KEYPAD     BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (817:6): [True: 0, False: 0]
  ------------------
  818|      0|		status = P2P_SC_SUCCESS;
  819|      0|	else if (bootstrap == P2P_PBMA_PIN_CODE_KEYPAD &&
  ------------------
  |  | 1946|      0|#define P2P_PBMA_PIN_CODE_KEYPAD     BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (819:11): [True: 0, False: 0]
  ------------------
  820|      0|		 dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_DISPLAY)
  ------------------
  |  | 1942|      0|#define P2P_PBMA_PIN_CODE_DISPLAY    BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (820:4): [True: 0, False: 0]
  ------------------
  821|      0|		status = P2P_SC_SUCCESS;
  822|      0|	else if (bootstrap == P2P_PBMA_PASSPHRASE_DISPLAY &&
  ------------------
  |  | 1943|      0|#define P2P_PBMA_PASSPHRASE_DISPLAY  BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (822:11): [True: 0, False: 0]
  ------------------
  823|      0|		 dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_KEYPAD)
  ------------------
  |  | 1947|      0|#define P2P_PBMA_PASSPHRASE_KEYPAD   BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (823:4): [True: 0, False: 0]
  ------------------
  824|      0|		status = P2P_SC_SUCCESS;
  825|      0|	else if (bootstrap == P2P_PBMA_PASSPHRASE_KEYPAD &&
  ------------------
  |  | 1947|      0|#define P2P_PBMA_PASSPHRASE_KEYPAD   BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (825:11): [True: 0, False: 0]
  ------------------
  826|      0|		 dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_DISPLAY)
  ------------------
  |  | 1943|      0|#define P2P_PBMA_PASSPHRASE_DISPLAY  BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (826:4): [True: 0, False: 0]
  ------------------
  827|      0|		status = P2P_SC_SUCCESS;
  828|      0|	else if (bootstrap == P2P_PBMA_NFC_TAG &&
  ------------------
  |  | 1945|      0|#define P2P_PBMA_NFC_TAG             BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (828:11): [True: 0, False: 0]
  ------------------
  829|      0|		 dev->req_bootstrap_method == P2P_PBMA_NFC_READER)
  ------------------
  |  | 1949|      0|#define P2P_PBMA_NFC_READER          BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (829:4): [True: 0, False: 0]
  ------------------
  830|      0|		status = P2P_SC_SUCCESS;
  831|      0|	else if (bootstrap == P2P_PBMA_NFC_READER &&
  ------------------
  |  | 1949|      0|#define P2P_PBMA_NFC_READER          BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (831:11): [True: 0, False: 0]
  ------------------
  832|      0|		 dev->req_bootstrap_method == P2P_PBMA_NFC_TAG)
  ------------------
  |  | 1945|      0|#define P2P_PBMA_NFC_TAG             BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (832:4): [True: 0, False: 0]
  ------------------
  833|      0|		status = P2P_SC_SUCCESS;
  834|      0|	else if (bootstrap == P2P_PBMA_QR_DISPLAY &&
  ------------------
  |  | 1944|      0|#define P2P_PBMA_QR_DISPLAY          BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (834:11): [True: 0, False: 0]
  ------------------
  835|      0|		 dev->req_bootstrap_method == P2P_PBMA_QR_SCAN)
  ------------------
  |  | 1948|      0|#define P2P_PBMA_QR_SCAN             BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (835:4): [True: 0, False: 0]
  ------------------
  836|      0|		status = P2P_SC_SUCCESS;
  837|      0|	else if (bootstrap == P2P_PBMA_QR_SCAN &&
  ------------------
  |  | 1948|      0|#define P2P_PBMA_QR_SCAN             BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (837:11): [True: 0, False: 0]
  ------------------
  838|      0|		 dev->req_bootstrap_method == P2P_PBMA_QR_DISPLAY)
  ------------------
  |  | 1944|      0|#define P2P_PBMA_QR_DISPLAY          BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (838:4): [True: 0, False: 0]
  ------------------
  839|      0|		status = P2P_SC_SUCCESS;
  840|      0|	else if (bootstrap == P2P_PBMA_OPPORTUNISTIC &&
  ------------------
  |  | 1941|      0|#define P2P_PBMA_OPPORTUNISTIC       BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (840:11): [True: 0, False: 0]
  ------------------
  841|      0|		 dev->req_bootstrap_method == P2P_PBMA_OPPORTUNISTIC)
  ------------------
  |  | 1941|      0|#define P2P_PBMA_OPPORTUNISTIC       BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (841:4): [True: 0, False: 0]
  ------------------
  842|      0|		status = P2P_SC_SUCCESS;
  843|      0|	else
  844|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
  845|       |
  846|      0|	wpa_printf(MSG_ERROR, "Bootstrap received %d", bootstrap);
  847|       |
  848|      0|	if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (848:6): [True: 0, False: 0]
  ------------------
  849|      0|		dev->role = P2P_ROLE_PAIRING_RESPONDER;
  850|       |#ifdef CONFIG_PASN
  851|       |		p2p_pasn_initialize(p2p, dev, sa, rx_freq, false, true);
  852|       |#endif /* CONFIG_PASN */
  853|      0|	}
  854|     50|out:
  855|       |	/* Send PD Bootstrapping Response for the PD Request */
  856|     50|	resp = p2p_build_prov_disc_bootstrap_resp(p2p, dev, msg->dialog_token,
  857|     50|						  status);
  858|     50|	if (!resp)
  ------------------
  |  Branch (858:6): [True: 0, False: 50]
  ------------------
  859|      0|		return;
  860|       |
  861|     50|	p2p_dbg(p2p, "Sending Provision Discovery Bootstrap Response");
  862|     50|	if (rx_freq > 0)
  ------------------
  |  Branch (862:6): [True: 50, False: 0]
  ------------------
  863|     50|		freq = rx_freq;
  864|      0|	else
  865|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  866|      0|					   p2p->cfg->channel);
  867|     50|	if (freq < 0) {
  ------------------
  |  Branch (867:6): [True: 0, False: 50]
  ------------------
  868|      0|		p2p_dbg(p2p, "Unknown operating class/channel");
  869|      0|		wpabuf_free(resp);
  870|      0|		return;
  871|      0|	}
  872|     50|	p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
  873|     50|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (873:6): [True: 0, False: 50]
  ------------------
  874|     50|			    p2p->cfg->dev_addr, wpabuf_head(resp),
  875|     50|			    wpabuf_len(resp), 50) < 0)
  876|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  877|     50|	else
  878|     50|		p2p->send_action_in_progress = 1;
  879|       |
  880|     50|	wpabuf_free(resp);
  881|     50|}
p2p_pd.c:p2p_build_prov_disc_bootstrap_resp:
  313|     50|{
  314|     50|	struct wpabuf *buf;
  315|     50|	u8 *cookie = NULL;
  316|     50|	size_t cookie_len = 0;
  317|     50|	int comeback_after = 0;
  318|     50|	u8 *len;
  319|       |
  320|     50|	buf = wpabuf_alloc(1000);
  321|     50|	if (!buf)
  ------------------
  |  Branch (321:6): [True: 0, False: 50]
  ------------------
  322|      0|		return NULL;
  323|       |
  324|     50|	p2p_dbg(p2p, "P2P2: Building boostrapping PD Response");
  325|     50|	if (status == P2P_SC_COMEBACK && dev->bootstrap_params) {
  ------------------
  |  Branch (325:6): [True: 43, False: 7]
  |  Branch (325:35): [True: 43, False: 0]
  ------------------
  326|     43|		cookie = dev->bootstrap_params->cookie;
  327|     43|		cookie_len = dev->bootstrap_params->cookie_len;
  328|     43|		comeback_after = dev->bootstrap_params->comeback_after;
  329|     43|	}
  330|       |
  331|     50|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  332|       |
  333|     50|	len = p2p_buf_add_p2p2_ie_hdr(buf);
  334|       |
  335|     50|	p2p_buf_add_status(buf, status);
  336|     50|	p2p_buf_add_pcea(buf, p2p);
  337|     50|	p2p_buf_add_pbma(buf, dev->req_bootstrap_method, cookie, cookie_len,
  338|     50|			 comeback_after);
  339|       |
  340|     50|	p2p_buf_update_ie_hdr(buf, len);
  341|       |
  342|     50|	return buf;
  343|     50|}
p2p_pd.c:p2p_process_prov_disc_req:
  887|    826|{
  888|    826|	struct p2p_device *dev;
  889|    826|	int freq;
  890|    826|	enum p2p_status_code reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
  891|    826|	struct wpabuf *resp;
  892|    826|	u32 adv_id = 0;
  893|    826|	struct p2ps_advertisement *p2ps_adv = NULL;
  894|    826|	u8 conncap = P2PS_SETUP_NEW;
  ------------------
  |  |   30|    826|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|    826|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  895|    826|	u8 auto_accept = 0;
  896|    826|	u32 session_id = 0;
  897|    826|	u8 session_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  898|    826|	u8 adv_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  899|    826|	const u8 *group_mac;
  900|    826|	int passwd_id = DEV_PW_DEFAULT;
  901|    826|	u16 config_methods;
  902|    826|	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|    826|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|    826|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  903|    826|	struct p2ps_feature_capab resp_fcap = { 0, 0 };
  904|    826|	struct p2ps_feature_capab *req_fcap = NULL;
  905|    826|	u8 remote_conncap;
  906|    826|	u16 method;
  907|       |
  908|    826|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  909|    826|		" with config methods 0x%x (freq=%d)",
  910|    826|		MAC2STR(sa), msg->wps_config_methods, rx_freq);
  ------------------
  |  |  447|    826|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  911|    826|	group_mac = msg->intended_addr;
  912|       |
  913|    826|	dev = p2p_get_device(p2p, sa);
  914|    826|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     65|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     65|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (914:6): [True: 761, False: 65]
  |  Branch (914:21): [True: 8, False: 57]
  ------------------
  915|    769|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  916|    769|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    769|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    769|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  917|       |
  918|    769|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (918:7): [True: 353, False: 416]
  ------------------
  919|    353|			p2p_dbg(p2p, "Provision Discovery Request add device failed "
  920|    353|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    353|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    353|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  921|    353|			goto out;
  922|    353|		}
  923|       |
  924|    416|		dev = p2p_get_device(p2p, sa);
  925|    416|		if (!dev) {
  ------------------
  |  Branch (925:7): [True: 319, False: 97]
  ------------------
  926|    319|			p2p_dbg(p2p,
  927|    319|				"Provision Discovery device not found "
  928|    319|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    319|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    319|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  929|    319|			goto out;
  930|    319|		}
  931|    416|	} else if (msg->wfd_subelems) {
  ------------------
  |  Branch (931:13): [True: 1, False: 56]
  ------------------
  932|      1|		wpabuf_free(dev->info.wfd_subelems);
  933|      1|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
  934|      1|	}
  935|       |
  936|    154|	p2p_update_peer_6ghz_capab(dev, msg);
  937|       |
  938|    154|	if (!msg->adv_id) {
  ------------------
  |  Branch (938:6): [True: 58, False: 96]
  ------------------
  939|     58|		allowed_config_methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|     58|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  940|     58|		if (!(msg->wps_config_methods & allowed_config_methods)) {
  ------------------
  |  Branch (940:7): [True: 8, False: 50]
  ------------------
  941|      8|			p2p_dbg(p2p,
  942|      8|				"Unsupported Config Methods in Provision Discovery Request");
  943|      8|			goto out;
  944|      8|		}
  945|       |
  946|       |		/* Legacy (non-P2PS) - Unknown groups allowed for P2PS */
  947|     50|		if (msg->group_id) {
  ------------------
  |  Branch (947:7): [True: 1, False: 49]
  ------------------
  948|      1|			size_t i;
  949|       |
  950|      1|			for (i = 0; i < p2p->num_groups; i++) {
  ------------------
  |  Branch (950:16): [True: 0, False: 1]
  ------------------
  951|      0|				if (p2p_group_is_group_id_match(
  ------------------
  |  Branch (951:9): [True: 0, False: 0]
  ------------------
  952|      0|					    p2p->groups[i],
  953|      0|					    msg->group_id, msg->group_id_len))
  954|      0|					break;
  955|      0|			}
  956|      1|			if (i == p2p->num_groups) {
  ------------------
  |  Branch (956:8): [True: 1, False: 0]
  ------------------
  957|      1|				p2p_dbg(p2p,
  958|      1|					"PD request for unknown P2P Group ID - reject");
  959|      1|				goto out;
  960|      1|			}
  961|      1|		}
  962|     96|	} else {
  963|     96|		allowed_config_methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     96|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  964|       |
  965|       |		/*
  966|       |		 * Set adv_id here, so in case of an error, a P2PS PD Response
  967|       |		 * will be sent.
  968|       |		 */
  969|     96|		adv_id = WPA_GET_LE32(msg->adv_id);
  970|     96|		if (p2ps_validate_pd_req(p2p, msg, sa) < 0) {
  ------------------
  |  Branch (970:7): [True: 23, False: 73]
  ------------------
  971|     23|			reject = P2P_SC_FAIL_INVALID_PARAMS;
  972|     23|			goto out;
  973|     23|		}
  974|       |
  975|     73|		req_fcap = (struct p2ps_feature_capab *) msg->feature_cap;
  976|       |
  977|     73|		os_memcpy(session_mac, msg->session_mac, ETH_ALEN);
  ------------------
  |  |  523|     73|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  978|     73|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|     73|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  979|       |
  980|     73|		session_id = WPA_GET_LE32(msg->session_id);
  981|       |
  982|     73|		if (msg->conn_cap)
  ------------------
  |  Branch (982:7): [True: 60, False: 13]
  ------------------
  983|     60|			conncap = *msg->conn_cap;
  984|       |
  985|       |		/*
  986|       |		 * We need to verify a P2PS config methog in an initial PD
  987|       |		 * request or in a follow-on PD request with the status
  988|       |		 * SUCCESS_DEFERRED.
  989|       |		 */
  990|     73|		if ((!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) &&
  ------------------
  |  Branch (990:8): [True: 7, False: 66]
  |  Branch (990:24): [True: 47, False: 19]
  ------------------
  991|     54|		    !(msg->wps_config_methods & allowed_config_methods)) {
  ------------------
  |  Branch (991:7): [True: 6, False: 48]
  ------------------
  992|      6|			p2p_dbg(p2p,
  993|      6|				"Unsupported Config Methods in Provision Discovery Request");
  994|      6|			goto out;
  995|      6|		}
  996|       |
  997|       |		/*
  998|       |		 * TODO: since we don't support multiple PD, reject PD request
  999|       |		 * if we are in the middle of P2PS PD with some other peer
 1000|       |		 */
 1001|     73|	}
 1002|       |
 1003|    116|	dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
  ------------------
  |  |  130|    116|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|    116|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1004|    116|			P2P_DEV_PD_PEER_KEYPAD |
  ------------------
  |  |  131|    116|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|    116|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1005|    116|			P2P_DEV_PD_PEER_P2PS);
  ------------------
  |  |  146|    116|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|    116|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1006|       |
 1007|    116|	if (msg->wps_config_methods & WPS_CONFIG_DISPLAY) {
  ------------------
  |  |  251|    116|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1007:6): [True: 49, False: 67]
  ------------------
 1008|     49|		p2p_dbg(p2p, "Peer " MACSTR
 1009|     49|			" requested us to show a PIN on display", MAC2STR(sa));
  ------------------
  |  |  447|     49|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1010|     49|		dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
  ------------------
  |  |  131|     49|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|     49|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1011|     49|		passwd_id = DEV_PW_USER_SPECIFIED;
 1012|     67|	} else if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|     67|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1012:13): [True: 30, False: 37]
  ------------------
 1013|     30|		p2p_dbg(p2p, "Peer " MACSTR
 1014|     30|			" requested us to write its PIN using keypad",
 1015|     30|			MAC2STR(sa));
  ------------------
  |  |  447|     30|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1016|     30|		dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
  ------------------
  |  |  130|     30|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|     30|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1017|     30|		passwd_id = DEV_PW_REGISTRAR_SPECIFIED;
 1018|     37|	} else if (msg->wps_config_methods & WPS_CONFIG_P2PS) {
  ------------------
  |  |  259|     37|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1018:13): [True: 15, False: 22]
  ------------------
 1019|     15|		p2p_dbg(p2p, "Peer " MACSTR " requesting P2PS PIN",
 1020|     15|			MAC2STR(sa));
  ------------------
  |  |  447|     15|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1021|     15|		dev->flags |= P2P_DEV_PD_PEER_P2PS;
  ------------------
  |  |  146|     15|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|     15|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1022|     15|		passwd_id = DEV_PW_P2PS_DEFAULT;
 1023|     15|	}
 1024|       |
 1025|       |	/* Remove stale persistent groups */
 1026|    116|	if (p2p->cfg->remove_stale_groups) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 116]
  ------------------
 1027|      0|		p2p->cfg->remove_stale_groups(
 1028|      0|			p2p->cfg->cb_ctx, dev->info.p2p_device_addr,
 1029|      0|			msg->persistent_dev,
 1030|      0|			msg->persistent_ssid, msg->persistent_ssid_len);
 1031|      0|	}
 1032|       |
 1033|    116|	reject = P2P_SC_SUCCESS;
 1034|       |
 1035|       |	/*
 1036|       |	 * End of a legacy P2P PD Request processing, from this point continue
 1037|       |	 * with P2PS one.
 1038|       |	 */
 1039|    116|	if (!msg->adv_id)
  ------------------
  |  Branch (1039:6): [True: 49, False: 67]
  ------------------
 1040|     49|		goto out;
 1041|       |
 1042|     67|	remote_conncap = conncap;
 1043|       |
 1044|     67|	if (!msg->status) {
  ------------------
  |  Branch (1044:6): [True: 2, False: 65]
  ------------------
 1045|      2|		unsigned int forced_freq, pref_freq;
 1046|       |
 1047|      2|		if (!ether_addr_equal(p2p->cfg->dev_addr, msg->adv_mac)) {
  ------------------
  |  Branch (1047:7): [True: 1, False: 1]
  ------------------
 1048|      1|			p2p_dbg(p2p,
 1049|      1|				"P2PS PD adv mac does not match the local one");
 1050|      1|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1051|      1|			goto out;
 1052|      1|		}
 1053|       |
 1054|      1|		p2ps_adv = p2p_service_p2ps_id(p2p, adv_id);
 1055|      1|		if (!p2ps_adv) {
  ------------------
  |  Branch (1055:7): [True: 1, False: 0]
  ------------------
 1056|      1|			p2p_dbg(p2p, "P2PS PD invalid adv_id=0x%X", adv_id);
 1057|      1|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1058|      1|			goto out;
 1059|      1|		}
 1060|      0|		p2p_dbg(p2p, "adv_id: 0x%X, p2ps_adv: %p", adv_id, p2ps_adv);
 1061|       |
 1062|      0|		auto_accept = p2ps_adv->auto_accept;
 1063|      0|		conncap = p2p->cfg->p2ps_group_capability(p2p->cfg->cb_ctx,
 1064|      0|							  conncap, auto_accept,
 1065|      0|							  &forced_freq,
 1066|      0|							  &pref_freq);
 1067|       |
 1068|      0|		p2p_dbg(p2p, "Conncap: local:%d remote:%d result:%d",
 1069|      0|			auto_accept, remote_conncap, conncap);
 1070|       |
 1071|      0|		p2p_prepare_channel(p2p, dev, forced_freq, pref_freq, 0);
 1072|       |
 1073|      0|		resp_fcap.cpt = p2ps_own_preferred_cpt(p2ps_adv->cpt_priority,
 1074|      0|						       req_fcap->cpt);
 1075|       |
 1076|      0|		p2p_dbg(p2p, "cpt: service:0x%x remote:0x%x result:0x%x",
 1077|      0|			p2ps_adv->cpt_mask, req_fcap->cpt, resp_fcap.cpt);
 1078|       |
 1079|      0|		if (!resp_fcap.cpt) {
  ------------------
  |  Branch (1079:7): [True: 0, False: 0]
  ------------------
 1080|      0|			p2p_dbg(p2p,
 1081|      0|				"Incompatible P2PS feature capability CPT bitmask");
 1082|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1083|      0|		} else if (p2ps_adv->config_methods &&
  ------------------
  |  Branch (1083:14): [True: 0, False: 0]
  ------------------
 1084|      0|			   !(msg->wps_config_methods &
  ------------------
  |  Branch (1084:7): [True: 0, False: 0]
  ------------------
 1085|      0|			     p2ps_adv->config_methods)) {
 1086|      0|			p2p_dbg(p2p,
 1087|      0|				"Unsupported config methods in Provision Discovery Request (own=0x%x peer=0x%x)",
 1088|      0|				p2ps_adv->config_methods,
 1089|      0|				msg->wps_config_methods);
 1090|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1091|      0|		} else if (!p2ps_adv->state) {
  ------------------
  |  Branch (1091:14): [True: 0, False: 0]
  ------------------
 1092|      0|			p2p_dbg(p2p, "P2PS state unavailable");
 1093|      0|			reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1094|      0|		} else if (!conncap) {
  ------------------
  |  Branch (1094:14): [True: 0, False: 0]
  ------------------
 1095|      0|			p2p_dbg(p2p, "Conncap resolution failed");
 1096|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1097|      0|		}
 1098|       |
 1099|      0|		if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1099:7): [True: 0, False: 0]
  ------------------
 1100|      0|			p2p_dbg(p2p, "Keypad - always defer");
 1101|      0|			auto_accept = 0;
 1102|      0|		}
 1103|       |
 1104|      0|		if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              		if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   31|      0|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1104:8): [True: 0, False: 0]
  ------------------
 1105|      0|		     msg->persistent_dev) && conncap != P2PS_SETUP_NEW &&
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1105:8): [True: 0, False: 0]
  |  Branch (1105:32): [True: 0, False: 0]
  ------------------
 1106|      0|		    msg->channel_list && msg->channel_list_len &&
  ------------------
  |  Branch (1106:7): [True: 0, False: 0]
  |  Branch (1106:28): [True: 0, False: 0]
  ------------------
 1107|      0|		    p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (1107:7): [True: 0, False: 0]
  ------------------
 1108|      0|					    msg->channel_list,
 1109|      0|					    msg->channel_list_len) < 0) {
 1110|      0|			p2p_dbg(p2p,
 1111|      0|				"No common channels - force deferred flow");
 1112|      0|			auto_accept = 0;
 1113|      0|		}
 1114|       |
 1115|      0|		if (((remote_conncap & P2PS_SETUP_GROUP_OWNER) ||
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1115:8): [True: 0, False: 0]
  ------------------
 1116|      0|		     msg->persistent_dev) && msg->operating_channel) {
  ------------------
  |  Branch (1116:8): [True: 0, False: 0]
  |  Branch (1116:32): [True: 0, False: 0]
  ------------------
 1117|      0|			struct p2p_channels intersect;
 1118|       |
 1119|       |			/*
 1120|       |			 * There are cases where only the operating channel is
 1121|       |			 * provided. This requires saving the channel as the
 1122|       |			 * supported channel list, and verifying that it is
 1123|       |			 * supported.
 1124|       |			 */
 1125|      0|			if (dev->channels.reg_classes == 0 ||
  ------------------
  |  Branch (1125:8): [True: 0, False: 0]
  ------------------
 1126|      0|			    !p2p_channels_includes(&dev->channels,
  ------------------
  |  Branch (1126:8): [True: 0, False: 0]
  ------------------
 1127|      0|						   msg->operating_channel[3],
 1128|      0|						   msg->operating_channel[4])) {
 1129|      0|				struct p2p_channels *ch = &dev->channels;
 1130|       |
 1131|      0|				os_memset(ch, 0, sizeof(*ch));
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1132|      0|				ch->reg_class[0].reg_class =
 1133|      0|					msg->operating_channel[3];
 1134|      0|				ch->reg_class[0].channel[0] =
 1135|      0|					msg->operating_channel[4];
 1136|      0|				ch->reg_class[0].channels = 1;
 1137|      0|				ch->reg_classes = 1;
 1138|      0|			}
 1139|       |
 1140|      0|			p2p_channels_intersect(&p2p->channels, &dev->channels,
 1141|      0|					       &intersect);
 1142|       |
 1143|      0|			if (intersect.reg_classes == 0) {
  ------------------
  |  Branch (1143:8): [True: 0, False: 0]
  ------------------
 1144|      0|				p2p_dbg(p2p,
 1145|      0|					"No common channels - force deferred flow");
 1146|      0|				auto_accept = 0;
 1147|      0|			}
 1148|      0|		}
 1149|       |
 1150|      0|		if (auto_accept || reject != P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1150:7): [True: 0, False: 0]
  |  Branch (1150:22): [True: 0, False: 0]
  ------------------
 1151|      0|			struct p2ps_provision *tmp;
 1152|       |
 1153|      0|			if (p2ps_setup_p2ps_prov(p2p, adv_id, session_id,
  ------------------
  |  Branch (1153:8): [True: 0, False: 0]
  ------------------
 1154|      0|						 msg->wps_config_methods,
 1155|      0|						 session_mac, adv_mac) < 0) {
 1156|      0|				reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1157|      0|				goto out;
 1158|      0|			}
 1159|       |
 1160|      0|			tmp = p2p->p2ps_prov;
 1161|      0|			tmp->force_freq = forced_freq;
 1162|      0|			tmp->pref_freq = pref_freq;
 1163|      0|			if (conncap) {
  ------------------
  |  Branch (1163:8): [True: 0, False: 0]
  ------------------
 1164|      0|				tmp->conncap = conncap;
 1165|      0|				tmp->status = P2P_SC_SUCCESS;
 1166|      0|			} else {
 1167|      0|				tmp->conncap = auto_accept;
 1168|      0|				tmp->status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1169|      0|			}
 1170|       |
 1171|      0|			if (reject != P2P_SC_SUCCESS)
  ------------------
  |  Branch (1171:8): [True: 0, False: 0]
  ------------------
 1172|      0|				goto out;
 1173|      0|		}
 1174|      0|	}
 1175|       |
 1176|     65|	if (!msg->status && !auto_accept &&
  ------------------
  |  Branch (1176:6): [True: 0, False: 65]
  |  Branch (1176:22): [True: 0, False: 0]
  ------------------
 1177|      0|	    (!p2p->p2ps_prov || p2p->p2ps_prov->adv_id != adv_id)) {
  ------------------
  |  Branch (1177:7): [True: 0, False: 0]
  |  Branch (1177:26): [True: 0, False: 0]
  ------------------
 1178|      0|		struct p2ps_provision *tmp;
 1179|       |
 1180|      0|		if (!conncap) {
  ------------------
  |  Branch (1180:7): [True: 0, False: 0]
  ------------------
 1181|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1182|      0|			goto out;
 1183|      0|		}
 1184|       |
 1185|      0|		if (p2ps_setup_p2ps_prov(p2p, adv_id, session_id,
  ------------------
  |  Branch (1185:7): [True: 0, False: 0]
  ------------------
 1186|      0|					 msg->wps_config_methods,
 1187|      0|					 session_mac, adv_mac) < 0) {
 1188|      0|			reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1189|      0|			goto out;
 1190|      0|		}
 1191|      0|		tmp = p2p->p2ps_prov;
 1192|      0|		reject = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
 1193|      0|		tmp->status = reject;
 1194|      0|	}
 1195|       |
 1196|       |	/* Not a P2PS Follow-on PD */
 1197|     65|	if (!msg->status)
  ------------------
  |  Branch (1197:6): [True: 0, False: 65]
  ------------------
 1198|      0|		goto out;
 1199|       |
 1200|     65|	if (*msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1200:6): [True: 57, False: 8]
  |  Branch (1200:22): [True: 11, False: 46]
  ------------------
 1201|     11|		reject = *msg->status;
 1202|     11|		goto out;
 1203|     11|	}
 1204|       |
 1205|     54|	if (*msg->status != P2P_SC_SUCCESS_DEFERRED || !p2p->p2ps_prov)
  ------------------
  |  Branch (1205:6): [True: 8, False: 46]
  |  Branch (1205:49): [True: 46, False: 0]
  ------------------
 1206|     54|		goto out;
 1207|       |
 1208|      0|	if (p2p->p2ps_prov->adv_id != adv_id ||
  ------------------
  |  Branch (1208:6): [True: 0, False: 0]
  ------------------
 1209|      0|	    !ether_addr_equal(p2p->p2ps_prov->adv_mac, msg->adv_mac)) {
  ------------------
  |  Branch (1209:6): [True: 0, False: 0]
  ------------------
 1210|      0|		p2p_dbg(p2p,
 1211|      0|			"P2PS Follow-on PD with mismatch Advertisement ID/MAC");
 1212|      0|		goto out;
 1213|      0|	}
 1214|       |
 1215|      0|	if (p2p->p2ps_prov->session_id != session_id ||
  ------------------
  |  Branch (1215:6): [True: 0, False: 0]
  ------------------
 1216|      0|	    !ether_addr_equal(p2p->p2ps_prov->session_mac, msg->session_mac)) {
  ------------------
  |  Branch (1216:6): [True: 0, False: 0]
  ------------------
 1217|      0|		p2p_dbg(p2p, "P2PS Follow-on PD with mismatch Session ID/MAC");
 1218|      0|		goto out;
 1219|      0|	}
 1220|       |
 1221|      0|	method = p2p->p2ps_prov->method;
 1222|       |
 1223|      0|	conncap = p2p->cfg->p2ps_group_capability(p2p->cfg->cb_ctx,
 1224|      0|						  remote_conncap,
 1225|      0|						  p2p->p2ps_prov->conncap,
 1226|      0|						  &p2p->p2ps_prov->force_freq,
 1227|      0|						  &p2p->p2ps_prov->pref_freq);
 1228|       |
 1229|      0|	resp_fcap.cpt = p2ps_own_preferred_cpt(p2p->p2ps_prov->cpt_priority,
 1230|      0|					       req_fcap->cpt);
 1231|       |
 1232|      0|	p2p_dbg(p2p, "cpt: local:0x%x remote:0x%x result:0x%x",
 1233|      0|		p2p->p2ps_prov->cpt_mask, req_fcap->cpt, resp_fcap.cpt);
 1234|       |
 1235|      0|	p2p_prepare_channel(p2p, dev, p2p->p2ps_prov->force_freq,
 1236|      0|			    p2p->p2ps_prov->pref_freq, 0);
 1237|       |
 1238|       |	/*
 1239|       |	 * Ensure that if we asked for PIN originally, our method is consistent
 1240|       |	 * with original request.
 1241|       |	 */
 1242|      0|	if (method & WPS_CONFIG_DISPLAY)
  ------------------
  |  |  251|      0|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1242:6): [True: 0, False: 0]
  ------------------
 1243|      0|		method = WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
 1244|      0|	else if (method & WPS_CONFIG_KEYPAD)
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1244:11): [True: 0, False: 0]
  ------------------
 1245|      0|		method = WPS_CONFIG_DISPLAY;
  ------------------
  |  |  251|      0|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
 1246|       |
 1247|      0|	if (!conncap || !(msg->wps_config_methods & method)) {
  ------------------
  |  Branch (1247:6): [True: 0, False: 0]
  |  Branch (1247:18): [True: 0, False: 0]
  ------------------
 1248|       |		/*
 1249|       |		 * Reject this "Deferred Accept*
 1250|       |		 * if incompatible conncap or method
 1251|       |		 */
 1252|      0|		reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1253|      0|	} else if (!resp_fcap.cpt) {
  ------------------
  |  Branch (1253:13): [True: 0, False: 0]
  ------------------
 1254|      0|		p2p_dbg(p2p,
 1255|      0|			"Incompatible P2PS feature capability CPT bitmask");
 1256|      0|		reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1257|      0|	} else if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	} else if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   31|      0|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1257:14): [True: 0, False: 0]
  ------------------
 1258|      0|		    msg->persistent_dev) && conncap != P2PS_SETUP_NEW &&
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1258:7): [True: 0, False: 0]
  |  Branch (1258:31): [True: 0, False: 0]
  ------------------
 1259|      0|		   msg->channel_list && msg->channel_list_len &&
  ------------------
  |  Branch (1259:6): [True: 0, False: 0]
  |  Branch (1259:27): [True: 0, False: 0]
  ------------------
 1260|      0|		   p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (1260:6): [True: 0, False: 0]
  ------------------
 1261|      0|					   msg->channel_list,
 1262|      0|					   msg->channel_list_len) < 0) {
 1263|      0|		p2p_dbg(p2p,
 1264|      0|			"No common channels in Follow-On Provision Discovery Request");
 1265|      0|		reject = P2P_SC_FAIL_NO_COMMON_CHANNELS;
 1266|      0|	} else {
 1267|      0|		reject = P2P_SC_SUCCESS;
 1268|      0|	}
 1269|       |
 1270|      0|	dev->oper_freq = 0;
 1271|      0|	if (reject == P2P_SC_SUCCESS || reject == P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1271:6): [True: 0, False: 0]
  |  Branch (1271:34): [True: 0, False: 0]
  ------------------
 1272|      0|		u8 tmp;
 1273|       |
 1274|      0|		if (msg->operating_channel)
  ------------------
  |  Branch (1274:7): [True: 0, False: 0]
  ------------------
 1275|      0|			dev->oper_freq =
 1276|      0|				p2p_channel_to_freq(msg->operating_channel[3],
 1277|      0|						    msg->operating_channel[4]);
 1278|       |
 1279|      0|		if ((conncap & P2PS_SETUP_GROUP_OWNER) &&
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1279:7): [True: 0, False: 0]
  ------------------
 1280|      0|		    p2p_go_select_channel(p2p, dev, &tmp) < 0)
  ------------------
  |  Branch (1280:7): [True: 0, False: 0]
  ------------------
 1281|      0|			reject = P2P_SC_FAIL_NO_COMMON_CHANNELS;
 1282|      0|	}
 1283|       |
 1284|      0|	p2p->p2ps_prov->status = reject;
 1285|      0|	p2p->p2ps_prov->conncap = conncap;
 1286|       |
 1287|    826|out:
 1288|    826|	if (reject == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (1288:6): [True: 103, False: 723]
  ------------------
 1289|    723|	    reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1289:6): [True: 1, False: 722]
  ------------------
 1290|    104|		config_methods = msg->wps_config_methods;
 1291|    722|	else
 1292|    722|		config_methods = 0;
 1293|       |
 1294|       |	/*
 1295|       |	 * Send PD Response for an initial PD Request or for follow-on
 1296|       |	 * PD Request with P2P_SC_SUCCESS_DEFERRED status.
 1297|       |	 */
 1298|    826|	if (!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1298:6): [True: 747, False: 79]
  |  Branch (1298:22): [True: 49, False: 30]
  ------------------
 1299|    796|		resp = p2p_build_prov_disc_resp(p2p, dev, msg->dialog_token,
 1300|    796|						reject, config_methods, adv_id,
 1301|    796|						msg->group_id,
 1302|    796|						msg->group_id_len,
 1303|    796|						msg->persistent_ssid,
 1304|    796|						msg->persistent_ssid_len,
 1305|    796|						(const u8 *) &resp_fcap,
 1306|    796|						sizeof(resp_fcap));
 1307|    796|		if (!resp)
  ------------------
  |  Branch (1307:7): [True: 0, False: 796]
  ------------------
 1308|      0|			return;
 1309|       |
 1310|    796|		p2p_dbg(p2p, "Sending Provision Discovery Response");
 1311|    796|		if (rx_freq > 0)
  ------------------
  |  Branch (1311:7): [True: 796, False: 0]
  ------------------
 1312|    796|			freq = rx_freq;
 1313|      0|		else
 1314|      0|			freq = p2p_channel_to_freq(p2p->cfg->reg_class,
 1315|      0|						   p2p->cfg->channel);
 1316|    796|		if (freq < 0) {
  ------------------
  |  Branch (1316:7): [True: 0, False: 796]
  ------------------
 1317|      0|			p2p_dbg(p2p, "Unknown regulatory class/channel");
 1318|      0|			wpabuf_free(resp);
 1319|      0|			return;
 1320|      0|		}
 1321|    796|		p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
 1322|    796|		if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (1322:7): [True: 0, False: 796]
  ------------------
 1323|    796|				    p2p->cfg->dev_addr,
 1324|    796|				    wpabuf_head(resp), wpabuf_len(resp),
 1325|    796|				    50) < 0)
 1326|      0|			p2p_dbg(p2p, "Failed to send Action frame");
 1327|    796|		else
 1328|    796|			p2p->send_action_in_progress = 1;
 1329|       |
 1330|    796|		wpabuf_free(resp);
 1331|    796|	}
 1332|       |
 1333|    826|	if (!dev)
  ------------------
  |  Branch (1333:6): [True: 671, False: 155]
  ------------------
 1334|    671|		return;
 1335|       |
 1336|    155|	freq = 0;
 1337|    155|	if (reject == P2P_SC_SUCCESS && conncap == P2PS_SETUP_GROUP_OWNER) {
  ------------------
  |  |   32|    103|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|    103|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1337:6): [True: 103, False: 52]
  |  Branch (1337:34): [True: 1, False: 102]
  ------------------
 1338|      1|		freq = p2p_channel_to_freq(p2p->op_reg_class,
 1339|      1|					   p2p->op_channel);
 1340|      1|		if (freq < 0)
  ------------------
  |  Branch (1340:7): [True: 1, False: 0]
  ------------------
 1341|      1|			freq = 0;
 1342|      1|	}
 1343|       |
 1344|    155|	if (!p2p->cfg->p2ps_prov_complete) {
  ------------------
  |  Branch (1344:6): [True: 155, False: 0]
  ------------------
 1345|       |		/* Don't emit anything */
 1346|    155|	} else if (msg->status && *msg->status != P2P_SC_SUCCESS &&
  ------------------
  |  Branch (1346:13): [True: 0, False: 0]
  |  Branch (1346:28): [True: 0, False: 0]
  ------------------
 1347|      0|		   *msg->status != P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1347:6): [True: 0, False: 0]
  ------------------
 1348|      0|		reject = *msg->status;
 1349|      0|		p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx, reject,
 1350|      0|					     sa, adv_mac, session_mac,
 1351|      0|					     NULL, adv_id, session_id,
 1352|      0|					     0, 0, msg->persistent_ssid,
 1353|      0|					     msg->persistent_ssid_len,
 1354|      0|					     0, 0, NULL, NULL, 0, freq,
 1355|      0|					     NULL, 0);
 1356|      0|	} else if (msg->status && *msg->status == P2P_SC_SUCCESS_DEFERRED &&
  ------------------
  |  Branch (1356:13): [True: 0, False: 0]
  |  Branch (1356:28): [True: 0, False: 0]
  ------------------
 1357|      0|		   p2p->p2ps_prov) {
  ------------------
  |  Branch (1357:6): [True: 0, False: 0]
  ------------------
 1358|      0|		p2p->p2ps_prov->status = reject;
 1359|      0|		p2p->p2ps_prov->conncap = conncap;
 1360|       |
 1361|      0|		if (reject != P2P_SC_SUCCESS)
  ------------------
  |  Branch (1361:7): [True: 0, False: 0]
  ------------------
 1362|      0|			p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx, reject,
 1363|      0|						     sa, adv_mac, session_mac,
 1364|      0|						     NULL, adv_id,
 1365|      0|						     session_id, conncap, 0,
 1366|      0|						     msg->persistent_ssid,
 1367|      0|						     msg->persistent_ssid_len,
 1368|      0|						     0, 0, NULL, NULL, 0, freq,
 1369|      0|						     NULL, 0);
 1370|      0|		else
 1371|      0|			p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx,
 1372|      0|						     *msg->status,
 1373|      0|						     sa, adv_mac, session_mac,
 1374|      0|						     group_mac, adv_id,
 1375|      0|						     session_id, conncap,
 1376|      0|						     passwd_id,
 1377|      0|						     msg->persistent_ssid,
 1378|      0|						     msg->persistent_ssid_len,
 1379|      0|						     0, 0, NULL,
 1380|      0|						     (const u8 *) &resp_fcap,
 1381|      0|						     sizeof(resp_fcap), freq,
 1382|      0|						     NULL, 0);
 1383|      0|	} else if (msg->status && p2p->p2ps_prov) {
  ------------------
  |  Branch (1383:13): [True: 0, False: 0]
  |  Branch (1383:28): [True: 0, False: 0]
  ------------------
 1384|      0|		p2p->p2ps_prov->status = P2P_SC_SUCCESS;
 1385|      0|		p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx, *msg->status, sa,
 1386|      0|					     adv_mac, session_mac, group_mac,
 1387|      0|					     adv_id, session_id, conncap,
 1388|      0|					     passwd_id,
 1389|      0|					     msg->persistent_ssid,
 1390|      0|					     msg->persistent_ssid_len,
 1391|      0|					     0, 0, NULL,
 1392|      0|					     (const u8 *) &resp_fcap,
 1393|      0|					     sizeof(resp_fcap), freq, NULL, 0);
 1394|      0|	} else if (msg->status) {
  ------------------
  |  Branch (1394:13): [True: 0, False: 0]
  ------------------
 1395|      0|	} else if (auto_accept && reject == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1395:13): [True: 0, False: 0]
  |  Branch (1395:28): [True: 0, False: 0]
  ------------------
 1396|      0|		p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx, P2P_SC_SUCCESS,
 1397|      0|					     sa, adv_mac, session_mac,
 1398|      0|					     group_mac, adv_id, session_id,
 1399|      0|					     conncap, passwd_id,
 1400|      0|					     msg->persistent_ssid,
 1401|      0|					     msg->persistent_ssid_len,
 1402|      0|					     0, 0, NULL,
 1403|      0|					     (const u8 *) &resp_fcap,
 1404|      0|					     sizeof(resp_fcap), freq,
 1405|      0|					     msg->group_id ?
  ------------------
  |  Branch (1405:11): [True: 0, False: 0]
  ------------------
 1406|      0|					     msg->group_id + ETH_ALEN : NULL,
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
 1407|      0|					     msg->group_id ?
  ------------------
  |  Branch (1407:11): [True: 0, False: 0]
  ------------------
 1408|      0|					     msg->group_id_len - ETH_ALEN : 0);
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
 1409|      0|	} else if (reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
  ------------------
  |  Branch (1409:13): [True: 0, False: 0]
  ------------------
 1410|      0|		   (!msg->session_info || !msg->session_info_len)) {
  ------------------
  |  Branch (1410:7): [True: 0, False: 0]
  |  Branch (1410:29): [True: 0, False: 0]
  ------------------
 1411|      0|		p2p->p2ps_prov->method = msg->wps_config_methods;
 1412|       |
 1413|      0|		p2p->cfg->p2ps_prov_complete(p2p->cfg->cb_ctx, P2P_SC_SUCCESS,
 1414|      0|					     sa, adv_mac, session_mac,
 1415|      0|					     group_mac, adv_id, session_id,
 1416|      0|					     conncap, passwd_id,
 1417|      0|					     msg->persistent_ssid,
 1418|      0|					     msg->persistent_ssid_len,
 1419|      0|					     0, 1, NULL,
 1420|      0|					     (const u8 *) &resp_fcap,
 1421|      0|					     sizeof(resp_fcap), freq, NULL, 0);
 1422|      0|	} else if (reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) {
  ------------------
  |  Branch (1422:13): [True: 0, False: 0]
  ------------------
 1423|      0|		size_t buf_len = msg->session_info_len;
 1424|      0|		char *buf = os_malloc(2 * buf_len + 1);
  ------------------
  |  |  505|      0|#define os_malloc(s) malloc((s))
  ------------------
 1425|       |
 1426|      0|		if (buf) {
  ------------------
  |  Branch (1426:7): [True: 0, False: 0]
  ------------------
 1427|      0|			p2p->p2ps_prov->method = msg->wps_config_methods;
 1428|       |
 1429|      0|			utf8_escape((char *) msg->session_info, buf_len,
 1430|      0|				    buf, 2 * buf_len + 1);
 1431|       |
 1432|      0|			p2p->cfg->p2ps_prov_complete(
 1433|      0|				p2p->cfg->cb_ctx, P2P_SC_SUCCESS, sa,
 1434|      0|				adv_mac, session_mac, group_mac, adv_id,
 1435|      0|				session_id, conncap, passwd_id,
 1436|      0|				msg->persistent_ssid, msg->persistent_ssid_len,
 1437|      0|				0, 1, buf,
 1438|      0|				(const u8 *) &resp_fcap, sizeof(resp_fcap),
 1439|      0|				freq, NULL, 0);
 1440|       |
 1441|      0|			os_free(buf);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
 1442|      0|		}
 1443|      0|	}
 1444|       |
 1445|       |	/*
 1446|       |	 * prov_disc_req callback is used to generate P2P-PROV-DISC-ENTER-PIN,
 1447|       |	 * P2P-PROV-DISC-SHOW-PIN, and P2P-PROV-DISC-PBC-REQ events.
 1448|       |	 * Call it either on legacy P2P PD or on P2PS PD only if we need to
 1449|       |	 * enter/show PIN.
 1450|       |	 *
 1451|       |	 * The callback is called in the following cases:
 1452|       |	 * 1. Legacy P2P PD request, response status SUCCESS
 1453|       |	 * 2. P2PS advertiser, method: DISPLAY, autoaccept: TRUE,
 1454|       |	 *    response status: SUCCESS
 1455|       |	 * 3. P2PS advertiser, method  DISPLAY, autoaccept: FALSE,
 1456|       |	 *    response status: INFO_CURRENTLY_UNAVAILABLE
 1457|       |	 * 4. P2PS advertiser, method: KEYPAD, autoaccept==any,
 1458|       |	 *    response status: INFO_CURRENTLY_UNAVAILABLE
 1459|       |	 * 5. P2PS follow-on with SUCCESS_DEFERRED,
 1460|       |	 *    advertiser role: DISPLAY, autoaccept: FALSE,
 1461|       |	 *    seeker: KEYPAD, response status: SUCCESS
 1462|       |	 */
 1463|    155|	if (p2p->cfg->prov_disc_req &&
  ------------------
  |  Branch (1463:6): [True: 0, False: 155]
  ------------------
 1464|      0|	    ((reject == P2P_SC_SUCCESS && !msg->adv_id) ||
  ------------------
  |  Branch (1464:8): [True: 0, False: 0]
  |  Branch (1464:36): [True: 0, False: 0]
  ------------------
 1465|      0|	     (!msg->status &&
  ------------------
  |  Branch (1465:8): [True: 0, False: 0]
  ------------------
 1466|      0|	     (reject == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (1466:8): [True: 0, False: 0]
  ------------------
 1467|      0|	      reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) &&
  ------------------
  |  Branch (1467:8): [True: 0, False: 0]
  ------------------
 1468|      0|	      passwd_id == DEV_PW_USER_SPECIFIED) ||
  ------------------
  |  Branch (1468:8): [True: 0, False: 0]
  ------------------
 1469|      0|	     (!msg->status &&
  ------------------
  |  Branch (1469:8): [True: 0, False: 0]
  ------------------
 1470|      0|	      reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
  ------------------
  |  Branch (1470:8): [True: 0, False: 0]
  ------------------
 1471|      0|	      passwd_id == DEV_PW_REGISTRAR_SPECIFIED) ||
  ------------------
  |  Branch (1471:8): [True: 0, False: 0]
  ------------------
 1472|      0|	     (reject == P2P_SC_SUCCESS &&
  ------------------
  |  Branch (1472:8): [True: 0, False: 0]
  ------------------
 1473|      0|	      msg->status && *msg->status == P2P_SC_SUCCESS_DEFERRED &&
  ------------------
  |  Branch (1473:8): [True: 0, False: 0]
  |  Branch (1473:23): [True: 0, False: 0]
  ------------------
 1474|      0|	       passwd_id == DEV_PW_REGISTRAR_SPECIFIED))) {
  ------------------
  |  Branch (1474:9): [True: 0, False: 0]
  ------------------
 1475|      0|		const u8 *dev_addr = sa;
 1476|       |
 1477|      0|		if (msg->p2p_device_addr)
  ------------------
  |  Branch (1477:7): [True: 0, False: 0]
  ------------------
 1478|      0|			dev_addr = msg->p2p_device_addr;
 1479|      0|		p2p->cfg->prov_disc_req(p2p->cfg->cb_ctx, sa,
 1480|      0|					msg->wps_config_methods,
 1481|      0|					dev_addr, msg->pri_dev_type,
 1482|      0|					msg->device_name, msg->config_methods,
 1483|      0|					msg->capability ? msg->capability[0] :
  ------------------
  |  Branch (1483:6): [True: 0, False: 0]
  ------------------
 1484|      0|					0,
 1485|      0|					msg->capability ? msg->capability[1] :
  ------------------
  |  Branch (1485:6): [True: 0, False: 0]
  ------------------
 1486|      0|					0,
 1487|      0|					msg->group_id, msg->group_id_len);
 1488|      0|	}
 1489|       |
 1490|    155|	if (reject != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1490:6): [True: 154, False: 1]
  ------------------
 1491|    154|		p2ps_prov_free(p2p);
 1492|       |
 1493|    155|	if (reject == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1493:6): [True: 103, False: 52]
  ------------------
 1494|    103|		switch (config_methods) {
 1495|      1|		case WPS_CONFIG_DISPLAY:
  ------------------
  |  |  251|      1|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1495:3): [True: 1, False: 102]
  ------------------
 1496|      1|			dev->wps_prov_info = WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|      1|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
 1497|      1|			break;
 1498|      2|		case WPS_CONFIG_KEYPAD:
  ------------------
  |  |  256|      2|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1498:3): [True: 2, False: 101]
  ------------------
 1499|      2|			dev->wps_prov_info = WPS_CONFIG_DISPLAY;
  ------------------
  |  |  251|      2|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
 1500|      2|			break;
 1501|      1|		case WPS_CONFIG_PUSHBUTTON:
  ------------------
  |  |  255|      1|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  |  Branch (1501:3): [True: 1, False: 102]
  ------------------
 1502|      1|			dev->wps_prov_info = WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|      1|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
 1503|      1|			break;
 1504|      8|		case WPS_CONFIG_P2PS:
  ------------------
  |  |  259|      8|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1504:3): [True: 8, False: 95]
  ------------------
 1505|      8|			dev->wps_prov_info = WPS_CONFIG_P2PS;
  ------------------
  |  |  259|      8|#define WPS_CONFIG_P2PS 0x1000
  ------------------
 1506|      8|			break;
 1507|     91|		default:
  ------------------
  |  Branch (1507:3): [True: 91, False: 12]
  ------------------
 1508|     91|			dev->wps_prov_info = 0;
 1509|     91|			break;
 1510|    103|		}
 1511|       |
 1512|    103|		if (msg->intended_addr)
  ------------------
  |  Branch (1512:7): [True: 1, False: 102]
  ------------------
 1513|      1|			os_memcpy(dev->interface_addr, msg->intended_addr,
  ------------------
  |  |  523|      1|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1514|    103|				  ETH_ALEN);
 1515|    103|	}
 1516|    155|}
p2p_pd.c:p2ps_validate_pd_req:
  552|     96|{
  553|     96|	u8 group_id = 0;
  554|     96|	u8 intended_addr = 0;
  555|     96|	u8 operating_channel = 0;
  556|     96|	u8 channel_list = 0;
  557|     96|	u8 config_timeout = 0;
  558|     96|	u8 listen_channel = 0;
  559|       |
  560|     96|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  561|     96|do { \
  562|     96|	if ((_val) && !msg->_attr) { \
  563|     96|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  564|     96|		return -1; \
  565|     96|	} \
  566|     96|} while (0)
  567|       |
  568|     96|	P2PS_PD_REQ_CHECK(1, adv_id);
  ------------------
  |  |  560|     96|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     96|do { \
  |  |  562|     96|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 96, Folded]
  |  |  |  Branch (562:16): [True: 0, False: 96]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     96|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 96]
  |  |  ------------------
  ------------------
  569|     96|	P2PS_PD_REQ_CHECK(1, session_id);
  ------------------
  |  |  560|     96|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     96|do { \
  |  |  562|     96|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 96, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 95]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     96|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 95]
  |  |  ------------------
  ------------------
  570|     95|	P2PS_PD_REQ_CHECK(1, session_mac);
  ------------------
  |  |  560|     95|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     95|do { \
  |  |  562|     95|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 95, Folded]
  |  |  |  Branch (562:16): [True: 0, False: 95]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     95|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 95]
  |  |  ------------------
  ------------------
  571|     95|	P2PS_PD_REQ_CHECK(1, adv_mac);
  ------------------
  |  |  560|     95|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     95|do { \
  |  |  562|     95|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 95, Folded]
  |  |  |  Branch (562:16): [True: 0, False: 95]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     95|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 95]
  |  |  ------------------
  ------------------
  572|     95|	P2PS_PD_REQ_CHECK(1, capability);
  ------------------
  |  |  560|     95|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     95|do { \
  |  |  562|     95|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 95, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 94]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     95|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 94]
  |  |  ------------------
  ------------------
  573|     94|	P2PS_PD_REQ_CHECK(1, p2p_device_info);
  ------------------
  |  |  560|     94|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     94|do { \
  |  |  562|     94|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 94, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 93]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     94|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 93]
  |  |  ------------------
  ------------------
  574|     93|	P2PS_PD_REQ_CHECK(1, feature_cap);
  ------------------
  |  |  560|     93|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     93|do { \
  |  |  562|     93|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 93, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 92]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     93|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 92]
  |  |  ------------------
  ------------------
  575|       |
  576|       |	/*
  577|       |	 * We don't need to check Connection Capability, Persistent Group,
  578|       |	 * and related attributes for follow-on PD Request with a status
  579|       |	 * other than SUCCESS_DEFERRED.
  580|       |	 */
  581|     92|	if (msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED)
  ------------------
  |  Branch (581:6): [True: 67, False: 25]
  |  Branch (581:21): [True: 19, False: 48]
  ------------------
  582|     19|		return 0;
  583|       |
  584|     73|	P2PS_PD_REQ_CHECK(1, conn_cap);
  ------------------
  |  |  560|     73|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     73|do { \
  |  |  562|     73|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 73, Folded]
  |  |  |  Branch (562:16): [True: 2, False: 71]
  |  |  ------------------
  |  |  563|      2|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      2|		return -1; \
  |  |  565|      2|	} \
  |  |  566|     73|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 71]
  |  |  ------------------
  ------------------
  585|       |
  586|       |	/*
  587|       |	 * Note 1: A feature capability attribute structure can be changed
  588|       |	 * in the future. The assumption is that such modifications are
  589|       |	 * backward compatible, therefore we allow processing of msg.feature_cap
  590|       |	 * exceeding the size of the p2ps_feature_capab structure.
  591|       |	 * Note 2: Verification of msg.feature_cap_len below has to be changed
  592|       |	 * to allow 2 byte feature capability processing if
  593|       |	 * struct p2ps_feature_capab is extended to include additional fields
  594|       |	 * and it affects the structure size.
  595|       |	 */
  596|     71|	if (msg->feature_cap_len < sizeof(struct p2ps_feature_capab)) {
  ------------------
  |  Branch (596:6): [True: 1, False: 70]
  ------------------
  597|      1|		p2p_dbg(p2p, "P2PS: Invalid feature capability len");
  598|      1|		return -1;
  599|      1|	}
  600|       |
  601|     70|	switch (*msg->conn_cap) {
  602|      5|	case P2PS_SETUP_NEW:
  ------------------
  |  |   30|      5|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      5|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (602:2): [True: 5, False: 65]
  ------------------
  603|      5|		group_id = 1;
  604|      5|		intended_addr = 1;
  605|      5|		operating_channel = 1;
  606|      5|		channel_list = 1;
  607|      5|		config_timeout = 1;
  608|      5|		listen_channel = 1;
  609|      5|		break;
  610|     58|	case P2PS_SETUP_CLIENT:
  ------------------
  |  |   31|     58|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|     58|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (610:2): [True: 58, False: 12]
  ------------------
  611|     58|		channel_list = 1;
  612|     58|		listen_channel = 1;
  613|     58|		break;
  614|      3|	case P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   32|      3|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      3|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (614:2): [True: 3, False: 67]
  ------------------
  615|      3|		group_id = 1;
  616|      3|		intended_addr = 1;
  617|      3|		operating_channel = 1;
  618|      3|		break;
  619|      1|	case P2PS_SETUP_NEW | P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   30|      1|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	case P2PS_SETUP_NEW | P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   32|      1|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (619:2): [True: 1, False: 69]
  ------------------
  620|      1|		group_id = 1;
  621|      1|		operating_channel = 1;
  622|      1|		intended_addr = 1;
  623|      1|		channel_list = 1;
  624|      1|		config_timeout = 1;
  625|      1|		break;
  626|      2|	case P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   31|      2|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	case P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   32|      2|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (626:2): [True: 2, False: 68]
  ------------------
  627|      2|		group_id = 1;
  628|      2|		intended_addr = 1;
  629|      2|		operating_channel = 1;
  630|      2|		channel_list = 1;
  631|      2|		config_timeout = 1;
  632|      2|		break;
  633|      1|	default:
  ------------------
  |  Branch (633:2): [True: 1, False: 69]
  ------------------
  634|      1|		p2p_dbg(p2p, "Invalid P2PS PD connection capability");
  635|      1|		return -1;
  636|     70|	}
  637|       |
  638|     69|	if (msg->persistent_dev) {
  ------------------
  |  Branch (638:6): [True: 5, False: 64]
  ------------------
  639|      5|		channel_list = 1;
  640|      5|		config_timeout = 1;
  641|      5|		if (ether_addr_equal(msg->persistent_dev, addr)) {
  ------------------
  |  Branch (641:7): [True: 1, False: 4]
  ------------------
  642|      1|			intended_addr = 1;
  643|      1|			operating_channel = 1;
  644|      1|		}
  645|      5|	}
  646|       |
  647|     69|	P2PS_PD_REQ_CHECK(group_id, group_id);
  ------------------
  |  |  560|     69|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     69|do { \
  |  |  562|     69|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 11, False: 58]
  |  |  |  Branch (562:16): [True: 8, False: 3]
  |  |  ------------------
  |  |  563|      8|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      8|		return -1; \
  |  |  565|      8|	} \
  |  |  566|     69|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 61]
  |  |  ------------------
  ------------------
  648|     61|	P2PS_PD_REQ_CHECK(intended_addr, intended_addr);
  ------------------
  |  |  560|     61|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     61|do { \
  |  |  562|     61|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 3, False: 58]
  |  |  |  Branch (562:16): [True: 1, False: 2]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     61|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 60]
  |  |  ------------------
  ------------------
  649|     60|	P2PS_PD_REQ_CHECK(operating_channel, operating_channel);
  ------------------
  |  |  560|     60|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     60|do { \
  |  |  562|     60|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 58]
  |  |  |  Branch (562:16): [True: 1, False: 1]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     60|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 59]
  |  |  ------------------
  ------------------
  650|     59|	P2PS_PD_REQ_CHECK(channel_list, channel_list);
  ------------------
  |  |  560|     59|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     59|do { \
  |  |  562|     59|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 58, False: 1]
  |  |  |  Branch (562:16): [True: 1, False: 57]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     59|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 58]
  |  |  ------------------
  ------------------
  651|     58|	P2PS_PD_REQ_CHECK(config_timeout, config_timeout);
  ------------------
  |  |  560|     58|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     58|do { \
  |  |  562|     58|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 56]
  |  |  |  Branch (562:16): [True: 1, False: 1]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     58|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 57]
  |  |  ------------------
  ------------------
  652|     57|	P2PS_PD_REQ_CHECK(listen_channel, listen_channel);
  ------------------
  |  |  560|     57|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     57|do { \
  |  |  562|     57|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 56, False: 1]
  |  |  |  Branch (562:16): [True: 3, False: 53]
  |  |  ------------------
  |  |  563|      3|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      3|		return -1; \
  |  |  565|      3|	} \
  |  |  566|     57|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 54]
  |  |  ------------------
  ------------------
  653|       |
  654|     54|#undef P2PS_PD_REQ_CHECK
  655|       |
  656|     54|	return 0;
  657|     57|}
p2p_pd.c:p2p_build_prov_disc_resp:
  358|    796|{
  359|    796|	struct wpabuf *buf;
  360|    796|	size_t extra = 0;
  361|    796|	int persist = 0;
  362|       |
  363|    796|#ifdef CONFIG_WIFI_DISPLAY
  364|    796|	struct wpabuf *wfd_ie = p2p->wfd_ie_prov_disc_resp;
  365|    796|	if (wfd_ie && group_id) {
  ------------------
  |  Branch (365:6): [True: 0, False: 796]
  |  Branch (365:16): [True: 0, False: 0]
  ------------------
  366|      0|		size_t i;
  367|      0|		for (i = 0; i < p2p->num_groups; i++) {
  ------------------
  |  Branch (367:15): [True: 0, False: 0]
  ------------------
  368|      0|			struct p2p_group *g = p2p->groups[i];
  369|      0|			struct wpabuf *ie;
  370|      0|			if (!p2p_group_is_group_id_match(g, group_id,
  ------------------
  |  Branch (370:8): [True: 0, False: 0]
  ------------------
  371|      0|							 group_id_len))
  372|      0|				continue;
  373|      0|			ie = p2p_group_get_wfd_ie(g);
  374|      0|			if (ie) {
  ------------------
  |  Branch (374:8): [True: 0, False: 0]
  ------------------
  375|      0|				wfd_ie = ie;
  376|      0|				break;
  377|      0|			}
  378|      0|		}
  379|      0|	}
  380|    796|	if (wfd_ie)
  ------------------
  |  Branch (380:6): [True: 0, False: 796]
  ------------------
  381|      0|		extra = wpabuf_len(wfd_ie);
  382|    796|#endif /* CONFIG_WIFI_DISPLAY */
  383|       |
  384|    796|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (384:6): [True: 0, False: 796]
  |  Branch (384:26): [True: 0, False: 0]
  ------------------
  385|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  386|       |
  387|    796|	buf = wpabuf_alloc(1000 + extra);
  388|    796|	if (buf == NULL)
  ------------------
  |  Branch (388:6): [True: 0, False: 796]
  ------------------
  389|      0|		return NULL;
  390|       |
  391|    796|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  392|       |
  393|       |	/* Add P2P IE for P2PS */
  394|    796|	if (p2p->p2ps_prov && p2p->p2ps_prov->adv_id == adv_id) {
  ------------------
  |  Branch (394:6): [True: 0, False: 796]
  |  Branch (394:24): [True: 0, False: 0]
  ------------------
  395|      0|		u8 *len = p2p_buf_add_ie_hdr(buf);
  396|      0|		struct p2ps_provision *prov = p2p->p2ps_prov;
  397|      0|		u8 group_capab;
  398|      0|		u8 conncap = 0;
  399|       |
  400|      0|		if (status == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (400:7): [True: 0, False: 0]
  ------------------
  401|      0|		    status == P2P_SC_SUCCESS_DEFERRED)
  ------------------
  |  Branch (401:7): [True: 0, False: 0]
  ------------------
  402|      0|			conncap = prov->conncap;
  403|       |
  404|      0|		if (!status && prov->status != -1)
  ------------------
  |  Branch (404:7): [True: 0, False: 0]
  |  Branch (404:18): [True: 0, False: 0]
  ------------------
  405|      0|			status = prov->status;
  406|       |
  407|      0|		p2p_buf_add_status(buf, status);
  408|      0|		group_capab = P2P_GROUP_CAPAB_PERSISTENT_GROUP |
  ------------------
  |  | 1920|      0|#define P2P_GROUP_CAPAB_PERSISTENT_GROUP BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  409|      0|			P2P_GROUP_CAPAB_PERSISTENT_RECONN;
  ------------------
  |  | 1924|      0|#define P2P_GROUP_CAPAB_PERSISTENT_RECONN BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  410|      0|		if (p2p->cross_connect)
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|      0|			group_capab |= P2P_GROUP_CAPAB_CROSS_CONN;
  ------------------
  |  | 1923|      0|#define P2P_GROUP_CAPAB_CROSS_CONN BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  412|      0|		if (p2p->cfg->p2p_intra_bss)
  ------------------
  |  Branch (412:7): [True: 0, False: 0]
  ------------------
  413|      0|			group_capab |= P2P_GROUP_CAPAB_INTRA_BSS_DIST;
  ------------------
  |  | 1922|      0|#define P2P_GROUP_CAPAB_INTRA_BSS_DIST BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  414|      0|		p2p_buf_add_capability(buf, p2p->dev_capab &
  415|      0|				       ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY,
  ------------------
  |  | 1911|      0|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  416|      0|				       group_capab);
  417|      0|		p2p_buf_add_device_info(buf, p2p, NULL);
  418|       |
  419|      0|		if (persist_ssid && p2p->cfg->get_persistent_group && dev &&
  ------------------
  |  Branch (419:7): [True: 0, False: 0]
  |  Branch (419:23): [True: 0, False: 0]
  |  Branch (419:57): [True: 0, False: 0]
  ------------------
  420|      0|		    (status == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (420:8): [True: 0, False: 0]
  ------------------
  421|      0|		     status == P2P_SC_SUCCESS_DEFERRED)) {
  ------------------
  |  Branch (421:8): [True: 0, False: 0]
  ------------------
  422|      0|			u8 ssid[SSID_MAX_LEN];
  423|      0|			size_t ssid_len;
  424|      0|			u8 go_dev_addr[ETH_ALEN];
  425|      0|			u8 intended_addr[ETH_ALEN];
  426|       |
  427|      0|			persist = p2p->cfg->get_persistent_group(
  428|      0|				p2p->cfg->cb_ctx,
  429|      0|				dev->info.p2p_device_addr,
  430|      0|				persist_ssid, persist_ssid_len, go_dev_addr,
  431|      0|				ssid, &ssid_len, intended_addr);
  432|      0|			if (persist) {
  ------------------
  |  Branch (432:8): [True: 0, False: 0]
  ------------------
  433|      0|				p2p_buf_add_persistent_group_info(
  434|      0|					buf, go_dev_addr, ssid, ssid_len);
  435|      0|				if (!is_zero_ether_addr(intended_addr))
  ------------------
  |  Branch (435:9): [True: 0, False: 0]
  ------------------
  436|      0|					p2p_buf_add_intended_addr(
  437|      0|						buf, intended_addr);
  438|      0|			}
  439|      0|		}
  440|       |
  441|      0|		if (!persist && (conncap & P2PS_SETUP_GROUP_OWNER))
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (441:7): [True: 0, False: 0]
  |  Branch (441:19): [True: 0, False: 0]
  ------------------
  442|      0|			p2ps_add_new_group_info(p2p, dev, buf);
  443|       |
  444|       |		/* Add Operating Channel if conncap indicates GO */
  445|      0|		if (persist || (conncap & P2PS_SETUP_GROUP_OWNER)) {
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (445:7): [True: 0, False: 0]
  |  Branch (445:18): [True: 0, False: 0]
  ------------------
  446|      0|			if (p2p->op_reg_class && p2p->op_channel)
  ------------------
  |  Branch (446:8): [True: 0, False: 0]
  |  Branch (446:29): [True: 0, False: 0]
  ------------------
  447|      0|				p2p_buf_add_operating_channel(
  448|      0|					buf, p2p->cfg->country,
  449|      0|					p2p->op_reg_class,
  450|      0|					p2p->op_channel);
  451|      0|			else
  452|      0|				p2p_buf_add_operating_channel(
  453|      0|					buf, p2p->cfg->country,
  454|      0|					p2p->cfg->op_reg_class,
  455|      0|					p2p->cfg->op_channel);
  456|      0|		}
  457|       |
  458|      0|		if (persist ||
  ------------------
  |  Branch (458:7): [True: 0, False: 0]
  ------------------
  459|      0|		    (conncap & (P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER))) {
  ------------------
  |  |   31|      0|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              		    (conncap & (P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER))) {
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (459:7): [True: 0, False: 0]
  ------------------
  460|      0|			bool is_6ghz_capab;
  461|       |
  462|      0|			is_6ghz_capab = is_p2p_6ghz_capable(p2p) && dev &&
  ------------------
  |  Branch (462:20): [True: 0, False: 0]
  |  Branch (462:48): [True: 0, False: 0]
  ------------------
  463|      0|				p2p_is_peer_6ghz_capab(
  ------------------
  |  Branch (463:5): [True: 0, False: 0]
  ------------------
  464|      0|					p2p, dev->info.p2p_device_addr);
  465|      0|			p2p_buf_add_channel_list(buf, p2p->cfg->country,
  466|      0|						 &p2p->channels, is_6ghz_capab);
  467|      0|		}
  468|       |
  469|      0|		if (!persist && conncap)
  ------------------
  |  Branch (469:7): [True: 0, False: 0]
  |  Branch (469:19): [True: 0, False: 0]
  ------------------
  470|      0|			p2p_buf_add_connection_capability(buf, conncap);
  471|       |
  472|      0|		p2p_buf_add_advertisement_id(buf, adv_id, prov->adv_mac);
  473|       |
  474|      0|		if (persist ||
  ------------------
  |  Branch (474:7): [True: 0, False: 0]
  ------------------
  475|      0|		    (conncap & (P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER)))
  ------------------
  |  |   31|      0|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              		    (conncap & (P2PS_SETUP_CLIENT | P2PS_SETUP_GROUP_OWNER)))
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (475:7): [True: 0, False: 0]
  ------------------
  476|      0|			p2p_buf_add_config_timeout(buf, p2p->go_timeout,
  477|      0|						   p2p->client_timeout);
  478|       |
  479|      0|		p2p_buf_add_session_id(buf, prov->session_id,
  480|      0|				       prov->session_mac);
  481|       |
  482|      0|		p2p_buf_add_feature_capability(buf, fcap_len, fcap);
  483|      0|		p2p_buf_update_ie_hdr(buf, len);
  484|    796|	} else if (status != P2P_SC_SUCCESS || adv_id) {
  ------------------
  |  Branch (484:13): [True: 701, False: 95]
  |  Branch (484:41): [True: 46, False: 49]
  ------------------
  485|    747|		u8 *len = p2p_buf_add_ie_hdr(buf);
  486|       |
  487|    747|		p2p_buf_add_status(buf, status);
  488|       |
  489|    747|		if (p2p->p2ps_prov)
  ------------------
  |  Branch (489:7): [True: 0, False: 747]
  ------------------
  490|      0|			p2p_buf_add_advertisement_id(buf, adv_id,
  491|      0|						     p2p->p2ps_prov->adv_mac);
  492|       |
  493|    747|		p2p_buf_update_ie_hdr(buf, len);
  494|    747|	}
  495|       |
  496|       |	/* WPS IE with Config Methods attribute */
  497|    796|	p2p_build_wps_ie_config_methods(buf, config_methods);
  498|       |
  499|    796|#ifdef CONFIG_WIFI_DISPLAY
  500|    796|	if (wfd_ie)
  ------------------
  |  Branch (500:6): [True: 0, False: 796]
  ------------------
  501|      0|		wpabuf_put_buf(buf, wfd_ie);
  502|    796|#endif /* CONFIG_WIFI_DISPLAY */
  503|       |
  504|    796|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (504:6): [True: 0, False: 796]
  |  Branch (504:26): [True: 0, False: 0]
  ------------------
  505|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  506|       |
  507|    796|	return buf;
  508|    796|}
p2p_pd.c:p2p_build_wps_ie_config_methods:
   28|    796|{
   29|    796|	u8 *len;
   30|    796|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|    796|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   31|    796|	len = wpabuf_put(buf, 1);
   32|    796|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|    796|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
   33|       |
   34|       |	/* Config Methods */
   35|    796|	wpabuf_put_be16(buf, ATTR_CONFIG_METHODS);
   36|    796|	wpabuf_put_be16(buf, 2);
   37|    796|	wpabuf_put_be16(buf, config_methods);
   38|       |
   39|    796|	p2p_buf_update_ie_hdr(buf, len);
   40|    796|}
p2p_pd.c:p2p_process_prov_disc_bootstrap_resp:
 1640|      5|{
 1641|      5|	struct p2p_device *dev;
 1642|      5|	enum p2p_status_code status = P2P_SC_SUCCESS;
 1643|      5|	size_t cookie_len = 0;
 1644|      5|	const u8 *pos, *cookie;
 1645|      5|	u16 comeback_after;
 1646|      5|	u16 bootstrap = 0;
 1647|       |
 1648|       |	/* Parse the P2P status present */
 1649|      5|	if (msg->status)
  ------------------
  |  Branch (1649:6): [True: 2, False: 3]
  ------------------
 1650|      2|		status = *msg->status;
 1651|       |
 1652|      5|	p2p_dbg(p2p, "Received Provision Discovery Bootstrap Response from "
 1653|      5|		MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      5|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              		MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      5|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1654|       |
 1655|      5|	dev = p2p_get_device(p2p, sa);
 1656|      5|	if (!dev || !dev->req_bootstrap_method) {
  ------------------
  |  Branch (1656:6): [True: 4, False: 1]
  |  Branch (1656:14): [True: 1, False: 0]
  ------------------
 1657|      5|		p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
 1658|      5|			" with no pending request", MAC2STR(sa));
  ------------------
  |  |  447|      5|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1659|      5|		return;
 1660|      5|	}
 1661|       |
 1662|      0|	p2p_update_peer_6ghz_capab(dev, msg);
 1663|       |
 1664|      0|	if (dev->dialog_token != msg->dialog_token) {
  ------------------
  |  Branch (1664:6): [True: 0, False: 0]
  ------------------
 1665|      0|		p2p_dbg(p2p,
 1666|      0|			"Ignore Provision Discovery Response with unexpected Dialog Token %u (expected %u)",
 1667|      0|			msg->dialog_token, dev->dialog_token);
 1668|      0|		return;
 1669|      0|	}
 1670|       |
 1671|      0|	if (p2p->pending_action_state == P2P_PENDING_PD) {
  ------------------
  |  Branch (1671:6): [True: 0, False: 0]
  ------------------
 1672|      0|		os_memset(p2p->pending_pd_devaddr, 0, ETH_ALEN);
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1673|      0|		p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 1674|      0|	}
 1675|       |
 1676|      0|	os_free(dev->bootstrap_params);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
 1677|      0|	dev->bootstrap_params = NULL;
 1678|       |
 1679|       |	/* If the response is from the peer to whom a user initiated request
 1680|       |	 * was sent earlier, we reset that state information here. */
 1681|      0|	if (p2p->user_initiated_pd &&
  ------------------
  |  Branch (1681:6): [True: 0, False: 0]
  ------------------
 1682|      0|	    ether_addr_equal(p2p->pending_pd_devaddr, sa))
  ------------------
  |  Branch (1682:6): [True: 0, False: 0]
  ------------------
 1683|      0|		p2p_reset_pending_pd(p2p);
 1684|       |
 1685|      0|	if (status == P2P_SC_COMEBACK) {
  ------------------
  |  Branch (1685:6): [True: 0, False: 0]
  ------------------
 1686|       |		/* PBMA comeback response */
 1687|      0|		pos = msg->pbma_info;
 1688|      0|		if (msg->pbma_info_len < 2 + 1)
  ------------------
  |  Branch (1688:7): [True: 0, False: 0]
  ------------------
 1689|      0|			return;
 1690|      0|		comeback_after = WPA_GET_LE16(pos);
 1691|      0|		pos += 2;
 1692|      0|		cookie_len = *pos++;
 1693|      0|		if (msg->pbma_info_len < 2 + 1 + cookie_len) {
  ------------------
  |  Branch (1693:7): [True: 0, False: 0]
  ------------------
 1694|      0|			p2p_dbg(p2p, "Truncated PBMA");
 1695|      0|			return;
 1696|      0|		}
 1697|       |
 1698|      0|		if (cookie_len > sizeof(dev->bootstrap_params->cookie)) {
  ------------------
  |  Branch (1698:7): [True: 0, False: 0]
  ------------------
 1699|      0|			p2p_dbg(p2p, "Too long PBMA cookie");
 1700|      0|			return;
 1701|      0|		}
 1702|       |
 1703|      0|		cookie = pos;
 1704|       |
 1705|      0|		dev->bootstrap_params =
 1706|      0|			os_zalloc(sizeof(struct p2p_bootstrap_params));
 1707|      0|		if (!dev->bootstrap_params)
  ------------------
  |  Branch (1707:7): [True: 0, False: 0]
  ------------------
 1708|      0|			return;
 1709|      0|		dev->bootstrap_params->cookie_len = cookie_len;
 1710|      0|		os_memcpy(dev->bootstrap_params->cookie, cookie, cookie_len);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1711|      0|		dev->bootstrap_params->comeback_after = comeback_after;
 1712|      0|		dev->bootstrap_params->bootstrap_method =
 1713|      0|						dev->req_bootstrap_method;
 1714|      0|		dev->bootstrap_params->status = status;
 1715|       |
 1716|      0|		p2p->cfg->register_bootstrap_comeback(p2p->cfg->cb_ctx, sa,
 1717|      0|						      comeback_after);
 1718|      0|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 1719|       |
 1720|      0|		if (p2p->cfg->bootstrap_rsp_rx)
  ------------------
  |  Branch (1720:7): [True: 0, False: 0]
  ------------------
 1721|      0|			p2p->cfg->bootstrap_rsp_rx(p2p->cfg->cb_ctx, sa, status,
 1722|      0|						   rx_freq,
 1723|      0|						   dev->req_bootstrap_method);
 1724|      0|		return;
 1725|      0|	}
 1726|       |
 1727|       |	/* PBMA response */
 1728|      0|	if (msg->pbma_info_len >= 2)
  ------------------
  |  Branch (1728:6): [True: 0, False: 0]
  ------------------
 1729|      0|		bootstrap = WPA_GET_LE16(msg->pbma_info);
 1730|       |
 1731|       |	/* Overwrite the status if bootstrap method does not match */
 1732|      0|	if (status == P2P_SC_SUCCESS &&
  ------------------
  |  Branch (1732:6): [True: 0, False: 0]
  ------------------
 1733|      0|	    !(bootstrap == P2P_PBMA_PIN_CODE_DISPLAY &&
  ------------------
  |  | 1942|      0|#define P2P_PBMA_PIN_CODE_DISPLAY    BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1733:8): [True: 0, False: 0]
  ------------------
 1734|      0|	      dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_KEYPAD) &&
  ------------------
  |  | 1946|      0|#define P2P_PBMA_PIN_CODE_KEYPAD     BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1734:8): [True: 0, False: 0]
  ------------------
 1735|      0|	    !(bootstrap == P2P_PBMA_PIN_CODE_KEYPAD &&
  ------------------
  |  | 1946|      0|#define P2P_PBMA_PIN_CODE_KEYPAD     BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1735:8): [True: 0, False: 0]
  ------------------
 1736|      0|	      dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_DISPLAY) &&
  ------------------
  |  | 1942|      0|#define P2P_PBMA_PIN_CODE_DISPLAY    BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1736:8): [True: 0, False: 0]
  ------------------
 1737|      0|	    !(bootstrap == P2P_PBMA_PASSPHRASE_DISPLAY &&
  ------------------
  |  | 1943|      0|#define P2P_PBMA_PASSPHRASE_DISPLAY  BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1737:8): [True: 0, False: 0]
  ------------------
 1738|      0|	      dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_KEYPAD) &&
  ------------------
  |  | 1947|      0|#define P2P_PBMA_PASSPHRASE_KEYPAD   BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1738:8): [True: 0, False: 0]
  ------------------
 1739|      0|	    !(bootstrap == P2P_PBMA_PASSPHRASE_KEYPAD &&
  ------------------
  |  | 1947|      0|#define P2P_PBMA_PASSPHRASE_KEYPAD   BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1739:8): [True: 0, False: 0]
  ------------------
 1740|      0|	      dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_DISPLAY) &&
  ------------------
  |  | 1943|      0|#define P2P_PBMA_PASSPHRASE_DISPLAY  BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1740:8): [True: 0, False: 0]
  ------------------
 1741|      0|	    !(bootstrap == P2P_PBMA_NFC_TAG &&
  ------------------
  |  | 1945|      0|#define P2P_PBMA_NFC_TAG             BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1741:8): [True: 0, False: 0]
  ------------------
 1742|      0|	      dev->req_bootstrap_method == P2P_PBMA_NFC_READER) &&
  ------------------
  |  | 1949|      0|#define P2P_PBMA_NFC_READER          BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1742:8): [True: 0, False: 0]
  ------------------
 1743|      0|	    !(bootstrap == P2P_PBMA_NFC_READER &&
  ------------------
  |  | 1949|      0|#define P2P_PBMA_NFC_READER          BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1743:8): [True: 0, False: 0]
  ------------------
 1744|      0|	      dev->req_bootstrap_method == P2P_PBMA_NFC_TAG) &&
  ------------------
  |  | 1945|      0|#define P2P_PBMA_NFC_TAG             BIT(4)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1744:8): [True: 0, False: 0]
  ------------------
 1745|      0|	    !(bootstrap == P2P_PBMA_QR_DISPLAY &&
  ------------------
  |  | 1944|      0|#define P2P_PBMA_QR_DISPLAY          BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1745:8): [True: 0, False: 0]
  ------------------
 1746|      0|	      dev->req_bootstrap_method == P2P_PBMA_QR_SCAN) &&
  ------------------
  |  | 1948|      0|#define P2P_PBMA_QR_SCAN             BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1746:8): [True: 0, False: 0]
  ------------------
 1747|      0|	    !(bootstrap == P2P_PBMA_QR_SCAN &&
  ------------------
  |  | 1948|      0|#define P2P_PBMA_QR_SCAN             BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1747:8): [True: 0, False: 0]
  ------------------
 1748|      0|	      dev->req_bootstrap_method == P2P_PBMA_QR_DISPLAY) &&
  ------------------
  |  | 1944|      0|#define P2P_PBMA_QR_DISPLAY          BIT(3)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1748:8): [True: 0, False: 0]
  ------------------
 1749|      0|	    !(bootstrap == P2P_PBMA_OPPORTUNISTIC &&
  ------------------
  |  | 1941|      0|#define P2P_PBMA_OPPORTUNISTIC       BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1749:8): [True: 0, False: 0]
  ------------------
 1750|      0|	      dev->req_bootstrap_method == P2P_PBMA_OPPORTUNISTIC))
  ------------------
  |  | 1941|      0|#define P2P_PBMA_OPPORTUNISTIC       BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1750:8): [True: 0, False: 0]
  ------------------
 1751|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 1752|       |
 1753|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 1754|      0|	if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG)
  ------------------
  |  |  142|      0|#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1754:6): [True: 0, False: 0]
  ------------------
 1755|      0|		dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
  ------------------
  |  |  142|      0|#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1756|       |
 1757|      0|	if (p2p->cfg->bootstrap_rsp_rx)
  ------------------
  |  Branch (1757:6): [True: 0, False: 0]
  ------------------
 1758|      0|		p2p->cfg->bootstrap_rsp_rx(p2p->cfg->cb_ctx, sa, status,
 1759|      0|					   rx_freq, dev->req_bootstrap_method);
 1760|      0|}
p2p_pd.c:p2p_process_prov_disc_resp:
 1766|     16|{
 1767|     16|	struct p2p_device *dev;
 1768|     16|	u16 report_config_methods = 0, req_config_methods;
 1769|     16|	enum p2p_status_code status = P2P_SC_SUCCESS;
 1770|     16|	u32 adv_id = 0;
 1771|     16|	u8 conncap = P2PS_SETUP_NEW;
  ------------------
  |  |   30|     16|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|     16|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1772|     16|	u8 adv_mac[ETH_ALEN];
 1773|     16|	const u8 *group_mac;
 1774|     16|	int passwd_id = DEV_PW_DEFAULT;
 1775|     16|	int p2ps_seeker;
 1776|       |
 1777|     16|	if (p2p->p2ps_prov && p2p_validate_p2ps_pd_resp(p2p, msg))
  ------------------
  |  Branch (1777:6): [True: 0, False: 16]
  |  Branch (1777:24): [True: 0, False: 0]
  ------------------
 1778|      0|		return;
 1779|       |
 1780|       |	/* Parse the P2PS members present */
 1781|     16|	if (msg->status)
  ------------------
  |  Branch (1781:6): [True: 1, False: 15]
  ------------------
 1782|      1|		status = *msg->status;
 1783|       |
 1784|     16|	group_mac = msg->intended_addr;
 1785|       |
 1786|     16|	if (msg->adv_mac)
  ------------------
  |  Branch (1786:6): [True: 2, False: 14]
  ------------------
 1787|      2|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|      2|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1788|     14|	else
 1789|     14|		os_memset(adv_mac, 0, ETH_ALEN);
  ------------------
  |  |  529|     14|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1790|       |
 1791|     16|	if (msg->adv_id)
  ------------------
  |  Branch (1791:6): [True: 2, False: 14]
  ------------------
 1792|      2|		adv_id = WPA_GET_LE32(msg->adv_id);
 1793|       |
 1794|     16|	if (msg->conn_cap) {
  ------------------
  |  Branch (1794:6): [True: 4, False: 12]
  ------------------
 1795|      4|		conncap = *msg->conn_cap;
 1796|       |
 1797|       |		/* Switch bits to local relative */
 1798|      4|		switch (conncap) {
  ------------------
  |  Branch (1798:11): [True: 2, False: 2]
  ------------------
 1799|      1|		case P2PS_SETUP_GROUP_OWNER:
  ------------------
  |  |   32|      1|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1799:3): [True: 1, False: 3]
  ------------------
 1800|      1|			conncap = P2PS_SETUP_CLIENT;
  ------------------
  |  |   31|      1|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1801|      1|			break;
 1802|      1|		case P2PS_SETUP_CLIENT:
  ------------------
  |  |   31|      1|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1802:3): [True: 1, False: 3]
  ------------------
 1803|      1|			conncap = P2PS_SETUP_GROUP_OWNER;
  ------------------
  |  |   32|      1|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1804|      1|			break;
 1805|      4|		}
 1806|      4|	}
 1807|       |
 1808|     16|	p2p_dbg(p2p, "Received Provision Discovery Response from " MACSTR
 1809|     16|		" with config methods 0x%x",
 1810|     16|		MAC2STR(sa), msg->wps_config_methods);
  ------------------
  |  |  447|     16|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1811|       |
 1812|     16|	dev = p2p_get_device(p2p, sa);
 1813|     16|	if (dev == NULL || !dev->req_config_methods) {
  ------------------
  |  Branch (1813:6): [True: 14, False: 2]
  |  Branch (1813:21): [True: 2, False: 0]
  ------------------
 1814|     16|		p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
 1815|     16|			" with no pending request", MAC2STR(sa));
  ------------------
  |  |  447|     16|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1816|     16|		return;
 1817|     16|	} else if (msg->wfd_subelems) {
  ------------------
  |  Branch (1817:13): [True: 0, False: 0]
  ------------------
 1818|      0|		wpabuf_free(dev->info.wfd_subelems);
 1819|      0|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
 1820|      0|	}
 1821|       |
 1822|      0|	p2p_update_peer_6ghz_capab(dev, msg);
 1823|       |
 1824|      0|	if (dev->dialog_token != msg->dialog_token) {
  ------------------
  |  Branch (1824:6): [True: 0, False: 0]
  ------------------
 1825|      0|		p2p_dbg(p2p, "Ignore Provision Discovery Response with unexpected Dialog Token %u (expected %u)",
 1826|      0|			msg->dialog_token, dev->dialog_token);
 1827|      0|		return;
 1828|      0|	}
 1829|       |
 1830|      0|	if (p2p->pending_action_state == P2P_PENDING_PD) {
  ------------------
  |  Branch (1830:6): [True: 0, False: 0]
  ------------------
 1831|      0|		os_memset(p2p->pending_pd_devaddr, 0, ETH_ALEN);
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1832|      0|		p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 1833|      0|	}
 1834|       |
 1835|      0|	p2ps_seeker = p2p->p2ps_prov && p2p->p2ps_prov->pd_seeker;
  ------------------
  |  Branch (1835:16): [True: 0, False: 0]
  |  Branch (1835:34): [True: 0, False: 0]
  ------------------
 1836|       |
 1837|       |	/*
 1838|       |	 * Use a local copy of the requested config methods since
 1839|       |	 * p2p_reset_pending_pd() can clear this in the peer entry.
 1840|       |	 */
 1841|      0|	req_config_methods = dev->req_config_methods;
 1842|       |
 1843|       |	/*
 1844|       |	 * If the response is from the peer to whom a user initiated request
 1845|       |	 * was sent earlier, we reset that state info here.
 1846|       |	 */
 1847|      0|	if (p2p->user_initiated_pd &&
  ------------------
  |  Branch (1847:6): [True: 0, False: 0]
  ------------------
 1848|      0|	    ether_addr_equal(p2p->pending_pd_devaddr, sa))
  ------------------
  |  Branch (1848:6): [True: 0, False: 0]
  ------------------
 1849|      0|		p2p_reset_pending_pd(p2p);
 1850|       |
 1851|      0|	if (msg->wps_config_methods != req_config_methods) {
  ------------------
  |  Branch (1851:6): [True: 0, False: 0]
  ------------------
 1852|      0|		p2p_dbg(p2p, "Peer rejected our Provision Discovery Request (received config_methods 0x%x expected 0x%x",
 1853|      0|			msg->wps_config_methods, req_config_methods);
 1854|      0|		if (p2p->cfg->prov_disc_fail)
  ------------------
  |  Branch (1854:7): [True: 0, False: 0]
  ------------------
 1855|      0|			p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa,
 1856|      0|						 P2P_PROV_DISC_REJECTED,
 1857|      0|						 adv_id, adv_mac, NULL);
 1858|      0|		p2ps_prov_free(p2p);
 1859|      0|		goto out;
 1860|      0|	}
 1861|       |
 1862|      0|	report_config_methods = req_config_methods;
 1863|      0|	dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
  ------------------
  |  |  130|      0|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1864|      0|			P2P_DEV_PD_PEER_KEYPAD |
  ------------------
  |  |  131|      0|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1865|      0|			P2P_DEV_PD_PEER_P2PS);
  ------------------
  |  |  146|      0|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1866|      0|	if (req_config_methods & WPS_CONFIG_DISPLAY) {
  ------------------
  |  |  251|      0|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1866:6): [True: 0, False: 0]
  ------------------
 1867|      0|		p2p_dbg(p2p, "Peer " MACSTR
 1868|      0|			" accepted to show a PIN on display", MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1869|      0|		dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
  ------------------
  |  |  130|      0|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1870|      0|		passwd_id = DEV_PW_REGISTRAR_SPECIFIED;
 1871|      0|	} else if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1871:13): [True: 0, False: 0]
  ------------------
 1872|      0|		p2p_dbg(p2p, "Peer " MACSTR
 1873|      0|			" accepted to write our PIN using keypad",
 1874|      0|			MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1875|      0|		dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
  ------------------
  |  |  131|      0|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1876|      0|		passwd_id = DEV_PW_USER_SPECIFIED;
 1877|      0|	} else if (msg->wps_config_methods & WPS_CONFIG_P2PS) {
  ------------------
  |  |  259|      0|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1877:13): [True: 0, False: 0]
  ------------------
 1878|      0|		p2p_dbg(p2p, "Peer " MACSTR " accepted P2PS PIN",
 1879|      0|			MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1880|      0|		dev->flags |= P2P_DEV_PD_PEER_P2PS;
  ------------------
  |  |  146|      0|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1881|      0|		passwd_id = DEV_PW_P2PS_DEFAULT;
 1882|      0|	}
 1883|       |
 1884|      0|	if ((status == P2P_SC_SUCCESS || status == P2P_SC_SUCCESS_DEFERRED) &&
  ------------------
  |  Branch (1884:7): [True: 0, False: 0]
  |  Branch (1884:35): [True: 0, False: 0]
  ------------------
 1885|      0|	    p2p->p2ps_prov) {
  ------------------
  |  Branch (1885:6): [True: 0, False: 0]
  ------------------
 1886|      0|		dev->oper_freq = 0;
 1887|       |
 1888|       |		/*
 1889|       |		 * Save the reported channel list and operating frequency.
 1890|       |		 * Note that the specification mandates that the responder
 1891|       |		 * should include in the channel list only channels reported by
 1892|       |		 * the initiator, so this is only a validity check, and if this
 1893|       |		 * fails the flow would continue, although it would probably
 1894|       |		 * fail. Same is true for the operating channel.
 1895|       |		 */
 1896|      0|		if (msg->channel_list && msg->channel_list_len &&
  ------------------
  |  Branch (1896:7): [True: 0, False: 0]
  |  Branch (1896:28): [True: 0, False: 0]
  ------------------
 1897|      0|		    p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (1897:7): [True: 0, False: 0]
  ------------------
 1898|      0|					    msg->channel_list,
 1899|      0|					    msg->channel_list_len) < 0)
 1900|      0|			p2p_dbg(p2p, "P2PS PD Response - no common channels");
 1901|       |
 1902|      0|		if (msg->operating_channel) {
  ------------------
  |  Branch (1902:7): [True: 0, False: 0]
  ------------------
 1903|      0|			if (p2p_channels_includes(&p2p->channels,
  ------------------
  |  Branch (1903:8): [True: 0, False: 0]
  ------------------
 1904|      0|						  msg->operating_channel[3],
 1905|      0|						  msg->operating_channel[4]) &&
 1906|      0|			    p2p_channels_includes(&dev->channels,
  ------------------
  |  Branch (1906:8): [True: 0, False: 0]
  ------------------
 1907|      0|						  msg->operating_channel[3],
 1908|      0|						  msg->operating_channel[4])) {
 1909|      0|				dev->oper_freq =
 1910|      0|					p2p_channel_to_freq(
 1911|      0|						msg->operating_channel[3],
 1912|      0|						msg->operating_channel[4]);
 1913|      0|			} else {
 1914|      0|				p2p_dbg(p2p,
 1915|      0|					"P2PS PD Response - invalid operating channel");
 1916|      0|			}
 1917|      0|		}
 1918|       |
 1919|      0|		if (p2p->cfg->p2ps_prov_complete) {
  ------------------
  |  Branch (1919:7): [True: 0, False: 0]
  ------------------
 1920|      0|			int freq = 0;
 1921|       |
 1922|      0|			if (conncap == P2PS_SETUP_GROUP_OWNER) {
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1922:8): [True: 0, False: 0]
  ------------------
 1923|      0|				u8 tmp;
 1924|       |
 1925|       |				/*
 1926|       |				 * Re-select the operating channel as it is
 1927|       |				 * possible that original channel is no longer
 1928|       |				 * valid. This should not really fail.
 1929|       |				 */
 1930|      0|				if (p2p_go_select_channel(p2p, dev, &tmp) < 0)
  ------------------
  |  Branch (1930:9): [True: 0, False: 0]
  ------------------
 1931|      0|					p2p_dbg(p2p,
 1932|      0|						"P2PS PD channel selection failed");
 1933|       |
 1934|      0|				freq = p2p_channel_to_freq(p2p->op_reg_class,
 1935|      0|							   p2p->op_channel);
 1936|      0|				if (freq < 0)
  ------------------
  |  Branch (1936:9): [True: 0, False: 0]
  ------------------
 1937|      0|					freq = 0;
 1938|      0|			}
 1939|       |
 1940|      0|			p2p->cfg->p2ps_prov_complete(
 1941|      0|				p2p->cfg->cb_ctx, status, sa, adv_mac,
 1942|      0|				p2p->p2ps_prov->session_mac,
 1943|      0|				group_mac, adv_id, p2p->p2ps_prov->session_id,
 1944|      0|				conncap, passwd_id, msg->persistent_ssid,
 1945|      0|				msg->persistent_ssid_len, 1, 0, NULL,
 1946|      0|				msg->feature_cap, msg->feature_cap_len, freq,
 1947|      0|				msg->group_id ? msg->group_id + ETH_ALEN : NULL,
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  |  Branch (1947:5): [True: 0, False: 0]
  ------------------
 1948|      0|				msg->group_id ? msg->group_id_len - ETH_ALEN :
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  |  Branch (1948:5): [True: 0, False: 0]
  ------------------
 1949|      0|				0);
 1950|      0|		}
 1951|      0|		p2ps_prov_free(p2p);
 1952|      0|	} else if (status != P2P_SC_SUCCESS &&
  ------------------
  |  Branch (1952:13): [True: 0, False: 0]
  ------------------
 1953|      0|		   status != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
  ------------------
  |  Branch (1953:6): [True: 0, False: 0]
  ------------------
 1954|      0|		   status != P2P_SC_SUCCESS_DEFERRED && p2p->p2ps_prov) {
  ------------------
  |  Branch (1954:6): [True: 0, False: 0]
  |  Branch (1954:43): [True: 0, False: 0]
  ------------------
 1955|      0|		if (p2p->cfg->p2ps_prov_complete)
  ------------------
  |  Branch (1955:7): [True: 0, False: 0]
  ------------------
 1956|      0|			p2p->cfg->p2ps_prov_complete(
 1957|      0|				p2p->cfg->cb_ctx, status, sa, adv_mac,
 1958|      0|				p2p->p2ps_prov->session_mac,
 1959|      0|				group_mac, adv_id, p2p->p2ps_prov->session_id,
 1960|      0|				0, 0, NULL, 0, 1, 0, NULL, NULL, 0, 0, NULL, 0);
 1961|      0|		p2ps_prov_free(p2p);
 1962|      0|	}
 1963|       |
 1964|      0|	if (status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) {
  ------------------
  |  Branch (1964:6): [True: 0, False: 0]
  ------------------
 1965|      0|		if (p2p->cfg->remove_stale_groups) {
  ------------------
  |  Branch (1965:7): [True: 0, False: 0]
  ------------------
 1966|      0|			p2p->cfg->remove_stale_groups(p2p->cfg->cb_ctx,
 1967|      0|						      dev->info.p2p_device_addr,
 1968|      0|						      NULL, NULL, 0);
 1969|      0|		}
 1970|       |
 1971|      0|		if (msg->session_info && msg->session_info_len) {
  ------------------
  |  Branch (1971:7): [True: 0, False: 0]
  |  Branch (1971:28): [True: 0, False: 0]
  ------------------
 1972|      0|			size_t info_len = msg->session_info_len;
 1973|      0|			char *deferred_sess_resp = os_malloc(2 * info_len + 1);
  ------------------
  |  |  505|      0|#define os_malloc(s) malloc((s))
  ------------------
 1974|       |
 1975|      0|			if (!deferred_sess_resp) {
  ------------------
  |  Branch (1975:8): [True: 0, False: 0]
  ------------------
 1976|      0|				p2ps_prov_free(p2p);
 1977|      0|				goto out;
 1978|      0|			}
 1979|      0|			utf8_escape((char *) msg->session_info, info_len,
 1980|      0|				    deferred_sess_resp, 2 * info_len + 1);
 1981|       |
 1982|      0|			if (p2p->cfg->prov_disc_fail)
  ------------------
  |  Branch (1982:8): [True: 0, False: 0]
  ------------------
 1983|      0|				p2p->cfg->prov_disc_fail(
 1984|      0|					p2p->cfg->cb_ctx, sa,
 1985|      0|					P2P_PROV_DISC_INFO_UNAVAILABLE,
 1986|      0|					adv_id, adv_mac,
 1987|      0|					deferred_sess_resp);
 1988|      0|			os_free(deferred_sess_resp);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
 1989|      0|		} else
 1990|      0|			if (p2p->cfg->prov_disc_fail)
  ------------------
  |  Branch (1990:8): [True: 0, False: 0]
  ------------------
 1991|      0|				p2p->cfg->prov_disc_fail(
 1992|      0|					p2p->cfg->cb_ctx, sa,
 1993|      0|					P2P_PROV_DISC_INFO_UNAVAILABLE,
 1994|      0|					adv_id, adv_mac, NULL);
 1995|      0|	} else if (status != P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1995:13): [True: 0, False: 0]
  ------------------
 1996|      0|		p2p_dbg(p2p, "Peer rejected our Provision Discovery Request");
 1997|      0|		if (p2p->cfg->prov_disc_fail)
  ------------------
  |  Branch (1997:7): [True: 0, False: 0]
  ------------------
 1998|      0|			p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa,
 1999|      0|						 P2P_PROV_DISC_REJECTED,
 2000|      0|						 adv_id, adv_mac, NULL);
 2001|      0|		p2ps_prov_free(p2p);
 2002|      0|		goto out;
 2003|      0|	}
 2004|       |
 2005|       |	/* Store the provisioning info */
 2006|      0|	dev->wps_prov_info = msg->wps_config_methods;
 2007|      0|	if (msg->intended_addr)
  ------------------
  |  Branch (2007:6): [True: 0, False: 0]
  ------------------
 2008|      0|		os_memcpy(dev->interface_addr, msg->intended_addr, ETH_ALEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2009|       |
 2010|      0|out:
 2011|      0|	dev->req_config_methods = 0;
 2012|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
 2013|      0|	if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
  ------------------
  |  |  142|      0|#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (2013:6): [True: 0, False: 0]
  ------------------
 2014|      0|		p2p_dbg(p2p, "Start GO Neg after the PD-before-GO-Neg workaround with "
 2015|      0|			MACSTR, MAC2STR(dev->info.p2p_device_addr));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(dev->info.p2p_device_addr));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2016|      0|		dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
  ------------------
  |  |  142|      0|#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2017|      0|		p2p_connect_send(p2p, dev);
 2018|      0|		return;
 2019|      0|	}
 2020|       |
 2021|       |	/*
 2022|       |	 * prov_disc_resp callback is used to generate P2P-PROV-DISC-ENTER-PIN,
 2023|       |	 * P2P-PROV-DISC-SHOW-PIN, and P2P-PROV-DISC-PBC-REQ events.
 2024|       |	 * Call it only for a legacy P2P PD or for P2PS PD scenarios where
 2025|       |	 * show/enter PIN events are needed.
 2026|       |	 *
 2027|       |	 * The callback is called in the following cases:
 2028|       |	 * 1. Legacy P2P PD response with a status SUCCESS
 2029|       |	 * 2. P2PS, advertiser method: DISPLAY, autoaccept: true,
 2030|       |	 *    response status: SUCCESS, local method KEYPAD
 2031|       |	 * 3. P2PS, advertiser method: KEYPAD,Seeker side,
 2032|       |	 *    response status: INFO_CURRENTLY_UNAVAILABLE,
 2033|       |	 *    local method: DISPLAY
 2034|       |	 */
 2035|      0|	if (p2p->cfg->prov_disc_resp &&
  ------------------
  |  Branch (2035:6): [True: 0, False: 0]
  ------------------
 2036|      0|	    ((status == P2P_SC_SUCCESS && !adv_id) ||
  ------------------
  |  Branch (2036:8): [True: 0, False: 0]
  |  Branch (2036:36): [True: 0, False: 0]
  ------------------
 2037|      0|	     (p2ps_seeker && status == P2P_SC_SUCCESS &&
  ------------------
  |  Branch (2037:8): [True: 0, False: 0]
  |  Branch (2037:23): [True: 0, False: 0]
  ------------------
 2038|      0|	      passwd_id == DEV_PW_REGISTRAR_SPECIFIED) ||
  ------------------
  |  Branch (2038:8): [True: 0, False: 0]
  ------------------
 2039|      0|	     (p2ps_seeker &&
  ------------------
  |  Branch (2039:8): [True: 0, False: 0]
  ------------------
 2040|      0|	      status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
  ------------------
  |  Branch (2040:8): [True: 0, False: 0]
  ------------------
 2041|      0|	      passwd_id == DEV_PW_USER_SPECIFIED)))
  ------------------
  |  Branch (2041:8): [True: 0, False: 0]
  ------------------
 2042|      0|		p2p->cfg->prov_disc_resp(p2p->cfg->cb_ctx, sa,
 2043|      0|					 report_config_methods);
 2044|       |
 2045|      0|	if (p2p->state == P2P_PD_DURING_FIND) {
  ------------------
  |  Branch (2045:6): [True: 0, False: 0]
  ------------------
 2046|      0|		p2p_stop_listen_for_freq(p2p, 0);
 2047|      0|		p2p_continue_find(p2p);
 2048|      0|	}
 2049|      0|}

p2p_free_sd_queries:
  157|  6.88k|{
  158|  6.88k|	struct p2p_sd_query *q, *prev;
  159|  6.88k|	q = p2p->sd_queries;
  160|  6.88k|	p2p->sd_queries = NULL;
  161|  6.88k|	while (q) {
  ------------------
  |  Branch (161:9): [True: 0, False: 6.88k]
  ------------------
  162|      0|		prev = q;
  163|      0|		q = q->next;
  164|      0|		p2p_free_sd_query(prev);
  165|      0|	}
  166|  6.88k|	p2p->num_p2p_sd_queries = 0;
  167|  6.88k|}
p2p_rx_gas_initial_req:
  328|      3|{
  329|      3|	const u8 *pos = data;
  330|      3|	const u8 *end = data + len;
  331|      3|	const u8 *next;
  332|      3|	u8 dialog_token;
  333|      3|	u16 slen;
  334|      3|	int freq;
  335|      3|	u16 update_indic;
  336|       |
  337|       |
  338|      3|	if (p2p->cfg->sd_request == NULL)
  ------------------
  |  Branch (338:6): [True: 3, False: 0]
  ------------------
  339|      3|		return;
  340|       |
  341|      0|	if (rx_freq > 0)
  ------------------
  |  Branch (341:6): [True: 0, False: 0]
  ------------------
  342|      0|		freq = rx_freq;
  343|      0|	else
  344|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  345|      0|					   p2p->cfg->channel);
  346|      0|	if (freq < 0)
  ------------------
  |  Branch (346:6): [True: 0, False: 0]
  ------------------
  347|      0|		return;
  348|       |
  349|      0|	if (len < 1 + 2)
  ------------------
  |  Branch (349:6): [True: 0, False: 0]
  ------------------
  350|      0|		return;
  351|       |
  352|      0|	dialog_token = *pos++;
  353|      0|	p2p_dbg(p2p, "GAS Initial Request from " MACSTR
  354|      0|		" (dialog token %u, freq %d)",
  355|      0|		MAC2STR(sa), dialog_token, rx_freq);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  356|       |
  357|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (357:6): [True: 0, False: 0]
  ------------------
  358|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
  359|      0|		return;
  360|      0|	}
  361|      0|	pos++;
  362|       |
  363|      0|	slen = *pos++;
  364|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (364:6): [True: 0, False: 0]
  |  Branch (364:26): [True: 0, False: 0]
  ------------------
  365|      0|		p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
  366|      0|		return;
  367|      0|	}
  368|      0|	next = pos + slen;
  369|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  370|       |
  371|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (371:6): [True: 0, False: 0]
  ------------------
  372|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  373|      0|			*pos);
  374|      0|		return;
  375|      0|	}
  376|       |
  377|      0|	pos = next;
  378|       |	/* Query Request */
  379|      0|	if (end - pos < 2)
  ------------------
  |  Branch (379:6): [True: 0, False: 0]
  ------------------
  380|      0|		return;
  381|      0|	slen = WPA_GET_LE16(pos);
  382|      0|	pos += 2;
  383|      0|	if (slen > end - pos)
  ------------------
  |  Branch (383:6): [True: 0, False: 0]
  ------------------
  384|      0|		return;
  385|      0|	end = pos + slen;
  386|       |
  387|       |	/* ANQP Query Request */
  388|      0|	if (end - pos < 4)
  ------------------
  |  Branch (388:6): [True: 0, False: 0]
  ------------------
  389|      0|		return;
  390|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (390:6): [True: 0, False: 0]
  ------------------
  391|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  392|      0|		return;
  393|      0|	}
  394|      0|	pos += 2;
  395|       |
  396|      0|	slen = WPA_GET_LE16(pos);
  397|      0|	pos += 2;
  398|      0|	if (slen > end - pos || slen < 3 + 1) {
  ------------------
  |  Branch (398:6): [True: 0, False: 0]
  |  Branch (398:26): [True: 0, False: 0]
  ------------------
  399|      0|		p2p_dbg(p2p, "Invalid ANQP Query Request length");
  400|      0|		return;
  401|      0|	}
  402|       |
  403|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1575|      0|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (403:6): [True: 0, False: 0]
  ------------------
  404|      0|		p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
  405|      0|			WPA_GET_BE32(pos));
  406|      0|		return;
  407|      0|	}
  408|      0|	pos += 4;
  409|       |
  410|      0|	if (end - pos < 2)
  ------------------
  |  Branch (410:6): [True: 0, False: 0]
  ------------------
  411|      0|		return;
  412|      0|	update_indic = WPA_GET_LE16(pos);
  413|      0|	p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
  414|      0|	pos += 2;
  415|       |
  416|      0|	p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
  417|      0|			     update_indic, pos, end - pos);
  418|       |	/* the response will be indicated with a call to p2p_sd_response() */
  419|      0|}
p2p_rx_gas_initial_resp:
  482|      1|{
  483|      1|	const u8 *pos = data;
  484|      1|	const u8 *end = data + len;
  485|      1|	const u8 *next;
  486|      1|	u8 dialog_token;
  487|      1|	u16 status_code;
  488|      1|	u16 comeback_delay;
  489|      1|	u16 slen;
  490|      1|	u16 update_indic;
  491|       |
  492|      1|	if ((p2p->state != P2P_SD_DURING_FIND && p2p->state != P2P_SEARCH) ||
  ------------------
  |  Branch (492:7): [True: 1, False: 0]
  |  Branch (492:43): [True: 1, False: 0]
  ------------------
  493|      0|	    !p2p->sd_peer ||
  ------------------
  |  Branch (493:6): [True: 0, False: 0]
  ------------------
  494|      1|	    !ether_addr_equal(sa, p2p->sd_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (494:6): [True: 0, False: 0]
  ------------------
  495|      1|		p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
  496|      1|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  497|      1|		return;
  498|      1|	}
  499|      0|	if (p2p->state == P2P_SEARCH) {
  ------------------
  |  Branch (499:6): [True: 0, False: 0]
  ------------------
  500|       |		/* It is possible for the TX status and RX response events to be
  501|       |		 * reordered, so assume the request was ACKed if a response is
  502|       |		 * received. */
  503|      0|		p2p_dbg(p2p,
  504|      0|			"GAS Initial Request had not yet received TX status - process the response anyway");
  505|      0|		p2p_sd_query_cb(p2p, 1);
  506|      0|	}
  507|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  508|      0|	p2p_clear_timeout(p2p);
  509|       |
  510|      0|	p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
  511|      0|		MAC2STR(sa), (int) len);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  512|       |
  513|      0|	if (len < 5 + 2) {
  ------------------
  |  Branch (513:6): [True: 0, False: 0]
  ------------------
  514|      0|		p2p_dbg(p2p, "Too short GAS Initial Response frame");
  515|      0|		return;
  516|      0|	}
  517|       |
  518|      0|	dialog_token = *pos++;
  519|       |	/* TODO: check dialog_token match */
  520|      0|	status_code = WPA_GET_LE16(pos);
  521|      0|	pos += 2;
  522|      0|	comeback_delay = WPA_GET_LE16(pos);
  523|      0|	pos += 2;
  524|      0|	p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
  525|      0|		dialog_token, status_code, comeback_delay);
  526|      0|	if (status_code) {
  ------------------
  |  Branch (526:6): [True: 0, False: 0]
  ------------------
  527|      0|		p2p_dbg(p2p, "Service Discovery failed: status code %u",
  528|      0|			status_code);
  529|      0|		return;
  530|      0|	}
  531|       |
  532|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (532:6): [True: 0, False: 0]
  ------------------
  533|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
  534|      0|		return;
  535|      0|	}
  536|      0|	pos++;
  537|       |
  538|      0|	slen = *pos++;
  539|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (539:6): [True: 0, False: 0]
  |  Branch (539:26): [True: 0, False: 0]
  ------------------
  540|      0|		p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
  541|      0|		return;
  542|      0|	}
  543|      0|	next = pos + slen;
  544|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  545|       |
  546|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (546:6): [True: 0, False: 0]
  ------------------
  547|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  548|      0|			*pos);
  549|      0|		return;
  550|      0|	}
  551|       |
  552|      0|	pos = next;
  553|       |	/* Query Response */
  554|      0|	if (end - pos < 2) {
  ------------------
  |  Branch (554:6): [True: 0, False: 0]
  ------------------
  555|      0|		p2p_dbg(p2p, "Too short Query Response");
  556|      0|		return;
  557|      0|	}
  558|      0|	slen = WPA_GET_LE16(pos);
  559|      0|	pos += 2;
  560|      0|	p2p_dbg(p2p, "Query Response Length: %d", slen);
  561|      0|	if (slen > end - pos) {
  ------------------
  |  Branch (561:6): [True: 0, False: 0]
  ------------------
  562|      0|		p2p_dbg(p2p, "Not enough Query Response data");
  563|      0|		return;
  564|      0|	}
  565|      0|	end = pos + slen;
  566|       |
  567|      0|	if (comeback_delay) {
  ------------------
  |  Branch (567:6): [True: 0, False: 0]
  ------------------
  568|      0|		p2p_dbg(p2p, "Fragmented response - request fragments");
  569|      0|		if (p2p->sd_rx_resp) {
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      0|			p2p_dbg(p2p, "Drop old SD reassembly buffer");
  571|      0|			wpabuf_free(p2p->sd_rx_resp);
  572|      0|			p2p->sd_rx_resp = NULL;
  573|      0|		}
  574|      0|		p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
  575|      0|		return;
  576|      0|	}
  577|       |
  578|       |	/* ANQP Query Response */
  579|      0|	if (end - pos < 4)
  ------------------
  |  Branch (579:6): [True: 0, False: 0]
  ------------------
  580|      0|		return;
  581|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (581:6): [True: 0, False: 0]
  ------------------
  582|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  583|      0|		return;
  584|      0|	}
  585|      0|	pos += 2;
  586|       |
  587|      0|	slen = WPA_GET_LE16(pos);
  588|      0|	pos += 2;
  589|      0|	if (slen > end - pos || slen < 3 + 1) {
  ------------------
  |  Branch (589:6): [True: 0, False: 0]
  |  Branch (589:26): [True: 0, False: 0]
  ------------------
  590|      0|		p2p_dbg(p2p, "Invalid ANQP Query Response length");
  591|      0|		return;
  592|      0|	}
  593|       |
  594|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1575|      0|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (594:6): [True: 0, False: 0]
  ------------------
  595|      0|		p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
  596|      0|			WPA_GET_BE32(pos));
  597|      0|		return;
  598|      0|	}
  599|      0|	pos += 4;
  600|       |
  601|      0|	if (end - pos < 2)
  ------------------
  |  Branch (601:6): [True: 0, False: 0]
  ------------------
  602|      0|		return;
  603|      0|	update_indic = WPA_GET_LE16(pos);
  604|      0|	p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
  605|      0|	pos += 2;
  606|       |
  607|      0|	p2p->sd_peer = NULL;
  608|       |
  609|      0|	if (p2p->sd_query) {
  ------------------
  |  Branch (609:6): [True: 0, False: 0]
  ------------------
  610|      0|		if (!p2p->sd_query->for_all_peers) {
  ------------------
  |  Branch (610:7): [True: 0, False: 0]
  ------------------
  611|      0|			struct p2p_sd_query *q;
  612|      0|			p2p_dbg(p2p, "Remove completed SD query %p",
  613|      0|				p2p->sd_query);
  614|      0|			q = p2p->sd_query;
  615|      0|			p2p_unlink_sd_query(p2p, p2p->sd_query);
  616|      0|			p2p_free_sd_query(q);
  617|      0|		}
  618|      0|		p2p->sd_query = NULL;
  619|      0|	}
  620|       |
  621|      0|	if (p2p->cfg->sd_response)
  ------------------
  |  Branch (621:6): [True: 0, False: 0]
  ------------------
  622|      0|		p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic,
  623|      0|				      pos, end - pos);
  624|      0|	p2p_continue_find(p2p);
  625|      0|}
p2p_rx_gas_comeback_req:
  630|     26|{
  631|     26|	struct wpabuf *resp;
  632|     26|	u8 dialog_token;
  633|     26|	size_t frag_len, max_len;
  634|     26|	int more = 0;
  635|     26|	unsigned int wait_time = 200;
  636|       |
  637|     26|	wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Request", data, len);
  638|     26|	if (len < 1)
  ------------------
  |  Branch (638:6): [True: 1, False: 25]
  ------------------
  639|      1|		return;
  640|     25|	dialog_token = *data;
  641|     25|	p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
  642|     25|	if (dialog_token != p2p->sd_resp_dialog_token) {
  ------------------
  |  Branch (642:6): [True: 23, False: 2]
  ------------------
  643|     23|		p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
  644|     23|			dialog_token);
  645|     23|		return;
  646|     23|	}
  647|       |
  648|      2|	if (p2p->sd_resp == NULL) {
  ------------------
  |  Branch (648:6): [True: 2, False: 0]
  ------------------
  649|      2|		p2p_dbg(p2p, "No pending SD response fragment available");
  650|      2|		return;
  651|      2|	}
  652|      0|	if (!ether_addr_equal(sa, p2p->sd_resp_addr)) {
  ------------------
  |  Branch (652:6): [True: 0, False: 0]
  ------------------
  653|      0|		p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  654|      0|			MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  655|      0|		return;
  656|      0|	}
  657|       |
  658|       |	/*
  659|       |	 * In the 60 GHz, we have a smaller maximum frame length for management
  660|       |	 * frames.
  661|       |	 */
  662|      0|	max_len = (rx_freq > 56160) ? 928 : 1400;
  ------------------
  |  Branch (662:12): [True: 0, False: 0]
  ------------------
  663|      0|	frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
  664|      0|	if (frag_len > max_len) {
  ------------------
  |  Branch (664:6): [True: 0, False: 0]
  ------------------
  665|      0|		frag_len = max_len;
  666|      0|		more = 1;
  667|      0|	}
  668|      0|	resp = p2p_build_gas_comeback_resp(dialog_token, WLAN_STATUS_SUCCESS,
  ------------------
  |  |  134|      0|#define WLAN_STATUS_SUCCESS 0
  ------------------
  669|      0|					   p2p->srv_update_indic,
  670|      0|					   wpabuf_head_u8(p2p->sd_resp) +
  671|      0|					   p2p->sd_resp_pos, frag_len,
  672|      0|					   p2p->sd_frag_id, more,
  673|      0|					   wpabuf_len(p2p->sd_resp));
  674|      0|	if (resp == NULL)
  ------------------
  |  Branch (674:6): [True: 0, False: 0]
  ------------------
  675|      0|		return;
  676|      0|	p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
  677|      0|		p2p->sd_frag_id, more, (int) frag_len);
  678|      0|	p2p->sd_frag_id++;
  679|      0|	p2p->sd_resp_pos += frag_len;
  680|       |
  681|      0|	if (more) {
  ------------------
  |  Branch (681:6): [True: 0, False: 0]
  ------------------
  682|      0|		p2p_dbg(p2p, "%d more bytes remain to be sent",
  683|      0|			(int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
  684|      0|	} else {
  685|      0|		p2p_dbg(p2p, "All fragments of SD response sent");
  686|      0|		wpabuf_free(p2p->sd_resp);
  687|      0|		p2p->sd_resp = NULL;
  688|      0|		wait_time = 0; /* no more SD frames in the sequence */
  689|      0|	}
  690|       |
  691|      0|	p2p->pending_action_state = P2P_NO_PENDING_ACTION;
  692|      0|	if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (692:6): [True: 0, False: 0]
  ------------------
  693|      0|			    p2p->cfg->dev_addr,
  694|      0|			    wpabuf_head(resp), wpabuf_len(resp), wait_time) < 0)
  695|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  696|       |
  697|      0|	wpabuf_free(resp);
  698|      0|}
p2p_rx_gas_comeback_resp:
  703|      1|{
  704|      1|	const u8 *pos = data;
  705|      1|	const u8 *end = data + len;
  706|      1|	const u8 *next;
  707|      1|	u8 dialog_token;
  708|      1|	u16 status_code;
  709|      1|	u8 frag_id;
  710|      1|	u8 more_frags;
  711|      1|	u16 comeback_delay;
  712|      1|	u16 slen;
  713|       |
  714|      1|	wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
  715|       |
  716|      1|	if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
  ------------------
  |  Branch (716:6): [True: 1, False: 0]
  |  Branch (716:42): [True: 0, False: 0]
  ------------------
  717|      1|	    !ether_addr_equal(sa, p2p->sd_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (717:6): [True: 0, False: 0]
  ------------------
  718|      1|		p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
  719|      1|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  720|      1|		return;
  721|      1|	}
  722|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  723|      0|	p2p_clear_timeout(p2p);
  724|       |
  725|      0|	p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
  726|      0|		MAC2STR(sa), (int) len);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  727|       |
  728|      0|	if (len < 6 + 2) {
  ------------------
  |  Branch (728:6): [True: 0, False: 0]
  ------------------
  729|      0|		p2p_dbg(p2p, "Too short GAS Comeback Response frame");
  730|      0|		return;
  731|      0|	}
  732|       |
  733|      0|	dialog_token = *pos++;
  734|       |	/* TODO: check dialog_token match */
  735|      0|	status_code = WPA_GET_LE16(pos);
  736|      0|	pos += 2;
  737|      0|	frag_id = *pos & 0x7f;
  738|      0|	more_frags = (*pos & 0x80) >> 7;
  739|      0|	pos++;
  740|      0|	comeback_delay = WPA_GET_LE16(pos);
  741|      0|	pos += 2;
  742|      0|	p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
  743|      0|		"comeback_delay=%u",
  744|      0|		dialog_token, status_code, frag_id, more_frags,
  745|      0|		comeback_delay);
  746|       |	/* TODO: check frag_id match */
  747|      0|	if (status_code) {
  ------------------
  |  Branch (747:6): [True: 0, False: 0]
  ------------------
  748|      0|		p2p_dbg(p2p, "Service Discovery failed: status code %u",
  749|      0|			status_code);
  750|      0|		return;
  751|      0|	}
  752|       |
  753|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (753:6): [True: 0, False: 0]
  ------------------
  754|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
  755|      0|			*pos);
  756|      0|		return;
  757|      0|	}
  758|      0|	pos++;
  759|       |
  760|      0|	slen = *pos++;
  761|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (761:6): [True: 0, False: 0]
  |  Branch (761:26): [True: 0, False: 0]
  ------------------
  762|      0|		p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
  763|      0|		return;
  764|      0|	}
  765|      0|	next = pos + slen;
  766|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  767|       |
  768|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (768:6): [True: 0, False: 0]
  ------------------
  769|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  770|      0|			*pos);
  771|      0|		return;
  772|      0|	}
  773|       |
  774|      0|	pos = next;
  775|       |	/* Query Response */
  776|      0|	if (end - pos < 2) {
  ------------------
  |  Branch (776:6): [True: 0, False: 0]
  ------------------
  777|      0|		p2p_dbg(p2p, "Too short Query Response");
  778|      0|		return;
  779|      0|	}
  780|      0|	slen = WPA_GET_LE16(pos);
  781|      0|	pos += 2;
  782|      0|	p2p_dbg(p2p, "Query Response Length: %d", slen);
  783|      0|	if (slen > end - pos) {
  ------------------
  |  Branch (783:6): [True: 0, False: 0]
  ------------------
  784|      0|		p2p_dbg(p2p, "Not enough Query Response data");
  785|      0|		return;
  786|      0|	}
  787|      0|	if (slen == 0) {
  ------------------
  |  Branch (787:6): [True: 0, False: 0]
  ------------------
  788|      0|		p2p_dbg(p2p, "No Query Response data");
  789|      0|		return;
  790|      0|	}
  791|      0|	end = pos + slen;
  792|       |
  793|      0|	if (p2p->sd_rx_resp) {
  ------------------
  |  Branch (793:6): [True: 0, False: 0]
  ------------------
  794|       |		 /*
  795|       |		  * ANQP header is only included in the first fragment; rest of
  796|       |		  * the fragments start with continue TLVs.
  797|       |		  */
  798|      0|		goto skip_nqp_header;
  799|      0|	}
  800|       |
  801|       |	/* ANQP Query Response */
  802|      0|	if (end - pos < 4)
  ------------------
  |  Branch (802:6): [True: 0, False: 0]
  ------------------
  803|      0|		return;
  804|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (804:6): [True: 0, False: 0]
  ------------------
  805|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  806|      0|		return;
  807|      0|	}
  808|      0|	pos += 2;
  809|       |
  810|      0|	slen = WPA_GET_LE16(pos);
  811|      0|	pos += 2;
  812|      0|	p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
  813|      0|	if (slen < 3 + 1) {
  ------------------
  |  Branch (813:6): [True: 0, False: 0]
  ------------------
  814|      0|		p2p_dbg(p2p, "Invalid ANQP Query Response length");
  815|      0|		return;
  816|      0|	}
  817|      0|	if (end - pos < 4)
  ------------------
  |  Branch (817:6): [True: 0, False: 0]
  ------------------
  818|      0|		return;
  819|       |
  820|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1575|      0|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (820:6): [True: 0, False: 0]
  ------------------
  821|      0|		p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
  822|      0|			WPA_GET_BE32(pos));
  823|      0|		return;
  824|      0|	}
  825|      0|	pos += 4;
  826|       |
  827|      0|	if (end - pos < 2)
  ------------------
  |  Branch (827:6): [True: 0, False: 0]
  ------------------
  828|      0|		return;
  829|      0|	p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
  830|      0|	p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
  831|      0|	pos += 2;
  832|       |
  833|      0|skip_nqp_header:
  834|      0|	if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
  ------------------
  |  Branch (834:6): [True: 0, False: 0]
  ------------------
  835|      0|		return;
  836|      0|	wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
  837|      0|	p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
  838|      0|		(unsigned int) wpabuf_len(p2p->sd_rx_resp));
  839|       |
  840|      0|	if (more_frags) {
  ------------------
  |  Branch (840:6): [True: 0, False: 0]
  ------------------
  841|      0|		p2p_dbg(p2p, "More fragments remains");
  842|       |		/* TODO: what would be a good size limit? */
  843|      0|		if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
  ------------------
  |  Branch (843:7): [True: 0, False: 0]
  ------------------
  844|      0|			wpabuf_free(p2p->sd_rx_resp);
  845|      0|			p2p->sd_rx_resp = NULL;
  846|      0|			p2p_dbg(p2p, "Too long SD response - drop it");
  847|      0|			return;
  848|      0|		}
  849|      0|		p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
  850|      0|		return;
  851|      0|	}
  852|       |
  853|      0|	p2p->sd_peer = NULL;
  854|       |
  855|      0|	if (p2p->sd_query) {
  ------------------
  |  Branch (855:6): [True: 0, False: 0]
  ------------------
  856|      0|		if (!p2p->sd_query->for_all_peers) {
  ------------------
  |  Branch (856:7): [True: 0, False: 0]
  ------------------
  857|      0|			struct p2p_sd_query *q;
  858|      0|			p2p_dbg(p2p, "Remove completed SD query %p",
  859|      0|				p2p->sd_query);
  860|      0|			q = p2p->sd_query;
  861|      0|			p2p_unlink_sd_query(p2p, p2p->sd_query);
  862|      0|			p2p_free_sd_query(q);
  863|      0|		}
  864|      0|		p2p->sd_query = NULL;
  865|      0|	}
  866|       |
  867|      0|	if (p2p->cfg->sd_response)
  ------------------
  |  Branch (867:6): [True: 0, False: 0]
  ------------------
  868|      0|		p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa,
  869|      0|				      p2p->sd_rx_update_indic,
  870|      0|				      wpabuf_head(p2p->sd_rx_resp),
  871|      0|				      wpabuf_len(p2p->sd_rx_resp));
  872|      0|	wpabuf_free(p2p->sd_rx_resp);
  873|      0|	p2p->sd_rx_resp = NULL;
  874|       |
  875|      0|	p2p_continue_find(p2p);
  876|      0|}

p2p_channel_to_freq:
   58|    562|{
   59|       |	return ieee80211_chan_to_freq(NULL, op_class, channel);
   60|    562|}
p2p_channels_intersect:
  114|    285|{
  115|    285|	size_t i, j;
  116|       |
  117|    285|	os_memset(res, 0, sizeof(*res));
  ------------------
  |  |  529|    285|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  118|       |
  119|    568|	for (i = 0; i < a->reg_classes; i++) {
  ------------------
  |  Branch (119:14): [True: 285, False: 283]
  ------------------
  120|    285|		const struct p2p_reg_class *a_reg = &a->reg_class[i];
  121|  1.44k|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (121:15): [True: 1.15k, False: 283]
  ------------------
  122|  1.15k|			const struct p2p_reg_class *b_reg = &b->reg_class[j];
  123|  1.15k|			if (a_reg->reg_class != b_reg->reg_class)
  ------------------
  |  Branch (123:8): [True: 473, False: 686]
  ------------------
  124|    473|				continue;
  125|    686|			p2p_reg_class_intersect(
  126|    686|				a_reg, b_reg,
  127|    686|				&res->reg_class[res->reg_classes]);
  128|    686|			if (res->reg_class[res->reg_classes].channels) {
  ------------------
  |  Branch (128:8): [True: 588, False: 98]
  ------------------
  129|    588|				res->reg_classes++;
  130|    588|				if (res->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|    588|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (130:9): [True: 2, False: 586]
  ------------------
  131|      2|					return;
  132|    588|			}
  133|    686|		}
  134|    285|	}
  135|    285|}
p2p_channels_union_inplace:
  164|    192|{
  165|    192|	size_t i, j;
  166|       |
  167|    384|	for (i = 0; i < res->reg_classes; i++) {
  ------------------
  |  Branch (167:14): [True: 192, False: 192]
  ------------------
  168|    192|		struct p2p_reg_class *cl = &res->reg_class[i];
  169|    192|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (169:15): [True: 0, False: 192]
  ------------------
  170|      0|			const struct p2p_reg_class *b_cl = &b->reg_class[j];
  171|      0|			if (cl->reg_class != b_cl->reg_class)
  ------------------
  |  Branch (171:8): [True: 0, False: 0]
  ------------------
  172|      0|				continue;
  173|      0|			p2p_op_class_union(cl, b_cl);
  174|      0|		}
  175|    192|	}
  176|       |
  177|    192|	for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (177:14): [True: 0, False: 192]
  ------------------
  178|      0|		const struct p2p_reg_class *b_cl = &b->reg_class[j];
  179|       |
  180|      0|		for (i = 0; i < res->reg_classes; i++) {
  ------------------
  |  Branch (180:15): [True: 0, False: 0]
  ------------------
  181|      0|			struct p2p_reg_class *cl = &res->reg_class[i];
  182|      0|			if (cl->reg_class == b_cl->reg_class)
  ------------------
  |  Branch (182:8): [True: 0, False: 0]
  ------------------
  183|      0|				break;
  184|      0|		}
  185|       |
  186|      0|		if (i == res->reg_classes) {
  ------------------
  |  Branch (186:7): [True: 0, False: 0]
  ------------------
  187|      0|			if (res->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|      0|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (187:8): [True: 0, False: 0]
  ------------------
  188|      0|				return;
  189|      0|			os_memcpy(&res->reg_class[res->reg_classes++],
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  190|      0|				  b_cl, sizeof(struct p2p_reg_class));
  191|      0|		}
  192|      0|	}
  193|    192|}
p2p_channels_union:
  205|    192|{
  206|    192|	os_memcpy(res, a, sizeof(*res));
  ------------------
  |  |  523|    192|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  207|    192|	p2p_channels_union_inplace(res, b);
  208|    192|}
p2p_channels_includes:
  256|     45|{
  257|     45|	size_t i, j;
  258|    154|	for (i = 0; i < channels->reg_classes; i++) {
  ------------------
  |  Branch (258:14): [True: 111, False: 43]
  ------------------
  259|    111|		const struct p2p_reg_class *reg = &channels->reg_class[i];
  260|    111|		if (reg->reg_class != reg_class)
  ------------------
  |  Branch (260:7): [True: 61, False: 50]
  ------------------
  261|     61|			continue;
  262|    173|		for (j = 0; j < reg->channels; j++) {
  ------------------
  |  Branch (262:15): [True: 125, False: 48]
  ------------------
  263|    125|			if (reg->channel[j] == channel)
  ------------------
  |  Branch (263:8): [True: 2, False: 123]
  ------------------
  264|      2|				return 1;
  265|    125|		}
  266|     50|	}
  267|     43|	return 0;
  268|     45|}
p2p_channels_dump:
  343|  14.2k|{
  344|  14.2k|	char buf[500], *pos, *end;
  345|  14.2k|	size_t i, j;
  346|  14.2k|	int ret;
  347|       |
  348|  14.2k|	pos = buf;
  349|  14.2k|	end = pos + sizeof(buf);
  350|       |
  351|  22.2k|	for (i = 0; i < chan->reg_classes; i++) {
  ------------------
  |  Branch (351:14): [True: 7.94k, False: 14.2k]
  ------------------
  352|  7.94k|		const struct p2p_reg_class *c;
  353|  7.94k|		c = &chan->reg_class[i];
  354|  7.94k|		ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
  ------------------
  |  |  572|  7.94k|#define os_snprintf snprintf
  ------------------
  355|  7.94k|		if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (355:7): [True: 2, False: 7.94k]
  ------------------
  356|      2|			break;
  357|  7.94k|		pos += ret;
  358|       |
  359|  26.0k|		for (j = 0; j < c->channels; j++) {
  ------------------
  |  Branch (359:15): [True: 18.1k, False: 7.93k]
  ------------------
  360|  18.1k|			ret = os_snprintf(pos, end - pos, "%s%u",
  ------------------
  |  |  572|  18.1k|#define os_snprintf snprintf
  ------------------
  361|  18.1k|					  j == 0 ? "" : ",",
  ------------------
  |  Branch (361:8): [True: 7.83k, False: 10.3k]
  ------------------
  362|  18.1k|					  c->channel[j]);
  363|  18.1k|			if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (363:8): [True: 5, False: 18.1k]
  ------------------
  364|      5|				break;
  365|  18.1k|			pos += ret;
  366|  18.1k|		}
  367|  7.94k|	}
  368|  14.2k|	*pos = '\0';
  369|       |
  370|  14.2k|	p2p_dbg(p2p, "%s:%s", title, buf);
  371|  14.2k|}
p2p_copy_channels:
  503|     55|{
  504|     55|	size_t i, j;
  505|       |
  506|     55|	if (allow_6ghz) {
  ------------------
  |  Branch (506:6): [True: 0, False: 55]
  ------------------
  507|      0|		os_memcpy(dst, src, sizeof(struct p2p_channels));
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  508|      0|		return;
  509|      0|	}
  510|       |
  511|     55|	for (i = 0, j = 0; i < src->reg_classes; i++) {
  ------------------
  |  Branch (511:21): [True: 0, False: 55]
  ------------------
  512|      0|		if (is_6ghz_op_class(src->reg_class[i].reg_class))
  ------------------
  |  Branch (512:7): [True: 0, False: 0]
  ------------------
  513|      0|			continue;
  514|      0|		os_memcpy(&dst->reg_class[j], &src->reg_class[i],
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  515|      0|			  sizeof(struct p2p_reg_class));
  516|      0|		j++;
  517|      0|	}
  518|     55|	dst->reg_classes = j;
  519|     55|}
p2p_utils.c:p2p_reg_class_intersect:
   82|    686|{
   83|    686|	size_t i, j;
   84|       |
   85|    686|	res->reg_class = a->reg_class;
   86|       |
   87|  2.05k|	for (i = 0; i < a->channels; i++) {
  ------------------
  |  Branch (87:14): [True: 1.37k, False: 678]
  ------------------
   88|  9.36k|		for (j = 0; j < b->channels; j++) {
  ------------------
  |  Branch (88:15): [True: 8.00k, False: 1.36k]
  ------------------
   89|  8.00k|			if (a->channel[i] != b->channel[j])
  ------------------
  |  Branch (89:8): [True: 5.73k, False: 2.27k]
  ------------------
   90|  5.73k|				continue;
   91|  2.27k|			res->channel[res->channels] = a->channel[i];
   92|  2.27k|			res->channels++;
   93|  2.27k|			if (res->channels == P2P_MAX_REG_CLASS_CHANNELS)
  ------------------
  |  |   52|  2.27k|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
  |  Branch (93:8): [True: 8, False: 2.26k]
  ------------------
   94|      8|				return;
   95|  2.27k|		}
   96|  1.37k|	}
   97|    686|}

printf_encode:
  478|  7.11k|{
  479|  7.11k|	char *end = txt + maxlen;
  480|  7.11k|	size_t i;
  481|       |
  482|   161k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (482:14): [True: 154k, False: 7.11k]
  ------------------
  483|   154k|		if (txt + 4 >= end)
  ------------------
  |  Branch (483:7): [True: 0, False: 154k]
  ------------------
  484|      0|			break;
  485|       |
  486|   154k|		switch (data[i]) {
  487|  7.14k|		case '\"':
  ------------------
  |  Branch (487:3): [True: 7.14k, False: 147k]
  ------------------
  488|  7.14k|			*txt++ = '\\';
  489|  7.14k|			*txt++ = '\"';
  490|  7.14k|			break;
  491|    208|		case '\\':
  ------------------
  |  Branch (491:3): [True: 208, False: 154k]
  ------------------
  492|    208|			*txt++ = '\\';
  493|    208|			*txt++ = '\\';
  494|    208|			break;
  495|    200|		case '\033':
  ------------------
  |  Branch (495:3): [True: 200, False: 154k]
  ------------------
  496|    200|			*txt++ = '\\';
  497|    200|			*txt++ = 'e';
  498|    200|			break;
  499|    393|		case '\n':
  ------------------
  |  Branch (499:3): [True: 393, False: 153k]
  ------------------
  500|    393|			*txt++ = '\\';
  501|    393|			*txt++ = 'n';
  502|    393|			break;
  503|    325|		case '\r':
  ------------------
  |  Branch (503:3): [True: 325, False: 153k]
  ------------------
  504|    325|			*txt++ = '\\';
  505|    325|			*txt++ = 'r';
  506|    325|			break;
  507|  11.7k|		case '\t':
  ------------------
  |  Branch (507:3): [True: 11.7k, False: 142k]
  ------------------
  508|  11.7k|			*txt++ = '\\';
  509|  11.7k|			*txt++ = 't';
  510|  11.7k|			break;
  511|   134k|		default:
  ------------------
  |  Branch (511:3): [True: 134k, False: 19.9k]
  ------------------
  512|   134k|			if (data[i] >= 32 && data[i] <= 126) {
  ------------------
  |  Branch (512:8): [True: 36.5k, False: 97.7k]
  |  Branch (512:25): [True: 15.0k, False: 21.5k]
  ------------------
  513|  15.0k|				*txt++ = data[i];
  514|   119k|			} else {
  515|   119k|				txt += os_snprintf(txt, end - txt, "\\x%02x",
  ------------------
  |  |  572|   119k|#define os_snprintf snprintf
  ------------------
  516|   119k|						   data[i]);
  517|   119k|			}
  518|   134k|			break;
  519|   154k|		}
  520|   154k|	}
  521|       |
  522|  7.11k|	*txt = '\0';
  523|  7.11k|}
wpa_ssid_txt:
  623|  7.11k|{
  624|  7.11k|	static char ssid_txt[SSID_MAX_LEN * 4 + 1];
  625|       |
  626|  7.11k|	if (ssid == NULL) {
  ------------------
  |  Branch (626:6): [True: 0, False: 7.11k]
  ------------------
  627|      0|		ssid_txt[0] = '\0';
  628|      0|		return ssid_txt;
  629|      0|	}
  630|       |
  631|  7.11k|	printf_encode(ssid_txt, sizeof(ssid_txt), ssid, ssid_len);
  632|  7.11k|	return ssid_txt;
  633|  7.11k|}
has_ctrl_char:
  712|  7.36k|{
  713|  7.36k|	size_t i;
  714|       |
  715|  16.9k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (715:14): [True: 12.7k, False: 4.23k]
  ------------------
  716|  12.7k|		if (data[i] < 32 || data[i] == 127)
  ------------------
  |  Branch (716:7): [True: 2.94k, False: 9.75k]
  |  Branch (716:23): [True: 178, False: 9.57k]
  ------------------
  717|  3.12k|			return 1;
  718|  12.7k|	}
  719|  4.23k|	return 0;
  720|  7.36k|}
is_ctrl_char:
 1226|  26.3k|{
 1227|  26.3k|	return c > 0 && c < 32;
  ------------------
  |  Branch (1227:9): [True: 19.6k, False: 6.65k]
  |  Branch (1227:18): [True: 6.01k, False: 13.6k]
  ------------------
 1228|  26.3k|}

p2p.c:WPA_GET_LE16:
  225|     16|{
  226|     16|	return (a[1] << 8) | a[0];
  227|     16|}
p2p.c:WPA_GET_BE32:
  260|  24.5k|{
  261|  24.5k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  24.5k|}
p2p.c:is_zero_ether_addr:
  562|  1.95k|{
  563|  1.95k|	return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
  564|  1.95k|}
p2p.c:is_broadcast_ether_addr:
  567|  2.52k|{
  568|  2.52k|	return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
  569|  2.52k|}
p2p.c:ether_addr_equal:
  577|  8.22k|{
  578|  8.22k|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|  8.22k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|  8.22k|}
p2p_go_neg.c:ether_addr_equal:
  577|     39|{
  578|     39|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|     39|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|     39|}
p2p_parse.c:WPA_GET_LE16:
  225|  45.7k|{
  226|  45.7k|	return (a[1] << 8) | a[0];
  227|  45.7k|}
p2p_parse.c:WPA_GET_LE32:
  273|  2.61k|{
  274|  2.61k|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|  2.61k|}
p2p_parse.c:WPA_GET_BE16:
  214|  8.24k|{
  215|  8.24k|	return (a[0] << 8) | a[1];
  216|  8.24k|}
p2p_pd.c:WPA_GET_LE16:
  225|     94|{
  226|     94|	return (a[1] << 8) | a[0];
  227|     94|}
p2p_pd.c:WPA_GET_LE32:
  273|    171|{
  274|    171|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|    171|}
p2p_pd.c:WPA_PUT_BE32:
  265|    796|{
  266|    796|	a[0] = (val >> 24) & 0xff;
  267|    796|	a[1] = (val >> 16) & 0xff;
  268|    796|	a[2] = (val >> 8) & 0xff;
  269|    796|	a[3] = val & 0xff;
  270|    796|}
p2p_pd.c:WPA_PUT_BE16:
  219|  2.38k|{
  220|  2.38k|	a[0] = val >> 8;
  221|  2.38k|	a[1] = val & 0xff;
  222|  2.38k|}
p2p_pd.c:ether_addr_equal:
  577|      7|{
  578|      7|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|      7|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|      7|}
p2p_build.c:WPA_PUT_BE32:
  265|  3.39k|{
  266|  3.39k|	a[0] = (val >> 24) & 0xff;
  267|  3.39k|	a[1] = (val >> 16) & 0xff;
  268|  3.39k|	a[2] = (val >> 8) & 0xff;
  269|  3.39k|	a[3] = val & 0xff;
  270|  3.39k|}
p2p_build.c:WPA_PUT_LE16:
  230|  3.08k|{
  231|  3.08k|	a[1] = val >> 8;
  232|  3.08k|	a[0] = val & 0xff;
  233|  3.08k|}
p2p_build.c:WPA_PUT_BE16:
  219|    311|{
  220|    311|	a[0] = val >> 8;
  221|    311|	a[1] = val & 0xff;
  222|    311|}
wps_attr_build.c:WPA_PUT_BE24:
  241|     36|{
  242|     36|	a[0] = (val >> 16) & 0xff;
  243|     36|	a[1] = (val >> 8) & 0xff;
  244|     36|	a[2] = val & 0xff;
  245|     36|}
wps_attr_build.c:WPA_PUT_BE16:
  219|    148|{
  220|    148|	a[0] = val >> 8;
  221|    148|	a[1] = val & 0xff;
  222|    148|}
wps_attr_parse.c:WPA_GET_BE16:
  214|  3.78M|{
  215|  3.78M|	return (a[0] << 8) | a[1];
  216|  3.78M|}
wps_attr_parse.c:WPA_GET_BE24:
  236|  1.81k|{
  237|  1.81k|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.81k|}
wps_common.c:WPA_GET_BE16:
  214|  4.64k|{
  215|  4.64k|	return (a[0] << 8) | a[1];
  216|  4.64k|}
wps_common.c:WPA_GET_BE32:
  260|  2.32k|{
  261|  2.32k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  2.32k|}
ieee802_11_common.c:WPA_GET_BE24:
  236|  1.12M|{
  237|  1.12M|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.12M|}
ieee802_11_common.c:WPA_GET_BE32:
  260|  1.20M|{
  261|  1.20M|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.20M|}
sha256-internal.c:WPA_GET_BE32:
  260|   110k|{
  261|   110k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|   110k|}
sha256-internal.c:WPA_PUT_BE64:
  311|  6.88k|{
  312|  6.88k|	a[0] = val >> 56;
  313|  6.88k|	a[1] = val >> 48;
  314|  6.88k|	a[2] = val >> 40;
  315|  6.88k|	a[3] = val >> 32;
  316|  6.88k|	a[4] = val >> 24;
  317|  6.88k|	a[5] = val >> 16;
  318|  6.88k|	a[6] = val >> 8;
  319|  6.88k|	a[7] = val & 0xff;
  320|  6.88k|}
sha256-internal.c:WPA_PUT_BE32:
  265|  55.0k|{
  266|  55.0k|	a[0] = (val >> 24) & 0xff;
  267|  55.0k|	a[1] = (val >> 16) & 0xff;
  268|  55.0k|	a[2] = (val >> 8) & 0xff;
  269|  55.0k|	a[3] = val & 0xff;
  270|  55.0k|}

eloop_init:
  164|  6.88k|{
  165|  6.88k|	os_memset(&eloop, 0, sizeof(eloop));
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  166|  6.88k|	dl_list_init(&eloop.timeout);
  167|       |#ifdef CONFIG_ELOOP_EPOLL
  168|       |	eloop.epollfd = epoll_create1(0);
  169|       |	if (eloop.epollfd < 0) {
  170|       |		wpa_printf(MSG_ERROR, "%s: epoll_create1 failed. %s",
  171|       |			   __func__, strerror(errno));
  172|       |		return -1;
  173|       |	}
  174|       |#endif /* CONFIG_ELOOP_EPOLL */
  175|       |#ifdef CONFIG_ELOOP_KQUEUE
  176|       |	eloop.kqueuefd = kqueue();
  177|       |	if (eloop.kqueuefd < 0) {
  178|       |		wpa_printf(MSG_ERROR, "%s: kqueue failed: %s",
  179|       |			   __func__, strerror(errno));
  180|       |		return -1;
  181|       |	}
  182|       |#endif /* CONFIG_ELOOP_KQUEUE */
  183|       |#if defined(CONFIG_ELOOP_EPOLL) || defined(CONFIG_ELOOP_KQUEUE)
  184|       |	eloop.readers.type = EVENT_TYPE_READ;
  185|       |	eloop.writers.type = EVENT_TYPE_WRITE;
  186|       |	eloop.exceptions.type = EVENT_TYPE_EXCEPTION;
  187|       |#endif /* CONFIG_ELOOP_EPOLL || CONFIG_ELOOP_KQUEUE */
  188|       |#ifdef WPA_TRACE
  189|       |	signal(SIGSEGV, eloop_sigsegv_handler);
  190|       |#endif /* WPA_TRACE */
  191|  6.88k|	return 0;
  192|  6.88k|}
eloop_register_timeout:
  776|  6.88k|{
  777|  6.88k|	struct eloop_timeout *timeout, *tmp;
  778|  6.88k|	os_time_t now_sec;
  779|       |
  780|  6.88k|	timeout = os_zalloc(sizeof(*timeout));
  781|  6.88k|	if (timeout == NULL)
  ------------------
  |  Branch (781:6): [True: 0, False: 6.88k]
  ------------------
  782|      0|		return -1;
  783|  6.88k|	if (os_get_reltime(&timeout->time) < 0) {
  ------------------
  |  Branch (783:6): [True: 0, False: 6.88k]
  ------------------
  784|      0|		os_free(timeout);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  785|      0|		return -1;
  786|      0|	}
  787|  6.88k|	now_sec = timeout->time.sec;
  788|  6.88k|	timeout->time.sec += secs;
  789|  6.88k|	if (timeout->time.sec < now_sec)
  ------------------
  |  Branch (789:6): [True: 0, False: 6.88k]
  ------------------
  790|      0|		goto overflow;
  791|  6.88k|	timeout->time.usec += usecs;
  792|  6.88k|	while (timeout->time.usec >= 1000000) {
  ------------------
  |  Branch (792:9): [True: 0, False: 6.88k]
  ------------------
  793|      0|		timeout->time.sec++;
  794|      0|		timeout->time.usec -= 1000000;
  795|      0|	}
  796|  6.88k|	if (timeout->time.sec < now_sec)
  ------------------
  |  Branch (796:6): [True: 0, False: 6.88k]
  ------------------
  797|      0|		goto overflow;
  798|  6.88k|	timeout->eloop_data = eloop_data;
  799|  6.88k|	timeout->user_data = user_data;
  800|  6.88k|	timeout->handler = handler;
  801|  6.88k|	wpa_trace_add_ref(timeout, eloop, eloop_data);
  ------------------
  |  |   63|  6.88k|#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (63:58): [Folded, False: 6.88k]
  |  |  ------------------
  ------------------
  802|  6.88k|	wpa_trace_add_ref(timeout, user, user_data);
  ------------------
  |  |   63|  6.88k|#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (63:58): [Folded, False: 6.88k]
  |  |  ------------------
  ------------------
  803|  6.88k|	wpa_trace_record(timeout);
  ------------------
  |  |   61|  6.88k|#define wpa_trace_record(ptr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (61:45): [Folded, False: 6.88k]
  |  |  ------------------
  ------------------
  804|       |
  805|       |	/* Maintain timeouts in order of increasing time */
  806|  6.88k|	dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
  ------------------
  |  |   79|  6.88k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  6.88k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 0, False: 6.88k]
  |  |  ------------------
  |  |   81|  6.88k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  807|      0|		if (os_reltime_before(&timeout->time, &tmp->time)) {
  ------------------
  |  Branch (807:7): [True: 0, False: 0]
  ------------------
  808|      0|			dl_list_add(tmp->list.prev, &timeout->list);
  809|      0|			return 0;
  810|      0|		}
  811|      0|	}
  812|  6.88k|	dl_list_add_tail(&eloop.timeout, &timeout->list);
  813|       |
  814|  6.88k|	return 0;
  815|       |
  816|      0|overflow:
  817|       |	/*
  818|       |	 * Integer overflow - assume long enough timeout to be assumed
  819|       |	 * to be infinite, i.e., the timeout would never happen.
  820|       |	 */
  821|      0|	wpa_printf(MSG_DEBUG,
  822|      0|		   "ELOOP: Too long timeout (secs=%u usecs=%u) to ever happen - ignore it",
  823|      0|		   secs,usecs);
  824|      0|	os_free(timeout);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  825|      0|	return 0;
  826|  6.88k|}
eloop_cancel_timeout:
  840|  48.1k|{
  841|  48.1k|	struct eloop_timeout *timeout, *prev;
  842|  48.1k|	int removed = 0;
  843|       |
  844|  48.1k|	dl_list_for_each_safe(timeout, prev, &eloop.timeout,
  ------------------
  |  |   84|  48.1k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  48.1k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  48.1k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  48.1k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  48.1k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 0, False: 48.1k]
  |  |  ------------------
  |  |   87|  48.1k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  845|  48.1k|			      struct eloop_timeout, list) {
  846|      0|		if (timeout->handler == handler &&
  ------------------
  |  Branch (846:7): [True: 0, False: 0]
  ------------------
  847|      0|		    (timeout->eloop_data == eloop_data ||
  ------------------
  |  Branch (847:8): [True: 0, False: 0]
  ------------------
  848|      0|		     eloop_data == ELOOP_ALL_CTX) &&
  ------------------
  |  |   23|      0|#define ELOOP_ALL_CTX (void *) -1
  ------------------
  |  Branch (848:8): [True: 0, False: 0]
  ------------------
  849|      0|		    (timeout->user_data == user_data ||
  ------------------
  |  Branch (849:8): [True: 0, False: 0]
  ------------------
  850|      0|		     user_data == ELOOP_ALL_CTX)) {
  ------------------
  |  |   23|      0|#define ELOOP_ALL_CTX (void *) -1
  ------------------
  |  Branch (850:8): [True: 0, False: 0]
  ------------------
  851|      0|			eloop_remove_timeout(timeout);
  852|      0|			removed++;
  853|      0|		}
  854|      0|	}
  855|       |
  856|  48.1k|	return removed;
  857|  48.1k|}
eloop_run:
 1076|  6.88k|{
 1077|       |#ifdef CONFIG_ELOOP_POLL
 1078|       |	int num_poll_fds;
 1079|       |	int timeout_ms = 0;
 1080|       |#endif /* CONFIG_ELOOP_POLL */
 1081|  6.88k|#ifdef CONFIG_ELOOP_SELECT
 1082|  6.88k|	fd_set *rfds, *wfds, *efds;
 1083|  6.88k|	struct timeval _tv;
 1084|  6.88k|#endif /* CONFIG_ELOOP_SELECT */
 1085|       |#ifdef CONFIG_ELOOP_EPOLL
 1086|       |	int timeout_ms = -1;
 1087|       |#endif /* CONFIG_ELOOP_EPOLL */
 1088|       |#ifdef CONFIG_ELOOP_KQUEUE
 1089|       |	struct timespec ts;
 1090|       |#endif /* CONFIG_ELOOP_KQUEUE */
 1091|  6.88k|	int res;
 1092|  6.88k|	struct os_reltime tv, now;
 1093|       |
 1094|  6.88k|#ifdef CONFIG_ELOOP_SELECT
 1095|  6.88k|	rfds = os_malloc(sizeof(*rfds));
  ------------------
  |  |  505|  6.88k|#define os_malloc(s) malloc((s))
  ------------------
 1096|  6.88k|	wfds = os_malloc(sizeof(*wfds));
  ------------------
  |  |  505|  6.88k|#define os_malloc(s) malloc((s))
  ------------------
 1097|  6.88k|	efds = os_malloc(sizeof(*efds));
  ------------------
  |  |  505|  6.88k|#define os_malloc(s) malloc((s))
  ------------------
 1098|  6.88k|	if (rfds == NULL || wfds == NULL || efds == NULL)
  ------------------
  |  Branch (1098:6): [True: 0, False: 6.88k]
  |  Branch (1098:22): [True: 0, False: 6.88k]
  |  Branch (1098:38): [True: 0, False: 6.88k]
  ------------------
 1099|      0|		goto out;
 1100|  6.88k|#endif /* CONFIG_ELOOP_SELECT */
 1101|       |
 1102|  13.7k|	while (!eloop.terminate &&
  ------------------
  |  Branch (1102:9): [True: 6.88k, False: 6.88k]
  ------------------
 1103|  6.88k|	       (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 ||
  ------------------
  |  Branch (1103:10): [True: 6.88k, False: 0]
  |  Branch (1103:44): [True: 0, False: 0]
  ------------------
 1104|  6.88k|		eloop.writers.count > 0 || eloop.exceptions.count > 0)) {
  ------------------
  |  Branch (1104:3): [True: 0, False: 0]
  |  Branch (1104:30): [True: 0, False: 0]
  ------------------
 1105|  6.88k|		struct eloop_timeout *timeout;
 1106|       |
 1107|  6.88k|		if (eloop.pending_terminate) {
  ------------------
  |  Branch (1107:7): [True: 0, False: 6.88k]
  ------------------
 1108|       |			/*
 1109|       |			 * This may happen in some corner cases where a signal
 1110|       |			 * is received during a blocking operation. We need to
 1111|       |			 * process the pending signals and exit if requested to
 1112|       |			 * avoid hitting the SIGALRM limit if the blocking
 1113|       |			 * operation took more than two seconds.
 1114|       |			 */
 1115|      0|			eloop_process_pending_signals();
 1116|      0|			if (eloop.terminate)
  ------------------
  |  Branch (1116:8): [True: 0, False: 0]
  ------------------
 1117|      0|				break;
 1118|      0|		}
 1119|       |
 1120|  6.88k|		timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
  ------------------
  |  |   71|  6.88k|	(dl_list_empty((list)) ? NULL : \
  |  |  ------------------
  |  |  |  Branch (71:3): [True: 0, False: 6.88k]
  |  |  ------------------
  |  |   72|  6.88k|	 dl_list_entry((list)->next, type, member))
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1121|  6.88k|					list);
 1122|  6.88k|		if (timeout) {
  ------------------
  |  Branch (1122:7): [True: 6.88k, False: 0]
  ------------------
 1123|  6.88k|			os_get_reltime(&now);
 1124|  6.88k|			if (os_reltime_before(&now, &timeout->time))
  ------------------
  |  Branch (1124:8): [True: 0, False: 6.88k]
  ------------------
 1125|      0|				os_reltime_sub(&timeout->time, &now, &tv);
 1126|  6.88k|			else
 1127|  6.88k|				tv.sec = tv.usec = 0;
 1128|       |#if defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL)
 1129|       |			timeout_ms = tv.sec * 1000 + tv.usec / 1000;
 1130|       |#endif /* defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL) */
 1131|  6.88k|#ifdef CONFIG_ELOOP_SELECT
 1132|  6.88k|			_tv.tv_sec = tv.sec;
 1133|  6.88k|			_tv.tv_usec = tv.usec;
 1134|  6.88k|#endif /* CONFIG_ELOOP_SELECT */
 1135|       |#ifdef CONFIG_ELOOP_KQUEUE
 1136|       |			ts.tv_sec = tv.sec;
 1137|       |			ts.tv_nsec = tv.usec * 1000L;
 1138|       |#endif /* CONFIG_ELOOP_KQUEUE */
 1139|  6.88k|		}
 1140|       |
 1141|       |#ifdef CONFIG_ELOOP_POLL
 1142|       |		num_poll_fds = eloop_sock_table_set_fds(
 1143|       |			&eloop.readers, &eloop.writers, &eloop.exceptions,
 1144|       |			eloop.pollfds, eloop.pollfds_map,
 1145|       |			eloop.max_pollfd_map);
 1146|       |		res = poll(eloop.pollfds, num_poll_fds,
 1147|       |			   timeout ? timeout_ms : -1);
 1148|       |#endif /* CONFIG_ELOOP_POLL */
 1149|  6.88k|#ifdef CONFIG_ELOOP_SELECT
 1150|  6.88k|		eloop_sock_table_set_fds(&eloop.readers, rfds);
 1151|  6.88k|		eloop_sock_table_set_fds(&eloop.writers, wfds);
 1152|  6.88k|		eloop_sock_table_set_fds(&eloop.exceptions, efds);
 1153|  6.88k|		res = select(eloop.max_sock + 1, rfds, wfds, efds,
 1154|  6.88k|			     timeout ? &_tv : NULL);
  ------------------
  |  Branch (1154:9): [True: 6.88k, False: 0]
  ------------------
 1155|  6.88k|#endif /* CONFIG_ELOOP_SELECT */
 1156|       |#ifdef CONFIG_ELOOP_EPOLL
 1157|       |		if (eloop.count == 0) {
 1158|       |			res = 0;
 1159|       |		} else {
 1160|       |			res = epoll_wait(eloop.epollfd, eloop.epoll_events,
 1161|       |					 eloop.count, timeout_ms);
 1162|       |		}
 1163|       |#endif /* CONFIG_ELOOP_EPOLL */
 1164|       |#ifdef CONFIG_ELOOP_KQUEUE
 1165|       |		if (eloop.count == 0) {
 1166|       |			res = 0;
 1167|       |		} else {
 1168|       |			res = kevent(eloop.kqueuefd, NULL, 0,
 1169|       |				     eloop.kqueue_events, eloop.kqueue_nevents,
 1170|       |				     timeout ? &ts : NULL);
 1171|       |		}
 1172|       |#endif /* CONFIG_ELOOP_KQUEUE */
 1173|  6.88k|		if (res < 0 && errno != EINTR && errno != 0) {
  ------------------
  |  Branch (1173:7): [True: 0, False: 6.88k]
  |  Branch (1173:18): [True: 0, False: 0]
  |  Branch (1173:36): [True: 0, False: 0]
  ------------------
 1174|      0|			wpa_printf(MSG_ERROR, "eloop: %s: %s",
 1175|       |#ifdef CONFIG_ELOOP_POLL
 1176|       |				   "poll"
 1177|       |#endif /* CONFIG_ELOOP_POLL */
 1178|      0|#ifdef CONFIG_ELOOP_SELECT
 1179|      0|				   "select"
 1180|      0|#endif /* CONFIG_ELOOP_SELECT */
 1181|       |#ifdef CONFIG_ELOOP_EPOLL
 1182|       |				   "epoll"
 1183|       |#endif /* CONFIG_ELOOP_EPOLL */
 1184|       |#ifdef CONFIG_ELOOP_KQUEUE
 1185|       |				   "kqueue"
 1186|       |#endif /* CONFIG_ELOOP_EKQUEUE */
 1187|       |
 1188|      0|				   , strerror(errno));
 1189|      0|			goto out;
 1190|      0|		}
 1191|       |
 1192|  6.88k|		eloop.readers.changed = 0;
 1193|  6.88k|		eloop.writers.changed = 0;
 1194|  6.88k|		eloop.exceptions.changed = 0;
 1195|       |
 1196|  6.88k|		eloop_process_pending_signals();
 1197|       |
 1198|       |
 1199|       |		/* check if some registered timeouts have occurred */
 1200|  6.88k|		timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
  ------------------
  |  |   71|  6.88k|	(dl_list_empty((list)) ? NULL : \
  |  |  ------------------
  |  |  |  Branch (71:3): [True: 0, False: 6.88k]
  |  |  ------------------
  |  |   72|  6.88k|	 dl_list_entry((list)->next, type, member))
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1201|  6.88k|					list);
 1202|  6.88k|		if (timeout) {
  ------------------
  |  Branch (1202:7): [True: 6.88k, False: 0]
  ------------------
 1203|  6.88k|			os_get_reltime(&now);
 1204|  6.88k|			if (!os_reltime_before(&now, &timeout->time)) {
  ------------------
  |  Branch (1204:8): [True: 6.88k, False: 0]
  ------------------
 1205|  6.88k|				void *eloop_data = timeout->eloop_data;
 1206|  6.88k|				void *user_data = timeout->user_data;
 1207|  6.88k|				eloop_timeout_handler handler =
 1208|  6.88k|					timeout->handler;
 1209|  6.88k|				eloop_remove_timeout(timeout);
 1210|  6.88k|				handler(eloop_data, user_data);
 1211|  6.88k|			}
 1212|       |
 1213|  6.88k|		}
 1214|       |
 1215|  6.88k|		if (res <= 0)
  ------------------
  |  Branch (1215:7): [True: 6.88k, False: 0]
  ------------------
 1216|  6.88k|			continue;
 1217|       |
 1218|      0|		if (eloop.readers.changed ||
  ------------------
  |  Branch (1218:7): [True: 0, False: 0]
  ------------------
 1219|      0|		    eloop.writers.changed ||
  ------------------
  |  Branch (1219:7): [True: 0, False: 0]
  ------------------
 1220|      0|		    eloop.exceptions.changed) {
  ------------------
  |  Branch (1220:7): [True: 0, False: 0]
  ------------------
 1221|       |			 /*
 1222|       |			  * Sockets may have been closed and reopened with the
 1223|       |			  * same FD in the signal or timeout handlers, so we
 1224|       |			  * must skip the previous results and check again
 1225|       |			  * whether any of the currently registered sockets have
 1226|       |			  * events.
 1227|       |			  */
 1228|      0|			continue;
 1229|      0|		}
 1230|       |
 1231|       |#ifdef CONFIG_ELOOP_POLL
 1232|       |		eloop_sock_table_dispatch(&eloop.readers, &eloop.writers,
 1233|       |					  &eloop.exceptions, eloop.pollfds_map,
 1234|       |					  eloop.max_pollfd_map);
 1235|       |#endif /* CONFIG_ELOOP_POLL */
 1236|      0|#ifdef CONFIG_ELOOP_SELECT
 1237|      0|		eloop_sock_table_dispatch(&eloop.readers, rfds);
 1238|      0|		eloop_sock_table_dispatch(&eloop.writers, wfds);
 1239|      0|		eloop_sock_table_dispatch(&eloop.exceptions, efds);
 1240|      0|#endif /* CONFIG_ELOOP_SELECT */
 1241|       |#ifdef CONFIG_ELOOP_EPOLL
 1242|       |		eloop_sock_table_dispatch(eloop.epoll_events, res);
 1243|       |#endif /* CONFIG_ELOOP_EPOLL */
 1244|       |#ifdef CONFIG_ELOOP_KQUEUE
 1245|       |		eloop_sock_table_dispatch(eloop.kqueue_events, res);
 1246|       |#endif /* CONFIG_ELOOP_KQUEUE */
 1247|      0|	}
 1248|       |
 1249|  6.88k|	eloop.terminate = 0;
 1250|  6.88k|out:
 1251|  6.88k|#ifdef CONFIG_ELOOP_SELECT
 1252|  6.88k|	os_free(rfds);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 1253|  6.88k|	os_free(wfds);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 1254|  6.88k|	os_free(efds);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 1255|  6.88k|#endif /* CONFIG_ELOOP_SELECT */
 1256|  6.88k|	return;
 1257|  6.88k|}
eloop_terminate:
 1261|  6.88k|{
 1262|  6.88k|	eloop.terminate = 1;
 1263|  6.88k|}
eloop_destroy:
 1267|  6.88k|{
 1268|  6.88k|	struct eloop_timeout *timeout, *prev;
 1269|  6.88k|	struct os_reltime now;
 1270|  6.88k|	size_t i;
 1271|       |
 1272|  6.88k|	os_get_reltime(&now);
 1273|  6.88k|	dl_list_for_each_safe(timeout, prev, &eloop.timeout,
  ------------------
  |  |   84|  6.88k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  6.88k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.88k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  6.88k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 0, False: 6.88k]
  |  |  ------------------
  |  |   87|  6.88k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1274|  6.88k|			      struct eloop_timeout, list) {
 1275|      0|		int sec, usec;
 1276|      0|		sec = timeout->time.sec - now.sec;
 1277|      0|		usec = timeout->time.usec - now.usec;
 1278|      0|		if (timeout->time.usec < now.usec) {
  ------------------
  |  Branch (1278:7): [True: 0, False: 0]
  ------------------
 1279|      0|			sec--;
 1280|      0|			usec += 1000000;
 1281|      0|		}
 1282|      0|		wpa_printf(MSG_INFO, "ELOOP: remaining timeout: %d.%06d "
 1283|      0|			   "eloop_data=%p user_data=%p handler=%p",
 1284|      0|			   sec, usec, timeout->eloop_data, timeout->user_data,
 1285|      0|			   timeout->handler);
 1286|      0|		wpa_trace_dump_funcname("eloop unregistered timeout handler",
  ------------------
  |  |   80|      0|#define wpa_trace_dump_funcname(title, pc) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (80:58): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1287|      0|					timeout->handler);
 1288|      0|		wpa_trace_dump("eloop timeout", timeout);
  ------------------
  |  |   60|      0|#define wpa_trace_dump(title, ptr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (60:50): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1289|      0|		eloop_remove_timeout(timeout);
 1290|      0|	}
 1291|  6.88k|	eloop_sock_table_destroy(&eloop.readers);
 1292|  6.88k|	eloop_sock_table_destroy(&eloop.writers);
 1293|  6.88k|	eloop_sock_table_destroy(&eloop.exceptions);
 1294|       |
 1295|  6.88k|	for (i = 0; i < eloop.signal_count; i++)
  ------------------
  |  Branch (1295:14): [True: 0, False: 6.88k]
  ------------------
 1296|      0|		signal(eloop.signals[i].sig, SIG_DFL);
 1297|       |
 1298|  6.88k|	os_free(eloop.signals);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
 1299|       |
 1300|       |#ifdef CONFIG_ELOOP_POLL
 1301|       |	os_free(eloop.pollfds);
 1302|       |	os_free(eloop.pollfds_map);
 1303|       |#endif /* CONFIG_ELOOP_POLL */
 1304|       |#if defined(CONFIG_ELOOP_EPOLL) || defined(CONFIG_ELOOP_KQUEUE)
 1305|       |	os_free(eloop.fd_table);
 1306|       |#endif /* CONFIG_ELOOP_EPOLL || CONFIG_ELOOP_KQUEUE */
 1307|       |#ifdef CONFIG_ELOOP_EPOLL
 1308|       |	os_free(eloop.epoll_events);
 1309|       |	close(eloop.epollfd);
 1310|       |#endif /* CONFIG_ELOOP_EPOLL */
 1311|       |#ifdef CONFIG_ELOOP_KQUEUE
 1312|       |	os_free(eloop.kqueue_events);
 1313|       |	close(eloop.kqueuefd);
 1314|       |#endif /* CONFIG_ELOOP_KQUEUE */
 1315|  6.88k|}
eloop.c:eloop_remove_timeout:
  830|  6.88k|{
  831|  6.88k|	dl_list_del(&timeout->list);
  832|  6.88k|	wpa_trace_remove_ref(timeout, eloop, timeout->eloop_data);
  ------------------
  |  |   64|  6.88k|#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (64:61): [Folded, False: 6.88k]
  |  |  ------------------
  ------------------
  833|  6.88k|	wpa_trace_remove_ref(timeout, user, timeout->user_data);
  ------------------
  |  |   64|  6.88k|#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (64:61): [Folded, False: 6.88k]
  |  |  ------------------
  ------------------
  834|  6.88k|	os_free(timeout);
  ------------------
  |  |  511|  6.88k|#define os_free(p) free((p))
  ------------------
  835|  6.88k|}
eloop.c:eloop_process_pending_signals:
 1008|  6.88k|{
 1009|  6.88k|	size_t i;
 1010|       |
 1011|  6.88k|	if (eloop.signaled == 0)
  ------------------
  |  Branch (1011:6): [True: 6.88k, False: 0]
  ------------------
 1012|  6.88k|		return;
 1013|      0|	eloop.signaled = 0;
 1014|       |
 1015|      0|	if (eloop.pending_terminate) {
  ------------------
  |  Branch (1015:6): [True: 0, False: 0]
  ------------------
 1016|      0|#ifndef CONFIG_NATIVE_WINDOWS
 1017|      0|		alarm(0);
 1018|      0|#endif /* CONFIG_NATIVE_WINDOWS */
 1019|      0|		eloop.pending_terminate = 0;
 1020|      0|	}
 1021|       |
 1022|      0|	for (i = 0; i < eloop.signal_count; i++) {
  ------------------
  |  Branch (1022:14): [True: 0, False: 0]
  ------------------
 1023|      0|		if (eloop.signals[i].signaled) {
  ------------------
  |  Branch (1023:7): [True: 0, False: 0]
  ------------------
 1024|      0|			eloop.signals[i].signaled = 0;
 1025|      0|			eloop.signals[i].handler(eloop.signals[i].sig,
 1026|      0|						 eloop.signals[i].user_data);
 1027|      0|		}
 1028|      0|	}
 1029|      0|}
eloop.c:eloop_sock_table_set_fds:
  577|  20.6k|{
  578|  20.6k|	size_t i;
  579|       |
  580|  20.6k|	FD_ZERO(fds);
  ------------------
  |  Branch (580:2): [Folded, False: 20.6k]
  ------------------
  581|       |
  582|  20.6k|	if (table->table == NULL)
  ------------------
  |  Branch (582:6): [True: 20.6k, False: 0]
  ------------------
  583|  20.6k|		return;
  584|       |
  585|      0|	for (i = 0; i < table->count; i++) {
  ------------------
  |  Branch (585:14): [True: 0, False: 0]
  ------------------
  586|      0|		assert(table->table[i].sock >= 0);
  ------------------
  |  Branch (586:3): [True: 0, False: 0]
  |  Branch (586:3): [True: 0, False: 0]
  ------------------
  587|      0|		FD_SET(table->table[i].sock, fds);
  588|      0|	}
  589|      0|}
eloop.c:eloop_sock_table_destroy:
  699|  20.6k|{
  700|  20.6k|	if (table) {
  ------------------
  |  Branch (700:6): [True: 20.6k, False: 0]
  ------------------
  701|  20.6k|		size_t i;
  702|       |
  703|  20.6k|		for (i = 0; i < table->count && table->table; i++) {
  ------------------
  |  Branch (703:15): [True: 0, False: 20.6k]
  |  Branch (703:35): [True: 0, False: 0]
  ------------------
  704|      0|			wpa_printf(MSG_INFO, "ELOOP: remaining socket: "
  705|      0|				   "sock=%d eloop_data=%p user_data=%p "
  706|      0|				   "handler=%p",
  707|      0|				   table->table[i].sock,
  708|      0|				   table->table[i].eloop_data,
  709|      0|				   table->table[i].user_data,
  710|      0|				   table->table[i].handler);
  711|      0|			wpa_trace_dump_funcname("eloop unregistered socket "
  ------------------
  |  |   80|      0|#define wpa_trace_dump_funcname(title, pc) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (80:58): [Folded, False: 0]
  |  |  ------------------
  ------------------
  712|      0|						"handler",
  713|      0|						table->table[i].handler);
  714|      0|			wpa_trace_dump("eloop sock", &table->table[i]);
  ------------------
  |  |   60|      0|#define wpa_trace_dump(title, ptr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (60:50): [Folded, False: 0]
  |  |  ------------------
  ------------------
  715|      0|		}
  716|  20.6k|		eloop_trace_sock_remove_ref(table);
  ------------------
  |  |  158|  20.6k|#define eloop_trace_sock_remove_ref(table) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (158:58): [Folded, False: 20.6k]
  |  |  ------------------
  ------------------
  717|  20.6k|		os_free(table->table);
  ------------------
  |  |  511|  20.6k|#define os_free(p) free((p))
  ------------------
  718|  20.6k|	}
  719|  20.6k|}

p2p.c:dl_list_init:
   23|  6.88k|{
   24|  6.88k|	list->next = list;
   25|  6.88k|	list->prev = list;
   26|  6.88k|}
p2p.c:dl_list_add:
   29|  1.97k|{
   30|  1.97k|	item->next = list->next;
   31|  1.97k|	item->prev = list;
   32|  1.97k|	list->next->prev = item;
   33|  1.97k|	list->next = item;
   34|  1.97k|}
p2p.c:dl_list_del:
   42|  1.97k|{
   43|  1.97k|	item->next->prev = item->prev;
   44|  1.97k|	item->prev->next = item->next;
   45|  1.97k|	item->next = NULL;
   46|       |	item->prev = NULL;
   47|  1.97k|}
eloop.c:dl_list_init:
   23|  6.88k|{
   24|  6.88k|	list->next = list;
   25|  6.88k|	list->prev = list;
   26|  6.88k|}
eloop.c:dl_list_add:
   29|  6.88k|{
   30|  6.88k|	item->next = list->next;
   31|  6.88k|	item->prev = list;
   32|  6.88k|	list->next->prev = item;
   33|  6.88k|	list->next = item;
   34|  6.88k|}
eloop.c:dl_list_add_tail:
   37|  6.88k|{
   38|  6.88k|	dl_list_add(list->prev, item);
   39|  6.88k|}
eloop.c:dl_list_del:
   42|  6.88k|{
   43|  6.88k|	item->next->prev = item->prev;
   44|  6.88k|	item->prev->next = item->next;
   45|  6.88k|	item->next = NULL;
   46|       |	item->prev = NULL;
   47|  6.88k|}
eloop.c:dl_list_empty:
   50|  20.6k|{
   51|  20.6k|	return list->next == list;
   52|  20.6k|}

p2p.c:os_reltime_before:
   71|  7.20k|{
   72|  7.20k|	return (a->sec < b->sec) ||
  ------------------
  |  Branch (72:9): [True: 11, False: 7.19k]
  ------------------
   73|  7.19k|	       (a->sec == b->sec && a->usec < b->usec);
  ------------------
  |  Branch (73:10): [True: 7.18k, False: 6]
  |  Branch (73:30): [True: 0, False: 7.18k]
  ------------------
   74|  7.20k|}
os_unix.c:testing_test_fail:
  736|  28.5k|{
  737|  28.5k|	return 0;
  738|  28.5k|}
eloop.c:os_reltime_before:
   71|  13.7k|{
   72|  13.7k|	return (a->sec < b->sec) ||
  ------------------
  |  Branch (72:9): [True: 0, False: 13.7k]
  ------------------
   73|  13.7k|	       (a->sec == b->sec && a->usec < b->usec);
  ------------------
  |  Branch (73:10): [True: 13.7k, False: 0]
  |  Branch (73:30): [True: 0, False: 13.7k]
  ------------------
   74|  13.7k|}
p2p_utils.c:os_snprintf_error:
  580|  26.0k|{
  581|  26.0k|	return res < 0 || (unsigned int) res >= size;
  ------------------
  |  Branch (581:9): [True: 0, False: 26.0k]
  |  Branch (581:20): [True: 7, False: 26.0k]
  ------------------
  582|  26.0k|}
wps_common.c:os_snprintf_error:
  580|  2.32k|{
  581|  2.32k|	return res < 0 || (unsigned int) res >= size;
  ------------------
  |  Branch (581:9): [True: 0, False: 2.32k]
  |  Branch (581:20): [True: 0, False: 2.32k]
  ------------------
  582|  2.32k|}
sha256-internal.c:testing_test_fail:
  736|  6.88k|{
  737|  6.88k|	return 0;
  738|  6.88k|}

os_get_reltime:
   77|  28.5k|{
   78|  28.5k|#ifndef __MACH__
   79|  28.5k|#if defined(CLOCK_BOOTTIME)
   80|  28.5k|	static clockid_t clock_id = CLOCK_BOOTTIME;
   81|       |#elif defined(CLOCK_MONOTONIC)
   82|       |	static clockid_t clock_id = CLOCK_MONOTONIC;
   83|       |#else
   84|       |	static clockid_t clock_id = CLOCK_REALTIME;
   85|       |#endif
   86|  28.5k|	struct timespec ts;
   87|  28.5k|	int res;
   88|       |
   89|  28.5k|	if (TEST_FAIL())
  ------------------
  |  |  727|  28.5k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (727:21): [True: 0, False: 28.5k]
  |  |  ------------------
  ------------------
   90|      0|		return -1;
   91|       |
   92|  28.5k|	while (1) {
  ------------------
  |  Branch (92:9): [True: 28.5k, Folded]
  ------------------
   93|  28.5k|		res = clock_gettime(clock_id, &ts);
   94|  28.5k|		if (res == 0) {
  ------------------
  |  Branch (94:7): [True: 28.5k, False: 0]
  ------------------
   95|  28.5k|			t->sec = ts.tv_sec;
   96|  28.5k|			t->usec = ts.tv_nsec / 1000;
   97|  28.5k|			return 0;
   98|  28.5k|		}
   99|       |
  100|       |		/* Try to fall back to alternative clockid_t values, if any */
  101|       |
  102|      0|#if defined(CLOCK_BOOTTIME) && defined(CLOCK_MONOTONIC)
  103|       |		/* Some systems (e.g., FreeBSD 15.0) define both CLOCK_BOOTTIME
  104|       |		 * and CLOCK_MONOTONIC to have the same value, so handle that
  105|       |		 * as a special case. */
  106|      0|		if (CLOCK_BOOTTIME == CLOCK_MONOTONIC &&
  ------------------
  |  Branch (106:7): [Folded, False: 0]
  ------------------
  107|      0|		    clock_id == CLOCK_BOOTTIME) {
  ------------------
  |  Branch (107:7): [True: 0, False: 0]
  ------------------
  108|      0|			clock_id = CLOCK_REALTIME;
  109|      0|			continue;
  110|      0|		}
  111|       |
  112|      0|		if (clock_id == CLOCK_BOOTTIME) {
  ------------------
  |  Branch (112:7): [True: 0, False: 0]
  ------------------
  113|      0|			clock_id = CLOCK_MONOTONIC;
  114|      0|			continue;
  115|      0|		}
  116|       |#elif CLOCK_BOOTTIME
  117|       |		/* CLOCK_MONOTONIC is not defined. Unknown whether such cases
  118|       |		 * exists, but it is safe to fall back to CLOCK_REALTIME.
  119|       |		 */
  120|       |		if (clock_id == CLOCK_BOOTTIME) {
  121|       |			clock_id = CLOCK_REALTIME;
  122|       |			continue;
  123|       |		}
  124|       |#endif
  125|       |
  126|      0|#ifdef CLOCK_MONOTONIC
  127|      0|		if (clock_id == CLOCK_MONOTONIC) {
  ------------------
  |  Branch (127:7): [True: 0, False: 0]
  ------------------
  128|      0|			clock_id = CLOCK_REALTIME;
  129|      0|			continue;
  130|      0|		}
  131|      0|#endif
  132|       |
  133|       |		/* No additional clockid_t values to fall back to */
  134|      0|		return -1;
  135|      0|	}
  136|       |#else /* __MACH__ */
  137|       |	uint64_t abstime, nano;
  138|       |	static mach_timebase_info_data_t info = { 0, 0 };
  139|       |
  140|       |	if (!info.denom) {
  141|       |		if (mach_timebase_info(&info) != KERN_SUCCESS)
  142|       |			return -1;
  143|       |	}
  144|       |
  145|       |	abstime = mach_absolute_time();
  146|       |	nano = (abstime * info.numer) / info.denom;
  147|       |
  148|       |	t->sec = nano / NSEC_PER_SEC;
  149|       |	t->usec = (nano - (((uint64_t) t->sec) * NSEC_PER_SEC)) / NSEC_PER_USEC;
  150|       |
  151|       |	return 0;
  152|       |#endif /* __MACH__ */
  153|  28.5k|}
os_get_random:
  280|  13.8k|{
  281|  13.8k|#ifdef TEST_FUZZ
  282|  13.8k|	size_t i;
  283|       |
  284|  48.3k|	for (i = 0; i < len; i++)
  ------------------
  |  Branch (284:14): [True: 34.5k, False: 13.8k]
  ------------------
  285|  34.5k|		buf[i] = i & 0xff;
  286|  13.8k|	return 0;
  287|       |#else /* TEST_FUZZ */
  288|       |	FILE *f;
  289|       |	size_t rc;
  290|       |
  291|       |	if (TEST_FAIL())
  292|       |		return -1;
  293|       |
  294|       |	f = fopen("/dev/urandom", "rb");
  295|       |	if (f == NULL) {
  296|       |		printf("Could not open /dev/urandom.\n");
  297|       |		return -1;
  298|       |	}
  299|       |
  300|       |	rc = fread(buf, 1, len, f);
  301|       |	fclose(f);
  302|       |
  303|       |	return rc != len ? -1 : 0;
  304|       |#endif /* TEST_FUZZ */
  305|  13.8k|}
os_program_init:
  361|  6.88k|{
  362|  6.88k|	unsigned int seed;
  363|       |
  364|       |#ifdef ANDROID
  365|       |	/*
  366|       |	 * We ignore errors here since errors are normal if we
  367|       |	 * are already running as non-root.
  368|       |	 */
  369|       |#ifdef ANDROID_SETGROUPS_OVERRIDE
  370|       |	gid_t groups[] = { ANDROID_SETGROUPS_OVERRIDE };
  371|       |#else /* ANDROID_SETGROUPS_OVERRIDE */
  372|       |	gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE };
  373|       |#endif /* ANDROID_SETGROUPS_OVERRIDE */
  374|       |	struct __user_cap_header_struct header;
  375|       |	struct __user_cap_data_struct cap;
  376|       |
  377|       |	setgroups(ARRAY_SIZE(groups), groups);
  378|       |
  379|       |	prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
  380|       |
  381|       |	setgid(AID_WIFI);
  382|       |	setuid(AID_WIFI);
  383|       |
  384|       |	header.version = _LINUX_CAPABILITY_VERSION;
  385|       |	header.pid = 0;
  386|       |	cap.effective = cap.permitted =
  387|       |		(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW);
  388|       |	cap.inheritable = 0;
  389|       |	capset(&header, &cap);
  390|       |#endif /* ANDROID */
  391|       |
  392|  6.88k|	if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
  ------------------
  |  Branch (392:6): [True: 6.88k, False: 0]
  ------------------
  393|  6.88k|		srandom(seed);
  394|       |
  395|  6.88k|	return 0;
  396|  6.88k|}
os_program_deinit:
  400|  6.88k|{
  401|       |#ifdef WPA_TRACE
  402|       |	struct os_alloc_trace *a;
  403|       |	unsigned long total = 0;
  404|       |	dl_list_for_each(a, &alloc_list, struct os_alloc_trace, list) {
  405|       |		total += a->len;
  406|       |		if (a->magic != ALLOC_MAGIC) {
  407|       |			wpa_printf(MSG_INFO, "MEMLEAK[%p]: invalid magic 0x%x "
  408|       |				   "len %lu",
  409|       |				   a, a->magic, (unsigned long) a->len);
  410|       |			continue;
  411|       |		}
  412|       |		wpa_printf(MSG_INFO, "MEMLEAK[%p]: len %lu",
  413|       |			   a, (unsigned long) a->len);
  414|       |		wpa_trace_dump("memleak", a);
  415|       |	}
  416|       |	if (total)
  417|       |		wpa_printf(MSG_INFO, "MEMLEAK: total %lu bytes",
  418|       |			   (unsigned long) total);
  419|       |	wpa_trace_deinit();
  420|       |#endif /* WPA_TRACE */
  421|  6.88k|}
os_zalloc:
  507|  40.6k|{
  508|  40.6k|	return calloc(1, size);
  509|  40.6k|}

wpa_printf:
  224|  49.5M|{
  225|  49.5M|	va_list ap;
  226|       |
  227|  49.5M|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 49.5M]
  ------------------
  228|       |#ifdef CONFIG_ANDROID_LOG
  229|       |		va_start(ap, fmt);
  230|       |		__android_log_vprint(wpa_to_android_level(level),
  231|       |				     ANDROID_LOG_NAME, fmt, ap);
  232|       |		va_end(ap);
  233|       |#else /* CONFIG_ANDROID_LOG */
  234|       |#ifdef CONFIG_DEBUG_SYSLOG
  235|       |		if (wpa_debug_syslog) {
  236|       |			va_start(ap, fmt);
  237|       |			vsyslog(syslog_priority(level), fmt, ap);
  238|       |			va_end(ap);
  239|       |		}
  240|       |#endif /* CONFIG_DEBUG_SYSLOG */
  241|      0|		wpa_debug_print_timestamp();
  242|      0|#ifdef CONFIG_DEBUG_FILE
  243|      0|		if (out_file) {
  ------------------
  |  Branch (243:7): [True: 0, False: 0]
  ------------------
  244|      0|			va_start(ap, fmt);
  245|      0|			vfprintf(out_file, fmt, ap);
  246|      0|			fprintf(out_file, "\n");
  247|      0|			va_end(ap);
  248|      0|		}
  249|      0|#endif /* CONFIG_DEBUG_FILE */
  250|      0|		if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (250:7): [True: 0, False: 0]
  |  Branch (250:28): [True: 0, False: 0]
  ------------------
  251|      0|			va_start(ap, fmt);
  252|      0|			vprintf(fmt, ap);
  253|      0|			printf("\n");
  254|      0|			va_end(ap);
  255|      0|		}
  256|      0|#endif /* CONFIG_ANDROID_LOG */
  257|      0|	}
  258|       |
  259|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  260|       |	if (wpa_debug_tracing_file != NULL) {
  261|       |		va_start(ap, fmt);
  262|       |		fprintf(wpa_debug_tracing_file, WPAS_TRACE_PFX, level);
  263|       |		vfprintf(wpa_debug_tracing_file, fmt, ap);
  264|       |		fprintf(wpa_debug_tracing_file, "\n");
  265|       |		fflush(wpa_debug_tracing_file);
  266|       |		va_end(ap);
  267|       |	}
  268|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  269|  49.5M|}
wpa_hexdump:
  400|  14.7k|{
  401|  14.7k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  14.7k|}
wpa_hexdump_ascii:
  526|  7.66k|{
  527|  7.66k|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|  7.66k|}
wpa_debug.c:_wpa_hexdump:
  274|  14.7k|{
  275|  14.7k|	size_t i;
  276|       |
  277|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  278|       |	if (wpa_debug_tracing_file != NULL) {
  279|       |		fprintf(wpa_debug_tracing_file,
  280|       |			WPAS_TRACE_PFX "%s - hexdump(len=%lu):",
  281|       |			level, title, (unsigned long) len);
  282|       |		if (buf == NULL) {
  283|       |			fprintf(wpa_debug_tracing_file, " [NULL]\n");
  284|       |		} else if (!show) {
  285|       |			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
  286|       |		} else {
  287|       |			for (i = 0; i < len; i++)
  288|       |				fprintf(wpa_debug_tracing_file,
  289|       |					" %02x", buf[i]);
  290|       |		}
  291|       |		fflush(wpa_debug_tracing_file);
  292|       |	}
  293|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  294|       |
  295|  14.7k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 14.7k, False: 0]
  ------------------
  296|  14.7k|		return;
  297|       |#ifdef CONFIG_ANDROID_LOG
  298|       |	{
  299|       |		const char *display;
  300|       |		char *strbuf = NULL;
  301|       |		size_t slen = len;
  302|       |		if (buf == NULL) {
  303|       |			display = " [NULL]";
  304|       |		} else if (len == 0) {
  305|       |			display = "";
  306|       |		} else if (show && len) {
  307|       |			/* Limit debug message length for Android log */
  308|       |			if (slen > 32)
  309|       |				slen = 32;
  310|       |			strbuf = os_malloc(1 + 3 * slen);
  311|       |			if (strbuf == NULL) {
  312|       |				wpa_printf(MSG_ERROR, "wpa_hexdump: Failed to "
  313|       |					   "allocate message buffer");
  314|       |				return;
  315|       |			}
  316|       |
  317|       |			for (i = 0; i < slen; i++)
  318|       |				os_snprintf(&strbuf[i * 3], 4, " %02x",
  319|       |					    buf[i]);
  320|       |
  321|       |			display = strbuf;
  322|       |		} else {
  323|       |			display = " [REMOVED]";
  324|       |		}
  325|       |
  326|       |		__android_log_print(wpa_to_android_level(level),
  327|       |				    ANDROID_LOG_NAME,
  328|       |				    "%s - hexdump(len=%lu):%s%s",
  329|       |				    title, (long unsigned int) len, display,
  330|       |				    len > slen ? " ..." : "");
  331|       |		bin_clear_free(strbuf, 1 + 3 * slen);
  332|       |		return;
  333|       |	}
  334|       |#else /* CONFIG_ANDROID_LOG */
  335|       |#ifdef CONFIG_DEBUG_SYSLOG
  336|       |	if (wpa_debug_syslog) {
  337|       |		const char *display;
  338|       |		char *strbuf = NULL;
  339|       |
  340|       |		if (buf == NULL) {
  341|       |			display = " [NULL]";
  342|       |		} else if (len == 0) {
  343|       |			display = "";
  344|       |		} else if (show && len) {
  345|       |			strbuf = os_malloc(1 + 3 * len);
  346|       |			if (strbuf == NULL) {
  347|       |				wpa_printf(MSG_ERROR, "wpa_hexdump: Failed to "
  348|       |					   "allocate message buffer");
  349|       |				return;
  350|       |			}
  351|       |
  352|       |			for (i = 0; i < len; i++)
  353|       |				os_snprintf(&strbuf[i * 3], 4, " %02x",
  354|       |					    buf[i]);
  355|       |
  356|       |			display = strbuf;
  357|       |		} else {
  358|       |			display = " [REMOVED]";
  359|       |		}
  360|       |
  361|       |		syslog(syslog_priority(level), "%s - hexdump(len=%lu):%s",
  362|       |		       title, (unsigned long) len, display);
  363|       |		bin_clear_free(strbuf, 1 + 3 * len);
  364|       |		if (only_syslog)
  365|       |			return;
  366|       |	}
  367|       |#endif /* CONFIG_DEBUG_SYSLOG */
  368|      0|	wpa_debug_print_timestamp();
  369|      0|#ifdef CONFIG_DEBUG_FILE
  370|      0|	if (out_file) {
  ------------------
  |  Branch (370:6): [True: 0, False: 0]
  ------------------
  371|      0|		fprintf(out_file, "%s - hexdump(len=%lu):",
  372|      0|			title, (unsigned long) len);
  373|      0|		if (buf == NULL) {
  ------------------
  |  Branch (373:7): [True: 0, False: 0]
  ------------------
  374|      0|			fprintf(out_file, " [NULL]");
  375|      0|		} else if (show) {
  ------------------
  |  Branch (375:14): [True: 0, False: 0]
  ------------------
  376|      0|			for (i = 0; i < len; i++)
  ------------------
  |  Branch (376:16): [True: 0, False: 0]
  ------------------
  377|      0|				fprintf(out_file, " %02x", buf[i]);
  378|      0|		} else {
  379|      0|			fprintf(out_file, " [REMOVED]");
  380|      0|		}
  381|      0|		fprintf(out_file, "\n");
  382|      0|	}
  383|      0|#endif /* CONFIG_DEBUG_FILE */
  384|      0|	if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (384:6): [True: 0, False: 0]
  |  Branch (384:27): [True: 0, False: 0]
  ------------------
  385|      0|		printf("%s - hexdump(len=%lu):", title, (unsigned long) len);
  386|      0|		if (buf == NULL) {
  ------------------
  |  Branch (386:7): [True: 0, False: 0]
  ------------------
  387|      0|			printf(" [NULL]");
  388|      0|		} else if (show) {
  ------------------
  |  Branch (388:14): [True: 0, False: 0]
  ------------------
  389|      0|			for (i = 0; i < len; i++)
  ------------------
  |  Branch (389:16): [True: 0, False: 0]
  ------------------
  390|      0|				printf(" %02x", buf[i]);
  391|      0|		} else {
  392|      0|			printf(" [REMOVED]");
  393|      0|		}
  394|      0|		printf("\n");
  395|      0|	}
  396|      0|#endif /* CONFIG_ANDROID_LOG */
  397|      0|}
wpa_debug.c:_wpa_hexdump_ascii:
  413|  7.66k|{
  414|  7.66k|	size_t i, llen;
  415|  7.66k|	const u8 *pos = buf;
  416|  7.66k|	const size_t line_len = 16;
  417|       |
  418|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  419|       |	if (wpa_debug_tracing_file != NULL) {
  420|       |		fprintf(wpa_debug_tracing_file,
  421|       |			WPAS_TRACE_PFX "%s - hexdump_ascii(len=%lu):",
  422|       |			level, title, (unsigned long) len);
  423|       |		if (buf == NULL) {
  424|       |			fprintf(wpa_debug_tracing_file, " [NULL]\n");
  425|       |		} else if (!show) {
  426|       |			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
  427|       |		} else {
  428|       |			/* can do ascii processing in userspace */
  429|       |			for (i = 0; i < len; i++)
  430|       |				fprintf(wpa_debug_tracing_file,
  431|       |					" %02x", pos[i]);
  432|       |		}
  433|       |		fflush(wpa_debug_tracing_file);
  434|       |	}
  435|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  436|       |
  437|  7.66k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (437:6): [True: 7.66k, False: 0]
  ------------------
  438|  7.66k|		return;
  439|       |#ifdef CONFIG_ANDROID_LOG
  440|       |	_wpa_hexdump(level, title, buf, len, show, 0);
  441|       |#else /* CONFIG_ANDROID_LOG */
  442|       |#ifdef CONFIG_DEBUG_SYSLOG
  443|       |	if (wpa_debug_syslog)
  444|       |		_wpa_hexdump(level, title, buf, len, show, 1);
  445|       |#endif /* CONFIG_DEBUG_SYSLOG */
  446|      0|	wpa_debug_print_timestamp();
  447|      0|#ifdef CONFIG_DEBUG_FILE
  448|      0|	if (out_file) {
  ------------------
  |  Branch (448:6): [True: 0, False: 0]
  ------------------
  449|      0|		if (!show) {
  ------------------
  |  Branch (449:7): [True: 0, False: 0]
  ------------------
  450|      0|			fprintf(out_file,
  451|      0|				"%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  452|      0|				title, (unsigned long) len);
  453|      0|			goto file_done;
  454|      0|		}
  455|      0|		if (buf == NULL) {
  ------------------
  |  Branch (455:7): [True: 0, False: 0]
  ------------------
  456|      0|			fprintf(out_file,
  457|      0|				"%s - hexdump_ascii(len=%lu): [NULL]\n",
  458|      0|				title, (unsigned long) len);
  459|      0|			goto file_done;
  460|      0|		}
  461|      0|		fprintf(out_file, "%s - hexdump_ascii(len=%lu):\n",
  462|      0|			title, (unsigned long) len);
  463|      0|		while (len) {
  ------------------
  |  Branch (463:10): [True: 0, False: 0]
  ------------------
  464|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (464:11): [True: 0, False: 0]
  ------------------
  465|      0|			fprintf(out_file, "    ");
  466|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (466:16): [True: 0, False: 0]
  ------------------
  467|      0|				fprintf(out_file, " %02x", pos[i]);
  468|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (468:19): [True: 0, False: 0]
  ------------------
  469|      0|				fprintf(out_file, "   ");
  470|      0|			fprintf(out_file, "   ");
  471|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (471:16): [True: 0, False: 0]
  ------------------
  472|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|					fprintf(out_file, "%c", pos[i]);
  474|      0|				else
  475|      0|					fprintf(out_file, "_");
  476|      0|			}
  477|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (477:19): [True: 0, False: 0]
  ------------------
  478|      0|				fprintf(out_file, " ");
  479|      0|			fprintf(out_file, "\n");
  480|      0|			pos += llen;
  481|      0|			len -= llen;
  482|      0|		}
  483|      0|	}
  484|      0|file_done:
  485|      0|#endif /* CONFIG_DEBUG_FILE */
  486|      0|	if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (486:6): [True: 0, False: 0]
  |  Branch (486:27): [True: 0, False: 0]
  ------------------
  487|      0|		if (!show) {
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|			printf("%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  489|      0|			       title, (unsigned long) len);
  490|      0|			return;
  491|      0|		}
  492|      0|		if (buf == NULL) {
  ------------------
  |  Branch (492:7): [True: 0, False: 0]
  ------------------
  493|      0|			printf("%s - hexdump_ascii(len=%lu): [NULL]\n",
  494|      0|			       title, (unsigned long) len);
  495|      0|			return;
  496|      0|		}
  497|      0|		printf("%s - hexdump_ascii(len=%lu):\n", title,
  498|      0|		       (unsigned long) len);
  499|      0|		while (len) {
  ------------------
  |  Branch (499:10): [True: 0, False: 0]
  ------------------
  500|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (500:11): [True: 0, False: 0]
  ------------------
  501|      0|			printf("    ");
  502|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (502:16): [True: 0, False: 0]
  ------------------
  503|      0|				printf(" %02x", pos[i]);
  504|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (504:19): [True: 0, False: 0]
  ------------------
  505|      0|				printf("   ");
  506|      0|			printf("   ");
  507|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (507:16): [True: 0, False: 0]
  ------------------
  508|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (508:9): [True: 0, False: 0]
  ------------------
  509|      0|					printf("%c", pos[i]);
  510|      0|				else
  511|      0|					printf("_");
  512|      0|			}
  513|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (513:19): [True: 0, False: 0]
  ------------------
  514|      0|				printf(" ");
  515|      0|			printf("\n");
  516|      0|			pos += llen;
  517|      0|			len -= llen;
  518|      0|		}
  519|      0|	}
  520|      0|#endif /* CONFIG_ANDROID_LOG */
  521|      0|}

p2p_parse.c:wpa_hexdump_buf:
  122|  1.36k|{
  123|  1.36k|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (123:28): [True: 1.36k, False: 0]
  ------------------
  124|  1.36k|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (124:7): [True: 1.36k, False: 0]
  ------------------
  125|  1.36k|}
wps_attr_parse.c:wpa_hexdump_buf:
  122|  1.05k|{
  123|  1.05k|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (123:28): [True: 1.05k, False: 0]
  ------------------
  124|  1.05k|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (124:7): [True: 1.05k, False: 0]
  ------------------
  125|  1.05k|}

wpabuf_resize:
   48|  6.21k|{
   49|  6.21k|	struct wpabuf *buf = *_buf;
   50|       |#ifdef WPA_TRACE
   51|       |	struct wpabuf_trace *trace;
   52|       |#endif /* WPA_TRACE */
   53|       |
   54|  6.21k|	if (buf == NULL) {
  ------------------
  |  Branch (54:6): [True: 488, False: 5.72k]
  ------------------
   55|    488|		*_buf = wpabuf_alloc(add_len);
   56|    488|		return *_buf == NULL ? -1 : 0;
  ------------------
  |  Branch (56:10): [True: 0, False: 488]
  ------------------
   57|    488|	}
   58|       |
   59|       |#ifdef WPA_TRACE
   60|       |	trace = wpabuf_get_trace(buf);
   61|       |	if (trace->magic != WPABUF_MAGIC) {
   62|       |		wpa_printf(MSG_ERROR, "wpabuf: invalid magic %x",
   63|       |			   trace->magic);
   64|       |		wpa_trace_show("wpabuf_resize invalid magic");
   65|       |		abort();
   66|       |	}
   67|       |#endif /* WPA_TRACE */
   68|       |
   69|  5.72k|	if (buf->used + add_len > buf->size) {
  ------------------
  |  Branch (69:6): [True: 5.72k, False: 0]
  ------------------
   70|  5.72k|		unsigned char *nbuf;
   71|  5.72k|		if (buf->flags & WPABUF_FLAG_EXT_DATA) {
  ------------------
  |  |   13|  5.72k|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|  5.72k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (71:7): [True: 0, False: 5.72k]
  ------------------
   72|      0|			nbuf = os_realloc(buf->buf, buf->used + add_len);
  ------------------
  |  |  508|      0|#define os_realloc(p, s) realloc((p), (s))
  ------------------
   73|      0|			if (nbuf == NULL)
  ------------------
  |  Branch (73:8): [True: 0, False: 0]
  ------------------
   74|      0|				return -1;
   75|      0|			os_memset(nbuf + buf->used, 0, add_len);
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   76|      0|			buf->buf = nbuf;
   77|  5.72k|		} else {
   78|       |#ifdef WPA_TRACE
   79|       |			nbuf = os_realloc(trace, sizeof(struct wpabuf_trace) +
   80|       |					  sizeof(struct wpabuf) +
   81|       |					  buf->used + add_len);
   82|       |			if (nbuf == NULL)
   83|       |				return -1;
   84|       |			trace = (struct wpabuf_trace *) nbuf;
   85|       |			buf = (struct wpabuf *) (trace + 1);
   86|       |			os_memset(nbuf + sizeof(struct wpabuf_trace) +
   87|       |				  sizeof(struct wpabuf) + buf->used, 0,
   88|       |				  add_len);
   89|       |#else /* WPA_TRACE */
   90|  5.72k|			nbuf = os_realloc(buf, sizeof(struct wpabuf) +
  ------------------
  |  |  508|  5.72k|#define os_realloc(p, s) realloc((p), (s))
  ------------------
   91|  5.72k|					  buf->used + add_len);
   92|  5.72k|			if (nbuf == NULL)
  ------------------
  |  Branch (92:8): [True: 0, False: 5.72k]
  ------------------
   93|      0|				return -1;
   94|  5.72k|			buf = (struct wpabuf *) nbuf;
   95|  5.72k|			os_memset(nbuf + sizeof(struct wpabuf) + buf->used, 0,
  ------------------
  |  |  529|  5.72k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   96|  5.72k|				  add_len);
   97|  5.72k|#endif /* WPA_TRACE */
   98|  5.72k|			buf->buf = (u8 *) (buf + 1);
   99|  5.72k|			*_buf = buf;
  100|  5.72k|		}
  101|  5.72k|		buf->size = buf->used + add_len;
  102|  5.72k|	}
  103|       |
  104|  5.72k|	return 0;
  105|  5.72k|}
wpabuf_alloc:
  114|  18.0k|{
  115|       |#ifdef WPA_TRACE
  116|       |	struct wpabuf_trace *trace = os_zalloc(sizeof(struct wpabuf_trace) +
  117|       |					       sizeof(struct wpabuf) + len);
  118|       |	struct wpabuf *buf;
  119|       |	if (trace == NULL)
  120|       |		return NULL;
  121|       |	trace->magic = WPABUF_MAGIC;
  122|       |	buf = (struct wpabuf *) (trace + 1);
  123|       |#else /* WPA_TRACE */
  124|  18.0k|	struct wpabuf *buf = os_zalloc(sizeof(struct wpabuf) + len);
  125|  18.0k|	if (buf == NULL)
  ------------------
  |  Branch (125:6): [True: 0, False: 18.0k]
  ------------------
  126|      0|		return NULL;
  127|  18.0k|#endif /* WPA_TRACE */
  128|       |
  129|  18.0k|	buf->size = len;
  130|  18.0k|	buf->buf = (u8 *) (buf + 1);
  131|  18.0k|	return buf;
  132|  18.0k|}
wpabuf_alloc_copy:
  161|    133|{
  162|    133|	struct wpabuf *buf = wpabuf_alloc(len);
  163|    133|	if (buf)
  ------------------
  |  Branch (163:6): [True: 133, False: 0]
  ------------------
  164|    133|		wpabuf_put_data(buf, data, len);
  165|    133|	return buf;
  166|    133|}
wpabuf_dup:
  170|    428|{
  171|    428|	struct wpabuf *buf;
  172|       |
  173|    428|	if (!src)
  ------------------
  |  Branch (173:6): [True: 0, False: 428]
  ------------------
  174|      0|		return NULL;
  175|    428|	buf = wpabuf_alloc(wpabuf_len(src));
  176|    428|	if (buf)
  ------------------
  |  Branch (176:6): [True: 428, False: 0]
  ------------------
  177|    428|		wpabuf_put_data(buf, wpabuf_head(src), wpabuf_len(src));
  178|    428|	return buf;
  179|    428|}
wpabuf_free:
  187|   298k|{
  188|       |#ifdef WPA_TRACE
  189|       |	struct wpabuf_trace *trace;
  190|       |	if (buf == NULL)
  191|       |		return;
  192|       |	trace = wpabuf_get_trace(buf);
  193|       |	if (trace->magic != WPABUF_MAGIC) {
  194|       |		wpa_printf(MSG_ERROR, "wpabuf_free: invalid magic %x",
  195|       |			   trace->magic);
  196|       |		wpa_trace_show("wpabuf_free magic mismatch");
  197|       |		abort();
  198|       |	}
  199|       |	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  200|       |		os_free(buf->buf);
  201|       |	os_free(trace);
  202|       |#else /* WPA_TRACE */
  203|   298k|	if (buf == NULL)
  ------------------
  |  Branch (203:6): [True: 279k, False: 18.0k]
  ------------------
  204|   279k|		return;
  205|  18.0k|	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  ------------------
  |  |   13|  18.0k|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|  18.0k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (205:6): [True: 0, False: 18.0k]
  ------------------
  206|      0|		os_free(buf->buf);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  207|  18.0k|	os_free(buf);
  ------------------
  |  |  511|  18.0k|#define os_free(p) free((p))
  ------------------
  208|  18.0k|#endif /* WPA_TRACE */
  209|  18.0k|}
wpabuf_put:
  222|   615k|{
  223|   615k|	void *tmp = wpabuf_mhead_u8(buf) + wpabuf_len(buf);
  224|   615k|	buf->used += len;
  225|   615k|	if (buf->used > buf->size) {
  ------------------
  |  Branch (225:6): [True: 0, False: 615k]
  ------------------
  226|      0|		wpabuf_overflow(buf, len);
  227|      0|	}
  228|   615k|	return tmp;
  229|   615k|}
wpabuf_concat:
  242|     55|{
  243|     55|	struct wpabuf *n = NULL;
  244|     55|	size_t len = 0;
  245|       |
  246|     55|	if (b == NULL)
  ------------------
  |  Branch (246:6): [True: 0, False: 55]
  ------------------
  247|      0|		return a;
  248|       |
  249|     55|	if (a)
  ------------------
  |  Branch (249:6): [True: 55, False: 0]
  ------------------
  250|     55|		len += wpabuf_len(a);
  251|     55|	len += wpabuf_len(b);
  252|       |
  253|     55|	n = wpabuf_alloc(len);
  254|     55|	if (n) {
  ------------------
  |  Branch (254:6): [True: 55, False: 0]
  ------------------
  255|     55|		if (a)
  ------------------
  |  Branch (255:7): [True: 55, False: 0]
  ------------------
  256|     55|			wpabuf_put_buf(n, a);
  257|     55|		wpabuf_put_buf(n, b);
  258|     55|	}
  259|       |
  260|     55|	wpabuf_free(a);
  261|     55|	wpabuf_free(b);
  262|       |
  263|     55|	return n;
  264|     55|}

p2p.c:wpabuf_size:
   49|  6.21k|{
   50|  6.21k|	return buf->size;
   51|  6.21k|}
p2p.c:wpabuf_put_data:
  174|  6.21k|{
  175|  6.21k|	if (data)
  ------------------
  |  Branch (175:6): [True: 6.21k, False: 0]
  ------------------
  176|  6.21k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  6.21k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  6.21k|}
p2p_dev_disc.c:wpabuf_head:
   94|      6|{
   95|      6|	return buf->buf;
   96|      6|}
p2p_dev_disc.c:wpabuf_len:
   59|      6|{
   60|      6|	return buf->used;
   61|      6|}
p2p_go_neg.c:wpabuf_len:
   59|     55|{
   60|     55|	return buf->used;
   61|     55|}
p2p_go_neg.c:wpabuf_head:
   94|     55|{
   95|     55|	return buf->buf;
   96|     55|}
p2p_invitation.c:wpabuf_len:
   59|  1.59k|{
   60|  1.59k|	return buf->used;
   61|  1.59k|}
p2p_invitation.c:wpabuf_put_buf:
  181|    797|{
  182|    797|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    797|}
p2p_invitation.c:wpabuf_put_data:
  174|    797|{
  175|    797|	if (data)
  ------------------
  |  Branch (175:6): [True: 797, False: 0]
  ------------------
  176|    797|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    797|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    797|}
p2p_invitation.c:wpabuf_head:
   94|  1.59k|{
   95|  1.59k|	return buf->buf;
   96|  1.59k|}
p2p_parse.c:wpabuf_head_u8:
   99|  7.54k|{
  100|  7.54k|	return (const u8 *) wpabuf_head(buf);
  101|  7.54k|}
p2p_parse.c:wpabuf_head:
   94|  8.91k|{
   95|  8.91k|	return buf->buf;
   96|  8.91k|}
p2p_parse.c:wpabuf_len:
   59|  8.91k|{
   60|  8.91k|	return buf->used;
   61|  8.91k|}
p2p_pd.c:wpabuf_put_u8:
  119|    796|{
  120|    796|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    796|	*pos = data;
  122|    796|}
p2p_pd.c:wpabuf_put_be32:
  161|    796|{
  162|    796|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|    796|	WPA_PUT_BE32(pos, data);
  164|    796|}
p2p_pd.c:wpabuf_put_be16:
  149|  2.38k|{
  150|  2.38k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|  2.38k|	WPA_PUT_BE16(pos, data);
  152|  2.38k|}
p2p_pd.c:wpabuf_head:
   94|    846|{
   95|    846|	return buf->buf;
   96|    846|}
p2p_pd.c:wpabuf_len:
   59|    846|{
   60|    846|	return buf->used;
   61|    846|}
p2p_build.c:wpabuf_put_u8:
  119|  16.0k|{
  120|  16.0k|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|  16.0k|	*pos = data;
  122|  16.0k|}
p2p_build.c:wpabuf_put_be32:
  161|  3.39k|{
  162|  3.39k|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|  3.39k|	WPA_PUT_BE32(pos, data);
  164|  3.39k|}
p2p_build.c:wpabuf_put_le16:
  125|  2.87k|{
  126|  2.87k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  127|  2.87k|	WPA_PUT_LE16(pos, data);
  128|  2.87k|}
p2p_build.c:wpabuf_put_data:
  174|  1.23k|{
  175|  1.23k|	if (data)
  ------------------
  |  Branch (175:6): [True: 1.17k, False: 57]
  ------------------
  176|  1.17k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  1.17k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  1.23k|}
p2p_build.c:wpabuf_put_be16:
  149|    311|{
  150|    311|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    311|	WPA_PUT_BE16(pos, data);
  152|    311|}
p2p_build.c:wpabuf_tailroom:
   69|     98|{
   70|     98|	return buf->size - buf->used;
   71|     98|}
p2p_build.c:wpabuf_len:
   59|  1.70k|{
   60|  1.70k|	return buf->used;
   61|  1.70k|}
p2p_build.c:wpabuf_head:
   94|    852|{
   95|    852|	return buf->buf;
   96|    852|}
wps_attr_build.c:wpabuf_put_be16:
  149|    112|{
  150|    112|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    112|	WPA_PUT_BE16(pos, data);
  152|    112|}
wps_attr_build.c:wpabuf_put_u8:
  119|    144|{
  120|    144|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    144|	*pos = data;
  122|    144|}
wps_attr_build.c:wpabuf_tailroom:
   69|     74|{
   70|     74|	return buf->size - buf->used;
   71|     74|}
wps_attr_build.c:wpabuf_put_data:
  174|      2|{
  175|      2|	if (data)
  ------------------
  |  Branch (175:6): [True: 2, False: 0]
  ------------------
  176|      2|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|      2|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|      2|}
wps_attr_build.c:wpabuf_put_be24:
  155|     36|{
  156|     36|	u8 *pos = (u8 *) wpabuf_put(buf, 3);
  157|     36|	WPA_PUT_BE24(pos, data);
  158|     36|}
wps_attr_parse.c:wpabuf_head:
   94|  5.98k|{
   95|  5.98k|	return buf->buf;
   96|  5.98k|}
wps_attr_parse.c:wpabuf_len:
   59|  5.98k|{
   60|  5.98k|	return buf->used;
   61|  5.98k|}
wpabuf.c:wpabuf_put_data:
  174|    671|{
  175|    671|	if (data)
  ------------------
  |  Branch (175:6): [True: 671, False: 0]
  ------------------
  176|    671|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    671|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    671|}
wpabuf.c:wpabuf_len:
   59|   616k|{
   60|   616k|	return buf->used;
   61|   616k|}
wpabuf.c:wpabuf_head:
   94|    538|{
   95|    538|	return buf->buf;
   96|    538|}
wpabuf.c:wpabuf_mhead:
  109|   615k|{
  110|   615k|	return buf->buf;
  111|   615k|}
wpabuf.c:wpabuf_mhead_u8:
  114|   615k|{
  115|   615k|	return (u8 *) wpabuf_mhead(buf);
  116|   615k|}
wpabuf.c:wpabuf_put_buf:
  181|    110|{
  182|    110|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    110|}
ieee802_11_common.c:wpabuf_put_data:
  174|   576k|{
  175|   576k|	if (data)
  ------------------
  |  Branch (175:6): [True: 576k, False: 0]
  ------------------
  176|   576k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|   576k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|   576k|}

wps_build_uuid_e:
  128|      2|{
  129|      2|	if (wpabuf_tailroom(msg) < 4 + WPS_UUID_LEN)
  ------------------
  |  |   32|      2|#define WPS_UUID_LEN 16
  ------------------
  |  Branch (129:6): [True: 0, False: 2]
  ------------------
  130|      0|		return -1;
  131|      2|	wpa_printf(MSG_DEBUG, "WPS:  * UUID-E");
  132|      2|	wpabuf_put_be16(msg, ATTR_UUID_E);
  133|      2|	wpabuf_put_be16(msg, WPS_UUID_LEN);
  ------------------
  |  |   32|      2|#define WPS_UUID_LEN 16
  ------------------
  134|      2|	wpabuf_put_data(msg, uuid, WPS_UUID_LEN);
  ------------------
  |  |   32|      2|#define WPS_UUID_LEN 16
  ------------------
  135|      2|	return 0;
  136|      2|}
wps_build_version:
  192|     36|{
  193|       |	/*
  194|       |	 * Note: This attribute is deprecated and set to hardcoded 0x10 for
  195|       |	 * backwards compatibility reasons. The real version negotiation is
  196|       |	 * done with Version2.
  197|       |	 */
  198|     36|	if (wpabuf_tailroom(msg) < 5)
  ------------------
  |  Branch (198:6): [True: 0, False: 36]
  ------------------
  199|      0|		return -1;
  200|     36|	wpa_printf(MSG_DEBUG, "WPS:  * Version (hardcoded 0x10)");
  201|     36|	wpabuf_put_be16(msg, ATTR_VERSION);
  202|     36|	wpabuf_put_be16(msg, 1);
  203|     36|	wpabuf_put_u8(msg, 0x10);
  204|     36|	return 0;
  205|     36|}
wps_build_wfa_ext:
  211|     36|{
  212|     36|	u8 *len;
  213|       |
  214|       |#ifdef CONFIG_WPS_TESTING
  215|       |	if (WPS_VERSION == 0x10)
  216|       |		return 0;
  217|       |#endif /* CONFIG_WPS_TESTING */
  218|       |
  219|     36|	if (wpabuf_tailroom(msg) <
  ------------------
  |  Branch (219:6): [True: 0, False: 36]
  ------------------
  220|     36|	    7 + 3 + (req_to_enroll ? 3 : 0) +
  ------------------
  |  Branch (220:15): [True: 0, False: 36]
  ------------------
  221|     36|	    (auth_macs ? 2 + auth_macs_count * ETH_ALEN : 0))
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  |  Branch (221:7): [True: 0, False: 36]
  ------------------
  222|      0|		return -1;
  223|     36|	wpabuf_put_be16(msg, ATTR_VENDOR_EXT);
  224|     36|	len = wpabuf_put(msg, 2); /* to be filled */
  225|     36|	wpabuf_put_be24(msg, WPS_VENDOR_ID_WFA);
  ------------------
  |  |  146|     36|#define WPS_VENDOR_ID_WFA 14122
  ------------------
  226|       |
  227|     36|	wpa_printf(MSG_DEBUG, "WPS:  * Version2 (0x%x)", WPS_VERSION);
  ------------------
  |  |   25|     36|#define WPS_VERSION 0x20
  ------------------
  228|     36|	wpabuf_put_u8(msg, WFA_ELEM_VERSION2);
  229|     36|	wpabuf_put_u8(msg, 1);
  230|     36|	wpabuf_put_u8(msg, WPS_VERSION);
  ------------------
  |  |   25|     36|#define WPS_VERSION 0x20
  ------------------
  231|       |
  232|     36|	if (req_to_enroll) {
  ------------------
  |  Branch (232:6): [True: 0, False: 36]
  ------------------
  233|      0|		wpa_printf(MSG_DEBUG, "WPS:  * Request to Enroll (1)");
  234|      0|		wpabuf_put_u8(msg, WFA_ELEM_REQUEST_TO_ENROLL);
  235|      0|		wpabuf_put_u8(msg, 1);
  236|      0|		wpabuf_put_u8(msg, 1);
  237|      0|	}
  238|       |
  239|     36|	if (auth_macs && auth_macs_count) {
  ------------------
  |  Branch (239:6): [True: 0, False: 36]
  |  Branch (239:19): [True: 0, False: 0]
  ------------------
  240|      0|		size_t i;
  241|      0|		wpa_printf(MSG_DEBUG, "WPS:  * AuthorizedMACs (count=%d)",
  242|      0|			   (int) auth_macs_count);
  243|      0|		wpabuf_put_u8(msg, WFA_ELEM_AUTHORIZEDMACS);
  244|      0|		wpabuf_put_u8(msg, auth_macs_count * ETH_ALEN);
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  245|      0|		wpabuf_put_data(msg, auth_macs, auth_macs_count * ETH_ALEN);
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  246|      0|		for (i = 0; i < auth_macs_count; i++)
  ------------------
  |  Branch (246:15): [True: 0, False: 0]
  ------------------
  247|      0|			wpa_printf(MSG_DEBUG, "WPS:    AuthorizedMAC: " MACSTR,
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  248|      0|				   MAC2STR(&auth_macs[i * ETH_ALEN]));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  249|      0|	}
  250|       |
  251|     36|	if (multi_ap_subelem) {
  ------------------
  |  Branch (251:6): [True: 0, False: 36]
  ------------------
  252|      0|		wpa_printf(MSG_DEBUG, "WPS:  * Multi-AP (0x%x)",
  253|      0|			   multi_ap_subelem);
  254|      0|		wpabuf_put_u8(msg, WFA_ELEM_MULTI_AP);
  255|      0|		wpabuf_put_u8(msg, 1); /* length */
  256|      0|		wpabuf_put_u8(msg, multi_ap_subelem);
  257|      0|	}
  258|       |
  259|     36|	WPA_PUT_BE16(len, (u8 *) wpabuf_put(msg, 0) - len - 2);
  260|       |
  261|       |#ifdef CONFIG_WPS_TESTING
  262|       |	if (WPS_VERSION > 0x20) {
  263|       |		if (wpabuf_tailroom(msg) < 5)
  264|       |			return -1;
  265|       |		wpa_printf(MSG_DEBUG, "WPS:  * Extensibility Testing - extra "
  266|       |			   "attribute");
  267|       |		wpabuf_put_be16(msg, ATTR_EXTENSIBILITY_TEST);
  268|       |		wpabuf_put_be16(msg, 1);
  269|       |		wpabuf_put_u8(msg, 42);
  270|       |	}
  271|       |#endif /* CONFIG_WPS_TESTING */
  272|     36|	return 0;
  273|     36|}

wps_parse_msg:
  597|  4.93k|{
  598|  4.93k|	const u8 *pos, *end;
  599|  4.93k|	u16 type, len;
  600|  4.93k|#ifdef WPS_WORKAROUNDS
  601|  4.93k|	u16 prev_type = 0;
  602|  4.93k|	size_t last_nonzero = 0;
  603|  4.93k|	const u8 *start;
  604|  4.93k|#endif /* WPS_WORKAROUNDS */
  605|       |
  606|  4.93k|	os_memset(attr, 0, sizeof(*attr));
  ------------------
  |  |  529|  4.93k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  607|  4.93k|	pos = wpabuf_head(msg);
  608|  4.93k|#ifdef WPS_WORKAROUNDS
  609|  4.93k|	start = pos;
  610|  4.93k|#endif /* WPS_WORKAROUNDS */
  611|  4.93k|	end = pos + wpabuf_len(msg);
  612|       |
  613|  1.89M|	while (pos < end) {
  ------------------
  |  Branch (613:9): [True: 1.89M, False: 2.86k]
  ------------------
  614|  1.89M|		if (end - pos < 4) {
  ------------------
  |  Branch (614:7): [True: 156, False: 1.88M]
  ------------------
  615|    156|			wpa_printf(MSG_DEBUG, "WPS: Invalid message - "
  616|    156|				   "%lu bytes remaining",
  617|    156|				   (unsigned long) (end - pos));
  618|    156|			return -1;
  619|    156|		}
  620|       |
  621|  1.88M|		type = WPA_GET_BE16(pos);
  622|  1.88M|		pos += 2;
  623|  1.88M|		len = WPA_GET_BE16(pos);
  624|  1.88M|		pos += 2;
  625|  1.88M|		wpa_printf(MSG_EXCESSIVE, "WPS: attr type=0x%x len=%u",
  626|  1.88M|			   type, len);
  627|  1.88M|		if (len > end - pos) {
  ------------------
  |  Branch (627:7): [True: 1.05k, False: 1.88M]
  ------------------
  628|  1.05k|			wpa_printf(MSG_DEBUG, "WPS: Attribute overflow");
  629|  1.05k|			wpa_hexdump_buf(MSG_MSGDUMP, "WPS: Message data", msg);
  630|  1.05k|#ifdef WPS_WORKAROUNDS
  631|       |			/*
  632|       |			 * Some deployed APs seem to have a bug in encoding of
  633|       |			 * Network Key attribute in the Credential attribute
  634|       |			 * where they add an extra octet after the Network Key
  635|       |			 * attribute at least when open network is being
  636|       |			 * provisioned.
  637|       |			 */
  638|  1.05k|			if ((type & 0xff00) != 0x1000 &&
  ------------------
  |  Branch (638:8): [True: 1.02k, False: 26]
  ------------------
  639|  1.02k|			    prev_type == ATTR_NETWORK_KEY) {
  ------------------
  |  Branch (639:8): [True: 658, False: 368]
  ------------------
  640|    658|				wpa_printf(MSG_DEBUG, "WPS: Workaround - try "
  641|    658|					   "to skip unexpected octet after "
  642|    658|					   "Network Key");
  643|    658|				pos -= 3;
  644|    658|				continue;
  645|    658|			}
  646|    394|#endif /* WPS_WORKAROUNDS */
  647|    394|			return -1;
  648|  1.05k|		}
  649|       |
  650|  1.88M|#ifdef WPS_WORKAROUNDS
  651|  1.88M|		if (type == 0 && len == 0) {
  ------------------
  |  Branch (651:7): [True: 1.86M, False: 24.5k]
  |  Branch (651:20): [True: 1.86M, False: 716]
  ------------------
  652|       |			/*
  653|       |			 * Mac OS X 10.6 seems to be adding 0x00 padding to the
  654|       |			 * end of M1. Skip those to avoid interop issues.
  655|       |			 */
  656|  1.86M|			int i;
  657|       |
  658|  1.86M|			if (last_nonzero > (size_t) (pos - start))
  ------------------
  |  Branch (658:8): [True: 1.86M, False: 2.44k]
  ------------------
  659|  1.86M|				continue;
  660|       |
  661|  7.47M|			for (i = 0; i < end - pos; i++) {
  ------------------
  |  Branch (661:16): [True: 7.47M, False: 97]
  ------------------
  662|  7.47M|				if (pos[i]) {
  ------------------
  |  Branch (662:9): [True: 2.34k, False: 7.47M]
  ------------------
  663|  2.34k|					last_nonzero = pos - start + i;
  664|  2.34k|					break;
  665|  2.34k|				}
  666|  7.47M|			}
  667|  2.44k|			if (i == end - pos) {
  ------------------
  |  Branch (667:8): [True: 97, False: 2.34k]
  ------------------
  668|     97|				wpa_printf(MSG_DEBUG, "WPS: Workaround - skip "
  669|     97|					   "unexpected message padding");
  670|     97|				break;
  671|     97|			}
  672|  2.44k|		}
  673|  27.6k|#endif /* WPS_WORKAROUNDS */
  674|       |
  675|  27.6k|		if (wps_set_attr(attr, type, pos, len) < 0)
  ------------------
  |  Branch (675:7): [True: 1.41k, False: 26.2k]
  ------------------
  676|  1.41k|			return -1;
  677|       |
  678|  26.2k|#ifdef WPS_WORKAROUNDS
  679|  26.2k|		prev_type = type;
  680|  26.2k|#endif /* WPS_WORKAROUNDS */
  681|  26.2k|		pos += len;
  682|  26.2k|	}
  683|       |
  684|  2.96k|	return 0;
  685|  4.93k|}
wps_attr_parse.c:wps_set_attr:
  154|  27.6k|{
  155|  27.6k|	switch (type) {
  156|    245|	case ATTR_VERSION:
  ------------------
  |  Branch (156:2): [True: 245, False: 27.3k]
  ------------------
  157|    245|		if (len != 1) {
  ------------------
  |  Branch (157:7): [True: 35, False: 210]
  ------------------
  158|     35|			wpa_printf(MSG_DEBUG, "WPS: Invalid Version length %u",
  159|     35|				   len);
  160|     35|			return -1;
  161|     35|		}
  162|    210|		attr->version = pos;
  163|    210|		break;
  164|    250|	case ATTR_MSG_TYPE:
  ------------------
  |  Branch (164:2): [True: 250, False: 27.3k]
  ------------------
  165|    250|		if (len != 1) {
  ------------------
  |  Branch (165:7): [True: 28, False: 222]
  ------------------
  166|     28|			wpa_printf(MSG_DEBUG, "WPS: Invalid Message Type "
  167|     28|				   "length %u", len);
  168|     28|			return -1;
  169|     28|		}
  170|    222|		attr->msg_type = pos;
  171|    222|		break;
  172|    210|	case ATTR_ENROLLEE_NONCE:
  ------------------
  |  Branch (172:2): [True: 210, False: 27.4k]
  ------------------
  173|    210|		if (len != WPS_NONCE_LEN) {
  ------------------
  |  |   33|    210|#define WPS_NONCE_LEN 16
  ------------------
  |  Branch (173:7): [True: 16, False: 194]
  ------------------
  174|     16|			wpa_printf(MSG_DEBUG, "WPS: Invalid Enrollee Nonce "
  175|     16|				   "length %u", len);
  176|     16|			return -1;
  177|     16|		}
  178|    194|		attr->enrollee_nonce = pos;
  179|    194|		break;
  180|    227|	case ATTR_REGISTRAR_NONCE:
  ------------------
  |  Branch (180:2): [True: 227, False: 27.4k]
  ------------------
  181|    227|		if (len != WPS_NONCE_LEN) {
  ------------------
  |  |   33|    227|#define WPS_NONCE_LEN 16
  ------------------
  |  Branch (181:7): [True: 33, False: 194]
  ------------------
  182|     33|			wpa_printf(MSG_DEBUG, "WPS: Invalid Registrar Nonce "
  183|     33|				   "length %u", len);
  184|     33|			return -1;
  185|     33|		}
  186|    194|		attr->registrar_nonce = pos;
  187|    194|		break;
  188|    227|	case ATTR_UUID_E:
  ------------------
  |  Branch (188:2): [True: 227, False: 27.4k]
  ------------------
  189|    227|		if (len != WPS_UUID_LEN) {
  ------------------
  |  |   32|    227|#define WPS_UUID_LEN 16
  ------------------
  |  Branch (189:7): [True: 33, False: 194]
  ------------------
  190|     33|			wpa_printf(MSG_DEBUG, "WPS: Invalid UUID-E length %u",
  191|     33|				   len);
  192|     33|			return -1;
  193|     33|		}
  194|    194|		attr->uuid_e = pos;
  195|    194|		break;
  196|    240|	case ATTR_UUID_R:
  ------------------
  |  Branch (196:2): [True: 240, False: 27.3k]
  ------------------
  197|    240|		if (len != WPS_UUID_LEN) {
  ------------------
  |  |   32|    240|#define WPS_UUID_LEN 16
  ------------------
  |  Branch (197:7): [True: 35, False: 205]
  ------------------
  198|     35|			wpa_printf(MSG_DEBUG, "WPS: Invalid UUID-R length %u",
  199|     35|				   len);
  200|     35|			return -1;
  201|     35|		}
  202|    205|		attr->uuid_r = pos;
  203|    205|		break;
  204|    206|	case ATTR_AUTH_TYPE_FLAGS:
  ------------------
  |  Branch (204:2): [True: 206, False: 27.4k]
  ------------------
  205|    206|		if (len != 2) {
  ------------------
  |  Branch (205:7): [True: 10, False: 196]
  ------------------
  206|     10|			wpa_printf(MSG_DEBUG, "WPS: Invalid Authentication "
  207|     10|				   "Type Flags length %u", len);
  208|     10|			return -1;
  209|     10|		}
  210|    196|		attr->auth_type_flags = pos;
  211|    196|		break;
  212|    312|	case ATTR_ENCR_TYPE_FLAGS:
  ------------------
  |  Branch (212:2): [True: 312, False: 27.3k]
  ------------------
  213|    312|		if (len != 2) {
  ------------------
  |  Branch (213:7): [True: 30, False: 282]
  ------------------
  214|     30|			wpa_printf(MSG_DEBUG, "WPS: Invalid Encryption Type "
  215|     30|				   "Flags length %u", len);
  216|     30|			return -1;
  217|     30|		}
  218|    282|		attr->encr_type_flags = pos;
  219|    282|		break;
  220|    279|	case ATTR_CONN_TYPE_FLAGS:
  ------------------
  |  Branch (220:2): [True: 279, False: 27.3k]
  ------------------
  221|    279|		if (len != 1) {
  ------------------
  |  Branch (221:7): [True: 21, False: 258]
  ------------------
  222|     21|			wpa_printf(MSG_DEBUG, "WPS: Invalid Connection Type "
  223|     21|				   "Flags length %u", len);
  224|     21|			return -1;
  225|     21|		}
  226|    258|		attr->conn_type_flags = pos;
  227|    258|		break;
  228|    716|	case ATTR_CONFIG_METHODS:
  ------------------
  |  Branch (228:2): [True: 716, False: 26.9k]
  ------------------
  229|    716|		if (len != 2) {
  ------------------
  |  Branch (229:7): [True: 23, False: 693]
  ------------------
  230|     23|			wpa_printf(MSG_DEBUG, "WPS: Invalid Config Methods "
  231|     23|				   "length %u", len);
  232|     23|			return -1;
  233|     23|		}
  234|    693|		attr->config_methods = pos;
  235|    693|		break;
  236|    243|	case ATTR_SELECTED_REGISTRAR_CONFIG_METHODS:
  ------------------
  |  Branch (236:2): [True: 243, False: 27.3k]
  ------------------
  237|    243|		if (len != 2) {
  ------------------
  |  Branch (237:7): [True: 39, False: 204]
  ------------------
  238|     39|			wpa_printf(MSG_DEBUG, "WPS: Invalid Selected "
  239|     39|				   "Registrar Config Methods length %u", len);
  240|     39|			return -1;
  241|     39|		}
  242|    204|		attr->sel_reg_config_methods = pos;
  243|    204|		break;
  244|    294|	case ATTR_PRIMARY_DEV_TYPE:
  ------------------
  |  Branch (244:2): [True: 294, False: 27.3k]
  ------------------
  245|    294|		if (len != WPS_DEV_TYPE_LEN) {
  ------------------
  |  |   60|    294|#define WPS_DEV_TYPE_LEN 8
  ------------------
  |  Branch (245:7): [True: 36, False: 258]
  ------------------
  246|     36|			wpa_printf(MSG_DEBUG, "WPS: Invalid Primary Device "
  247|     36|				   "Type length %u", len);
  248|     36|			return -1;
  249|     36|		}
  250|    258|		attr->primary_dev_type = pos;
  251|    258|		break;
  252|    216|	case ATTR_RF_BANDS:
  ------------------
  |  Branch (252:2): [True: 216, False: 27.4k]
  ------------------
  253|    216|		if (len != 1) {
  ------------------
  |  Branch (253:7): [True: 12, False: 204]
  ------------------
  254|     12|			wpa_printf(MSG_DEBUG, "WPS: Invalid RF Bands length "
  255|     12|				   "%u", len);
  256|     12|			return -1;
  257|     12|		}
  258|    204|		attr->rf_bands = pos;
  259|    204|		break;
  260|    258|	case ATTR_ASSOC_STATE:
  ------------------
  |  Branch (260:2): [True: 258, False: 27.3k]
  ------------------
  261|    258|		if (len != 2) {
  ------------------
  |  Branch (261:7): [True: 40, False: 218]
  ------------------
  262|     40|			wpa_printf(MSG_DEBUG, "WPS: Invalid Association State "
  263|     40|				   "length %u", len);
  264|     40|			return -1;
  265|     40|		}
  266|    218|		attr->assoc_state = pos;
  267|    218|		break;
  268|    264|	case ATTR_CONFIG_ERROR:
  ------------------
  |  Branch (268:2): [True: 264, False: 27.3k]
  ------------------
  269|    264|		if (len != 2) {
  ------------------
  |  Branch (269:7): [True: 49, False: 215]
  ------------------
  270|     49|			wpa_printf(MSG_DEBUG, "WPS: Invalid Configuration "
  271|     49|				   "Error length %u", len);
  272|     49|			return -1;
  273|     49|		}
  274|    215|		attr->config_error = pos;
  275|    215|		break;
  276|    222|	case ATTR_DEV_PASSWORD_ID:
  ------------------
  |  Branch (276:2): [True: 222, False: 27.4k]
  ------------------
  277|    222|		if (len != 2) {
  ------------------
  |  Branch (277:7): [True: 24, False: 198]
  ------------------
  278|     24|			wpa_printf(MSG_DEBUG, "WPS: Invalid Device Password "
  279|     24|				   "ID length %u", len);
  280|     24|			return -1;
  281|     24|		}
  282|    198|		attr->dev_password_id = pos;
  283|    198|		break;
  284|    468|	case ATTR_OOB_DEVICE_PASSWORD:
  ------------------
  |  Branch (284:2): [True: 468, False: 27.1k]
  ------------------
  285|    468|		if (len < WPS_OOB_PUBKEY_HASH_LEN + 2 ||
  ------------------
  |  |   47|    468|#define WPS_OOB_PUBKEY_HASH_LEN 20
  ------------------
  |  Branch (285:7): [True: 17, False: 451]
  ------------------
  286|    451|		    len > WPS_OOB_PUBKEY_HASH_LEN + 2 +
  ------------------
  |  |   47|    451|#define WPS_OOB_PUBKEY_HASH_LEN 20
  ------------------
  |  Branch (286:7): [True: 27, False: 424]
  ------------------
  287|    451|		    WPS_OOB_DEVICE_PASSWORD_LEN ||
  ------------------
  |  |   46|    919|#define WPS_OOB_DEVICE_PASSWORD_LEN 32
  ------------------
  288|    424|		    (len < WPS_OOB_PUBKEY_HASH_LEN + 2 +
  ------------------
  |  |   47|    424|#define WPS_OOB_PUBKEY_HASH_LEN 20
  ------------------
  |  Branch (288:8): [True: 222, False: 202]
  ------------------
  289|    424|		     WPS_OOB_DEVICE_PASSWORD_MIN_LEN &&
  ------------------
  |  |   45|    848|#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN 16
  ------------------
  290|    222|		     WPA_GET_BE16(pos + WPS_OOB_PUBKEY_HASH_LEN) !=
  ------------------
  |  |   47|    222|#define WPS_OOB_PUBKEY_HASH_LEN 20
  ------------------
  |  Branch (290:8): [True: 22, False: 200]
  ------------------
  291|    222|		     DEV_PW_NFC_CONNECTION_HANDOVER)) {
  292|     66|			wpa_printf(MSG_DEBUG, "WPS: Invalid OOB Device "
  293|     66|				   "Password length %u", len);
  294|     66|			return -1;
  295|     66|		}
  296|    402|		attr->oob_dev_password = pos;
  297|    402|		attr->oob_dev_password_len = len;
  298|    402|		break;
  299|    226|	case ATTR_OS_VERSION:
  ------------------
  |  Branch (299:2): [True: 226, False: 27.4k]
  ------------------
  300|    226|		if (len != 4) {
  ------------------
  |  Branch (300:7): [True: 32, False: 194]
  ------------------
  301|     32|			wpa_printf(MSG_DEBUG, "WPS: Invalid OS Version length "
  302|     32|				   "%u", len);
  303|     32|			return -1;
  304|     32|		}
  305|    194|		attr->os_version = pos;
  306|    194|		break;
  307|    255|	case ATTR_WPS_STATE:
  ------------------
  |  Branch (307:2): [True: 255, False: 27.3k]
  ------------------
  308|    255|		if (len != 1) {
  ------------------
  |  Branch (308:7): [True: 17, False: 238]
  ------------------
  309|     17|			wpa_printf(MSG_DEBUG, "WPS: Invalid Wi-Fi Protected "
  310|     17|				   "Setup State length %u", len);
  311|     17|			return -1;
  312|     17|		}
  313|    238|		attr->wps_state = pos;
  314|    238|		break;
  315|    325|	case ATTR_AUTHENTICATOR:
  ------------------
  |  Branch (315:2): [True: 325, False: 27.3k]
  ------------------
  316|    325|		if (len != WPS_AUTHENTICATOR_LEN) {
  ------------------
  |  |   34|    325|#define WPS_AUTHENTICATOR_LEN 8
  ------------------
  |  Branch (316:7): [True: 40, False: 285]
  ------------------
  317|     40|			wpa_printf(MSG_DEBUG, "WPS: Invalid Authenticator "
  318|     40|				   "length %u", len);
  319|     40|			return -1;
  320|     40|		}
  321|    285|		attr->authenticator = pos;
  322|    285|		break;
  323|    234|	case ATTR_R_HASH1:
  ------------------
  |  Branch (323:2): [True: 234, False: 27.4k]
  ------------------
  324|    234|		if (len != WPS_HASH_LEN) {
  ------------------
  |  |   40|    234|#define WPS_HASH_LEN 32
  ------------------
  |  Branch (324:7): [True: 40, False: 194]
  ------------------
  325|     40|			wpa_printf(MSG_DEBUG, "WPS: Invalid R-Hash1 length %u",
  326|     40|				   len);
  327|     40|			return -1;
  328|     40|		}
  329|    194|		attr->r_hash1 = pos;
  330|    194|		break;
  331|    232|	case ATTR_R_HASH2:
  ------------------
  |  Branch (331:2): [True: 232, False: 27.4k]
  ------------------
  332|    232|		if (len != WPS_HASH_LEN) {
  ------------------
  |  |   40|    232|#define WPS_HASH_LEN 32
  ------------------
  |  Branch (332:7): [True: 38, False: 194]
  ------------------
  333|     38|			wpa_printf(MSG_DEBUG, "WPS: Invalid R-Hash2 length %u",
  334|     38|				   len);
  335|     38|			return -1;
  336|     38|		}
  337|    194|		attr->r_hash2 = pos;
  338|    194|		break;
  339|    231|	case ATTR_E_HASH1:
  ------------------
  |  Branch (339:2): [True: 231, False: 27.4k]
  ------------------
  340|    231|		if (len != WPS_HASH_LEN) {
  ------------------
  |  |   40|    231|#define WPS_HASH_LEN 32
  ------------------
  |  Branch (340:7): [True: 35, False: 196]
  ------------------
  341|     35|			wpa_printf(MSG_DEBUG, "WPS: Invalid E-Hash1 length %u",
  342|     35|				   len);
  343|     35|			return -1;
  344|     35|		}
  345|    196|		attr->e_hash1 = pos;
  346|    196|		break;
  347|    226|	case ATTR_E_HASH2:
  ------------------
  |  Branch (347:2): [True: 226, False: 27.4k]
  ------------------
  348|    226|		if (len != WPS_HASH_LEN) {
  ------------------
  |  |   40|    226|#define WPS_HASH_LEN 32
  ------------------
  |  Branch (348:7): [True: 8, False: 218]
  ------------------
  349|      8|			wpa_printf(MSG_DEBUG, "WPS: Invalid E-Hash2 length %u",
  350|      8|				   len);
  351|      8|			return -1;
  352|      8|		}
  353|    218|		attr->e_hash2 = pos;
  354|    218|		break;
  355|    398|	case ATTR_R_SNONCE1:
  ------------------
  |  Branch (355:2): [True: 398, False: 27.2k]
  ------------------
  356|    398|		if (len != WPS_SECRET_NONCE_LEN) {
  ------------------
  |  |   39|    398|#define WPS_SECRET_NONCE_LEN 16
  ------------------
  |  Branch (356:7): [True: 35, False: 363]
  ------------------
  357|     35|			wpa_printf(MSG_DEBUG, "WPS: Invalid R-SNonce1 length "
  358|     35|				   "%u", len);
  359|     35|			return -1;
  360|     35|		}
  361|    363|		attr->r_snonce1 = pos;
  362|    363|		break;
  363|    211|	case ATTR_R_SNONCE2:
  ------------------
  |  Branch (363:2): [True: 211, False: 27.4k]
  ------------------
  364|    211|		if (len != WPS_SECRET_NONCE_LEN) {
  ------------------
  |  |   39|    211|#define WPS_SECRET_NONCE_LEN 16
  ------------------
  |  Branch (364:7): [True: 17, False: 194]
  ------------------
  365|     17|			wpa_printf(MSG_DEBUG, "WPS: Invalid R-SNonce2 length "
  366|     17|				   "%u", len);
  367|     17|			return -1;
  368|     17|		}
  369|    194|		attr->r_snonce2 = pos;
  370|    194|		break;
  371|    251|	case ATTR_E_SNONCE1:
  ------------------
  |  Branch (371:2): [True: 251, False: 27.3k]
  ------------------
  372|    251|		if (len != WPS_SECRET_NONCE_LEN) {
  ------------------
  |  |   39|    251|#define WPS_SECRET_NONCE_LEN 16
  ------------------
  |  Branch (372:7): [True: 14, False: 237]
  ------------------
  373|     14|			wpa_printf(MSG_DEBUG, "WPS: Invalid E-SNonce1 length "
  374|     14|				   "%u", len);
  375|     14|			return -1;
  376|     14|		}
  377|    237|		attr->e_snonce1 = pos;
  378|    237|		break;
  379|    245|	case ATTR_E_SNONCE2:
  ------------------
  |  Branch (379:2): [True: 245, False: 27.3k]
  ------------------
  380|    245|		if (len != WPS_SECRET_NONCE_LEN) {
  ------------------
  |  |   39|    245|#define WPS_SECRET_NONCE_LEN 16
  ------------------
  |  Branch (380:7): [True: 39, False: 206]
  ------------------
  381|     39|			wpa_printf(MSG_DEBUG, "WPS: Invalid E-SNonce2 length "
  382|     39|				   "%u", len);
  383|     39|			return -1;
  384|     39|		}
  385|    206|		attr->e_snonce2 = pos;
  386|    206|		break;
  387|    240|	case ATTR_KEY_WRAP_AUTH:
  ------------------
  |  Branch (387:2): [True: 240, False: 27.3k]
  ------------------
  388|    240|		if (len != WPS_KWA_LEN) {
  ------------------
  |  |   41|    240|#define WPS_KWA_LEN 8
  ------------------
  |  Branch (388:7): [True: 40, False: 200]
  ------------------
  389|     40|			wpa_printf(MSG_DEBUG, "WPS: Invalid Key Wrap "
  390|     40|				   "Authenticator length %u", len);
  391|     40|			return -1;
  392|     40|		}
  393|    200|		attr->key_wrap_auth = pos;
  394|    200|		break;
  395|    269|	case ATTR_AUTH_TYPE:
  ------------------
  |  Branch (395:2): [True: 269, False: 27.3k]
  ------------------
  396|    269|		if (len != 2) {
  ------------------
  |  Branch (396:7): [True: 35, False: 234]
  ------------------
  397|     35|			wpa_printf(MSG_DEBUG, "WPS: Invalid Authentication "
  398|     35|				   "Type length %u", len);
  399|     35|			return -1;
  400|     35|		}
  401|    234|		attr->auth_type = pos;
  402|    234|		break;
  403|    252|	case ATTR_ENCR_TYPE:
  ------------------
  |  Branch (403:2): [True: 252, False: 27.3k]
  ------------------
  404|    252|		if (len != 2) {
  ------------------
  |  Branch (404:7): [True: 32, False: 220]
  ------------------
  405|     32|			wpa_printf(MSG_DEBUG, "WPS: Invalid Encryption "
  406|     32|				   "Type length %u", len);
  407|     32|			return -1;
  408|     32|		}
  409|    220|		attr->encr_type = pos;
  410|    220|		break;
  411|    325|	case ATTR_NETWORK_INDEX:
  ------------------
  |  Branch (411:2): [True: 325, False: 27.3k]
  ------------------
  412|    325|		if (len != 1) {
  ------------------
  |  Branch (412:7): [True: 32, False: 293]
  ------------------
  413|     32|			wpa_printf(MSG_DEBUG, "WPS: Invalid Network Index "
  414|     32|				   "length %u", len);
  415|     32|			return -1;
  416|     32|		}
  417|    293|		attr->network_idx = pos;
  418|    293|		break;
  419|    210|	case ATTR_NETWORK_KEY_INDEX:
  ------------------
  |  Branch (419:2): [True: 210, False: 27.4k]
  ------------------
  420|    210|		if (len != 1) {
  ------------------
  |  Branch (420:7): [True: 15, False: 195]
  ------------------
  421|     15|			wpa_printf(MSG_DEBUG, "WPS: Invalid Network Key Index "
  422|     15|				   "length %u", len);
  423|     15|			return -1;
  424|     15|		}
  425|    195|		attr->network_key_idx = pos;
  426|    195|		break;
  427|    215|	case ATTR_MAC_ADDR:
  ------------------
  |  Branch (427:2): [True: 215, False: 27.4k]
  ------------------
  428|    215|		if (len != ETH_ALEN) {
  ------------------
  |  |  344|    215|#define ETH_ALEN 6
  ------------------
  |  Branch (428:7): [True: 21, False: 194]
  ------------------
  429|     21|			wpa_printf(MSG_DEBUG, "WPS: Invalid MAC Address "
  430|     21|				   "length %u", len);
  431|     21|			return -1;
  432|     21|		}
  433|    194|		attr->mac_addr = pos;
  434|    194|		break;
  435|    286|	case ATTR_SELECTED_REGISTRAR:
  ------------------
  |  Branch (435:2): [True: 286, False: 27.3k]
  ------------------
  436|    286|		if (len != 1) {
  ------------------
  |  Branch (436:7): [True: 36, False: 250]
  ------------------
  437|     36|			wpa_printf(MSG_DEBUG, "WPS: Invalid Selected Registrar"
  438|     36|				   " length %u", len);
  439|     36|			return -1;
  440|     36|		}
  441|    250|		attr->selected_registrar = pos;
  442|    250|		break;
  443|    235|	case ATTR_REQUEST_TYPE:
  ------------------
  |  Branch (443:2): [True: 235, False: 27.4k]
  ------------------
  444|    235|		if (len != 1) {
  ------------------
  |  Branch (444:7): [True: 33, False: 202]
  ------------------
  445|     33|			wpa_printf(MSG_DEBUG, "WPS: Invalid Request Type "
  446|     33|				   "length %u", len);
  447|     33|			return -1;
  448|     33|		}
  449|    202|		attr->request_type = pos;
  450|    202|		break;
  451|  1.01k|	case ATTR_RESPONSE_TYPE:
  ------------------
  |  Branch (451:2): [True: 1.01k, False: 26.6k]
  ------------------
  452|  1.01k|		if (len != 1) {
  ------------------
  |  Branch (452:7): [True: 20, False: 994]
  ------------------
  453|     20|			wpa_printf(MSG_DEBUG, "WPS: Invalid Response Type "
  454|     20|				   "length %u", len);
  455|     20|			return -1;
  456|     20|		}
  457|    994|		attr->response_type = pos;
  458|    994|		break;
  459|  1.02k|	case ATTR_MANUFACTURER:
  ------------------
  |  Branch (459:2): [True: 1.02k, False: 26.6k]
  ------------------
  460|  1.02k|		attr->manufacturer = pos;
  461|  1.02k|		if (len > WPS_MANUFACTURER_MAX_LEN)
  ------------------
  |  |   49|  1.02k|#define WPS_MANUFACTURER_MAX_LEN 64
  ------------------
  |  Branch (461:7): [True: 743, False: 281]
  ------------------
  462|    743|			attr->manufacturer_len = WPS_MANUFACTURER_MAX_LEN;
  ------------------
  |  |   49|    743|#define WPS_MANUFACTURER_MAX_LEN 64
  ------------------
  463|    281|		else
  464|    281|			attr->manufacturer_len = len;
  465|  1.02k|		break;
  466|    845|	case ATTR_MODEL_NAME:
  ------------------
  |  Branch (466:2): [True: 845, False: 26.7k]
  ------------------
  467|    845|		attr->model_name = pos;
  468|    845|		if (len > WPS_MODEL_NAME_MAX_LEN)
  ------------------
  |  |   50|    845|#define WPS_MODEL_NAME_MAX_LEN 32
  ------------------
  |  Branch (468:7): [True: 577, False: 268]
  ------------------
  469|    577|			attr->model_name_len = WPS_MODEL_NAME_MAX_LEN;
  ------------------
  |  |   50|    577|#define WPS_MODEL_NAME_MAX_LEN 32
  ------------------
  470|    268|		else
  471|    268|			attr->model_name_len = len;
  472|    845|		break;
  473|  1.80k|	case ATTR_MODEL_NUMBER:
  ------------------
  |  Branch (473:2): [True: 1.80k, False: 25.8k]
  ------------------
  474|  1.80k|		attr->model_number = pos;
  475|  1.80k|		if (len > WPS_MODEL_NUMBER_MAX_LEN)
  ------------------
  |  |   51|  1.80k|#define WPS_MODEL_NUMBER_MAX_LEN 32
  ------------------
  |  Branch (475:7): [True: 1.44k, False: 368]
  ------------------
  476|  1.44k|			attr->model_number_len = WPS_MODEL_NUMBER_MAX_LEN;
  ------------------
  |  |   51|  1.44k|#define WPS_MODEL_NUMBER_MAX_LEN 32
  ------------------
  477|    368|		else
  478|    368|			attr->model_number_len = len;
  479|  1.80k|		break;
  480|    883|	case ATTR_SERIAL_NUMBER:
  ------------------
  |  Branch (480:2): [True: 883, False: 26.7k]
  ------------------
  481|    883|		attr->serial_number = pos;
  482|    883|		if (len > WPS_SERIAL_NUMBER_MAX_LEN)
  ------------------
  |  |   52|    883|#define WPS_SERIAL_NUMBER_MAX_LEN 32
  ------------------
  |  Branch (482:7): [True: 612, False: 271]
  ------------------
  483|    612|			attr->serial_number_len = WPS_SERIAL_NUMBER_MAX_LEN;
  ------------------
  |  |   52|    612|#define WPS_SERIAL_NUMBER_MAX_LEN 32
  ------------------
  484|    271|		else
  485|    271|			attr->serial_number_len = len;
  486|    883|		break;
  487|    581|	case ATTR_DEV_NAME:
  ------------------
  |  Branch (487:2): [True: 581, False: 27.0k]
  ------------------
  488|    581|		if (len > WPS_DEV_NAME_MAX_LEN) {
  ------------------
  |  |   48|    581|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  |  Branch (488:7): [True: 220, False: 361]
  ------------------
  489|    220|			wpa_printf(MSG_DEBUG,
  490|    220|				   "WPS: Ignore too long Device Name (len=%u)",
  491|    220|				   len);
  492|    220|			break;
  493|    220|		}
  494|    361|		attr->dev_name = pos;
  495|    361|		attr->dev_name_len = len;
  496|    361|		break;
  497|    769|	case ATTR_PUBLIC_KEY:
  ------------------
  |  Branch (497:2): [True: 769, False: 26.8k]
  ------------------
  498|       |		/*
  499|       |		 * The Public Key attribute is supposed to be exactly 192 bytes
  500|       |		 * in length. Allow couple of bytes shorter one to try to
  501|       |		 * interoperate with implementations that do not use proper
  502|       |		 * zero-padding.
  503|       |		 */
  504|    769|		if (len < 190 || len > 192) {
  ------------------
  |  Branch (504:7): [True: 286, False: 483]
  |  Branch (504:20): [True: 282, False: 201]
  ------------------
  505|    568|			wpa_printf(MSG_DEBUG,
  506|    568|				   "WPS: Ignore Public Key with unexpected length %u",
  507|    568|				   len);
  508|    568|			break;
  509|    568|		}
  510|    201|		attr->public_key = pos;
  511|    201|		attr->public_key_len = len;
  512|    201|		break;
  513|    194|	case ATTR_ENCR_SETTINGS:
  ------------------
  |  Branch (513:2): [True: 194, False: 27.4k]
  ------------------
  514|    194|		attr->encr_settings = pos;
  515|    194|		attr->encr_settings_len = len;
  516|    194|		break;
  517|  1.46k|	case ATTR_CRED:
  ------------------
  |  Branch (517:2): [True: 1.46k, False: 26.1k]
  ------------------
  518|  1.46k|		if (attr->num_cred >= MAX_CRED_COUNT) {
  ------------------
  |  |   87|  1.46k|#define MAX_CRED_COUNT 10
  ------------------
  |  Branch (518:7): [True: 920, False: 540]
  ------------------
  519|    920|			wpa_printf(MSG_DEBUG, "WPS: Skipped Credential "
  520|    920|				   "attribute (max %d credentials)",
  521|    920|				   MAX_CRED_COUNT);
  ------------------
  |  |   87|    920|#define MAX_CRED_COUNT 10
  ------------------
  522|    920|			break;
  523|    920|		}
  524|    540|		attr->cred[attr->num_cred] = pos;
  525|    540|		attr->cred_len[attr->num_cred] = len;
  526|    540|		attr->num_cred++;
  527|    540|		break;
  528|    453|	case ATTR_SSID:
  ------------------
  |  Branch (528:2): [True: 453, False: 27.1k]
  ------------------
  529|    453|		if (len > SSID_MAX_LEN) {
  ------------------
  |  |  511|    453|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (529:7): [True: 201, False: 252]
  ------------------
  530|    201|			wpa_printf(MSG_DEBUG,
  531|    201|				   "WPS: Ignore too long SSID (len=%u)", len);
  532|    201|			break;
  533|    201|		}
  534|    252|		attr->ssid = pos;
  535|    252|		attr->ssid_len = len;
  536|    252|		break;
  537|    250|	case ATTR_NETWORK_KEY:
  ------------------
  |  Branch (537:2): [True: 250, False: 27.3k]
  ------------------
  538|    250|		attr->network_key = pos;
  539|    250|		attr->network_key_len = len;
  540|    250|		break;
  541|    238|	case ATTR_AP_SETUP_LOCKED:
  ------------------
  |  Branch (541:2): [True: 238, False: 27.3k]
  ------------------
  542|    238|		if (len != 1) {
  ------------------
  |  Branch (542:7): [True: 34, False: 204]
  ------------------
  543|     34|			wpa_printf(MSG_DEBUG, "WPS: Invalid AP Setup Locked "
  544|     34|				   "length %u", len);
  545|     34|			return -1;
  546|     34|		}
  547|    204|		attr->ap_setup_locked = pos;
  548|    204|		break;
  549|    569|	case ATTR_REQUESTED_DEV_TYPE:
  ------------------
  |  Branch (549:2): [True: 569, False: 27.0k]
  ------------------
  550|    569|		if (len != WPS_DEV_TYPE_LEN) {
  ------------------
  |  |   60|    569|#define WPS_DEV_TYPE_LEN 8
  ------------------
  |  Branch (550:7): [True: 34, False: 535]
  ------------------
  551|     34|			wpa_printf(MSG_DEBUG, "WPS: Invalid Requested Device "
  552|     34|				   "Type length %u", len);
  553|     34|			return -1;
  554|     34|		}
  555|    535|		if (attr->num_req_dev_type >= MAX_REQ_DEV_TYPE_COUNT) {
  ------------------
  |  |   88|    535|#define MAX_REQ_DEV_TYPE_COUNT 10
  ------------------
  |  Branch (555:7): [True: 194, False: 341]
  ------------------
  556|    194|			wpa_printf(MSG_DEBUG, "WPS: Skipped Requested Device "
  557|    194|				   "Type attribute (max %u types)",
  558|    194|				   MAX_REQ_DEV_TYPE_COUNT);
  ------------------
  |  |   88|    194|#define MAX_REQ_DEV_TYPE_COUNT 10
  ------------------
  559|    194|			break;
  560|    194|		}
  561|    341|		attr->req_dev_type[attr->num_req_dev_type] = pos;
  562|    341|		attr->num_req_dev_type++;
  563|    341|		break;
  564|    269|	case ATTR_SECONDARY_DEV_TYPE_LIST:
  ------------------
  |  Branch (564:2): [True: 269, False: 27.3k]
  ------------------
  565|    269|		if (len > WPS_SEC_DEV_TYPE_MAX_LEN ||
  ------------------
  |  |   62|    538|#define WPS_SEC_DEV_TYPE_MAX_LEN 128
  ------------------
  |  Branch (565:7): [True: 16, False: 253]
  ------------------
  566|    253|		    (len % WPS_DEV_TYPE_LEN) > 0) {
  ------------------
  |  |   60|    253|#define WPS_DEV_TYPE_LEN 8
  ------------------
  |  Branch (566:7): [True: 31, False: 222]
  ------------------
  567|     47|			wpa_printf(MSG_DEBUG, "WPS: Invalid Secondary Device "
  568|     47|				   "Type length %u", len);
  569|     47|			return -1;
  570|     47|		}
  571|    222|		attr->sec_dev_type_list = pos;
  572|    222|		attr->sec_dev_type_list_len = len;
  573|    222|		break;
  574|  2.01k|	case ATTR_VENDOR_EXT:
  ------------------
  |  Branch (574:2): [True: 2.01k, False: 25.6k]
  ------------------
  575|  2.01k|		if (wps_parse_vendor_ext(attr, pos, len) < 0)
  ------------------
  |  Branch (575:7): [True: 156, False: 1.86k]
  ------------------
  576|    156|			return -1;
  577|  1.86k|		break;
  578|  1.86k|	case ATTR_AP_CHANNEL:
  ------------------
  |  Branch (578:2): [True: 494, False: 27.1k]
  ------------------
  579|    494|		if (len != 2) {
  ------------------
  |  Branch (579:7): [True: 39, False: 455]
  ------------------
  580|     39|			wpa_printf(MSG_DEBUG, "WPS: Invalid AP Channel "
  581|     39|				   "length %u", len);
  582|     39|			return -1;
  583|     39|		}
  584|    455|		attr->ap_channel = pos;
  585|    455|		break;
  586|  5.02k|	default:
  ------------------
  |  Branch (586:2): [True: 5.02k, False: 22.6k]
  ------------------
  587|  5.02k|		wpa_printf(MSG_DEBUG, "WPS: Unsupported attribute type 0x%x "
  588|  5.02k|			   "len=%u", type, len);
  589|  5.02k|		break;
  590|  27.6k|	}
  591|       |
  592|  26.2k|	return 0;
  593|  27.6k|}
wps_attr_parse.c:wps_parse_vendor_ext:
  113|  2.01k|{
  114|  2.01k|	u32 vendor_id;
  115|       |
  116|  2.01k|	if (len < 3) {
  ------------------
  |  Branch (116:6): [True: 206, False: 1.81k]
  ------------------
  117|    206|		wpa_printf(MSG_DEBUG, "WPS: Skip invalid Vendor Extension");
  118|    206|		return 0;
  119|    206|	}
  120|       |
  121|  1.81k|	vendor_id = WPA_GET_BE24(pos);
  122|  1.81k|	switch (vendor_id) {
  ------------------
  |  Branch (122:10): [True: 1.29k, False: 517]
  ------------------
  123|  1.29k|	case WPS_VENDOR_ID_WFA:
  ------------------
  |  |  146|  1.29k|#define WPS_VENDOR_ID_WFA 14122
  ------------------
  |  Branch (123:2): [True: 1.29k, False: 517]
  ------------------
  124|  1.29k|		return wps_parse_vendor_ext_wfa(attr, pos + 3, len - 3);
  125|  1.81k|	}
  126|       |
  127|       |	/* Handle unknown vendor extensions */
  128|       |
  129|    517|	wpa_printf(MSG_MSGDUMP, "WPS: Unknown Vendor Extension (Vendor ID %u)",
  130|    517|		   vendor_id);
  131|       |
  132|    517|	if (len > WPS_MAX_VENDOR_EXT_LEN) {
  ------------------
  |  |   66|    517|#define WPS_MAX_VENDOR_EXT_LEN 1024
  ------------------
  |  Branch (132:6): [True: 18, False: 499]
  ------------------
  133|     18|		wpa_printf(MSG_DEBUG, "WPS: Too long Vendor Extension (%u)",
  134|     18|			   len);
  135|     18|		return -1;
  136|     18|	}
  137|       |
  138|    499|	if (attr->num_vendor_ext >= MAX_WPS_PARSE_VENDOR_EXT) {
  ------------------
  |  |   68|    499|#define MAX_WPS_PARSE_VENDOR_EXT 10
  ------------------
  |  Branch (138:6): [True: 6, False: 493]
  ------------------
  139|      6|		wpa_printf(MSG_DEBUG, "WPS: Skipped Vendor Extension "
  140|      6|			   "attribute (max %d vendor extensions)",
  141|      6|			   MAX_WPS_PARSE_VENDOR_EXT);
  ------------------
  |  |   68|      6|#define MAX_WPS_PARSE_VENDOR_EXT 10
  ------------------
  142|      6|		return -1;
  143|      6|	}
  144|    493|	attr->vendor_ext[attr->num_vendor_ext] = pos;
  145|    493|	attr->vendor_ext_len[attr->num_vendor_ext] = len;
  146|    493|	attr->num_vendor_ext++;
  147|       |
  148|    493|	return 0;
  149|    499|}
wps_attr_parse.c:wps_parse_vendor_ext_wfa:
   93|  1.29k|{
   94|  1.29k|	const u8 *end = pos + len;
   95|  1.29k|	u8 id, elen;
   96|       |
   97|  4.07k|	while (end - pos >= 2) {
  ------------------
  |  Branch (97:9): [True: 3.42k, False: 650]
  ------------------
   98|  3.42k|		id = *pos++;
   99|  3.42k|		elen = *pos++;
  100|  3.42k|		if (elen > end - pos)
  ------------------
  |  Branch (100:7): [True: 511, False: 2.91k]
  ------------------
  101|    511|			break;
  102|  2.91k|		if (wps_set_vendor_ext_wfa_subelem(attr, id, elen, pos) < 0)
  ------------------
  |  Branch (102:7): [True: 132, False: 2.78k]
  ------------------
  103|    132|			return -1;
  104|  2.78k|		pos += elen;
  105|  2.78k|	}
  106|       |
  107|  1.16k|	return 0;
  108|  1.29k|}
wps_attr_parse.c:wps_set_vendor_ext_wfa_subelem:
   22|  2.91k|{
   23|  2.91k|	wpa_printf(MSG_EXCESSIVE, "WPS: WFA subelement id=%u len=%u",
   24|  2.91k|		   id, len);
   25|  2.91k|	switch (id) {
   26|    253|	case WFA_ELEM_VERSION2:
  ------------------
  |  Branch (26:2): [True: 253, False: 2.66k]
  ------------------
   27|    253|		if (len != 1) {
  ------------------
  |  Branch (27:7): [True: 31, False: 222]
  ------------------
   28|     31|			wpa_printf(MSG_DEBUG, "WPS: Invalid Version2 length "
   29|     31|				   "%u", len);
   30|     31|			return -1;
   31|     31|		}
   32|    222|		attr->version2 = pos;
   33|    222|		break;
   34|    267|	case WFA_ELEM_AUTHORIZEDMACS:
  ------------------
  |  Branch (34:2): [True: 267, False: 2.64k]
  ------------------
   35|    267|		attr->authorized_macs = pos;
   36|    267|		attr->authorized_macs_len = len;
   37|    267|		break;
   38|    318|	case WFA_ELEM_NETWORK_KEY_SHAREABLE:
  ------------------
  |  Branch (38:2): [True: 318, False: 2.59k]
  ------------------
   39|    318|		if (len != 1) {
  ------------------
  |  Branch (39:7): [True: 14, False: 304]
  ------------------
   40|     14|			wpa_printf(MSG_DEBUG, "WPS: Invalid Network Key "
   41|     14|				   "Shareable length %u", len);
   42|     14|			return -1;
   43|     14|		}
   44|    304|		attr->network_key_shareable = pos;
   45|    304|		break;
   46|    220|	case WFA_ELEM_REQUEST_TO_ENROLL:
  ------------------
  |  Branch (46:2): [True: 220, False: 2.69k]
  ------------------
   47|    220|		if (len != 1) {
  ------------------
  |  Branch (47:7): [True: 13, False: 207]
  ------------------
   48|     13|			wpa_printf(MSG_DEBUG, "WPS: Invalid Request to Enroll "
   49|     13|				   "length %u", len);
   50|     13|			return -1;
   51|     13|		}
   52|    207|		attr->request_to_enroll = pos;
   53|    207|		break;
   54|    234|	case WFA_ELEM_SETTINGS_DELAY_TIME:
  ------------------
  |  Branch (54:2): [True: 234, False: 2.68k]
  ------------------
   55|    234|		if (len != 1) {
  ------------------
  |  Branch (55:7): [True: 22, False: 212]
  ------------------
   56|     22|			wpa_printf(MSG_DEBUG, "WPS: Invalid Settings Delay "
   57|     22|				   "Time length %u", len);
   58|     22|			return -1;
   59|     22|		}
   60|    212|		attr->settings_delay_time = pos;
   61|    212|		break;
   62|    371|	case WFA_ELEM_REGISTRAR_CONFIGURATION_METHODS:
  ------------------
  |  Branch (62:2): [True: 371, False: 2.54k]
  ------------------
   63|    371|		if (len != 2) {
  ------------------
  |  Branch (63:7): [True: 27, False: 344]
  ------------------
   64|     27|			wpa_printf(MSG_DEBUG, "WPS: Invalid Registrar Configuration Methods length %u",
   65|     27|				   len);
   66|     27|			return -1;
   67|     27|		}
   68|    344|		attr->registrar_configuration_methods = pos;
   69|    344|		break;
   70|    571|	case WFA_ELEM_MULTI_AP:
  ------------------
  |  Branch (70:2): [True: 571, False: 2.34k]
  ------------------
   71|    571|		if (len != 1) {
  ------------------
  |  Branch (71:7): [True: 25, False: 546]
  ------------------
   72|     25|			wpa_printf(MSG_DEBUG,
   73|     25|				   "WPS: Invalid Multi-AP Extension length %u",
   74|     25|				   len);
   75|     25|			return -1;
   76|     25|		}
   77|    546|		attr->multi_ap_ext = *pos;
   78|    546|		wpa_printf(MSG_DEBUG, "WPS: Multi-AP Extension 0x%02x",
   79|    546|			   attr->multi_ap_ext);
   80|    546|		break;
   81|    680|	default:
  ------------------
  |  Branch (81:2): [True: 680, False: 2.23k]
  ------------------
   82|    680|		wpa_printf(MSG_MSGDUMP, "WPS: Skipped unknown WFA Vendor "
   83|    680|			   "Extension subelement %u", id);
   84|    680|		break;
   85|  2.91k|	}
   86|       |
   87|  2.78k|	return 0;
   88|  2.91k|}

wps_dev_type_bin2str:
  487|  2.32k|{
  488|  2.32k|	int ret;
  489|       |
  490|  2.32k|	ret = os_snprintf(buf, buf_len, "%u-%08X-%u",
  ------------------
  |  |  572|  2.32k|#define os_snprintf snprintf
  ------------------
  491|  2.32k|			  WPA_GET_BE16(dev_type), WPA_GET_BE32(&dev_type[2]),
  492|  2.32k|			  WPA_GET_BE16(&dev_type[6]));
  493|  2.32k|	if (os_snprintf_error(buf_len, ret))
  ------------------
  |  Branch (493:6): [True: 0, False: 2.32k]
  ------------------
  494|      0|		return NULL;
  495|       |
  496|  2.32k|	return buf;
  497|  2.32k|}

wpa_fuzzer_set_debug_level:
   15|  6.88k|{
   16|  6.88k|	static int first = 1;
   17|       |
   18|  6.88k|	if (first) {
  ------------------
  |  Branch (18:6): [True: 1, False: 6.87k]
  ------------------
   19|      1|		char *env;
   20|       |
   21|      1|		first = 0;
   22|      1|		env = getenv("WPADEBUG");
   23|      1|		if (env)
  ------------------
  |  Branch (23:7): [True: 0, False: 1]
  ------------------
   24|      0|			wpa_debug_level = atoi(env);
   25|      1|		else
   26|      1|			wpa_debug_level = MSG_ERROR + 1;
   27|       |
   28|      1|		wpa_debug_show_keys = 1;
   29|      1|	}
   30|  6.88k|}

LLVMFuzzerTestOneInput:
  153|  6.88k|{
  154|  6.88k|	struct p2p_data *p2p;
  155|  6.88k|	struct arg_ctx ctx;
  156|       |
  157|  6.88k|	wpa_fuzzer_set_debug_level();
  158|       |
  159|  6.88k|	if (os_program_init())
  ------------------
  |  Branch (159:6): [True: 0, False: 6.88k]
  ------------------
  160|      0|		return -1;
  161|       |
  162|  6.88k|	if (eloop_init()) {
  ------------------
  |  Branch (162:6): [True: 0, False: 6.88k]
  ------------------
  163|      0|		wpa_printf(MSG_ERROR, "Failed to initialize event loop");
  164|      0|		return 0;
  165|      0|	}
  166|       |
  167|  6.88k|	p2p = init_p2p();
  168|  6.88k|	if (!p2p) {
  ------------------
  |  Branch (168:6): [True: 0, False: 6.88k]
  ------------------
  169|      0|		wpa_printf(MSG_ERROR, "P2P init failed");
  170|      0|		return 0;
  171|      0|	}
  172|       |
  173|  6.88k|	os_memset(&ctx, 0, sizeof(ctx));
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  174|  6.88k|	ctx.p2p = p2p;
  175|  6.88k|	ctx.data = data;
  176|  6.88k|	ctx.data_len = size;
  177|       |
  178|  6.88k|	eloop_register_timeout(0, 0, test_send, &ctx, NULL);
  179|       |
  180|  6.88k|	wpa_printf(MSG_DEBUG, "Starting eloop");
  181|  6.88k|	eloop_run();
  182|  6.88k|	wpa_printf(MSG_DEBUG, "eloop done");
  183|       |
  184|  6.88k|	p2p_deinit(p2p);
  185|  6.88k|	eloop_destroy();
  186|  6.88k|	os_program_deinit();
  187|       |
  188|  6.88k|	return 0;
  189|  6.88k|}
p2p.c:init_p2p:
   86|  6.88k|{
   87|  6.88k|	struct p2p_config p2p;
   88|       |
   89|  6.88k|	os_memset(&p2p, 0, sizeof(p2p));
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   90|  6.88k|	p2p.max_peers = 100;
   91|  6.88k|	p2p.passphrase_len = 8;
   92|  6.88k|	p2p.channels.reg_classes = 1;
   93|  6.88k|	p2p.channels.reg_class[0].reg_class = 81;
   94|  6.88k|	p2p.channels.reg_class[0].channel[0] = 1;
   95|  6.88k|	p2p.channels.reg_class[0].channel[1] = 2;
   96|  6.88k|	p2p.channels.reg_class[0].channels = 2;
   97|  6.88k|	p2p.debug_print = debug_print;
   98|  6.88k|	p2p.find_stopped = find_stopped;
   99|  6.88k|	p2p.start_listen = start_listen;
  100|  6.88k|	p2p.stop_listen = stop_listen;
  101|  6.88k|	p2p.dev_found = dev_found;
  102|  6.88k|	p2p.dev_lost = dev_lost;
  103|  6.88k|	p2p.send_action = send_action;
  104|  6.88k|	p2p.send_action_done = send_action_done;
  105|  6.88k|	p2p.go_neg_req_rx = go_neg_req_rx;
  106|       |
  107|  6.88k|	return p2p_init(&p2p);
  108|  6.88k|}
p2p.c:debug_print:
   30|  98.1k|{
   31|  98.1k|	wpa_printf(level, "P2P: %s", msg);
   32|  98.1k|}
p2p.c:start_listen:
   43|      2|{
   44|      2|	return 0;
   45|      2|}
p2p.c:stop_listen:
   49|  6.88k|{
   50|  6.88k|}
p2p.c:dev_found:
   56|    775|{
   57|    775|}
p2p.c:dev_lost:
   61|    620|{
   62|    620|}
p2p.c:send_action:
   68|  1.70k|{
   69|  1.70k|	*scheduled = 0;
   70|  1.70k|	return 0;
   71|  1.70k|}
p2p.c:send_action_done:
   75|      5|{
   76|      5|}
p2p.c:go_neg_req_rx:
   81|     32|{
   82|     32|}
p2p.c:test_send:
  120|  6.88k|{
  121|  6.88k|	struct arg_ctx *ctx = eloop_data;
  122|  6.88k|	struct os_reltime rx_time;
  123|       |
  124|  6.88k|	wpa_hexdump(MSG_MSGDUMP, "fuzzer - IEs", ctx->data, ctx->data_len);
  125|       |
  126|  6.88k|	os_memset(&rx_time, 0, sizeof(rx_time));
  ------------------
  |  |  529|  6.88k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  127|  6.88k|	p2p_scan_res_handler(ctx->p2p, (u8 *) "\x02\x00\x00\x00\x01\x00", 2412,
  128|  6.88k|			     &rx_time, 0, ctx->data, ctx->data_len);
  129|  6.88k|	p2p_scan_res_handled(ctx->p2p, 0);
  130|       |
  131|  6.88k|	p2p_probe_req_rx(ctx->p2p, (u8 *) "\x02\x00\x00\x00\x01\x00",
  132|  6.88k|			 (u8 *) "\x02\x00\x00\x00\x00\x00",
  133|  6.88k|			 (u8 *) "\x02\x00\x00\x00\x00\x00",
  134|  6.88k|			 ctx->data, ctx->data_len, 2412, 0);
  135|       |
  136|  6.88k|	if (ctx->data_len >= IEEE80211_HDRLEN + 1) {
  ------------------
  |  | 1086|  6.88k|#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
  ------------------
  |  Branch (136:6): [True: 4.63k, False: 2.24k]
  ------------------
  137|  4.63k|		struct os_reltime rx_time;
  138|  4.63k|		const struct ieee80211_mgmt *mgmt;
  139|       |
  140|  4.63k|		mgmt = (const struct ieee80211_mgmt *) ctx->data;
  141|  4.63k|		os_memset(&rx_time, 0, sizeof(rx_time));
  ------------------
  |  |  529|  4.63k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  142|  4.63k|		p2p_rx_action(ctx->p2p, mgmt->da, mgmt->sa, mgmt->bssid,
  143|  4.63k|			      mgmt->u.action.category,
  144|  4.63k|			      (const u8 *) ctx->data + IEEE80211_HDRLEN + 1,
  ------------------
  |  | 1086|  4.63k|#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
  ------------------
  145|  4.63k|			      ctx->data_len - IEEE80211_HDRLEN - 1, 2412);
  ------------------
  |  | 1086|  4.63k|#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
  ------------------
  146|  4.63k|	}
  147|       |
  148|  6.88k|	eloop_terminate();
  149|  6.88k|}

