-fix leaks
[oweals/gnunet.git] / src / gns / nss / nss_gns_query.h
1 /*
2      This file is part of GNUnet.
3      (C) 2012 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 #ifndef NSS_GNS_QUERY_H
21 #define NSS_GNS_QUERY_H
22
23 /**
24  * Parts taken from nss-mdns
25  */
26 #include <inttypes.h>
27
28 /* Maximum number of entries to return */
29 #define MAX_ENTRIES 16
30
31 typedef struct {
32     uint32_t address;
33 } ipv4_address_t;
34
35 typedef struct {
36     uint8_t address[16];
37 } ipv6_address_t;
38
39
40 struct userdata {
41   int count;
42   int data_len; /* only valid when doing reverse lookup */
43   union  {
44       ipv4_address_t ipv4[MAX_ENTRIES];
45       ipv6_address_t ipv6[MAX_ENTRIES];
46       char *name[MAX_ENTRIES];
47   } data;
48 };
49
50 /**
51  * Wrapper function that uses gnunet-gns cli tool to resolve
52  * an IPv4/6 address.
53  *
54  * @param af address family
55  * @param name the name to resolve
56  * @param u the userdata (result struct)
57  * @return -1 on error else 0
58  */
59 int gns_resolve_name(int af,
60                const char *name,
61                struct userdata *userdata);
62
63 #endif