diff options
Diffstat (limited to 'mdk-stage1/network.c')
-rw-r--r-- | mdk-stage1/network.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c index d82ca28d5..ab512399a 100644 --- a/mdk-stage1/network.c +++ b/mdk-stage1/network.c @@ -291,7 +291,7 @@ static int save_netinfo(struct interface_info * intf) fprintf(f, "NETWORKING=yes\n"); fprintf(f, "FORWARD_IPV4=false\n"); - if (hostname && !intf->boot_proto == BOOTPROTO_DHCP) + if (hostname && !(intf->boot_proto == BOOTPROTO_DHCP)) fprintf(f, "HOSTNAME=%s\n", hostname); if (gateway.s_addr != 0) fprintf(f, "GATEWAY=%s\n", inet_ntoa(gateway)); @@ -538,7 +538,7 @@ static enum return_type configure_network(struct interface_info * intf) char * boulet; if (dhcp_hostname || dhcp_domain) { - answers = (char **) malloc(sizeof(questions)); + answers = (char **) calloc(1, sizeof(questions)); answers[0] = strdup(dhcp_hostname); answers[1] = strdup(dhcp_domain); } @@ -575,7 +575,7 @@ static enum return_type bringup_networking(struct interface_info * intf) /* badly */ fd = open("/proc/net/packet", O_RDONLY); if (fd < 0) - my_insmod("af_packet", ANY_DRIVER_TYPE, NULL, 1); + my_modprobe("af_packet", ANY_DRIVER_TYPE, NULL); else close(fd); @@ -691,8 +691,7 @@ static char * interface_select(void) } if (count == 0) { - stg1_error_message("No NET device found.\n" - "Hint: if you're using a Laptop, note that PCMCIA Network adapters are now supported either with `pcmcia.img' or `network.img', please try both these bootdisks."); + stg1_error_message("No NET device found."); i = ask_insmod(NETWORK_DEVICES); if (i == RETURN_BACK) return NULL; @@ -1002,11 +1001,12 @@ enum return_type ftp_prepare(void) char location_full[500]; int ftp_serv_response = -1; int fd, size; + int need_arch = 0; char ftp_hostname[500]; if (!IS_AUTOMATIC) { if (answers == NULL) - answers = (char **) malloc(sizeof(questions)); + answers = (char **) calloc(1, sizeof(questions)); results = choose_mirror_from_list(http_proxy_host, http_proxy_port, "ftp", &answers[0], &answers[1]); @@ -1077,9 +1077,14 @@ enum return_type ftp_prepare(void) log_message("%s failed.", location_full); char *with_arch = asprintf_("%s%s/%s/%s", answers[1][0] == '/' ? "" : "/", answers[1], ARCH, COMPRESSED_FILE_REL("/")); log_message("trying %s...", with_arch); - fd = http_download_file(answers[0], with_arch, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port); - if (0 < fd) + if (use_http_proxy) + fd = http_download_file(answers[0], with_arch, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port); + else + fd = ftp_start_download(ftp_serv_response, with_arch, &size); + if (0 < fd) { strcpy(location_full, with_arch); + need_arch = 1; + } } if (fd < 0) { @@ -1103,13 +1108,17 @@ enum return_type ftp_prepare(void) if (use_http_proxy) { add_to_env("METHOD", "http"); - sprintf(location_full, "ftp://%s%s", ftp_hostname, answers[1]); + snprintf(location_full, sizeof(location_full), "ftp://%s%s", ftp_hostname, answers[1]); + if (need_arch) + strcat(location_full, "/" ARCH); add_to_env("URLPREFIX", location_full); add_to_env("PROXY", http_proxy_host); add_to_env("PROXYPORT", http_proxy_port); } else { add_to_env("METHOD", "ftp"); add_to_env("HOST", answers[0]); + if (need_arch) + strcat(answers[1], "/" ARCH); add_to_env("PREFIX", answers[1]); if (!streq(answers[2], "")) { add_to_env("LOGIN", answers[2]); @@ -1145,17 +1154,17 @@ enum return_type http_prepare(void) do { char location_full[500]; - int fd, size; + int fd, size, need_arch = 0; int use_http_proxy; if (!IS_AUTOMATIC) { if (answers == NULL) - answers = (char **) malloc(sizeof(questions)); + answers = (char **) calloc(1, sizeof(questions)); results = choose_mirror_from_list(http_proxy_host, http_proxy_port, "http", &answers[0], &answers[1]); if (results == RETURN_BACK) - return ftp_prepare(); + return http_prepare(); } results = ask_from_entries_auto("Please enter the name or IP address of the HTTP server, " @@ -1182,8 +1191,10 @@ enum return_type http_prepare(void) char *with_arch = asprintf_("%s%s/%s/%s", answers[1][0] == '/' ? "" : "/", answers[1], ARCH, COMPRESSED_FILE_REL("/")); log_message("trying %s...", with_arch); fd = http_download_file(answers[0], with_arch, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port); - if (0 < fd) + if (0 < fd) { strcpy(location_full, with_arch); + need_arch = 1; + } } if (fd < 0) { @@ -1205,6 +1216,8 @@ enum return_type http_prepare(void) add_to_env("METHOD", "http"); sprintf(location_full, "http://%s%s%s", answers[0], answers[1][0] == '/' ? "" : "/", answers[1]); + if (need_arch) + strcat(location_full, "/" ARCH); add_to_env("URLPREFIX", location_full); if (!streq(http_proxy_host, "")) add_to_env("PROXY", http_proxy_host); |