-adding plugin for fundamental gns records
[oweals/gnunet.git] / src / include / gnunet_gnsrecord_lib.h
1 /*
2      This file is part of GNUnet
3      (C) 2012, 2013 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
21 /**
22  * @file include/gnunet_gnsrecord_lib.h
23  * @brief API that can be used to manipulate GNS record data
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_GNSRECORD_LIB_H
27 #define GNUNET_GNSRECORD_LIB_H
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0                           /* keep Emacsens' auto-indent happy */
33 }
34 #endif
35 #endif
36
37
38 /**
39  * Record type indicating any record/'*'
40  */
41 #define GNUNET_GNSRECORD_TYPE_ANY 0
42
43 /**
44  * Record type for GNS zone transfer ("PKEY").
45  */
46 #define GNUNET_GNSRECORD_TYPE_PKEY 65536
47
48 /**
49  * Record type for GNS zone transfer ("PSEU").
50  */
51 #define GNUNET_GNSRECORD_TYPE_PSEU 65537
52
53 /**
54  * Record type for GNS legacy hostnames ("LEHO").
55  */
56 #define GNUNET_GNSRECORD_TYPE_LEHO 65538
57
58 /**
59  * Record type for VPN resolution
60  */
61 #define GNUNET_GNSRECORD_TYPE_VPN 65539
62
63 /**
64  * Record type for delegation to DNS.
65  */
66 #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540
67
68 /**
69  * Record type for a social place.
70  */
71 #define GNUNET_GNSRECORD_TYPE_PLACE 65541
72
73 /**
74  * Record type for a phone (of CONVERSATION).
75  */
76 #define GNUNET_GNSRECORD_TYPE_PHONE 65542
77
78
79
80 /**
81  * Convert the binary value @a data of a record of
82  * type @a type to a human-readable string.
83  *
84  * @param type type of the record
85  * @param data value in binary encoding
86  * @param data_size number of bytes in @a data
87  * @return NULL on error, otherwise human-readable representation of the value
88  */
89 char *
90 GNUNET_GNSRECORD_value_to_string (uint32_t type,
91                                   const void *data,
92                                   size_t data_size);
93
94
95 /**
96  * Convert human-readable version of the value @a s of a record
97  * of type @a type to the respective binary representation.
98  *
99  * @param type type of the record
100  * @param s human-readable string
101  * @param data set to value in binary encoding (will be allocated)
102  * @param data_size set to number of bytes in @a data
103  * @return #GNUNET_OK on success
104  */
105 int
106 GNUNET_GNSRECORD_string_to_value (uint32_t type,
107                                   const char *s,
108                                   void **data,
109                                   size_t *data_size);
110
111
112 /**
113  * Convert a type name (i.e. "AAAA") to the corresponding number.
114  *
115  * @param dns_typename name to convert
116  * @return corresponding number, UINT32_MAX on error
117  */
118 uint32_t
119 GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
120
121
122 /**
123  * Convert a type number (i.e. 1) to the corresponding type string (i.e. "A")
124  *
125  * @param type number of a type to convert
126  * @return corresponding typestring, NULL on error
127  */
128 const char *
129 GNUNET_GNSRECORD_number_to_typename (uint32_t type);
130
131
132 #if 0                           /* keep Emacsens' auto-indent happy */
133 {
134 #endif
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif