aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-02-23 23:48:36 +0000
committerJulius Bünger <buenger@mytum.de>2015-02-23 23:48:36 +0000
commitd8b7abbebb419f825b2bf412d7c7ecfa9db89541 (patch)
treeb8888630ff944aed2fc4796719e7c3996fbd09ca /src/rps
parent7f424af3f7d3d3271feafecc6330185e76f95ee2 (diff)
downloadgnunet-d8b7abbebb419f825b2bf412d7c7ecfa9db89541.tar.gz
gnunet-d8b7abbebb419f825b2bf412d7c7ecfa9db89541.zip
- sending act malicious message
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 4ff5ca5e6..923540db0 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -668,50 +668,30 @@ cadet_ntfy_tmt_rdy_cb (void *cls, size_t size, void *buf)
668get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, 668get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
669 const struct GNUNET_PeerIdentity *peer) 669 const struct GNUNET_PeerIdentity *peer)
670{ 670{
671 struct PeerContext *ctx; 671 struct PeerContext *peer_ctx;
672 672
673 LOG (GNUNET_ERROR_TYPE_DEBUG, 673 LOG (GNUNET_ERROR_TYPE_DEBUG,
674 "Trying to establish channel to peer %s\n", 674 "Trying to establish channel to peer %s\n",
675 GNUNET_i2s (peer)); 675 GNUNET_i2s (peer));
676 676
677 ctx = get_peer_ctx (peer_map, peer); 677 peer_ctx = get_peer_ctx (peer_map, peer);
678 if (NULL == ctx->send_channel) 678 if (NULL == peer_ctx->send_channel)
679 { 679 {
680 ctx->send_channel = GNUNET_CADET_channel_create (cadet_handle, 680 peer_ctx->send_channel =
681 NULL, 681 GNUNET_CADET_channel_create (cadet_handle,
682 peer, 682 NULL,
683 GNUNET_RPS_CADET_PORT, 683 peer,
684 GNUNET_CADET_OPTION_RELIABLE); 684 GNUNET_RPS_CADET_PORT,
685 685 GNUNET_CADET_OPTION_RELIABLE);
686 /* If we don't know whether peer is live,
687 * get notified when we know it is live. */
688 if (GNUNET_YES != get_peer_flag (ctx, VALID)
689 && NULL != ctx->is_live_task
690 && NULL == ctx->recv_channel
691 && NULL == ctx->is_live_task)
692 {
693 ctx->peer_id = *peer;
694 LOG (GNUNET_ERROR_TYPE_DEBUG,
695 "Get informed about peer %s getting live\n",
696 GNUNET_i2s (peer));
697 ctx->is_live_task =
698 GNUNET_CADET_notify_transmit_ready (ctx->send_channel,
699 GNUNET_NO,
700 GNUNET_TIME_UNIT_FOREVER_REL,
701 sizeof (struct GNUNET_MessageHeader),
702 cadet_ntfy_tmt_rdy_cb,
703 ctx);
704 }
705 // FIXME check whether this is NULL
706 686
707 // do I have to explicitly put it in the peer_map? 687 // do I have to explicitly put it in the peer_map?
708 (void) GNUNET_CONTAINER_multipeermap_put 688 (void) GNUNET_CONTAINER_multipeermap_put
709 (peer_map, 689 (peer_map,
710 peer, 690 peer,
711 ctx, 691 peer_ctx,
712 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 692 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
713 } 693 }
714 return ctx->send_channel; 694 return peer_ctx->send_channel;
715} 695}
716 696
717 697
@@ -729,8 +709,6 @@ get_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
729 709
730 peer_ctx = get_peer_ctx (peer_map, peer_id); 710 peer_ctx = get_peer_ctx (peer_map, peer_id);
731 711
732 GNUNET_assert (NULL == peer_ctx->is_live_task);
733
734 if (NULL == peer_ctx->mq) 712 if (NULL == peer_ctx->mq)
735 { 713 {
736 (void) get_channel (peer_map, peer_id); 714 (void) get_channel (peer_map, peer_id);
@@ -744,6 +722,29 @@ get_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
744 722
745 723
746/** 724/**
725 * Issue check whether peer is live
726 *
727 * @param peer_ctx the context of the peer
728 */
729void
730check_peer_live (struct PeerContext *peer_ctx)
731{
732 (void) get_channel (peer_map, &peer_ctx->peer_id);
733 LOG (GNUNET_ERROR_TYPE_DEBUG,
734 "Get informed about peer %s getting live\n",
735 GNUNET_i2s (&peer_ctx->peer_id));
736 peer_ctx->is_live_task =
737 GNUNET_CADET_notify_transmit_ready (peer_ctx->send_channel,
738 GNUNET_NO,
739 GNUNET_TIME_UNIT_FOREVER_REL,
740 sizeof (struct GNUNET_MessageHeader),
741 cadet_ntfy_tmt_rdy_cb,
742 peer_ctx);
743 // FIXME check whether this is NULL
744}
745
746
747/**
747 * Sum all time relatives of an array. 748 * Sum all time relatives of an array.
748 */ 749 */
749 struct GNUNET_TIME_Relative 750 struct GNUNET_TIME_Relative
@@ -1312,6 +1313,7 @@ handle_peer_pull_reply (void *cls,
1312 GNUNET_array_append (peer_ctx->outstanding_ops, 1313 GNUNET_array_append (peer_ctx->outstanding_ops,
1313 peer_ctx->num_outstanding_ops, 1314 peer_ctx->num_outstanding_ops,
1314 out_op); 1315 out_op);
1316 check_peer_live (peer_ctx);
1315 } 1317 }
1316 } 1318 }
1317 1319
@@ -1654,7 +1656,7 @@ init_peer_cb (void *cls,
1654 } 1656 }
1655 1657
1656 /* Trigger livelyness test on peer */ 1658 /* Trigger livelyness test on peer */
1657 (void) get_channel (peer_map, peer); 1659 check_peer_live (peer_ctx);
1658 } 1660 }
1659 1661
1660 // send push/pull to each of those peers? 1662 // send push/pull to each of those peers?
@@ -1884,7 +1886,7 @@ cleanup_channel (void *cls,
1884 /* Cast to void is ok, because it's used as void in peer_remove_cb */ 1886 /* Cast to void is ok, because it's used as void in peer_remove_cb */
1885 (void) peer_remove_cb ((void *) channel, peer, peer_ctx); 1887 (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
1886 } 1888 }
1887 else 1889 else /* Other peer doesn't want to send us messages anymore */
1888 peer_ctx->recv_channel = NULL; 1890 peer_ctx->recv_channel = NULL;
1889 } 1891 }
1890} 1892}