3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 09:39:25 +01:00

p2p: Add p2p.Peer.Address D-bus property

Expose the Device Address property for each peer.  The spec doesn't say
much about how permanent the address or the name are, although the
device address by definition lives longer than the interface addresses.
However the device address is defined to be unique and the name is not
so the address can be used to differentiate devices with identical name.
Being unique also may imply that it's assigned globally and thus
permanent.

Network Manager uses the P2P device address when saving connection
profiles (and will need it from the backend) and in this case it seems
better justified than using the name.

The address is already in the object path but the object path also
includes the local phy index which may change for no reason even when
the peer's address hasn't changed so the path is not useful for
remembering which device we've connected to before.  Looking at only
parts of the path is considered wrong.
This commit is contained in:
Andrew Zaborowski 2021-10-06 22:52:13 +02:00 committed by Denis Kenzior
parent d2f52a6723
commit af47112a30

View File

@ -4708,6 +4708,18 @@ static bool p2p_peer_get_name(struct l_dbus *dbus,
return true; return true;
} }
static bool p2p_peer_get_addr(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
void *user_data)
{
struct p2p_peer *peer = user_data;
const char *addr = util_address_to_string(peer->device_addr);
l_dbus_message_builder_append_basic(builder, 's', addr);
return true;
}
static bool p2p_peer_get_device(struct l_dbus *dbus, static bool p2p_peer_get_device(struct l_dbus *dbus,
struct l_dbus_message *message, struct l_dbus_message *message,
struct l_dbus_message_builder *builder, struct l_dbus_message_builder *builder,
@ -4825,6 +4837,8 @@ static void p2p_peer_interface_setup(struct l_dbus_interface *interface)
{ {
l_dbus_interface_property(interface, "Name", 0, "s", l_dbus_interface_property(interface, "Name", 0, "s",
p2p_peer_get_name, NULL); p2p_peer_get_name, NULL);
l_dbus_interface_property(interface, "Address", 0, "s",
p2p_peer_get_addr, NULL);
l_dbus_interface_property(interface, "Device", 0, "o", l_dbus_interface_property(interface, "Device", 0, "o",
p2p_peer_get_device, NULL); p2p_peer_get_device, NULL);
l_dbus_interface_property(interface, "DeviceCategory", 0, "s", l_dbus_interface_property(interface, "DeviceCategory", 0, "s",