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

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

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

p2p_set_state:
  193|  6.66k|{
  194|  6.66k|	p2p_dbg(p2p, "State %s -> %s",
  195|  6.66k|		p2p_state_txt(p2p->state), p2p_state_txt(new_state));
  196|  6.66k|	p2p->state = new_state;
  197|       |
  198|  6.66k|	if (new_state == P2P_IDLE && p2p->pending_channel) {
  ------------------
  |  Branch (198:6): [True: 6.66k, False: 0]
  |  Branch (198:31): [True: 0, False: 6.66k]
  ------------------
  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.66k|}
p2p_clear_timeout:
  218|  6.66k|{
  219|  6.66k|	p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state));
  220|       |	eloop_cancel_timeout(p2p_state_timeout, p2p, NULL);
  221|  6.66k|}
p2p_get_device:
  392|  5.43k|{
  393|  5.43k|	struct p2p_device *dev;
  394|  5.43k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  5.43k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  5.43k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  7.99k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 3.59k, False: 4.39k]
  |  |  ------------------
  |  |   81|  5.43k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  2.55k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  395|  3.59k|		if (ether_addr_equal(dev->info.p2p_device_addr, addr))
  ------------------
  |  Branch (395:7): [True: 1.04k, False: 2.55k]
  ------------------
  396|  1.04k|			return dev;
  397|  3.59k|	}
  398|  4.39k|	return NULL;
  399|  5.43k|}
p2p_update_peer_6ghz_capab:
  653|  2.64k|{
  654|  2.64k|	if (msg->capability &&
  ------------------
  |  Branch (654:6): [True: 257, False: 2.38k]
  ------------------
  655|    257|	    (msg->capability[0] & P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE))
  ------------------
  |  | 1856|    257|#define P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE BIT(6)
  |  |  ------------------
  |  |  |  |  458|    257|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (655:6): [True: 74, False: 183]
  ------------------
  656|     74|		dev->support_6ghz = true;
  657|  2.64k|}
p2p_add_device:
  741|  8.02k|{
  742|  8.02k|	struct p2p_device *dev;
  743|  8.02k|	struct p2p_message msg;
  744|  8.02k|	const u8 *p2p_dev_addr;
  745|  8.02k|	int wfd_changed;
  746|  8.02k|	int dev_name_changed;
  747|  8.02k|	int i;
  748|  8.02k|	struct os_reltime time_now;
  749|       |
  750|  8.02k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  8.02k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  751|  8.02k|	if (p2p_parse_ies(ies, ies_len, &msg)) {
  ------------------
  |  Branch (751:6): [True: 2.43k, False: 5.58k]
  ------------------
  752|  2.43k|		p2p_dbg(p2p, "Failed to parse P2P IE for a device entry");
  753|  2.43k|		p2p_parse_free(&msg);
  754|  2.43k|		return -1;
  755|  2.43k|	}
  756|       |
  757|  5.58k|	if (msg.p2p_device_addr)
  ------------------
  |  Branch (757:6): [True: 511, False: 5.07k]
  ------------------
  758|    511|		p2p_dev_addr = msg.p2p_device_addr;
  759|  5.07k|	else if (msg.device_id)
  ------------------
  |  Branch (759:11): [True: 1.40k, False: 3.67k]
  ------------------
  760|  1.40k|		p2p_dev_addr = msg.device_id;
  761|  3.67k|	else {
  762|  3.67k|		p2p_dbg(p2p, "Ignore scan data without P2P Device Info or P2P Device Id");
  763|  3.67k|		p2p_parse_free(&msg);
  764|  3.67k|		return -1;
  765|  3.67k|	}
  766|       |
  767|  1.91k|	if (!is_zero_ether_addr(p2p->peer_filter) &&
  ------------------
  |  Branch (767:6): [True: 0, False: 1.91k]
  ------------------
  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.91k|	dev = p2p_create_device(p2p, p2p_dev_addr);
  776|  1.91k|	if (dev == NULL) {
  ------------------
  |  Branch (776:6): [True: 0, False: 1.91k]
  ------------------
  777|      0|		p2p_parse_free(&msg);
  778|      0|		return -1;
  779|      0|	}
  780|       |
  781|  1.91k|	if (rx_time == NULL) {
  ------------------
  |  Branch (781:6): [True: 607, False: 1.30k]
  ------------------
  782|    607|		os_get_reltime(&time_now);
  783|    607|		rx_time = &time_now;
  784|    607|	}
  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.91k|	if (dev->last_seen.sec > 0 &&
  ------------------
  |  Branch (792:6): [True: 80, False: 1.83k]
  ------------------
  793|     80|	    os_reltime_before(rx_time, &dev->last_seen) &&
  ------------------
  |  Branch (793:6): [True: 0, False: 80]
  ------------------
  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.91k|	os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|  1.91k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  809|       |
  810|  1.91k|	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  127|  1.91k|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|  1.91k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|  1.91k|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|  1.91k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  811|  1.91k|			P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT);
  ------------------
  |  |  147|  1.91k|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|  1.91k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  812|       |
  813|  1.91k|	if (!ether_addr_equal(addr, p2p_dev_addr))
  ------------------
  |  Branch (813:6): [True: 1.68k, False: 228]
  ------------------
  814|  1.68k|		os_memcpy(dev->interface_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.68k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  815|  1.91k|	if (msg.ssid &&
  ------------------
  |  Branch (815:6): [True: 747, False: 1.16k]
  ------------------
  816|    747|	    msg.ssid[1] <= sizeof(dev->oper_ssid) &&
  ------------------
  |  Branch (816:6): [True: 747, False: 0]
  ------------------
  817|    747|	    (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1934|  1.49k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (817:7): [True: 467, False: 280]
  ------------------
  818|    280|	     os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    280|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (818:7): [True: 51, False: 229]
  ------------------
  819|    518|	     != 0)) {
  820|    518|		os_memcpy(dev->oper_ssid, msg.ssid + 2, msg.ssid[1]);
  ------------------
  |  |  523|    518|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  821|    518|		dev->oper_ssid_len = msg.ssid[1];
  822|    518|	}
  823|       |
  824|  1.91k|	wpabuf_free(dev->info.p2ps_instance);
  825|  1.91k|	dev->info.p2ps_instance = NULL;
  826|  1.91k|	if (msg.adv_service_instance && msg.adv_service_instance_len)
  ------------------
  |  Branch (826:6): [True: 22, False: 1.89k]
  |  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.91k|	if (freq >= 2412 && freq <= 2484 && msg.ds_params &&
  ------------------
  |  Branch (830:6): [True: 1.91k, False: 0]
  |  Branch (830:22): [True: 1.91k, False: 0]
  |  Branch (830:38): [True: 196, False: 1.71k]
  ------------------
  831|    196|	    *msg.ds_params >= 1 && *msg.ds_params <= 14) {
  ------------------
  |  Branch (831:6): [True: 130, False: 66]
  |  Branch (831:29): [True: 106, False: 24]
  ------------------
  832|    106|		int ds_freq;
  833|    106|		if (*msg.ds_params == 14)
  ------------------
  |  Branch (833:7): [True: 13, False: 93]
  ------------------
  834|     13|			ds_freq = 2484;
  835|     93|		else
  836|     93|			ds_freq = 2407 + *msg.ds_params * 5;
  837|    106|		if (freq != ds_freq) {
  ------------------
  |  Branch (837:7): [True: 82, False: 24]
  ------------------
  838|     82|			p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz",
  839|     82|				freq, ds_freq);
  840|     82|			freq = ds_freq;
  841|     82|		}
  842|    106|	}
  843|       |
  844|  1.91k|	if (dev->listen_freq && dev->listen_freq != freq && scan_res) {
  ------------------
  |  Branch (844:6): [True: 461, False: 1.45k]
  |  Branch (844:26): [True: 54, False: 407]
  |  Branch (844:54): [True: 0, False: 54]
  ------------------
  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.91k|	if (scan_res) {
  ------------------
  |  Branch (850:6): [True: 1.30k, False: 607]
  ------------------
  851|  1.30k|		dev->listen_freq = freq;
  852|  1.30k|		if (msg.group_info)
  ------------------
  |  Branch (852:7): [True: 150, False: 1.15k]
  ------------------
  853|    150|			dev->oper_freq = freq;
  854|  1.30k|	}
  855|  1.91k|	dev->info.level = level;
  856|       |
  857|  1.91k|	dev_name_changed = os_strncmp(dev->info.device_name, msg.device_name,
  ------------------
  |  |  559|  1.91k|#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
  ------------------
  858|  1.91k|				      WPS_DEV_NAME_MAX_LEN) != 0;
  859|       |
  860|  1.91k|	p2p_copy_wps_info(p2p, dev, 0, &msg);
  861|       |
  862|  21.0k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  21.0k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (862:14): [True: 19.1k, False: 1.91k]
  ------------------
  863|  19.1k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  864|  19.1k|		dev->info.wps_vendor_ext[i] = NULL;
  865|  19.1k|	}
  866|       |
  867|  2.13k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  2.13k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (867:14): [True: 2.12k, False: 6]
  ------------------
  868|  2.12k|		if (msg.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (868:7): [True: 1.90k, False: 217]
  ------------------
  869|  1.90k|			break;
  870|    217|		dev->info.wps_vendor_ext[i] = wpabuf_alloc_copy(
  871|    217|			msg.wps_vendor_ext[i], msg.wps_vendor_ext_len[i]);
  872|    217|		if (dev->info.wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (872:7): [True: 0, False: 217]
  ------------------
  873|      0|			break;
  874|    217|	}
  875|       |
  876|  1.91k|	wfd_changed = p2p_compare_wfd_info(dev, &msg);
  877|       |
  878|  1.91k|	if (wfd_changed) {
  ------------------
  |  Branch (878:6): [True: 383, False: 1.53k]
  ------------------
  879|    383|		wpabuf_free(dev->info.wfd_subelems);
  880|    383|		if (msg.wfd_subelems)
  ------------------
  |  Branch (880:7): [True: 376, False: 7]
  ------------------
  881|    376|			dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
  882|      7|		else
  883|      7|			dev->info.wfd_subelems = NULL;
  884|    383|	}
  885|       |
  886|  1.91k|	if (scan_res) {
  ------------------
  |  Branch (886:6): [True: 1.30k, False: 607]
  ------------------
  887|  1.30k|		p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq,
  888|  1.30k|				      msg.group_info, msg.group_info_len,
  889|  1.30k|				      rx_time);
  890|  1.30k|	}
  891|       |
  892|  1.91k|	p2p_parse_free(&msg);
  893|       |
  894|  1.91k|	p2p_update_peer_vendor_elems(dev, ies, ies_len);
  895|       |
  896|  1.91k|	if (dev->flags & P2P_DEV_REPORTED && !wfd_changed &&
  ------------------
  |  |  128|  1.91k|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|  3.82k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (896:6): [True: 208, False: 1.70k]
  |  Branch (896:39): [True: 197, False: 11]
  ------------------
  897|    197|	    !dev_name_changed &&
  ------------------
  |  Branch (897:6): [True: 51, False: 146]
  ------------------
  898|     51|	    (!msg.adv_service_instance ||
  ------------------
  |  Branch (898:7): [True: 47, False: 4]
  ------------------
  899|      4|	     (dev->flags & P2P_DEV_P2PS_REPORTED)))
  ------------------
  |  |  145|      4|#define P2P_DEV_P2PS_REPORTED BIT(20)
  |  |  ------------------
  |  |  |  |  458|      4|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (899:7): [True: 3, False: 1]
  ------------------
  900|     50|		return 0;
  901|       |
  902|  1.86k|	p2p_dbg(p2p, "Peer found with Listen frequency %d MHz (rx_time=%u.%06u)",
  903|  1.86k|		freq, (unsigned int) rx_time->sec,
  904|  1.86k|		(unsigned int) rx_time->usec);
  905|  1.86k|	if (dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|  1.86k|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|  1.86k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (905:6): [True: 0, False: 1.86k]
  ------------------
  906|      0|		p2p_dbg(p2p, "Do not report rejected device");
  907|      0|		return 0;
  908|      0|	}
  909|       |
  910|  1.86k|	if (dev->info.config_methods == 0 &&
  ------------------
  |  Branch (910:6): [True: 1.32k, False: 538]
  ------------------
  911|  1.32k|	    (freq == 2412 || freq == 2437 || freq == 2462)) {
  ------------------
  |  Branch (911:7): [True: 1.25k, False: 73]
  |  Branch (911:23): [True: 10, False: 63]
  |  Branch (911:39): [True: 5, False: 58]
  ------------------
  912|       |		/*
  913|       |		 * If we have only seen a Beacon frame from a GO, we do not yet
  914|       |		 * know what WPS config methods it supports. Since some
  915|       |		 * applications use config_methods value from P2P-DEVICE-FOUND
  916|       |		 * events, postpone reporting this peer until we've fully
  917|       |		 * discovered its capabilities.
  918|       |		 *
  919|       |		 * At least for now, do this only if the peer was detected on
  920|       |		 * one of the social channels since that peer can be easily be
  921|       |		 * found again and there are no limitations of having to use
  922|       |		 * passive scan on this channels, so this can be done through
  923|       |		 * Probe Response frame that includes the config_methods
  924|       |		 * information.
  925|       |		 */
  926|  1.26k|		p2p_dbg(p2p, "Do not report peer " MACSTR
  927|  1.26k|			" with unknown config methods", MAC2STR(addr));
  ------------------
  |  |  447|  1.26k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  928|  1.26k|		return 0;
  929|  1.26k|	}
  930|       |
  931|    596|	p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info,
  932|    596|			    !(dev->flags & P2P_DEV_REPORTED_ONCE));
  ------------------
  |  |  140|    596|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    596|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  933|    596|	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    596|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    596|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              	dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    596|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    596|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  934|       |
  935|    596|	if (msg.adv_service_instance)
  ------------------
  |  Branch (935:6): [True: 6, False: 590]
  ------------------
  936|      6|		dev->flags |= P2P_DEV_P2PS_REPORTED;
  ------------------
  |  |  145|      6|#define P2P_DEV_P2PS_REPORTED BIT(20)
  |  |  ------------------
  |  |  |  |  458|      6|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  937|       |
  938|    596|	return 0;
  939|  1.86k|}
p2p_stop_find_for_freq:
 1344|  6.66k|{
 1345|  6.66k|	p2p_dbg(p2p, "Stopping find");
 1346|  6.66k|	eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
 1347|  6.66k|	p2p_clear_timeout(p2p);
 1348|  6.66k|	if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND)
  ------------------
  |  Branch (1348:6): [True: 0, False: 6.66k]
  |  Branch (1348:34): [True: 0, False: 6.66k]
  ------------------
 1349|      0|		p2p->cfg->find_stopped(p2p->cfg->cb_ctx);
 1350|       |
 1351|  6.66k|	p2p->p2ps_seek_count = 0;
 1352|       |
 1353|  6.66k|	p2p_set_state(p2p, P2P_IDLE);
 1354|  6.66k|	p2p_free_req_dev_types(p2p);
 1355|  6.66k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1356|  6.66k|	if (p2p->go_neg_peer)
  ------------------
  |  Branch (1356:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2p->go_neg_peer = NULL;
 1359|  6.66k|	p2p->sd_peer = NULL;
 1360|       |	p2p->invite_peer = NULL;
 1361|  6.66k|	p2p_stop_listen_for_freq(p2p, freq);
 1362|  6.66k|	p2p->send_action_in_progress = 0;
 1363|  6.66k|}
p2p_stop_listen_for_freq:
 1367|  6.66k|{
 1368|  6.66k|	p2p_dbg(p2p,
 1369|  6.66k|		"%s(freq=%d) pending_listen_freq=%d in_listen=%d drv_in_listen=%d",
 1370|  6.66k|		__func__, freq, p2p->pending_listen_freq, p2p->in_listen,
 1371|  6.66k|		p2p->drv_in_listen);
 1372|  6.66k|	if (freq > 0 &&
  ------------------
  |  Branch (1372:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	if (p2p->in_listen) {
  ------------------
  |  Branch (1378:6): [True: 0, False: 6.66k]
  ------------------
 1379|      0|		p2p->in_listen = 0;
 1380|      0|		p2p_clear_timeout(p2p);
 1381|      0|	}
 1382|  6.66k|	if (p2p->drv_in_listen) {
  ------------------
  |  Branch (1382:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	if (p2p->pending_listen_freq &&
  ------------------
  |  Branch (1391:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 1399|       |	p2p->pending_listen_wait_drv = false;
 1400|  6.66k|}
p2p_stop_find:
 1416|  6.66k|{
 1417|  6.66k|	p2p->pending_listen_freq = 0;
 1418|  6.66k|	p2p_stop_find_for_freq(p2p, 0);
 1419|  6.66k|}
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: 5, False: 20]
  ------------------
 1819|      5|			p2p_dbg(p2p, "Unknown peer Listen channel: "
 1820|      5|				"country=%c%c(0x%02x) reg_class=%u channel=%u",
 1821|      5|				msg->listen_channel[0],
 1822|      5|				msg->listen_channel[1],
 1823|      5|				msg->listen_channel[2],
 1824|      5|				msg->listen_channel[3],
 1825|      5|				msg->listen_channel[4]);
 1826|     20|		} else {
 1827|     20|			p2p_dbg(p2p, "Update peer " MACSTR
 1828|     20|				" Listen channel: %u -> %u MHz",
 1829|     20|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|     20|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1830|     20|				dev->listen_freq, freq);
 1831|     20|			dev->listen_freq = freq;
 1832|     20|		}
 1833|     25|	}
 1834|       |
 1835|     25|	if (msg->wfd_subelems) {
  ------------------
  |  Branch (1835:6): [True: 5, False: 20]
  ------------------
 1836|      5|		wpabuf_free(dev->info.wfd_subelems);
 1837|      5|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
 1838|      5|	}
 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.48k|{
 2111|  4.48k|	if (category == WLAN_ACTION_PUBLIC) {
  ------------------
  |  |  670|  4.48k|#define WLAN_ACTION_PUBLIC 4
  ------------------
  |  Branch (2111:6): [True: 2.26k, False: 2.22k]
  ------------------
 2112|  2.26k|		p2p_rx_action_public(p2p, da, sa, bssid, data, len, freq);
 2113|  2.26k|		return;
 2114|  2.26k|	}
 2115|       |
 2116|  2.22k|	if (category != WLAN_ACTION_VENDOR_SPECIFIC)
  ------------------
  |  |  704|  2.22k|#define WLAN_ACTION_VENDOR_SPECIFIC 127
  ------------------
  |  Branch (2116:6): [True: 1.54k, False: 687]
  ------------------
 2117|  1.54k|		return;
 2118|       |
 2119|    687|	if (len < 4)
  ------------------
  |  Branch (2119:6): [True: 3, False: 684]
  ------------------
 2120|      3|		return;
 2121|       |
 2122|    684|	if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
  ------------------
  |  | 1515|    684|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (2122:6): [True: 57, False: 627]
  ------------------
 2123|     57|		return;
 2124|    627|	data += 4;
 2125|    627|	len -= 4;
 2126|       |
 2127|       |	/* P2P action frame */
 2128|    627|	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    627|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              	p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    627|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2129|    627|	wpa_hexdump(MSG_MSGDUMP, "P2P: P2P Action contents", data, len);
 2130|       |
 2131|    627|	if (len < 1)
  ------------------
  |  Branch (2131:6): [True: 1, False: 626]
  ------------------
 2132|      1|		return;
 2133|    626|	switch (data[0]) {
 2134|      2|	case P2P_NOA:
  ------------------
  |  Branch (2134:2): [True: 2, False: 624]
  ------------------
 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: 625]
  ------------------
 2139|      1|		p2p_process_presence_req(p2p, da, sa, data + 1, len - 1, freq);
 2140|      1|		break;
 2141|    616|	case P2P_PRESENCE_RESP:
  ------------------
  |  Branch (2141:2): [True: 616, False: 10]
  ------------------
 2142|    616|		p2p_process_presence_resp(p2p, da, sa, data + 1, len - 1);
 2143|    616|		break;
 2144|      2|	case P2P_GO_DISC_REQ:
  ------------------
  |  Branch (2144:2): [True: 2, False: 624]
  ------------------
 2145|      2|		p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq);
 2146|      2|		break;
 2147|      5|	default:
  ------------------
  |  Branch (2147:2): [True: 5, False: 621]
  ------------------
 2148|      5|		p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]);
 2149|      5|		break;
 2150|    626|	}
 2151|    626|}
p2p_add_dev_from_go_neg_req:
 2276|     18|{
 2277|     18|	struct p2p_device *dev;
 2278|       |
 2279|     18|	dev = p2p_get_device(p2p, addr);
 2280|     18|	if (dev) {
  ------------------
  |  Branch (2280:6): [True: 0, False: 18]
  ------------------
 2281|      0|		os_get_reltime(&dev->last_seen);
 2282|      0|		return dev; /* already known */
 2283|      0|	}
 2284|       |
 2285|     18|	dev = p2p_create_device(p2p, addr);
 2286|     18|	if (dev == NULL)
  ------------------
  |  Branch (2286:6): [True: 0, False: 18]
  ------------------
 2287|      0|		return NULL;
 2288|       |
 2289|     18|	p2p_add_dev_info(p2p, addr, dev, msg);
 2290|       |
 2291|     18|	return dev;
 2292|     18|}
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.66k|{
 2669|  6.66k|	enum p2p_probe_req_status res;
 2670|       |
 2671|  6.66k|	p2p_add_dev_from_probe_req(p2p, addr, ie, ie_len);
 2672|       |
 2673|  6.66k|	if (p2p_lo_started) {
  ------------------
  |  Branch (2673:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	res = p2p_reply_probe(p2p, addr, dst, bssid, ie, ie_len, rx_freq);
 2680|  6.66k|	if (res != P2P_PREQ_PROCESSED && res != P2P_PREQ_NOT_PROCESSED)
  ------------------
  |  Branch (2680:6): [True: 6.66k, False: 0]
  |  Branch (2680:35): [True: 4.12k, False: 2.54k]
  ------------------
 2681|  4.12k|		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.54k|	if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) &&
  ------------------
  |  Branch (2691:7): [True: 0, False: 2.54k]
  |  Branch (2691:36): [True: 0, False: 2.54k]
  ------------------
 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.54k|	if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) &&
  ------------------
  |  Branch (2702:7): [True: 0, False: 2.54k]
  |  Branch (2702:35): [True: 0, False: 2.54k]
  ------------------
 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.54k|	return res;
 2714|  2.54k|}
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.66k|{
 2991|  6.66k|	struct p2ps_advertisement *adv, *prev;
 2992|       |
 2993|  6.66k|	if (!p2p)
  ------------------
  |  Branch (2993:6): [True: 0, False: 6.66k]
  ------------------
 2994|      0|		return;
 2995|       |
 2996|  6.66k|	adv = p2p->p2ps_adv_list;
 2997|  6.66k|	while (adv) {
  ------------------
  |  Branch (2997:9): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2ps_prov_free(p2p);
 3005|  6.66k|	p2p_dbg(p2p, "All ASP advertisements flushed");
 3006|  6.66k|}
p2p_init:
 3167|  6.66k|{
 3168|  6.66k|	struct p2p_data *p2p;
 3169|       |
 3170|  6.66k|	if (cfg->max_peers < 1 ||
  ------------------
  |  Branch (3170:6): [True: 0, False: 6.66k]
  ------------------
 3171|  6.66k|	    cfg->passphrase_len < 8 || cfg->passphrase_len > 63)
  ------------------
  |  Branch (3171:6): [True: 0, False: 6.66k]
  |  Branch (3171:33): [True: 0, False: 6.66k]
  ------------------
 3172|      0|		return NULL;
 3173|       |
 3174|  6.66k|	p2p = os_zalloc(sizeof(*p2p) + sizeof(*cfg));
 3175|  6.66k|	if (p2p == NULL)
  ------------------
  |  Branch (3175:6): [True: 0, False: 6.66k]
  ------------------
 3176|      0|		return NULL;
 3177|  6.66k|	p2p->cfg = (struct p2p_config *) (p2p + 1);
 3178|  6.66k|	os_memcpy(p2p->cfg, cfg, sizeof(*cfg));
  ------------------
  |  |  523|  6.66k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3179|  6.66k|	if (cfg->dev_name)
  ------------------
  |  Branch (3179:6): [True: 0, False: 6.66k]
  ------------------
 3180|      0|		p2p->cfg->dev_name = os_strdup(cfg->dev_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3181|  6.66k|	if (cfg->manufacturer)
  ------------------
  |  Branch (3181:6): [True: 0, False: 6.66k]
  ------------------
 3182|      0|		p2p->cfg->manufacturer = os_strdup(cfg->manufacturer);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3183|  6.66k|	if (cfg->model_name)
  ------------------
  |  Branch (3183:6): [True: 0, False: 6.66k]
  ------------------
 3184|      0|		p2p->cfg->model_name = os_strdup(cfg->model_name);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3185|  6.66k|	if (cfg->model_number)
  ------------------
  |  Branch (3185:6): [True: 0, False: 6.66k]
  ------------------
 3186|      0|		p2p->cfg->model_number = os_strdup(cfg->model_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3187|  6.66k|	if (cfg->serial_number)
  ------------------
  |  Branch (3187:6): [True: 0, False: 6.66k]
  ------------------
 3188|      0|		p2p->cfg->serial_number = os_strdup(cfg->serial_number);
  ------------------
  |  |  517|      0|#define os_strdup(s) strdup(s)
  ------------------
 3189|  6.66k|	if (cfg->pref_chan) {
  ------------------
  |  Branch (3189:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2ps_gen_hash(p2p, P2PS_WILD_HASH_STR, p2p->wild_card_hash);
  ------------------
  |  |   34|  6.66k|#define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
  ------------------
 3201|       |
 3202|  6.66k|	p2p->min_disc_int = 1;
 3203|  6.66k|	p2p->max_disc_int = 3;
 3204|  6.66k|	p2p->max_disc_tu = -1;
 3205|       |
 3206|  6.66k|	if (os_get_random(&p2p->next_tie_breaker, 1) < 0)
  ------------------
  |  Branch (3206:6): [True: 0, False: 6.66k]
  ------------------
 3207|      0|		p2p->next_tie_breaker = 0;
 3208|  6.66k|	p2p->next_tie_breaker &= 0x01;
 3209|  6.66k|	if (cfg->sd_request)
  ------------------
  |  Branch (3209:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2p->dev_capab |= P2P_DEV_CAPAB_INVITATION_PROCEDURE;
  ------------------
  |  | 1855|  6.66k|#define P2P_DEV_CAPAB_INVITATION_PROCEDURE BIT(5)
  |  |  ------------------
  |  |  |  |  458|  6.66k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3212|  6.66k|	if (cfg->concurrent_operations)
  ------------------
  |  Branch (3212:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|  6.66k|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|  6.66k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 3215|       |
 3216|  6.66k|	dl_list_init(&p2p->devices);
 3217|       |
 3218|  6.66k|	p2p->go_timeout = 100;
 3219|  6.66k|	p2p->client_timeout = 20;
 3220|  6.66k|	p2p->num_p2p_sd_queries = 0;
 3221|       |	/* Default comeback after one second */
 3222|  6.66k|	if (!p2p->cfg->comeback_after)
  ------------------
  |  Branch (3222:6): [True: 6.66k, False: 0]
  ------------------
 3223|  6.66k|		p2p->cfg->comeback_after = 977; /* TUs */
 3224|  6.66k|	p2p_pairing_info_init(p2p);
 3225|       |
 3226|  6.66k|	p2p_dbg(p2p, "initialized");
 3227|  6.66k|	p2p_channels_dump(p2p, "channels", &p2p->cfg->channels);
 3228|  6.66k|	p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels);
 3229|       |
 3230|  6.66k|	return p2p;
 3231|  6.66k|}
p2p_deinit:
 3235|  6.66k|{
 3236|  6.66k|#ifdef CONFIG_WIFI_DISPLAY
 3237|  6.66k|	wpabuf_free(p2p->wfd_ie_beacon);
 3238|  6.66k|	wpabuf_free(p2p->wfd_ie_probe_req);
 3239|  6.66k|	wpabuf_free(p2p->wfd_ie_probe_resp);
 3240|  6.66k|	wpabuf_free(p2p->wfd_ie_assoc_req);
 3241|  6.66k|	wpabuf_free(p2p->wfd_ie_invitation);
 3242|  6.66k|	wpabuf_free(p2p->wfd_ie_prov_disc_req);
 3243|  6.66k|	wpabuf_free(p2p->wfd_ie_prov_disc_resp);
 3244|  6.66k|	wpabuf_free(p2p->wfd_ie_go_neg);
 3245|  6.66k|	wpabuf_free(p2p->wfd_dev_info);
 3246|  6.66k|	wpabuf_free(p2p->wfd_assoc_bssid);
 3247|  6.66k|	wpabuf_free(p2p->wfd_coupled_sink_info);
 3248|  6.66k|	wpabuf_free(p2p->wfd_r2_dev_info);
 3249|  6.66k|#endif /* CONFIG_WIFI_DISPLAY */
 3250|       |
 3251|  6.66k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3252|  6.66k|	eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);
 3253|  6.66k|	eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
 3254|  6.66k|	p2p_flush(p2p);
 3255|  6.66k|	p2p_free_req_dev_types(p2p);
 3256|  6.66k|	os_free(p2p->cfg->dev_name);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3257|  6.66k|	os_free(p2p->cfg->manufacturer);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3258|  6.66k|	os_free(p2p->cfg->model_name);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3259|  6.66k|	os_free(p2p->cfg->model_number);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3260|  6.66k|	os_free(p2p->cfg->serial_number);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3261|  6.66k|	os_free(p2p->cfg->pref_chan);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3262|  6.66k|	os_free(p2p->groups);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3263|  6.66k|	p2ps_prov_free(p2p);
 3264|  6.66k|	wpabuf_free(p2p->sd_resp);
 3265|  6.66k|	p2p_remove_wps_vendor_extensions(p2p);
 3266|  6.66k|	os_free(p2p->no_go_freq.range);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3267|  6.66k|	p2p_service_flush_asp(p2p);
 3268|  6.66k|	p2p_pairing_info_deinit(p2p);
 3269|       |
 3270|  6.66k|	os_free(p2p);
  ------------------
  |  |  511|  6.66k|#define os_free(p) free((p))
  ------------------
 3271|  6.66k|}
p2p_flush:
 3275|  6.66k|{
 3276|  6.66k|	struct p2p_device *dev, *prev;
 3277|       |
 3278|  6.66k|	p2p_ext_listen(p2p, 0, 0);
 3279|  6.66k|	p2p_stop_find(p2p);
 3280|  6.66k|	dl_list_for_each_safe(dev, prev, &p2p->devices, struct p2p_device,
  ------------------
  |  |   84|  6.66k|	for (item = dl_list_entry((list)->next, type, member), \
  |  |  ------------------
  |  |  |  |   68|  6.66k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   85|  6.66k|		     n = dl_list_entry(item->member.next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.66k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   86|  8.65k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (86:7): [True: 1.98k, False: 6.66k]
  |  |  ------------------
  |  |   87|  6.66k|	     item = n, n = dl_list_entry(n->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|  1.98k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
 3281|  6.66k|			      list) {
 3282|  1.98k|		dl_list_del(&dev->list);
 3283|  1.98k|		p2p_device_free(p2p, dev);
 3284|  1.98k|	}
 3285|  6.66k|	p2p_free_sd_queries(p2p);
 3286|  6.66k|	p2p->ssid_set = 0;
 3287|  6.66k|	p2ps_prov_free(p2p);
 3288|  6.66k|	p2p_reset_pending_pd(p2p);
 3289|  6.66k|	p2p->override_pref_op_class = 0;
 3290|  6.66k|	p2p->override_pref_channel = 0;
 3291|  6.66k|}
p2p_remove_wps_vendor_extensions:
 3418|  6.66k|{
 3419|  6.66k|	int i;
 3420|       |
 3421|  73.3k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  73.3k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (3421:14): [True: 66.6k, False: 6.66k]
  ------------------
 3422|  66.6k|		wpabuf_free(p2p->wps_vendor_ext[i]);
 3423|       |		p2p->wps_vendor_ext[i] = NULL;
 3424|  66.6k|	}
 3425|  6.66k|}
p2p_scan_res_handler:
 3736|  6.66k|{
 3737|  6.66k|	if (os_reltime_before(rx_time, &p2p->find_start)) {
  ------------------
  |  Branch (3737:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1);
 3755|       |
 3756|  6.66k|	return 0;
 3757|  6.66k|}
p2p_scan_res_handled:
 3761|  6.66k|{
 3762|  6.66k|	if (!p2p->p2p_scan_running) {
  ------------------
  |  Branch (3762:6): [True: 6.66k, False: 0]
  ------------------
 3763|  6.66k|		p2p_dbg(p2p, "p2p_scan was not running, but scan results received");
 3764|  6.66k|	}
 3765|  6.66k|	p2p->p2p_scan_running = 0;
 3766|       |
 3767|       |	/* Use this delay only when p2p_find doesn't set it */
 3768|  6.66k|	if (!p2p->search_delay)
  ------------------
  |  Branch (3768:6): [True: 6.66k, False: 0]
  ------------------
 3769|  6.66k|		p2p->search_delay = delay;
 3770|       |
 3771|  6.66k|	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 3772|       |
 3773|  6.66k|	if (p2p_run_after_scan(p2p))
  ------------------
  |  Branch (3773:6): [True: 0, False: 6.66k]
  ------------------
 3774|      0|		return;
 3775|  6.66k|	if (p2p->state == P2P_SEARCH)
  ------------------
  |  Branch (3775:6): [True: 0, False: 6.66k]
  ------------------
 3776|      0|		p2p_continue_find(p2p);
 3777|  6.66k|}
p2p_ext_listen:
 4914|  6.66k|{
 4915|  6.66k|	if (period > 65535 || interval > 65535 || period > interval ||
  ------------------
  |  Branch (4915:6): [True: 0, False: 6.66k]
  |  Branch (4915:24): [True: 0, False: 6.66k]
  |  Branch (4915:44): [True: 0, False: 6.66k]
  ------------------
 4916|  6.66k|	    (period == 0 && interval > 0) || (period > 0 && interval == 0)) {
  ------------------
  |  Branch (4916:7): [True: 6.66k, False: 0]
  |  Branch (4916:22): [True: 0, False: 6.66k]
  |  Branch (4916:40): [True: 0, False: 6.66k]
  |  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.66k|	eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL);
 4923|       |
 4924|  6.66k|	if (interval == 0) {
  ------------------
  |  Branch (4924:6): [True: 6.66k, False: 0]
  ------------------
 4925|  6.66k|		p2p_dbg(p2p, "Disabling Extended Listen Timing");
 4926|  6.66k|		p2p->ext_listen_period = 0;
 4927|  6.66k|		p2p->ext_listen_interval = 0;
 4928|  6.66k|		return 0;
 4929|  6.66k|	}
 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.66k|}
p2p_send_action:
 5306|  1.69k|{
 5307|  1.69k|	int res, scheduled;
 5308|       |
 5309|  1.69k|	res = p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid,
 5310|  1.69k|				    buf, len, wait_time, &scheduled);
 5311|  1.69k|	if (res == 0 && scheduled && p2p->in_listen && freq > 0 &&
  ------------------
  |  Branch (5311:6): [True: 1.69k, False: 0]
  |  Branch (5311:18): [True: 0, False: 1.69k]
  |  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.69k|	return res;
 5320|  1.69k|}
p2p_dbg:
 5566|  95.3k|{
 5567|  95.3k|	va_list ap;
 5568|  95.3k|	char buf[500];
 5569|       |
 5570|  95.3k|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5570:6): [True: 0, False: 95.3k]
  ------------------
 5571|      0|		return;
 5572|       |
 5573|  95.3k|	va_start(ap, fmt);
 5574|  95.3k|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5575|  95.3k|	buf[sizeof(buf) - 1] = '\0';
 5576|       |	va_end(ap);
 5577|  95.3k|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf);
 5578|  95.3k|}
p2p_info:
 5582|     57|{
 5583|     57|	va_list ap;
 5584|     57|	char buf[500];
 5585|       |
 5586|     57|	if (!p2p->cfg->debug_print)
  ------------------
  |  Branch (5586:6): [True: 0, False: 57]
  ------------------
 5587|      0|		return;
 5588|       |
 5589|     57|	va_start(ap, fmt);
 5590|     57|	vsnprintf(buf, sizeof(buf), fmt, ap);
 5591|     57|	buf[sizeof(buf) - 1] = '\0';
 5592|       |	va_end(ap);
 5593|     57|	p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf);
 5594|     57|}
p2p.c:p2p_state_txt:
  111|  20.0k|{
  112|  20.0k|	switch (state) {
  113|  20.0k|	case P2P_IDLE:
  ------------------
  |  Branch (113:2): [True: 20.0k, False: 0]
  ------------------
  114|  20.0k|		return "IDLE";
  115|      0|	case P2P_SEARCH:
  ------------------
  |  Branch (115:2): [True: 0, False: 20.0k]
  ------------------
  116|      0|		return "SEARCH";
  117|      0|	case P2P_CONNECT:
  ------------------
  |  Branch (117:2): [True: 0, False: 20.0k]
  ------------------
  118|      0|		return "CONNECT";
  119|      0|	case P2P_CONNECT_LISTEN:
  ------------------
  |  Branch (119:2): [True: 0, False: 20.0k]
  ------------------
  120|      0|		return "CONNECT_LISTEN";
  121|      0|	case P2P_GO_NEG:
  ------------------
  |  Branch (121:2): [True: 0, False: 20.0k]
  ------------------
  122|      0|		return "GO_NEG";
  123|      0|	case P2P_LISTEN_ONLY:
  ------------------
  |  Branch (123:2): [True: 0, False: 20.0k]
  ------------------
  124|      0|		return "LISTEN_ONLY";
  125|      0|	case P2P_WAIT_PEER_CONNECT:
  ------------------
  |  Branch (125:2): [True: 0, False: 20.0k]
  ------------------
  126|      0|		return "WAIT_PEER_CONNECT";
  127|      0|	case P2P_WAIT_PEER_IDLE:
  ------------------
  |  Branch (127:2): [True: 0, False: 20.0k]
  ------------------
  128|      0|		return "WAIT_PEER_IDLE";
  129|      0|	case P2P_SD_DURING_FIND:
  ------------------
  |  Branch (129:2): [True: 0, False: 20.0k]
  ------------------
  130|      0|		return "SD_DURING_FIND";
  131|      0|	case P2P_PROVISIONING:
  ------------------
  |  Branch (131:2): [True: 0, False: 20.0k]
  ------------------
  132|      0|		return "PROVISIONING";
  133|      0|	case P2P_PD_DURING_FIND:
  ------------------
  |  Branch (133:2): [True: 0, False: 20.0k]
  ------------------
  134|      0|		return "PD_DURING_FIND";
  135|      0|	case P2P_INVITE:
  ------------------
  |  Branch (135:2): [True: 0, False: 20.0k]
  ------------------
  136|      0|		return "INVITE";
  137|      0|	case P2P_INVITE_LISTEN:
  ------------------
  |  Branch (137:2): [True: 0, False: 20.0k]
  ------------------
  138|      0|		return "INVITE_LISTEN";
  139|      0|	default:
  ------------------
  |  Branch (139:2): [True: 0, False: 20.0k]
  ------------------
  140|      0|		return "?";
  141|  20.0k|	}
  142|  20.0k|}
p2p.c:p2p_create_device:
  431|  2.45k|{
  432|  2.45k|	struct p2p_device *dev, *oldest = NULL;
  433|  2.45k|	size_t count = 0;
  434|       |
  435|  2.45k|	dev = p2p_get_device(p2p, addr);
  436|  2.45k|	if (dev)
  ------------------
  |  Branch (436:6): [True: 471, False: 1.98k]
  ------------------
  437|    471|		return dev;
  438|       |
  439|  1.98k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  2.45k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  2.45k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  2.60k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 616, False: 1.98k]
  |  |  ------------------
  |  |   81|  1.98k|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|    616|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  440|    616|		count++;
  441|    616|		if (oldest == NULL ||
  ------------------
  |  Branch (441:7): [True: 312, False: 304]
  ------------------
  442|    304|		    os_reltime_before(&dev->last_seen, &oldest->last_seen))
  ------------------
  |  Branch (442:7): [True: 12, False: 292]
  ------------------
  443|    324|			oldest = dev;
  444|    616|	}
  445|  1.98k|	if (count + 1 > p2p->cfg->max_peers && oldest) {
  ------------------
  |  Branch (445:6): [True: 0, False: 1.98k]
  |  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.98k|	dev = os_zalloc(sizeof(*dev));
  454|  1.98k|	if (dev == NULL)
  ------------------
  |  Branch (454:6): [True: 0, False: 1.98k]
  ------------------
  455|      0|		return NULL;
  456|  1.98k|	dl_list_add(&p2p->devices, &dev->list);
  457|  1.98k|	os_memcpy(dev->info.p2p_device_addr, addr, ETH_ALEN);
  ------------------
  |  |  523|  1.98k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  458|  1.98k|	dev->support_6ghz = false;
  459|       |
  460|  1.98k|	return dev;
  461|  1.98k|}
p2p.c:p2p_copy_wps_info:
  564|  2.31k|{
  565|  2.31k|	os_memcpy(dev->info.device_name, msg->device_name,
  ------------------
  |  |  523|  2.31k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  566|  2.31k|		  sizeof(dev->info.device_name));
  567|       |
  568|  2.31k|	if (msg->manufacturer &&
  ------------------
  |  Branch (568:6): [True: 31, False: 2.28k]
  ------------------
  569|     31|	    msg->manufacturer_len < sizeof(dev->info.manufacturer)) {
  ------------------
  |  Branch (569:6): [True: 31, False: 0]
  ------------------
  570|     31|		os_memset(dev->info.manufacturer, 0,
  ------------------
  |  |  529|     31|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  571|     31|			  sizeof(dev->info.manufacturer));
  572|     31|		os_memcpy(dev->info.manufacturer, msg->manufacturer,
  ------------------
  |  |  523|     31|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  573|     31|			  msg->manufacturer_len);
  574|     31|	}
  575|       |
  576|  2.31k|	if (msg->model_name &&
  ------------------
  |  Branch (576:6): [True: 35, False: 2.28k]
  ------------------
  577|     35|	    msg->model_name_len < sizeof(dev->info.model_name)) {
  ------------------
  |  Branch (577:6): [True: 35, False: 0]
  ------------------
  578|     35|		os_memset(dev->info.model_name, 0,
  ------------------
  |  |  529|     35|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  579|     35|			  sizeof(dev->info.model_name));
  580|     35|		os_memcpy(dev->info.model_name, msg->model_name,
  ------------------
  |  |  523|     35|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  581|     35|			  msg->model_name_len);
  582|     35|	}
  583|       |
  584|  2.31k|	if (msg->model_number &&
  ------------------
  |  Branch (584:6): [True: 33, False: 2.28k]
  ------------------
  585|     33|	    msg->model_number_len < sizeof(dev->info.model_number)) {
  ------------------
  |  Branch (585:6): [True: 33, False: 0]
  ------------------
  586|     33|		os_memset(dev->info.model_number, 0,
  ------------------
  |  |  529|     33|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  587|     33|			  sizeof(dev->info.model_number));
  588|     33|		os_memcpy(dev->info.model_number, msg->model_number,
  ------------------
  |  |  523|     33|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  589|     33|			  msg->model_number_len);
  590|     33|	}
  591|       |
  592|  2.31k|	if (msg->serial_number &&
  ------------------
  |  Branch (592:6): [True: 48, False: 2.26k]
  ------------------
  593|     48|	    msg->serial_number_len < sizeof(dev->info.serial_number)) {
  ------------------
  |  Branch (593:6): [True: 48, False: 0]
  ------------------
  594|     48|		os_memset(dev->info.serial_number, 0,
  ------------------
  |  |  529|     48|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  595|     48|			  sizeof(dev->info.serial_number));
  596|     48|		os_memcpy(dev->info.serial_number, msg->serial_number,
  ------------------
  |  |  523|     48|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  597|     48|			  msg->serial_number_len);
  598|     48|	}
  599|       |
  600|  2.31k|	if (msg->pri_dev_type)
  ------------------
  |  Branch (600:6): [True: 555, False: 1.76k]
  ------------------
  601|    555|		os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type,
  ------------------
  |  |  523|    555|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  602|  2.31k|			  sizeof(dev->info.pri_dev_type));
  603|  1.76k|	else if (msg->wps_pri_dev_type)
  ------------------
  |  Branch (603:11): [True: 14, False: 1.74k]
  ------------------
  604|     14|		os_memcpy(dev->info.pri_dev_type, msg->wps_pri_dev_type,
  ------------------
  |  |  523|     14|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  605|  2.31k|			  sizeof(dev->info.pri_dev_type));
  606|       |
  607|  2.31k|	if (msg->wps_sec_dev_type_list) {
  ------------------
  |  Branch (607:6): [True: 12, False: 2.30k]
  ------------------
  608|     12|		os_memcpy(dev->info.wps_sec_dev_type_list,
  ------------------
  |  |  523|     12|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  609|     12|			  msg->wps_sec_dev_type_list,
  610|     12|			  msg->wps_sec_dev_type_list_len);
  611|     12|		dev->info.wps_sec_dev_type_list_len =
  612|     12|			msg->wps_sec_dev_type_list_len;
  613|     12|	}
  614|       |
  615|  2.31k|	if (msg->capability) {
  ------------------
  |  Branch (615:6): [True: 156, False: 2.16k]
  ------------------
  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|    156|		dev->info.dev_capab &= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|    156|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    156|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  621|    156|		dev->info.dev_capab |= msg->capability[0] &
  622|    156|			~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
  ------------------
  |  | 1851|    156|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|    156|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  623|    156|		dev->info.group_capab = msg->capability[1];
  624|    156|	}
  625|       |
  626|  2.31k|	p2p_update_peer_6ghz_capab(dev, msg);
  627|       |
  628|  2.31k|	if (msg->ext_listen_timing) {
  ------------------
  |  Branch (628:6): [True: 9, False: 2.30k]
  ------------------
  629|      9|		dev->ext_listen_period = WPA_GET_LE16(msg->ext_listen_timing);
  630|      9|		dev->ext_listen_interval =
  631|      9|			WPA_GET_LE16(msg->ext_listen_timing + 2);
  632|      9|	}
  633|       |
  634|  2.31k|	if (!probe_req) {
  ------------------
  |  Branch (634:6): [True: 1.93k, False: 378]
  ------------------
  635|  1.93k|		u16 new_config_methods;
  636|  1.93k|		new_config_methods = msg->config_methods ?
  ------------------
  |  Branch (636:24): [True: 508, False: 1.43k]
  ------------------
  637|  1.43k|			msg->config_methods : msg->wps_config_methods;
  638|  1.93k|		if (new_config_methods &&
  ------------------
  |  Branch (638:7): [True: 592, False: 1.34k]
  ------------------
  639|    592|		    dev->info.config_methods != new_config_methods) {
  ------------------
  |  Branch (639:7): [True: 499, False: 93]
  ------------------
  640|    499|			p2p_dbg(p2p, "Update peer " MACSTR
  641|    499|				" config_methods 0x%x -> 0x%x",
  642|    499|				MAC2STR(dev->info.p2p_device_addr),
  ------------------
  |  |  447|    499|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  643|    499|				dev->info.config_methods,
  644|    499|				new_config_methods);
  645|    499|			dev->info.config_methods = new_config_methods;
  646|    499|		}
  647|  1.93k|	}
  648|  2.31k|}
p2p.c:p2p_compare_wfd_info:
  704|  1.91k|{
  705|  1.91k|	if (dev->info.wfd_subelems && msg->wfd_subelems) {
  ------------------
  |  Branch (705:6): [True: 199, False: 1.71k]
  |  Branch (705:32): [True: 192, False: 7]
  ------------------
  706|    192|		if (dev->info.wfd_subelems->used != msg->wfd_subelems->used)
  ------------------
  |  Branch (706:7): [True: 35, False: 157]
  ------------------
  707|     35|			return 1;
  708|       |
  709|    157|		return os_memcmp(dev->info.wfd_subelems->buf,
  ------------------
  |  |  532|    157|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  710|    192|				 msg->wfd_subelems->buf,
  711|    192|				 dev->info.wfd_subelems->used);
  712|    192|	}
  713|  1.72k|	if (dev->info.wfd_subelems || msg->wfd_subelems)
  ------------------
  |  Branch (713:6): [True: 7, False: 1.71k]
  |  Branch (713:32): [True: 227, False: 1.48k]
  ------------------
  714|    234|		return 1;
  715|       |
  716|  1.48k|	return 0;
  717|  1.72k|}
p2p.c:p2p_add_group_clients:
  485|  1.30k|{
  486|  1.30k|	struct p2p_group_info info;
  487|  1.30k|	size_t c;
  488|  1.30k|	struct p2p_device *dev;
  489|       |
  490|  1.30k|	if (gi == NULL)
  ------------------
  |  Branch (490:6): [True: 1.15k, False: 150]
  ------------------
  491|  1.15k|		return 0;
  492|       |
  493|    150|	if (p2p_group_info_parse(gi, gi_len, &info) < 0)
  ------------------
  |  Branch (493:6): [True: 69, False: 81]
  ------------------
  494|     69|		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|     81|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|    150|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|    150|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|    162|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 81, False: 81]
  |  |  ------------------
  |  |   81|     81|	     item = dl_list_entry(item->member.next, type, member))
  |  |  ------------------
  |  |  |  |   68|     81|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  ------------------
  501|     81|		if (ether_addr_equal(dev->member_in_go_iface,
  ------------------
  |  Branch (501:7): [True: 0, False: 81]
  ------------------
  502|     81|				     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|     81|	}
  507|       |
  508|    264|	for (c = 0; c < info.num_clients; c++) {
  ------------------
  |  Branch (508:14): [True: 183, False: 81]
  ------------------
  509|    183|		struct p2p_client_info *cli = &info.client[c];
  510|    183|		if (ether_addr_equal(cli->p2p_device_addr, p2p->cfg->dev_addr))
  ------------------
  |  Branch (510:7): [True: 10, False: 173]
  ------------------
  511|     10|			continue; /* ignore our own entry */
  512|    173|		dev = p2p_get_device(p2p, cli->p2p_device_addr);
  513|    173|		if (dev) {
  ------------------
  |  Branch (513:7): [True: 27, False: 146]
  ------------------
  514|     27|			if (dev->flags & (P2P_DEV_GROUP_CLIENT_ONLY |
  ------------------
  |  |  137|     27|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|     27|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (514:8): [True: 16, False: 11]
  ------------------
  515|     27|					  P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     27|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     27|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  516|       |				/*
  517|       |				 * Update information since we have not
  518|       |				 * received this directly from the client.
  519|       |				 */
  520|     16|				p2p_copy_client_info(dev, cli);
  521|     16|			} 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|     27|			if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
  ------------------
  |  |  127|     27|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     27|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (533:8): [True: 0, False: 27]
  ------------------
  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|    146|		} else {
  537|    146|			dev = p2p_create_device(p2p, cli->p2p_device_addr);
  538|    146|			if (dev == NULL)
  ------------------
  |  Branch (538:8): [True: 0, False: 146]
  ------------------
  539|      0|				continue;
  540|    146|			dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY;
  ------------------
  |  |  137|    146|#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
  |  |  ------------------
  |  |  |  |  458|    146|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  541|    146|			p2p_copy_client_info(dev, cli);
  542|    146|			dev->oper_freq = freq;
  543|    146|			p2p->cfg->dev_found(p2p->cfg->cb_ctx,
  544|    146|					    dev->info.p2p_device_addr,
  545|    146|					    &dev->info, 1);
  546|    146|			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  128|    146|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|    146|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              			dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE;
  ------------------
  |  |  140|    146|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|    146|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  547|    146|		}
  548|       |
  549|    173|		os_memcpy(dev->interface_addr, cli->p2p_interface_addr,
  ------------------
  |  |  523|    173|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  550|    173|			  ETH_ALEN);
  551|    173|		os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime));
  ------------------
  |  |  523|    173|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  552|    173|		os_memcpy(dev->member_in_go_dev, go_dev_addr, ETH_ALEN);
  ------------------
  |  |  523|    173|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  553|    173|		os_memcpy(dev->member_in_go_iface, go_interface_addr,
  ------------------
  |  |  523|    173|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  554|    173|			  ETH_ALEN);
  555|    173|		dev->flags |= P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT;
  ------------------
  |  |  147|    173|#define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22)
  |  |  ------------------
  |  |  |  |  458|    173|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  556|    173|	}
  557|       |
  558|     81|	return 0;
  559|    150|}
p2p.c:p2p_copy_client_info:
  466|    162|{
  467|    162|	p2p_copy_filter_devname(dev->info.device_name,
  468|    162|				sizeof(dev->info.device_name),
  469|    162|				cli->dev_name, cli->dev_name_len);
  470|    162|	dev->info.dev_capab = cli->dev_capab;
  471|    162|	dev->info.config_methods = cli->config_methods;
  472|    162|	os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);
  ------------------
  |  |  523|    162|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  473|    162|	dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types;
  474|    162|	if (dev->info.wps_sec_dev_type_list_len > WPS_SEC_DEV_TYPE_MAX_LEN)
  ------------------
  |  |   62|    162|#define WPS_SEC_DEV_TYPE_MAX_LEN 128
  ------------------
  |  Branch (474:6): [True: 3, False: 159]
  ------------------
  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|    162|	os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types,
  ------------------
  |  |  523|    162|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  477|    162|		  dev->info.wps_sec_dev_type_list_len);
  478|    162|}
p2p.c:p2p_update_peer_vendor_elems:
  662|  1.91k|{
  663|  1.91k|	const u8 *pos, *end;
  664|  1.91k|	u8 id, len;
  665|       |
  666|  1.91k|	wpabuf_free(dev->info.vendor_elems);
  667|  1.91k|	dev->info.vendor_elems = NULL;
  668|       |
  669|  1.91k|	end = ies + ies_len;
  670|       |
  671|  10.2M|	for (pos = ies; end - pos > 1; pos += len) {
  ------------------
  |  Branch (671:18): [True: 10.2M, False: 1.87k]
  ------------------
  672|  10.2M|		id = *pos++;
  673|  10.2M|		len = *pos++;
  674|       |
  675|  10.2M|		if (len > end - pos)
  ------------------
  |  Branch (675:7): [True: 0, False: 10.2M]
  ------------------
  676|      0|			break;
  677|       |
  678|  10.2M|		if (id != WLAN_EID_VENDOR_SPECIFIC || len < 3)
  ------------------
  |  |  493|  20.5M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (678:7): [True: 10.2M, False: 40.2k]
  |  Branch (678:41): [True: 1.36k, False: 38.9k]
  ------------------
  679|  10.2M|			continue;
  680|       |
  681|  38.9k|		if (len >= 4) {
  ------------------
  |  Branch (681:7): [True: 37.7k, False: 1.12k]
  ------------------
  682|  37.7k|			u32 type = WPA_GET_BE32(pos);
  683|       |
  684|  37.7k|			if (type == WPA_IE_VENDOR_TYPE ||
  ------------------
  |  | 1511|  75.5k|#define WPA_IE_VENDOR_TYPE 0x0050f201
  ------------------
  |  Branch (684:8): [True: 1.01k, False: 36.7k]
  ------------------
  685|  36.7k|			    type == WMM_IE_VENDOR_TYPE ||
  ------------------
  |  | 1512|  74.5k|#define WMM_IE_VENDOR_TYPE 0x0050f202
  ------------------
  |  Branch (685:8): [True: 235, False: 36.5k]
  ------------------
  686|  36.5k|			    type == WPS_IE_VENDOR_TYPE ||
  ------------------
  |  | 1513|  74.3k|#define WPS_IE_VENDOR_TYPE 0x0050f204
  ------------------
  |  Branch (686:8): [True: 2.75k, False: 33.7k]
  ------------------
  687|  33.7k|			    type == P2P_IE_VENDOR_TYPE ||
  ------------------
  |  | 1515|  71.5k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (687:8): [True: 15.2k, False: 18.5k]
  ------------------
  688|  18.5k|			    type == WFD_IE_VENDOR_TYPE)
  ------------------
  |  | 1517|  18.5k|#define WFD_IE_VENDOR_TYPE 0x506f9a0a
  ------------------
  |  Branch (688:8): [True: 13.0k, False: 5.48k]
  ------------------
  689|  32.3k|				continue;
  690|  37.7k|		}
  691|       |
  692|       |		/* Unknown vendor element - make raw IE data available */
  693|  6.61k|		if (wpabuf_resize(&dev->info.vendor_elems, 2 + len) < 0)
  ------------------
  |  Branch (693:7): [True: 0, False: 6.61k]
  ------------------
  694|      0|			break;
  695|  6.61k|		wpabuf_put_data(dev->info.vendor_elems, pos - 2, 2 + len);
  696|  6.61k|		if (wpabuf_size(dev->info.vendor_elems) > 2000)
  ------------------
  |  Branch (696:7): [True: 35, False: 6.57k]
  ------------------
  697|     35|			break;
  698|  6.61k|	}
  699|  1.91k|}
p2p.c:p2p_device_free:
  943|  1.98k|{
  944|  1.98k|	int i;
  945|       |
  946|  1.98k|	if (p2p->go_neg_peer == dev) {
  ------------------
  |  Branch (946:6): [True: 0, False: 1.98k]
  ------------------
  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.98k|	if (p2p->invite_peer == dev)
  ------------------
  |  Branch (952:6): [True: 0, False: 1.98k]
  ------------------
  953|      0|		p2p->invite_peer = NULL;
  954|  1.98k|	if (p2p->sd_peer == dev)
  ------------------
  |  Branch (954:6): [True: 0, False: 1.98k]
  ------------------
  955|      0|		p2p->sd_peer = NULL;
  956|  1.98k|	if (p2p->pending_client_disc_go == dev)
  ------------------
  |  Branch (956:6): [True: 0, False: 1.98k]
  ------------------
  957|      0|		p2p->pending_client_disc_go = NULL;
  958|       |
  959|       |	/* dev_lost() device, but only if it was previously dev_found() */
  960|  1.98k|	if (dev->flags & P2P_DEV_REPORTED_ONCE)
  ------------------
  |  |  140|  1.98k|#define P2P_DEV_REPORTED_ONCE BIT(15)
  |  |  ------------------
  |  |  |  |  458|  1.98k|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (960:6): [True: 611, False: 1.37k]
  ------------------
  961|    611|		p2p->cfg->dev_lost(p2p->cfg->cb_ctx,
  962|    611|				   dev->info.p2p_device_addr);
  963|       |
  964|  21.8k|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|  21.8k|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (964:14): [True: 19.8k, False: 1.98k]
  ------------------
  965|  19.8k|		wpabuf_free(dev->info.wps_vendor_ext[i]);
  966|  19.8k|		dev->info.wps_vendor_ext[i] = NULL;
  967|  19.8k|	}
  968|       |
  969|  1.98k|	os_free(dev->bootstrap_params);
  ------------------
  |  |  511|  1.98k|#define os_free(p) free((p))
  ------------------
  970|       |
  971|  1.98k|	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.98k|	wpabuf_free(dev->info.wfd_subelems);
  981|  1.98k|	wpabuf_free(dev->info.vendor_elems);
  982|  1.98k|	wpabuf_free(dev->go_neg_conf);
  983|  1.98k|	wpabuf_free(dev->info.p2ps_instance);
  984|       |
  985|  1.98k|	os_free(dev);
  ------------------
  |  |  511|  1.98k|#define os_free(p) free((p))
  ------------------
  986|  1.98k|}
p2p.c:p2p_free_req_dev_types:
 1154|  13.3k|{
 1155|  13.3k|	p2p->num_req_dev_types = 0;
 1156|  13.3k|	os_free(p2p->req_dev_types);
  ------------------
  |  |  511|  13.3k|#define os_free(p) free((p))
  ------------------
 1157|       |	p2p->req_dev_types = NULL;
 1158|  13.3k|}
p2p.c:p2ps_gen_hash:
 1162|  6.66k|{
 1163|  6.66k|	u8 buf[SHA256_MAC_LEN];
 1164|  6.66k|	char str_buf[256];
 1165|  6.66k|	const u8 *adv_array;
 1166|  6.66k|	size_t i, adv_len;
 1167|       |
 1168|  6.66k|	if (!str || !hash)
  ------------------
  |  Branch (1168:6): [True: 0, False: 6.66k]
  |  Branch (1168:14): [True: 0, False: 6.66k]
  ------------------
 1169|      0|		return 0;
 1170|       |
 1171|  6.66k|	if (!str[0]) {
  ------------------
  |  Branch (1171:6): [True: 0, False: 6.66k]
  ------------------
 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.66k|	adv_array = (u8 *) str_buf;
 1177|  6.66k|	adv_len = os_strlen(str);
  ------------------
  |  |  536|  6.66k|#define os_strlen(s) strlen(s)
  ------------------
 1178|  6.66k|	if (adv_len >= sizeof(str_buf))
  ------------------
  |  Branch (1178:6): [True: 0, False: 6.66k]
  ------------------
 1179|      0|		return 0;
 1180|       |
 1181|   100k|	for (i = 0; i < adv_len; i++) {
  ------------------
  |  Branch (1181:14): [True: 93.3k, False: 6.66k]
  ------------------
 1182|  93.3k|		if (str[i] >= 'A' && str[i] <= 'Z')
  ------------------
  |  Branch (1182:7): [True: 73.3k, False: 20.0k]
  |  Branch (1182:24): [True: 0, False: 73.3k]
  ------------------
 1183|      0|			str_buf[i] = str[i] - 'A' + 'a';
 1184|  93.3k|		else
 1185|  93.3k|			str_buf[i] = str[i];
 1186|  93.3k|	}
 1187|       |
 1188|  6.66k|	if (sha256_vector(1, &adv_array, &adv_len, buf))
  ------------------
  |  Branch (1188:6): [True: 0, False: 6.66k]
  ------------------
 1189|      0|		return 0;
 1190|       |
 1191|  6.66k|	os_memcpy(hash, buf, P2PS_HASH_LEN);
  ------------------
  |  |  523|  6.66k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1192|  6.66k|	return 1;
 1193|  6.66k|}
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: 20]
  ------------------
 2078|  2.20k|	case WLAN_PA_VENDOR_SPECIFIC:
  ------------------
  |  |  717|  2.20k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
  |  Branch (2078:2): [True: 2.20k, False: 54]
  ------------------
 2079|  2.20k|		data++;
 2080|  2.20k|		len--;
 2081|  2.20k|		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: 22, False: 2.17k]
  ------------------
 2084|     22|			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|      2|	case WLAN_PA_GAS_INITIAL_RESP:
  ------------------
  |  |  719|      2|#define WLAN_PA_GAS_INITIAL_RESP 11
  ------------------
  |  Branch (2094:2): [True: 2, False: 2.25k]
  ------------------
 2095|      2|		p2p_rx_gas_initial_resp(p2p, sa, data + 1, len - 1, freq);
 2096|      2|		break;
 2097|     30|	case WLAN_PA_GAS_COMEBACK_REQ:
  ------------------
  |  |  720|     30|#define WLAN_PA_GAS_COMEBACK_REQ 12
  ------------------
  |  Branch (2097:2): [True: 30, False: 2.22k]
  ------------------
 2098|     30|		p2p_rx_gas_comeback_req(p2p, sa, data + 1, len - 1, freq);
 2099|     30|		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.17k]
  ------------------
 2032|      1|		return;
 2033|       |
 2034|  2.17k|	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|      3|	case P2P_GO_NEG_RESP:
  ------------------
  |  Branch (2038:2): [True: 3, False: 2.17k]
  ------------------
 2039|      3|		p2p_handle_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq);
 2040|      3|		break;
 2041|      2|	case P2P_GO_NEG_CONF:
  ------------------
  |  Branch (2041:2): [True: 2, False: 2.17k]
  ------------------
 2042|      2|		p2p_handle_go_neg_conf(p2p, sa, data + 1, len - 1, false);
 2043|      2|		break;
 2044|    972|	case P2P_INVITATION_REQ:
  ------------------
  |  Branch (2044:2): [True: 972, False: 1.20k]
  ------------------
 2045|    972|		p2p_handle_invitation_req(p2p, sa, data + 1, len - 1, rx_freq);
 2046|    972|		break;
 2047|      4|	case P2P_INVITATION_RESP:
  ------------------
  |  Branch (2047:2): [True: 4, False: 2.17k]
  ------------------
 2048|      4|		p2p_process_invitation_resp(p2p, sa, data + 1, len - 1);
 2049|      4|		break;
 2050|  1.03k|	case P2P_PROV_DISC_REQ:
  ------------------
  |  Branch (2050:2): [True: 1.03k, False: 1.14k]
  ------------------
 2051|  1.03k|		p2p_handle_prov_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2052|  1.03k|		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|     23|	case P2P_DEV_DISC_REQ:
  ------------------
  |  Branch (2056:2): [True: 23, False: 2.15k]
  ------------------
 2057|     23|		p2p_process_dev_disc_req(p2p, sa, data + 1, len - 1, rx_freq);
 2058|     23|		break;
 2059|      1|	case P2P_DEV_DISC_RESP:
  ------------------
  |  Branch (2059:2): [True: 1, False: 2.17k]
  ------------------
 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.17k]
  ------------------
 2063|      3|		p2p_dbg(p2p, "Unsupported P2P Public Action frame type %d",
 2064|      3|			data[0]);
 2065|      3|		break;
 2066|  2.17k|	}
 2067|  2.17k|}
p2p.c:p2p_add_dev_from_probe_req:
 2193|  6.66k|{
 2194|  6.66k|	struct p2p_message msg;
 2195|  6.66k|	struct p2p_device *dev;
 2196|       |
 2197|  6.66k|	os_memset(&msg, 0, sizeof(msg));
  ------------------
  |  |  529|  6.66k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2198|  6.66k|	if (p2p_parse_ies(ie, ie_len, &msg) < 0 || msg.p2p_attributes == NULL)
  ------------------
  |  Branch (2198:6): [True: 2.43k, False: 4.23k]
  |  Branch (2198:45): [True: 2.34k, False: 1.88k]
  ------------------
 2199|  4.78k|	{
 2200|  4.78k|		p2p_parse_free(&msg);
 2201|  4.78k|		return; /* not a P2P probe */
 2202|  4.78k|	}
 2203|       |
 2204|  1.88k|	if (msg.ssid == NULL || msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
  ------------------
  |  | 1934|  2.81k|#define P2P_WILDCARD_SSID_LEN 7
  ------------------
  |  Branch (2204:6): [True: 957, False: 931]
  |  Branch (2204:26): [True: 373, False: 558]
  ------------------
 2205|    558|	    os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
  ------------------
  |  |  532|    558|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (2205:6): [True: 90, False: 468]
  ------------------
 2206|  1.42k|	    != 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.42k|		p2p_parse_free(&msg);
 2213|  1.42k|		return;
 2214|  1.42k|	}
 2215|       |
 2216|    468|	dev = p2p_get_device(p2p, addr);
 2217|    468|	if (dev) {
  ------------------
  |  Branch (2217:6): [True: 90, False: 378]
  ------------------
 2218|     90|		if (msg.listen_channel) {
  ------------------
  |  Branch (2218:7): [True: 66, False: 24]
  ------------------
 2219|     66|			int freq;
 2220|       |
 2221|     66|			if (dev->country[0] == 0)
  ------------------
  |  Branch (2221:8): [True: 66, False: 0]
  ------------------
 2222|     66|				os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|     66|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2223|       |
 2224|     66|			freq = p2p_channel_to_freq(msg.listen_channel[3],
 2225|     66|						   msg.listen_channel[4]);
 2226|       |
 2227|     66|			if (freq > 0 && dev->listen_freq != freq) {
  ------------------
  |  Branch (2227:8): [True: 41, False: 25]
  |  Branch (2227:20): [True: 40, False: 1]
  ------------------
 2228|     40|				p2p_dbg(p2p,
 2229|     40|					"Updated peer " MACSTR " Listen channel (Probe Request): %d -> %d MHz",
 2230|     40|					MAC2STR(addr), dev->listen_freq, freq);
  ------------------
  |  |  447|     40|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2231|     40|				dev->listen_freq = freq;
 2232|     40|			}
 2233|     66|		}
 2234|       |
 2235|     90|		p2p_update_peer_6ghz_capab(dev, &msg);
 2236|     90|		os_get_reltime(&dev->last_seen);
 2237|     90|		p2p_parse_free(&msg);
 2238|     90|		return; /* already known */
 2239|     90|	}
 2240|       |
 2241|    378|	dev = p2p_create_device(p2p, addr);
 2242|    378|	if (dev == NULL) {
  ------------------
  |  Branch (2242:6): [True: 0, False: 378]
  ------------------
 2243|      0|		p2p_parse_free(&msg);
 2244|      0|		return;
 2245|      0|	}
 2246|       |
 2247|    378|	os_get_reltime(&dev->last_seen);
 2248|    378|	dev->flags |= P2P_DEV_PROBE_REQ_ONLY;
  ------------------
  |  |  127|    378|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    378|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2249|       |
 2250|    378|	if (msg.listen_channel) {
  ------------------
  |  Branch (2250:6): [True: 296, False: 82]
  ------------------
 2251|    296|		os_memcpy(dev->country, msg.listen_channel, 3);
  ------------------
  |  |  523|    296|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2252|    296|		dev->listen_freq = p2p_channel_to_freq(msg.listen_channel[3],
 2253|    296|						       msg.listen_channel[4]);
 2254|    296|	}
 2255|       |
 2256|    378|	p2p_copy_wps_info(p2p, dev, 1, &msg);
 2257|       |
 2258|    378|	if (msg.wfd_subelems) {
  ------------------
  |  Branch (2258:6): [True: 42, False: 336]
  ------------------
 2259|     42|		wpabuf_free(dev->info.wfd_subelems);
 2260|     42|		dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 2261|     42|	}
 2262|       |
 2263|    378|	p2p_parse_free(&msg);
 2264|       |
 2265|    378|	p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR
 2266|    378|		" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
 2267|    378|		MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
  ------------------
  |  |  447|    378|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2268|    378|		dev->info.group_capab, dev->info.device_name,
 2269|    378|		dev->listen_freq);
 2270|    378|}
p2p.c:p2p_reply_probe:
 2500|  6.66k|{
 2501|  6.66k|	struct ieee802_11_elems elems;
 2502|  6.66k|	struct wpabuf *buf;
 2503|  6.66k|	struct p2p_message msg;
 2504|  6.66k|	struct wpabuf *ies;
 2505|       |
 2506|  6.66k|	if (ieee802_11_parse_elems((u8 *) ie, ie_len, &elems, 0) ==
  ------------------
  |  Branch (2506:6): [True: 948, False: 5.72k]
  ------------------
 2507|  6.66k|	    ParseFailed) {
 2508|       |		/* Ignore invalid Probe Request frames */
 2509|    948|		p2p_dbg(p2p, "Could not parse Probe Request frame - ignore it");
 2510|    948|		return P2P_PREQ_MALFORMED;
 2511|    948|	}
 2512|       |
 2513|  5.72k|	if (elems.p2p == NULL) {
  ------------------
  |  Branch (2513:6): [True: 3.17k, False: 2.54k]
  ------------------
 2514|       |		/* not a P2P probe - ignore it */
 2515|  3.17k|		p2p_dbg(p2p, "Not a P2P probe - ignore it");
 2516|  3.17k|		return P2P_PREQ_NOT_P2P;
 2517|  3.17k|	}
 2518|       |
 2519|  2.54k|	if (dst && !is_broadcast_ether_addr(dst) &&
  ------------------
  |  Branch (2519:6): [True: 2.54k, False: 0]
  |  Branch (2519:13): [True: 2.54k, False: 0]
  ------------------
 2520|  2.54k|	    !ether_addr_equal(dst, p2p->cfg->dev_addr)) {
  ------------------
  |  Branch (2520:6): [True: 2.54k, False: 0]
  ------------------
 2521|       |		/* Not sent to the broadcast address or our P2P Device Address
 2522|       |		 */
 2523|  2.54k|		p2p_dbg(p2p, "Probe Req DA " MACSTR " not ours - ignore it",
 2524|  2.54k|			MAC2STR(dst));
  ------------------
  |  |  447|  2.54k|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 2525|  2.54k|		return P2P_PREQ_NOT_PROCESSED;
 2526|  2.54k|	}
 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.66k|{
 3130|  6.66k|	struct p2p_pairing_info *pairing_info;
 3131|       |
 3132|  6.66k|	if (p2p->cfg->pairing_config.dik_len > DEVICE_IDENTITY_KEY_MAX_LEN)
  ------------------
  |  |   16|  6.66k|#define DEVICE_IDENTITY_KEY_MAX_LEN 64
  ------------------
  |  Branch (3132:6): [True: 0, False: 6.66k]
  ------------------
 3133|      0|		return -1;
 3134|       |
 3135|  6.66k|	pairing_info = os_zalloc(sizeof(struct p2p_pairing_info));
 3136|  6.66k|	if (!pairing_info)
  ------------------
  |  Branch (3136:6): [True: 0, False: 6.66k]
  ------------------
 3137|      0|		return -1;
 3138|       |
 3139|  6.66k|	pairing_info->enable_pairing_setup =
 3140|  6.66k|		p2p->cfg->pairing_config.enable_pairing_setup;
 3141|  6.66k|	pairing_info->enable_pairing_cache =
 3142|  6.66k|		p2p->cfg->pairing_config.enable_pairing_cache;
 3143|  6.66k|	pairing_info->supported_bootstrap =
 3144|  6.66k|		p2p->cfg->pairing_config.bootstrap_methods;
 3145|       |
 3146|  6.66k|	pairing_info->dev_ik.cipher_version =
 3147|  6.66k|		p2p->cfg->pairing_config.dik_cipher;
 3148|  6.66k|	pairing_info->dev_ik.dik_len = p2p->cfg->pairing_config.dik_len;
 3149|  6.66k|	os_memcpy(pairing_info->dev_ik.dik_data,
  ------------------
  |  |  523|  6.66k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 3150|  6.66k|		  p2p->cfg->pairing_config.dik_data,
 3151|  6.66k|		  p2p->cfg->pairing_config.dik_len);
 3152|  6.66k|	pairing_info->dev_ik.expiration = 24; /* hours */
 3153|       |
 3154|  6.66k|	p2p_pairing_info_deinit(p2p);
 3155|       |
 3156|  6.66k|	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.66k|	return 0;
 3163|  6.66k|}
p2p.c:p2p_pairing_info_deinit:
 3119|  13.3k|{
 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.3k|	os_free(p2p->pairing_info);
  ------------------
  |  |  511|  13.3k|#define os_free(p) free((p))
  ------------------
 3125|  13.3k|}
p2p.c:p2p_run_after_scan:
 1109|  6.66k|{
 1110|  6.66k|	struct p2p_device *dev;
 1111|  6.66k|	enum p2p_after_scan op;
 1112|       |
 1113|  6.66k|	op = p2p->start_after_scan;
 1114|  6.66k|	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
 1115|  6.66k|	switch (op) {
  ------------------
  |  Branch (1115:10): [True: 6.66k, False: 0]
  ------------------
 1116|  6.66k|	case P2P_AFTER_SCAN_NOTHING:
  ------------------
  |  Branch (1116:2): [True: 6.66k, False: 0]
  ------------------
 1117|  6.66k|		break;
 1118|      0|	case P2P_AFTER_SCAN_LISTEN:
  ------------------
  |  Branch (1118:2): [True: 0, False: 6.66k]
  ------------------
 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.66k]
  ------------------
 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.66k|	}
 1134|       |
 1135|  6.66k|	return 0;
 1136|  6.66k|}
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|    616|{
 4831|    616|	struct p2p_message msg;
 4832|       |
 4833|    616|	p2p_dbg(p2p, "Received P2P Action - P2P Presence Response");
 4834|       |
 4835|    616|	if (p2p_parse(data, len, &msg) < 0) {
  ------------------
  |  Branch (4835:6): [True: 247, False: 369]
  ------------------
 4836|    247|		p2p_dbg(p2p, "Failed to parse P2P Presence Response");
 4837|    247|		return;
 4838|    247|	}
 4839|       |
 4840|    369|	if (msg.status == NULL || msg.noa == NULL) {
  ------------------
  |  Branch (4840:6): [True: 364, False: 5]
  |  Branch (4840:28): [True: 2, False: 3]
  ------------------
 4841|    366|		p2p_dbg(p2p, "No Status or NoA attribute in P2P Presence Response");
 4842|    366|		p2p_parse_free(&msg);
 4843|    366|		return;
 4844|    366|	}
 4845|       |
 4846|      3|	if (p2p->cfg->presence_resp) {
  ------------------
  |  Branch (4846:6): [True: 0, False: 3]
  ------------------
 4847|      0|		p2p->cfg->presence_resp(p2p->cfg->cb_ctx, sa, *msg.status,
 4848|      0|					msg.noa, msg.noa_len);
 4849|      0|	}
 4850|       |
 4851|      3|	if (*msg.status) {
  ------------------
  |  Branch (4851:6): [True: 2, False: 1]
  ------------------
 4852|      2|		p2p_dbg(p2p, "P2P Presence Request was rejected: status %u",
 4853|      2|			*msg.status);
 4854|      2|		p2p_parse_free(&msg);
 4855|      2|		return;
 4856|      2|	}
 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.69k|{
   33|  1.69k|	wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC);
  ------------------
  |  |  670|  1.69k|#define WLAN_ACTION_PUBLIC 4
  ------------------
   34|  1.69k|	wpabuf_put_u8(buf, WLAN_PA_VENDOR_SPECIFIC);
  ------------------
  |  |  717|  1.69k|#define WLAN_PA_VENDOR_SPECIFIC 9
  ------------------
   35|  1.69k|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|  1.69k|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   36|       |
   37|  1.69k|	wpabuf_put_u8(buf, subtype); /* OUI Subtype */
   38|  1.69k|	wpabuf_put_u8(buf, dialog_token);
   39|  1.69k|	wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", dialog_token);
   40|  1.69k|}
p2p_buf_add_ie_hdr:
   44|    695|{
   45|    695|	u8 *len;
   46|       |
   47|       |	/* P2P IE header */
   48|    695|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|    695|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   49|    695|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   50|    695|	wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|    695|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
   51|    695|	wpa_printf(MSG_DEBUG, "P2P: * P2P IE header");
   52|    695|	return len;
   53|    695|}
p2p_buf_update_ie_hdr:
   57|  1.50k|{
   58|       |	/* Update P2P/P2P2 IE Length */
   59|  1.50k|	*len = (u8 *) wpabuf_put(buf, 0) - len - 1;
   60|  1.50k|}
p2p_buf_add_p2p2_ie_hdr:
   64|     51|{
   65|     51|	u8 *len;
   66|       |
   67|       |	/* P2P2 IE header */
   68|     51|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|     51|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   69|     51|	len = wpabuf_put(buf, 1); /* IE length to be filled */
   70|     51|	wpabuf_put_be32(buf, P2P2_IE_VENDOR_TYPE);
  ------------------
  |  | 1516|     51|#define P2P2_IE_VENDOR_TYPE 0x506f9a28
  ------------------
   71|     51|	wpa_printf(MSG_DEBUG, "P2P: * P2P2 IE header");
   72|     51|	return len;
   73|     51|}
p2p_buf_add_capability:
   77|     85|{
   78|       |	/* P2P Capability */
   79|     85|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY);
   80|     85|	wpabuf_put_le16(buf, 2);
   81|     85|	wpabuf_put_u8(buf, dev_capab); /* Device Capabilities */
   82|     85|	wpabuf_put_u8(buf, group_capab); /* Group Capabilities */
   83|     85|	wpa_printf(MSG_DEBUG, "P2P: * Capability dev=%02x group=%02x",
   84|     85|		   dev_capab, group_capab);
   85|     85|}
p2p_buf_add_go_intent:
   89|     83|{
   90|       |	/* Group Owner Intent */
   91|     83|	wpabuf_put_u8(buf, P2P_ATTR_GROUP_OWNER_INTENT);
   92|     83|	wpabuf_put_le16(buf, 1);
   93|     83|	wpabuf_put_u8(buf, go_intent);
   94|     83|	wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u Tie breaker %u",
   95|     83|		   go_intent >> 1, go_intent & 0x01);
   96|     83|}
p2p_buf_add_operating_channel:
  115|     83|{
  116|       |	/* Operating Channel */
  117|     83|	wpabuf_put_u8(buf, P2P_ATTR_OPERATING_CHANNEL);
  118|     83|	wpabuf_put_le16(buf, 5);
  119|     83|	wpabuf_put_data(buf, country, 3);
  120|     83|	wpabuf_put_u8(buf, reg_class); /* Regulatory Class */
  121|     83|	wpabuf_put_u8(buf, channel); /* Channel Number */
  122|     83|	wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: Regulatory Class %u "
  123|     83|		   "Channel %u", reg_class, channel);
  124|     83|}
p2p_buf_add_channel_list:
  169|     83|{
  170|     83|	u8 *len;
  171|     83|	size_t i;
  172|       |
  173|       |	/* Channel List */
  174|     83|	wpabuf_put_u8(buf, P2P_ATTR_CHANNEL_LIST);
  175|     83|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  176|     83|	wpabuf_put_data(buf, country, 3); /* Country String */
  177|       |
  178|     83|	for (i = 0; i < chan->reg_classes; i++) {
  ------------------
  |  Branch (178:14): [True: 0, False: 83]
  ------------------
  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|     83|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  190|     83|	wpa_hexdump(MSG_DEBUG, "P2P: * Channel List",
  191|     83|		    len + 2, (u8 *) wpabuf_put(buf, 0) - len - 2);
  192|     83|}
p2p_buf_add_status:
  196|  1.66k|{
  197|       |	/* Status */
  198|  1.66k|	wpabuf_put_u8(buf, P2P_ATTR_STATUS);
  199|  1.66k|	wpabuf_put_le16(buf, 1);
  200|  1.66k|	wpabuf_put_u8(buf, status);
  201|  1.66k|	wpa_printf(MSG_DEBUG, "P2P: * Status: %d", status);
  202|  1.66k|}
p2p_buf_add_device_info:
  207|     85|{
  208|     85|	u8 *len;
  209|     85|	u16 methods;
  210|     85|	size_t nlen, i;
  211|       |
  212|       |	/* P2P Device Info */
  213|     85|	wpabuf_put_u8(buf, P2P_ATTR_DEVICE_INFO);
  214|     85|	len = wpabuf_put(buf, 2); /* IE length to be filled */
  215|       |
  216|       |	/* P2P Device address */
  217|     85|	wpabuf_put_data(buf, p2p->cfg->dev_addr, ETH_ALEN);
  ------------------
  |  |  344|     85|#define ETH_ALEN 6
  ------------------
  218|       |
  219|       |	/* Config Methods */
  220|     85|	methods = 0;
  221|     85|	if (peer && peer->wps_method != WPS_NOT_READY) {
  ------------------
  |  Branch (221:6): [True: 41, False: 44]
  |  Branch (221:14): [True: 0, False: 41]
  ------------------
  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|     85|	} else if (p2p->cfg->config_methods) {
  ------------------
  |  Branch (229:13): [True: 0, False: 85]
  ------------------
  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|     85|	} else {
  234|     85|		methods |= WPS_CONFIG_PUSHBUTTON;
  ------------------
  |  |  255|     85|#define WPS_CONFIG_PUSHBUTTON 0x0080
  ------------------
  235|     85|		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|     85|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              		methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|     85|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  236|     85|		methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     85|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  237|     85|	}
  238|     85|	wpabuf_put_be16(buf, methods);
  239|       |
  240|       |	/* Primary Device Type */
  241|     85|	wpabuf_put_data(buf, p2p->cfg->pri_dev_type,
  242|     85|			sizeof(p2p->cfg->pri_dev_type));
  243|       |
  244|       |	/* Number of Secondary Device Types */
  245|     85|	wpabuf_put_u8(buf, p2p->cfg->num_sec_dev_types);
  246|       |
  247|       |	/* Secondary Device Type List */
  248|     85|	for (i = 0; i < p2p->cfg->num_sec_dev_types; i++)
  ------------------
  |  Branch (248:14): [True: 0, False: 85]
  ------------------
  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|     85|	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: 85]
  ------------------
  254|     85|	wpabuf_put_be16(buf, ATTR_DEV_NAME);
  255|     85|	wpabuf_put_be16(buf, nlen);
  256|     85|	wpabuf_put_data(buf, p2p->cfg->dev_name, nlen);
  257|       |
  258|       |	/* Update attribute length */
  259|     85|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  260|     85|	wpa_printf(MSG_DEBUG, "P2P: * Device Info");
  261|     85|}
p2p_buf_add_config_timeout:
  276|    916|{
  277|       |	/* Configuration Timeout */
  278|    916|	wpabuf_put_u8(buf, P2P_ATTR_CONFIGURATION_TIMEOUT);
  279|    916|	wpabuf_put_le16(buf, 2);
  280|    916|	wpabuf_put_u8(buf, go_timeout);
  281|    916|	wpabuf_put_u8(buf, client_timeout);
  282|    916|	wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout: GO %d (*10ms)  "
  283|    916|		   "client %d (*10ms)", go_timeout, client_timeout);
  284|    916|}
p2p_buf_add_intended_addr:
  288|     83|{
  289|       |	/* Intended P2P Interface Address */
  290|     83|	wpabuf_put_u8(buf, P2P_ATTR_INTENDED_INTERFACE_ADDR);
  291|     83|	wpabuf_put_le16(buf, ETH_ALEN);
  ------------------
  |  |  344|     83|#define ETH_ALEN 6
  ------------------
  292|     83|	wpabuf_put_data(buf, interface_addr, ETH_ALEN);
  ------------------
  |  |  344|     83|#define ETH_ALEN 6
  ------------------
  293|     83|	wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address " MACSTR,
  ------------------
  |  |  448|     83|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  294|     83|		   MAC2STR(interface_addr));
  ------------------
  |  |  447|     83|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  295|     83|}
p2p_buf_add_pcea:
  740|     51|{
  741|     51|	u8 *len;
  742|     51|	u16 capability_info = 0;
  743|       |
  744|       |	/* P2P Capability Extension */
  745|     51|	wpabuf_put_u8(buf, P2P_ATTR_CAPABILITY_EXTENSION);
  746|       |	/* Length to be filled */
  747|     51|	len = wpabuf_put(buf, 2);
  748|       |
  749|     51|	if (!p2p->cfg->p2p_6ghz_disable)
  ------------------
  |  Branch (749:6): [True: 51, False: 0]
  ------------------
  750|     51|		capability_info |= P2P_PCEA_6GHZ;
  ------------------
  |  | 1870|     51|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  751|       |
  752|     51|	if (p2p->cfg->reg_info)
  ------------------
  |  Branch (752:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->dfs_owner)
  ------------------
  |  Branch (755:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->chan_switch_req_enable)
  ------------------
  |  Branch (758:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->pairing_config.pairing_capable)
  ------------------
  |  Branch (761:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->pairing_config.enable_pairing_setup)
  ------------------
  |  Branch (764:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->pairing_config.enable_pairing_cache)
  ------------------
  |  Branch (767:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->pairing_config.pasn_type)
  ------------------
  |  Branch (770:6): [True: 0, False: 51]
  ------------------
  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|     51|	if (p2p->cfg->twt_power_mgmt)
  ------------------
  |  Branch (773:6): [True: 0, False: 51]
  ------------------
  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|     51|	capability_info |= (2 - 1) & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1869|     51|#define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  778|     51|	wpabuf_put_le16(buf, capability_info);
  779|       |
  780|     51|	if (capability_info & P2P_PCEA_REG_INFO)
  ------------------
  |  | 1871|     51|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (780:6): [True: 0, False: 51]
  ------------------
  781|      0|		wpabuf_put_u8(buf, p2p->cfg->reg_info);
  782|       |
  783|     51|	if (capability_info & P2P_PCEA_PASN_TYPE)
  ------------------
  |  | 1877|     51|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     51|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (783:6): [True: 0, False: 51]
  ------------------
  784|      0|		wpabuf_put_u8(buf, p2p->cfg->pairing_config.pasn_type);
  785|       |
  786|       |	/* Update attribute length */
  787|     51|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  788|       |
  789|     51|	wpa_printf(MSG_DEBUG, "P2P: * Capability Extension info=0x%x",
  790|     51|		   capability_info);
  791|     51|}
p2p_buf_add_pbma:
  796|     51|{
  797|     51|	u8 *len;
  798|       |
  799|       |	/* P2P Pairing and Bootstrapping methods */
  800|     51|	wpabuf_put_u8(buf, P2P_ATTR_PAIRING_AND_BOOTSTRAPPING);
  801|       |	/* Length to be filled */
  802|     51|	len = wpabuf_put(buf, 2);
  803|       |
  804|     51|	if (cookie && cookie_len) {
  ------------------
  |  Branch (804:6): [True: 41, False: 10]
  |  Branch (804:16): [True: 41, False: 0]
  ------------------
  805|     41|		if (comeback_after)
  ------------------
  |  Branch (805:7): [True: 41, False: 0]
  ------------------
  806|     41|			wpabuf_put_le16(buf, comeback_after);
  807|     41|		wpabuf_put_u8(buf, cookie_len);
  808|     41|		wpabuf_put_data(buf, cookie, cookie_len);
  809|     41|	}
  810|     51|	wpabuf_put_le16(buf, bootstrap);
  811|       |
  812|       |	/* Update attribute length */
  813|     51|	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
  814|       |
  815|     51|	wpa_printf(MSG_DEBUG, "P2P: * Bootstrapping method=0x%x",
  816|     51|		   bootstrap);
  817|     51|}
p2p_build_wps_ie:
  878|     43|{
  879|     43|	u8 *len;
  880|     43|	int i;
  881|       |
  882|     43|	if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (882:6): [True: 0, False: 43]
  ------------------
  883|      0|		return -1;
  884|     43|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|     43|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  885|     43|	len = wpabuf_put(buf, 1);
  886|     43|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|     43|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
  887|       |
  888|     43|	if (wps_build_version(buf) < 0)
  ------------------
  |  Branch (888:6): [True: 0, False: 43]
  ------------------
  889|      0|		return -1;
  890|       |
  891|     43|	if (all_attr) {
  ------------------
  |  Branch (891:6): [True: 2, False: 41]
  ------------------
  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|     43|	if (pw_id >= 0) {
  ------------------
  |  Branch (899:6): [True: 41, False: 2]
  ------------------
  900|     41|		if (wpabuf_tailroom(buf) < 6)
  ------------------
  |  Branch (900:7): [True: 0, False: 41]
  ------------------
  901|      0|			return -1;
  902|       |		/* Device Password ID */
  903|     41|		wpabuf_put_be16(buf, ATTR_DEV_PASSWORD_ID);
  904|     41|		wpabuf_put_be16(buf, 2);
  905|     41|		wpa_printf(MSG_DEBUG, "P2P: WPS IE Device Password ID: %d",
  906|     41|			   pw_id);
  907|     41|		wpabuf_put_be16(buf, pw_id);
  908|     41|	}
  909|       |
  910|     43|	if (all_attr) {
  ------------------
  |  Branch (910:6): [True: 2, False: 41]
  ------------------
  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|     43|	if (wps_build_wfa_ext(buf, 0, NULL, 0, 0) < 0)
  ------------------
  |  Branch (945:6): [True: 0, False: 43]
  ------------------
  946|      0|		return -1;
  947|       |
  948|     43|	if (all_attr && p2p->cfg->num_sec_dev_types) {
  ------------------
  |  Branch (948:6): [True: 2, False: 41]
  |  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|     43|	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  ------------------
  |  |  367|     43|#define P2P_MAX_WPS_VENDOR_EXT 10
  ------------------
  |  Branch (961:14): [True: 43, False: 0]
  ------------------
  962|     43|		if (p2p->wps_vendor_ext[i] == NULL)
  ------------------
  |  Branch (962:7): [True: 43, False: 0]
  ------------------
  963|     43|			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|     43|	p2p_buf_update_ie_hdr(buf, len);
  973|       |
  974|     43|	return 0;
  975|     43|}
p2p_encaps_ie:
  979|    916|{
  980|    916|	struct wpabuf *ie;
  981|    916|	const u8 *pos, *end;
  982|    916|	size_t len;
  983|       |
  984|    916|	if (!subelems)
  ------------------
  |  Branch (984:6): [True: 0, False: 916]
  ------------------
  985|      0|		return NULL;
  986|       |
  987|    916|	len = wpabuf_len(subelems) + 1000;
  988|       |
  989|    916|	ie = wpabuf_alloc(len);
  990|    916|	if (!ie)
  ------------------
  |  Branch (990:6): [True: 0, False: 916]
  ------------------
  991|      0|		return NULL;
  992|       |
  993|    916|	pos = wpabuf_head(subelems);
  994|    916|	end = pos + wpabuf_len(subelems);
  995|       |
  996|  1.83k|	while (end > pos) {
  ------------------
  |  Branch (996:9): [True: 916, False: 916]
  ------------------
  997|    916|		size_t frag_len = end - pos;
  998|       |
  999|    916|		if (frag_len > 251)
  ------------------
  |  Branch (999:7): [True: 0, False: 916]
  ------------------
 1000|      0|			frag_len = 251;
 1001|    916|		wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  493|    916|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
 1002|    916|		wpabuf_put_u8(ie, 4 + frag_len);
 1003|    916|		wpabuf_put_be32(ie, ie_type);
 1004|    916|		wpabuf_put_data(ie, pos, frag_len);
 1005|    916|		pos += frag_len;
 1006|    916|	}
 1007|       |
 1008|    916|	return ie;
 1009|    916|}
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|     23|{
  164|     23|	struct p2p_message msg;
  165|     23|	size_t g;
  166|       |
  167|     23|	p2p_dbg(p2p, "Received Device Discoverability Request from " MACSTR
  168|     23|		" (freq=%d)", MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     23|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  169|       |
  170|     23|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (170:6): [True: 3, False: 20]
  ------------------
  171|      3|		return;
  172|       |
  173|     20|	if (msg.dialog_token == 0) {
  ------------------
  |  Branch (173:6): [True: 4, False: 16]
  ------------------
  174|      4|		p2p_dbg(p2p, "Invalid Dialog Token 0 (must be nonzero) in Device Discoverability Request");
  175|      4|		p2p_send_dev_disc_resp(p2p, msg.dialog_token, sa, rx_freq,
  176|      4|				       P2P_SC_FAIL_INVALID_PARAMS);
  177|      4|		p2p_parse_free(&msg);
  178|      4|		return;
  179|      4|	}
  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|     20|{
  140|     20|	struct wpabuf *resp;
  141|       |
  142|     20|	resp = p2p_build_dev_disc_resp(dialog_token, status);
  143|     20|	if (resp == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 20]
  ------------------
  144|      0|		return;
  145|       |
  146|     20|	p2p_dbg(p2p, "Sending Device Discoverability Response to " MACSTR
  147|     20|		" (status %u freq %d)",
  148|     20|		MAC2STR(addr), status, freq);
  ------------------
  |  |  447|     20|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  149|       |
  150|     20|	p2p->pending_action_state = P2P_PENDING_DEV_DISC_RESPONSE;
  151|     20|	if (p2p_send_action(p2p, freq, addr, p2p->cfg->dev_addr,
  ------------------
  |  Branch (151:6): [True: 0, False: 20]
  ------------------
  152|     20|			    p2p->cfg->dev_addr,
  153|     20|			    wpabuf_head(resp), wpabuf_len(resp), 200) < 0) {
  154|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  155|      0|	}
  156|       |
  157|     20|	wpabuf_free(resp);
  158|     20|}
p2p_dev_disc.c:p2p_build_dev_disc_resp:
  111|     20|{
  112|     20|	struct wpabuf *buf;
  113|     20|	u8 *len;
  114|       |
  115|     20|	buf = wpabuf_alloc(100);
  116|     20|	if (buf == NULL)
  ------------------
  |  Branch (116:6): [True: 0, False: 20]
  ------------------
  117|      0|		return NULL;
  118|       |
  119|     20|	p2p_buf_add_public_action_hdr(buf, P2P_DEV_DISC_RESP, dialog_token);
  120|       |
  121|     20|	len = p2p_buf_add_ie_hdr(buf);
  122|     20|	p2p_buf_add_status(buf, status);
  123|     20|	p2p_buf_update_ie_hdr(buf, len);
  124|       |
  125|     20|	return buf;
  126|     20|}

p2p_peer_channels_check:
   39|    192|{
   40|    192|	const u8 *pos, *end;
   41|    192|	struct p2p_channels *ch;
   42|    192|	u8 channels;
   43|    192|	struct p2p_channels intersection;
   44|       |
   45|    192|	ch = &dev->channels;
   46|    192|	os_memset(ch, 0, sizeof(*ch));
  ------------------
  |  |  529|    192|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   47|    192|	pos = channel_list;
   48|    192|	end = channel_list + channel_list_len;
   49|       |
   50|    192|	if (end - pos < 3)
  ------------------
  |  Branch (50:6): [True: 1, False: 191]
  ------------------
   51|      1|		return -1;
   52|    191|	os_memcpy(dev->country, pos, 3);
  ------------------
  |  |  523|    191|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   53|    191|	wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer country", pos, 3);
   54|    191|	if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) {
  ------------------
  |  |  532|    171|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (54:6): [True: 171, False: 20]
  |  Branch (54:24): [True: 26, False: 145]
  ------------------
   55|     26|		p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)",
   56|     26|			p2p->cfg->country[0], p2p->cfg->country[1],
   57|     26|			pos[0], pos[1]);
   58|     26|		return -1;
   59|     26|	}
   60|    165|	pos += 3;
   61|       |
   62|    813|	while (end - pos > 2) {
  ------------------
  |  Branch (62:9): [True: 661, False: 152]
  ------------------
   63|    661|		struct p2p_reg_class *cl = &ch->reg_class[ch->reg_classes];
   64|    661|		cl->reg_class = *pos++;
   65|    661|		channels = *pos++;
   66|    661|		if (channels > end - pos) {
  ------------------
  |  Branch (66:7): [True: 7, False: 654]
  ------------------
   67|      7|			p2p_info(p2p, "Invalid peer Channel List");
   68|      7|			return -1;
   69|      7|		}
   70|    654|		cl->channels = channels > P2P_MAX_REG_CLASS_CHANNELS ?
  ------------------
  |  |   52|    654|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
  |  Branch (70:18): [True: 10, False: 644]
  ------------------
   71|    644|			P2P_MAX_REG_CLASS_CHANNELS : channels;
  ------------------
  |  |   52|     10|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
   72|    654|		os_memcpy(cl->channel, pos, cl->channels);
  ------------------
  |  |  523|    654|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
   73|    654|		pos += channels;
   74|    654|		ch->reg_classes++;
   75|    654|		if (ch->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|    654|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (75:7): [True: 6, False: 648]
  ------------------
   76|      6|			break;
   77|    654|	}
   78|       |
   79|    158|	p2p_channels_intersect(own, &dev->channels, &intersection);
   80|    158|	p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d",
   81|    158|		(int) own->reg_classes,
   82|    158|		(int) dev->channels.reg_classes,
   83|    158|		(int) intersection.reg_classes);
   84|    158|	if (intersection.reg_classes == 0) {
  ------------------
  |  Branch (84:6): [True: 24, False: 134]
  ------------------
   85|     24|		p2p_info(p2p, "No common channels found");
   86|     24|		return -1;
   87|     24|	}
   88|    134|	return 0;
   89|    158|}
p2p_wps_method_pw_id:
  101|     83|{
  102|     83|	switch (wps_method) {
  103|      0|	case WPS_PIN_DISPLAY:
  ------------------
  |  Branch (103:2): [True: 0, False: 83]
  ------------------
  104|      0|		return DEV_PW_REGISTRAR_SPECIFIED;
  105|      0|	case WPS_PIN_KEYPAD:
  ------------------
  |  Branch (105:2): [True: 0, False: 83]
  ------------------
  106|      0|		return DEV_PW_USER_SPECIFIED;
  107|      0|	case WPS_PBC:
  ------------------
  |  Branch (107:2): [True: 0, False: 83]
  ------------------
  108|      0|		return DEV_PW_PUSHBUTTON;
  109|      0|	case WPS_NFC:
  ------------------
  |  Branch (109:2): [True: 0, False: 83]
  ------------------
  110|      0|		return DEV_PW_NFC_CONNECTION_HANDOVER;
  111|      0|	case WPS_P2PS:
  ------------------
  |  Branch (111:2): [True: 0, False: 83]
  ------------------
  112|      0|		return DEV_PW_P2PS_DEFAULT;
  113|     83|	default:
  ------------------
  |  Branch (113:2): [True: 83, False: 0]
  ------------------
  114|     83|		return DEV_PW_DEFAULT;
  115|     83|	}
  116|     83|}
p2p_check_pref_chan:
  719|    134|{
  720|    134|	unsigned int size;
  721|    134|	unsigned int i;
  722|    134|	u8 op_class, op_channel;
  723|    134|	char txt[100], *pos, *end;
  724|    134|	bool is_6ghz_capab;
  725|    134|	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|    134|	if (!p2p->cfg->get_pref_freq_list || p2p->cfg->num_pref_chan ||
  ------------------
  |  Branch (732:6): [True: 134, 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|    134|		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: 25, False: 83]
  ------------------
  846|     25|		return NULL;
  847|       |
  848|     83|	if (!msg.capability) {
  ------------------
  |  Branch (848:6): [True: 81, False: 2]
  ------------------
  849|     81|		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|     81|	}
  854|       |
  855|     83|	if (msg.go_intent)
  ------------------
  |  Branch (855:6): [True: 2, False: 81]
  ------------------
  856|      2|		tie_breaker = *msg.go_intent & 0x01;
  857|     81|	else {
  858|     81|		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|     81|	}
  863|       |
  864|     83|	if (!msg.config_timeout) {
  ------------------
  |  Branch (864:6): [True: 82, False: 1]
  ------------------
  865|     82|		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|     82|	}
  870|       |
  871|     83|	if (!msg.listen_channel) {
  ------------------
  |  Branch (871:6): [True: 30, False: 53]
  ------------------
  872|     30|		p2p_dbg(p2p, "No Listen Channel attribute received");
  873|     30|		goto fail;
  874|     30|	}
  875|     53|	if (!msg.operating_channel) {
  ------------------
  |  Branch (875:6): [True: 3, False: 50]
  ------------------
  876|      3|		p2p_dbg(p2p, "No Operating Channel attribute received");
  877|      3|		goto fail;
  878|      3|	}
  879|     50|	if (!msg.channel_list) {
  ------------------
  |  Branch (879:6): [True: 1, False: 49]
  ------------------
  880|      1|		p2p_dbg(p2p, "No Channel List attribute received");
  881|      1|		goto fail;
  882|      1|	}
  883|     49|	if (!msg.intended_addr) {
  ------------------
  |  Branch (883:6): [True: 1, False: 48]
  ------------------
  884|      1|		p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
  885|      1|		goto fail;
  886|      1|	}
  887|     48|	if (!msg.p2p_device_info) {
  ------------------
  |  Branch (887:6): [True: 1, False: 47]
  ------------------
  888|      1|		p2p_dbg(p2p, "No P2P Device Info attribute received");
  889|      1|		goto fail;
  890|      1|	}
  891|       |
  892|     47|	if (!ether_addr_equal(msg.p2p_device_addr, sa)) {
  ------------------
  |  Branch (892:6): [True: 2, False: 45]
  ------------------
  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|     45|	dev = p2p_get_device(p2p, sa);
  900|       |
  901|     45|	if (msg.status && *msg.status) {
  ------------------
  |  Branch (901:6): [True: 13, False: 32]
  |  Branch (901:20): [True: 8, False: 5]
  ------------------
  902|      8|		p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
  903|      8|			*msg.status);
  904|      8|		if (dev && p2p->go_neg_peer == dev &&
  ------------------
  |  Branch (904:7): [True: 4, False: 4]
  |  Branch (904:14): [True: 0, False: 4]
  ------------------
  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|      8|		goto fail;
  924|      8|	}
  925|       |
  926|     37|	if (dev == NULL)
  ------------------
  |  Branch (926:6): [True: 18, False: 19]
  ------------------
  927|     18|		dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg);
  928|     19|	else if ((dev->flags & P2P_DEV_PROBE_REQ_ONLY) ||
  ------------------
  |  |  127|     19|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     19|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (928:11): [True: 1, False: 18]
  ------------------
  929|     18|		  !(dev->flags & P2P_DEV_REPORTED))
  ------------------
  |  |  128|     18|#define P2P_DEV_REPORTED BIT(1)
  |  |  ------------------
  |  |  |  |  458|     18|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (929:5): [True: 6, False: 12]
  ------------------
  930|      7|		p2p_add_dev_info(p2p, sa, dev, &msg);
  931|     12|	else if (!dev->listen_freq && !dev->oper_freq) {
  ------------------
  |  Branch (931:11): [True: 5, False: 7]
  |  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|     37|	if (dev)
  ------------------
  |  Branch (943:6): [True: 37, False: 0]
  ------------------
  944|     37|		p2p_update_peer_6ghz_capab(dev, &msg);
  945|       |
  946|     37|	if (p2p->go_neg_peer && p2p->go_neg_peer == dev)
  ------------------
  |  Branch (946:6): [True: 0, False: 37]
  |  Branch (946:26): [True: 0, False: 0]
  ------------------
  947|      0|		eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
  948|       |
  949|     37|	if (dev && dev->flags & P2P_DEV_USER_REJECTED) {
  ------------------
  |  |  132|     37|#define P2P_DEV_USER_REJECTED BIT(7)
  |  |  ------------------
  |  |  |  |  458|     37|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (949:6): [True: 37, False: 0]
  |  Branch (949:13): [True: 0, False: 37]
  ------------------
  950|      0|		p2p_dbg(p2p, "User has rejected this peer");
  951|      0|		status = P2P_SC_FAIL_REJECTED_BY_USER;
  952|     37|	} else if (dev == NULL ||
  ------------------
  |  Branch (952:13): [True: 0, False: 37]
  ------------------
  953|     37|		   (dev->wps_method == WPS_NOT_READY && !p2p2 &&
  ------------------
  |  Branch (953:7): [True: 37, False: 0]
  |  Branch (953:43): [True: 37, False: 0]
  ------------------
  954|     37|		    (p2p->authorized_oob_dev_pw_id == 0 ||
  ------------------
  |  Branch (954:8): [True: 37, False: 0]
  ------------------
  955|      0|		     p2p->authorized_oob_dev_pw_id !=
  ------------------
  |  Branch (955:8): [True: 0, False: 0]
  ------------------
  956|     37|		     msg.dev_password_id))) {
  957|     37|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|     37|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  958|     37|			MAC2STR(sa));
  ------------------
  |  |  447|     37|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  959|     37|		status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  960|     37|		p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
  961|     37|					msg.dev_password_id,
  962|     37|					msg.go_intent ? (*msg.go_intent >> 1) :
  ------------------
  |  Branch (962:6): [True: 1, False: 36]
  ------------------
  963|     37|					0);
  964|     37|	} 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|     83|fail:
 1128|     83|	if (dev)
  ------------------
  |  Branch (1128:6): [True: 41, False: 42]
  ------------------
 1129|     41|		dev->status = status;
 1130|     83|	resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status,
 1131|     83|				     !tie_breaker);
 1132|     83|	p2p_parse_free(&msg);
 1133|     83|	if (resp == NULL)
  ------------------
  |  Branch (1133:6): [True: 0, False: 83]
  ------------------
 1134|      0|		return NULL;
 1135|       |
 1136|     83|	if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1136:6): [True: 0, False: 83]
  ------------------
 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|     83|		p2p->pending_action_state =
 1152|     83|			P2P_PENDING_GO_NEG_RESPONSE_FAILURE;
 1153|     83|	return resp;
 1154|     83|}
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: 25, False: 83]
  ------------------
 1165|     25|		return;
 1166|       |
 1167|     83|	p2p_dbg(p2p, "Sending GO Negotiation Response");
 1168|       |
 1169|     83|	if (rx_freq > 0)
  ------------------
  |  Branch (1169:6): [True: 83, False: 0]
  ------------------
 1170|     83|		freq = rx_freq;
 1171|      0|	else
 1172|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
 1173|      0|					   p2p->cfg->channel);
 1174|     83|	if (freq < 0) {
  ------------------
  |  Branch (1174:6): [True: 0, False: 83]
  ------------------
 1175|      0|		p2p_dbg(p2p, "Unknown regulatory class/channel");
 1176|      0|		wpabuf_free(resp);
 1177|      0|		return;
 1178|      0|	}
 1179|       |
 1180|     83|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (1180:6): [True: 0, False: 83]
  ------------------
 1181|     83|			    p2p->cfg->dev_addr,
 1182|     83|			    wpabuf_head(resp), wpabuf_len(resp), 100) < 0) {
 1183|      0|		p2p_dbg(p2p, "Failed to send Action frame");
 1184|      0|	}
 1185|       |
 1186|     83|	wpabuf_free(resp);
 1187|     83|}
p2p_process_go_neg_resp:
 1276|      3|{
 1277|      3|	struct p2p_device *dev;
 1278|      3|	int go = -1;
 1279|      3|	struct p2p_message msg;
 1280|      3|	u8 status = P2P_SC_SUCCESS;
 1281|      3|	int freq;
 1282|      3|	struct wpabuf *conf = NULL;
 1283|       |
 1284|      3|	p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
 1285|      3|		" (freq=%d)", MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1286|      3|	dev = p2p_get_device(p2p, sa);
 1287|      3|	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
  ------------------
  |  Branch (1287:6): [True: 2, False: 1]
  |  Branch (1287:22): [True: 1, False: 0]
  |  Branch (1287:31): [True: 1, False: 0]
  ------------------
 1288|      3|	    dev != p2p->go_neg_peer) {
  ------------------
  |  Branch (1288:6): [True: 0, False: 0]
  ------------------
 1289|      3|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|      3|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1290|      3|			MAC2STR(sa));
  ------------------
  |  |  447|      3|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1291|      3|		return NULL;
 1292|      3|	}
 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|      3|{
 1551|      3|	int freq;
 1552|      3|	struct p2p_device *dev;
 1553|      3|	struct wpabuf *conf;
 1554|       |
 1555|      3|	conf = p2p_process_go_neg_resp(p2p, sa, data, len, rx_freq, false);
 1556|      3|	if (!conf)
  ------------------
  |  Branch (1556:6): [True: 3, False: 0]
  ------------------
 1557|      3|		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|      2|{
 1588|      2|	struct p2p_device *dev;
 1589|      2|	struct p2p_message msg;
 1590|       |
 1591|      2|	p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1592|      2|		MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1593|      2|	dev = p2p_get_device(p2p, sa);
 1594|      2|	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
  ------------------
  |  Branch (1594:6): [True: 1, False: 1]
  |  Branch (1594:22): [True: 1, False: 0]
  |  Branch (1594:31): [True: 1, False: 0]
  ------------------
 1595|      2|	    dev != p2p->go_neg_peer) {
  ------------------
  |  Branch (1595:6): [True: 0, False: 0]
  ------------------
 1596|      2|		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
 1597|      2|			MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1598|      2|		return;
 1599|      2|	}
 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|     83|{
  307|     83|	struct wpabuf *buf;
  308|     83|	struct wpabuf *subelems;
  309|     83|	u8 group_capab;
  310|     83|	size_t extra = 0;
  311|     83|	u16 pw_id;
  312|     83|	bool is_6ghz_capab;
  313|     83|	struct p2p_channels pref_chanlist;
  314|       |
  315|     83|	p2p_dbg(p2p, "Building GO Negotiation Response");
  316|       |
  317|     83|#ifdef CONFIG_WIFI_DISPLAY
  318|     83|	if (p2p->wfd_ie_go_neg)
  ------------------
  |  Branch (318:6): [True: 0, False: 83]
  ------------------
  319|      0|		extra = wpabuf_len(p2p->wfd_ie_go_neg);
  320|     83|#endif /* CONFIG_WIFI_DISPLAY */
  321|       |
  322|     83|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
  ------------------
  |  Branch (322:6): [True: 0, False: 83]
  |  Branch (322:26): [True: 0, False: 0]
  ------------------
  323|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
  324|       |
  325|     83|	buf = wpabuf_alloc(1000 + extra);
  326|     83|	if (buf == NULL)
  ------------------
  |  Branch (326:6): [True: 0, False: 83]
  ------------------
  327|      0|		return NULL;
  328|       |
  329|     83|	p2p_buf_add_public_action_hdr(buf, P2P_GO_NEG_RESP, dialog_token);
  330|       |
  331|     83|	subelems = wpabuf_alloc(500);
  332|     83|	if (!subelems) {
  ------------------
  |  Branch (332:6): [True: 0, False: 83]
  ------------------
  333|      0|		wpabuf_free(buf);
  334|      0|		return NULL;
  335|      0|	}
  336|       |
  337|     83|	p2p_buf_add_status(subelems, status);
  338|     83|	group_capab = 0;
  339|     83|	if (peer && peer->go_state == LOCAL_GO) {
  ------------------
  |  Branch (339:6): [True: 41, False: 42]
  |  Branch (339:14): [True: 0, False: 41]
  ------------------
  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|     83|	p2p_buf_add_capability(subelems, p2p->dev_capab &
  352|     83|			       ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY,
  ------------------
  |  | 1851|     83|#define P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY BIT(1)
  |  |  ------------------
  |  |  |  |  458|     83|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  353|     83|			       group_capab);
  354|     83|	p2p_buf_add_go_intent(subelems, (p2p->go_intent << 1) | tie_breaker);
  355|     83|	p2p_buf_add_config_timeout(subelems, p2p->go_timeout,
  356|     83|				   p2p->client_timeout);
  357|     83|	if (p2p->override_pref_op_class) {
  ------------------
  |  Branch (357:6): [True: 0, False: 83]
  ------------------
  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|     83|	} else if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
  ------------------
  |  Branch (362:13): [True: 41, False: 42]
  |  Branch (362:21): [True: 0, False: 41]
  |  Branch (362:52): [True: 0, False: 0]
  ------------------
  363|      0|		p2p_dbg(p2p, "Omit Operating Channel attribute");
  364|     83|	} else {
  365|     83|		p2p_buf_add_operating_channel(subelems, p2p->cfg->country,
  366|     83|					      p2p->op_reg_class,
  367|     83|					      p2p->op_channel);
  368|     83|	}
  369|     83|	p2p_buf_add_intended_addr(subelems, p2p->intended_addr);
  370|       |
  371|     83|	if (p2p->num_pref_freq) {
  ------------------
  |  Branch (371:6): [True: 0, False: 83]
  ------------------
  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|     83|	} else {
  380|     83|		p2p_copy_channels(&pref_chanlist, &p2p->channels,
  381|     83|				  p2p->allow_6ghz);
  382|     83|	}
  383|     83|	if (status || peer == NULL) {
  ------------------
  |  Branch (383:6): [True: 83, False: 0]
  |  Branch (383:16): [True: 0, False: 0]
  ------------------
  384|     83|		p2p_buf_add_channel_list(subelems, p2p->cfg->country,
  385|     83|					 &pref_chanlist, false);
  386|     83|	} 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|     83|	p2p_buf_add_device_info(subelems, p2p, peer);
  402|     83|	if (peer && peer->go_state == LOCAL_GO) {
  ------------------
  |  Branch (402:6): [True: 41, False: 42]
  |  Branch (402:14): [True: 0, False: 41]
  ------------------
  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|     83|	pw_id = p2p_wps_method_pw_id(peer ? peer->wps_method : WPS_NOT_READY);
  ------------------
  |  Branch (408:31): [True: 41, False: 42]
  ------------------
  409|     83|	if (peer && peer->oob_pw_id)
  ------------------
  |  Branch (409:6): [True: 41, False: 42]
  |  Branch (409:14): [True: 0, False: 41]
  ------------------
  410|      0|		pw_id = peer->oob_pw_id;
  411|     83|	if (peer && !peer->p2p2 && p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
  ------------------
  |  Branch (411:6): [True: 41, False: 42]
  |  Branch (411:14): [True: 41, False: 0]
  |  Branch (411:29): [True: 0, False: 41]
  ------------------
  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|     83|#ifdef CONFIG_WIFI_DISPLAY
  419|     83|	if (p2p->wfd_ie_go_neg)
  ------------------
  |  Branch (419:6): [True: 0, False: 83]
  ------------------
  420|      0|		wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
  421|     83|#endif /* CONFIG_WIFI_DISPLAY */
  422|       |
  423|     83|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
  ------------------
  |  Branch (423:6): [True: 0, False: 83]
  |  Branch (423:26): [True: 0, False: 0]
  ------------------
  424|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
  425|       |
  426|     83|	buf = wpabuf_concat(buf, p2p_encaps_ie(subelems, P2P_IE_VENDOR_TYPE));
  ------------------
  |  | 1515|     83|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  427|     83|	wpabuf_free(subelems);
  428|     83|	return buf;
  429|     83|}

p2p_process_invitation_req:
  230|    972|{
  231|    972|	struct p2p_device *dev;
  232|    972|	struct p2p_message msg;
  233|    972|	struct wpabuf *resp = NULL;
  234|    972|	u8 status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  235|    972|	int go = 0;
  236|    972|	u8 group_bssid[ETH_ALEN], *bssid;
  237|    972|	int op_freq = 0;
  238|    972|	u8 reg_class = 0, channel = 0;
  239|    972|	const u8 *new_ssid = NULL;
  240|    972|	size_t new_ssid_len = 0;
  241|    972|	struct p2p_channels all_channels, intersection, *channels = NULL;
  242|    972|	int persistent;
  243|       |
  244|    972|	os_memset(group_bssid, 0, sizeof(group_bssid));
  ------------------
  |  |  529|    972|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  245|       |
  246|    972|	p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
  247|    972|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|    972|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  248|       |
  249|    972|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (249:6): [True: 139, False: 833]
  ------------------
  250|    139|		return NULL;
  251|       |
  252|    833|	dev = p2p_get_device(p2p, sa);
  253|    833|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|    202|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    202|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (253:6): [True: 631, False: 202]
  |  Branch (253:21): [True: 7, False: 195]
  ------------------
  254|    638|		p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
  ------------------
  |  |  448|    638|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  255|    638|			MAC2STR(sa));
  ------------------
  |  |  447|    638|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  256|       |
  257|    638|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
  ------------------
  |  Branch (257:7): [True: 446, False: 192]
  ------------------
  258|    638|				   0)) {
  259|    446|			p2p_dbg(p2p, "Invitation Request add device failed "
  260|    446|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    446|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    446|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  261|    446|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  262|    446|			goto fail;
  263|    446|		}
  264|       |
  265|    192|		dev = p2p_get_device(p2p, sa);
  266|    192|		if (dev == NULL) {
  ------------------
  |  Branch (266:7): [True: 184, False: 8]
  ------------------
  267|    184|			p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
  268|    184|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    184|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    184|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  269|    184|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  270|    184|			goto fail;
  271|    184|		}
  272|    192|	}
  273|       |
  274|    203|	if (!msg.group_id || !msg.channel_list) {
  ------------------
  |  Branch (274:6): [True: 8, False: 195]
  |  Branch (274:23): [True: 3, False: 192]
  ------------------
  275|     11|		p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
  276|     11|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|     11|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|     11|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  277|     11|		status = P2P_SC_FAIL_INVALID_PARAMS;
  278|     11|		goto fail;
  279|     11|	}
  280|       |
  281|    192|	if (msg.invitation_flags)
  ------------------
  |  Branch (281:6): [True: 1, False: 191]
  ------------------
  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|    191|	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|    191|		p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
  290|    191|		persistent = 1;
  291|    191|	}
  292|       |
  293|    192|	p2p_channels_union(&p2p->cfg->channels, &p2p->cfg->cli_channels,
  294|    192|			   &all_channels);
  295|       |
  296|    192|	if (p2p_peer_channels_check(p2p, &all_channels, dev,
  ------------------
  |  Branch (296:6): [True: 58, False: 134]
  ------------------
  297|    192|				    msg.channel_list, msg.channel_list_len) <
  298|    192|	    0) {
  299|     58|		p2p_dbg(p2p, "No common channels found");
  300|     58|		status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  301|     58|		goto fail;
  302|     58|	}
  303|       |
  304|    134|	p2p_channels_dump(p2p, "own channels", &p2p->cfg->channels);
  305|    134|	p2p_channels_dump(p2p, "own client channels", &all_channels);
  306|    134|	p2p_channels_dump(p2p, "peer channels", &dev->channels);
  307|    134|	p2p_channels_intersect(&all_channels, &dev->channels,
  308|    134|			       &intersection);
  309|    134|	p2p_channels_dump(p2p, "intersection", &intersection);
  310|       |
  311|    134|	if (p2p->cfg->invitation_process) {
  ------------------
  |  Branch (311:6): [True: 0, False: 134]
  ------------------
  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|    134|	if (go) {
  ------------------
  |  Branch (320:6): [True: 0, False: 134]
  ------------------
  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|    134|	if (op_freq) {
  ------------------
  |  Branch (331:6): [True: 0, False: 134]
  ------------------
  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|    134|	} else {
  352|    134|		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|    134|		p2p->op_reg_class = p2p->cfg->op_reg_class;
  356|    134|		p2p->op_channel = p2p->cfg->op_channel;
  357|    134|		p2p_dbg(p2p, "Own default op_class %d channel %d",
  358|    134|			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|    134|		if (msg.operating_channel) {
  ------------------
  |  Branch (372:7): [True: 89, False: 45]
  ------------------
  373|     89|			int req_freq;
  374|     89|			req_freq = p2p_channel_to_freq(
  375|     89|				msg.operating_channel[3],
  376|     89|				msg.operating_channel[4]);
  377|     89|			p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
  378|     89|				req_freq);
  379|     89|			if (req_freq > 0 &&
  ------------------
  |  Branch (379:8): [True: 50, False: 39]
  ------------------
  380|     50|			    p2p_channels_includes(&intersection,
  ------------------
  |  Branch (380:8): [True: 5, False: 45]
  ------------------
  381|     50|						  msg.operating_channel[3],
  382|     50|						  msg.operating_channel[4])) {
  383|      5|				p2p->op_reg_class = msg.operating_channel[3];
  384|      5|				p2p->op_channel = msg.operating_channel[4];
  385|      5|				p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
  386|      5|					p2p->op_reg_class, p2p->op_channel);
  387|     84|			} else {
  388|     84|				p2p_dbg(p2p, "Cannot use peer channel preference");
  389|     84|			}
  390|     89|		}
  391|       |
  392|       |		/* Reselect the channel only for the case of the GO */
  393|    134|		if (go &&
  ------------------
  |  Branch (393:7): [True: 0, False: 134]
  ------------------
  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|    134|		} 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: 134]
  |  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|    134|		p2p_check_pref_chan(p2p, go, dev, &msg);
  421|       |
  422|    134|		op_freq = p2p_channel_to_freq(p2p->op_reg_class,
  423|    134|					      p2p->op_channel);
  424|    134|		if (op_freq < 0) {
  ------------------
  |  Branch (424:7): [True: 129, False: 5]
  ------------------
  425|    129|			p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
  426|    129|				p2p->cfg->country[0], p2p->cfg->country[1],
  427|    129|				p2p->op_reg_class, p2p->op_channel);
  428|    129|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  429|    129|			goto fail;
  430|    129|		}
  431|      5|		p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
  432|       |
  433|      5|		if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (433:7): [True: 0, False: 5]
  ------------------
  434|      0|			reg_class = p2p->op_reg_class;
  435|      0|			channel = p2p->op_channel;
  436|      0|			channels = &intersection;
  437|      0|		}
  438|      5|	}
  439|       |
  440|    833|fail:
  441|    833|	if (go && status == P2P_SC_SUCCESS && !is_zero_ether_addr(group_bssid))
  ------------------
  |  Branch (441:6): [True: 0, False: 833]
  |  Branch (441:12): [True: 0, False: 0]
  |  Branch (441:40): [True: 0, False: 0]
  ------------------
  442|      0|		bssid = group_bssid;
  443|    833|	else
  444|    833|		bssid = NULL;
  445|    833|	resp = p2p_build_invitation_resp(p2p, dev, msg.dialog_token, status,
  446|    833|					 bssid, reg_class, channel, channels,
  447|    833|					 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|    833|	os_memcpy(p2p->inv_sa, sa, ETH_ALEN);
  ------------------
  |  |  523|    833|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  454|    833|	if (msg.group_bssid) {
  ------------------
  |  Branch (454:6): [True: 4, False: 829]
  ------------------
  455|      4|		os_memcpy(p2p->inv_group_bssid, msg.group_bssid, ETH_ALEN);
  ------------------
  |  |  523|      4|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  456|      4|		p2p->inv_group_bssid_ptr = p2p->inv_group_bssid;
  457|      4|	} else
  458|    829|		p2p->inv_group_bssid_ptr = NULL;
  459|       |
  460|    833|	if (p2p2 && new_ssid_len) {
  ------------------
  |  Branch (460:6): [True: 0, False: 833]
  |  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|    833|	} else if (msg.group_id) {
  ------------------
  |  Branch (464:13): [True: 221, False: 612]
  ------------------
  465|    221|		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  344|    221|#define ETH_ALEN 6
  ------------------
              		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  511|    221|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (465:7): [True: 221, False: 0]
  ------------------
  466|    221|			os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN,
  ------------------
  |  |  523|    221|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  467|    221|				  msg.group_id_len - ETH_ALEN);
  468|    221|			p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|    221|#define ETH_ALEN 6
  ------------------
  469|    221|		}
  470|    221|		os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN);
  ------------------
  |  |  523|    221|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  471|    612|	} else {
  472|    612|		p2p->inv_ssid_len = 0;
  473|    612|		os_memset(p2p->inv_go_dev_addr, 0, ETH_ALEN);
  ------------------
  |  |  529|    612|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  474|    612|	}
  475|    833|	p2p->inv_status = status;
  476|    833|	p2p->inv_op_freq = op_freq;
  477|    833|	p2p_parse_free(&msg);
  478|    833|	return resp;
  479|    134|}
p2p_handle_invitation_req:
  484|    972|{
  485|    972|	int freq;
  486|    972|	struct wpabuf *resp;
  487|       |
  488|    972|	resp = p2p_process_invitation_req(p2p, sa, data, len, rx_freq, false);
  489|    972|	if (!resp)
  ------------------
  |  Branch (489:6): [True: 139, False: 833]
  ------------------
  490|    139|		return;
  491|       |
  492|    833|	if (rx_freq > 0)
  ------------------
  |  Branch (492:6): [True: 833, False: 0]
  ------------------
  493|    833|		freq = rx_freq;
  494|      0|	else
  495|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  496|      0|					   p2p->cfg->channel);
  497|    833|	if (freq < 0)
  ------------------
  |  Branch (497:6): [True: 0, False: 833]
  ------------------
  498|      0|		p2p_dbg(p2p, "Unknown regulatory class/channel");
  499|       |
  500|    833|	p2p->pending_action_state = P2P_PENDING_INVITATION_RESPONSE;
  501|    833|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (501:6): [True: 0, False: 833]
  ------------------
  502|    833|			    p2p->cfg->dev_addr,
  503|    833|			    wpabuf_head(resp), wpabuf_len(resp), 50) < 0) {
  504|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  505|      0|	}
  506|       |
  507|    833|	wpabuf_free(resp);
  508|    833|}
p2p_process_invitation_resp:
  513|      4|{
  514|      4|	struct p2p_device *dev;
  515|      4|	struct p2p_message msg;
  516|      4|	struct p2p_channels intersection, *channels = NULL;
  517|      4|	bool all_channels = false;
  518|      4|	const u8 *go_dev_addr = NULL;
  519|       |
  520|      4|	p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
  ------------------
  |  |  448|      4|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  521|      4|		MAC2STR(sa));
  ------------------
  |  |  447|      4|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  522|       |
  523|      4|	dev = p2p_get_device(p2p, sa);
  524|      4|	if (dev == NULL) {
  ------------------
  |  Branch (524:6): [True: 3, False: 1]
  ------------------
  525|      3|		p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
  526|      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]
  ------------------
  527|      3|		p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  528|      3|		return;
  529|      3|	}
  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|    833|{
  137|    833|	struct wpabuf *buf, *elems, *p2p_ie;
  138|    833|	size_t extra = 0;
  139|       |
  140|    833|#ifdef CONFIG_WIFI_DISPLAY
  141|    833|	struct wpabuf *wfd_ie = p2p->wfd_ie_invitation;
  142|    833|	if (wfd_ie && group_bssid) {
  ------------------
  |  Branch (142:6): [True: 0, False: 833]
  |  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|    833|	if (wfd_ie)
  ------------------
  |  Branch (157:6): [True: 0, False: 833]
  ------------------
  158|      0|		extra = wpabuf_len(wfd_ie);
  159|    833|#endif /* CONFIG_WIFI_DISPLAY */
  160|       |
  161|    833|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (161:6): [True: 0, False: 833]
  |  Branch (161:26): [True: 0, False: 0]
  ------------------
  162|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  163|       |
  164|    833|	buf = wpabuf_alloc(1000 + extra);
  165|    833|	if (buf == NULL)
  ------------------
  |  Branch (165:6): [True: 0, False: 833]
  ------------------
  166|      0|		return NULL;
  167|       |
  168|    833|	p2p_buf_add_public_action_hdr(buf, P2P_INVITATION_RESP,
  169|    833|				      dialog_token);
  170|       |
  171|    833|	elems = wpabuf_alloc(1000);
  172|    833|	if (!elems) {
  ------------------
  |  Branch (172:6): [True: 0, False: 833]
  ------------------
  173|      0|		wpabuf_free(buf);
  174|      0|		return NULL;
  175|      0|	}
  176|       |
  177|    833|	p2p_buf_add_status(elems, status);
  178|    833|	p2p_buf_add_config_timeout(elems, 0, 0); /* FIX */
  179|    833|	if (reg_class && channel)
  ------------------
  |  Branch (179:6): [True: 0, False: 833]
  |  Branch (179:19): [True: 0, False: 0]
  ------------------
  180|      0|		p2p_buf_add_operating_channel(elems, p2p->cfg->country,
  181|      0|					      reg_class, channel);
  182|    833|	if (group_bssid)
  ------------------
  |  Branch (182:6): [True: 0, False: 833]
  ------------------
  183|      0|		p2p_buf_add_group_bssid(elems, group_bssid);
  184|       |
  185|    833|	if (ssid_len && ssid) {
  ------------------
  |  Branch (185:6): [True: 0, False: 833]
  |  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|    833|	if (channels) {
  ------------------
  |  Branch (196:6): [True: 0, False: 833]
  ------------------
  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|    833|	p2p_ie = p2p_encaps_ie(elems, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1515|    833|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  206|    833|	wpabuf_free(elems);
  207|    833|	if (!p2p_ie) {
  ------------------
  |  Branch (207:6): [True: 0, False: 833]
  ------------------
  208|      0|		wpabuf_free(buf);
  209|      0|		return NULL;
  210|      0|	}
  211|       |
  212|    833|	wpabuf_put_buf(buf, p2p_ie);
  213|    833|	wpabuf_free(p2p_ie);
  214|       |
  215|    833|#ifdef CONFIG_WIFI_DISPLAY
  216|    833|	if (wfd_ie)
  ------------------
  |  Branch (216:6): [True: 0, False: 833]
  ------------------
  217|      0|		wpabuf_put_buf(buf, wfd_ie);
  218|    833|#endif /* CONFIG_WIFI_DISPLAY */
  219|       |
  220|    833|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (220:6): [True: 0, False: 833]
  |  Branch (220:26): [True: 0, False: 0]
  ------------------
  221|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  222|       |
  223|    833|	return buf;
  224|    833|}

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

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

printf_encode:
  478|  6.24k|{
  479|  6.24k|	char *end = txt + maxlen;
  480|  6.24k|	size_t i;
  481|       |
  482|   143k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (482:14): [True: 137k, False: 6.24k]
  ------------------
  483|   137k|		if (txt + 4 >= end)
  ------------------
  |  Branch (483:7): [True: 0, False: 137k]
  ------------------
  484|      0|			break;
  485|       |
  486|   137k|		switch (data[i]) {
  487|  6.62k|		case '\"':
  ------------------
  |  Branch (487:3): [True: 6.62k, False: 130k]
  ------------------
  488|  6.62k|			*txt++ = '\\';
  489|  6.62k|			*txt++ = '\"';
  490|  6.62k|			break;
  491|    470|		case '\\':
  ------------------
  |  Branch (491:3): [True: 470, False: 137k]
  ------------------
  492|    470|			*txt++ = '\\';
  493|    470|			*txt++ = '\\';
  494|    470|			break;
  495|    225|		case '\033':
  ------------------
  |  Branch (495:3): [True: 225, False: 137k]
  ------------------
  496|    225|			*txt++ = '\\';
  497|    225|			*txt++ = 'e';
  498|    225|			break;
  499|    441|		case '\n':
  ------------------
  |  Branch (499:3): [True: 441, False: 137k]
  ------------------
  500|    441|			*txt++ = '\\';
  501|    441|			*txt++ = 'n';
  502|    441|			break;
  503|    406|		case '\r':
  ------------------
  |  Branch (503:3): [True: 406, False: 137k]
  ------------------
  504|    406|			*txt++ = '\\';
  505|    406|			*txt++ = 'r';
  506|    406|			break;
  507|  10.0k|		case '\t':
  ------------------
  |  Branch (507:3): [True: 10.0k, False: 127k]
  ------------------
  508|  10.0k|			*txt++ = '\\';
  509|  10.0k|			*txt++ = 't';
  510|  10.0k|			break;
  511|   119k|		default:
  ------------------
  |  Branch (511:3): [True: 119k, False: 18.1k]
  ------------------
  512|   119k|			if (data[i] >= 32 && data[i] <= 126) {
  ------------------
  |  Branch (512:8): [True: 35.3k, False: 83.9k]
  |  Branch (512:25): [True: 15.1k, False: 20.1k]
  ------------------
  513|  15.1k|				*txt++ = data[i];
  514|   104k|			} else {
  515|   104k|				txt += os_snprintf(txt, end - txt, "\\x%02x",
  ------------------
  |  |  572|   104k|#define os_snprintf snprintf
  ------------------
  516|   104k|						   data[i]);
  517|   104k|			}
  518|   119k|			break;
  519|   137k|		}
  520|   137k|	}
  521|       |
  522|  6.24k|	*txt = '\0';
  523|  6.24k|}
wpa_ssid_txt:
  623|  6.24k|{
  624|  6.24k|	static char ssid_txt[SSID_MAX_LEN * 4 + 1];
  625|       |
  626|  6.24k|	if (ssid == NULL) {
  ------------------
  |  Branch (626:6): [True: 0, False: 6.24k]
  ------------------
  627|      0|		ssid_txt[0] = '\0';
  628|      0|		return ssid_txt;
  629|      0|	}
  630|       |
  631|  6.24k|	printf_encode(ssid_txt, sizeof(ssid_txt), ssid, ssid_len);
  632|  6.24k|	return ssid_txt;
  633|  6.24k|}
has_ctrl_char:
  712|  25.3k|{
  713|  25.3k|	size_t i;
  714|       |
  715|  63.6k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (715:14): [True: 45.3k, False: 18.3k]
  ------------------
  716|  45.3k|		if (data[i] < 32 || data[i] == 127)
  ------------------
  |  Branch (716:7): [True: 6.85k, False: 38.4k]
  |  Branch (716:23): [True: 191, False: 38.2k]
  ------------------
  717|  7.04k|			return 1;
  718|  45.3k|	}
  719|  18.3k|	return 0;
  720|  25.3k|}
is_ctrl_char:
 1226|  14.8k|{
 1227|  14.8k|	return c > 0 && c < 32;
  ------------------
  |  Branch (1227:9): [True: 9.85k, False: 4.94k]
  |  Branch (1227:18): [True: 3.47k, False: 6.38k]
  ------------------
 1228|  14.8k|}

p2p.c:WPA_GET_LE16:
  225|     18|{
  226|     18|	return (a[1] << 8) | a[0];
  227|     18|}
p2p.c:WPA_GET_BE32:
  260|  40.6k|{
  261|  40.6k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  40.6k|}
p2p.c:is_zero_ether_addr:
  562|  1.91k|{
  563|  1.91k|	return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
  564|  1.91k|}
p2p.c:is_broadcast_ether_addr:
  567|  2.54k|{
  568|  2.54k|	return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
  569|  2.54k|}
p2p.c:ether_addr_equal:
  577|  8.31k|{
  578|  8.31k|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|  8.31k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|  8.31k|}
p2p_go_neg.c:ether_addr_equal:
  577|     47|{
  578|     47|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|     47|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|     47|}
p2p_parse.c:WPA_GET_LE16:
  225|  67.7k|{
  226|  67.7k|	return (a[1] << 8) | a[0];
  227|  67.7k|}
p2p_parse.c:WPA_GET_LE32:
  273|  1.25k|{
  274|  1.25k|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|  1.25k|}
p2p_parse.c:WPA_GET_BE16:
  214|  6.67k|{
  215|  6.67k|	return (a[0] << 8) | a[1];
  216|  6.67k|}
p2p_pd.c:WPA_GET_LE16:
  225|     99|{
  226|     99|	return (a[1] << 8) | a[0];
  227|     99|}
p2p_pd.c:WPA_GET_LE32:
  273|    162|{
  274|    162|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|    162|}
p2p_pd.c:WPA_PUT_BE32:
  265|    711|{
  266|    711|	a[0] = (val >> 24) & 0xff;
  267|    711|	a[1] = (val >> 16) & 0xff;
  268|    711|	a[2] = (val >> 8) & 0xff;
  269|    711|	a[3] = val & 0xff;
  270|    711|}
p2p_pd.c:WPA_PUT_BE16:
  219|  2.13k|{
  220|  2.13k|	a[0] = val >> 8;
  221|  2.13k|	a[1] = val & 0xff;
  222|  2.13k|}
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.40k|{
  266|  3.40k|	a[0] = (val >> 24) & 0xff;
  267|  3.40k|	a[1] = (val >> 16) & 0xff;
  268|  3.40k|	a[2] = (val >> 8) & 0xff;
  269|  3.40k|	a[3] = val & 0xff;
  270|  3.40k|}
p2p_build.c:WPA_PUT_LE16:
  230|  3.32k|{
  231|  3.32k|	a[1] = val >> 8;
  232|  3.32k|	a[0] = val & 0xff;
  233|  3.32k|}
p2p_build.c:WPA_PUT_BE16:
  219|    416|{
  220|    416|	a[0] = val >> 8;
  221|    416|	a[1] = val & 0xff;
  222|    416|}
wps_attr_build.c:WPA_PUT_BE24:
  241|     43|{
  242|     43|	a[0] = (val >> 16) & 0xff;
  243|     43|	a[1] = (val >> 8) & 0xff;
  244|     43|	a[2] = val & 0xff;
  245|     43|}
wps_attr_build.c:WPA_PUT_BE16:
  219|    176|{
  220|    176|	a[0] = val >> 8;
  221|    176|	a[1] = val & 0xff;
  222|    176|}
wps_attr_parse.c:WPA_GET_BE16:
  214|  2.12M|{
  215|  2.12M|	return (a[0] << 8) | a[1];
  216|  2.12M|}
wps_attr_parse.c:WPA_GET_BE24:
  236|  2.28k|{
  237|  2.28k|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  2.28k|}
wps_common.c:WPA_GET_BE16:
  214|  3.62k|{
  215|  3.62k|	return (a[0] << 8) | a[1];
  216|  3.62k|}
wps_common.c:WPA_GET_BE32:
  260|  1.81k|{
  261|  1.81k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.81k|}
ieee802_11_common.c:WPA_GET_BE24:
  236|  1.23M|{
  237|  1.23M|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.23M|}
ieee802_11_common.c:WPA_GET_BE32:
  260|  1.44M|{
  261|  1.44M|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.44M|}
sha256-internal.c:WPA_GET_BE32:
  260|   106k|{
  261|   106k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|   106k|}
sha256-internal.c:WPA_PUT_BE64:
  311|  6.66k|{
  312|  6.66k|	a[0] = val >> 56;
  313|  6.66k|	a[1] = val >> 48;
  314|  6.66k|	a[2] = val >> 40;
  315|  6.66k|	a[3] = val >> 32;
  316|  6.66k|	a[4] = val >> 24;
  317|  6.66k|	a[5] = val >> 16;
  318|  6.66k|	a[6] = val >> 8;
  319|  6.66k|	a[7] = val & 0xff;
  320|  6.66k|}
sha256-internal.c:WPA_PUT_BE32:
  265|  53.3k|{
  266|  53.3k|	a[0] = (val >> 24) & 0xff;
  267|  53.3k|	a[1] = (val >> 16) & 0xff;
  268|  53.3k|	a[2] = (val >> 8) & 0xff;
  269|  53.3k|	a[3] = val & 0xff;
  270|  53.3k|}

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

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

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

os_get_reltime:
   77|  27.7k|{
   78|  27.7k|#ifndef __MACH__
   79|  27.7k|#if defined(CLOCK_BOOTTIME)
   80|  27.7k|	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.7k|	struct timespec ts;
   87|  27.7k|	int res;
   88|       |
   89|  27.7k|	if (TEST_FAIL())
  ------------------
  |  |  688|  27.7k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 27.7k]
  |  |  ------------------
  ------------------
   90|      0|		return -1;
   91|       |
   92|  27.7k|	while (1) {
  ------------------
  |  Branch (92:9): [True: 27.7k, Folded]
  ------------------
   93|  27.7k|		res = clock_gettime(clock_id, &ts);
   94|  27.7k|		if (res == 0) {
  ------------------
  |  Branch (94:7): [True: 27.7k, False: 0]
  ------------------
   95|  27.7k|			t->sec = ts.tv_sec;
   96|  27.7k|			t->usec = ts.tv_nsec / 1000;
   97|  27.7k|			return 0;
   98|  27.7k|		}
   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.7k|}
os_get_random:
  258|  13.3k|{
  259|  13.3k|#ifdef TEST_FUZZ
  260|  13.3k|	size_t i;
  261|       |
  262|  46.8k|	for (i = 0; i < len; i++)
  ------------------
  |  Branch (262:14): [True: 33.5k, False: 13.3k]
  ------------------
  263|  33.5k|		buf[i] = i & 0xff;
  264|  13.3k|	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.3k|}
os_program_init:
  339|  6.66k|{
  340|  6.66k|	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.66k|	if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
  ------------------
  |  Branch (370:6): [True: 6.66k, False: 0]
  ------------------
  371|  6.66k|		srandom(seed);
  372|       |
  373|  6.66k|	return 0;
  374|  6.66k|}
os_program_deinit:
  378|  6.66k|{
  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.66k|}
os_zalloc:
  485|  40.2k|{
  486|  40.2k|	return calloc(1, size);
  487|  40.2k|}

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

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

p2p.c:wpabuf_size:
   49|  6.61k|{
   50|  6.61k|	return buf->size;
   51|  6.61k|}
p2p.c:wpabuf_put_data:
  174|  6.61k|{
  175|  6.61k|	if (data)
  ------------------
  |  Branch (175:6): [True: 6.61k, False: 0]
  ------------------
  176|  6.61k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  6.61k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  6.61k|}
p2p_dev_disc.c:wpabuf_head:
   94|     20|{
   95|     20|	return buf->buf;
   96|     20|}
p2p_dev_disc.c:wpabuf_len:
   59|     20|{
   60|     20|	return buf->used;
   61|     20|}
p2p_go_neg.c:wpabuf_len:
   59|     83|{
   60|     83|	return buf->used;
   61|     83|}
p2p_go_neg.c:wpabuf_head:
   94|     83|{
   95|     83|	return buf->buf;
   96|     83|}
p2p_invitation.c:wpabuf_len:
   59|  1.66k|{
   60|  1.66k|	return buf->used;
   61|  1.66k|}
p2p_invitation.c:wpabuf_put_buf:
  181|    833|{
  182|    833|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    833|}
p2p_invitation.c:wpabuf_put_data:
  174|    833|{
  175|    833|	if (data)
  ------------------
  |  Branch (175:6): [True: 833, False: 0]
  ------------------
  176|    833|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    833|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    833|}
p2p_invitation.c:wpabuf_head:
   94|  1.66k|{
   95|  1.66k|	return buf->buf;
   96|  1.66k|}
p2p_parse.c:wpabuf_head_u8:
   99|  7.56k|{
  100|  7.56k|	return (const u8 *) wpabuf_head(buf);
  101|  7.56k|}
p2p_parse.c:wpabuf_head:
   94|  9.06k|{
   95|  9.06k|	return buf->buf;
   96|  9.06k|}
p2p_parse.c:wpabuf_len:
   59|  9.06k|{
   60|  9.06k|	return buf->used;
   61|  9.06k|}
p2p_pd.c:wpabuf_put_u8:
  119|    711|{
  120|    711|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    711|	*pos = data;
  122|    711|}
p2p_pd.c:wpabuf_put_be32:
  161|    711|{
  162|    711|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|    711|	WPA_PUT_BE32(pos, data);
  164|    711|}
p2p_pd.c:wpabuf_put_be16:
  149|  2.13k|{
  150|  2.13k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|  2.13k|	WPA_PUT_BE16(pos, data);
  152|  2.13k|}
p2p_pd.c:wpabuf_head:
   94|    762|{
   95|    762|	return buf->buf;
   96|    762|}
p2p_pd.c:wpabuf_len:
   59|    762|{
   60|    762|	return buf->used;
   61|    762|}
p2p_build.c:wpabuf_put_u8:
  119|  16.6k|{
  120|  16.6k|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|  16.6k|	*pos = data;
  122|  16.6k|}
p2p_build.c:wpabuf_put_be32:
  161|  3.40k|{
  162|  3.40k|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|  3.40k|	WPA_PUT_BE32(pos, data);
  164|  3.40k|}
p2p_build.c:wpabuf_put_le16:
  125|  3.05k|{
  126|  3.05k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  127|  3.05k|	WPA_PUT_LE16(pos, data);
  128|  3.05k|}
p2p_build.c:wpabuf_put_data:
  174|  1.46k|{
  175|  1.46k|	if (data)
  ------------------
  |  Branch (175:6): [True: 1.37k, False: 85]
  ------------------
  176|  1.37k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  1.37k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  1.46k|}
p2p_build.c:wpabuf_put_be16:
  149|    416|{
  150|    416|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    416|	WPA_PUT_BE16(pos, data);
  152|    416|}
p2p_build.c:wpabuf_tailroom:
   69|    112|{
   70|    112|	return buf->size - buf->used;
   71|    112|}
p2p_build.c:wpabuf_len:
   59|  1.83k|{
   60|  1.83k|	return buf->used;
   61|  1.83k|}
p2p_build.c:wpabuf_head:
   94|    916|{
   95|    916|	return buf->buf;
   96|    916|}
wps_attr_build.c:wpabuf_put_be16:
  149|    133|{
  150|    133|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    133|	WPA_PUT_BE16(pos, data);
  152|    133|}
wps_attr_build.c:wpabuf_put_u8:
  119|    172|{
  120|    172|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    172|	*pos = data;
  122|    172|}
wps_attr_build.c:wpabuf_tailroom:
   69|     88|{
   70|     88|	return buf->size - buf->used;
   71|     88|}
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|     43|{
  156|     43|	u8 *pos = (u8 *) wpabuf_put(buf, 3);
  157|     43|	WPA_PUT_BE24(pos, data);
  158|     43|}
wps_attr_parse.c:wpabuf_head:
   94|  5.99k|{
   95|  5.99k|	return buf->buf;
   96|  5.99k|}
wps_attr_parse.c:wpabuf_len:
   59|  5.99k|{
   60|  5.99k|	return buf->used;
   61|  5.99k|}
wpabuf.c:wpabuf_put_data:
  174|    829|{
  175|    829|	if (data)
  ------------------
  |  Branch (175:6): [True: 829, False: 0]
  ------------------
  176|    829|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    829|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    829|}
wpabuf.c:wpabuf_len:
   59|   675k|{
   60|   675k|	return buf->used;
   61|   675k|}
wpabuf.c:wpabuf_head:
   94|    590|{
   95|    590|	return buf->buf;
   96|    590|}
wpabuf.c:wpabuf_mhead:
  109|   674k|{
  110|   674k|	return buf->buf;
  111|   674k|}
wpabuf.c:wpabuf_mhead_u8:
  114|   674k|{
  115|   674k|	return (u8 *) wpabuf_mhead(buf);
  116|   674k|}
wpabuf.c:wpabuf_put_buf:
  181|    166|{
  182|    166|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    166|}
ieee802_11_common.c:wpabuf_put_data:
  174|   633k|{
  175|   633k|	if (data)
  ------------------
  |  Branch (175:6): [True: 633k, False: 0]
  ------------------
  176|   633k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|   633k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|   633k|}

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

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

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

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

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

