summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-03-05 16:08:38 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-03-05 16:08:38 +0000
commit0d62382d3c9fd32ffb9375facaafc0c5daa7177e (patch)
treef981f551b0c3421d12d0d311c3d2625c1847e6a5 /mdk-stage1
parent968684ae56afe97cb8f50a82993cc7342eb3a9fb (diff)
downloaddrakx-0d62382d3c9fd32ffb9375facaafc0c5daa7177e.tar
drakx-0d62382d3c9fd32ffb9375facaafc0c5daa7177e.tar.gz
drakx-0d62382d3c9fd32ffb9375facaafc0c5daa7177e.tar.bz2
drakx-0d62382d3c9fd32ffb9375facaafc0c5daa7177e.tar.xz
drakx-0d62382d3c9fd32ffb9375facaafc0c5daa7177e.zip
save dhcp_hostname for stage2
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/dhcp.c32
-rw-r--r--mdk-stage1/dhcp.h2
-rw-r--r--mdk-stage1/network.c2
3 files changed, 21 insertions, 15 deletions
diff --git a/mdk-stage1/dhcp.c b/mdk-stage1/dhcp.c
index 34ce5a9e0..65b7df56e 100644
--- a/mdk-stage1/dhcp.c
+++ b/mdk-stage1/dhcp.c
@@ -502,6 +502,8 @@ static void add_vendor_code(struct bootp_request * breq, unsigned char option, u
}
+char * dhcp_hostname = NULL;
+char * dhcp_domain = NULL;
enum return_type perform_dhcp(struct interface_info * intf)
{
@@ -515,7 +517,7 @@ enum return_type perform_dhcp(struct interface_info * intf)
short aShort;
int num_options;
char requested_options[50];
- char * my_hostname, * my_domainname, * client_id_str, * client_id_hwaddr;
+ char * client_id_str, * client_id_hwaddr;
if (strncmp(intf->device, "eth", 3)) {
stg1_error_message("DHCP available only for Ethernet networking.");
@@ -535,7 +537,7 @@ enum return_type perform_dhcp(struct interface_info * intf)
static char ** answers = NULL;
char * boulet;
- my_hostname = my_domainname = client_id_str = client_id_hwaddr = NULL;
+ client_id_str = client_id_hwaddr = NULL;
results = ask_from_entries_auto("If the DHCP server needs to know you by name; please fill in this information. "
"Valid answers are for example: `mybox' for hostname and `mynetwork.com' for "
@@ -543,16 +545,16 @@ enum return_type perform_dhcp(struct interface_info * intf)
questions, &answers, 32, questions_auto, NULL);
if (results == RETURN_OK)
{
- my_hostname = answers[0];
- if ((boulet = strchr(my_hostname, '.')) != NULL)
+ dhcp_hostname = answers[0];
+ if ((boulet = strchr(dhcp_hostname, '.')) != NULL)
boulet[0] = '\0';
- my_domainname = answers[1];
+ dhcp_domain = answers[1];
- if (*my_hostname && *my_domainname) {
+ if (*dhcp_hostname && *dhcp_domain) {
/* if we have both, then create client id from them */
- client_id_str = memdup(my_hostname, strlen(my_domainname) + 2);
+ client_id_str = memdup(dhcp_hostname, strlen(dhcp_domain) + 2);
strcat(client_id_str, ".");
- strcat(client_id_str, my_domainname);
+ strcat(client_id_str, dhcp_domain);
}
}
}
@@ -571,8 +573,8 @@ enum return_type perform_dhcp(struct interface_info * intf)
add_vendor_code(&breq, DHCP_OPTION_TYPE, 1, &messageType);
/* add pieces needed to have DDNS/DHCP IP selection based on requested name */
- if (my_hostname && *my_hostname) { /* pick client id form based on absence or presence of domain name */
- if (*my_domainname) /* alternate style <hostname>.<domainname> */
+ 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), client_id_str);
else { /* usual style (aka windows / dhcpcd) */
/* but put MAC in form required for client identifier first */
@@ -582,8 +584,8 @@ enum return_type perform_dhcp(struct interface_info * intf)
add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, IFHWADDRLEN+1, client_id_hwaddr);
}
/* this is the one that the dhcp server really wants for DDNS updates */
- add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(my_hostname), my_hostname);
- log_message("DHCP: telling server to use name = %s", my_hostname);
+ add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(dhcp_hostname), dhcp_hostname);
+ log_message("DHCP: telling server to use name = %s", dhcp_hostname);
}
memset(&client_addr.sin_addr, 0, sizeof(&client_addr.sin_addr));
@@ -626,13 +628,13 @@ enum return_type perform_dhcp(struct interface_info * intf)
add_vendor_code(&breq, DHCP_OPTION_REQADDR, 4, &bresp.yiaddr);
/* if used the first time, then have to use it again */
- if (my_hostname && *my_hostname) { /* add pieces needed to have DDNS/DHCP IP selection based on requested name */
- if (my_domainname && *my_domainname) /* alternate style */
+ if (dhcp_hostname && *dhcp_hostname) { /* add pieces needed to have DDNS/DHCP IP selection based on requested name */
+ if (dhcp_domain && *dhcp_domain) /* alternate style */
add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, strlen(client_id_str), client_id_str);
else /* usual style (aka windows / dhcpcd) */
add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, IFHWADDRLEN+1, client_id_hwaddr);
/* this is the one that the dhcp server really wants for DDNS updates */
- add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(my_hostname), my_hostname);
+ add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(dhcp_hostname), dhcp_hostname);
}
aShort = ntohs(sizeof(struct bootp_request));
diff --git a/mdk-stage1/dhcp.h b/mdk-stage1/dhcp.h
index 6fb121ea4..71d062e9c 100644
--- a/mdk-stage1/dhcp.h
+++ b/mdk-stage1/dhcp.h
@@ -31,4 +31,6 @@
enum return_type perform_dhcp(struct interface_info * intf);
+extern char * dhcp_hostname;
+
#endif
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 1f53813b2..5127872fc 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -283,6 +283,8 @@ static int save_netinfo(struct interface_info * intf) {
fprintf(f, "HOSTNAME=%s\n", hostname);
if (domain)
fprintf(f, "DOMAINNAME=%s\n", domain);
+ if (dhcp_hostname)
+ fprintf(f, "DHCP_HOSTNAME=%s\n", dhcp_hostname);
if (gateway.s_addr != 0)
fprintf(f, "GATEWAY=%s\n", inet_ntoa(gateway));