summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/network.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-06-01 19:09:27 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-06-01 19:09:27 +0000
commite31889e238c53438cd387b11fed03b8645ac24c0 (patch)
tree124c2a619791936b958b2f023c61790c559fe676 /mdk-stage1/network.c
parent8b643ee943076746ac3707c266f3222c97278edd (diff)
downloaddrakx-backup-do-not-use-e31889e238c53438cd387b11fed03b8645ac24c0.tar
drakx-backup-do-not-use-e31889e238c53438cd387b11fed03b8645ac24c0.tar.gz
drakx-backup-do-not-use-e31889e238c53438cd387b11fed03b8645ac24c0.tar.bz2
drakx-backup-do-not-use-e31889e238c53438cd387b11fed03b8645ac24c0.tar.xz
drakx-backup-do-not-use-e31889e238c53438cd387b11fed03b8645ac24c0.zip
- first draft of adsl support
- get back some code for supporting broken glibc unable to resolve when linked statically
Diffstat (limited to 'mdk-stage1/network.c')
-rw-r--r--mdk-stage1/network.c65
1 files changed, 40 insertions, 25 deletions
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 4efecda13..48779cdfa 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -40,7 +40,9 @@
#include "mount.h"
#include "automatic.h"
#include "dhcp.h"
+#include "adsl.h"
#include "url.h"
+#include "dns.h"
#include "network.h"
@@ -51,7 +53,7 @@ static void error_message_net(void) /* reduce code size */
}
-static int configure_net_device(struct interface_info * intf)
+int configure_net_device(struct interface_info * intf)
{
struct ifreq req;
struct rtentry route;
@@ -167,6 +169,15 @@ static int configure_net_device(struct interface_info * intf)
intf->is_up = 1;
+ if (intf->boot_proto == BOOTPROTO_STATIC) {
+ /* I need to sleep a bit in order for kernel to finish
+ init of the network device; if not, first sendto() for
+ gethostbyaddr will get an EINVAL. */
+ wait_message("Bringing up networking...");
+ sleep(2);
+ remove_wait_message();
+ }
+
return 0;
}
@@ -353,8 +364,8 @@ static void static_ip_callback(char ** strings)
static enum return_type setup_network_interface(struct interface_info * intf)
{
enum return_type results;
- char * bootprotos[] = { "Static", "DHCP", NULL };
- char * bootprotos_auto[] = { "static", "dhcp" };
+ char * bootprotos[] = { "Static", "DHCP", "ADSL", NULL };
+ char * bootprotos_auto[] = { "static", "dhcp", "adsl" };
char * choice;
results = ask_from_list_auto("Please choose the desired IP attribution.", bootprotos, &choice, "network", bootprotos_auto);
@@ -409,7 +420,11 @@ static enum return_type setup_network_interface(struct interface_info * intf)
intf->is_ptp = 0;
}
intf->boot_proto = BOOTPROTO_STATIC;
- } else {
+
+ if (configure_net_device(intf))
+ return RETURN_ERROR;
+
+ } else if (streq(choice, "DHCP")) {
results = perform_dhcp(intf);
if (results == RETURN_BACK)
@@ -417,37 +432,37 @@ static enum return_type setup_network_interface(struct interface_info * intf)
if (results == RETURN_ERROR)
return results;
intf->boot_proto = BOOTPROTO_DHCP;
- }
-
- if (configure_net_device(intf))
- return RETURN_ERROR;
- if (intf->boot_proto == BOOTPROTO_STATIC) {
- /* I need to sleep a bit in order for kernel to finish
- init of the network device; if not, first sendto() for
- gethostbyaddr will get an EINVAL. */
- wait_message("Bringing up networking...");
- sleep(2);
- remove_wait_message();
- }
+ if (configure_net_device(intf))
+ return RETURN_ERROR;
+ } else if (streq(choice, "ADSL")) {
+ intf->boot_proto = BOOTPROTO_STATIC;
+
+ results = perform_adsl(intf);
+
+ if (results == RETURN_BACK)
+ return setup_network_interface(intf);
+ if (results == RETURN_ERROR)
+ return results;
+ } else
+ return RETURN_ERROR;
+
return add_default_route();
}
static enum return_type configure_network(struct interface_info * intf)
{
- struct hostent * host;
+ char * dnshostname;
if (hostname && domain)
return RETURN_OK;
- wait_message("Trying to resolve hostname...");
- host = gethostbyaddr(&(intf->ip), strlen((void *) &(intf->ip)), AF_INET);
- remove_wait_message();
+ dnshostname = mygethostbyaddr(inet_ntoa(intf->ip));
- if (host && host->h_name) {
- hostname = strdup(host->h_name);
+ if (dnshostname) {
+ hostname = strdup(dnshostname);
domain = strchr(strdup(hostname), '.') + 1;
log_message("got hostname and domain from dns entry, %s and %s", hostname, domain);
return RETURN_OK;
@@ -460,12 +475,12 @@ static enum return_type configure_network(struct interface_info * intf)
if (dns_server.s_addr != 0) {
wait_message("Trying to resolve dns...");
- host = gethostbyaddr(&dns_server, strlen((void *) &dns_server), AF_INET);
+ dnshostname = mygethostbyaddr(inet_ntoa(dns_server));
remove_wait_message();
}
- if (host && host->h_name) {
- domain = strchr(strdup(host->h_name), '.') + 1;
+ if (dnshostname) {
+ domain = strchr(strdup(dnshostname), '.') + 1;
log_message("got domain from DNS fullname, %s", domain);
} else {
enum return_type results;