tool to test resolver
More...
Go to the source code of this file.
|
static void | print_hostname (void *cls, const char *hostname) |
| Prints each hostname obtained from DNS. More...
|
|
static void | print_sockaddr (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
| Callback function to display address. More...
|
|
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
| Main function that will be run by the scheduler. More...
|
|
int | main (int argc, char *const *argv) |
| The main function to access GNUnet's DNS resolver. More...
|
|
tool to test resolver
- Author
- Christian Grothoff
Definition in file gnunet-resolver.c.
◆ GET_TIMEOUT
◆ print_hostname()
static void print_hostname |
( |
void * |
cls, |
|
|
const char * |
hostname |
|
) |
| |
|
static |
Prints each hostname obtained from DNS.
- Parameters
-
cls | closure (unused) |
hostname | one of the names for the host, NULL on the last call to the callback |
Definition at line 47 of file gnunet-resolver.c.
static char * hostname
Our hostname; we give this to all the peers we start.
References hostname.
Referenced by run().
◆ print_sockaddr()
static void print_sockaddr |
( |
void * |
cls, |
|
|
const struct sockaddr * |
addr, |
|
|
socklen_t |
addrlen |
|
) |
| |
|
static |
Callback function to display address.
- Parameters
-
cls | closure (unused) |
addr | one of the addresses of the host, NULL for the last address |
addrlen | length of the address |
Definition at line 67 of file gnunet-resolver.c.
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages).
References GNUNET_a2s().
Referenced by run().
◆ run()
Main function that will be run by the scheduler.
- Parameters
-
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
cfg | configuration |
Definition at line 90 of file gnunet-resolver.c.
95 const struct sockaddr *sa;
97 struct sockaddr_in v4;
98 struct sockaddr_in6 v6;
116 memset (&v4, 0,
sizeof(v4));
117 v4.sin_family = AF_INET;
118 #if HAVE_SOCKADDR_IN_SIN_LEN
119 v4.sin_len =
sizeof(v4);
121 if (1 == inet_pton (AF_INET,
125 sa = (
struct sockaddr *) &v4;
128 memset (&v6, 0,
sizeof(v6));
129 v6.sin6_family = AF_INET6;
130 #if HAVE_SOCKADDR_IN_SIN_LEN
131 v6.sin6_len =
sizeof(v6);
133 if (1 == inet_pton (AF_INET6,
137 sa = (
struct sockaddr *) &v6;
143 "`%s' is not a valid IP: %s\n",
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static void print_sockaddr(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Callback function to display address.
static void print_hostname(void *cls, const char *hostname)
Prints each hostname obtained from DNS.
static int reverse
Flag for reverse lookup.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_ip_get(const char *hostname, int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls)
Convert a string to one or more IP addresses.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_hostname_get(const struct sockaddr *sa, socklen_t salen, int do_resolve, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_HostnameCallback callback, void *cls)
Perform a reverse DNS lookup.
References consensus-simulation::args, cfg, GET_TIMEOUT, GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_YES, print_hostname(), print_sockaddr(), and reverse.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
char *const * |
argv |
|
) |
| |
The main function to access GNUnet's DNS resolver.
- Parameters
-
argc | number of arguments from the command line |
argv | command line arguments |
- Returns
- 0 ok, 1 on error
Definition at line 164 of file gnunet-resolver.c.
182 "gnunet-resolver [hostname]",
185 &
run, NULL)) ? 0 : 1;
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static int ret
Return value of the commandline.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition of a command line option.
References gettext_noop, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), options, ret, reverse, and run().
◆ reverse