ieee802_11_parse_elems:
  774|  24.1k|{
  775|  24.1k|	os_memset(elems, 0, sizeof(*elems));
  ------------------
  |  |  529|  24.1k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  776|       |
  777|  24.1k|	return __ieee802_11_parse_elems(start, len, elems, show_errors);
  778|  24.1k|}
ieee802_11_vendor_ie_concat:
 1280|  42.0k|{
 1281|  42.0k|	struct wpabuf *buf;
 1282|  42.0k|	const struct element *elem, *found = NULL;
 1283|       |
 1284|  39.0M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  366|  42.0k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  358|  42.0k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  359|  39.0M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (359:7): [True: 39.0M, False: 28.6k]
  |  |  |  |  ------------------
  |  |  |  |  360|  39.0M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  361|  39.0M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (361:7): [True: 39.0M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  362|  39.0M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  |  |  363|  39.0M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  |  |  ------------------
  |  |  367|  39.0M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (367:7): [True: 945k, False: 38.0M]
  |  |  ------------------
  ------------------
 1285|   945k|		if (elem->datalen >= 4 &&
  ------------------
  |  Branch (1285:7): [True: 422k, False: 523k]
  ------------------
 1286|   422k|		    WPA_GET_BE32(elem->data) == oui_type) {
  ------------------
  |  Branch (1286:7): [True: 13.3k, False: 408k]
  ------------------
 1287|  13.3k|			found = elem;
 1288|  13.3k|			break;
 1289|  13.3k|		}
 1290|   945k|	}
 1291|       |
 1292|  42.0k|	if (!found)
  ------------------
  |  Branch (1292:6): [True: 28.6k, False: 13.3k]
  ------------------
 1293|  28.6k|		return NULL; /* No specified vendor IE found */
 1294|       |
 1295|  13.3k|	buf = wpabuf_alloc(ies_len);
 1296|  13.3k|	if (buf == NULL)
  ------------------
  |  Branch (1296:6): [True: 0, False: 13.3k]
  ------------------
 1297|      0|		return NULL;
 1298|       |
 1299|       |	/*
 1300|       |	 * There may be multiple vendor IEs in the message, so need to
 1301|       |	 * concatenate their data fields.
 1302|       |	 */
 1303|  58.1M|	for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, ies_len) {
  ------------------
  |  |  366|  13.3k|	for_each_element(element, data, datalen)			\
  |  |  ------------------
  |  |  |  |  358|  13.3k|	for (_elem = (const struct element *) (_data);			\
  |  |  |  |  359|  58.1M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (359:7): [True: 58.1M, False: 13.3k]
  |  |  |  |  ------------------
  |  |  |  |  360|  58.1M|		(int) sizeof(*_elem) &&					\
  |  |  |  |  361|  58.1M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (361:7): [True: 58.1M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  362|  58.1M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  |  |  363|  58.1M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  |  |  ------------------
  |  |  367|  58.1M|		if (element->id == (_id))
  |  |  ------------------
  |  |  |  Branch (367:7): [True: 2.91M, False: 55.1M]
  |  |  ------------------
  ------------------
 1304|  2.91M|		if (elem->datalen >= 4 && WPA_GET_BE32(elem->data) == oui_type)
  ------------------
  |  Branch (1304:7): [True: 893k, False: 2.02M]
  |  Branch (1304:29): [True: 525k, False: 368k]
  ------------------
 1305|   525k|			wpabuf_put_data(buf, elem->data + 4, elem->datalen - 4);
 1306|  2.91M|	}
 1307|       |
 1308|  13.3k|	return buf;
 1309|  13.3k|}
ieee80211_chan_to_freq:
 2142|    611|{
 2143|    611|	int freq;
 2144|       |
 2145|    611|	if (country_match(us_op_class_cc, country)) {
  ------------------
  |  Branch (2145:6): [True: 0, False: 611]
  ------------------
 2146|      0|		freq = ieee80211_chan_to_freq_us(op_class, chan);
 2147|      0|		if (freq > 0)
  ------------------
  |  Branch (2147:7): [True: 0, False: 0]
  ------------------
 2148|      0|			return freq;
 2149|      0|	}
 2150|       |
 2151|    611|	if (country_match(eu_op_class_cc, country)) {
  ------------------
  |  Branch (2151:6): [True: 0, False: 611]
  ------------------
 2152|      0|		freq = ieee80211_chan_to_freq_eu(op_class, chan);
 2153|      0|		if (freq > 0)
  ------------------
  |  Branch (2153:7): [True: 0, False: 0]
  ------------------
 2154|      0|			return freq;
 2155|      0|	}
 2156|       |
 2157|    611|	if (country_match(jp_op_class_cc, country)) {
  ------------------
  |  Branch (2157:6): [True: 0, False: 611]
  ------------------
 2158|      0|		freq = ieee80211_chan_to_freq_jp(op_class, chan);
 2159|      0|		if (freq > 0)
  ------------------
  |  Branch (2159:7): [True: 0, False: 0]
  ------------------
 2160|      0|			return freq;
 2161|      0|	}
 2162|       |
 2163|    611|	if (country_match(cn_op_class_cc, country)) {
  ------------------
  |  Branch (2163:6): [True: 0, False: 611]
  ------------------
 2164|      0|		freq = ieee80211_chan_to_freq_cn(op_class, chan);
 2165|      0|		if (freq > 0)
  ------------------
  |  Branch (2165:7): [True: 0, False: 0]
  ------------------
 2166|      0|			return freq;
 2167|      0|	}
 2168|       |
 2169|    611|	return ieee80211_chan_to_freq_global(op_class, chan);
 2170|    611|}
ieee802_11_common.c:__ieee802_11_parse_elems:
  489|  24.1k|{
  490|  24.1k|	const struct element *elem;
  491|  24.1k|	int unknown = 0;
  492|       |
  493|  24.1k|	if (!start)
  ------------------
  |  Branch (493:6): [True: 0, False: 24.1k]
  ------------------
  494|      0|		return ParseOK;
  495|       |
  496|  44.4M|	for_each_element(elem, start, len) {
  ------------------
  |  |  358|  24.1k|	for (_elem = (const struct element *) (_data);			\
  |  |  359|  44.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (359:7): [True: 44.4M, False: 21.3k]
  |  |  ------------------
  |  |  360|  44.4M|		(int) sizeof(*_elem) &&					\
  |  |  361|  44.4M|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (361:7): [True: 44.4M, False: 2.83k]
  |  |  ------------------
  |  |  362|  44.4M|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  363|  44.4M|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  ------------------
  497|  44.4M|		u8 id = elem->id, elen = elem->datalen;
  498|  44.4M|		const u8 *pos = elem->data;
  499|  44.4M|		size_t *total_len = NULL;
  500|       |
  501|  44.4M|		if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) {
  ------------------
  |  |  503|  88.8M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (501:7): [True: 2.10M, False: 42.3M]
  |  Branch (501:34): [True: 537k, False: 1.56M]
  ------------------
  502|   537k|			elems->num_frag_elems--;
  503|   537k|			continue;
  504|   537k|		}
  505|  43.8M|		elems->num_frag_elems = 0;
  506|       |
  507|  43.8M|		switch (id) {
  508|  37.5M|		case WLAN_EID_SSID:
  ------------------
  |  |  323|  37.5M|#define WLAN_EID_SSID 0
  ------------------
  |  Branch (508:3): [True: 37.5M, False: 6.37M]
  ------------------
  509|  37.5M|			if (elen > SSID_MAX_LEN) {
  ------------------
  |  |  511|  37.5M|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (509:8): [True: 161k, False: 37.3M]
  ------------------
  510|   161k|				wpa_printf(MSG_DEBUG,
  511|   161k|					   "Ignored too long SSID element (elen=%u)",
  512|   161k|					   elen);
  513|   161k|				break;
  514|   161k|			}
  515|  37.3M|			if (elems->ssid) {
  ------------------
  |  Branch (515:8): [True: 37.3M, False: 8.26k]
  ------------------
  516|  37.3M|				wpa_printf(MSG_MSGDUMP,
  517|  37.3M|					   "Ignored duplicated SSID element");
  518|  37.3M|				break;
  519|  37.3M|			}
  520|  8.26k|			elems->ssid = pos;
  521|  8.26k|			elems->ssid_len = elen;
  522|  8.26k|			break;
  523|   187k|		case WLAN_EID_SUPP_RATES:
  ------------------
  |  |  324|   187k|#define WLAN_EID_SUPP_RATES 1
  ------------------
  |  Branch (523:3): [True: 187k, False: 43.6M]
  ------------------
  524|   187k|			elems->supp_rates = pos;
  525|   187k|			elems->supp_rates_len = elen;
  526|   187k|			break;
  527|   210k|		case WLAN_EID_DS_PARAMS:
  ------------------
  |  |  325|   210k|#define WLAN_EID_DS_PARAMS 3
  ------------------
  |  Branch (527:3): [True: 210k, False: 43.6M]
  ------------------
  528|   210k|			if (elen < 1)
  ------------------
  |  Branch (528:8): [True: 18.9k, False: 191k]
  ------------------
  529|  18.9k|				break;
  530|   191k|			elems->ds_params = pos;
  531|   191k|			break;
  532|  52.0k|		case WLAN_EID_CF_PARAMS:
  ------------------
  |  |  326|  52.0k|#define WLAN_EID_CF_PARAMS 4
  ------------------
  |  Branch (532:3): [True: 52.0k, False: 43.8M]
  ------------------
  533|  65.2k|		case WLAN_EID_TIM:
  ------------------
  |  |  327|  65.2k|#define WLAN_EID_TIM 5
  ------------------
  |  Branch (533:3): [True: 13.2k, False: 43.8M]
  ------------------
  534|  65.2k|			break;
  535|  31.2k|		case WLAN_EID_CHALLENGE:
  ------------------
  |  |  336|  31.2k|#define WLAN_EID_CHALLENGE 16
  ------------------
  |  Branch (535:3): [True: 31.2k, False: 43.8M]
  ------------------
  536|  31.2k|			elems->challenge = pos;
  537|  31.2k|			elems->challenge_len = elen;
  538|  31.2k|			break;
  539|  12.0k|		case WLAN_EID_ERP_INFO:
  ------------------
  |  |  347|  12.0k|#define WLAN_EID_ERP_INFO 42
  ------------------
  |  Branch (539:3): [True: 12.0k, False: 43.8M]
  ------------------
  540|  12.0k|			if (elen < 1)
  ------------------
  |  Branch (540:8): [True: 9.93k, False: 2.10k]
  ------------------
  541|  9.93k|				break;
  542|  2.10k|			elems->erp_info = pos;
  543|  2.10k|			break;
  544|  3.47k|		case WLAN_EID_EXT_SUPP_RATES:
  ------------------
  |  |  353|  3.47k|#define WLAN_EID_EXT_SUPP_RATES 50
  ------------------
  |  Branch (544:3): [True: 3.47k, False: 43.8M]
  ------------------
  545|  3.47k|			elems->ext_supp_rates = pos;
  546|  3.47k|			elems->ext_supp_rates_len = elen;
  547|  3.47k|			break;
  548|  2.32M|		case WLAN_EID_VENDOR_SPECIFIC:
  ------------------
  |  |  496|  2.32M|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
  |  Branch (548:3): [True: 2.32M, False: 41.5M]
  ------------------
  549|  2.32M|			if (ieee802_11_parse_vendor_specific(pos, elen,
  ------------------
  |  Branch (549:8): [True: 1.40M, False: 921k]
  ------------------
  550|  2.32M|							     elems,
  551|  2.32M|							     show_errors))
  552|  1.40M|				unknown++;
  553|  2.32M|			break;
  554|  5.49k|		case WLAN_EID_RSN:
  ------------------
  |  |  352|  5.49k|#define WLAN_EID_RSN 48
  ------------------
  |  Branch (554:3): [True: 5.49k, False: 43.8M]
  ------------------
  555|  5.49k|			elems->rsn_ie = pos;
  556|  5.49k|			elems->rsn_ie_len = elen;
  557|  5.49k|			break;
  558|  2.27k|		case WLAN_EID_RSNX:
  ------------------
  |  |  504|  2.27k|#define WLAN_EID_RSNX 244
  ------------------
  |  Branch (558:3): [True: 2.27k, False: 43.8M]
  ------------------
  559|  2.27k|			elems->rsnxe = pos;
  560|  2.27k|			elems->rsnxe_len = elen;
  561|  2.27k|			break;
  562|  6.10k|		case WLAN_EID_PWR_CAPABILITY:
  ------------------
  |  |  338|  6.10k|#define WLAN_EID_PWR_CAPABILITY 33
  ------------------
  |  Branch (562:3): [True: 6.10k, False: 43.8M]
  ------------------
  563|  6.10k|			if (elen < 2)
  ------------------
  |  Branch (563:8): [True: 1.35k, False: 4.74k]
  ------------------
  564|  1.35k|				break;
  565|  4.74k|			elems->power_capab = pos;
  566|  4.74k|			elems->power_capab_len = elen;
  567|  4.74k|			break;
  568|  6.07k|		case WLAN_EID_SUPPORTED_CHANNELS:
  ------------------
  |  |  341|  6.07k|#define WLAN_EID_SUPPORTED_CHANNELS 36
  ------------------
  |  Branch (568:3): [True: 6.07k, False: 43.8M]
  ------------------
  569|  6.07k|			elems->supp_channels = pos;
  570|  6.07k|			elems->supp_channels_len = elen;
  571|  6.07k|			break;
  572|  2.44k|		case WLAN_EID_MOBILITY_DOMAIN:
  ------------------
  |  |  357|  2.44k|#define WLAN_EID_MOBILITY_DOMAIN 54
  ------------------
  |  Branch (572:3): [True: 2.44k, False: 43.8M]
  ------------------
  573|  2.44k|			if (elen < sizeof(struct rsn_mdie))
  ------------------
  |  Branch (573:8): [True: 712, False: 1.73k]
  ------------------
  574|    712|				break;
  575|  1.73k|			elems->mdie = pos;
  576|  1.73k|			elems->mdie_len = elen;
  577|  1.73k|			break;
  578|  5.80k|		case WLAN_EID_FAST_BSS_TRANSITION:
  ------------------
  |  |  358|  5.80k|#define WLAN_EID_FAST_BSS_TRANSITION 55
  ------------------
  |  Branch (578:3): [True: 5.80k, False: 43.8M]
  ------------------
  579|  5.80k|			if (elen < sizeof(struct rsn_ftie))
  ------------------
  |  Branch (579:8): [True: 3.06k, False: 2.74k]
  ------------------
  580|  3.06k|				break;
  581|  2.74k|			elems->ftie = pos;
  582|  2.74k|			elems->ftie_len = elen;
  583|  2.74k|			elems->fte_defrag_len = elen;
  584|  2.74k|			total_len = &elems->fte_defrag_len;
  585|  2.74k|			break;
  586|  3.92k|		case WLAN_EID_TIMEOUT_INTERVAL:
  ------------------
  |  |  359|  3.92k|#define WLAN_EID_TIMEOUT_INTERVAL 56
  ------------------
  |  Branch (586:3): [True: 3.92k, False: 43.8M]
  ------------------
  587|  3.92k|			if (elen != 5)
  ------------------
  |  Branch (587:8): [True: 3.72k, False: 203]
  ------------------
  588|  3.72k|				break;
  589|    203|			elems->timeout_int = pos;
  590|    203|			break;
  591|  9.17k|		case WLAN_EID_HT_CAP:
  ------------------
  |  |  350|  9.17k|#define WLAN_EID_HT_CAP 45
  ------------------
  |  Branch (591:3): [True: 9.17k, False: 43.8M]
  ------------------
  592|  9.17k|			if (elen < sizeof(struct ieee80211_ht_capabilities))
  ------------------
  |  Branch (592:8): [True: 2.46k, False: 6.70k]
  ------------------
  593|  2.46k|				break;
  594|  6.70k|			elems->ht_capabilities = pos;
  595|  6.70k|			break;
  596|  16.7k|		case WLAN_EID_HT_OPERATION:
  ------------------
  |  |  364|  16.7k|#define WLAN_EID_HT_OPERATION 61
  ------------------
  |  Branch (596:3): [True: 16.7k, False: 43.8M]
  ------------------
  597|  16.7k|			if (elen < sizeof(struct ieee80211_ht_operation))
  ------------------
  |  Branch (597:8): [True: 1.80k, False: 14.9k]
  ------------------
  598|  1.80k|				break;
  599|  14.9k|			elems->ht_operation = pos;
  600|  14.9k|			break;
  601|  2.88k|		case WLAN_EID_MESH_CONFIG:
  ------------------
  |  |  414|  2.88k|#define WLAN_EID_MESH_CONFIG 113
  ------------------
  |  Branch (601:3): [True: 2.88k, False: 43.8M]
  ------------------
  602|  2.88k|			elems->mesh_config = pos;
  603|  2.88k|			elems->mesh_config_len = elen;
  604|  2.88k|			break;
  605|  2.01k|		case WLAN_EID_MESH_ID:
  ------------------
  |  |  415|  2.01k|#define WLAN_EID_MESH_ID 114
  ------------------
  |  Branch (605:3): [True: 2.01k, False: 43.8M]
  ------------------
  606|  2.01k|			elems->mesh_id = pos;
  607|  2.01k|			elems->mesh_id_len = elen;
  608|  2.01k|			break;
  609|  6.66k|		case WLAN_EID_PEER_MGMT:
  ------------------
  |  |  418|  6.66k|#define WLAN_EID_PEER_MGMT 117
  ------------------
  |  Branch (609:3): [True: 6.66k, False: 43.8M]
  ------------------
  610|  6.66k|			elems->peer_mgmt = pos;
  611|  6.66k|			elems->peer_mgmt_len = elen;
  612|  6.66k|			break;
  613|  2.45k|		case WLAN_EID_VHT_CAP:
  ------------------
  |  |  478|  2.45k|#define WLAN_EID_VHT_CAP 191
  ------------------
  |  Branch (613:3): [True: 2.45k, False: 43.8M]
  ------------------
  614|  2.45k|			if (elen < sizeof(struct ieee80211_vht_capabilities))
  ------------------
  |  Branch (614:8): [True: 1.03k, False: 1.41k]
  ------------------
  615|  1.03k|				break;
  616|  1.41k|			elems->vht_capabilities = pos;
  617|  1.41k|			break;
  618|  2.48k|		case WLAN_EID_VHT_OPERATION:
  ------------------
  |  |  479|  2.48k|#define WLAN_EID_VHT_OPERATION 192
  ------------------
  |  Branch (618:3): [True: 2.48k, False: 43.8M]
  ------------------
  619|  2.48k|			if (elen < sizeof(struct ieee80211_vht_operation))
  ------------------
  |  Branch (619:8): [True: 706, False: 1.78k]
  ------------------
  620|    706|				break;
  621|  1.78k|			elems->vht_operation = pos;
  622|  1.78k|			break;
  623|  2.10k|		case WLAN_EID_OPERATING_MODE_NOTIFICATION:
  ------------------
  |  |  486|  2.10k|#define WLAN_EID_OPERATING_MODE_NOTIFICATION 199
  ------------------
  |  Branch (623:3): [True: 2.10k, False: 43.8M]
  ------------------
  624|  2.10k|			if (elen != 1)
  ------------------
  |  Branch (624:8): [True: 1.88k, False: 216]
  ------------------
  625|  1.88k|				break;
  626|    216|			elems->opmode_notif = pos;
  627|    216|			break;
  628|  3.45k|		case WLAN_EID_LINK_ID:
  ------------------
  |  |  403|  3.45k|#define WLAN_EID_LINK_ID 101
  ------------------
  |  Branch (628:3): [True: 3.45k, False: 43.8M]
  ------------------
  629|  3.45k|			if (elen < 18)
  ------------------
  |  Branch (629:8): [True: 1.17k, False: 2.27k]
  ------------------
  630|  1.17k|				break;
  631|  2.27k|			elems->link_id = pos;
  632|  2.27k|			break;
  633|  3.98k|		case WLAN_EID_INTERWORKING:
  ------------------
  |  |  408|  3.98k|#define WLAN_EID_INTERWORKING 107
  ------------------
  |  Branch (633:3): [True: 3.98k, False: 43.8M]
  ------------------
  634|  3.98k|			elems->interworking = pos;
  635|  3.98k|			elems->interworking_len = elen;
  636|  3.98k|			break;
  637|  2.59k|		case WLAN_EID_QOS_MAP_SET:
  ------------------
  |  |  411|  2.59k|#define WLAN_EID_QOS_MAP_SET 110
  ------------------
  |  Branch (637:3): [True: 2.59k, False: 43.8M]
  ------------------
  638|  2.59k|			if (elen < 16)
  ------------------
  |  Branch (638:8): [True: 1.32k, False: 1.27k]
  ------------------
  639|  1.32k|				break;
  640|  1.27k|			elems->qos_map_set = pos;
  641|  1.27k|			elems->qos_map_set_len = elen;
  642|  1.27k|			break;
  643|  7.77k|		case WLAN_EID_EXT_CAPAB:
  ------------------
  |  |  428|  7.77k|#define WLAN_EID_EXT_CAPAB 127
  ------------------
  |  Branch (643:3): [True: 7.77k, False: 43.8M]
  ------------------
  644|  7.77k|			elems->ext_capab = pos;
  645|  7.77k|			elems->ext_capab_len = elen;
  646|  7.77k|			break;
  647|  3.04k|		case WLAN_EID_BSS_MAX_IDLE_PERIOD:
  ------------------
  |  |  392|  3.04k|#define WLAN_EID_BSS_MAX_IDLE_PERIOD 90
  ------------------
  |  Branch (647:3): [True: 3.04k, False: 43.8M]
  ------------------
  648|  3.04k|			if (elen < 3)
  ------------------
  |  Branch (648:8): [True: 944, False: 2.09k]
  ------------------
  649|    944|				break;
  650|  2.09k|			elems->bss_max_idle_period = pos;
  651|  2.09k|			break;
  652|  3.05k|		case WLAN_EID_SSID_LIST:
  ------------------
  |  |  386|  3.05k|#define WLAN_EID_SSID_LIST 84
  ------------------
  |  Branch (652:3): [True: 3.05k, False: 43.8M]
  ------------------
  653|  3.05k|			elems->ssid_list = pos;
  654|  3.05k|			elems->ssid_list_len = elen;
  655|  3.05k|			break;
  656|  1.41k|		case WLAN_EID_AMPE:
  ------------------
  |  |  434|  1.41k|#define WLAN_EID_AMPE 139
  ------------------
  |  Branch (656:3): [True: 1.41k, False: 43.8M]
  ------------------
  657|  1.41k|			elems->ampe = pos;
  658|  1.41k|			elems->ampe_len = elen;
  659|  1.41k|			break;
  660|  5.44k|		case WLAN_EID_MIC:
  ------------------
  |  |  435|  5.44k|#define WLAN_EID_MIC 140
  ------------------
  |  Branch (660:3): [True: 5.44k, False: 43.8M]
  ------------------
  661|  5.44k|			elems->mic = pos;
  662|  5.44k|			elems->mic_len = elen;
  663|  5.44k|			if (elems->stop_at_mic) {
  ------------------
  |  Branch (663:8): [True: 0, False: 5.44k]
  ------------------
  664|       |				/* After MIC everything is encrypted, so stop.
  665|       |				 */
  666|      0|				goto done;
  667|      0|			}
  668|  5.44k|			break;
  669|  5.44k|		case WLAN_EID_MULTI_BAND:
  ------------------
  |  |  450|  4.28k|#define WLAN_EID_MULTI_BAND 158
  ------------------
  |  Branch (669:3): [True: 4.28k, False: 43.8M]
  ------------------
  670|  4.28k|			if (elems->mb_ies.nof_ies >= MAX_NOF_MB_IES_SUPPORTED) {
  ------------------
  |  |   23|  4.28k|#define MAX_NOF_MB_IES_SUPPORTED 5
  ------------------
  |  Branch (670:8): [True: 3.44k, False: 841]
  ------------------
  671|  3.44k|				wpa_printf(MSG_MSGDUMP,
  672|  3.44k|					   "IEEE 802.11 element parse ignored MB IE (id=%d elen=%d)",
  673|  3.44k|					   id, elen);
  674|  3.44k|				break;
  675|  3.44k|			}
  676|       |
  677|    841|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie = pos;
  678|    841|			elems->mb_ies.ies[elems->mb_ies.nof_ies].ie_len = elen;
  679|    841|			elems->mb_ies.nof_ies++;
  680|    841|			break;
  681|  7.76k|		case WLAN_EID_SUPPORTED_OPERATING_CLASSES:
  ------------------
  |  |  362|  7.76k|#define WLAN_EID_SUPPORTED_OPERATING_CLASSES 59
  ------------------
  |  Branch (681:3): [True: 7.76k, False: 43.8M]
  ------------------
  682|  7.76k|			elems->supp_op_classes = pos;
  683|  7.76k|			elems->supp_op_classes_len = elen;
  684|  7.76k|			break;
  685|  2.01k|		case WLAN_EID_RRM_ENABLED_CAPABILITIES:
  ------------------
  |  |  373|  2.01k|#define WLAN_EID_RRM_ENABLED_CAPABILITIES 70
  ------------------
  |  Branch (685:3): [True: 2.01k, False: 43.8M]
  ------------------
  686|  2.01k|			elems->rrm_enabled = pos;
  687|  2.01k|			elems->rrm_enabled_len = elen;
  688|  2.01k|			break;
  689|  6.08k|		case WLAN_EID_MULTIPLE_BSSID:
  ------------------
  |  |  374|  6.08k|#define WLAN_EID_MULTIPLE_BSSID 71
  ------------------
  |  Branch (689:3): [True: 6.08k, False: 43.8M]
  ------------------
  690|  6.08k|			if (elen < 1)
  ------------------
  |  Branch (690:8): [True: 967, False: 5.11k]
  ------------------
  691|    967|				break;
  692|  5.11k|			elems->mbssid = pos;
  693|  5.11k|			elems->mbssid_len = elen;
  694|  5.11k|			break;
  695|  1.13k|		case WLAN_EID_CAG_NUMBER:
  ------------------
  |  |  499|  1.13k|#define WLAN_EID_CAG_NUMBER 237
  ------------------
  |  Branch (695:3): [True: 1.13k, False: 43.8M]
  ------------------
  696|  1.13k|			elems->cag_number = pos;
  697|  1.13k|			elems->cag_number_len = elen;
  698|  1.13k|			break;
  699|  2.70k|		case WLAN_EID_AP_CSN:
  ------------------
  |  |  500|  2.70k|#define WLAN_EID_AP_CSN 239
  ------------------
  |  Branch (699:3): [True: 2.70k, False: 43.8M]
  ------------------
  700|  2.70k|			if (elen < 1)
  ------------------
  |  Branch (700:8): [True: 716, False: 1.98k]
  ------------------
  701|    716|				break;
  702|  1.98k|			elems->ap_csn = pos;
  703|  1.98k|			break;
  704|  29.2k|		case WLAN_EID_FILS_INDICATION:
  ------------------
  |  |  501|  29.2k|#define WLAN_EID_FILS_INDICATION 240
  ------------------
  |  Branch (704:3): [True: 29.2k, False: 43.8M]
  ------------------
  705|  29.2k|			if (elen < 2)
  ------------------
  |  Branch (705:8): [True: 26.7k, False: 2.52k]
  ------------------
  706|  26.7k|				break;
  707|  2.52k|			elems->fils_indic = pos;
  708|  2.52k|			elems->fils_indic_len = elen;
  709|  2.52k|			break;
  710|  4.20k|		case WLAN_EID_DILS:
  ------------------
  |  |  502|  4.20k|#define WLAN_EID_DILS 241
  ------------------
  |  Branch (710:3): [True: 4.20k, False: 43.8M]
  ------------------
  711|  4.20k|			if (elen < 2)
  ------------------
  |  Branch (711:8): [True: 1.43k, False: 2.77k]
  ------------------
  712|  1.43k|				break;
  713|  2.77k|			elems->dils = pos;
  714|  2.77k|			elems->dils_len = elen;
  715|  2.77k|			break;
  716|  2.08k|		case WLAN_EID_S1G_CAPABILITIES:
  ------------------
  |  |  495|  2.08k|#define WLAN_EID_S1G_CAPABILITIES 217
  ------------------
  |  Branch (716:3): [True: 2.08k, False: 43.8M]
  ------------------
  717|  2.08k|			if (elen < 15)
  ------------------
  |  Branch (717:8): [True: 485, False: 1.60k]
  ------------------
  718|    485|				break;
  719|  1.60k|			elems->s1g_capab = pos;
  720|  1.60k|			break;
  721|  1.56M|		case WLAN_EID_FRAGMENT:
  ------------------
  |  |  503|  1.56M|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (721:3): [True: 1.56M, False: 42.3M]
  ------------------
  722|  1.56M|			wpa_printf(MSG_MSGDUMP,
  723|  1.56M|				   "Fragment without a valid last element - skip");
  724|       |
  725|  1.56M|			break;
  726|  76.5k|		case WLAN_EID_EXTENSION:
  ------------------
  |  |  505|  76.5k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (726:3): [True: 76.5k, False: 43.8M]
  ------------------
  727|  76.5k|			if (ieee802_11_parse_extension(pos, elen, elems, start,
  ------------------
  |  Branch (727:8): [True: 49.3k, False: 27.2k]
  ------------------
  728|  76.5k|						       len, show_errors))
  729|  49.3k|				unknown++;
  730|  76.5k|			break;
  731|  1.73M|		default:
  ------------------
  |  Branch (731:3): [True: 1.73M, False: 42.1M]
  ------------------
  732|  1.73M|			unknown++;
  733|  1.73M|			if (!show_errors)
  ------------------
  |  Branch (733:8): [True: 1.73M, False: 0]
  ------------------
  734|  1.73M|				break;
  735|      0|			wpa_printf(MSG_MSGDUMP, "IEEE 802.11 element parse "
  736|      0|				   "ignored unknown element (id=%d elen=%d)",
  737|      0|				   id, elen);
  738|      0|			break;
  739|  43.8M|		}
  740|       |
  741|  43.8M|		if (elen == 255 && total_len)
  ------------------
  |  Branch (741:7): [True: 63.5k, False: 43.8M]
  |  Branch (741:22): [True: 2.02k, False: 61.4k]
  ------------------
  742|  2.02k|			*total_len += ieee802_11_fragments_length(
  743|  2.02k|				elems, pos + elen,
  744|  2.02k|				(start + len) - (pos + elen));
  745|       |
  746|  43.8M|	}
  747|       |
  748|  24.1k|	if (!for_each_element_completed(elem, start, len)) {
  ------------------
  |  Branch (748:6): [True: 2.96k, False: 21.1k]
  ------------------
  749|  2.96k|		if (show_errors) {
  ------------------
  |  Branch (749:7): [True: 0, False: 2.96k]
  ------------------
  750|      0|			wpa_printf(MSG_DEBUG,
  751|      0|				   "IEEE 802.11 element parse failed @%d",
  752|      0|				   (int) (start + len - (const u8 *) elem));
  753|      0|			wpa_hexdump(MSG_MSGDUMP, "IEs", start, len);
  754|      0|		}
  755|  2.96k|		return ParseFailed;
  756|  2.96k|	}
  757|       |
  758|  21.1k|done:
  759|  21.1k|	return unknown ? ParseUnknown : ParseOK;
  ------------------
  |  Branch (759:9): [True: 8.08k, False: 13.0k]
  ------------------
  760|  24.1k|}
ieee802_11_common.c:ieee802_11_parse_vendor_specific:
   23|  2.32M|{
   24|  2.32M|	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|  2.32M|	if (elen < 4) {
  ------------------
  |  Branch (29:6): [True: 1.24M, False: 1.08M]
  ------------------
   30|  1.24M|		if (show_errors) {
  ------------------
  |  Branch (30:7): [True: 0, False: 1.24M]
  ------------------
   31|      0|			wpa_printf(MSG_MSGDUMP, "short vendor specific "
   32|      0|				   "information element ignored (len=%lu)",
   33|      0|				   (unsigned long) elen);
   34|      0|		}
   35|  1.24M|		return -1;
   36|  1.24M|	}
   37|       |
   38|  1.08M|	oui = WPA_GET_BE24(pos);
   39|  1.08M|	switch (oui) {
   40|   415k|	case OUI_MICROSOFT:
  ------------------
  |  | 1562|   415k|#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
  ------------------
  |  Branch (40:2): [True: 415k, False: 667k]
  ------------------
   41|       |		/* Microsoft/Wi-Fi information elements are further typed and
   42|       |		 * subtyped */
   43|   415k|		switch (pos[3]) {
   44|  9.88k|		case 1:
  ------------------
  |  Branch (44:3): [True: 9.88k, False: 405k]
  ------------------
   45|       |			/* Microsoft OUI (00:50:F2) with OUI Type 1:
   46|       |			 * real WPA information element */
   47|  9.88k|			elems->wpa_ie = pos;
   48|  9.88k|			elems->wpa_ie_len = elen;
   49|  9.88k|			break;
   50|  3.29k|		case WMM_OUI_TYPE:
  ------------------
  |  | 1618|  3.29k|#define WMM_OUI_TYPE 2
  ------------------
  |  Branch (50:3): [True: 3.29k, False: 412k]
  ------------------
   51|       |			/* WMM information element */
   52|  3.29k|			if (elen < 5) {
  ------------------
  |  Branch (52:8): [True: 1.67k, False: 1.61k]
  ------------------
   53|  1.67k|				wpa_printf(MSG_MSGDUMP, "short WMM "
   54|  1.67k|					   "information element ignored "
   55|  1.67k|					   "(len=%lu)",
   56|  1.67k|					   (unsigned long) elen);
   57|  1.67k|				return -1;
   58|  1.67k|			}
   59|  1.61k|			switch (pos[4]) {
   60|    603|			case WMM_OUI_SUBTYPE_INFORMATION_ELEMENT:
  ------------------
  |  | 1619|    603|#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  ------------------
  |  Branch (60:4): [True: 603, False: 1.01k]
  ------------------
   61|    805|			case WMM_OUI_SUBTYPE_PARAMETER_ELEMENT:
  ------------------
  |  | 1620|    805|#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  ------------------
  |  Branch (61:4): [True: 202, False: 1.41k]
  ------------------
   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|    805|				elems->wmm = pos;
   69|    805|				elems->wmm_len = elen;
   70|    805|				break;
   71|    207|			case WMM_OUI_SUBTYPE_TSPEC_ELEMENT:
  ------------------
  |  | 1621|    207|#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
  ------------------
  |  Branch (71:4): [True: 207, False: 1.41k]
  ------------------
   72|    207|				elems->wmm_tspec = pos;
   73|    207|				elems->wmm_tspec_len = elen;
   74|    207|				break;
   75|    606|			default:
  ------------------
  |  Branch (75:4): [True: 606, False: 1.01k]
  ------------------
   76|    606|				wpa_printf(MSG_EXCESSIVE, "unknown WMM "
   77|    606|					   "information element ignored "
   78|    606|					   "(subtype=%d len=%lu)",
   79|    606|					   pos[4], (unsigned long) elen);
   80|    606|				return -1;
   81|  1.61k|			}
   82|  1.01k|			break;
   83|   399k|		case 4:
  ------------------
  |  Branch (83:3): [True: 399k, False: 15.7k]
  ------------------
   84|       |			/* Wi-Fi Protected Setup (WPS) IE */
   85|   399k|			elems->wps_ie = pos;
   86|   399k|			elems->wps_ie_len = elen;
   87|   399k|			break;
   88|  2.61k|		default:
  ------------------
  |  Branch (88:3): [True: 2.61k, False: 413k]
  ------------------
   89|  2.61k|			wpa_printf(MSG_EXCESSIVE, "Unknown Microsoft "
   90|  2.61k|				   "information element ignored "
   91|  2.61k|				   "(type=%d len=%lu)",
   92|  2.61k|				   pos[3], (unsigned long) elen);
   93|  2.61k|			return -1;
   94|   415k|		}
   95|   410k|		break;
   96|       |
   97|   511k|	case OUI_WFA:
  ------------------
  |  | 1567|   511k|#define OUI_WFA 0x506f9a
  ------------------
  |  Branch (97:2): [True: 511k, False: 571k]
  ------------------
   98|   511k|		switch (pos[3]) {
   99|   341k|		case P2P_OUI_TYPE:
  ------------------
  |  | 1858|   341k|#define P2P_OUI_TYPE 9
  ------------------
  |  Branch (99:3): [True: 341k, False: 169k]
  ------------------
  100|       |			/* Wi-Fi Alliance - P2P IE */
  101|   341k|			elems->p2p = pos;
  102|   341k|			elems->p2p_len = elen;
  103|   341k|			break;
  104|   159k|		case WFD_OUI_TYPE:
  ------------------
  |  | 1571|   159k|#define WFD_OUI_TYPE 10
  ------------------
  |  Branch (104:3): [True: 159k, False: 351k]
  ------------------
  105|       |			/* Wi-Fi Alliance - WFD IE */
  106|   159k|			elems->wfd = pos;
  107|   159k|			elems->wfd_len = elen;
  108|   159k|			break;
  109|    202|		case HS20_INDICATION_OUI_TYPE:
  ------------------
  |  | 1733|    202|#define HS20_INDICATION_OUI_TYPE 16
  ------------------
  |  Branch (109:3): [True: 202, False: 510k]
  ------------------
  110|       |			/* Hotspot 2.0 */
  111|    202|			elems->hs20 = pos;
  112|    202|			elems->hs20_len = elen;
  113|    202|			break;
  114|    217|		case MBO_OUI_TYPE:
  ------------------
  |  | 1579|    217|#define MBO_OUI_TYPE 22
  ------------------
  |  Branch (114:3): [True: 217, False: 510k]
  ------------------
  115|       |			/* MBO-OCE */
  116|    217|			elems->mbo = pos;
  117|    217|			elems->mbo_len = elen;
  118|    217|			break;
  119|    202|		case HS20_ROAMING_CONS_SEL_OUI_TYPE:
  ------------------
  |  | 1735|    202|#define HS20_ROAMING_CONS_SEL_OUI_TYPE 29
  ------------------
  |  Branch (119:3): [True: 202, False: 510k]
  ------------------
  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:
  ------------------
  |  | 1582|    202|#define MULTI_AP_OUI_TYPE 0x1B
  ------------------
  |  Branch (124:3): [True: 202, False: 510k]
  ------------------
  125|    202|			elems->multi_ap = pos;
  126|    202|			elems->multi_ap_len = elen;
  127|    202|			break;
  128|    239|		case OWE_OUI_TYPE:
  ------------------
  |  | 1581|    239|#define OWE_OUI_TYPE 28
  ------------------
  |  Branch (128:3): [True: 239, False: 510k]
  ------------------
  129|       |			/* OWE Transition Mode element */
  130|    239|			break;
  131|    202|		case DPP_CC_OUI_TYPE:
  ------------------
  |  | 1584|    202|#define DPP_CC_OUI_TYPE 0x1e
  ------------------
  |  Branch (131:3): [True: 202, False: 510k]
  ------------------
  132|       |			/* DPP Configurator Connectivity element */
  133|    202|			break;
  134|    260|		case SAE_PK_OUI_TYPE:
  ------------------
  |  | 1586|    260|#define SAE_PK_OUI_TYPE 0x1f
  ------------------
  |  Branch (134:3): [True: 260, False: 510k]
  ------------------
  135|    260|			elems->sae_pk = pos + 4;
  136|    260|			elems->sae_pk_len = elen - 4;
  137|    260|			break;
  138|    818|		case WFA_CAPA_OUI_TYPE:
  ------------------
  |  | 1590|    818|#define WFA_CAPA_OUI_TYPE 0x23
  ------------------
  |  Branch (138:3): [True: 818, False: 510k]
  ------------------
  139|    818|			elems->wfa_capab = pos + 4;
  140|    818|			elems->wfa_capab_len = elen - 4;
  141|    818|			break;
  142|    268|		case WFA_RSNE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1591|    268|#define WFA_RSNE_OVERRIDE_OUI_TYPE 0x29
  ------------------
  |  Branch (142:3): [True: 268, False: 510k]
  ------------------
  143|    268|			elems->rsne_override = pos;
  144|    268|			elems->rsne_override_len = elen;
  145|    268|			break;
  146|    245|		case WFA_RSNE_OVERRIDE_2_OUI_TYPE:
  ------------------
  |  | 1592|    245|#define WFA_RSNE_OVERRIDE_2_OUI_TYPE 0x2a
  ------------------
  |  Branch (146:3): [True: 245, False: 510k]
  ------------------
  147|    245|			elems->rsne_override_2 = pos;
  148|    245|			elems->rsne_override_2_len = elen;
  149|    245|			break;
  150|    225|		case WFA_RSNXE_OVERRIDE_OUI_TYPE:
  ------------------
  |  | 1593|    225|#define WFA_RSNXE_OVERRIDE_OUI_TYPE 0x2b
  ------------------
  |  Branch (150:3): [True: 225, False: 510k]
  ------------------
  151|    225|			elems->rsnxe_override = pos;
  152|    225|			elems->rsnxe_override_len = elen;
  153|    225|			break;
  154|    594|		case WFA_RSN_SELECTION_OUI_TYPE:
  ------------------
  |  | 1594|    594|#define WFA_RSN_SELECTION_OUI_TYPE 0x2c
  ------------------
  |  Branch (154:3): [True: 594, False: 510k]
  ------------------
  155|    594|			if (elen < 4 + 1) {
  ------------------
  |  Branch (155:8): [True: 290, False: 304]
  ------------------
  156|    290|				wpa_printf(MSG_DEBUG,
  157|    290|					   "Too short RSN Selection element ignored");
  158|    290|				return -1;
  159|    290|			}
  160|    304|			elems->rsn_selection = pos + 4;
  161|    304|			elems->rsn_selection_len = elen - 4;
  162|    304|			break;
  163|  3.85k|		case P2P2_OUI_TYPE:
  ------------------
  |  | 1859|  3.85k|#define P2P2_OUI_TYPE 0x28
  ------------------
  |  Branch (163:3): [True: 3.85k, False: 507k]
  ------------------
  164|       |			/* Wi-Fi Alliance - P2P2 IE */
  165|  3.85k|			elems->p2p2_ie = pos;
  166|  3.85k|			elems->p2p2_ie_len = elen;
  167|  3.85k|			break;
  168|    260|		case PR_OUI_TYPE:
  ------------------
  |  | 1601|    260|#define PR_OUI_TYPE 0x2e
  ------------------
  |  Branch (168:3): [True: 260, False: 510k]
  ------------------
  169|       |			/* Wi-Fi Alliance - Proximity Ranging element */
  170|    260|			elems->proximity_ranging = pos;
  171|    260|			elems->proximity_ranging_len = elen;
  172|    260|			break;
  173|    269|		case NAN_SDF_OUI_TYPE:
  ------------------
  |  | 1575|    269|#define NAN_SDF_OUI_TYPE 0x13
  ------------------
  |  Branch (173:3): [True: 269, False: 510k]
  ------------------
  174|       |			/* Wi-Fi Alliance - NAN IE */
  175|    269|			elems->nan_ie = pos;
  176|    269|			elems->nan_len = elen;
  177|    269|			break;
  178|  1.49k|		default:
  ------------------
  |  Branch (178:3): [True: 1.49k, False: 509k]
  ------------------
  179|  1.49k|			wpa_printf(MSG_MSGDUMP, "Unknown WFA "
  180|  1.49k|				   "information element ignored "
  181|  1.49k|				   "(type=%d len=%lu)",
  182|  1.49k|				   pos[3], (unsigned long) elen);
  183|  1.49k|			return -1;
  184|   511k|		}
  185|   509k|		break;
  186|       |
  187|   509k|	case OUI_BROADCOM:
  ------------------
  |  | 2065|  1.36k|#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
  ------------------
  |  Branch (187:2): [True: 1.36k, False: 1.08M]
  ------------------
  188|  1.36k|		switch (pos[3]) {
  189|    200|		case VENDOR_HT_CAPAB_OUI_TYPE:
  ------------------
  |  | 2070|    200|#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
  ------------------
  |  Branch (189:3): [True: 200, False: 1.16k]
  ------------------
  190|    200|			elems->vendor_ht_cap = pos;
  191|    200|			elems->vendor_ht_cap_len = elen;
  192|    200|			break;
  193|    942|		case VENDOR_VHT_TYPE:
  ------------------
  |  | 2066|    942|#define VENDOR_VHT_TYPE		0x04
  ------------------
  |  Branch (193:3): [True: 942, False: 420]
  ------------------
  194|    942|			if (elen > 4 &&
  ------------------
  |  Branch (194:8): [True: 733, False: 209]
  ------------------
  195|    733|			    (pos[4] == VENDOR_VHT_SUBTYPE ||
  ------------------
  |  | 2067|  1.46k|#define VENDOR_VHT_SUBTYPE	0x08
  ------------------
  |  Branch (195:9): [True: 208, False: 525]
  ------------------
  196|    525|			     pos[4] == VENDOR_VHT_SUBTYPE2)) {
  ------------------
  |  | 2068|    525|#define VENDOR_VHT_SUBTYPE2	0x00
  ------------------
  |  Branch (196:9): [True: 223, False: 302]
  ------------------
  197|    431|				elems->vendor_vht = pos;
  198|    431|				elems->vendor_vht_len = elen;
  199|    431|			} else
  200|    511|				return -1;
  201|    431|			break;
  202|    431|		default:
  ------------------
  |  Branch (202:3): [True: 220, False: 1.14k]
  ------------------
  203|    220|			wpa_printf(MSG_EXCESSIVE, "Unknown Broadcom "
  204|    220|				   "information element ignored "
  205|    220|				   "(type=%d len=%lu)",
  206|    220|				   pos[3], (unsigned long) elen);
  207|    220|			return -1;
  208|  1.36k|		}
  209|    631|		break;
  210|       |
  211|    631|	case OUI_QCA:
  ------------------
  |  |   21|    599|#define OUI_QCA 0x001374
  ------------------
  |  Branch (211:2): [True: 599, False: 1.08M]
  ------------------
  212|    599|		switch (pos[3]) {
  213|    237|		case QCA_VENDOR_ELEM_P2P_PREF_CHAN_LIST:
  ------------------
  |  Branch (213:3): [True: 237, False: 362]
  ------------------
  214|    237|			elems->pref_freq_list = pos;
  215|    237|			elems->pref_freq_list_len = elen;
  216|    237|			break;
  217|    362|		default:
  ------------------
  |  Branch (217:3): [True: 362, False: 237]
  ------------------
  218|    362|			wpa_printf(MSG_EXCESSIVE,
  219|    362|				   "Unknown QCA information element ignored (type=%d len=%lu)",
  220|    362|				   pos[3], (unsigned long) elen);
  221|    362|			return -1;
  222|    599|		}
  223|    237|		break;
  224|       |
  225|   154k|	default:
  ------------------
  |  Branch (225:2): [True: 154k, False: 928k]
  ------------------
  226|   154k|		wpa_printf(MSG_EXCESSIVE, "unknown vendor specific "
  227|   154k|			   "information element ignored (vendor OUI "
  228|   154k|			   "%02x:%02x:%02x len=%lu)",
  229|   154k|			   pos[0], pos[1], pos[2], (unsigned long) elen);
  230|   154k|		return -1;
  231|  1.08M|	}
  232|       |
  233|   921k|	return 0;
  234|  1.08M|}
ieee802_11_common.c:ieee802_11_parse_extension:
  304|  76.5k|{
  305|  76.5k|	u8 ext_id;
  306|  76.5k|	size_t *total_len = NULL;
  307|       |
  308|  76.5k|	if (elen < 1) {
  ------------------
  |  Branch (308:6): [True: 5.89k, False: 70.6k]
  ------------------
  309|  5.89k|		if (show_errors) {
  ------------------
  |  Branch (309:7): [True: 0, False: 5.89k]
  ------------------
  310|      0|			wpa_printf(MSG_MSGDUMP,
  311|      0|				   "short information element (Ext)");
  312|      0|		}
  313|  5.89k|		return -1;
  314|  5.89k|	}
  315|       |
  316|  70.6k|	ext_id = *pos++;
  317|  70.6k|	elen--;
  318|       |
  319|  70.6k|	switch (ext_id) {
  320|  1.61k|	case WLAN_EID_EXT_ASSOC_DELAY_INFO:
  ------------------
  |  |  508|  1.61k|#define WLAN_EID_EXT_ASSOC_DELAY_INFO 1
  ------------------
  |  Branch (320:2): [True: 1.61k, False: 69.0k]
  ------------------
  321|  1.61k|		if (elen != 1)
  ------------------
  |  Branch (321:7): [True: 1.29k, False: 316]
  ------------------
  322|  1.29k|			break;
  323|    316|		elems->assoc_delay_info = pos;
  324|    316|		break;
  325|  1.07k|	case WLAN_EID_EXT_FILS_REQ_PARAMS:
  ------------------
  |  |  509|  1.07k|#define WLAN_EID_EXT_FILS_REQ_PARAMS 2
  ------------------
  |  Branch (325:2): [True: 1.07k, False: 69.6k]
  ------------------
  326|  1.07k|		if (elen < 3)
  ------------------
  |  Branch (326:7): [True: 667, False: 407]
  ------------------
  327|    667|			break;
  328|    407|		elems->fils_req_params = pos;
  329|    407|		elems->fils_req_params_len = elen;
  330|    407|		break;
  331|  1.02k|	case WLAN_EID_EXT_FILS_KEY_CONFIRM:
  ------------------
  |  |  510|  1.02k|#define WLAN_EID_EXT_FILS_KEY_CONFIRM 3
  ------------------
  |  Branch (331:2): [True: 1.02k, False: 69.6k]
  ------------------
  332|  1.02k|		elems->fils_key_confirm = pos;
  333|  1.02k|		elems->fils_key_confirm_len = elen;
  334|  1.02k|		break;
  335|  1.04k|	case WLAN_EID_EXT_FILS_SESSION:
  ------------------
  |  |  511|  1.04k|#define WLAN_EID_EXT_FILS_SESSION 4
  ------------------
  |  Branch (335:2): [True: 1.04k, False: 69.6k]
  ------------------
  336|  1.04k|		if (elen != FILS_SESSION_LEN)
  ------------------
  |  | 1056|  1.04k|#define FILS_SESSION_LEN 8
  ------------------
  |  Branch (336:7): [True: 845, False: 204]
  ------------------
  337|    845|			break;
  338|    204|		elems->fils_session = pos;
  339|    204|		break;
  340|  1.41k|	case WLAN_EID_EXT_FILS_HLP_CONTAINER:
  ------------------
  |  |  512|  1.41k|#define WLAN_EID_EXT_FILS_HLP_CONTAINER 5
  ------------------
  |  Branch (340:2): [True: 1.41k, False: 69.2k]
  ------------------
  341|  1.41k|		if (elen < 2 * ETH_ALEN)
  ------------------
  |  |  344|  1.41k|#define ETH_ALEN 6
  ------------------
  |  Branch (341:7): [True: 643, False: 770]
  ------------------
  342|    643|			break;
  343|    770|		elems->fils_hlp = pos;
  344|    770|		elems->fils_hlp_len = elen;
  345|    770|		total_len = &elems->fils_hlp_len;
  346|    770|		break;
  347|  1.45k|	case WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN:
  ------------------
  |  |  513|  1.45k|#define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6
  ------------------
  |  Branch (347:2): [True: 1.45k, False: 69.2k]
  ------------------
  348|  1.45k|		if (elen < 1)
  ------------------
  |  Branch (348:7): [True: 416, False: 1.04k]
  ------------------
  349|    416|			break;
  350|  1.04k|		elems->fils_ip_addr_assign = pos;
  351|  1.04k|		elems->fils_ip_addr_assign_len = elen;
  352|  1.04k|		break;
  353|  2.06k|	case WLAN_EID_EXT_KEY_DELIVERY:
  ------------------
  |  |  514|  2.06k|#define WLAN_EID_EXT_KEY_DELIVERY 7
  ------------------
  |  Branch (353:2): [True: 2.06k, False: 68.6k]
  ------------------
  354|  2.06k|		if (elen < WPA_KEY_RSC_LEN)
  ------------------
  |  |   22|  2.06k|#define WPA_KEY_RSC_LEN 8
  ------------------
  |  Branch (354:7): [True: 263, False: 1.80k]
  ------------------
  355|    263|			break;
  356|  1.80k|		elems->key_delivery = pos;
  357|  1.80k|		elems->key_delivery_len = elen;
  358|  1.80k|		total_len = &elems->key_delivery_len;
  359|  1.80k|		break;
  360|    680|	case WLAN_EID_EXT_WRAPPED_DATA:
  ------------------
  |  |  515|    680|#define WLAN_EID_EXT_WRAPPED_DATA 8
  ------------------
  |  Branch (360:2): [True: 680, False: 70.0k]
  ------------------
  361|    680|		elems->wrapped_data = pos;
  362|    680|		elems->wrapped_data_len = elen;
  363|    680|		total_len = &elems->wrapped_data_len;
  364|    680|		break;
  365|    664|	case WLAN_EID_EXT_FILS_PUBLIC_KEY:
  ------------------
  |  |  519|    664|#define WLAN_EID_EXT_FILS_PUBLIC_KEY 12
  ------------------
  |  Branch (365:2): [True: 664, False: 70.0k]
  ------------------
  366|    664|		if (elen < 1)
  ------------------
  |  Branch (366:7): [True: 365, False: 299]
  ------------------
  367|    365|			break;
  368|    299|		elems->fils_pk = pos;
  369|    299|		elems->fils_pk_len = elen;
  370|    299|		break;
  371|    727|	case WLAN_EID_EXT_NONCE:
  ------------------
  |  |  520|    727|#define WLAN_EID_EXT_NONCE 13
  ------------------
  |  Branch (371:2): [True: 727, False: 69.9k]
  ------------------
  372|    727|		if (elen < NONCE_LEN)
  ------------------
  |  | 1055|    727|#define NONCE_LEN 16
  ------------------
  |  Branch (372:7): [True: 379, False: 348]
  ------------------
  373|    379|			break;
  374|    348|		elems->nonce = pos;
  375|    348|		elems->nonce_len = elen;
  376|    348|		break;
  377|    471|	case WLAN_EID_EXT_OWE_DH_PARAM:
  ------------------
  |  |  522|    471|#define WLAN_EID_EXT_OWE_DH_PARAM 32
  ------------------
  |  Branch (377:2): [True: 471, False: 70.2k]
  ------------------
  378|    471|		if (elen < 2)
  ------------------
  |  Branch (378:7): [True: 213, False: 258]
  ------------------
  379|    213|			break;
  380|    258|		elems->owe_dh = pos;
  381|    258|		elems->owe_dh_len = elen;
  382|    258|		break;
  383|    301|	case WLAN_EID_EXT_PASSWORD_IDENTIFIER:
  ------------------
  |  |  523|    301|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (383:2): [True: 301, False: 70.3k]
  ------------------
  384|    301|		elems->password_id = pos;
  385|    301|		elems->password_id_len = elen;
  386|    301|		break;
  387|  1.02k|	case WLAN_EID_EXT_HE_CAPABILITIES:
  ------------------
  |  |  524|  1.02k|#define WLAN_EID_EXT_HE_CAPABILITIES 35
  ------------------
  |  Branch (387:2): [True: 1.02k, False: 69.6k]
  ------------------
  388|  1.02k|		if (elen < HE_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2638|  1.02k|#define HE_CAPABILITIES_ELEM_MIN_LEN		21
  ------------------
  |  Branch (388:7): [True: 464, False: 565]
  ------------------
  389|    464|			break;
  390|    565|		elems->he_capabilities = pos;
  391|    565|		elems->he_capabilities_len = elen;
  392|    565|		break;
  393|    438|	case WLAN_EID_EXT_HE_OPERATION:
  ------------------
  |  |  525|    438|#define WLAN_EID_EXT_HE_OPERATION 36
  ------------------
  |  Branch (393:2): [True: 438, False: 70.2k]
  ------------------
  394|    438|		if (elen < HE_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2692|    438|#define HE_OPERATION_ELEM_MIN_LEN				6
  ------------------
  |  Branch (394:7): [True: 212, False: 226]
  ------------------
  395|    212|			break;
  396|    226|		elems->he_operation = pos;
  397|    226|		elems->he_operation_len = elen;
  398|    226|		break;
  399|    226|	case WLAN_EID_EXT_OCV_OCI:
  ------------------
  |  |  530|    226|#define WLAN_EID_EXT_OCV_OCI 54
  ------------------
  |  Branch (399:2): [True: 226, False: 70.4k]
  ------------------
  400|    226|		elems->oci = pos;
  401|    226|		elems->oci_len = elen;
  402|    226|		break;
  403|    515|	case WLAN_EID_EXT_SHORT_SSID_LIST:
  ------------------
  |  |  534|    515|#define WLAN_EID_EXT_SHORT_SSID_LIST 58
  ------------------
  |  Branch (403:2): [True: 515, False: 70.1k]
  ------------------
  404|    515|		elems->short_ssid_list = pos;
  405|    515|		elems->short_ssid_list_len = elen;
  406|    515|		break;
  407|    652|	case WLAN_EID_EXT_HE_6GHZ_BAND_CAP:
  ------------------
  |  |  535|    652|#define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59
  ------------------
  |  Branch (407:2): [True: 652, False: 70.0k]
  ------------------
  408|    652|		if (elen < sizeof(struct ieee80211_he_6ghz_band_cap))
  ------------------
  |  Branch (408:7): [True: 423, False: 229]
  ------------------
  409|    423|			break;
  410|    229|		elems->he_6ghz_band_cap = pos;
  411|    229|		break;
  412|    322|	case WLAN_EID_EXT_PASN_PARAMS:
  ------------------
  |  |  542|    322|#define WLAN_EID_EXT_PASN_PARAMS 100
  ------------------
  |  Branch (412:2): [True: 322, False: 70.3k]
  ------------------
  413|    322|		elems->pasn_params = pos;
  414|    322|		elems->pasn_params_len = elen;
  415|    322|		break;
  416|  2.92k|	case WLAN_EID_EXT_EHT_CAPABILITIES:
  ------------------
  |  |  545|  2.92k|#define WLAN_EID_EXT_EHT_CAPABILITIES 108
  ------------------
  |  Branch (416:2): [True: 2.92k, False: 67.7k]
  ------------------
  417|  2.92k|		if (elen < EHT_CAPABILITIES_ELEM_MIN_LEN)
  ------------------
  |  | 2839|  2.92k|#define EHT_CAPABILITIES_ELEM_MIN_LEN             11
  ------------------
  |  Branch (417:7): [True: 2.70k, False: 220]
  ------------------
  418|  2.70k|			break;
  419|    220|		elems->eht_capabilities = pos;
  420|    220|		elems->eht_capabilities_len = elen;
  421|    220|		break;
  422|  2.75k|	case WLAN_EID_EXT_EHT_OPERATION:
  ------------------
  |  |  543|  2.75k|#define WLAN_EID_EXT_EHT_OPERATION 106
  ------------------
  |  Branch (422:2): [True: 2.75k, False: 67.9k]
  ------------------
  423|  2.75k|		if (elen < EHT_OPERATION_ELEM_MIN_LEN)
  ------------------
  |  | 2801|  2.75k|#define EHT_OPERATION_ELEM_MIN_LEN                       5
  ------------------
  |  Branch (423:7): [True: 2.34k, False: 413]
  ------------------
  424|  2.34k|			break;
  425|    413|		elems->eht_operation = pos;
  426|    413|		elems->eht_operation_len = elen;
  427|    413|		break;
  428|  3.67k|	case WLAN_EID_EXT_MULTI_LINK:
  ------------------
  |  |  544|  3.67k|#define WLAN_EID_EXT_MULTI_LINK 107
  ------------------
  |  Branch (428:2): [True: 3.67k, False: 67.0k]
  ------------------
  429|  3.67k|		if (elen < 2)
  ------------------
  |  Branch (429:7): [True: 356, False: 3.31k]
  ------------------
  430|    356|			break;
  431|  3.31k|		if (ieee802_11_parse_mle(pos, elen, &total_len, elems,
  ------------------
  |  Branch (431:7): [True: 243, False: 3.07k]
  ------------------
  432|  3.31k|					 show_errors))
  433|    243|			return -1;
  434|  3.07k|		break;
  435|  3.07k|	case WLAN_EID_EXT_KNOWN_BSSID:
  ------------------
  |  |  533|    207|#define WLAN_EID_EXT_KNOWN_BSSID 57
  ------------------
  |  Branch (435:2): [True: 207, False: 70.4k]
  ------------------
  436|    207|		elems->mbssid_known_bss = pos;
  437|    207|		elems->mbssid_known_bss_len = elen;
  438|    207|		break;
  439|    205|	case WLAN_EID_EXT_PASN_ENCRYPTED_DATA:
  ------------------
  |  |  552|    205|#define WLAN_EID_EXT_PASN_ENCRYPTED_DATA 140
  ------------------
  |  Branch (439:2): [True: 205, False: 70.4k]
  ------------------
  440|    205|		elems->pasn_encrypted_data = pos;
  441|    205|		elems->pasn_encrypted_data_len = elen;
  442|    205|		break;
  443|    482|	case WLAN_EID_EXT_AKM_SUITE_SELECTOR:
  ------------------
  |  |  549|    482|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (443:2): [True: 482, False: 70.2k]
  ------------------
  444|    482|		if (elen < RSN_SELECTOR_LEN)
  ------------------
  |  |   63|    482|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (444:7): [True: 235, False: 247]
  ------------------
  445|    235|			break;
  446|    247|		elems->akm_suite_selector = pos;
  447|    247|		elems->akm_suite_selector_len = elen;
  448|    247|		break;
  449|    678|	case WLAN_EID_EXT_SUPPORTED_GROUPS:
  ------------------
  |  |  562|    678|#define WLAN_EID_EXT_SUPPORTED_GROUPS 161
  ------------------
  |  Branch (449:2): [True: 678, False: 70.0k]
  ------------------
  450|    678|		if (elen < 2 || elen % 2 != 0)
  ------------------
  |  Branch (450:7): [True: 206, False: 472]
  |  Branch (450:19): [True: 258, False: 214]
  ------------------
  451|    464|			break;
  452|    214|		elems->supported_groups = pos;
  453|    214|		elems->supported_groups_len = elen;
  454|    214|		break;
  455|    200|	case WLAN_EID_EXT_UHR_CAPABILITIES:
  ------------------
  |  |  554|    200|#define WLAN_EID_EXT_UHR_CAPABILITIES 152
  ------------------
  |  Branch (455:2): [True: 200, False: 70.4k]
  ------------------
  456|    200|		elems->uhr_capabilities = pos;
  457|    200|		elems->uhr_capabilities_len = elen;
  458|    200|		break;
  459|    203|	case WLAN_EID_EXT_UHR_OPERATION:
  ------------------
  |  |  553|    203|#define WLAN_EID_EXT_UHR_OPERATION 151
  ------------------
  |  Branch (459:2): [True: 203, False: 70.4k]
  ------------------
  460|    203|		elems->uhr_operation = pos;
  461|    203|		elems->uhr_operation_len = elen;
  462|    203|		break;
  463|    436|	case WLAN_EID_EXT_SECURITY_PROFILE:
  ------------------
  |  |  563|    436|#define WLAN_EID_EXT_SECURITY_PROFILE 162
  ------------------
  |  Branch (463:2): [True: 436, False: 70.2k]
  ------------------
  464|    436|		if (elen < 2)
  ------------------
  |  Branch (464:7): [True: 206, False: 230]
  ------------------
  465|    206|			break;
  466|    230|		elems->security_profile = pos;
  467|    230|		elems->security_profile_len = elen;
  468|    230|		break;
  469|  43.2k|	default:
  ------------------
  |  Branch (469:2): [True: 43.2k, False: 27.4k]
  ------------------
  470|  43.2k|		if (show_errors) {
  ------------------
  |  Branch (470:7): [True: 0, False: 43.2k]
  ------------------
  471|      0|			wpa_printf(MSG_MSGDUMP,
  472|      0|				   "IEEE 802.11 element parsing ignored unknown element extension (ext_id=%u elen=%u)",
  473|      0|				   ext_id, (unsigned int) elen);
  474|      0|		}
  475|  43.2k|		return -1;
  476|  70.6k|	}
  477|       |
  478|  27.2k|	if (elen == 254 && total_len)
  ------------------
  |  Branch (478:6): [True: 1.78k, False: 25.4k]
  |  Branch (478:21): [True: 976, False: 806]
  ------------------
  479|    976|		*total_len += ieee802_11_fragments_length(
  480|    976|			elems, pos + elen, (start + len) - (pos + elen));
  481|       |
  482|  27.2k|	return 0;
  483|  70.6k|}
ieee802_11_common.c:ieee802_11_parse_mle:
  240|  3.31k|{
  241|  3.31k|	u8 mle_type = pos[0] & MULTI_LINK_CONTROL_TYPE_MASK;
  ------------------
  |  | 2916|  3.31k|#define MULTI_LINK_CONTROL_TYPE_MASK			0x07
  ------------------
  242|       |
  243|  3.31k|	switch (mle_type) {
  244|    301|	case MULTI_LINK_CONTROL_TYPE_BASIC:
  ------------------
  |  | 2920|    301|#define MULTI_LINK_CONTROL_TYPE_BASIC			0
  ------------------
  |  Branch (244:2): [True: 301, False: 3.01k]
  ------------------
  245|    301|		elems->basic_mle = pos;
  246|    301|		elems->basic_mle_len = elen;
  247|    301|		*total_len = &elems->basic_mle_len;
  248|    301|		break;
  249|  1.62k|	case MULTI_LINK_CONTROL_TYPE_PROBE_REQ:
  ------------------
  |  | 2921|  1.62k|#define MULTI_LINK_CONTROL_TYPE_PROBE_REQ		1
  ------------------
  |  Branch (249:2): [True: 1.62k, False: 1.68k]
  ------------------
  250|  1.62k|		elems->probe_req_mle = pos;
  251|  1.62k|		elems->probe_req_mle_len = elen;
  252|  1.62k|		*total_len = &elems->probe_req_mle_len;
  253|  1.62k|		break;
  254|    253|	case MULTI_LINK_CONTROL_TYPE_RECONF:
  ------------------
  |  | 2922|    253|#define MULTI_LINK_CONTROL_TYPE_RECONF			2
  ------------------
  |  Branch (254:2): [True: 253, False: 3.06k]
  ------------------
  255|    253|		elems->reconf_mle = pos;
  256|    253|		elems->reconf_mle_len = elen;
  257|    253|		*total_len = &elems->reconf_mle_len;
  258|    253|		break;
  259|    261|	case MULTI_LINK_CONTROL_TYPE_TDLS:
  ------------------
  |  | 2923|    261|#define MULTI_LINK_CONTROL_TYPE_TDLS			3
  ------------------
  |  Branch (259:2): [True: 261, False: 3.05k]
  ------------------
  260|    261|		elems->tdls_mle = pos;
  261|    261|		elems->tdls_mle_len = elen;
  262|    261|		*total_len = &elems->tdls_mle_len;
  263|    261|		break;
  264|    628|	case MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS:
  ------------------
  |  | 2924|    628|#define MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS		4
  ------------------
  |  Branch (264:2): [True: 628, False: 2.68k]
  ------------------
  265|    628|		elems->prior_access_mle = pos;
  266|    628|		elems->prior_access_mle_len = elen;
  267|    628|		*total_len = &elems->prior_access_mle_len;
  268|    628|		break;
  269|    243|	default:
  ------------------
  |  Branch (269:2): [True: 243, False: 3.07k]
  ------------------
  270|    243|		if (show_errors) {
  ------------------
  |  Branch (270:7): [True: 0, False: 243]
  ------------------
  271|      0|			wpa_printf(MSG_MSGDUMP,
  272|      0|				   "Unknown Multi-Link element type %u",
  273|      0|				   mle_type);
  274|      0|		}
  275|    243|		return -1;
  276|  3.31k|	}
  277|       |
  278|  3.07k|	return 0;
  279|  3.31k|}
ieee802_11_common.c:ieee802_11_fragments_length:
  284|  3.00k|{
  285|  3.00k|	const struct element *elem;
  286|  3.00k|	size_t frags_len = 0;
  287|       |
  288|   540k|	for_each_element(elem, start, len) {
  ------------------
  |  |  358|  3.00k|	for (_elem = (const struct element *) (_data);			\
  |  |  359|   540k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (359:7): [True: 540k, False: 90]
  |  |  ------------------
  |  |  360|   540k|		(int) sizeof(*_elem) &&					\
  |  |  361|   540k|	     (const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=	\
  |  |  ------------------
  |  |  |  Branch (361:7): [True: 540k, False: 54]
  |  |  ------------------
  |  |  362|   540k|		(int) sizeof(*_elem) + _elem->datalen;			\
  |  |  363|   537k|	     _elem = (const struct element *) (_elem->data + _elem->datalen))
  ------------------
  289|   540k|		if (elem->id != WLAN_EID_FRAGMENT)
  ------------------
  |  |  503|   540k|#define WLAN_EID_FRAGMENT 242
  ------------------
  |  Branch (289:7): [True: 2.85k, False: 537k]
  ------------------
  290|  2.85k|			break;
  291|       |
  292|   537k|		frags_len += elem->datalen + 2;
  293|   537k|		elems->num_frag_elems++;
  294|   537k|	}
  295|       |
  296|  3.00k|	return frags_len;
  297|  3.00k|}
ieee802_11_common.c:country_match:
 1840|  2.44k|{
 1841|  2.44k|	int i;
 1842|       |
 1843|  2.44k|	if (country == NULL)
  ------------------
  |  Branch (1843:6): [True: 2.44k, False: 0]
  ------------------
 1844|  2.44k|		return 0;
 1845|      0|	for (i = 0; cc[i]; i++) {
  ------------------
  |  Branch (1845:14): [True: 0, False: 0]
  ------------------
 1846|      0|		if (cc[i][0] == country[0] && cc[i][1] == country[1])
  ------------------
  |  Branch (1846:7): [True: 0, False: 0]
  |  Branch (1846:33): [True: 0, False: 0]
  ------------------
 1847|      0|			return 1;
 1848|      0|	}
 1849|       |
 1850|      0|	return 0;
 1851|      0|}
ieee802_11_common.c:ieee80211_chan_to_freq_global:
 2048|    611|{
 2049|       |	/* Table E-4 in IEEE Std 802.11-2020 - Global operating classes */
 2050|    611|	switch (op_class) {
 2051|     42|	case 81:
  ------------------
  |  Branch (2051:2): [True: 42, False: 569]
  ------------------
 2052|       |		/* channels 1..13 */
 2053|     42|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2053:7): [True: 3, False: 39]
  |  Branch (2053:19): [True: 7, False: 32]
  ------------------
 2054|     10|			return -1;
 2055|     32|		return 2407 + 5 * chan;
 2056|     14|	case 82:
  ------------------
  |  Branch (2056:2): [True: 14, False: 597]
  ------------------
 2057|       |		/* channel 14 */
 2058|     14|		if (chan != 14)
  ------------------
  |  Branch (2058:7): [True: 11, False: 3]
  ------------------
 2059|     11|			return -1;
 2060|      3|		return 2414 + 5 * chan;
 2061|      9|	case 83: /* channels 1..9; 40 MHz */
  ------------------
  |  Branch (2061:2): [True: 9, False: 602]
  ------------------
 2062|     22|	case 84: /* channels 5..13; 40 MHz */
  ------------------
  |  Branch (2062:2): [True: 13, False: 598]
  ------------------
 2063|     22|		if (chan < 1 || chan > 13)
  ------------------
  |  Branch (2063:7): [True: 3, False: 19]
  |  Branch (2063:19): [True: 11, False: 8]
  ------------------
 2064|     14|			return -1;
 2065|      8|		return 2407 + 5 * chan;
 2066|      6|	case 115: /* channels 36,40,44,48; indoor only */
  ------------------
  |  Branch (2066:2): [True: 6, False: 605]
  ------------------
 2067|     16|	case 116: /* channels 36,44; 40 MHz; indoor only */
  ------------------
  |  Branch (2067:2): [True: 10, False: 601]
  ------------------
 2068|     20|	case 117: /* channels 40,48; 40 MHz; indoor only */
  ------------------
  |  Branch (2068:2): [True: 4, False: 607]
  ------------------
 2069|     25|	case 118: /* channels 52,56,60,64; dfs */
  ------------------
  |  Branch (2069:2): [True: 5, False: 606]
  ------------------
 2070|     29|	case 119: /* channels 52,60; 40 MHz; dfs */
  ------------------
  |  Branch (2070:2): [True: 4, False: 607]
  ------------------
 2071|     36|	case 120: /* channels 56,64; 40 MHz; dfs */
  ------------------
  |  Branch (2071:2): [True: 7, False: 604]
  ------------------
 2072|     36|		if (chan < 36 || chan > 64)
  ------------------
  |  Branch (2072:7): [True: 9, False: 27]
  |  Branch (2072:20): [True: 14, False: 13]
  ------------------
 2073|     23|			return -1;
 2074|     13|		return 5000 + 5 * chan;
 2075|     11|	case 121: /* channels 100-144 */
  ------------------
  |  Branch (2075:2): [True: 11, False: 600]
  ------------------
 2076|     22|	case 122: /* channels 100-140; 40 MHz */
  ------------------
  |  Branch (2076:2): [True: 11, False: 600]
  ------------------
 2077|     30|	case 123: /* channels 104-144; 40 MHz */
  ------------------
  |  Branch (2077:2): [True: 8, False: 603]
  ------------------
 2078|     30|		if (chan < 100 || chan > 144)
  ------------------
  |  Branch (2078:7): [True: 9, False: 21]
  |  Branch (2078:21): [True: 5, False: 16]
  ------------------
 2079|     14|			return -1;
 2080|     16|		return 5000 + 5 * chan;
 2081|     25|	case 124: /* channels 149,153,157,161 */
  ------------------
  |  Branch (2081:2): [True: 25, False: 586]
  ------------------
 2082|     25|		if (chan < 149 || chan > 161)
  ------------------
  |  Branch (2082:7): [True: 12, False: 13]
  |  Branch (2082:21): [True: 5, False: 8]
  ------------------
 2083|     17|			return -1;
 2084|      8|		return 5000 + 5 * chan;
 2085|      7|	case 125: /* channels 149,153,157,161,165,169,173,177 */
  ------------------
  |  Branch (2085:2): [True: 7, False: 604]
  ------------------
 2086|     20|	case 126: /* channels 149,157,165,173; 40 MHz */
  ------------------
  |  Branch (2086:2): [True: 13, False: 598]
  ------------------
 2087|     33|	case 127: /* channels 153,161,169,177; 40 MHz */
  ------------------
  |  Branch (2087:2): [True: 13, False: 598]
  ------------------
 2088|     33|		if (chan < 149 || chan > 177)
  ------------------
  |  Branch (2088:7): [True: 12, False: 21]
  |  Branch (2088:21): [True: 8, False: 13]
  ------------------
 2089|     20|			return -1;
 2090|     13|		return 5000 + 5 * chan;
 2091|     17|	case 128: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2091:2): [True: 17, False: 594]
  ------------------
 2092|     32|	case 130: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */
  ------------------
  |  Branch (2092:2): [True: 15, False: 596]
  ------------------
 2093|     32|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2093:7): [True: 10, False: 22]
  |  Branch (2093:20): [True: 4, False: 18]
  ------------------
 2094|     14|			return -1;
 2095|     18|		return 5000 + 5 * chan;
 2096|     34|	case 129: /* center freqs 50, 114, 163; 160 MHz */
  ------------------
  |  Branch (2096:2): [True: 34, False: 577]
  ------------------
 2097|     34|		if (chan < 36 || chan > 177)
  ------------------
  |  Branch (2097:7): [True: 8, False: 26]
  |  Branch (2097:20): [True: 6, False: 20]
  ------------------
 2098|     14|			return -1;
 2099|     20|		return 5000 + 5 * chan;
 2100|      8|	case 131: /* UHB channels, 20 MHz: 1, 5, 9.. */
  ------------------
  |  Branch (2100:2): [True: 8, False: 603]
  ------------------
 2101|     15|	case 132: /* UHB channels, 40 MHz: 3, 11, 19.. */
  ------------------
  |  Branch (2101:2): [True: 7, False: 604]
  ------------------
 2102|     23|	case 133: /* UHB channels, 80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2102:2): [True: 8, False: 603]
  ------------------
 2103|     31|	case 134: /* UHB channels, 160 MHz: 15, 47, 79.. */
  ------------------
  |  Branch (2103:2): [True: 8, False: 603]
  ------------------
 2104|     38|	case 135: /* UHB channels, 80+80 MHz: 7, 23, 39.. */
  ------------------
  |  Branch (2104:2): [True: 7, False: 604]
  ------------------
 2105|     50|	case 137: /* UHB channels, 320 MHz: 31, 63, 95, 127, 159, 191 */
  ------------------
  |  Branch (2105:2): [True: 12, False: 599]
  ------------------
 2106|     50|		if (chan < 1 || chan > 233)
  ------------------
  |  Branch (2106:7): [True: 8, False: 42]
  |  Branch (2106:19): [True: 6, False: 36]
  ------------------
 2107|     14|			return -1;
 2108|     36|		return 5950 + chan * 5;
 2109|     14|	case 136: /* UHB channels, 20 MHz: 2 */
  ------------------
  |  Branch (2109:2): [True: 14, False: 597]
  ------------------
 2110|     14|		if (chan == 2)
  ------------------
  |  Branch (2110:7): [True: 3, False: 11]
  ------------------
 2111|      3|			return 5935;
 2112|     11|		return -1;
 2113|     22|	case 180: /* 60 GHz band, channels 1..8 */
  ------------------
  |  Branch (2113:2): [True: 22, False: 589]
  ------------------
 2114|     22|		if (chan < 1 || chan > 8)
  ------------------
  |  Branch (2114:7): [True: 3, False: 19]
  |  Branch (2114:19): [True: 9, False: 10]
  ------------------
 2115|     12|			return -1;
 2116|     10|		return 56160 + 2160 * chan;
 2117|     23|	case 181: /* 60 GHz band, EDMG CB2, channels 9..15 */
  ------------------
  |  Branch (2117:2): [True: 23, False: 588]
  ------------------
 2118|     23|		if (chan < 9 || chan > 15)
  ------------------
  |  Branch (2118:7): [True: 5, False: 18]
  |  Branch (2118:19): [True: 9, False: 9]
  ------------------
 2119|     14|			return -1;
 2120|      9|		return 56160 + 2160 * (chan - 8);
 2121|     31|	case 182: /* 60 GHz band, EDMG CB3, channels 17..22 */
  ------------------
  |  Branch (2121:2): [True: 31, False: 580]
  ------------------
 2122|     31|		if (chan < 17 || chan > 22)
  ------------------
  |  Branch (2122:7): [True: 7, False: 24]
  |  Branch (2122:20): [True: 18, False: 6]
  ------------------
 2123|     25|			return -1;
 2124|      6|		return 56160 + 2160 * (chan - 16);
 2125|     19|	case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */
  ------------------
  |  Branch (2125:2): [True: 19, False: 592]
  ------------------
 2126|     19|		if (chan < 25 || chan > 29)
  ------------------
  |  Branch (2126:7): [True: 7, False: 12]
  |  Branch (2126:20): [True: 6, False: 6]
  ------------------
 2127|     13|			return -1;
 2128|      6|		return 56160 + 2160 * (chan - 24);
 2129|    184|	default:
  ------------------
  |  Branch (2129:2): [True: 184, False: 427]
  ------------------
 2130|    184|		return -1;
 2131|    611|	}
 2132|    611|}

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

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

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

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

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

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

p2p_process_invitation_req:
  230|    916|{
  231|    916|	struct p2p_device *dev;
  232|    916|	struct p2p_message msg;
  233|    916|	struct wpabuf *resp = NULL;
  234|    916|	u8 status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  235|    916|	int go = 0;
  236|    916|	u8 group_bssid[ETH_ALEN], *bssid;
  237|    916|	int op_freq = 0;
  238|    916|	u8 reg_class = 0, channel = 0;
  239|    916|	const u8 *new_ssid = NULL;
  240|    916|	size_t new_ssid_len = 0;
  241|    916|	struct p2p_channels all_channels, intersection, *channels = NULL;
  242|    916|	int persistent;
  243|       |
  244|    916|	os_memset(group_bssid, 0, sizeof(group_bssid));
  ------------------
  |  |  529|    916|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  245|       |
  246|    916|	p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
  247|    916|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|    916|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  248|       |
  249|    916|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (249:6): [True: 120, False: 796]
  ------------------
  250|    120|		return NULL;
  251|       |
  252|    796|	dev = p2p_get_device(p2p, sa);
  253|    796|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|    185|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|    185|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (253:6): [True: 611, False: 185]
  |  Branch (253:21): [True: 6, False: 179]
  ------------------
  254|    617|		p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
  ------------------
  |  |  448|    617|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  255|    617|			MAC2STR(sa));
  ------------------
  |  |  447|    617|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  256|       |
  257|    617|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
  ------------------
  |  Branch (257:7): [True: 427, False: 190]
  ------------------
  258|    617|				   0)) {
  259|    427|			p2p_dbg(p2p, "Invitation Request add device failed "
  260|    427|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    427|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    427|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  261|    427|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  262|    427|			goto fail;
  263|    427|		}
  264|       |
  265|    190|		dev = p2p_get_device(p2p, sa);
  266|    190|		if (dev == NULL) {
  ------------------
  |  Branch (266:7): [True: 183, False: 7]
  ------------------
  267|    183|			p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
  268|    183|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    183|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    183|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  269|    183|			status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
  270|    183|			goto fail;
  271|    183|		}
  272|    190|	}
  273|       |
  274|    186|	if (!msg.group_id || !msg.channel_list) {
  ------------------
  |  Branch (274:6): [True: 6, False: 180]
  |  Branch (274:23): [True: 2, False: 178]
  ------------------
  275|      8|		p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
  276|      8|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      8|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      8|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  277|      8|		status = P2P_SC_FAIL_INVALID_PARAMS;
  278|      8|		goto fail;
  279|      8|	}
  280|       |
  281|    178|	if (msg.invitation_flags)
  ------------------
  |  Branch (281:6): [True: 3, False: 175]
  ------------------
  282|      3|		persistent = *msg.invitation_flags & P2P_INVITATION_FLAGS_TYPE;
  ------------------
  |  | 1956|      3|#define P2P_INVITATION_FLAGS_TYPE BIT(0)
  |  |  ------------------
  |  |  |  |  458|      3|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  283|    175|	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|    175|		p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
  290|    175|		persistent = 1;
  291|    175|	}
  292|       |
  293|    178|	p2p_channels_union(&p2p->cfg->channels, &p2p->cfg->cli_channels,
  294|    178|			   &all_channels);
  295|       |
  296|    178|	if (p2p_peer_channels_check(p2p, &all_channels, dev,
  ------------------
  |  Branch (296:6): [True: 48, False: 130]
  ------------------
  297|    178|				    msg.channel_list, msg.channel_list_len) <
  298|    178|	    0) {
  299|     48|		p2p_dbg(p2p, "No common channels found");
  300|     48|		status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  301|     48|		goto fail;
  302|     48|	}
  303|       |
  304|    130|	p2p_channels_dump(p2p, "own channels", &p2p->cfg->channels);
  305|    130|	p2p_channels_dump(p2p, "own client channels", &all_channels);
  306|    130|	p2p_channels_dump(p2p, "peer channels", &dev->channels);
  307|    130|	p2p_channels_intersect(&all_channels, &dev->channels,
  308|    130|			       &intersection);
  309|    130|	p2p_channels_dump(p2p, "intersection", &intersection);
  310|       |
  311|    130|	if (p2p->cfg->invitation_process) {
  ------------------
  |  Branch (311:6): [True: 0, False: 130]
  ------------------
  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|    130|	if (go) {
  ------------------
  |  Branch (320:6): [True: 0, False: 130]
  ------------------
  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|    130|	if (op_freq) {
  ------------------
  |  Branch (331:6): [True: 0, False: 130]
  ------------------
  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|    130|	} else {
  352|    130|		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|    130|		p2p->op_reg_class = p2p->cfg->op_reg_class;
  356|    130|		p2p->op_channel = p2p->cfg->op_channel;
  357|    130|		p2p_dbg(p2p, "Own default op_class %d channel %d",
  358|    130|			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|    130|		if (msg.operating_channel) {
  ------------------
  |  Branch (372:7): [True: 79, False: 51]
  ------------------
  373|     79|			int req_freq;
  374|     79|			req_freq = p2p_channel_to_freq(
  375|     79|				msg.operating_channel[3],
  376|     79|				msg.operating_channel[4]);
  377|     79|			p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
  378|     79|				req_freq);
  379|     79|			if (req_freq > 0 &&
  ------------------
  |  Branch (379:8): [True: 45, False: 34]
  ------------------
  380|     45|			    p2p_channels_includes(&intersection,
  ------------------
  |  Branch (380:8): [True: 4, False: 41]
  ------------------
  381|     45|						  msg.operating_channel[3],
  382|     45|						  msg.operating_channel[4])) {
  383|      4|				p2p->op_reg_class = msg.operating_channel[3];
  384|      4|				p2p->op_channel = msg.operating_channel[4];
  385|      4|				p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
  386|      4|					p2p->op_reg_class, p2p->op_channel);
  387|     75|			} else {
  388|     75|				p2p_dbg(p2p, "Cannot use peer channel preference");
  389|     75|			}
  390|     79|		}
  391|       |
  392|       |		/* Reselect the channel only for the case of the GO */
  393|    130|		if (go &&
  ------------------
  |  Branch (393:7): [True: 0, False: 130]
  ------------------
  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|    130|		} 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: 130]
  |  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|    130|		p2p_check_pref_chan(p2p, go, dev, &msg);
  421|       |
  422|    130|		op_freq = p2p_channel_to_freq(p2p->op_reg_class,
  423|    130|					      p2p->op_channel);
  424|    130|		if (op_freq < 0) {
  ------------------
  |  Branch (424:7): [True: 126, False: 4]
  ------------------
  425|    126|			p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
  426|    126|				p2p->cfg->country[0], p2p->cfg->country[1],
  427|    126|				p2p->op_reg_class, p2p->op_channel);
  428|    126|			status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
  429|    126|			goto fail;
  430|    126|		}
  431|      4|		p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
  432|       |
  433|      4|		if (status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (433:7): [True: 0, False: 4]
  ------------------
  434|      0|			reg_class = p2p->op_reg_class;
  435|      0|			channel = p2p->op_channel;
  436|      0|			channels = &intersection;
  437|      0|		}
  438|      4|	}
  439|       |
  440|    796|fail:
  441|    796|	if (go && status == P2P_SC_SUCCESS && !is_zero_ether_addr(group_bssid))
  ------------------
  |  Branch (441:6): [True: 0, False: 796]
  |  Branch (441:12): [True: 0, False: 0]
  |  Branch (441:40): [True: 0, False: 0]
  ------------------
  442|      0|		bssid = group_bssid;
  443|    796|	else
  444|    796|		bssid = NULL;
  445|    796|	resp = p2p_build_invitation_resp(p2p, dev, msg.dialog_token, status,
  446|    796|					 bssid, reg_class, channel, channels,
  447|    796|					 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|    796|	os_memcpy(p2p->inv_sa, sa, ETH_ALEN);
  ------------------
  |  |  523|    796|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  454|    796|	if (msg.group_bssid) {
  ------------------
  |  Branch (454:6): [True: 4, False: 792]
  ------------------
  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|    792|		p2p->inv_group_bssid_ptr = NULL;
  459|       |
  460|    796|	if (p2p2 && new_ssid_len) {
  ------------------
  |  Branch (460:6): [True: 0, False: 796]
  |  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|    796|	} else if (msg.group_id) {
  ------------------
  |  Branch (464:13): [True: 204, False: 592]
  ------------------
  465|    204|		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  344|    204|#define ETH_ALEN 6
  ------------------
              		if (msg.group_id_len - ETH_ALEN <= SSID_MAX_LEN) {
  ------------------
  |  |  511|    204|#define SSID_MAX_LEN 32
  ------------------
  |  Branch (465:7): [True: 204, False: 0]
  ------------------
  466|    204|			os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN,
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  467|    204|				  msg.group_id_len - ETH_ALEN);
  468|    204|			p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|    204|#define ETH_ALEN 6
  ------------------
  469|    204|		}
  470|    204|		os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN);
  ------------------
  |  |  523|    204|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  471|    592|	} else {
  472|    592|		p2p->inv_ssid_len = 0;
  473|    592|		os_memset(p2p->inv_go_dev_addr, 0, ETH_ALEN);
  ------------------
  |  |  529|    592|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  474|    592|	}
  475|    796|	p2p->inv_status = status;
  476|    796|	p2p->inv_op_freq = op_freq;
  477|    796|	p2p_parse_free(&msg);
  478|    796|	return resp;
  479|    130|}
p2p_handle_invitation_req:
  484|    916|{
  485|    916|	int freq;
  486|    916|	struct wpabuf *resp;
  487|       |
  488|    916|	resp = p2p_process_invitation_req(p2p, sa, data, len, rx_freq, false);
  489|    916|	if (!resp)
  ------------------
  |  Branch (489:6): [True: 120, False: 796]
  ------------------
  490|    120|		return;
  491|       |
  492|    796|	if (rx_freq > 0)
  ------------------
  |  Branch (492:6): [True: 796, False: 0]
  ------------------
  493|    796|		freq = rx_freq;
  494|      0|	else
  495|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  496|      0|					   p2p->cfg->channel);
  497|    796|	if (freq < 0)
  ------------------
  |  Branch (497:6): [True: 0, False: 796]
  ------------------
  498|      0|		p2p_dbg(p2p, "Unknown regulatory class/channel");
  499|       |
  500|    796|	p2p->pending_action_state = P2P_PENDING_INVITATION_RESPONSE;
  501|    796|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (501:6): [True: 0, False: 796]
  ------------------
  502|    796|			    p2p->cfg->dev_addr,
  503|    796|			    wpabuf_head(resp), wpabuf_len(resp), 50) < 0) {
  504|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  505|      0|	}
  506|       |
  507|    796|	wpabuf_free(resp);
  508|    796|}
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|       |
  577|      0|		if (p2p->pending_listen_freq) {
  ------------------
  |  Branch (577:7): [True: 0, False: 0]
  ------------------
  578|      0|			p2p_dbg(p2p,
  579|      0|				"Clear pending_listen_freq for p2p_invite");
  580|      0|			p2p->pending_listen_freq = 0;
  581|      0|		}
  582|       |
  583|      0|		p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
  584|      0|		p2p_set_state(p2p, P2P_INVITE);
  585|      0|		p2p_dbg(p2p, "Resend Invitation Request setting op_class %u channel %u as operating channel",
  586|      0|			p2p->op_reg_class, p2p->op_channel);
  587|      0|		p2p->retry_invite_req_sent = 1;
  588|      0|		p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr,
  589|      0|				p2p->invite_dev_pw_id);
  590|      0|		p2p_parse_free(&msg);
  591|      0|		return;
  592|      0|	}
  593|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  594|      0|	p2p->retry_invite_req = 0;
  595|       |
  596|      0|	if (!msg.channel_list && *msg.status == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (596:6): [True: 0, False: 0]
  |  Branch (596:27): [True: 0, False: 0]
  ------------------
  597|      0|		p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
  598|      0|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  599|       |#ifdef CONFIG_P2P_STRICT
  600|       |		p2p_parse_free(&msg);
  601|       |		return;
  602|       |#endif /* CONFIG_P2P_STRICT */
  603|       |		/* Try to survive without peer channel list */
  604|      0|		channels = &p2p->channels;
  605|      0|		all_channels = true;
  606|      0|	} else if (!msg.channel_list) {
  ------------------
  |  Branch (606:13): [True: 0, False: 0]
  ------------------
  607|       |		/* Non-success cases are not required to include Channel List */
  608|      0|		channels = &p2p->channels;
  609|      0|		all_channels = true;
  610|      0|	} else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (610:13): [True: 0, False: 0]
  ------------------
  611|      0|					   msg.channel_list,
  612|      0|					   msg.channel_list_len) < 0) {
  613|      0|		p2p_dbg(p2p, "No common channels found");
  614|      0|		p2p_parse_free(&msg);
  615|      0|		dev->inv_reject = true;
  616|      0|		return;
  617|      0|	} else {
  618|      0|		p2p_channels_intersect(&p2p->channels, &dev->channels,
  619|      0|				       &intersection);
  620|      0|		channels = &intersection;
  621|      0|	}
  622|       |
  623|      0|	if (p2p->cfg->invitation_result) {
  ------------------
  |  Branch (623:6): [True: 0, False: 0]
  ------------------
  624|      0|		int peer_oper_freq = 0;
  625|      0|		int freq = p2p_channel_to_freq(p2p->op_reg_class,
  626|      0|					       p2p->op_channel);
  627|      0|		if (freq < 0)
  ------------------
  |  Branch (627:7): [True: 0, False: 0]
  ------------------
  628|      0|			freq = 0;
  629|       |
  630|      0|		if (msg.operating_channel) {
  ------------------
  |  Branch (630:7): [True: 0, False: 0]
  ------------------
  631|      0|			peer_oper_freq = p2p_channel_to_freq(
  632|      0|				msg.operating_channel[3],
  633|      0|				msg.operating_channel[4]);
  634|      0|			if (peer_oper_freq < 0)
  ------------------
  |  Branch (634:8): [True: 0, False: 0]
  ------------------
  635|      0|				peer_oper_freq = 0;
  636|      0|		}
  637|       |
  638|       |		/*
  639|       |		 * Use the driver preferred frequency list extension if
  640|       |		 * supported.
  641|       |		 */
  642|      0|		p2p_check_pref_chan(p2p, 0, dev, &msg);
  643|       |
  644|      0|		if (dev->p2p2) {
  ------------------
  |  Branch (644:7): [True: 0, False: 0]
  ------------------
  645|      0|			dev->inv_freq = freq;
  646|      0|			dev->inv_status = *msg.status;
  647|      0|			dev->inv_all_channels = all_channels;
  648|      0|			dev->inv_peer_oper_freq = peer_oper_freq;
  649|      0|			if (msg.group_bssid)
  ------------------
  |  Branch (649:8): [True: 0, False: 0]
  ------------------
  650|      0|				os_memcpy(dev->inv_bssid, msg.group_bssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  651|      0|					  ETH_ALEN);
  652|      0|			if (msg.group_id) {
  ------------------
  |  Branch (652:8): [True: 0, False: 0]
  ------------------
  653|      0|				dev->inv_ssid_len = msg.group_id_len - ETH_ALEN;
  ------------------
  |  |  344|      0|#define ETH_ALEN 6
  ------------------
  654|      0|				os_memcpy(dev->inv_ssid,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  655|      0|					  msg.group_id + ETH_ALEN,
  656|      0|					  dev->inv_ssid_len);
  657|       |
  658|      0|				os_memcpy(p2p->invite_go_dev_addr_buf,
  ------------------
  |  |  523|      0|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  659|      0|					  msg.group_id, ETH_ALEN);
  660|      0|				p2p->invite_go_dev_addr =
  661|      0|					p2p->invite_go_dev_addr_buf;
  662|      0|				go_dev_addr = p2p->invite_go_dev_addr;
  663|      0|			}
  664|      0|			goto out;
  665|      0|		}
  666|       |
  667|      0|		p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status,
  668|      0|					    NULL, 0,
  669|      0|					    msg.group_bssid, channels, sa,
  670|      0|					    freq, peer_oper_freq, NULL, NULL,
  671|      0|					    0, go_dev_addr);
  672|      0|	}
  673|       |
  674|      0|	p2p_clear_timeout(p2p);
  675|      0|	p2p_set_state(p2p, P2P_IDLE);
  676|      0|	p2p->invite_peer = NULL;
  677|       |
  678|      0|out:
  679|      0|	p2p_parse_free(&msg);
  680|      0|}
p2p_invitation.c:p2p_build_invitation_resp:
  136|    796|{
  137|    796|	struct wpabuf *buf, *elems, *p2p_ie;
  138|    796|	size_t extra = 0;
  139|       |
  140|    796|#ifdef CONFIG_WIFI_DISPLAY
  141|    796|	struct wpabuf *wfd_ie = p2p->wfd_ie_invitation;
  142|    796|	if (wfd_ie && group_bssid) {
  ------------------
  |  Branch (142:6): [True: 0, False: 796]
  |  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|    796|	if (wfd_ie)
  ------------------
  |  Branch (157:6): [True: 0, False: 796]
  ------------------
  158|      0|		extra = wpabuf_len(wfd_ie);
  159|    796|#endif /* CONFIG_WIFI_DISPLAY */
  160|       |
  161|    796|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (161:6): [True: 0, False: 796]
  |  Branch (161:26): [True: 0, False: 0]
  ------------------
  162|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  163|       |
  164|    796|	buf = wpabuf_alloc(1000 + extra);
  165|    796|	if (buf == NULL)
  ------------------
  |  Branch (165:6): [True: 0, False: 796]
  ------------------
  166|      0|		return NULL;
  167|       |
  168|    796|	p2p_buf_add_public_action_hdr(buf, P2P_INVITATION_RESP,
  169|    796|				      dialog_token);
  170|       |
  171|    796|	elems = wpabuf_alloc(1000);
  172|    796|	if (!elems) {
  ------------------
  |  Branch (172:6): [True: 0, False: 796]
  ------------------
  173|      0|		wpabuf_free(buf);
  174|      0|		return NULL;
  175|      0|	}
  176|       |
  177|    796|	p2p_buf_add_status(elems, status);
  178|    796|	p2p_buf_add_config_timeout(elems, 0, 0); /* FIX */
  179|    796|	if (reg_class && channel)
  ------------------
  |  Branch (179:6): [True: 0, False: 796]
  |  Branch (179:19): [True: 0, False: 0]
  ------------------
  180|      0|		p2p_buf_add_operating_channel(elems, p2p->cfg->country,
  181|      0|					      reg_class, channel);
  182|    796|	if (group_bssid)
  ------------------
  |  Branch (182:6): [True: 0, False: 796]
  ------------------
  183|      0|		p2p_buf_add_group_bssid(elems, group_bssid);
  184|       |
  185|    796|	if (ssid_len && ssid) {
  ------------------
  |  Branch (185:6): [True: 0, False: 796]
  |  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|    796|	if (channels) {
  ------------------
  |  Branch (196:6): [True: 0, False: 796]
  ------------------
  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|    796|	p2p_ie = p2p_encaps_ie(elems, P2P_IE_VENDOR_TYPE);
  ------------------
  |  | 1568|    796|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  206|    796|	wpabuf_free(elems);
  207|    796|	if (!p2p_ie) {
  ------------------
  |  Branch (207:6): [True: 0, False: 796]
  ------------------
  208|      0|		wpabuf_free(buf);
  209|      0|		return NULL;
  210|      0|	}
  211|       |
  212|    796|	wpabuf_put_buf(buf, p2p_ie);
  213|    796|	wpabuf_free(p2p_ie);
  214|       |
  215|    796|#ifdef CONFIG_WIFI_DISPLAY
  216|    796|	if (wfd_ie)
  ------------------
  |  Branch (216:6): [True: 0, False: 796]
  ------------------
  217|      0|		wpabuf_put_buf(buf, wfd_ie);
  218|    796|#endif /* CONFIG_WIFI_DISPLAY */
  219|       |
  220|    796|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP])
  ------------------
  |  Branch (220:6): [True: 0, False: 796]
  |  Branch (220:26): [True: 0, False: 0]
  ------------------
  221|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]);
  222|       |
  223|    796|	return buf;
  224|    796|}

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

p2p_process_pcea:
  662|     39|{
  663|     39|	const u8 *pos, *end;
  664|     39|	u8 cap_info_len;
  665|       |
  666|     39|	if (!p2p || !dev || !msg || !msg->pcea_info)
  ------------------
  |  Branch (666:6): [True: 0, False: 39]
  |  Branch (666:14): [True: 0, False: 39]
  |  Branch (666:22): [True: 0, False: 39]
  |  Branch (666:30): [True: 0, False: 39]
  ------------------
  667|      0|		return;
  668|       |
  669|     39|	pos = msg->pcea_info;
  670|     39|	end = pos + msg->pcea_info_len;
  671|     39|	dev->info.pcea_cap_info = WPA_GET_LE16(pos);
  672|     39|	cap_info_len = dev->info.pcea_cap_info & P2P_PCEA_LEN_MASK;
  ------------------
  |  | 1922|     39|#define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     39|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     39|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     39|#define BIT(x) (1U << (x))
  |  |  ------------------
  |  |               #define P2P_PCEA_LEN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  |  |  ------------------
  |  |  |  |  458|     39|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  673|       |
  674|       |	/* Field length is (n-1), n in octets */
  675|     39|	if (end - pos < cap_info_len + 1)
  ------------------
  |  Branch (675:6): [True: 11, False: 28]
  ------------------
  676|     11|		return;
  677|     28|	pos += cap_info_len + 1;
  678|       |
  679|     28|	if (dev->info.pcea_cap_info & P2P_PCEA_6GHZ)
  ------------------
  |  | 1923|     28|#define P2P_PCEA_6GHZ BIT(4)
  |  |  ------------------
  |  |  |  |  458|     28|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (679:6): [True: 14, False: 14]
  ------------------
  680|     14|		dev->support_6ghz = true;
  681|       |
  682|     28|	if (dev->info.pcea_cap_info & P2P_PCEA_REG_INFO) {
  ------------------
  |  | 1924|     28|#define P2P_PCEA_REG_INFO BIT(5)
  |  |  ------------------
  |  |  |  |  458|     28|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (682:6): [True: 19, False: 9]
  ------------------
  683|     19|		if (end - pos < 1) {
  ------------------
  |  Branch (683:7): [True: 2, False: 17]
  ------------------
  684|      2|			p2p_dbg(p2p, "Truncated PCEA");
  685|      2|			return;
  686|      2|		}
  687|     17|		dev->info.reg_info = *pos++;
  688|     17|	}
  689|       |
  690|     26|	if (dev->info.pcea_cap_info & P2P_PCEA_PASN_TYPE) {
  ------------------
  |  | 1930|     26|#define P2P_PCEA_PASN_TYPE BIT(11)
  |  |  ------------------
  |  |  |  |  458|     26|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (690:6): [True: 20, False: 6]
  ------------------
  691|     20|		if (end - pos < 1) {
  ------------------
  |  Branch (691:7): [True: 2, False: 18]
  ------------------
  692|      2|			p2p_dbg(p2p, "Truncated PCEA");
  693|      2|			return;
  694|      2|		}
  695|     18|		dev->info.pairing_config.pasn_type = *pos++;
  696|     18|	}
  697|       |
  698|     24|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_CAPABLE)
  ------------------
  |  | 1927|     24|#define P2P_PCEA_PAIRING_CAPABLE BIT(8)
  |  |  ------------------
  |  |  |  |  458|     24|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (698:6): [True: 13, False: 11]
  ------------------
  699|     13|		dev->info.pairing_config.pairing_capable = true;
  700|       |
  701|     24|	if (dev->info.pcea_cap_info & P2P_PCEA_PAIRING_SETUP_ENABLED)
  ------------------
  |  | 1928|     24|#define P2P_PCEA_PAIRING_SETUP_ENABLED BIT(9)
  |  |  ------------------
  |  |  |  |  458|     24|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (701:6): [True: 15, False: 9]
  ------------------
  702|     15|		dev->info.pairing_config.enable_pairing_setup = true;
  703|       |
  704|     24|	if (dev->info.pcea_cap_info & P2P_PCEA_PMK_CACHING) {
  ------------------
  |  | 1929|     24|#define P2P_PCEA_PMK_CACHING BIT(10)
  |  |  ------------------
  |  |  |  |  458|     24|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (704:6): [True: 9, False: 15]
  ------------------
  705|       |		dev->info.pairing_config.enable_pairing_cache = true;
  706|      9|	}
  707|     24|}
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: 809]
  ------------------
 1525|    225|		return;
 1526|       |
 1527|    809|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (1527:6): [True: 45, False: 764]
  |  Branch (1527:23): [True: 44, False: 1]
  ------------------
 1528|     44|		p2p_process_prov_disc_bootstrap_req(p2p, &msg, sa, data + 1,
 1529|     44|						    len - 1, rx_freq);
 1530|    765|	else
 1531|    765|		p2p_process_prov_disc_req(p2p, &msg, sa, data + 1, len - 1,
 1532|    765|					  rx_freq);
 1533|       |
 1534|    809|	p2p_parse_free(&msg);
 1535|    809|}
p2p_handle_prov_disc_resp:
 2054|     31|{
 2055|     31|	struct p2p_message msg;
 2056|       |
 2057|     31|	if (p2p_parse(data, len, &msg))
  ------------------
  |  Branch (2057:6): [True: 12, False: 19]
  ------------------
 2058|     12|		return;
 2059|       |
 2060|     19|	if (msg.pcea_info && msg.pbma_info)
  ------------------
  |  Branch (2060:6): [True: 6, False: 13]
  |  Branch (2060:23): [True: 4, False: 2]
  ------------------
 2061|      4|		p2p_process_prov_disc_bootstrap_resp(p2p, &msg, sa, data + 1,
 2062|      4|						     len - 1, rx_freq);
 2063|     15|	else
 2064|     15|		p2p_process_prov_disc_resp(p2p, &msg, sa, data + 1, len - 1);
 2065|       |
 2066|     19|	p2p_parse_free(&msg);
 2067|     19|}
p2p_reset_pending_pd:
 2250|  6.67k|{
 2251|  6.67k|	struct p2p_device *dev;
 2252|       |
 2253|  6.67k|	dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
  ------------------
  |  |   79|  6.67k|	for (item = dl_list_entry((list)->next, type, member); \
  |  |  ------------------
  |  |  |  |   68|  6.67k|	((type *) ((char *) item - offsetof(type, member)))
  |  |  ------------------
  |  |   80|  6.67k|	     &item->member != (list); \
  |  |  ------------------
  |  |  |  Branch (80:7): [True: 0, False: 6.67k]
  |  |  ------------------
  |  |   81|  6.67k|	     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.67k|	p2p->user_initiated_pd = 0;
 2266|  6.67k|	os_memset(p2p->pending_pd_devaddr, 0, ETH_ALEN);
  ------------------
  |  |  529|  6.67k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2267|  6.67k|	p2p->pd_retries = 0;
 2268|  6.67k|	p2p->pd_force_freq = 0;
 2269|  6.67k|}
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|     44|{
  715|     44|	struct p2p_device *dev;
  716|     44|	int freq;
  717|     44|	struct wpabuf *resp;
  718|     44|	u16 bootstrap;
  719|     44|	size_t cookie_len = 0;
  720|     44|	const u8 *pos, *cookie;
  721|     44|	enum p2p_status_code status = P2P_SC_FAIL_INVALID_PARAMS;
  722|       |
  723|     44|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  724|     44|		" with bootstrapping Attribute (freq=%d)",
  725|     44|		MAC2STR(sa), rx_freq);
  ------------------
  |  |  447|     44|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  726|       |
  727|     44|	dev = p2p_get_device(p2p, sa);
  728|     44|	if (!dev) {
  ------------------
  |  Branch (728:6): [True: 18, False: 26]
  ------------------
  729|     18|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  730|     18|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|     18|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|     18|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  731|       |
  732|     18|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (732:7): [True: 2, False: 16]
  ------------------
  733|      2|			p2p_dbg(p2p,
  734|      2|				"Provision Discovery Request add device failed "
  735|      2|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      2|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      2|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  736|      2|			return;
  737|      2|		}
  738|       |
  739|     16|		dev = p2p_get_device(p2p, sa);
  740|     16|		if (!dev) {
  ------------------
  |  Branch (740:7): [True: 3, False: 13]
  ------------------
  741|      3|			p2p_dbg(p2p,
  742|      3|				"Provision Discovery device not found "
  743|      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]
  ------------------
  744|      3|			return;
  745|      3|		}
  746|     16|	}
  747|     39|	dev->p2p2 = true;
  748|       |
  749|     39|	if (p2p->send_action_in_progress) {
  ------------------
  |  Branch (749:6): [True: 0, False: 39]
  ------------------
  750|      0|		p2p_dbg(p2p, "Dropping retry frame as response TX pending");
  751|      0|		return;
  752|      0|	}
  753|       |
  754|     39|	p2p_update_peer_6ghz_capab(dev, msg);
  755|       |
  756|     39|	if (msg->pcea_info && msg->pcea_info_len >= 2)
  ------------------
  |  Branch (756:6): [True: 39, False: 0]
  |  Branch (756:24): [True: 39, False: 0]
  ------------------
  757|     39|		p2p_process_pcea(p2p, msg, dev);
  758|       |
  759|     39|	pos = msg->pbma_info;
  760|       |
  761|     39|	if (msg->pbma_info_len > 2 && msg->status &&
  ------------------
  |  Branch (761:6): [True: 29, False: 10]
  |  Branch (761:32): [True: 23, False: 6]
  ------------------
  762|     23|	    *msg->status == P2P_SC_COMEBACK) {
  ------------------
  |  Branch (762:6): [True: 5, False: 18]
  ------------------
  763|       |		/* PBMA comeback request */
  764|      5|		cookie_len = *pos++;
  765|      5|		if (msg->pbma_info_len < 1 + cookie_len) {
  ------------------
  |  Branch (765:7): [True: 1, False: 4]
  ------------------
  766|      1|			p2p_dbg(p2p, "Truncated PBMA");
  767|      1|			return;
  768|      1|		}
  769|      4|		cookie = pos;
  770|       |
  771|      4|		if (!dev->bootstrap_params ||
  ------------------
  |  Branch (771:7): [True: 4, 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|      4|			      cookie_len) != 0) {
  775|      4|			status = P2P_SC_FAIL_REJECTED_BY_USER;
  776|      4|			goto out;
  777|      4|		}
  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|     34|	} else {
  786|       |		/* PBMA request */
  787|     34|		bootstrap = WPA_GET_LE16(pos);
  788|       |
  789|     34|		os_free(dev->bootstrap_params);
  ------------------
  |  |  511|     34|#define os_free(p) free((p))
  ------------------
  790|     34|		dev->bootstrap_params = NULL;
  791|       |
  792|     34|		if (!dev->req_bootstrap_method) {
  ------------------
  |  Branch (792:7): [True: 34, False: 0]
  ------------------
  793|     34|			dev->bootstrap_params =
  794|     34|				os_zalloc(sizeof(struct p2p_bootstrap_params));
  795|     34|			if (!dev->bootstrap_params)
  ------------------
  |  Branch (795:8): [True: 0, False: 34]
  ------------------
  796|      0|				return;
  797|     34|			dev->bootstrap_params->bootstrap_method = bootstrap;
  798|     34|			dev->bootstrap_params->cookie_len = 4;
  799|     34|			if (os_get_random(dev->bootstrap_params->cookie,
  ------------------
  |  Branch (799:8): [True: 0, False: 34]
  ------------------
  800|     34|					  dev->bootstrap_params->cookie_len) <
  801|     34|			    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|     34|			dev->bootstrap_params->comeback_after =
  807|     34|				p2p->cfg->comeback_after;
  808|     34|			status = P2P_SC_COMEBACK;
  809|     34|			if (p2p->cfg->bootstrap_req_rx)
  ------------------
  |  Branch (809:8): [True: 0, False: 34]
  ------------------
  810|      0|				p2p->cfg->bootstrap_req_rx(p2p->cfg->cb_ctx,
  811|      0|							   sa, bootstrap);
  812|     34|			goto out;
  813|     34|		}
  814|     34|	}
  815|       |
  816|      0|	if (bootstrap == P2P_PBMA_PIN_CODE_DISPLAY &&
  ------------------
  |  | 1935|      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)
  ------------------
  |  | 1939|      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 &&
  ------------------
  |  | 1939|      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)
  ------------------
  |  | 1935|      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 &&
  ------------------
  |  | 1936|      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)
  ------------------
  |  | 1940|      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 &&
  ------------------
  |  | 1940|      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)
  ------------------
  |  | 1936|      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 &&
  ------------------
  |  | 1938|      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)
  ------------------
  |  | 1942|      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 &&
  ------------------
  |  | 1942|      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)
  ------------------
  |  | 1938|      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 &&
  ------------------
  |  | 1937|      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)
  ------------------
  |  | 1941|      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 &&
  ------------------
  |  | 1941|      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)
  ------------------
  |  | 1937|      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 &&
  ------------------
  |  | 1934|      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)
  ------------------
  |  | 1934|      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|     38|out:
  855|       |	/* Send PD Bootstrapping Response for the PD Request */
  856|     38|	resp = p2p_build_prov_disc_bootstrap_resp(p2p, dev, msg->dialog_token,
  857|     38|						  status);
  858|     38|	if (!resp)
  ------------------
  |  Branch (858:6): [True: 0, False: 38]
  ------------------
  859|      0|		return;
  860|       |
  861|     38|	p2p_dbg(p2p, "Sending Provision Discovery Bootstrap Response");
  862|     38|	if (rx_freq > 0)
  ------------------
  |  Branch (862:6): [True: 38, False: 0]
  ------------------
  863|     38|		freq = rx_freq;
  864|      0|	else
  865|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  866|      0|					   p2p->cfg->channel);
  867|     38|	if (freq < 0) {
  ------------------
  |  Branch (867:6): [True: 0, False: 38]
  ------------------
  868|      0|		p2p_dbg(p2p, "Unknown operating class/channel");
  869|      0|		wpabuf_free(resp);
  870|      0|		return;
  871|      0|	}
  872|     38|	p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
  873|     38|	if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (873:6): [True: 0, False: 38]
  ------------------
  874|     38|			    p2p->cfg->dev_addr, wpabuf_head(resp),
  875|     38|			    wpabuf_len(resp), 50) < 0)
  876|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  877|     38|	else
  878|     38|		p2p->send_action_in_progress = 1;
  879|       |
  880|     38|	wpabuf_free(resp);
  881|     38|}
p2p_pd.c:p2p_build_prov_disc_bootstrap_resp:
  313|     38|{
  314|     38|	struct wpabuf *buf;
  315|     38|	u8 *cookie = NULL;
  316|     38|	size_t cookie_len = 0;
  317|     38|	int comeback_after = 0;
  318|     38|	u8 *len;
  319|       |
  320|     38|	buf = wpabuf_alloc(1000);
  321|     38|	if (!buf)
  ------------------
  |  Branch (321:6): [True: 0, False: 38]
  ------------------
  322|      0|		return NULL;
  323|       |
  324|     38|	p2p_dbg(p2p, "P2P2: Building boostrapping PD Response");
  325|     38|	if (status == P2P_SC_COMEBACK && dev->bootstrap_params) {
  ------------------
  |  Branch (325:6): [True: 34, False: 4]
  |  Branch (325:35): [True: 34, False: 0]
  ------------------
  326|     34|		cookie = dev->bootstrap_params->cookie;
  327|     34|		cookie_len = dev->bootstrap_params->cookie_len;
  328|     34|		comeback_after = dev->bootstrap_params->comeback_after;
  329|     34|	}
  330|       |
  331|     38|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  332|       |
  333|     38|	len = p2p_buf_add_p2p2_ie_hdr(buf);
  334|       |
  335|     38|	p2p_buf_add_status(buf, status);
  336|     38|	p2p_buf_add_pcea(buf, p2p);
  337|     38|	p2p_buf_add_pbma(buf, dev->req_bootstrap_method, cookie, cookie_len,
  338|     38|			 comeback_after);
  339|       |
  340|     38|	p2p_buf_update_ie_hdr(buf, len);
  341|       |
  342|     38|	return buf;
  343|     38|}
p2p_pd.c:p2p_process_prov_disc_req:
  887|    765|{
  888|    765|	struct p2p_device *dev;
  889|    765|	int freq;
  890|    765|	enum p2p_status_code reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
  891|    765|	struct wpabuf *resp;
  892|    765|	u32 adv_id = 0;
  893|    765|	struct p2ps_advertisement *p2ps_adv = NULL;
  894|    765|	u8 conncap = P2PS_SETUP_NEW;
  ------------------
  |  |   30|    765|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|    765|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  895|    765|	u8 auto_accept = 0;
  896|    765|	u32 session_id = 0;
  897|    765|	u8 session_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  898|    765|	u8 adv_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
  899|    765|	const u8 *group_mac;
  900|    765|	int passwd_id = DEV_PW_DEFAULT;
  901|    765|	u16 config_methods;
  902|    765|	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  251|    765|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
              	u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|    765|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  903|    765|	struct p2ps_feature_capab resp_fcap = { 0, 0 };
  904|    765|	struct p2ps_feature_capab *req_fcap = NULL;
  905|    765|	u8 remote_conncap;
  906|    765|	u16 method;
  907|       |
  908|    765|	p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR
  909|    765|		" with config methods 0x%x (freq=%d)",
  910|    765|		MAC2STR(sa), msg->wps_config_methods, rx_freq);
  ------------------
  |  |  447|    765|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  911|    765|	group_mac = msg->intended_addr;
  912|       |
  913|    765|	dev = p2p_get_device(p2p, sa);
  914|    765|	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
  ------------------
  |  |  127|     59|#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
  |  |  ------------------
  |  |  |  |  458|     59|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (914:6): [True: 706, False: 59]
  |  Branch (914:21): [True: 9, False: 50]
  ------------------
  915|    715|		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
  916|    715|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    715|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    715|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  917|       |
  918|    715|		if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data, len, 0)) {
  ------------------
  |  Branch (918:7): [True: 328, False: 387]
  ------------------
  919|    328|			p2p_dbg(p2p, "Provision Discovery Request add device failed "
  920|    328|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    328|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    328|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  921|    328|			goto out;
  922|    328|		}
  923|       |
  924|    387|		dev = p2p_get_device(p2p, sa);
  925|    387|		if (!dev) {
  ------------------
  |  Branch (925:7): [True: 293, False: 94]
  ------------------
  926|    293|			p2p_dbg(p2p,
  927|    293|				"Provision Discovery device not found "
  928|    293|				MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|    293|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              				MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|    293|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  929|    293|			goto out;
  930|    293|		}
  931|    387|	} else if (msg->wfd_subelems) {
  ------------------
  |  Branch (931:13): [True: 1, False: 49]
  ------------------
  932|      1|		wpabuf_free(dev->info.wfd_subelems);
  933|      1|		dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems);
  934|      1|	}
  935|       |
  936|    144|	p2p_update_peer_6ghz_capab(dev, msg);
  937|       |
  938|    144|	if (!msg->adv_id) {
  ------------------
  |  Branch (938:6): [True: 53, False: 91]
  ------------------
  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: 10, False: 43]
  ------------------
  941|     10|			p2p_dbg(p2p,
  942|     10|				"Unsupported Config Methods in Provision Discovery Request");
  943|     10|			goto out;
  944|     10|		}
  945|       |
  946|       |		/* Legacy (non-P2PS) - Unknown groups allowed for P2PS */
  947|     43|		if (msg->group_id) {
  ------------------
  |  Branch (947:7): [True: 1, False: 42]
  ------------------
  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|     91|	} else {
  963|     91|		allowed_config_methods |= WPS_CONFIG_P2PS;
  ------------------
  |  |  259|     91|#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|     91|		adv_id = WPA_GET_LE32(msg->adv_id);
  970|     91|		if (p2ps_validate_pd_req(p2p, msg, sa) < 0) {
  ------------------
  |  Branch (970:7): [True: 20, False: 71]
  ------------------
  971|     20|			reject = P2P_SC_FAIL_INVALID_PARAMS;
  972|     20|			goto out;
  973|     20|		}
  974|       |
  975|     71|		req_fcap = (struct p2ps_feature_capab *) msg->feature_cap;
  976|       |
  977|     71|		os_memcpy(session_mac, msg->session_mac, ETH_ALEN);
  ------------------
  |  |  523|     71|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  978|     71|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|     71|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  979|       |
  980|     71|		session_id = WPA_GET_LE32(msg->session_id);
  981|       |
  982|     71|		if (msg->conn_cap)
  ------------------
  |  Branch (982:7): [True: 58, False: 13]
  ------------------
  983|     58|			conncap = *msg->conn_cap;
  984|       |
  985|       |		/*
  986|       |		 * We need to verify a P2PS config methog in an initial PD
  987|       |		 * request or in a follow-on PD request with the status
  988|       |		 * SUCCESS_DEFERRED.
  989|       |		 */
  990|     71|		if ((!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) &&
  ------------------
  |  Branch (990:8): [True: 4, False: 67]
  |  Branch (990:24): [True: 47, False: 20]
  ------------------
  991|     51|		    !(msg->wps_config_methods & allowed_config_methods)) {
  ------------------
  |  Branch (991:7): [True: 3, False: 48]
  ------------------
  992|      3|			p2p_dbg(p2p,
  993|      3|				"Unsupported Config Methods in Provision Discovery Request");
  994|      3|			goto out;
  995|      3|		}
  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|     71|	}
 1002|       |
 1003|    110|	dev->flags &= ~(P2P_DEV_PD_PEER_DISPLAY |
  ------------------
  |  |  130|    110|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|    110|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1004|    110|			P2P_DEV_PD_PEER_KEYPAD |
  ------------------
  |  |  131|    110|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|    110|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1005|    110|			P2P_DEV_PD_PEER_P2PS);
  ------------------
  |  |  146|    110|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|    110|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1006|       |
 1007|    110|	if (msg->wps_config_methods & WPS_CONFIG_DISPLAY) {
  ------------------
  |  |  251|    110|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1007:6): [True: 50, False: 60]
  ------------------
 1008|     50|		p2p_dbg(p2p, "Peer " MACSTR
 1009|     50|			" requested us to show a PIN on display", MAC2STR(sa));
  ------------------
  |  |  447|     50|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1010|     50|		dev->flags |= P2P_DEV_PD_PEER_KEYPAD;
  ------------------
  |  |  131|     50|#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
  |  |  ------------------
  |  |  |  |  458|     50|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1011|     50|		passwd_id = DEV_PW_USER_SPECIFIED;
 1012|     60|	} else if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|     60|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1012:13): [True: 27, False: 33]
  ------------------
 1013|     27|		p2p_dbg(p2p, "Peer " MACSTR
 1014|     27|			" requested us to write its PIN using keypad",
 1015|     27|			MAC2STR(sa));
  ------------------
  |  |  447|     27|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1016|     27|		dev->flags |= P2P_DEV_PD_PEER_DISPLAY;
  ------------------
  |  |  130|     27|#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
  |  |  ------------------
  |  |  |  |  458|     27|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1017|     27|		passwd_id = DEV_PW_REGISTRAR_SPECIFIED;
 1018|     33|	} else if (msg->wps_config_methods & WPS_CONFIG_P2PS) {
  ------------------
  |  |  259|     33|#define WPS_CONFIG_P2PS 0x1000
  ------------------
  |  Branch (1018:13): [True: 12, False: 21]
  ------------------
 1019|     12|		p2p_dbg(p2p, "Peer " MACSTR " requesting P2PS PIN",
 1020|     12|			MAC2STR(sa));
  ------------------
  |  |  447|     12|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1021|     12|		dev->flags |= P2P_DEV_PD_PEER_P2PS;
  ------------------
  |  |  146|     12|#define P2P_DEV_PD_PEER_P2PS BIT(21)
  |  |  ------------------
  |  |  |  |  458|     12|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1022|     12|		passwd_id = DEV_PW_P2PS_DEFAULT;
 1023|     12|	}
 1024|       |
 1025|       |	/* Remove stale persistent groups */
 1026|    110|	if (p2p->cfg->remove_stale_groups) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 110]
  ------------------
 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|    110|	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|    110|	if (!msg->adv_id)
  ------------------
  |  Branch (1039:6): [True: 42, False: 68]
  ------------------
 1040|     42|		goto out;
 1041|       |
 1042|     68|	remote_conncap = conncap;
 1043|       |
 1044|     68|	if (!msg->status) {
  ------------------
  |  Branch (1044:6): [True: 2, False: 66]
  ------------------
 1045|      2|		unsigned int forced_freq, pref_freq;
 1046|       |
 1047|      2|		if (!ether_addr_equal(p2p->cfg->dev_addr, msg->adv_mac)) {
  ------------------
  |  Branch (1047:7): [True: 1, False: 1]
  ------------------
 1048|      1|			p2p_dbg(p2p,
 1049|      1|				"P2PS PD adv mac does not match the local one");
 1050|      1|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1051|      1|			goto out;
 1052|      1|		}
 1053|       |
 1054|      1|		p2ps_adv = p2p_service_p2ps_id(p2p, adv_id);
 1055|      1|		if (!p2ps_adv) {
  ------------------
  |  Branch (1055:7): [True: 1, False: 0]
  ------------------
 1056|      1|			p2p_dbg(p2p, "P2PS PD invalid adv_id=0x%X", adv_id);
 1057|      1|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1058|      1|			goto out;
 1059|      1|		}
 1060|      0|		p2p_dbg(p2p, "adv_id: 0x%X, p2ps_adv: %p", adv_id, p2ps_adv);
 1061|       |
 1062|      0|		auto_accept = p2ps_adv->auto_accept;
 1063|      0|		conncap = p2p->cfg->p2ps_group_capability(p2p->cfg->cb_ctx,
 1064|      0|							  conncap, auto_accept,
 1065|      0|							  &forced_freq,
 1066|      0|							  &pref_freq);
 1067|       |
 1068|      0|		p2p_dbg(p2p, "Conncap: local:%d remote:%d result:%d",
 1069|      0|			auto_accept, remote_conncap, conncap);
 1070|       |
 1071|      0|		p2p_prepare_channel(p2p, dev, forced_freq, pref_freq, 0);
 1072|       |
 1073|      0|		resp_fcap.cpt = p2ps_own_preferred_cpt(p2ps_adv->cpt_priority,
 1074|      0|						       req_fcap->cpt);
 1075|       |
 1076|      0|		p2p_dbg(p2p, "cpt: service:0x%x remote:0x%x result:0x%x",
 1077|      0|			p2ps_adv->cpt_mask, req_fcap->cpt, resp_fcap.cpt);
 1078|       |
 1079|      0|		if (!resp_fcap.cpt) {
  ------------------
  |  Branch (1079:7): [True: 0, False: 0]
  ------------------
 1080|      0|			p2p_dbg(p2p,
 1081|      0|				"Incompatible P2PS feature capability CPT bitmask");
 1082|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1083|      0|		} else if (p2ps_adv->config_methods &&
  ------------------
  |  Branch (1083:14): [True: 0, False: 0]
  ------------------
 1084|      0|			   !(msg->wps_config_methods &
  ------------------
  |  Branch (1084:7): [True: 0, False: 0]
  ------------------
 1085|      0|			     p2ps_adv->config_methods)) {
 1086|      0|			p2p_dbg(p2p,
 1087|      0|				"Unsupported config methods in Provision Discovery Request (own=0x%x peer=0x%x)",
 1088|      0|				p2ps_adv->config_methods,
 1089|      0|				msg->wps_config_methods);
 1090|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1091|      0|		} else if (!p2ps_adv->state) {
  ------------------
  |  Branch (1091:14): [True: 0, False: 0]
  ------------------
 1092|      0|			p2p_dbg(p2p, "P2PS state unavailable");
 1093|      0|			reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1094|      0|		} else if (!conncap) {
  ------------------
  |  Branch (1094:14): [True: 0, False: 0]
  ------------------
 1095|      0|			p2p_dbg(p2p, "Conncap resolution failed");
 1096|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1097|      0|		}
 1098|       |
 1099|      0|		if (msg->wps_config_methods & WPS_CONFIG_KEYPAD) {
  ------------------
  |  |  256|      0|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1099:7): [True: 0, False: 0]
  ------------------
 1100|      0|			p2p_dbg(p2p, "Keypad - always defer");
 1101|      0|			auto_accept = 0;
 1102|      0|		}
 1103|       |
 1104|      0|		if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
              		if ((remote_conncap & (P2PS_SETUP_NEW | P2PS_SETUP_CLIENT) ||
  ------------------
  |  |   31|      0|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1104:8): [True: 0, False: 0]
  ------------------
 1105|      0|		     msg->persistent_dev) && conncap != P2PS_SETUP_NEW &&
  ------------------
  |  |   30|      0|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1105:8): [True: 0, False: 0]
  |  Branch (1105:32): [True: 0, False: 0]
  ------------------
 1106|      0|		    msg->channel_list && msg->channel_list_len &&
  ------------------
  |  Branch (1106:7): [True: 0, False: 0]
  |  Branch (1106:28): [True: 0, False: 0]
  ------------------
 1107|      0|		    p2p_peer_channels_check(p2p, &p2p->channels, dev,
  ------------------
  |  Branch (1107:7): [True: 0, False: 0]
  ------------------
 1108|      0|					    msg->channel_list,
 1109|      0|					    msg->channel_list_len) < 0) {
 1110|      0|			p2p_dbg(p2p,
 1111|      0|				"No common channels - force deferred flow");
 1112|      0|			auto_accept = 0;
 1113|      0|		}
 1114|       |
 1115|      0|		if (((remote_conncap & P2PS_SETUP_GROUP_OWNER) ||
  ------------------
  |  |   32|      0|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1115:8): [True: 0, False: 0]
  ------------------
 1116|      0|		     msg->persistent_dev) && msg->operating_channel) {
  ------------------
  |  Branch (1116:8): [True: 0, False: 0]
  |  Branch (1116:32): [True: 0, False: 0]
  ------------------
 1117|      0|			struct p2p_channels intersect;
 1118|       |
 1119|       |			/*
 1120|       |			 * There are cases where only the operating channel is
 1121|       |			 * provided. This requires saving the channel as the
 1122|       |			 * supported channel list, and verifying that it is
 1123|       |			 * supported.
 1124|       |			 */
 1125|      0|			if (dev->channels.reg_classes == 0 ||
  ------------------
  |  Branch (1125:8): [True: 0, False: 0]
  ------------------
 1126|      0|			    !p2p_channels_includes(&dev->channels,
  ------------------
  |  Branch (1126:8): [True: 0, False: 0]
  ------------------
 1127|      0|						   msg->operating_channel[3],
 1128|      0|						   msg->operating_channel[4])) {
 1129|      0|				struct p2p_channels *ch = &dev->channels;
 1130|       |
 1131|      0|				os_memset(ch, 0, sizeof(*ch));
  ------------------
  |  |  529|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1132|      0|				ch->reg_class[0].reg_class =
 1133|      0|					msg->operating_channel[3];
 1134|      0|				ch->reg_class[0].channel[0] =
 1135|      0|					msg->operating_channel[4];
 1136|      0|				ch->reg_class[0].channels = 1;
 1137|      0|				ch->reg_classes = 1;
 1138|      0|			}
 1139|       |
 1140|      0|			p2p_channels_intersect(&p2p->channels, &dev->channels,
 1141|      0|					       &intersect);
 1142|       |
 1143|      0|			if (intersect.reg_classes == 0) {
  ------------------
  |  Branch (1143:8): [True: 0, False: 0]
  ------------------
 1144|      0|				p2p_dbg(p2p,
 1145|      0|					"No common channels - force deferred flow");
 1146|      0|				auto_accept = 0;
 1147|      0|			}
 1148|      0|		}
 1149|       |
 1150|      0|		if (auto_accept || reject != P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1150:7): [True: 0, False: 0]
  |  Branch (1150:22): [True: 0, False: 0]
  ------------------
 1151|      0|			struct p2ps_provision *tmp;
 1152|       |
 1153|      0|			if (p2ps_setup_p2ps_prov(p2p, adv_id, session_id,
  ------------------
  |  Branch (1153:8): [True: 0, False: 0]
  ------------------
 1154|      0|						 msg->wps_config_methods,
 1155|      0|						 session_mac, adv_mac) < 0) {
 1156|      0|				reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1157|      0|				goto out;
 1158|      0|			}
 1159|       |
 1160|      0|			tmp = p2p->p2ps_prov;
 1161|      0|			tmp->force_freq = forced_freq;
 1162|      0|			tmp->pref_freq = pref_freq;
 1163|      0|			if (conncap) {
  ------------------
  |  Branch (1163:8): [True: 0, False: 0]
  ------------------
 1164|      0|				tmp->conncap = conncap;
 1165|      0|				tmp->status = P2P_SC_SUCCESS;
 1166|      0|			} else {
 1167|      0|				tmp->conncap = auto_accept;
 1168|      0|				tmp->status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1169|      0|			}
 1170|       |
 1171|      0|			if (reject != P2P_SC_SUCCESS)
  ------------------
  |  Branch (1171:8): [True: 0, False: 0]
  ------------------
 1172|      0|				goto out;
 1173|      0|		}
 1174|      0|	}
 1175|       |
 1176|     66|	if (!msg->status && !auto_accept &&
  ------------------
  |  Branch (1176:6): [True: 0, False: 66]
  |  Branch (1176:22): [True: 0, False: 0]
  ------------------
 1177|      0|	    (!p2p->p2ps_prov || p2p->p2ps_prov->adv_id != adv_id)) {
  ------------------
  |  Branch (1177:7): [True: 0, False: 0]
  |  Branch (1177:26): [True: 0, False: 0]
  ------------------
 1178|      0|		struct p2ps_provision *tmp;
 1179|       |
 1180|      0|		if (!conncap) {
  ------------------
  |  Branch (1180:7): [True: 0, False: 0]
  ------------------
 1181|      0|			reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 1182|      0|			goto out;
 1183|      0|		}
 1184|       |
 1185|      0|		if (p2ps_setup_p2ps_prov(p2p, adv_id, session_id,
  ------------------
  |  Branch (1185:7): [True: 0, False: 0]
  ------------------
 1186|      0|					 msg->wps_config_methods,
 1187|      0|					 session_mac, adv_mac) < 0) {
 1188|      0|			reject = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
 1189|      0|			goto out;
 1190|      0|		}
 1191|      0|		tmp = p2p->p2ps_prov;
 1192|      0|		reject = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE;
 1193|      0|		tmp->status = reject;
 1194|      0|	}
 1195|       |
 1196|       |	/* Not a P2PS Follow-on PD */
 1197|     66|	if (!msg->status)
  ------------------
  |  Branch (1197:6): [True: 0, False: 66]
  ------------------
 1198|      0|		goto out;
 1199|       |
 1200|     66|	if (*msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1200:6): [True: 57, False: 9]
  |  Branch (1200:22): [True: 11, False: 46]
  ------------------
 1201|     11|		reject = *msg->status;
 1202|     11|		goto out;
 1203|     11|	}
 1204|       |
 1205|     55|	if (*msg->status != P2P_SC_SUCCESS_DEFERRED || !p2p->p2ps_prov)
  ------------------
  |  Branch (1205:6): [True: 9, False: 46]
  |  Branch (1205:49): [True: 46, False: 0]
  ------------------
 1206|     55|		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|    765|out:
 1288|    765|	if (reject == P2P_SC_SUCCESS ||
  ------------------
  |  Branch (1288:6): [True: 97, False: 668]
  ------------------
 1289|    668|	    reject == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1289:6): [True: 1, False: 667]
  ------------------
 1290|     98|		config_methods = msg->wps_config_methods;
 1291|    667|	else
 1292|    667|		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|    765|	if (!msg->status || *msg->status == P2P_SC_SUCCESS_DEFERRED) {
  ------------------
  |  Branch (1298:6): [True: 682, False: 83]
  |  Branch (1298:22): [True: 50, False: 33]
  ------------------
 1299|    732|		resp = p2p_build_prov_disc_resp(p2p, dev, msg->dialog_token,
 1300|    732|						reject, config_methods, adv_id,
 1301|    732|						msg->group_id,
 1302|    732|						msg->group_id_len,
 1303|    732|						msg->persistent_ssid,
 1304|    732|						msg->persistent_ssid_len,
 1305|    732|						(const u8 *) &resp_fcap,
 1306|    732|						sizeof(resp_fcap));
 1307|    732|		if (!resp)
  ------------------
  |  Branch (1307:7): [True: 0, False: 732]
  ------------------
 1308|      0|			return;
 1309|       |
 1310|    732|		p2p_dbg(p2p, "Sending Provision Discovery Response");
 1311|    732|		if (rx_freq > 0)
  ------------------
  |  Branch (1311:7): [True: 732, False: 0]
  ------------------
 1312|    732|			freq = rx_freq;
 1313|      0|		else
 1314|      0|			freq = p2p_channel_to_freq(p2p->cfg->reg_class,
 1315|      0|						   p2p->cfg->channel);
 1316|    732|		if (freq < 0) {
  ------------------
  |  Branch (1316:7): [True: 0, False: 732]
  ------------------
 1317|      0|			p2p_dbg(p2p, "Unknown regulatory class/channel");
 1318|      0|			wpabuf_free(resp);
 1319|      0|			return;
 1320|      0|		}
 1321|    732|		p2p->pending_action_state = P2P_PENDING_PD_RESPONSE;
 1322|    732|		if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (1322:7): [True: 0, False: 732]
  ------------------
 1323|    732|				    p2p->cfg->dev_addr,
 1324|    732|				    wpabuf_head(resp), wpabuf_len(resp),
 1325|    732|				    50) < 0)
 1326|      0|			p2p_dbg(p2p, "Failed to send Action frame");
 1327|    732|		else
 1328|    732|			p2p->send_action_in_progress = 1;
 1329|       |
 1330|    732|		wpabuf_free(resp);
 1331|    732|	}
 1332|       |
 1333|    765|	if (!dev)
  ------------------
  |  Branch (1333:6): [True: 620, False: 145]
  ------------------
 1334|    620|		return;
 1335|       |
 1336|    145|	freq = 0;
 1337|    145|	if (reject == P2P_SC_SUCCESS && conncap == P2PS_SETUP_GROUP_OWNER) {
  ------------------
  |  |   32|     97|#define P2PS_SETUP_GROUP_OWNER BIT(2)
  |  |  ------------------
  |  |  |  |  458|     97|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (1337:6): [True: 97, False: 48]
  |  Branch (1337:34): [True: 1, False: 96]
  ------------------
 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|    145|	if (!p2p->cfg->p2ps_prov_complete) {
  ------------------
  |  Branch (1344:6): [True: 145, False: 0]
  ------------------
 1345|       |		/* Don't emit anything */
 1346|    145|	} 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|    145|	if (p2p->cfg->prov_disc_req &&
  ------------------
  |  Branch (1463:6): [True: 0, False: 145]
  ------------------
 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|    145|	if (reject != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE)
  ------------------
  |  Branch (1490:6): [True: 144, False: 1]
  ------------------
 1491|    144|		p2ps_prov_free(p2p);
 1492|       |
 1493|    145|	if (reject == P2P_SC_SUCCESS) {
  ------------------
  |  Branch (1493:6): [True: 97, False: 48]
  ------------------
 1494|     97|		switch (config_methods) {
 1495|      1|		case WPS_CONFIG_DISPLAY:
  ------------------
  |  |  251|      1|#define WPS_CONFIG_DISPLAY 0x0008
  ------------------
  |  Branch (1495:3): [True: 1, False: 96]
  ------------------
 1496|      1|			dev->wps_prov_info = WPS_CONFIG_KEYPAD;
  ------------------
  |  |  256|      1|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
 1497|      1|			break;
 1498|      3|		case WPS_CONFIG_KEYPAD:
  ------------------
  |  |  256|      3|#define WPS_CONFIG_KEYPAD 0x0100
  ------------------
  |  Branch (1498:3): [True: 3, False: 94]
  ------------------
 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: 96]
  ------------------
 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: 95]
  ------------------
 1505|      2|			dev->wps_prov_info = WPS_CONFIG_P2PS;
  ------------------
  |  |  259|      2|#define WPS_CONFIG_P2PS 0x1000
  ------------------
 1506|      2|			break;
 1507|     90|		default:
  ------------------
  |  Branch (1507:3): [True: 90, False: 7]
  ------------------
 1508|     90|			dev->wps_prov_info = 0;
 1509|     90|			break;
 1510|     97|		}
 1511|       |
 1512|     97|		if (msg->intended_addr)
  ------------------
  |  Branch (1512:7): [True: 1, False: 96]
  ------------------
 1513|      1|			os_memcpy(dev->interface_addr, msg->intended_addr,
  ------------------
  |  |  523|      1|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1514|     97|				  ETH_ALEN);
 1515|     97|	}
 1516|    145|}
p2p_pd.c:p2ps_validate_pd_req:
  552|     91|{
  553|     91|	u8 group_id = 0;
  554|     91|	u8 intended_addr = 0;
  555|     91|	u8 operating_channel = 0;
  556|     91|	u8 channel_list = 0;
  557|     91|	u8 config_timeout = 0;
  558|     91|	u8 listen_channel = 0;
  559|       |
  560|     91|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  561|     91|do { \
  562|     91|	if ((_val) && !msg->_attr) { \
  563|     91|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  564|     91|		return -1; \
  565|     91|	} \
  566|     91|} while (0)
  567|       |
  568|     91|	P2PS_PD_REQ_CHECK(1, adv_id);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  569|     91|	P2PS_PD_REQ_CHECK(1, session_id);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  570|     90|	P2PS_PD_REQ_CHECK(1, session_mac);
  ------------------
  |  |  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: 0, False: 90]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     90|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 90]
  |  |  ------------------
  ------------------
  571|     90|	P2PS_PD_REQ_CHECK(1, adv_mac);
  ------------------
  |  |  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: 0, False: 90]
  |  |  ------------------
  |  |  563|      0|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      0|		return -1; \
  |  |  565|      0|	} \
  |  |  566|     90|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 90]
  |  |  ------------------
  ------------------
  572|     90|	P2PS_PD_REQ_CHECK(1, capability);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  573|     89|	P2PS_PD_REQ_CHECK(1, p2p_device_info);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  574|     88|	P2PS_PD_REQ_CHECK(1, feature_cap);
  ------------------
  |  |  560|     88|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     88|do { \
  |  |  562|     88|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 88, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 87]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     88|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 87]
  |  |  ------------------
  ------------------
  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|     87|	if (msg->status && *msg->status != P2P_SC_SUCCESS_DEFERRED)
  ------------------
  |  Branch (581:6): [True: 68, False: 19]
  |  Branch (581:21): [True: 20, False: 48]
  ------------------
  582|     20|		return 0;
  583|       |
  584|     67|	P2PS_PD_REQ_CHECK(1, conn_cap);
  ------------------
  |  |  560|     67|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     67|do { \
  |  |  562|     67|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 67, Folded]
  |  |  |  Branch (562:16): [True: 1, False: 66]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     67|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 66]
  |  |  ------------------
  ------------------
  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|     66|	if (msg->feature_cap_len < sizeof(struct p2ps_feature_capab)) {
  ------------------
  |  Branch (596:6): [True: 1, False: 65]
  ------------------
  597|      1|		p2p_dbg(p2p, "P2PS: Invalid feature capability len");
  598|      1|		return -1;
  599|      1|	}
  600|       |
  601|     65|	switch (*msg->conn_cap) {
  602|      4|	case P2PS_SETUP_NEW:
  ------------------
  |  |   30|      4|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|      4|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (602:2): [True: 4, False: 61]
  ------------------
  603|      4|		group_id = 1;
  604|      4|		intended_addr = 1;
  605|      4|		operating_channel = 1;
  606|      4|		channel_list = 1;
  607|      4|		config_timeout = 1;
  608|      4|		listen_channel = 1;
  609|      4|		break;
  610|     54|	case P2PS_SETUP_CLIENT:
  ------------------
  |  |   31|     54|#define P2PS_SETUP_CLIENT BIT(1)
  |  |  ------------------
  |  |  |  |  458|     54|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (610:2): [True: 54, False: 11]
  ------------------
  611|     54|		channel_list = 1;
  612|     54|		listen_channel = 1;
  613|     54|		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: 63]
  ------------------
  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: 64]
  ------------------
  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: 62]
  ------------------
  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: 64]
  ------------------
  634|      1|		p2p_dbg(p2p, "Invalid P2PS PD connection capability");
  635|      1|		return -1;
  636|     65|	}
  637|       |
  638|     64|	if (msg->persistent_dev) {
  ------------------
  |  Branch (638:6): [True: 5, False: 59]
  ------------------
  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|     64|	P2PS_PD_REQ_CHECK(group_id, group_id);
  ------------------
  |  |  560|     64|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     64|do { \
  |  |  562|     64|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 10, False: 54]
  |  |  |  Branch (562:16): [True: 7, False: 3]
  |  |  ------------------
  |  |  563|      7|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      7|		return -1; \
  |  |  565|      7|	} \
  |  |  566|     64|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 57]
  |  |  ------------------
  ------------------
  648|     57|	P2PS_PD_REQ_CHECK(intended_addr, intended_addr);
  ------------------
  |  |  560|     57|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     57|do { \
  |  |  562|     57|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 3, False: 54]
  |  |  |  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|     57|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 56]
  |  |  ------------------
  ------------------
  649|     56|	P2PS_PD_REQ_CHECK(operating_channel, operating_channel);
  ------------------
  |  |  560|     56|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     56|do { \
  |  |  562|     56|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 54]
  |  |  |  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|     56|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 55]
  |  |  ------------------
  ------------------
  650|     55|	P2PS_PD_REQ_CHECK(channel_list, channel_list);
  ------------------
  |  |  560|     55|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     55|do { \
  |  |  562|     55|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 54, False: 1]
  |  |  |  Branch (562:16): [True: 1, False: 53]
  |  |  ------------------
  |  |  563|      1|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      1|		return -1; \
  |  |  565|      1|	} \
  |  |  566|     55|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 54]
  |  |  ------------------
  ------------------
  651|     54|	P2PS_PD_REQ_CHECK(config_timeout, config_timeout);
  ------------------
  |  |  560|     54|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     54|do { \
  |  |  562|     54|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 2, False: 52]
  |  |  |  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|     54|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 53]
  |  |  ------------------
  ------------------
  652|     53|	P2PS_PD_REQ_CHECK(listen_channel, listen_channel);
  ------------------
  |  |  560|     53|#define P2PS_PD_REQ_CHECK(_val, _attr) \
  |  |  561|     53|do { \
  |  |  562|     53|	if ((_val) && !msg->_attr) { \
  |  |  ------------------
  |  |  |  Branch (562:6): [True: 52, False: 1]
  |  |  |  Branch (562:16): [True: 2, False: 50]
  |  |  ------------------
  |  |  563|      2|		p2p_dbg(p2p, "Not P2PS PD Request. Missing %s", #_attr); \
  |  |  564|      2|		return -1; \
  |  |  565|      2|	} \
  |  |  566|     53|} while (0)
  |  |  ------------------
  |  |  |  Branch (566:10): [Folded, False: 51]
  |  |  ------------------
  ------------------
  653|       |
  654|     51|#undef P2PS_PD_REQ_CHECK
  655|       |
  656|     51|	return 0;
  657|     53|}
p2p_pd.c:p2p_build_prov_disc_resp:
  358|    732|{
  359|    732|	struct wpabuf *buf;
  360|    732|	size_t extra = 0;
  361|    732|	int persist = 0;
  362|       |
  363|    732|#ifdef CONFIG_WIFI_DISPLAY
  364|    732|	struct wpabuf *wfd_ie = p2p->wfd_ie_prov_disc_resp;
  365|    732|	if (wfd_ie && group_id) {
  ------------------
  |  Branch (365:6): [True: 0, False: 732]
  |  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|    732|	if (wfd_ie)
  ------------------
  |  Branch (380:6): [True: 0, False: 732]
  ------------------
  381|      0|		extra = wpabuf_len(wfd_ie);
  382|    732|#endif /* CONFIG_WIFI_DISPLAY */
  383|       |
  384|    732|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (384:6): [True: 0, False: 732]
  |  Branch (384:26): [True: 0, False: 0]
  ------------------
  385|      0|		extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  386|       |
  387|    732|	buf = wpabuf_alloc(1000 + extra);
  388|    732|	if (buf == NULL)
  ------------------
  |  Branch (388:6): [True: 0, False: 732]
  ------------------
  389|      0|		return NULL;
  390|       |
  391|    732|	p2p_buf_add_public_action_hdr(buf, P2P_PROV_DISC_RESP, dialog_token);
  392|       |
  393|       |	/* Add P2P IE for P2PS */
  394|    732|	if (p2p->p2ps_prov && p2p->p2ps_prov->adv_id == adv_id) {
  ------------------
  |  Branch (394:6): [True: 0, False: 732]
  |  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 |
  ------------------
  |  | 1913|      0|#define P2P_GROUP_CAPAB_PERSISTENT_GROUP BIT(1)
  |  |  ------------------
  |  |  |  |  458|      0|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  409|      0|			P2P_GROUP_CAPAB_PERSISTENT_RECONN;
  ------------------
  |  | 1917|      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;
  ------------------
  |  | 1916|      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;
  ------------------
  |  | 1915|      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,
  ------------------
  |  | 1904|      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|    732|	} else if (status != P2P_SC_SUCCESS || adv_id) {
  ------------------
  |  Branch (484:13): [True: 644, False: 88]
  |  Branch (484:41): [True: 46, False: 42]
  ------------------
  485|    690|		u8 *len = p2p_buf_add_ie_hdr(buf);
  486|       |
  487|    690|		p2p_buf_add_status(buf, status);
  488|       |
  489|    690|		if (p2p->p2ps_prov)
  ------------------
  |  Branch (489:7): [True: 0, False: 690]
  ------------------
  490|      0|			p2p_buf_add_advertisement_id(buf, adv_id,
  491|      0|						     p2p->p2ps_prov->adv_mac);
  492|       |
  493|    690|		p2p_buf_update_ie_hdr(buf, len);
  494|    690|	}
  495|       |
  496|       |	/* WPS IE with Config Methods attribute */
  497|    732|	p2p_build_wps_ie_config_methods(buf, config_methods);
  498|       |
  499|    732|#ifdef CONFIG_WIFI_DISPLAY
  500|    732|	if (wfd_ie)
  ------------------
  |  Branch (500:6): [True: 0, False: 732]
  ------------------
  501|      0|		wpabuf_put_buf(buf, wfd_ie);
  502|    732|#endif /* CONFIG_WIFI_DISPLAY */
  503|       |
  504|    732|	if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP])
  ------------------
  |  Branch (504:6): [True: 0, False: 732]
  |  Branch (504:26): [True: 0, False: 0]
  ------------------
  505|      0|		wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_PD_RESP]);
  506|       |
  507|    732|	return buf;
  508|    732|}
p2p_pd.c:p2p_build_wps_ie_config_methods:
   28|    732|{
   29|    732|	u8 *len;
   30|    732|	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  ------------------
  |  |  496|    732|#define WLAN_EID_VENDOR_SPECIFIC 221
  ------------------
   31|    732|	len = wpabuf_put(buf, 1);
   32|    732|	wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
  ------------------
  |  |  283|    732|#define WPS_DEV_OUI_WFA 0x0050f204
  ------------------
   33|       |
   34|       |	/* Config Methods */
   35|    732|	wpabuf_put_be16(buf, ATTR_CONFIG_METHODS);
   36|    732|	wpabuf_put_be16(buf, 2);
   37|    732|	wpabuf_put_be16(buf, config_methods);
   38|       |
   39|    732|	p2p_buf_update_ie_hdr(buf, len);
   40|    732|}
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: 2, False: 2]
  ------------------
 1650|      2|		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: 2, False: 2]
  |  Branch (1656:14): [True: 2, 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 &&
  ------------------
  |  | 1935|      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) &&
  ------------------
  |  | 1939|      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 &&
  ------------------
  |  | 1939|      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) &&
  ------------------
  |  | 1935|      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 &&
  ------------------
  |  | 1936|      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) &&
  ------------------
  |  | 1940|      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 &&
  ------------------
  |  | 1940|      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) &&
  ------------------
  |  | 1936|      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 &&
  ------------------
  |  | 1938|      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) &&
  ------------------
  |  | 1942|      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 &&
  ------------------
  |  | 1942|      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) &&
  ------------------
  |  | 1938|      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 &&
  ------------------
  |  | 1937|      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) &&
  ------------------
  |  | 1941|      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 &&
  ------------------
  |  | 1941|      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) &&
  ------------------
  |  | 1937|      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 &&
  ------------------
  |  | 1934|      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))
  ------------------
  |  | 1934|      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|     15|{
 1767|     15|	struct p2p_device *dev;
 1768|     15|	u16 report_config_methods = 0, req_config_methods;
 1769|     15|	enum p2p_status_code status = P2P_SC_SUCCESS;
 1770|     15|	u32 adv_id = 0;
 1771|     15|	u8 conncap = P2PS_SETUP_NEW;
  ------------------
  |  |   30|     15|#define P2PS_SETUP_NEW BIT(0)
  |  |  ------------------
  |  |  |  |  458|     15|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 1772|     15|	u8 adv_mac[ETH_ALEN];
 1773|     15|	const u8 *group_mac;
 1774|     15|	int passwd_id = DEV_PW_DEFAULT;
 1775|     15|	int p2ps_seeker;
 1776|       |
 1777|     15|	if (p2p->p2ps_prov && p2p_validate_p2ps_pd_resp(p2p, msg))
  ------------------
  |  Branch (1777:6): [True: 0, False: 15]
  |  Branch (1777:24): [True: 0, False: 0]
  ------------------
 1778|      0|		return;
 1779|       |
 1780|       |	/* Parse the P2PS members present */
 1781|     15|	if (msg->status)
  ------------------
  |  Branch (1781:6): [True: 1, False: 14]
  ------------------
 1782|      1|		status = *msg->status;
 1783|       |
 1784|     15|	group_mac = msg->intended_addr;
 1785|       |
 1786|     15|	if (msg->adv_mac)
  ------------------
  |  Branch (1786:6): [True: 3, False: 12]
  ------------------
 1787|      3|		os_memcpy(adv_mac, msg->adv_mac, ETH_ALEN);
  ------------------
  |  |  523|      3|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 1788|     12|	else
 1789|     12|		os_memset(adv_mac, 0, ETH_ALEN);
  ------------------
  |  |  529|     12|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 1790|       |
 1791|     15|	if (msg->adv_id)
  ------------------
  |  Branch (1791:6): [True: 3, False: 12]
  ------------------
 1792|      3|		adv_id = WPA_GET_LE32(msg->adv_id);
 1793|       |
 1794|     15|	if (msg->conn_cap) {
  ------------------
  |  Branch (1794:6): [True: 5, False: 10]
  ------------------
 1795|      5|		conncap = *msg->conn_cap;
 1796|       |
 1797|       |		/* Switch bits to local relative */
 1798|      5|		switch (conncap) {
  ------------------
  |  Branch (1798:11): [True: 2, False: 3]
  ------------------
 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: 4]
  ------------------
 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: 4]
  ------------------
 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|      5|		}
 1806|      5|	}
 1807|       |
 1808|     15|	p2p_dbg(p2p, "Received Provision Discovery Response from " MACSTR
 1809|     15|		" with config methods 0x%x",
 1810|     15|		MAC2STR(sa), msg->wps_config_methods);
  ------------------
  |  |  447|     15|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1811|       |
 1812|     15|	dev = p2p_get_device(p2p, sa);
 1813|     15|	if (dev == NULL || !dev->req_config_methods) {
  ------------------
  |  Branch (1813:6): [True: 14, False: 1]
  |  Branch (1813:21): [True: 1, False: 0]
  ------------------
 1814|     15|		p2p_dbg(p2p, "Ignore Provision Discovery Response from " MACSTR
 1815|     15|			" with no pending request", MAC2STR(sa));
  ------------------
  |  |  447|     15|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
 1816|     15|		return;
 1817|     15|	} 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.67k|{
  158|  6.67k|	struct p2p_sd_query *q, *prev;
  159|  6.67k|	q = p2p->sd_queries;
  160|  6.67k|	p2p->sd_queries = NULL;
  161|  6.67k|	while (q) {
  ------------------
  |  Branch (161:9): [True: 0, False: 6.67k]
  ------------------
  162|      0|		prev = q;
  163|      0|		q = q->next;
  164|      0|		p2p_free_sd_query(prev);
  165|      0|	}
  166|  6.67k|	p2p->num_p2p_sd_queries = 0;
  167|  6.67k|}
p2p_rx_gas_initial_req:
  328|      2|{
  329|      2|	const u8 *pos = data;
  330|      2|	const u8 *end = data + len;
  331|      2|	const u8 *next;
  332|      2|	u8 dialog_token;
  333|      2|	u16 slen;
  334|      2|	int freq;
  335|      2|	u16 update_indic;
  336|       |
  337|       |
  338|      2|	if (p2p->cfg->sd_request == NULL)
  ------------------
  |  Branch (338:6): [True: 2, False: 0]
  ------------------
  339|      2|		return;
  340|       |
  341|      0|	if (rx_freq > 0)
  ------------------
  |  Branch (341:6): [True: 0, False: 0]
  ------------------
  342|      0|		freq = rx_freq;
  343|      0|	else
  344|      0|		freq = p2p_channel_to_freq(p2p->cfg->reg_class,
  345|      0|					   p2p->cfg->channel);
  346|      0|	if (freq < 0)
  ------------------
  |  Branch (346:6): [True: 0, False: 0]
  ------------------
  347|      0|		return;
  348|       |
  349|      0|	if (len < 1 + 2)
  ------------------
  |  Branch (349:6): [True: 0, False: 0]
  ------------------
  350|      0|		return;
  351|       |
  352|      0|	dialog_token = *pos++;
  353|      0|	p2p_dbg(p2p, "GAS Initial Request from " MACSTR
  354|      0|		" (dialog token %u, freq %d)",
  355|      0|		MAC2STR(sa), dialog_token, rx_freq);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  356|       |
  357|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (357:6): [True: 0, False: 0]
  ------------------
  358|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
  359|      0|		return;
  360|      0|	}
  361|      0|	pos++;
  362|       |
  363|      0|	slen = *pos++;
  364|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (364:6): [True: 0, False: 0]
  |  Branch (364:26): [True: 0, False: 0]
  ------------------
  365|      0|		p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
  366|      0|		return;
  367|      0|	}
  368|      0|	next = pos + slen;
  369|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  370|       |
  371|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (371:6): [True: 0, False: 0]
  ------------------
  372|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  373|      0|			*pos);
  374|      0|		return;
  375|      0|	}
  376|       |
  377|      0|	pos = next;
  378|       |	/* Query Request */
  379|      0|	if (end - pos < 2)
  ------------------
  |  Branch (379:6): [True: 0, False: 0]
  ------------------
  380|      0|		return;
  381|      0|	slen = WPA_GET_LE16(pos);
  382|      0|	pos += 2;
  383|      0|	if (slen > end - pos)
  ------------------
  |  Branch (383:6): [True: 0, False: 0]
  ------------------
  384|      0|		return;
  385|      0|	end = pos + slen;
  386|       |
  387|       |	/* ANQP Query Request */
  388|      0|	if (end - pos < 4)
  ------------------
  |  Branch (388:6): [True: 0, False: 0]
  ------------------
  389|      0|		return;
  390|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (390:6): [True: 0, False: 0]
  ------------------
  391|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  392|      0|		return;
  393|      0|	}
  394|      0|	pos += 2;
  395|       |
  396|      0|	slen = WPA_GET_LE16(pos);
  397|      0|	pos += 2;
  398|      0|	if (slen > end - pos || slen < 3 + 1) {
  ------------------
  |  Branch (398:6): [True: 0, False: 0]
  |  Branch (398:26): [True: 0, False: 0]
  ------------------
  399|      0|		p2p_dbg(p2p, "Invalid ANQP Query Request length");
  400|      0|		return;
  401|      0|	}
  402|       |
  403|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1568|      0|#define P2P_IE_VENDOR_TYPE 0x506f9a09
  ------------------
  |  Branch (403:6): [True: 0, False: 0]
  ------------------
  404|      0|		p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
  405|      0|			WPA_GET_BE32(pos));
  406|      0|		return;
  407|      0|	}
  408|      0|	pos += 4;
  409|       |
  410|      0|	if (end - pos < 2)
  ------------------
  |  Branch (410:6): [True: 0, False: 0]
  ------------------
  411|      0|		return;
  412|      0|	update_indic = WPA_GET_LE16(pos);
  413|      0|	p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
  414|      0|	pos += 2;
  415|       |
  416|      0|	p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
  417|      0|			     update_indic, pos, end - pos);
  418|       |	/* the response will be indicated with a call to p2p_sd_response() */
  419|      0|}
p2p_rx_gas_initial_resp:
  482|      1|{
  483|      1|	const u8 *pos = data;
  484|      1|	const u8 *end = data + len;
  485|      1|	const u8 *next;
  486|      1|	u8 dialog_token;
  487|      1|	u16 status_code;
  488|      1|	u16 comeback_delay;
  489|      1|	u16 slen;
  490|      1|	u16 update_indic;
  491|       |
  492|      1|	if ((p2p->state != P2P_SD_DURING_FIND && p2p->state != P2P_SEARCH) ||
  ------------------
  |  Branch (492:7): [True: 1, False: 0]
  |  Branch (492:43): [True: 1, False: 0]
  ------------------
  493|      0|	    !p2p->sd_peer ||
  ------------------
  |  Branch (493:6): [True: 0, False: 0]
  ------------------
  494|      1|	    !ether_addr_equal(sa, p2p->sd_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (494:6): [True: 0, False: 0]
  ------------------
  495|      1|		p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
  496|      1|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  497|      1|		return;
  498|      1|	}
  499|      0|	if (p2p->state == P2P_SEARCH) {
  ------------------
  |  Branch (499:6): [True: 0, False: 0]
  ------------------
  500|       |		/* It is possible for the TX status and RX response events to be
  501|       |		 * reordered, so assume the request was ACKed if a response is
  502|       |		 * received. */
  503|      0|		p2p_dbg(p2p,
  504|      0|			"GAS Initial Request had not yet received TX status - process the response anyway");
  505|      0|		p2p_sd_query_cb(p2p, 1);
  506|      0|	}
  507|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  508|      0|	p2p_clear_timeout(p2p);
  509|       |
  510|      0|	p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
  511|      0|		MAC2STR(sa), (int) len);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  512|       |
  513|      0|	if (len < 5 + 2) {
  ------------------
  |  Branch (513:6): [True: 0, False: 0]
  ------------------
  514|      0|		p2p_dbg(p2p, "Too short GAS Initial Response frame");
  515|      0|		return;
  516|      0|	}
  517|       |
  518|      0|	dialog_token = *pos++;
  519|       |	/* TODO: check dialog_token match */
  520|      0|	status_code = WPA_GET_LE16(pos);
  521|      0|	pos += 2;
  522|      0|	comeback_delay = WPA_GET_LE16(pos);
  523|      0|	pos += 2;
  524|      0|	p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
  525|      0|		dialog_token, status_code, comeback_delay);
  526|      0|	if (status_code) {
  ------------------
  |  Branch (526:6): [True: 0, False: 0]
  ------------------
  527|      0|		p2p_dbg(p2p, "Service Discovery failed: status code %u",
  528|      0|			status_code);
  529|      0|		return;
  530|      0|	}
  531|       |
  532|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (532:6): [True: 0, False: 0]
  ------------------
  533|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
  534|      0|		return;
  535|      0|	}
  536|      0|	pos++;
  537|       |
  538|      0|	slen = *pos++;
  539|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (539:6): [True: 0, False: 0]
  |  Branch (539:26): [True: 0, False: 0]
  ------------------
  540|      0|		p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
  541|      0|		return;
  542|      0|	}
  543|      0|	next = pos + slen;
  544|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  545|       |
  546|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (546:6): [True: 0, False: 0]
  ------------------
  547|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  548|      0|			*pos);
  549|      0|		return;
  550|      0|	}
  551|       |
  552|      0|	pos = next;
  553|       |	/* Query Response */
  554|      0|	if (end - pos < 2) {
  ------------------
  |  Branch (554:6): [True: 0, False: 0]
  ------------------
  555|      0|		p2p_dbg(p2p, "Too short Query Response");
  556|      0|		return;
  557|      0|	}
  558|      0|	slen = WPA_GET_LE16(pos);
  559|      0|	pos += 2;
  560|      0|	p2p_dbg(p2p, "Query Response Length: %d", slen);
  561|      0|	if (slen > end - pos) {
  ------------------
  |  Branch (561:6): [True: 0, False: 0]
  ------------------
  562|      0|		p2p_dbg(p2p, "Not enough Query Response data");
  563|      0|		return;
  564|      0|	}
  565|      0|	end = pos + slen;
  566|       |
  567|      0|	if (comeback_delay) {
  ------------------
  |  Branch (567:6): [True: 0, False: 0]
  ------------------
  568|      0|		p2p_dbg(p2p, "Fragmented response - request fragments");
  569|      0|		if (p2p->sd_rx_resp) {
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      0|			p2p_dbg(p2p, "Drop old SD reassembly buffer");
  571|      0|			wpabuf_free(p2p->sd_rx_resp);
  572|      0|			p2p->sd_rx_resp = NULL;
  573|      0|		}
  574|      0|		p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
  575|      0|		return;
  576|      0|	}
  577|       |
  578|       |	/* ANQP Query Response */
  579|      0|	if (end - pos < 4)
  ------------------
  |  Branch (579:6): [True: 0, False: 0]
  ------------------
  580|      0|		return;
  581|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (581:6): [True: 0, False: 0]
  ------------------
  582|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  583|      0|		return;
  584|      0|	}
  585|      0|	pos += 2;
  586|       |
  587|      0|	slen = WPA_GET_LE16(pos);
  588|      0|	pos += 2;
  589|      0|	if (slen > end - pos || slen < 3 + 1) {
  ------------------
  |  Branch (589:6): [True: 0, False: 0]
  |  Branch (589:26): [True: 0, False: 0]
  ------------------
  590|      0|		p2p_dbg(p2p, "Invalid ANQP Query Response length");
  591|      0|		return;
  592|      0|	}
  593|       |
  594|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1568|      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|     29|{
  631|     29|	struct wpabuf *resp;
  632|     29|	u8 dialog_token;
  633|     29|	size_t frag_len, max_len;
  634|     29|	int more = 0;
  635|     29|	unsigned int wait_time = 200;
  636|       |
  637|     29|	wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Request", data, len);
  638|     29|	if (len < 1)
  ------------------
  |  Branch (638:6): [True: 1, False: 28]
  ------------------
  639|      1|		return;
  640|     28|	dialog_token = *data;
  641|     28|	p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
  642|     28|	if (dialog_token != p2p->sd_resp_dialog_token) {
  ------------------
  |  Branch (642:6): [True: 23, False: 5]
  ------------------
  643|     23|		p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
  644|     23|			dialog_token);
  645|     23|		return;
  646|     23|	}
  647|       |
  648|      5|	if (p2p->sd_resp == NULL) {
  ------------------
  |  Branch (648:6): [True: 5, False: 0]
  ------------------
  649|      5|		p2p_dbg(p2p, "No pending SD response fragment available");
  650|      5|		return;
  651|      5|	}
  652|      0|	if (!ether_addr_equal(sa, p2p->sd_resp_addr)) {
  ------------------
  |  Branch (652:6): [True: 0, False: 0]
  ------------------
  653|      0|		p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
  ------------------
  |  |  448|      0|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
  654|      0|			MAC2STR(sa));
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  655|      0|		return;
  656|      0|	}
  657|       |
  658|       |	/*
  659|       |	 * In the 60 GHz, we have a smaller maximum frame length for management
  660|       |	 * frames.
  661|       |	 */
  662|      0|	max_len = (rx_freq > 56160) ? 928 : 1400;
  ------------------
  |  Branch (662:12): [True: 0, False: 0]
  ------------------
  663|      0|	frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
  664|      0|	if (frag_len > max_len) {
  ------------------
  |  Branch (664:6): [True: 0, False: 0]
  ------------------
  665|      0|		frag_len = max_len;
  666|      0|		more = 1;
  667|      0|	}
  668|      0|	resp = p2p_build_gas_comeback_resp(dialog_token, WLAN_STATUS_SUCCESS,
  ------------------
  |  |  134|      0|#define WLAN_STATUS_SUCCESS 0
  ------------------
  669|      0|					   p2p->srv_update_indic,
  670|      0|					   wpabuf_head_u8(p2p->sd_resp) +
  671|      0|					   p2p->sd_resp_pos, frag_len,
  672|      0|					   p2p->sd_frag_id, more,
  673|      0|					   wpabuf_len(p2p->sd_resp));
  674|      0|	if (resp == NULL)
  ------------------
  |  Branch (674:6): [True: 0, False: 0]
  ------------------
  675|      0|		return;
  676|      0|	p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
  677|      0|		p2p->sd_frag_id, more, (int) frag_len);
  678|      0|	p2p->sd_frag_id++;
  679|      0|	p2p->sd_resp_pos += frag_len;
  680|       |
  681|      0|	if (more) {
  ------------------
  |  Branch (681:6): [True: 0, False: 0]
  ------------------
  682|      0|		p2p_dbg(p2p, "%d more bytes remain to be sent",
  683|      0|			(int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
  684|      0|	} else {
  685|      0|		p2p_dbg(p2p, "All fragments of SD response sent");
  686|      0|		wpabuf_free(p2p->sd_resp);
  687|      0|		p2p->sd_resp = NULL;
  688|      0|		wait_time = 0; /* no more SD frames in the sequence */
  689|      0|	}
  690|       |
  691|      0|	p2p->pending_action_state = P2P_NO_PENDING_ACTION;
  692|      0|	if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
  ------------------
  |  Branch (692:6): [True: 0, False: 0]
  ------------------
  693|      0|			    p2p->cfg->dev_addr,
  694|      0|			    wpabuf_head(resp), wpabuf_len(resp), wait_time) < 0)
  695|      0|		p2p_dbg(p2p, "Failed to send Action frame");
  696|       |
  697|      0|	wpabuf_free(resp);
  698|      0|}
p2p_rx_gas_comeback_resp:
  703|      1|{
  704|      1|	const u8 *pos = data;
  705|      1|	const u8 *end = data + len;
  706|      1|	const u8 *next;
  707|      1|	u8 dialog_token;
  708|      1|	u16 status_code;
  709|      1|	u8 frag_id;
  710|      1|	u8 more_frags;
  711|      1|	u16 comeback_delay;
  712|      1|	u16 slen;
  713|       |
  714|      1|	wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
  715|       |
  716|      1|	if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
  ------------------
  |  Branch (716:6): [True: 1, False: 0]
  |  Branch (716:42): [True: 0, False: 0]
  ------------------
  717|      1|	    !ether_addr_equal(sa, p2p->sd_peer->info.p2p_device_addr)) {
  ------------------
  |  Branch (717:6): [True: 0, False: 0]
  ------------------
  718|      1|		p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
  719|      1|			MACSTR, MAC2STR(sa));
  ------------------
  |  |  448|      1|#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  ------------------
              			MACSTR, MAC2STR(sa));
  ------------------
  |  |  447|      1|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  720|      1|		return;
  721|      1|	}
  722|      0|	p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
  723|      0|	p2p_clear_timeout(p2p);
  724|       |
  725|      0|	p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
  726|      0|		MAC2STR(sa), (int) len);
  ------------------
  |  |  447|      0|#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  ------------------
  727|       |
  728|      0|	if (len < 6 + 2) {
  ------------------
  |  Branch (728:6): [True: 0, False: 0]
  ------------------
  729|      0|		p2p_dbg(p2p, "Too short GAS Comeback Response frame");
  730|      0|		return;
  731|      0|	}
  732|       |
  733|      0|	dialog_token = *pos++;
  734|       |	/* TODO: check dialog_token match */
  735|      0|	status_code = WPA_GET_LE16(pos);
  736|      0|	pos += 2;
  737|      0|	frag_id = *pos & 0x7f;
  738|      0|	more_frags = (*pos & 0x80) >> 7;
  739|      0|	pos++;
  740|      0|	comeback_delay = WPA_GET_LE16(pos);
  741|      0|	pos += 2;
  742|      0|	p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
  743|      0|		"comeback_delay=%u",
  744|      0|		dialog_token, status_code, frag_id, more_frags,
  745|      0|		comeback_delay);
  746|       |	/* TODO: check frag_id match */
  747|      0|	if (status_code) {
  ------------------
  |  Branch (747:6): [True: 0, False: 0]
  ------------------
  748|      0|		p2p_dbg(p2p, "Service Discovery failed: status code %u",
  749|      0|			status_code);
  750|      0|		return;
  751|      0|	}
  752|       |
  753|      0|	if (*pos != WLAN_EID_ADV_PROTO) {
  ------------------
  |  |  409|      0|#define WLAN_EID_ADV_PROTO 108
  ------------------
  |  Branch (753:6): [True: 0, False: 0]
  ------------------
  754|      0|		p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
  755|      0|			*pos);
  756|      0|		return;
  757|      0|	}
  758|      0|	pos++;
  759|       |
  760|      0|	slen = *pos++;
  761|      0|	if (slen > end - pos || slen < 2) {
  ------------------
  |  Branch (761:6): [True: 0, False: 0]
  |  Branch (761:26): [True: 0, False: 0]
  ------------------
  762|      0|		p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
  763|      0|		return;
  764|      0|	}
  765|      0|	next = pos + slen;
  766|      0|	pos++; /* skip QueryRespLenLimit and PAME-BI */
  767|       |
  768|      0|	if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
  ------------------
  |  Branch (768:6): [True: 0, False: 0]
  ------------------
  769|      0|		p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
  770|      0|			*pos);
  771|      0|		return;
  772|      0|	}
  773|       |
  774|      0|	pos = next;
  775|       |	/* Query Response */
  776|      0|	if (end - pos < 2) {
  ------------------
  |  Branch (776:6): [True: 0, False: 0]
  ------------------
  777|      0|		p2p_dbg(p2p, "Too short Query Response");
  778|      0|		return;
  779|      0|	}
  780|      0|	slen = WPA_GET_LE16(pos);
  781|      0|	pos += 2;
  782|      0|	p2p_dbg(p2p, "Query Response Length: %d", slen);
  783|      0|	if (slen > end - pos) {
  ------------------
  |  Branch (783:6): [True: 0, False: 0]
  ------------------
  784|      0|		p2p_dbg(p2p, "Not enough Query Response data");
  785|      0|		return;
  786|      0|	}
  787|      0|	if (slen == 0) {
  ------------------
  |  Branch (787:6): [True: 0, False: 0]
  ------------------
  788|      0|		p2p_dbg(p2p, "No Query Response data");
  789|      0|		return;
  790|      0|	}
  791|      0|	end = pos + slen;
  792|       |
  793|      0|	if (p2p->sd_rx_resp) {
  ------------------
  |  Branch (793:6): [True: 0, False: 0]
  ------------------
  794|       |		 /*
  795|       |		  * ANQP header is only included in the first fragment; rest of
  796|       |		  * the fragments start with continue TLVs.
  797|       |		  */
  798|      0|		goto skip_nqp_header;
  799|      0|	}
  800|       |
  801|       |	/* ANQP Query Response */
  802|      0|	if (end - pos < 4)
  ------------------
  |  Branch (802:6): [True: 0, False: 0]
  ------------------
  803|      0|		return;
  804|      0|	if (WPA_GET_LE16(pos) != ANQP_VENDOR_SPECIFIC) {
  ------------------
  |  Branch (804:6): [True: 0, False: 0]
  ------------------
  805|      0|		p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
  806|      0|		return;
  807|      0|	}
  808|      0|	pos += 2;
  809|       |
  810|      0|	slen = WPA_GET_LE16(pos);
  811|      0|	pos += 2;
  812|      0|	p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
  813|      0|	if (slen < 3 + 1) {
  ------------------
  |  Branch (813:6): [True: 0, False: 0]
  ------------------
  814|      0|		p2p_dbg(p2p, "Invalid ANQP Query Response length");
  815|      0|		return;
  816|      0|	}
  817|      0|	if (end - pos < 4)
  ------------------
  |  Branch (817:6): [True: 0, False: 0]
  ------------------
  818|      0|		return;
  819|       |
  820|      0|	if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
  ------------------
  |  | 1568|      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|    288|{
  115|    288|	size_t i, j;
  116|       |
  117|    288|	os_memset(res, 0, sizeof(*res));
  ------------------
  |  |  529|    288|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  118|       |
  119|    574|	for (i = 0; i < a->reg_classes; i++) {
  ------------------
  |  Branch (119:14): [True: 288, False: 286]
  ------------------
  120|    288|		const struct p2p_reg_class *a_reg = &a->reg_class[i];
  121|  1.42k|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (121:15): [True: 1.13k, False: 286]
  ------------------
  122|  1.13k|			const struct p2p_reg_class *b_reg = &b->reg_class[j];
  123|  1.13k|			if (a_reg->reg_class != b_reg->reg_class)
  ------------------
  |  Branch (123:8): [True: 457, False: 679]
  ------------------
  124|    457|				continue;
  125|    679|			p2p_reg_class_intersect(
  126|    679|				a_reg, b_reg,
  127|    679|				&res->reg_class[res->reg_classes]);
  128|    679|			if (res->reg_class[res->reg_classes].channels) {
  ------------------
  |  Branch (128:8): [True: 590, False: 89]
  ------------------
  129|    590|				res->reg_classes++;
  130|    590|				if (res->reg_classes == P2P_MAX_REG_CLASSES)
  ------------------
  |  |   47|    590|#define P2P_MAX_REG_CLASSES 20
  ------------------
  |  Branch (130:9): [True: 2, False: 588]
  ------------------
  131|      2|					return;
  132|    590|			}
  133|    679|		}
  134|    288|	}
  135|    288|}
p2p_channels_union_inplace:
  164|    178|{
  165|    178|	size_t i, j;
  166|       |
  167|    356|	for (i = 0; i < res->reg_classes; i++) {
  ------------------
  |  Branch (167:14): [True: 178, False: 178]
  ------------------
  168|    178|		struct p2p_reg_class *cl = &res->reg_class[i];
  169|    178|		for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (169:15): [True: 0, False: 178]
  ------------------
  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|    178|	}
  176|       |
  177|    178|	for (j = 0; j < b->reg_classes; j++) {
  ------------------
  |  Branch (177:14): [True: 0, False: 178]
  ------------------
  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|    178|}
p2p_channels_union:
  205|    178|{
  206|    178|	os_memcpy(res, a, sizeof(*res));
  ------------------
  |  |  523|    178|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  207|    178|	p2p_channels_union_inplace(res, b);
  208|    178|}
p2p_channels_includes:
  256|     45|{
  257|     45|	size_t i, j;
  258|    167|	for (i = 0; i < channels->reg_classes; i++) {
  ------------------
  |  Branch (258:14): [True: 126, False: 41]
  ------------------
  259|    126|		const struct p2p_reg_class *reg = &channels->reg_class[i];
  260|    126|		if (reg->reg_class != reg_class)
  ------------------
  |  Branch (260:7): [True: 76, False: 50]
  ------------------
  261|     76|			continue;
  262|    163|		for (j = 0; j < reg->channels; j++) {
  ------------------
  |  Branch (262:15): [True: 117, False: 46]
  ------------------
  263|    117|			if (reg->channel[j] == channel)
  ------------------
  |  Branch (263:8): [True: 4, False: 113]
  ------------------
  264|      4|				return 1;
  265|    117|		}
  266|     50|	}
  267|     41|	return 0;
  268|     45|}
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.75k, False: 13.8k]
  ------------------
  352|  7.75k|		const struct p2p_reg_class *c;
  353|  7.75k|		c = &chan->reg_class[i];
  354|  7.75k|		ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
  ------------------
  |  |  572|  7.75k|#define os_snprintf snprintf
  ------------------
  355|  7.75k|		if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (355:7): [True: 3, False: 7.74k]
  ------------------
  356|      3|			break;
  357|  7.74k|		pos += ret;
  358|       |
  359|  25.6k|		for (j = 0; j < c->channels; j++) {
  ------------------
  |  Branch (359:15): [True: 17.9k, False: 7.74k]
  ------------------
  360|  17.9k|			ret = os_snprintf(pos, end - pos, "%s%u",
  ------------------
  |  |  572|  17.9k|#define os_snprintf snprintf
  ------------------
  361|  17.9k|					  j == 0 ? "" : ",",
  ------------------
  |  Branch (361:8): [True: 7.63k, False: 10.2k]
  ------------------
  362|  17.9k|					  c->channel[j]);
  363|  17.9k|			if (os_snprintf_error(end - pos, ret))
  ------------------
  |  Branch (363:8): [True: 3, False: 17.9k]
  ------------------
  364|      3|				break;
  365|  17.9k|			pos += ret;
  366|  17.9k|		}
  367|  7.74k|	}
  368|  13.8k|	*pos = '\0';
  369|       |
  370|  13.8k|	p2p_dbg(p2p, "%s:%s", title, buf);
  371|  13.8k|}
p2p_copy_channels:
  503|     61|{
  504|     61|	size_t i, j;
  505|       |
  506|     61|	if (allow_6ghz) {
  ------------------
  |  Branch (506:6): [True: 0, False: 61]
  ------------------
  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|     61|	for (i = 0, j = 0; i < src->reg_classes; i++) {
  ------------------
  |  Branch (511:21): [True: 0, False: 61]
  ------------------
  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|     61|	dst->reg_classes = j;
  519|     61|}
p2p_utils.c:p2p_reg_class_intersect:
   82|    679|{
   83|    679|	size_t i, j;
   84|       |
   85|    679|	res->reg_class = a->reg_class;
   86|       |
   87|  2.03k|	for (i = 0; i < a->channels; i++) {
  ------------------
  |  Branch (87:14): [True: 1.35k, False: 673]
  ------------------
   88|  9.61k|		for (j = 0; j < b->channels; j++) {
  ------------------
  |  Branch (88:15): [True: 8.26k, False: 1.35k]
  ------------------
   89|  8.26k|			if (a->channel[i] != b->channel[j])
  ------------------
  |  Branch (89:8): [True: 5.93k, False: 2.32k]
  ------------------
   90|  5.93k|				continue;
   91|  2.32k|			res->channel[res->channels] = a->channel[i];
   92|  2.32k|			res->channels++;
   93|  2.32k|			if (res->channels == P2P_MAX_REG_CLASS_CHANNELS)
  ------------------
  |  |   52|  2.32k|#define P2P_MAX_REG_CLASS_CHANNELS 60
  ------------------
  |  Branch (93:8): [True: 6, False: 2.32k]
  ------------------
   94|      6|				return;
   95|  2.32k|		}
   96|  1.35k|	}
   97|    679|}

printf_encode:
  478|  6.16k|{
  479|  6.16k|	char *end = txt + maxlen;
  480|  6.16k|	size_t i;
  481|       |
  482|   139k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (482:14): [True: 133k, False: 6.16k]
  ------------------
  483|   133k|		if (txt + 4 >= end)
  ------------------
  |  Branch (483:7): [True: 0, False: 133k]
  ------------------
  484|      0|			break;
  485|       |
  486|   133k|		switch (data[i]) {
  487|  6.63k|		case '\"':
  ------------------
  |  Branch (487:3): [True: 6.63k, False: 126k]
  ------------------
  488|  6.63k|			*txt++ = '\\';
  489|  6.63k|			*txt++ = '\"';
  490|  6.63k|			break;
  491|    209|		case '\\':
  ------------------
  |  Branch (491:3): [True: 209, False: 132k]
  ------------------
  492|    209|			*txt++ = '\\';
  493|    209|			*txt++ = '\\';
  494|    209|			break;
  495|    208|		case '\033':
  ------------------
  |  Branch (495:3): [True: 208, False: 132k]
  ------------------
  496|    208|			*txt++ = '\\';
  497|    208|			*txt++ = 'e';
  498|    208|			break;
  499|    411|		case '\n':
  ------------------
  |  Branch (499:3): [True: 411, False: 132k]
  ------------------
  500|    411|			*txt++ = '\\';
  501|    411|			*txt++ = 'n';
  502|    411|			break;
  503|    301|		case '\r':
  ------------------
  |  Branch (503:3): [True: 301, False: 132k]
  ------------------
  504|    301|			*txt++ = '\\';
  505|    301|			*txt++ = 'r';
  506|    301|			break;
  507|  10.1k|		case '\t':
  ------------------
  |  Branch (507:3): [True: 10.1k, False: 123k]
  ------------------
  508|  10.1k|			*txt++ = '\\';
  509|  10.1k|			*txt++ = 't';
  510|  10.1k|			break;
  511|   115k|		default:
  ------------------
  |  Branch (511:3): [True: 115k, False: 17.8k]
  ------------------
  512|   115k|			if (data[i] >= 32 && data[i] <= 126) {
  ------------------
  |  Branch (512:8): [True: 31.3k, False: 83.9k]
  |  Branch (512:25): [True: 12.6k, False: 18.6k]
  ------------------
  513|  12.6k|				*txt++ = data[i];
  514|   102k|			} else {
  515|   102k|				txt += os_snprintf(txt, end - txt, "\\x%02x",
  ------------------
  |  |  572|   102k|#define os_snprintf snprintf
  ------------------
  516|   102k|						   data[i]);
  517|   102k|			}
  518|   115k|			break;
  519|   133k|		}
  520|   133k|	}
  521|       |
  522|  6.16k|	*txt = '\0';
  523|  6.16k|}
wpa_ssid_txt:
  623|  6.16k|{
  624|  6.16k|	static char ssid_txt[SSID_MAX_LEN * 4 + 1];
  625|       |
  626|  6.16k|	if (ssid == NULL) {
  ------------------
  |  Branch (626:6): [True: 0, False: 6.16k]
  ------------------
  627|      0|		ssid_txt[0] = '\0';
  628|      0|		return ssid_txt;
  629|      0|	}
  630|       |
  631|  6.16k|	printf_encode(ssid_txt, sizeof(ssid_txt), ssid, ssid_len);
  632|  6.16k|	return ssid_txt;
  633|  6.16k|}
has_ctrl_char:
  712|  6.15k|{
  713|  6.15k|	size_t i;
  714|       |
  715|  13.4k|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (715:14): [True: 10.3k, False: 3.13k]
  ------------------
  716|  10.3k|		if (data[i] < 32 || data[i] == 127)
  ------------------
  |  Branch (716:7): [True: 2.83k, False: 7.50k]
  |  Branch (716:23): [True: 183, False: 7.32k]
  ------------------
  717|  3.02k|			return 1;
  718|  10.3k|	}
  719|  3.13k|	return 0;
  720|  6.15k|}
is_ctrl_char:
 1226|  20.4k|{
 1227|  20.4k|	return c > 0 && c < 32;
  ------------------
  |  Branch (1227:9): [True: 14.2k, False: 6.18k]
  |  Branch (1227:18): [True: 4.49k, False: 9.79k]
  ------------------
 1228|  20.4k|}

p2p.c:WPA_GET_LE16:
  225|     14|{
  226|     14|	return (a[1] << 8) | a[0];
  227|     14|}
p2p.c:WPA_GET_BE32:
  260|  28.9k|{
  261|  28.9k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  28.9k|}
p2p.c:is_zero_ether_addr:
  562|  1.86k|{
  563|  1.86k|	return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
  564|  1.86k|}
p2p.c:is_broadcast_ether_addr:
  567|  2.53k|{
  568|  2.53k|	return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
  569|  2.53k|}
p2p.c:ether_addr_equal:
  577|  8.38k|{
  578|  8.38k|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|  8.38k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|  8.38k|}
p2p_go_neg.c:ether_addr_equal:
  577|     43|{
  578|     43|	return os_memcmp(a, b, ETH_ALEN) == 0;
  ------------------
  |  |  532|     43|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  579|     43|}
p2p_parse.c:WPA_GET_LE16:
  225|  46.7k|{
  226|  46.7k|	return (a[1] << 8) | a[0];
  227|  46.7k|}
p2p_parse.c:WPA_GET_LE32:
  273|  2.86k|{
  274|  2.86k|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|  2.86k|}
p2p_parse.c:WPA_GET_BE16:
  214|  7.30k|{
  215|  7.30k|	return (a[0] << 8) | a[1];
  216|  7.30k|}
p2p_pd.c:WPA_GET_LE16:
  225|     73|{
  226|     73|	return (a[1] << 8) | a[0];
  227|     73|}
p2p_pd.c:WPA_GET_LE32:
  273|    165|{
  274|    165|	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  275|    165|}
p2p_pd.c:WPA_PUT_BE32:
  265|    732|{
  266|    732|	a[0] = (val >> 24) & 0xff;
  267|    732|	a[1] = (val >> 16) & 0xff;
  268|    732|	a[2] = (val >> 8) & 0xff;
  269|    732|	a[3] = val & 0xff;
  270|    732|}
p2p_pd.c:WPA_PUT_BE16:
  219|  2.19k|{
  220|  2.19k|	a[0] = val >> 8;
  221|  2.19k|	a[1] = val & 0xff;
  222|  2.19k|}
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.27k|{
  266|  3.27k|	a[0] = (val >> 24) & 0xff;
  267|  3.27k|	a[1] = (val >> 16) & 0xff;
  268|  3.27k|	a[2] = (val >> 8) & 0xff;
  269|  3.27k|	a[3] = val & 0xff;
  270|  3.27k|}
p2p_build.c:WPA_PUT_LE16:
  230|  3.00k|{
  231|  3.00k|	a[1] = val >> 8;
  232|  3.00k|	a[0] = val & 0xff;
  233|  3.00k|}
p2p_build.c:WPA_PUT_BE16:
  219|    366|{
  220|    366|	a[0] = val >> 8;
  221|    366|	a[1] = val & 0xff;
  222|    366|}
wps_attr_build.c:WPA_PUT_BE24:
  241|     42|{
  242|     42|	a[0] = (val >> 16) & 0xff;
  243|     42|	a[1] = (val >> 8) & 0xff;
  244|     42|	a[2] = val & 0xff;
  245|     42|}
wps_attr_build.c:WPA_PUT_BE16:
  219|    174|{
  220|    174|	a[0] = val >> 8;
  221|    174|	a[1] = val & 0xff;
  222|    174|}
wps_attr_parse.c:WPA_GET_BE16:
  214|  2.09M|{
  215|  2.09M|	return (a[0] << 8) | a[1];
  216|  2.09M|}
wps_attr_parse.c:WPA_GET_BE24:
  236|  1.95k|{
  237|  1.95k|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.95k|}
wps_common.c:WPA_GET_BE16:
  214|  3.99k|{
  215|  3.99k|	return (a[0] << 8) | a[1];
  216|  3.99k|}
wps_common.c:WPA_GET_BE32:
  260|  1.99k|{
  261|  1.99k|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.99k|}
ieee802_11_common.c:WPA_GET_BE24:
  236|  1.08M|{
  237|  1.08M|	return (a[0] << 16) | (a[1] << 8) | a[2];
  238|  1.08M|}
ieee802_11_common.c:WPA_GET_BE32:
  260|  1.31M|{
  261|  1.31M|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|  1.31M|}
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.67k|{
  312|  6.67k|	a[0] = val >> 56;
  313|  6.67k|	a[1] = val >> 48;
  314|  6.67k|	a[2] = val >> 40;
  315|  6.67k|	a[3] = val >> 32;
  316|  6.67k|	a[4] = val >> 24;
  317|  6.67k|	a[5] = val >> 16;
  318|  6.67k|	a[6] = val >> 8;
  319|  6.67k|	a[7] = val & 0xff;
  320|  6.67k|}
sha256-internal.c:WPA_PUT_BE32:
  265|  53.4k|{
  266|  53.4k|	a[0] = (val >> 24) & 0xff;
  267|  53.4k|	a[1] = (val >> 16) & 0xff;
  268|  53.4k|	a[2] = (val >> 8) & 0xff;
  269|  53.4k|	a[3] = val & 0xff;
  270|  53.4k|}

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

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

wpa_printf:
  224|  40.5M|{
  225|  40.5M|	va_list ap;
  226|       |
  227|  40.5M|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 40.5M]
  ------------------
  228|       |#ifdef CONFIG_ANDROID_LOG
  229|       |		va_start(ap, fmt);
  230|       |		__android_log_vprint(wpa_to_android_level(level),
  231|       |				     ANDROID_LOG_NAME, fmt, ap);
  232|       |		va_end(ap);
  233|       |#else /* CONFIG_ANDROID_LOG */
  234|       |#ifdef CONFIG_DEBUG_SYSLOG
  235|       |		if (wpa_debug_syslog) {
  236|       |			va_start(ap, fmt);
  237|       |			vsyslog(syslog_priority(level), fmt, ap);
  238|       |			va_end(ap);
  239|       |		}
  240|       |#endif /* CONFIG_DEBUG_SYSLOG */
  241|      0|		wpa_debug_print_timestamp();
  242|      0|#ifdef CONFIG_DEBUG_FILE
  243|      0|		if (out_file) {
  ------------------
  |  Branch (243:7): [True: 0, False: 0]
  ------------------
  244|      0|			va_start(ap, fmt);
  245|      0|			vfprintf(out_file, fmt, ap);
  246|      0|			fprintf(out_file, "\n");
  247|      0|			va_end(ap);
  248|      0|		}
  249|      0|#endif /* CONFIG_DEBUG_FILE */
  250|      0|		if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (250:7): [True: 0, False: 0]
  |  Branch (250:28): [True: 0, False: 0]
  ------------------
  251|      0|			va_start(ap, fmt);
  252|      0|			vprintf(fmt, ap);
  253|      0|			printf("\n");
  254|      0|			va_end(ap);
  255|      0|		}
  256|      0|#endif /* CONFIG_ANDROID_LOG */
  257|      0|	}
  258|       |
  259|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  260|       |	if (wpa_debug_tracing_file != NULL) {
  261|       |		va_start(ap, fmt);
  262|       |		fprintf(wpa_debug_tracing_file, WPAS_TRACE_PFX, level);
  263|       |		vfprintf(wpa_debug_tracing_file, fmt, ap);
  264|       |		fprintf(wpa_debug_tracing_file, "\n");
  265|       |		fflush(wpa_debug_tracing_file);
  266|       |		va_end(ap);
  267|       |	}
  268|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  269|  40.5M|}
wpa_hexdump:
  400|  14.5k|{
  401|  14.5k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  14.5k|}
wpa_hexdump_ascii:
  526|  6.67k|{
  527|  6.67k|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|  6.67k|}
wpa_debug.c:_wpa_hexdump:
  274|  14.5k|{
  275|  14.5k|	size_t i;
  276|       |
  277|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  278|       |	if (wpa_debug_tracing_file != NULL) {
  279|       |		fprintf(wpa_debug_tracing_file,
  280|       |			WPAS_TRACE_PFX "%s - hexdump(len=%lu):",
  281|       |			level, title, (unsigned long) len);
  282|       |		if (buf == NULL) {
  283|       |			fprintf(wpa_debug_tracing_file, " [NULL]\n");
  284|       |		} else if (!show) {
  285|       |			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
  286|       |		} else {
  287|       |			for (i = 0; i < len; i++)
  288|       |				fprintf(wpa_debug_tracing_file,
  289|       |					" %02x", buf[i]);
  290|       |		}
  291|       |		fflush(wpa_debug_tracing_file);
  292|       |	}
  293|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  294|       |
  295|  14.5k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 14.5k, False: 0]
  ------------------
  296|  14.5k|		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|  6.67k|{
  414|  6.67k|	size_t i, llen;
  415|  6.67k|	const u8 *pos = buf;
  416|  6.67k|	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|  6.67k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (437:6): [True: 6.67k, False: 0]
  ------------------
  438|  6.67k|		return;
  439|       |#ifdef CONFIG_ANDROID_LOG
  440|       |	_wpa_hexdump(level, title, buf, len, show, 0);
  441|       |#else /* CONFIG_ANDROID_LOG */
  442|       |#ifdef CONFIG_DEBUG_SYSLOG
  443|       |	if (wpa_debug_syslog)
  444|       |		_wpa_hexdump(level, title, buf, len, show, 1);
  445|       |#endif /* CONFIG_DEBUG_SYSLOG */
  446|      0|	wpa_debug_print_timestamp();
  447|      0|#ifdef CONFIG_DEBUG_FILE
  448|      0|	if (out_file) {
  ------------------
  |  Branch (448:6): [True: 0, False: 0]
  ------------------
  449|      0|		if (!show) {
  ------------------
  |  Branch (449:7): [True: 0, False: 0]
  ------------------
  450|      0|			fprintf(out_file,
  451|      0|				"%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  452|      0|				title, (unsigned long) len);
  453|      0|			goto file_done;
  454|      0|		}
  455|      0|		if (buf == NULL) {
  ------------------
  |  Branch (455:7): [True: 0, False: 0]
  ------------------
  456|      0|			fprintf(out_file,
  457|      0|				"%s - hexdump_ascii(len=%lu): [NULL]\n",
  458|      0|				title, (unsigned long) len);
  459|      0|			goto file_done;
  460|      0|		}
  461|      0|		fprintf(out_file, "%s - hexdump_ascii(len=%lu):\n",
  462|      0|			title, (unsigned long) len);
  463|      0|		while (len) {
  ------------------
  |  Branch (463:10): [True: 0, False: 0]
  ------------------
  464|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (464:11): [True: 0, False: 0]
  ------------------
  465|      0|			fprintf(out_file, "    ");
  466|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (466:16): [True: 0, False: 0]
  ------------------
  467|      0|				fprintf(out_file, " %02x", pos[i]);
  468|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (468:19): [True: 0, False: 0]
  ------------------
  469|      0|				fprintf(out_file, "   ");
  470|      0|			fprintf(out_file, "   ");
  471|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (471:16): [True: 0, False: 0]
  ------------------
  472|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|					fprintf(out_file, "%c", pos[i]);
  474|      0|				else
  475|      0|					fprintf(out_file, "_");
  476|      0|			}
  477|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (477:19): [True: 0, False: 0]
  ------------------
  478|      0|				fprintf(out_file, " ");
  479|      0|			fprintf(out_file, "\n");
  480|      0|			pos += llen;
  481|      0|			len -= llen;
  482|      0|		}
  483|      0|	}
  484|      0|file_done:
  485|      0|#endif /* CONFIG_DEBUG_FILE */
  486|      0|	if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (486:6): [True: 0, False: 0]
  |  Branch (486:27): [True: 0, False: 0]
  ------------------
  487|      0|		if (!show) {
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|			printf("%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  489|      0|			       title, (unsigned long) len);
  490|      0|			return;
  491|      0|		}
  492|      0|		if (buf == NULL) {
  ------------------
  |  Branch (492:7): [True: 0, False: 0]
  ------------------
  493|      0|			printf("%s - hexdump_ascii(len=%lu): [NULL]\n",
  494|      0|			       title, (unsigned long) len);
  495|      0|			return;
  496|      0|		}
  497|      0|		printf("%s - hexdump_ascii(len=%lu):\n", title,
  498|      0|		       (unsigned long) len);
  499|      0|		while (len) {
  ------------------
  |  Branch (499:10): [True: 0, False: 0]
  ------------------
  500|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (500:11): [True: 0, False: 0]
  ------------------
  501|      0|			printf("    ");
  502|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (502:16): [True: 0, False: 0]
  ------------------
  503|      0|				printf(" %02x", pos[i]);
  504|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (504:19): [True: 0, False: 0]
  ------------------
  505|      0|				printf("   ");
  506|      0|			printf("   ");
  507|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (507:16): [True: 0, False: 0]
  ------------------
  508|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (508:9): [True: 0, False: 0]
  ------------------
  509|      0|					printf("%c", pos[i]);
  510|      0|				else
  511|      0|					printf("_");
  512|      0|			}
  513|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (513:19): [True: 0, False: 0]
  ------------------
  514|      0|				printf(" ");
  515|      0|			printf("\n");
  516|      0|			pos += llen;
  517|      0|			len -= llen;
  518|      0|		}
  519|      0|	}
  520|      0|#endif /* CONFIG_ANDROID_LOG */
  521|      0|}

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

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

p2p.c:wpabuf_size:
   49|  5.89k|{
   50|  5.89k|	return buf->size;
   51|  5.89k|}
p2p.c:wpabuf_put_data:
  174|  5.89k|{
  175|  5.89k|	if (data)
  ------------------
  |  Branch (175:6): [True: 5.89k, False: 0]
  ------------------
  176|  5.89k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  5.89k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  5.89k|}
p2p_dev_disc.c:wpabuf_head:
   94|      9|{
   95|      9|	return buf->buf;
   96|      9|}
p2p_dev_disc.c:wpabuf_len:
   59|      9|{
   60|      9|	return buf->used;
   61|      9|}
p2p_go_neg.c:wpabuf_len:
   59|     61|{
   60|     61|	return buf->used;
   61|     61|}
p2p_go_neg.c:wpabuf_head:
   94|     61|{
   95|     61|	return buf->buf;
   96|     61|}
p2p_invitation.c:wpabuf_len:
   59|  1.59k|{
   60|  1.59k|	return buf->used;
   61|  1.59k|}
p2p_invitation.c:wpabuf_put_buf:
  181|    796|{
  182|    796|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    796|}
p2p_invitation.c:wpabuf_put_data:
  174|    796|{
  175|    796|	if (data)
  ------------------
  |  Branch (175:6): [True: 796, False: 0]
  ------------------
  176|    796|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    796|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    796|}
p2p_invitation.c:wpabuf_head:
   94|  1.59k|{
   95|  1.59k|	return buf->buf;
   96|  1.59k|}
p2p_parse.c:wpabuf_head_u8:
   99|  7.53k|{
  100|  7.53k|	return (const u8 *) wpabuf_head(buf);
  101|  7.53k|}
p2p_parse.c:wpabuf_head:
   94|  9.01k|{
   95|  9.01k|	return buf->buf;
   96|  9.01k|}
p2p_parse.c:wpabuf_len:
   59|  9.01k|{
   60|  9.01k|	return buf->used;
   61|  9.01k|}
p2p_pd.c:wpabuf_put_u8:
  119|    732|{
  120|    732|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    732|	*pos = data;
  122|    732|}
p2p_pd.c:wpabuf_put_be32:
  161|    732|{
  162|    732|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|    732|	WPA_PUT_BE32(pos, data);
  164|    732|}
p2p_pd.c:wpabuf_put_be16:
  149|  2.19k|{
  150|  2.19k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|  2.19k|	WPA_PUT_BE16(pos, data);
  152|  2.19k|}
p2p_pd.c:wpabuf_head:
   94|    770|{
   95|    770|	return buf->buf;
   96|    770|}
p2p_pd.c:wpabuf_len:
   59|    770|{
   60|    770|	return buf->used;
   61|    770|}
p2p_build.c:wpabuf_put_u8:
  119|  15.6k|{
  120|  15.6k|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|  15.6k|	*pos = data;
  122|  15.6k|}
p2p_build.c:wpabuf_put_be32:
  161|  3.27k|{
  162|  3.27k|	u8 *pos = (u8 *) wpabuf_put(buf, 4);
  163|  3.27k|	WPA_PUT_BE32(pos, data);
  164|  3.27k|}
p2p_build.c:wpabuf_put_le16:
  125|  2.80k|{
  126|  2.80k|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  127|  2.80k|	WPA_PUT_LE16(pos, data);
  128|  2.80k|}
p2p_build.c:wpabuf_put_data:
  174|  1.26k|{
  175|  1.26k|	if (data)
  ------------------
  |  Branch (175:6): [True: 1.20k, False: 64]
  ------------------
  176|  1.20k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|  1.20k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|  1.26k|}
p2p_build.c:wpabuf_put_be16:
  149|    366|{
  150|    366|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    366|	WPA_PUT_BE16(pos, data);
  152|    366|}
p2p_build.c:wpabuf_tailroom:
   69|    123|{
   70|    123|	return buf->size - buf->used;
   71|    123|}
p2p_build.c:wpabuf_len:
   59|  1.71k|{
   60|  1.71k|	return buf->used;
   61|  1.71k|}
p2p_build.c:wpabuf_head:
   94|    857|{
   95|    857|	return buf->buf;
   96|    857|}
wps_attr_build.c:wpabuf_put_be16:
  149|    132|{
  150|    132|	u8 *pos = (u8 *) wpabuf_put(buf, 2);
  151|    132|	WPA_PUT_BE16(pos, data);
  152|    132|}
wps_attr_build.c:wpabuf_put_u8:
  119|    168|{
  120|    168|	u8 *pos = (u8 *) wpabuf_put(buf, 1);
  121|    168|	*pos = data;
  122|    168|}
wps_attr_build.c:wpabuf_tailroom:
   69|     87|{
   70|     87|	return buf->size - buf->used;
   71|     87|}
wps_attr_build.c:wpabuf_put_data:
  174|      3|{
  175|      3|	if (data)
  ------------------
  |  Branch (175:6): [True: 3, False: 0]
  ------------------
  176|      3|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|      3|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|      3|}
wps_attr_build.c:wpabuf_put_be24:
  155|     42|{
  156|     42|	u8 *pos = (u8 *) wpabuf_put(buf, 3);
  157|     42|	WPA_PUT_BE24(pos, data);
  158|     42|}
wps_attr_parse.c:wpabuf_head:
   94|  5.89k|{
   95|  5.89k|	return buf->buf;
   96|  5.89k|}
wps_attr_parse.c:wpabuf_len:
   59|  5.89k|{
   60|  5.89k|	return buf->used;
   61|  5.89k|}
wpabuf.c:wpabuf_put_data:
  174|    713|{
  175|    713|	if (data)
  ------------------
  |  Branch (175:6): [True: 713, False: 0]
  ------------------
  176|    713|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|    713|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|    713|}
wpabuf.c:wpabuf_len:
   59|   564k|{
   60|   564k|	return buf->used;
   61|   564k|}
wpabuf.c:wpabuf_head:
   94|    553|{
   95|    553|	return buf->buf;
   96|    553|}
wpabuf.c:wpabuf_mhead:
  109|   563k|{
  110|   563k|	return buf->buf;
  111|   563k|}
wpabuf.c:wpabuf_mhead_u8:
  114|   563k|{
  115|   563k|	return (u8 *) wpabuf_mhead(buf);
  116|   563k|}
wpabuf.c:wpabuf_put_buf:
  181|    122|{
  182|    122|	wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
  183|    122|}
ieee802_11_common.c:wpabuf_put_data:
  174|   525k|{
  175|   525k|	if (data)
  ------------------
  |  Branch (175:6): [True: 525k, False: 0]
  ------------------
  176|   525k|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  523|   525k|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|   525k|}

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

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

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

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

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

