Browse Source

fix everything

r22513
tags/1.03
Joshua Kwan 17 years ago
parent
commit
34b905e8b1
4 changed files with 45 additions and 12 deletions
  1. +3
    -2
      debian/changelog
  2. +22
    -5
      ethtool-lite.c
  3. +10
    -3
      netcfg-common.c
  4. +10
    -2
      netcfg.c

+ 3
- 2
debian/changelog View File

@@ -3,14 +3,15 @@ netcfg (1.03) UNRELEASED; urgency=low
* Joshua Kwan
- mii-diag support is back, but once again, as a function. Hopefully
it works better than the old one. This time, it only chooses a
default interface based on the first connected one it finds.
default interface based on the first connected one it finds. It also
prefers ethtool to MII.
- Apply Andrew Pollock's WEP key patch. Thanks!
* Thomas Hood
- Use "wireless-key1" option in /e/n/i rather than "wireless-key"
since the former allows the key string to contain whitespace
whereas the latter does not. (Closes: #271978)

-- Joshua Kwan <joshk@triplehelix.org> Sun, 12 Sep 2004 20:48:48 -0700
-- Joshua Kwan <joshk@triplehelix.org> Sun, 3 Oct 2004 14:37:39 -0700

netcfg (1.02) unstable; urgency=low



+ 22
- 5
ethtool-lite.c View File

@@ -5,7 +5,9 @@
#include <net/if.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <debian-installer/log.h>
#ifndef TEST
# include <debian-installer/log.h>
#endif

#define CONNECTED 1
#define DISCONNECTED 2
@@ -31,12 +33,14 @@ int main(int argc, char** argv)
int ethtool_lite (char * iface)
#endif
{
struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
struct ethtool_value edata;
struct ifreq ifr;
#ifdef TEST
char* iface;
#endif
int fd = socket(AF_INET, SOCK_DGRAM, 0);

memset (&edata, 0, sizeof(struct ethtool_value));
if (fd < 0)
{
@@ -44,6 +48,7 @@ int ethtool_lite (char * iface)
fprintf(stderr, "Error: could not open control socket\n");
return 1;
#else
di_warning("could not open control socket\n");
return UNKNOWN;
#endif
}
@@ -57,10 +62,18 @@ int ethtool_lite (char * iface)
iface = argv[1];
#endif
ifr.ifr_data = (void *)&edata;
edata.cmd = ETHTOOL_GLINK;
ifr.ifr_data = (char *)&edata;
strncpy (ifr.ifr_name, iface, IFNAMSIZ);
ioctl (fd, SIOCETHTOOL, &ifr);
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0)
{
#ifdef TEST
printf("ethtool ioctl failed\n");
#else
di_info("ethtool ioctl on %s failed", iface);
#endif
}
if (edata.data)
{
@@ -77,6 +90,10 @@ int ethtool_lite (char * iface)
int ctl;
data[0] = 0;

#ifndef TEST
di_info("%s is disconnected / ethtool not implemented.", iface);
#endif

if (ioctl (fd, 0x8947, &ifr) >= 0)
ctl = 0x8948;
else if (ioctl (fd, SIOCDEVPRIVATE, &ifr) >= 0)
@@ -112,7 +129,7 @@ int ethtool_lite (char * iface)
fprintf(stderr, "MII ioctl failed\n");
return 1;
#else
di_error("MII ioctl failed for %s\n", iface);
di_warning("MII ioctl failed for %s\n", iface);
return UNKNOWN;
#endif
}


+ 10
- 3
netcfg-common.c View File

@@ -379,6 +379,7 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
for (i = 0; i < num_interfaces; i++)
{
size_t newchars;
char *temp = NULL;

inter = ifs[i];

@@ -390,11 +391,17 @@ int netcfg_get_interface(struct debconfclient *client, char **interface,
goto error;
len += newchars + 128;
}
di_snprintfcat(ptr, len, "%s: %s, ", inter, ifdsc);
temp = malloc(newchars);
snprintf(temp, newchars, "%s: %s", inter, ifdsc);

if (num_interfaces > 1 && defif != NULL && !strcmp(defif, inter))
debconf_set(client, "netcfg/choose_interface", temp);

if (num_interfaces > 1 && !strcmp(defif, inter))
debconf_set(client, "netcfg/get_interfaces", ptr);
di_snprintfcat(ptr, len, "%s, ", temp);

free(temp);
free(ifdsc);
}



+ 10
- 2
netcfg.c View File

@@ -97,16 +97,24 @@ int main(int argc, char *argv[])
{
while (*ifaces)
{
interface_up(*ifaces);
usleep(250);
if (ethtool_lite (*ifaces) == 1) /* CONNECTED */
{
defiface = strdup(*ifaces);
interface_down(*ifaces);
break;
}

interface_down(*ifaces);

ifaces++;
}
}
if(netcfg_get_interface(client, &interface, &num_interfaces, defiface))
if(netcfg_get_interface(client, &interface, &num_interfaces, defiface))
state = BACKUP;
else if (! interface || ! num_interfaces)
state = GET_HOSTNAME_ONLY;


Loading…
Cancel
Save