DBus: Add support for P2P primitives

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2011-06-12 15:08:19 -07:00 committed by Jouni Malinen
parent 911e97e400
commit 9abafccc0d
7 changed files with 3500 additions and 0 deletions

View file

@ -1140,6 +1140,9 @@ DBUS_OBJS += dbus/dbus_new.o dbus/dbus_new_handlers.o
ifdef CONFIG_WPS
DBUS_OBJS += dbus/dbus_new_handlers_wps.o
endif
ifdef CONFIG_P2P
DBUS_OBJS += dbus/dbus_new_handlers_p2p.o
endif
ifndef DBUS_LIBS
DBUS_LIBS := $(shell pkg-config --libs dbus-1)
endif

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,8 @@
#ifndef CTRL_IFACE_DBUS_NEW_H
#define CTRL_IFACE_DBUS_NEW_H
#include "p2p/p2p.h"
struct wpa_global;
struct wpa_supplicant;
struct wpa_ssid;
@ -61,6 +63,21 @@ enum wpas_dbus_bss_prop {
#define WPAS_DBUS_NEW_BSSIDS_PART "BSSs"
#define WPAS_DBUS_NEW_IFACE_BSS WPAS_DBUS_NEW_INTERFACE ".BSS"
#define WPAS_DBUS_NEW_IFACE_P2PDEVICE \
WPAS_DBUS_NEW_IFACE_INTERFACE ".P2PDevice"
/*
* Groups correspond to P2P groups where this device is a GO (owner)
*/
#define WPAS_DBUS_NEW_P2P_GROUPS_PART "Groups"
#define WPAS_DBUS_NEW_IFACE_P2P_GROUP WPAS_DBUS_NEW_INTERFACE ".Group"
#define WPAS_DBUS_NEW_P2P_PEERS_PART "Peers"
#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"
/* Errors */
#define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
@ -78,6 +95,13 @@ enum wpas_dbus_bss_prop {
#define WPAS_DBUS_ERROR_NETWORK_UNKNOWN \
WPAS_DBUS_NEW_INTERFACE ".NetworkUnknown"
#define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE \
WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnavailable"
#define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED \
WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnsupported"
#define WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR \
WPAS_DBUS_NEW_INTERFACE ".ConnectUnspecifiedError"
#define WPAS_DBUS_ERROR_BLOB_EXISTS \
WPAS_DBUS_NEW_INTERFACE ".BlobExists"
#define WPAS_DBUS_ERROR_BLOB_UNKNOWN \
@ -122,6 +146,48 @@ void wpas_dbus_signal_debug_level_changed(struct wpa_global *global);
void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr);
void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
const char *role);
void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, int request,
enum p2p_prov_disc_status status,
u16 config_methods,
unsigned int generated_pin);
void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
const u8 *src, u16 dev_passwd_id);
void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
int client, int network_id);
void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status);
void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid);
void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
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,
const u8 *member);
void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
int freq, const u8 *sa, u8 dialog_token,
u16 update_indic, const u8 *tlvs,
size_t tlvs_len);
void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
const u8 *sa, u16 update_indic,
const u8 *tlvs, size_t tlvs_len);
void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
const u8 *member);
#else /* CONFIG_CTRL_IFACE_DBUS_NEW */
static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
@ -231,6 +297,119 @@ static inline void wpas_dbus_signal_debug_show_keys_changed(
{
}
static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
return 0;
}
static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
return 0;
}
static inline void
wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
const char *role)
{
}
static inline void
wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, int request,
enum p2p_prov_disc_status status,
u16 config_methods,
unsigned int generated_pin)
{
}
static inline void wpas_dbus_signal_p2p_go_neg_req(
struct wpa_supplicant *wpa_s,
const u8 *src,
u16 dev_passwd_id)
{
}
static inline void
wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
int client, int network_id)
{
}
static inline void
wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
}
static inline void
wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status)
{
}
static inline void
wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid)
{
}
static inline void wpas_dbus_signal_p2p_invitation_result(
struct wpa_supplicant *wpa_s, int status,
const u8 *bssid)
{
}
static inline void
wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr)
{
}
static inline void
wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq,
const u8 *sa, u8 dialog_token, u16 update_indic,
const u8 *tlvs, size_t tlvs_len)
{
}
static inline void
wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
const u8 *sa, u16 update_indic,
const u8 *tlvs, size_t tlvs_len)
{
}
static inline void
wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
const u8 *p2p_if_addr)
{
}
static inline void
wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
const u8 *member)
{
}
static inline void
wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
}
static inline void
wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
}
static inline void
wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *member)
{
}
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
#endif /* CTRL_IFACE_DBUS_H_NEW */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,142 @@
/*
* WPA Supplicant / dbus-based control interface for p2p
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*/
#ifndef DBUS_NEW_HANDLERS_P2P_H
#define DBUS_NEW_HANDLERS_P2P_H
struct peer_handler_args {
struct wpa_supplicant *wpa_s;
u8 p2p_device_addr[ETH_ALEN];
};
struct groupmember_handler_args {
struct wpa_supplicant *wpa_s;
u8 member_addr[ETH_ALEN];
};
/*
* P2P Device methods
*/
DBusMessage *wpas_dbus_handler_p2p_find(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_stop_find(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_rejectpeer(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_listen(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_extendedlisten(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_presence_request(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_prov_disc_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_group_add(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_connect(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_invite(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_disconnect(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_flush(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_add_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_delete_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_flush_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_res(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_cancel_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_update(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_serv_disc_external(
DBusMessage *message, struct wpa_supplicant *wpa_s);
/*
* P2P Device property accessor methods.
*/
DBusMessage *wpas_dbus_setter_p2p_device_properties(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_device_properties(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_peers(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_role(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_group(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_peergo(DBusMessage *message,
struct wpa_supplicant *wpa_s);
/*
* P2P Peer properties.
*/
DBusMessage *wpas_dbus_getter_p2p_peer_properties(
DBusMessage *message,
struct peer_handler_args *peer);
DBusMessage *wpas_dbus_getter_p2p_peer_ies(
DBusMessage *message,
struct peer_handler_args *peer);
/*
* P2P Group properties
*/
DBusMessage *wpas_dbus_getter_p2p_group_members(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_getter_p2p_group_properties(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_setter_p2p_group_properties(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
#endif /* DBUS_NEW_HANDLERS_P2P_H */

View file

@ -368,12 +368,23 @@ void wpas_notify_resume(struct wpa_global *global)
void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, int new_device)
{
if (new_device) {
/* Create the new peer object */
wpas_dbus_register_peer(wpa_s, dev_addr);
}
/* Notify a new peer has been detected*/
wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
}
void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
wpas_dbus_unregister_peer(wpa_s, dev_addr);
/* Create signal on interface object*/
wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
}
@ -381,23 +392,29 @@ void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
const char *role)
{
wpas_dbus_unregister_p2p_group(wpa_s, ssid);
wpas_dbus_signal_p2p_group_removed(wpa_s, role);
}
void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
const u8 *src, u16 dev_passwd_id)
{
wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
}
void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, int status)
{
wpas_dbus_signal_p2p_go_neg_resp(wpa_s, status);
}
void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
int status, const u8 *bssid)
{
wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
}
@ -406,6 +423,8 @@ void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
u16 update_indic, const u8 *tlvs,
size_t tlvs_len)
{
wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
update_indic, tlvs, tlvs_len);
}
@ -413,6 +432,8 @@ void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
const u8 *sa, u16 update_indic,
const u8 *tlvs, size_t tlvs_len)
{
wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
tlvs, tlvs_len);
}
@ -435,6 +456,9 @@ void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
u16 config_methods,
unsigned int generated_pin)
{
wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
status, config_methods,
generated_pin);
}
@ -442,6 +466,10 @@ void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid, int network_id,
int client)
{
/* Notify a group has been started */
wpas_dbus_register_p2p_group(wpa_s, ssid);
wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
}
#endif /* CONFIG_P2P */
@ -449,12 +477,35 @@ void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
const u8 *sta)
{
/*
* 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
* check P2P itself.
*/
wpas_dbus_signal_p2p_peer_joined(wpa_s, sta);
}
static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
const u8 *sta)
{
/*
* 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
* is a P2P group.
*/
wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta);
}

View file

@ -342,6 +342,7 @@ struct wpa_supplicant {
#endif /* CONFIG_CTRL_IFACE_DBUS */
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
char *dbus_new_path;
char *dbus_groupobj_path;
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
char bridge_ifname[16];