aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-24 10:23:08 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-24 10:23:08 +0000
commit309372ff522a9bb0bf5437c760f50296586c5922 (patch)
tree772a0dcd1ec879da8486c2e4a56ca1756f048be7 /src/gns
parent38be3ab6333e09e5689b4626bf9caa93bd1bbfba (diff)
downloadgnunet-309372ff522a9bb0bf5437c760f50296586c5922.tar.gz
gnunet-309372ff522a9bb0bf5437c760f50296586c5922.zip
-towards translating .+ names in GNS records
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 3cb05a371..22ef0deb3 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1138,9 +1138,13 @@ handle_gns_resolution_result (void *cls,
1138 const char *vname; 1138 const char *vname;
1139 struct GNUNET_HashCode vhash; 1139 struct GNUNET_HashCode vhash;
1140 int af; 1140 int af;
1141 char **scratch; 1141 char scratch[UINT16_MAX];
1142 unsigned int scratch_len; 1142 size_t scratch_off;
1143 1143 size_t scratch_start;
1144 size_t off;
1145 struct GNUNET_NAMESTORE_RecordData rd_new[rd_count];
1146 unsigned int rd_off;
1147
1144 if (0 == rh->name_resolution_pos) 1148 if (0 == rh->name_resolution_pos)
1145 { 1149 {
1146 /* top-level match, are we done yet? */ 1150 /* top-level match, are we done yet? */
@@ -1210,20 +1214,52 @@ handle_gns_resolution_result (void *cls,
1210 } 1214 }
1211 /* convert relative names in record values to absolute names, 1215 /* convert relative names in record values to absolute names,
1212 using 'scratch' array for memory allocations */ 1216 using 'scratch' array for memory allocations */
1213 scratch = NULL; 1217 scratch_off = 0;
1214 scratch_len = 0; 1218 rd_off = 0;
1215 for (i=0;i<rd_count;i++) 1219 for (i=0;i<rd_count;i++)
1216 { 1220 {
1217 /* Strategy: dnsparser should expose API to make it easier 1221 rd_new[rd_off] = rd[i];
1218 for us to parse all of these binary record values individually; 1222 /* Check if the embedded name(s) end in "+", and if so,
1219 then, we check if the embedded name(s) end in "+", and if so,
1220 replace the "+" with the zone at "ac_tail", changing the name 1223 replace the "+" with the zone at "ac_tail", changing the name
1221 to a ".zkey". The name is allocated on the 'scratch' array, 1224 to a ".zkey". The name is allocated on the 'scratch' array,
1222 so we can free it afterwards. */ 1225 so we can free it afterwards. */
1223 switch (rd[i].record_type) 1226 switch (rd[i].record_type)
1224 { 1227 {
1225 case GNUNET_DNSPARSER_TYPE_CNAME: 1228 case GNUNET_DNSPARSER_TYPE_CNAME:
1226 GNUNET_break (0); // FIXME: not implemented 1229 {
1230 char *cname;
1231
1232 off = 0;
1233 cname = GNUNET_DNSPARSER_parse_name (rd[i].data,
1234 rd[i].data_size,
1235 &off);
1236 if ( (NULL == cname) ||
1237 (off != rd[i].data_size) )
1238 {
1239 GNUNET_break_op (0); /* record not well-formed */
1240 }
1241 else
1242 {
1243 // FIXME: do 'cname' transformation here!
1244 // cname = translate_dot_plus (rh, cname);
1245 scratch_start = scratch_off;
1246 if (GNUNET_OK !=
1247 GNUNET_DNSPARSER_builder_add_name (scratch,
1248 sizeof (scratch),
1249 &scratch_off,
1250 cname))
1251 {
1252 GNUNET_break (0);
1253 }
1254 else
1255 {
1256 rd_new[rd_off].data = &scratch[scratch_start];
1257 rd_new[rd_off].data_size = scratch_off - scratch_start;
1258 rd_off++;
1259 }
1260 GNUNET_free (cname);
1261 }
1262 }
1227 break; 1263 break;
1228 case GNUNET_DNSPARSER_TYPE_SOA: 1264 case GNUNET_DNSPARSER_TYPE_SOA:
1229 GNUNET_break (0); // FIXME: not implemented 1265 GNUNET_break (0); // FIXME: not implemented
@@ -1240,13 +1276,8 @@ handle_gns_resolution_result (void *cls,
1240 } 1276 }
1241 1277
1242 /* yes, we are done, return result */ 1278 /* yes, we are done, return result */
1243 rh->proc (rh->proc_cls, rd_count, rd); 1279 rh->proc (rh->proc_cls, rd_off, rd_new);
1244 GNS_resolver_lookup_cancel (rh); 1280 GNS_resolver_lookup_cancel (rh);
1245 for (i=0;i<scratch_len;i++)
1246 GNUNET_free (scratch[i]);
1247 GNUNET_array_grow (scratch,
1248 scratch_len,
1249 0);
1250 return; 1281 return;
1251 } 1282 }
1252 /* need to recurse, check if we can */ 1283 /* need to recurse, check if we can */