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