22 #include <gnunet_private_config.h>
28 #include <sys/socket.h>
36 #include <arpa/inet.h>
39 #define ALIGN(idx) do { \
40 if (idx % sizeof(void*)) \
41 idx += (sizeof(void*) - idx % sizeof(void*)); \
67 enum nss_status
status = NSS_STATUS_UNAVAIL;
69 size_t address_length;
86 if ((af != AF_INET) &&
91 *h_errnop = NO_RECOVERY;
103 *h_errnop = NO_RECOVERY;
104 status = NSS_STATUS_TRYAGAIN;
116 status = NSS_STATUS_UNAVAIL;
117 *h_errnop = NO_RECOVERY;
123 *h_errnop = NO_RECOVERY;
124 status = NSS_STATUS_UNAVAIL;
130 *h_errnop = HOST_NOT_FOUND;
131 status = NSS_STATUS_NOTFOUND;
138 status = NSS_STATUS_NOTFOUND;
142 *((
char **) buffer) = NULL;
143 result->h_aliases = (
char **) buffer;
147 strcpy (buffer + idx,
149 result->h_name = buffer + idx;
150 idx += strlen (
name) + 1;
155 result->h_length = address_length;
158 if (buflen < idx + u.
data_len +
sizeof(
char*) * (u.
count + 1))
161 *h_errnop = NO_RECOVERY;
162 status = NSS_STATUS_TRYAGAIN;
167 l = u.
count * address_length;
169 memcpy (buffer + astart,
177 for (i = 0; i < u.
count; i++)
178 ((
char **) (buffer + idx))[i] = buffer + astart + address_length * i;
179 ((
char **) (buffer + idx))[i] = NULL;
180 result->h_addr_list = (
char **) (buffer + idx);
182 status = NSS_STATUS_SUCCESS;
249 *h_errnop = NO_RECOVERY;
251 return NSS_STATUS_UNAVAIL;
static struct LoggingHandle * l
uint16_t status
See PRISM_STATUS_*-constants.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static int result
Global testing status.
enum nss_status _nss_gns_gethostbyname_r(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop)
The gethostbyname hook executed by nsswitch.
enum nss_status _nss_gns_gethostbyname2_r(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop)
The gethostbyname hook executed by nsswitch.
#define ALIGN(idx)
macro to align idx to 32bit boundary
enum nss_status _nss_gns_gethostbyaddr_r(const void *addr, int len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop)
The gethostbyaddr hook executed by nsswitch We can't do this so we always return NSS_STATUS_UNAVAIL.
int gns_resolve_name(int af, const char *name, struct userdata *u)
Wrapper function that uses gnunet-gns cli tool to resolve an IPv4/6 address.