+ screen->widgets.timeout_help_l = widget_new_label(set, 0, 0, "seconds");
+
+ screen->widgets.network_l = widget_new_label(set, 0, 0, "Network");
+ screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
+
+ widget_select_add_option(screen->widgets.network_f,
+ NET_CONF_TYPE_DHCP_ALL,
+ "DHCP on all active interfaces",
+ type == NET_CONF_TYPE_DHCP_ALL);
+ widget_select_add_option(screen->widgets.network_f,
+ NET_CONF_TYPE_DHCP_ONE,
+ "DHCP on a specific interface",
+ type == NET_CONF_TYPE_DHCP_ONE);
+ widget_select_add_option(screen->widgets.network_f,
+ NET_CONF_TYPE_STATIC,
+ "Static IP configuration",
+ type == NET_CONF_TYPE_STATIC);
+
+ widget_select_on_change(screen->widgets.network_f,
+ config_screen_network_change, screen);
+
+ screen->widgets.iface_l = widget_new_label(set, 0, 0, "Device:");
+ screen->widgets.iface_f = widget_new_select(set, 0, 0, 20);
+
+ for (i = 0; i < sysinfo->n_interfaces; i++) {
+ struct interface_info *info = sysinfo->interfaces[i];
+ bool is_default;
+
+ is_default = ifcfg && !memcmp(ifcfg->hwaddr, info->hwaddr,
+ sizeof(ifcfg->hwaddr));
+
+ widget_select_add_option(screen->widgets.iface_f,
+ i, info->name, is_default);
+ }
+
+ gw = ip = mask = NULL;
+ if (ifcfg && ifcfg->method == CONFIG_METHOD_STATIC) {
+ char *sep;
+
+ str = talloc_strdup(screen, ifcfg->static_config.address);
+ sep = strchr(str, '/');
+ ip = str;
+
+ if (sep) {
+ *sep = '\0';
+ mask = sep + 1;
+ }
+ gw = ifcfg->static_config.gateway;
+ }
+
+ screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, "IP/mask:");
+ screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip);
+ screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/");
+ screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 3, mask);
+ screen->widgets.ip_addr_mask_help_l =
+ widget_new_label(set, 0, 0, "(eg. 192.168.0.10 / 24)");
+
+ screen->widgets.gateway_l = widget_new_label(set, 0, 0, "Gateway:");
+ screen->widgets.gateway_f = widget_new_textbox(set, 0, 0, 16, gw);
+ screen->widgets.gateway_help_l =
+ widget_new_label(set, 0, 0, "(eg. 192.168.0.1)");
+
+ str = talloc_strdup(screen, "");
+ for (i = 0; i < config->network.n_dns_servers; i++) {
+ str = talloc_asprintf_append(str, "%s%s",
+ (i == 0) ? "" : " ",
+ config->network.dns_servers[i]);
+ }
+
+ screen->widgets.dns_l = widget_new_label(set, 0, 0, "DNS Server(s):");
+ screen->widgets.dns_f = widget_new_textbox(set, 0, 0, 32, str);
+ screen->widgets.dns_help_l =
+ widget_new_label(set, 0, 0, "(eg. 192.168.0.2)");
+
+ screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0,
+ "(if not provided by DHCP server)");