Lines Matching refs:group
49 struct p2p_group *group, **groups; in p2p_group_init() local
51 group = os_zalloc(sizeof(*group)); in p2p_group_init()
52 if (group == NULL) in p2p_group_init()
58 os_free(group); in p2p_group_init()
61 groups[p2p->num_groups++] = group; in p2p_group_init()
64 group->p2p = p2p; in p2p_group_init()
65 group->cfg = config; in p2p_group_init()
66 group->group_formation = 1; in p2p_group_init()
67 group->beacon_update = 1; in p2p_group_init()
68 p2p_group_update_ies(group); in p2p_group_init()
69 group->cfg->idle_update(group->cfg->cb_ctx, 1); in p2p_group_init()
71 return group; in p2p_group_init()
84 static void p2p_group_free_members(struct p2p_group *group) in p2p_group_free_members() argument
87 m = group->members; in p2p_group_free_members()
88 group->members = NULL; in p2p_group_free_members()
89 group->num_members = 0; in p2p_group_free_members()
98 void p2p_group_deinit(struct p2p_group *group) in p2p_group_deinit() argument
103 if (group == NULL) in p2p_group_deinit()
106 p2p = group->p2p; in p2p_group_deinit()
109 if (p2p->groups[g] == group) { in p2p_group_deinit()
119 p2p_group_free_members(group); in p2p_group_deinit()
120 os_free(group->cfg); in p2p_group_deinit()
121 wpabuf_free(group->noa); in p2p_group_deinit()
122 wpabuf_free(group->wfd_ie); in p2p_group_deinit()
123 os_free(group); in p2p_group_deinit()
137 static void p2p_group_add_common_ies(struct p2p_group *group, in p2p_group_add_common_ies() argument
140 u8 dev_capab = group->p2p->dev_capab, group_capab = 0; in p2p_group_add_common_ies()
145 if (group->cfg->persistent_group) { in p2p_group_add_common_ies()
147 if (group->cfg->persistent_group == 2) in p2p_group_add_common_ies()
150 if (group->p2p->cfg->p2p_intra_bss) in p2p_group_add_common_ies()
152 if (group->group_formation) in p2p_group_add_common_ies()
154 if (group->p2p->cross_connect) in p2p_group_add_common_ies()
156 if (group->num_members >= group->cfg->max_clients) in p2p_group_add_common_ies()
158 if (group->cfg->ip_addr_alloc) in p2p_group_add_common_ies()
208 static struct wpabuf * p2p_group_build_beacon_ie(struct p2p_group *group) in p2p_group_build_beacon_ie() argument
215 if (group->p2p->wfd_ie_beacon) in p2p_group_build_beacon_ie()
216 extra = wpabuf_len(group->p2p->wfd_ie_beacon); in p2p_group_build_beacon_ie()
219 if (group->p2p->vendor_elem && in p2p_group_build_beacon_ie()
220 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]) in p2p_group_build_beacon_ie()
221 extra += wpabuf_len(group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]); in p2p_group_build_beacon_ie()
228 if (group->p2p->wfd_ie_beacon) in p2p_group_build_beacon_ie()
229 wpabuf_put_buf(ie, group->p2p->wfd_ie_beacon); in p2p_group_build_beacon_ie()
232 if (group->p2p->vendor_elem && in p2p_group_build_beacon_ie()
233 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]) in p2p_group_build_beacon_ie()
235 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]); in p2p_group_build_beacon_ie()
238 p2p_group_add_common_ies(group, ie); in p2p_group_build_beacon_ie()
239 p2p_buf_add_device_id(ie, group->p2p->cfg->dev_addr); in p2p_group_build_beacon_ie()
240 p2p_group_add_noa(ie, group->noa); in p2p_group_build_beacon_ie()
354 wifi_display_build_go_ie(struct p2p_group *group) in wifi_display_build_go_ie() argument
361 if (!group->p2p->wfd_ie_probe_resp) in wifi_display_build_go_ie()
364 wfd_subelems = wpabuf_alloc(wpabuf_len(group->p2p->wfd_ie_probe_resp) + in wifi_display_build_go_ie()
365 group->num_members * 24 + 100); in wifi_display_build_go_ie()
368 if (group->p2p->wfd_dev_info) in wifi_display_build_go_ie()
369 wpabuf_put_buf(wfd_subelems, group->p2p->wfd_dev_info); in wifi_display_build_go_ie()
370 if (group->p2p->wfd_r2_dev_info) in wifi_display_build_go_ie()
371 wpabuf_put_buf(wfd_subelems, group->p2p->wfd_r2_dev_info); in wifi_display_build_go_ie()
372 if (group->p2p->wfd_assoc_bssid) in wifi_display_build_go_ie()
374 group->p2p->wfd_assoc_bssid); in wifi_display_build_go_ie()
375 if (group->p2p->wfd_coupled_sink_info) in wifi_display_build_go_ie()
377 group->p2p->wfd_coupled_sink_info); in wifi_display_build_go_ie()
382 m = group->members; in wifi_display_build_go_ie()
395 p2p_dbg(group->p2p, "WFD: WFD Session Info: %u descriptors", in wifi_display_build_go_ie()
405 static void wifi_display_group_update(struct p2p_group *group) in wifi_display_group_update() argument
407 wpabuf_free(group->wfd_ie); in wifi_display_group_update()
408 group->wfd_ie = wifi_display_build_go_ie(group); in wifi_display_group_update()
414 void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf, in p2p_buf_add_group_info() argument
421 p2p_dbg(group->p2p, "* P2P Group Info"); in p2p_buf_add_group_info()
425 for (m = group->members; m; m = m->next) { in p2p_buf_add_group_info()
436 void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf) in p2p_group_buf_add_id() argument
438 p2p_buf_add_group_id(buf, group->p2p->cfg->dev_addr, group->cfg->ssid, in p2p_group_buf_add_id()
439 group->cfg->ssid_len); in p2p_group_buf_add_id()
443 static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group) in p2p_group_build_probe_resp_ie() argument
451 p2p_group_add_common_ies(group, p2p_subelems); in p2p_group_build_probe_resp_ie()
452 p2p_group_add_noa(p2p_subelems, group->noa); in p2p_group_build_probe_resp_ie()
455 p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL); in p2p_group_build_probe_resp_ie()
458 if (group->members) in p2p_group_build_probe_resp_ie()
459 p2p_buf_add_group_info(group, p2p_subelems, -1); in p2p_group_build_probe_resp_ie()
464 if (group->p2p->vendor_elem && in p2p_group_build_probe_resp_ie()
465 group->p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P_GO]) { in p2p_group_build_probe_resp_ie()
467 extra = wpabuf_dup(group->p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P_GO]); in p2p_group_build_probe_resp_ie()
472 if (group->wfd_ie) { in p2p_group_build_probe_resp_ie()
473 struct wpabuf *wfd = wpabuf_dup(group->wfd_ie); in p2p_group_build_probe_resp_ie()
482 void p2p_group_update_ies(struct p2p_group *group) in p2p_group_update_ies() argument
488 wifi_display_group_update(group); in p2p_group_update_ies()
491 probe_resp_ie = p2p_group_build_probe_resp_ie(group); in p2p_group_update_ies()
497 if (group->beacon_update) { in p2p_group_update_ies()
498 beacon_ie = p2p_group_build_beacon_ie(group); in p2p_group_update_ies()
500 group->beacon_update = 0; in p2p_group_update_ies()
506 group->cfg->ie_update(group->cfg->cb_ctx, beacon_ie, probe_resp_ie); in p2p_group_update_ies()
572 static int p2p_group_remove_member(struct p2p_group *group, const u8 *addr) in p2p_group_remove_member() argument
576 if (group == NULL) in p2p_group_remove_member()
579 m = group->members; in p2p_group_remove_member()
594 group->members = m->next; in p2p_group_remove_member()
596 group->num_members--; in p2p_group_remove_member()
602 int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr, in p2p_group_notif_assoc() argument
607 if (group == NULL) in p2p_group_notif_assoc()
610 p2p_add_device(group->p2p, addr, 0, NULL, 0, ie, len, 0); in p2p_group_notif_assoc()
626 p2p_group_remove_member(group, addr); in p2p_group_notif_assoc()
628 m->next = group->members; in p2p_group_notif_assoc()
629 group->members = m; in p2p_group_notif_assoc()
630 group->num_members++; in p2p_group_notif_assoc()
631 p2p_dbg(group->p2p, "Add client " MACSTR in p2p_group_notif_assoc()
635 group->num_members, group->cfg->max_clients); in p2p_group_notif_assoc()
636 if (group->num_members == group->cfg->max_clients) in p2p_group_notif_assoc()
637 group->beacon_update = 1; in p2p_group_notif_assoc()
638 p2p_group_update_ies(group); in p2p_group_notif_assoc()
639 if (group->num_members == 1) in p2p_group_notif_assoc()
640 group->cfg->idle_update(group->cfg->cb_ctx, 0); in p2p_group_notif_assoc()
646 struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status) in p2p_group_assoc_resp_ie() argument
653 if (group->wfd_ie) in p2p_group_assoc_resp_ie()
654 extra = wpabuf_len(group->wfd_ie); in p2p_group_assoc_resp_ie()
657 if (group->p2p->vendor_elem && in p2p_group_assoc_resp_ie()
658 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]) in p2p_group_assoc_resp_ie()
659 extra += wpabuf_len(group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]); in p2p_group_assoc_resp_ie()
672 if (group->wfd_ie) in p2p_group_assoc_resp_ie()
673 wpabuf_put_buf(resp, group->wfd_ie); in p2p_group_assoc_resp_ie()
676 if (group->p2p->vendor_elem && in p2p_group_assoc_resp_ie()
677 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]) in p2p_group_assoc_resp_ie()
679 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]); in p2p_group_assoc_resp_ie()
690 void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr) in p2p_group_notif_disassoc() argument
692 if (p2p_group_remove_member(group, addr)) { in p2p_group_notif_disassoc()
693 p2p_dbg(group->p2p, "Remove client " MACSTR in p2p_group_notif_disassoc()
695 MAC2STR(addr), group->num_members, in p2p_group_notif_disassoc()
696 group->cfg->max_clients); in p2p_group_notif_disassoc()
697 if (group->num_members == group->cfg->max_clients - 1) in p2p_group_notif_disassoc()
698 group->beacon_update = 1; in p2p_group_notif_disassoc()
699 p2p_group_update_ies(group); in p2p_group_notif_disassoc()
700 if (group->num_members == 0) in p2p_group_notif_disassoc()
701 group->cfg->idle_update(group->cfg->cb_ctx, 1); in p2p_group_notif_disassoc()
759 int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps) in p2p_group_match_dev_type() argument
763 if (p2p_match_dev_type(group->p2p, wps)) in p2p_group_match_dev_type()
766 for (m = group->members; m; m = m->next) { in p2p_group_match_dev_type()
776 int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p) in p2p_group_match_dev_id() argument
788 if (os_memcmp(msg.device_id, group->p2p->cfg->dev_addr, ETH_ALEN) == 0) in p2p_group_match_dev_id()
791 for (m = group->members; m; m = m->next) { in p2p_group_match_dev_id()
801 void p2p_group_notif_formation_done(struct p2p_group *group) in p2p_group_notif_formation_done() argument
803 if (group == NULL) in p2p_group_notif_formation_done()
805 group->group_formation = 0; in p2p_group_notif_formation_done()
806 group->beacon_update = 1; in p2p_group_notif_formation_done()
807 p2p_group_update_ies(group); in p2p_group_notif_formation_done()
811 int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, in p2p_group_notif_noa() argument
815 wpabuf_free(group->noa); in p2p_group_notif_noa()
816 group->noa = NULL; in p2p_group_notif_noa()
818 if (group->noa) { in p2p_group_notif_noa()
819 if (wpabuf_size(group->noa) >= noa_len) { in p2p_group_notif_noa()
820 group->noa->used = 0; in p2p_group_notif_noa()
821 wpabuf_put_data(group->noa, noa, noa_len); in p2p_group_notif_noa()
823 wpabuf_free(group->noa); in p2p_group_notif_noa()
824 group->noa = NULL; in p2p_group_notif_noa()
828 if (!group->noa) { in p2p_group_notif_noa()
829 group->noa = wpabuf_alloc_copy(noa, noa_len); in p2p_group_notif_noa()
830 if (group->noa == NULL) in p2p_group_notif_noa()
835 group->beacon_update = 1; in p2p_group_notif_noa()
836 p2p_group_update_ies(group); in p2p_group_notif_noa()
841 static struct p2p_group_member * p2p_group_get_client(struct p2p_group *group, in p2p_group_get_client() argument
846 for (m = group->members; m; m = m->next) { in p2p_group_get_client()
855 const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group, in p2p_group_get_client_interface_addr() argument
860 if (!group) in p2p_group_get_client_interface_addr()
862 m = p2p_group_get_client(group, dev_addr); in p2p_group_get_client_interface_addr()
870 struct p2p_group *group, const u8 *interface_addr) in p2p_group_get_client_iface() argument
874 for (m = group->members; m; m = m->next) { in p2p_group_get_client_iface()
883 const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr) in p2p_group_get_dev_addr() argument
887 if (group == NULL) in p2p_group_get_dev_addr()
889 m = p2p_group_get_client_iface(group, addr); in p2p_group_get_dev_addr()
910 int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id, in p2p_group_go_discover() argument
915 struct p2p_data *p2p = group->p2p; in p2p_group_go_discover()
918 m = p2p_group_get_client(group, dev_id); in p2p_group_go_discover()
920 p2p_dbg(group->p2p, "Requested client was not in this group " in p2p_group_go_discover()
921 MACSTR, MAC2STR(group->cfg->interface_addr)); in p2p_group_go_discover()
926 p2p_dbg(group->p2p, "Requested client does not support client discoverability"); in p2p_group_go_discover()
930 p2p_dbg(group->p2p, "Schedule GO Discoverability Request to be sent to " in p2p_group_go_discover()
942 group->cfg->interface_addr, in p2p_group_go_discover()
943 group->cfg->interface_addr, in p2p_group_go_discover()
956 const u8 * p2p_group_get_interface_addr(struct p2p_group *group) in p2p_group_get_interface_addr() argument
958 return group->cfg->interface_addr; in p2p_group_get_interface_addr()
962 u8 p2p_group_presence_req(struct p2p_group *group, in p2p_group_presence_req() argument
970 m = p2p_group_get_client_iface(group, client_interface_addr); in p2p_group_presence_req()
972 p2p_dbg(group->p2p, "Client was not in this group"); in p2p_group_presence_req()
978 if (group->p2p->cfg->get_noa) in p2p_group_presence_req()
979 curr_noa_len = group->p2p->cfg->get_noa( in p2p_group_presence_req()
980 group->p2p->cfg->cb_ctx, group->cfg->interface_addr, in p2p_group_presence_req()
985 p2p_dbg(group->p2p, "Failed to fetch current NoA"); in p2p_group_presence_req()
987 p2p_dbg(group->p2p, "No NoA being advertized"); in p2p_group_presence_req()
1000 unsigned int p2p_get_group_num_members(struct p2p_group *group) in p2p_get_group_num_members() argument
1002 if (!group) in p2p_get_group_num_members()
1005 return group->num_members; in p2p_get_group_num_members()
1009 int p2p_client_limit_reached(struct p2p_group *group) in p2p_client_limit_reached() argument
1011 if (!group || !group->cfg) in p2p_client_limit_reached()
1014 return group->num_members >= group->cfg->max_clients; in p2p_client_limit_reached()
1018 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next) in p2p_iterate_group_members() argument
1023 iter = group->members; in p2p_iterate_group_members()
1036 int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr) in p2p_group_is_client_connected() argument
1040 for (m = group->members; m; m = m->next) { in p2p_group_is_client_connected()
1049 int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id, in p2p_group_is_group_id_match() argument
1052 if (group_id_len != ETH_ALEN + group->cfg->ssid_len) in p2p_group_is_group_id_match()
1054 if (os_memcmp(group_id, group->p2p->cfg->dev_addr, ETH_ALEN) != 0) in p2p_group_is_group_id_match()
1056 return os_memcmp(group_id + ETH_ALEN, group->cfg->ssid, in p2p_group_is_group_id_match()
1057 group->cfg->ssid_len) == 0; in p2p_group_is_group_id_match()
1061 void p2p_group_force_beacon_update_ies(struct p2p_group *group) in p2p_group_force_beacon_update_ies() argument
1063 group->beacon_update = 1; in p2p_group_force_beacon_update_ies()
1064 p2p_group_update_ies(group); in p2p_group_force_beacon_update_ies()
1068 int p2p_group_get_freq(struct p2p_group *group) in p2p_group_get_freq() argument
1070 return group->cfg->freq; in p2p_group_get_freq()
1074 const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group) in p2p_group_get_config() argument
1076 return group->cfg; in p2p_group_get_config()
1081 int (*group_callback)(struct p2p_group *group, in p2p_loop_on_all_groups() argument
1094 int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs, in p2p_group_get_common_freqs() argument
1101 if (!group || !common_freqs || !num) in p2p_group_get_common_freqs()
1107 p2p_channels_union(&intersect, &group->p2p->cfg->channels, in p2p_group_get_common_freqs()
1110 p2p_channels_dump(group->p2p, in p2p_group_get_common_freqs()
1114 for (m = group->members; m; m = m->next) { in p2p_group_get_common_freqs()
1117 dev = p2p_get_device(group->p2p, m->dev_addr); in p2p_group_get_common_freqs()
1125 p2p_channels_dump(group->p2p, "Group common channels", &intersect); in p2p_group_get_common_freqs()