dhcp next-server and root-path options can be used,
if no server nor directory params supplied in automatic mode.
This commit is contained in:
parent
2547c76dbf
commit
85b34d353b
19
dhcp.c
19
dhcp.c
@ -54,18 +54,19 @@
|
||||
typedef int bp_int32;
|
||||
typedef short bp_int16;
|
||||
|
||||
#define BOOTP_OPTION_NETMASK 1
|
||||
#define BOOTP_OPTION_GATEWAY 3
|
||||
#define BOOTP_OPTION_NETMASK 1
|
||||
#define BOOTP_OPTION_GATEWAY 3
|
||||
#define BOOTP_OPTION_DNS 6
|
||||
#define BOOTP_OPTION_HOSTNAME 12
|
||||
#define BOOTP_OPTION_HOSTNAME 12
|
||||
#define BOOTP_OPTION_DOMAIN 15
|
||||
#define BOOTP_OPTION_BROADCAST 28
|
||||
#define BOOTP_OPTION_ROOTPATH 17
|
||||
#define BOOTP_OPTION_BROADCAST 28
|
||||
|
||||
#define DHCP_OPTION_REQADDR 50
|
||||
#define DHCP_OPTION_LEASE 51
|
||||
#define DHCP_OPTION_TYPE 53
|
||||
#define DHCP_OPTION_SERVER 54
|
||||
#define DHCP_OPTION_OPTIONREQ 55
|
||||
#define DHCP_OPTION_OPTIONREQ 55
|
||||
#define DHCP_OPTION_MAXSIZE 57
|
||||
|
||||
#define BOOTP_CLIENT_PORT 68
|
||||
@ -209,6 +210,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
|
||||
unsigned char option, length;
|
||||
|
||||
memcpy(&intf->ip, &breq->yiaddr, 4);
|
||||
memcpy(&next_server, &breq->server_ip, 4);
|
||||
|
||||
chptr = breq->vendor;
|
||||
chptr += 4;
|
||||
@ -258,6 +260,12 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
|
||||
log_message("got hostname %s", hostname);
|
||||
break;
|
||||
|
||||
case BOOTP_OPTION_ROOTPATH:
|
||||
memcpy(tmp_str, chptr, length);
|
||||
tmp_str[length] = '\0';
|
||||
rootpath = strdup(tmp_str);
|
||||
log_message("got next-server: %s rootpath: %s", inet_ntoa(next_server), rootpath);
|
||||
break;
|
||||
}
|
||||
|
||||
chptr += length;
|
||||
@ -581,6 +589,7 @@ enum return_type perform_dhcp(struct interface_info * intf)
|
||||
requested_options[num_options++] = BOOTP_OPTION_GATEWAY;
|
||||
requested_options[num_options++] = BOOTP_OPTION_DNS;
|
||||
requested_options[num_options++] = BOOTP_OPTION_DOMAIN;
|
||||
requested_options[num_options++] = BOOTP_OPTION_ROOTPATH;
|
||||
requested_options[num_options++] = BOOTP_OPTION_BROADCAST;
|
||||
add_vendor_code(&breq, DHCP_OPTION_OPTIONREQ, num_options, requested_options);
|
||||
|
||||
|
26
network.c
26
network.c
@ -187,9 +187,11 @@ int configure_net_device(struct interface_info * intf)
|
||||
/* host network informations */
|
||||
char * hostname = NULL;
|
||||
char * domain = NULL;
|
||||
char * rootpath = NULL;
|
||||
struct in_addr gateway = { 0 };
|
||||
struct in_addr dns_server = { 0 };
|
||||
struct in_addr dns_server2 = { 0 };
|
||||
struct in_addr next_server = { 0 };
|
||||
|
||||
static int add_default_route(void)
|
||||
{
|
||||
@ -644,15 +646,23 @@ enum return_type nfs_prepare(void)
|
||||
"and the directory (or ISO image file) containing the %s Distribution.", version);
|
||||
results = ask_from_entries_auto(msg, questions, &answers, 40, questions_auto, NULL);
|
||||
if (results != RETURN_OK || streq(answers[0], "")) {
|
||||
unset_param(MODE_AUTOMATIC); /* we are in a fallback mode */
|
||||
return nfs_prepare();
|
||||
if (next_server.s_addr && rootpath != NULL) {
|
||||
log_message("Using params supplied by DHCP");
|
||||
nfsmount_location = malloc(strlen(rootpath) + 17);
|
||||
strcpy(nfsmount_location, inet_ntoa(next_server));
|
||||
strcat(nfsmount_location, ":");
|
||||
strcat(nfsmount_location, rootpath);
|
||||
} else {
|
||||
unset_param(MODE_AUTOMATIC); /* we are in a fallback mode */
|
||||
return nfs_prepare();
|
||||
}
|
||||
} else {
|
||||
nfsmount_location = malloc(strlen(answers[0]) + strlen(answers[1]) + 2);
|
||||
strcpy(nfsmount_location, answers[0]);
|
||||
strcat(nfsmount_location, ":");
|
||||
strcat(nfsmount_location, answers[1]);
|
||||
}
|
||||
|
||||
nfsmount_location = malloc(strlen(answers[0]) + strlen(answers[1]) + 2);
|
||||
strcpy(nfsmount_location, answers[0]);
|
||||
strcat(nfsmount_location, ":");
|
||||
strcat(nfsmount_location, answers[1]);
|
||||
|
||||
|
||||
if (my_mount(nfsmount_location, IMAGE_LOCATION, "nfs", 0) == -1) {
|
||||
char location_full[500];
|
||||
char *s;
|
||||
|
@ -52,10 +52,11 @@ int configure_net_device(struct interface_info * intf);
|
||||
|
||||
extern char * hostname;
|
||||
extern char * domain;
|
||||
extern char * rootpath;
|
||||
extern struct in_addr gateway;
|
||||
extern struct in_addr dns_server;
|
||||
extern struct in_addr dns_server2;
|
||||
|
||||
extern struct in_addr next_server;
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user