p2p: Add p2p.Peer.Address D-bus property
Andrew Zaborowski
PATCH 1/2 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.
--- src/p2p.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
src/p2p.c +14 -0
@@ -4708,6 +4708,18 @@ static bool p2p_peer_get_name(struct l_dbus *dbus,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, struct l_dbus_message *message, 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" , 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" , p2p_peer_get_device,NULL ); l_dbus_interface_property(interface, "DeviceCategory", 0, "s",
Signature · 1 line
2.30.2
Andrew Zaborowski
PATCH 2/2 doc: Document the p2p.Peer.Address property
--- doc/p2p-peer-api.txt | 5 +++++ 1 file changed, 5 insertions(+)
doc/p2p-peer-api.txt +5 -0
@@ -19,6 +19,11 @@ Properties string Name [readonly] P2P Peer's display name + string Address [readonly] + + The peer's unique Device Address in the xx:xx:xx:xx:xx:xx + format. + string DeviceCategory [readonly] The category part of the peer's declared
Signature · 1 line
2.30.2
Denis Kenzior
Hi Andrew,
Quoted 12 lines · Andrew Zaborowski
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.
Quoted 9 lines
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.
--- src/p2p.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Both applied, thanks.
Regards,
-Denis