Skip to content

Commit

Permalink
fix compile for !WIN_USE_NO_ADMIN_PING
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbesen committed Feb 21, 2024
1 parent 97cdd6b commit f1f3da6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void listener( struct PreparedPing* pp )
#ifndef WIN32
int sd = createSocket( pp->psaddr.sin6_family );

setTTL( sd, pp->psaddr.sin6_family );
setTTL( pp->fd, pp->psaddr.sin6_family );
#endif

struct sockaddr_in6 recvFromAddr;
Expand All @@ -383,15 +383,15 @@ void listener( struct PreparedPing* pp )

#ifdef WIN32
WSAPOLLFD fda[1];
fda[0].fd = sd;
fda[0].fd = pp->fd;
fda[0].events = POLLIN;
WSAPoll(fda, 1, 10);
#endif

int bytes;

keep_retry_quick:
bytes = recvfrom(sd, buf, sizeof(buf), 0, (struct sockaddr*)&recvFromAddr, &recvFromAddrLen );
bytes = recvfrom( pp->fd, (void*) buf, sizeof(buf), 0, (struct sockaddr*)&recvFromAddr, &recvFromAddrLen );
if( !isICMPResponse( pp->psaddr.sin6_family, buf, bytes) ) continue;

// compare the sender
Expand Down Expand Up @@ -545,6 +545,7 @@ struct PreparedPing* ping_setup(const char * strhost, const char * device)

memset(&pp->psaddr, 0, sizeof(pp->psaddr));
pp->psaddr_len = sizeof(pp->psaddr);
pp->psaddr.sin6_family = AF_INET;

#ifdef WIN32
pp->fd = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, 0, 0, WSA_FLAG_OVERLAPPED);
Expand All @@ -561,10 +562,6 @@ struct PreparedPing* ping_setup(const char * strhost, const char * device)
{
resolveName((struct sockaddr*) &pp->psaddr, &pp->psaddr_len, strhost, AF_UNSPEC);
}
else
{
pp->psaddr.sin6_family = AF_INET;
}

pp->fd = createSocket( pp->psaddr.sin6_family );

Expand Down

0 comments on commit f1f3da6

Please sign in to comment.