+/*
+ * Check netinfo for ipv4 parameters and add them to the fspec iff the
+ * fspec has no existing value.
+ *
+ * Returns 1 on success, 0 on failure.
+ */
+static int
+extract_netinfo_args(struct boot_fspec_t *result)
+{
+ struct bootp_packet *packet;
+
+ /* Check to see if we can get the [scyg]iaddr fields from netinfo */
+ packet = prom_get_netinfo();
+ if (!packet)
+ return 0;
+
+ DEBUG_F("We have a boot packet\n");
+ DEBUG_F(" siaddr = <%x>\n", packet->siaddr);
+ DEBUG_F(" ciaddr = <%x>\n", packet->ciaddr);
+ DEBUG_F(" yiaddr = <%x>\n", packet->yiaddr);
+ DEBUG_F(" giaddr = <%x>\n", packet->giaddr);
+
+ /* Try to fallback to yiaddr if ciaddr is empty. Broken? */
+ if (packet->ciaddr == 0 && packet->yiaddr != 0)
+ packet->ciaddr = packet->yiaddr;
+
+ if ((result->siaddr == NULL || *(result->siaddr) == NULL)
+ && packet->siaddr != 0)
+ result->siaddr = ipv4_to_str(packet->siaddr);
+ if ((result->ciaddr == NULL || *(result->ciaddr) == NULL)
+ && packet->ciaddr != 0)
+ result->ciaddr = ipv4_to_str(packet->ciaddr);
+ if ((result->giaddr == NULL || *(result->giaddr) == NULL)
+ && packet->giaddr != 0)
+ result->giaddr = ipv4_to_str(packet->giaddr);
+
+ /* FIXME: Yck! if we /still/ do not have a gateway then "cheat" and use
+ * the server. This will be okay if the client and server are on
+ * the same IP network, if not then lets hope the server does ICMP
+ * redirections */
+ if (result->giaddr == NULL) {
+ result->giaddr = ipv4_to_str(packet->siaddr);
+ DEBUG_F("Forcing giaddr to siaddr <%s>\n", result->giaddr);
+ }
+
+ return 1;
+}
+