glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / gns / nss / nss_gns_query.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      Affero General Public License for more details.
14 */
15 #ifndef NSS_GNS_QUERY_H
16 #define NSS_GNS_QUERY_H
17
18 /**
19  * Parts taken from nss-mdns
20  */
21 #include <inttypes.h>
22
23 /* Maximum number of entries to return */
24 #define MAX_ENTRIES 16
25
26 typedef struct {
27     uint32_t address;
28 } ipv4_address_t;
29
30 typedef struct {
31     uint8_t address[16];
32 } ipv6_address_t;
33
34
35 struct userdata {
36   int count;
37   int data_len; /* only valid when doing reverse lookup */
38   union  {
39       ipv4_address_t ipv4[MAX_ENTRIES];
40       ipv6_address_t ipv6[MAX_ENTRIES];
41       char *name[MAX_ENTRIES];
42   } data;
43 };
44
45 /**
46  * Wrapper function that uses gnunet-gns cli tool to resolve
47  * an IPv4/6 address.
48  *
49  * @param af address family
50  * @param name the name to resolve
51  * @param u the userdata (result struct)
52  * @return -1 on error else 0
53  */
54 int gns_resolve_name(int af,
55                const char *name,
56                struct userdata *userdata);
57
58 #endif