static jmp_buf main_env;
/* Store the prefix specified by an argument. */
-static char *root_dev = NULL, *dir = DEFAULT_DIRECTORY;
+static char *root_dev = NULL, *dir = NULL;
int grub_no_autoload;
set_program_name (argv[0]);
+ dir = xstrdup (DEFAULT_DIRECTORY);
+
while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1)
switch (opt)
{
case 'r':
- root_dev = optarg;
+ free (root_dev);
+ root_dev = xstrdup (optarg);
break;
case 'd':
- dir = optarg;
+ free (dir);
+ dir = xstrdup (optarg);
break;
case 'm':
dev_map = optarg;
{
struct iphdr *iph = (struct iphdr *) nb->data;
grub_err_t err;
- struct grub_net_network_level_interface *inf;
+ struct grub_net_network_level_interface *inf = NULL;
err = grub_netbuff_pull (nb, sizeof (*iph));
if (err)
return err;
- FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ /* DHCP needs special treatment since we don't know IP yet. */
{
- if (inf->card == card
- && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
- && inf->address.ipv4 == iph->dest
- && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0)
- break;
+ struct udphdr *udph;
+ udph = (struct udphdr *) nb->data;
+ if (iph->protocol == IP_UDP && grub_be_to_cpu16 (udph->dst) == 68)
+ {
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ if (inf->card == card
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
+ && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0)
+ {
+ err = grub_netbuff_pull (nb, sizeof (*udph));
+ if (err)
+ return err;
+ grub_net_process_dhcp (nb, inf->card);
+ grub_netbuff_free (nb);
+ }
+ return GRUB_ERR_NONE;
+ }
}
+
if (!inf)
{
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
if (inf->card == card
- && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+ && inf->address.ipv4 == iph->dest
&& grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0)
- break;
- }
- if (!inf)
- {
- if (iph->protocol == IP_UDP
- && grub_net_hwaddr_cmp (&card->default_address, hwaddress) == 0)
- {
- struct udphdr *udph;
- udph = (struct udphdr *) nb->data;
- err = grub_netbuff_pull (nb, sizeof (*udph));
- if (err)
- return err;
- if (grub_be_to_cpu16 (udph->dst) == 68)
- grub_net_process_dhcp (nb, card);
- }
- grub_netbuff_free (nb);
- return GRUB_ERR_NONE;
+ break;
+ }
}
switch (iph->protocol)
{
case IP_UDP:
return grub_net_recv_udp_packet (nb, inf);
- break;
default:
grub_netbuff_free (nb);
break;
return 0;
switch (net->type)
{
- case GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC:
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
return 0;
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
{
{
switch (target->type)
{
- case GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC:
- grub_strcpy (buf, "promisc");
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ grub_strcpy (buf, "temporary");
return;
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
{
{
switch (target->type)
{
- case GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC:
- grub_printf ("promisc\n");
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ grub_printf ("temporary\n");
break;
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
{
grub_free (ifaces);
return grub_errno;
}
- ifaces[j].address.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC;
+ ifaces[j].address.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV;
grub_memcpy (&ifaces[j].hwaddress, &card->default_address,
sizeof (ifaces[j].hwaddress));
j++;
{
struct udphdr *udph;
grub_net_socket_t sock;
+ grub_err_t err;
udph = (struct udphdr *) nb->data;
- grub_netbuff_pull (nb, sizeof (*udph));
+ err = grub_netbuff_pull (nb, sizeof (*udph));
+ if (err)
+ return err;
FOR_NET_SOCKETS (sock)
{
return GRUB_ERR_NONE;
}
}
- if (grub_be_to_cpu16 (udph->dst) == 68)
- grub_net_process_dhcp (nb, inf->card);
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
}
typedef enum grub_network_level_protocol_id
{
- GRUB_NET_NETWORK_LEVEL_PROTOCOL_PROMISC,
+ GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV,
GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
} grub_network_level_protocol_id_t;