Skip to content

Instantly share code, notes, and snippets.

@Kagee
Forked from jantore/getaddrinfo-no_inet6.c
Last active August 29, 2015 14:24
Show Gist options
  • Save Kagee/26fb520b54a4defacfd7 to your computer and use it in GitHub Desktop.
Save Kagee/26fb520b54a4defacfd7 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <dlfcn.h>
#include <netdb.h>
#include <string.h>
typedef int (*getaddrinfo_t)(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res);
int getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res)
{
struct addrinfo new_hints;
memcpy(&new_hints, hints, sizeof(struct addrinfo));
new_hints.ai_family = AF_INET;
getaddrinfo_t gai;
gai = (getaddrinfo_t)dlsym(RTLD_NEXT, "getaddrinfo");
return gai(node, service, &new_hints, res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment