iPXE
Functions
pingmgmt.h File Reference

ICMP ping management. More...

#include <stdint.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int ping (const char *hostname, unsigned long timeout, size_t len, unsigned int count, int quiet)
 Ping a host. More...
 

Detailed Description

ICMP ping management.

Definition in file pingmgmt.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ping()

int ping ( const char *  hostname,
unsigned long  timeout,
size_t  len,
unsigned int  count,
int  quiet 
)

Ping a host.

Parameters
hostnameHostname
timeoutTimeout between pings, in ticks
lenPayload length
countNumber of packets to send (or zero for no limit)
quietInhibit output
Return values
rcReturn status code

Definition at line 69 of file pingmgmt.c.

70  {
71  int rc;
72 
73  /* Create pinger */
74  if ( ( rc = create_pinger ( &monojob, hostname, timeout, len, count,
75  ( quiet ? NULL : ping_callback ) ) ) != 0 ){
76  printf ( "Could not start ping: %s\n", strerror ( rc ) );
77  return rc;
78  }
79 
80  /* Wait for ping to complete */
81  if ( ( rc = monojob_wait ( NULL, 0 ) ) != 0 ) {
82  if ( ! quiet )
83  printf ( "Finished: %s\n", strerror ( rc ) );
84  return rc;
85  }
86 
87  return 0;
88 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
int monojob_wait(const char *string, unsigned long timeout)
Wait for single foreground job to complete.
Definition: monojob.c:81
int create_pinger(struct interface *job, const char *hostname, unsigned long timeout, size_t len, unsigned int count, void(*callback)(struct sockaddr *src, unsigned int sequence, size_t len, int rc))
Create pinger.
Definition: pinger.c:312
struct interface monojob
Definition: monojob.c:56
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22
void timeout(int)
static void ping_callback(struct sockaddr *peer, unsigned int sequence, size_t len, int rc)
Display ping result.
Definition: pingmgmt.c:48
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References count, create_pinger(), len, monojob, monojob_wait(), NULL, ping_callback(), printf(), rc, strerror(), and timeout().

Referenced by ping_close(), ping_deliver(), ping_demux(), ping_exec(), ping_open(), and ping_rx().