Skip to contentSkip to conversation

ap: Expose connected stations property

RFC PATCH In review Michael Trimarchi 2 participants 4 messages Oct 24, 2021 – Oct 25, 2021

lore
Share & tools
lore

Michael Trimarchi

author
#0 lore raw

RFC PATCH v2 1/1 ap: Expose connected stations property

Add a way to be notified about the connected stations in access point mode. This can be used in order to ask from Diagnostic interface the properties for each station or to just use them from other services like connman or network manager to report the number of clients

Signed-off-by Michael Trimarchi <michael(a)amarulasolutions.com>

---
Changes V1->V2:
typo in message dbus type

---
 src/ap.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
src/ap.c +23 -0
index 46a7a6a8..e88be99c 100644
@@ -98,6 +98,7 @@ struct ap_state {
 	uint8_t netconfig_gateway4_mac[6];
 	uint8_t netconfig_dns4_mac[6];
 
+	uint16_t connected_stations;
 	bool started : 1;
 	bool gtk_set : 1;
 	bool netconfig_set_addr4 : 1;
@@ -347,6 +348,7 @@ static void ap_new_rsna(struct sta_state *sta)
 		event_data.assoc_ies_len = sta->assoc_ies_len;
 		ap->ops->handle_event(AP_EVENT_STATION_ADDED, &event_data,
 					ap->user_data);
+		ap->connected_stations++;
 	}
 }
 
@@ -385,6 +387,7 @@ static void ap_drop_rsna(struct sta_state *sta)
 		event_data.mac = sta->addr;
 		ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data,
 					ap->user_data);
+		ap->connected_stations++;
 	}
 }
 
@@ -3495,6 +3498,10 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
 
 	case AP_EVENT_STATION_ADDED:
 	case AP_EVENT_STATION_REMOVED:
+		l_dbus_property_changed(dbus_get_bus(),
+					netdev_get_path(ap_if->netdev),
+					IWD_AP_INTERFACE, "ConnectedStations");
+		break;
 	case AP_EVENT_REGISTRATION_START:
 	case AP_EVENT_REGISTRATION_SUCCESS:
 	case AP_EVENT_PBC_MODE_EXIT:
@@ -3626,6 +3633,19 @@ error:
 	return dbus_error_from_errno(err, message);
 }
 
+static bool ap_dbus_property_connected_stations(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						struct l_dbus_message_builder *builder,
+						void *user_data)
+{
+	struct ap_if_data *ap_if = user_data;
+	uint16_t stations = ap_if->ap ? ap_if->ap->connected_stations : 0;
+
+	l_dbus_message_builder_append_basic(builder, 'q', &stations);
+
+	return true;
+}
+
 static bool ap_dbus_property_get_started(struct l_dbus *dbus,
 					struct l_dbus_message *message,
 					struct l_dbus_message_builder *builder,
@@ -3668,6 +3688,9 @@ static void ap_setup_interface(struct l_dbus_interface *interface)
 					ap_dbus_property_get_started, NULL);
 	l_dbus_interface_property(interface, "Name", 0, "s",
 					ap_dbus_property_get_name, NULL);
+
+	l_dbus_interface_property(interface, "ConnectedStations", 0, "q",
+					ap_dbus_property_connected_stations, NULL);
 }
 
 static void ap_destroy_interface(void *user_data)
Signature · 1 line
2.25.1
#1 lore raw

Hi Michael,

Quoted 5 lines · Michael Trimarchi

Add a way to be notified about the connected stations in access point mode. This can be used in order to ask from Diagnostic interface the properties for each station or to just use them from other services like connman or network manager to report the number of clients

So do you want the actual number of clients or a way to know when the client list has changed? If it is the latter, then a signal might be better.

Also, you should document the new property in doc/access-point-api.txt in a separate patch.

Quoted 2 lines
Signed-off-by Michael Trimarchi <michael(a)amarulasolutions.com>

We don't use S-o-B in ell/iwd.

Quoted 12 lines

---
Changes V1->V2:
typo in message dbus type

---
  src/ap.c | 23 +++++++++++++++++++++++
  1 file changed, 23 insertions(+)
src/ap.c +0 -0
index 46a7a6a8..e88be99c 100644

src/ap.c struct ap_state { · line 101

Quoted 4 lines
src/ap.c +1 -0
@@ -98,6 +98,7 @@ struct ap_state {
  	uint8_t netconfig_gateway4_mac[6];
  	uint8_t netconfig_dns4_mac[6];
 
+	uint16_t connected_stations;

num_connected_stations?

Quoted 12 lines
src/ap.c +1 -0
  	bool started : 1;
  	bool gtk_set : 1;
  	bool netconfig_set_addr4 : 1;
@@ -347,6 +348,7 @@ static void ap_new_rsna(struct sta_state *sta)
  		event_data.assoc_ies_len = sta->assoc_ies_len;
  		ap->ops->handle_event(AP_EVENT_STATION_ADDED, &event_data,
  					ap->user_data);
+		ap->connected_stations++;
  	}
  }
 

src/ap.c static void ap_drop_rsna(struct sta_state *sta) · line 390

Quoted 4 lines
src/ap.c +1 -0
@@ -385,6 +387,7 @@ static void ap_drop_rsna(struct sta_state *sta)
  		event_data.mac = sta->addr;
  		ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data,
  					ap->user_data);
+		ap->connected_stations++;

do you mean ap->connected_stations-- here?

Quoted 15 lines
src/ap.c +4 -0
  	}
  }
 
@@ -3495,6 +3498,10 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
 
  	case AP_EVENT_STATION_ADDED:
  	case AP_EVENT_STATION_REMOVED:
+		l_dbus_property_changed(dbus_get_bus(),
+					netdev_get_path(ap_if->netdev),
+					IWD_AP_INTERFACE, "ConnectedStations");
+		break;
  	case AP_EVENT_REGISTRATION_START:
  	case AP_EVENT_REGISTRATION_SUCCESS:
  	case AP_EVENT_PBC_MODE_EXIT:

src/ap.c error: · line 3642

Quoted 10 lines
src/ap.c +7 -0
@@ -3626,6 +3633,19 @@ error:
  	return dbus_error_from_errno(err, message);
  }
 
+static bool ap_dbus_property_connected_stations(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						struct l_dbus_message_builder *builder,
+						void *user_data)
+{
+	struct ap_if_data *ap_if = user_data;
+	uint16_t stations = ap_if->ap ? ap_if->ap->connected_stations : 0;

You could simply omit this property if the AP isn't started by returning false.

Quoted 10 lines
src/ap.c +6 -0
+
+	l_dbus_message_builder_append_basic(builder, 'q', &stations);
+
+	return true;
+}
+
  static bool ap_dbus_property_get_started(struct l_dbus *dbus,
  					struct l_dbus_message *message,
  					struct l_dbus_message_builder *builder,

src/ap.c static void ap_setup_interface(struct l_dbus_interface *interface) · line 3692

Quoted 5 lines
src/ap.c +2 -0
@@ -3668,6 +3688,9 @@ static void ap_setup_interface(struct l_dbus_interface *interface)
  					ap_dbus_property_get_started, NULL);
  	l_dbus_interface_property(interface, "Name", 0, "s",
  					ap_dbus_property_get_name, NULL);
+
+	l_dbus_interface_property(interface, "ConnectedStations", 0, "q",

Just curious, why was uint16_t chosen as the return type?

src/ap.c static void ap_setup_interface(struct l_dbus_interface *interface) · line 3696

Quoted 5 lines
src/ap.c +1 -0
+					ap_dbus_property_connected_stations, NULL);
  }
 
  static void ap_destroy_interface(void *user_data)

Regards,
-Denis

author
#2 lore raw

Hi

Quoted 10 lines · Denis Kenzior

Hi Michael,

Quoted 5 lines · Michael Trimarchi

Add a way to be notified about the connected stations in access point mode. This can be used in order to ask from Diagnostic interface the properties for each station or to just use them from other services like connman or network manager to report the number of clients

Quoted 5 lines

So do you want the actual number of clients or a way to know when the client list has changed? If it is the latter, then a signal might be better.

Also, you should document the new property in doc/access-point-api.txt in a separate patch.

I'm thinking even about:

StaAuthorized ( s : mac )

A new station has been authorized to the interface.

Arguments

s : mac A mac address which has been authorized.

StaDeauthorized ( s : mac )

A station has been deauthorized to the interface.

Arguments

s : mac A mac address which has been deauthorized.

This will be then compatible on what we have in wpa_supplicant.

I will address all your comments. Do you like more this approach?

Michael

Quoted 98 lines
Quoted 3 lines
Signed-off-by Michael Trimarchi <michael(a)amarulasolutions.com>

We don't use S-o-B in ell/iwd.

Quoted 12 lines

---
Changes V1->V2:
typo in message dbus type

---
  src/ap.c | 23 +++++++++++++++++++++++
  1 file changed, 23 insertions(+)
src/ap.c +0 -0
index 46a7a6a8..e88be99c 100644

src/ap.c struct ap_state { · line 101

Quoted 4 lines
src/ap.c +1 -0
@@ -98,6 +98,7 @@ struct ap_state {
      uint8_t netconfig_gateway4_mac[6];
      uint8_t netconfig_dns4_mac[6];
 
+     uint16_t connected_stations;

num_connected_stations?

Quoted 12 lines
src/ap.c +1 -0
      bool started : 1;
      bool gtk_set : 1;
      bool netconfig_set_addr4 : 1;
@@ -347,6 +348,7 @@ static void ap_new_rsna(struct sta_state *sta)
              event_data.assoc_ies_len = sta->assoc_ies_len;
              ap->ops->handle_event(AP_EVENT_STATION_ADDED, &event_data,
                                      ap->user_data);
+             ap->connected_stations++;
      }
  }
 

src/ap.c static void ap_drop_rsna(struct sta_state *sta) · line 390

Quoted 4 lines
src/ap.c +1 -0
@@ -385,6 +387,7 @@ static void ap_drop_rsna(struct sta_state *sta)
              event_data.mac = sta->addr;
              ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data,
                                      ap->user_data);
+             ap->connected_stations++;

do you mean ap->connected_stations-- here?

Quoted 15 lines
src/ap.c +4 -0
      }
  }
 
@@ -3495,6 +3498,10 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
 
      case AP_EVENT_STATION_ADDED:
      case AP_EVENT_STATION_REMOVED:
+             l_dbus_property_changed(dbus_get_bus(),
+                                     netdev_get_path(ap_if->netdev),
+                                     IWD_AP_INTERFACE, "ConnectedStations");
+             break;
      case AP_EVENT_REGISTRATION_START:
      case AP_EVENT_REGISTRATION_SUCCESS:
      case AP_EVENT_PBC_MODE_EXIT:

src/ap.c error: · line 3642

Quoted 10 lines
src/ap.c +7 -0
@@ -3626,6 +3633,19 @@ error:
      return dbus_error_from_errno(err, message);
  }
 
+static bool ap_dbus_property_connected_stations(struct l_dbus *dbus,
+                                             struct l_dbus_message *message,
+                                             struct l_dbus_message_builder *builder,
+                                             void *user_data)
+{
+     struct ap_if_data *ap_if = user_data;
+     uint16_t stations = ap_if->ap ? ap_if->ap->connected_stations : 0;

You could simply omit this property if the AP isn't started by returning false.

Quoted 10 lines
src/ap.c +6 -0
+
+     l_dbus_message_builder_append_basic(builder, 'q', &stations);
+
+     return true;
+}
+
  static bool ap_dbus_property_get_started(struct l_dbus *dbus,
                                      struct l_dbus_message *message,
                                      struct l_dbus_message_builder *builder,

src/ap.c static void ap_setup_interface(struct l_dbus_interface *interface) · line 3692

Quoted 5 lines
src/ap.c +2 -0
@@ -3668,6 +3688,9 @@ static void ap_setup_interface(struct l_dbus_interface *interface)
                                      ap_dbus_property_get_started, NULL);
      l_dbus_interface_property(interface, "Name", 0, "s",
                                      ap_dbus_property_get_name, NULL);
+
+     l_dbus_interface_property(interface, "ConnectedStations", 0, "q",

Just curious, why was uint16_t chosen as the return type?

src/ap.c static void ap_setup_interface(struct l_dbus_interface *interface) · line 3696

Quoted 5 lines
src/ap.c +1 -0
+                                     ap_dbus_property_connected_stations, NULL);
  }
 
  static void ap_destroy_interface(void *user_data)

Regards,
-Denis

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael(a)amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info(a)amarulasolutions.com
www.amarulasolutions.com
#3 lore raw

Hi Michael,

Quoted 33 lines · Michael Nazzareno Trimarchi

Hi

Quoted 10 lines · Denis Kenzior

Hi Michael,

Quoted 5 lines · Michael Trimarchi

Add a way to be notified about the connected stations in access point mode. This can be used in order to ask from Diagnostic interface the properties for each station or to just use them from other services like connman or network manager to report the number of clients

Quoted 5 lines

So do you want the actual number of clients or a way to know when the client list has changed? If it is the latter, then a signal might be better.

Also, you should document the new property in doc/access-point-api.txt in a separate patch.

I'm thinking even about:

StaAuthorized ( s : mac )

A new station has been authorized to the interface.

Arguments

s : mac A mac address which has been authorized.

StaDeauthorized ( s : mac )

A station has been deauthorized to the interface.

Quoted 7 lines

Arguments

s : mac A mac address which has been deauthorized.

This will be then compatible on what we have in wpa_supplicant.

I will address all your comments. Do you like more this approach?

I like this more than the original proposal. Do note that we like to spell out terms in our D-Bus APIs since they're more user-visible. So maybe
StationJoined/StationLeft StationConnected/StationDisconnected or ClientAdded/ClientRemoved

However, do note that signals are somewhat limiting. If there's more information on a client that might be required in the future (obtained DHCP address maybe?), then modeling the client station as an object may be more future-proof. With ObjectManager, above signals would be replaced by InterfacesAdded/InterfacesRemoved() and you would get the contents of the entire (future-extensible) property set instead of just the mac.

This doesn't have to be solved now since the AccessPoint API is marked experimental and is subject to change. But the less churn there is, the less work there would be in the future to migrate from old APIs to the new.

Regards,
-Denis