Browse Source

Remove trailing spaces

r62650
tags/1.53
Frans Pop 11 years ago
parent
commit
3027542297
7 changed files with 361 additions and 361 deletions
  1. +56
    -56
      dhcp.c
  2. +3
    -3
      ethtool-lite.c
  3. +120
    -120
      netcfg-common.c
  4. +16
    -16
      netcfg-static.c
  5. +40
    -40
      netcfg.c
  6. +72
    -72
      static.c
  7. +54
    -54
      wireless.c

+ 56
- 56
dhcp.c View File

@@ -53,7 +53,7 @@ static pid_t dhcp_pid = -1;
static void netcfg_write_dhcp (char *iface, char *dhostname)
{
FILE *fp;
if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp, "\n# The primary network interface\n");
if (!iface_is_hotpluggable(iface) && !find_in_stab(iface))
@@ -82,7 +82,7 @@ static short no_default_route (void)
{
FILE* iproute = NULL;
char buf[256] = { 0 };
if ((iproute = popen("ip route", "r")) != NULL) {
while (fgets (buf, 256, iproute) != NULL) {
if (buf[0] == 'd' && strstr (buf, "default via ")) {
@@ -92,7 +92,7 @@ static short no_default_route (void)
}
pclose(iproute);
}
return 1;
}

@@ -103,7 +103,7 @@ static short no_default_route (void)
* lease or because it succeeded and daemonized itself), this
* gets the child's exit status and sets dhcp_pid to -1
*/
static void dhcp_client_sigchld(int sig __attribute__ ((unused)))
static void dhcp_client_sigchld(int sig __attribute__ ((unused)))
{
if (dhcp_pid <= 0)
return;
@@ -115,7 +115,7 @@ static void dhcp_client_sigchld(int sig __attribute__ ((unused)))
}


/*
/*
* This function will start whichever DHCP client is available
* using the provided DHCP hostname, if supplied
*
@@ -129,7 +129,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
int options_count;
enum { DHCLIENT, DHCLIENT3, PUMP, UDHCPC } dhcp_client;
int dhcp_seconds;
if (access("/sbin/dhclient", F_OK) == 0)
if (access("/var/lib/dhcp3", F_OK) == 0)
dhcp_client = DHCLIENT3;
@@ -147,11 +147,11 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)

debconf_get(client, "netcfg/dhcp_timeout");
dhcp_seconds = atoi(client->value);
if ((dhcp_pid = fork()) == 0) { /* child */
/* disassociate from debconf */
fclose(client->out);
/* get dhcp lease */
switch (dhcp_client) {
case PUMP:
@@ -159,9 +159,9 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
execlp("pump", "pump", "-i", interface, "-h", dhostname, NULL);
else
execlp("pump", "pump", "-i", interface, NULL);
break;
case DHCLIENT:
/* First, set up dhclient.conf */
if ((dc = file_open(DHCLIENT_CONF, "w"))) {
@@ -184,13 +184,13 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
fprintf(dc, "timeout %d;\n", dhcp_seconds);
fclose(dc);
}
execlp("dhclient", "dhclient", "-e", interface, NULL);
break;
case DHCLIENT3:
/* Different place.. */
if ((dc = file_open(DHCLIENT3_CONF, "w"))) {
fprintf(dc, "send vendor-class-identifier \"d-i\";\n" );
fprintf(dc, "request ");
@@ -211,7 +211,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
fprintf(dc, "timeout %d;\n", dhcp_seconds);
fclose(dc);
}
execlp("dhclient", "dhclient", "-1", interface, NULL);
break;

@@ -253,7 +253,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
}
if (errno != 0)
di_error("Could not exec dhcp client: %s", strerror(errno));
return 1; /* should NEVER EVER get here */
}
else if (dhcp_pid == -1)
@@ -268,7 +268,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)

static int kill_dhcp_client(void)
{
system("killall.sh");
system("killall.sh");
return 0;
}

@@ -289,18 +289,18 @@ int poll_dhcp_client (struct debconfclient *client)
int seconds_slept = 0;
int ret = 1;
int dhcp_seconds;
debconf_get(client, "netcfg/dhcp_timeout");
dhcp_seconds = atoi(client->value);
/* show progress bar */
debconf_capb(client, "backup progresscancel");
debconf_progress_start(client, 0, dhcp_seconds, "netcfg/dhcp_progress");
if (debconf_progress_info(client, "netcfg/dhcp_progress_note") == 30)
goto stop;
netcfg_progress_displayed = 1;
/* wait between 2 and dhcp_seconds seconds for a DHCP lease */
while ( ((dhcp_pid > 0) || (seconds_slept < 2))
&& (seconds_slept < dhcp_seconds) ) {
@@ -310,11 +310,11 @@ int poll_dhcp_client (struct debconfclient *client)
goto stop;
}
/* Either the client exited or time ran out */
/* got a lease? display a success message */
if (!(dhcp_pid > 0) && (dhcp_exit_status == 0)) {
ret = 0;
debconf_capb(client, "backup"); /* stop displaying cancel button */
if (debconf_progress_set(client, dhcp_seconds) == 30)
goto stop;
@@ -322,13 +322,13 @@ int poll_dhcp_client (struct debconfclient *client)
goto stop;
sleep(2);
}
stop:
/* stop progress bar */
debconf_progress_stop(client);
debconf_capb(client, "backup");
netcfg_progress_displayed = 0;
return ret;
}

@@ -345,23 +345,23 @@ int poll_dhcp_client (struct debconfclient *client)
int ask_dhcp_options (struct debconfclient *client)
{
int ret;
if (is_wireless_iface(interface)) {
debconf_metaget(client, "netcfg/internal-wifireconf", "description");
debconf_subst(client, "netcfg/dhcp_options", "wifireconf", client->value);
}
else /* blank from last time */
debconf_subst(client, "netcfg/dhcp_options", "wifireconf", "");
/* critical, we don't want to enter a loop */
debconf_input(client, "critical", "netcfg/dhcp_options");
ret = debconf_go(client);
if (ret == 30)
return GO_BACK;
debconf_get(client, "netcfg/dhcp_options");
/* strcmp sucks */
if (client->value[0] == 'R') { /* _R_etry ... or _R_econfigure ... */
size_t len = strlen(client->value);
@@ -408,10 +408,10 @@ int netcfg_activate_dhcp (struct debconfclient *client)
{
char* dhostname = NULL;
enum { START, POLL, ASK_OPTIONS, DHCP_HOSTNAME, HOSTNAME, DOMAIN, HOSTNAME_SANS_NETWORK } state = START;
kill_dhcp_client();
loop_setup();
for (;;) {
switch (state) {
case START:
@@ -437,31 +437,31 @@ int netcfg_activate_dhcp (struct debconfclient *client)
*/

/* Before doing anything else, check for a default route */
if (no_default_route()) {
debconf_input(client, "critical", "netcfg/no_default_route");
debconf_go(client);
debconf_get(client, "netcfg/no_default_route");
if (!strcmp(client->value, "false")) {
state = ASK_OPTIONS;
break;
}
}
/*
* Set defaults for domain name and hostname
*/
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 63
#endif
char buf[MAXHOSTNAMELEN + 1] = { 0 };
char *ptr = NULL;
FILE *d = NULL;
have_domain = 0;
/*
* Default to the domain name returned via DHCP, if any
*/
@@ -470,7 +470,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
fgets(domain, _UTSNAME_LENGTH, d);
fclose(d);
unlink(DOMAIN_FILE);
if (!empty_str(domain) && verify_hostname(domain) == 0) {
debconf_set(client, "netcfg/get_domain", domain);
have_domain = 1;
@@ -486,9 +486,9 @@ int netcfg_activate_dhcp (struct debconfclient *client)
fgets(ntpservers, DHCP_OPTION_LEN, d);
fclose(d);
unlink(NTP_SERVER_FILE);
if (!empty_str(ntpservers)) {
debconf_set(client, "netcfg/dhcp_ntp_servers",
debconf_set(client, "netcfg/dhcp_ntp_servers",
ntpservers);
}
}
@@ -512,7 +512,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
} else {
struct ifreq ifr;
struct in_addr d_ipaddr = { 0 };
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, interface, IFNAMSIZ);
if (ioctl(skfd, SIOCGIFADDR, &ifr) == 0) {
@@ -522,7 +522,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
else
di_warning("ioctl failed (%s)", strerror(errno));
}
/*
* Default to the domain name that is the domain part
* of the hostname, if any
@@ -531,23 +531,23 @@ int netcfg_activate_dhcp (struct debconfclient *client)
debconf_set(client, "netcfg/get_domain", ptr + 1);
have_domain = 1;
}
/* Make sure we have NS going if the DHCP server didn't serve it up */
if (resolv_conf_entries() <= 0) {
char *nameservers = NULL;
if (netcfg_get_nameservers (client, &nameservers) == GO_BACK) {
state = ASK_OPTIONS;
break;
}
netcfg_nameservers_to_array (nameservers, nameserver_array);
}
state = HOSTNAME;
}
break;
case ASK_OPTIONS:
/* DHCP client may still be running */
switch (ask_dhcp_options (client)) {
@@ -602,7 +602,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
state = START;
}
break;
case HOSTNAME:
if (netcfg_get_hostname (client, "netcfg/get_hostname", &hostname, 1)) {
/*
@@ -616,7 +616,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
else
state = DOMAIN;
break;
case DOMAIN:
if (!have_domain && netcfg_get_domain (client, &domain))
state = HOSTNAME;
@@ -626,7 +626,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
return 0;
}
break;
case HOSTNAME_SANS_NETWORK:
if (netcfg_get_hostname (client, "netcfg/get_hostname", &hostname, 0))
state = ASK_OPTIONS;
@@ -639,31 +639,31 @@ int netcfg_activate_dhcp (struct debconfclient *client)
break;
}
}
}
}

/* returns number of 'nameserver' entries in resolv.conf */
int resolv_conf_entries (void)
{
FILE *f;
int count = 0;
if ((f = fopen(RESOLV_FILE, "r")) != NULL) {
char buf[256];
while (fgets(buf, 256, f) != NULL) {
char *ptr;
if ((ptr = strchr(buf, ' ')) != NULL) {
*ptr = '\0';
if (strcmp(buf, "nameserver") == 0)
count++;
}
}
fclose(f);
}
else
count = -1;
return count;
}

+ 3
- 3
ethtool-lite.c View File

@@ -65,7 +65,7 @@ int ethtool_lite (char * iface)
}
iface = argv[1];
#endif
#if defined(__linux__)
struct ethtool_value edata;
struct ifreq ifr;
@@ -74,10 +74,10 @@ int ethtool_lite (char * iface)
edata.cmd = ETHTOOL_GLINK;
ifr.ifr_data = (char *)&edata;
strncpy (ifr.ifr_name, iface, IFNAMSIZ);
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0)
di_info("ethtool ioctl on %s failed\n", iface);
if (edata.data)
{
di_info("%s is connected.\n", iface);


+ 120
- 120
netcfg-common.c View File

@@ -1,20 +1,20 @@
/*
netcfg-common.c - Shared functions used to configure the network for
/*
netcfg-common.c - Shared functions used to configure the network for
the debian-installer.

Copyright (C) 2000-2002 David Kimdon <dwhedon@debian.org>
and others (see debian/copyright)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -77,7 +77,7 @@ int inet_ptom (const char *src, int *dst, struct in_addr *addrp)
{
struct in_addr newaddr, *addr;
in_addr_t mask, num;
if (src && !addrp) {
if (inet_pton (AF_INET, src, &newaddr) < 0)
return 0;
@@ -85,22 +85,22 @@ int inet_ptom (const char *src, int *dst, struct in_addr *addrp)
}
else
addr = addrp;
mask = ntohl(addr->s_addr);

for (num = mask; num & 1; num >>= 1);
if (num != 0 && mask != 0) {
for (num = ~mask; num & 1; num >>= 1);
if (num)
return 0;
}
for (num = 0; mask; mask <<= 1)
num++;
*dst = num;
return 1;
}

@@ -109,12 +109,12 @@ const char *inet_mtop (int src, char *dst, socklen_t cnt)
{
struct in_addr addr;
in_addr_t mask = 0;
for(; src; src--)
mask |= 1 << (32 - src);
addr.s_addr = htonl(mask);
return inet_ntop (AF_INET, &addr, dst, cnt);
}

@@ -142,24 +142,24 @@ int check_kill_switch(const char *iface)
int linklen, killlen;
int fd = -1;
int ret = 0;
/* longest string we need */
len = strlen(SYSCLASSNET) + strlen(iface) + strlen("/device/rf_kill") + 1;
temp = malloc(len);
snprintf(temp, len, SYSCLASSNET "%s/driver", iface);
linkbuf = malloc(1024); /* probably OK ... I hate readlink() */
linklen = readlink(temp, linkbuf, 1024);
if (linklen < 0)
goto out;
if (strncmp(linkbuf + linklen - 8, "/ipw2100", 8) == 0)
killname = "rf_kill";
else if (strncmp(linkbuf + linklen - 8, "/ipw2200", 8) == 0)
killname = "rf_kill";
else
goto out;
snprintf(temp, len, SYSCLASSNET "%s/device/%s", iface, killname);
di_info("Checking RF kill switch: %s", temp);
fd = open(temp, O_RDONLY);
@@ -173,12 +173,12 @@ int check_kill_switch(const char *iface)
di_warning("RF kill state file empty");
goto out;
}
if (killstate == '2') {
di_info("RF kill switch enabled");
ret = 1;
}
out:
free(temp);
free(linkbuf);
@@ -201,9 +201,9 @@ int is_raw_80211(const char *iface)
{
struct ifreq ifr;
struct sockaddr sa;
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
if (skfd && ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) {
di_warning("Unable to retrieve interface type.");
return 0;
@@ -235,7 +235,7 @@ int get_all_ifs (int all, char*** ptr)
char ibuf[512];
char** list = NULL;
size_t len = 0;
if (getifaddrs(&ifap) == -1)
return 0;

@@ -267,16 +267,16 @@ int get_all_ifs (int all, char*** ptr)
}
}
}
/* OK, now sort the list and terminate it if necessary */
if (list != NULL) {
qsort(list, len, sizeof(char *), qsort_strcmp);
list[len] = NULL;
}
freeifaddrs(ifap);
*ptr = list;
return len;
}

@@ -286,13 +286,13 @@ short find_in_stab(const char* iface)
FILE *dn = NULL;
char buf[128];
size_t len = strlen(iface);
if (access(STAB, F_OK) == -1)
return 0;
if (!(dn = popen("grep -v '^Socket' " STAB " | cut -f5", "r")))
return 0;
while (fgets (buf, 128, dn) != NULL) {
if (!strncmp(buf, iface, len)) {
pclose(dn);
@@ -315,13 +315,13 @@ char *find_in_devnames(const char* iface)
FILE* dn = NULL;
char buf[512], *result = NULL;
size_t len = strlen(iface);
if (!(dn = fopen(DEVNAMES, "r")))
return NULL;
while (fgets(buf, 512, dn) != NULL) {
char *ptr = strchr(buf, ':'), *desc = ptr + 1;
if (!ptr) {
result = NULL; /* corrupt */
break;
@@ -331,35 +331,35 @@ char *find_in_devnames(const char* iface)
break;
}
}
fclose(dn);
if (result) {
len = strlen(result);
if (result[len - 1] == '\n')
result[len - 1] = '\0';
}
return result;
}

char *get_ifdsc(struct debconfclient *client, const char *ifp)
{
char template[256], *ptr = NULL;
if ((ptr = find_in_devnames(ifp)) != NULL) {
debconf_metaget(client, "netcfg/internal-wireless", "description");
if (is_wireless_iface(ifp)) {
size_t len = strlen(ptr) + strlen(client->value) + 4;
ptr = realloc(ptr, len);
di_snprintfcat(ptr, len, " (%s)", client->value);
}
return ptr; /* already strdup'd */
}
if (strlen(ifp) < 100) {
if (!is_wireless_iface(ifp)) {
/* strip away the number from the interface (eth0 -> eth) */
@@ -367,10 +367,10 @@ char *get_ifdsc(struct debconfclient *client, const char *ifp)
while ((*ptr < '0' || *ptr > '9') && *ptr != '\0')
ptr++;
*ptr = '\0';
sprintf(template, "netcfg/internal-%s", new_ifp);
free(new_ifp);
if (debconf_metaget(client, template, "description") == 0 &&
client->value != NULL) {
return strdup(client->value);
@@ -393,12 +393,12 @@ int iface_is_hotpluggable(const char *iface)
FILE* f = NULL;
char buf[256];
size_t len = strlen(iface);
if (!(f = fopen(DEVHOTPLUG, "r"))) {
di_info("No hotpluggable devices are present in the system.");
return 0;
}
while (fgets(buf, 256, f) != NULL) {
if (!strncmp(buf, iface, len)) {
di_info("Detected %s as a hotpluggable device", iface);
@@ -406,9 +406,9 @@ int iface_is_hotpluggable(const char *iface)
return 1;
}
}
fclose(f);
di_info("Hotpluggable devices available, but %s is not one of them", iface);
return 0;
}
@@ -437,7 +437,7 @@ void netcfg_die(struct debconfclient *client)

/**
* @brief Ask which interface to configure
* @param client - client
* @param client - client
* @param interface - set to the answer
* @param numif - number of interfaces found.
*/
@@ -452,35 +452,35 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
char *ptr = NULL;
char *ifdsc = NULL;
char *old_selection = NULL;
if (*interface) {
free(*interface);
*interface = NULL;
}
if (!(ptr = malloc(128)))
goto error;
len = 128;
*ptr = '\0';
num_interfaces = get_all_ifs(1, &ifs);
/* If no default was provided, use the first in the list of interfaces. */
if (! defif && num_interfaces > 0) {
defif=ifs[0];
}
/* Remember old interface selection, in case it's preseeded. */
debconf_get(client, "netcfg/choose_interface");
old_selection = strdup(client->value);
for (i = 0; i < num_interfaces; i++) {
size_t newchars;
char *temp = NULL;
inter = ifs[i];
interface_down(inter);
ifdsc = get_ifdsc(client, inter);
newchars = strlen(inter) + strlen(ifdsc) + 5; /* ": , " + NUL */
@@ -489,21 +489,21 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
goto error;
len += newchars + 128;
}
temp = malloc(newchars);
snprintf(temp, newchars, "%s: %s", inter, ifdsc);
if (num_interfaces > 1 &&
((strcmp(defif, inter) == 0) || (strcmp(defif, temp) == 0)))
debconf_set(client, "netcfg/choose_interface", temp);
di_snprintfcat(ptr, len, "%s, ", temp);
free(temp);
free(ifdsc);
}
if (num_interfaces == 0) {
debconf_input(client, "high", "netcfg/no_interfaces");
ret = debconf_go(client);
@@ -521,32 +521,32 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
*numif = num_interfaces;
/* remove the trailing ", ", which confuses cdebconf */
ptr[strlen(ptr) - 2] = '\0';
debconf_subst(client, "netcfg/choose_interface", "ifchoices", ptr);
free(ptr);
asked = (debconf_input(client, "critical", "netcfg/choose_interface") == 0);
ret = debconf_go(client);
/* If the question is not asked, honor preseeded interface name.
* However, if it was preseeded to "auto", or there was no old value,
* leave it set to defif. */
if (!asked && strlen(old_selection) && strcmp(old_selection, "auto") != 0) {
debconf_set(client, "netcfg/choose_interface", old_selection);
}
free(old_selection);
if (ret)
return ret;
debconf_get(client, "netcfg/choose_interface");
inter = client->value;
if (!inter)
netcfg_die(client);
}
/* grab just the interface name, not the description too */
*interface = inter;
/* Note that the question may be preseeded to just the interface name,
@@ -556,17 +556,17 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
*ptr = '\0';
}
*interface = strdup(*interface);
/* Free allocated memory */
while (ifs && *ifs)
free(*ifs++);
return 0;

error:
if (ptr)
free(ptr);
netcfg_die(client);
return 10; /* unreachable */
}
@@ -581,9 +581,9 @@ short verify_hostname (char *hname)
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.";
size_t len;
assert(hname != NULL);
len = strlen(hname);
/* Check the hostname for RFC 1123 compliance. */
if ((len < 1) ||
(len > 63) ||
@@ -597,25 +597,25 @@ short verify_hostname (char *hname)
}

/*
* Set the hostname.
* Set the hostname.
* @return 0 on success, 30 on BACKUP being selected.
*/
int netcfg_get_hostname(struct debconfclient *client, char *template, char **hostname, short hdset)
{
int ret;
char *s;
for(;;) {
if (hdset)
have_domain = 0;
debconf_input(client, "high", template);
ret = debconf_go(client);
if (ret == 30) /* backup */
return ret;
debconf_get(client, template);
if (verify_hostname(client->value) != 0) {
debconf_subst(client, "netcfg/invalid_hostname",
"hostname", client->value);
@@ -630,7 +630,7 @@ int netcfg_get_hostname(struct debconfclient *client, char *template, char **hos
break;
}
}
/* don't strip DHCP hostnames */
if (hdset && (s = strchr(*hostname, '.'))) {
if (s[1] == '\0') { /* "somehostname." <- . should be ignored */
@@ -653,7 +653,7 @@ int netcfg_get_hostname(struct debconfclient *client, char *template, char **hos
int netcfg_get_domain(struct debconfclient *client, char **domain)
{
int ret;
if (have_domain == 1)
{
debconf_get(client, "netcfg/get_domain");
@@ -666,12 +666,12 @@ int netcfg_get_domain(struct debconfclient *client, char **domain)

debconf_input (client, "high", "netcfg/get_domain");
ret = debconf_go(client);
if (ret)
return ret;
debconf_get (client, "netcfg/get_domain");
if (*domain)
free(*domain);
*domain = NULL;
@@ -687,7 +687,7 @@ int netcfg_get_domain(struct debconfclient *client, char **domain)
void netcfg_write_loopback (void)
{
FILE *fp;
if ((fp = file_open(INTERFACES_FILE, "w"))) {
fprintf(fp, HELPFUL_COMMENT);
fprintf(fp, "\n# The loopback network interface\n");
@@ -706,10 +706,10 @@ void netcfg_write_loopback (void)
void netcfg_write_common(struct in_addr ipaddress, char *hostname, char *domain)
{
FILE *fp;
if (!hostname)
return;
if ((fp = file_open(INTERFACES_FILE, "w"))) {
fprintf(fp, HELPFUL_COMMENT);
fprintf(fp, "\n# The loopback network interface\n");
@@ -717,20 +717,20 @@ void netcfg_write_common(struct in_addr ipaddress, char *hostname, char *domain)
fprintf(fp, "iface "LO_IF" inet loopback\n");
fclose(fp);
}
/* Currently busybox, hostname is not available. */
sethostname (hostname, strlen(hostname) + 1);
if ((fp = file_open(HOSTNAME_FILE, "w"))) {
fprintf(fp, "%s\n", hostname);
fclose(fp);
}
if ((fp = file_open(HOSTS_FILE, "w"))) {
char ptr1[INET_ADDRSTRLEN];
fprintf(fp, "127.0.0.1\tlocalhost\n");
if (ipaddress.s_addr) {
inet_ntop (AF_INET, &ipaddress, ptr1, sizeof(ptr1));
if (domain && !empty_str(domain))
@@ -743,9 +743,9 @@ void netcfg_write_common(struct in_addr ipaddress, char *hostname, char *domain)
else
fprintf(fp, "127.0.1.1\t%s\n", hostname);
}
fprintf(fp, "\n" IPV6_HOSTS);
fclose(fp);
}
}
@@ -761,12 +761,12 @@ void deconfigure_network(void)
void loop_setup(void)
{
static int afpacket_notloaded = 1;
deconfigure_network();
if (afpacket_notloaded)
afpacket_notloaded = di_exec_shell("modprobe af_packet"); /* should become 0 */
di_exec_shell_log("ip link set "LO_IF" up");
di_exec_shell_log("ip addr flush dev "LO_IF);
di_exec_shell_log("ip addr add 127.0.0.1/8 dev "LO_IF);
@@ -777,43 +777,43 @@ void seed_hostname_from_dns (struct debconfclient * client, struct in_addr *ipad
struct sockaddr_in sin;
char *host;
int err;
host = malloc(NI_MAXHOST);
if (!host)
netcfg_die(client);
/* copy IP address into required format */
sin.sin_family = AF_INET;
sin.sin_port = 0;
memcpy(&sin.sin_addr, ipaddr, sizeof(*ipaddr));
/* attempt resolution */
err = getnameinfo((struct sockaddr *) &sin, sizeof(sin),
host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
/* got it? */
if (err == 0 && !empty_str(host)) {
/* remove domain part */
char* ptr = strchr(host, '.');
if (ptr)
*ptr = '\0';
debconf_set(client, "netcfg/get_hostname", host);
if (!have_domain && (ptr && ptr[1] != '\0'))
debconf_set(client, "netcfg/get_domain", ptr + 1);
}
free(host);
}

void interface_up (char* iface)
{
struct ifreq ifr;
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
if (skfd && ioctl(skfd, SIOCGIFFLAGS, &ifr) >= 0) {
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
@@ -824,9 +824,9 @@ void interface_up (char* iface)
void interface_down (char* iface)
{
struct ifreq ifr;
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
if (skfd && ioctl(skfd, SIOCGIFFLAGS, &ifr) >= 0) {
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
ifr.ifr_flags &= ~IFF_UP;
@@ -849,7 +849,7 @@ void parse_args (int argc, char ** argv)
netcfg_write_loopback();
exit(EXIT_SUCCESS);
}
exit(EXIT_FAILURE);
}
}
@@ -860,7 +860,7 @@ void reap_old_files (void)
{ INTERFACES_FILE, HOSTS_FILE, HOSTNAME_FILE, NETWORKS_FILE,
RESOLV_FILE, DHCLIENT_CONF, DHCLIENT3_CONF, DOMAIN_FILE, 0 };
char **ptr = remove;
while (*ptr)
unlink(*ptr++);
}
@@ -869,10 +869,10 @@ void netcfg_nameservers_to_array(char *nameservers, struct in_addr array[])
{
char *save, *ptr, *ns;
int i;
if (nameservers) {
save = ptr = strdup(nameservers);
for (i = 0; i < 3; i++) {
ns = strtok_r(ptr, " \n\t", &ptr);
if (ns)
@@ -880,7 +880,7 @@ void netcfg_nameservers_to_array(char *nameservers, struct in_addr array[])
else
array[i].s_addr = 0;
}
array[3].s_addr = 0;
free(save);
} else
@@ -891,7 +891,7 @@ int netcfg_get_nameservers (struct debconfclient *client, char **nameservers)
{
char *ptr, ptr1[INET_ADDRSTRLEN];
int ret;
debconf_get(client,"netcfg/get_nameservers");
if (*nameservers)
ptr = *nameservers;
@@ -904,16 +904,16 @@ int netcfg_get_nameservers (struct debconfclient *client, char **nameservers)
else
ptr = "";
debconf_set(client, "netcfg/get_nameservers", ptr);
debconf_input(client, "critical", "netcfg/get_nameservers");
ret = debconf_go(client);
if (ret)
return ret;
debconf_get(client, "netcfg/get_nameservers");
ptr = client->value;
if (*nameservers)
free(*nameservers);
*nameservers = NULL;


+ 16
- 16
netcfg-static.c View File

@@ -1,22 +1,22 @@
/*
/*
netcfg-static.c - Configure a static network for debian-installer

Copyright (C) 2000-2002 David Kimdon <dwhedon@debian.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include <stdlib.h>
@@ -32,20 +32,20 @@ int main(int argc, char** argv)
int num_interfaces = 0;
static struct debconfclient *client;
static int requested_wireless_tools = 0;
enum { BACKUP, GET_INTERFACE, GET_HOSTNAME_ONLY, GET_STATIC, WCONFIG, WCONFIG_ESSID, WCONFIG_WEP, QUIT} state = GET_INTERFACE;
/* initialize libd-i */
di_system_init("netcfg-static");
parse_args(argc, argv);
reap_old_files();
open_sockets();
/* initialize debconf */
client = debconfclient_new();
debconf_capb(client, "backup");
while (1) {
switch(state) {
case BACKUP:
@@ -73,12 +73,12 @@ int main(int argc, char** argv)
}
break;
case GET_STATIC:
if (netcfg_get_static(client))
if (netcfg_get_static(client))
state = (num_interfaces == 1) ? BACKUP : GET_INTERFACE;
else
state = QUIT;
break;
case WCONFIG:
if (requested_wireless_tools == 0) {
requested_wireless_tools = 1;
@@ -86,26 +86,26 @@ int main(int argc, char** argv)
}
state = WCONFIG_ESSID;
break;
case WCONFIG_ESSID:
if (netcfg_wireless_set_essid (client, interface, NULL))
state = BACKUP;
else
state = WCONFIG_WEP;
break;
case WCONFIG_WEP:
if (netcfg_wireless_set_wep (client, interface))
state = WCONFIG_ESSID;
else
state = GET_STATIC;
break;
case QUIT:
netcfg_update_entropy();
return 0;
}
}
return 0;
}

+ 40
- 40
netcfg.c View File

@@ -1,20 +1,20 @@
/*
netcfg.c - Configure a network via DHCP or manual configuration
/*
netcfg.c - Configure a network via DHCP or manual configuration
for debian-installer

Copyright (C) 2000-2002 David Kimdon <dwhedon@debian.org>
and others (see debian/copyright)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -38,23 +38,23 @@ static method_t netcfg_method = DHCP;
response_t netcfg_get_method(struct debconfclient *client)
{
int iret, ret;
iret = debconf_input(client, "medium", "netcfg/use_dhcp");
ret = debconf_go(client);
if (ret == 30)
return GO_BACK;
debconf_get(client, "netcfg/use_dhcp");
if (strcmp(client->value, "true") == 0)
netcfg_method = DHCP;
else
else
netcfg_method = STATIC;
if (iret == 30)
return NOT_ASKED;
return 0;
}

@@ -71,20 +71,20 @@ int main(int argc, char *argv[])
WCONFIG_ESSID,
WCONFIG_WEP,
QUIT } state = GET_INTERFACE;
static struct debconfclient *client;
static int requested_wireless_tools = 0;
char **ifaces;
char *defiface = NULL, *defwireless = NULL;
response_t res;
/* initialize libd-i */
di_system_init("netcfg");
parse_args (argc, argv);
reap_old_files ();
open_sockets();
/* initialize debconf */
client = debconfclient_new();
debconf_capb(client, "backup");
@@ -101,16 +101,16 @@ int main(int argc, char *argv[])
netcfg_write_common(null_ipaddress, hostname, NULL);
return 0;
}
/* always always always default back to DHCP, unless you've specified
* disable_dhcp on the command line. */
debconf_get(client, "netcfg/disable_dhcp");
if (!strcmp(client->value, "true"))
debconf_set(client, "netcfg/use_dhcp", "false");
else
debconf_set(client, "netcfg/use_dhcp", "true");
for (;;) {
switch(state) {
case BACKUP:
@@ -132,11 +132,11 @@ int main(int argc, char *argv[])
continue;
}
}
interface_up(*ifaces);
usleep(250);
if (ethtool_lite (*ifaces) == 1) /* CONNECTED */ {
defiface = strdup(*ifaces);
interface_down(*ifaces);
@@ -145,17 +145,17 @@ int main(int argc, char *argv[])
#ifdef WIRELESS
else {
struct wireless_config wc;
if (iw_get_basic_config(wfd, *ifaces, &wc) == 0) {
wc.essid[0] = '\0';
wc.essid_on = 0;
iw_set_basic_config(wfd, *ifaces, &wc);
sleep(1);
iw_get_basic_config(wfd, *ifaces, &wc);
if (!empty_str(wc.essid)) {
di_info("%s is associated with %s. Selecting as default", *ifaces, wc.essid);
defiface = strdup(*ifaces);
@@ -170,23 +170,23 @@ int main(int argc, char *argv[])
}
else
di_info("%s is not a wireless interface. Continuing.", *ifaces);
interface_down(*ifaces);
}
#endif
interface_down(*ifaces);
ifaces++;
}
}
if (state == BACKUP)
break;
if (!defiface && defwireless)
defiface = defwireless;
if(netcfg_get_interface(client, &interface, &num_interfaces, defiface))
state = BACKUP;
else if (! interface || ! num_interfaces)
@@ -212,13 +212,13 @@ int main(int argc, char *argv[])
if ((res = netcfg_get_method(client)) == GO_BACK)
state = (num_interfaces == 1) ? BACKUP : GET_INTERFACE;
else {
if (netcfg_method == DHCP)
if (netcfg_method == DHCP)
state = GET_DHCP;
else
state = GET_STATIC;
}
break;
case GET_DHCP:
switch (netcfg_activate_dhcp(client)) {
case 0:
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
return 1;
}
break;
case GET_STATIC:
{
int ret;
@@ -252,7 +252,7 @@ int main(int argc, char *argv[])
state = QUIT;
break;
}
case WCONFIG:
if (requested_wireless_tools == 0) {
di_exec_shell_log("apt-install wireless-tools");
@@ -260,21 +260,21 @@ int main(int argc, char *argv[])
}
state = WCONFIG_ESSID;
break;
case WCONFIG_ESSID:
if (netcfg_wireless_set_essid(client, interface, NULL) == GO_BACK)
state = BACKUP;
else
state = WCONFIG_WEP;
break;
case WCONFIG_WEP:
if (netcfg_wireless_set_wep(client, interface) == GO_BACK)
state = WCONFIG_ESSID;
else
state = GET_METHOD;
break;
case QUIT:
netcfg_update_entropy();
return 0;


+ 72
- 72
static.c View File

@@ -19,19 +19,19 @@ struct in_addr pointopoint = { 0 };
int netcfg_get_ipaddress(struct debconfclient *client)
{
int ret, ok = 0;
old_ipaddress = ipaddress;
while (!ok) {
debconf_input (client, "critical", "netcfg/get_ipaddress");
ret = debconf_go (client);
if (ret)
return ret;
debconf_get(client, "netcfg/get_ipaddress");
ok = inet_pton (AF_INET, client->value, &ipaddress);
if (!ok) {
debconf_capb(client);
debconf_input (client, "critical", "netcfg/bad_ipaddress");
@@ -39,30 +39,30 @@ int netcfg_get_ipaddress(struct debconfclient *client)
debconf_go (client);
}
}
return 0;
}

int netcfg_get_pointopoint(struct debconfclient *client)
{
int ret, ok = 0;
while (!ok) {
debconf_input(client, "critical", "netcfg/get_pointopoint");
ret = debconf_go(client);
if (ret)
return ret;
debconf_get(client, "netcfg/get_pointopoint");
if (empty_str(client->value)) { /* No P-P is ok */
memset(&pointopoint, 0, sizeof(struct in_addr));
return 0;
}
ok = inet_pton (AF_INET, client->value, &pointopoint);
if (!ok) {
debconf_capb(client);
debconf_input (client, "critical", "netcfg/bad_ipaddress");
@@ -70,11 +70,11 @@ int netcfg_get_pointopoint(struct debconfclient *client)
debconf_capb(client, "backup");
}
}
inet_pton (AF_INET, "255.255.255.255", &netmask);
network = ipaddress;
gateway = pointopoint;
return 0;
}

@@ -83,18 +83,18 @@ int netcfg_get_netmask(struct debconfclient *client)
int ret, ok = 0;
char ptr1[INET_ADDRSTRLEN];
struct in_addr old_netmask = netmask;
while (!ok) {
debconf_input (client, "critical", "netcfg/get_netmask");
ret = debconf_go(client);
if (ret)
return ret;
debconf_get (client, "netcfg/get_netmask");
ok = inet_pton (AF_INET, client->value, &netmask);
if (!ok) {
debconf_capb(client);
debconf_input (client, "critical", "netcfg/bad_ipaddress");
@@ -102,20 +102,20 @@ int netcfg_get_netmask(struct debconfclient *client)
debconf_capb(client, "backup");
}
}
if (ipaddress.s_addr != old_ipaddress.s_addr ||
netmask.s_addr != old_netmask.s_addr
) {
network.s_addr = ipaddress.s_addr & netmask.s_addr;
broadcast.s_addr = (network.s_addr | ~netmask.s_addr);
/* Preseed gateway */
gateway.s_addr = ipaddress.s_addr & netmask.s_addr;
gateway.s_addr |= htonl(1);
}
inet_ntop (AF_INET, &gateway, ptr1, sizeof (ptr1));
/* if you entered a .1 ip, you'll get a .1 back, so makes sense
* to clear the last bit */
if (gateway.s_addr == ipaddress.s_addr) {
@@ -123,11 +123,11 @@ int netcfg_get_netmask(struct debconfclient *client)
assert (ptr); /* if there's no dot in ptr1 we're in deep shit */
ptr[1] = '\0';
}
debconf_get(client, "netcfg/get_gateway");
if (empty_str(client->value))
debconf_set(client, "netcfg/get_gateway", ptr1);
return 0;
}

@@ -135,26 +135,26 @@ int netcfg_get_gateway(struct debconfclient *client)
{
int ret, ok = 0;
char *ptr;
while (!ok) {
debconf_input (client, "critical", "netcfg/get_gateway");
ret = debconf_go(client);
if (ret)
if (ret)
return ret;
debconf_get(client, "netcfg/get_gateway");
ptr = client->value;
if (empty_str(ptr) || /* No gateway, that's fine */
(strcmp(ptr, "none") == 0)) /* special case for preseeding */ {
/* clear existing gateway setting */
memset(&gateway, 0, sizeof(struct in_addr));
return 0;
}
ok = inet_pton (AF_INET, ptr, &gateway);
if (!ok) {
debconf_capb(client);
debconf_input (client, "critical", "netcfg/bad_ipaddress");
@@ -162,7 +162,7 @@ int netcfg_get_gateway(struct debconfclient *client)
debconf_capb(client, "backup");
}
}
return 0;
}

@@ -170,7 +170,7 @@ static int netcfg_write_static(char *domain, struct in_addr nameservers[])
{
char ptr1[INET_ADDRSTRLEN];
FILE *fp;
if ((fp = file_open(NETWORKS_FILE, "w"))) {
fprintf(fp, "default\t\t0.0.0.0\n");
fprintf(fp, "loopback\t127.0.0.0\n");
@@ -179,7 +179,7 @@ static int netcfg_write_static(char *domain, struct in_addr nameservers[])
fclose(fp);
} else
goto error;
if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp, "\n# The primary network interface\n");
if (!iface_is_hotpluggable(interface) && !find_in_stab(interface))
@@ -204,7 +204,7 @@ static int netcfg_write_static(char *domain, struct in_addr nameservers[])
(mode == MANAGED) ? "managed" : "ad-hoc");
fprintf(fp, "\twireless-essid %s\n",
(essid && *essid) ? essid : "any");
if (wepkey != NULL)
fprintf(fp, "\twireless-key1 %s\n", wepkey);
}
@@ -237,10 +237,10 @@ static int netcfg_write_static(char *domain, struct in_addr nameservers[])
fclose(fp);
} else
goto error;
if (netcfg_write_resolv(domain, nameservers))
goto error;
return 0;
error:
return -1;
@@ -250,16 +250,16 @@ int netcfg_write_resolv (char* domain, struct in_addr* nameservers)
{
FILE* fp = NULL;
char ptr1[INET_ADDRSTRLEN];
if ((fp = file_open(RESOLV_FILE, "w"))) {
int i = 0;
if (domain && !empty_str(domain))
fprintf(fp, "search %s\n", domain);
while (nameservers[i].s_addr)
fprintf(fp, "nameserver %s\n",
inet_ntop (AF_INET, &nameservers[i++], ptr1, sizeof (ptr1)));
fclose(fp);
return 0;
}
@@ -272,7 +272,7 @@ int netcfg_activate_static(struct debconfclient *client)
int rv = 0, masksize;
char buf[256];
char ptr1[INET_ADDRSTRLEN];
#ifdef __GNU__
di_exec_shell_log("settrans /servers/socket/2 --fg");
snprintf(buf, sizeof(buf),
@@ -281,45 +281,45 @@ int netcfg_activate_static(struct debconfclient *client)
di_snprintfcat(buf, sizeof(buf), " --netmask=%s",
inet_ntop (AF_INET, &netmask, ptr1, sizeof (ptr1)));
buf[sizeof(buf) - 1] = '\0';
if (gateway)
snprintf(buf, sizeof(buf), " --gateway=%s",
inet_ntop (AF_INET, &gateway, ptr1, sizeof (ptr1)));
rv |= di_exec_shell_log(buf);
#else
deconfigure_network();
loop_setup();
interface_up(interface);
/* Flush all previous addresses, routes */
snprintf(buf, sizeof(buf), "ip addr flush dev %s", interface);
rv |= di_exec_shell_log(buf);
snprintf(buf, sizeof(buf), "ip route flush dev %s", interface);
rv |= di_exec_shell_log(buf);
rv |= !inet_ptom (NULL, &masksize, &netmask);
/* Add the new IP address, P-t-P peer (if necessary) and netmask */
snprintf(buf, sizeof(buf), "ip addr add %s/%d ",
inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)),
masksize);
/* avoid using a second buffer */
di_snprintfcat(buf, sizeof(buf), "broadcast %s dev %s",
inet_ntop (AF_INET, &broadcast, ptr1, sizeof (ptr1)),
interface);
if (pointopoint.s_addr)
di_snprintfcat(buf, sizeof(buf), " peer %s",
inet_ntop (AF_INET, &pointopoint, ptr1, sizeof (ptr1)));
di_info("executing: %s", buf);
rv |= di_exec_shell_log(buf);
if (pointopoint.s_addr)
{
snprintf(buf, sizeof(buf), "ip route add default dev %s", interface);
@@ -331,7 +331,7 @@ int netcfg_activate_static(struct debconfclient *client)
rv |= di_exec_shell_log(buf);
}
#endif
if (rv != 0) {
debconf_capb(client);
debconf_input(client, "high", "netcfg/error");
@@ -339,33 +339,33 @@ int netcfg_activate_static(struct debconfclient *client)
debconf_capb(client, "backup");
return -1;
}
return 0;
}

int netcfg_get_static(struct debconfclient *client)
int netcfg_get_static(struct debconfclient *client)
{
char *nameservers = NULL;
char ptr1[INET_ADDRSTRLEN];
char *none;
enum { BACKUP, GET_HOSTNAME, GET_IPADDRESS, GET_POINTOPOINT, GET_NETMASK,
GET_GATEWAY, GATEWAY_UNREACHABLE, GET_NAMESERVERS, CONFIRM,
GET_DOMAIN, QUIT }
state = GET_IPADDRESS;
ipaddress.s_addr = network.s_addr = broadcast.s_addr = netmask.s_addr = gateway.s_addr = pointopoint.s_addr =
0;
debconf_metaget(client, "netcfg/internal-none", "description");
none = client->value ? strdup(client->value) : strdup("<none>");
for (;;) {
switch (state) {
case BACKUP:
return 10; /* Back to main */
break;
case GET_IPADDRESS:
if (netcfg_get_ipaddress (client)) {
state = BACKUP;
@@ -380,21 +380,21 @@ int netcfg_get_static(struct debconfclient *client)
state = GET_NETMASK;
}
break;
case GET_POINTOPOINT:
state = netcfg_get_pointopoint(client) ?
GET_IPADDRESS : GET_NAMESERVERS;
break;
case GET_NETMASK:
state = netcfg_get_netmask(client) ?
GET_IPADDRESS : GET_GATEWAY;
break;
case GET_GATEWAY:
if (netcfg_get_gateway(client))
state = GET_NETMASK;
else
else
if (gateway.s_addr && ((gateway.s_addr & netmask.s_addr) != network.s_addr))
state = GATEWAY_UNREACHABLE;
else
@@ -425,7 +425,7 @@ int netcfg_get_static(struct debconfclient *client)
state = QUIT;
}
break;
case CONFIRM:
debconf_subst(client, "netcfg/confirm_static", "interface", interface);
debconf_subst(client, "netcfg/confirm_static", "ipaddress",
@@ -439,9 +439,9 @@ int netcfg_get_static(struct debconfclient *client)
debconf_subst(client, "netcfg/confirm_static", "nameservers",
(nameservers ? nameservers : none));
netcfg_nameservers_to_array(nameservers, nameserver_array);
debconf_capb(client); /* Turn off backup for yes/no confirmation */
debconf_input(client, "medium", "netcfg/confirm_static");
debconf_go(client);
debconf_get(client, "netcfg/confirm_static");
@@ -452,11 +452,11 @@ int netcfg_get_static(struct debconfclient *client)
}
else
state = GET_IPADDRESS;
debconf_capb(client, "backup");
break;
case QUIT:
netcfg_write_common(ipaddress, hostname, domain);
netcfg_write_static(domain, nameserver_array);


+ 54
- 54
wireless.c View File

@@ -33,62 +33,62 @@ int netcfg_wireless_set_essid (struct debconfclient * client, char *iface, char*
int ret, couldnt_associate = 0;
wireless_config wconf;
char* tf = NULL, *user_essid = NULL, *ptr = wconf.essid;
iw_get_basic_config (wfd, iface, &wconf);
debconf_subst(client, "netcfg/wireless_essid", "iface", iface);
debconf_subst(client, "netcfg/wireless_essid_again", "iface", iface);
debconf_subst(client, "netcfg/wireless_adhoc_managed", "iface", iface);
debconf_input(client, priority ? priority : "low", "netcfg/wireless_adhoc_managed");
if (debconf_go(client) == 30)
return GO_BACK;
debconf_get(client, "netcfg/wireless_adhoc_managed");
if (!strcmp(client->value, "Ad-hoc network (Peer to peer)"))
mode = ADHOC;
wconf.has_mode = 1;
wconf.mode = mode;
debconf_input(client, priority ? priority : "low", "netcfg/wireless_essid");
if (debconf_go(client) == 30)
return GO_BACK;
debconf_get(client, "netcfg/wireless_essid");
tf = strdup(client->value);
automatic:
/* question not asked or user doesn't care or we're successfully associated */
if (!empty_str(wconf.essid) || empty_str(client->value))
if (!empty_str(wconf.essid) || empty_str(client->value))
{
int i, success = 0;
/* Default to any AP */
wconf.essid[0] = '\0';
wconf.essid_on = 0;
iw_set_basic_config (wfd, iface, &wconf);
/* Wait for association.. (MAX_SECS seconds)*/
#define MAX_SECS 3
debconf_capb(client, "backup progresscancel");
debconf_progress_start(client, 0, MAX_SECS, "netcfg/wifi_progress_title");
if (debconf_progress_info(client, "netcfg/wifi_progress_info") == 30)
goto stop;
netcfg_progress_displayed = 1;
for (i = 0; i <= MAX_SECS; i++) {
int progress_ret;
interface_up(iface);
sleep (1);
iw_get_basic_config (wfd, iface, &wconf);
if (!empty_str(wconf.essid)) {
/* Save for later */
debconf_set(client, "netcfg/wireless_essid", wconf.essid);
@@ -96,28 +96,28 @@ automatic:
success = 1;
break;
}
progress_ret = debconf_progress_step(client, 1);
interface_down(iface);
if (progress_ret == 30)
break;
}