void grub_net_process_dhcp (struct grub_net_buff *nb, struct grub_net_card *card) { char *name; struct grub_net_network_level_interface *inf; name = grub_xasprintf ("%s:dhcp", card->name); if (!name) { grub_print_error (); return; } grub_net_configure_by_dhcp_ack (name, card, 0, (const struct grub_net_bootp_packet *) nb->data, (nb->tail - nb->data), 0, 0, 0); grub_free (name); if (grub_errno) grub_print_error (); else { FOR_NET_NETWORK_LEVEL_INTERFACES(inf) if (grub_memcmp (inf->name, card->name, grub_strlen (card->name)) == 0 && grub_memcmp (inf->name + grub_strlen (card->name), ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0) { grub_net_network_level_interface_unregister (inf); break; } } }
static void grub_ieee1275_net_config_real (const char *devpath, char **device, char **path) { struct grub_net_card *card; /* FIXME: Check that it's the right card. */ FOR_NET_CARDS (card) { char *bootp_response; char *cardpath; char *canon; grub_ssize_t size = -1; unsigned int i; if (card->driver != &ofdriver) continue; cardpath = ((struct grub_ofnetcard_data *) card->data)->path; canon = grub_ieee1275_canonicalise_devname (cardpath); if (grub_strcmp (devpath, canon) != 0) { grub_free (canon); continue; } grub_free (canon); for (i = 0; i < ARRAY_SIZE (bootp_response_properties); i++) if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, bootp_response_properties[i].name, &size) >= 0) break; if (size < 0) return; bootp_response = grub_malloc (size); if (!bootp_response) { grub_print_error (); return; } if (grub_ieee1275_get_property (grub_ieee1275_chosen, bootp_response_properties[i].name, bootp_response, size, 0) < 0) return; grub_net_configure_by_dhcp_ack (card->name, card, 0, (struct grub_net_bootp_packet *) &bootp_response + bootp_response_properties[i].offset, size - bootp_response_properties[i].offset, 1, device, path); return; } }