Retrieve DNS names from DHCP/BOOTP

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-16 17:37:47 +01:00
parent f0f4253cd2
commit aa7d205236
3 changed files with 37 additions and 12 deletions

View file

@ -68,18 +68,18 @@ parse_dhcp_vendor (const char *name, void *vend, int limit)
tagtype = *ptr++;
/* Pad tag. */
if (tagtype == 0)
if (tagtype == GRUB_NET_BOOTP_PAD)
continue;
/* End tag. */
if (tagtype == 0xff)
if (tagtype == GRUB_NET_BOOTP_END)
return;
taglength = *ptr++;
switch (tagtype)
{
case 3:
case GRUB_NET_BOOTP_ROUTER:
if (taglength == 4)
{
grub_net_network_level_netaddress_t target;
@ -95,19 +95,32 @@ parse_dhcp_vendor (const char *name, void *vend, int limit)
grub_net_add_route_gw (rname, target, gw);
}
break;
case 12:
case GRUB_NET_BOOTP_DNS:
{
int i;
for (i = 0; i < taglength / 4; i++)
{
struct grub_net_network_level_address s;
s.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
s.ipv4 = grub_get_unaligned32 (ptr);
grub_net_add_dns_server (&s);
ptr += 4;
}
}
break;
case GRUB_NET_BOOTP_HOSTNAME:
set_env_limn_ro (name, "hostname", (char *) ptr, taglength);
break;
case 15:
case GRUB_NET_BOOTP_DOMAIN:
set_env_limn_ro (name, "domain", (char *) ptr, taglength);
break;
case 17:
case GRUB_NET_BOOTP_ROOT_PATH:
set_env_limn_ro (name, "rootpath", (char *) ptr, taglength);
break;
case 18:
case GRUB_NET_BOOTP_EXTENSIONS_PATH:
set_env_limn_ro (name, "extensionspath", (char *) ptr, taglength);
break;

View file

@ -674,15 +674,15 @@ grub_dns_init (void)
{
cmd = grub_register_command ("net_nslookup", grub_cmd_nslookup,
"ADDRESS DNSSERVER",
N_("perform a DNS lookup"));
N_("Perform a DNS lookup"));
cmd_add = grub_register_command ("net_add_dns", grub_cmd_add_dns,
"DNSSERVER",
N_("add a DNS server"));
N_("Add a DNS server"));
cmd_del = grub_register_command ("net_del_dns", grub_cmd_del_dns,
"DNSSERVER",
N_("remove a DNS server"));
cmd_list = grub_register_command ("net_del_dns", grub_cmd_list_dns,
NULL, N_("remove a DNS server"));
N_("Remove a DNS server"));
cmd_list = grub_register_command ("net_ls_dns", grub_cmd_list_dns,
NULL, N_("List DNS servers"));
}
void

View file

@ -396,6 +396,18 @@ struct grub_net_bootp_packet
#define GRUB_NET_BOOTP_RFC1048_MAGIC_2 0x53
#define GRUB_NET_BOOTP_RFC1048_MAGIC_3 0x63
enum
{
GRUB_NET_BOOTP_PAD = 0x00,
GRUB_NET_BOOTP_ROUTER = 0x03,
GRUB_NET_BOOTP_DNS = 0x06,
GRUB_NET_BOOTP_HOSTNAME = 0x0c,
GRUB_NET_BOOTP_DOMAIN = 0x0f,
GRUB_NET_BOOTP_ROOT_PATH = 0x11,
GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12,
GRUB_NET_BOOTP_END = 0xff
};
struct grub_net_network_level_interface *
grub_net_configure_by_dhcp_ack (const char *name,
struct grub_net_card *card,