diff options
author | Denis Kenzior <denkenz@gmail.com> | 2020-04-08 12:33:17 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2020-04-08 12:35:04 -0500 |
commit | 848897ec172f5617cbc8b261715e7556184042f2 (patch) | |
tree | 16a8c6d4c53c006fa5bf5375f4e449c2be1f46f7 | |
parent | 6c959336639e2f6464c4a489b1025d776de58baf (diff) | |
download | iwd-848897ec172f5617cbc8b261715e7556184042f2.tar.gz |
adhoc: Set linkmode & operstate for open networks
For PSK networks we have netdev.c taking care of setting the linkmode &
operstate. For open adhoc networks, netdev.c was never involved which
resulted in linkmode & operstate never being set. Fix this by invoking
the necessary magic when a connection is established.
-rw-r--r-- | src/adhoc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/adhoc.c b/src/adhoc.c index 8c61f81e9..8a995481a 100644 --- a/src/adhoc.c +++ b/src/adhoc.c @@ -24,6 +24,9 @@ #include <config.h> #endif +#include <linux/rtnetlink.h> +#include <linux/if.h> + #include <ell/ell.h> #include "linux/nl80211.h" @@ -160,6 +163,17 @@ static bool ap_sta_match_addr(const void *a, const void *b) return !memcmp(sta->addr, b, 6); } +static void adhoc_operstate_cb(int error, uint16_t type, + const void *data, + uint32_t len, void *user_data) +{ + if (!error) + return; + + l_debug("netdev: %u, error: %s", L_PTR_TO_UINT(user_data), + strerror(-error)); +} + static void adhoc_handshake_event(struct handshake_state *hs, enum handshake_event event, void *user_data, ...) { @@ -397,7 +411,15 @@ static void adhoc_new_station(struct adhoc_state *adhoc, const uint8_t *mac) /* with open networks nothing else is required */ if (sta->adhoc->open) { + int ifindex = netdev_get_ifindex(adhoc->netdev); + sta->authenticated = true; + + l_rtnl_set_linkmode_and_operstate(iwd_get_rtnl(), ifindex, + IF_LINK_MODE_DORMANT, IF_OPER_UP, + adhoc_operstate_cb, + L_UINT_TO_PTR(ifindex), NULL); + l_dbus_property_changed(dbus_get_bus(), netdev_get_path(adhoc->netdev), IWD_ADHOC_INTERFACE, "ConnectedPeers"); |