MCPcopy Create free account
hub / github.com/F-Stack/f-stack / debugnet_arp_gw

Function debugnet_arp_gw

freebsd/net/debugnet_inet.c:395–430  ·  view source on GitHub ↗

* Sends ARP requests to locate the server and waits for a response. * We first try to ARP the server itself, and fall back to the provided * gateway if the server appears to be off-link. * * Return value: * 0 on success * errno on error */

Source from the content-addressed store, hash-verified

393 * errno on error
394 */
395int
396debugnet_arp_gw(struct debugnet_pcb *pcb)
397{
398 in_addr_t dst;
399 int error, polls, retries;
400
401 dst = pcb->dp_server;
402restart:
403 for (retries = 0; retries < debugnet_arp_nretries; retries++) {
404 error = debugnet_send_arp(pcb, dst);
405 if (error != 0)
406 return (error);
407 for (polls = 0; polls < debugnet_npolls &&
408 pcb->dp_state < DN_STATE_HAVE_GW_MAC; polls++) {
409 debugnet_network_poll(pcb);
410 DELAY(500);
411 }
412 if (pcb->dp_state >= DN_STATE_HAVE_GW_MAC)
413 break;
414 printf("(ARP retry)");
415 }
416 if (pcb->dp_state >= DN_STATE_HAVE_GW_MAC)
417 return (0);
418 if (dst == pcb->dp_server) {
419 printf("\nFailed to ARP server");
420 if (pcb->dp_gateway != INADDR_ANY) {
421 printf(", trying to reach gateway...\n");
422 dst = pcb->dp_gateway;
423 goto restart;
424 } else
425 printf(".\n");
426 } else
427 printf("\nFailed to ARP gateway.\n");
428
429 return (ETIMEDOUT);
430}
431
432/*
433 * Unreliable IPv4 transmission of an mbuf chain to the debugnet server

Callers 1

debugnet_connectFunction · 0.85

Calls 4

debugnet_send_arpFunction · 0.85
debugnet_network_pollFunction · 0.85
DELAYFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected