aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 19:28:18 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 19:28:18 +0000
commitc0a40a3ee5cc8ce715f53a46cc9d734d3a1d154f (patch)
treee0172a234eb705923f1922230d72a401cdfc51b9 /src
parent2ccdea00105e6821140f85b871f75fffe4439000 (diff)
downloadgnunet-c0a40a3ee5cc8ce715f53a46cc9d734d3a1d154f.tar.gz
gnunet-c0a40a3ee5cc8ce715f53a46cc9d734d3a1d154f.zip
-more dht block layout fixes
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index cb1c5fc7d..d3a785185 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -1029,7 +1029,7 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
1029 */ 1029 */
1030void 1030void
1031put_gns_record(void *cls, 1031put_gns_record(void *cls,
1032 const const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 1032 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
1033 struct GNUNET_TIME_Absolute expiration, 1033 struct GNUNET_TIME_Absolute expiration,
1034 const char *name, 1034 const char *name,
1035 unsigned int rd_count, 1035 unsigned int rd_count,
@@ -1038,8 +1038,12 @@ put_gns_record(void *cls,
1038{ 1038{
1039 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Putting records into the DHT\n"); 1039 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Putting records into the DHT\n");
1040 struct GNUNET_TIME_Relative timeout; 1040 struct GNUNET_TIME_Relative timeout;
1041 struct GNSNameRecordBlock *nrb;
1042 struct GNSRecordBlock *rb;
1041 GNUNET_HashCode name_hash; 1043 GNUNET_HashCode name_hash;
1042 GNUNET_HashCode xor_hash; 1044 GNUNET_HashCode xor_hash;
1045 int i;
1046 uint32_t rd_payload_length;
1043 1047
1044 if (NULL == name) //We're done 1048 if (NULL == name) //We're done
1045 { 1049 {
@@ -1049,6 +1053,39 @@ put_gns_record(void *cls,
1049 NULL); 1053 NULL);
1050 return; 1054 return;
1051 } 1055 }
1056
1057 rd_payload_length = rd_count * sizeof(struct GNSRecordBlock);
1058 rd_payload_length += strlen(name) + sizeof(struct GNSNameRecordBlock);
1059 //Calculate payload size
1060 for (i=0; i<rd_count; i++)
1061 {
1062 rd_payload_length += rd[i].data_size;
1063 }
1064
1065 nrb = GNUNET_malloc(rd_payload_length);
1066
1067 memcpy(&nrb->signature, signature,
1068 sizeof(struct GNUNET_CRYPTO_RsaSignature));
1069 //FIXME signature purpose
1070 memcpy(&nrb->public_key, key,
1071 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
1072
1073 nrb->rd_count = htonl(rd_count);
1074
1075 memcpy(&nrb[1], name, strlen(name)); //FIXME is this 0 terminated??
1076
1077 rb = (struct GNSRecordBlock *)(&nrb[1]+strlen(name));
1078
1079 for (i=0; i<rd_count; i++)
1080 {
1081 rb->type = htonl(rd[i].record_type);
1082 rb->expiration = GNUNET_TIME_absolute_hton(rd[i].expiration);
1083 rb->data_length = htonl(rd[i].data_size);
1084 rb->flags = htonl(rd[i].flags);
1085 memcpy(&rb[1], rd[i].data, rd[i].data_size);
1086 rb = &rb[1] + rd[i].data_size;
1087 }
1088
1052 /** 1089 /**
1053 * FIXME magic number 20 move to config file 1090 * FIXME magic number 20 move to config file
1054 */ 1091 */
@@ -1059,8 +1096,8 @@ put_gns_record(void *cls,
1059 5, //replication level 1096 5, //replication level
1060 GNUNET_DHT_RO_NONE, 1097 GNUNET_DHT_RO_NONE,
1061 GNUNET_BLOCK_TYPE_TEST, //FIXME todo block plugin 1098 GNUNET_BLOCK_TYPE_TEST, //FIXME todo block plugin
1062 rd->data_size, 1099 rd_payload_length,
1063 rd->data, 1100 (char*)nrb,
1064 expiration, 1101 expiration,
1065 timeout, 1102 timeout,
1066 NULL, //FIXME continuation needed? success check? yes ofc 1103 NULL, //FIXME continuation needed? success check? yes ofc