* [PATCH v2 1/3] station: Move 'connected' logic out of enter state func
@ 2019-10-09 21:53 Tim Kourt
2019-10-09 21:53 ` [PATCH v2 2/3] netconfig: Add netconfig event notifier Tim Kourt
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tim Kourt @ 2019-10-09 21:53 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2920 bytes --]
Previously, station state 'connected' used to identify an interface associated
with AP. With the introduction of netconfig, an interface is assumed to be
connected after the IP addresses have been assigned to it. If netconfig is
disabled, the behavior remains unchanged.
---
src/station.c | 41 +++++++++++++++++------------------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/src/station.c b/src/station.c
index 72393d51..af209ebb 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1158,26 +1158,9 @@ static void station_enter_state(struct station *station,
IWD_NETWORK_INTERFACE, "Connected");
/* fall through */
case STATION_STATE_DISCONNECTED:
- periodic_scan_stop(station);
-
- break;
case STATION_STATE_CONNECTED:
periodic_scan_stop(station);
- if (!station->netconfig)
- break;
-
- if (station->state == STATION_STATE_ROAMING) {
- netconfig_reconfigure(station->netconfig);
-
- break;
- }
-
- netconfig_configure(station->netconfig,
- network_get_settings(
- station->connected_network),
- netdev_get_address(
- station->netdev));
break;
case STATION_STATE_DISCONNECTING:
case STATION_STATE_ROAMING:
@@ -1302,6 +1285,11 @@ static void station_roamed(struct station *station)
station->signal_low = false;
station->roam_min_time.tv_sec = 0;
station->roam_no_orig_ap = false;
+
+ if (station->netconfig)
+ netconfig_reconfigure(station->netconfig);
+
+ station_enter_state(station, STATION_STATE_CONNECTED);
}
static void station_roam_failed(struct station *station)
@@ -1338,10 +1326,9 @@ static void station_reassociate_cb(struct netdev *netdev,
if (station->state != STATION_STATE_ROAMING)
return;
- if (result == NETDEV_RESULT_OK) {
+ if (result == NETDEV_RESULT_OK)
station_roamed(station);
- station_enter_state(station, STATION_STATE_CONNECTED);
- } else
+ else
station_roam_failed(station);
}
@@ -1357,10 +1344,9 @@ static void station_fast_transition_cb(struct netdev *netdev,
if (station->state != STATION_STATE_ROAMING)
return;
- if (result == NETDEV_RESULT_OK) {
+ if (result == NETDEV_RESULT_OK)
station_roamed(station);
- station_enter_state(station, STATION_STATE_CONNECTED);
- } else
+ else
station_roam_failed(station);
}
@@ -2280,7 +2266,14 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
}
network_connected(station->connected_network);
- station_enter_state(station, STATION_STATE_CONNECTED);
+
+ if (station->netconfig)
+ netconfig_configure(station->netconfig,
+ network_get_settings(
+ station->connected_network),
+ netdev_get_address(station->netdev));
+ else
+ station_enter_state(station, STATION_STATE_CONNECTED);
}
int __station_connect_network(struct station *station, struct network *network,
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] netconfig: Add netconfig event notifier
2019-10-09 21:53 [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Tim Kourt
@ 2019-10-09 21:53 ` Tim Kourt
2019-10-09 22:52 ` Denis Kenzior
2019-10-09 21:53 ` [PATCH v2 3/3] station: Subscribe to " Tim Kourt
2019-10-09 22:06 ` [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Denis Kenzior
2 siblings, 1 reply; 5+ messages in thread
From: Tim Kourt @ 2019-10-09 21:53 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3693 bytes --]
The notifier allows to subscribe for the netconfig events such as ‘connected’.
---
src/netconfig.c | 29 ++++++++++++++++++++++-------
src/netconfig.h | 11 ++++++++++-
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/src/netconfig.c b/src/netconfig.c
index 31cbeb2a..c48e25b1 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -50,6 +50,9 @@ struct netconfig {
uint8_t rtm_v6_protocol;
const struct l_settings *active_settings;
+
+ netconfig_notify_func_t notify;
+ void *user_data;
};
struct netconfig_ifaddr {
@@ -595,11 +598,19 @@ static void netconfig_route_add_cmd_cb(int error, uint16_t type,
const void *data, uint32_t len,
void *user_data)
{
- if (!error)
- return;
+ struct netconfig *netconfig = user_data;
- l_error("netconfig: Failed to add route. Error %d: %s",
+ if (error) {
+ l_error("netconfig: Failed to add route. Error %d: %s",
error, strerror(-error));
+ return;
+ }
+
+ if (!netconfig->notify)
+ return;
+
+ netconfig->notify(NETCONFIG_EVENT_CONNECTED, netconfig->user_data);
+ netconfig->notify = NULL;
}
static void netconfig_route_del_cmd_cb(int error, uint16_t type,
@@ -611,6 +622,7 @@ static void netconfig_route_del_cmd_cb(int error, uint16_t type,
l_error("netconfig: Failed to delete route. Error %d: %s",
error, strerror(-error));
+
}
static bool netconfig_ipv4_routes_install(struct netconfig *netconfig,
@@ -635,7 +647,7 @@ static bool netconfig_ipv4_routes_install(struct netconfig *netconfig,
ifaddr->ip,
netconfig->rtm_protocol,
netconfig_route_add_cmd_cb,
- NULL, NULL)) {
+ netconfig, NULL)) {
l_error("netconfig: Failed to add subnet route.");
return false;
@@ -655,7 +667,7 @@ static bool netconfig_ipv4_routes_install(struct netconfig *netconfig,
ROUTE_PRIORITY_OFFSET,
netconfig->rtm_protocol,
netconfig_route_add_cmd_cb,
- NULL, NULL)) {
+ netconfig, NULL)) {
l_error("netconfig: Failed to add route for: %s gateway.",
gateway);
@@ -723,7 +735,7 @@ static bool netconfig_ipv6_routes_install(struct netconfig *netconfig)
ROUTE_PRIORITY_OFFSET,
netconfig->rtm_v6_protocol,
netconfig_route_add_cmd_cb,
- NULL, NULL)) {
+ netconfig, NULL)) {
l_error("netconfig: Failed to add route for: %s gateway.",
gateway);
@@ -1020,9 +1032,12 @@ static void netconfig_ipv6_select_and_uninstall(struct netconfig *netconfig)
bool netconfig_configure(struct netconfig *netconfig,
const struct l_settings *active_settings,
- const uint8_t *mac_address)
+ const uint8_t *mac_address,
+ netconfig_notify_func_t notify, void *user_data)
{
netconfig->active_settings = active_settings;
+ netconfig->notify = notify;
+ netconfig->user_data = user_data;
l_dhcp_client_set_address(netconfig->dhcp_client, ARPHRD_ETHER,
mac_address, ETH_ALEN);
diff --git a/src/netconfig.h b/src/netconfig.h
index cacd384a..5a527950 100644
--- a/src/netconfig.h
+++ b/src/netconfig.h
@@ -22,9 +22,18 @@
struct netconfig;
+enum netconfig_event {
+ NETCONFIG_EVENT_CONNECTED,
+};
+
+typedef void (*netconfig_notify_func_t)(enum netconfig_event event,
+ void *user_data);
+
bool netconfig_configure(struct netconfig *netconfig,
const struct l_settings *active_settings,
- const uint8_t *mac_address);
+ const uint8_t *mac_address,
+ netconfig_notify_func_t notify,
+ void *user_data);
bool netconfig_reconfigure(struct netconfig *netconfig);
bool netconfig_reset(struct netconfig *netconfig);
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] station: Subscribe to netconfig event notifier
2019-10-09 21:53 [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Tim Kourt
2019-10-09 21:53 ` [PATCH v2 2/3] netconfig: Add netconfig event notifier Tim Kourt
@ 2019-10-09 21:53 ` Tim Kourt
2019-10-09 22:06 ` [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Denis Kenzior
2 siblings, 0 replies; 5+ messages in thread
From: Tim Kourt @ 2019-10-09 21:53 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]
---
src/station.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index af209ebb..9b31cd20 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1314,6 +1314,22 @@ static void station_roam_failed(struct station *station)
station_roam_timeout_rearm(station, 60);
}
+static void station_netconfig_event_handler(enum netconfig_event event,
+ void *user_data)
+{
+ struct station *station = user_data;
+
+ switch (event) {
+ case NETCONFIG_EVENT_CONNECTED:
+ station_enter_state(station, STATION_STATE_CONNECTED);
+
+ break;
+ default:
+ l_error("station: Unsupported netconfig event: %d.", event);
+ break;
+ }
+}
+
static void station_reassociate_cb(struct netdev *netdev,
enum netdev_result result,
void *event_data,
@@ -2271,7 +2287,9 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
netconfig_configure(station->netconfig,
network_get_settings(
station->connected_network),
- netdev_get_address(station->netdev));
+ netdev_get_address(station->netdev),
+ station_netconfig_event_handler,
+ station);
else
station_enter_state(station, STATION_STATE_CONNECTED);
}
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/3] station: Move 'connected' logic out of enter state func
2019-10-09 21:53 [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Tim Kourt
2019-10-09 21:53 ` [PATCH v2 2/3] netconfig: Add netconfig event notifier Tim Kourt
2019-10-09 21:53 ` [PATCH v2 3/3] station: Subscribe to " Tim Kourt
@ 2019-10-09 22:06 ` Denis Kenzior
2 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2019-10-09 22:06 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
Hi Tim,
On 10/9/19 4:53 PM, Tim Kourt wrote:
> Previously, station state 'connected' used to identify an interface associated
> with AP. With the introduction of netconfig, an interface is assumed to be
> connected after the IP addresses have been assigned to it. If netconfig is
> disabled, the behavior remains unchanged.
> ---
> src/station.c | 41 +++++++++++++++++------------------------
> 1 file changed, 17 insertions(+), 24 deletions(-)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/3] netconfig: Add netconfig event notifier
2019-10-09 21:53 ` [PATCH v2 2/3] netconfig: Add netconfig event notifier Tim Kourt
@ 2019-10-09 22:52 ` Denis Kenzior
0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2019-10-09 22:52 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
Hi Tim,
On 10/9/19 4:53 PM, Tim Kourt wrote:
> The notifier allows to subscribe for the netconfig events such as ‘connected’.
> ---
> src/netconfig.c | 29 ++++++++++++++++++++++-------
> src/netconfig.h | 11 ++++++++++-
> 2 files changed, 32 insertions(+), 8 deletions(-)
>
Patch 2 & 3 applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-09 22:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-09 21:53 [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Tim Kourt
2019-10-09 21:53 ` [PATCH v2 2/3] netconfig: Add netconfig event notifier Tim Kourt
2019-10-09 22:52 ` Denis Kenzior
2019-10-09 21:53 ` [PATCH v2 3/3] station: Subscribe to " Tim Kourt
2019-10-09 22:06 ` [PATCH v2 1/3] station: Move 'connected' logic out of enter state func Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox