diff options
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-bcd.c | 12 | ||||
-rw-r--r-- | src/gns/gnutls_ca.cfg | 25 | ||||
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 438 |
3 files changed, 226 insertions, 249 deletions
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c index f3249eee0..7906ffd4d 100644 --- a/src/gns/gnunet-bcd.c +++ b/src/gns/gnunet-bcd.c | |||
@@ -179,7 +179,7 @@ access_handler_callback (void *cls, | |||
179 | return MHD_NO; | 179 | return MHD_NO; |
180 | } | 180 | } |
181 | GNUNET_asprintf (&deffile, "%s%s%s", tmp, DIR_SEPARATOR_STR, "def.tex"); | 181 | GNUNET_asprintf (&deffile, "%s%s%s", tmp, DIR_SEPARATOR_STR, "def.tex"); |
182 | f = FOPEN (deffile, "w"); | 182 | f = fopen (deffile, "w"); |
183 | if (NULL == f) | 183 | if (NULL == f) |
184 | { | 184 | { |
185 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", deffile); | 185 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", deffile); |
@@ -194,9 +194,9 @@ access_handler_callback (void *cls, | |||
194 | MHD_GET_ARGUMENT_KIND, | 194 | MHD_GET_ARGUMENT_KIND, |
195 | map[i].formname); | 195 | map[i].formname); |
196 | if (NULL != val) | 196 | if (NULL != val) |
197 | FPRINTF (f, "\\def\\%s{%s}\n", map[i].texname, val); | 197 | fprintf (f, "\\def\\%s{%s}\n", map[i].texname, val); |
198 | else | 198 | else |
199 | FPRINTF (f, "\\def\\%s{}\n", map[i].texname); | 199 | fprintf (f, "\\def\\%s{}\n", map[i].texname); |
200 | } | 200 | } |
201 | if (NULL != gpg_fp) | 201 | if (NULL != gpg_fp) |
202 | { | 202 | { |
@@ -206,15 +206,15 @@ access_handler_callback (void *cls, | |||
206 | slen = strlen (gpg_fp); | 206 | slen = strlen (gpg_fp); |
207 | gpg1 = GNUNET_strndup (gpg_fp, slen / 2); | 207 | gpg1 = GNUNET_strndup (gpg_fp, slen / 2); |
208 | gpg2 = GNUNET_strdup (&gpg_fp[slen / 2]); | 208 | gpg2 = GNUNET_strdup (&gpg_fp[slen / 2]); |
209 | FPRINTF (f, "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n", gpg1, gpg2); | 209 | fprintf (f, "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n", gpg1, gpg2); |
210 | GNUNET_free (gpg2); | 210 | GNUNET_free (gpg2); |
211 | GNUNET_free (gpg1); | 211 | GNUNET_free (gpg1); |
212 | } | 212 | } |
213 | FPRINTF (f, | 213 | fprintf (f, |
214 | "\\def\\gns{%s/%s}\n", | 214 | "\\def\\gns{%s/%s}\n", |
215 | gnskey, | 215 | gnskey, |
216 | (NULL == gns_nick) ? "" : gns_nick); | 216 | (NULL == gns_nick) ? "" : gns_nick); |
217 | FCLOSE (f); | 217 | fclose (f); |
218 | GNUNET_asprintf ( | 218 | GNUNET_asprintf ( |
219 | &p, | 219 | &p, |
220 | "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null", | 220 | "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null", |
diff --git a/src/gns/gnutls_ca.cfg b/src/gns/gnutls_ca.cfg new file mode 100644 index 000000000..f551ae8ab --- /dev/null +++ b/src/gns/gnutls_ca.cfg | |||
@@ -0,0 +1,25 @@ | |||
1 | # This template file specifies that the certificate is a certificate | ||
2 | # authority that will be used to sign other certificates, and | ||
3 | # certificate revocations. Set additional properties (e.g. a CRL URI) | ||
4 | # as appropriate. | ||
5 | |||
6 | # Certificate authority template | ||
7 | organization = "Example" | ||
8 | cn = "Your CA name here" | ||
9 | expiration_days = 3650 | ||
10 | |||
11 | # This CA can not issue subsidiary CAs | ||
12 | path_len = 0 | ||
13 | |||
14 | # Is a CA | ||
15 | ca | ||
16 | |||
17 | # Signs certificates and certificate revocation lists | ||
18 | cert_signing_key | ||
19 | crl_signing_key | ||
20 | |||
21 | # Name constraints (recommended); new in GnuTLS 3.3.x | ||
22 | # Setting this will allow this CA to only issue | ||
23 | # certificates for this domain | ||
24 | nc_permit_dns = "example.com" | ||
25 | #nc_exclude_dns = "test.example.com" | ||
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c index ebba0db47..8cb76cffe 100644 --- a/src/gns/plugin_gnsrecord_gns.c +++ b/src/gns/plugin_gnsrecord_gns.c | |||
@@ -61,85 +61,68 @@ gns_value_to_string (void *cls, | |||
61 | return GNUNET_strndup (data, data_size); | 61 | return GNUNET_strndup (data, data_size); |
62 | case GNUNET_GNSRECORD_TYPE_LEHO: | 62 | case GNUNET_GNSRECORD_TYPE_LEHO: |
63 | return GNUNET_strndup (data, data_size); | 63 | return GNUNET_strndup (data, data_size); |
64 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: | 64 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: { |
65 | char *ns; | ||
66 | char *ip; | ||
67 | size_t off; | ||
68 | char *nstr; | ||
69 | |||
70 | off = 0; | ||
71 | ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); | ||
72 | ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); | ||
73 | if ((NULL == ns) || (NULL == ip) || (off != data_size)) | ||
65 | { | 74 | { |
66 | char *ns; | 75 | GNUNET_break_op (0); |
67 | char *ip; | ||
68 | size_t off; | ||
69 | char *nstr; | ||
70 | |||
71 | off = 0; | ||
72 | ns = GNUNET_DNSPARSER_parse_name (data, | ||
73 | data_size, | ||
74 | &off); | ||
75 | ip = GNUNET_DNSPARSER_parse_name (data, | ||
76 | data_size, | ||
77 | &off); | ||
78 | if ( (NULL == ns) || | ||
79 | (NULL == ip) || | ||
80 | (off != data_size) ) | ||
81 | { | ||
82 | GNUNET_break_op (0); | ||
83 | GNUNET_free_non_null (ns); | ||
84 | GNUNET_free_non_null (ip); | ||
85 | return NULL; | ||
86 | } | ||
87 | GNUNET_asprintf (&nstr, | ||
88 | "%s@%s", | ||
89 | ns, | ||
90 | ip); | ||
91 | GNUNET_free_non_null (ns); | 76 | GNUNET_free_non_null (ns); |
92 | GNUNET_free_non_null (ip); | 77 | GNUNET_free_non_null (ip); |
93 | return nstr; | 78 | return NULL; |
94 | } | ||
95 | case GNUNET_GNSRECORD_TYPE_VPN: | ||
96 | { | ||
97 | struct GNUNET_TUN_GnsVpnRecord vpn; | ||
98 | char* vpn_str; | ||
99 | |||
100 | cdata = data; | ||
101 | if ( (data_size <= sizeof (vpn)) || | ||
102 | ('\0' != cdata[data_size - 1]) ) | ||
103 | return NULL; /* malformed */ | ||
104 | /* need to memcpy for alignment */ | ||
105 | GNUNET_memcpy (&vpn, | ||
106 | data, | ||
107 | sizeof (vpn)); | ||
108 | GNUNET_asprintf (&vpn_str, | ||
109 | "%u %s %s", | ||
110 | (unsigned int) ntohs (vpn.proto), | ||
111 | (const char*) GNUNET_i2s_full (&vpn.peer), | ||
112 | (const char*) &cdata[sizeof (vpn)]); | ||
113 | return vpn_str; | ||
114 | } | ||
115 | case GNUNET_GNSRECORD_TYPE_BOX: | ||
116 | { | ||
117 | struct GNUNET_GNSRECORD_BoxRecord box; | ||
118 | uint32_t rt; | ||
119 | char *box_str; | ||
120 | char *ival; | ||
121 | |||
122 | cdata = data; | ||
123 | if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord)) | ||
124 | return NULL; /* malformed */ | ||
125 | GNUNET_memcpy (&box, | ||
126 | data, | ||
127 | sizeof (box)); | ||
128 | rt = ntohl (box.record_type); | ||
129 | ival = GNUNET_GNSRECORD_value_to_string (rt, | ||
130 | &cdata[sizeof (box)], | ||
131 | data_size - sizeof (box)); | ||
132 | if (NULL == ival) | ||
133 | return NULL; /* malformed */ | ||
134 | GNUNET_asprintf (&box_str, | ||
135 | "%u %u %u %s", | ||
136 | (unsigned int) ntohs (box.protocol), | ||
137 | (unsigned int) ntohs (box.service), | ||
138 | (unsigned int) rt, | ||
139 | ival); | ||
140 | GNUNET_free (ival); | ||
141 | return box_str; | ||
142 | } | 79 | } |
80 | GNUNET_asprintf (&nstr, "%s@%s", ns, ip); | ||
81 | GNUNET_free_non_null (ns); | ||
82 | GNUNET_free_non_null (ip); | ||
83 | return nstr; | ||
84 | } | ||
85 | case GNUNET_GNSRECORD_TYPE_VPN: { | ||
86 | struct GNUNET_TUN_GnsVpnRecord vpn; | ||
87 | char *vpn_str; | ||
88 | |||
89 | cdata = data; | ||
90 | if ((data_size <= sizeof (vpn)) || ('\0' != cdata[data_size - 1])) | ||
91 | return NULL; /* malformed */ | ||
92 | /* need to memcpy for alignment */ | ||
93 | GNUNET_memcpy (&vpn, data, sizeof (vpn)); | ||
94 | GNUNET_asprintf (&vpn_str, | ||
95 | "%u %s %s", | ||
96 | (unsigned int) ntohs (vpn.proto), | ||
97 | (const char *) GNUNET_i2s_full (&vpn.peer), | ||
98 | (const char *) &cdata[sizeof (vpn)]); | ||
99 | return vpn_str; | ||
100 | } | ||
101 | case GNUNET_GNSRECORD_TYPE_BOX: { | ||
102 | struct GNUNET_GNSRECORD_BoxRecord box; | ||
103 | uint32_t rt; | ||
104 | char *box_str; | ||
105 | char *ival; | ||
106 | |||
107 | cdata = data; | ||
108 | if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord)) | ||
109 | return NULL; /* malformed */ | ||
110 | GNUNET_memcpy (&box, data, sizeof (box)); | ||
111 | rt = ntohl (box.record_type); | ||
112 | ival = GNUNET_GNSRECORD_value_to_string (rt, | ||
113 | &cdata[sizeof (box)], | ||
114 | data_size - sizeof (box)); | ||
115 | if (NULL == ival) | ||
116 | return NULL; /* malformed */ | ||
117 | GNUNET_asprintf (&box_str, | ||
118 | "%u %u %u %s", | ||
119 | (unsigned int) ntohs (box.protocol), | ||
120 | (unsigned int) ntohs (box.service), | ||
121 | (unsigned int) rt, | ||
122 | ival); | ||
123 | GNUNET_free (ival); | ||
124 | return box_str; | ||
125 | } | ||
143 | default: | 126 | default: |
144 | return NULL; | 127 | return NULL; |
145 | } | 128 | } |
@@ -171,154 +154,128 @@ gns_string_to_value (void *cls, | |||
171 | switch (type) | 154 | switch (type) |
172 | { | 155 | { |
173 | 156 | ||
174 | case GNUNET_GNSRECORD_TYPE_PKEY: | 157 | case GNUNET_GNSRECORD_TYPE_PKEY: |
175 | if (GNUNET_OK != | 158 | if (GNUNET_OK != |
176 | GNUNET_CRYPTO_ecdsa_public_key_from_string (s, | 159 | GNUNET_CRYPTO_ecdsa_public_key_from_string (s, strlen (s), &pkey)) |
177 | strlen (s), | 160 | { |
178 | &pkey)) | 161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
179 | { | 162 | _ ("Unable to parse PKEY record `%s'\n"), |
180 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 163 | s); |
181 | _("Unable to parse PKEY record `%s'\n"), | 164 | return GNUNET_SYSERR; |
182 | s); | 165 | } |
183 | return GNUNET_SYSERR; | 166 | *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
184 | } | 167 | GNUNET_memcpy (*data, &pkey, sizeof (pkey)); |
185 | *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 168 | *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); |
186 | GNUNET_memcpy (*data, | 169 | return GNUNET_OK; |
187 | &pkey, | 170 | |
188 | sizeof (pkey)); | 171 | case GNUNET_GNSRECORD_TYPE_NICK: |
189 | *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | 172 | *data = GNUNET_strdup (s); |
190 | return GNUNET_OK; | 173 | *data_size = strlen (s); |
191 | 174 | return GNUNET_OK; | |
192 | case GNUNET_GNSRECORD_TYPE_NICK: | 175 | case GNUNET_GNSRECORD_TYPE_LEHO: |
193 | *data = GNUNET_strdup (s); | 176 | *data = GNUNET_strdup (s); |
194 | *data_size = strlen (s); | 177 | *data_size = strlen (s); |
195 | return GNUNET_OK; | 178 | return GNUNET_OK; |
196 | case GNUNET_GNSRECORD_TYPE_LEHO: | 179 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: { |
197 | *data = GNUNET_strdup (s); | 180 | char nsbuf[514]; |
198 | *data_size = strlen (s); | 181 | char *cpy; |
199 | return GNUNET_OK; | 182 | char *at; |
200 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: | 183 | size_t off; |
201 | { | 184 | |
202 | char nsbuf[514]; | 185 | cpy = GNUNET_strdup (s); |
203 | char *cpy; | 186 | at = strchr (cpy, '@'); |
204 | char *at; | 187 | if (NULL == at) |
205 | size_t off; | 188 | { |
206 | 189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | |
207 | cpy = GNUNET_strdup (s); | 190 | _ ("Unable to parse GNS2DNS record `%s'\n"), |
208 | at = strchr (cpy, '@'); | 191 | s); |
209 | if (NULL == at) | 192 | GNUNET_free (cpy); |
210 | { | 193 | return GNUNET_SYSERR; |
211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 194 | } |
212 | _("Unable to parse GNS2DNS record `%s'\n"), | 195 | *at = '\0'; |
213 | s); | 196 | at++; |
214 | GNUNET_free (cpy); | 197 | |
215 | return GNUNET_SYSERR; | 198 | off = 0; |
216 | } | 199 | if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf, |
217 | *at = '\0'; | 200 | sizeof (nsbuf), |
218 | at++; | 201 | &off, |
219 | 202 | cpy)) || | |
220 | off = 0; | 203 | (GNUNET_OK != |
221 | if ( (GNUNET_OK != | 204 | GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof (nsbuf), &off, at))) |
222 | GNUNET_DNSPARSER_builder_add_name (nsbuf, | 205 | { |
223 | sizeof (nsbuf), | 206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
224 | &off, | 207 | _ ("Failed to serialize GNS2DNS record with value `%s'\n"), |
225 | cpy)) || | 208 | s); |
226 | (GNUNET_OK != | 209 | GNUNET_free (cpy); |
227 | GNUNET_DNSPARSER_builder_add_name (nsbuf, | ||
228 | sizeof (nsbuf), | ||
229 | &off, | ||
230 | at)) ) | ||
231 | { | ||
232 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
233 | _("Failed to serialize GNS2DNS record with value `%s'\n"), | ||
234 | s); | ||
235 | GNUNET_free (cpy); | ||
236 | return GNUNET_SYSERR; | ||
237 | } | ||
238 | GNUNET_free (cpy); | ||
239 | *data_size = off; | ||
240 | *data = GNUNET_malloc (off); | ||
241 | GNUNET_memcpy (*data, | ||
242 | nsbuf, | ||
243 | off); | ||
244 | return GNUNET_OK; | ||
245 | } | ||
246 | case GNUNET_GNSRECORD_TYPE_VPN: | ||
247 | { | ||
248 | struct GNUNET_TUN_GnsVpnRecord *vpn; | ||
249 | char s_peer[103 + 1]; | ||
250 | char s_serv[253 + 1]; | ||
251 | unsigned int proto; | ||
252 | |||
253 | if (3 != SSCANF (s, | ||
254 | "%u %103s %253s", | ||
255 | &proto, s_peer, s_serv)) | ||
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
258 | _("Unable to parse VPN record string `%s'\n"), | ||
259 | s); | ||
260 | return GNUNET_SYSERR; | ||
261 | } | ||
262 | *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1; | ||
263 | *data = vpn = GNUNET_malloc (*data_size); | ||
264 | if (GNUNET_OK != | ||
265 | GNUNET_CRYPTO_eddsa_public_key_from_string ((char*) s_peer, | ||
266 | strlen (s_peer), | ||
267 | &vpn->peer.public_key)) | ||
268 | { | ||
269 | GNUNET_free (vpn); | ||
270 | *data_size = 0; | ||
271 | return GNUNET_SYSERR; | ||
272 | } | ||
273 | vpn->proto = htons ((uint16_t) proto); | ||
274 | strcpy ((char*)&vpn[1], s_serv); | ||
275 | return GNUNET_OK; | ||
276 | } | ||
277 | case GNUNET_GNSRECORD_TYPE_BOX: | ||
278 | { | ||
279 | struct GNUNET_GNSRECORD_BoxRecord *box; | ||
280 | size_t rest; | ||
281 | unsigned int protocol; | ||
282 | unsigned int service; | ||
283 | unsigned int record_type; | ||
284 | void *bval; | ||
285 | size_t bval_size; | ||
286 | |||
287 | if (3 != SSCANF (s, | ||
288 | "%u %u %u ", | ||
289 | &protocol, | ||
290 | &service, | ||
291 | &record_type)) | ||
292 | { | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
294 | _("Unable to parse BOX record string `%s'\n"), | ||
295 | s); | ||
296 | return GNUNET_SYSERR; | ||
297 | } | ||
298 | rest = snprintf (NULL, 0, | ||
299 | "%u %u %u ", | ||
300 | protocol, | ||
301 | service, | ||
302 | record_type); | ||
303 | if (GNUNET_OK != | ||
304 | GNUNET_GNSRECORD_string_to_value (record_type, | ||
305 | &s[rest], | ||
306 | &bval, | ||
307 | &bval_size)) | ||
308 | return GNUNET_SYSERR; | ||
309 | *data_size = sizeof (struct GNUNET_GNSRECORD_BoxRecord) + bval_size; | ||
310 | *data = box = GNUNET_malloc (*data_size); | ||
311 | box->protocol = htons (protocol); | ||
312 | box->service = htons (service); | ||
313 | box->record_type = htonl (record_type); | ||
314 | GNUNET_memcpy (&box[1], | ||
315 | bval, | ||
316 | bval_size); | ||
317 | GNUNET_free (bval); | ||
318 | return GNUNET_OK; | ||
319 | } | ||
320 | default: | ||
321 | return GNUNET_SYSERR; | 210 | return GNUNET_SYSERR; |
211 | } | ||
212 | GNUNET_free (cpy); | ||
213 | *data_size = off; | ||
214 | *data = GNUNET_malloc (off); | ||
215 | GNUNET_memcpy (*data, nsbuf, off); | ||
216 | return GNUNET_OK; | ||
217 | } | ||
218 | case GNUNET_GNSRECORD_TYPE_VPN: { | ||
219 | struct GNUNET_TUN_GnsVpnRecord *vpn; | ||
220 | char s_peer[103 + 1]; | ||
221 | char s_serv[253 + 1]; | ||
222 | unsigned int proto; | ||
223 | |||
224 | if (3 != sscanf (s, "%u %103s %253s", &proto, s_peer, s_serv)) | ||
225 | { | ||
226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
227 | _ ("Unable to parse VPN record string `%s'\n"), | ||
228 | s); | ||
229 | return GNUNET_SYSERR; | ||
230 | } | ||
231 | *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1; | ||
232 | *data = vpn = GNUNET_malloc (*data_size); | ||
233 | if (GNUNET_OK != | ||
234 | GNUNET_CRYPTO_eddsa_public_key_from_string ((char *) s_peer, | ||
235 | strlen (s_peer), | ||
236 | &vpn->peer.public_key)) | ||
237 | { | ||
238 | GNUNET_free (vpn); | ||
239 | *data_size = 0; | ||
240 | return GNUNET_SYSERR; | ||
241 | } | ||
242 | vpn->proto = htons ((uint16_t) proto); | ||
243 | strcpy ((char *) &vpn[1], s_serv); | ||
244 | return GNUNET_OK; | ||
245 | } | ||
246 | case GNUNET_GNSRECORD_TYPE_BOX: { | ||
247 | struct GNUNET_GNSRECORD_BoxRecord *box; | ||
248 | size_t rest; | ||
249 | unsigned int protocol; | ||
250 | unsigned int service; | ||
251 | unsigned int record_type; | ||
252 | void *bval; | ||
253 | size_t bval_size; | ||
254 | |||
255 | if (3 != sscanf (s, "%u %u %u ", &protocol, &service, &record_type)) | ||
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
258 | _ ("Unable to parse BOX record string `%s'\n"), | ||
259 | s); | ||
260 | return GNUNET_SYSERR; | ||
261 | } | ||
262 | rest = snprintf (NULL, 0, "%u %u %u ", protocol, service, record_type); | ||
263 | if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (record_type, | ||
264 | &s[rest], | ||
265 | &bval, | ||
266 | &bval_size)) | ||
267 | return GNUNET_SYSERR; | ||
268 | *data_size = sizeof (struct GNUNET_GNSRECORD_BoxRecord) + bval_size; | ||
269 | *data = box = GNUNET_malloc (*data_size); | ||
270 | box->protocol = htons (protocol); | ||
271 | box->service = htons (service); | ||
272 | box->record_type = htonl (record_type); | ||
273 | GNUNET_memcpy (&box[1], bval, bval_size); | ||
274 | GNUNET_free (bval); | ||
275 | return GNUNET_OK; | ||
276 | } | ||
277 | default: | ||
278 | return GNUNET_SYSERR; | ||
322 | } | 279 | } |
323 | } | 280 | } |
324 | 281 | ||
@@ -327,18 +284,17 @@ gns_string_to_value (void *cls, | |||
327 | * Mapping of record type numbers to human-readable | 284 | * Mapping of record type numbers to human-readable |
328 | * record type names. | 285 | * record type names. |
329 | */ | 286 | */ |
330 | static struct { | 287 | static struct |
288 | { | ||
331 | const char *name; | 289 | const char *name; |
332 | uint32_t number; | 290 | uint32_t number; |
333 | } gns_name_map[] = { | 291 | } gns_name_map[] = {{"PKEY", GNUNET_GNSRECORD_TYPE_PKEY}, |
334 | { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY }, | 292 | {"NICK", GNUNET_GNSRECORD_TYPE_NICK}, |
335 | { "NICK", GNUNET_GNSRECORD_TYPE_NICK }, | 293 | {"LEHO", GNUNET_GNSRECORD_TYPE_LEHO}, |
336 | { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO }, | 294 | {"VPN", GNUNET_GNSRECORD_TYPE_VPN}, |
337 | { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, | 295 | {"GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS}, |
338 | { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS }, | 296 | {"BOX", GNUNET_GNSRECORD_TYPE_BOX}, |
339 | { "BOX", GNUNET_GNSRECORD_TYPE_BOX }, | 297 | {NULL, UINT32_MAX}}; |
340 | { NULL, UINT32_MAX } | ||
341 | }; | ||
342 | 298 | ||
343 | 299 | ||
344 | /** | 300 | /** |
@@ -349,15 +305,13 @@ static struct { | |||
349 | * @return corresponding number, UINT32_MAX on error | 305 | * @return corresponding number, UINT32_MAX on error |
350 | */ | 306 | */ |
351 | static uint32_t | 307 | static uint32_t |
352 | gns_typename_to_number (void *cls, | 308 | gns_typename_to_number (void *cls, const char *gns_typename) |
353 | const char *gns_typename) | ||
354 | { | 309 | { |
355 | unsigned int i; | 310 | unsigned int i; |
356 | 311 | ||
357 | i=0; | 312 | i = 0; |
358 | while ( (NULL != gns_name_map[i].name) && | 313 | while ((NULL != gns_name_map[i].name) && |
359 | (0 != strcasecmp (gns_typename, | 314 | (0 != strcasecmp (gns_typename, gns_name_map[i].name))) |
360 | gns_name_map[i].name)) ) | ||
361 | i++; | 315 | i++; |
362 | return gns_name_map[i].number; | 316 | return gns_name_map[i].number; |
363 | } | 317 | } |
@@ -371,14 +325,12 @@ gns_typename_to_number (void *cls, | |||
371 | * @return corresponding typestring, NULL on error | 325 | * @return corresponding typestring, NULL on error |
372 | */ | 326 | */ |
373 | static const char * | 327 | static const char * |
374 | gns_number_to_typename (void *cls, | 328 | gns_number_to_typename (void *cls, uint32_t type) |
375 | uint32_t type) | ||
376 | { | 329 | { |
377 | unsigned int i; | 330 | unsigned int i; |
378 | 331 | ||
379 | i=0; | 332 | i = 0; |
380 | while ( (NULL != gns_name_map[i].name) && | 333 | while ((NULL != gns_name_map[i].name) && (type != gns_name_map[i].number)) |
381 | (type != gns_name_map[i].number) ) | ||
382 | i++; | 334 | i++; |
383 | return gns_name_map[i].name; | 335 | return gns_name_map[i].name; |
384 | } | 336 | } |