aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-19 21:59:30 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-19 21:59:30 +0000
commit5c9791cbb128494bcaf1544c3e89195e4007207c (patch)
tree86c9ba0a140c34efbe7462cfa25a167a84f0a211
parent0970f98adb25e2ec8076ddf61b3437b5003af0b2 (diff)
downloadgnunet-5c9791cbb128494bcaf1544c3e89195e4007207c.tar.gz
gnunet-5c9791cbb128494bcaf1544c3e89195e4007207c.zip
-towards enabling relative expiration times in namestore
-rw-r--r--src/gns/gnunet-gns-fcfsd.c2
-rw-r--r--src/gns/gnunet-service-gns.c11
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c21
-rw-r--r--src/gns/gnunet-service-gns_resolver.c31
-rw-r--r--src/gns/plugin_block_gns.c16
-rw-r--r--src/include/gnunet_namestore_service.h39
-rw-r--r--src/namestore/gnunet-namestore.c45
-rw-r--r--src/namestore/gnunet-service-namestore.c79
-rw-r--r--src/namestore/namestore_common.c72
9 files changed, 208 insertions, 108 deletions
diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c
index b919b4fed..6802d6685 100644
--- a/src/gns/gnunet-gns-fcfsd.c
+++ b/src/gns/gnunet-gns-fcfsd.c
@@ -386,7 +386,7 @@ zone_to_name_cb (void *cls,
386 &pub)); 386 &pub));
387 r.data = &pub; 387 r.data = &pub;
388 r.data_size = sizeof (pub); 388 r.data_size = sizeof (pub);
389 r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; 389 r.expiration_time = UINT64_MAX;
390 r.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 390 r.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
391 r.flags = GNUNET_NAMESTORE_RF_AUTHORITY; 391 r.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
392 request->qe = GNUNET_NAMESTORE_record_create (ns, 392 request->qe = GNUNET_NAMESTORE_record_create (ns,
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 63b180b4b..f63e22e25 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -500,13 +500,16 @@ process_shorten_zone_shorten (void *cls,
500{ 500{
501 struct ClientShortenHandle *csh = cls; 501 struct ClientShortenHandle *csh = cls;
502 struct GNUNET_TIME_Relative remaining_time; 502 struct GNUNET_TIME_Relative remaining_time;
503 struct GNUNET_TIME_Absolute et;
503 504
504 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 505 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
505 506
506 if ((rd_count == 1) && 507 if ((rd_count == 1) &&
507 (remaining_time.rel_value != 0)) 508 (remaining_time.rel_value != 0))
508 { 509 {
509 remaining_time = GNUNET_TIME_absolute_get_remaining (rd->expiration); 510 GNUNET_break (0 == (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
511 et.abs_value = rd->expiration_time;
512 remaining_time = GNUNET_TIME_absolute_get_remaining (et);
510 if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) && 513 if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) &&
511 (remaining_time.rel_value != 0)) 514 (remaining_time.rel_value != 0))
512 { 515 {
@@ -523,6 +526,7 @@ process_shorten_zone_shorten (void *cls,
523 526
524} 527}
525 528
529
526static void 530static void
527process_private_zone_shorten (void *cls, 531process_private_zone_shorten (void *cls,
528 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 532 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
@@ -534,13 +538,16 @@ process_private_zone_shorten (void *cls,
534{ 538{
535 struct GNUNET_TIME_Relative remaining_time; 539 struct GNUNET_TIME_Relative remaining_time;
536 struct ClientShortenHandle *csh = cls; 540 struct ClientShortenHandle *csh = cls;
541 struct GNUNET_TIME_Absolute et;
537 542
538 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 543 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
539 544
540 if ((rd_count == 1) && 545 if ((rd_count == 1) &&
541 (remaining_time.rel_value != 0)) 546 (remaining_time.rel_value != 0))
542 { 547 {
543 remaining_time = GNUNET_TIME_absolute_get_remaining (rd->expiration); 548 GNUNET_break (0 == (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
549 et.abs_value = rd->expiration_time;
550 remaining_time = GNUNET_TIME_absolute_get_remaining (et);
544 if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) && 551 if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) &&
545 (remaining_time.rel_value != 0)) 552 (remaining_time.rel_value != 0))
546 { 553 {
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 0e44755ed..5956e5223 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -40,13 +40,19 @@
40 */ 40 */
41struct InterceptLookupHandle 41struct InterceptLookupHandle
42{ 42{
43 /* the request handle to reply to */ 43 /**
44 * the request handle to reply to
45 */
44 struct GNUNET_DNS_RequestHandle *request_handle; 46 struct GNUNET_DNS_RequestHandle *request_handle;
45 47
46 /* the dns parser packet received */ 48 /**
49 * the dns parser packet received
50 */
47 struct GNUNET_DNSPARSER_Packet *packet; 51 struct GNUNET_DNSPARSER_Packet *packet;
48 52
49 /* the query parsed from the packet */ 53 /**
54 * the query parsed from the packet
55 */
50 struct GNUNET_DNSPARSER_Query *query; 56 struct GNUNET_DNSPARSER_Query *query;
51}; 57};
52 58
@@ -71,6 +77,7 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
71 */ 77 */
72static struct GNUNET_TIME_Relative default_lookup_timeout; 78static struct GNUNET_TIME_Relative default_lookup_timeout;
73 79
80
74/** 81/**
75 * Reply to dns request with the result from our lookup. 82 * Reply to dns request with the result from our lookup.
76 * 83 *
@@ -82,7 +89,7 @@ static void
82reply_to_dns(void* cls, uint32_t rd_count, 89reply_to_dns(void* cls, uint32_t rd_count,
83 const struct GNUNET_NAMESTORE_RecordData *rd) 90 const struct GNUNET_NAMESTORE_RecordData *rd)
84{ 91{
85 int i; 92 uint32_t i;
86 size_t len; 93 size_t len;
87 int ret; 94 int ret;
88 char *buf; 95 char *buf;
@@ -137,7 +144,8 @@ reply_to_dns(void* cls, uint32_t rd_count,
137 answer_records[i].data.raw.data_len = rd[i].data_size; 144 answer_records[i].data.raw.data_len = rd[i].data_size;
138 answer_records[i].data.raw.data = (char*)rd[i].data; 145 answer_records[i].data.raw.data = (char*)rd[i].data;
139 } 146 }
140 answer_records[i].expiration_time = rd[i].expiration; 147 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
148 answer_records[i].expiration_time.abs_value = rd[i].expiration_time;
141 answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn 149 answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
142 } 150 }
143 else 151 else
@@ -163,7 +171,8 @@ reply_to_dns(void* cls, uint32_t rd_count,
163 additional_records[i].data.raw.data_len = rd[i].data_size; 171 additional_records[i].data.raw.data_len = rd[i].data_size;
164 additional_records[i].data.raw.data = (char*)rd[i].data; 172 additional_records[i].data.raw.data = (char*)rd[i].data;
165 } 173 }
166 additional_records[i].expiration_time = rd[i].expiration; 174 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
175 additional_records[i].expiration_time.abs_value = rd[i].expiration_time;
167 additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn 176 additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
168 } 177 }
169 } 178 }
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index b6bc5eb1d..8d82fa8ad 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -200,11 +200,11 @@ process_pseu_lookup_ns (void* cls,
200 return; 200 return;
201 } 201 }
202 202
203 /** name is free */ 203 /* name is free */
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
205 "GNS_AUTO_PSEU: Name %s not taken in NS! Adding\n", gph->test_name); 205 "GNS_AUTO_PSEU: Name %s not taken in NS! Adding\n", gph->test_name);
206 206
207 new_pkey.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; 207 new_pkey.expiration_time = UINT64_MAX;
208 new_pkey.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode); 208 new_pkey.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode);
209 new_pkey.data = &gph->ahead->zone; 209 new_pkey.data = &gph->ahead->zone;
210 new_pkey.record_type = GNUNET_GNS_RECORD_PKEY; 210 new_pkey.record_type = GNUNET_GNS_RECORD_PKEY;
@@ -1136,6 +1136,8 @@ process_record_result_ns(void* cls,
1136 struct RecordLookupHandle *rlh; 1136 struct RecordLookupHandle *rlh;
1137 struct GNUNET_TIME_Relative remaining_time; 1137 struct GNUNET_TIME_Relative remaining_time;
1138 struct GNUNET_CRYPTO_ShortHashCode zone; 1138 struct GNUNET_CRYPTO_ShortHashCode zone;
1139 struct GNUNET_TIME_Absolute et;
1140 unsigned int i;
1139 1141
1140 rh = (struct ResolverHandle *) cls; 1142 rh = (struct ResolverHandle *) cls;
1141 rlh = (struct RecordLookupHandle *)rh->proc_cls; 1143 rlh = (struct RecordLookupHandle *)rh->proc_cls;
@@ -1179,14 +1181,11 @@ process_record_result_ns(void* cls,
1179 } 1181 }
1180 else 1182 else
1181 { 1183 {
1182
1183 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1184 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1184 "GNS_PHASE_REC-%d: Processing additional result %s from namestore\n", 1185 "GNS_PHASE_REC-%d: Processing additional result %s from namestore\n",
1185 rh->id, name); 1186 rh->id, name);
1186 int i;
1187 for (i=0; i<rd_count;i++) 1187 for (i=0; i<rd_count;i++)
1188 { 1188 {
1189
1190 if (rd[i].record_type != rlh->record_type) 1189 if (rd[i].record_type != rlh->record_type)
1191 continue; 1190 continue;
1192 1191
@@ -1199,7 +1198,9 @@ process_record_result_ns(void* cls,
1199 continue; 1198 continue;
1200 } 1199 }
1201 1200
1202 if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value 1201 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
1202 et.abs_value = rd[i].expiration_time;
1203 if ((GNUNET_TIME_absolute_get_remaining (et)).rel_value
1203 == 0) 1204 == 0)
1204 { 1205 {
1205 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1206 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -1207,9 +1208,7 @@ process_record_result_ns(void* cls,
1207 rh->id); 1208 rh->id);
1208 continue; 1209 continue;
1209 } 1210 }
1210
1211 rh->answered++; 1211 rh->answered++;
1212
1213 } 1212 }
1214 1213
1215 /** 1214 /**
@@ -1265,7 +1264,7 @@ process_record_result_vpn (void* cls, int af, const void *address)
1265 return; 1264 return;
1266 } 1265 }
1267 rd.record_type = GNUNET_GNS_RECORD_TYPE_A; 1266 rd.record_type = GNUNET_GNS_RECORD_TYPE_A;
1268 rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; 1267 rd.expiration_time = UINT64_MAX; /* FIXME: should probably pick something shorter... */
1269 rd.data = address; 1268 rd.data = address;
1270 rd.data_size = sizeof (struct in_addr); 1269 rd.data_size = sizeof (struct in_addr);
1271 rd.flags = 0; 1270 rd.flags = 0;
@@ -1286,7 +1285,7 @@ process_record_result_vpn (void* cls, int af, const void *address)
1286 return; 1285 return;
1287 } 1286 }
1288 rd.record_type = GNUNET_GNS_RECORD_AAAA; 1287 rd.record_type = GNUNET_GNS_RECORD_AAAA;
1289 rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; 1288 rd.expiration_time = UINT64_MAX; /* FIXME: should probably pick something shorter... */
1290 rd.data = address; 1289 rd.data = address;
1291 rd.data_size = sizeof (struct in6_addr); 1290 rd.data_size = sizeof (struct in6_addr);
1292 rd.flags = 0; 1291 rd.flags = 0;
@@ -1360,6 +1359,7 @@ handle_record_vpn (void* cls, struct ResolverHandle *rh,
1360static void 1359static void
1361send_dns_packet (struct ResolverHandle *rh); 1360send_dns_packet (struct ResolverHandle *rh);
1362 1361
1362
1363static void 1363static void
1364handle_dns_resolver (void *cls, 1364handle_dns_resolver (void *cls,
1365 const struct sockaddr *addr, 1365 const struct sockaddr *addr,
@@ -1395,7 +1395,7 @@ handle_dns_resolver (void *cls,
1395 rd.data = &sai6->sin6_addr; 1395 rd.data = &sai6->sin6_addr;
1396 } 1396 }
1397 1397
1398 rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; 1398 rd.expiration_time = UINT64_MAX; /* FIXME: should probably pick something shorter */
1399 1399
1400 finish_lookup (rh, rlh, 1, &rd); 1400 finish_lookup (rh, rlh, 1, &rd);
1401 free_resolver_handle (rh); 1401 free_resolver_handle (rh);
@@ -1530,7 +1530,7 @@ read_dns_response (void *cls,
1530 rd.data_size = packet->answers[i].data.raw.data_len; 1530 rd.data_size = packet->answers[i].data.raw.data_len;
1531 rd.record_type = packet->answers[i].type; 1531 rd.record_type = packet->answers[i].type;
1532 rd.flags = 0; 1532 rd.flags = 0;
1533 rd.expiration = packet->answers[i].expiration_time; 1533 rd.expiration_time = packet->answers[i].expiration_time.abs_value;
1534 finish_lookup (rh, rlh, 1, &rd); 1534 finish_lookup (rh, rlh, 1, &rd);
1535 GNUNET_NETWORK_socket_close (rh->dns_sock); 1535 GNUNET_NETWORK_socket_close (rh->dns_sock);
1536 GNUNET_DNSPARSER_free_packet (packet); 1536 GNUNET_DNSPARSER_free_packet (packet);
@@ -2956,6 +2956,8 @@ process_delegation_result_ns (void* cls,
2956 struct GNUNET_TIME_Relative remaining_time; 2956 struct GNUNET_TIME_Relative remaining_time;
2957 struct GNUNET_CRYPTO_ShortHashCode zone; 2957 struct GNUNET_CRYPTO_ShortHashCode zone;
2958 char new_name[MAX_DNS_NAME_LENGTH]; 2958 char new_name[MAX_DNS_NAME_LENGTH];
2959 unsigned int i;
2960 struct GNUNET_TIME_Absolute et;
2959 2961
2960 rh = (struct ResolverHandle *)cls; 2962 rh = (struct ResolverHandle *)cls;
2961 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2963 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -3032,7 +3034,6 @@ process_delegation_result_ns (void* cls,
3032 * move on with query 3034 * move on with query
3033 * Note only 1 pkey should have been returned.. anything else would be strange 3035 * Note only 1 pkey should have been returned.. anything else would be strange
3034 */ 3036 */
3035 int i;
3036 for (i=0; i<rd_count;i++) 3037 for (i=0; i<rd_count;i++)
3037 { 3038 {
3038 3039
@@ -3096,7 +3097,9 @@ process_delegation_result_ns (void* cls,
3096 continue; 3097 continue;
3097 } 3098 }
3098 3099
3099 if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value 3100 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
3101 et.abs_value = rd[i].expiration_time;
3102 if ((GNUNET_TIME_absolute_get_remaining (et)).rel_value
3100 == 0) 3103 == 0)
3101 { 3104 {
3102 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 3105 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index ba1fd56e1..f033811ee 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -135,7 +135,8 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
135 { 135 {
136 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 136 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
137 unsigned int i; 137 unsigned int i;
138 struct GNUNET_TIME_Absolute exp = GNUNET_TIME_UNIT_FOREVER_ABS; 138 uint64_t exp = UINT64_MAX;
139 struct GNUNET_TIME_Absolute et;
139 140
140 if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len, 141 if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len,
141 rd_data, 142 rd_data,
@@ -154,26 +155,25 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
154 record_xquery = ntohl(*((uint32_t*)xquery)); 155 record_xquery = ntohl(*((uint32_t*)xquery));
155 156
156 for (i=0; i<rd_count; i++) 157 for (i=0; i<rd_count; i++)
157 { 158 {
158 159 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
159 exp = GNUNET_TIME_absolute_min (exp, rd[i].expiration); 160 exp = GNUNET_MIN (exp, rd[i].expiration_time);
160
161 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 161 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
162 "Got record of size %d\n", rd[i].data_size); 162 "Got record of size %d\n", rd[i].data_size);
163
164 if ((record_xquery != 0) 163 if ((record_xquery != 0)
165 && (rd[i].record_type == record_xquery)) 164 && (rd[i].record_type == record_xquery))
166 { 165 {
167 record_match++; 166 record_match++;
168 } 167 }
169 } 168 }
169 et.abs_value = exp;
170 170
171 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 171 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
172 "Verifying signature of %d records for name %s\n", 172 "Verifying signature of %d records for name %s\n",
173 rd_count, name); 173 rd_count, name);
174 174
175 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, 175 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
176 exp, 176 et,
177 name, 177 name,
178 rd_count, 178 rd_count,
179 rd, 179 rd,
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index 05e4fbf06..f8a830dd7 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -25,8 +25,6 @@
25 * 25 *
26 * Other functions we might want: 26 * Other functions we might want:
27 * - enumerate all known zones 27 * - enumerate all known zones
28 * - convenience function to gather record and the full affilliated stree
29 * in one shot
30 */ 28 */
31 29
32#ifndef GNUNET_NAMESTORE_SERVICE_H 30#ifndef GNUNET_NAMESTORE_SERVICE_H
@@ -159,7 +157,13 @@ enum GNUNET_NAMESTORE_RecordFlags
159 * This record was added by the system 157 * This record was added by the system
160 * and is pending user confimation 158 * and is pending user confimation
161 */ 159 */
162 GNUNET_NAMESTORE_RF_PENDING = 4 160 GNUNET_NAMESTORE_RF_PENDING = 4,
161
162 /**
163 * This expiration time of the record is a relative
164 * time (not an absolute time).
165 */
166 GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION = 8
163 167
164}; 168};
165 169
@@ -176,9 +180,10 @@ struct GNUNET_NAMESTORE_RecordData
176 const void *data; 180 const void *data;
177 181
178 /** 182 /**
179 * Expiration time for the DNS record. 183 * Expiration time for the DNS record. Can be relative
184 * or absolute, depending on 'flags'.
180 */ 185 */
181 struct GNUNET_TIME_Absolute expiration; 186 uint64_t expiration_time;
182 187
183 /** 188 /**
184 * Number of bytes in 'data'. 189 * Number of bytes in 'data'.
@@ -232,7 +237,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
232 * to validate signatures received from the network. 237 * to validate signatures received from the network.
233 * 238 *
234 * @param public_key public key of the zone 239 * @param public_key public key of the zone
235 * @param expire block expiration 240 * @param freshness time set for block expiration
236 * @param name name that is being mapped (at most 255 characters long) 241 * @param name name that is being mapped (at most 255 characters long)
237 * @param rd_count number of entries in 'rd' array 242 * @param rd_count number of entries in 'rd' array
238 * @param rd array of records with data to store 243 * @param rd array of records with data to store
@@ -299,7 +304,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
299 * 304 *
300 * @param cls closure 305 * @param cls closure
301 * @param zone_key public key of the zone 306 * @param zone_key public key of the zone
302 * @param expire when does the corresponding block in the DHT expire (until 307 * @param freshness when does the corresponding block in the DHT expire (until
303 * when should we never do a DHT lookup for the same name again)?; 308 * when should we never do a DHT lookup for the same name again)?;
304 * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, 309 * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore,
305 * or the expiration time of the block in the namestore (even if there are zero 310 * or the expiration time of the block in the namestore (even if there are zero
@@ -364,9 +369,23 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
364 369
365/** 370/**
366 * Starts a new zone iteration (used to periodically PUT all of our 371 * Starts a new zone iteration (used to periodically PUT all of our
367 * records into our DHT). "proc" will be called once 372 * records into our DHT). "proc" will be called once immediately, and
368 * immediately, and then again after 373 * then again after "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
369 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked. 374 *
375 * By specifying a 'zone' of NULL and setting 'GNUNET_NAMESTORE_RF_AUTHORITY'
376 * in 'must_have_flags', we can iterate over all records for which we are
377 * the authority. In this case, the 'GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION'
378 * bit in 'must_have_flags' has a special meaning:
379 *
380 * 0) If the bit is clear, all relative expriation times are converted to
381 * absolute expiration times. This is useful for performing DHT PUT
382 * operations (and zone transfers) of our zone.
383 * 1) if it is set, it means that relative expiration times should be
384 * preserved when returned (this is useful for the zone editor user
385 * interface).
386 *
387 * Note that not all queries against this interface are equally performant
388 * as for some combinations no efficient index may exist.
370 * 389 *
371 * @param h handle to the namestore 390 * @param h handle to the namestore
372 * @param zone zone to access, NULL for all zones 391 * @param zone zone to access, NULL for all zones
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 624981201..aa3af1a73 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -32,6 +32,7 @@
32#include <gnunet_dnsparser_lib.h> 32#include <gnunet_dnsparser_lib.h>
33#include <gnunet_namestore_service.h> 33#include <gnunet_namestore_service.h>
34 34
35
35/** 36/**
36 * Handle to the namestore. 37 * Handle to the namestore.
37 */ 38 */
@@ -264,7 +265,9 @@ run (void *cls, char *const *args, const char *cfgfile,
264 uint32_t type; 265 uint32_t type;
265 void *data = NULL; 266 void *data = NULL;
266 size_t data_size = 0; 267 size_t data_size = 0;
267 struct GNUNET_TIME_Relative etime; 268 struct GNUNET_TIME_Relative etime_rel;
269 struct GNUNET_TIME_Absolute etime_abs;
270 int etime_is_rel = GNUNET_SYSERR;
268 struct GNUNET_NAMESTORE_RecordData rd; 271 struct GNUNET_NAMESTORE_RecordData rd;
269 272
270 if (NULL == keyfile) 273 if (NULL == keyfile)
@@ -356,11 +359,22 @@ run (void *cls, char *const *args, const char *cfgfile,
356 { 359 {
357 if (0 == strcmp (expirationstring, "never")) 360 if (0 == strcmp (expirationstring, "never"))
358 { 361 {
359 etime = GNUNET_TIME_UNIT_FOREVER_REL; 362 etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS;
363 etime_is_rel = GNUNET_NO;
364 }
365 else if (GNUNET_OK ==
366 GNUNET_STRINGS_fancy_time_to_relative (expirationstring,
367 &etime_rel))
368 {
369 etime_is_rel = GNUNET_YES;
360 } 370 }
361 else if (GNUNET_OK != 371 else if (GNUNET_OK ==
362 GNUNET_STRINGS_fancy_time_to_relative (expirationstring, 372 GNUNET_STRINGS_fancy_time_to_absolute (expirationstring,
363 &etime)) 373 &etime_abs))
374 {
375 etime_is_rel = GNUNET_NO;
376 }
377 else
364 { 378 {
365 fprintf (stderr, 379 fprintf (stderr,
366 _("Invalid time format `%s'\n"), 380 _("Invalid time format `%s'\n"),
@@ -368,7 +382,8 @@ run (void *cls, char *const *args, const char *cfgfile,
368 GNUNET_SCHEDULER_shutdown (); 382 GNUNET_SCHEDULER_shutdown ();
369 return; 383 return;
370 } 384 }
371 } else if (add) 385 }
386 else if (add)
372 { 387 {
373 fprintf (stderr, 388 fprintf (stderr,
374 _("Missing option `%s' for operation `%s'\n"), 389 _("Missing option `%s' for operation `%s'\n"),
@@ -389,7 +404,21 @@ run (void *cls, char *const *args, const char *cfgfile,
389 rd.data = data; 404 rd.data = data;
390 rd.data_size = data_size; 405 rd.data_size = data_size;
391 rd.record_type = type; 406 rd.record_type = type;
392 rd.expiration = GNUNET_TIME_relative_to_absolute (etime); 407 if (GNUNET_YES == etime_is_rel)
408 {
409 rd.expiration_time = etime_rel.rel_value;
410 rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
411 }
412 else if (GNUNET_NO == etime_is_rel)
413 rd.expiration_time = etime_abs.abs_value;
414 else
415 {
416 fprintf (stderr,
417 _("No valid expiration time for operation `%s'\n"),
418 _("add"));
419 GNUNET_SCHEDULER_shutdown ();
420 return;
421 }
393 if (1 != nonauthority) 422 if (1 != nonauthority)
394 rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY; 423 rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
395 if (1 != public) 424 if (1 != public)
@@ -414,7 +443,7 @@ run (void *cls, char *const *args, const char *cfgfile,
414 rd.data = data; 443 rd.data = data;
415 rd.data_size = data_size; 444 rd.data_size = data_size;
416 rd.record_type = type; 445 rd.record_type = type;
417 rd.expiration.abs_value = 0; 446 rd.expiration_time = 0;
418 rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; 447 rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
419 del_qe = GNUNET_NAMESTORE_record_remove (ns, 448 del_qe = GNUNET_NAMESTORE_record_remove (ns,
420 zone_pkey, 449 zone_pkey,
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 7483c0a89..e67ffaa65 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -228,11 +228,24 @@ get_block_expiration_time (unsigned int rd_count, const struct GNUNET_NAMESTORE_
228{ 228{
229 unsigned int c; 229 unsigned int c;
230 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_UNIT_FOREVER_ABS; 230 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_UNIT_FOREVER_ABS;
231 struct GNUNET_TIME_Absolute at;
232 struct GNUNET_TIME_Relative rt;
231 233
232 if (NULL == rd) 234 if (NULL == rd)
233 return GNUNET_TIME_UNIT_ZERO_ABS; 235 return GNUNET_TIME_UNIT_ZERO_ABS;
234 for (c = 0; c < rd_count; c++) 236 for (c = 0; c < rd_count; c++)
235 expire = GNUNET_TIME_absolute_min (rd[c].expiration, expire); 237 {
238 if (0 != (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
239 {
240 rt.rel_value = rd[c].expiration_time;
241 at = GNUNET_TIME_relative_to_absolute (rt);
242 }
243 else
244 {
245 at.abs_value = rd[c].expiration_time;
246 }
247 expire = GNUNET_TIME_absolute_min (at, expire);
248 }
236 return expire; 249 return expire;
237} 250}
238 251
@@ -725,12 +738,12 @@ struct CreateRecordContext
725 738
726static void 739static void
727handle_create_record_it (void *cls, 740handle_create_record_it (void *cls,
728 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey, 741 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey,
729 struct GNUNET_TIME_Absolute expire, 742 struct GNUNET_TIME_Absolute expire,
730 const char *name, 743 const char *name,
731 unsigned int rd_count, 744 unsigned int rd_count,
732 const struct GNUNET_NAMESTORE_RecordData *rd, 745 const struct GNUNET_NAMESTORE_RecordData *rd,
733 const struct GNUNET_CRYPTO_RsaSignature *signature) 746 const struct GNUNET_CRYPTO_RsaSignature *signature)
734{ 747{
735 struct CreateRecordContext * crc = cls; 748 struct CreateRecordContext * crc = cls;
736 struct GNUNET_NAMESTORE_RecordData *rd_new = NULL; 749 struct GNUNET_NAMESTORE_RecordData *rd_new = NULL;
@@ -745,37 +758,43 @@ handle_create_record_it (void *cls,
745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u existing records for `%s'\n", rd_count, crc->name); 758 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u existing records for `%s'\n", rd_count, crc->name);
746 for (c = 0; c < rd_count; c++) 759 for (c = 0; c < rd_count; c++)
747 { 760 {
748 if ((crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PKEY) && (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PKEY)) 761 if ( (crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PKEY) &&
762 (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PKEY))
749 { 763 {
750 /* Update unique PKEY */ 764 /* Update unique PKEY */
751 exist = c; 765 exist = c;
752 update = GNUNET_YES; 766 update = GNUNET_YES;
753 break; 767 break;
754 } 768 }
755 else if ((crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PSEU) && (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PSEU)) 769 if ( (crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PSEU) &&
770 (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PSEU))
756 { 771 {
757 /* Update unique PSEU */ 772 /* Update unique PSEU */
758 exist = c; 773 exist = c;
759 update = GNUNET_YES; 774 update = GNUNET_YES;
760 break; 775 break;
761 } 776 }
762 else if ((crc->rd->record_type == rd[c].record_type) && 777 if ((crc->rd->record_type == rd[c].record_type) &&
763 (crc->rd->data_size == rd[c].data_size) && 778 (crc->rd->data_size == rd[c].data_size) &&
764 (0 == memcmp (crc->rd->data, rd[c].data, rd[c].data_size))) 779 (0 == memcmp (crc->rd->data, rd[c].data, rd[c].data_size)))
765 { 780 {
766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing records for `%s' to update expiration date!\n", crc->name); 781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
782 "Found existing records for `%s' to update expiration date!\n",
783 crc->name);
767 exist = c; 784 exist = c;
768 if (crc->rd->expiration.abs_value != rd[c].expiration.abs_value) 785 if ( (crc->rd->expiration_time != rd[c].expiration_time) &&
786 ((crc->rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)
787 == (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION) ) )
769 update = GNUNET_YES; 788 update = GNUNET_YES;
770 break; 789 break;
771 } 790 }
772 } 791 }
773 792
774 if (exist == GNUNET_SYSERR) 793 if (exist == GNUNET_SYSERR)
775 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New record does not exist for name `%s'!\n", crc->name);
776
777 if (exist == GNUNET_SYSERR)
778 { 794 {
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
796 "No existing record for name `%s'!\n",
797 crc->name);
779 rd_new = GNUNET_malloc ((rd_count+1) * sizeof (struct GNUNET_NAMESTORE_RecordData)); 798 rd_new = GNUNET_malloc ((rd_count+1) * sizeof (struct GNUNET_NAMESTORE_RecordData));
780 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData)); 799 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData));
781 rd_count_new = rd_count + 1; 800 rd_count_new = rd_count + 1;
@@ -784,24 +803,34 @@ handle_create_record_it (void *cls,
784 else if (update == GNUNET_NO) 803 else if (update == GNUNET_NO)
785 { 804 {
786 /* Exact same record already exists */ 805 /* Exact same record already exists */
787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No update for %s' record required!\n", crc->name); 806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
807 "Matching record for %s' exists, no change required!\n",
808 crc->name);
788 res = GNUNET_NO; 809 res = GNUNET_NO;
789 goto end; 810 goto end;
790 } 811 }
791 else if (update == GNUNET_YES) 812 else
792 { 813 {
793 /* Update record */ 814 /* Update record */
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating existing records for `%s'!\n", crc->name); 815 GNUNET_assert (GNUNET_YES == update);
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Updating existing records for `%s'!\n",
818 crc->name);
795 rd_new = GNUNET_malloc ((rd_count) * sizeof (struct GNUNET_NAMESTORE_RecordData)); 819 rd_new = GNUNET_malloc ((rd_count) * sizeof (struct GNUNET_NAMESTORE_RecordData));
796 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData)); 820 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData));
797 rd_count_new = rd_count; 821 rd_count_new = rd_count;
798 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration from %llu to %llu!\n", rd_new[exist].expiration.abs_value, crc->rd->expiration.abs_value); 822 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
823 (0 == (crc->rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
824 ? "Updating absolute expiration from %llu to %llu!\n"
825 : "Updating relative expiration from %llu to %llu!\n",
826 rd_new[exist].expiration_time, crc->rd->expiration_time);
799 rd_new[exist] = *(crc->rd); 827 rd_new[exist] = *(crc->rd);
800 } 828 }
801 829
802 block_expiration = GNUNET_TIME_absolute_max(crc->expire, expire); 830 block_expiration = GNUNET_TIME_absolute_max(crc->expire, expire);
803 if (block_expiration.abs_value != expire.abs_value) 831 if (block_expiration.abs_value != expire.abs_value)
804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updated block expiration time\n"); 832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
833 "Updated block expiration time\n");
805 834
806 memset (&dummy_signature, '\0', sizeof (dummy_signature)); 835 memset (&dummy_signature, '\0', sizeof (dummy_signature));
807 836
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c
index 2b34a84e7..a56192c5a 100644
--- a/src/namestore/namestore_common.c
+++ b/src/namestore/namestore_common.c
@@ -45,9 +45,10 @@ struct NetworkRecord
45{ 45{
46 46
47 /** 47 /**
48 * Expiration time for the DNS record. 48 * Expiration time for the DNS record; relative or absolute depends
49 * on 'flags', network byte order.
49 */ 50 */
50 struct GNUNET_TIME_AbsoluteNBO expiration; 51 uint64_t expiration_time;
51 52
52 /** 53 /**
53 * Number of bytes in 'data', network byte order. 54 * Number of bytes in 'data', network byte order.
@@ -135,7 +136,7 @@ GNUNET_NAMESTORE_records_serialize (unsigned int rd_count,
135 off = 0; 136 off = 0;
136 for (i=0;i<rd_count;i++) 137 for (i=0;i<rd_count;i++)
137 { 138 {
138 rec.expiration = GNUNET_TIME_absolute_hton (rd[i].expiration); 139 rec.expiration_time = GNUNET_htonll (rd[i].expiration_time);
139 rec.data_size = htonl ((uint32_t) rd[i].data_size); 140 rec.data_size = htonl ((uint32_t) rd[i].data_size);
140 rec.record_type = htonl (rd[i].record_type); 141 rec.record_type = htonl (rd[i].record_type);
141 rec.flags = htonl (rd[i].flags); 142 rec.flags = htonl (rd[i].flags);
@@ -151,25 +152,28 @@ GNUNET_NAMESTORE_records_serialize (unsigned int rd_count,
151 return off; 152 return off;
152} 153}
153 154
155
154/** 156/**
155 * Compares if two records are equal 157 * Compares if two records are equal (ignoring flags such
158 * as authority, private and pending, but not relative vs.
159 * absolute expiration time).
156 * 160 *
157 * @param a record 161 * @param a record
158 * @param b record 162 * @param b record
159 * 163 * @return GNUNET_YES if the records are equal or GNUNET_NO if they are not
160 * @return GNUNET_YES or GNUNET_NO
161 */ 164 */
162int 165int
163GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, 166GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
164 const struct GNUNET_NAMESTORE_RecordData *b) 167 const struct GNUNET_NAMESTORE_RecordData *b)
165{ 168{
166 if ((a->record_type == b->record_type) && 169 if ((a->record_type == b->record_type) &&
167 (a->expiration.abs_value == b->expiration.abs_value) && 170 (a->expiration_time == b->expiration_time) &&
171 ((a->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)
172 == (b->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION) ) &&
168 (a->data_size == b->data_size) && 173 (a->data_size == b->data_size) &&
169 (0 == memcmp (a->data, b->data, a->data_size))) 174 (0 == memcmp (a->data, b->data, a->data_size)))
170 return GNUNET_YES; 175 return GNUNET_YES;
171 else 176 return GNUNET_NO;
172 return GNUNET_NO;
173} 177}
174 178
175 179
@@ -199,7 +203,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
199 if (off + sizeof (rec) > len) 203 if (off + sizeof (rec) > len)
200 return GNUNET_SYSERR; 204 return GNUNET_SYSERR;
201 memcpy (&rec, &src[off], sizeof (rec)); 205 memcpy (&rec, &src[off], sizeof (rec));
202 dest[i].expiration = GNUNET_TIME_absolute_ntoh (rec.expiration); 206 dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time);
203 dest[i].data_size = ntohl ((uint32_t) rec.data_size); 207 dest[i].data_size = ntohl ((uint32_t) rec.data_size);
204 dest[i].record_type = ntohl (rec.record_type); 208 dest[i].record_type = ntohl (rec.record_type);
205 dest[i].flags = ntohl (rec.flags); 209 dest[i].flags = ntohl (rec.flags);
@@ -213,6 +217,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
213 return GNUNET_OK; 217 return GNUNET_OK;
214} 218}
215 219
220
216/** 221/**
217 * Sign name and records 222 * Sign name and records
218 * 223 *
@@ -226,46 +231,45 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
226 */ 231 */
227struct GNUNET_CRYPTO_RsaSignature * 232struct GNUNET_CRYPTO_RsaSignature *
228GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 233GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
229 struct GNUNET_TIME_Absolute expire, 234 struct GNUNET_TIME_Absolute expire,
230 const char *name, 235 const char *name,
231 const struct GNUNET_NAMESTORE_RecordData *rd, 236 const struct GNUNET_NAMESTORE_RecordData *rd,
232 unsigned int rd_count) 237 unsigned int rd_count)
233{ 238{
234 struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); 239 struct GNUNET_CRYPTO_RsaSignature *sig;
235 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose; 240 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
236 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire); 241 struct GNUNET_TIME_AbsoluteNBO expire_nbo;
237 size_t rd_ser_len; 242 size_t rd_ser_len;
238 size_t name_len; 243 size_t name_len;
239
240 struct GNUNET_TIME_AbsoluteNBO *expire_tmp; 244 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
241 char * name_tmp; 245 char * name_tmp;
242 char * rd_tmp; 246 char * rd_tmp;
243 int res; 247 int res;
244 248
245 if (name == NULL) 249 if (NULL == name)
246 { 250 {
247 GNUNET_break (0); 251 GNUNET_break (0);
248 GNUNET_free (sig);
249 return NULL; 252 return NULL;
250 } 253 }
254 sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature));
251 name_len = strlen (name) + 1; 255 name_len = strlen (name) + 1;
252 256 expire_nbo = GNUNET_TIME_absolute_hton(expire);
253 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd); 257 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
254 char rd_ser[rd_ser_len]; 258 {
255 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser); 259 char rd_ser[rd_ser_len];
256 260
257 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len); 261 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
258 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len); 262 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
259 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); 263 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
260 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1]; 264 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
261 name_tmp = (char *) &expire_tmp[1]; 265 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
262 rd_tmp = &name_tmp[name_len]; 266 name_tmp = (char *) &expire_tmp[1];
263 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO)); 267 rd_tmp = &name_tmp[name_len];
264 memcpy (name_tmp, name, name_len); 268 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
265 memcpy (rd_tmp, rd_ser, rd_ser_len); 269 memcpy (name_tmp, name, name_len);
266 270 memcpy (rd_tmp, rd_ser, rd_ser_len);
271 }
267 res = GNUNET_CRYPTO_rsa_sign (key, sig_purpose, sig); 272 res = GNUNET_CRYPTO_rsa_sign (key, sig_purpose, sig);
268
269 GNUNET_free (sig_purpose); 273 GNUNET_free (sig_purpose);
270 274
271 if (GNUNET_OK != res) 275 if (GNUNET_OK != res)