dbus: Remove GroupMember object type and use Peer instead

GroupMember is unusable in itself and all the necessary informations are
stored in Peer objects, thus replace the use of GroupMember by Peer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2014-06-02 17:42:06 +03:00 committed by Jouni Malinen
parent 17a37d7110
commit bf035663c9
7 changed files with 24 additions and 152 deletions

View file

@ -1788,7 +1788,7 @@ unsigned int p2p_get_group_num_members(struct p2p_group *group);
* @group: P2P group context from p2p_group_init() * @group: P2P group context from p2p_group_init()
* @next: iteration pointer, must be a pointer to a void * that is set to %NULL * @next: iteration pointer, must be a pointer to a void * that is set to %NULL
* on the first call and not modified later * on the first call and not modified later
* Returns: A P2P Interface Address for each call and %NULL for no more members * Returns: A P2P Device Address for each call and %NULL for no more members
*/ */
const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next); const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);

View file

@ -973,7 +973,7 @@ const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next)
if (!iter) if (!iter)
return NULL; return NULL;
return iter->addr; return iter->dev_addr;
} }

View file

@ -1398,15 +1398,15 @@ nomem:
* constructed using p2p i/f addr used for connecting. * constructed using p2p i/f addr used for connecting.
* *
* @wpa_s: %wpa_supplicant network interface data * @wpa_s: %wpa_supplicant network interface data
* @member_addr: addr (p2p i/f) of the peer joining the group * @peer_addr: P2P Device Address of the peer joining the group
*/ */
void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
const u8 *member) const u8 *peer_addr)
{ {
struct wpas_dbus_priv *iface; struct wpas_dbus_priv *iface;
DBusMessage *msg; DBusMessage *msg;
DBusMessageIter iter; DBusMessageIter iter;
char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path; char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
iface = wpa_s->global->dbus; iface = wpa_s->global->dbus;
@ -1417,10 +1417,10 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
if (!wpa_s->dbus_groupobj_path) if (!wpa_s->dbus_groupobj_path)
return; return;
os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
COMPACT_MACSTR, COMPACT_MACSTR,
wpa_s->dbus_groupobj_path, MAC2STR(member)); wpa_s->parent->dbus_new_path, MAC2STR(peer_addr));
msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path, msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
WPAS_DBUS_NEW_IFACE_P2P_GROUP, WPAS_DBUS_NEW_IFACE_P2P_GROUP,
@ -1429,7 +1429,7 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
path = groupmember_obj_path; path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path))
goto err; goto err;
@ -1449,18 +1449,18 @@ err:
* *
* Method to emit a signal for a peer disconnecting the group. * Method to emit a signal for a peer disconnecting the group.
* The signal will carry path to the group member object * The signal will carry path to the group member object
* constructed using p2p i/f addr used for connecting. * constructed using the P2P Device Address of the peer.
* *
* @wpa_s: %wpa_supplicant network interface data * @wpa_s: %wpa_supplicant network interface data
* @member_addr: addr (p2p i/f) of the peer joining the group * @peer_addr: P2P Device Address of the peer joining the group
*/ */
void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *member) const u8 *peer_addr)
{ {
struct wpas_dbus_priv *iface; struct wpas_dbus_priv *iface;
DBusMessage *msg; DBusMessage *msg;
DBusMessageIter iter; DBusMessageIter iter;
char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path; char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
iface = wpa_s->global->dbus; iface = wpa_s->global->dbus;
@ -1471,10 +1471,10 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
if (!wpa_s->dbus_groupobj_path) if (!wpa_s->dbus_groupobj_path)
return; return;
os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
COMPACT_MACSTR, COMPACT_MACSTR,
wpa_s->dbus_groupobj_path, MAC2STR(member)); wpa_s->dbus_groupobj_path, MAC2STR(peer_addr));
msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path, msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
WPAS_DBUS_NEW_IFACE_P2P_GROUP, WPAS_DBUS_NEW_IFACE_P2P_GROUP,
@ -1483,7 +1483,7 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
path = groupmember_obj_path; path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path))
goto err; goto err;
@ -3618,109 +3618,6 @@ void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
wpa_s->dbus_groupobj_path = NULL; wpa_s->dbus_groupobj_path = NULL;
} }
static const struct wpa_dbus_property_desc
wpas_dbus_p2p_groupmember_properties[] = {
{ NULL, NULL, NULL, NULL, NULL }
};
/**
* wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
* object with dbus
* @wpa_s: wpa_supplicant interface structure
* @p2p_if_addr: i/f addr of the device joining this group
*
* Registers p2p groupmember representing object with dbus
*/
void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr)
{
struct wpas_dbus_priv *ctrl_iface;
struct wpa_dbus_object_desc *obj_desc = NULL;
struct groupmember_handler_args *arg;
char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
/* Do nothing if the control interface is not turned on */
if (wpa_s == NULL || wpa_s->global == NULL)
return;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
return;
if (!wpa_s->dbus_groupobj_path)
return;
os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory "
"to create object description");
goto err;
}
/* allocate memory for handlers arguments */
arg = os_zalloc(sizeof(struct groupmember_handler_args));
if (!arg) {
wpa_printf(MSG_ERROR, "Not enough memory "
"to create arguments for method");
goto err;
}
arg->wpa_s = wpa_s;
os_memcpy(arg->member_addr, p2p_if_addr, ETH_ALEN);
wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
wpas_dbus_p2p_groupmember_properties, NULL);
if (wpa_dbus_register_object_per_iface(ctrl_iface, groupmember_obj_path,
wpa_s->ifname, obj_desc))
goto err;
wpa_printf(MSG_INFO,
"dbus: Registered group member object '%s' successfully",
groupmember_obj_path);
return;
err:
free_dbus_object_desc(obj_desc);
}
/**
* wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
* object with dbus
* @wpa_s: wpa_supplicant interface structure
* @p2p_if_addr: i/f addr of the device joining this group
*
* Unregisters p2p groupmember representing object with dbus
*/
void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr)
{
struct wpas_dbus_priv *ctrl_iface;
char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
/* Do nothing if the control interface is not turned on */
if (wpa_s == NULL || wpa_s->global == NULL)
return;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
return;
if (!wpa_s->dbus_groupobj_path)
return;
os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
wpa_dbus_unregister_object_per_iface(ctrl_iface, groupmember_obj_path);
}
static const struct wpa_dbus_property_desc static const struct wpa_dbus_property_desc
wpas_dbus_persistent_group_properties[] = { wpas_dbus_persistent_group_properties[] = {
{ "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}", { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",

View file

@ -79,10 +79,6 @@ enum wpas_dbus_bss_prop {
#define WPAS_DBUS_NEW_P2P_PEERS_PART "Peers" #define WPAS_DBUS_NEW_P2P_PEERS_PART "Peers"
#define WPAS_DBUS_NEW_IFACE_P2P_PEER WPAS_DBUS_NEW_INTERFACE ".Peer" #define WPAS_DBUS_NEW_IFACE_P2P_PEER WPAS_DBUS_NEW_INTERFACE ".Peer"
#define WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "Members"
#define WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER \
WPAS_DBUS_NEW_INTERFACE ".GroupMember"
/* Top-level Errors */ /* Top-level Errors */
#define WPAS_DBUS_ERROR_UNKNOWN_ERROR \ #define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
WPAS_DBUS_NEW_INTERFACE ".UnknownError" WPAS_DBUS_NEW_INTERFACE ".UnknownError"
@ -201,10 +197,6 @@ int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
int nid); int nid);
void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
int status, const u8 *bssid); int status, const u8 *bssid);
void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr);
void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr);
void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *member); const u8 *member);
void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,

View file

@ -1979,9 +1979,9 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
if (!paths[i]) if (!paths[i])
goto out_of_memory; goto out_of_memory;
os_snprintf(paths[i], WPAS_DBUS_OBJECT_PATH_MAX, os_snprintf(paths[i], WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR, "/" COMPACT_MACSTR,
wpa_s->dbus_groupobj_path, MAC2STR(addr)); wpa_s->parent->dbus_new_path, MAC2STR(addr));
i++; i++;
} }

View file

@ -14,11 +14,6 @@ struct peer_handler_args {
u8 p2p_device_addr[ETH_ALEN]; u8 p2p_device_addr[ETH_ALEN];
}; };
struct groupmember_handler_args {
struct wpa_supplicant *wpa_s;
u8 member_addr[ETH_ALEN];
};
/* /*
* P2P Device methods * P2P Device methods
*/ */

View file

@ -536,18 +536,11 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
/*
* Register a group member object corresponding to this peer and
* emit a PeerJoined signal. This will check if it really is a
* P2P group.
*/
wpas_dbus_register_p2p_groupmember(wpa_s, sta);
/* /*
* Create 'peer-joined' signal on group object -- will also * Create 'peer-joined' signal on group object -- will also
* check P2P itself. * check P2P itself.
*/ */
wpas_dbus_signal_p2p_peer_joined(wpa_s, sta); wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
/* Notify listeners a new station has been authorized */ /* Notify listeners a new station has been authorized */
@ -556,20 +549,15 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
const u8 *sta) const u8 *sta,
const u8 *p2p_dev_addr)
{ {
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
/*
* Unregister a group member object corresponding to this peer
* if this is a P2P group.
*/
wpas_dbus_unregister_p2p_groupmember(wpa_s, sta);
/* /*
* Create 'peer-disconnected' signal on group object if this * Create 'peer-disconnected' signal on group object if this
* is a P2P group. * is a P2P group.
*/ */
wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta); wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
/* Notify listeners a station has been deauthorized */ /* Notify listeners a station has been deauthorized */
@ -584,7 +572,7 @@ void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
if (authorized) if (authorized)
wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
else else
wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr); wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
} }