+static void
+transmit_ARP_request(uint32_t ip_addr)
+{
+ struct ether_header *eh = (struct ether_header *) &pkt.data[0];
+ struct ether_arp *ea = (struct ether_arp *) &pkt.data[sizeof(struct ether_header)];
+
+ KDP_DEBUG("Transmitting ARP request\n");
+ /* Populate the ether_header */
+ eh->ether_type = htons(ETHERTYPE_ARP);
+ enaddr_copy(&kdp_current_mac_address, eh->ether_shost);
+ enaddr_copy(ðerbroadcastaddr, eh->ether_dhost);
+
+ /* Populate the ARP header */
+ ea->arp_pro = htons(ETHERTYPE_IP);
+ ea->arp_hln = sizeof(ea->arp_sha);
+ ea->arp_pln = sizeof(ea->arp_spa);
+ ea->arp_hrd = htons(ARPHRD_ETHER);
+ ea->arp_op = htons(ARPOP_REQUEST);
+
+ /* Target fields */
+ enaddr_copy(ðerbroadcastaddr, ea->arp_tha);
+ memcpy(ea->arp_tpa, (void *) &ip_addr, sizeof(ip_addr));
+
+ /* Source fields */
+ enaddr_copy(&kdp_current_mac_address, ea->arp_sha);
+ memcpy(ea->arp_spa, (void *) &kdp_current_ip_address, sizeof(kdp_current_ip_address));
+
+ pkt.off = 0;
+ pkt.len = sizeof(struct ether_header) + sizeof(struct ether_arp);
+ /* Transmit */
+ (*kdp_en_send_pkt)(&pkt.data[pkt.off], pkt.len);
+}
+
+static boolean_t
+kdp_arp_resolve(uint32_t arp_target_ip, struct ether_addr *resolved_MAC)
+{
+ int poll_count = 256; /* ~770 ms modulo broadcast/delayed traffic? */
+ char tretries = 0;
+
+#define NUM_ARP_TX_RETRIES 5
+
+ target_ip = arp_target_ip;
+ flag_arp_resolved = FALSE;
+
+TRANSMIT_RETRY:
+ pkt.off = pkt.len = 0;
+
+ tretries++;
+
+ if (tretries >= NUM_ARP_TX_RETRIES) {
+ return FALSE;
+ }
+
+ KDP_DEBUG("ARP TX attempt #%d \n", tretries);
+
+ transmit_ARP_request(arp_target_ip);
+
+ while (!pkt.input && !flag_arp_resolved && flag_panic_dump_in_progress && --poll_count) {
+ kdp_poll();
+ }
+
+ if (flag_arp_resolved) {
+ *resolved_MAC = current_resolved_MAC;
+ return TRUE;
+ }
+
+ if (!flag_panic_dump_in_progress || pkt.input) /* we received a debugging packet, bail*/
+ {
+ printf("Received a debugger packet,transferring control to debugger\n");
+ /* Indicate that we should wait in the debugger when we return */
+ kdp_flag |= DBG_POST_CORE;
+ pkt.input = FALSE;
+ return FALSE;
+ }
+ else /* We timed out */
+ if (0 == poll_count) {
+ poll_count = 256;
+ goto TRANSMIT_RETRY;
+ }
+ return FALSE;