diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/gns/plugin_gnsrecord_gns.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/gns/plugin_gnsrecord_gns.c')
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 443 |
1 files changed, 226 insertions, 217 deletions
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c index 8cb76cffe..094307ea3 100644 --- a/src/gns/plugin_gnsrecord_gns.c +++ b/src/gns/plugin_gnsrecord_gns.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file gns/plugin_gnsrecord_gns.c | 22 | * @file gns/plugin_gnsrecord_gns.c |
@@ -44,88 +44,94 @@ | |||
44 | * @return NULL on error, otherwise human-readable representation of the value | 44 | * @return NULL on error, otherwise human-readable representation of the value |
45 | */ | 45 | */ |
46 | static char * | 46 | static char * |
47 | gns_value_to_string (void *cls, | 47 | gns_value_to_string(void *cls, |
48 | uint32_t type, | 48 | uint32_t type, |
49 | const void *data, | 49 | const void *data, |
50 | size_t data_size) | 50 | size_t data_size) |
51 | { | 51 | { |
52 | const char *cdata; | 52 | const char *cdata; |
53 | 53 | ||
54 | switch (type) | 54 | switch (type) |
55 | { | ||
56 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
57 | if (data_size != sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) | ||
58 | return NULL; | ||
59 | return GNUNET_CRYPTO_ecdsa_public_key_to_string (data); | ||
60 | case GNUNET_GNSRECORD_TYPE_NICK: | ||
61 | return GNUNET_strndup (data, data_size); | ||
62 | case GNUNET_GNSRECORD_TYPE_LEHO: | ||
63 | return GNUNET_strndup (data, data_size); | ||
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)) | ||
74 | { | 55 | { |
75 | GNUNET_break_op (0); | 56 | case GNUNET_GNSRECORD_TYPE_PKEY: |
76 | GNUNET_free_non_null (ns); | 57 | if (data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) |
77 | GNUNET_free_non_null (ip); | 58 | return NULL; |
59 | return GNUNET_CRYPTO_ecdsa_public_key_to_string(data); | ||
60 | |||
61 | case GNUNET_GNSRECORD_TYPE_NICK: | ||
62 | return GNUNET_strndup(data, data_size); | ||
63 | |||
64 | case GNUNET_GNSRECORD_TYPE_LEHO: | ||
65 | return GNUNET_strndup(data, data_size); | ||
66 | |||
67 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: { | ||
68 | char *ns; | ||
69 | char *ip; | ||
70 | size_t off; | ||
71 | char *nstr; | ||
72 | |||
73 | off = 0; | ||
74 | ns = GNUNET_DNSPARSER_parse_name(data, data_size, &off); | ||
75 | ip = GNUNET_DNSPARSER_parse_name(data, data_size, &off); | ||
76 | if ((NULL == ns) || (NULL == ip) || (off != data_size)) | ||
77 | { | ||
78 | GNUNET_break_op(0); | ||
79 | GNUNET_free_non_null(ns); | ||
80 | GNUNET_free_non_null(ip); | ||
81 | return NULL; | ||
82 | } | ||
83 | GNUNET_asprintf(&nstr, "%s@%s", ns, ip); | ||
84 | GNUNET_free_non_null(ns); | ||
85 | GNUNET_free_non_null(ip); | ||
86 | return nstr; | ||
87 | } | ||
88 | |||
89 | case GNUNET_GNSRECORD_TYPE_VPN: { | ||
90 | struct GNUNET_TUN_GnsVpnRecord vpn; | ||
91 | char *vpn_str; | ||
92 | |||
93 | cdata = data; | ||
94 | if ((data_size <= sizeof(vpn)) || ('\0' != cdata[data_size - 1])) | ||
95 | return NULL; /* malformed */ | ||
96 | /* need to memcpy for alignment */ | ||
97 | GNUNET_memcpy(&vpn, data, sizeof(vpn)); | ||
98 | GNUNET_asprintf(&vpn_str, | ||
99 | "%u %s %s", | ||
100 | (unsigned int)ntohs(vpn.proto), | ||
101 | (const char *)GNUNET_i2s_full(&vpn.peer), | ||
102 | (const char *)&cdata[sizeof(vpn)]); | ||
103 | return vpn_str; | ||
104 | } | ||
105 | |||
106 | case GNUNET_GNSRECORD_TYPE_BOX: { | ||
107 | struct GNUNET_GNSRECORD_BoxRecord box; | ||
108 | uint32_t rt; | ||
109 | char *box_str; | ||
110 | char *ival; | ||
111 | |||
112 | cdata = data; | ||
113 | if (data_size < sizeof(struct GNUNET_GNSRECORD_BoxRecord)) | ||
114 | return NULL; /* malformed */ | ||
115 | GNUNET_memcpy(&box, data, sizeof(box)); | ||
116 | rt = ntohl(box.record_type); | ||
117 | ival = GNUNET_GNSRECORD_value_to_string(rt, | ||
118 | &cdata[sizeof(box)], | ||
119 | data_size - sizeof(box)); | ||
120 | if (NULL == ival) | ||
121 | return NULL; /* malformed */ | ||
122 | GNUNET_asprintf(&box_str, | ||
123 | "%u %u %u %s", | ||
124 | (unsigned int)ntohs(box.protocol), | ||
125 | (unsigned int)ntohs(box.service), | ||
126 | (unsigned int)rt, | ||
127 | ival); | ||
128 | GNUNET_free(ival); | ||
129 | return box_str; | ||
130 | } | ||
131 | |||
132 | default: | ||
78 | return NULL; | 133 | return NULL; |
79 | } | 134 | } |
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 | } | ||
126 | default: | ||
127 | return NULL; | ||
128 | } | ||
129 | } | 135 | } |
130 | 136 | ||
131 | 137 | ||
@@ -141,142 +147,146 @@ gns_value_to_string (void *cls, | |||
141 | * @return #GNUNET_OK on success | 147 | * @return #GNUNET_OK on success |
142 | */ | 148 | */ |
143 | static int | 149 | static int |
144 | gns_string_to_value (void *cls, | 150 | gns_string_to_value(void *cls, |
145 | uint32_t type, | 151 | uint32_t type, |
146 | const char *s, | 152 | const char *s, |
147 | void **data, | 153 | void **data, |
148 | size_t *data_size) | 154 | size_t *data_size) |
149 | { | 155 | { |
150 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 156 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
151 | 157 | ||
152 | if (NULL == s) | 158 | if (NULL == s) |
153 | return GNUNET_SYSERR; | 159 | return GNUNET_SYSERR; |
154 | switch (type) | 160 | switch (type) |
155 | { | ||
156 | |||
157 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
158 | if (GNUNET_OK != | ||
159 | GNUNET_CRYPTO_ecdsa_public_key_from_string (s, strlen (s), &pkey)) | ||
160 | { | ||
161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
162 | _ ("Unable to parse PKEY record `%s'\n"), | ||
163 | s); | ||
164 | return GNUNET_SYSERR; | ||
165 | } | ||
166 | *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
167 | GNUNET_memcpy (*data, &pkey, sizeof (pkey)); | ||
168 | *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
169 | return GNUNET_OK; | ||
170 | |||
171 | case GNUNET_GNSRECORD_TYPE_NICK: | ||
172 | *data = GNUNET_strdup (s); | ||
173 | *data_size = strlen (s); | ||
174 | return GNUNET_OK; | ||
175 | case GNUNET_GNSRECORD_TYPE_LEHO: | ||
176 | *data = GNUNET_strdup (s); | ||
177 | *data_size = strlen (s); | ||
178 | return GNUNET_OK; | ||
179 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: { | ||
180 | char nsbuf[514]; | ||
181 | char *cpy; | ||
182 | char *at; | ||
183 | size_t off; | ||
184 | |||
185 | cpy = GNUNET_strdup (s); | ||
186 | at = strchr (cpy, '@'); | ||
187 | if (NULL == at) | ||
188 | { | ||
189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
190 | _ ("Unable to parse GNS2DNS record `%s'\n"), | ||
191 | s); | ||
192 | GNUNET_free (cpy); | ||
193 | return GNUNET_SYSERR; | ||
194 | } | ||
195 | *at = '\0'; | ||
196 | at++; | ||
197 | |||
198 | off = 0; | ||
199 | if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf, | ||
200 | sizeof (nsbuf), | ||
201 | &off, | ||
202 | cpy)) || | ||
203 | (GNUNET_OK != | ||
204 | GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof (nsbuf), &off, at))) | ||
205 | { | 161 | { |
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 162 | case GNUNET_GNSRECORD_TYPE_PKEY: |
207 | _ ("Failed to serialize GNS2DNS record with value `%s'\n"), | 163 | if (GNUNET_OK != |
208 | s); | 164 | GNUNET_CRYPTO_ecdsa_public_key_from_string(s, strlen(s), &pkey)) |
209 | GNUNET_free (cpy); | 165 | { |
210 | return GNUNET_SYSERR; | 166 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
167 | _("Unable to parse PKEY record `%s'\n"), | ||
168 | s); | ||
169 | return GNUNET_SYSERR; | ||
170 | } | ||
171 | *data = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
172 | GNUNET_memcpy(*data, &pkey, sizeof(pkey)); | ||
173 | *data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
174 | return GNUNET_OK; | ||
175 | |||
176 | case GNUNET_GNSRECORD_TYPE_NICK: | ||
177 | *data = GNUNET_strdup(s); | ||
178 | *data_size = strlen(s); | ||
179 | return GNUNET_OK; | ||
180 | |||
181 | case GNUNET_GNSRECORD_TYPE_LEHO: | ||
182 | *data = GNUNET_strdup(s); | ||
183 | *data_size = strlen(s); | ||
184 | return GNUNET_OK; | ||
185 | |||
186 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: { | ||
187 | char nsbuf[514]; | ||
188 | char *cpy; | ||
189 | char *at; | ||
190 | size_t off; | ||
191 | |||
192 | cpy = GNUNET_strdup(s); | ||
193 | at = strchr(cpy, '@'); | ||
194 | if (NULL == at) | ||
195 | { | ||
196 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
197 | _("Unable to parse GNS2DNS record `%s'\n"), | ||
198 | s); | ||
199 | GNUNET_free(cpy); | ||
200 | return GNUNET_SYSERR; | ||
201 | } | ||
202 | *at = '\0'; | ||
203 | at++; | ||
204 | |||
205 | off = 0; | ||
206 | if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name(nsbuf, | ||
207 | sizeof(nsbuf), | ||
208 | &off, | ||
209 | cpy)) || | ||
210 | (GNUNET_OK != | ||
211 | GNUNET_DNSPARSER_builder_add_name(nsbuf, sizeof(nsbuf), &off, at))) | ||
212 | { | ||
213 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
214 | _("Failed to serialize GNS2DNS record with value `%s'\n"), | ||
215 | s); | ||
216 | GNUNET_free(cpy); | ||
217 | return GNUNET_SYSERR; | ||
218 | } | ||
219 | GNUNET_free(cpy); | ||
220 | *data_size = off; | ||
221 | *data = GNUNET_malloc(off); | ||
222 | GNUNET_memcpy(*data, nsbuf, off); | ||
223 | return GNUNET_OK; | ||
211 | } | 224 | } |
212 | GNUNET_free (cpy); | 225 | |
213 | *data_size = off; | 226 | case GNUNET_GNSRECORD_TYPE_VPN: { |
214 | *data = GNUNET_malloc (off); | 227 | struct GNUNET_TUN_GnsVpnRecord *vpn; |
215 | GNUNET_memcpy (*data, nsbuf, off); | 228 | char s_peer[103 + 1]; |
216 | return GNUNET_OK; | 229 | char s_serv[253 + 1]; |
217 | } | 230 | unsigned int proto; |
218 | case GNUNET_GNSRECORD_TYPE_VPN: { | 231 | |
219 | struct GNUNET_TUN_GnsVpnRecord *vpn; | 232 | if (3 != sscanf(s, "%u %103s %253s", &proto, s_peer, s_serv)) |
220 | char s_peer[103 + 1]; | 233 | { |
221 | char s_serv[253 + 1]; | 234 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
222 | unsigned int proto; | 235 | _("Unable to parse VPN record string `%s'\n"), |
223 | 236 | s); | |
224 | if (3 != sscanf (s, "%u %103s %253s", &proto, s_peer, s_serv)) | 237 | return GNUNET_SYSERR; |
225 | { | 238 | } |
226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 239 | *data_size = sizeof(struct GNUNET_TUN_GnsVpnRecord) + strlen(s_serv) + 1; |
227 | _ ("Unable to parse VPN record string `%s'\n"), | 240 | *data = vpn = GNUNET_malloc(*data_size); |
228 | s); | 241 | if (GNUNET_OK != |
229 | return GNUNET_SYSERR; | 242 | GNUNET_CRYPTO_eddsa_public_key_from_string((char *)s_peer, |
243 | strlen(s_peer), | ||
244 | &vpn->peer.public_key)) | ||
245 | { | ||
246 | GNUNET_free(vpn); | ||
247 | *data_size = 0; | ||
248 | return GNUNET_SYSERR; | ||
249 | } | ||
250 | vpn->proto = htons((uint16_t)proto); | ||
251 | strcpy((char *)&vpn[1], s_serv); | ||
252 | return GNUNET_OK; | ||
230 | } | 253 | } |
231 | *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1; | 254 | |
232 | *data = vpn = GNUNET_malloc (*data_size); | 255 | case GNUNET_GNSRECORD_TYPE_BOX: { |
233 | if (GNUNET_OK != | 256 | struct GNUNET_GNSRECORD_BoxRecord *box; |
234 | GNUNET_CRYPTO_eddsa_public_key_from_string ((char *) s_peer, | 257 | size_t rest; |
235 | strlen (s_peer), | 258 | unsigned int protocol; |
236 | &vpn->peer.public_key)) | 259 | unsigned int service; |
237 | { | 260 | unsigned int record_type; |
238 | GNUNET_free (vpn); | 261 | void *bval; |
239 | *data_size = 0; | 262 | size_t bval_size; |
240 | return GNUNET_SYSERR; | 263 | |
264 | if (3 != sscanf(s, "%u %u %u ", &protocol, &service, &record_type)) | ||
265 | { | ||
266 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
267 | _("Unable to parse BOX record string `%s'\n"), | ||
268 | s); | ||
269 | return GNUNET_SYSERR; | ||
270 | } | ||
271 | rest = snprintf(NULL, 0, "%u %u %u ", protocol, service, record_type); | ||
272 | if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value(record_type, | ||
273 | &s[rest], | ||
274 | &bval, | ||
275 | &bval_size)) | ||
276 | return GNUNET_SYSERR; | ||
277 | *data_size = sizeof(struct GNUNET_GNSRECORD_BoxRecord) + bval_size; | ||
278 | *data = box = GNUNET_malloc(*data_size); | ||
279 | box->protocol = htons(protocol); | ||
280 | box->service = htons(service); | ||
281 | box->record_type = htonl(record_type); | ||
282 | GNUNET_memcpy(&box[1], bval, bval_size); | ||
283 | GNUNET_free(bval); | ||
284 | return GNUNET_OK; | ||
241 | } | 285 | } |
242 | vpn->proto = htons ((uint16_t) proto); | 286 | |
243 | strcpy ((char *) &vpn[1], s_serv); | 287 | default: |
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; | 288 | return GNUNET_SYSERR; |
261 | } | 289 | } |
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; | ||
279 | } | ||
280 | } | 290 | } |
281 | 291 | ||
282 | 292 | ||
@@ -284,17 +294,16 @@ gns_string_to_value (void *cls, | |||
284 | * Mapping of record type numbers to human-readable | 294 | * Mapping of record type numbers to human-readable |
285 | * record type names. | 295 | * record type names. |
286 | */ | 296 | */ |
287 | static struct | 297 | static struct { |
288 | { | ||
289 | const char *name; | 298 | const char *name; |
290 | uint32_t number; | 299 | uint32_t number; |
291 | } gns_name_map[] = {{"PKEY", GNUNET_GNSRECORD_TYPE_PKEY}, | 300 | } gns_name_map[] = { { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY }, |
292 | {"NICK", GNUNET_GNSRECORD_TYPE_NICK}, | 301 | { "NICK", GNUNET_GNSRECORD_TYPE_NICK }, |
293 | {"LEHO", GNUNET_GNSRECORD_TYPE_LEHO}, | 302 | { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO }, |
294 | {"VPN", GNUNET_GNSRECORD_TYPE_VPN}, | 303 | { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, |
295 | {"GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS}, | 304 | { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS }, |
296 | {"BOX", GNUNET_GNSRECORD_TYPE_BOX}, | 305 | { "BOX", GNUNET_GNSRECORD_TYPE_BOX }, |
297 | {NULL, UINT32_MAX}}; | 306 | { NULL, UINT32_MAX } }; |
298 | 307 | ||
299 | 308 | ||
300 | /** | 309 | /** |
@@ -305,13 +314,13 @@ static struct | |||
305 | * @return corresponding number, UINT32_MAX on error | 314 | * @return corresponding number, UINT32_MAX on error |
306 | */ | 315 | */ |
307 | static uint32_t | 316 | static uint32_t |
308 | gns_typename_to_number (void *cls, const char *gns_typename) | 317 | gns_typename_to_number(void *cls, const char *gns_typename) |
309 | { | 318 | { |
310 | unsigned int i; | 319 | unsigned int i; |
311 | 320 | ||
312 | i = 0; | 321 | i = 0; |
313 | while ((NULL != gns_name_map[i].name) && | 322 | while ((NULL != gns_name_map[i].name) && |
314 | (0 != strcasecmp (gns_typename, gns_name_map[i].name))) | 323 | (0 != strcasecmp(gns_typename, gns_name_map[i].name))) |
315 | i++; | 324 | i++; |
316 | return gns_name_map[i].number; | 325 | return gns_name_map[i].number; |
317 | } | 326 | } |
@@ -325,7 +334,7 @@ gns_typename_to_number (void *cls, const char *gns_typename) | |||
325 | * @return corresponding typestring, NULL on error | 334 | * @return corresponding typestring, NULL on error |
326 | */ | 335 | */ |
327 | static const char * | 336 | static const char * |
328 | gns_number_to_typename (void *cls, uint32_t type) | 337 | gns_number_to_typename(void *cls, uint32_t type) |
329 | { | 338 | { |
330 | unsigned int i; | 339 | unsigned int i; |
331 | 340 | ||
@@ -343,11 +352,11 @@ gns_number_to_typename (void *cls, uint32_t type) | |||
343 | * @return the exported block API | 352 | * @return the exported block API |
344 | */ | 353 | */ |
345 | void * | 354 | void * |
346 | libgnunet_plugin_gnsrecord_gns_init (void *cls) | 355 | libgnunet_plugin_gnsrecord_gns_init(void *cls) |
347 | { | 356 | { |
348 | struct GNUNET_GNSRECORD_PluginFunctions *api; | 357 | struct GNUNET_GNSRECORD_PluginFunctions *api; |
349 | 358 | ||
350 | api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions); | 359 | api = GNUNET_new(struct GNUNET_GNSRECORD_PluginFunctions); |
351 | api->value_to_string = &gns_value_to_string; | 360 | api->value_to_string = &gns_value_to_string; |
352 | api->string_to_value = &gns_string_to_value; | 361 | api->string_to_value = &gns_string_to_value; |
353 | api->typename_to_number = &gns_typename_to_number; | 362 | api->typename_to_number = &gns_typename_to_number; |
@@ -363,11 +372,11 @@ libgnunet_plugin_gnsrecord_gns_init (void *cls) | |||
363 | * @return NULL | 372 | * @return NULL |
364 | */ | 373 | */ |
365 | void * | 374 | void * |
366 | libgnunet_plugin_gnsrecord_gns_done (void *cls) | 375 | libgnunet_plugin_gnsrecord_gns_done(void *cls) |
367 | { | 376 | { |
368 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; | 377 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; |
369 | 378 | ||
370 | GNUNET_free (api); | 379 | GNUNET_free(api); |
371 | return NULL; | 380 | return NULL; |
372 | } | 381 | } |
373 | 382 | ||