5 kx /*
5 kx * Infinite loop to receive every ICMP packet received on the socket.
5 kx * For every packet that's received, we just call pr_pack() to look
5 kx * at it and print it.
5 kx */
5 kx
5 kx #include "defs.h"
5 kx
5 kx int recv_ping()
5 kx {
5 kx register int n;
5 kx #if !defined(__GLIBC__)
5 kx int fromlen;
5 kx #else /* __GLIBC__ */
5 kx socklen_t fromlen;
5 kx #endif /* __GLIBC__ */
5 kx struct sockaddr_in from;
5 kx
5 kx for ( ; ; ) {
5 kx fromlen = sizeof(from);
5 kx if ( (n = recvfrom(sockfd, recvpack, sizeof(recvpack), 0,
5 kx (struct sockaddr *) &from, &fromlen)) < 0) {
5 kx if (errno == EINTR)
5 kx continue; /* normal */
5 kx err_ret("recvfrom error");
5 kx continue;
5 kx }
5 kx
5 kx pr_pack(recvpack, n, &from);
5 kx
5 kx }
5 kx }