#include <gnunet_private_config.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <netdb.h>
#include <sys/socket.h>
#include <nss.h>
#include <stdio.h>
#include <stdlib.h>
#include "nss_gns_query.h"
#include <arpa/inet.h>
Go to the source code of this file.
|
#define | ALIGN(idx) |
| macro to align idx to 32bit boundary More...
|
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
◆ ALIGN
Value: do { \
if (idx % sizeof(void*)) \
idx += (sizeof(void*) - idx % sizeof(void*)); \
} while (0)
macro to align idx to 32bit boundary
Definition at line 39 of file nss_gns.c.
◆ _nss_gns_gethostbyname2_r()
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.
- Parameters
-
name | the name to resolve |
af | the address family to resolve |
result | the result hostent |
buffer | the result buffer |
buflen | length of the buffer |
errnop | idk |
h_errnop | idk |
- Returns
- a nss_status code
Definition at line 1 of file nss_gns.c.
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;
static struct LoggingHandle * l
uint16_t status
See PRISM_STATUS_*-constants.
static int result
Global testing status.
#define ALIGN(idx)
macro to align idx to 32bit boundary
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.
◆ _nss_gns_gethostbyname_r()
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.
- Parameters
-
| name | the name to resolve |
| result | the result hostent |
| buffer | the result buffer |
| buflen | length of the buffer |
[out] | errnop | the low-level error code to return to the application |
| h_errnop | idk |
- Returns
- a nss_status code
Definition at line 1 of file nss_gns.c.
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.
◆ _nss_gns_gethostbyaddr_r()
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.
- Parameters
-
| addr | the address to resolve |
| len | the length of the address |
| af | the address family of the address |
| result | the result hostent |
| buffer | the result buffer |
| buflen | length of the buffer |
[out] | errnop | the low-level error code to return to the application |
| h_errnop | idk |
- Returns
- NSS_STATUS_UNAVAIL
Definition at line 1 of file nss_gns.c.
249 *h_errnop = NO_RECOVERY;
251 return NSS_STATUS_UNAVAIL;
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...