summaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-05 10:26:56 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-05 10:26:56 +0000
commit0333d3afbc95ada40eabbac5e7cf02c598507a67 (patch)
treea42129ad9130a51561d72e117e9222bb00be07d4 /src/gns/gnunet-gns.c
parent02ff54a5f5daec8a93d75991a77b8e27b22708aa (diff)
downloadgnunet-0333d3afbc95ada40eabbac5e7cf02c598507a67.tar.gz
gnunet-0333d3afbc95ada40eabbac5e7cf02c598507a67.zip
-parsing type and common values in gnunet-gns
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r--src/gns/gnunet-gns.c92
1 files changed, 89 insertions, 3 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index b56423c04..738c68788 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -27,6 +27,7 @@
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include <gnunet_util_lib.h> 29#include <gnunet_util_lib.h>
30#include <gnunet_dnsparser_lib.h>
30#include <gnunet_namestore_service.h> 31#include <gnunet_namestore_service.h>
31 32
32/** 33/**
@@ -121,6 +122,11 @@ run (void *cls, char *const *args, const char *cfgfile,
121 const struct GNUNET_CONFIGURATION_Handle *cfg) 122 const struct GNUNET_CONFIGURATION_Handle *cfg)
122{ 123{
123 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; 124 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
125 uint32_t type;
126 const void *data;
127 size_t data_size;
128 struct in_addr value_a;
129 struct in6_addr value_aaaa;
124 130
125 if (NULL == keyfile) 131 if (NULL == keyfile)
126 { 132 {
@@ -143,12 +149,92 @@ run (void *cls, char *const *args, const char *cfgfile,
143 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone); 149 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone);
144 ns = GNUNET_NAMESTORE_connect (cfg); 150 ns = GNUNET_NAMESTORE_connect (cfg);
145 if (NULL == ns) 151 if (NULL == ns)
152 {
153 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
154 _("Failed to connect to namestore\n"));
155 return;
156 }
157 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
158 if (NULL == typestring)
159 type = 0;
160 else
161 type = GNUNET_NAMESTORE_typename_to_number (typestring);
162 if (UINT32_MAX == type)
163 {
164 fprintf (stderr, _("Unsupported type `%s'\n"), typestring);
165 GNUNET_SCHEDULER_shutdown ();
166 return;
167 }
168 if (NULL != value)
169 {
170 switch (type)
146 { 171 {
147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 172 case 0:
148 _("Failed to connect to namestore\n")); 173 fprintf (stderr, _("Need a record type to interpret value `%s'\n"), value);
174 GNUNET_SCHEDULER_shutdown ();
175 break;
176 case GNUNET_DNSPARSER_TYPE_A:
177 if (1 != inet_pton (AF_INET, value, &value_a))
178 {
179 fprintf (stderr, _("Value `%s' invalid for record type `%s'\n"),
180 value,
181 typestring);
182 GNUNET_SCHEDULER_shutdown ();
183 return;
184 }
185 data = &value_a;
186 data_size = sizeof (value_a);
187 break;
188 case GNUNET_DNSPARSER_TYPE_NS:
189 data = value;
190 data_size = strlen (value);
191 break;
192 case GNUNET_DNSPARSER_TYPE_CNAME:
193 data = value;
194 data_size = strlen (value);
195 break;
196 case GNUNET_DNSPARSER_TYPE_SOA:
197 fprintf (stderr, _("Record type `%s' not implemented yet\n"), typestring);
198 GNUNET_SCHEDULER_shutdown ();
199 return;
200 case GNUNET_DNSPARSER_TYPE_PTR:
201 fprintf (stderr, _("Record type `%s' not implemented yet\n"), typestring);
202 GNUNET_SCHEDULER_shutdown ();
203 return;
204 case GNUNET_DNSPARSER_TYPE_MX:
205 fprintf (stderr, _("Record type `%s' not implemented yet\n"), typestring);
206 GNUNET_SCHEDULER_shutdown ();
207 return;
208 case GNUNET_DNSPARSER_TYPE_TXT:
209 data = value;
210 data_size = strlen (value);
211 break;
212 case GNUNET_DNSPARSER_TYPE_AAAA:
213 if (1 != inet_pton (AF_INET6, value, &value_aaaa))
214 {
215 fprintf (stderr, _("Value `%s' invalid for record type `%s'\n"),
216 value,
217 typestring);
218 GNUNET_SCHEDULER_shutdown ();
219 return;
220 }
221 data = &value_aaaa;
222 data_size = sizeof (value_aaaa);
223 break;
224 case GNUNET_GNS_TYPE_PKEY:
225 fprintf (stderr, _("Record type `%s' not implemented yet\n"), typestring);
226 GNUNET_SCHEDULER_shutdown ();
149 return; 227 return;
228 case GNUNET_GNS_TYPE_PSEU:
229 data = value;
230 data_size = strlen (value);
231 break;
232 default:
233 GNUNET_assert (0);
150 } 234 }
151 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 235 }
236
237
152} 238}
153 239
154 240