897
902
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
898
WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
903
WPAS_DBUS_NEW_IFACE_INTERFACE,
902
if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
904
dbus_connection_send(iface->con, msg, NULL);
906
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
907
dbus_message_unref(msg);
909
wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
908
dbus_message_iter_init_append(msg, &iter);
909
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
914
if (!wpa_dbus_get_object_properties(iface, path,
915
WPAS_DBUS_NEW_IFACE_STA,
920
wpa_printf(MSG_DEBUG, "dbus: Station MAC address '" MACSTR "' '%s'",
921
MAC2STR(sta), sig_name);
923
dbus_connection_send(iface->con, msg, NULL);
924
dbus_message_unref(msg);
928
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
929
dbus_message_unref(msg);
1925
* wpas_dbus_sta_signal_prop_changed - Signals change of STA property
1926
* @wpa_s: %wpa_supplicant network interface data
1927
* @property: indicates which property has changed
1928
* @address: unique BSS identifier
1930
* Sends PropertyChanged signals with path, interface, and arguments depending
1931
* on which property has changed.
1933
void wpas_dbus_sta_signal_prop_changed(struct wpa_supplicant *wpa_s,
1934
enum wpas_dbus_bss_prop property,
1935
u8 address[ETH_ALEN])
1937
char path[WPAS_DBUS_OBJECT_PATH_MAX];
1941
case WPAS_DBUS_STA_PROP_ADDRESS:
1945
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1946
__func__, property);
1950
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
1951
"%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
1952
wpa_s->dbus_new_path, MAC2STR(address));
1954
wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
1955
WPAS_DBUS_NEW_IFACE_STA, prop);
1903
1958
* wpas_dbus_signal_debug_level_changed - Signals change of debug param
1904
1959
* @global: wpa_global structure
2502
static const struct wpa_dbus_property_desc wpas_dbus_sta_properties[] = {
2503
{ "Address", WPAS_DBUS_NEW_IFACE_STA, "ay",
2504
wpas_dbus_getter_sta_address,
2507
{ "AID", WPAS_DBUS_NEW_IFACE_STA, "q",
2508
wpas_dbus_getter_sta_aid,
2511
{ "Flags", WPAS_DBUS_NEW_IFACE_STA, "u",
2512
wpas_dbus_getter_sta_flags,
2515
{ "Capabilities", WPAS_DBUS_NEW_IFACE_STA, "q",
2516
wpas_dbus_getter_sta_caps,
2519
{ "RxPackets", WPAS_DBUS_NEW_IFACE_STA, "t",
2520
wpas_dbus_getter_sta_rx_packets,
2523
{ "TxPackets", WPAS_DBUS_NEW_IFACE_STA, "t",
2524
wpas_dbus_getter_sta_tx_packets,
2527
{ "RxBytes", WPAS_DBUS_NEW_IFACE_STA, "t",
2528
wpas_dbus_getter_sta_rx_bytes,
2531
{ "TxBytes", WPAS_DBUS_NEW_IFACE_STA, "t",
2532
wpas_dbus_getter_sta_tx_bytes,
2535
{ NULL, NULL, NULL, NULL, NULL }
2539
static const struct wpa_dbus_signal_desc wpas_dbus_sta_signals[] = {
2540
/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2541
{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_STA,
2543
{ "properties", "a{sv}", ARG_OUT },
2547
{ NULL, NULL, { END_ARGS } }
2552
* wpas_dbus_unregister_sta - Unregister a connected station from dbus
2553
* @wpa_s: wpa_supplicant interface structure
2554
* @bssid: connected station bssid
2555
* @id: unique station identifier
2556
* Returns: 0 on success, -1 on failure
2558
* Unregisters STA representing object from dbus
2560
int wpas_dbus_unregister_sta(struct wpa_supplicant *wpa_s,
2563
struct wpas_dbus_priv *ctrl_iface;
2564
char sta_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2566
/* Do nothing if the control interface is not turned on */
2567
if (wpa_s == NULL || wpa_s->global == NULL)
2569
ctrl_iface = wpa_s->global->dbus;
2570
if (ctrl_iface == NULL)
2573
os_snprintf(sta_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2574
"%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
2575
wpa_s->dbus_new_path, MAC2STR(sta));
2577
wpa_printf(MSG_DEBUG, "dbus: Unregister STA object '%s'",
2579
if (wpa_dbus_unregister_object_per_iface(ctrl_iface, sta_obj_path)) {
2580
wpa_printf(MSG_ERROR, "dbus: Cannot unregister STA object %s",
2585
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STAS);
2592
* wpas_dbus_register_sta - Register a scanned station with dbus
2593
* @wpa_s: wpa_supplicant interface structure
2594
* @bssid: connection network station
2595
* @id: unique STA identifier
2596
* Returns: 0 on success, -1 on failure
2598
* Registers STA representing object with dbus
2600
int wpas_dbus_register_sta(struct wpa_supplicant *wpa_s,
2603
struct wpas_dbus_priv *ctrl_iface;
2604
struct wpa_dbus_object_desc *obj_desc;
2605
char sta_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2606
struct sta_handler_args *arg;
2608
/* Do nothing if the control interface is not turned on */
2609
if (wpa_s == NULL || wpa_s->global == NULL)
2611
ctrl_iface = wpa_s->global->dbus;
2612
if (ctrl_iface == NULL)
2615
os_snprintf(sta_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2616
"%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
2617
wpa_s->dbus_new_path, MAC2STR(sta));
2619
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2621
wpa_printf(MSG_ERROR, "Not enough memory "
2622
"to create object description");
2626
arg = os_zalloc(sizeof(struct sta_handler_args));
2628
wpa_printf(MSG_ERROR, "Not enough memory "
2629
"to create arguments for handler");
2635
wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
2637
wpas_dbus_sta_properties,
2638
wpas_dbus_sta_signals);
2640
wpa_printf(MSG_DEBUG, "dbus: Register STA object '%s'",
2642
if (wpa_dbus_register_object_per_iface(ctrl_iface, sta_obj_path,
2643
wpa_s->ifname, obj_desc)) {
2644
wpa_printf(MSG_ERROR,
2645
"Cannot register STA dbus object %s.",
2650
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STAS);
2655
free_dbus_object_desc(obj_desc);
2447
2660
static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
2448
2661
{ "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2449
2662
(WPADBusMethodHandler) &wpas_dbus_handler_scan,