aboutsummaryrefslogtreecommitdiff
path: root/src/setu/gnunet-service-setu.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-19 17:54:21 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-19 17:54:21 +0200
commit1ca1140d4602dcc5c66da0d1ab1b082db9258ead (patch)
tree4a57b97b7f5f4f2b93f67bd8d39e890f3fa67dc3 /src/setu/gnunet-service-setu.c
parentaa2b84ff8caed28aec31e9a39375a02fceeb4e8c (diff)
downloadgnunet-1ca1140d4602dcc5c66da0d1ab1b082db9258ead.tar.gz
gnunet-1ca1140d4602dcc5c66da0d1ab1b082db9258ead.zip
-implement the symmetric option in setu
Diffstat (limited to 'src/setu/gnunet-service-setu.c')
-rw-r--r--src/setu/gnunet-service-setu.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index e61e1ab0c..326589186 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -371,6 +371,12 @@ struct Operation
371 int byzantine; 371 int byzantine;
372 372
373 /** 373 /**
374 * #GNUNET_YES to also send back set elements we are sending to
375 * the remote peer.
376 */
377 int symmetric;
378
379 /**
374 * Lower bound for the set size, used only when 380 * Lower bound for the set size, used only when
375 * byzantine mode is enabled. 381 * byzantine mode is enabled.
376 */ 382 */
@@ -1576,7 +1582,9 @@ decode_and_send (struct Operation *op)
1576 1582
1577 last_key = key; 1583 last_key = key;
1578 1584
1579 res = ibf_decode (diff_ibf, &side, &key); 1585 res = ibf_decode (diff_ibf,
1586 &side,
1587 &key);
1580 if (res == GNUNET_OK) 1588 if (res == GNUNET_OK)
1581 { 1589 {
1582 LOG (GNUNET_ERROR_TYPE_DEBUG, 1590 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1839,7 +1847,7 @@ handle_union_p2p_ibf (void *cls,
1839static void 1847static void
1840send_client_element (struct Operation *op, 1848send_client_element (struct Operation *op,
1841 const struct GNUNET_SETU_Element *element, 1849 const struct GNUNET_SETU_Element *element,
1842 int status) 1850 enum GNUNET_SETU_Status status)
1843{ 1851{
1844 struct GNUNET_MQ_Envelope *ev; 1852 struct GNUNET_MQ_Envelope *ev;
1845 struct GNUNET_SETU_ResultMessage *rm; 1853 struct GNUNET_SETU_ResultMessage *rm;
@@ -2071,8 +2079,8 @@ handle_union_p2p_full_element (void *cls,
2071 ee->element.data = &ee[1]; 2079 ee->element.data = &ee[1];
2072 ee->element.element_type = ntohs (emsg->element_type); 2080 ee->element.element_type = ntohs (emsg->element_type);
2073 ee->remote = GNUNET_YES; 2081 ee->remote = GNUNET_YES;
2074 GNUNET_SETU_element_hash (&ee->element, &ee->element_hash); 2082 GNUNET_SETU_element_hash (&ee->element,
2075 2083 &ee->element_hash);
2076 LOG (GNUNET_ERROR_TYPE_DEBUG, 2084 LOG (GNUNET_ERROR_TYPE_DEBUG,
2077 "Got element (full diff, size %u, hash %s) from peer\n", 2085 "Got element (full diff, size %u, hash %s) from peer\n",
2078 (unsigned int) element_size, 2086 (unsigned int) element_size,
@@ -2285,7 +2293,6 @@ handle_union_p2p_full_done (void *cls,
2285 GNUNET_CONTAINER_multihashmap32_iterate (op->key_to_element, 2293 GNUNET_CONTAINER_multihashmap32_iterate (op->key_to_element,
2286 &send_missing_full_elements_iter, 2294 &send_missing_full_elements_iter,
2287 op); 2295 op);
2288
2289 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE); 2296 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE);
2290 GNUNET_MQ_send (op->mq, 2297 GNUNET_MQ_send (op->mq,
2291 ev); 2298 ev);
@@ -2387,9 +2394,12 @@ handle_union_p2p_demand (void *cls,
2387 fail_union_operation (op); 2394 fail_union_operation (op);
2388 return; 2395 return;
2389 } 2396 }
2390 ev = GNUNET_MQ_msg_extra (emsg, ee->element.size, 2397 ev = GNUNET_MQ_msg_extra (emsg,
2398 ee->element.size,
2391 GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS); 2399 GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS);
2392 GNUNET_memcpy (&emsg[1], ee->element.data, ee->element.size); 2400 GNUNET_memcpy (&emsg[1],
2401 ee->element.data,
2402 ee->element.size);
2393 emsg->reserved = htons (0); 2403 emsg->reserved = htons (0);
2394 emsg->element_type = htons (ee->element.element_type); 2404 emsg->element_type = htons (ee->element.element_type);
2395 LOG (GNUNET_ERROR_TYPE_DEBUG, 2405 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2402,6 +2412,10 @@ handle_union_p2p_demand (void *cls,
2402 "# exchanged elements", 2412 "# exchanged elements",
2403 1, 2413 1,
2404 GNUNET_NO); 2414 GNUNET_NO);
2415 if (op->symmetric)
2416 send_client_element (op,
2417 &ee->element,
2418 GNUNET_SET_STATUS_ADD_REMOTE);
2405 } 2419 }
2406 GNUNET_CADET_receive_done (op->channel); 2420 GNUNET_CADET_receive_done (op->channel);
2407} 2421}
@@ -3316,9 +3330,10 @@ handle_client_evaluate (void *cls,
3316 op->peer = msg->target_peer; 3330 op->peer = msg->target_peer;
3317 op->client_request_id = ntohl (msg->request_id); 3331 op->client_request_id = ntohl (msg->request_id);
3318 op->byzantine = msg->byzantine; 3332 op->byzantine = msg->byzantine;
3319 op->byzantine_lower_bound = msg->byzantine_lower_bound; 3333 op->byzantine_lower_bound = ntohl (msg->byzantine_lower_bound);
3320 op->force_full = msg->force_full; 3334 op->force_full = msg->force_full;
3321 op->force_delta = msg->force_delta; 3335 op->force_delta = msg->force_delta;
3336 op->symmetric = msg->symmetric;
3322 context = GNUNET_MQ_extract_nested_mh (msg); 3337 context = GNUNET_MQ_extract_nested_mh (msg);
3323 3338
3324 /* Advance generation values, so that 3339 /* Advance generation values, so that
@@ -3500,9 +3515,10 @@ handle_client_accept (void *cls,
3500 op); 3515 op);
3501 op->client_request_id = ntohl (msg->request_id); 3516 op->client_request_id = ntohl (msg->request_id);
3502 op->byzantine = msg->byzantine; 3517 op->byzantine = msg->byzantine;
3503 op->byzantine_lower_bound = msg->byzantine_lower_bound; 3518 op->byzantine_lower_bound = ntohl (msg->byzantine_lower_bound);
3504 op->force_full = msg->force_full; 3519 op->force_full = msg->force_full;
3505 op->force_delta = msg->force_delta; 3520 op->force_delta = msg->force_delta;
3521 op->symmetric = msg->symmetric;
3506 3522
3507 /* Advance generation values, so that future mutations do not 3523 /* Advance generation values, so that future mutations do not
3508 interfer with the running operation. */ 3524 interfer with the running operation. */