Lines Matching defs:group
2 * Wi-Fi Direct - P2P group operations
32 * struct p2p_group - Internal P2P module per-group data
49 struct p2p_group *group, **groups;
51 group = os_zalloc(sizeof(*group));
52 if (group == NULL)
58 os_free(group);
61 groups[p2p->num_groups++] = group;
64 group->p2p = p2p;
65 group->cfg = config;
66 group->group_formation = 1;
67 group->beacon_update = 1;
68 p2p_group_update_ies(group);
69 group->cfg->idle_update(group->cfg->cb_ctx, 1);
71 return group;
84 static void p2p_group_free_members(struct p2p_group *group)
87 m = group->members;
88 group->members = NULL;
89 group->num_members = 0;
98 void p2p_group_deinit(struct p2p_group *group)
103 if (group == NULL)
106 p2p = group->p2p;
109 if (p2p->groups[g] == group) {
119 p2p_group_free_members(group);
120 os_free(group->cfg);
121 wpabuf_free(group->noa);
122 wpabuf_free(group->wfd_ie);
123 os_free(group);
137 static void p2p_group_add_common_ies(struct p2p_group *group,
140 u8 dev_capab = group->p2p->dev_capab, group_capab = 0;
145 if (group->cfg->persistent_group) {
147 if (group->cfg->persistent_group == 2)
150 if (group->p2p->cfg->p2p_intra_bss)
152 if (group->group_formation)
154 if (group->p2p->cross_connect)
156 if (group->num_members >= group->cfg->max_clients)
158 if (group->cfg->ip_addr_alloc)
208 static struct wpabuf * p2p_group_build_beacon_ie(struct p2p_group *group)
215 if (group->p2p->wfd_ie_beacon)
216 extra = wpabuf_len(group->p2p->wfd_ie_beacon);
219 if (group->p2p->vendor_elem &&
220 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO])
221 extra += wpabuf_len(group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]);
228 if (group->p2p->wfd_ie_beacon)
229 wpabuf_put_buf(ie, group->p2p->wfd_ie_beacon);
232 if (group->p2p->vendor_elem &&
233 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO])
235 group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]);
238 p2p_group_add_common_ies(group, ie);
239 p2p_buf_add_device_id(ie, group->p2p->cfg->dev_addr);
240 p2p_group_add_noa(ie, group->noa);
354 wifi_display_build_go_ie(struct p2p_group *group)
361 if (!group->p2p->wfd_ie_probe_resp)
364 wfd_subelems = wpabuf_alloc(wpabuf_len(group->p2p->wfd_ie_probe_resp) +
365 group->num_members * 24 + 100);
368 if (group->p2p->wfd_dev_info)
369 wpabuf_put_buf(wfd_subelems, group->p2p->wfd_dev_info);
370 if (group->p2p->wfd_assoc_bssid)
372 group->p2p->wfd_assoc_bssid);
373 if (group->p2p->wfd_coupled_sink_info)
375 group->p2p->wfd_coupled_sink_info);
380 m = group->members;
393 p2p_dbg(group->p2p, "WFD: WFD Session Info: %u descriptors",
403 static void wifi_display_group_update(struct p2p_group *group)
405 wpabuf_free(group->wfd_ie);
406 group->wfd_ie = wifi_display_build_go_ie(group);
412 void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf,
419 p2p_dbg(group->p2p, "* P2P Group Info");
423 for (m = group->members; m; m = m->next) {
434 void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf)
436 p2p_buf_add_group_id(buf, group->p2p->cfg->dev_addr, group->cfg->ssid,
437 group->cfg->ssid_len);
441 static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
449 p2p_group_add_common_ies(group, p2p_subelems);
450 p2p_group_add_noa(p2p_subelems, group->noa);
453 p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL);
455 /* P2P Group Info: Only when at least one P2P Client is connected */
456 if (group->members)
457 p2p_buf_add_group_info(group, p2p_subelems, -1);
462 if (group->p2p->vendor_elem &&
463 group->p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P_GO]) {
465 extra = wpabuf_dup(group->p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P_GO]);
470 if (group->wfd_ie) {
471 struct wpabuf *wfd = wpabuf_dup(group->wfd_ie);
480 void p2p_group_update_ies(struct p2p_group *group)
486 wifi_display_group_update(group);
489 probe_resp_ie = p2p_group_build_probe_resp_ie(group);
495 if (group->beacon_update) {
496 beacon_ie = p2p_group_build_beacon_ie(group);
498 group->beacon_update = 0;
504 group->cfg->ie_update(group->cfg->cb_ctx, beacon_ie, probe_resp_ie);
517 * available from (Re)Association Request frame. Group owner can use this to
518 * build the P2P Group Info attribute for Probe Response frames.
570 static int p2p_group_remove_member(struct p2p_group *group, const u8 *addr)
574 if (group == NULL)
577 m = group->members;
592 group->members = m->next;
594 group->num_members--;
600 int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
605 if (group == NULL)
608 p2p_add_device(group->p2p, addr, 0, NULL, 0, ie, len, 0);
624 p2p_group_remove_member(group, addr);
626 m->next = group->members;
627 group->members = m;
628 group->num_members++;
629 p2p_dbg(group->p2p, "Add client " MACSTR
630 " to group (p2p=%d wfd=%d client_info=%d); num_members=%u/%u",
633 group->num_members, group->cfg->max_clients);
634 if (group->num_members == group->cfg->max_clients)
635 group->beacon_update = 1;
636 p2p_group_update_ies(group);
637 if (group->num_members == 1)
638 group->cfg->idle_update(group->cfg->cb_ctx, 0);
644 struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status)
651 if (group->wfd_ie)
652 extra = wpabuf_len(group->wfd_ie);
655 if (group->p2p->vendor_elem &&
656 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP])
657 extra += wpabuf_len(group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]);
670 if (group->wfd_ie)
671 wpabuf_put_buf(resp, group->wfd_ie);
674 if (group->p2p->vendor_elem &&
675 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP])
677 group->p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_RESP]);
688 void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr)
690 if (p2p_group_remove_member(group, addr)) {
691 p2p_dbg(group->p2p, "Remove client " MACSTR
692 " from group; num_members=%u/%u",
693 MAC2STR(addr), group->num_members,
694 group->cfg->max_clients);
695 if (group->num_members == group
696 group->beacon_update = 1;
697 p2p_group_update_ies(group);
698 if (group->num_members == 0)
699 group->cfg->idle_update(group->cfg->cb_ctx, 1);
706 * @m: Group member
711 * WPS IE with the device types of a group member for deciding whether a GO
757 int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps)
761 if (p2p_match_dev_type(group->p2p, wps))
764 for (m = group->members; m; m = m->next) {
766 return 1; /* Match with group client device type */
774 int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p)
786 if (os_memcmp(msg.device_id, group->p2p->cfg->dev_addr, ETH_ALEN) == 0)
789 for (m = group->members; m; m = m->next) {
791 return 1; /* Match with group client P2P Device Address */
799 void p2p_group_notif_formation_done(struct p2p_group *group)
801 if (group == NULL)
803 group->group_formation = 0;
804 group->beacon_update = 1;
805 p2p_group_update_ies(group);
809 int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
813 wpabuf_free(group->noa);
814 group->noa = NULL;
816 if (group->noa) {
817 if (wpabuf_size(group->noa) >= noa_len) {
818 group->noa->used = 0;
819 wpabuf_put_data(group->noa, noa, noa_len);
821 wpabuf_free(group->noa);
822 group->noa = NULL;
826 if (!group->noa) {
827 group->noa = wpabuf_alloc_copy(noa, noa_len);
828 if (group->noa == NULL)
833 group->beacon_update = 1;
834 p2p_group_update_ies(group);
839 static struct p2p_group_member * p2p_group_get_client(struct p2p_group *group,
844 for (m = group->members; m; m = m->next) {
854 struct p2p_group *group, const u8 *interface_addr)
858 for (m = group->members; m; m = m->next) {
867 const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr)
871 if (group == NULL)
873 m = p2p_group_get_client_iface(group, addr);
894 int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
899 struct p2p_data *p2p = group->p2p;
902 m = p2p_group_get_client(group, dev_id);
904 p2p_dbg(group->p2p, "Requested client was not in this group "
905 MACSTR, MAC2STR(group->cfg->interface_addr));
910 p2p_dbg(group->p2p, "Requested client does not support client discoverability");
914 p2p_dbg(group->p2p, "Schedule GO Discoverability Request to be sent to "
921 /* TODO: Should really use group operating frequency here */
926 group->cfg->interface_addr,
927 group->cfg->interface_addr,
939 const u8 * p2p_group_get_interface_addr(struct p2p_group *group)
941 return group->cfg->interface_addr;
945 u8 p2p_group_presence_req(struct p2p_group *group,
953 m = p2p_group_get_client_iface(group, client_interface_addr);
955 p2p_dbg(group->p2p, "Client was not in this group");
961 if (group->p2p->cfg->get_noa)
962 curr_noa_len = group->p2p->cfg->get_noa(
963 group->p2p->cfg->cb_ctx, group->cfg->interface_addr,
968 p2p_dbg(group->p2p, "Failed to fetch current NoA");
970 p2p_dbg(group->p2p, "No NoA being advertized");
983 unsigned int p2p_get_group_num_members(struct p2p_group *group)
985 if (!group)
988 return group->num_members;
992 int p2p_client_limit_reached(struct p2p_group *group)
994 if (!group || !group->cfg)
997 return group->num_members >= group->cfg->max_clients;
1001 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next)
1006 iter = group->members;
1019 int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr)
1023 for (m = group->members; m; m = m->next) {
1032 int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
1035 if (group_id_len != ETH_ALEN + group->cfg->ssid_len)
1037 if (os_memcmp(group_id, group->p2p->cfg->dev_addr, ETH_ALEN) != 0)
1039 return os_memcmp(group_id + ETH_ALEN, group->cfg->ssid,
1040 group->cfg->ssid_len) == 0;
1044 void p2p_group_force_beacon_update_ies(struct p2p_group *group)
1046 group->beacon_update = 1;
1047 p2p_group_update_ies(group);
1051 int p2p_group_get_freq(struct p2p_group *group)
1053 return group->cfg->freq;
1057 const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group)
1059 return group->cfg;
1064 int (*group_callback)(struct p2p_group *group,
1077 int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
1084 if (!group || !common_freqs || !num)
1090 p2p_channels_union(&intersect, &group->p2p->cfg->channels,
1093 p2p_channels_dump(group->p2p,
1094 "Group common freqs before iterating members",
1097 for (m = group->members; m; m = m->next) {
1100 dev = p2p_get_device(group->p2p, m->dev_addr);
1108 p2p_channels_dump(group->p2p, "Group common channels", &intersect);