Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH v2 3/8] netconfig: Switch to internal active network settings
Date: Mon, 30 Sep 2019 09:35:53 -0700	[thread overview]
Message-ID: <20190930163558.28123-3-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20190930163558.28123-1-tim.a.kourt@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3762 bytes --]

As part of the de-coupling from station object, switch all of
the network settings inquiries to use active_settings. active_settings
are set with netconfig_configure by the owner of netconfig object
and removed with netconfig_reset once network disconnects.
---
 src/netconfig.c | 46 +++++++++++-----------------------------------
 1 file changed, 11 insertions(+), 35 deletions(-)

diff --git a/src/netconfig.c b/src/netconfig.c
index 88d2588e..4e294512 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -113,29 +113,11 @@ static struct netconfig *netconfig_find(uint32_t ifindex)
 	return NULL;
 }
 
-static struct l_settings *netconfig_get_connected_network_settings(
-						struct netconfig *netconfig)
-{
-	struct station *station;
-	const struct network *network;
-
-	station = station_find(netconfig->ifindex);
-	if (!station)
-		return NULL;
-
-	network = station_get_connected_network(station);
-	if (!network)
-		return NULL;
-
-	return network_get_settings(network);
-}
-
 static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
 						struct netconfig *netconfig,
 						uint8_t proto)
 {
 	const struct l_dhcp_lease *lease;
-	const struct l_settings *settings;
 	struct netconfig_ifaddr *ifaddr;
 	struct in_addr in_addr;
 	char *netmask;
@@ -143,18 +125,17 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
 
 	switch (proto) {
 	case RTPROT_STATIC:
-		settings = netconfig_get_connected_network_settings(netconfig);
-		if (!settings)
-			return NULL;
 
-		ip = l_settings_get_string(settings, "IPv4", "ip");
+		ip = l_settings_get_string(netconfig->active_settings, "IPv4",
+									"ip");
 		if (!ip)
 			return NULL;
 
 		ifaddr = l_new(struct netconfig_ifaddr, 1);
 		ifaddr->ip = ip;
 
-		netmask = l_settings_get_string(settings, "IPv4", "netmask");
+		netmask = l_settings_get_string(netconfig->active_settings,
+							"IPv4", "netmask");
 		if (netmask && inet_pton(AF_INET, netmask, &in_addr) > 0)
 			ifaddr->prefix_len = __builtin_popcountl(
 						L_BE32_TO_CPU(in_addr.s_addr));
@@ -163,8 +144,9 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
 
 		l_free(netmask);
 
-		ifaddr->broadcast = l_settings_get_string(settings, "IPv4",
-								"broadcast");
+		ifaddr->broadcast =
+			l_settings_get_string(netconfig->active_settings,
+							"IPv4", "broadcast");
 		ifaddr->family = AF_INET;
 
 		return ifaddr;
@@ -203,15 +185,12 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
 static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig)
 {
 	const struct l_dhcp_lease *lease;
-	const struct l_settings *settings;
 
 	switch (netconfig->rtm_protocol) {
 	case RTPROT_STATIC:
-		settings = netconfig_get_connected_network_settings(netconfig);
-		if (!settings)
-			return NULL;
 
-		return l_settings_get_string(settings, "IPv4", "gateway");
+		return l_settings_get_string(netconfig->active_settings,
+							"IPv4", "gateway");
 
 	case RTPROT_DHCP:
 		lease = l_dhcp_client_get_lease(netconfig->dhcp_client);
@@ -227,15 +206,12 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig)
 static char **netconfig_ipv4_get_dns(struct netconfig *netconfig, uint8_t proto)
 {
 	const struct l_dhcp_lease *lease;
-	const struct l_settings *settings;
 
 	switch (proto) {
 	case RTPROT_STATIC:
-		settings = netconfig_get_connected_network_settings(netconfig);
-		if (!settings)
-			return NULL;
 
-		return l_settings_get_string_list(settings, "IPv4", "dns", ' ');
+		return l_settings_get_string_list(netconfig->active_settings,
+							"IPv4", "dns", ' ');
 
 	case RTPROT_DHCP:
 		lease = l_dhcp_client_get_lease(netconfig->dhcp_client);
-- 
2.13.6

  parent reply	other threads:[~2019-09-30 16:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 16:35 [PATCH v2 1/8] netconfig: Decouple from station state Tim Kourt
2019-09-30 16:35 ` [PATCH v2 2/8] station: netconfig devices based on " Tim Kourt
2019-09-30 16:35 ` Tim Kourt [this message]
2019-09-30 16:35 ` [PATCH v2 4/8] netconfig: Subscribe for IPv6 address changes Tim Kourt
2019-09-30 20:13   ` Denis Kenzior
2019-09-30 16:35 ` [PATCH v2 5/8] netconfig: Request all known IPv6 addresses Tim Kourt
2019-09-30 16:35 ` [PATCH v2 6/8] netconfig: Add IPv6 static address installation/removal Tim Kourt
2019-09-30 16:35 ` [PATCH v2 7/8] netconfig: Install IPv6 default route Tim Kourt
2019-09-30 16:35 ` [PATCH v2 8/8] netconfig: Install IPv6 DNS Tim Kourt
2019-09-30 20:12 ` [PATCH v2 1/8] netconfig: Decouple from station state Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190930163558.28123-3-tim.a.kourt@linux.intel.com \
    --to=tim.a.kourt@linux.intel.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox