ieee802_11_parse_elems:
  768|  23.7k|{
  769|  23.7k|	os_memset(elems, 0, sizeof(*elems));
  ------------------
  |  |  529|  23.7k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  770|       |
  771|  23.7k|	return __ieee802_11_parse_elems(start, len, elems, show_errors);
  772|  23.7k|}
ieee802_11_vendor_ie_concat:
 1270|  40.9k|{
 1271|  40.9k|	struct wpabuf *buf;
 1272|  40.9k|	const struct element *elem, *found = NULL;
 1273|       |
 1274|  62.3M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  364|  40.9k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  356|  40.9k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  357|  62.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (357:7): [True: 62.3M, False: 27.8k]
  |  |  |  |  ------------------
  |  |  |  |  358|  62.4M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  359|  62.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (359:7): [True: 62.3M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  360|  62.3M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  |  |  361|  62.3M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  |  |  ------------------
  |  |  365|  62.3M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (365:7): [True: 960k, False: 61.4M]
  |  |  ------------------
  ------------------
 1275|   960k|		if (elem->datalen >= 4 &&
  ------------------
  |  Branch (1275:7): [True: 522k, False: 437k]
  ------------------
 1276|   522k|		    WPA_GET_BE32(elem->data) == oui_type) {
  ------------------
  |  Branch (1276:7): [True: 13.1k, False: 509k]
  ------------------
 1277|  13.1k|			found = elem;
 1278|  13.1k|			break;
 1279|  13.1k|		}
 1280|   960k|	}
 1281|       |
 1282|  40.9k|	if (!found)
  ------------------
  |  Branch (1282:6): [True: 27.8k, False: 13.1k]
  ------------------
 1283|  27.8k|		return NULL; /* No specified vendor IE found */
 1284|       |
 1285|  13.1k|	buf = wpabuf_alloc(ies_len);
 1286|  13.1k|	if (buf == NULL)
  ------------------
  |  Branch (1286:6): [True: 0, False: 13.1k]
  ------------------
 1287|      0|		return NULL;
 1288|       |
 1289|       |	/*
 1290|       |	 * There may be multiple vendor IEs in the message, so need to
 1291|       |	 * concatenate their data fields.
 1292|       |	 */
 1293|  68.4M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  364|  13.1k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  356|  13.1k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  357|  68.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (357:7): [True: 68.4M, False: 13.1k]
  |  |  |  |  ------------------
  |  |  |  |  358|  68.4M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  359|  68.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (359:7): [True: 68.4M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  360|  68.4M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  |  |  361|  68.4M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  |  |  ------------------
  |  |  365|  68.4M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (365:7): [True: 2.24M, False: 66.1M]
  |  |  ------------------
  ------------------
 1294|  2.24M|		if (elem->datalen >= 4 && WPA_GET_BE32(elem->data) == oui_type)
  ------------------
  |  Branch (1294:7): [True: 985k, False: 1.25M]
  |  Branch (1294:29): [True: 630k, False: 354k]
  ------------------
 1295|   630k|			wpabuf_put_data(buf, elem->data + 4, elem->datalen - 4);
 1296|  2.24M|	}
 1297|       |
 1298|  13.1k|	return buf;
 1299|  13.1k|}
ieee80211_chan_to_freq:
 2132|    645|{
 2133|    645|	int freq;
 2134|       |
 2135|    645|	if (country_match(us_op_class_cc, country)) {
  ------------------
  |  Branch (2135:6): [True: 0, False: 645]
  ------------------
 2136|      0|		freq = ieee80211_chan_to_freq_us(op_class, chan);
 2137|      0|		if (freq > 0)
  ------------------
  |  Branch (2137:7): [True: 0, False: 0]
  ------------------
 2138|      0|			return freq;
 2139|      0|	}
 2140|       |
 2141|    645|	if (country_match(eu_op_class_cc, country)) {
  ------------------
  |  Branch (2141:6): [True: 0, False: 645]
  ------------------
 2142|      0|		freq = ieee80211_chan_to_freq_eu(op_class, chan);
 2143|      0|		if (freq > 0)
  ------------------
  |  Branch (2143:7): [True: 0, False: 0]
  ------------------
 2144|      0|			return freq;
 2145|      0|	}
 2146|       |
 2147|    645|	if (country_match(jp_op_class_cc, country)) {
  ------------------
  |  Branch (2147:6): [True: 0, False: 645]
  ------------------
 2148|      0|		freq = ieee80211_chan_to_freq_jp(op_class, chan);
 2149|      0|		if (freq > 0)
  ------------------
  |  Branch (2149:7): [True: 0, False: 0]
  ------------------
 2150|      0|			return freq;
 2151|      0|	}
 2152|       |
 2153|    645|	if (country_match(cn_op_class_cc, country)) {
  ------------------
  |  Branch (2153:6): [True: 0, False: 645]
  ------------------
 2154|      0|		freq = ieee80211_chan_to_freq_cn(op_class, chan);
 2155|      0|		if (freq > 0)
  ------------------
  |  Branch (2155:7): [True: 0, False: 0]
  ------------------
 2156|      0|			return freq;
 2157|      0|	}
 2158|       |
 2159|    645|	return ieee80211_chan_to_freq_global(op_class, chan);
 2160|    645|}
ieee802_11_common.c:__ieee802_11_parse_elems:
  483|  23.7k|{
  484|  23.7k|	const struct element *elem;
  485|  23.7k|	int unknown = 0;
  486|       |
  487|  23.7k|	if (!start)
  ------------------
  |  Branch (487:6): [True: 0, False: 23.7k]
  ------------------
  488|      0|		return ParseOK;
  489|       |
  490|  47.8M|	for_each_element(elem, start, len) {
  ------------------
  |  |  356|  23.7k|	for (_elem = (const struct element *) (_data);			\
  |  |  357|  47.8M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (357:7): [True: 47.8M, False: 20.8k]
  |  |  ------------------
  |  |  358|  47.8M|		(int) sizeof(*_elem) &&					\
  |  |  359|  47.8M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (359:7): [True: 47.8M, False: 2.95k]
  |  |  ------------------
  |  |  360|  47.8M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  361|  47.8M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  ------------------
  491|  47.8M|		u8 id = elem->id, elen = elem->datalen;
  492|  47.8M|		const u8 *pos = elem->data;
  493|  47.8M|		size_t *total_len = NULL;
  494|       |
  495|  47.8M|		if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) {
  ------------------
  |  |  499|  95.7M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (495:7): [True: 2.31M, False: 45.5M]
  |  Branch (495:34): [True: 560k, False: 1.75M]
  ------------------
  496|   560k|			elems->num_frag_elems--;
  497|   560k|			continue;
  498|   560k|		}
  499|  47.3M|		elems->num_frag_elems = 0;
  500|       |
  501|  47.3M|		switch (id) {
  502|  40.8M|		case WLAN_EID_SSID:
  ------------------
  |  |  320|  40.8M|#define WLAN_EID_SSID 0
  ------------------
  |  Branch (502:3): [True: 40.8M, False: 6.50M]
  ------------------
  503|  40.8M|			if (elen > SSID_MAX_LEN) {
  ------------------
  |  |  511|  40.8M|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (503:8): [True: 183k, False: 40.6M]
  ------------------
  504|   183k|				wpa_printf(MSG_DEBUG,
  505|   183k|					   "Ignored too long SSID element (elen=%u)",
  506|   183k|					   elen);
  507|   183k|				break;
  508|   183k|			}
  509|  40.6M|			if (elems->ssid) {
  ------------------
  |  Branch (509:8): [True: 40.6M, False: 8.75k]
  ------------------
  510|  40.6M|				wpa_printf(MSG_MSGDUMP,
  511|  40.6M|					   "Ignored duplicated SSID element");
  512|  40.6M|				break;
  513|  40.6M|			}
  514|  8.75k|			elems->ssid = pos;
  515|  8.75k|			elems->ssid_len = elen;
  516|  8.75k|			break;
  517|   168k|		case WLAN_EID_SUPP_RATES:
  ------------------
  |  |  321|   168k|#define WLAN_EID_SUPP_RATES 1
  ------------------
  |  Branch (517:3): [True: 168k, False: 47.1M]
  ------------------
  518|   168k|			elems->supp_rates = pos;
  519|   168k|			elems->supp_rates_len = elen;
  520|   168k|			break;
  521|   197k|		case WLAN_EID_DS_PARAMS:
  ------------------
  |  |  322|   197k|#define WLAN_EID_DS_PARAMS 3
  ------------------
  |  Branch (521:3): [True: 197k, False: 47.1M]
  ------------------
  522|   197k|			if (elen < 1)
  ------------------
  |  Branch (522:8): [True: 6.45k, False: 190k]
  ------------------
  523|  6.45k|				break;
  524|   190k|			elems->ds_params = pos;
  525|   190k|			break;
  526|  50.1k|		case WLAN_EID_CF_PARAMS:
  ------------------
  |  |  323|  50.1k|#define WLAN_EID_CF_PARAMS 4
  ------------------
  |  Branch (526:3): [True: 50.1k, False: 47.2M]
  ------------------
  527|  62.0k|		case WLAN_EID_TIM:
  ------------------
  |  |  324|  62.0k|#define WLAN_EID_TIM 5
  ------------------
  |  Branch (527:3): [True: 11.9k, False: 47.3M]
  ------------------
  528|  62.0k|			break;
  529|  35.9k|		case WLAN_EID_CHALLENGE:
  ------------------
  |  |  333|  35.9k|#define WLAN_EID_CHALLENGE 16
  ------------------
  |  Branch (529:3): [True: 35.9k, False: 47.2M]
  ------------------
  530|  35.9k|			elems->challenge = pos;
  531|  35.9k|			elems->challenge_len = elen;
  532|  35.9k|			break;
  533|  12.7k|		case WLAN_EID_ERP_INFO:
  ------------------
  |  |  344|  12.7k|#define WLAN_EID_ERP_INFO 42
  ------------------
  |  Branch (533:3): [True: 12.7k, False: 47.2M]
  ------------------
  534|  12.7k|			if (elen < 1)
  ------------------
  |  Branch (534:8): [True: 8.39k, False: 4.40k]
  ------------------
  535|  8.39k|				break;
  536|  4.40k|			elems->erp_info = pos;
  537|  4.40k|			break;
  538|  27.1k|		case WLAN_EID_EXT_SUPP_RATES:
  ------------------
  |  |  350|  27.1k|#define WLAN_EID_EXT_SUPP_RATES 50
  ------------------
  |  Branch (538:3): [True: 27.1k, False: 47.2M]
  ------------------
  539|  27.1k|			elems->ext_supp_rates = pos;
  540|  27.1k|			elems->ext_supp_rates_len = elen;
  541|  27.1k|			break;
  542|  1.81M|		case WLAN_EID_VENDOR_SPECIFIC:
  ------------------
  |  |  493|  1.81M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (542:3): [True: 1.81M, False: 45.4M]
  ------------------
  543|  1.81M|			if (ieee802_11_parse_vendor_specific(pos, elen,
  ------------------
  |  Branch (543:8): [True: 682k, False: 1.13M]
  ------------------
  544|  1.81M|							     elems,
  545|  1.81M|							     show_errors))
  546|   682k|				unknown++;
  547|  1.81M|			break;
  548|  6.08k|		case WLAN_EID_RSN:
  ------------------
  |  |  349|  6.08k|#define WLAN_EID_RSN 48
  ------------------
  |  Branch (548:3): [True: 6.08k, False: 47.3M]
  ------------------
  549|  6.08k|			elems->rsn_ie = pos;
  550|  6.08k|			elems->rsn_ie_len = elen;
  551|  6.08k|			break;
  552|    923|		case WLAN_EID_RSNX:
  ------------------
  |  |  500|    923|#define WLAN_EID_RSNX 244
  ------------------
  |  Branch (552:3): [True: 923, False: 47.3M]
  ------------------
  553|    923|			elems->rsnxe = pos;
  554|    923|			elems->rsnxe_len = elen;
  555|    923|			break;
  556|  5.47k|		case WLAN_EID_PWR_CAPABILITY:
  ------------------
  |  |  335|  5.47k|#define WLAN_EID_PWR_CAPABILITY 33
  ------------------
  |  Branch (556:3): [True: 5.47k, False: 47.3M]
  ------------------
  557|  5.47k|			if (elen < 2)
  ------------------
  |  Branch (557:8): [True: 2.02k, False: 3.44k]
  ------------------
  558|  2.02k|				break;
  559|  3.44k|			elems->power_capab = pos;
  560|  3.44k|			elems->power_capab_len = elen;
  561|  3.44k|			break;
  562|  4.18k|		case WLAN_EID_SUPPORTED_CHANNELS:
  ------------------
  |  |  338|  4.18k|#define WLAN_EID_SUPPORTED_CHANNELS 36
  ------------------
  |  Branch (562:3): [True: 4.18k, False: 47.3M]
  ------------------
  563|  4.18k|			elems->supp_channels = pos;
  564|  4.18k|			elems->supp_channels_len = elen;
  565|  4.18k|			break;
  566|  2.56k|		case WLAN_EID_MOBILITY_DOMAIN:
  ------------------
  |  |  354|  2.56k|#define WLAN_EID_MOBILITY_DOMAIN 54
  ------------------
  |  Branch (566:3): [True: 2.56k, False: 47.3M]
  ------------------
  567|  2.56k|			if (elen < sizeof(struct rsn_mdie))
  ------------------
  |  Branch (567:8): [True: 839, False: 1.72k]
  ------------------
  568|    839|				break;
  569|  1.72k|			elems->mdie = pos;
  570|  1.72k|			elems->mdie_len = elen;
  571|  1.72k|			break;
  572|  5.17k|		case WLAN_EID_FAST_BSS_TRANSITION:
  ------------------
  |  |  355|  5.17k|#define WLAN_EID_FAST_BSS_TRANSITION 55
  ------------------
  |  Branch (572:3): [True: 5.17k, False: 47.3M]
  ------------------
  573|  5.17k|			if (elen < sizeof(struct rsn_ftie))
  ------------------
  |  Branch (573:8): [True: 3.69k, False: 1.47k]
  ------------------
  574|  3.69k|				break;
  575|  1.47k|			elems->ftie = pos;
  576|  1.47k|			elems->ftie_len = elen;
  577|  1.47k|			elems->fte_defrag_len = elen;
  578|  1.47k|			total_len = &elems->fte_defrag_len;
  579|  1.47k|			break;
  580|  5.66k|		case WLAN_EID_TIMEOUT_INTERVAL:
  ------------------
  |  |  356|  5.66k|#define WLAN_EID_TIMEOUT_INTERVAL 56
  ------------------
  |  Branch (580:3): [True: 5.66k, False: 47.3M]
  ------------------
  581|  5.66k|			if (elen != 5)
  ------------------
  |  Branch (581:8): [True: 5.45k, False: 214]
  ------------------
  582|  5.45k|				break;
  583|    214|			elems->timeout_int = pos;
  584|    214|			break;
  585|  10.9k|		case WLAN_EID_HT_CAP:
  ------------------
  |  |  347|  10.9k|#define WLAN_EID_HT_CAP 45
  ------------------
  |  Branch (585:3): [True: 10.9k, False: 47.3M]
  ------------------
  586|  10.9k|			if (elen < sizeof(struct ieee80211_ht_capabilities))
  ------------------
  |  Branch (586:8): [True: 1.94k, False: 8.96k]
  ------------------
  587|  1.94k|				break;
  588|  8.96k|			elems->ht_capabilities = pos;
  589|  8.96k|			break;
  590|  3.85k|		case WLAN_EID_HT_OPERATION:
  ------------------
  |  |  361|  3.85k|#define WLAN_EID_HT_OPERATION 61
  ------------------
  |  Branch (590:3): [True: 3.85k, False: 47.3M]
  ------------------
  591|  3.85k|			if (elen < sizeof(struct ieee80211_ht_operation))
  ------------------
  |  Branch (591:8): [True: 1.76k, False: 2.09k]
  ------------------
  592|  1.76k|				break;
  593|  2.09k|			elems->ht_operation = pos;
  594|  2.09k|			break;
  595|    841|		case WLAN_EID_MESH_CONFIG:
  ------------------
  |  |  411|    841|#define WLAN_EID_MESH_CONFIG 113
  ------------------
  |  Branch (595:3): [True: 841, False: 47.3M]
  ------------------
  596|    841|			elems->mesh_config = pos;
  597|    841|			elems->mesh_config_len = elen;
  598|    841|			break;
  599|  1.42k|		case WLAN_EID_MESH_ID:
  ------------------
  |  |  412|  1.42k|#define WLAN_EID_MESH_ID 114
  ------------------
  |  Branch (599:3): [True: 1.42k, False: 47.3M]
  ------------------
  600|  1.42k|			elems->mesh_id = pos;
  601|  1.42k|			elems->mesh_id_len = elen;
  602|  1.42k|			break;
  603|  7.91k|		case WLAN_EID_PEER_MGMT:
  ------------------
  |  |  415|  7.91k|#define WLAN_EID_PEER_MGMT 117
  ------------------
  |  Branch (603:3): [True: 7.91k, False: 47.3M]
  ------------------
  604|  7.91k|			elems->peer_mgmt = pos;
  605|  7.91k|			elems->peer_mgmt_len = elen;
  606|  7.91k|			break;
  607|  2.02k|		case WLAN_EID_VHT_CAP:
  ------------------
  |  |  475|  2.02k|#define WLAN_EID_VHT_CAP 191
  ------------------
  |  Branch (607:3): [True: 2.02k, False: 47.3M]
  ------------------
  608|  2.02k|			if (elen < sizeof(struct ieee80211_vht_capabilities))
  ------------------
  |  Branch (608:8): [True: 608, False: 1.41k]
  ------------------
  609|    608|				break;
  610|  1.41k|			elems->vht_capabilities = pos;
  611|  1.41k|			break;
  612|  1.41k|		case WLAN_EID_VHT_OPERATION:
  ------------------
  |  |  476|  1.41k|#define WLAN_EID_VHT_OPERATION 192
  ------------------
  |  Branch (612:3): [True: 1.41k, False: 47.3M]
  ------------------
  613|  1.41k|			if (elen < sizeof(struct ieee80211_vht_operation))
  ------------------
  |  Branch (613:8): [True: 416, False: 994]
  ------------------
  614|    416|				break;
  615|    994|			elems->vht_operation = pos;
  616|    994|			break;
  617|  2.32k|		case WLAN_EID_OPERATING_MODE_NOTIFICATION:
  ------------------
  |  |  483|  2.32k|#define WLAN_EID_OPERATING_MODE_NOTIFICATION 199
  ------------------
  |  Branch (617:3): [True: 2.32k, False: 47.3M]
  ------------------
  618|  2.32k|			if (elen != 1)
  ------------------
  |  Branch (618:8): [True: 2.10k, False: 224]
  ------------------
  619|  2.10k|				break;
  620|    224|			elems->opmode_notif = pos;
  621|    224|			break;
  622|  6.32k|		case WLAN_EID_LINK_ID:
  ------------------
  |  |  400|  6.32k|#define WLAN_EID_LINK_ID 101
  ------------------
  |  Branch (622:3): [True: 6.32k, False: 47.3M]
  ------------------
  623|  6.32k|			if (elen < 18)
  ------------------
  |  Branch (623:8): [True: 731, False: 5.59k]
  ------------------
  624|    731|				break;
  625|  5.59k|			elems->link_id = pos;
  626|  5.59k|			break;
  627|  2.14k|		case WLAN_EID_INTERWORKING:
  ------------------
  |  |  405|  2.14k|#define WLAN_EID_INTERWORKING 107
  ------------------
  |  Branch (627:3): [True: 2.14k, False: 47.3M]
  ------------------
  628|  2.14k|			elems->interworking = pos;
  629|  2.14k|			elems->interworking_len = elen;
  630|  2.14k|			break;
  631|  4.02k|		case WLAN_EID_QOS_MAP_SET:
  ------------------
  |  |  408|  4.02k|#define WLAN_EID_QOS_MAP_SET 110
  ------------------
  |  Branch (631:3): [True: 4.02k, False: 47.3M]
  ------------------
  632|  4.02k|			if (elen < 16)
  ------------------
  |  Branch (632:8): [True: 2.63k, False: 1.38k]
  ------------------
  633|  2.63k|				break;
  634|  1.38k|			elems->qos_map_set = pos;
  635|  1.38k|			elems->qos_map_set_len = elen;
  636|  1.38k|			break;
  637|  6.15k|		case WLAN_EID_EXT_CAPAB:
  ------------------
  |  |  425|  6.15k|#define WLAN_EID_EXT_CAPAB 127
  ------------------
  |  Branch (637:3): [True: 6.15k, False: 47.3M]
  ------------------
  638|  6.15k|			elems->ext_capab = pos;
  639|  6.15k|			elems->ext_capab_len = elen;
  640|  6.15k|			break;
  641|  3.13k|		case WLAN_EID_BSS_MAX_IDLE_PERIOD:
  ------------------
  |  |  389|  3.13k|#define WLAN_EID_BSS_MAX_IDLE_PERIOD 90
  ------------------
  |  Branch (641:3): [True: 3.13k, False: 47.3M]
  ------------------
  642|  3.13k|			if (elen < 3)
  ------------------
  |  Branch (642:8): [True: 727, False: 2.41k]
  ------------------
  643|    727|				break;
  644|  2.41k|			elems->bss_max_idle_period = pos;
  645|  2.41k|			break;
  646|  2.28k|		case WLAN_EID_SSID_LIST:
  ------------------
  |  |  383|  2.28k|#define WLAN_EID_SSID_LIST 84
  ------------------
  |  Branch (646:3): [True: 2.28k, False: 47.3M]
  ------------------
  647|  2.28k|			elems->ssid_list = pos;
  648|  2.28k|			elems->ssid_list_len = elen;
  649|  2.28k|			break;
  650|    681|		case WLAN_EID_AMPE:
  ------------------
  |  |  431|    681|#define WLAN_EID_AMPE 139
  ------------------
  |  Branch (650:3): [True: 681, False: 47.3M]
  ------------------
  651|    681|			elems->ampe = pos;
  652|    681|			elems->ampe_len = elen;
  653|    681|			break;
  654|  4.05k|		case WLAN_EID_MIC:
  ------------------
  |  |  432|  4.05k|#define WLAN_EID_MIC 140
  ------------------
  |  Branch (654:3): [True: 4.05k, False: 47.3M]
  ------------------
  655|  4.05k|			elems->mic = pos;
  656|  4.05k|			elems->mic_len = elen;
  657|  4.05k|			if (elems->stop_at_mic) {
  ------------------
  |  Branch (657:8): [True: 0, False: 4.05k]
  ------------------
  658|       |				/* After MIC everything is encrypted, so stop.
  659|       |				 */
  660|      0|				goto done;
  661|      0|			}
  662|  4.05k|			break;
  663|  4.05k|		case WLAN_EID_MULTI_BAND:
  ------------------
  |  |  447|  1.11k|#define WLAN_EID_MULTI_BAND 158
  ------------------
  |  Branch (663:3): [True: 1.11k, False: 47.3M]
  ------------------
  664|  1.11k|			if (elems->mb_ies.nof_ies >= MAX_NOF_MB_IES_SUPPORTED) {
  ------------------
  |  |   23|  1.11k|#define MAX_NOF_MB_IES_SUPPORTED 5
  ------------------
  |  Branch (664:8): [True: 577, False: 539]
  ------------------
  665|    577|				wpa_printf(MSG_MSGDUMP,
  666|    577|					   "IEEE 802.11 element parse ignored MB IE (id=%d elen=%d)",
  667|    577|					   id, elen);
  668|    577|				break;
  669|    577|			}
  670|       |
  671|    539|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie = pos;
  672|    539|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie_len = elen;
  673|    539|			elems->mb_ies.nof_ies++;
  674|    539|			break;
  675|  7.78k|		case WLAN_EID_SUPPORTED_OPERATING_CLASSES:
  ------------------
  |  |  359|  7.78k|#define WLAN_EID_SUPPORTED_OPERATING_CLASSES 59
  ------------------
  |  Branch (675:3): [True: 7.78k, False: 47.3M]
  ------------------
  676|  7.78k|			elems->supp_op_classes = pos;
  677|  7.78k|			elems->supp_op_classes_len = elen;
  678|  7.78k|			break;
  679|  1.53k|		case WLAN_EID_RRM_ENABLED_CAPABILITIES:
  ------------------
  |  |  370|  1.53k|#define WLAN_EID_RRM_ENABLED_CAPABILITIES 70
  ------------------
  |  Branch (679:3): [True: 1.53k, False: 47.3M]
  ------------------
  680|  1.53k|			elems->rrm_enabled = pos;
  681|  1.53k|			elems->rrm_enabled_len = elen;
  682|  1.53k|			break;
  683|  4.56k|		case WLAN_EID_MULTIPLE_BSSID:
  ------------------
  |  |  371|  4.56k|#define WLAN_EID_MULTIPLE_BSSID 71
  ------------------
  |  Branch (683:3): [True: 4.56k, False: 47.3M]
  ------------------
  684|  4.56k|			if (elen < 1)
  ------------------
  |  Branch (684:8): [True: 422, False: 4.14k]
  ------------------
  685|    422|				break;
  686|  4.14k|			elems->mbssid = pos;
  687|  4.14k|			elems->mbssid_len = elen;
  688|  4.14k|			break;
  689|  1.05k|		case WLAN_EID_CAG_NUMBER:
  ------------------
  |  |  495|  1.05k|#define WLAN_EID_CAG_NUMBER 237
  ------------------
  |  Branch (689:3): [True: 1.05k, False: 47.3M]
  ------------------
  690|  1.05k|			elems->cag_number = pos;
  691|  1.05k|			elems->cag_number_len = elen;
  692|  1.05k|			break;
  693|  5.09k|		case WLAN_EID_AP_CSN:
  ------------------
  |  |  496|  5.09k|#define WLAN_EID_AP_CSN 239
  ------------------
  |  Branch (693:3): [True: 5.09k, False: 47.3M]
  ------------------
  694|  5.09k|			if (elen < 1)
  ------------------
  |  Branch (694:8): [True: 516, False: 4.57k]
  ------------------
  695|    516|				break;
  696|  4.57k|			elems->ap_csn = pos;
  697|  4.57k|			break;
  698|  24.0k|		case WLAN_EID_FILS_INDICATION:
  ------------------
  |  |  497|  24.0k|#define WLAN_EID_FILS_INDICATION 240
  ------------------
  |  Branch (698:3): [True: 24.0k, False: 47.2M]
  ------------------
  699|  24.0k|			if (elen < 2)
  ------------------
  |  Branch (699:8): [True: 22.0k, False: 1.94k]
  ------------------
  700|  22.0k|				break;
  701|  1.94k|			elems->fils_indic = pos;
  702|  1.94k|			elems->fils_indic_len = elen;
  703|  1.94k|			break;
  704|  3.98k|		case WLAN_EID_DILS:
  ------------------
  |  |  498|  3.98k|#define WLAN_EID_DILS 241
  ------------------
  |  Branch (704:3): [True: 3.98k, False: 47.3M]
  ------------------
  705|  3.98k|			if (elen < 2)
  ------------------
  |  Branch (705:8): [True: 611, False: 3.37k]
  ------------------
  706|    611|				break;
  707|  3.37k|			elems->dils = pos;
  708|  3.37k|			elems->dils_len = elen;
  709|  3.37k|			break;
  710|  1.26k|		case WLAN_EID_S1G_CAPABILITIES:
  ------------------
  |  |  492|  1.26k|#define WLAN_EID_S1G_CAPABILITIES 217
  ------------------
  |  Branch (710:3): [True: 1.26k, False: 47.3M]
  ------------------
  711|  1.26k|			if (elen < 15)
  ------------------
  |  Branch (711:8): [True: 499, False: 767]
  ------------------
  712|    499|				break;
  713|    767|			elems->s1g_capab = pos;
  714|    767|			break;
  715|  1.75M|		case WLAN_EID_FRAGMENT:
  ------------------
  |  |  499|  1.75M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (715:3): [True: 1.75M, False: 45.5M]
  ------------------
  716|  1.75M|			wpa_printf(MSG_MSGDUMP,
  717|  1.75M|				   "Fragment without a valid last element - skip");
  718|       |
  719|  1.75M|			break;
  720|  71.2k|		case WLAN_EID_EXTENSION:
  ------------------
  |  |  501|  71.2k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (720:3): [True: 71.2k, False: 47.2M]
  ------------------
  721|  71.2k|			if (ieee802_11_parse_extension(pos, elen, elems, start,
  ------------------
  |  Branch (721:8): [True: 43.0k, False: 28.1k]
  ------------------
  722|  71.2k|						       len, show_errors))
  723|  43.0k|				unknown++;
  724|  71.2k|			break;
  725|  2.21M|		default:
  ------------------
  |  Branch (725:3): [True: 2.21M, False: 45.0M]
  ------------------
  726|  2.21M|			unknown++;
  727|  2.21M|			if (!show_errors)
  ------------------
  |  Branch (727:8): [True: 2.21M, False: 0]
  ------------------
  728|  2.21M|				break;
  729|      0|			wpa_printf(MSG_MSGDUMP, "IEEE 802.11 element parse "
  730|      0|				   "ignored unknown element (id=%d elen=%d)",
  731|      0|				   id, elen);
  732|      0|			break;
  733|  47.3M|		}
  734|       |
  735|  47.3M|		if (elen == 255 && total_len)
  ------------------
  |  Branch (735:7): [True: 56.2k, False: 47.2M]
  |  Branch (735:22): [True: 990, False: 55.2k]
  ------------------
  736|    990|			*total_len += ieee802_11_fragments_length(
  737|    990|				elems, pos + elen,
  738|    990|				(start + len) - (pos + elen));
  739|       |
  740|  47.3M|	}
  741|       |
  742|  23.7k|	if (!for_each_element_completed(elem, start, len)) {
  ------------------
  |  Branch (742:6): [True: 3.07k, False: 20.7k]
  ------------------
  743|  3.07k|		if (show_errors) {
  ------------------
  |  Branch (743:7): [True: 0, False: 3.07k]
  ------------------
  744|      0|			wpa_printf(MSG_DEBUG,
  745|      0|				   "IEEE 802.11 element parse failed @%d",
  746|      0|				   (int) (start + len - (const u8 *) elem));
  747|      0|			wpa_hexdump(MSG_MSGDUMP, "IEs", start, len);
  748|      0|		}
  749|  3.07k|		return ParseFailed;
  750|  3.07k|	}
  751|       |
  752|  20.7k|done:
  753|  20.7k|	return unknown ? ParseUnknown : ParseOK;
  ------------------
  |  Branch (753:9): [True: 8.34k, False: 12.3k]
  ------------------
  754|  23.7k|}
ieee802_11_common.c:ieee802_11_parse_vendor_specific:
   23|  1.81M|{
   24|  1.81M|	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.81M|	if (elen < 4) {
  ------------------
  |  Branch (29:6): [True: 576k, False: 1.24M]
  ------------------
   30|   576k|		if (show_errors) {
  ------------------
  |  Branch (30:7): [True: 0, False: 576k]
  ------------------
   31|      0|			wpa_printf(MSG_MSGDUMP, "short vendor specific "
   32|      0|				   "information element ignored (len=%lu)",
   33|      0|				   (unsigned long) elen);
   34|      0|		}
   35|   576k|		return -1;
   36|   576k|	}
   37|       |
   38|  1.24M|	oui = WPA_GET_BE24(pos);
   39|  1.24M|	switch (oui) {
   40|   531k|	case OUI_MICROSOFT:
  ------------------
  |  | 1509|   531k|#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
  ------------------
  |  Branch (40:2): [True: 531k, False: 711k]
  ------------------
   41|       |		/* Microsoft/Wi-Fi information elements are further typed and
   42|       |		 * subtyped */
   43|   531k|		switch (pos[3]) {
   44|  4.05k|		case 1:
  ------------------
  |  Branch (44:3): [True: 4.05k, False: 527k]
  ------------------
   45|       |			/* Microsoft OUI (00:50:F2) with OUI Type 1:
   46|       |			 * real WPA information element */
   47|  4.05k|			elems->wpa_ie = pos;
   48|  4.05k|			elems->wpa_ie_len = elen;
   49|  4.05k|			break;
   50|  2.24k|		case WMM_OUI_TYPE:
  ------------------
  |  | 1565|  2.24k|#define WMM_OUI_TYPE 2
  ------------------
  |  Branch (50:3): [True: 2.24k, False: 529k]
  ------------------
   51|       |			/* WMM information element */
   52|  2.24k|			if (elen < 5) {
  ------------------
  |  Branch (52:8): [True: 1.23k, False: 1.01k]
  ------------------
   53|  1.23k|				wpa_printf(MSG_MSGDUMP, "short WMM "
   54|  1.23k|					   "information element ignored "
   55|  1.23k|					   "(len=%lu)",
   56|  1.23k|					   (unsigned long) elen);
   57|  1.23k|				return -1;
   58|  1.23k|			}
   59|  1.01k|			switch (pos[4]) {
   60|    226|			case WMM_OUI_SUBTYPE_INFORMATION_ELEMENT:
  ------------------
  |  | 1566|    226|#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  ------------------
  |  Branch (60:4): [True: 226, False: 790]
  ------------------
   61|    428|			case WMM_OUI_SUBTYPE_PARAMETER_ELEMENT:
  ------------------
  |  | 1567|    428|#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  ------------------
  |  Branch (61:4): [True: 202, False: 814]
  ------------------
   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|    428|				elems->wmm = pos;
   69|    428|				elems->wmm_len = elen;
   70|    428|				break;
   71|    213|			case WMM_OUI_SUBTYPE_TSPEC_ELEMENT:
  ------------------
  |  | 1568|    213|#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
  ------------------
  |  Branch (71:4): [True: 213, False: 803]
  ------------------
   72|    213|				elems->wmm_tspec = pos;
   73|    213|				elems->wmm_tspec_len = elen;
   74|    213|				break;
   75|    375|			default:
  ------------------
  |  Branch (75:4): [True: 375, False: 641]
  ------------------
   76|    375|				wpa_printf(MSG_EXCESSIVE, "unknown WMM "
   77|    375|					   "information element ignored "
   78|    375|					   "(subtype=%d len=%lu)",
   79|    375|					   pos[4], (unsigned long) elen);
   80|    375|				return -1;
   81|  1.01k|			}
   82|    641|			break;
   83|   523k|		case 4:
  ------------------
  |  Branch (83:3): [True: 523k, False: 8.04k]
  ------------------
   84|       |			/* Wi-Fi Protected Setup (WPS) IE */
   85|   523k|			elems->wps_ie = pos;
   86|   523k|			elems->wps_ie_len = elen;
   87|   523k|			break;
   88|  1.74k|		default:
  ------------------
  |  Branch (88:3): [True: 1.74k, False: 529k]
  ------------------
   89|  1.74k|			wpa_printf(MSG_EXCESSIVE, "Unknown Microsoft "
   90|  1.74k|				   "information element ignored "
   91|  1.74k|				   "(type=%d len=%lu)",
   92|  1.74k|				   pos[3], (unsigned long) elen);
   93|  1.74k|			return -1;
   94|   531k|		}
   95|   527k|		break;
   96|       |
   97|   609k|	case OUI_WFA:
  ------------------
  |  | 1514|   609k|#define OUI_WFA 0x506f9a
  ------------------
  |  Branch (97:2): [True: 609k, False: 632k]
  ------------------
   98|   609k|		switch (pos[3]) {
   99|   469k|		case P2P_OUI_TYPE:
  ------------------
  |  | 1805|   469k|#define P2P_OUI_TYPE 9
  ------------------
  |  Branch (99:3): [True: 469k, False: 140k]
  ------------------
  100|       |			/* Wi-Fi Alliance - P2P IE */
  101|   469k|			elems->p2p = pos;
  102|   469k|			elems->p2p_len = elen;
  103|   469k|			break;
  104|   133k|		case WFD_OUI_TYPE:
  ------------------
  |  | 1518|   133k|#define WFD_OUI_TYPE 10
  ------------------
  |  Branch (104:3): [True: 133k, False: 476k]
  ------------------
  105|       |			/* Wi-Fi Alliance - WFD IE */
  106|   133k|			elems->wfd = pos;
  107|   133k|			elems->wfd_len = elen;
  108|   133k|			break;
  109|    224|		case HS20_INDICATION_OUI_TYPE:
  ------------------
  |  | 1680|    224|#define HS20_INDICATION_OUI_TYPE 16
  ------------------
  |  Branch (109:3): [True: 224, False: 609k]
  ------------------
  110|       |			/* Hotspot 2.0 */
  111|    224|			elems->hs20 = pos;
  112|    224|			elems->hs20_len = elen;
  113|    224|			break;
  114|    273|		case MBO_OUI_TYPE:
  ------------------
  |  | 1526|    273|#define MBO_OUI_TYPE 22
  ------------------
  |  Branch (114:3): [True: 273, False: 609k]
  ------------------
  115|       |			/* MBO-OCE */
  116|    273|			elems->mbo = pos;
  117|    273|			elems->mbo_len = elen;
  118|    273|			break;
  119|    202|		case HS20_ROAMING_CONS_SEL_OUI_TYPE:
  ------------------
  |  | 1682|    202|#define HS20_ROAMING_CONS_SEL_OUI_TYPE 29
  ------------------
  |  Branch (119:3): [True: 202, False: 609k]
  ------------------
  120|       |			/* Hotspot 2.0 Roaming Consortium Selection */
  121|    202|			elems->roaming_cons_sel = pos;
  122|    202|			elems->roaming_cons_sel_len = elen;
  123|    202|			break;
  124|    202|		case MULTI_AP_OUI_TYPE:
  ------------------
  |  | 1529|    202|#define MULTI_AP_OUI_TYPE 0x1B
  ------------------
  |  Branch (124:3): [True: 202, False: 609k]
  ------------------
  125|    202|			elems->multi_ap = pos;
  126|    202|			elems->multi_ap_len = elen;
  127|    202|			break;
  128|    256|		case OWE_OUI_TYPE:
  ------------------
  |  | 1528|    256|#define OWE_OUI_TYPE 28
  ------------------
  |  Branch (128:3): [True: 256, False: 609k]
  ------------------
  129|       |			/* OWE Transition Mode element */
  130|    256|			break;
  131|    206|		case DPP_CC_OUI_TYPE:
  ------------------
  |  | 1531|    206|#define DPP_CC_OUI_TYPE 0x1e
  ------------------
  |  Branch (131:3): [True: 206, False: 609k]
  ------------------
  132|       |			/* DPP Configurator Connectivity element */
  133|    206|			break;
  134|    209|		case SAE_PK_OUI_TYPE:
  ------------------
  |  | 1533|    209|#define SAE_PK_OUI_TYPE 0x1f
  ------------------
  |  Branch (134:3): [True: 209, False: 609k]
  ------------------
  135|    209|			elems->sae_pk = pos + 4;
  136|    209|			elems->sae_pk_len = elen - 4;
  137|    209|			break;
  138|    380|		case WFA_CAPA_OUI_TYPE:
  ------------------
  |  | 1537|    380|#define WFA_CAPA_OUI_TYPE 0x23
  ------------------
  |  Branch (138:3): [True: 380, False: 609k]
  ------------------
  139|    380|			elems->wfa_capab = pos + 4;
  140|    380|			elems->wfa_capab_len = elen - 4;
  141|    380|			break;
  142|    350|		case WFA_RSNE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1538|    350|#define WFA_RSNE_OVERRIDE_OUI_TYPE 0x29
  ------------------
  |  Branch (142:3): [True: 350, False: 609k]
  ------------------
  143|    350|			elems->rsne_override = pos;
  144|    350|			elems->rsne_override_len = elen;
  145|    350|			break;
  146|    386|		case WFA_RSNE_OVERRIDE_2_OUI_TYPE:
  ------------------
  |  | 1539|    386|#define WFA_RSNE_OVERRIDE_2_OUI_TYPE 0x2a
  ------------------
  |  Branch (146:3): [True: 386, False: 609k]
  ------------------
  147|    386|			elems->rsne_override_2 = pos;
  148|    386|			elems->rsne_override_2_len = elen;
  149|    386|			break;
  150|    266|		case WFA_RSNXE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1540|    266|#define WFA_RSNXE_OVERRIDE_OUI_TYPE 0x2b
  ------------------
  |  Branch (150:3): [True: 266, False: 609k]
  ------------------
  151|    266|			elems->rsnxe_override = pos;
  152|    266|			elems->rsnxe_override_len = elen;
  153|    266|			break;
  154|    604|		case WFA_RSN_SELECTION_OUI_TYPE:
  ------------------
  |  | 1541|    604|#define WFA_RSN_SELECTION_OUI_TYPE 0x2c
  ------------------
  |  Branch (154:3): [True: 604, False: 609k]
  ------------------
  155|    604|			if (elen < 4 + 1) {
  ------------------
  |  Branch (155:8): [True: 351, False: 253]
  ------------------
  156|    351|				wpa_printf(MSG_DEBUG,
  157|    351|					   "Too short RSN Selection element ignored");
  158|    351|				return -1;
  159|    351|			}
  160|    253|			elems->rsn_selection = pos + 4;
  161|    253|			elems->rsn_selection_len = elen - 4;
  162|    253|			break;
  163|  1.65k|		case P2P2_OUI_TYPE:
  ------------------
  |  | 1806|  1.65k|#define P2P2_OUI_TYPE 0x28
  ------------------
  |  Branch (163:3): [True: 1.65k, False: 608k]
  ------------------
  164|       |			/* Wi-Fi Alliance - P2P2 IE */
  165|  1.65k|			elems->p2p2_ie = pos;
  166|  1.65k|			elems->p2p2_ie_len = elen;
  167|  1.65k|			break;
  168|    281|		case PR_OUI_TYPE:
  ------------------
  |  | 1548|    281|#define PR_OUI_TYPE 0x2e
  ------------------
  |  Branch (168:3): [True: 281, False: 609k]
  ------------------
  169|       |			/* Wi-Fi Alliance - Proximity Ranging element */
  170|    281|			elems->proximity_ranging = pos;
  171|    281|			elems->proximity_ranging_len = elen;
  172|    281|			break;
  173|    228|		case NAN_SDF_OUI_TYPE:
  ------------------
  |  | 1522|    228|#define NAN_SDF_OUI_TYPE 0x13
  ------------------
  |  Branch (173:3): [True: 228, False: 609k]
  ------------------
  174|       |			/* Wi-Fi Alliance - NAN IE */
  175|    228|			elems->nan_ie = pos;
  176|    228|			elems->nan_len = elen;
  177|    228|			break;
  178|  1.27k|		default:
  ------------------
  |  Branch (178:3): [True: 1.27k, False: 608k]
  ------------------
  179|  1.27k|			wpa_printf(MSG_MSGDUMP, "Unknown WFA "
  180|  1.27k|				   "information element ignored "
  181|  1.27k|				   "(type=%d len=%lu)",
  182|  1.27k|				   pos[3], (unsigned long) elen);
  183|  1.27k|			return -1;
  184|   609k|		}
  185|   608k|		break;
  186|       |
  187|   608k|	case OUI_BROADCOM:
  ------------------
  |  | 2012|  1.40k|#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
  ------------------
  |  Branch (187:2): [True: 1.40k, False: 1.24M]
  ------------------
  188|  1.40k|		switch (pos[3]) {
  189|    203|		case VENDOR_HT_CAPAB_OUI_TYPE:
  ------------------
  |  | 2017|    203|#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
  ------------------
  |  Branch (189:3): [True: 203, False: 1.20k]
  ------------------
  190|    203|			elems->vendor_ht_cap = pos;
  191|    203|			elems->vendor_ht_cap_len = elen;
  192|    203|			break;
  193|    986|		case VENDOR_VHT_TYPE:
  ------------------
  |  | 2013|    986|#define VENDOR_VHT_TYPE		0x04
  ------------------
  |  Branch (193:3): [True: 986, False: 420]
  ------------------
  194|    986|			if (elen > 4 &&
  ------------------
  |  Branch (194:8): [True: 776, False: 210]
  ------------------
  195|    776|			    (pos[4] == VENDOR_VHT_SUBTYPE ||
  ------------------
  |  | 2014|  1.55k|#define VENDOR_VHT_SUBTYPE	0x08
  ------------------
  |  Branch (195:9): [True: 205, False: 571]
  ------------------
  196|    571|			     pos[4] == VENDOR_VHT_SUBTYPE2)) {
  ------------------
  |  | 2015|    571|#define VENDOR_VHT_SUBTYPE2	0x00
  ------------------
  |  Branch (196:9): [True: 260, False: 311]
  ------------------
  197|    465|				elems->vendor_vht = pos;
  198|    465|				elems->vendor_vht_len = elen;
  199|    465|			} else
  200|    521|				return -1;
  201|    465|			break;
  202|    465|		default:
  ------------------
  |  Branch (202:3): [True: 217, False: 1.18k]
  ------------------
  203|    217|			wpa_printf(MSG_EXCESSIVE, "Unknown Broadcom "
  204|    217|				   "information element ignored "
  205|    217|				   "(type=%d len=%lu)",
  206|    217|				   pos[3], (unsigned long) elen);
  207|    217|			return -1;
  208|  1.40k|		}
  209|    668|		break;
  210|       |
  211|  1.09k|	case OUI_QCA:
  ------------------
  |  |   21|  1.09k|#define OUI_QCA 0x001374
  ------------------
  |  Branch (211:2): [True: 1.09k, False: 1.24M]
  ------------------
  212|  1.09k|		switch (pos[3]) {
  213|    384|		case QCA_VENDOR_ELEM_P2P_PREF_CHAN_LIST:
  ------------------
  |  Branch (213:3): [True: 384, False: 709]
  ------------------
  214|    384|			elems->pref_freq_list = pos;
  215|    384|			elems->pref_freq_list_len = elen;
  216|    384|			break;
  217|    709|		default:
  ------------------
  |  Branch (217:3): [True: 709, False: 384]
  ------------------
  218|    709|			wpa_printf(MSG_EXCESSIVE,
  219|    709|				   "Unknown QCA information element ignored (type=%d len=%lu)",
  220|    709|				   pos[3], (unsigned long) elen);
  221|    709|			return -1;
  222|  1.09k|		}
  223|    384|		break;
  224|       |
  225|  99.0k|	default:
  ------------------
  |  Branch (225:2): [True: 99.0k, False: 1.14M]
  ------------------
  226|  99.0k|		wpa_printf(MSG_EXCESSIVE, "unknown vendor specific "
  227|  99.0k|			   "information element ignored (vendor OUI "
  228|  99.0k|			   "%02x:%02x:%02x len=%lu)",
  229|  99.0k|			   pos[0], pos[1], pos[2], (unsigned long) elen);
  230|  99.0k|		return -1;
  231|  1.24M|	}
  232|       |
  233|  1.13M|	return 0;
  234|  1.24M|}
ieee802_11_common.c:ieee802_11_parse_extension:
  304|  71.2k|{
  305|  71.2k|	u8 ext_id;
  306|  71.2k|	size_t *total_len = NULL;
  307|       |
  308|  71.2k|	if (elen < 1) {
  ------------------
  |  Branch (308:6): [True: 6.41k, False: 64.8k]
  ------------------
  309|  6.41k|		if (show_errors) {
  ------------------
  |  Branch (309:7): [True: 0, False: 6.41k]
  ------------------
  310|      0|			wpa_printf(MSG_MSGDUMP,
  311|      0|				   "short information element (Ext)");
  312|      0|		}
  313|  6.41k|		return -1;
  314|  6.41k|	}
  315|       |
  316|  64.8k|	ext_id = *pos++;
  317|  64.8k|	elen--;
  318|       |
  319|  64.8k|	switch (ext_id) {
  320|  1.22k|	case WLAN_EID_EXT_ASSOC_DELAY_INFO:
  ------------------
  |  |  504|  1.22k|#define WLAN_EID_EXT_ASSOC_DELAY_INFO 1
  ------------------
  |  Branch (320:2): [True: 1.22k, False: 63.6k]
  ------------------
  321|  1.22k|		if (elen != 1)
  ------------------
  |  Branch (321:7): [True: 962, False: 264]
  ------------------
  322|    962|			break;
  323|    264|		elems->assoc_delay_info = pos;
  324|    264|		break;
  325|  1.71k|	case WLAN_EID_EXT_FILS_REQ_PARAMS:
  ------------------
  |  |  505|  1.71k|#define WLAN_EID_EXT_FILS_REQ_PARAMS 2
  ------------------
  |  Branch (325:2): [True: 1.71k, False: 63.1k]
  ------------------
  326|  1.71k|		if (elen < 3)
  ------------------
  |  Branch (326:7): [True: 936, False: 782]
  ------------------
  327|    936|			break;
  328|    782|		elems->fils_req_params = pos;
  329|    782|		elems->fils_req_params_len = elen;
  330|    782|		break;
  331|  1.62k|	case WLAN_EID_EXT_FILS_KEY_CONFIRM:
  ------------------
  |  |  506|  1.62k|#define WLAN_EID_EXT_FILS_KEY_CONFIRM 3
  ------------------
  |  Branch (331:2): [True: 1.62k, False: 63.2k]
  ------------------
  332|  1.62k|		elems->fils_key_confirm = pos;
  333|  1.62k|		elems->fils_key_confirm_len = elen;
  334|  1.62k|		break;
  335|  1.06k|	case WLAN_EID_EXT_FILS_SESSION:
  ------------------
  |  |  507|  1.06k|#define WLAN_EID_EXT_FILS_SESSION 4
  ------------------
  |  Branch (335:2): [True: 1.06k, False: 63.7k]
  ------------------
  336|  1.06k|		if (elen != FILS_SESSION_LEN)
  ------------------
  |  | 1003|  1.06k|#define FILS_SESSION_LEN 8
  ------------------
  |  Branch (336:7): [True: 810, False: 258]
  ------------------
  337|    810|			break;
  338|    258|		elems->fils_session = pos;
  339|    258|		break;
  340|  1.45k|	case WLAN_EID_EXT_FILS_HLP_CONTAINER:
  ------------------
  |  |  508|  1.45k|#define WLAN_EID_EXT_FILS_HLP_CONTAINER 5
  ------------------
  |  Branch (340:2): [True: 1.45k, False: 63.4k]
  ------------------
  341|  1.45k|		if (elen < 2 * ETH_ALEN)
  ------------------
  |  |  344|  1.45k|#define ETH_ALEN 6
  ------------------
  |  Branch (341:7): [True: 479, False: 975]
  ------------------
  342|    479|			break;
  343|    975|		elems->fils_hlp = pos;
  344|    975|		elems->fils_hlp_len = elen;
  345|    975|		total_len = &elems->fils_hlp_len;
  346|    975|		break;
  347|  1.81k|	case WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN:
  ------------------
  |  |  509|  1.81k|#define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6
  ------------------
  |  Branch (347:2): [True: 1.81k, False: 63.0k]
  ------------------
  348|  1.81k|		if (elen < 1)
  ------------------
  |  Branch (348:7): [True: 201, False: 1.61k]
  ------------------
  349|    201|			break;
  350|  1.61k|		elems->fils_ip_addr_assign = pos;
  351|  1.61k|		elems->fils_ip_addr_assign_len = elen;
  352|  1.61k|		break;
  353|  4.33k|	case WLAN_EID_EXT_KEY_DELIVERY:
  ------------------
  |  |  510|  4.33k|#define WLAN_EID_EXT_KEY_DELIVERY 7
  ------------------
  |  Branch (353:2): [True: 4.33k, False: 60.5k]
  ------------------
  354|  4.33k|		if (elen < WPA_KEY_RSC_LEN)
  ------------------
  |  |   22|  4.33k|#define WPA_KEY_RSC_LEN 8
  ------------------
  |  Branch (354:7): [True: 329, False: 4.00k]
  ------------------
  355|    329|			break;
  356|  4.00k|		elems->key_delivery = pos;
  357|  4.00k|		elems->key_delivery_len = elen;
  358|  4.00k|		total_len = &elems->key_delivery_len;
  359|  4.00k|		break;
  360|    595|	case WLAN_EID_EXT_WRAPPED_DATA:
  ------------------
  |  |  511|    595|#define WLAN_EID_EXT_WRAPPED_DATA 8
  ------------------
  |  Branch (360:2): [True: 595, False: 64.2k]
  ------------------
  361|    595|		elems->wrapped_data = pos;
  362|    595|		elems->wrapped_data_len = elen;
  363|    595|		total_len = &elems->wrapped_data_len;
  364|    595|		break;
  365|    747|	case WLAN_EID_EXT_FILS_PUBLIC_KEY:
  ------------------
  |  |  515|    747|#define WLAN_EID_EXT_FILS_PUBLIC_KEY 12
  ------------------
  |  Branch (365:2): [True: 747, False: 64.1k]
  ------------------
  366|    747|		if (elen < 1)
  ------------------
  |  Branch (366:7): [True: 242, False: 505]
  ------------------
  367|    242|			break;
  368|    505|		elems->fils_pk = pos;
  369|    505|		elems->fils_pk_len = elen;
  370|    505|		break;
  371|    688|	case WLAN_EID_EXT_NONCE:
  ------------------
  |  |  516|    688|#define WLAN_EID_EXT_NONCE 13
  ------------------
  |  Branch (371:2): [True: 688, False: 64.1k]
  ------------------
  372|    688|		if (elen < NONCE_LEN)
  ------------------
  |  | 1002|    688|#define NONCE_LEN 16
  ------------------
  |  Branch (372:7): [True: 239, False: 449]
  ------------------
  373|    239|			break;
  374|    449|		elems->nonce = pos;
  375|    449|		elems->nonce_len = elen;
  376|    449|		break;
  377|    494|	case WLAN_EID_EXT_OWE_DH_PARAM:
  ------------------
  |  |  518|    494|#define WLAN_EID_EXT_OWE_DH_PARAM 32
  ------------------
  |  Branch (377:2): [True: 494, False: 64.3k]
  ------------------
  378|    494|		if (elen < 2)
  ------------------
  |  Branch (378:7): [True: 229, False: 265]
  ------------------
  379|    229|			break;
  380|    265|		elems->owe_dh = pos;
  381|    265|		elems->owe_dh_len = elen;
  382|    265|		break;
  383|    217|	case WLAN_EID_EXT_PASSWORD_IDENTIFIER:
  ------------------
  |  |  519|    217|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (383:2): [True: 217, False: 64.6k]
  ------------------
  384|    217|		elems->password_id = pos;
  385|    217|		elems->password_id_len = elen;
  386|    217|		break;
  387|    804|	case WLAN_EID_EXT_HE_CAPABILITIES:
  ------------------
  |  |  520|    804|#define WLAN_EID_EXT_HE_CAPABILITIES 35
  ------------------
  |  Branch (387:2): [True: 804, False: 64.0k]
  ------------------
  388|    804|		if (elen < HE_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2585|    804|#define HE_CAPABILITIES_ELEM_MIN_LEN		21
  ------------------
  |  Branch (388:7): [True: 360, False: 444]
  ------------------
  389|    360|			break;
  390|    444|		elems->he_capabilities = pos;
  391|    444|		elems->he_capabilities_len = elen;
  392|    444|		break;
  393|    459|	case WLAN_EID_EXT_HE_OPERATION:
  ------------------
  |  |  521|    459|#define WLAN_EID_EXT_HE_OPERATION 36
  ------------------
  |  Branch (393:2): [True: 459, False: 64.4k]
  ------------------
  394|    459|		if (elen < HE_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2639|    459|#define HE_OPERATION_ELEM_MIN_LEN				6
  ------------------
  |  Branch (394:7): [True: 228, False: 231]
  ------------------
  395|    228|			break;
  396|    231|		elems->he_operation = pos;
  397|    231|		elems->he_operation_len = elen;
  398|    231|		break;
  399|    314|	case WLAN_EID_EXT_OCV_OCI:
  ------------------
  |  |  526|    314|#define WLAN_EID_EXT_OCV_OCI 54
  ------------------
  |  Branch (399:2): [True: 314, False: 64.5k]
  ------------------
  400|    314|		elems->oci = pos;
  401|    314|		elems->oci_len = elen;
  402|    314|		break;
  403|    448|	case WLAN_EID_EXT_SHORT_SSID_LIST:
  ------------------
  |  |  530|    448|#define WLAN_EID_EXT_SHORT_SSID_LIST 58
  ------------------
  |  Branch (403:2): [True: 448, False: 64.4k]
  ------------------
  404|    448|		elems->short_ssid_list = pos;
  405|    448|		elems->short_ssid_list_len = elen;
  406|    448|		break;
  407|    887|	case WLAN_EID_EXT_HE_6GHZ_BAND_CAP:
  ------------------
  |  |  531|    887|#define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59
  ------------------
  |  Branch (407:2): [True: 887, False: 63.9k]
  ------------------
  408|    887|		if (elen < sizeof(struct ieee80211_he_6ghz_band_cap))
  ------------------
  |  Branch (408:7): [True: 231, False: 656]
  ------------------
  409|    231|			break;
  410|    656|		elems->he_6ghz_band_cap = pos;
  411|    656|		break;
  412|    243|	case WLAN_EID_EXT_PASN_PARAMS:
  ------------------
  |  |  538|    243|#define WLAN_EID_EXT_PASN_PARAMS 100
  ------------------
  |  Branch (412:2): [True: 243, False: 64.6k]
  ------------------
  413|    243|		elems->pasn_params = pos;
  414|    243|		elems->pasn_params_len = elen;
  415|    243|		break;
  416|  4.29k|	case WLAN_EID_EXT_EHT_CAPABILITIES:
  ------------------
  |  |  541|  4.29k|#define WLAN_EID_EXT_EHT_CAPABILITIES 108
  ------------------
  |  Branch (416:2): [True: 4.29k, False: 60.5k]
  ------------------
  417|  4.29k|		if (elen < EHT_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2788|  4.29k|#define EHT_CAPABILITIES_ELEM_MIN_LEN             11
  ------------------
  |  Branch (417:7): [True: 4.06k, False: 230]
  ------------------
  418|  4.06k|			break;
  419|    230|		elems->eht_capabilities = pos;
  420|    230|		elems->eht_capabilities_len = elen;
  421|    230|		break;
  422|    852|	case WLAN_EID_EXT_EHT_OPERATION:
  ------------------
  |  |  539|    852|#define WLAN_EID_EXT_EHT_OPERATION 106
  ------------------
  |  Branch (422:2): [True: 852, False: 64.0k]
  ------------------
  423|    852|		if (elen < EHT_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2748|    852|#define EHT_OPERATION_ELEM_MIN_LEN                       1
  ------------------
  |  Branch (423:7): [True: 401, False: 451]
  ------------------
  424|    401|			break;
  425|    451|		elems->eht_operation = pos;
  426|    451|		elems->eht_operation_len = elen;
  427|    451|		break;
  428|  2.63k|	case WLAN_EID_EXT_MULTI_LINK:
  ------------------
  |  |  540|  2.63k|#define WLAN_EID_EXT_MULTI_LINK 107
  ------------------
  |  Branch (428:2): [True: 2.63k, False: 62.2k]
  ------------------
  429|  2.63k|		if (elen < 2)
  ------------------
  |  Branch (429:7): [True: 432, False: 2.20k]
  ------------------
  430|    432|			break;
  431|  2.20k|		if (ieee802_11_parse_mle(pos, elen, &total_len, elems,
  ------------------
  |  Branch (431:7): [True: 278, False: 1.92k]
  ------------------
  432|  2.20k|					 show_errors))
  433|    278|			return -1;
  434|  1.92k|		break;
  435|  1.92k|	case WLAN_EID_EXT_KNOWN_BSSID:
  ------------------
  |  |  529|    211|#define WLAN_EID_EXT_KNOWN_BSSID 57
  ------------------
  |  Branch (435:2): [True: 211, False: 64.6k]
  ------------------
  436|    211|		elems->mbssid_known_bss = pos;
  437|    211|		elems->mbssid_known_bss_len = elen;
  438|    211|		break;
  439|    205|	case WLAN_EID_EXT_PASN_ENCRYPTED_DATA:
  ------------------
  |  |  548|    205|#define WLAN_EID_EXT_PASN_ENCRYPTED_DATA 140
  ------------------
  |  Branch (439:2): [True: 205, False: 64.6k]
  ------------------
  440|    205|		elems->pasn_encrypted_data = pos;
  441|    205|		elems->pasn_encrypted_data_len = elen;
  442|    205|		break;
  443|    503|	case WLAN_EID_EXT_AKM_SUITE_SELECTOR:
  ------------------
  |  |  545|    503|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (443:2): [True: 503, False: 64.3k]
  ------------------
  444|    503|		if (elen < RSN_SELECTOR_LEN)
  ------------------
  |  |   62|    503|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (444:7): [True: 259, False: 244]
  ------------------
  445|    259|			break;
  446|    244|		elems->akm_suite_selector = pos;
  447|    244|		elems->akm_suite_selector_len = elen;
  448|    244|		break;
  449|    630|	case WLAN_EID_EXT_SUPPORTED_GROUPS:
  ------------------
  |  |  558|    630|#define WLAN_EID_EXT_SUPPORTED_GROUPS 161
  ------------------
  |  Branch (449:2): [True: 630, False: 64.2k]
  ------------------
  450|    630|		if (elen < 2 || elen % 2 != 0)
  ------------------
  |  Branch (450:7): [True: 203, False: 427]
  |  Branch (450:19): [True: 215, False: 212]
  ------------------
  451|    418|			break;
  452|    212|		elems->supported_groups = pos;
  453|    212|		elems->supported_groups_len = elen;
  454|    212|		break;
  455|      0|	case WLAN_EID_EXT_UHR_CAPABILITIES:
  ------------------
  |  |  550|      0|#define WLAN_EID_EXT_UHR_CAPABILITIES 152
  ------------------
  |  Branch (455:2): [True: 0, False: 64.8k]
  ------------------
  456|      0|		elems->uhr_capabilities = pos;
  457|      0|		elems->uhr_capabilities_len = elen;
  458|      0|		break;
  459|      8|	case WLAN_EID_EXT_UHR_OPERATION:
  ------------------
  |  |  549|      8|#define WLAN_EID_EXT_UHR_OPERATION 151
  ------------------
  |  Branch (459:2): [True: 8, False: 64.8k]
  ------------------
  460|      8|		elems->uhr_operation = pos;
  461|      8|		elems->uhr_operation_len = elen;
  462|      8|		break;
  463|  36.3k|	default:
  ------------------
  |  Branch (463:2): [True: 36.3k, False: 28.4k]
  ------------------
  464|  36.3k|		if (show_errors) {
  ------------------
  |  Branch (464:7): [True: 0, False: 36.3k]
  ------------------
  465|      0|			wpa_printf(MSG_MSGDUMP,
  466|      0|				   "IEEE 802.11 element parsing ignored unknown element extension (ext_id=%u elen=%u)",
  467|      0|				   ext_id, (unsigned int) elen);
  468|      0|		}
  469|  36.3k|		return -1;
  470|  64.8k|	}
  471|       |
  472|  28.1k|	if (elen == 254 && total_len)
  ------------------
  |  Branch (472:6): [True: 2.34k, False: 25.8k]
  |  Branch (472:21): [True: 1.09k, False: 1.25k]
  ------------------
  473|  1.09k|		*total_len += ieee802_11_fragments_length(
  474|  1.09k|			elems, pos + elen, (start + len) - (pos + elen));
  475|       |
  476|  28.1k|	return 0;
  477|  64.8k|}
ieee802_11_common.c:ieee802_11_parse_mle:
  240|  2.20k|{
  241|  2.20k|	u8 mle_type = pos[0] & MULTI_LINK_CONTROL_TYPE_MASK;
  ------------------
  |  | 2865|  2.20k|#define MULTI_LINK_CONTROL_TYPE_MASK			0x07
  ------------------
  242|       |
  243|  2.20k|	switch (mle_type) {
  244|    367|	case MULTI_LINK_CONTROL_TYPE_BASIC:
  ------------------
  |  | 2869|    367|#define MULTI_LINK_CONTROL_TYPE_BASIC			0
  ------------------
  |  Branch (244:2): [True: 367, False: 1.83k]
  ------------------
  245|    367|		elems->basic_mle = pos;
  246|    367|		elems->basic_mle_len = elen;
  247|    367|		*total_len = &elems->basic_mle_len;
  248|    367|		break;
  249|    302|	case MULTI_LINK_CONTROL_TYPE_PROBE_REQ:
  ------------------
  |  | 2870|    302|#define MULTI_LINK_CONTROL_TYPE_PROBE_REQ		1
  ------------------
  |  Branch (249:2): [True: 302, False: 1.90k]
  ------------------
  250|    302|		elems->probe_req_mle = pos;
  251|    302|		elems->probe_req_mle_len = elen;
  252|    302|		*total_len = &elems->probe_req_mle_len;
  253|    302|		break;
  254|    272|	case MULTI_LINK_CONTROL_TYPE_RECONF:
  ------------------
  |  | 2871|    272|#define MULTI_LINK_CONTROL_TYPE_RECONF			2
  ------------------
  |  Branch (254:2): [True: 272, False: 1.93k]
  ------------------
  255|    272|		elems->reconf_mle = pos;
  256|    272|		elems->reconf_mle_len = elen;
  257|    272|		*total_len = &elems->reconf_mle_len;
  258|    272|		break;
  259|    461|	case MULTI_LINK_CONTROL_TYPE_TDLS:
  ------------------
  |  | 2872|    461|#define MULTI_LINK_CONTROL_TYPE_TDLS			3
  ------------------
  |  Branch (259:2): [True: 461, False: 1.74k]
  ------------------
  260|    461|		elems->tdls_mle = pos;
  261|    461|		elems->tdls_mle_len = elen;
  262|    461|		*total_len = &elems->tdls_mle_len;
  263|    461|		break;
  264|    524|	case MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS:
  ------------------
  |  | 2873|    524|#define MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS		4
  ------------------
  |  Branch (264:2): [True: 524, False: 1.68k]
  ------------------
  265|    524|		elems->prior_access_mle = pos;
  266|    524|		elems->prior_access_mle_len = elen;
  267|    524|		*total_len = &elems->prior_access_mle_len;
  268|    524|		break;
  269|    278|	default:
  ------------------
  |  Branch (269:2): [True: 278, False: 1.92k]
  ------------------
  270|    278|		if (show_errors) {
  ------------------
  |  Branch (270:7): [True: 0, False: 278]
  ------------------
  271|      0|			wpa_printf(MSG_MSGDUMP,
  272|      0|				   "Unknown Multi-Link element type %u",
  273|      0|				   mle_type);
  274|      0|		}
  275|    278|		return -1;
  276|  2.20k|	}
  277|       |
  278|  1.92k|	return 0;
  279|  2.20k|}
ieee802_11_common.c:ieee802_11_fragments_length:
  284|  2.08k|{
  285|  2.08k|	const struct element *elem;
  286|  2.08k|	size_t frags_len = 0;
  287|       |
  288|   562k|	for_each_element(elem, start, len) {
  ------------------
  |  |  356|  2.08k|	for (_elem = (const struct element *) (_data);			\
  |  |  357|   562k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (357:7): [True: 562k, False: 80]
  |  |  ------------------
  |  |  358|   562k|		(int) sizeof(*_elem) &&					\
  |  |  359|   562k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (359:7): [True: 562k, False: 42]
  |  |  ------------------
  |  |  360|   562k|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  361|   560k|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  ------------------
  289|   562k|		if (elem->id != WLAN_EID_FRAGMENT)
  ------------------
  |  |  499|   562k|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (289:7): [True: 1.96k, False: 560k]
  ------------------
  290|  1.96k|			break;
  291|       |
  292|   560k|		frags_len += elem->datalen + 2;
  293|   560k|		elems->num_frag_elems++;
  294|   560k|	}
  295|       |
  296|  2.08k|	return frags_len;
  297|  2.08k|}
ieee802_11_common.c:country_match:
 1830|  2.58k|{
 1831|  2.58k|	int i;
 1832|       |
 1833|  2.58k|	if (country == NULL)
  ------------------
  |  Branch (1833:6): [True: 2.58k, False: 0]
  ------------------
 1834|  2.58k|		return 0;
 1835|      0|	for (i = 0; cc[i]; i++) {
  ------------------
  |  Branch (1835:14): [True: 0, False: 0]
  ------------------
 1836|      0|		if (cc[i][0] == country[0] && cc[i][1] == country[1])
  ------------------
  |  Branch (1836:7): [True: 0, False: 0]
  |  Branch (1836:33): [True: 0, False: 0]
  ------------------
 1837|      0|			return 1;
 1838|      0|	}
 1839|       |
 1840|      0|	return 0;
 1841|      0|}
ieee802_11_common.c:ieee80211_chan_to_freq_global:
 2038|    645|{
 2039|       |	/* Table E-4 in IEEE Std 802.11-2020 - Global operating classes */
 2040|    645|	switch (op_class) {
 2041|     45|	case 81:
  ------------------
  |  Branch (2041:2): [True: 45, False: 600]
  ------------------
 2042|       |		/* channels 1..13 */
 2043|     45|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2043:7): [True: 3, False: 42]
  |  Branch (2043:19): [True: 8, False: 34]
  ------------------
 2044|     11|			return -1;
 2045|     34|		return 2407 + 5 * chan;
 2046|     14|	case 82:
  ------------------
  |  Branch (2046:2): [True: 14, False: 631]
  ------------------
 2047|       |		/* channel 14 */
 2048|     14|		if (chan != 14)
  ------------------
  |  Branch (2048:7): [True: 10, False: 4]
  ------------------
 2049|     10|			return -1;
 2050|      4|		return 2414 + 5 * chan;
 2051|      9|	case 83: /* channels 1..9; 40 MHz */
  ------------------
  |  Branch (2051:2): [True: 9, False: 636]
  ------------------
 2052|     31|	case 84: /* channels 5..13; 40 MHz */
  ------------------
  |  Branch (2052:2): [True: 22, False: 623]
  ------------------
 2053|     31|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2053:7): [True: 3, False: 28]
  |  Branch (2053:19): [True: 14, False: 14]
  ------------------
 2054|     17|			return -1;
 2055|     14|		return 2407 + 5 * chan;
 2056|      4|	case 115: /* channels 36,40,44,48; indoor only */
  ------------------
  |  Branch (2056:2): [True: 4, False: 641]
  ------------------
 2057|     14|	case 116: /* channels 36,44; 40 MHz; indoor only */
  ------------------
  |  Branch (2057:2): [True: 10, False: 635]
  ------------------
 2058|     33|	case 117: /* channels 40,48; 40 MHz; indoor only */
  ------------------
  |  Branch (2058:2): [True: 19, False: 626]
  ------------------
 2059|     39|	case 118: /* channels 52,56,60,64; dfs */
  ------------------
  |  Branch (2059:2): [True: 6, False: 639]
  ------------------
 2060|     49|	case 119: /* channels 52,60; 40 MHz; dfs */
  ------------------
  |  Branch (2060:2): [True: 10, False: 635]
  ------------------
 2061|     54|	case 120: /* channels 56,64; 40 MHz; dfs */
  ------------------
  |  Branch (2061:2): [True: 5, False: 640]
  ------------------
 2062|     54|		if (chan < 36 || chan > 64)
  ------------------
  |  Branch (2062:7): [True: 12, False: 42]
  |  Branch (2062:20): [True: 17, False: 25]
  ------------------
 2063|     29|			return -1;
 2064|     25|		return 5000 + 5 * chan;
 2065|      9|	case 121: /* channels 100-144 */
  ------------------
  |  Branch (2065:2): [True: 9, False: 636]
  ------------------
 2066|     23|	case 122: /* channels 100-140; 40 MHz */
  ------------------
  |  Branch (2066:2): [True: 14, False: 631]
  ------------------
 2067|     35|	case 123: /* channels 104-144; 40 MHz */
  ------------------
  |  Branch (2067:2): [True: 12, False: 633]
  ------------------
 2068|     35|		if (chan < 100 || chan > 144)
  ------------------
  |  Branch (2068:7): [True: 9, False: 26]
  |  Branch (2068:21): [True: 8, False: 18]
  ------------------
 2069|     17|			return -1;
 2070|     18|		return 5000 + 5 * chan;
 2071|     27|	case 124: /* channels 149,153,157,161 */
  ------------------
  |  Branch (2071:2): [True: 27, False: 618]
  ------------------
 2072|     27|		if (chan < 149 || chan > 161)
  ------------------
  |  Branch (2072:7): [True: 14, False: 13]
  |  Branch (2072:21): [True: 5, False: 8]
  ------------------
 2073|     19|			return -1;
 2074|      8|		return 5000 + 5 * chan;
 2075|      8|	case 125: /* channels 149,153,157,161,165,169,173,177 */
  ------------------
  |  Branch (2075:2): [True: 8, False: 637]
  ------------------
 2076|     23|	case 126: /* channels 149,157,165,173; 40 MHz */
  ------------------
  |  Branch (2076:2): [True: 15, False: 630]
  ------------------
 2077|     29|	case 127: /* channels 153,161,169,177; 40 MHz */
  ------------------
  |  Branch (2077:2): [True: 6, False: 639]
  ------------------
 2078|     29|		if (chan < 149 || chan > 177)
  ------------------
  |  Branch (2078:7): [True: 12, False: 17]
  |  Branch (2078:21): [True: 5, False: 12]
  ------------------
 2079|     17|			return -1;
 2080|     12|		return 5000 + 5 * chan;
 2081|     20|	case 128: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2081:2): [True: 20, False: 625]
  ------------------
 2082|     35|	case 130: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2082:2): [True: 15, False: 630]
  ------------------
 2083|     35|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2083:7): [True: 9, False: 26]
  |  Branch (2083:20): [True: 7, False: 19]
  ------------------
 2084|     16|			return -1;
 2085|     19|		return 5000 + 5 * chan;
 2086|     36|	case 129: /* center freqs 50, 114, 163; 160 MHz */
  ------------------
  |  Branch (2086:2): [True: 36, False: 609]
  ------------------
 2087|     36|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2087:7): [True: 8, False: 28]
  |  Branch (2087:20): [True: 7, False: 21]
  ------------------
 2088|     15|			return -1;
 2089|     21|		return 5000 + 5 * chan;
 2090|      7|	case 131: /* UHB channels, 20 MHz: 1, 5, 9.. */
  ------------------
  |  Branch (2090:2): [True: 7, False: 638]
  ------------------
 2091|     21|	case 132: /* UHB channels, 40 MHz: 3, 11, 19.. */
  ------------------
  |  Branch (2091:2): [True: 14, False: 631]
  ------------------
 2092|     29|	case 133: /* UHB channels, 80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2092:2): [True: 8, False: 637]
  ------------------
 2093|     33|	case 134: /* UHB channels, 160 MHz: 15, 47, 79.. */
  ------------------
  |  Branch (2093:2): [True: 4, False: 641]
  ------------------
 2094|     41|	case 135: /* UHB channels, 80+80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2094:2): [True: 8, False: 637]
  ------------------
 2095|     46|	case 137: /* UHB channels, 320 MHz: 31, 63, 95, 127, 159, 191 */
  ------------------
  |  Branch (2095:2): [True: 5, False: 640]
  ------------------
 2096|     46|		if (chan < 1 || chan > 233)
  ------------------
  |  Branch (2096:7): [True: 5, False: 41]
  |  Branch (2096:19): [True: 5, False: 36]
  ------------------
 2097|     10|			return -1;
 2098|     36|		return 5950 + chan * 5;
 2099|      8|	case 136: /* UHB channels, 20 MHz: 2 */
  ------------------
  |  Branch (2099:2): [True: 8, False: 637]
  ------------------
 2100|      8|		if (chan == 2)
  ------------------
  |  Branch (2100:7): [True: 3, False: 5]
  ------------------
 2101|      3|			return 5935;
 2102|      5|		return -1;
 2103|     21|	case 180: /* 60 GHz band, channels 1..8 */
  ------------------
  |  Branch (2103:2): [True: 21, False: 624]
  ------------------
 2104|     21|		if (chan < 1 || chan > 8)
  ------------------
  |  Branch (2104:7): [True: 3, False: 18]
  |  Branch (2104:19): [True: 9, False: 9]
  ------------------
 2105|     12|			return -1;
 2106|      9|		return 56160 + 2160 * chan;
 2107|     23|	case 181: /* 60 GHz band, EDMG CB2, channels 9..15 */
  ------------------
  |  Branch (2107:2): [True: 23, False: 622]
  ------------------
 2108|     23|		if (chan < 9 || chan > 15)
  ------------------
  |  Branch (2108:7): [True: 6, False: 17]
  |  Branch (2108:19): [True: 11, False: 6]
  ------------------
 2109|     17|			return -1;
 2110|      6|		return 56160 + 2160 * (chan - 8);
 2111|     30|	case 182: /* 60 GHz band, EDMG CB3, channels 17..22 */
  ------------------
  |  Branch (2111:2): [True: 30, False: 615]
  ------------------
 2112|     30|		if (chan < 17 || chan > 22)
  ------------------
  |  Branch (2112:7): [True: 6, False: 24]
  |  Branch (2112:20): [True: 16, False: 8]
  ------------------
 2113|     22|			return -1;
 2114|      8|		return 56160 + 2160 * (chan - 16);
 2115|     29|	case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */
  ------------------
  |  Branch (2115:2): [True: 29, False: 616]
  ------------------
 2116|     29|		if (chan < 25 || chan > 29)
  ------------------
  |  Branch (2116:7): [True: 7, False: 22]
  |  Branch (2116:20): [True: 11, False: 11]
  ------------------
 2117|     18|			return -1;
 2118|     11|		return 56160 + 2160 * (chan - 24);
 2119|    182|	default:
  ------------------
  |  Branch (2119:2): [True: 182, False: 463]
  ------------------
 2120|    182|		return -1;
 2121|    645|	}
 2122|    645|}

ieee802_11_common.c:for_each_element_completed:
  397|  23.7k|{
  398|  23.7k|	return (const u8 *) element == (const u8 *) data + datalen;
  399|  23.7k|}

sha256_vector:
   27|  6.57k|{
   28|  6.57k|	struct sha256_state ctx;
   29|  6.57k|	size_t i;
   30|       |
   31|  6.57k|	if (TEST_FAIL())
  ------------------
  |  |  688|  6.57k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 6.57k]
  |  |  ------------------
  ------------------
   32|      0|		return -1;
   33|       |
   34|  6.57k|	sha256_init(&ctx);
   35|  13.1k|	for (i = 0; i < num_elem; i++)
  ------------------
  |  Branch (35:14): [True: 6.57k, False: 6.57k]
  ------------------
   36|  6.57k|		if (sha256_process(&ctx, addr[i], len[i]))
  ------------------
  |  Branch (36:7): [True: 0, False: 6.57k]
  ------------------
   37|      0|			return -1;
   38|  6.57k|	if (sha256_done(&ctx, mac))
  ------------------
  |  Branch (38:6): [True: 0, False: 6.57k]
  ------------------
   39|      0|		return -1;
   40|  6.57k|	return 0;
   41|  6.57k|}
sha256_init:
  125|  6.57k|{
  126|  6.57k|	md->curlen = 0;
  127|  6.57k|	md->length = 0;
  128|  6.57k|	md->state[0] = 0x6A09E667UL;
  129|  6.57k|	md->state[1] = 0xBB67AE85UL;
  130|  6.57k|	md->state[2] = 0x3C6EF372UL;
  131|  6.57k|	md->state[3] = 0xA54FF53AUL;
  132|  6.57k|	md->state[4] = 0x510E527FUL;
  133|  6.57k|	md->state[5] = 0x9B05688CUL;
  134|  6.57k|	md->state[6] = 0x1F83D9ABUL;
  135|  6.57k|	md->state[7] = 0x5BE0CD19UL;
  136|  6.57k|}
sha256_process:
  147|  6.57k|{
  148|  6.57k|	unsigned long n;
  149|       |
  150|  6.57k|	if (md->curlen >= sizeof(md->buf))
  ------------------
  |  Branch (150:6): [True: 0, False: 6.57k]
  ------------------
  151|      0|		return -1;
  152|       |
  153|  13.1k|	while (inlen > 0) {
  ------------------
  |  Branch (153:9): [True: 6.57k, False: 6.57k]
  ------------------
  154|  6.57k|		if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) {
  ------------------
  |  |   12|  6.57k|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (154:7): [True: 6.57k, False: 0]
  |  Branch (154:26): [True: 0, False: 6.57k]
  ------------------
  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.57k|		} else {
  161|  6.57k|			n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen));
  ------------------
  |  |  468|  6.57k|#define MIN(a, b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (468:20): [True: 6.57k, False: 0]
  |  |  ------------------
  ------------------
  162|  6.57k|			os_memcpy(md->buf + md->curlen, in, n);
  ------------------
  |  |  523|  6.57k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  163|  6.57k|			md->curlen += n;
  164|  6.57k|			in += n;
  165|  6.57k|			inlen -= n;
  166|  6.57k|			if (md->curlen == SHA256_BLOCK_SIZE) {
  ------------------
  |  |   12|  6.57k|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (166:8): [True: 0, False: 6.57k]
  ------------------
  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.57k|		}
  173|  6.57k|	}
  174|       |
  175|  6.57k|	return 0;
  176|  6.57k|}
sha256_done:
  186|  6.57k|{
  187|  6.57k|	int i;
  188|       |
  189|  6.57k|	if (md->curlen >= sizeof(md->buf))
  ------------------
  |  Branch (189:6): [True: 0, False: 6.57k]
  ------------------
  190|      0|		return -1;
  191|       |
  192|       |	/* increase the length of the message */
  193|  6.57k|	md->length += md->curlen * 8;
  194|       |
  195|       |	/* append the '1' bit */
  196|  6.57k|	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.57k|	if (md->curlen > 56) {
  ------------------
  |  Branch (202:6): [True: 0, False: 6.57k]
  ------------------
  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|   276k|	while (md->curlen < 56) {
  ------------------
  |  Branch (211:9): [True: 269k, False: 6.57k]
  ------------------
  212|   269k|		md->buf[md->curlen++] = (unsigned char) 0;
  213|   269k|	}
  214|       |
  215|       |	/* store length */
  216|  6.57k|	WPA_PUT_BE64(md->buf + 56, md->length);
  217|  6.57k|	sha256_compress(md, md->buf);
  218|       |
  219|       |	/* copy output */
  220|  59.1k|	for (i = 0; i < 8; i++)
  ------------------
  |  Branch (220:14): [True: 52.5k, False: 6.57k]
  ------------------
  221|  52.5k|		WPA_PUT_BE32(out + (4 * i), md->state[i]);
  222|       |
  223|  6.57k|	return 0;
  224|  6.57k|}
sha256-internal.c:sha256_compress:
   82|  6.57k|{
   83|  6.57k|	u32 S[8], W[64], t0, t1;
   84|  6.57k|	u32 t;
   85|  6.57k|	int i;
   86|       |
   87|       |	/* copy state into S */
   88|  59.1k|	for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (88:14): [True: 52.5k, False: 6.57k]
  ------------------
   89|  52.5k|		S[i] = md->state[i];
   90|  52.5k|	}
   91|       |
   92|       |	/* copy the state into 512-bits into W[0..15] */
   93|   111k|	for (i = 0; i < 16; i++)
  ------------------
  |  Branch (93:14): [True: 105k, False: 6.57k]
  ------------------
   94|   105k|		W[i] = WPA_GET_BE32(buf + (4 * i));
   95|       |
   96|       |	/* fill W[16..63] */
   97|   322k|	for (i = 16; i < 64; i++) {
  ------------------
  |  Branch (97:15): [True: 315k, False: 6.57k]
  ------------------
   98|   315k|		W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
  ------------------
  |  |   78|   315k|#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   73|   315k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   315k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   315k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   315k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   73|   315k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   315k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   315k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   315k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   74|   315k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
              		W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
  ------------------
  |  |   77|   315k|#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   73|   315k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   315k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   315k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   315k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   73|   315k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|   315k|#define RORc(x, y) \
  |  |  |  |  |  |   69|   315k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |   70|   315k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   74|   315k|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
   99|   315k|			W[i - 16];
  100|   315k|	}
  101|       |
  102|       |	/* Compress */
  103|  6.57k|#define RND(a,b,c,d,e,f,g,h,i)                          \
  104|  6.57k|	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  105|  6.57k|	t1 = Sigma0(a) + Maj(a, b, c);			\
  106|  6.57k|	d += t0;					\
  107|  6.57k|	h  = t0 + t1;
  108|       |
  109|   427k|	for (i = 0; i < 64; ++i) {
  ------------------
  |  Branch (109:14): [True: 420k, False: 6.57k]
  ------------------
  110|   420k|		RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
  ------------------
  |  |  104|   420k|	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  |  |  ------------------
  |  |  |  |   76|   420k|#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];	\
  |  |  ------------------
  |  |  |  |   71|   420k|#define Ch(x,y,z)       (z ^ (x & (y ^ z)))
  |  |  ------------------
  |  |  105|   420k|	t1 = Sigma0(a) + Maj(a, b, c);			\
  |  |  ------------------
  |  |  |  |   75|   420k|#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|   420k|#define S(x, n)         RORc((x), (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   68|   420k|#define RORc(x, y) \
  |  |  |  |  |  |  |  |   69|   420k|( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
  |  |  |  |  |  |  |  |   70|   420k|   ((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	t1 = Sigma0(a) + Maj(a, b, c);			\
  |  |  ------------------
  |  |  |  |   72|   420k|#define Maj(x,y,z)      (((x | y) & z) | (x & y))
  |  |  ------------------
  |  |  106|   420k|	d += t0;					\
  |  |  107|   420k|	h  = t0 + t1;
  ------------------
  111|   420k|		t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
  112|   420k|		S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
  113|   420k|	}
  114|       |
  115|       |	/* feedback */
  116|  59.1k|	for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (116:14): [True: 52.5k, False: 6.57k]
  ------------------
  117|  52.5k|		md->state[i] = md->state[i] + S[i];
  118|  52.5k|	}
  119|  6.57k|	return 0;
  120|  6.57k|}

p2p_set_state:
  193|  6.57k|{
  194|  6.57k|	p2p_dbg(p2p, "State %s -> %s",
  195|  6.57k|		p2p_state_txt(p2p->state), p2p_state_txt(new_state));
  196|  6.57k|	p2p->state = new_state;
  197|       |
  198|  6.57k|	if (new_state == P2P_IDLE && p2p->pending_channel) {
  ------------------
  |  Branch (198:6): [True: 6.57k, False: 0]
  |  Branch (198:31): [True: 0, False: 6.57k]
  ------------------
  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.57k|}
p2p_clear_timeout:
  218|  6.57k|{
  219|  6.57k|	p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state));
  220|       |	eloop_cancel_timeout(p2p_state_timeout, p2p, NULL);
  221|  6.57k|}
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|  8.19k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 3.76k, False: 4.42k]
  |  |  ------------------
  |  |   81|  5.43k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  2.75k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  395|  3.76k|		if (ether_addr_equal(dev->info.p2p_device_addr, addr))
  ------------------
  |  Branch (395:7): [True: 1.01k, False: 2.75k]
  ------------------
  396|  1.01k|			return dev;
  397|  3.76k|	}
  398|  4.42k|	return NULL;
  399|  5.43k|}
p2p_update_peer_6ghz_capab:
  653|  2.61k|{
  654|  2.61k|	if (msg->capability &&
  ------------------
  |  Branch (654:6): [True: 246, False: 2.37k]
  ------------------
  655|    246|	    (msg->capability[0] & P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE))
  ------------------
  |  | 1856|    246|#define P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE BIT(6)
  |  |  ------------------
  |  |  |  |  458|    246|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (655:6): [True: 55, False: 191]
  ------------------
  656|     55|		dev->support_6ghz = true;
  657|  2.61k|}
p2p_add_device:
  741|  7.89k|{
  742|  7.89k|	struct p2p_device *dev;
  743|  7.89k|	struct p2p_message msg;
  744|  7.89k|	const u8 *p2p_dev_addr;
  745|  7.89k|	int wfd_changed;
  746|  7.89k|	int dev_name_changed;
  747|  7.89k|	int i;
  748|  7.89k|	struct os_reltime time_now;
  749|       |
  750|  7.89k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  7.89k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  751|  7.89k|	if (p2p_parse_ies(ies, ies_len, &msg)) {
  ------------------
  |  Branch (751:6): [True: 2.42k, False: 5.47k]
  ------------------
  752|  2.42k|		p2p_dbg(p2p, "Failed to parse P2P IE for a device entry");
  753|  2.42k|		p2p_parse_free(&msg);
  754|  2.42k|		return -1;
  755|  2.42k|	}
  756|       |
  757|  5.47k|	if (msg.p2p_device_addr)
  ------------------
  |  Branch (757:6): [True: 490, False: 4.98k]
  ------------------
  758|    490|		p2p_dev_addr = msg.p2p_device_addr;
  759|  4.98k|	else if (msg.device_id)
  ------------------
  |  Branch (759:11): [True: 1.35k, False: 3.62k]
  ------------------
  760|  1.35k|		p2p_dev_addr = msg.device_id;
  761|  3.62k|	else {
  762|  3.62k|		p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id");
  763|  3.62k|		p2p_parse_free(&msg);
  764|  3.62k|		return -1;
  765|  3.62k|	}
  766|       |
  767|  1.84k|	if (!is_zero_ether_addr(p2p->peer_filter) &&
  ------------------
  |  Branch (767:6): [True: 0, False: 1.84k]
  ------------------
  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.84k|	dev = p2p_create_device(p2p, p2p_dev_addr);
  776|  1.84k|	if (dev == NULL) {
  ------------------
  |  Branch (776:6): [True: 0, False: 1.84k]
  ------------------
  777|      0|		p2p_parse_free(&msg);
  778|      0|		return -1;
  779|      0|	}
  780|       |
  781|  1.84k|	if (rx_time == NULL) {
  ------------------
  |  Branch (781:6): [True: 585, False: 1.26k]
  ------------------
  782|    585|		os_get_reltime(&time_now);
  783|    585|		rx_time = &time_now;
  784|    585|	}
  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.84k|	if (dev->last_seen.sec > 0 &&
  ------------------
  |  Branch (792:6): [True: 86, False: 1.76k]
  ------------------
  793|     86|	    os_reltime_before(rx_time, &dev->last_seen) &&
  ------------------
  |  Branch (793:6): [True: 0, False: 86]
  ------------------
  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.84k|	os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|  1.84k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  809|       |
  810|  1.84k|	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  127|  1.84k|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|  1.84k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|  1.84k|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|  1.84k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  811|  1.84k|			P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT);
  ------------------
  |  |  147|  1.84k|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|  1.84k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  812|       |
  813|  1.84k|	if (!ether_addr_equal(addr, p2p_dev_addr))
  ------------------
  |  Branch (813:6): [True: 1.61k, False: 236]
  ------------------
  814|  1.61k|		os_memcpy(dev->interface_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.61k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  815|  1.84k|	if (msg.ssid &&
  ------------------
  |  Branch (815:6): [True: 770, False: 1.07k]
  ------------------
  816|    770|	    msg.ssid[1] <= sizeof(dev->oper_ssid) &&
  ------------------
  |  Branch (816:6): [True: 770, False: 0]
  ------------------
  817|    770|	    (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1934|  1.54k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (817:7): [True: 491, False: 279]
  ------------------
  818|    279|	     os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    279|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (818:7): [True: 45, False: 234]
  ------------------
  819|    536|	     != 0)) {
  820|    536|		os_memcpy(dev->oper_ssid, msg.ssid + 2, msg.ssid[1]);
  ------------------
  |  |  523|    536|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  821|    536|		dev->oper_ssid_len = msg.ssid[1];
  822|    536|	}
  823|       |
  824|  1.84k|	wpabuf_free(dev->info.p2ps_instance);
  825|  1.84k|	dev->info.p2ps_instance = NULL;
  826|  1.84k|	if (msg.adv_service_instance && msg.adv_service_instance_len)
  ------------------
  |  Branch (826:6): [True: 22, False: 1.82k]
  |  Branch (826:34): [True: 22, False: 0]
  ------------------
  827|     22|		dev->info.p2ps_instance = wpabuf_alloc_copy(
  828|     22|			msg.adv_service_instance, msg.adv_service_instance_len);
  829|       |
  830|  1.84k|	if (freq >= 2412 && freq <= 2484 && msg.ds_params &&
  ------------------
  |  Branch (830:6): [True: 1.84k, False: 0]
  |  Branch (830:22): [True: 1.84k, False: 0]
  |  Branch (830:38): [True: 198, False: 1.64k]
  ------------------
  831|    198|	    *msg.ds_params >= 1 && *msg.ds_params <= 14) {
  ------------------
  |  Branch (831:6): [True: 119, False: 79]
  |  Branch (831:29): [True: 94, False: 25]
  ------------------
  832|     94|		int ds_freq;
  833|     94|		if (*msg.ds_params == 14)
  ------------------
  |  Branch (833:7): [True: 7, False: 87]
  ------------------
  834|      7|			ds_freq = 2484;
  835|     87|		else
  836|     87|			ds_freq = 2407 + *msg.ds_params * 5;
  837|     94|		if (freq != ds_freq) {
  ------------------
  |  Branch (837:7): [True: 75, False: 19]
  ------------------
  838|     75|			p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz",
  839|     75|				freq, ds_freq);
  840|     75|			freq = ds_freq;
  841|     75|		}
  842|     94|	}
  843|       |
  844|  1.84k|	if (dev->listen_freq && dev->listen_freq != freq && scan_res) {
  ------------------
  |  Branch (844:6): [True: 443, False: 1.40k]
  |  Branch (844:26): [True: 57, False: 386]
  |  Branch (844:54): [True: 0, False: 57]
  ------------------
  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.84k|	if (scan_res) {
  ------------------
  |  Branch (850:6): [True: 1.26k, False: 585]
  ------------------
  851|  1.26k|		dev->listen_freq = freq;
  852|  1.26k|		if (msg.group_info)
  ------------------
  |  Branch (852:7): [True: 148, False: 1.11k]
  ------------------
  853|    148|			dev->oper_freq = freq;
  854|  1.26k|	}
  855|  1.84k|	dev->info.level = level;
  856|       |
  857|  1.84k|	dev_name_changed = os_strncmp(dev->info.device_name, msg.device_name,
  ------------------
  |  |  559|  1.84k|#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
  ------------------
  858|  1.84k|				      WPS_DEV_NAME_MAX_LEN) != 0;
  859|       |
  860|  1.84k|	p2p_copy_wps_info(p2p, dev, 0, &msg);
  861|       |
  862|  20.3k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  20.3k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (862:14): [True: 18.4k, False: 1.84k]
  ------------------
  863|  18.4k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  864|  18.4k|		dev->info.wps_vendor_ext[i] = NULL;
  865|  18.4k|	}
  866|       |
  867|  2.00k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  2.00k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (867:14): [True: 2.00k, False: 3]
  ------------------
  868|  2.00k|		if (msg.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (868:7): [True: 1.84k, False: 162]
  ------------------
  869|  1.84k|			break;
  870|    162|		dev->info.wps_vendor_ext[i] = wpabuf_alloc_copy(
  871|    162|			msg.wps_vendor_ext[i], msg.wps_vendor_ext_len[i]);
  872|    162|		if (dev->info.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (872:7): [True: 0, False: 162]
  ------------------
  873|      0|			break;
  874|    162|	}
  875|       |
  876|  1.84k|	wfd_changed = p2p_compare_wfd_info(dev, &msg);
  877|       |
  878|  1.84k|	if (wfd_changed) {
  ------------------
  |  Branch (878:6): [True: 369, False: 1.47k]
  ------------------
  879|    369|		wpabuf_free(dev->info.wfd_subelems);
  880|    369|		if (msg.wfd_subelems)
  ------------------
  |  Branch (880:7): [True: 360, False: 9]
  ------------------
  881|    360|			dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
  882|      9|		else
  883|      9|			dev->info.wfd_subelems = NULL;
  884|    369|	}
  885|       |
  886|  1.84k|	if (scan_res) {
  ------------------
  |  Branch (886:6): [True: 1.26k, False: 585]
  ------------------
  887|  1.26k|		p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq,
  888|  1.26k|				      msg.group_info, msg.group_info_len,
  889|  1.26k|				      rx_time);
  890|  1.26k|	}
  891|       |
  892|  1.84k|	p2p_parse_free(&msg);
  893|       |
  894|  1.84k|	p2p_update_peer_vendor_elems(dev, ies, ies_len);
  895|       |
  896|  1.84k|	if (dev->flags & P2P_DEV_REPORTED && !wfd_changed &&
  ------------------
  |  |  128|  1.84k|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|  3.69k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (896:6): [True: 200, False: 1.64k]
  |  Branch (896:39): [True: 184, False: 16]
  ------------------
  897|    184|	    !dev_name_changed &&
  ------------------
  |  Branch (897:6): [True: 39, False: 145]
  ------------------
  898|     39|	    (!msg.adv_service_instance ||
  ------------------
  |  Branch (898:7): [True: 36, 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|     38|		return 0;
  901|       |
  902|  1.80k|	p2p_dbg(p2p, "Peer found with Listen frequency %d MHz (rx_time=%u.%06u)",
  903|  1.80k|		freq, (unsigned int) rx_time->sec,
  904|  1.80k|		(unsigned int) rx_time->usec);
  905|  1.80k|	if (dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|  1.80k|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|  1.80k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (905:6): [True: 0, False: 1.80k]
  ------------------
  906|      0|		p2p_dbg(p2p, "Do not report rejected device");
  907|      0|		return 0;
  908|      0|	}
  909|       |
  910|  1.80k|	if (dev->info.config_methods == 0 &&
  ------------------
  |  Branch (910:6): [True: 1.27k, False: 531]
  ------------------
  911|  1.27k|	    (freq == 2412 || freq == 2437 || freq == 2462)) {
  ------------------
  |  Branch (911:7): [True: 1.20k, False: 70]
  |  Branch (911:23): [True: 10, False: 60]
  |  Branch (911:39): [True: 6, False: 54]
  ------------------
  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.22k|		p2p_dbg(p2p, "Do not report peer " MACSTR
  927|  1.22k|			" with unknown config methods", MAC2STR(addr));
  ------------------
  |  |  447|  1.22k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  928|  1.22k|		return 0;
  929|  1.22k|	}
  930|       |
  931|    585|	p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info,
  932|    585|			    !(dev->flags & P2P_DEV_REPORTED_ONCE));
  ------------------
  |  |  140|    585|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    585|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  933|    585|	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    585|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    585|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    585|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    585|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  934|       |
  935|    585|	if (msg.adv_service_instance)
  ------------------
  |  Branch (935:6): [True: 9, False: 576]
  ------------------
  936|      9|		dev->flags |= P2P_DEV_P2PS_REPORTED;
  ------------------
  |  |  145|      9|#define P2P_DEV_P2PS_REPORTED BIT(20)
  |  |  ------------------
  |  |  |  |  458|      9|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  937|       |
  938|    585|	return 0;
  939|  1.80k|}
p2p_stop_find_for_freq:
 1344|  6.57k|{
 1345|  6.57k|	p2p_dbg(p2p, "Stopping find");
 1346|  6.57k|	eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
 1347|  6.57k|	p2p_clear_timeout(p2p);
 1348|  6.57k|	if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND)
  ------------------
  |  Branch (1348:6): [True: 0, False: 6.57k]
  |  Branch (1348:34): [True: 0, False: 6.57k]
  ------------------
 1349|      0|		p2p->cfg->find_stopped(p2p->cfg->cb_ctx);
 1350|       |
 1351|  6.57k|	p2p->p2ps_seek_count = 0;
 1352|       |
 1353|  6.57k|	p2p_set_state(p2p, P2P_IDLE);
 1354|  6.57k|	p2p_free_req_dev_types(p2p);
 1355|  6.57k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1356|  6.57k|	if (p2p->go_neg_peer)
  ------------------
  |  Branch (1356:6): [True: 0, False: 6.57k]
  ------------------
 1357|      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))
  |  |  ------------------
  ------------------
 1358|  6.57k|	p2p->go_neg_peer = NULL;
 1359|  6.57k|	p2p->sd_peer = NULL;
 1360|       |	p2p->invite_peer = NULL;
 1361|  6.57k|	p2p_stop_listen_for_freq(p2p, freq);
 1362|  6.57k|	p2p->send_action_in_progress = 0;
 1363|  6.57k|}
p2p_stop_listen_for_freq:
 1367|  6.57k|{
 1368|  6.57k|	p2p_dbg(p2p,
 1369|  6.57k|		"%s(freq=%d) pending_listen_freq=%d in_listen=%d drv_in_listen=%d",
 1370|  6.57k|		__func__, freq, p2p->pending_listen_freq, p2p->in_listen,
 1371|  6.57k|		p2p->drv_in_listen);
 1372|  6.57k|	if (freq > 0 &&
  ------------------
  |  Branch (1372:6): [True: 0, False: 6.57k]
  ------------------
 1373|      0|	    ((p2p->drv_in_listen == freq && p2p->in_listen) ||
  ------------------
  |  Branch (1373:8): [True: 0, False: 0]
  |  Branch (1373:38): [True: 0, False: 0]
  ------------------
 1374|      0|	     p2p->pending_listen_freq == (unsigned int) freq)) {
  ------------------
  |  Branch (1374:7): [True: 0, False: 0]
  ------------------
 1375|      0|		p2p_dbg(p2p, "Skip stop_listen since we are on correct channel for response");
 1376|      0|		return;
 1377|      0|	}
 1378|  6.57k|	if (p2p->in_listen) {
  ------------------
  |  Branch (1378:6): [True: 0, False: 6.57k]
  ------------------
 1379|      0|		p2p->in_listen = 0;
 1380|      0|		p2p_clear_timeout(p2p);
 1381|      0|	}
 1382|  6.57k|	if (p2p->drv_in_listen) {
  ------------------
  |  Branch (1382:6): [True: 0, False: 6.57k]
  ------------------
 1383|       |		/*
 1384|       |		 * The driver may not deliver callback to p2p_listen_end()
 1385|       |		 * when the operation gets canceled, so clear the internal
 1386|       |		 * variable that is tracking driver state.
 1387|       |		 */
 1388|      0|		p2p_dbg(p2p, "Clear drv_in_listen (%d)", p2p->drv_in_listen);
 1389|      0|		p2p->drv_in_listen = 0;
 1390|      0|	}
 1391|  6.57k|	if (p2p->pending_listen_freq &&
  ------------------
  |  Branch (1391:6): [True: 0, False: 6.57k]
  ------------------
 1392|      0|	    p2p->pending_listen_freq != (unsigned int) freq &&
  ------------------
  |  Branch (1392:6): [True: 0, False: 0]
  ------------------
 1393|      0|	    !p2p->drv_in_listen && p2p->pending_listen_wait_drv) {
  ------------------
  |  Branch (1393:6): [True: 0, False: 0]
  |  Branch (1393:29): [True: 0, False: 0]
  ------------------
 1394|      0|		p2p_dbg(p2p,
 1395|      0|			"Clear pending_listen_freq since the started listen did not complete before being stopped");
 1396|      0|		p2p->pending_listen_freq = 0;
 1397|      0|	}
 1398|  6.57k|	p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 1399|       |	p2p->pending_listen_wait_drv = false;
 1400|  6.57k|}
p2p_stop_find:
 1416|  6.57k|{
 1417|  6.57k|	p2p->pending_listen_freq = 0;
 1418|  6.57k|	p2p_stop_find_for_freq(p2p, 0);
 1419|  6.57k|}
p2p_add_dev_info:
 1809|     25|{
 1810|     25|	os_get_reltime(&dev->last_seen);
 1811|       |
 1812|     25|	p2p_copy_wps_info(p2p, dev, 0, msg);
 1813|       |
 1814|     25|	if (msg->listen_channel) {
  ------------------
  |  Branch (1814:6): [True: 25, False: 0]
  ------------------
 1815|     25|		int freq;
 1816|     25|		freq = p2p_channel_to_freq(msg->listen_channel[3],
 1817|     25|					   msg->listen_channel[4]);
 1818|     25|		if (freq < 0) {
  ------------------
  |  Branch (1818:7): [True: 9, False: 16]
  ------------------
 1819|      9|			p2p_dbg(p2p, "Unknown peer Listen channel: "
 1820|      9|				"country=%c%c(0x%02x) reg_class=%u channel=%u",
 1821|      9|				msg->listen_channel[0],
 1822|      9|				msg->listen_channel[1],
 1823|      9|				msg->listen_channel[2],
 1824|      9|				msg->listen_channel[3],
 1825|      9|				msg->listen_channel[4]);
 1826|     16|		} else {
 1827|     16|			p2p_dbg(p2p, "Update peer " MACSTR
 1828|     16|				" Listen channel: %u -> %u MHz",
 1829|     16|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|     16|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1830|     16|				dev->listen_freq, freq);
 1831|     16|			dev->listen_freq = freq;
 1832|     16|		}
 1833|     25|	}
 1834|       |
 1835|     25|	if (msg->wfd_subelems) {
  ------------------
  |  Branch (1835:6): [True: 3, False: 22]
  ------------------
 1836|      3|		wpabuf_free(dev->info.wfd_subelems);
 1837|      3|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
 1838|      3|	}
 1839|       |
 1840|     25|	if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
  ------------------
  |  |  127|     25|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1840:6): [True: 1, False: 24]
  ------------------
 1841|      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))
  |  |  ------------------
  ------------------
 1842|      1|		p2p_dbg(p2p, "Completed device entry based on data from GO Negotiation Request");
 1843|     24|	} else {
 1844|     24|		p2p_dbg(p2p, "Created device entry based on GO Neg Req: "
 1845|     24|			MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
 1846|     24|			"listen_freq=%d",
 1847|     24|			MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|     24|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1848|     24|			dev->info.dev_capab, dev->info.group_capab,
 1849|     24|			dev->info.device_name, dev->listen_freq);
 1850|     24|	}
 1851|       |
 1852|     25|	dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
  ------------------
  |  |  137|     25|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1853|       |
 1854|     25|	if (dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|     25|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1854:6): [True: 0, False: 25]
  ------------------
 1855|      0|		p2p_dbg(p2p, "Do not report rejected device");
 1856|      0|		return;
 1857|      0|	}
 1858|       |
 1859|     25|	p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info,
 1860|     25|			    !(dev->flags & P2P_DEV_REPORTED_ONCE));
  ------------------
  |  |  140|     25|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1861|     25|	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|     25|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|     25|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|     25|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1862|     25|}
p2p_rx_action:
 2110|  4.44k|{
 2111|  4.44k|	if (category == WLAN_ACTION_PUBLIC) {
  ------------------
  |  |  670|  4.44k|#define WLAN_ACTION_PUBLIC 4
  ------------------
  |  Branch (2111:6): [True: 2.26k, False: 2.17k]
  ------------------
 2112|  2.26k|		p2p_rx_action_public(p2p, da, sa, bssid, data, len, freq);
 2113|  2.26k|		return;
 2114|  2.26k|	}
 2115|       |
 2116|  2.17k|	if (category != WLAN_ACTION_VENDOR_SPECIFIC)
  ------------------
  |  |  704|  2.17k|#define WLAN_ACTION_VENDOR_SPECIFIC 127
  ------------------
  |  Branch (2116:6): [True: 1.52k, False: 656]
  ------------------
 2117|  1.52k|		return;
 2118|       |
 2119|    656|	if (len < 4)
  ------------------
  |  Branch (2119:6): [True: 3, False: 653]
  ------------------
 2120|      3|		return;
 2121|       |
 2122|    653|	if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
  ------------------
  |  | 1515|    653|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (2122:6): [True: 56, False: 597]
  ------------------
 2123|     56|		return;
 2124|    597|	data += 4;
 2125|    597|	len -= 4;
 2126|       |
 2127|       |	/* P2P action frame */
 2128|    597|	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    597|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    597|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2129|    597|	wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Action contents", data, len);
 2130|       |
 2131|    597|	if (len < 1)
  ------------------
  |  Branch (2131:6): [True: 1, False: 596]
  ------------------
 2132|      1|		return;
 2133|    596|	switch (data[0]) {
 2134|      2|	case P2P_NOA:
  ------------------
  |  Branch (2134:2): [True: 2, False: 594]
  ------------------
 2135|      2|		p2p_dbg(p2p, "Received P2P Action - Notice of Absence");
 2136|       |		/* TODO */
 2137|      2|		break;
 2138|      1|	case P2P_PRESENCE_REQ:
  ------------------
  |  Branch (2138:2): [True: 1, False: 595]
  ------------------
 2139|      1|		p2p_process_presence_req(p2p, da, sa, data + 1, len - 1, freq);
 2140|      1|		break;
 2141|    588|	case P2P_PRESENCE_RESP:
  ------------------
  |  Branch (2141:2): [True: 588, False: 8]
  ------------------
 2142|    588|		p2p_process_presence_resp(p2p, da, sa, data + 1, len - 1);
 2143|    588|		break;
 2144|      2|	case P2P_GO_DISC_REQ:
  ------------------
  |  Branch (2144:2): [True: 2, False: 594]
  ------------------
 2145|      2|		p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq);
 2146|      2|		break;
 2147|      3|	default:
  ------------------
  |  Branch (2147:2): [True: 3, False: 593]
  ------------------
 2148|      3|		p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]);
 2149|      3|		break;
 2150|    596|	}
 2151|    596|}
p2p_add_dev_from_go_neg_req:
 2276|     16|{
 2277|     16|	struct p2p_device *dev;
 2278|       |
 2279|     16|	dev = p2p_get_device(p2p, addr);
 2280|     16|	if (dev) {
  ------------------
  |  Branch (2280:6): [True: 0, False: 16]
  ------------------
 2281|      0|		os_get_reltime(&dev->last_seen);
 2282|      0|		return dev; /* already known */
 2283|      0|	}
 2284|       |
 2285|     16|	dev = p2p_create_device(p2p, addr);
 2286|     16|	if (dev == NULL)
  ------------------
  |  Branch (2286:6): [True: 0, False: 16]
  ------------------
 2287|      0|		return NULL;
 2288|       |
 2289|     16|	p2p_add_dev_info(p2p, addr, dev, msg);
 2290|       |
 2291|     16|	return dev;
 2292|     16|}
p2p_build_probe_resp_ies:
 2359|      2|{
 2360|      2|	struct wpabuf *buf;
 2361|      2|	u8 *len;
 2362|      2|	int pw_id = -1;
 2363|      2|	size_t extra = 0;
 2364|       |
 2365|      2|#ifdef CONFIG_WIFI_DISPLAY
 2366|      2|	if (p2p->wfd_ie_probe_resp)
  ------------------
  |  Branch (2366:6): [True: 0, False: 2]
  ------------------
 2367|      0|		extra = wpabuf_len(p2p->wfd_ie_probe_resp);
 2368|      2|#endif /* CONFIG_WIFI_DISPLAY */
 2369|       |
 2370|      2|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P])
  ------------------
  |  Branch (2370:6): [True: 0, False: 2]
  |  Branch (2370:26): [True: 0, False: 0]
  ------------------
 2371|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]);
 2372|       |
 2373|      2|	if (query_count)
  ------------------
  |  Branch (2373:6): [True: 0, False: 2]
  ------------------
 2374|      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
  |  |  ------------------
  ------------------
 2375|       |
 2376|      2|	buf = wpabuf_alloc(1000 + extra);
 2377|      2|	if (buf == NULL)
  ------------------
  |  Branch (2377:6): [True: 0, False: 2]
  ------------------
 2378|      0|		return NULL;
 2379|       |
 2380|      2|	if (p2p->go_neg_peer) {
  ------------------
  |  Branch (2380:6): [True: 0, False: 2]
  ------------------
 2381|       |		/* Advertise immediate availability of WPS credential */
 2382|      0|		pw_id = p2p_wps_method_pw_id(p2p->go_neg_peer->wps_method);
 2383|      0|	}
 2384|       |
 2385|      2|	if (p2p_build_wps_ie(p2p, buf, pw_id, 1) < 0) {
  ------------------
  |  Branch (2385:6): [True: 0, False: 2]
  ------------------
 2386|      0|		p2p_dbg(p2p, "Failed to build WPS IE for Probe Response");
 2387|      0|		wpabuf_free(buf);
 2388|      0|		return NULL;
 2389|      0|	}
 2390|       |
 2391|      2|#ifdef CONFIG_WIFI_DISPLAY
 2392|      2|	if (p2p->wfd_ie_probe_resp)
  ------------------
  |  Branch (2392:6): [True: 0, False: 2]
  ------------------
 2393|      0|		wpabuf_put_buf(buf, p2p->wfd_ie_probe_resp);
 2394|      2|#endif /* CONFIG_WIFI_DISPLAY */
 2395|       |
 2396|      2|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P])
  ------------------
  |  Branch (2396:6): [True: 0, False: 2]
  |  Branch (2396:26): [True: 0, False: 0]
  ------------------
 2397|      0|		wpabuf_put_buf(buf,
 2398|      0|			       p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]);
 2399|       |
 2400|       |	/* P2P IE */
 2401|      2|	len = p2p_buf_add_ie_hdr(buf);
 2402|      2|	p2p_buf_add_capability(buf, p2p->dev_capab &
 2403|      2|			       ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 0);
  ------------------
  |  | 1851|      2|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2404|      2|	if (p2p->ext_listen_interval)
  ------------------
  |  Branch (2404:6): [True: 0, False: 2]
  ------------------
 2405|      0|		p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period,
 2406|      0|					      p2p->ext_listen_interval);
 2407|      2|	p2p_buf_add_device_info(buf, p2p, NULL);
 2408|      2|	p2p_buf_update_ie_hdr(buf, len);
 2409|       |
 2410|      2|	if (query_count) {
  ------------------
  |  Branch (2410:6): [True: 0, False: 2]
  ------------------
 2411|      0|		p2p_buf_add_service_instance(buf, p2p, query_count, query_hash,
 2412|      0|					     p2p->p2ps_adv_list);
 2413|      0|	}
 2414|       |
 2415|      2|	return buf;
 2416|      2|}
p2p_probe_req_rx:
 2668|  6.57k|{
 2669|  6.57k|	enum p2p_probe_req_status res;
 2670|       |
 2671|  6.57k|	p2p_add_dev_from_probe_req(p2p, addr, ie, ie_len);
 2672|       |
 2673|  6.57k|	if (p2p_lo_started) {
  ------------------
  |  Branch (2673:6): [True: 0, False: 6.57k]
  ------------------
 2674|      0|		p2p_dbg(p2p,
 2675|      0|			"Probe Response is offloaded, do not reply Probe Request");
 2676|      0|		return P2P_PREQ_PROCESSED;
 2677|      0|	}
 2678|       |
 2679|  6.57k|	res = p2p_reply_probe(p2p, addr, dst, bssid, ie, ie_len, rx_freq);
 2680|  6.57k|	if (res != P2P_PREQ_PROCESSED && res != P2P_PREQ_NOT_PROCESSED)
  ------------------
  |  Branch (2680:6): [True: 6.57k, False: 0]
  |  Branch (2680:35): [True: 4.04k, False: 2.53k]
  ------------------
 2681|  4.04k|		return res;
 2682|       |
 2683|       |	/*
 2684|       |	 * Activate a pending GO Negotiation/Invite flow if a received Probe
 2685|       |	 * Request frame is from an expected peer. Some devices may share the
 2686|       |	 * same address for P2P and non-P2P STA running simultaneously. The
 2687|       |	 * P2P_PREQ_PROCESSED and P2P_PREQ_NOT_PROCESSED p2p_reply_probe()
 2688|       |	 * return values verified above ensure we are handling a Probe Request
 2689|       |	 * frame from a P2P peer.
 2690|       |	 */
 2691|  2.53k|	if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) &&
  ------------------
  |  Branch (2691:7): [True: 0, False: 2.53k]
  |  Branch (2691:36): [True: 0, False: 2.53k]
  ------------------
 2692|      0|	    p2p->go_neg_peer &&
  ------------------
  |  Branch (2692:6): [True: 0, False: 0]
  ------------------
 2693|      0|	    ether_addr_equal(addr, p2p->go_neg_peer->info.p2p_device_addr) &&
  ------------------
  |  Branch (2693:6): [True: 0, False: 0]
  ------------------
 2694|      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 (2694:6): [True: 0, False: 0]
  ------------------
 2695|       |		/* Received a Probe Request from GO Negotiation peer */
 2696|      0|		p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout");
 2697|      0|		eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
 2698|      0|		eloop_register_timeout(0, 0, p2p_go_neg_start, p2p, NULL);
 2699|      0|		return res;
 2700|      0|	}
 2701|       |
 2702|  2.53k|	if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) &&
  ------------------
  |  Branch (2702:7): [True: 0, False: 2.53k]
  |  Branch (2702:35): [True: 0, False: 2.53k]
  ------------------
 2703|      0|	    p2p->invite_peer &&
  ------------------
  |  Branch (2703:6): [True: 0, False: 0]
  ------------------
 2704|      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 (2704:6): [True: 0, False: 0]
  ------------------
 2705|      0|	    ether_addr_equal(addr, p2p->invite_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (2705:6): [True: 0, False: 0]
  ------------------
 2706|       |		/* Received a Probe Request from Invite peer */
 2707|      0|		p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout");
 2708|      0|		eloop_cancel_timeout(p2p_invite_start, p2p, NULL);
 2709|      0|		eloop_register_timeout(0, 0, p2p_invite_start, p2p, NULL);
 2710|      0|		return res;
 2711|      0|	}
 2712|       |
 2713|  2.53k|	return res;
 2714|  2.53k|}
p2p_service_p2ps_id:
 2858|      1|{
 2859|      1|	struct p2ps_advertisement *adv_data;
 2860|       |
 2861|      1|	if (!p2p)
  ------------------
  |  Branch (2861:6): [True: 0, False: 1]
  ------------------
 2862|      0|		return NULL;
 2863|       |
 2864|      1|	adv_data = p2p->p2ps_adv_list;
 2865|      1|	while (adv_data) {
  ------------------
  |  Branch (2865:9): [True: 0, False: 1]
  ------------------
 2866|      0|		if (adv_data->id == adv_id)
  ------------------
  |  Branch (2866:7): [True: 0, False: 0]
  ------------------
 2867|      0|			return adv_data;
 2868|      0|		adv_data = adv_data->next;
 2869|      0|	}
 2870|       |
 2871|      1|	return NULL;
 2872|      1|}
p2p_service_flush_asp:
 2990|  6.57k|{
 2991|  6.57k|	struct p2ps_advertisement *adv, *prev;
 2992|       |
 2993|  6.57k|	if (!p2p)
  ------------------
  |  Branch (2993:6): [True: 0, False: 6.57k]
  ------------------
 2994|      0|		return;
 2995|       |
 2996|  6.57k|	adv = p2p->p2ps_adv_list;
 2997|  6.57k|	while (adv) {
  ------------------
  |  Branch (2997:9): [True: 0, False: 6.57k]
  ------------------
 2998|      0|		prev = adv;
 2999|      0|		adv = adv->next;
 3000|      0|		os_free(prev);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
 3001|      0|	}
 3002|       |
 3003|       |	p2p->p2ps_adv_list = NULL;
 3004|  6.57k|	p2ps_prov_free(p2p);
 3005|  6.57k|	p2p_dbg(p2p, "All ASP advertisements flushed");
 3006|  6.57k|}
p2p_init:
 3167|  6.57k|{
 3168|  6.57k|	struct p2p_data *p2p;
 3169|       |
 3170|  6.57k|	if (cfg->max_peers < 1 ||
  ------------------
  |  Branch (3170:6): [True: 0, False: 6.57k]
  ------------------
 3171|  6.57k|	    cfg->passphrase_len < 8 || cfg->passphrase_len > 63)
  ------------------
  |  Branch (3171:6): [True: 0, False: 6.57k]
  |  Branch (3171:33): [True: 0, False: 6.57k]
  ------------------
 3172|      0|		return NULL;
 3173|       |
 3174|  6.57k|	p2p = os_zalloc(sizeof(*p2p) + sizeof(*cfg));
 3175|  6.57k|	if (p2p == NULL)
  ------------------
  |  Branch (3175:6): [True: 0, False: 6.57k]
  ------------------
 3176|      0|		return NULL;
 3177|  6.57k|	p2p->cfg = (struct p2p_config *) (p2p + 1);
 3178|  6.57k|	os_memcpy(p2p->cfg, cfg, sizeof(*cfg));
  ------------------
  |  |  523|  6.57k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3179|  6.57k|	if (cfg->dev_name)
  ------------------
  |  Branch (3179:6): [True: 0, False: 6.57k]
  ------------------
 3180|      0|		p2p->cfg->dev_name = os_strdup(cfg->dev_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3181|  6.57k|	if (cfg->manufacturer)
  ------------------
  |  Branch (3181:6): [True: 0, False: 6.57k]
  ------------------
 3182|      0|		p2p->cfg->manufacturer = os_strdup(cfg->manufacturer);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3183|  6.57k|	if (cfg->model_name)
  ------------------
  |  Branch (3183:6): [True: 0, False: 6.57k]
  ------------------
 3184|      0|		p2p->cfg->model_name = os_strdup(cfg->model_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3185|  6.57k|	if (cfg->model_number)
  ------------------
  |  Branch (3185:6): [True: 0, False: 6.57k]
  ------------------
 3186|      0|		p2p->cfg->model_number = os_strdup(cfg->model_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3187|  6.57k|	if (cfg->serial_number)
  ------------------
  |  Branch (3187:6): [True: 0, False: 6.57k]
  ------------------
 3188|      0|		p2p->cfg->serial_number = os_strdup(cfg->serial_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3189|  6.57k|	if (cfg->pref_chan) {
  ------------------
  |  Branch (3189:6): [True: 0, False: 6.57k]
  ------------------
 3190|      0|		p2p->cfg->pref_chan = os_malloc(cfg->num_pref_chan *
  ------------------
  |  |  505|      0|#define os_malloc(s) malloc((s))
  ------------------
 3191|      0|						sizeof(struct p2p_channel));
 3192|      0|		if (p2p->cfg->pref_chan) {
  ------------------
  |  Branch (3192:7): [True: 0, False: 0]
  ------------------
 3193|      0|			os_memcpy(p2p->cfg->pref_chan, cfg->pref_chan,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3194|      0|				  cfg->num_pref_chan *
 3195|      0|				  sizeof(struct p2p_channel));
 3196|      0|		} else
 3197|      0|			p2p->cfg->num_pref_chan = 0;
 3198|      0|	}
 3199|       |
 3200|  6.57k|	p2ps_gen_hash(p2p, P2PS_WILD_HASH_STR, p2p->wild_card_hash);
  ------------------
  |  |   34|  6.57k|#define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
  ------------------
 3201|       |
 3202|  6.57k|	p2p->min_disc_int = 1;
 3203|  6.57k|	p2p->max_disc_int = 3;
 3204|  6.57k|	p2p->max_disc_tu = -1;
 3205|       |
 3206|  6.57k|	if (os_get_random(&p2p->next_tie_breaker, 1) < 0)
  ------------------
  |  Branch (3206:6): [True: 0, False: 6.57k]
  ------------------
 3207|      0|		p2p->next_tie_breaker = 0;
 3208|  6.57k|	p2p->next_tie_breaker &= 0x01;
 3209|  6.57k|	if (cfg->sd_request)
  ------------------
  |  Branch (3209:6): [True: 0, False: 6.57k]
  ------------------
 3210|      0|		p2p->dev_capab |= P2P_DEV_CAPAB_SERVICE_DISCOVERY;
  ------------------
  |  | 1850|      0|#define P2P_DEV_CAPAB_SERVICE_DISCOVERY BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3211|  6.57k|	p2p->dev_capab |= P2P_DEV_CAPAB_INVITATION_PROCEDURE;
  ------------------
  |  | 1855|  6.57k|#define P2P_DEV_CAPAB_INVITATION_PROCEDURE BIT(5)
  |  |  ------------------
  |  |  |  |  458|  6.57k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3212|  6.57k|	if (cfg->concurrent_operations)
  ------------------
  |  Branch (3212:6): [True: 0, False: 6.57k]
  ------------------
 3213|      0|		p2p->dev_capab |= P2P_DEV_CAPAB_CONCURRENT_OPER;
  ------------------
  |  | 1852|      0|#define P2P_DEV_CAPAB_CONCURRENT_OPER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3214|  6.57k|	p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|  6.57k|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|  6.57k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3215|       |
 3216|  6.57k|	dl_list_init(&p2p->devices);
 3217|       |
 3218|  6.57k|	p2p->go_timeout = 100;
 3219|  6.57k|	p2p->client_timeout = 20;
 3220|  6.57k|	p2p->num_p2p_sd_queries = 0;
 3221|       |	/* Default comeback after one second */
 3222|  6.57k|	if (!p2p->cfg->comeback_after)
  ------------------
  |  Branch (3222:6): [True: 6.57k, False: 0]
  ------------------
 3223|  6.57k|		p2p->cfg->comeback_after = 977; /* TUs */
 3224|  6.57k|	p2p_pairing_info_init(p2p);
 3225|       |
 3226|  6.57k|	p2p_dbg(p2p, "initialized");
 3227|  6.57k|	p2p_channels_dump(p2p, "channels", &p2p->cfg->channels);
 3228|  6.57k|	p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels);
 3229|       |
 3230|  6.57k|	return p2p;
 3231|  6.57k|}
p2p_deinit:
 3235|  6.57k|{
 3236|  6.57k|#ifdef CONFIG_WIFI_DISPLAY
 3237|  6.57k|	wpabuf_free(p2p->wfd_ie_beacon);
 3238|  6.57k|	wpabuf_free(p2p->wfd_ie_probe_req);
 3239|  6.57k|	wpabuf_free(p2p->wfd_ie_probe_resp);
 3240|  6.57k|	wpabuf_free(p2p->wfd_ie_assoc_req);
 3241|  6.57k|	wpabuf_free(p2p->wfd_ie_invitation);
 3242|  6.57k|	wpabuf_free(p2p->wfd_ie_prov_disc_req);
 3243|  6.57k|	wpabuf_free(p2p->wfd_ie_prov_disc_resp);
 3244|  6.57k|	wpabuf_free(p2p->wfd_ie_go_neg);
 3245|  6.57k|	wpabuf_free(p2p->wfd_dev_info);
 3246|  6.57k|	wpabuf_free(p2p->wfd_assoc_bssid);
 3247|  6.57k|	wpabuf_free(p2p->wfd_coupled_sink_info);
 3248|  6.57k|	wpabuf_free(p2p->wfd_r2_dev_info);
 3249|  6.57k|#endif /* CONFIG_WIFI_DISPLAY */
 3250|       |
 3251|  6.57k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3252|  6.57k|	eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
 3253|  6.57k|	eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
 3254|  6.57k|	p2p_flush(p2p);
 3255|  6.57k|	p2p_free_req_dev_types(p2p);
 3256|  6.57k|	os_free(p2p->cfg->dev_name);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3257|  6.57k|	os_free(p2p->cfg->manufacturer);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3258|  6.57k|	os_free(p2p->cfg->model_name);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3259|  6.57k|	os_free(p2p->cfg->model_number);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3260|  6.57k|	os_free(p2p->cfg->serial_number);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3261|  6.57k|	os_free(p2p->cfg->pref_chan);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3262|  6.57k|	os_free(p2p->groups);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3263|  6.57k|	p2ps_prov_free(p2p);
 3264|  6.57k|	wpabuf_free(p2p->sd_resp);
 3265|  6.57k|	p2p_remove_wps_vendor_extensions(p2p);
 3266|  6.57k|	os_free(p2p->no_go_freq.range);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3267|  6.57k|	p2p_service_flush_asp(p2p);
 3268|  6.57k|	p2p_pairing_info_deinit(p2p);
 3269|       |
 3270|  6.57k|	os_free(p2p);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 3271|  6.57k|}
p2p_flush:
 3275|  6.57k|{
 3276|  6.57k|	struct p2p_device *dev, *prev;
 3277|       |
 3278|  6.57k|	p2p_ext_listen(p2p, 0, 0);
 3279|  6.57k|	p2p_stop_find(p2p);
 3280|  6.57k|	dl_list_for_each_safe(dev, prev, &p2p->devices, struct p2p_device,
  ------------------
  |  |   84|  6.57k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  6.57k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  8.56k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 1.99k, False: 6.57k]
  |  |  ------------------
  |  |   87|  6.57k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  1.99k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 3281|  6.57k|			      list) {
 3282|  1.99k|		dl_list_del(&dev->list);
 3283|  1.99k|		p2p_device_free(p2p, dev);
 3284|  1.99k|	}
 3285|  6.57k|	p2p_free_sd_queries(p2p);
 3286|  6.57k|	p2p->ssid_set = 0;
 3287|  6.57k|	p2ps_prov_free(p2p);
 3288|  6.57k|	p2p_reset_pending_pd(p2p);
 3289|  6.57k|	p2p->override_pref_op_class = 0;
 3290|  6.57k|	p2p->override_pref_channel = 0;
 3291|  6.57k|}
p2p_remove_wps_vendor_extensions:
 3418|  6.57k|{
 3419|  6.57k|	int i;
 3420|       |
 3421|  72.3k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  72.3k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (3421:14): [True: 65.7k, False: 6.57k]
  ------------------
 3422|  65.7k|		wpabuf_free(p2p->wps_vendor_ext[i]);
 3423|       |		p2p->wps_vendor_ext[i] = NULL;
 3424|  65.7k|	}
 3425|  6.57k|}
p2p_scan_res_handler:
 3736|  6.57k|{
 3737|  6.57k|	if (os_reltime_before(rx_time, &p2p->find_start)) {
  ------------------
  |  Branch (3737:6): [True: 0, False: 6.57k]
  ------------------
 3738|       |		/*
 3739|       |		 * The driver may have cached (e.g., in cfg80211 BSS table) the
 3740|       |		 * scan results for relatively long time. To avoid reporting
 3741|       |		 * stale information, update P2P peers only based on results
 3742|       |		 * that have based on frames received after the last p2p_find
 3743|       |		 * operation was started.
 3744|       |		 */
 3745|      0|		p2p_dbg(p2p, "Ignore old scan result for " MACSTR
 3746|      0|			" (rx_time=%u.%06u find_start=%u.%06u)",
 3747|      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]
  ------------------
 3748|      0|			(unsigned int) rx_time->usec,
 3749|      0|			(unsigned int) p2p->find_start.sec,
 3750|      0|			(unsigned int) p2p->find_start.usec);
 3751|      0|		return 0;
 3752|      0|	}
 3753|       |
 3754|  6.57k|	p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1);
 3755|       |
 3756|  6.57k|	return 0;
 3757|  6.57k|}
p2p_scan_res_handled:
 3761|  6.57k|{
 3762|  6.57k|	if (!p2p->p2p_scan_running) {
  ------------------
  |  Branch (3762:6): [True: 6.57k, False: 0]
  ------------------
 3763|  6.57k|		p2p_dbg(p2p, "p2p_scan was not running, but scan results received");
 3764|  6.57k|	}
 3765|  6.57k|	p2p->p2p_scan_running = 0;
 3766|       |
 3767|       |	/* Use this delay only when p2p_find doesn't set it */
 3768|  6.57k|	if (!p2p->search_delay)
  ------------------
  |  Branch (3768:6): [True: 6.57k, False: 0]
  ------------------
 3769|  6.57k|		p2p->search_delay = delay;
 3770|       |
 3771|  6.57k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3772|       |
 3773|  6.57k|	if (p2p_run_after_scan(p2p))
  ------------------
  |  Branch (3773:6): [True: 0, False: 6.57k]
  ------------------
 3774|      0|		return;
 3775|  6.57k|	if (p2p->state == P2P_SEARCH)
  ------------------
  |  Branch (3775:6): [True: 0, False: 6.57k]
  ------------------
 3776|      0|		p2p_continue_find(p2p);
 3777|  6.57k|}
p2p_ext_listen:
 4914|  6.57k|{
 4915|  6.57k|	if (period > 65535 || interval > 65535 || period > interval ||
  ------------------
  |  Branch (4915:6): [True: 0, False: 6.57k]
  |  Branch (4915:24): [True: 0, False: 6.57k]
  |  Branch (4915:44): [True: 0, False: 6.57k]
  ------------------
 4916|  6.57k|	    (period == 0 && interval > 0) || (period > 0 && interval == 0)) {
  ------------------
  |  Branch (4916:7): [True: 6.57k, False: 0]
  |  Branch (4916:22): [True: 0, False: 6.57k]
  |  Branch (4916:40): [True: 0, False: 6.57k]
  |  Branch (4916:54): [True: 0, False: 0]
  ------------------
 4917|      0|		p2p_dbg(p2p, "Invalid Extended Listen Timing request: period=%u interval=%u",
 4918|      0|			period, interval);
 4919|      0|		return -1;
 4920|      0|	}
 4921|       |
 4922|  6.57k|	eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL);
 4923|       |
 4924|  6.57k|	if (interval == 0) {
  ------------------
  |  Branch (4924:6): [True: 6.57k, False: 0]
  ------------------
 4925|  6.57k|		p2p_dbg(p2p, "Disabling Extended Listen Timing");
 4926|  6.57k|		p2p->ext_listen_period = 0;
 4927|  6.57k|		p2p->ext_listen_interval = 0;
 4928|  6.57k|		return 0;
 4929|  6.57k|	}
 4930|       |
 4931|      0|	p2p_dbg(p2p, "Enabling Extended Listen Timing: period %u msec, interval %u msec",
 4932|      0|		period, interval);
 4933|      0|	p2p->ext_listen_period = period;
 4934|      0|	p2p->ext_listen_interval = interval;
 4935|      0|	p2p->ext_listen_interval_sec = interval / 1000;
 4936|      0|	p2p->ext_listen_interval_usec = (interval % 1000) * 1000;
 4937|       |
 4938|      0|	eloop_register_timeout(p2p->ext_listen_interval_sec,
 4939|      0|			       p2p->ext_listen_interval_usec,
 4940|      0|			       p2p_ext_listen_timeout, p2p, NULL);
 4941|       |
 4942|      0|	return 0;
 4943|  6.57k|}
p2p_send_action:
 5306|  1.68k|{
 5307|  1.68k|	int res, scheduled;
 5308|       |
 5309|  1.68k|	res = p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid,
 5310|  1.68k|				    buf, len, wait_time, &scheduled);
 5311|  1.68k|	if (res == 0 && scheduled && p2p->in_listen && freq > 0 &&
  ------------------
  |  Branch (5311:6): [True: 1.68k, False: 0]
  |  Branch (5311:18): [True: 0, False: 1.68k]
  |  Branch (5311:31): [True: 0, False: 0]
  |  Branch (5311:49): [True: 0, False: 0]
  ------------------
 5312|      0|	    p2p->drv_in_listen > 0 &&
  ------------------
  |  Branch (5312:6): [True: 0, False: 0]
  ------------------
 5313|      0|	    (unsigned int) p2p->drv_in_listen != freq) {
  ------------------
  |  Branch (5313:6): [True: 0, False: 0]
  ------------------
 5314|      0|		p2p_dbg(p2p,
 5315|      0|			"Stop listen on %d MHz to allow a frame to be sent immediately on %d MHz",
 5316|      0|			p2p->drv_in_listen, freq);
 5317|      0|		p2p_stop_listen_for_freq(p2p, freq);
 5318|      0|	}
 5319|  1.68k|	return res;
 5320|  1.68k|}
p2p_dbg:
 5566|  94.0k|{
 5567|  94.0k|	va_list ap;
 5568|  94.0k|	char buf[500];
 5569|       |
 5570|  94.0k|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5570:6): [True: 0, False: 94.0k]
  ------------------
 5571|      0|		return;
 5572|       |
 5573|  94.0k|	va_start(ap, fmt);
 5574|  94.0k|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5575|  94.0k|	buf[sizeof(buf) - 1] = '\0';
 5576|       |	va_end(ap);
 5577|  94.0k|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf);
 5578|  94.0k|}
p2p_info:
 5582|     51|{
 5583|     51|	va_list ap;
 5584|     51|	char buf[500];
 5585|       |
 5586|     51|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5586:6): [True: 0, False: 51]
  ------------------
 5587|      0|		return;
 5588|       |
 5589|     51|	va_start(ap, fmt);
 5590|     51|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5591|     51|	buf[sizeof(buf) - 1] = '\0';
 5592|       |	va_end(ap);
 5593|     51|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf);
 5594|     51|}
p2p.c:p2p_state_txt:
  111|  19.7k|{
  112|  19.7k|	switch (state) {
  113|  19.7k|	case P2P_IDLE:
  ------------------
  |  Branch (113:2): [True: 19.7k, False: 0]
  ------------------
  114|  19.7k|		return "IDLE";
  115|      0|	case P2P_SEARCH:
  ------------------
  |  Branch (115:2): [True: 0, False: 19.7k]
  ------------------
  116|      0|		return "SEARCH";
  117|      0|	case P2P_CONNECT:
  ------------------
  |  Branch (117:2): [True: 0, False: 19.7k]
  ------------------
  118|      0|		return "CONNECT";
  119|      0|	case P2P_CONNECT_LISTEN:
  ------------------
  |  Branch (119:2): [True: 0, False: 19.7k]
  ------------------
  120|      0|		return "CONNECT_LISTEN";
  121|      0|	case P2P_GO_NEG:
  ------------------
  |  Branch (121:2): [True: 0, False: 19.7k]
  ------------------
  122|      0|		return "GO_NEG";
  123|      0|	case P2P_LISTEN_ONLY:
  ------------------
  |  Branch (123:2): [True: 0, False: 19.7k]
  ------------------
  124|      0|		return "LISTEN_ONLY";
  125|      0|	case P2P_WAIT_PEER_CONNECT:
  ------------------
  |  Branch (125:2): [True: 0, False: 19.7k]
  ------------------
  126|      0|		return "WAIT_PEER_CONNECT";
  127|      0|	case P2P_WAIT_PEER_IDLE:
  ------------------
  |  Branch (127:2): [True: 0, False: 19.7k]
  ------------------
  128|      0|		return "WAIT_PEER_IDLE";
  129|      0|	case P2P_SD_DURING_FIND:
  ------------------
  |  Branch (129:2): [True: 0, False: 19.7k]
  ------------------
  130|      0|		return "SD_DURING_FIND";
  131|      0|	case P2P_PROVISIONING:
  ------------------
  |  Branch (131:2): [True: 0, False: 19.7k]
  ------------------
  132|      0|		return "PROVISIONING";
  133|      0|	case P2P_PD_DURING_FIND:
  ------------------
  |  Branch (133:2): [True: 0, False: 19.7k]
  ------------------
  134|      0|		return "PD_DURING_FIND";
  135|      0|	case P2P_INVITE:
  ------------------
  |  Branch (135:2): [True: 0, False: 19.7k]
  ------------------
  136|      0|		return "INVITE";
  137|      0|	case P2P_INVITE_LISTEN:
  ------------------
  |  Branch (137:2): [True: 0, False: 19.7k]
  ------------------
  138|      0|		return "INVITE_LISTEN";
  139|      0|	default:
  ------------------
  |  Branch (139:2): [True: 0, False: 19.7k]
  ------------------
  140|      0|		return "?";
  141|  19.7k|	}
  142|  19.7k|}
p2p.c:p2p_create_device:
  431|  2.44k|{
  432|  2.44k|	struct p2p_device *dev, *oldest = NULL;
  433|  2.44k|	size_t count = 0;
  434|       |
  435|  2.44k|	dev = p2p_get_device(p2p, addr);
  436|  2.44k|	if (dev)
  ------------------
  |  Branch (436:6): [True: 452, False: 1.99k]
  ------------------
  437|    452|		return dev;
  438|       |
  439|  1.99k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  2.44k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  2.44k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  2.73k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 736, False: 1.99k]
  |  |  ------------------
  |  |   81|  1.99k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|    736|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  440|    736|		count++;
  441|    736|		if (oldest == NULL ||
  ------------------
  |  Branch (441:7): [True: 330, False: 406]
  ------------------
  442|    406|		    os_reltime_before(&dev->last_seen, &oldest->last_seen))
  ------------------
  |  Branch (442:7): [True: 10, False: 396]
  ------------------
  443|    340|			oldest = dev;
  444|    736|	}
  445|  1.99k|	if (count + 1 > p2p->cfg->max_peers && oldest) {
  ------------------
  |  Branch (445:6): [True: 0, False: 1.99k]
  |  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.99k|	dev = os_zalloc(sizeof(*dev));
  454|  1.99k|	if (dev == NULL)
  ------------------
  |  Branch (454:6): [True: 0, False: 1.99k]
  ------------------
  455|      0|		return NULL;
  456|  1.99k|	dl_list_add(&p2p->devices, &dev->list);
  457|  1.99k|	os_memcpy(dev->info.p2p_device_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.99k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  458|  1.99k|	dev->support_6ghz = false;
  459|       |
  460|  1.99k|	return dev;
  461|  1.99k|}
p2p.c:p2p_copy_wps_info:
  564|  2.27k|{
  565|  2.27k|	os_memcpy(dev->info.device_name, msg->device_name,
  ------------------
  |  |  523|  2.27k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  566|  2.27k|		  sizeof(dev->info.device_name));
  567|       |
  568|  2.27k|	if (msg->manufacturer &&
  ------------------
  |  Branch (568:6): [True: 23, False: 2.25k]
  ------------------
  569|     23|	    msg->manufacturer_len < sizeof(dev->info.manufacturer)) {
  ------------------
  |  Branch (569:6): [True: 23, False: 0]
  ------------------
  570|     23|		os_memset(dev->info.manufacturer, 0,
  ------------------
  |  |  529|     23|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  571|     23|			  sizeof(dev->info.manufacturer));
  572|     23|		os_memcpy(dev->info.manufacturer, msg->manufacturer,
  ------------------
  |  |  523|     23|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  573|     23|			  msg->manufacturer_len);
  574|     23|	}
  575|       |
  576|  2.27k|	if (msg->model_name &&
  ------------------
  |  Branch (576:6): [True: 17, False: 2.26k]
  ------------------
  577|     17|	    msg->model_name_len < sizeof(dev->info.model_name)) {
  ------------------
  |  Branch (577:6): [True: 17, False: 0]
  ------------------
  578|     17|		os_memset(dev->info.model_name, 0,
  ------------------
  |  |  529|     17|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  579|     17|			  sizeof(dev->info.model_name));
  580|     17|		os_memcpy(dev->info.model_name, msg->model_name,
  ------------------
  |  |  523|     17|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  581|     17|			  msg->model_name_len);
  582|     17|	}
  583|       |
  584|  2.27k|	if (msg->model_number &&
  ------------------
  |  Branch (584:6): [True: 25, False: 2.25k]
  ------------------
  585|     25|	    msg->model_number_len < sizeof(dev->info.model_number)) {
  ------------------
  |  Branch (585:6): [True: 25, False: 0]
  ------------------
  586|     25|		os_memset(dev->info.model_number, 0,
  ------------------
  |  |  529|     25|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  587|     25|			  sizeof(dev->info.model_number));
  588|     25|		os_memcpy(dev->info.model_number, msg->model_number,
  ------------------
  |  |  523|     25|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  589|     25|			  msg->model_number_len);
  590|     25|	}
  591|       |
  592|  2.27k|	if (msg->serial_number &&
  ------------------
  |  Branch (592:6): [True: 33, False: 2.24k]
  ------------------
  593|     33|	    msg->serial_number_len < sizeof(dev->info.serial_number)) {
  ------------------
  |  Branch (593:6): [True: 33, False: 0]
  ------------------
  594|     33|		os_memset(dev->info.serial_number, 0,
  ------------------
  |  |  529|     33|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  595|     33|			  sizeof(dev->info.serial_number));
  596|     33|		os_memcpy(dev->info.serial_number, msg->serial_number,
  ------------------
  |  |  523|     33|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  597|     33|			  msg->serial_number_len);
  598|     33|	}
  599|       |
  600|  2.27k|	if (msg->pri_dev_type)
  ------------------
  |  Branch (600:6): [True: 522, False: 1.75k]
  ------------------
  601|    522|		os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type,
  ------------------
  |  |  523|    522|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  602|  2.27k|			  sizeof(dev->info.pri_dev_type));
  603|  1.75k|	else if (msg->wps_pri_dev_type)
  ------------------
  |  Branch (603:11): [True: 11, False: 1.74k]
  ------------------
  604|     11|		os_memcpy(dev->info.pri_dev_type, msg->wps_pri_dev_type,
  ------------------
  |  |  523|     11|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  605|  2.27k|			  sizeof(dev->info.pri_dev_type));
  606|       |
  607|  2.27k|	if (msg->wps_sec_dev_type_list) {
  ------------------
  |  Branch (607:6): [True: 6, False: 2.27k]
  ------------------
  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.27k|	if (msg->capability) {
  ------------------
  |  Branch (615:6): [True: 139, False: 2.14k]
  ------------------
  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|    139|		dev->info.dev_capab &= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|    139|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    139|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  621|    139|		dev->info.dev_capab |= msg->capability[0] &
  622|    139|			~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|    139|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    139|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  623|    139|		dev->info.group_capab = msg->capability[1];
  624|    139|	}
  625|       |
  626|  2.27k|	p2p_update_peer_6ghz_capab(dev, msg);
  627|       |
  628|  2.27k|	if (msg->ext_listen_timing) {
  ------------------
  |  Branch (628:6): [True: 8, False: 2.27k]
  ------------------
  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.27k|	if (!probe_req) {
  ------------------
  |  Branch (634:6): [True: 1.87k, False: 407]
  ------------------
  635|  1.87k|		u16 new_config_methods;
  636|  1.87k|		new_config_methods = msg->config_methods ?
  ------------------
  |  Branch (636:24): [True: 488, False: 1.38k]
  ------------------
  637|  1.38k|			msg->config_methods : msg->wps_config_methods;
  638|  1.87k|		if (new_config_methods &&
  ------------------
  |  Branch (638:7): [True: 573, False: 1.29k]
  ------------------
  639|    573|		    dev->info.config_methods != new_config_methods) {
  ------------------
  |  Branch (639:7): [True: 528, False: 45]
  ------------------
  640|    528|			p2p_dbg(p2p, "Update peer " MACSTR
  641|    528|				" config_methods 0x%x -> 0x%x",
  642|    528|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|    528|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  643|    528|				dev->info.config_methods,
  644|    528|				new_config_methods);
  645|    528|			dev->info.config_methods = new_config_methods;
  646|    528|		}
  647|  1.87k|	}
  648|  2.27k|}
p2p.c:p2p_compare_wfd_info:
  704|  1.84k|{
  705|  1.84k|	if (dev->info.wfd_subelems && msg->wfd_subelems) {
  ------------------
  |  Branch (705:6): [True: 183, False: 1.66k]
  |  Branch (705:32): [True: 174, False: 9]
  ------------------
  706|    174|		if (dev->info.wfd_subelems->used != msg->wfd_subelems->used)
  ------------------
  |  Branch (706:7): [True: 31, False: 143]
  ------------------
  707|     31|			return 1;
  708|       |
  709|    143|		return os_memcmp(dev->info.wfd_subelems->buf,
  ------------------
  |  |  532|    143|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  710|    174|				 msg->wfd_subelems->buf,
  711|    174|				 dev->info.wfd_subelems->used);
  712|    174|	}
  713|  1.67k|	if (dev->info.wfd_subelems || msg->wfd_subelems)
  ------------------
  |  Branch (713:6): [True: 9, False: 1.66k]
  |  Branch (713:32): [True: 216, False: 1.44k]
  ------------------
  714|    225|		return 1;
  715|       |
  716|  1.44k|	return 0;
  717|  1.67k|}
p2p.c:p2p_add_group_clients:
  485|  1.26k|{
  486|  1.26k|	struct p2p_group_info info;
  487|  1.26k|	size_t c;
  488|  1.26k|	struct p2p_device *dev;
  489|       |
  490|  1.26k|	if (gi == NULL)
  ------------------
  |  Branch (490:6): [True: 1.11k, False: 148]
  ------------------
  491|  1.11k|		return 0;
  492|       |
  493|    148|	if (p2p_group_info_parse(gi, gi_len, &info) < 0)
  ------------------
  |  Branch (493:6): [True: 64, False: 84]
  ------------------
  494|     64|		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|     84|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|    148|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|    148|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|    168|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 84, False: 84]
  |  |  ------------------
  |  |   81|     84|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|     84|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  501|     84|		if (ether_addr_equal(dev->member_in_go_iface,
  ------------------
  |  Branch (501:7): [True: 0, False: 84]
  ------------------
  502|     84|				     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|     84|	}
  507|       |
  508|    302|	for (c = 0; c < info.num_clients; c++) {
  ------------------
  |  Branch (508:14): [True: 218, False: 84]
  ------------------
  509|    218|		struct p2p_client_info *cli = &info.client[c];
  510|    218|		if (ether_addr_equal(cli->p2p_device_addr, p2p->cfg->dev_addr))
  ------------------
  |  Branch (510:7): [True: 14, False: 204]
  ------------------
  511|     14|			continue; /* ignore our own entry */
  512|    204|		dev = p2p_get_device(p2p, cli->p2p_device_addr);
  513|    204|		if (dev) {
  ------------------
  |  Branch (513:7): [True: 28, False: 176]
  ------------------
  514|     28|			if (dev->flags & (P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|     28|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|     28|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (514:8): [True: 17, False: 11]
  ------------------
  515|     28|					  P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     28|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     28|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  516|       |				/*
  517|       |				 * Update information since we have not
  518|       |				 * received this directly from the client.
  519|       |				 */
  520|     17|				p2p_copy_client_info(dev, cli);
  521|     17|			} 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;
  ------------------
  |  | 1851|     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;
  ------------------
  |  | 1851|     11|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|     11|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  532|     11|			}
  533|     28|			if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
  ------------------
  |  |  127|     28|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     28|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (533:8): [True: 0, False: 28]
  ------------------
  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|    176|		} else {
  537|    176|			dev = p2p_create_device(p2p, cli->p2p_device_addr);
  538|    176|			if (dev == NULL)
  ------------------
  |  Branch (538:8): [True: 0, False: 176]
  ------------------
  539|      0|				continue;
  540|    176|			dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY;
  ------------------
  |  |  137|    176|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|    176|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  541|    176|			p2p_copy_client_info(dev, cli);
  542|    176|			dev->oper_freq = freq;
  543|    176|			p2p->cfg->dev_found(p2p->cfg->cb_ctx,
  544|    176|					    dev->info.p2p_device_addr,
  545|    176|					    &dev->info, 1);
  546|    176|			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    176|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    176|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    176|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    176|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  547|    176|		}
  548|       |
  549|    204|		os_memcpy(dev->interface_addr, cli->p2p_interface_addr,
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  550|    204|			  ETH_ALEN);
  551|    204|		os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  552|    204|		os_memcpy(dev->member_in_go_dev, go_dev_addr, ETH_ALEN);
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  553|    204|		os_memcpy(dev->member_in_go_iface, go_interface_addr,
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  554|    204|			  ETH_ALEN);
  555|    204|		dev->flags |= P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT;
  ------------------
  |  |  147|    204|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|    204|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  556|    204|	}
  557|       |
  558|     84|	return 0;
  559|    148|}
p2p.c:p2p_copy_client_info:
  466|    193|{
  467|    193|	p2p_copy_filter_devname(dev->info.device_name,
  468|    193|				sizeof(dev->info.device_name),
  469|    193|				cli->dev_name, cli->dev_name_len);
  470|    193|	dev->info.dev_capab = cli->dev_capab;
  471|    193|	dev->info.config_methods = cli->config_methods;
  472|    193|	os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);
  ------------------
  |  |  523|    193|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  473|    193|	dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types;
  474|    193|	if (dev->info.wps_sec_dev_type_list_len > WPS_SEC_DEV_TYPE_MAX_LEN)
  ------------------
  |  |   62|    193|#define WPS_SEC_DEV_TYPE_MAX_LEN 128
  ------------------
  |  Branch (474:6): [True: 3, False: 190]
  ------------------
  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|    193|	os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types,
  ------------------
  |  |  523|    193|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  477|    193|		  dev->info.wps_sec_dev_type_list_len);
  478|    193|}
p2p.c:p2p_update_peer_vendor_elems:
  662|  1.84k|{
  663|  1.84k|	const u8 *pos, *end;
  664|  1.84k|	u8 id, len;
  665|       |
  666|  1.84k|	wpabuf_free(dev->info.vendor_elems);
  667|  1.84k|	dev->info.vendor_elems = NULL;
  668|       |
  669|  1.84k|	end = ies + ies_len;
  670|       |
  671|  11.1M|	for (pos = ies; end - pos > 1; pos += len) {
  ------------------
  |  Branch (671:18): [True: 11.1M, False: 1.81k]
  ------------------
  672|  11.1M|		id = *pos++;
  673|  11.1M|		len = *pos++;
  674|       |
  675|  11.1M|		if (len > end - pos)
  ------------------
  |  Branch (675:7): [True: 0, False: 11.1M]
  ------------------
  676|      0|			break;
  677|       |
  678|  11.1M|		if (id != WLAN_EID_VENDOR_SPECIFIC || len < 3)
  ------------------
  |  |  493|  22.3M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (678:7): [True: 11.1M, False: 55.6k]
  |  Branch (678:41): [True: 1.10k, False: 54.5k]
  ------------------
  679|  11.1M|			continue;
  680|       |
  681|  54.5k|		if (len >= 4) {
  ------------------
  |  Branch (681:7): [True: 53.6k, False: 947]
  ------------------
  682|  53.6k|			u32 type = WPA_GET_BE32(pos);
  683|       |
  684|  53.6k|			if (type == WPA_IE_VENDOR_TYPE ||
  ------------------
  |  | 1511|   107k|#define WPA_IE_VENDOR_TYPE 0x0050f201
  ------------------
  |  Branch (684:8): [True: 708, False: 52.8k]
  ------------------
  685|  52.8k|			    type == WMM_IE_VENDOR_TYPE ||
  ------------------
  |  | 1512|   106k|#define WMM_IE_VENDOR_TYPE 0x0050f202
  ------------------
  |  Branch (685:8): [True: 229, False: 52.6k]
  ------------------
  686|  52.6k|			    type == WPS_IE_VENDOR_TYPE ||
  ------------------
  |  | 1513|   106k|#define WPS_IE_VENDOR_TYPE 0x0050f204
  ------------------
  |  Branch (686:8): [True: 24.6k, False: 28.0k]
  ------------------
  687|  28.0k|			    type == P2P_IE_VENDOR_TYPE ||
  ------------------
  |  | 1515|  81.6k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (687:8): [True: 12.2k, False: 15.7k]
  ------------------
  688|  15.7k|			    type == WFD_IE_VENDOR_TYPE)
  ------------------
  |  | 1517|  15.7k|#define WFD_IE_VENDOR_TYPE 0x506f9a0a
  ------------------
  |  Branch (688:8): [True: 11.1k, False: 4.59k]
  ------------------
  689|  49.0k|				continue;
  690|  53.6k|		}
  691|       |
  692|       |		/* Unknown vendor element - make raw IE data available */
  693|  5.54k|		if (wpabuf_resize(&dev->info.vendor_elems, 2 + len) < 0)
  ------------------
  |  Branch (693:7): [True: 0, False: 5.54k]
  ------------------
  694|      0|			break;
  695|  5.54k|		wpabuf_put_data(dev->info.vendor_elems, pos - 2, 2 + len);
  696|  5.54k|		if (wpabuf_size(dev->info.vendor_elems) > 2000)
  ------------------
  |  Branch (696:7): [True: 29, False: 5.51k]
  ------------------
  697|     29|			break;
  698|  5.54k|	}
  699|  1.84k|}
p2p.c:p2p_device_free:
  943|  1.99k|{
  944|  1.99k|	int i;
  945|       |
  946|  1.99k|	if (p2p->go_neg_peer == dev) {
  ------------------
  |  Branch (946:6): [True: 0, False: 1.99k]
  ------------------
  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.99k|	if (p2p->invite_peer == dev)
  ------------------
  |  Branch (952:6): [True: 0, False: 1.99k]
  ------------------
  953|      0|		p2p->invite_peer = NULL;
  954|  1.99k|	if (p2p->sd_peer == dev)
  ------------------
  |  Branch (954:6): [True: 0, False: 1.99k]
  ------------------
  955|      0|		p2p->sd_peer = NULL;
  956|  1.99k|	if (p2p->pending_client_disc_go == dev)
  ------------------
  |  Branch (956:6): [True: 0, False: 1.99k]
  ------------------
  957|      0|		p2p->pending_client_disc_go = NULL;
  958|       |
  959|       |	/* dev_lost() device, but only if it was previously dev_found() */
  960|  1.99k|	if (dev->flags & P2P_DEV_REPORTED_ONCE)
  ------------------
  |  |  140|  1.99k|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|  1.99k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (960:6): [True: 626, False: 1.36k]
  ------------------
  961|    626|		p2p->cfg->dev_lost(p2p->cfg->cb_ctx,
  962|    626|				   dev->info.p2p_device_addr);
  963|       |
  964|  21.9k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  21.9k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (964:14): [True: 19.9k, False: 1.99k]
  ------------------
  965|  19.9k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  966|  19.9k|		dev->info.wps_vendor_ext[i] = NULL;
  967|  19.9k|	}
  968|       |
  969|  1.99k|	os_free(dev->bootstrap_params);
  ------------------
  |  |  511|  1.99k|#define os_free(p) free((p))
  ------------------
  970|       |
  971|  1.99k|	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.99k|	wpabuf_free(dev->info.wfd_subelems);
  981|  1.99k|	wpabuf_free(dev->info.vendor_elems);
  982|  1.99k|	wpabuf_free(dev->go_neg_conf);
  983|  1.99k|	wpabuf_free(dev->info.p2ps_instance);
  984|       |
  985|  1.99k|	os_free(dev);
  ------------------
  |  |  511|  1.99k|#define os_free(p) free((p))
  ------------------
  986|  1.99k|}
p2p.c:p2p_free_req_dev_types:
 1154|  13.1k|{
 1155|  13.1k|	p2p->num_req_dev_types = 0;
 1156|  13.1k|	os_free(p2p->req_dev_types);
  ------------------
  |  |  511|  13.1k|#define os_free(p) free((p))
  ------------------
 1157|       |	p2p->req_dev_types = NULL;
 1158|  13.1k|}
p2p.c:p2ps_gen_hash:
 1162|  6.57k|{
 1163|  6.57k|	u8 buf[SHA256_MAC_LEN];
 1164|  6.57k|	char str_buf[256];
 1165|  6.57k|	const u8 *adv_array;
 1166|  6.57k|	size_t i, adv_len;
 1167|       |
 1168|  6.57k|	if (!str || !hash)
  ------------------
  |  Branch (1168:6): [True: 0, False: 6.57k]
  |  Branch (1168:14): [True: 0, False: 6.57k]
  ------------------
 1169|      0|		return 0;
 1170|       |
 1171|  6.57k|	if (!str[0]) {
  ------------------
  |  Branch (1171:6): [True: 0, False: 6.57k]
  ------------------
 1172|      0|		os_memcpy(hash, p2p->wild_card_hash, P2PS_HASH_LEN);
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1173|      0|		return 1;
 1174|      0|	}
 1175|       |
 1176|  6.57k|	adv_array = (u8 *) str_buf;
 1177|  6.57k|	adv_len = os_strlen(str);
  ------------------
  |  |  536|  6.57k|#define os_strlen(s) strlen(s)
  ------------------
 1178|  6.57k|	if (adv_len >= sizeof(str_buf))
  ------------------
  |  Branch (1178:6): [True: 0, False: 6.57k]
  ------------------
 1179|      0|		return 0;
 1180|       |
 1181|  98.6k|	for (i = 0; i < adv_len; i++) {
  ------------------
  |  Branch (1181:14): [True: 92.0k, False: 6.57k]
  ------------------
 1182|  92.0k|		if (str[i] >= 'A' && str[i] <= 'Z')
  ------------------
  |  Branch (1182:7): [True: 72.3k, False: 19.7k]
  |  Branch (1182:24): [True: 0, False: 72.3k]
  ------------------
 1183|      0|			str_buf[i] = str[i] - 'A' + 'a';
 1184|  92.0k|		else
 1185|  92.0k|			str_buf[i] = str[i];
 1186|  92.0k|	}
 1187|       |
 1188|  6.57k|	if (sha256_vector(1, &adv_array, &adv_len, buf))
  ------------------
  |  Branch (1188:6): [True: 0, False: 6.57k]
  ------------------
 1189|      0|		return 0;
 1190|       |
 1191|  6.57k|	os_memcpy(hash, buf, P2PS_HASH_LEN);
  ------------------
  |  |  523|  6.57k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1192|  6.57k|	return 1;
 1193|  6.57k|}
p2p.c:p2p_rx_action_public:
 2073|  2.26k|{
 2074|  2.26k|	if (len < 1)
  ------------------
  |  Branch (2074:6): [True: 5, False: 2.25k]
  ------------------
 2075|      5|		return;
 2076|       |
 2077|  2.25k|	switch (data[0]) {
  ------------------
  |  Branch (2077:10): [True: 2.23k, False: 22]
  ------------------
 2078|  2.19k|	case WLAN_PA_VENDOR_SPECIFIC:
  ------------------
  |  |  717|  2.19k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
  |  Branch (2078:2): [True: 2.19k, False: 58]
  ------------------
 2079|  2.19k|		data++;
 2080|  2.19k|		len--;
 2081|  2.19k|		if (len < 4)
  ------------------
  |  Branch (2081:7): [True: 4, False: 2.19k]
  ------------------
 2082|      4|			return;
 2083|  2.19k|		if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
  ------------------
  |  | 1515|  2.19k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (2083:7): [True: 24, False: 2.17k]
  ------------------
 2084|     24|			return;
 2085|       |
 2086|  2.17k|		data += 4;
 2087|  2.17k|		len -= 4;
 2088|       |
 2089|  2.17k|		p2p_rx_p2p_action(p2p, sa, data, len, freq);
 2090|  2.17k|		break;
 2091|      1|	case WLAN_PA_GAS_INITIAL_REQ:
  ------------------
  |  |  718|      1|#define WLAN_PA_GAS_INITIAL_REQ 10
  ------------------
  |  Branch (2091:2): [True: 1, False: 2.25k]
  ------------------
 2092|      1|		p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq);
 2093|      1|		break;
 2094|      1|	case WLAN_PA_GAS_INITIAL_RESP:
  ------------------
  |  |  719|      1|#define WLAN_PA_GAS_INITIAL_RESP 11
  ------------------
  |  Branch (2094:2): [True: 1, False: 2.25k]
  ------------------
 2095|      1|		p2p_rx_gas_initial_resp(p2p, sa, data + 1, len - 1, freq);
 2096|      1|		break;
 2097|     33|	case WLAN_PA_GAS_COMEBACK_REQ:
  ------------------
  |  |  720|     33|#define WLAN_PA_GAS_COMEBACK_REQ 12
  ------------------
  |  Branch (2097:2): [True: 33, False: 2.22k]
  ------------------
 2098|     33|		p2p_rx_gas_comeback_req(p2p, sa, data + 1, len - 1, freq);
 2099|     33|		break;
 2100|      1|	case WLAN_PA_GAS_COMEBACK_RESP:
  ------------------
  |  |  721|      1|#define WLAN_PA_GAS_COMEBACK_RESP 13
  ------------------
  |  Branch (2100:2): [True: 1, False: 2.25k]
  ------------------
 2101|      1|		p2p_rx_gas_comeback_resp(p2p, sa, data + 1, len - 1, freq);
 2102|      1|		break;
 2103|  2.25k|	}
 2104|  2.25k|}
p2p.c:p2p_rx_p2p_action:
 2027|  2.17k|{
 2028|  2.17k|	p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|  2.17k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "RX P2P Public Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|  2.17k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2029|  2.17k|	wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Public Action contents", data, len);
 2030|       |
 2031|  2.17k|	if (len < 1)
  ------------------
  |  Branch (2031:6): [True: 1, False: 2.16k]
  ------------------
 2032|      1|		return;
 2033|       |
 2034|  2.16k|	switch (data[0]) {
 2035|    108|	case P2P_GO_NEG_REQ:
  ------------------
  |  Branch (2035:2): [True: 108, False: 2.06k]
  ------------------
 2036|    108|		p2p_handle_go_neg_req(p2p, sa, data + 1, len - 1, rx_freq);
 2037|    108|		break;
 2038|      2|	case P2P_GO_NEG_RESP:
  ------------------
  |  Branch (2038:2): [True: 2, False: 2.16k]
  ------------------
 2039|      2|		p2p_handle_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq);
 2040|      2|		break;
 2041|      3|	case P2P_GO_NEG_CONF:
  ------------------
  |  Branch (2041:2): [True: 3, False: 2.16k]
  ------------------
 2042|      3|		p2p_handle_go_neg_conf(p2p, sa, data + 1, len - 1, false);
 2043|      3|		break;
 2044|    949|	case P2P_INVITATION_REQ:
  ------------------
  |  Branch (2044:2): [True: 949, False: 1.22k]
  ------------------
 2045|    949|		p2p_handle_invitation_req(p2p, sa, data + 1, len - 1, rx_freq);
 2046|    949|		break;
 2047|      3|	case P2P_INVITATION_RESP:
  ------------------
  |  Branch (2047:2): [True: 3, False: 2.16k]
  ------------------
 2048|      3|		p2p_process_invitation_resp(p2p, sa, data + 1, len - 1);
 2049|      3|		break;
 2050|  1.04k|	case P2P_PROV_DISC_REQ:
  ------------------
  |  Branch (2050:2): [True: 1.04k, False: 1.12k]
  ------------------
 2051|  1.04k|		p2p_handle_prov_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2052|  1.04k|		break;
 2053|     28|	case P2P_PROV_DISC_RESP:
  ------------------
  |  Branch (2053:2): [True: 28, False: 2.14k]
  ------------------
 2054|     28|		p2p_handle_prov_disc_resp(p2p, sa, data + 1, len - 1, rx_freq);
 2055|     28|		break;
 2056|     31|	case P2P_DEV_DISC_REQ:
  ------------------
  |  Branch (2056:2): [True: 31, False: 2.13k]
  ------------------
 2057|     31|		p2p_process_dev_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2058|     31|		break;
 2059|      1|	case P2P_DEV_DISC_RESP:
  ------------------
  |  Branch (2059:2): [True: 1, False: 2.16k]
  ------------------
 2060|      1|		p2p_process_dev_disc_resp(p2p, sa, data + 1, len - 1);
 2061|      1|		break;
 2062|      3|	default:
  ------------------
  |  Branch (2062:2): [True: 3, False: 2.16k]
  ------------------
 2063|      3|		p2p_dbg(p2p, "Unsupported P2P Public Action frame type %d",
 2064|      3|			data[0]);
 2065|      3|		break;
 2066|  2.16k|	}
 2067|  2.16k|}
p2p.c:p2p_add_dev_from_probe_req:
 2193|  6.57k|{
 2194|  6.57k|	struct p2p_message msg;
 2195|  6.57k|	struct p2p_device *dev;
 2196|       |
 2197|  6.57k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  6.57k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2198|  6.57k|	if (p2p_parse_ies(ie, ie_len, &msg) < 0 || msg.p2p_attributes == NULL)
  ------------------
  |  Branch (2198:6): [True: 2.42k, False: 4.14k]
  |  Branch (2198:45): [True: 2.25k, False: 1.88k]
  ------------------
 2199|  4.68k|	{
 2200|  4.68k|		p2p_parse_free(&msg);
 2201|  4.68k|		return; /* not a P2P probe */
 2202|  4.68k|	}
 2203|       |
 2204|  1.88k|	if (msg.ssid == NULL || msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1934|  2.87k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (2204:6): [True: 900, False: 989]
  |  Branch (2204:26): [True: 382, False: 607]
  ------------------
 2205|    607|	    os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    607|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (2205:6): [True: 96, False: 511]
  ------------------
 2206|  1.37k|	    != 0) {
 2207|       |		/* The Probe Request is not part of P2P Device Discovery. It is
 2208|       |		 * not known whether the source address of the frame is the P2P
 2209|       |		 * Device Address or P2P Interface Address. Do not add a new
 2210|       |		 * peer entry based on this frames.
 2211|       |		 */
 2212|  1.37k|		p2p_parse_free(&msg);
 2213|  1.37k|		return;
 2214|  1.37k|	}
 2215|       |
 2216|    511|	dev = p2p_get_device(p2p, addr);
 2217|    511|	if (dev) {
  ------------------
  |  Branch (2217:6): [True: 104, False: 407]
  ------------------
 2218|    104|		if (msg.listen_channel) {
  ------------------
  |  Branch (2218:7): [True: 70, False: 34]
  ------------------
 2219|     70|			int freq;
 2220|       |
 2221|     70|			if (dev->country[0] == 0)
  ------------------
  |  Branch (2221:8): [True: 70, False: 0]
  ------------------
 2222|     70|				os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|     70|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2223|       |
 2224|     70|			freq = p2p_channel_to_freq(msg.listen_channel[3],
 2225|     70|						   msg.listen_channel[4]);
 2226|       |
 2227|     70|			if (freq > 0 && dev->listen_freq != freq) {
  ------------------
  |  Branch (2227:8): [True: 48, False: 22]
  |  Branch (2227:20): [True: 47, False: 1]
  ------------------
 2228|     47|				p2p_dbg(p2p,
 2229|     47|					"Updated peer " MACSTR " Listen channel (Probe Request): %d -> %d MHz",
 2230|     47|					MAC2STR(addr), dev->listen_freq, freq);
  ------------------
  |  |  447|     47|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2231|     47|				dev->listen_freq = freq;
 2232|     47|			}
 2233|     70|		}
 2234|       |
 2235|    104|		p2p_update_peer_6ghz_capab(dev, &msg);
 2236|    104|		os_get_reltime(&dev->last_seen);
 2237|    104|		p2p_parse_free(&msg);
 2238|    104|		return; /* already known */
 2239|    104|	}
 2240|       |
 2241|    407|	dev = p2p_create_device(p2p, addr);
 2242|    407|	if (dev == NULL) {
  ------------------
  |  Branch (2242:6): [True: 0, False: 407]
  ------------------
 2243|      0|		p2p_parse_free(&msg);
 2244|      0|		return;
 2245|      0|	}
 2246|       |
 2247|    407|	os_get_reltime(&dev->last_seen);
 2248|    407|	dev->flags |= P2P_DEV_PROBE_REQ_ONLY;
  ------------------
  |  |  127|    407|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    407|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2249|       |
 2250|    407|	if (msg.listen_channel) {
  ------------------
  |  Branch (2250:6): [True: 326, False: 81]
  ------------------
 2251|    326|		os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|    326|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2252|    326|		dev->listen_freq = p2p_channel_to_freq(msg.listen_channel[3],
 2253|    326|						       msg.listen_channel[4]);
 2254|    326|	}
 2255|       |
 2256|    407|	p2p_copy_wps_info(p2p, dev, 1, &msg);
 2257|       |
 2258|    407|	if (msg.wfd_subelems) {
  ------------------
  |  Branch (2258:6): [True: 32, False: 375]
  ------------------
 2259|     32|		wpabuf_free(dev->info.wfd_subelems);
 2260|     32|		dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 2261|     32|	}
 2262|       |
 2263|    407|	p2p_parse_free(&msg);
 2264|       |
 2265|    407|	p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR
 2266|    407|		" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
 2267|    407|		MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
  ------------------
  |  |  447|    407|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2268|    407|		dev->info.group_capab, dev->info.device_name,
 2269|    407|		dev->listen_freq);
 2270|    407|}
p2p.c:p2p_reply_probe:
 2500|  6.57k|{
 2501|  6.57k|	struct ieee802_11_elems elems;
 2502|  6.57k|	struct wpabuf *buf;
 2503|  6.57k|	struct p2p_message msg;
 2504|  6.57k|	struct wpabuf *ies;
 2505|       |
 2506|  6.57k|	if (ieee802_11_parse_elems((u8 *) ie, ie_len, &elems, 0) ==
  ------------------
  |  Branch (2506:6): [True: 985, False: 5.58k]
  ------------------
 2507|  6.57k|	    ParseFailed) {
 2508|       |		/* Ignore invalid Probe Request frames */
 2509|    985|		p2p_dbg(p2p, "Could not parse Probe Request frame - ignore it");
 2510|    985|		return P2P_PREQ_MALFORMED;
 2511|    985|	}
 2512|       |
 2513|  5.58k|	if (elems.p2p == NULL) {
  ------------------
  |  Branch (2513:6): [True: 3.05k, False: 2.53k]
  ------------------
 2514|       |		/* not a P2P probe - ignore it */
 2515|  3.05k|		p2p_dbg(p2p, "Not a P2P probe - ignore it");
 2516|  3.05k|		return P2P_PREQ_NOT_P2P;
 2517|  3.05k|	}
 2518|       |
 2519|  2.53k|	if (dst && !is_broadcast_ether_addr(dst) &&
  ------------------
  |  Branch (2519:6): [True: 2.53k, False: 0]
  |  Branch (2519:13): [True: 2.53k, False: 0]
  ------------------
 2520|  2.53k|	    !ether_addr_equal(dst, p2p->cfg->dev_addr)) {
  ------------------
  |  Branch (2520:6): [True: 2.53k, False: 0]
  ------------------
 2521|       |		/* Not sent to the broadcast address or our P2P Device Address
 2522|       |		 */
 2523|  2.53k|		p2p_dbg(p2p, "Probe Req DA " MACSTR " not ours - ignore it",
 2524|  2.53k|			MAC2STR(dst));
  ------------------
  |  |  447|  2.53k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2525|  2.53k|		return P2P_PREQ_NOT_PROCESSED;
 2526|  2.53k|	}
 2527|       |
 2528|      0|	if (bssid && !is_broadcast_ether_addr(bssid)) {
  ------------------
  |  Branch (2528:6): [True: 0, False: 0]
  |  Branch (2528:15): [True: 0, False: 0]
  ------------------
 2529|       |		/* Not sent to the Wildcard BSSID */
 2530|      0|		p2p_dbg(p2p, "Probe Req BSSID " MACSTR " not wildcard - ignore it",
 2531|      0|			MAC2STR(bssid));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2532|      0|		return P2P_PREQ_NOT_PROCESSED;
 2533|      0|	}
 2534|       |
 2535|      0|	if (elems.ssid == NULL || elems.ssid_len != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1934|      0|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (2535:6): [True: 0, False: 0]
  |  Branch (2535:28): [True: 0, False: 0]
  ------------------
 2536|      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 (2536:6): [True: 0, False: 0]
  ------------------
 2537|      0|	    0) {
 2538|       |		/* not using P2P Wildcard SSID - ignore */
 2539|      0|		p2p_dbg(p2p, "Probe Req not using P2P Wildcard SSID - ignore it");
 2540|      0|		return P2P_PREQ_NOT_PROCESSED;
 2541|      0|	}
 2542|       |
 2543|      0|	if (supp_rates_11b_only(&elems)) {
  ------------------
  |  Branch (2543:6): [True: 0, False: 0]
  ------------------
 2544|       |		/* Indicates support for 11b rates only */
 2545|      0|		p2p_dbg(p2p, "Probe Req with 11b rates only supported - ignore it");
 2546|      0|		return P2P_PREQ_NOT_P2P;
 2547|      0|	}
 2548|       |
 2549|      0|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2550|      0|	if (p2p_parse_ies(ie, ie_len, &msg) < 0) {
  ------------------
  |  Branch (2550:6): [True: 0, False: 0]
  ------------------
 2551|       |		/* Could not parse P2P attributes */
 2552|      0|		p2p_dbg(p2p, "Could not parse P2P attributes in Probe Req - ignore it");
 2553|      0|		return P2P_PREQ_NOT_P2P;
 2554|      0|	}
 2555|       |
 2556|      0|	if (msg.service_hash && msg.service_hash_count) {
  ------------------
  |  Branch (2556:6): [True: 0, False: 0]
  |  Branch (2556:26): [True: 0, False: 0]
  ------------------
 2557|      0|		const u8 *hash = msg.service_hash;
 2558|      0|		u8 i;
 2559|      0|		int p2ps_svc_found = 0;
 2560|       |
 2561|      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",
 2562|      0|			p2p->in_listen, p2p->drv_in_listen, rx_freq,
 2563|      0|			p2p->cfg->channel, p2p->pending_listen_freq);
 2564|       |
 2565|      0|		if (!p2p->in_listen && !p2p->drv_in_listen &&
  ------------------
  |  Branch (2565:7): [True: 0, False: 0]
  |  Branch (2565:26): [True: 0, False: 0]
  ------------------
 2566|      0|		    p2p->pending_listen_freq && rx_freq &&
  ------------------
  |  Branch (2566:7): [True: 0, False: 0]
  |  Branch (2566:35): [True: 0, False: 0]
  ------------------
 2567|      0|		    rx_freq != p2p->pending_listen_freq) {
  ------------------
  |  Branch (2567:7): [True: 0, False: 0]
  ------------------
 2568|      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",
 2569|      0|				rx_freq, p2p->pending_listen_freq);
 2570|      0|			p2p_parse_free(&msg);
 2571|      0|			return P2P_PREQ_NOT_LISTEN;
 2572|      0|		}
 2573|       |
 2574|      0|		for (i = 0; i < msg.service_hash_count; i++) {
  ------------------
  |  Branch (2574:15): [True: 0, False: 0]
  ------------------
 2575|      0|			if (p2p_service_find_asp(p2p, hash)) {
  ------------------
  |  Branch (2575:8): [True: 0, False: 0]
  ------------------
 2576|      0|				p2p_dbg(p2p, "Service Hash match found: "
 2577|      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]
  ------------------
 2578|      0|				p2ps_svc_found = 1;
 2579|      0|				break;
 2580|      0|			}
 2581|      0|			hash += P2PS_HASH_LEN;
  ------------------
  |  |   35|      0|#define P2PS_HASH_LEN 6
  ------------------
 2582|      0|		}
 2583|       |
 2584|       |		/* Probed hash unknown */
 2585|      0|		if (!p2ps_svc_found) {
  ------------------
  |  Branch (2585:7): [True: 0, False: 0]
  ------------------
 2586|      0|			p2p_dbg(p2p, "No Service Hash match found");
 2587|      0|			p2p_parse_free(&msg);
 2588|      0|			return P2P_PREQ_NOT_PROCESSED;
 2589|      0|		}
 2590|      0|	} else {
 2591|       |		/* This is not a P2PS Probe Request */
 2592|      0|		p2p_dbg(p2p, "No P2PS Hash in Probe Request");
 2593|       |
 2594|      0|		if (!p2p->in_listen || !p2p->drv_in_listen) {
  ------------------
  |  Branch (2594:7): [True: 0, False: 0]
  |  Branch (2594:26): [True: 0, False: 0]
  ------------------
 2595|       |			/* not in Listen state - ignore Probe Request */
 2596|      0|			p2p_dbg(p2p, "Not in Listen state (in_listen=%d drv_in_listen=%d) - ignore Probe Request",
 2597|      0|				p2p->in_listen, p2p->drv_in_listen);
 2598|      0|			p2p_parse_free(&msg);
 2599|      0|			return P2P_PREQ_NOT_LISTEN;
 2600|      0|		}
 2601|      0|	}
 2602|       |
 2603|      0|	if (msg.device_id &&
  ------------------
  |  Branch (2603:6): [True: 0, False: 0]
  ------------------
 2604|      0|	    !ether_addr_equal(msg.device_id, p2p->cfg->dev_addr)) {
  ------------------
  |  Branch (2604:6): [True: 0, False: 0]
  ------------------
 2605|       |		/* Device ID did not match */
 2606|      0|		p2p_dbg(p2p, "Probe Req requested Device ID " MACSTR " did not match - ignore it",
 2607|      0|			MAC2STR(msg.device_id));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2608|      0|		p2p_parse_free(&msg);
 2609|      0|		return P2P_PREQ_NOT_PROCESSED;
 2610|      0|	}
 2611|       |
 2612|       |	/* Check Requested Device Type match */
 2613|      0|	if (msg.wps_attributes &&
  ------------------
  |  Branch (2613:6): [True: 0, False: 0]
  ------------------
 2614|      0|	    !p2p_match_dev_type(p2p, msg.wps_attributes)) {
  ------------------
  |  Branch (2614:6): [True: 0, False: 0]
  ------------------
 2615|       |		/* No match with Requested Device Type */
 2616|      0|		p2p_dbg(p2p, "Probe Req requested Device Type did not match - ignore it");
 2617|      0|		p2p_parse_free(&msg);
 2618|      0|		return P2P_PREQ_NOT_PROCESSED;
 2619|      0|	}
 2620|       |
 2621|      0|	if (!p2p->cfg->send_probe_resp) {
  ------------------
  |  Branch (2621:6): [True: 0, False: 0]
  ------------------
 2622|       |		/* Response generated elsewhere */
 2623|      0|		p2p_dbg(p2p, "Probe Resp generated elsewhere - do not generate additional response");
 2624|      0|		p2p_parse_free(&msg);
 2625|      0|		return P2P_PREQ_NOT_PROCESSED;
 2626|      0|	}
 2627|       |
 2628|      0|	p2p_dbg(p2p, "Reply to P2P Probe Request in Listen state");
 2629|       |
 2630|       |	/*
 2631|       |	 * We do not really have a specific BSS that this frame is advertising,
 2632|       |	 * so build a frame that has some information in valid format. This is
 2633|       |	 * really only used for discovery purposes, not to learn exact BSS
 2634|       |	 * parameters.
 2635|       |	 */
 2636|      0|	ies = p2p_build_probe_resp_ies(p2p, msg.service_hash,
 2637|      0|				       msg.service_hash_count);
 2638|      0|	p2p_parse_free(&msg);
 2639|      0|	if (ies == NULL)
  ------------------
  |  Branch (2639:6): [True: 0, False: 0]
  ------------------
 2640|      0|		return P2P_PREQ_NOT_PROCESSED;
 2641|       |
 2642|      0|	buf = wpabuf_alloc(200 + wpabuf_len(ies));
 2643|      0|	if (buf == NULL) {
  ------------------
  |  Branch (2643:6): [True: 0, False: 0]
  ------------------
 2644|      0|		wpabuf_free(ies);
 2645|      0|		return P2P_PREQ_NOT_PROCESSED;
 2646|      0|	}
 2647|       |
 2648|      0|	if (p2p_build_probe_resp_buf(p2p, buf, ies, addr, rx_freq)) {
  ------------------
  |  Branch (2648:6): [True: 0, False: 0]
  ------------------
 2649|      0|		wpabuf_free(ies);
 2650|      0|		wpabuf_free(buf);
 2651|      0|		return P2P_PREQ_NOT_PROCESSED;
 2652|      0|	}
 2653|       |
 2654|      0|	wpabuf_free(ies);
 2655|       |
 2656|      0|	p2p->cfg->send_probe_resp(p2p->cfg->cb_ctx, buf, rx_freq);
 2657|       |
 2658|      0|	wpabuf_free(buf);
 2659|       |
 2660|      0|	return P2P_PREQ_PROCESSED;
 2661|      0|}
p2p.c:p2p_pairing_info_init:
 3129|  6.57k|{
 3130|  6.57k|	struct p2p_pairing_info *pairing_info;
 3131|       |
 3132|  6.57k|	if (p2p->cfg->pairing_config.dik_len > DEVICE_IDENTITY_KEY_MAX_LEN)
  ------------------
  |  |   16|  6.57k|#define DEVICE_IDENTITY_KEY_MAX_LEN 64
  ------------------
  |  Branch (3132:6): [True: 0, False: 6.57k]
  ------------------
 3133|      0|		return -1;
 3134|       |
 3135|  6.57k|	pairing_info = os_zalloc(sizeof(struct p2p_pairing_info));
 3136|  6.57k|	if (!pairing_info)
  ------------------
  |  Branch (3136:6): [True: 0, False: 6.57k]
  ------------------
 3137|      0|		return -1;
 3138|       |
 3139|  6.57k|	pairing_info->enable_pairing_setup =
 3140|  6.57k|		p2p->cfg->pairing_config.enable_pairing_setup;
 3141|  6.57k|	pairing_info->enable_pairing_cache =
 3142|  6.57k|		p2p->cfg->pairing_config.enable_pairing_cache;
 3143|  6.57k|	pairing_info->supported_bootstrap =
 3144|  6.57k|		p2p->cfg->pairing_config.bootstrap_methods;
 3145|       |
 3146|  6.57k|	pairing_info->dev_ik.cipher_version =
 3147|  6.57k|		p2p->cfg->pairing_config.dik_cipher;
 3148|  6.57k|	pairing_info->dev_ik.dik_len = p2p->cfg->pairing_config.dik_len;
 3149|  6.57k|	os_memcpy(pairing_info->dev_ik.dik_data,
  ------------------
  |  |  523|  6.57k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3150|  6.57k|		  p2p->cfg->pairing_config.dik_data,
 3151|  6.57k|		  p2p->cfg->pairing_config.dik_len);
 3152|  6.57k|	pairing_info->dev_ik.expiration = 24; /* hours */
 3153|       |
 3154|  6.57k|	p2p_pairing_info_deinit(p2p);
 3155|       |
 3156|  6.57k|	p2p->pairing_info = pairing_info;
 3157|       |#ifdef CONFIG_PASN
 3158|       |	p2p->initiator_pmksa = pasn_initiator_pmksa_cache_init();
 3159|       |	p2p->responder_pmksa = pasn_responder_pmksa_cache_init();
 3160|       |#endif /* CONFIG_PASN */
 3161|       |
 3162|  6.57k|	return 0;
 3163|  6.57k|}
p2p.c:p2p_pairing_info_deinit:
 3119|  13.1k|{
 3120|       |#ifdef CONFIG_PASN
 3121|       |	pasn_initiator_pmksa_cache_deinit(p2p->initiator_pmksa);
 3122|       |	pasn_responder_pmksa_cache_deinit(p2p->responder_pmksa);
 3123|       |#endif /* CONFIG_PASN */
 3124|  13.1k|	os_free(p2p->pairing_info);
  ------------------
  |  |  511|  13.1k|#define os_free(p) free((p))
  ------------------
 3125|  13.1k|}
p2p.c:p2p_run_after_scan:
 1109|  6.57k|{
 1110|  6.57k|	struct p2p_device *dev;
 1111|  6.57k|	enum p2p_after_scan op;
 1112|       |
 1113|  6.57k|	op = p2p->start_after_scan;
 1114|  6.57k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1115|  6.57k|	switch (op) {
  ------------------
  |  Branch (1115:10): [True: 6.57k, False: 0]
  ------------------
 1116|  6.57k|	case P2P_AFTER_SCAN_NOTHING:
  ------------------
  |  Branch (1116:2): [True: 6.57k, False: 0]
  ------------------
 1117|  6.57k|		break;
 1118|      0|	case P2P_AFTER_SCAN_LISTEN:
  ------------------
  |  Branch (1118:2): [True: 0, False: 6.57k]
  ------------------
 1119|      0|		p2p_dbg(p2p, "Start previously requested Listen state");
 1120|      0|		p2p_listen(p2p, p2p->pending_listen_sec * 1000 +
 1121|      0|			   p2p->pending_listen_usec / 1000);
 1122|      0|		return 1;
 1123|      0|	case P2P_AFTER_SCAN_CONNECT:
  ------------------
  |  Branch (1123:2): [True: 0, False: 6.57k]
  ------------------
 1124|      0|		p2p_dbg(p2p, "Start previously requested connect with " MACSTR,
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1125|      0|			MAC2STR(p2p->after_scan_peer));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1126|      0|		dev = p2p_get_device(p2p, p2p->after_scan_peer);
 1127|      0|		if (dev == NULL) {
  ------------------
  |  Branch (1127:7): [True: 0, False: 0]
  ------------------
 1128|      0|			p2p_dbg(p2p, "Peer not known anymore");
 1129|      0|			break;
 1130|      0|		}
 1131|      0|		p2p_connect_send(p2p, dev);
 1132|      0|		return 1;
 1133|  6.57k|	}
 1134|       |
 1135|  6.57k|	return 0;
 1136|  6.57k|}
p2p.c:p2p_process_presence_req:
 4765|      1|{
 4766|      1|	struct p2p_message msg;
 4767|      1|	u8 status;
 4768|      1|	struct wpabuf *resp;
 4769|      1|	size_t g;
 4770|      1|	struct p2p_group *group = NULL;
 4771|      1|	int parsed = 0;
 4772|      1|	u8 noa[50];
 4773|      1|	int noa_len;
 4774|       |
 4775|      1|	p2p_dbg(p2p, "Received P2P Action - P2P Presence Request");
 4776|       |
 4777|      1|	for (g = 0; g < p2p->num_groups; g++) {
  ------------------
  |  Branch (4777:14): [True: 0, False: 1]
  ------------------
 4778|      0|		if (ether_addr_equal(
  ------------------
  |  Branch (4778:7): [True: 0, False: 0]
  ------------------
 4779|      0|			    da, p2p_group_get_interface_addr(p2p->groups[g]))) {
 4780|      0|			group = p2p->groups[g];
 4781|      0|			break;
 4782|      0|		}
 4783|      0|	}
 4784|      1|	if (group == NULL) {
  ------------------
  |  Branch (4784:6): [True: 1, False: 0]
  ------------------
 4785|      1|		p2p_dbg(p2p, "Ignore P2P Presence Request for unknown group "
 4786|      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]
  ------------------
 4787|      1|		return;
 4788|      1|	}
 4789|       |
 4790|      0|	if (p2p_parse(data, len, &msg) < 0) {
  ------------------
  |  Branch (4790:6): [True: 0, False: 0]
  ------------------
 4791|      0|		p2p_dbg(p2p, "Failed to parse P2P Presence Request");
 4792|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 4793|      0|		goto fail;
 4794|      0|	}
 4795|      0|	parsed = 1;
 4796|       |
 4797|      0|	if (msg.noa == NULL) {
  ------------------
  |  Branch (4797:6): [True: 0, False: 0]
  ------------------
 4798|      0|		p2p_dbg(p2p, "No NoA attribute in P2P Presence Request");
 4799|      0|		status = P2P_SC_FAIL_INVALID_PARAMS;
 4800|      0|		goto fail;
 4801|      0|	}
 4802|       |
 4803|      0|	status = p2p_group_presence_req(group, sa, msg.noa, msg.noa_len);
 4804|       |
 4805|      0|fail:
 4806|      0|	if (p2p->cfg->get_noa)
  ------------------
  |  Branch (4806:6): [True: 0, False: 0]
  ------------------
 4807|      0|		noa_len = p2p->cfg->get_noa(p2p->cfg->cb_ctx, da, noa,
 4808|      0|					    sizeof(noa));
 4809|      0|	else
 4810|      0|		noa_len = -1;
 4811|      0|	resp = p2p_build_presence_resp(status, noa_len > 0 ? noa : NULL,
  ------------------
  |  Branch (4811:41): [True: 0, False: 0]
  ------------------
 4812|      0|				       noa_len > 0 ? noa_len : 0,
  ------------------
  |  Branch (4812:12): [True: 0, False: 0]
  ------------------
 4813|      0|				       msg.dialog_token);
 4814|      0|	if (parsed)
  ------------------
  |  Branch (4814:6): [True: 0, False: 0]
  ------------------
 4815|      0|		p2p_parse_free(&msg);
 4816|      0|	if (resp == NULL)
  ------------------
  |  Branch (4816:6): [True: 0, False: 0]
  ------------------
 4817|      0|		return;
 4818|       |
 4819|      0|	p2p->pending_action_state = P2P_NO_PENDING_ACTION;
 4820|      0|	if (p2p_send_action(p2p, rx_freq, sa, da, da,
  ------------------
  |  Branch (4820:6): [True: 0, False: 0]
  ------------------
 4821|      0|			    wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
 4822|      0|		p2p_dbg(p2p, "Failed to send Action frame");
 4823|      0|	}
 4824|      0|	wpabuf_free(resp);
 4825|      0|}
p2p.c:p2p_process_presence_resp:
 4830|    588|{
 4831|    588|	struct p2p_message msg;
 4832|       |
 4833|    588|	p2p_dbg(p2p, "Received P2P Action - P2P Presence Response");
 4834|       |
 4835|    588|	if (p2p_parse(data, len, &msg) < 0) {
  ------------------
  |  Branch (4835:6): [True: 255, False: 333]
  ------------------
 4836|    255|		p2p_dbg(p2p, "Failed to parse P2P Presence Response");
 4837|    255|		return;
 4838|    255|	}
 4839|       |
 4840|    333|	if (msg.status == NULL || msg.noa == NULL) {
  ------------------
  |  Branch (4840:6): [True: 324, False: 9]
  |  Branch (4840:28): [True: 3, False: 6]
  ------------------
 4841|    327|		p2p_dbg(p2p, "No Status or NoA attribute in P2P Presence Response");
 4842|    327|		p2p_parse_free(&msg);
 4843|    327|		return;
 4844|    327|	}
 4845|       |
 4846|      6|	if (p2p->cfg->presence_resp) {
  ------------------
  |  Branch (4846:6): [True: 0, False: 6]
  ------------------
 4847|      0|		p2p->cfg->presence_resp(p2p->cfg->cb_ctx, sa, *msg.status,
 4848|      0|					msg.noa, msg.noa_len);
 4849|      0|	}
 4850|       |
 4851|      6|	if (*msg.status) {
  ------------------
  |  Branch (4851:6): [True: 5, False: 1]
  ------------------
 4852|      5|		p2p_dbg(p2p, "P2P Presence Request was rejected: status %u",
 4853|      5|			*msg.status);
 4854|      5|		p2p_parse_free(&msg);
 4855|      5|		return;
 4856|      5|	}
 4857|       |
 4858|      1|	p2p_dbg(p2p, "P2P Presence Request was accepted");
 4859|      1|	wpa_hexdump(MSG_DEBUG, "P2P: P2P Presence Response - NoA",
 4860|      1|		    msg.noa, msg.noa_len);
 4861|       |	/* TODO: process NoA */
 4862|      1|	p2p_parse_free(&msg);
 4863|      1|}

p2p_buf_add_public_action_hdr:
   32|  1.68k|{
   33|  1.68k|	wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC);
  ------------------
  |  |  670|  1.68k|#define WLAN_ACTION_PUBLIC 4
  ------------------
   34|  1.68k|	wpabuf_put_u8(buf, WLAN_PA_VENDOR_SPECIFIC);
  ------------------
  |  |  717|  1.68k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
   35|  1.68k|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|  1.68k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   36|       |
   37|  1.68k|	wpabuf_put_u8(buf, subtype); /* OUI Subtype */
   38|  1.68k|	wpabuf_put_u8(buf, dialog_token);
   39|  1.68k|	wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", dialog_token);
   40|  1.68k|}
p2p_buf_add_ie_hdr:
   44|    715|{
   45|    715|	u8 *len;
   46|       |
   47|       |	/* P2P IE header */
   48|    715|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|    715|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   49|    715|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   50|    715|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|    715|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   51|    715|	wpa_printf(MSG_DEBUG, "P2P: * P2P IE header");
   52|    715|	return len;
   53|    715|}
p2p_buf_update_ie_hdr:
   57|  1.52k|{
   58|       |	/* Update P2P/P2P2 IE Length */
   59|  1.52k|	*len = (u8 *) wpabuf_put(buf, 0) - len - 1;
   60|  1.52k|}
p2p_buf_add_p2p2_ie_hdr:
   64|     43|{
   65|     43|	u8 *len;
   66|       |
   67|       |	/* P2P2 IE header */
   68|     43|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|     43|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   69|     43|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   70|     43|	wpabuf_put_be32(buf, P2P2_IE_VENDOR_TYPE);
  ------------------
  |  | 1516|     43|#define P2P2_IE_VENDOR_TYPE 0x506f9a28
  ------------------
   71|     43|	wpa_printf(MSG_DEBUG, "P2P: * P2P2 IE header");
   72|     43|	return len;
   73|     43|}
p2p_buf_add_capability:
   77|     93|{
   78|       |	/* P2P Capability */
   79|     93|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY);
   80|     93|	wpabuf_put_le16(buf, 2);
   81|     93|	wpabuf_put_u8(buf, dev_capab); /* Device Capabilities */
   82|     93|	wpabuf_put_u8(buf, group_capab); /* Group Capabilities */
   83|     93|	wpa_printf(MSG_DEBUG, "P2P: * Capability dev=%02x group=%02x",
   84|     93|		   dev_capab, group_capab);
   85|     93|}
p2p_buf_add_go_intent:
   89|     91|{
   90|       |	/* Group Owner Intent */
   91|     91|	wpabuf_put_u8(buf, P2P_ATTR_GROUP_OWNER_INTENT);
   92|     91|	wpabuf_put_le16(buf, 1);
   93|     91|	wpabuf_put_u8(buf, go_intent);
   94|     91|	wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u Tie breaker %u",
   95|     91|		   go_intent >> 1, go_intent & 0x01);
   96|     91|}
p2p_buf_add_operating_channel:
  115|     91|{
  116|       |	/* Operating Channel */
  117|     91|	wpabuf_put_u8(buf, P2P_ATTR_OPERATING_CHANNEL);
  118|     91|	wpabuf_put_le16(buf, 5);
  119|     91|	wpabuf_put_data(buf, country, 3);
  120|     91|	wpabuf_put_u8(buf, reg_class); /* Regulatory Class */
  121|     91|	wpabuf_put_u8(buf, channel); /* Channel Number */
  122|     91|	wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: Regulatory Class %u "
  123|     91|		   "Channel %u", reg_class, channel);
  124|     91|}
p2p_buf_add_channel_list:
  169|     91|{
  170|     91|	u8 *len;
  171|     91|	size_t i;
  172|       |
  173|       |	/* Channel List */
  174|     91|	wpabuf_put_u8(buf, P2P_ATTR_CHANNEL_LIST);
  175|     91|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  176|     91|	wpabuf_put_data(buf, country, 3); /* Country String */
  177|       |
  178|     91|	for (i = 0; i < chan->reg_classes; i++) {
  ------------------
  |  Branch (178:14): [True: 0, False: 91]
  ------------------
  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|     91|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  190|     91|	wpa_hexdump(MSG_DEBUG, "P2P: * Channel List",
  191|     91|		    len + 2, (u8 *) wpabuf_put(buf, 0) - len - 2);
  192|     91|}
p2p_buf_add_status:
  196|  1.64k|{
  197|       |	/* Status */
  198|  1.64k|	wpabuf_put_u8(buf, P2P_ATTR_STATUS);
  199|  1.64k|	wpabuf_put_le16(buf, 1);
  200|  1.64k|	wpabuf_put_u8(buf, status);
  201|  1.64k|	wpa_printf(MSG_DEBUG, "P2P: * Status: %d", status);
  202|  1.64k|}
p2p_buf_add_device_info:
  207|     93|{
  208|     93|	u8 *len;
  209|     93|	u16 methods;
  210|     93|	size_t nlen, i;
  211|       |
  212|       |	/* P2P Device Info */
  213|     93|	wpabuf_put_u8(buf, P2P_ATTR_DEVICE_INFO);
  214|     93|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  215|       |
  216|       |	/* P2P Device address */
  217|     93|	wpabuf_put_data(buf, p2p->cfg->dev_addr, ETH_ALEN);
  ------------------
  |  |  344|     93|#define ETH_ALEN 6
  ------------------
  218|       |
  219|       |	/* Config Methods */
  220|     93|	methods = 0;
  221|     93|	if (peer && peer->wps_method != WPS_NOT_READY) {
  ------------------
  |  Branch (221:6): [True: 37, False: 56]
  |  Branch (221:14): [True: 0, False: 37]
  ------------------
  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|     93|	} else if (p2p->cfg->config_methods) {
  ------------------
  |  Branch (229:13): [True: 0, False: 93]
  ------------------
  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|     93|	} else {
  234|     93|		methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|     93|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  235|     93|		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|     93|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|     93|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  236|     93|		methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     93|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  237|     93|	}
  238|     93|	wpabuf_put_be16(buf, methods);
  239|       |
  240|       |	/* Primary Device Type */
  241|     93|	wpabuf_put_data(buf, p2p->cfg->pri_dev_type,
  242|     93|			sizeof(p2p->cfg->pri_dev_type));
  243|       |
  244|       |	/* Number of Secondary Device Types */
  245|     93|	wpabuf_put_u8(buf, p2p->cfg->num_sec_dev_types);
  246|       |
  247|       |	/* Secondary Device Type List */
  248|     93|	for (i = 0; i < p2p->cfg->num_sec_dev_types; i++)
  ------------------
  |  Branch (248:14): [True: 0, False: 93]
  ------------------
  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|     93|	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: 93]
  ------------------
  254|     93|	wpabuf_put_be16(buf, ATTR_DEV_NAME);
  255|     93|	wpabuf_put_be16(buf, nlen);
  256|     93|	wpabuf_put_data(buf, p2p->cfg->dev_name, nlen);
  257|       |
  258|       |	/* Update attribute length */
  259|     93|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  260|     93|	wpa_printf(MSG_DEBUG, "P2P: * Device Info");
  261|     93|}
p2p_buf_add_config_timeout:
  276|    888|{
  277|       |	/* Configuration Timeout */
  278|    888|	wpabuf_put_u8(buf, P2P_ATTR_CONFIGURATION_TIMEOUT);
  279|    888|	wpabuf_put_le16(buf, 2);
  280|    888|	wpabuf_put_u8(buf, go_timeout);
  281|    888|	wpabuf_put_u8(buf, client_timeout);
  282|    888|	wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout: GO %d (*10ms)  "
  283|    888|		   "client %d (*10ms)", go_timeout, client_timeout);
  284|    888|}
p2p_buf_add_intended_addr:
  288|     91|{
  289|       |	/* Intended P2P Interface Address */
  290|     91|	wpabuf_put_u8(buf, P2P_ATTR_INTENDED_INTERFACE_ADDR);
  291|     91|	wpabuf_put_le16(buf, ETH_ALEN);
  ------------------
  |  |  344|     91|#define ETH_ALEN 6
  ------------------
  292|     91|	wpabuf_put_data(buf, interface_addr, ETH_ALEN);
  ------------------
  |  |  344|     91|#define ETH_ALEN 6
  ------------------
  293|     91|	wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address " MACSTR,
  ------------------
  |  |  448|     91|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  294|     91|		   MAC2STR(interface_addr));
  ------------------
  |  |  447|     91|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  295|     91|}
p2p_buf_add_pcea:
  740|     43|{
  741|     43|	u8 *len;
  742|     43|	u16 capability_info = 0;
  743|       |
  744|       |	/* P2P Capability Extension */
  745|     43|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY_EXTENSION);
  746|       |	/* Length to be filled */
  747|     43|	len = wpabuf_put(buf, 2);
  748|       |
  749|     43|	if (!p2p->cfg->p2p_6ghz_disable)
  ------------------
  |  Branch (749:6): [True: 43, False: 0]
  ------------------
  750|     43|		capability_info |= P2P_PCEA_6GHZ;
  ------------------
  |  | 1870|     43|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  751|       |
  752|     43|	if (p2p->cfg->reg_info)
  ------------------
  |  Branch (752:6): [True: 0, False: 43]
  ------------------
  753|      0|		capability_info |= P2P_PCEA_REG_INFO;
  ------------------
  |  | 1871|      0|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  754|       |
  755|     43|	if (p2p->cfg->dfs_owner)
  ------------------
  |  Branch (755:6): [True: 0, False: 43]
  ------------------
  756|      0|		capability_info |= P2P_PCEA_DFS_OWNER;
  ------------------
  |  | 1872|      0|#define P2P_PCEA_DFS_OWNER BIT(6)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  757|       |
  758|     43|	if (p2p->cfg->chan_switch_req_enable)
  ------------------
  |  Branch (758:6): [True: 0, False: 43]
  ------------------
  759|      0|		capability_info |= P2P_PCEA_CLI_REQ_CS;
  ------------------
  |  | 1873|      0|#define P2P_PCEA_CLI_REQ_CS BIT(7)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  760|       |
  761|     43|	if (p2p->cfg->pairing_config.pairing_capable)
  ------------------
  |  Branch (761:6): [True: 0, False: 43]
  ------------------
  762|      0|		capability_info |= P2P_PCEA_PAIRING_CAPABLE;
  ------------------
  |  | 1874|      0|#define P2P_PCEA_PAIRING_CAPABLE BIT(8)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  763|       |
  764|     43|	if (p2p->cfg->pairing_config.enable_pairing_setup)
  ------------------
  |  Branch (764:6): [True: 0, False: 43]
  ------------------
  765|      0|		capability_info |= P2P_PCEA_PAIRING_SETUP_ENABLED;
  ------------------
  |  | 1875|      0|#define P2P_PCEA_PAIRING_SETUP_ENABLED BIT(9)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  766|       |
  767|     43|	if (p2p->cfg->pairing_config.enable_pairing_cache)
  ------------------
  |  Branch (767:6): [True: 0, False: 43]
  ------------------
  768|      0|		capability_info |= P2P_PCEA_PMK_CACHING;
  ------------------
  |  | 1876|      0|#define P2P_PCEA_PMK_CACHING BIT(10)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  769|       |
  770|     43|	if (p2p->cfg->pairing_config.pasn_type)
  ------------------
  |  Branch (770:6): [True: 0, False: 43]
  ------------------
  771|      0|		capability_info |= P2P_PCEA_PASN_TYPE;
  ------------------
  |  | 1877|      0|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  772|       |
  773|     43|	if (p2p->cfg->twt_power_mgmt)
  ------------------
  |  Branch (773:6): [True: 0, False: 43]
  ------------------
  774|      0|		capability_info |= P2P_PCEA_TWT_POWER_MGMT;
  ------------------
  |  | 1878|      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|     43|	capability_info |= (2 - 1) & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1869|     43|#define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  778|     43|	wpabuf_put_le16(buf, capability_info);
  779|       |
  780|     43|	if (capability_info & P2P_PCEA_REG_INFO)
  ------------------
  |  | 1871|     43|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (780:6): [True: 0, False: 43]
  ------------------
  781|      0|		wpabuf_put_u8(buf, p2p->cfg->reg_info);
  782|       |
  783|     43|	if (capability_info & P2P_PCEA_PASN_TYPE)
  ------------------
  |  | 1877|     43|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     43|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (783:6): [True: 0, False: 43]
  ------------------
  784|      0|		wpabuf_put_u8(buf, p2p->cfg->pairing_config.pasn_type);
  785|       |
  786|       |	/* Update attribute length */
  787|     43|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  788|       |
  789|     43|	wpa_printf(MSG_DEBUG, "P2P: * Capability Extension info=0x%x",
  790|     43|		   capability_info);
  791|     43|}
p2p_buf_add_pbma:
  796|     43|{
  797|     43|	u8 *len;
  798|       |
  799|       |	/* P2P Pairing and Bootstrapping methods */
  800|     43|	wpabuf_put_u8(buf, P2P_ATTR_PAIRING_AND_BOOTSTRAPPING);
  801|       |	/* Length to be filled */
  802|     43|	len = wpabuf_put(buf, 2);
  803|       |
  804|     43|	if (cookie && cookie_len) {
  ------------------
  |  Branch (804:6): [True: 35, False: 8]
  |  Branch (804:16): [True: 35, False: 0]
  ------------------
  805|     35|		if (comeback_after)
  ------------------
  |  Branch (805:7): [True: 35, False: 0]
  ------------------
  806|     35|			wpabuf_put_le16(buf, comeback_after);
  807|     35|		wpabuf_put_u8(buf, cookie_len);
  808|     35|		wpabuf_put_data(buf, cookie, cookie_len);
  809|     35|	}
  810|     43|	wpabuf_put_le16(buf, bootstrap);
  811|       |
  812|       |	/* Update attribute length */
  813|     43|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  814|       |
  815|     43|	wpa_printf(MSG_DEBUG, "P2P: * Bootstrapping method=0x%x",
  816|     43|		   bootstrap);
  817|     43|}
p2p_build_wps_ie:
  878|     39|{
  879|     39|	u8 *len;
  880|     39|	int i;
  881|       |
  882|     39|	if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (882:6): [True: 0, False: 39]
  ------------------
  883|      0|		return -1;
  884|     39|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|     39|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  885|     39|	len = wpabuf_put(buf, 1);
  886|     39|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|     39|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
  887|       |
  888|     39|	if (wps_build_version(buf) < 0)
  ------------------
  |  Branch (888:6): [True: 0, False: 39]
  ------------------
  889|      0|		return -1;
  890|       |
  891|     39|	if (all_attr) {
  ------------------
  |  Branch (891:6): [True: 2, False: 37]
  ------------------
  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|     39|	if (pw_id >= 0) {
  ------------------
  |  Branch (899:6): [True: 37, False: 2]
  ------------------
  900|     37|		if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (900:7): [True: 0, False: 37]
  ------------------
  901|      0|			return -1;
  902|       |		/* Device Password ID */
  903|     37|		wpabuf_put_be16(buf, ATTR_DEV_PASSWORD_ID);
  904|     37|		wpabuf_put_be16(buf, 2);
  905|     37|		wpa_printf(MSG_DEBUG, "P2P: WPS IE Device Password ID: %d",
  906|     37|			   pw_id);
  907|     37|		wpabuf_put_be16(buf, pw_id);
  908|     37|	}
  909|       |
  910|     39|	if (all_attr) {
  ------------------
  |  Branch (910:6): [True: 2, False: 37]
  ------------------
  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|     39|	if (wps_build_wfa_ext(buf, 0, NULL, 0, 0) < 0)
  ------------------
  |  Branch (945:6): [True: 0, False: 39]
  ------------------
  946|      0|		return -1;
  947|       |
  948|     39|	if (all_attr && p2p->cfg->num_sec_dev_types) {
  ------------------
  |  Branch (948:6): [True: 2, False: 37]
  |  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|     39|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|     39|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (961:14): [True: 39, False: 0]
  ------------------
  962|     39|		if (p2p->wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (962:7): [True: 39, False: 0]
  ------------------
  963|     39|			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|     39|	p2p_buf_update_ie_hdr(buf, len);
  973|       |
  974|     39|	return 0;
  975|     39|}
p2p_encaps_ie:
  979|    888|{
  980|    888|	struct wpabuf *ie;
  981|    888|	const u8 *pos, *end;
  982|    888|	size_t len;
  983|       |
  984|    888|	if (!subelems)
  ------------------
  |  Branch (984:6): [True: 0, False: 888]
  ------------------
  985|      0|		return NULL;
  986|       |
  987|    888|	len = wpabuf_len(subelems) + 1000;
  988|       |
  989|    888|	ie = wpabuf_alloc(len);
  990|    888|	if (!ie)
  ------------------
  |  Branch (990:6): [True: 0, False: 888]
  ------------------
  991|      0|		return NULL;
  992|       |
  993|    888|	pos = wpabuf_head(subelems);
  994|    888|	end = pos + wpabuf_len(subelems);
  995|       |
  996|  1.77k|	while (end > pos) {
  ------------------
  |  Branch (996:9): [True: 888, False: 888]
  ------------------
  997|    888|		size_t frag_len = end - pos;
  998|       |
  999|    888|		if (frag_len > 251)
  ------------------
  |  Branch (999:7): [True: 0, False: 888]
  ------------------
 1000|      0|			frag_len = 251;
 1001|    888|		wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|    888|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
 1002|    888|		wpabuf_put_u8(ie, 4 + frag_len);
 1003|    888|		wpabuf_put_be32(ie, ie_type);
 1004|    888|		wpabuf_put_data(ie, pos, frag_len);
 1005|    888|		pos += frag_len;
 1006|    888|	}
 1007|       |
 1008|    888|	return ie;
 1009|    888|}
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|     31|{
  164|     31|	struct p2p_message msg;
  165|     31|	size_t g;
  166|       |
  167|     31|	p2p_dbg(p2p, "Received Device Discoverability Request from " MACSTR
  168|     31|		" (freq=%d)", MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     31|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  169|       |
  170|     31|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (170:6): [True: 5, False: 26]
  ------------------
  171|      5|		return;
  172|       |
  173|     26|	if (msg.dialog_token == 0) {
  ------------------
  |  Branch (173:6): [True: 10, False: 16]
  ------------------
  174|     10|		p2p_dbg(p2p, "Invalid Dialog Token 0 (must be nonzero) in Device Discoverability Request");
  175|     10|		p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  176|     10|				       P2P_SC_FAIL_INVALID_PARAMS);
  177|     10|		p2p_parse_free(&msg);
  178|     10|		return;
  179|     10|	}
  180|       |
  181|     16|	if (msg.device_id == NULL) {
  ------------------
  |  Branch (181:6): [True: 14, False: 2]
  ------------------
  182|     14|		p2p_dbg(p2p, "P2P Device ID attribute missing from Device Discoverability Request");
  183|     14|		p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  184|     14|				       P2P_SC_FAIL_INVALID_PARAMS);
  185|     14|		p2p_parse_free(&msg);
  186|     14|		return;
  187|     14|	}
  188|       |
  189|      2|	for (g = 0; g < p2p->num_groups; g++) {
  ------------------
  |  Branch (189:14): [True: 0, False: 2]
  ------------------
  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|      2|	p2p_dbg(p2p, "Requested client was not found in any group or did not support client discoverability");
  208|      2|	p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  209|      2|			       P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE);
  210|      2|	p2p_parse_free(&msg);
  211|      2|}
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|     26|{
  140|     26|	struct wpabuf *resp;
  141|       |
  142|     26|	resp = p2p_build_dev_disc_resp(dialog_token, status);
  143|     26|	if (resp == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 26]
  ------------------
  144|      0|		return;
  145|       |
  146|     26|	p2p_dbg(p2p, "Sending Device Discoverability Response to " MACSTR
  147|     26|		" (status %u freq %d)",
  148|     26|		MAC2STR(addr), status, freq);
  ------------------
  |  |  447|     26|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  149|       |
  150|     26|	p2p->pending_action_state = P2P_PENDING_DEV_DISC_RESPONSE;
  151|     26|	if (p2p_send_action(p2p, freq, addr, p2p->cfg->dev_addr,
  ------------------
  |  Branch (151:6): [True: 0, False: 26]
  ------------------
  152|     26|			    p2p->cfg->dev_addr,
  153|     26|			    wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
  154|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  155|      0|	}
  156|       |
  157|     26|	wpabuf_free(resp);
  158|     26|}
p2p_dev_disc.c:p2p_build_dev_disc_resp:
  111|     26|{
  112|     26|	struct wpabuf *buf;
  113|     26|	u8 *len;
  114|       |
  115|     26|	buf = wpabuf_alloc(100);
  116|     26|	if (buf == NULL)
  ------------------
  |  Branch (116:6): [True: 0, False: 26]
  ------------------
  117|      0|		return NULL;
  118|       |
  119|     26|	p2p_buf_add_public_action_hdr(buf, P2P_DEV_DISC_RESP, dialog_token);
  120|       |
  121|     26|	len = p2p_buf_add_ie_hdr(buf);
  122|     26|	p2p_buf_add_status(buf, status);
  123|     26|	p2p_buf_update_ie_hdr(buf, len);
  124|       |
  125|     26|	return buf;
  126|     26|}

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

p2p_process_invitation_req:
  230|    949|{
  231|    949|	struct p2p_device *dev;
  232|    949|	struct p2p_message msg;
  233|    949|	struct wpabuf *resp = NULL;
  234|    949|	u8 status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  235|    949|	int go = 0;
  236|    949|	u8 group_bssid[ETH_ALEN], *bssid;
  237|    949|	int op_freq = 0;
  238|    949|	u8 reg_class = 0, channel = 0;
  239|    949|	const u8 *new_ssid = NULL;
  240|    949|	size_t new_ssid_len = 0;
  241|    949|	struct p2p_channels all_channels, intersection, *channels = NULL;
  242|    949|	int persistent;
  243|       |
  244|    949|	os_memset(group_bssid, 0, sizeof(group_bssid));
  ------------------
  |  |  529|    949|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  245|       |
  246|    949|	p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
  247|    949|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|    949|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  248|       |
  249|    949|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (249:6): [True: 152, False: 797]
  ------------------
  250|    152|		return NULL;
  251|       |
  252|    797|	dev = p2p_get_device(p2p, sa);
  253|    797|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|    193|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    193|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (253:6): [True: 604, False: 193]
  |  Branch (253:21): [True: 3, False: 190]
  ------------------
  254|    607|		p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
  ------------------
  |  |  448|    607|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  255|    607|			MAC2STR(sa));
  ------------------
  |  |  447|    607|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  256|       |
  257|    607|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
  ------------------
  |  Branch (257:7): [True: 427, False: 180]
  ------------------
  258|    607|				   0)) {
  259|    427|			p2p_dbg(p2p, "Invitation Request add device failed "
  260|    427|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    427|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    427|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  261|    427|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  262|    427|			goto fail;
  263|    427|		}
  264|       |
  265|    180|		dev = p2p_get_device(p2p, sa);
  266|    180|		if (dev == NULL) {
  ------------------
  |  Branch (266:7): [True: 176, False: 4]
  ------------------
  267|    176|			p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
  268|    176|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    176|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    176|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  269|    176|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  270|    176|			goto fail;
  271|    176|		}
  272|    180|	}
  273|       |
  274|    194|	if (!msg.group_id || !msg.channel_list) {
  ------------------
  |  Branch (274:6): [True: 6, False: 188]
  |  Branch (274:23): [True: 3, False: 185]
  ------------------
  275|      9|		p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
  276|      9|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      9|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      9|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  277|      9|		status = P2P_SC_FAIL_INVALID_PARAMS;
  278|      9|		goto fail;
  279|      9|	}
  280|       |
  281|    185|	if (msg.invitation_flags)
  ------------------
  |  Branch (281:6): [True: 1, False: 184]
  ------------------
  282|      1|		persistent = *msg.invitation_flags & P2P_INVITATION_FLAGS_TYPE;
  ------------------
  |  | 1903|      1|#define P2P_INVITATION_FLAGS_TYPE BIT(0)
  |  |  ------------------
  |  |  |  |  458|      1|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  283|    184|	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|    184|		p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
  290|    184|		persistent = 1;
  291|    184|	}
  292|       |
  293|    185|	p2p_channels_union(&p2p->cfg->channels, &p2p->cfg->cli_channels,
  294|    185|			   &all_channels);
  295|       |
  296|    185|	if (p2p_peer_channels_check(p2p, &all_channels, dev,
  ------------------
  |  Branch (296:6): [True: 52, False: 133]
  ------------------
  297|    185|				    msg.channel_list, msg.channel_list_len) <
  298|    185|	    0) {
  299|     52|		p2p_dbg(p2p, "No common channels found");
  300|     52|		status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  301|     52|		goto fail;
  302|     52|	}
  303|       |
  304|    133|	p2p_channels_dump(p2p, "own channels", &p2p->cfg->channels);
  305|    133|	p2p_channels_dump(p2p, "own client channels", &all_channels);
  306|    133|	p2p_channels_dump(p2p, "peer channels", &dev->channels);
  307|    133|	p2p_channels_intersect(&all_channels, &dev->channels,
  308|    133|			       &intersection);
  309|    133|	p2p_channels_dump(p2p, "intersection", &intersection);
  310|       |
  311|    133|	if (p2p->cfg->invitation_process) {
  ------------------
  |  Branch (311:6): [True: 0, False: 133]
  ------------------
  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|    133|	if (go) {
  ------------------
  |  Branch (320:6): [True: 0, False: 133]
  ------------------
  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|    133|	if (op_freq) {
  ------------------
  |  Branch (331:6): [True: 0, False: 133]
  ------------------
  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|    133|	} else {
  352|    133|		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|    133|		p2p->op_reg_class = p2p->cfg->op_reg_class;
  356|    133|		p2p->op_channel = p2p->cfg->op_channel;
  357|    133|		p2p_dbg(p2p, "Own default op_class %d channel %d",
  358|    133|			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|    133|		if (msg.operating_channel) {
  ------------------
  |  Branch (372:7): [True: 90, False: 43]
  ------------------
  373|     90|			int req_freq;
  374|     90|			req_freq = p2p_channel_to_freq(
  375|     90|				msg.operating_channel[3],
  376|     90|				msg.operating_channel[4]);
  377|     90|			p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
  378|     90|				req_freq);
  379|     90|			if (req_freq > 0 &&
  ------------------
  |  Branch (379:8): [True: 50, False: 40]
  ------------------
  380|     50|			    p2p_channels_includes(&intersection,
  ------------------
  |  Branch (380:8): [True: 3, False: 47]
  ------------------
  381|     50|						  msg.operating_channel[3],
  382|     50|						  msg.operating_channel[4])) {
  383|      3|				p2p->op_reg_class = msg.operating_channel[3];
  384|      3|				p2p->op_channel = msg.operating_channel[4];
  385|      3|				p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
  386|      3|					p2p->op_reg_class, p2p->op_channel);
  387|     87|			} else {
  388|     87|				p2p_dbg(p2p, "Cannot use peer channel preference");
  389|     87|			}
  390|     90|		}
  391|       |
  392|       |		/* Reselect the channel only for the case of the GO */
  393|    133|		if (go &&
  ------------------
  |  Branch (393:7): [True: 0, False: 133]
  ------------------
  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|    133|		} 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: 133]
  |  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|    133|		p2p_check_pref_chan(p2p, go, dev, &msg);
  421|       |
  422|    133|		op_freq = p2p_channel_to_freq(p2p->op_reg_class,
  423|    133|					      p2p->op_channel);
  424|    133|		if (op_freq < 0) {
  ------------------
  |  Branch (424:7): [True: 130, False: 3]
  ------------------
  425|    130|			p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
  426|    130|				p2p->cfg->country[0], p2p->cfg->country[1],
  427|    130|				p2p->op_reg_class, p2p->op_channel);
  428|    130|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  429|    130|			goto fail;
  430|    130|		}
  431|      3|		p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
  432|       |
  433|      3|		if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (433:7): [True: 0, False: 3]
  ------------------
  434|      0|			reg_class = p2p->op_reg_class;
  435|      0|			channel = p2p->op_channel;
  436|      0|			channels = &intersection;
  437|      0|		}
  438|      3|	}
  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: 3, False: 794]
  ------------------
  455|      3|		os_memcpy(p2p->inv_group_bssid, msg.group_bssid, ETH_ALEN);
  ------------------
  |  |  523|      3|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  456|      3|		p2p->inv_group_bssid_ptr = p2p->inv_group_bssid;
  457|      3|	} else
  458|    794|		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: 208, False: 589]
  ------------------
  465|    208|		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  344|    208|#define ETH_ALEN 6
  ------------------
              		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  511|    208|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (465:7): [True: 208, False: 0]
  ------------------
  466|    208|			os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN,
  ------------------
  |  |  523|    208|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  467|    208|				  msg.group_id_len - ETH_ALEN);
  468|    208|			p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|    208|#define ETH_ALEN 6
  ------------------
  469|    208|		}
  470|    208|		os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN);
  ------------------
  |  |  523|    208|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  471|    589|	} else {
  472|    589|		p2p->inv_ssid_len = 0;
  473|    589|		os_memset(p2p->inv_go_dev_addr, 0, ETH_ALEN);
  ------------------
  |  |  529|    589|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  474|    589|	}
  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|    133|}
p2p_handle_invitation_req:
  484|    949|{
  485|    949|	int freq;
  486|    949|	struct wpabuf *resp;
  487|       |
  488|    949|	resp = p2p_process_invitation_req(p2p, sa, data, len, rx_freq, false);
  489|    949|	if (!resp)
  ------------------
  |  Branch (489:6): [True: 152, False: 797]
  ------------------
  490|    152|		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|      3|{
  514|      3|	struct p2p_device *dev;
  515|      3|	struct p2p_message msg;
  516|      3|	struct p2p_channels intersection, *channels = NULL;
  517|      3|	bool all_channels = false;
  518|      3|	const u8 *go_dev_addr = NULL;
  519|       |
  520|      3|	p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
  ------------------
  |  |  448|      3|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  521|      3|		MAC2STR(sa));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  522|       |
  523|      3|	dev = p2p_get_device(p2p, sa);
  524|      3|	if (dev == NULL) {
  ------------------
  |  Branch (524:6): [True: 2, False: 1]
  ------------------
  525|      2|		p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
  526|      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]
  ------------------
  527|      2|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  528|      2|		return;
  529|      2|	}
  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|      0|		p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
  577|      0|		p2p_set_state(p2p, P2P_INVITE);
  578|      0|		p2p_dbg(p2p, "Resend Invitation Request setting op_class %u channel %u as operating channel",
  579|      0|			p2p->op_reg_class, p2p->op_channel);
  580|      0|		p2p->retry_invite_req_sent = 1;
  581|      0|		p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr,
  582|      0|				p2p->invite_dev_pw_id);
  583|      0|		p2p_parse_free(&msg);
  584|      0|		return;
  585|      0|	}
  586|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  587|      0|	p2p->retry_invite_req = 0;
  588|       |
  589|      0|	if (!msg.channel_list && *msg.status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (589:6): [True: 0, False: 0]
  |  Branch (589:27): [True: 0, False: 0]
  ------------------
  590|      0|		p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
  591|      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]
  ------------------
  592|       |#ifdef CONFIG_P2P_STRICT
  593|       |		p2p_parse_free(&msg);
  594|       |		return;
  595|       |#endif /* CONFIG_P2P_STRICT */
  596|       |		/* Try to survive without peer channel list */
  597|      0|		channels = &p2p->channels;
  598|      0|		all_channels = true;
  599|      0|	} else if (!msg.channel_list) {
  ------------------
  |  Branch (599:13): [True: 0, False: 0]
  ------------------
  600|       |		/* Non-success cases are not required to include Channel List */
  601|      0|		channels = &p2p->channels;
  602|      0|		all_channels = true;
  603|      0|	} else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (603:13): [True: 0, False: 0]
  ------------------
  604|      0|					   msg.channel_list,
  605|      0|					   msg.channel_list_len) < 0) {
  606|      0|		p2p_dbg(p2p, "No common channels found");
  607|      0|		p2p_parse_free(&msg);
  608|      0|		dev->inv_reject = true;
  609|      0|		return;
  610|      0|	} else {
  611|      0|		p2p_channels_intersect(&p2p->channels, &dev->channels,
  612|      0|				       &intersection);
  613|      0|		channels = &intersection;
  614|      0|	}
  615|       |
  616|      0|	if (p2p->cfg->invitation_result) {
  ------------------
  |  Branch (616:6): [True: 0, False: 0]
  ------------------
  617|      0|		int peer_oper_freq = 0;
  618|      0|		int freq = p2p_channel_to_freq(p2p->op_reg_class,
  619|      0|					       p2p->op_channel);
  620|      0|		if (freq < 0)
  ------------------
  |  Branch (620:7): [True: 0, False: 0]
  ------------------
  621|      0|			freq = 0;
  622|       |
  623|      0|		if (msg.operating_channel) {
  ------------------
  |  Branch (623:7): [True: 0, False: 0]
  ------------------
  624|      0|			peer_oper_freq = p2p_channel_to_freq(
  625|      0|				msg.operating_channel[3],
  626|      0|				msg.operating_channel[4]);
  627|      0|			if (peer_oper_freq < 0)
  ------------------
  |  Branch (627:8): [True: 0, False: 0]
  ------------------
  628|      0|				peer_oper_freq = 0;
  629|      0|		}
  630|       |
  631|       |		/*
  632|       |		 * Use the driver preferred frequency list extension if
  633|       |		 * supported.
  634|       |		 */
  635|      0|		p2p_check_pref_chan(p2p, 0, dev, &msg);
  636|       |
  637|      0|		if (dev->p2p2) {
  ------------------
  |  Branch (637:7): [True: 0, False: 0]
  ------------------
  638|      0|			dev->inv_freq = freq;
  639|      0|			dev->inv_status = *msg.status;
  640|      0|			dev->inv_all_channels = all_channels;
  641|      0|			dev->inv_peer_oper_freq = peer_oper_freq;
  642|      0|			if (msg.group_bssid)
  ------------------
  |  Branch (642:8): [True: 0, False: 0]
  ------------------
  643|      0|				os_memcpy(dev->inv_bssid, msg.group_bssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  644|      0|					  ETH_ALEN);
  645|      0|			if (msg.group_id) {
  ------------------
  |  Branch (645:8): [True: 0, False: 0]
  ------------------
  646|      0|				dev->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  647|      0|				os_memcpy(dev->inv_ssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  648|      0|					  msg.group_id + ETH_ALEN,
  649|      0|					  dev->inv_ssid_len);
  650|       |
  651|      0|				os_memcpy(p2p->invite_go_dev_addr_buf,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  652|      0|					  msg.group_id, ETH_ALEN);
  653|      0|				p2p->invite_go_dev_addr =
  654|      0|					p2p->invite_go_dev_addr_buf;
  655|      0|				go_dev_addr = p2p->invite_go_dev_addr;
  656|      0|			}
  657|      0|			goto out;
  658|      0|		}
  659|       |
  660|      0|		p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status,
  661|      0|					    NULL, 0,
  662|      0|					    msg.group_bssid, channels, sa,
  663|      0|					    freq, peer_oper_freq, NULL, NULL,
  664|      0|					    0, go_dev_addr);
  665|      0|	}
  666|       |
  667|      0|	p2p_clear_timeout(p2p);
  668|      0|	p2p_set_state(p2p, P2P_IDLE);
  669|      0|	p2p->invite_peer = NULL;
  670|       |
  671|      0|out:
  672|      0|	p2p_parse_free(&msg);
  673|      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);
  ------------------
  |  | 1515|    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|  1.96k|{
   21|  1.96k|	size_t i;
   22|       |
   23|  1.96k|	if (src_len >= dst_len)
  ------------------
  |  Branch (23:6): [True: 0, False: 1.96k]
  ------------------
   24|      0|		src_len = dst_len - 1;
   25|  1.96k|	os_memcpy(dst, src, src_len);
  ------------------
  |  |  523|  1.96k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   26|  1.96k|	dst[src_len] = '\0';
   27|  14.7k|	for (i = 0; i < src_len; i++) {
  ------------------
  |  Branch (27:14): [True: 13.6k, False: 1.08k]
  ------------------
   28|  13.6k|		if (dst[i] == '\0')
  ------------------
  |  Branch (28:7): [True: 880, False: 12.7k]
  ------------------
   29|    880|			break;
   30|  12.7k|		if (is_ctrl_char(dst[i]))
  ------------------
  |  Branch (30:7): [True: 2.91k, False: 9.86k]
  ------------------
   31|  2.91k|			dst[i] = '_';
   32|  12.7k|	}
   33|  1.96k|}
p2p_parse_p2p_ie:
  494|  7.40k|{
  495|  7.40k|	const u8 *pos = wpabuf_head_u8(buf);
  496|  7.40k|	const u8 *end = pos + wpabuf_len(buf);
  497|       |
  498|  7.40k|	wpa_printf(MSG_DEBUG, "P2P: Parsing P2P IE");
  499|       |
  500|  60.9k|	while (pos < end) {
  ------------------
  |  Branch (500:9): [True: 54.9k, False: 5.97k]
  ------------------
  501|  54.9k|		u16 attr_len;
  502|  54.9k|		u8 id;
  503|       |
  504|  54.9k|		if (end - pos < 3) {
  ------------------
  |  Branch (504:7): [True: 147, False: 54.7k]
  ------------------
  505|    147|			wpa_printf(MSG_DEBUG, "P2P: Invalid P2P attribute");
  506|    147|			return -1;
  507|    147|		}
  508|  54.7k|		id = *pos++;
  509|  54.7k|		attr_len = WPA_GET_LE16(pos);
  510|  54.7k|		pos += 2;
  511|  54.7k|		wpa_printf(MSG_DEBUG, "P2P: Attribute %d length %u",
  512|  54.7k|			   id, attr_len);
  513|  54.7k|		if (attr_len > end - pos) {
  ------------------
  |  Branch (513:7): [True: 464, False: 54.3k]
  ------------------
  514|    464|			wpa_printf(MSG_DEBUG, "P2P: Attribute underflow "
  515|    464|				   "(len=%u left=%d)",
  516|    464|				   attr_len, (int) (end - pos));
  517|    464|			wpa_hexdump(MSG_MSGDUMP, "P2P: Data", pos, end - pos);
  518|    464|			return -1;
  519|    464|		}
  520|  54.3k|		if (p2p_parse_attribute(id, pos, attr_len, msg))
  ------------------
  |  Branch (520:7): [True: 816, False: 53.5k]
  ------------------
  521|    816|			return -1;
  522|  53.5k|		pos += attr_len;
  523|  53.5k|	}
  524|       |
  525|  5.97k|	return 0;
  526|  7.40k|}
p2p_parse_ies:
  599|  17.2k|{
  600|  17.2k|	struct ieee802_11_elems elems;
  601|       |
  602|  17.2k|	if (ieee802_11_parse_elems(data, len, &elems, 0) == ParseFailed)
  ------------------
  |  Branch (602:6): [True: 2.08k, False: 15.1k]
  ------------------
  603|  2.08k|		return -1;
  604|       |
  605|  15.1k|	if (elems.ds_params)
  ------------------
  |  Branch (605:6): [True: 1.11k, False: 14.0k]
  ------------------
  606|  1.11k|		msg->ds_params = elems.ds_params;
  607|  15.1k|	if (elems.ssid)
  ------------------
  |  Branch (607:6): [True: 5.02k, False: 10.1k]
  ------------------
  608|  5.02k|		msg->ssid = elems.ssid - 2;
  609|       |
  610|  15.1k|	msg->wps_attributes = ieee802_11_vendor_ie_concat(data, len,
  611|  15.1k|							  WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|  15.1k|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
  612|  15.1k|	if (msg->wps_attributes &&
  ------------------
  |  Branch (612:6): [True: 4.80k, False: 10.3k]
  ------------------
  613|  4.80k|	    p2p_parse_wps_ie(msg->wps_attributes, msg)) {
  ------------------
  |  Branch (613:6): [True: 2.00k, False: 2.80k]
  ------------------
  614|  2.00k|		p2p_parse_free(msg);
  615|  2.00k|		return -1;
  616|  2.00k|	}
  617|       |
  618|  13.1k|	msg->p2p_attributes = ieee802_11_vendor_ie_concat(data, len,
  619|  13.1k|							  P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|  13.1k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  620|  13.1k|	if (msg->p2p_attributes &&
  ------------------
  |  Branch (620:6): [True: 6.83k, False: 6.28k]
  ------------------
  621|  6.83k|	    p2p_parse_p2p_ie(msg->p2p_attributes, msg)) {
  ------------------
  |  Branch (621:6): [True: 1.32k, False: 5.51k]
  ------------------
  622|  1.32k|		wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P IE data");
  623|  1.32k|		if (msg->p2p_attributes)
  ------------------
  |  Branch (623:7): [True: 1.32k, False: 0]
  ------------------
  624|  1.32k|			wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P IE data",
  625|  1.32k|					msg->p2p_attributes);
  626|  1.32k|		p2p_parse_free(msg);
  627|  1.32k|		return -1;
  628|  1.32k|	}
  629|       |
  630|  11.8k|	msg->p2p2_attributes = ieee802_11_vendor_ie_concat(data, len,
  631|  11.8k|							   P2P2_IE_VENDOR_TYPE);
  ------------------
  |  | 1516|  11.8k|#define P2P2_IE_VENDOR_TYPE 0x506f9a28
  ------------------
  632|  11.8k|	if (msg->p2p2_attributes &&
  ------------------
  |  Branch (632:6): [True: 569, False: 11.2k]
  ------------------
  633|    569|	    p2p_parse_p2p_ie(msg->p2p2_attributes, msg)) {
  ------------------
  |  Branch (633:6): [True: 107, False: 462]
  ------------------
  634|    107|		wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P2 IE data");
  635|    107|		if (msg->p2p2_attributes)
  ------------------
  |  Branch (635:7): [True: 107, False: 0]
  ------------------
  636|    107|			wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P2 IE data",
  637|    107|					msg->p2p2_attributes);
  638|    107|		p2p_parse_free(msg);
  639|    107|		return -1;
  640|    107|	}
  641|       |
  642|  11.6k|#ifdef CONFIG_WIFI_DISPLAY
  643|  11.6k|	if (elems.wfd) {
  ------------------
  |  Branch (643:6): [True: 941, False: 10.7k]
  ------------------
  644|    941|		msg->wfd_subelems = ieee802_11_vendor_ie_concat(
  645|    941|			data, len, WFD_IE_VENDOR_TYPE);
  ------------------
  |  | 1517|    941|#define WFD_IE_VENDOR_TYPE 0x506f9a0a
  ------------------
  646|    941|	}
  647|  11.6k|#endif /* CONFIG_WIFI_DISPLAY */
  648|       |
  649|  11.6k|	msg->pref_freq_list = elems.pref_freq_list;
  650|  11.6k|	msg->pref_freq_list_len = elems.pref_freq_list_len;
  651|       |
  652|  11.6k|	return 0;
  653|  11.8k|}
p2p_parse:
  667|  2.74k|{
  668|  2.74k|	os_memset(msg, 0, sizeof(*msg));
  ------------------
  |  |  529|  2.74k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  669|  2.74k|	wpa_printf(MSG_DEBUG, "P2P: Parsing the received message");
  670|  2.74k|	if (len < 1) {
  ------------------
  |  Branch (670:6): [True: 6, False: 2.73k]
  ------------------
  671|      6|		wpa_printf(MSG_DEBUG, "P2P: No Dialog Token in the message");
  672|      6|		return -1;
  673|      6|	}
  674|  2.73k|	msg->dialog_token = data[0];
  675|  2.73k|	wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", msg->dialog_token);
  676|       |
  677|  2.73k|	return p2p_parse_ies(data + 1, len - 1, msg);
  678|  2.74k|}
p2p_parse_free:
  713|  19.9k|{
  714|  19.9k|	wpabuf_free(msg->p2p_attributes);
  715|  19.9k|	msg->p2p_attributes = NULL;
  716|  19.9k|	wpabuf_free(msg->p2p2_attributes);
  717|  19.9k|	msg->p2p2_attributes = NULL;
  718|  19.9k|	wpabuf_free(msg->wps_attributes);
  719|  19.9k|	msg->wps_attributes = NULL;
  720|  19.9k|#ifdef CONFIG_WIFI_DISPLAY
  721|  19.9k|	wpabuf_free(msg->wfd_subelems);
  722|       |	msg->wfd_subelems = NULL;
  723|  19.9k|#endif /* CONFIG_WIFI_DISPLAY */
  724|  19.9k|}
p2p_group_info_parse:
  729|    148|{
  730|    148|	const u8 *g, *gend;
  731|       |
  732|    148|	os_memset(info, 0, sizeof(*info));
  ------------------
  |  |  529|    148|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  733|    148|	if (gi == NULL)
  ------------------
  |  Branch (733:6): [True: 0, False: 148]
  ------------------
  734|      0|		return 0;
  735|       |
  736|    148|	g = gi;
  737|    148|	gend = gi + gi_len;
  738|    386|	while (g < gend) {
  ------------------
  |  Branch (738:9): [True: 302, False: 84]
  ------------------
  739|    302|		struct p2p_client_info *cli;
  740|    302|		const u8 *cend;
  741|    302|		u16 count;
  742|    302|		u8 len;
  743|       |
  744|    302|		cli = &info->client[info->num_clients];
  745|    302|		len = *g++;
  746|    302|		if (len > gend - g || len < 2 * ETH_ALEN + 1 + 2 + 8 + 1)
  ------------------
  |  |  344|    295|#define ETH_ALEN 6
  ------------------
  |  Branch (746:7): [True: 7, False: 295]
  |  Branch (746:25): [True: 9, False: 286]
  ------------------
  747|     16|			return -1; /* invalid data */
  748|    286|		cend = g + len;
  749|       |		/* g at start of P2P Client Info Descriptor */
  750|    286|		cli->p2p_device_addr = g;
  751|    286|		g += ETH_ALEN;
  ------------------
  |  |  344|    286|#define ETH_ALEN 6
  ------------------
  752|    286|		cli->p2p_interface_addr = g;
  753|    286|		g += ETH_ALEN;
  ------------------
  |  |  344|    286|#define ETH_ALEN 6
  ------------------
  754|    286|		cli->dev_capab = *g++;
  755|       |
  756|    286|		cli->config_methods = WPA_GET_BE16(g);
  757|    286|		g += 2;
  758|    286|		cli->pri_dev_type = g;
  759|    286|		g += 8;
  760|       |
  761|       |		/* g at Number of Secondary Device Types */
  762|    286|		len = *g++;
  763|    286|		if (8 * len > cend - g)
  ------------------
  |  Branch (763:7): [True: 17, False: 269]
  ------------------
  764|     17|			return -1; /* invalid data */
  765|    269|		cli->num_sec_dev_types = len;
  766|    269|		cli->sec_dev_types = g;
  767|    269|		g += 8 * len;
  768|       |
  769|       |		/* g at Device Name in WPS TLV format */
  770|    269|		if (cend - g < 2 + 2)
  ------------------
  |  Branch (770:7): [True: 4, False: 265]
  ------------------
  771|      4|			return -1; /* invalid data */
  772|    265|		if (WPA_GET_BE16(g) != ATTR_DEV_NAME)
  ------------------
  |  Branch (772:7): [True: 25, False: 240]
  ------------------
  773|     25|			return -1; /* invalid Device Name TLV */
  774|    240|		g += 2;
  775|    240|		count = WPA_GET_BE16(g);
  776|    240|		g += 2;
  777|    240|		if (count > cend - g)
  ------------------
  |  Branch (777:7): [True: 2, False: 238]
  ------------------
  778|      2|			return -1; /* invalid Device Name TLV */
  779|    238|		if (count >= WPS_DEV_NAME_MAX_LEN)
  ------------------
  |  |   48|    238|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  |  Branch (779:7): [True: 6, False: 232]
  ------------------
  780|      6|			count = WPS_DEV_NAME_MAX_LEN;
  ------------------
  |  |   48|      6|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  781|    238|		cli->dev_name = (const char *) g;
  782|    238|		cli->dev_name_len = count;
  783|       |
  784|    238|		g = cend;
  785|       |
  786|    238|		info->num_clients++;
  787|    238|		if (info->num_clients == P2P_MAX_GROUP_ENTRIES)
  ------------------
  |  |  841|    238|#define P2P_MAX_GROUP_ENTRIES 50
  ------------------
  |  Branch (787:7): [True: 0, False: 238]
  ------------------
  788|      0|			return -1;
  789|    238|	}
  790|       |
  791|     84|	return 0;
  792|    148|}
p2p_parse.c:p2p_parse_attribute:
   38|  54.3k|{
   39|  54.3k|	const u8 *pos;
   40|  54.3k|	u16 nlen;
   41|  54.3k|	char devtype[WPS_DEV_TYPE_BUFSIZE];
   42|       |
   43|  54.3k|	switch (id) {
   44|    589|	case P2P_ATTR_CAPABILITY:
  ------------------
  |  Branch (44:2): [True: 589, False: 53.7k]
  ------------------
   45|    589|		if (len < 2) {
  ------------------
  |  Branch (45:7): [True: 11, False: 578]
  ------------------
   46|     11|			wpa_printf(MSG_DEBUG, "P2P: Too short Capability "
   47|     11|				   "attribute (length %d)", len);
   48|     11|			return -1;
   49|     11|		}
   50|    578|		msg->capability = data;
   51|    578|		wpa_printf(MSG_DEBUG, "P2P: * Device Capability %02x "
   52|    578|			   "Group Capability %02x",
   53|    578|			   data[0], data[1]);
   54|    578|		break;
   55|  7.21k|	case P2P_ATTR_DEVICE_ID:
  ------------------
  |  Branch (55:2): [True: 7.21k, False: 47.1k]
  ------------------
   56|  7.21k|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|  7.21k|#define ETH_ALEN 6
  ------------------
  |  Branch (56:7): [True: 17, False: 7.19k]
  ------------------
   57|     17|			wpa_printf(MSG_DEBUG, "P2P: Too short Device ID "
   58|     17|				   "attribute (length %d)", len);
   59|     17|			return -1;
   60|     17|		}
   61|  7.19k|		msg->device_id = data;
   62|  7.19k|		wpa_printf(MSG_DEBUG, "P2P: * Device ID " MACSTR,
  ------------------
  |  |  448|  7.19k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
   63|  7.19k|			   MAC2STR(msg->device_id));
  ------------------
  |  |  447|  7.19k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
   64|  7.19k|		break;
   65|    293|	case P2P_ATTR_GROUP_OWNER_INTENT:
  ------------------
  |  Branch (65:2): [True: 293, False: 54.0k]
  ------------------
   66|    293|		if (len < 1) {
  ------------------
  |  Branch (66:7): [True: 10, False: 283]
  ------------------
   67|     10|			wpa_printf(MSG_DEBUG, "P2P: Too short GO Intent "
   68|     10|				   "attribute (length %d)", len);
   69|     10|			return -1;
   70|     10|		}
   71|    283|		msg->go_intent = data;
   72|    283|		wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u "
   73|    283|			   "Tie breaker %u", data[0] >> 1, data[0] & 0x01);
   74|    283|		break;
   75|  1.08k|	case P2P_ATTR_STATUS:
  ------------------
  |  Branch (75:2): [True: 1.08k, False: 53.2k]
  ------------------
   76|  1.08k|		if (len < 1) {
  ------------------
  |  Branch (76:7): [True: 208, False: 873]
  ------------------
   77|    208|			wpa_printf(MSG_DEBUG, "P2P: Too short Status "
   78|    208|				   "attribute (length %d)", len);
   79|    208|			return -1;
   80|    208|		}
   81|    873|		msg->status = data;
   82|    873|		wpa_printf(MSG_DEBUG, "P2P: * Status: %d", data[0]);
   83|    873|		break;
   84|  15.7k|	case P2P_ATTR_LISTEN_CHANNEL:
  ------------------
  |  Branch (84:2): [True: 15.7k, False: 38.5k]
  ------------------
   85|  15.7k|		if (len == 0) {
  ------------------
  |  Branch (85:7): [True: 204, False: 15.5k]
  ------------------
   86|    204|			wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: Ignore "
   87|    204|				   "null channel");
   88|    204|			break;
   89|    204|		}
   90|  15.5k|		if (len < 5) {
  ------------------
  |  Branch (90:7): [True: 10, False: 15.5k]
  ------------------
   91|     10|			wpa_printf(MSG_DEBUG, "P2P: Too short Listen Channel "
   92|     10|				   "attribute (length %d)", len);
   93|     10|			return -1;
   94|     10|		}
   95|  15.5k|		msg->listen_channel = data;
   96|  15.5k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (96:7): [True: 2.85k, False: 12.6k]
  ------------------
   97|  2.85k|			wpa_printf(MSG_DEBUG,
   98|  2.85k|				   "P2P: * Listen Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
   99|  2.85k|				   data[0], data[1], data[2], data[3], data[4]);
  100|  2.85k|			break;
  101|  2.85k|		}
  102|  12.6k|		wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: "
  103|  12.6k|			   "Country %c%c(0x%02x) Regulatory "
  104|  12.6k|			   "Class %d Channel Number %d", data[0], data[1],
  105|  12.6k|			   data[2], data[3], data[4]);
  106|  12.6k|		break;
  107|  2.26k|	case P2P_ATTR_OPERATING_CHANNEL:
  ------------------
  |  Branch (107:2): [True: 2.26k, False: 52.0k]
  ------------------
  108|  2.26k|		if (len == 0) {
  ------------------
  |  Branch (108:7): [True: 237, False: 2.03k]
  ------------------
  109|    237|			wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
  110|    237|				   "Ignore null channel");
  111|    237|			break;
  112|    237|		}
  113|  2.03k|		if (len < 5) {
  ------------------
  |  Branch (113:7): [True: 12, False: 2.01k]
  ------------------
  114|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Operating "
  115|     12|				   "Channel attribute (length %d)", len);
  116|     12|			return -1;
  117|     12|		}
  118|  2.01k|		msg->operating_channel = data;
  119|  2.01k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (119:7): [True: 461, False: 1.55k]
  ------------------
  120|    461|			wpa_printf(MSG_DEBUG,
  121|    461|				   "P2P: * Operating Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
  122|    461|				   data[0], data[1], data[2], data[3], data[4]);
  123|    461|			break;
  124|    461|		}
  125|  1.55k|		wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
  126|  1.55k|			   "Country %c%c(0x%02x) Regulatory "
  127|  1.55k|			   "Class %d Channel Number %d", data[0], data[1],
  128|  1.55k|			   data[2], data[3], data[4]);
  129|  1.55k|		break;
  130|  2.37k|	case P2P_ATTR_CHANNEL_LIST:
  ------------------
  |  Branch (130:2): [True: 2.37k, False: 51.9k]
  ------------------
  131|  2.37k|		if (len < 3) {
  ------------------
  |  Branch (131:7): [True: 12, False: 2.36k]
  ------------------
  132|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Channel List "
  133|     12|				   "attribute (length %d)", len);
  134|     12|			return -1;
  135|     12|		}
  136|  2.36k|		msg->channel_list = data;
  137|  2.36k|		msg->channel_list_len = len;
  138|  2.36k|		if (has_ctrl_char(data, 2)) {
  ------------------
  |  Branch (138:7): [True: 1.85k, False: 511]
  ------------------
  139|  1.85k|			wpa_printf(MSG_DEBUG,
  140|  1.85k|				   "P2P: * Channel List: Country String (binary) %02x %02x (0x%02x)",
  141|  1.85k|				   data[0], data[1], data[2]);
  142|  1.85k|		} else {
  143|    511|			wpa_printf(MSG_DEBUG,
  144|    511|				   "P2P: * Channel List: Country String '%c%c(0x%02x)'",
  145|    511|				   data[0], data[1], data[2]);
  146|    511|		}
  147|  2.36k|		wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List",
  148|  2.36k|			    msg->channel_list, msg->channel_list_len);
  149|  2.36k|		break;
  150|    771|	case P2P_ATTR_GROUP_INFO:
  ------------------
  |  Branch (150:2): [True: 771, False: 53.5k]
  ------------------
  151|    771|		msg->group_info = data;
  152|    771|		msg->group_info_len = len;
  153|    771|		wpa_printf(MSG_DEBUG, "P2P: * Group Info");
  154|    771|		break;
  155|  1.95k|	case P2P_ATTR_DEVICE_INFO:
  ------------------
  |  Branch (155:2): [True: 1.95k, False: 52.3k]
  ------------------
  156|  1.95k|		if (len < ETH_ALEN + 2 + 8 + 1) {
  ------------------
  |  |  344|  1.95k|#define ETH_ALEN 6
  ------------------
  |  Branch (156:7): [True: 17, False: 1.93k]
  ------------------
  157|     17|			wpa_printf(MSG_DEBUG, "P2P: Too short Device Info "
  158|     17|				   "attribute (length %d)", len);
  159|     17|			return -1;
  160|     17|		}
  161|  1.93k|		msg->p2p_device_info = data;
  162|  1.93k|		msg->p2p_device_info_len = len;
  163|  1.93k|		pos = data;
  164|  1.93k|		msg->p2p_device_addr = pos;
  165|  1.93k|		pos += ETH_ALEN;
  ------------------
  |  |  344|  1.93k|#define ETH_ALEN 6
  ------------------
  166|  1.93k|		msg->config_methods = WPA_GET_BE16(pos);
  167|  1.93k|		pos += 2;
  168|  1.93k|		msg->pri_dev_type = pos;
  169|  1.93k|		pos += 8;
  170|  1.93k|		msg->num_sec_dev_types = *pos++;
  171|  1.93k|		if (msg->num_sec_dev_types * 8 > data + len - pos) {
  ------------------
  |  Branch (171:7): [True: 39, False: 1.89k]
  ------------------
  172|     39|			wpa_printf(MSG_DEBUG, "P2P: Device Info underflow");
  173|     39|			return -1;
  174|     39|		}
  175|  1.89k|		pos += msg->num_sec_dev_types * 8;
  176|  1.89k|		if (data + len - pos < 4) {
  ------------------
  |  Branch (176:7): [True: 8, False: 1.88k]
  ------------------
  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|  1.88k|		if (WPA_GET_BE16(pos) != ATTR_DEV_NAME) {
  ------------------
  |  Branch (181:7): [True: 82, False: 1.80k]
  ------------------
  182|     82|			wpa_hexdump(MSG_DEBUG, "P2P: Unexpected Device Name "
  183|     82|				    "header", pos, 4);
  184|     82|			return -1;
  185|     82|		}
  186|  1.80k|		pos += 2;
  187|  1.80k|		nlen = WPA_GET_BE16(pos);
  188|  1.80k|		pos += 2;
  189|  1.80k|		if (nlen > data + len - pos || nlen > WPS_DEV_NAME_MAX_LEN) {
  ------------------
  |  |   48|  1.78k|#define WPS_DEV_NAME_MAX_LEN 32
  ------------------
  |  Branch (189:7): [True: 26, False: 1.78k]
  |  Branch (189:34): [True: 12, False: 1.76k]
  ------------------
  190|     38|			wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
  191|     38|				   "length %u (buf len %d)", nlen,
  192|     38|				   (int) (data + len - pos));
  193|     38|			return -1;
  194|     38|		}
  195|  1.76k|		p2p_copy_filter_devname(msg->device_name,
  196|  1.76k|					sizeof(msg->device_name), pos, nlen);
  197|  1.76k|		wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
  198|  1.76k|			   " primary device type %s device name '%s' "
  199|  1.76k|			   "config methods 0x%x",
  200|  1.76k|			   MAC2STR(msg->p2p_device_addr),
  ------------------
  |  |  447|  1.76k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  201|  1.76k|			   wps_dev_type_bin2str(msg->pri_dev_type, devtype,
  202|  1.76k|						sizeof(devtype)),
  203|  1.76k|			   msg->device_name, msg->config_methods);
  204|  1.76k|		break;
  205|    365|	case P2P_ATTR_CONFIGURATION_TIMEOUT:
  ------------------
  |  Branch (205:2): [True: 365, False: 53.9k]
  ------------------
  206|    365|		if (len < 2) {
  ------------------
  |  Branch (206:7): [True: 12, False: 353]
  ------------------
  207|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Configuration "
  208|     12|				   "Timeout attribute (length %d)", len);
  209|     12|			return -1;
  210|     12|		}
  211|    353|		msg->config_timeout = data;
  212|    353|		wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout");
  213|    353|		break;
  214|    439|	case P2P_ATTR_INTENDED_INTERFACE_ADDR:
  ------------------
  |  Branch (214:2): [True: 439, False: 53.8k]
  ------------------
  215|    439|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|    439|#define ETH_ALEN 6
  ------------------
  |  Branch (215:7): [True: 12, False: 427]
  ------------------
  216|     12|			wpa_printf(MSG_DEBUG, "P2P: Too short Intended P2P "
  217|     12|				   "Interface Address attribute (length %d)",
  218|     12|				   len);
  219|     12|			return -1;
  220|     12|		}
  221|    427|		msg->intended_addr = data;
  222|    427|		wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address: "
  223|    427|			   MACSTR, MAC2STR(msg->intended_addr));
  ------------------
  |  |  448|    427|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			   MACSTR, MAC2STR(msg->intended_addr));
  ------------------
  |  |  447|    427|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  224|    427|		break;
  225|    268|	case P2P_ATTR_GROUP_BSSID:
  ------------------
  |  Branch (225:2): [True: 268, False: 54.0k]
  ------------------
  226|    268|		if (len < ETH_ALEN) {
  ------------------
  |  |  344|    268|#define ETH_ALEN 6
  ------------------
  |  Branch (226:7): [True: 18, False: 250]
  ------------------
  227|     18|			wpa_printf(MSG_DEBUG, "P2P: Too short P2P Group BSSID "
  228|     18|				   "attribute (length %d)", len);
  229|     18|			return -1;
  230|     18|		}
  231|    250|		msg->group_bssid = data;
  232|    250|		wpa_printf(MSG_DEBUG, "P2P: * P2P Group BSSID: " MACSTR,
  ------------------
  |  |  448|    250|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  233|    250|			   MAC2STR(msg->group_bssid));
  ------------------
  |  |  447|    250|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  234|    250|		break;
  235|  7.01k|	case P2P_ATTR_GROUP_ID:
  ------------------
  |  Branch (235:2): [True: 7.01k, False: 47.3k]
  ------------------
  236|  7.01k|		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  14.0k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  7.00k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  511|  7.00k|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (236:7): [True: 10, False: 7.00k]
  |  Branch (236:25): [True: 44, False: 6.96k]
  ------------------
  237|     54|			wpa_printf(MSG_DEBUG, "P2P: Invalid P2P Group ID "
  238|     54|				   "attribute length %d", len);
  239|     54|			return -1;
  240|     54|		}
  241|  6.96k|		msg->group_id = data;
  242|  6.96k|		msg->group_id_len = len;
  243|  6.96k|		wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID: Device Address "
  244|  6.96k|			   MACSTR, MAC2STR(msg->group_id));
  ------------------
  |  |  448|  6.96k|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			   MACSTR, MAC2STR(msg->group_id));
  ------------------
  |  |  447|  6.96k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  245|  6.96k|		wpa_hexdump_ascii(MSG_DEBUG, "P2P: * P2P Group ID: SSID",
  246|  6.96k|				  msg->group_id + ETH_ALEN,
  ------------------
  |  |  344|  6.96k|#define ETH_ALEN 6
  ------------------
  247|  6.96k|				  msg->group_id_len - ETH_ALEN);
  ------------------
  |  |  344|  6.96k|#define ETH_ALEN 6
  ------------------
  248|  6.96k|		break;
  249|    275|	case P2P_ATTR_INVITATION_FLAGS:
  ------------------
  |  Branch (249:2): [True: 275, False: 54.0k]
  ------------------
  250|    275|		if (len < 1) {
  ------------------
  |  Branch (250:7): [True: 9, False: 266]
  ------------------
  251|      9|			wpa_printf(MSG_DEBUG, "P2P: Too short Invitation "
  252|      9|				   "Flag attribute (length %d)", len);
  253|      9|			return -1;
  254|      9|		}
  255|    266|		msg->invitation_flags = data;
  256|    266|		wpa_printf(MSG_DEBUG, "P2P: * Invitation Flags: bitmap 0x%x",
  257|    266|			   data[0]);
  258|    266|		break;
  259|    281|	case P2P_ATTR_MANAGEABILITY:
  ------------------
  |  Branch (259:2): [True: 281, False: 54.0k]
  ------------------
  260|    281|		if (len < 1) {
  ------------------
  |  Branch (260:7): [True: 6, False: 275]
  ------------------
  261|      6|			wpa_printf(MSG_DEBUG, "P2P: Too short Manageability "
  262|      6|				   "attribute (length %d)", len);
  263|      6|			return -1;
  264|      6|		}
  265|    275|		msg->manageability = data;
  266|    275|		wpa_printf(MSG_DEBUG, "P2P: * Manageability: bitmap 0x%x",
  267|    275|			   data[0]);
  268|    275|		break;
  269|    491|	case P2P_ATTR_NOTICE_OF_ABSENCE:
  ------------------
  |  Branch (269:2): [True: 491, False: 53.8k]
  ------------------
  270|    491|		if (len < 2) {
  ------------------
  |  Branch (270:7): [True: 8, False: 483]
  ------------------
  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|    483|		msg->noa = data;
  276|    483|		msg->noa_len = len;
  277|    483|		wpa_printf(MSG_DEBUG, "P2P: * Notice of Absence");
  278|    483|		break;
  279|    244|	case P2P_ATTR_EXT_LISTEN_TIMING:
  ------------------
  |  Branch (279:2): [True: 244, False: 54.0k]
  ------------------
  280|    244|		if (len < 4) {
  ------------------
  |  Branch (280:7): [True: 13, False: 231]
  ------------------
  281|     13|			wpa_printf(MSG_DEBUG, "P2P: Too short Extended Listen "
  282|     13|				   "Timing attribute (length %d)", len);
  283|     13|			return -1;
  284|     13|		}
  285|    231|		msg->ext_listen_timing = data;
  286|    231|		wpa_printf(MSG_DEBUG, "P2P: * Extended Listen Timing "
  287|    231|			   "(period %u msec  interval %u msec)",
  288|    231|			   WPA_GET_LE16(msg->ext_listen_timing),
  289|    231|			   WPA_GET_LE16(msg->ext_listen_timing + 2));
  290|    231|		break;
  291|    244|	case P2P_ATTR_MINOR_REASON_CODE:
  ------------------
  |  Branch (291:2): [True: 244, False: 54.0k]
  ------------------
  292|    244|		if (len < 1) {
  ------------------
  |  Branch (292:7): [True: 15, False: 229]
  ------------------
  293|     15|			wpa_printf(MSG_DEBUG, "P2P: Too short Minor Reason "
  294|     15|				   "Code attribute (length %d)", len);
  295|     15|			return -1;
  296|     15|		}
  297|    229|		msg->minor_reason_code = data;
  298|    229|		wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u",
  299|    229|			   *msg->minor_reason_code);
  300|    229|		break;
  301|    234|	case P2P_ATTR_OOB_GO_NEG_CHANNEL:
  ------------------
  |  Branch (301:2): [True: 234, False: 54.0k]
  ------------------
  302|    234|		if (len < 6) {
  ------------------
  |  Branch (302:7): [True: 15, False: 219]
  ------------------
  303|     15|			wpa_printf(MSG_DEBUG, "P2P: Too short OOB GO Neg "
  304|     15|				   "Channel attribute (length %d)", len);
  305|     15|			return -1;
  306|     15|		}
  307|    219|		msg->oob_go_neg_channel = data;
  308|    219|		wpa_printf(MSG_DEBUG, "P2P: * OOB GO Neg Channel: "
  309|    219|			   "Country %c%c(0x%02x) Operating Class %d "
  310|    219|			   "Channel Number %d Role %d",
  311|    219|			   data[0], data[1], data[2], data[3], data[4],
  312|    219|			   data[5]);
  313|    219|		break;
  314|    218|	case P2P_ATTR_SERVICE_HASH:
  ------------------
  |  Branch (314:2): [True: 218, False: 54.1k]
  ------------------
  315|    218|		if (len < P2PS_HASH_LEN) {
  ------------------
  |  |   35|    218|#define P2PS_HASH_LEN 6
  ------------------
  |  Branch (315:7): [True: 6, False: 212]
  ------------------
  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|    212|		msg->service_hash_count = len / P2PS_HASH_LEN;
  ------------------
  |  |   35|    212|#define P2PS_HASH_LEN 6
  ------------------
  322|    212|		msg->service_hash = data;
  323|    212|		wpa_hexdump(MSG_DEBUG, "P2P: * Service Hash(s)", data, len);
  324|    212|		break;
  325|    211|	case P2P_ATTR_SESSION_INFORMATION_DATA:
  ------------------
  |  Branch (325:2): [True: 211, False: 54.1k]
  ------------------
  326|    211|		msg->session_info = data;
  327|    211|		msg->session_info_len = len;
  328|    211|		wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %u bytes - %p",
  329|    211|			   len, data);
  330|    211|		break;
  331|    440|	case P2P_ATTR_CONNECTION_CAPABILITY:
  ------------------
  |  Branch (331:2): [True: 440, False: 53.8k]
  ------------------
  332|    440|		if (len < 1) {
  ------------------
  |  Branch (332:7): [True: 19, False: 421]
  ------------------
  333|     19|			wpa_printf(MSG_DEBUG,
  334|     19|				   "P2P: Too short Connection Capability (length %u)",
  335|     19|				   len);
  336|     19|			return -1;
  337|     19|		}
  338|    421|		msg->conn_cap = data;
  339|    421|		wpa_printf(MSG_DEBUG, "P2P: * Connection Capability: 0x%x",
  340|    421|			   *msg->conn_cap);
  341|    421|		break;
  342|    418|	case P2P_ATTR_ADVERTISEMENT_ID:
  ------------------
  |  Branch (342:2): [True: 418, False: 53.9k]
  ------------------
  343|    418|		if (len < 10) {
  ------------------
  |  Branch (343:7): [True: 12, False: 406]
  ------------------
  344|     12|			wpa_printf(MSG_DEBUG,
  345|     12|				   "P2P: Too short Advertisement ID (length %u)",
  346|     12|				   len);
  347|     12|			return -1;
  348|     12|		}
  349|    406|		msg->adv_id = data;
  350|    406|		msg->adv_mac = &data[sizeof(u32)];
  351|    406|		wpa_printf(MSG_DEBUG, "P2P: * Advertisement ID %x",
  352|    406|			   WPA_GET_LE32(data));
  353|    406|		break;
  354|  1.18k|	case P2P_ATTR_ADVERTISED_SERVICE:
  ------------------
  |  Branch (354:2): [True: 1.18k, False: 53.1k]
  ------------------
  355|  1.18k|		if (len < 8) {
  ------------------
  |  Branch (355:7): [True: 14, False: 1.17k]
  ------------------
  356|     14|			wpa_printf(MSG_DEBUG,
  357|     14|				   "P2P: Too short Service Instance (length %u)",
  358|     14|				   len);
  359|     14|			return -1;
  360|     14|		}
  361|  1.17k|		msg->adv_service_instance = data;
  362|  1.17k|		msg->adv_service_instance_len = len;
  363|  1.17k|		if (len <= 255 + 8) {
  ------------------
  |  Branch (363:7): [True: 958, False: 215]
  ------------------
  364|    958|			char str[256];
  365|    958|			u8 namelen;
  366|       |
  367|    958|			namelen = data[6];
  368|    958|			if (namelen > len - 7)
  ------------------
  |  Branch (368:8): [True: 528, False: 430]
  ------------------
  369|    528|				break;
  370|    430|			os_memcpy(str, &data[7], namelen);
  ------------------
  |  |  523|    430|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  371|    430|			str[namelen] = '\0';
  372|    430|			wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %x-%s",
  373|    430|				   WPA_GET_LE32(data), str);
  374|    430|		} else {
  375|    215|			wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %p",
  376|    215|				   data);
  377|    215|		}
  378|    645|		break;
  379|    645|	case P2P_ATTR_SESSION_ID:
  ------------------
  |  Branch (379:2): [True: 486, False: 53.8k]
  ------------------
  380|    486|		if (len < sizeof(u32) + ETH_ALEN) {
  ------------------
  |  |  344|    486|#define ETH_ALEN 6
  ------------------
  |  Branch (380:7): [True: 18, False: 468]
  ------------------
  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|    468|		msg->session_id = data;
  387|    468|		msg->session_mac = &data[sizeof(u32)];
  388|    468|		wpa_printf(MSG_DEBUG, "P2P: * Session ID: %x " MACSTR,
  ------------------
  |  |  448|    468|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  389|    468|			   WPA_GET_LE32(data), MAC2STR(msg->session_mac));
  ------------------
  |  |  447|    468|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  390|    468|		break;
  391|    494|	case P2P_ATTR_FEATURE_CAPABILITY:
  ------------------
  |  Branch (391:2): [True: 494, False: 53.8k]
  ------------------
  392|    494|		if (!len) {
  ------------------
  |  Branch (392:7): [True: 6, False: 488]
  ------------------
  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|    488|		msg->feature_cap = data;
  399|    488|		msg->feature_cap_len = len;
  400|    488|		wpa_printf(MSG_DEBUG, "P2P: * Feature Cap (length=%u)", len);
  401|    488|		break;
  402|  6.14k|	case P2P_ATTR_PERSISTENT_GROUP:
  ------------------
  |  Branch (402:2): [True: 6.14k, False: 48.1k]
  ------------------
  403|  6.14k|	{
  404|  6.14k|		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  12.2k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  344|  6.13k|#define ETH_ALEN 6
  ------------------
              		if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
  ------------------
  |  |  511|  6.13k|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (404:7): [True: 8, False: 6.13k]
  |  Branch (404:25): [True: 58, False: 6.07k]
  ------------------
  405|     66|			wpa_printf(MSG_DEBUG,
  406|     66|				   "P2P: Invalid Persistent Group Info (length %u)",
  407|     66|				   len);
  408|     66|			return -1;
  409|     66|		}
  410|       |
  411|  6.07k|		msg->persistent_dev = data;
  412|  6.07k|		msg->persistent_ssid_len = len - ETH_ALEN;
  ------------------
  |  |  344|  6.07k|#define ETH_ALEN 6
  ------------------
  413|  6.07k|		msg->persistent_ssid = &data[ETH_ALEN];
  ------------------
  |  |  344|  6.07k|#define ETH_ALEN 6
  ------------------
  414|  6.07k|		wpa_printf(MSG_DEBUG, "P2P: * Persistent Group: " MACSTR " %s",
  415|  6.07k|			   MAC2STR(msg->persistent_dev),
  ------------------
  |  |  447|  6.07k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  416|  6.07k|			   wpa_ssid_txt(msg->persistent_ssid,
  417|  6.07k|					msg->persistent_ssid_len));
  418|  6.07k|		break;
  419|  6.14k|	}
  420|    345|	case P2P_ATTR_CAPABILITY_EXTENSION:
  ------------------
  |  Branch (420:2): [True: 345, False: 53.9k]
  ------------------
  421|    345|		if (len < 2) {
  ------------------
  |  Branch (421:7): [True: 10, False: 335]
  ------------------
  422|     10|			wpa_printf(MSG_DEBUG, "P2P: Too short PCEA (length %d)",
  423|     10|				   len);
  424|     10|			return -1;
  425|     10|		}
  426|    335|		msg->pcea_info = data;
  427|    335|		msg->pcea_info_len = len;
  428|    335|		wpa_printf(MSG_DEBUG, "P2P: * PCEA (length=%u)", len);
  429|    335|		break;
  430|    555|	case P2P_ATTR_PAIRING_AND_BOOTSTRAPPING:
  ------------------
  |  Branch (430:2): [True: 555, False: 53.7k]
  ------------------
  431|    555|		if (len < 1) {
  ------------------
  |  Branch (431:7): [True: 6, False: 549]
  ------------------
  432|      6|			wpa_printf(MSG_DEBUG, "P2P: Too short PBMA (length %d)",
  433|      6|				   len);
  434|      6|			return -1;
  435|      6|		}
  436|    549|		msg->pbma_info = data;
  437|    549|		msg->pbma_info_len = len;
  438|    549|		wpa_printf(MSG_DEBUG, "P2P: * PBMA (length=%u)", len);
  439|    549|		break;
  440|    318|	case P2P_ATTR_ACTION_FRAME_WRAPPER:
  ------------------
  |  Branch (440:2): [True: 318, False: 54.0k]
  ------------------
  441|    318|		if (len < 2) {
  ------------------
  |  Branch (441:7): [True: 8, False: 310]
  ------------------
  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|    310|		msg->action_frame_wrapper = data;
  448|    310|		msg->action_frame_wrapper_len = len;
  449|    310|		wpa_printf(MSG_DEBUG, "P2P: * Action frame wrapper (length=%u)",
  450|    310|			   len);
  451|    310|		break;
  452|    322|	case P2P_ATTR_DEVICE_IDENTITY_RESOLUTION:
  ------------------
  |  Branch (452:2): [True: 322, False: 54.0k]
  ------------------
  453|    322|		if (len < 1) {
  ------------------
  |  Branch (453:7): [True: 6, False: 316]
  ------------------
  454|      6|			wpa_printf(MSG_DEBUG, "P2P: Too short DIRA (length %d)",
  455|      6|				   len);
  456|      6|			return -1;
  457|      6|		}
  458|    316|		msg->dira = data;
  459|    316|		msg->dira_len = len;
  460|    316|		wpa_printf(MSG_DEBUG, "P2P: * DIRA (length=%u)", len);
  461|    316|		break;
  462|    250|	case P2P_ATTR_WLAN_AP_INFORMATION:
  ------------------
  |  Branch (462:2): [True: 250, False: 54.0k]
  ------------------
  463|       |		/* One or more AP Info fields (each being 12 octets) is required
  464|       |		 * to be included. */
  465|    250|		if (len < 12) {
  ------------------
  |  Branch (465:7): [True: 19, False: 231]
  ------------------
  466|     19|			wpa_printf(MSG_DEBUG,
  467|     19|				   "P2P: Too short WLAN AP info (length %d)",
  468|     19|				   len);
  469|     19|			return -1;
  470|     19|		}
  471|    231|		msg->wlan_ap_info = data;
  472|    231|		msg->wlan_ap_info_len = len;
  473|    231|		break;
  474|    788|	default:
  ------------------
  |  Branch (474:2): [True: 788, False: 53.5k]
  ------------------
  475|    788|		wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d "
  476|    788|			   "(length %d)", id, len);
  477|    788|		break;
  478|  54.3k|	}
  479|       |
  480|  53.5k|	return 0;
  481|  54.3k|}
p2p_parse.c:p2p_parse_wps_ie:
  530|  4.80k|{
  531|  4.80k|	struct wps_parse_attr attr;
  532|  4.80k|	int i;
  533|       |
  534|  4.80k|	wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE");
  535|  4.80k|	if (wps_parse_msg(buf, &attr))
  ------------------
  |  Branch (535:6): [True: 2.00k, False: 2.80k]
  ------------------
  536|  2.00k|		return -1;
  537|  2.80k|	if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) &&
  ------------------
  |  Branch (537:6): [True: 58, False: 2.74k]
  |  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.80k|	if (attr.config_methods) {
  ------------------
  |  Branch (540:6): [True: 331, False: 2.47k]
  ------------------
  541|    331|		msg->wps_config_methods =
  542|    331|			WPA_GET_BE16(attr.config_methods);
  543|    331|		wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x",
  544|    331|			   msg->wps_config_methods);
  545|    331|	}
  546|  2.80k|	if (attr.dev_password_id) {
  ------------------
  |  Branch (546:6): [True: 24, False: 2.77k]
  ------------------
  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.80k|	if (attr.primary_dev_type) {
  ------------------
  |  Branch (552:6): [True: 53, False: 2.74k]
  ------------------
  553|     53|		char devtype[WPS_DEV_TYPE_BUFSIZE];
  554|     53|		msg->wps_pri_dev_type = attr.primary_dev_type;
  555|     53|		wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s",
  556|     53|			   wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype,
  557|     53|						sizeof(devtype)));
  558|     53|	}
  559|  2.80k|	if (attr.sec_dev_type_list) {
  ------------------
  |  Branch (559:6): [True: 42, False: 2.76k]
  ------------------
  560|     42|		msg->wps_sec_dev_type_list = attr.sec_dev_type_list;
  561|     42|		msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len;
  562|     42|	}
  563|       |
  564|  30.8k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  30.8k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (564:14): [True: 28.0k, False: 2.80k]
  ------------------
  565|  28.0k|		msg->wps_vendor_ext[i] = attr.vendor_ext[i];
  566|  28.0k|		msg->wps_vendor_ext_len[i] = attr.vendor_ext_len[i];
  567|  28.0k|	}
  568|       |
  569|  2.80k|	msg->manufacturer = attr.manufacturer;
  570|  2.80k|	msg->manufacturer_len = attr.manufacturer_len;
  571|  2.80k|	msg->model_name = attr.model_name;
  572|  2.80k|	msg->model_name_len = attr.model_name_len;
  573|  2.80k|	msg->model_number = attr.model_number;
  574|  2.80k|	msg->model_number_len = attr.model_number_len;
  575|  2.80k|	msg->serial_number = attr.serial_number;
  576|  2.80k|	msg->serial_number_len = attr.serial_number_len;
  577|       |
  578|  2.80k|	msg->oob_dev_password = attr.oob_dev_password;
  579|  2.80k|	msg->oob_dev_password_len = attr.oob_dev_password_len;
  580|       |
  581|  2.80k|	return 0;
  582|  4.80k|}

p2p_process_pcea:
  662|     50|{
  663|     50|	const u8 *pos, *end;
  664|     50|	u8 cap_info_len;
  665|       |
  666|     50|	if (!p2p || !dev || !msg || !msg->pcea_info)
  ------------------
  |  Branch (666:6): [True: 0, False: 50]
  |  Branch (666:14): [True: 0, False: 50]
  |  Branch (666:22): [True: 0, False: 50]
  |  Branch (666:30): [True: 0, False: 50]
  ------------------
  667|      0|		return;
  668|       |
  669|     50|	pos = msg->pcea_info;
  670|     50|	end = pos + msg->pcea_info_len;
  671|     50|	dev->info.pcea_cap_info = WPA_GET_LE16(pos);
  672|     50|	cap_info_len = dev->info.pcea_cap_info & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1869|     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))
  |  |  ------------------
  ------------------
  673|       |
  674|       |	/* Field length is (n-1), n in octets */
  675|     50|	if (end - pos < cap_info_len + 1)
  ------------------
  |  Branch (675:6): [True: 12, False: 38]
  ------------------
  676|     12|		return;
  677|     38|	pos += cap_info_len + 1;
  678|       |
  679|     38|	if (dev->info.pcea_cap_info & P2P_PCEA_6GHZ)
  ------------------
  |  | 1870|     38|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     38|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (679:6): [True: 18, False: 20]
  ------------------
  680|     18|		dev->support_6ghz = true;
  681|       |
  682|     38|	if (dev->info.pcea_cap_info & P2P_PCEA_REG_INFO) {
  ------------------
  |  | 1871|     38|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     38|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (682:6): [True: 26, False: 12]
  ------------------
  683|     26|		if (end - pos < 1) {
  ------------------
  |  Branch (683:7): [True: 5, False: 21]
  ------------------
  684|      5|			p2p_dbg(p2p, "Truncated PCEA");
  685|      5|			return;
  686|      5|		}
  687|     21|		dev->info.reg_info = *pos++;
  688|     21|	}
  689|       |
  690|     33|	if (dev->info.pcea_cap_info & P2P_PCEA_PASN_TYPE) {
  ------------------
  |  | 1877|     33|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     33|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (690:6): [True: 21, False: 12]
  ------------------
  691|     21|		if (end - pos < 1) {
  ------------------
  |  Branch (691:7): [True: 3, False: 18]
  ------------------
  692|      3|			p2p_dbg(p2p, "Truncated PCEA");
  693|      3|			return;
  694|      3|		}
  695|     18|		dev->info.pairing_config.pasn_type = *pos++;
  696|     18|	}
  697|       |
  698|     30|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_CAPABLE)
  ------------------
  |  | 1874|     30|#define P2P_PCEA_PAIRING_CAPABLE BIT(8)
  |  |  ------------------
  |  |  |  |  458|     30|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (698:6): [True: 14, False: 16]
  ------------------
  699|     14|		dev->info.pairing_config.pairing_capable = true;
  700|       |
  701|     30|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_SETUP_ENABLED)
  ------------------
  |  | 1875|     30|#define P2P_PCEA_PAIRING_SETUP_ENABLED BIT(9)
  |  |  ------------------
  |  |  |  |  458|     30|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (701:6): [True: 15, False: 15]
  ------------------
  702|     15|		dev->info.pairing_config.enable_pairing_setup = true;
  703|       |
  704|     30|	if (dev->info.pcea_cap_info & P2P_PCEA_PMK_CACHING) {
  ------------------
  |  | 1876|     30|#define P2P_PCEA_PMK_CACHING BIT(10)
  |  |  ------------------
  |  |  |  |  458|     30|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (704:6): [True: 17, False: 13]
  ------------------
  705|       |		dev->info.pairing_config.enable_pairing_cache = true;
  706|     17|	}
  707|     30|}
p2p_handle_prov_disc_req:
 1521|  1.04k|{
 1522|  1.04k|	struct p2p_message msg;
 1523|       |
 1524|  1.04k|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (1524:6): [True: 234, False: 807]
  ------------------
 1525|    234|		return;
 1526|       |
 1527|    807|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (1527:6): [True: 56, False: 751]
  |  Branch (1527:23): [True: 53, False: 3]
  ------------------
 1528|     53|		p2p_process_prov_disc_bootstrap_req(p2p, &msg, sa, data + 1,
 1529|     53|						    len - 1, rx_freq);
 1530|    754|	else
 1531|    754|		p2p_process_prov_disc_req(p2p, &msg, sa, data + 1, len - 1,
 1532|    754|					  rx_freq);
 1533|       |
 1534|    807|	p2p_parse_free(&msg);
 1535|    807|}
p2p_handle_prov_disc_resp:
 2054|     28|{
 2055|     28|	struct p2p_message msg;
 2056|       |
 2057|     28|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (2057:6): [True: 9, False: 19]
  ------------------
 2058|      9|		return;
 2059|       |
 2060|     19|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (2060:6): [True: 4, False: 15]
  |  Branch (2060:23): [True: 3, False: 1]
  ------------------
 2061|      3|		p2p_process_prov_disc_bootstrap_resp(p2p, &msg, sa, data + 1,
 2062|      3|						     len - 1, rx_freq);
 2063|     16|	else
 2064|     16|		p2p_process_prov_disc_resp(p2p, &msg, sa, data + 1, len - 1);
 2065|       |
 2066|     19|	p2p_parse_free(&msg);
 2067|     19|}
p2p_reset_pending_pd:
 2250|  6.57k|{
 2251|  6.57k|	struct p2p_device *dev;
 2252|       |
 2253|  6.57k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  6.57k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  6.57k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 0, False: 6.57k]
  |  |  ------------------
  |  |   81|  6.57k|	     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.57k|	p2p->user_initiated_pd = 0;
 2266|  6.57k|	os_memset(p2p->pending_pd_devaddr, 0, ETH_ALEN);
  ------------------
  |  |  529|  6.57k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2267|  6.57k|	p2p->pd_retries = 0;
 2268|  6.57k|	p2p->pd_force_freq = 0;
 2269|  6.57k|}
p2ps_prov_free:
 2273|  19.8k|{
 2274|  19.8k|	os_free(p2p->p2ps_prov);
  ------------------
  |  |  511|  19.8k|#define os_free(p) free((p))
  ------------------
 2275|       |	p2p->p2ps_prov = NULL;
 2276|  19.8k|}
p2p_pd.c:p2p_process_prov_disc_bootstrap_req:
  714|     53|{
  715|     53|	struct p2p_device *dev;
  716|     53|	int freq;
  717|     53|	struct wpabuf *resp;
  718|     53|	u16 bootstrap;
  719|     53|	size_t cookie_len = 0;
  720|     53|	const u8 *pos, *cookie;
  721|     53|	enum p2p_status_code status = P2P_SC_FAIL_INVALID_PARAMS;
  722|       |
  723|     53|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  724|     53|		" with bootstrapping Attribute (freq=%d)",
  725|     53|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     53|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  726|       |
  727|     53|	dev = p2p_get_device(p2p, sa);
  728|     53|	if (!dev) {
  ------------------
  |  Branch (728:6): [True: 16, False: 37]
  ------------------
  729|     16|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  730|     16|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|     16|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|     16|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  731|       |
  732|     16|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (732:7): [True: 2, False: 14]
  ------------------
  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|     14|		dev = p2p_get_device(p2p, sa);
  740|     14|		if (!dev) {
  ------------------
  |  Branch (740:7): [True: 1, False: 13]
  ------------------
  741|      1|			p2p_dbg(p2p,
  742|      1|				"Provision Discovery device not found "
  743|      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]
  ------------------
  744|      1|			return;
  745|      1|		}
  746|     14|	}
  747|     50|	dev->p2p2 = true;
  748|       |
  749|     50|	if (p2p->send_action_in_progress) {
  ------------------
  |  Branch (749:6): [True: 0, False: 50]
  ------------------
  750|      0|		p2p_dbg(p2p, "Dropping retry frame as response TX pending");
  751|      0|		return;
  752|      0|	}
  753|       |
  754|     50|	p2p_update_peer_6ghz_capab(dev, msg);
  755|       |
  756|     50|	if (msg->pcea_info && msg->pcea_info_len >= 2)
  ------------------
  |  Branch (756:6): [True: 50, False: 0]
  |  Branch (756:24): [True: 50, False: 0]
  ------------------
  757|     50|		p2p_process_pcea(p2p, msg, dev);
  758|       |
  759|     50|	pos = msg->pbma_info;
  760|       |
  761|     50|	if (msg->pbma_info_len > 2 && msg->status &&
  ------------------
  |  Branch (761:6): [True: 37, False: 13]
  |  Branch (761:32): [True: 26, False: 11]
  ------------------
  762|     26|	    *msg->status == P2P_SC_COMEBACK) {
  ------------------
  |  Branch (762:6): [True: 15, False: 11]
  ------------------
  763|       |		/* PBMA comeback request */
  764|     15|		cookie_len = *pos++;
  765|     15|		if (msg->pbma_info_len < 1 + cookie_len) {
  ------------------
  |  Branch (765:7): [True: 7, False: 8]
  ------------------
  766|      7|			p2p_dbg(p2p, "Truncated PBMA");
  767|      7|			return;
  768|      7|		}
  769|      8|		cookie = pos;
  770|       |
  771|      8|		if (!dev->bootstrap_params ||
  ------------------
  |  Branch (771:7): [True: 8, 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|      8|			      cookie_len) != 0) {
  775|      8|			status = P2P_SC_FAIL_REJECTED_BY_USER;
  776|      8|			goto out;
  777|      8|		}
  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|     35|	} else {
  786|       |		/* PBMA request */
  787|     35|		bootstrap = WPA_GET_LE16(pos);
  788|       |
  789|     35|		os_free(dev->bootstrap_params);
  ------------------
  |  |  511|     35|#define os_free(p) free((p))
  ------------------
  790|     35|		dev->bootstrap_params = NULL;
  791|       |
  792|     35|		if (!dev->req_bootstrap_method) {
  ------------------
  |  Branch (792:7): [True: 35, False: 0]
  ------------------
  793|     35|			dev->bootstrap_params =
  794|     35|				os_zalloc(sizeof(struct p2p_bootstrap_params));
  795|     35|			if (!dev->bootstrap_params)
  ------------------
  |  Branch (795:8): [True: 0, False: 35]
  ------------------
  796|      0|				return;
  797|     35|			dev->bootstrap_params->bootstrap_method = bootstrap;
  798|     35|			dev->bootstrap_params->cookie_len = 4;
  799|     35|			if (os_get_random(dev->bootstrap_params->cookie,
  ------------------
  |  Branch (799:8): [True: 0, False: 35]
  ------------------
  800|     35|					  dev->bootstrap_params->cookie_len) <
  801|     35|			    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|     35|			dev->bootstrap_params->comeback_after =
  807|     35|				p2p->cfg->comeback_after;
  808|     35|			status = P2P_SC_COMEBACK;
  809|     35|			if (p2p->cfg->bootstrap_req_rx)
  ------------------
  |  Branch (809:8): [True: 0, False: 35]
  ------------------
  810|      0|				p2p->cfg->bootstrap_req_rx(p2p->cfg->cb_ctx,
  811|      0|							   sa, bootstrap);
  812|     35|			goto out;
  813|     35|		}
  814|     35|	}
  815|       |
  816|      0|	if (bootstrap == P2P_PBMA_PIN_CODE_DISPLAY &&
  ------------------
  |  | 1882|      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)
  ------------------
  |  | 1886|      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 &&
  ------------------
  |  | 1886|      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)
  ------------------
  |  | 1882|      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 &&
  ------------------
  |  | 1883|      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)
  ------------------
  |  | 1887|      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 &&
  ------------------
  |  | 1887|      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)
  ------------------
  |  | 1883|      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 &&
  ------------------
  |  | 1885|      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)
  ------------------
  |  | 1889|      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 &&
  ------------------
  |  | 1889|      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)
  ------------------
  |  | 1885|      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 &&
  ------------------
  |  | 1884|      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)
  ------------------
  |  | 1888|      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 &&
  ------------------
  |  | 1888|      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)
  ------------------
  |  | 1884|      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 &&
  ------------------
  |  | 1881|      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)
  ------------------
  |  | 1881|      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|     43|out:
  855|       |	/* Send PD Bootstrapping Response for the PD Request */
  856|     43|	resp = p2p_build_prov_disc_bootstrap_resp(p2p, dev, msg->dialog_token,
  857|     43|						  status);
  858|     43|	if (!resp)
  ------------------
  |  Branch (858:6): [True: 0, False: 43]
  ------------------
  859|      0|		return;
  860|       |
  861|     43|	p2p_dbg(p2p, "Sending Provision Discovery Bootstrap Response");
  862|     43|	if (rx_freq > 0)
  ------------------
  |  Branch (862:6): [True: 43, False: 0]
  ------------------
  863|     43|		freq = rx_freq;
  864|      0|	else
  865|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  866|      0|					   p2p->cfg->channel);
  867|     43|	if (freq < 0) {
  ------------------
  |  Branch (867:6): [True: 0, False: 43]
  ------------------
  868|      0|		p2p_dbg(p2p, "Unknown operating class/channel");
  869|      0|		wpabuf_free(resp);
  870|      0|		return;
  871|      0|	}
  872|     43|	p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
  873|     43|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (873:6): [True: 0, False: 43]
  ------------------
  874|     43|			    p2p->cfg->dev_addr, wpabuf_head(resp),
  875|     43|			    wpabuf_len(resp), 50) < 0)
  876|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  877|     43|	else
  878|     43|		p2p->send_action_in_progress = 1;
  879|       |
  880|     43|	wpabuf_free(resp);
  881|     43|}
p2p_pd.c:p2p_build_prov_disc_bootstrap_resp:
  313|     43|{
  314|     43|	struct wpabuf *buf;
  315|     43|	u8 *cookie = NULL;
  316|     43|	size_t cookie_len = 0;
  317|     43|	int comeback_after = 0;
  318|     43|	u8 *len;
  319|       |
  320|     43|	buf = wpabuf_alloc(1000);
  321|     43|	if (!buf)
  ------------------
  |  Branch (321:6): [True: 0, False: 43]
  ------------------
  322|      0|		return NULL;
  323|       |
  324|     43|	p2p_dbg(p2p, "P2P2: Building boostrapping PD Response");
  325|     43|	if (status == P2P_SC_COMEBACK && dev->bootstrap_params) {
  ------------------
  |  Branch (325:6): [True: 35, False: 8]
  |  Branch (325:35): [True: 35, False: 0]
  ------------------
  326|     35|		cookie = dev->bootstrap_params->cookie;
  327|     35|		cookie_len = dev->bootstrap_params->cookie_len;
  328|     35|		comeback_after = dev->bootstrap_params->comeback_after;
  329|     35|	}
  330|       |
  331|     43|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  332|       |
  333|     43|	len = p2p_buf_add_p2p2_ie_hdr(buf);
  334|       |
  335|     43|	p2p_buf_add_status(buf, status);
  336|     43|	p2p_buf_add_pcea(buf, p2p);
  337|     43|	p2p_buf_add_pbma(buf, dev->req_bootstrap_method, cookie, cookie_len,
  338|     43|			 comeback_after);
  339|       |
  340|     43|	p2p_buf_update_ie_hdr(buf, len);
  341|       |
  342|     43|	return buf;
  343|     43|}
p2p_pd.c:p2p_process_prov_disc_req:
  887|    754|{
  888|    754|	struct p2p_device *dev;
  889|    754|	int freq;
  890|    754|	enum p2p_status_code reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
  891|    754|	struct wpabuf *resp;
  892|    754|	u32 adv_id = 0;
  893|    754|	struct p2ps_advertisement *p2ps_adv = NULL;
  894|    754|	u8 conncap = P2PS_SETUP_NEW;
  ------------------
  |  |   30|    754|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|    754|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  895|    754|	u8 auto_accept = 0;
  896|    754|	u32 session_id = 0;
  897|    754|	u8 session_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  898|    754|	u8 adv_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  899|    754|	const u8 *group_mac;
  900|    754|	int passwd_id = DEV_PW_DEFAULT;
  901|    754|	u16 config_methods;
  902|    754|	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|    754|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|    754|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  903|    754|	struct p2ps_feature_capab resp_fcap = { 0, 0 };
  904|    754|	struct p2ps_feature_capab *req_fcap = NULL;
  905|    754|	u8 remote_conncap;
  906|    754|	u16 method;
  907|       |
  908|    754|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  909|    754|		" with config methods 0x%x (freq=%d)",
  910|    754|		MAC2STR(sa), msg->wps_config_methods, rx_freq);
  ------------------
  |  |  447|    754|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  911|    754|	group_mac = msg->intended_addr;
  912|       |
  913|    754|	dev = p2p_get_device(p2p, sa);
  914|    754|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     58|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     58|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (914:6): [True: 696, False: 58]
  |  Branch (914:21): [True: 5, False: 53]
  ------------------
  915|    701|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  916|    701|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    701|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    701|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  917|       |
  918|    701|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (918:7): [True: 310, False: 391]
  ------------------
  919|    310|			p2p_dbg(p2p, "Provision Discovery Request add device failed "
  920|    310|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    310|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    310|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  921|    310|			goto out;
  922|    310|		}
  923|       |
  924|    391|		dev = p2p_get_device(p2p, sa);
  925|    391|		if (!dev) {
  ------------------
  |  Branch (925:7): [True: 295, False: 96]
  ------------------
  926|    295|			p2p_dbg(p2p,
  927|    295|				"Provision Discovery device not found "
  928|    295|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    295|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    295|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  929|    295|			goto out;
  930|    295|		}
  931|    391|	} else if (msg->wfd_subelems) {
  ------------------
  |  Branch (931:13): [True: 1, False: 52]
  ------------------
  932|      1|		wpabuf_free(dev->info.wfd_subelems);
  933|      1|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
  934|      1|	}
  935|       |
  936|    149|	p2p_update_peer_6ghz_capab(dev, msg);
  937|       |
  938|    149|	if (!msg->adv_id) {
  ------------------
  |  Branch (938:6): [True: 54, False: 95]
  ------------------
  939|     54|		allowed_config_methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|     54|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  940|     54|		if (!(msg->wps_config_methods & allowed_config_methods)) {
  ------------------
  |  Branch (940:7): [True: 15, False: 39]
  ------------------
  941|     15|			p2p_dbg(p2p,
  942|     15|				"Unsupported Config Methods in Provision Discovery Request");
  943|     15|			goto out;
  944|     15|		}
  945|       |
  946|       |		/* Legacy (non-P2PS) - Unknown groups allowed for P2PS */
  947|     39|		if (msg->group_id) {
  ------------------
  |  Branch (947:7): [True: 1, False: 38]
  ------------------
  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|     95|	} else {
  963|     95|		allowed_config_methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     95|#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|     95|		adv_id = WPA_GET_LE32(msg->adv_id);
  970|     95|		if (p2ps_validate_pd_req(p2p, msg, sa) < 0) {
  ------------------
  |  Branch (970:7): [True: 23, False: 72]
  ------------------
  971|     23|			reject = P2P_SC_FAIL_INVALID_PARAMS;
  972|     23|			goto out;
  973|     23|		}
  974|       |
  975|     72|		req_fcap = (struct p2ps_feature_capab *) msg->feature_cap;
  976|       |
  977|     72|		os_memcpy(session_mac, msg->session_mac, ETH_ALEN);
  ------------------
  |  |  523|     72|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  978|     72|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|     72|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  979|       |
  980|     72|		session_id = WPA_GET_LE32(msg->session_id);
  981|       |
  982|     72|		if (msg->conn_cap)
  ------------------
  |  Branch (982:7): [True: 58, False: 14]
  ------------------
  983|     58|			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|     72|		if ((!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) &&
  ------------------
  |  Branch (990:8): [True: 5, False: 67]
  |  Branch (990:24): [True: 51, False: 16]
  ------------------
  991|     56|		    !(msg->wps_config_methods & allowed_config_methods)) {
  ------------------
  |  Branch (991:7): [True: 4, False: 52]
  ------------------
  992|      4|			p2p_dbg(p2p,
  993|      4|				"Unsupported Config Methods in Provision Discovery Request");
  994|      4|			goto out;
  995|      4|		}
  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|     72|	}
 1002|       |
 1003|    106|	dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
  ------------------
  |  |  130|    106|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|    106|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1004|    106|			P2P_DEV_PD_PEER_KEYPAD |
  ------------------
  |  |  131|    106|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|    106|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1005|    106|			P2P_DEV_PD_PEER_P2PS);
  ------------------
  |  |  146|    106|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|    106|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1006|       |
 1007|    106|	if (msg->wps_config_methods & WPS_CONFIG_DISPLAY) {
  ------------------
  |  |  251|    106|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1007:6): [True: 41, False: 65]
  ------------------
 1008|     41|		p2p_dbg(p2p, "Peer " MACSTR
 1009|     41|			" requested us to show a PIN on display", MAC2STR(sa));
  ------------------
  |  |  447|     41|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1010|     41|		dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
  ------------------
  |  |  131|     41|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|     41|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1011|     41|		passwd_id = DEV_PW_USER_SPECIFIED;
 1012|     65|	} else if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|     65|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1012:13): [True: 34, False: 31]
  ------------------
 1013|     34|		p2p_dbg(p2p, "Peer " MACSTR
 1014|     34|			" requested us to write its PIN using keypad",
 1015|     34|			MAC2STR(sa));
  ------------------
  |  |  447|     34|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1016|     34|		dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
  ------------------
  |  |  130|     34|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|     34|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1017|     34|		passwd_id = DEV_PW_REGISTRAR_SPECIFIED;
 1018|     34|	} else if (msg->wps_config_methods & WPS_CONFIG_P2PS) {
  ------------------
  |  |  259|     31|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1018:13): [True: 14, False: 17]
  ------------------
 1019|     14|		p2p_dbg(p2p, "Peer " MACSTR " requesting P2PS PIN",
 1020|     14|			MAC2STR(sa));
  ------------------
  |  |  447|     14|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1021|     14|		dev->flags |= P2P_DEV_PD_PEER_P2PS;
  ------------------
  |  |  146|     14|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|     14|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1022|     14|		passwd_id = DEV_PW_P2PS_DEFAULT;
 1023|     14|	}
 1024|       |
 1025|       |	/* Remove stale persistent groups */
 1026|    106|	if (p2p->cfg->remove_stale_groups) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 106]
  ------------------
 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|    106|	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|    106|	if (!msg->adv_id)
  ------------------
  |  Branch (1039:6): [True: 38, False: 68]
  ------------------
 1040|     38|		goto out;
 1041|       |
 1042|     68|	remote_conncap = conncap;
 1043|       |
 1044|     68|	if (!msg->status) {
  ------------------
  |  Branch (1044:6): [True: 2, False: 66]
  ------------------
 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|     66|	if (!msg->status && !auto_accept &&
  ------------------
  |  Branch (1176:6): [True: 0, False: 66]
  |  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|     66|	if (!msg->status)
  ------------------
  |  Branch (1197:6): [True: 0, False: 66]
  ------------------
 1198|      0|		goto out;
 1199|       |
 1200|     66|	if (*msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1200:6): [True: 63, False: 3]
  |  Branch (1200:22): [True: 13, False: 50]
  ------------------
 1201|     13|		reject = *msg->status;
 1202|     13|		goto out;
 1203|     13|	}
 1204|       |
 1205|     53|	if (*msg->status != P2P_SC_SUCCESS_DEFERRED || !p2p->p2ps_prov)
  ------------------
  |  Branch (1205:6): [True: 3, False: 50]
  |  Branch (1205:49): [True: 50, False: 0]
  ------------------
 1206|     53|		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|    754|out:
 1288|    754|	if (reject == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (1288:6): [True: 91, False: 663]
  ------------------
 1289|    663|	    reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1289:6): [True: 1, False: 662]
  ------------------
 1290|     92|		config_methods = msg->wps_config_methods;
 1291|    662|	else
 1292|    662|		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|    754|	if (!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1298:6): [True: 672, False: 82]
  |  Branch (1298:22): [True: 53, False: 29]
  ------------------
 1299|    725|		resp = p2p_build_prov_disc_resp(p2p, dev, msg->dialog_token,
 1300|    725|						reject, config_methods, adv_id,
 1301|    725|						msg->group_id,
 1302|    725|						msg->group_id_len,
 1303|    725|						msg->persistent_ssid,
 1304|    725|						msg->persistent_ssid_len,
 1305|    725|						(const u8 *) &resp_fcap,
 1306|    725|						sizeof(resp_fcap));
 1307|    725|		if (!resp)
  ------------------
  |  Branch (1307:7): [True: 0, False: 725]
  ------------------
 1308|      0|			return;
 1309|       |
 1310|    725|		p2p_dbg(p2p, "Sending Provision Discovery Response");
 1311|    725|		if (rx_freq > 0)
  ------------------
  |  Branch (1311:7): [True: 725, False: 0]
  ------------------
 1312|    725|			freq = rx_freq;
 1313|      0|		else
 1314|      0|			freq = p2p_channel_to_freq(p2p->cfg->reg_class,
 1315|      0|						   p2p->cfg->channel);
 1316|    725|		if (freq < 0) {
  ------------------
  |  Branch (1316:7): [True: 0, False: 725]
  ------------------
 1317|      0|			p2p_dbg(p2p, "Unknown regulatory class/channel");
 1318|      0|			wpabuf_free(resp);
 1319|      0|			return;
 1320|      0|		}
 1321|    725|		p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
 1322|    725|		if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (1322:7): [True: 0, False: 725]
  ------------------
 1323|    725|				    p2p->cfg->dev_addr,
 1324|    725|				    wpabuf_head(resp), wpabuf_len(resp),
 1325|    725|				    50) < 0)
 1326|      0|			p2p_dbg(p2p, "Failed to send Action frame");
 1327|    725|		else
 1328|    725|			p2p->send_action_in_progress = 1;
 1329|       |
 1330|    725|		wpabuf_free(resp);
 1331|    725|	}
 1332|       |
 1333|    754|	if (!dev)
  ------------------
  |  Branch (1333:6): [True: 604, False: 150]
  ------------------
 1334|    604|		return;
 1335|       |
 1336|    150|	freq = 0;
 1337|    150|	if (reject == P2P_SC_SUCCESS && conncap == P2PS_SETUP_GROUP_OWNER) {
  ------------------
  |  |   32|     91|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|     91|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1337:6): [True: 91, False: 59]
  |  Branch (1337:34): [True: 1, False: 90]
  ------------------
 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|    150|	if (!p2p->cfg->p2ps_prov_complete) {
  ------------------
  |  Branch (1344:6): [True: 150, False: 0]
  ------------------
 1345|       |		/* Don't emit anything */
 1346|    150|	} 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|    150|	if (p2p->cfg->prov_disc_req &&
  ------------------
  |  Branch (1463:6): [True: 0, False: 150]
  ------------------
 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|    150|	if (reject != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1490:6): [True: 149, False: 1]
  ------------------
 1491|    149|		p2ps_prov_free(p2p);
 1492|       |
 1493|    150|	if (reject == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1493:6): [True: 91, False: 59]
  ------------------
 1494|     91|		switch (config_methods) {
 1495|      3|		case WPS_CONFIG_DISPLAY:
  ------------------
  |  |  251|      3|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1495:3): [True: 3, False: 88]
  ------------------
 1496|      3|			dev->wps_prov_info = WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|      3|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
 1497|      3|			break;
 1498|      1|		case WPS_CONFIG_KEYPAD:
  ------------------
  |  |  256|      1|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1498:3): [True: 1, False: 90]
  ------------------
 1499|      1|			dev->wps_prov_info = WPS_CONFIG_DISPLAY;
  ------------------
  |  |  251|      1|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
 1500|      1|			break;
 1501|      1|		case WPS_CONFIG_PUSHBUTTON:
  ------------------
  |  |  255|      1|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  |  Branch (1501:3): [True: 1, False: 90]
  ------------------
 1502|      1|			dev->wps_prov_info = WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|      1|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
 1503|      1|			break;
 1504|      1|		case WPS_CONFIG_P2PS:
  ------------------
  |  |  259|      1|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1504:3): [True: 1, False: 90]
  ------------------
 1505|      1|			dev->wps_prov_info = WPS_CONFIG_P2PS;
  ------------------
  |  |  259|      1|#define WPS_CONFIG_P2PS 0x1000
  ------------------
 1506|      1|			break;
 1507|     85|		default:
  ------------------
  |  Branch (1507:3): [True: 85, False: 6]
  ------------------
 1508|     85|			dev->wps_prov_info = 0;
 1509|     85|			break;
 1510|     91|		}
 1511|       |
 1512|     91|		if (msg->intended_addr)
  ------------------
  |  Branch (1512:7): [True: 1, False: 90]
  ------------------
 1513|      1|			os_memcpy(dev->interface_addr, msg->intended_addr,
  ------------------
  |  |  523|      1|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1514|     91|				  ETH_ALEN);
 1515|     91|	}
 1516|    150|}
p2p_pd.c:p2ps_validate_pd_req:
  552|     95|{
  553|     95|	u8 group_id = 0;
  554|     95|	u8 intended_addr = 0;
  555|     95|	u8 operating_channel = 0;
  556|     95|	u8 channel_list = 0;
  557|     95|	u8 config_timeout = 0;
  558|     95|	u8 listen_channel = 0;
  559|       |
  560|     95|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  561|     95|do { \
  562|     95|	if ((_val) && !msg->_attr) { \
  563|     95|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  564|     95|		return -1; \
  565|     95|	} \
  566|     95|} while (0)
  567|       |
  568|     95|	P2PS_PD_REQ_CHECK(1, adv_id);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  569|     95|	P2PS_PD_REQ_CHECK(1, session_id);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  570|     94|	P2PS_PD_REQ_CHECK(1, session_mac);
  ------------------
  |  |  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: 0, False: 94]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     94|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 94]
  |  |  ------------------
  ------------------
  571|     94|	P2PS_PD_REQ_CHECK(1, adv_mac);
  ------------------
  |  |  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: 0, False: 94]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     94|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 94]
  |  |  ------------------
  ------------------
  572|     94|	P2PS_PD_REQ_CHECK(1, capability);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  573|     93|	P2PS_PD_REQ_CHECK(1, p2p_device_info);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  574|     92|	P2PS_PD_REQ_CHECK(1, feature_cap);
  ------------------
  |  |  560|     92|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     92|do { \
  |  |  562|     92|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 92, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 91]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     92|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 91]
  |  |  ------------------
  ------------------
  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|     91|	if (msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED)
  ------------------
  |  Branch (581:6): [True: 68, False: 23]
  |  Branch (581:21): [True: 16, False: 52]
  ------------------
  582|     16|		return 0;
  583|       |
  584|     75|	P2PS_PD_REQ_CHECK(1, conn_cap);
  ------------------
  |  |  560|     75|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     75|do { \
  |  |  562|     75|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 75, Folded]
  |  |  |  Branch (562:16): [True: 2, False: 73]
  |  |  ------------------
  |  |  563|      2|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      2|		return -1; \
  |  |  565|      2|	} \
  |  |  566|     75|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 73]
  |  |  ------------------
  ------------------
  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|     73|	if (msg->feature_cap_len < sizeof(struct p2ps_feature_capab)) {
  ------------------
  |  Branch (596:6): [True: 1, False: 72]
  ------------------
  597|      1|		p2p_dbg(p2p, "P2PS: Invalid feature capability len");
  598|      1|		return -1;
  599|      1|	}
  600|       |
  601|     72|	switch (*msg->conn_cap) {
  602|      2|	case P2PS_SETUP_NEW:
  ------------------
  |  |   30|      2|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      2|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (602:2): [True: 2, False: 70]
  ------------------
  603|      2|		group_id = 1;
  604|      2|		intended_addr = 1;
  605|      2|		operating_channel = 1;
  606|      2|		channel_list = 1;
  607|      2|		config_timeout = 1;
  608|      2|		listen_channel = 1;
  609|      2|		break;
  610|     63|	case P2PS_SETUP_CLIENT:
  ------------------
  |  |   31|     63|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|     63|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (610:2): [True: 63, False: 9]
  ------------------
  611|     63|		channel_list = 1;
  612|     63|		listen_channel = 1;
  613|     63|		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: 69]
  ------------------
  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: 71]
  ------------------
  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: 70]
  ------------------
  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: 71]
  ------------------
  634|      1|		p2p_dbg(p2p, "Invalid P2PS PD connection capability");
  635|      1|		return -1;
  636|     72|	}
  637|       |
  638|     71|	if (msg->persistent_dev) {
  ------------------
  |  Branch (638:6): [True: 5, False: 66]
  ------------------
  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|     71|	P2PS_PD_REQ_CHECK(group_id, group_id);
  ------------------
  |  |  560|     71|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     71|do { \
  |  |  562|     71|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 8, False: 63]
  |  |  |  Branch (562:16): [True: 5, False: 3]
  |  |  ------------------
  |  |  563|      5|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      5|		return -1; \
  |  |  565|      5|	} \
  |  |  566|     71|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 66]
  |  |  ------------------
  ------------------
  648|     66|	P2PS_PD_REQ_CHECK(intended_addr, intended_addr);
  ------------------
  |  |  560|     66|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     66|do { \
  |  |  562|     66|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 4, False: 62]
  |  |  |  Branch (562:16): [True: 2, False: 2]
  |  |  ------------------
  |  |  563|      2|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      2|		return -1; \
  |  |  565|      2|	} \
  |  |  566|     66|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 64]
  |  |  ------------------
  ------------------
  649|     64|	P2PS_PD_REQ_CHECK(operating_channel, operating_channel);
  ------------------
  |  |  560|     64|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     64|do { \
  |  |  562|     64|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 62]
  |  |  |  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|     64|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 63]
  |  |  ------------------
  ------------------
  650|     63|	P2PS_PD_REQ_CHECK(channel_list, channel_list);
  ------------------
  |  |  560|     63|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     63|do { \
  |  |  562|     63|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 62, False: 1]
  |  |  |  Branch (562:16): [True: 4, False: 58]
  |  |  ------------------
  |  |  563|      4|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      4|		return -1; \
  |  |  565|      4|	} \
  |  |  566|     63|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 59]
  |  |  ------------------
  ------------------
  651|     59|	P2PS_PD_REQ_CHECK(config_timeout, config_timeout);
  ------------------
  |  |  560|     59|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     59|do { \
  |  |  562|     59|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 57]
  |  |  |  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|     59|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 58]
  |  |  ------------------
  ------------------
  652|     58|	P2PS_PD_REQ_CHECK(listen_channel, listen_channel);
  ------------------
  |  |  560|     58|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     58|do { \
  |  |  562|     58|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 57, False: 1]
  |  |  |  Branch (562:16): [True: 2, False: 55]
  |  |  ------------------
  |  |  563|      2|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      2|		return -1; \
  |  |  565|      2|	} \
  |  |  566|     58|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 56]
  |  |  ------------------
  ------------------
  653|       |
  654|     56|#undef P2PS_PD_REQ_CHECK
  655|       |
  656|     56|	return 0;
  657|     58|}
p2p_pd.c:p2p_build_prov_disc_resp:
  358|    725|{
  359|    725|	struct wpabuf *buf;
  360|    725|	size_t extra = 0;
  361|    725|	int persist = 0;
  362|       |
  363|    725|#ifdef CONFIG_WIFI_DISPLAY
  364|    725|	struct wpabuf *wfd_ie = p2p->wfd_ie_prov_disc_resp;
  365|    725|	if (wfd_ie && group_id) {
  ------------------
  |  Branch (365:6): [True: 0, False: 725]
  |  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|    725|	if (wfd_ie)
  ------------------
  |  Branch (380:6): [True: 0, False: 725]
  ------------------
  381|      0|		extra = wpabuf_len(wfd_ie);
  382|    725|#endif /* CONFIG_WIFI_DISPLAY */
  383|       |
  384|    725|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (384:6): [True: 0, False: 725]
  |  Branch (384:26): [True: 0, False: 0]
  ------------------
  385|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  386|       |
  387|    725|	buf = wpabuf_alloc(1000 + extra);
  388|    725|	if (buf == NULL)
  ------------------
  |  Branch (388:6): [True: 0, False: 725]
  ------------------
  389|      0|		return NULL;
  390|       |
  391|    725|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  392|       |
  393|       |	/* Add P2P IE for P2PS */
  394|    725|	if (p2p->p2ps_prov && p2p->p2ps_prov->adv_id == adv_id) {
  ------------------
  |  Branch (394:6): [True: 0, False: 725]
  |  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 |
  ------------------
  |  | 1860|      0|#define P2P_GROUP_CAPAB_PERSISTENT_GROUP BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  409|      0|			P2P_GROUP_CAPAB_PERSISTENT_RECONN;
  ------------------
  |  | 1864|      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;
  ------------------
  |  | 1863|      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;
  ------------------
  |  | 1862|      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,
  ------------------
  |  | 1851|      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|    725|	} else if (status != P2P_SC_SUCCESS || adv_id) {
  ------------------
  |  Branch (484:13): [True: 637, False: 88]
  |  Branch (484:41): [True: 50, False: 38]
  ------------------
  485|    687|		u8 *len = p2p_buf_add_ie_hdr(buf);
  486|       |
  487|    687|		p2p_buf_add_status(buf, status);
  488|       |
  489|    687|		if (p2p->p2ps_prov)
  ------------------
  |  Branch (489:7): [True: 0, False: 687]
  ------------------
  490|      0|			p2p_buf_add_advertisement_id(buf, adv_id,
  491|      0|						     p2p->p2ps_prov->adv_mac);
  492|       |
  493|    687|		p2p_buf_update_ie_hdr(buf, len);
  494|    687|	}
  495|       |
  496|       |	/* WPS IE with Config Methods attribute */
  497|    725|	p2p_build_wps_ie_config_methods(buf, config_methods);
  498|       |
  499|    725|#ifdef CONFIG_WIFI_DISPLAY
  500|    725|	if (wfd_ie)
  ------------------
  |  Branch (500:6): [True: 0, False: 725]
  ------------------
  501|      0|		wpabuf_put_buf(buf, wfd_ie);
  502|    725|#endif /* CONFIG_WIFI_DISPLAY */
  503|       |
  504|    725|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (504:6): [True: 0, False: 725]
  |  Branch (504:26): [True: 0, False: 0]
  ------------------
  505|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  506|       |
  507|    725|	return buf;
  508|    725|}
p2p_pd.c:p2p_build_wps_ie_config_methods:
   28|    725|{
   29|    725|	u8 *len;
   30|    725|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|    725|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   31|    725|	len = wpabuf_put(buf, 1);
   32|    725|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|    725|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
   33|       |
   34|       |	/* Config Methods */
   35|    725|	wpabuf_put_be16(buf, ATTR_CONFIG_METHODS);
   36|    725|	wpabuf_put_be16(buf, 2);
   37|    725|	wpabuf_put_be16(buf, config_methods);
   38|       |
   39|    725|	p2p_buf_update_ie_hdr(buf, len);
   40|    725|}
p2p_pd.c:p2p_process_prov_disc_bootstrap_resp:
 1640|      3|{
 1641|      3|	struct p2p_device *dev;
 1642|      3|	enum p2p_status_code status = P2P_SC_SUCCESS;
 1643|      3|	size_t cookie_len = 0;
 1644|      3|	const u8 *pos, *cookie;
 1645|      3|	u16 comeback_after;
 1646|      3|	u16 bootstrap = 0;
 1647|       |
 1648|       |	/* Parse the P2P status present */
 1649|      3|	if (msg->status)
  ------------------
  |  Branch (1649:6): [True: 1, False: 2]
  ------------------
 1650|      1|		status = *msg->status;
 1651|       |
 1652|      3|	p2p_dbg(p2p, "Received Provision Discovery Bootstrap Response from "
 1653|      3|		MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      3|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              		MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1654|       |
 1655|      3|	dev = p2p_get_device(p2p, sa);
 1656|      3|	if (!dev || !dev->req_bootstrap_method) {
  ------------------
  |  Branch (1656:6): [True: 2, False: 1]
  |  Branch (1656:14): [True: 1, False: 0]
  ------------------
 1657|      3|		p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
 1658|      3|			" with no pending request", MAC2STR(sa));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1659|      3|		return;
 1660|      3|	}
 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 &&
  ------------------
  |  | 1882|      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) &&
  ------------------
  |  | 1886|      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 &&
  ------------------
  |  | 1886|      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) &&
  ------------------
  |  | 1882|      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 &&
  ------------------
  |  | 1883|      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) &&
  ------------------
  |  | 1887|      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 &&
  ------------------
  |  | 1887|      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) &&
  ------------------
  |  | 1883|      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 &&
  ------------------
  |  | 1885|      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) &&
  ------------------
  |  | 1889|      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 &&
  ------------------
  |  | 1889|      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) &&
  ------------------
  |  | 1885|      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 &&
  ------------------
  |  | 1884|      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) &&
  ------------------
  |  | 1888|      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 &&
  ------------------
  |  | 1888|      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) &&
  ------------------
  |  | 1884|      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 &&
  ------------------
  |  | 1881|      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))
  ------------------
  |  | 1881|      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: 1, False: 15]
  ------------------
 1787|      1|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|      1|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1788|     15|	else
 1789|     15|		os_memset(adv_mac, 0, ETH_ALEN);
  ------------------
  |  |  529|     15|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1790|       |
 1791|     16|	if (msg->adv_id)
  ------------------
  |  Branch (1791:6): [True: 1, False: 15]
  ------------------
 1792|      1|		adv_id = WPA_GET_LE32(msg->adv_id);
 1793|       |
 1794|     16|	if (msg->conn_cap) {
  ------------------
  |  Branch (1794:6): [True: 3, False: 13]
  ------------------
 1795|      3|		conncap = *msg->conn_cap;
 1796|       |
 1797|       |		/* Switch bits to local relative */
 1798|      3|		switch (conncap) {
  ------------------
  |  Branch (1798:11): [True: 2, False: 1]
  ------------------
 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: 2]
  ------------------
 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: 2]
  ------------------
 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|      3|		}
 1806|      3|	}
 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: 15, False: 1]
  |  Branch (1813:21): [True: 1, 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.57k|{
  158|  6.57k|	struct p2p_sd_query *q, *prev;
  159|  6.57k|	q = p2p->sd_queries;
  160|  6.57k|	p2p->sd_queries = NULL;
  161|  6.57k|	while (q) {
  ------------------
  |  Branch (161:9): [True: 0, False: 6.57k]
  ------------------
  162|      0|		prev = q;
  163|      0|		q = q->next;
  164|      0|		p2p_free_sd_query(prev);
  165|      0|	}
  166|  6.57k|	p2p->num_p2p_sd_queries = 0;
  167|  6.57k|}
p2p_rx_gas_initial_req:
  328|      1|{
  329|      1|	const u8 *pos = data;
  330|      1|	const u8 *end = data + len;
  331|      1|	const u8 *next;
  332|      1|	u8 dialog_token;
  333|      1|	u16 slen;
  334|      1|	int freq;
  335|      1|	u16 update_indic;
  336|       |
  337|       |
  338|      1|	if (p2p->cfg->sd_request == NULL)
  ------------------
  |  Branch (338:6): [True: 1, False: 0]
  ------------------
  339|      1|		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) {
  ------------------
  |  |  406|      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) {
  ------------------
  |  | 1515|      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) {
  ------------------
  |  |  406|      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) {
  ------------------
  |  | 1515|      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|     33|{
  631|     33|	struct wpabuf *resp;
  632|     33|	u8 dialog_token;
  633|     33|	size_t frag_len, max_len;
  634|     33|	int more = 0;
  635|     33|	unsigned int wait_time = 200;
  636|       |
  637|     33|	wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Request", data, len);
  638|     33|	if (len < 1)
  ------------------
  |  Branch (638:6): [True: 1, False: 32]
  ------------------
  639|      1|		return;
  640|     32|	dialog_token = *data;
  641|     32|	p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
  642|     32|	if (dialog_token != p2p->sd_resp_dialog_token) {
  ------------------
  |  Branch (642:6): [True: 27, False: 5]
  ------------------
  643|     27|		p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
  644|     27|			dialog_token);
  645|     27|		return;
  646|     27|	}
  647|       |
  648|      5|	if (p2p->sd_resp == NULL) {
  ------------------
  |  Branch (648:6): [True: 5, False: 0]
  ------------------
  649|      5|		p2p_dbg(p2p, "No pending SD response fragment available");
  650|      5|		return;
  651|      5|	}
  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) {
  ------------------
  |  |  406|      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) {
  ------------------
  |  | 1515|      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|    645|{
   59|       |	return ieee80211_chan_to_freq(NULL, op_class, channel);
   60|    645|}
p2p_channels_intersect:
  114|    290|{
  115|    290|	size_t i, j;
  116|       |
  117|    290|	os_memset(res, 0, sizeof(*res));
  ------------------
  |  |  529|    290|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  118|       |
  119|    578|	for (i = 0; i < a->reg_classes; i++) {
  ------------------
  |  Branch (119:14): [True: 290, False: 288]
  ------------------
  120|    290|		const struct p2p_reg_class *a_reg = &a->reg_class[i];
  121|  1.57k|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (121:15): [True: 1.28k, False: 288]
  ------------------
  122|  1.28k|			const struct p2p_reg_class *b_reg = &b->reg_class[j];
  123|  1.28k|			if (a_reg->reg_class != b_reg->reg_class)
  ------------------
  |  Branch (123:8): [True: 522, False: 763]
  ------------------
  124|    522|				continue;
  125|    763|			p2p_reg_class_intersect(
  126|    763|				a_reg, b_reg,
  127|    763|				&res->reg_class[res->reg_classes]);
  128|    763|			if (res->reg_class[res->reg_classes].channels) {
  ------------------
  |  Branch (128:8): [True: 648, False: 115]
  ------------------
  129|    648|				res->reg_classes++;
  130|    648|				if (res->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|    648|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (130:9): [True: 2, False: 646]
  ------------------
  131|      2|					return;
  132|    648|			}
  133|    763|		}
  134|    290|	}
  135|    290|}
p2p_channels_union_inplace:
  164|    185|{
  165|    185|	size_t i, j;
  166|       |
  167|    370|	for (i = 0; i < res->reg_classes; i++) {
  ------------------
  |  Branch (167:14): [True: 185, False: 185]
  ------------------
  168|    185|		struct p2p_reg_class *cl = &res->reg_class[i];
  169|    185|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (169:15): [True: 0, False: 185]
  ------------------
  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|    185|	}
  176|       |
  177|    185|	for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (177:14): [True: 0, False: 185]
  ------------------
  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|    185|}
p2p_channels_union:
  205|    185|{
  206|    185|	os_memcpy(res, a, sizeof(*res));
  ------------------
  |  |  523|    185|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  207|    185|	p2p_channels_union_inplace(res, b);
  208|    185|}
p2p_channels_includes:
  256|     50|{
  257|     50|	size_t i, j;
  258|    205|	for (i = 0; i < channels->reg_classes; i++) {
  ------------------
  |  Branch (258:14): [True: 158, False: 47]
  ------------------
  259|    158|		const struct p2p_reg_class *reg = &channels->reg_class[i];
  260|    158|		if (reg->reg_class != reg_class)
  ------------------
  |  Branch (260:7): [True: 76, False: 82]
  ------------------
  261|     76|			continue;
  262|    302|		for (j = 0; j < reg->channels; j++) {
  ------------------
  |  Branch (262:15): [True: 223, False: 79]
  ------------------
  263|    223|			if (reg->channel[j] == channel)
  ------------------
  |  Branch (263:8): [True: 3, False: 220]
  ------------------
  264|      3|				return 1;
  265|    223|		}
  266|     82|	}
  267|     47|	return 0;
  268|     50|}
p2p_channels_dump:
  343|  13.6k|{
  344|  13.6k|	char buf[500], *pos, *end;
  345|  13.6k|	size_t i, j;
  346|  13.6k|	int ret;
  347|       |
  348|  13.6k|	pos = buf;
  349|  13.6k|	end = pos + sizeof(buf);
  350|       |
  351|  21.4k|	for (i = 0; i < chan->reg_classes; i++) {
  ------------------
  |  Branch (351:14): [True: 7.75k, False: 13.6k]
  ------------------
  352|  7.75k|		const struct p2p_reg_class *c;
  353|  7.75k|		c = &chan->reg_class[i];
  354|  7.75k|		ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
  ------------------
  |  |  572|  7.75k|#define os_snprintf snprintf
  ------------------
  355|  7.75k|		if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (355:7): [True: 2, False: 7.74k]
  ------------------
  356|      2|			break;
  357|  7.74k|		pos += ret;
  358|       |
  359|  26.2k|		for (j = 0; j < c->channels; j++) {
  ------------------
  |  Branch (359:15): [True: 18.4k, False: 7.74k]
  ------------------
  360|  18.4k|			ret = os_snprintf(pos, end - pos, "%s%u",
  ------------------
  |  |  572|  18.4k|#define os_snprintf snprintf
  ------------------
  361|  18.4k|					  j == 0 ? "" : ",",
  ------------------
  |  Branch (361:8): [True: 7.62k, False: 10.8k]
  ------------------
  362|  18.4k|					  c->channel[j]);
  363|  18.4k|			if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (363:8): [True: 6, False: 18.4k]
  ------------------
  364|      6|				break;
  365|  18.4k|			pos += ret;
  366|  18.4k|		}
  367|  7.74k|	}
  368|  13.6k|	*pos = '\0';
  369|       |
  370|  13.6k|	p2p_dbg(p2p, "%s:%s", title, buf);
  371|  13.6k|}
p2p_copy_channels:
  503|     91|{
  504|     91|	size_t i, j;
  505|       |
  506|     91|	if (allow_6ghz) {
  ------------------
  |  Branch (506:6): [True: 0, False: 91]
  ------------------
  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|     91|	for (i = 0, j = 0; i < src->reg_classes; i++) {
  ------------------
  |  Branch (511:21): [True: 0, False: 91]
  ------------------
  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|     91|	dst->reg_classes = j;
  519|     91|}
p2p_utils.c:p2p_reg_class_intersect:
   82|    763|{
   83|    763|	size_t i, j;
   84|       |
   85|    763|	res->reg_class = a->reg_class;
   86|       |
   87|  2.28k|	for (i = 0; i < a->channels; i++) {
  ------------------
  |  Branch (87:14): [True: 1.52k, False: 757]
  ------------------
   88|  12.0k|		for (j = 0; j < b->channels; j++) {
  ------------------
  |  Branch (88:15): [True: 10.5k, False: 1.52k]
  ------------------
   89|  10.5k|			if (a->channel[i] != b->channel[j])
  ------------------
  |  Branch (89:8): [True: 8.02k, False: 2.47k]
  ------------------
   90|  8.02k|				continue;
   91|  2.47k|			res->channel[res->channels] = a->channel[i];
   92|  2.47k|			res->channels++;
   93|  2.47k|			if (res->channels == P2P_MAX_REG_CLASS_CHANNELS)
  ------------------
  |  |   52|  2.47k|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
  |  Branch (93:8): [True: 6, False: 2.46k]
  ------------------
   94|      6|				return;
   95|  2.47k|		}
   96|  1.52k|	}
   97|    763|}

printf_encode:
  478|  6.07k|{
  479|  6.07k|	char *end = txt + maxlen;
  480|  6.07k|	size_t i;
  481|       |
  482|   138k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (482:14): [True: 132k, False: 6.07k]
  ------------------
  483|   132k|		if (txt + 4 >= end)
  ------------------
  |  Branch (483:7): [True: 0, False: 132k]
  ------------------
  484|      0|			break;
  485|       |
  486|   132k|		switch (data[i]) {
  487|  5.80k|		case '\"':
  ------------------
  |  Branch (487:3): [True: 5.80k, False: 127k]
  ------------------
  488|  5.80k|			*txt++ = '\\';
  489|  5.80k|			*txt++ = '\"';
  490|  5.80k|			break;
  491|    464|		case '\\':
  ------------------
  |  Branch (491:3): [True: 464, False: 132k]
  ------------------
  492|    464|			*txt++ = '\\';
  493|    464|			*txt++ = '\\';
  494|    464|			break;
  495|    222|		case '\033':
  ------------------
  |  Branch (495:3): [True: 222, False: 132k]
  ------------------
  496|    222|			*txt++ = '\\';
  497|    222|			*txt++ = 'e';
  498|    222|			break;
  499|    347|		case '\n':
  ------------------
  |  Branch (499:3): [True: 347, False: 132k]
  ------------------
  500|    347|			*txt++ = '\\';
  501|    347|			*txt++ = 'n';
  502|    347|			break;
  503|    244|		case '\r':
  ------------------
  |  Branch (503:3): [True: 244, False: 132k]
  ------------------
  504|    244|			*txt++ = '\\';
  505|    244|			*txt++ = 'r';
  506|    244|			break;
  507|  10.1k|		case '\t':
  ------------------
  |  Branch (507:3): [True: 10.1k, False: 122k]
  ------------------
  508|  10.1k|			*txt++ = '\\';
  509|  10.1k|			*txt++ = 't';
  510|  10.1k|			break;
  511|   115k|		default:
  ------------------
  |  Branch (511:3): [True: 115k, False: 17.2k]
  ------------------
  512|   115k|			if (data[i] >= 32 && data[i] <= 126) {
  ------------------
  |  Branch (512:8): [True: 34.8k, False: 80.6k]
  |  Branch (512:25): [True: 14.7k, False: 20.1k]
  ------------------
  513|  14.7k|				*txt++ = data[i];
  514|   100k|			} else {
  515|   100k|				txt += os_snprintf(txt, end - txt, "\\x%02x",
  ------------------
  |  |  572|   100k|#define os_snprintf snprintf
  ------------------
  516|   100k|						   data[i]);
  517|   100k|			}
  518|   115k|			break;
  519|   132k|		}
  520|   132k|	}
  521|       |
  522|  6.07k|	*txt = '\0';
  523|  6.07k|}
wpa_ssid_txt:
  623|  6.07k|{
  624|  6.07k|	static char ssid_txt[SSID_MAX_LEN * 4 + 1];
  625|       |
  626|  6.07k|	if (ssid == NULL) {
  ------------------
  |  Branch (626:6): [True: 0, False: 6.07k]
  ------------------
  627|      0|		ssid_txt[0] = '\0';
  628|      0|		return ssid_txt;
  629|      0|	}
  630|       |
  631|  6.07k|	printf_encode(ssid_txt, sizeof(ssid_txt), ssid, ssid_len);
  632|  6.07k|	return ssid_txt;
  633|  6.07k|}
has_ctrl_char:
  712|  19.9k|{
  713|  19.9k|	size_t i;
  714|       |
  715|  50.4k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (715:14): [True: 35.6k, False: 14.7k]
  ------------------
  716|  35.6k|		if (data[i] < 32 || data[i] == 127)
  ------------------
  |  Branch (716:7): [True: 5.01k, False: 30.6k]
  |  Branch (716:23): [True: 152, False: 30.4k]
  ------------------
  717|  5.17k|			return 1;
  718|  35.6k|	}
  719|  14.7k|	return 0;
  720|  19.9k|}
is_ctrl_char:
 1226|  12.7k|{
 1227|  12.7k|	return c > 0 && c < 32;
  ------------------
  |  Branch (1227:9): [True: 7.76k, False: 5.00k]
  |  Branch (1227:18): [True: 2.91k, False: 4.85k]
  ------------------
 1228|  12.7k|}

p2p.c:WPA_GET_LE16:
  225|     16|{
  226|     16|	return (a[1] << 8) | a[0];
  227|     16|}
p2p.c:WPA_GET_BE32:
  260|  56.4k|{
  261|  56.4k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  56.4k|}
p2p.c:is_zero_ether_addr:
  562|  1.84k|{
  563|  1.84k|	return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
  564|  1.84k|}
p2p.c:is_broadcast_ether_addr:
  567|  2.53k|{
  568|  2.53k|	return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
  569|  2.53k|}
p2p.c:ether_addr_equal:
  577|  8.44k|{
  578|  8.44k|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|  8.44k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|  8.44k|}
p2p_go_neg.c:ether_addr_equal:
  577|     41|{
  578|     41|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|     41|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|     41|}
p2p_parse.c:WPA_GET_LE16:
  225|  55.2k|{
  226|  55.2k|	return (a[1] << 8) | a[0];
  227|  55.2k|}
p2p_parse.c:WPA_GET_LE32:
  273|  1.30k|{
  274|  1.30k|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|  1.30k|}
p2p_parse.c:WPA_GET_BE16:
  214|  6.77k|{
  215|  6.77k|	return (a[0] << 8) | a[1];
  216|  6.77k|}
p2p_pd.c:WPA_GET_LE16:
  225|     85|{
  226|     85|	return (a[1] << 8) | a[0];
  227|     85|}
p2p_pd.c:WPA_GET_LE32:
  273|    168|{
  274|    168|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|    168|}
p2p_pd.c:WPA_PUT_BE32:
  265|    725|{
  266|    725|	a[0] = (val >> 24) & 0xff;
  267|    725|	a[1] = (val >> 16) & 0xff;
  268|    725|	a[2] = (val >> 8) & 0xff;
  269|    725|	a[3] = val & 0xff;
  270|    725|}
p2p_pd.c:WPA_PUT_BE16:
  219|  2.17k|{
  220|  2.17k|	a[0] = val >> 8;
  221|  2.17k|	a[1] = val & 0xff;
  222|  2.17k|}
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.36k|{
  266|  3.36k|	a[0] = (val >> 24) & 0xff;
  267|  3.36k|	a[1] = (val >> 16) & 0xff;
  268|  3.36k|	a[2] = (val >> 8) & 0xff;
  269|  3.36k|	a[3] = val & 0xff;
  270|  3.36k|}
p2p_build.c:WPA_PUT_LE16:
  230|  3.28k|{
  231|  3.28k|	a[1] = val >> 8;
  232|  3.28k|	a[0] = val & 0xff;
  233|  3.28k|}
p2p_build.c:WPA_PUT_BE16:
  219|    428|{
  220|    428|	a[0] = val >> 8;
  221|    428|	a[1] = val & 0xff;
  222|    428|}
wps_attr_build.c:WPA_PUT_BE24:
  241|     39|{
  242|     39|	a[0] = (val >> 16) & 0xff;
  243|     39|	a[1] = (val >> 8) & 0xff;
  244|     39|	a[2] = val & 0xff;
  245|     39|}
wps_attr_build.c:WPA_PUT_BE16:
  219|    160|{
  220|    160|	a[0] = val >> 8;
  221|    160|	a[1] = val & 0xff;
  222|    160|}
wps_attr_parse.c:WPA_GET_BE16:
  214|  1.90M|{
  215|  1.90M|	return (a[0] << 8) | a[1];
  216|  1.90M|}
wps_attr_parse.c:WPA_GET_BE24:
  236|  2.00k|{
  237|  2.00k|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  2.00k|}
wps_common.c:WPA_GET_BE16:
  214|  3.64k|{
  215|  3.64k|	return (a[0] << 8) | a[1];
  216|  3.64k|}
wps_common.c:WPA_GET_BE32:
  260|  1.82k|{
  261|  1.82k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.82k|}
ieee802_11_common.c:WPA_GET_BE24:
  236|  1.24M|{
  237|  1.24M|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.24M|}
ieee802_11_common.c:WPA_GET_BE32:
  260|  1.50M|{
  261|  1.50M|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.50M|}
sha256-internal.c:WPA_GET_BE32:
  260|   105k|{
  261|   105k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|   105k|}
sha256-internal.c:WPA_PUT_BE64:
  311|  6.57k|{
  312|  6.57k|	a[0] = val >> 56;
  313|  6.57k|	a[1] = val >> 48;
  314|  6.57k|	a[2] = val >> 40;
  315|  6.57k|	a[3] = val >> 32;
  316|  6.57k|	a[4] = val >> 24;
  317|  6.57k|	a[5] = val >> 16;
  318|  6.57k|	a[6] = val >> 8;
  319|  6.57k|	a[7] = val & 0xff;
  320|  6.57k|}
sha256-internal.c:WPA_PUT_BE32:
  265|  52.5k|{
  266|  52.5k|	a[0] = (val >> 24) & 0xff;
  267|  52.5k|	a[1] = (val >> 16) & 0xff;
  268|  52.5k|	a[2] = (val >> 8) & 0xff;
  269|  52.5k|	a[3] = val & 0xff;
  270|  52.5k|}

eloop_init:
  164|  6.57k|{
  165|  6.57k|	os_memset(&eloop, 0, sizeof(eloop));
  ------------------
  |  |  529|  6.57k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  166|  6.57k|	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.57k|	return 0;
  192|  6.57k|}
eloop_register_timeout:
  776|  6.57k|{
  777|  6.57k|	struct eloop_timeout *timeout, *tmp;
  778|  6.57k|	os_time_t now_sec;
  779|       |
  780|  6.57k|	timeout = os_zalloc(sizeof(*timeout));
  781|  6.57k|	if (timeout == NULL)
  ------------------
  |  Branch (781:6): [True: 0, False: 6.57k]
  ------------------
  782|      0|		return -1;
  783|  6.57k|	if (os_get_reltime(&timeout->time) < 0) {
  ------------------
  |  Branch (783:6): [True: 0, False: 6.57k]
  ------------------
  784|      0|		os_free(timeout);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  785|      0|		return -1;
  786|      0|	}
  787|  6.57k|	now_sec = timeout->time.sec;
  788|  6.57k|	timeout->time.sec += secs;
  789|  6.57k|	if (timeout->time.sec < now_sec)
  ------------------
  |  Branch (789:6): [True: 0, False: 6.57k]
  ------------------
  790|      0|		goto overflow;
  791|  6.57k|	timeout->time.usec += usecs;
  792|  6.57k|	while (timeout->time.usec >= 1000000) {
  ------------------
  |  Branch (792:9): [True: 0, False: 6.57k]
  ------------------
  793|      0|		timeout->time.sec++;
  794|      0|		timeout->time.usec -= 1000000;
  795|      0|	}
  796|  6.57k|	if (timeout->time.sec < now_sec)
  ------------------
  |  Branch (796:6): [True: 0, False: 6.57k]
  ------------------
  797|      0|		goto overflow;
  798|  6.57k|	timeout->eloop_data = eloop_data;
  799|  6.57k|	timeout->user_data = user_data;
  800|  6.57k|	timeout->handler = handler;
  801|  6.57k|	wpa_trace_add_ref(timeout, eloop, eloop_data);
  ------------------
  |  |   63|  6.57k|#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (63:58): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  802|  6.57k|	wpa_trace_add_ref(timeout, user, user_data);
  ------------------
  |  |   63|  6.57k|#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (63:58): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  803|  6.57k|	wpa_trace_record(timeout);
  ------------------
  |  |   61|  6.57k|#define wpa_trace_record(ptr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (61:45): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  804|       |
  805|       |	/* Maintain timeouts in order of increasing time */
  806|  6.57k|	dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
  ------------------
  |  |   79|  6.57k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  6.57k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 0, False: 6.57k]
  |  |  ------------------
  |  |   81|  6.57k|	     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.57k|	dl_list_add_tail(&eloop.timeout, &timeout->list);
  813|       |
  814|  6.57k|	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.57k|}
eloop_cancel_timeout:
  840|  46.0k|{
  841|  46.0k|	struct eloop_timeout *timeout, *prev;
  842|  46.0k|	int removed = 0;
  843|       |
  844|  46.0k|	dl_list_for_each_safe(timeout, prev, &eloop.timeout,
  ------------------
  |  |   84|  46.0k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  46.0k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  46.0k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  46.0k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  46.0k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 0, False: 46.0k]
  |  |  ------------------
  |  |   87|  46.0k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  845|  46.0k|			      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|  46.0k|	return removed;
  857|  46.0k|}
eloop_run:
 1076|  6.57k|{
 1077|       |#ifdef CONFIG_ELOOP_POLL
 1078|       |	int num_poll_fds;
 1079|       |	int timeout_ms = 0;
 1080|       |#endif /* CONFIG_ELOOP_POLL */
 1081|  6.57k|#ifdef CONFIG_ELOOP_SELECT
 1082|  6.57k|	fd_set *rfds, *wfds, *efds;
 1083|  6.57k|	struct timeval _tv;
 1084|  6.57k|#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.57k|	int res;
 1092|  6.57k|	struct os_reltime tv, now;
 1093|       |
 1094|  6.57k|#ifdef CONFIG_ELOOP_SELECT
 1095|  6.57k|	rfds = os_malloc(sizeof(*rfds));
  ------------------
  |  |  505|  6.57k|#define os_malloc(s) malloc((s))
  ------------------
 1096|  6.57k|	wfds = os_malloc(sizeof(*wfds));
  ------------------
  |  |  505|  6.57k|#define os_malloc(s) malloc((s))
  ------------------
 1097|  6.57k|	efds = os_malloc(sizeof(*efds));
  ------------------
  |  |  505|  6.57k|#define os_malloc(s) malloc((s))
  ------------------
 1098|  6.57k|	if (rfds == NULL || wfds == NULL || efds == NULL)
  ------------------
  |  Branch (1098:6): [True: 0, False: 6.57k]
  |  Branch (1098:22): [True: 0, False: 6.57k]
  |  Branch (1098:38): [True: 0, False: 6.57k]
  ------------------
 1099|      0|		goto out;
 1100|  6.57k|#endif /* CONFIG_ELOOP_SELECT */
 1101|       |
 1102|  13.1k|	while (!eloop.terminate &&
  ------------------
  |  Branch (1102:9): [True: 6.57k, False: 6.57k]
  ------------------
 1103|  6.57k|	       (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 ||
  ------------------
  |  Branch (1103:10): [True: 6.57k, False: 0]
  |  Branch (1103:44): [True: 0, False: 0]
  ------------------
 1104|  6.57k|		eloop.writers.count > 0 || eloop.exceptions.count > 0)) {
  ------------------
  |  Branch (1104:3): [True: 0, False: 0]
  |  Branch (1104:30): [True: 0, False: 0]
  ------------------
 1105|  6.57k|		struct eloop_timeout *timeout;
 1106|       |
 1107|  6.57k|		if (eloop.pending_terminate) {
  ------------------
  |  Branch (1107:7): [True: 0, False: 6.57k]
  ------------------
 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.57k|		timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
  ------------------
  |  |   71|  6.57k|	(dl_list_empty((list)) ? NULL : \
  |  |  ------------------
  |  |  |  Branch (71:3): [True: 0, False: 6.57k]
  |  |  ------------------
  |  |   72|  6.57k|	 dl_list_entry((list)->next, type, member))
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1121|  6.57k|					list);
 1122|  6.57k|		if (timeout) {
  ------------------
  |  Branch (1122:7): [True: 6.57k, False: 0]
  ------------------
 1123|  6.57k|			os_get_reltime(&now);
 1124|  6.57k|			if (os_reltime_before(&now, &timeout->time))
  ------------------
  |  Branch (1124:8): [True: 0, False: 6.57k]
  ------------------
 1125|      0|				os_reltime_sub(&timeout->time, &now, &tv);
 1126|  6.57k|			else
 1127|  6.57k|				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.57k|#ifdef CONFIG_ELOOP_SELECT
 1132|  6.57k|			_tv.tv_sec = tv.sec;
 1133|  6.57k|			_tv.tv_usec = tv.usec;
 1134|  6.57k|#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.57k|		}
 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.57k|#ifdef CONFIG_ELOOP_SELECT
 1150|  6.57k|		eloop_sock_table_set_fds(&eloop.readers, rfds);
 1151|  6.57k|		eloop_sock_table_set_fds(&eloop.writers, wfds);
 1152|  6.57k|		eloop_sock_table_set_fds(&eloop.exceptions, efds);
 1153|  6.57k|		res = select(eloop.max_sock + 1, rfds, wfds, efds,
 1154|  6.57k|			     timeout ? &_tv : NULL);
  ------------------
  |  Branch (1154:9): [True: 6.57k, False: 0]
  ------------------
 1155|  6.57k|#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.57k|		if (res < 0 && errno != EINTR && errno != 0) {
  ------------------
  |  Branch (1173:7): [True: 0, False: 6.57k]
  |  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.57k|		eloop.readers.changed = 0;
 1193|  6.57k|		eloop.writers.changed = 0;
 1194|  6.57k|		eloop.exceptions.changed = 0;
 1195|       |
 1196|  6.57k|		eloop_process_pending_signals();
 1197|       |
 1198|       |
 1199|       |		/* check if some registered timeouts have occurred */
 1200|  6.57k|		timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
  ------------------
  |  |   71|  6.57k|	(dl_list_empty((list)) ? NULL : \
  |  |  ------------------
  |  |  |  Branch (71:3): [True: 0, False: 6.57k]
  |  |  ------------------
  |  |   72|  6.57k|	 dl_list_entry((list)->next, type, member))
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1201|  6.57k|					list);
 1202|  6.57k|		if (timeout) {
  ------------------
  |  Branch (1202:7): [True: 6.57k, False: 0]
  ------------------
 1203|  6.57k|			os_get_reltime(&now);
 1204|  6.57k|			if (!os_reltime_before(&now, &timeout->time)) {
  ------------------
  |  Branch (1204:8): [True: 6.57k, False: 0]
  ------------------
 1205|  6.57k|				void *eloop_data = timeout->eloop_data;
 1206|  6.57k|				void *user_data = timeout->user_data;
 1207|  6.57k|				eloop_timeout_handler handler =
 1208|  6.57k|					timeout->handler;
 1209|  6.57k|				eloop_remove_timeout(timeout);
 1210|  6.57k|				handler(eloop_data, user_data);
 1211|  6.57k|			}
 1212|       |
 1213|  6.57k|		}
 1214|       |
 1215|  6.57k|		if (res <= 0)
  ------------------
  |  Branch (1215:7): [True: 6.57k, False: 0]
  ------------------
 1216|  6.57k|			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.57k|	eloop.terminate = 0;
 1250|  6.57k|out:
 1251|  6.57k|#ifdef CONFIG_ELOOP_SELECT
 1252|  6.57k|	os_free(rfds);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 1253|  6.57k|	os_free(wfds);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 1254|  6.57k|	os_free(efds);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
 1255|  6.57k|#endif /* CONFIG_ELOOP_SELECT */
 1256|  6.57k|	return;
 1257|  6.57k|}
eloop_terminate:
 1261|  6.57k|{
 1262|  6.57k|	eloop.terminate = 1;
 1263|  6.57k|}
eloop_destroy:
 1267|  6.57k|{
 1268|  6.57k|	struct eloop_timeout *timeout, *prev;
 1269|  6.57k|	struct os_reltime now;
 1270|  6.57k|	size_t i;
 1271|       |
 1272|  6.57k|	os_get_reltime(&now);
 1273|  6.57k|	dl_list_for_each_safe(timeout, prev, &eloop.timeout,
  ------------------
  |  |   84|  6.57k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  6.57k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.57k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  6.57k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 0, False: 6.57k]
  |  |  ------------------
  |  |   87|  6.57k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|      0|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 1274|  6.57k|			      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.57k|	eloop_sock_table_destroy(&eloop.readers);
 1292|  6.57k|	eloop_sock_table_destroy(&eloop.writers);
 1293|  6.57k|	eloop_sock_table_destroy(&eloop.exceptions);
 1294|       |
 1295|  6.57k|	for (i = 0; i < eloop.signal_count; i++)
  ------------------
  |  Branch (1295:14): [True: 0, False: 6.57k]
  ------------------
 1296|      0|		signal(eloop.signals[i].sig, SIG_DFL);
 1297|       |
 1298|  6.57k|	os_free(eloop.signals);
  ------------------
  |  |  511|  6.57k|#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.57k|}
eloop.c:eloop_remove_timeout:
  830|  6.57k|{
  831|  6.57k|	dl_list_del(&timeout->list);
  832|  6.57k|	wpa_trace_remove_ref(timeout, eloop, timeout->eloop_data);
  ------------------
  |  |   64|  6.57k|#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (64:61): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  833|  6.57k|	wpa_trace_remove_ref(timeout, user, timeout->user_data);
  ------------------
  |  |   64|  6.57k|#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (64:61): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  834|  6.57k|	os_free(timeout);
  ------------------
  |  |  511|  6.57k|#define os_free(p) free((p))
  ------------------
  835|  6.57k|}
eloop.c:eloop_process_pending_signals:
 1008|  6.57k|{
 1009|  6.57k|	size_t i;
 1010|       |
 1011|  6.57k|	if (eloop.signaled == 0)
  ------------------
  |  Branch (1011:6): [True: 6.57k, False: 0]
  ------------------
 1012|  6.57k|		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|  19.7k|{
  578|  19.7k|	size_t i;
  579|       |
  580|  19.7k|	FD_ZERO(fds);
  ------------------
  |  Branch (580:2): [Folded, False: 19.7k]
  ------------------
  581|       |
  582|  19.7k|	if (table->table == NULL)
  ------------------
  |  Branch (582:6): [True: 19.7k, False: 0]
  ------------------
  583|  19.7k|		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|  19.7k|{
  700|  19.7k|	if (table) {
  ------------------
  |  Branch (700:6): [True: 19.7k, False: 0]
  ------------------
  701|  19.7k|		size_t i;
  702|       |
  703|  19.7k|		for (i = 0; i < table->count && table->table; i++) {
  ------------------
  |  Branch (703:15): [True: 0, False: 19.7k]
  |  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|  19.7k|		eloop_trace_sock_remove_ref(table);
  ------------------
  |  |  158|  19.7k|#define eloop_trace_sock_remove_ref(table) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (158:58): [Folded, False: 19.7k]
  |  |  ------------------
  ------------------
  717|  19.7k|		os_free(table->table);
  ------------------
  |  |  511|  19.7k|#define os_free(p) free((p))
  ------------------
  718|  19.7k|	}
  719|  19.7k|}

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

p2p.c:os_reltime_before:
   71|  7.06k|{
   72|  7.06k|	return (a->sec < b->sec) ||
  ------------------
  |  Branch (72:9): [True: 10, False: 7.05k]
  ------------------
   73|  7.05k|	       (a->sec == b->sec && a->usec < b->usec);
  ------------------
  |  Branch (73:10): [True: 7.04k, False: 9]
  |  Branch (73:30): [True: 0, False: 7.04k]
  ------------------
   74|  7.06k|}
os_unix.c:testing_test_fail:
  697|  27.4k|{
  698|  27.4k|	return 0;
  699|  27.4k|}
eloop.c:os_reltime_before:
   71|  13.1k|{
   72|  13.1k|	return (a->sec < b->sec) ||
  ------------------
  |  Branch (72:9): [True: 0, False: 13.1k]
  ------------------
   73|  13.1k|	       (a->sec == b->sec && a->usec < b->usec);
  ------------------
  |  Branch (73:10): [True: 13.1k, False: 0]
  |  Branch (73:30): [True: 0, False: 13.1k]
  ------------------
   74|  13.1k|}
p2p_utils.c:os_snprintf_error:
  580|  26.2k|{
  581|  26.2k|	return res < 0 || (unsigned int) res >= size;
  ------------------
  |  Branch (581:9): [True: 0, False: 26.2k]
  |  Branch (581:20): [True: 8, False: 26.2k]
  ------------------
  582|  26.2k|}
wps_common.c:os_snprintf_error:
  580|  1.82k|{
  581|  1.82k|	return res < 0 || (unsigned int) res >= size;
  ------------------
  |  Branch (581:9): [True: 0, False: 1.82k]
  |  Branch (581:20): [True: 0, False: 1.82k]
  ------------------
  582|  1.82k|}
sha256-internal.c:testing_test_fail:
  697|  6.57k|{
  698|  6.57k|	return 0;
  699|  6.57k|}

os_get_reltime:
   77|  27.4k|{
   78|  27.4k|#ifndef __MACH__
   79|  27.4k|#if defined(CLOCK_BOOTTIME)
   80|  27.4k|	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|  27.4k|	struct timespec ts;
   87|  27.4k|	int res;
   88|       |
   89|  27.4k|	if (TEST_FAIL())
  ------------------
  |  |  688|  27.4k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 27.4k]
  |  |  ------------------
  ------------------
   90|      0|		return -1;
   91|       |
   92|  27.4k|	while (1) {
  ------------------
  |  Branch (92:9): [True: 27.4k, Folded]
  ------------------
   93|  27.4k|		res = clock_gettime(clock_id, &ts);
   94|  27.4k|		if (res == 0) {
  ------------------
  |  Branch (94:7): [True: 27.4k, False: 0]
  ------------------
   95|  27.4k|			t->sec = ts.tv_sec;
   96|  27.4k|			t->usec = ts.tv_nsec / 1000;
   97|  27.4k|			return 0;
   98|  27.4k|		}
   99|      0|		switch (clock_id) {
  ------------------
  |  Branch (99:11): [True: 0, False: 0]
  ------------------
  100|      0|#ifdef CLOCK_BOOTTIME
  101|      0|		case CLOCK_BOOTTIME:
  ------------------
  |  Branch (101:3): [True: 0, False: 0]
  ------------------
  102|      0|			clock_id = CLOCK_MONOTONIC;
  103|      0|			break;
  104|      0|#endif
  105|      0|#ifdef CLOCK_MONOTONIC
  106|      0|		case CLOCK_MONOTONIC:
  ------------------
  |  Branch (106:3): [True: 0, False: 0]
  ------------------
  107|      0|			clock_id = CLOCK_REALTIME;
  108|      0|			break;
  109|      0|#endif
  110|      0|		case CLOCK_REALTIME:
  ------------------
  |  Branch (110:3): [True: 0, False: 0]
  ------------------
  111|      0|			return -1;
  112|      0|		}
  113|      0|	}
  114|       |#else /* __MACH__ */
  115|       |	uint64_t abstime, nano;
  116|       |	static mach_timebase_info_data_t info = { 0, 0 };
  117|       |
  118|       |	if (!info.denom) {
  119|       |		if (mach_timebase_info(&info) != KERN_SUCCESS)
  120|       |			return -1;
  121|       |	}
  122|       |
  123|       |	abstime = mach_absolute_time();
  124|       |	nano = (abstime * info.numer) / info.denom;
  125|       |
  126|       |	t->sec = nano / NSEC_PER_SEC;
  127|       |	t->usec = (nano - (((uint64_t) t->sec) * NSEC_PER_SEC)) / NSEC_PER_USEC;
  128|       |
  129|       |	return 0;
  130|       |#endif /* __MACH__ */
  131|  27.4k|}
os_get_random:
  258|  13.1k|{
  259|  13.1k|#ifdef TEST_FUZZ
  260|  13.1k|	size_t i;
  261|       |
  262|  46.1k|	for (i = 0; i < len; i++)
  ------------------
  |  Branch (262:14): [True: 33.0k, False: 13.1k]
  ------------------
  263|  33.0k|		buf[i] = i & 0xff;
  264|  13.1k|	return 0;
  265|       |#else /* TEST_FUZZ */
  266|       |	FILE *f;
  267|       |	size_t rc;
  268|       |
  269|       |	if (TEST_FAIL())
  270|       |		return -1;
  271|       |
  272|       |	f = fopen("/dev/urandom", "rb");
  273|       |	if (f == NULL) {
  274|       |		printf("Could not open /dev/urandom.\n");
  275|       |		return -1;
  276|       |	}
  277|       |
  278|       |	rc = fread(buf, 1, len, f);
  279|       |	fclose(f);
  280|       |
  281|       |	return rc != len ? -1 : 0;
  282|       |#endif /* TEST_FUZZ */
  283|  13.1k|}
os_program_init:
  339|  6.57k|{
  340|  6.57k|	unsigned int seed;
  341|       |
  342|       |#ifdef ANDROID
  343|       |	/*
  344|       |	 * We ignore errors here since errors are normal if we
  345|       |	 * are already running as non-root.
  346|       |	 */
  347|       |#ifdef ANDROID_SETGROUPS_OVERRIDE
  348|       |	gid_t groups[] = { ANDROID_SETGROUPS_OVERRIDE };
  349|       |#else /* ANDROID_SETGROUPS_OVERRIDE */
  350|       |	gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE };
  351|       |#endif /* ANDROID_SETGROUPS_OVERRIDE */
  352|       |	struct __user_cap_header_struct header;
  353|       |	struct __user_cap_data_struct cap;
  354|       |
  355|       |	setgroups(ARRAY_SIZE(groups), groups);
  356|       |
  357|       |	prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
  358|       |
  359|       |	setgid(AID_WIFI);
  360|       |	setuid(AID_WIFI);
  361|       |
  362|       |	header.version = _LINUX_CAPABILITY_VERSION;
  363|       |	header.pid = 0;
  364|       |	cap.effective = cap.permitted =
  365|       |		(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW);
  366|       |	cap.inheritable = 0;
  367|       |	capset(&header, &cap);
  368|       |#endif /* ANDROID */
  369|       |
  370|  6.57k|	if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
  ------------------
  |  Branch (370:6): [True: 6.57k, False: 0]
  ------------------
  371|  6.57k|		srandom(seed);
  372|       |
  373|  6.57k|	return 0;
  374|  6.57k|}
os_program_deinit:
  378|  6.57k|{
  379|       |#ifdef WPA_TRACE
  380|       |	struct os_alloc_trace *a;
  381|       |	unsigned long total = 0;
  382|       |	dl_list_for_each(a, &alloc_list, struct os_alloc_trace, list) {
  383|       |		total += a->len;
  384|       |		if (a->magic != ALLOC_MAGIC) {
  385|       |			wpa_printf(MSG_INFO, "MEMLEAK[%p]: invalid magic 0x%x "
  386|       |				   "len %lu",
  387|       |				   a, a->magic, (unsigned long) a->len);
  388|       |			continue;
  389|       |		}
  390|       |		wpa_printf(MSG_INFO, "MEMLEAK[%p]: len %lu",
  391|       |			   a, (unsigned long) a->len);
  392|       |		wpa_trace_dump("memleak", a);
  393|       |	}
  394|       |	if (total)
  395|       |		wpa_printf(MSG_INFO, "MEMLEAK: total %lu bytes",
  396|       |			   (unsigned long) total);
  397|       |	wpa_trace_deinit();
  398|       |#endif /* WPA_TRACE */
  399|  6.57k|}
os_zalloc:
  485|  39.4k|{
  486|  39.4k|	return calloc(1, size);
  487|  39.4k|}

wpa_printf:
  224|  43.8M|{
  225|  43.8M|	va_list ap;
  226|       |
  227|  43.8M|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 43.8M]
  ------------------
  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|  43.8M|}
wpa_hexdump:
  400|  15.1k|{
  401|  15.1k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  15.1k|}
wpa_hexdump_ascii:
  526|  7.14k|{
  527|  7.14k|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|  7.14k|}
wpa_debug.c:_wpa_hexdump:
  274|  15.1k|{
  275|  15.1k|	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|  15.1k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 15.1k, False: 0]
  ------------------
  296|  15.1k|		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.14k|{
  414|  7.14k|	size_t i, llen;
  415|  7.14k|	const u8 *pos = buf;
  416|  7.14k|	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.14k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (437:6): [True: 7.14k, False: 0]
  ------------------
  438|  7.14k|		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:
  117|  1.42k|{
  118|  1.42k|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (118:28): [True: 1.42k, False: 0]
  ------------------
  119|  1.42k|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (119:7): [True: 1.42k, False: 0]
  ------------------
  120|  1.42k|}
wps_attr_parse.c:wpa_hexdump_buf:
  117|  1.08k|{
  118|  1.08k|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (118:28): [True: 1.08k, False: 0]
  ------------------
  119|  1.08k|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (119:7): [True: 1.08k, False: 0]
  ------------------
  120|  1.08k|}

wpabuf_resize:
   48|  5.54k|{
   49|  5.54k|	struct wpabuf *buf = *_buf;
   50|       |#ifdef WPA_TRACE
   51|       |	struct wpabuf_trace *trace;
   52|       |#endif /* WPA_TRACE */
   53|       |
   54|  5.54k|	if (buf == NULL) {
  ------------------
  |  Branch (54:6): [True: 463, False: 5.08k]
  ------------------
   55|    463|		*_buf = wpabuf_alloc(add_len);
   56|    463|		return *_buf == NULL ? -1 : 0;
  ------------------
  |  Branch (56:10): [True: 0, False: 463]
  ------------------
   57|    463|	}
   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.08k|	if (buf->used + add_len > buf->size) {
  ------------------
  |  Branch (69:6): [True: 5.08k, False: 0]
  ------------------
   70|  5.08k|		unsigned char *nbuf;
   71|  5.08k|		if (buf->flags & WPABUF_FLAG_EXT_DATA) {
  ------------------
  |  |   13|  5.08k|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|  5.08k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (71:7): [True: 0, False: 5.08k]
  ------------------
   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.08k|		} 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.08k|			nbuf = os_realloc(buf, sizeof(struct wpabuf) +
  ------------------
  |  |  508|  5.08k|#define os_realloc(p, s) realloc((p), (s))
  ------------------
   91|  5.08k|					  buf->used + add_len);
   92|  5.08k|			if (nbuf == NULL)
  ------------------
  |  Branch (92:8): [True: 0, False: 5.08k]
  ------------------
   93|      0|				return -1;
   94|  5.08k|			buf = (struct wpabuf *) nbuf;
   95|  5.08k|			os_memset(nbuf + sizeof(struct wpabuf) + buf->used, 0,
  ------------------
  |  |  529|  5.08k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   96|  5.08k|				  add_len);
   97|  5.08k|#endif /* WPA_TRACE */
   98|  5.08k|			buf->buf = (u8 *) (buf + 1);
   99|  5.08k|			*_buf = buf;
  100|  5.08k|		}
  101|  5.08k|		buf->size = buf->used + add_len;
  102|  5.08k|	}
  103|       |
  104|  5.08k|	return 0;
  105|  5.08k|}
wpabuf_alloc:
  114|  17.7k|{
  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|  17.7k|	struct wpabuf *buf = os_zalloc(sizeof(struct wpabuf) + len);
  125|  17.7k|	if (buf == NULL)
  ------------------
  |  Branch (125:6): [True: 0, False: 17.7k]
  ------------------
  126|      0|		return NULL;
  127|  17.7k|#endif /* WPA_TRACE */
  128|       |
  129|  17.7k|	buf->size = len;
  130|  17.7k|	buf->buf = (u8 *) (buf + 1);
  131|  17.7k|	return buf;
  132|  17.7k|}
wpabuf_alloc_copy:
  161|    184|{
  162|    184|	struct wpabuf *buf = wpabuf_alloc(len);
  163|    184|	if (buf)
  ------------------
  |  Branch (163:6): [True: 184, False: 0]
  ------------------
  164|    184|		wpabuf_put_data(buf, data, len);
  165|    184|	return buf;
  166|    184|}
wpabuf_dup:
  170|    396|{
  171|    396|	struct wpabuf *buf;
  172|       |
  173|    396|	if (!src)
  ------------------
  |  Branch (173:6): [True: 0, False: 396]
  ------------------
  174|      0|		return NULL;
  175|    396|	buf = wpabuf_alloc(wpabuf_len(src));
  176|    396|	if (buf)
  ------------------
  |  Branch (176:6): [True: 396, False: 0]
  ------------------
  177|    396|		wpabuf_put_data(buf, wpabuf_head(src), wpabuf_len(src));
  178|    396|	return buf;
  179|    396|}
wpabuf_free:
  187|   287k|{
  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|   287k|	if (buf == NULL)
  ------------------
  |  Branch (203:6): [True: 269k, False: 17.7k]
  ------------------
  204|   269k|		return;
  205|  17.7k|	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  ------------------
  |  |   13|  17.7k|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|  17.7k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (205:6): [True: 0, False: 17.7k]
  ------------------
  206|      0|		os_free(buf->buf);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  207|  17.7k|	os_free(buf);
  ------------------
  |  |  511|  17.7k|#define os_free(p) free((p))
  ------------------
  208|  17.7k|#endif /* WPA_TRACE */
  209|  17.7k|}
wpabuf_put:
  222|   670k|{
  223|   670k|	void *tmp = wpabuf_mhead_u8(buf) + wpabuf_len(buf);
  224|   670k|	buf->used += len;
  225|   670k|	if (buf->used > buf->size) {
  ------------------
  |  Branch (225:6): [True: 0, False: 670k]
  ------------------
  226|      0|		wpabuf_overflow(buf, len);
  227|      0|	}
  228|   670k|	return tmp;
  229|   670k|}
wpabuf_concat:
  242|     91|{
  243|     91|	struct wpabuf *n = NULL;
  244|     91|	size_t len = 0;
  245|       |
  246|     91|	if (b == NULL)
  ------------------
  |  Branch (246:6): [True: 0, False: 91]
  ------------------
  247|      0|		return a;
  248|       |
  249|     91|	if (a)
  ------------------
  |  Branch (249:6): [True: 91, False: 0]
  ------------------
  250|     91|		len += wpabuf_len(a);
  251|     91|	len += wpabuf_len(b);
  252|       |
  253|     91|	n = wpabuf_alloc(len);
  254|     91|	if (n) {
  ------------------
  |  Branch (254:6): [True: 91, False: 0]
  ------------------
  255|     91|		if (a)
  ------------------
  |  Branch (255:7): [True: 91, False: 0]
  ------------------
  256|     91|			wpabuf_put_buf(n, a);
  257|     91|		wpabuf_put_buf(n, b);
  258|     91|	}
  259|       |
  260|     91|	wpabuf_free(a);
  261|     91|	wpabuf_free(b);
  262|       |
  263|     91|	return n;
  264|     91|}

p2p.c:wpabuf_size:
   49|  5.54k|{
   50|  5.54k|	return buf->size;
   51|  5.54k|}
p2p.c:wpabuf_put_data:
  174|  5.54k|{
  175|  5.54k|	if (data)
  ------------------
  |  Branch (175:6): [True: 5.54k, False: 0]
  ------------------
  176|  5.54k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  5.54k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  5.54k|}
p2p_dev_disc.c:wpabuf_head:
   94|     26|{
   95|     26|	return buf->buf;
   96|     26|}
p2p_dev_disc.c:wpabuf_len:
   59|     26|{
   60|     26|	return buf->used;
   61|     26|}
p2p_go_neg.c:wpabuf_len:
   59|     91|{
   60|     91|	return buf->used;
   61|     91|}
p2p_go_neg.c:wpabuf_head:
   94|     91|{
   95|     91|	return buf->buf;
   96|     91|}
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.40k|{
  100|  7.40k|	return (const u8 *) wpabuf_head(buf);
  101|  7.40k|}
p2p_parse.c:wpabuf_head:
   94|  8.83k|{
   95|  8.83k|	return buf->buf;
   96|  8.83k|}
p2p_parse.c:wpabuf_len:
   59|  8.83k|{
   60|  8.83k|	return buf->used;
   61|  8.83k|}
p2p_pd.c:wpabuf_put_u8:
  119|    725|{
  120|    725|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    725|	*pos = data;
  122|    725|}
p2p_pd.c:wpabuf_put_be32:
  161|    725|{
  162|    725|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|    725|	WPA_PUT_BE32(pos, data);
  164|    725|}
p2p_pd.c:wpabuf_put_be16:
  149|  2.17k|{
  150|  2.17k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|  2.17k|	WPA_PUT_BE16(pos, data);
  152|  2.17k|}
p2p_pd.c:wpabuf_head:
   94|    768|{
   95|    768|	return buf->buf;
   96|    768|}
p2p_pd.c:wpabuf_len:
   59|    768|{
   60|    768|	return buf->used;
   61|    768|}
p2p_build.c:wpabuf_put_u8:
  119|  16.4k|{
  120|  16.4k|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|  16.4k|	*pos = data;
  122|  16.4k|}
p2p_build.c:wpabuf_put_be32:
  161|  3.36k|{
  162|  3.36k|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|  3.36k|	WPA_PUT_BE32(pos, data);
  164|  3.36k|}
p2p_build.c:wpabuf_put_le16:
  125|  3.01k|{
  126|  3.01k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  127|  3.01k|	WPA_PUT_LE16(pos, data);
  128|  3.01k|}
p2p_build.c:wpabuf_put_data:
  174|  1.47k|{
  175|  1.47k|	if (data)
  ------------------
  |  Branch (175:6): [True: 1.38k, False: 93]
  ------------------
  176|  1.38k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  1.38k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  1.47k|}
p2p_build.c:wpabuf_put_be16:
  149|    428|{
  150|    428|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    428|	WPA_PUT_BE16(pos, data);
  152|    428|}
p2p_build.c:wpabuf_tailroom:
   69|    104|{
   70|    104|	return buf->size - buf->used;
   71|    104|}
p2p_build.c:wpabuf_len:
   59|  1.77k|{
   60|  1.77k|	return buf->used;
   61|  1.77k|}
p2p_build.c:wpabuf_head:
   94|    888|{
   95|    888|	return buf->buf;
   96|    888|}
wps_attr_build.c:wpabuf_put_be16:
  149|    121|{
  150|    121|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    121|	WPA_PUT_BE16(pos, data);
  152|    121|}
wps_attr_build.c:wpabuf_put_u8:
  119|    156|{
  120|    156|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    156|	*pos = data;
  122|    156|}
wps_attr_build.c:wpabuf_tailroom:
   69|     80|{
   70|     80|	return buf->size - buf->used;
   71|     80|}
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|     39|{
  156|     39|	u8 *pos = (u8 *) wpabuf_put(buf, 3);
  157|     39|	WPA_PUT_BE24(pos, data);
  158|     39|}
wps_attr_parse.c:wpabuf_head:
   94|  5.89k|{
   95|  5.89k|	return buf->buf;
   96|  5.89k|}
wps_attr_parse.c:wpabuf_len:
   59|  5.89k|{
   60|  5.89k|	return buf->used;
   61|  5.89k|}
wpabuf.c:wpabuf_put_data:
  174|    762|{
  175|    762|	if (data)
  ------------------
  |  Branch (175:6): [True: 762, False: 0]
  ------------------
  176|    762|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    762|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    762|}
wpabuf.c:wpabuf_len:
   59|   671k|{
   60|   671k|	return buf->used;
   61|   671k|}
wpabuf.c:wpabuf_head:
   94|    578|{
   95|    578|	return buf->buf;
   96|    578|}
wpabuf.c:wpabuf_mhead:
  109|   670k|{
  110|   670k|	return buf->buf;
  111|   670k|}
wpabuf.c:wpabuf_mhead_u8:
  114|   670k|{
  115|   670k|	return (u8 *) wpabuf_mhead(buf);
  116|   670k|}
wpabuf.c:wpabuf_put_buf:
  181|    182|{
  182|    182|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    182|}
ieee802_11_common.c:wpabuf_put_data:
  174|   630k|{
  175|   630k|	if (data)
  ------------------
  |  Branch (175:6): [True: 630k, False: 0]
  ------------------
  176|   630k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|   630k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|   630k|}

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|     39|{
  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|     39|	if (wpabuf_tailroom(msg) < 5)
  ------------------
  |  Branch (198:6): [True: 0, False: 39]
  ------------------
  199|      0|		return -1;
  200|     39|	wpa_printf(MSG_DEBUG, "WPS:  * Version (hardcoded 0x10)");
  201|     39|	wpabuf_put_be16(msg, ATTR_VERSION);
  202|     39|	wpabuf_put_be16(msg, 1);
  203|     39|	wpabuf_put_u8(msg, 0x10);
  204|     39|	return 0;
  205|     39|}
wps_build_wfa_ext:
  211|     39|{
  212|     39|	u8 *len;
  213|       |
  214|       |#ifdef CONFIG_WPS_TESTING
  215|       |	if (WPS_VERSION == 0x10)
  216|       |		return 0;
  217|       |#endif /* CONFIG_WPS_TESTING */
  218|       |
  219|     39|	if (wpabuf_tailroom(msg) <
  ------------------
  |  Branch (219:6): [True: 0, False: 39]
  ------------------
  220|     39|	    7 + 3 + (req_to_enroll ? 3 : 0) +
  ------------------
  |  Branch (220:15): [True: 0, False: 39]
  ------------------
  221|     39|	    (auth_macs ? 2 + auth_macs_count * ETH_ALEN : 0))
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  |  Branch (221:7): [True: 0, False: 39]
  ------------------
  222|      0|		return -1;
  223|     39|	wpabuf_put_be16(msg, ATTR_VENDOR_EXT);
  224|     39|	len = wpabuf_put(msg, 2); /* to be filled */
  225|     39|	wpabuf_put_be24(msg, WPS_VENDOR_ID_WFA);
  ------------------
  |  |  146|     39|#define WPS_VENDOR_ID_WFA 14122
  ------------------
  226|       |
  227|     39|	wpa_printf(MSG_DEBUG, "WPS:  * Version2 (0x%x)", WPS_VERSION);
  ------------------
  |  |   25|     39|#define WPS_VERSION 0x20
  ------------------
  228|     39|	wpabuf_put_u8(msg, WFA_ELEM_VERSION2);
  229|     39|	wpabuf_put_u8(msg, 1);
  230|     39|	wpabuf_put_u8(msg, WPS_VERSION);
  ------------------
  |  |   25|     39|#define WPS_VERSION 0x20
  ------------------
  231|       |
  232|     39|	if (req_to_enroll) {
  ------------------
  |  Branch (232:6): [True: 0, False: 39]
  ------------------
  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|     39|	if (auth_macs && auth_macs_count) {
  ------------------
  |  Branch (239:6): [True: 0, False: 39]
  |  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|     39|	if (multi_ap_subelem) {
  ------------------
  |  Branch (251:6): [True: 0, False: 39]
  ------------------
  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|     39|	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|     39|	return 0;
  273|     39|}

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

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

wpa_fuzzer_set_debug_level:
   15|  6.57k|{
   16|  6.57k|	static int first = 1;
   17|       |
   18|  6.57k|	if (first) {
  ------------------
  |  Branch (18:6): [True: 1, False: 6.57k]
  ------------------
   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.57k|}

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

