static void synchronize_device_config (Network *self, Netinterface *iface, NMDevice *device) { NMConnection *connection; NMSettingIP4Config *ip4config; NMSettingIP6Config *ip6config; const char *ip4_method = ""; const char *ip6_method = ""; connection = device_find_connection (self->settings, device); if (!connection) return; ip4config = nm_connection_get_setting_ip4_config (connection); if (ip4config) ip4_method = nm_setting_ip4_config_get_method (ip4config); cockpit_network_netinterface_set_ip4_config_mode (COCKPIT_NETWORK_NETINTERFACE (iface), ip4_method); ip6config = nm_connection_get_setting_ip6_config (connection); if (ip6config) ip6_method = nm_setting_ip6_config_get_method (ip6config); cockpit_network_netinterface_set_ip6_config_mode (COCKPIT_NETWORK_NETINTERFACE (iface), ip6_method); }
const char * nm_utils_get_shared_wifi_permission (NMConnection *connection) { NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIP4Config *s_ip4; const char *method = NULL; s_ip4 = nm_connection_get_setting_ip4_config (connection); if (s_ip4) method = nm_setting_ip4_config_get_method (s_ip4); if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0) return NULL; /* Not shared */ s_wifi = nm_connection_get_setting_wireless (connection); if (s_wifi) { s_wsec = nm_connection_get_setting_wireless_security (connection); if (nm_setting_wireless_get_security (s_wifi) || s_wsec) return NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED; else return NM_AUTH_PERMISSION_WIFI_SHARE_OPEN; } return NULL; }
void nm_utils_complete_generic (NMConnection *connection, const char *ctype, const GSList *existing, const char *format, const char *preferred, gboolean default_enable_ipv6) { NMSettingConnection *s_con; NMSettingIP4Config *s_ip4; NMSettingIP6Config *s_ip6; const char *method; char *id, *uuid; s_con = nm_connection_get_setting_connection (connection); if (!s_con) { s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); } g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_TYPE, ctype, NULL); if (!nm_setting_connection_get_uuid (s_con)) { uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, uuid, NULL); g_free (uuid); } /* Add a connection ID if absent */ if (!nm_setting_connection_get_id (s_con)) { id = get_new_connection_name (existing, format, preferred); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, id, NULL); g_free (id); } /* Add an 'auto' IPv4 connection if present */ s_ip4 = nm_connection_get_setting_ip4_config (connection); if (!s_ip4) { s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); } method = nm_setting_ip4_config_get_method (s_ip4); if (!method) { g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); } /* Add an 'auto' IPv6 setting if allowed and not preset */ s_ip6 = nm_connection_get_setting_ip6_config (connection); if (!s_ip6 && default_enable_ipv6) { s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); } if (s_ip6 && !nm_setting_ip6_config_get_method (s_ip6)) { g_object_set (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, NULL); } }
gboolean nmt_page_ip4_is_non_empty (NmtPageIP4 *ip4) { NMConnection *conn; NMSettingIP4Config *s_ip4; conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ip4)); s_ip4 = nm_connection_get_setting_ip4_config (conn); if ( !g_strcmp0 (nm_setting_ip4_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL) || nm_setting_ip4_config_get_num_addresses (s_ip4)) return TRUE; return FALSE; }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMSettingIP4Config *setting = NM_SETTING_IP4_CONFIG (object); NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting); switch (prop_id) { case PROP_METHOD: g_value_set_string (value, nm_setting_ip4_config_get_method (setting)); break; case PROP_DNS: g_value_set_boxed (value, priv->dns); break; case PROP_DNS_SEARCH: g_value_set_boxed (value, priv->dns_search); break; case PROP_ADDRESSES: nm_utils_ip4_addresses_to_gvalue (priv->addresses, value); break; case PROP_ROUTES: nm_utils_ip4_routes_to_gvalue (priv->routes, value); break; case PROP_IGNORE_AUTO_ROUTES: g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_routes (setting)); break; case PROP_IGNORE_AUTO_DNS: g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_dns (setting)); break; case PROP_DHCP_CLIENT_ID: g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (setting)); break; case PROP_DHCP_SEND_HOSTNAME: g_value_set_boolean (value, nm_setting_ip4_config_get_dhcp_send_hostname (setting)); break; case PROP_DHCP_HOSTNAME: g_value_set_string (value, nm_setting_ip4_config_get_dhcp_hostname (setting)); break; case PROP_NEVER_DEFAULT: g_value_set_boolean (value, priv->never_default); break; case PROP_MAY_FAIL: g_value_set_boolean (value, priv->may_fail); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/* Caller owns a reference to the NMDHCPClient on return */ NMDHCPClient * nm_dhcp_manager_start_ip4 (NMDHCPManager *self, const char *iface, const char *uuid, NMSettingIP4Config *s_ip4, guint32 timeout, guint8 *dhcp_anycast_addr) { NMDHCPManagerPrivate *priv; NMDHCPClient *client = NULL; const char *hostname = NULL; g_return_val_if_fail (self, NULL); g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); priv = NM_DHCP_MANAGER_GET_PRIVATE (self); if (s_ip4) { const char *method = nm_setting_ip4_config_get_method (s_ip4); if (method) { /* Method must be 'auto' */ g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL); } /* If we're asked to send the hostname to DHCP server, and the hostname * isn't specified, and a hostname provider is registered: use that */ if (nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4)) { hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4); /* If we're supposed to send the hostname to the DHCP server but * the user didn't specify one, use the persistent hostname. */ if (!hostname && priv->hostname_provider) { hostname = nm_hostname_provider_get_hostname (priv->hostname_provider); if ( hostname && (!strcmp (hostname, "localhost.localdomain") || !strcmp (hostname, "localhost6.localdomain6"))) hostname = NULL; } } } client = client_start (self, iface, uuid, FALSE, s_ip4, NULL, timeout, dhcp_anycast_addr, hostname, FALSE); return client; }
static void routes_button_clicked_cb (GtkWidget *button, gpointer user_data) { CEPageIP4 *self = CE_PAGE_IP4 (user_data); CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self); GtkWidget *dialog, *toplevel; gboolean automatic = FALSE; const char *method; char *tmp; toplevel = gtk_widget_get_toplevel (CE_PAGE (self)->page); g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel)); method = nm_setting_ip4_config_get_method (priv->setting); if (!method || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) automatic = TRUE; dialog = ip4_routes_dialog_new (priv->setting, automatic); if (!dialog) { g_warning ("%s: failed to create the routes dialog!", __func__); return; } gtk_window_group_add_window (priv->window_group, GTK_WINDOW (dialog)); if (!priv->window_added) { gtk_window_group_add_window (priv->window_group, GTK_WINDOW (toplevel)); priv->window_added = TRUE; } gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); tmp = g_strdup_printf (_("Editing IPv4 routes for %s"), priv->connection_id); gtk_window_set_title (GTK_WINDOW (dialog), tmp); g_free (tmp); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (routes_dialog_response_cb), self); g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (routes_dialog_close_cb), self); gtk_widget_show_all (dialog); }
static NMDevice * get_best_ip4_device (NMManager *manager, NMActRequest **out_req) { GSList *devices, *iter; NMDevice *best = NULL; int best_prio = G_MAXINT; g_return_val_if_fail (manager != NULL, NULL); g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); g_return_val_if_fail (out_req != NULL, NULL); g_return_val_if_fail (*out_req == NULL, NULL); devices = nm_manager_get_devices (manager); for (iter = devices; iter; iter = g_slist_next (iter)) { NMDevice *dev = NM_DEVICE (iter->data); NMActRequest *req; NMConnection *connection; NMIP4Config *ip4_config; NMSettingIP4Config *s_ip4; int prio; guint i; gboolean can_default = FALSE; const char *method = NULL; if (nm_device_get_state (dev) != NM_DEVICE_STATE_ACTIVATED) continue; ip4_config = nm_device_get_ip4_config (dev); if (!ip4_config) continue; req = nm_device_get_act_request (dev); g_assert (req); connection = nm_act_request_get_connection (req); g_assert (connection); /* Never set the default route through an IPv4LL-addressed device */ s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG); if (s_ip4) method = nm_setting_ip4_config_get_method (s_ip4); if (s_ip4 && !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) continue; /* Make sure at least one of this device's IP addresses has a gateway */ for (i = 0; i < nm_ip4_config_get_num_addresses (ip4_config); i++) { NMIP4Address *addr; addr = nm_ip4_config_get_address (ip4_config, i); if (nm_ip4_address_get_gateway (addr)) { can_default = TRUE; break; } } if (!can_default && !NM_IS_DEVICE_MODEM (dev)) continue; /* 'never-default' devices can't ever be the default */ if ( (s_ip4 && nm_setting_ip4_config_get_never_default (s_ip4)) || nm_ip4_config_get_never_default (ip4_config)) continue; prio = nm_device_get_priority (dev); if (prio > 0 && prio < best_prio) { best = dev; best_prio = prio; *out_req = req; } } return best; }
static void test_basic_import (NMVpnPluginUiInterface *plugin, const char *dir) { NMConnection *connection; NMSettingConnection *s_con; NMSettingIP4Config *s_ip4; NMSettingVPN *s_vpn; NMIP4Route *route; struct in_addr tmp; const char *expected_id = "Basic VPN"; const char *expected_route1_dest = "10.0.0.0"; const char *expected_route1_gw = "0.0.0.0"; const char *expected_route2_dest = "172.16.0.0"; const char *expected_route2_gw = "0.0.0.0"; connection = get_basic_connection ("basic-import", plugin, dir, "basic.pcf"); ASSERT (connection != NULL, "basic-import", "failed to import connection"); /* Connection setting */ s_con = nm_connection_get_setting_connection (connection); ASSERT (s_con != NULL, "basic-import", "missing 'connection' setting"); ASSERT (strcmp (nm_setting_connection_get_id (s_con), expected_id) == 0, "basic-import", "unexpected connection ID"); ASSERT (nm_setting_connection_get_uuid (s_con) == NULL, "basic-import", "unexpected valid UUID"); /* IP4 setting */ s_ip4 = nm_connection_get_setting_ip4_config (connection); ASSERT (s_ip4 != NULL, "basic-import", "missing 'ip4-config' setting"); ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 0, "basic-import", "unexpected addresses"); ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == TRUE, "basic-import", "never-default unexpectedly FALSE"); ASSERT (nm_setting_ip4_config_get_method (s_ip4) == NULL, "basic-import", "unexpected IPv4 method"); ASSERT (nm_setting_ip4_config_get_dhcp_client_id (s_ip4) == NULL, "basic-import", "unexpected valid DHCP client ID"); ASSERT (nm_setting_ip4_config_get_dhcp_hostname (s_ip4) == NULL, "basic-import", "unexpected valid DHCP hostname"); ASSERT (nm_setting_ip4_config_get_num_dns_searches (s_ip4) == 0, "basic-import", "unexpected DNS searches"); ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 0, "basic-import", "unexpected DNS servers"); ASSERT (nm_setting_ip4_config_get_num_routes (s_ip4) == 2, "basic-import", "unexpected number of routes"); /* Route #1 */ route = nm_setting_ip4_config_get_route (s_ip4, 0); ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0, "basic-import", "couldn't convert expected route destination #1"); ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr, "basic-import", "unexpected route #1 destination"); ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0, "basic-import", "couldn't convert expected route next hop #1"); ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr, "basic-import", "unexpected route #1 next hop"); ASSERT (nm_ip4_route_get_prefix (route) == 8, "basic-import", "unexpected route #1 prefix"); ASSERT (nm_ip4_route_get_metric (route) == 0, "basic-import", "unexpected route #1 metric"); /* Route #2 */ route = nm_setting_ip4_config_get_route (s_ip4, 1); ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0, "basic-import", "couldn't convert expected route destination #2"); ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr, "basic-import", "unexpected route #2 destination"); ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0, "basic-import", "couldn't convert expected route next hop #2"); ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr, "basic-import", "unexpected route #2 next hop"); ASSERT (nm_ip4_route_get_prefix (route) == 16, "basic-import", "unexpected route #2 prefix"); ASSERT (nm_ip4_route_get_metric (route) == 0, "basic-import", "unexpected route #2 metric"); /* VPN setting */ s_vpn = nm_connection_get_setting_vpn (connection); ASSERT (s_vpn != NULL, "basic-import", "missing 'vpn' setting"); /* Data items */ test_items ("basic-import-data", s_vpn, &basic_items[0], FALSE); /* Secrets */ test_items ("basic-import-secrets", s_vpn, &basic_secrets[0], TRUE); g_object_unref (connection); }
static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting); if (!priv->id) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, NM_SETTING_CONNECTION_ID); return FALSE; } else if (!strlen (priv->id)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, NM_SETTING_CONNECTION_ID); return FALSE; } if (!priv->uuid) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, NM_SETTING_CONNECTION_UUID); return FALSE; } else if (!nm_utils_is_uuid (priv->uuid)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, NM_SETTING_CONNECTION_UUID); return FALSE; } if (!priv->type) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, NM_SETTING_CONNECTION_TYPE); return FALSE; } else if (!strlen (priv->type)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, NM_SETTING_CONNECTION_TYPE); return FALSE; } /* Make sure the corresponding 'type' item is present */ if (all_settings && !g_slist_find_custom (all_settings, priv->type, find_setting_by_name)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, NM_SETTING_CONNECTION_TYPE); return FALSE; } /* * Bonding: Slaves are not allowed to have any IP configuration. */ if (priv->slave_type && all_settings && !strcmp(priv->slave_type, NM_SETTING_BOND_SETTING_NAME)) { GSList *list; list = g_slist_find_custom (all_settings, NM_SETTING_IP4_CONFIG_SETTING_NAME, find_setting_by_name); if (list) { NMSettingIP4Config *s_ip4 = g_slist_nth_data (list, 0); g_assert (s_ip4); if (strcmp (nm_setting_ip4_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, "No IP configuration allowed for bonding slave"); return FALSE; } } list = g_slist_find_custom (all_settings, NM_SETTING_IP6_CONFIG_SETTING_NAME, find_setting_by_name); if (list) { NMSettingIP6Config *s_ip6 = g_slist_nth_data (list, 0); g_assert (s_ip6); if (strcmp (nm_setting_ip6_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { g_set_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, "No IPv6 configuration allowed for bonding slave"); return FALSE; } } } return TRUE; }
static void connect_ip4_page (CEPageIP4 *page) { GtkWidget *content; const gchar *str_method; gboolean disabled; GtkListStore *store; GtkTreeIter iter; guint method; add_address_section (page); add_dns_section (page); add_routes_section (page); page->enabled = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "switch_enable")); g_signal_connect (page->enabled, "notify::active", G_CALLBACK (switch_toggled), page); str_method = nm_setting_ip4_config_get_method (page->setting); disabled = g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0; gtk_switch_set_active (page->enabled, !disabled); g_signal_connect_swapped (page->enabled, "notify::active", G_CALLBACK (ce_page_changed), page); content = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "page_content")); g_object_bind_property (page->enabled, "active", content, "sensitive", G_BINDING_SYNC_CREATE); page->method = GTK_COMBO_BOX (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_addresses")); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Automatic (DHCP)"), METHOD_COL_METHOD, IP4_METHOD_AUTO, -1); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Manual"), METHOD_COL_METHOD, IP4_METHOD_MANUAL, -1); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Link-Local Only"), METHOD_COL_METHOD, IP4_METHOD_LINK_LOCAL, -1); gtk_combo_box_set_model (page->method, GTK_TREE_MODEL (store)); method = IP4_METHOD_AUTO; if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) { method = IP4_METHOD_LINK_LOCAL; } else if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) { method = IP4_METHOD_MANUAL; } else if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { method = IP4_METHOD_SHARED; } else if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) { method = IP4_METHOD_DISABLED; } page->never_default = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "never_default_check")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->never_default), nm_setting_ip4_config_get_never_default (page->setting)); g_signal_connect_swapped (page->never_default, "toggled", G_CALLBACK (ce_page_changed), page); g_signal_connect (page->method, "changed", G_CALLBACK (method_changed), page); if (method != IP4_METHOD_SHARED && method != IP4_METHOD_DISABLED) gtk_combo_box_set_active (page->method, method); }
static void populate_ui (CEPageIP4 *self) { CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self); NMSettingIP4Config *setting = priv->setting; GtkListStore *store; GtkTreeIter model_iter; int method = IP4_METHOD_AUTO; GString *string = NULL; SetMethodInfo info; const char *str_method; int i; /* Method */ gtk_combo_box_set_active (priv->method, 0); str_method = nm_setting_ip4_config_get_method (setting); if (str_method) { if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) method = IP4_METHOD_LINK_LOCAL; else if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) method = IP4_METHOD_MANUAL; else if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) method = IP4_METHOD_SHARED; } if (method == IP4_METHOD_AUTO && nm_setting_ip4_config_get_ignore_auto_dns (setting)) method = IP4_METHOD_AUTO_ADDRESSES; info.method = method; info.combo = priv->method; gtk_tree_model_foreach (GTK_TREE_MODEL (priv->method_store), set_method, &info); /* Addresses */ store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); for (i = 0; i < nm_setting_ip4_config_get_num_addresses (setting); i++) { NMIP4Address *addr = nm_setting_ip4_config_get_address (setting, i); struct in_addr tmp_addr; char buf[INET_ADDRSTRLEN + 1]; const char *ignored; if (!addr) { g_warning ("%s: empty IP4 Address structure!", __func__); continue; } gtk_list_store_append (store, &model_iter); tmp_addr.s_addr = nm_ip4_address_get_address (addr); ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf)); gtk_list_store_set (store, &model_iter, COL_ADDRESS, buf, -1); tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip4_address_get_prefix (addr)); ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf)); gtk_list_store_set (store, &model_iter, COL_PREFIX, buf, -1); tmp_addr.s_addr = nm_ip4_address_get_gateway (addr); ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf)); gtk_list_store_set (store, &model_iter, COL_GATEWAY, buf, -1); } gtk_tree_view_set_model (priv->addr_list, GTK_TREE_MODEL (store)); g_signal_connect_swapped (store, "row-inserted", G_CALLBACK (ce_page_changed), self); g_signal_connect_swapped (store, "row-deleted", G_CALLBACK (ce_page_changed), self); g_object_unref (store); /* DNS servers */ string = g_string_new (""); for (i = 0; i < nm_setting_ip4_config_get_num_dns (setting); i++) { struct in_addr tmp_addr; char buf[INET_ADDRSTRLEN + 1]; const char *ignored; tmp_addr.s_addr = nm_setting_ip4_config_get_dns (setting, i); if (!tmp_addr.s_addr) continue; ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf)); if (string->len) g_string_append (string, ", "); g_string_append (string, buf); } gtk_entry_set_text (priv->dns_servers, string->str); g_string_free (string, TRUE); /* DNS searches */ string = g_string_new (""); for (i = 0; i < nm_setting_ip4_config_get_num_dns_searches (setting); i++) { if (string->len) g_string_append (string, ", "); g_string_append (string, nm_setting_ip4_config_get_dns_search (setting, i)); } gtk_entry_set_text (priv->dns_searches, string->str); g_string_free (string, TRUE); if ((method == IP4_METHOD_AUTO) || (method = IP4_METHOD_AUTO_ADDRESSES)) { if (nm_setting_ip4_config_get_dhcp_client_id (setting)) { gtk_entry_set_text (priv->dhcp_client_id, nm_setting_ip4_config_get_dhcp_client_id (setting)); } } }