summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dhcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dhcp.c')
-rw-r--r--mdk-stage1/dhcp.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/mdk-stage1/dhcp.c b/mdk-stage1/dhcp.c
index 32c7a932b..678031e85 100644
--- a/mdk-stage1/dhcp.c
+++ b/mdk-stage1/dhcp.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc)
*
- * Copyright 2000 MandrakeSoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -45,6 +45,8 @@
#include "stage1.h"
#include "log.h"
+#include "tools.h"
+#include "utils.h"
#include "network.h"
#include "frontend.h"
#include "automatic.h"
@@ -211,12 +213,16 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
unsigned char * chptr;
unsigned char option, length;
- if (breq->bootfile && strlen(breq->bootfile) > 0)
- stage2_kickstart = strdup(breq->bootfile);
+ if (strlen(breq->bootfile) > 0) {
+ if (IS_NETAUTO)
+ add_to_env("KICKSTART", breq->bootfile);
+ else
+ log_message("warning: ignoring `bootfile' DHCP server parameter, since `netauto' boot parameter was not given; reboot with `linux netauto' (and anymore useful boot parameters) if you want `bootfile' to be used as a `auto_inst.cfg.pl' stage2 configuration file");
+ }
memcpy(&intf->ip, &breq->yiaddr, 4);
- chptr = breq->vendor;
+ chptr = (unsigned char *) breq->vendor;
chptr += 4;
while (*chptr != 0xFF && (void *) chptr < (void *) breq->vendor + DHCP_VENDOR_LENGTH) {
char tmp_str[500];
@@ -257,13 +263,6 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
log_message("got gateway %s", inet_ntoa(gateway));
break;
- case BOOTP_OPTION_HOSTNAME:
- memcpy(tmp_str, chptr, length);
- tmp_str[length] = '\0';
- hostname = strdup(tmp_str);
- log_message("got hostname %s", hostname);
- break;
-
}
chptr += length;
@@ -293,7 +292,7 @@ static int prepare_request(struct bootp_request * breq, int sock, char * device)
return -1;
}
- breq->hw = 1; /* ethernet */
+ breq->hw = req.ifr_hwaddr.sa_family;
breq->hwlength = IFHWADDRLEN;
memcpy(breq->hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
memcpy(gen_hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
@@ -310,7 +309,7 @@ static int get_vendor_code(struct bootp_request * bresp, unsigned char option, v
unsigned char * chptr;
unsigned int length, theOption;
- chptr = bresp->vendor + 4;
+ chptr = (unsigned char*) bresp->vendor + 4;
while (*chptr != 0xFF && *chptr != option) {
theOption = *chptr++;
if (!theOption)
@@ -347,7 +346,7 @@ static unsigned long currticks(void)
#define BACKOFF_LIMIT 7
#define TICKS_PER_SEC 18
-#define MAX_ARP_RETRIES 4
+#define MAX_ARP_RETRIES 7
static void rfc951_sleep(int exp)
{
@@ -486,7 +485,7 @@ static void add_vendor_code(struct bootp_request * breq, unsigned char option, u
unsigned char * chptr;
int theOption, theLength;
- chptr = breq->vendor;
+ chptr = (unsigned char*) breq->vendor;
chptr += 4;
while (*chptr != 0xFF && *chptr != option) {
theOption = *chptr++;
@@ -519,11 +518,6 @@ enum return_type perform_dhcp(struct interface_info * intf)
char requested_options[50];
char * client_id_str, * client_id_hwaddr;
- if (strncmp(intf->device, "eth", 3)) {
- stg1_error_message("DHCP available only for Ethernet networking.");
- return RETURN_ERROR;
- }
-
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0) {
log_perror("socket");
@@ -576,9 +570,14 @@ enum return_type perform_dhcp(struct interface_info * intf)
if (dhcp_hostname && *dhcp_hostname) { /* pick client id form based on absence or presence of domain name */
if (*dhcp_domain) /* alternate style <hostname>.<domainname> */
add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, strlen(client_id_str+1)+1, client_id_str);
- else { /* usual style (aka windows / dhcpcd) */
+ else { /* usual style (aka windows / dhcpcd) */
/* but put MAC in form required for client identifier first */
client_id_hwaddr = malloc(IFHWADDRLEN+2);
+ /* (from pump-0.8.22/dhcp.c)
+ * Microsoft uses a client identifier field of the 802.3 address with a
+ * pre-byte of a "1". In order to re-use the DHCP address that they set
+ * for this interface, we have to mimic their identifier.
+ */
client_id_hwaddr[0] = 1; /* set flag for ethernet */
memcpy(client_id_hwaddr+1, gen_hwaddr, IFHWADDRLEN);
add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, IFHWADDRLEN+1, client_id_hwaddr);
@@ -588,7 +587,7 @@ enum return_type perform_dhcp(struct interface_info * intf)
log_message("DHCP: telling server to use name = %s", dhcp_hostname);
}
- memset(&client_addr.sin_addr, 0, sizeof(&client_addr.sin_addr));
+ memset(&client_addr.sin_addr, 0, sizeof(client_addr.sin_addr));
client_addr.sin_family = AF_INET;
client_addr.sin_port = htons(BOOTP_CLIENT_PORT); /* bootp client */