From 9d611a318dae7f3f55de4e2ad6674c7e8feef9db Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 21 Jun 2012 22:15:10 +0200 Subject: [PATCH] * grub-core/net/bootp.c (grub_net_configure_by_dhcp_ack): Prefer IP address to server name since we may not hame the DNS. --- ChangeLog | 5 +++++ grub-core/net/bootp.c | 37 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6376fa086..adf2dd547 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-06-21 Vladimir Serbinenko + + * grub-core/net/bootp.c (grub_net_configure_by_dhcp_ack): Prefer + IP address to server name since we may not hame the DNS. + 2012-06-21 Vladimir Serbinenko * grub-core/net/dns.c (grub_cmd_nslookup): Init addresses to 0 to avoid diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 5c43a908e..7bd5e2034 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -204,6 +204,25 @@ grub_net_configure_by_dhcp_ack (const char *name, sizeof (bp->boot_file)); if (is_def) grub_net_default_server = 0; + if (is_def && !grub_net_default_server && bp->server_ip) + { + grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d", + ((grub_uint8_t *) &bp->server_ip)[0], + ((grub_uint8_t *) &bp->server_ip)[1], + ((grub_uint8_t *) &bp->server_ip)[2], + ((grub_uint8_t *) &bp->server_ip)[3]); + grub_print_error (); + } + + if (device && !*device && bp->server_ip) + { + *device = grub_xasprintf ("tftp,%d.%d.%d.%d", + ((grub_uint8_t *) &bp->server_ip)[0], + ((grub_uint8_t *) &bp->server_ip)[1], + ((grub_uint8_t *) &bp->server_ip)[2], + ((grub_uint8_t *) &bp->server_ip)[3]); + grub_print_error (); + } if (size > OFFSET_OF (server_name, bp) && bp->server_name[0]) { @@ -220,25 +239,7 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_print_error (); } } - if (is_def && !grub_net_default_server) - { - grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d", - ((grub_uint8_t *) &bp->server_ip)[0], - ((grub_uint8_t *) &bp->server_ip)[1], - ((grub_uint8_t *) &bp->server_ip)[2], - ((grub_uint8_t *) &bp->server_ip)[3]); - grub_print_error (); - } - if (device && !*device) - { - *device = grub_xasprintf ("tftp,%d.%d.%d.%d", - ((grub_uint8_t *) &bp->server_ip)[0], - ((grub_uint8_t *) &bp->server_ip)[1], - ((grub_uint8_t *) &bp->server_ip)[2], - ((grub_uint8_t *) &bp->server_ip)[3]); - grub_print_error (); - } if (size > OFFSET_OF (boot_file, bp) && path) { *path = grub_strndup (bp->boot_file, sizeof (bp->boot_file));