aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-30 17:26:45 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-30 17:26:45 +0000
commit2e6e4ee945072c30c24289da5d01aed1b282dfcd (patch)
tree2c8bfc2183657fc03dfc08a3d67b11e3a8eeda56 /src/fs
parent7398e127e6b600054c20deafb3fae075adeafd8f (diff)
downloadgnunet-2e6e4ee945072c30c24289da5d01aed1b282dfcd.tar.gz
gnunet-2e6e4ee945072c30c24289da5d01aed1b282dfcd.zip
fixing #3146: peer identities no longer have the size of hash codes; breaks FS protocol compatibility with previous versions slightly...
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-service-fs.h6
-rw-r--r--src/fs/gnunet-service-fs_cp.c24
-rw-r--r--src/fs/gnunet-service-fs_pr.c14
3 files changed, 21 insertions, 23 deletions
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index 8830058e9..c5fb47ef3 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -83,7 +83,7 @@ struct GetMessage
83{ 83{
84 84
85 /** 85 /**
86 * Message type will be GNUNET_MESSAGE_TYPE_FS_GET. 86 * Message type will be #GNUNET_MESSAGE_TYPE_FS_GET.
87 */ 87 */
88 struct GNUNET_MessageHeader header; 88 struct GNUNET_MessageHeader header;
89 89
@@ -114,7 +114,7 @@ struct GetMessage
114 /** 114 /**
115 * Which of the optional hash codes are present at the end of the 115 * Which of the optional hash codes are present at the end of the
116 * message? See GET_MESSAGE_BIT_xx constants. For each bit that is 116 * message? See GET_MESSAGE_BIT_xx constants. For each bit that is
117 * set, an additional struct GNUNET_HashCode with the respective content 117 * set, an additional `struct GNUNET_HashCode` with the respective content
118 * (in order of the bits) will be appended to the end of the GET 118 * (in order of the bits) will be appended to the end of the GET
119 * message. 119 * message.
120 */ 120 */
@@ -126,7 +126,7 @@ struct GetMessage
126 */ 126 */
127 struct GNUNET_HashCode query; 127 struct GNUNET_HashCode query;
128 128
129 /* this is followed by hash codes as specified in the "hash_bitmap"; 129 /* this is followed by PeerIdentities as specified in the "hash_bitmap";
130 * after that, an optional bloomfilter (with bits set for replies 130 * after that, an optional bloomfilter (with bits set for replies
131 * that should be suppressed) can be present */ 131 * that should be suppressed) can be present */
132}; 132};
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 593250e2c..a586ea503 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -98,7 +98,7 @@ struct GSF_PeerTransmitHandle
98 struct GSF_ConnectedPeer *cp; 98 struct GSF_ConnectedPeer *cp;
99 99
100 /** 100 /**
101 * Closure for 'gmc'. 101 * Closure for @e gmc.
102 */ 102 */
103 void *gmc_cls; 103 void *gmc_cls;
104 104
@@ -108,7 +108,7 @@ struct GSF_PeerTransmitHandle
108 size_t size; 108 size_t size;
109 109
110 /** 110 /**
111 * GNUNET_YES if this is a query, GNUNET_NO for content. 111 * #GNUNET_YES if this is a query, #GNUNET_NO for content.
112 */ 112 */
113 int is_query; 113 int is_query;
114 114
@@ -1116,7 +1116,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1116 uint16_t msize; 1116 uint16_t msize;
1117 const struct GetMessage *gm; 1117 const struct GetMessage *gm;
1118 unsigned int bits; 1118 unsigned int bits;
1119 const struct GNUNET_HashCode *opt; 1119 const struct GNUNET_PeerIdentity *opt;
1120 uint32_t bm; 1120 uint32_t bm;
1121 size_t bfsize; 1121 size_t bfsize;
1122 uint32_t ttl_decrement; 1122 uint32_t ttl_decrement;
@@ -1146,13 +1146,13 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1146 bits++; 1146 bits++;
1147 bm >>= 1; 1147 bm >>= 1;
1148 } 1148 }
1149 if (msize < sizeof (struct GetMessage) + bits * sizeof (struct GNUNET_HashCode)) 1149 if (msize < sizeof (struct GetMessage) + bits * sizeof (struct GNUNET_PeerIdentity))
1150 { 1150 {
1151 GNUNET_break_op (0); 1151 GNUNET_break_op (0);
1152 return NULL; 1152 return NULL;
1153 } 1153 }
1154 opt = (const struct GNUNET_HashCode *) &gm[1]; 1154 opt = (const struct GNUNET_PeerIdentity *) &gm[1];
1155 bfsize = msize - sizeof (struct GetMessage) - bits * sizeof (struct GNUNET_HashCode); 1155 bfsize = msize - sizeof (struct GetMessage) - bits * sizeof (struct GNUNET_PeerIdentity);
1156 /* bfsize must be power of 2, check! */ 1156 /* bfsize must be power of 2, check! */
1157 if (0 != ((bfsize - 1) & bfsize)) 1157 if (0 != ((bfsize - 1) & bfsize))
1158 { 1158 {
@@ -1173,7 +1173,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1173 return NULL; 1173 return NULL;
1174 } 1174 }
1175 if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO)) 1175 if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
1176 cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity *) &opt[bits++]); 1176 cp = GSF_peer_get_ (&opt[bits++]);
1177 else 1177 else
1178 cp = cps; 1178 cp = cps;
1179 if (NULL == cp) 1179 if (NULL == cp)
@@ -1181,8 +1181,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1181 if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO)) 1181 if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1183 "Failed to find RETURN-TO peer `%4s' in connection set. Dropping query.\n", 1183 "Failed to find RETURN-TO peer `%4s' in connection set. Dropping query.\n",
1184 GNUNET_i2s ((const struct GNUNET_PeerIdentity *) 1184 GNUNET_i2s (&opt[bits - 1]));
1185 &opt[bits - 1]));
1186 1185
1187 else 1186 else
1188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1209,12 +1208,13 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1209 } 1208 }
1210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1211 "Received request for `%s' of type %u from peer `%4s' with flags %u\n", 1210 "Received request for `%s' of type %u from peer `%4s' with flags %u\n",
1212 GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other), 1211 GNUNET_h2s (&gm->query),
1212 (unsigned int) type,
1213 GNUNET_i2s (other),
1213 (unsigned int) bm); 1214 (unsigned int) bm);
1214 target = 1215 target =
1215 (0 != 1216 (0 !=
1216 (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity 1217 (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? (&opt[bits++]) : NULL;
1217 *) &opt[bits++]) : NULL;
1218 options = GSF_PRO_DEFAULTS; 1218 options = GSF_PRO_DEFAULTS;
1219 spid = 0; 1219 spid = 0;
1220 if ((GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority)) 1220 if ((GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority))
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index e5a789a2b..e3ce8dd69 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -504,7 +504,7 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
504{ 504{
505 char lbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; 505 char lbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
506 struct GetMessage *gm; 506 struct GetMessage *gm;
507 struct GNUNET_HashCode *ext; 507 struct GNUNET_PeerIdentity *ext;
508 size_t msize; 508 size_t msize;
509 unsigned int k; 509 unsigned int k;
510 uint32_t bm; 510 uint32_t bm;
@@ -537,7 +537,7 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
537 k++; 537 k++;
538 } 538 }
539 bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf); 539 bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf);
540 msize = sizeof (struct GetMessage) + bf_size + k * sizeof (struct GNUNET_HashCode); 540 msize = sizeof (struct GetMessage) + bf_size + k * sizeof (struct GNUNET_PeerIdentity);
541 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 541 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
542 if (buf_size < msize) 542 if (buf_size < msize)
543 return msize; 543 return msize;
@@ -561,16 +561,14 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
561 gm->filter_mutator = htonl (pr->mingle); 561 gm->filter_mutator = htonl (pr->mingle);
562 gm->hash_bitmap = htonl (bm); 562 gm->hash_bitmap = htonl (bm);
563 gm->query = pr->public_data.query; 563 gm->query = pr->public_data.query;
564 ext = (struct GNUNET_HashCode *) & gm[1]; 564 ext = (struct GNUNET_PeerIdentity *) &gm[1];
565 k = 0; 565 k = 0;
566 if (!do_route) 566 if (!do_route)
567 GNUNET_PEER_resolve (pr->sender_pid, 567 GNUNET_PEER_resolve (pr->sender_pid,
568 (struct GNUNET_PeerIdentity *) &ext[k++]); 568 &ext[k++]);
569 if (NULL != pr->public_data.target) 569 if (NULL != pr->public_data.target)
570 memcpy (&ext[k++], 570 ext[k++] = *pr->public_data.target;
571 pr->public_data.target, 571 if (NULL != pr->bf)
572 sizeof (struct GNUNET_PeerIdentity));
573 if (pr->bf != NULL)
574 GNUNET_assert (GNUNET_SYSERR != 572 GNUNET_assert (GNUNET_SYSERR !=
575 GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf, 573 GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf,
576 (char *) &ext[k], 574 (char *) &ext[k],