dbus: Add method to enable channel switching with a TDLS peer

This patch adds "TDLSChannelSwitch" dbus method on
"fi.w1.wpa_supplicant1.Interface" interface to enable channel switching
with a TDLS peer.

Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
This commit is contained in:
Nishant Chaprana 2017-05-01 09:35:37 +05:30 committed by Jouni Malinen
parent 0238e8ba4c
commit 2a57b4b821
4 changed files with 138 additions and 0 deletions

View File

@ -455,6 +455,15 @@ fi.w1.wpa_supplicant1.CreateInterface.
<dd>Initiating the TDLS operation failed for an unknown reason.</dd> <dd>Initiating the TDLS operation failed for an unknown reason.</dd>
</dl> </dl>
</li> </li>
<li>
<h3>TDLSChannelSwitch ( a{sv} : args ) --> nothing</h3>
<p>Configure TDLS channel switching behavior with a peer.</p>
<h4>Arguments</h4>
<dl>
<dt>a{sv} : args</dt>
<dd>A dictionary with arguments identifying the peer and channel switching behavior.</dd>
</dl>
</li>
<li> <li>
<h3>VendorElemAdd ( i: frame_id, ay: ielems ) --> nothing</h3> <h3>VendorElemAdd ( i: frame_id, ay: ielems ) --> nothing</h3>
<p>Add Vendor Elements to corresponding frame ID.</p> <p>Add Vendor Elements to corresponding frame ID.</p>

View File

@ -3086,6 +3086,13 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
END_ARGS END_ARGS
} }
}, },
{ "TDLSChannelSwitch", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) wpas_dbus_handler_tdls_channel_switch,
{
{ "args", "a{sv}", ARG_IN },
END_ARGS
}
},
#endif /* CONFIG_TDLS */ #endif /* CONFIG_TDLS */
{ "VendorElemAdd", WPAS_DBUS_NEW_IFACE_INTERFACE, { "VendorElemAdd", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_add, (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_add,

View File

@ -2313,6 +2313,125 @@ DBusMessage * wpas_dbus_handler_tdls_teardown(DBusMessage *message,
return NULL; return NULL;
} }
/*
* wpas_dbus_handler_tdls_channel_switch - Enable channel switching with TDLS peer
* @message: Pointer to incoming dbus message
* @wpa_s: wpa_supplicant structure for a network interface
* Returns: NULL indicating success or DBus error message on failure
*
* Handler function for "TDLSChannelSwitch" method call of network interface.
*/
DBusMessage *
wpas_dbus_handler_tdls_channel_switch(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
DBusMessageIter iter, iter_dict;
struct wpa_dbus_dict_entry entry;
u8 peer[ETH_ALEN];
struct hostapd_freq_params freq_params;
u8 oper_class = 0;
int ret;
int is_peer_present = 0;
if (!wpa_tdls_is_external_setup(wpa_s->wpa)) {
wpa_printf(MSG_INFO,
"tdls_chanswitch: Only supported with external setup");
return wpas_dbus_error_unknown_error(message, "TDLS is not using external setup");
}
os_memset(&freq_params, 0, sizeof(freq_params));
dbus_message_iter_init(message, &iter);
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
return wpas_dbus_error_invalid_args(message, NULL);
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
return wpas_dbus_error_invalid_args(message, NULL);
if (os_strcmp(entry.key, "PeerAddress") == 0 &&
entry.type == DBUS_TYPE_STRING) {
if (hwaddr_aton(entry.str_value, peer)) {
wpa_printf(MSG_DEBUG,
"tdls_chanswitch: Invalid address '%s'",
entry.str_value);
wpa_dbus_dict_entry_clear(&entry);
return wpas_dbus_error_invalid_args(message,
NULL);
}
is_peer_present = 1;
} else if (os_strcmp(entry.key, "OperClass") == 0 &&
entry.type == DBUS_TYPE_BYTE) {
oper_class = entry.byte_value;
} else if (os_strcmp(entry.key, "Frequency") == 0 &&
entry.type == DBUS_TYPE_UINT32) {
freq_params.freq = entry.uint32_value;
} else if (os_strcmp(entry.key, "SecChannelOffset") == 0 &&
entry.type == DBUS_TYPE_UINT32) {
freq_params.sec_channel_offset = entry.uint32_value;
} else if (os_strcmp(entry.key, "CenterFrequency1") == 0 &&
entry.type == DBUS_TYPE_UINT32) {
freq_params.center_freq1 = entry.uint32_value;
} else if (os_strcmp(entry.key, "CenterFrequency2") == 0 &&
entry.type == DBUS_TYPE_UINT32) {
freq_params.center_freq2 = entry.uint32_value;
} else if (os_strcmp(entry.key, "Bandwidth") == 0 &&
entry.type == DBUS_TYPE_UINT32) {
freq_params.bandwidth = entry.uint32_value;
} else if (os_strcmp(entry.key, "HT") == 0 &&
entry.type == DBUS_TYPE_BOOLEAN) {
freq_params.ht_enabled = entry.bool_value;
} else if (os_strcmp(entry.key, "VHT") == 0 &&
entry.type == DBUS_TYPE_BOOLEAN) {
freq_params.vht_enabled = entry.bool_value;
} else {
wpa_dbus_dict_entry_clear(&entry);
return wpas_dbus_error_invalid_args(message, NULL);
}
wpa_dbus_dict_entry_clear(&entry);
}
if (oper_class == 0) {
wpa_printf(MSG_INFO,
"tdls_chanswitch: Invalid op class provided");
return wpas_dbus_error_invalid_args(
message, "Invalid op class provided");
}
if (freq_params.freq == 0) {
wpa_printf(MSG_INFO,
"tdls_chanswitch: Invalid freq provided");
return wpas_dbus_error_invalid_args(message,
"Invalid freq provided");
}
if (is_peer_present == 0) {
wpa_printf(MSG_DEBUG,
"tdls_chanswitch: peer address not provided");
return wpas_dbus_error_invalid_args(
message, "peer address not provided");
}
wpa_printf(MSG_DEBUG, "dbus: TDLS_CHAN_SWITCH " MACSTR
" OP CLASS %d FREQ %d CENTER1 %d CENTER2 %d BW %d SEC_OFFSET %d%s%s",
MAC2STR(peer), oper_class, freq_params.freq,
freq_params.center_freq1, freq_params.center_freq2,
freq_params.bandwidth, freq_params.sec_channel_offset,
freq_params.ht_enabled ? " HT" : "",
freq_params.vht_enabled ? " VHT" : "");
ret = wpa_tdls_enable_chan_switch(wpa_s->wpa, peer, oper_class,
&freq_params);
if (ret)
return wpas_dbus_error_unknown_error(
message, "error processing TDLS channel switch");
return NULL;
}
#endif /* CONFIG_TDLS */ #endif /* CONFIG_TDLS */

View File

@ -216,6 +216,9 @@ DBusMessage * wpas_dbus_handler_tdls_status(DBusMessage *message,
struct wpa_supplicant *wpa_s); struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_tdls_teardown(DBusMessage *message, DBusMessage * wpas_dbus_handler_tdls_teardown(DBusMessage *message,
struct wpa_supplicant *wpa_s); struct wpa_supplicant *wpa_s);
DBusMessage *
wpas_dbus_handler_tdls_channel_switch(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_vendor_elem_add(DBusMessage *message, DBusMessage * wpas_dbus_handler_vendor_elem_add(DBusMessage *message,
struct wpa_supplicant *wpa_s); struct wpa_supplicant *wpa_s);