aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-service-rps.c')
-rw-r--r--src/rps/gnunet-service-rps.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 66ffd173a..58fbd6a18 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -85,7 +85,6 @@
85#define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask)) 85#define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask))
86 86
87 87
88
89/** 88/**
90 * Pending operation on peer consisting of callback and closure 89 * Pending operation on peer consisting of callback and closure
91 * 90 *
@@ -623,6 +622,7 @@ get_peer_ctx (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
623 return ctx; 622 return ctx;
624} 623}
625 624
625
626/** 626/**
627 * @brief Check whether we have information about the given peer. 627 * @brief Check whether we have information about the given peer.
628 * 628 *
@@ -856,6 +856,7 @@ add_valid_peer (const struct GNUNET_PeerIdentity *peer,
856 return ret; 856 return ret;
857} 857}
858 858
859
859static void 860static void
860remove_pending_message (struct PendingMessage *pending_msg, int cancel); 861remove_pending_message (struct PendingMessage *pending_msg, int cancel);
861 862
@@ -900,6 +901,7 @@ set_peer_online (struct PeerContext *peer_ctx)
900 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); 901 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0);
901} 902}
902 903
904
903static void 905static void
904cleanup_destroyed_channel (void *cls, 906cleanup_destroyed_channel (void *cls,
905 const struct GNUNET_CADET_Channel *channel); 907 const struct GNUNET_CADET_Channel *channel);
@@ -1048,6 +1050,7 @@ get_mq (struct PeerContext *peer_ctx)
1048 return peer_ctx->mq; 1050 return peer_ctx->mq;
1049} 1051}
1050 1052
1053
1051/** 1054/**
1052 * @brief Add an envelope to a message passed to mq to list of pending messages 1055 * @brief Add an envelope to a message passed to mq to list of pending messages
1053 * 1056 *
@@ -1124,6 +1127,7 @@ mq_online_check_successful (void *cls)
1124 } 1127 }
1125} 1128}
1126 1129
1130
1127/** 1131/**
1128 * Issue a check whether peer is online 1132 * Issue a check whether peer is online
1129 * 1133 *
@@ -1758,6 +1762,7 @@ check_peer_flag (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
1758 return check_peer_flag_set (peer_ctx, flags); 1762 return check_peer_flag_set (peer_ctx, flags);
1759} 1763}
1760 1764
1765
1761/** 1766/**
1762 * @brief Try connecting to a peer to see whether it is online 1767 * @brief Try connecting to a peer to see whether it is online
1763 * 1768 *
@@ -1969,6 +1974,7 @@ destroy_sending_channel (struct PeerContext *peer_ctx)
1969 return GNUNET_NO; 1974 return GNUNET_NO;
1970} 1975}
1971 1976
1977
1972/** 1978/**
1973 * @brief Send a message to another peer. 1979 * @brief Send a message to another peer.
1974 * 1980 *
@@ -1999,6 +2005,7 @@ send_message (struct PeerContext *peer_ctx,
1999 GNUNET_MQ_send (mq, ev); 2005 GNUNET_MQ_send (mq, ev);
2000} 2006}
2001 2007
2008
2002/** 2009/**
2003 * @brief Schedule a operation on given peer 2010 * @brief Schedule a operation on given peer
2004 * 2011 *
@@ -2035,6 +2042,7 @@ schedule_operation (struct PeerContext *peer_ctx,
2035 return GNUNET_NO; 2042 return GNUNET_NO;
2036} 2043}
2037 2044
2045
2038/*********************************************************************** 2046/***********************************************************************
2039* /Old gnunet-service-rps_peers.c 2047* /Old gnunet-service-rps_peers.c
2040***********************************************************************/ 2048***********************************************************************/
@@ -2122,9 +2130,6 @@ struct ClientContext *cli_ctx_tail;
2122***********************************************************************/ 2130***********************************************************************/
2123 2131
2124 2132
2125
2126
2127
2128/*********************************************************************** 2133/***********************************************************************
2129* Util functions 2134* Util functions
2130***********************************************************************/ 2135***********************************************************************/
@@ -2383,7 +2388,7 @@ clients_notify_stream_peer (const struct Sub *sub,
2383 cli_ctx_iter = cli_ctx_iter->next) 2388 cli_ctx_iter = cli_ctx_iter->next)
2384 { 2389 {
2385 if ((GNUNET_YES == cli_ctx_iter->stream_update) && 2390 if ((GNUNET_YES == cli_ctx_iter->stream_update) &&
2386 ((sub == cli_ctx_iter->sub) ||(sub == msub) )) 2391 ((sub == cli_ctx_iter->sub) || (sub == msub) ))
2387 { 2392 {
2388 send_stream_peers (cli_ctx_iter, num_peers, peers); 2393 send_stream_peers (cli_ctx_iter, num_peers, peers);
2389 } 2394 }
@@ -2828,7 +2833,7 @@ cleanup_destroyed_channel (void *cls,
2828 2833
2829 channel_ctx->channel = NULL; 2834 channel_ctx->channel = NULL;
2830 remove_channel_ctx (channel_ctx); 2835 remove_channel_ctx (channel_ctx);
2831 if ((NULL != peer_ctx)&& 2836 if ((NULL != peer_ctx) &&
2832 (peer_ctx->send_channel_ctx == channel_ctx) && 2837 (peer_ctx->send_channel_ctx == channel_ctx) &&
2833 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) ) 2838 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) )
2834 { 2839 {
@@ -2836,12 +2841,12 @@ cleanup_destroyed_channel (void *cls,
2836 } 2841 }
2837} 2842}
2838 2843
2844
2839/*********************************************************************** 2845/***********************************************************************
2840* /Util functions 2846* /Util functions
2841***********************************************************************/ 2847***********************************************************************/
2842 2848
2843 2849
2844
2845/*********************************************************************** 2850/***********************************************************************
2846* Sub 2851* Sub
2847***********************************************************************/ 2852***********************************************************************/
@@ -3016,6 +3021,8 @@ write_histogram_to_file (const uint32_t hist_array[],
3016 collect_str); 3021 collect_str);
3017 GNUNET_free (file_name_full); 3022 GNUNET_free (file_name_full);
3018} 3023}
3024
3025
3019#endif /* TO_FILE */ 3026#endif /* TO_FILE */
3020 3027
3021 3028
@@ -3148,6 +3155,7 @@ core_disconnects (void *cls,
3148 GNUNET_CONTAINER_multipeermap_remove_all (map_single_hop, peer); 3155 GNUNET_CONTAINER_multipeermap_remove_all (map_single_hop, peer);
3149} 3156}
3150 3157
3158
3151/*********************************************************************** 3159/***********************************************************************
3152* /Core handlers 3160* /Core handlers
3153***********************************************************************/ 3161***********************************************************************/
@@ -3442,7 +3450,7 @@ handle_client_start_sub (void *cls,
3442 struct ClientContext *cli_ctx = cls; 3450 struct ClientContext *cli_ctx = cls;
3443 3451
3444 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client requested start of a new sub.\n"); 3452 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client requested start of a new sub.\n");
3445 if ((NULL != cli_ctx->sub)&& 3453 if ((NULL != cli_ctx->sub) &&
3446 (0 != memcmp (&cli_ctx->sub->hash, 3454 (0 != memcmp (&cli_ctx->sub->hash,
3447 &msg->hash, 3455 &msg->hash,
3448 sizeof(struct GNUNET_HashCode))) ) 3456 sizeof(struct GNUNET_HashCode))) )
@@ -3633,7 +3641,7 @@ handle_peer_pull_request (void *cls,
3633 3641
3634 #if ENABLE_MALICIOUS 3642 #if ENABLE_MALICIOUS
3635 if ((1 == mal_type) 3643 if ((1 == mal_type)
3636 ||(3 == mal_type)) 3644 || (3 == mal_type))
3637 { /* Try to maximise representation */ 3645 { /* Try to maximise representation */
3638 send_pull_reply (peer_ctx, mal_peers, num_mal_peers); 3646 send_pull_reply (peer_ctx, mal_peers, num_mal_peers);
3639 } 3647 }
@@ -3774,13 +3782,13 @@ handle_peer_pull_reply (void *cls,
3774 3782
3775 #if ENABLE_MALICIOUS 3783 #if ENABLE_MALICIOUS
3776 if ((NULL != att_peer_set) && 3784 if ((NULL != att_peer_set) &&
3777 ((1 == mal_type) ||(3 == mal_type) )) 3785 ((1 == mal_type) || (3 == mal_type) ))
3778 { /* Add attacked peer to local list */ 3786 { /* Add attacked peer to local list */
3779 // TODO check if we sent a request and this was the first reply 3787 // TODO check if we sent a request and this was the first reply
3780 if ((GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, 3788 if ((GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set,
3781 &peers[i])) 3789 &peers[i]))
3782 &&(GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, 3790 && (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set,
3783 &peers[i])) ) 3791 &peers[i])) )
3784 { 3792 {
3785 tmp_att_peer = GNUNET_new (struct AttackedPeer); 3793 tmp_att_peer = GNUNET_new (struct AttackedPeer);
3786 tmp_att_peer->peer_id = peers[i]; 3794 tmp_att_peer->peer_id = peers[i];
@@ -3988,6 +3996,7 @@ check_client_act_malicious (void *cls,
3988 return GNUNET_OK; 3996 return GNUNET_OK;
3989} 3997}
3990 3998
3999
3991/** 4000/**
3992 * Turn RPS service to act malicious. 4001 * Turn RPS service to act malicious.
3993 * 4002 *
@@ -4236,6 +4245,8 @@ do_mal_round (void *cls)
4236 &do_mal_round, sub); 4245 &do_mal_round, sub);
4237 LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); 4246 LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n");
4238} 4247}
4248
4249
4239#endif /* ENABLE_MALICIOUS */ 4250#endif /* ENABLE_MALICIOUS */
4240 4251
4241 4252
@@ -4785,6 +4796,7 @@ client_connect_cb (void *cls,
4785 return cli_ctx; 4796 return cli_ctx;
4786} 4797}
4787 4798
4799
4788/** 4800/**
4789 * Callback called when a client disconnected from the service 4801 * Callback called when a client disconnected from the service
4790 * 4802 *