Skip to content

Instantly share code, notes, and snippets.

@jantore
Created July 14, 2015 09:05
Show Gist options
  • Save jantore/b78659338838367b98f1 to your computer and use it in GitHub Desktop.
Save jantore/b78659338838367b98f1 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