Skip to content

Commit

Permalink
macos: use AI_UNUSABLE hint for getaddrinfo()
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
  • Loading branch information
tycho committed Feb 27, 2020
1 parent bc5017b commit 5187f5b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ extern "C" {

#include <sys/select.h>

/*** compatibility ***/

/* Mac OS X's getaddrinfo() does not fail if we use an invalid combination,
* e.g. AF_INET6 with "127.0.0.1". If we pass AI_UNUSABLE to flags, it behaves
* like other platforms. But AI_UNUSABLE isn't available on other platforms,
* and we can safely use 0 for flags instead.
*/
#ifndef AI_UNUSABLE
#define AI_UNUSABLE 0
#endif

/*** externals ***/

extern char* optarg;
Expand Down Expand Up @@ -2273,7 +2284,7 @@ void add_name(char* name)

/* getaddrinfo */
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = 0;
hints.ai_flags = AI_UNUSABLE;
hints.ai_socktype = SOCK_RAW;
hints.ai_family = hints_ai_family;
if (hints_ai_family == AF_INET) {
Expand Down

0 comments on commit 5187f5b

Please sign in to comment.