3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

netconfig: Switch to internal active network settings

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.
This commit is contained in:
Tim Kourt 2019-09-30 09:35:53 -07:00 committed by Denis Kenzior
parent d7c52b8280
commit 77770b9566

View File

@ -113,29 +113,11 @@ static struct netconfig *netconfig_find(uint32_t ifindex)
return NULL; 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( static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
struct netconfig *netconfig, struct netconfig *netconfig,
uint8_t proto) uint8_t proto)
{ {
const struct l_dhcp_lease *lease; const struct l_dhcp_lease *lease;
const struct l_settings *settings;
struct netconfig_ifaddr *ifaddr; struct netconfig_ifaddr *ifaddr;
struct in_addr in_addr; struct in_addr in_addr;
char *netmask; char *netmask;
@ -143,18 +125,17 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
switch (proto) { switch (proto) {
case RTPROT_STATIC: 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) if (!ip)
return NULL; return NULL;
ifaddr = l_new(struct netconfig_ifaddr, 1); ifaddr = l_new(struct netconfig_ifaddr, 1);
ifaddr->ip = ip; 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) if (netmask && inet_pton(AF_INET, netmask, &in_addr) > 0)
ifaddr->prefix_len = __builtin_popcountl( ifaddr->prefix_len = __builtin_popcountl(
L_BE32_TO_CPU(in_addr.s_addr)); L_BE32_TO_CPU(in_addr.s_addr));
@ -163,8 +144,9 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
l_free(netmask); l_free(netmask);
ifaddr->broadcast = l_settings_get_string(settings, "IPv4", ifaddr->broadcast =
"broadcast"); l_settings_get_string(netconfig->active_settings,
"IPv4", "broadcast");
ifaddr->family = AF_INET; ifaddr->family = AF_INET;
return ifaddr; return ifaddr;
@ -203,15 +185,12 @@ static struct netconfig_ifaddr *netconfig_ipv4_get_ifaddr(
static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig) static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig)
{ {
const struct l_dhcp_lease *lease; const struct l_dhcp_lease *lease;
const struct l_settings *settings;
switch (netconfig->rtm_protocol) { switch (netconfig->rtm_protocol) {
case RTPROT_STATIC: 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: case RTPROT_DHCP:
lease = l_dhcp_client_get_lease(netconfig->dhcp_client); 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) static char **netconfig_ipv4_get_dns(struct netconfig *netconfig, uint8_t proto)
{ {
const struct l_dhcp_lease *lease; const struct l_dhcp_lease *lease;
const struct l_settings *settings;
switch (proto) { switch (proto) {
case RTPROT_STATIC: 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: case RTPROT_DHCP:
lease = l_dhcp_client_get_lease(netconfig->dhcp_client); lease = l_dhcp_client_get_lease(netconfig->dhcp_client);