From f1f4f32c02e724f59fcc958d08ab8d543a01311d Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 18 Dec 2013 11:49:39 -0500 Subject: [PATCH] cli: get IP/DHCP config directly from the NMActiveConnection (rh #1036132) Now that NMActiveConnection has IP and DHCP config info, use that directly in "nmcli con show active" rather than getting it from the connection's device; this way, we get the right info for VPN connections as well. --- cli/src/connections.c | 60 ++++++++++++------------------------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/cli/src/connections.c b/cli/src/connections.c index 26be72f50..7376405e6 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -941,66 +941,38 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc) /* IP4 */ if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[1].name) == 0) { - const GPtrArray *devices; - int j; + gboolean b1 = FALSE; + NMIP4Config *cfg4 = nm_active_connection_get_ip4_config (acon); - devices = nm_active_connection_get_devices (acon); - for (j = 0; devices && (j < devices->len); j++) { - gboolean b1 = FALSE; - NMDevice *device = g_ptr_array_index (devices, j); - NMIP4Config *cfg4 = nm_device_get_ip4_config (device); - - b1 = print_ip4_config (cfg4, nmc, "IP4", group_fld); - was_output = was_output || b1; - } + b1 = print_ip4_config (cfg4, nmc, "IP4", group_fld); + was_output = was_output || b1; } /* DHCP4 */ if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[2].name) == 0) { - const GPtrArray *devices; - int j; + gboolean b1 = FALSE; + NMDHCP4Config *dhcp4 = nm_active_connection_get_dhcp4_config (acon); - devices = nm_active_connection_get_devices (acon); - for (j = 0; devices && (j < devices->len); j++) { - gboolean b1 = FALSE; - NMDevice *device = g_ptr_array_index (devices, j); - NMDHCP4Config *dhcp4 = nm_device_get_dhcp4_config (device); - - b1 = print_dhcp4_config (dhcp4, nmc, "DHCP4", group_fld); - was_output = was_output || b1; - } + b1 = print_dhcp4_config (dhcp4, nmc, "DHCP4", group_fld); + was_output = was_output || b1; } /* IP6 */ if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[3].name) == 0) { - const GPtrArray *devices; - int j; + gboolean b1 = FALSE; + NMIP6Config *cfg6 = nm_active_connection_get_ip6_config (acon); - devices = nm_active_connection_get_devices (acon); - for (j = 0; devices && (j < devices->len); j++) { - gboolean b1 = FALSE; - NMDevice *device = g_ptr_array_index (devices, j); - NMIP6Config *cfg6 = nm_device_get_ip6_config (device); - - b1 = print_ip6_config (cfg6, nmc, "IP6", group_fld); - was_output = was_output || b1; - } + b1 = print_ip6_config (cfg6, nmc, "IP6", group_fld); + was_output = was_output || b1; } /* DHCP6 */ if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[4].name) == 0) { - const GPtrArray *devices; - int j; + gboolean b1 = FALSE; + NMDHCP6Config *dhcp6 = nm_active_connection_get_dhcp6_config (acon); - devices = nm_active_connection_get_devices (acon); - for (j = 0; devices && (j < devices->len); j++) { - gboolean b1 = FALSE; - NMDevice *device = g_ptr_array_index (devices, j); - NMDHCP6Config *dhcp6 = nm_device_get_dhcp6_config (device); - - b1 = print_dhcp6_config (dhcp6, nmc, "DHCP6", group_fld); - was_output = was_output || b1; - } + b1 = print_dhcp6_config (dhcp6, nmc, "DHCP6", group_fld); + was_output = was_output || b1; } /* VPN */