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.c55
1 files changed, 8 insertions, 47 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 5d568dfac..12794945e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -265,34 +265,6 @@ struct PeersIteratorCls
265}; 265};
266 266
267/** 267/**
268 * @brief Context for a channel
269 */
270struct ChannelCtx
271{
272 /**
273 * @brief Meant to be used in a DLL
274 */
275 struct ChannelCtx *next;
276 struct ChannelCtx *prev;
277
278 /**
279 * @brief The channel itself
280 */
281 struct GNUNET_CADET_Channel *channel;
282
283 /**
284 * @brief The peer context associated with the channel
285 */
286 struct PeerContext *peer_ctx;
287};
288
289/**
290 * @brief The DLL of channel contexts
291 */
292static struct ChannelCtx *channel_ctx_head;
293static struct ChannelCtx *channel_ctx_tail;
294
295/**
296 * @brief Hashmap of valid peers. 268 * @brief Hashmap of valid peers.
297 */ 269 */
298static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers; 270static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers;
@@ -1549,7 +1521,6 @@ Peers_handle_inbound_channel (void *cls,
1549{ 1521{
1550 struct PeerContext *peer_ctx; 1522 struct PeerContext *peer_ctx;
1551 struct GNUNET_PeerIdentity *ctx_peer; 1523 struct GNUNET_PeerIdentity *ctx_peer;
1552 struct ChannelCtx *channel_ctx;
1553 1524
1554 LOG (GNUNET_ERROR_TYPE_DEBUG, 1525 LOG (GNUNET_ERROR_TYPE_DEBUG,
1555 "New channel was established to us (Peer %s).\n", 1526 "New channel was established to us (Peer %s).\n",
@@ -1560,10 +1531,6 @@ Peers_handle_inbound_channel (void *cls,
1560 set_peer_live (peer_ctx); 1531 set_peer_live (peer_ctx);
1561 ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); 1532 ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity);
1562 *ctx_peer = *initiator; 1533 *ctx_peer = *initiator;
1563 channel_ctx = GNUNET_new (struct ChannelCtx);
1564 channel_ctx->peer_ctx = peer_ctx;
1565 channel_ctx->channel = channel;
1566 GNUNET_CONTAINER_DLL_insert (channel_ctx_head, channel_ctx_tail, channel_ctx);
1567 /* We only accept one incoming channel per peer */ 1534 /* We only accept one incoming channel per peer */
1568 if (GNUNET_YES == Peers_check_peer_send_intention (initiator)) 1535 if (GNUNET_YES == Peers_check_peer_send_intention (initiator))
1569 { 1536 {
@@ -1576,10 +1543,10 @@ Peers_handle_inbound_channel (void *cls,
1576 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); 1543 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel);
1577 peer_ctx->recv_channel = channel; 1544 peer_ctx->recv_channel = channel;
1578 /* return the channel context */ 1545 /* return the channel context */
1579 return channel_ctx; 1546 return ctx_peer;
1580 } 1547 }
1581 peer_ctx->recv_channel = channel; 1548 peer_ctx->recv_channel = channel;
1582 return channel_ctx; 1549 return ctx_peer;
1583} 1550}
1584 1551
1585 1552
@@ -1691,8 +1658,7 @@ void
1691Peers_cleanup_destroyed_channel (void *cls, 1658Peers_cleanup_destroyed_channel (void *cls,
1692 const struct GNUNET_CADET_Channel *channel) 1659 const struct GNUNET_CADET_Channel *channel)
1693{ 1660{
1694 struct ChannelCtx *channel_ctx = cls; 1661 struct GNUNET_PeerIdentity *peer = cls;
1695 const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
1696 struct PeerContext *peer_ctx; 1662 struct PeerContext *peer_ctx;
1697 uint32_t *channel_flag; 1663 uint32_t *channel_flag;
1698 1664
@@ -2704,8 +2670,7 @@ static void
2704cleanup_destroyed_channel (void *cls, 2670cleanup_destroyed_channel (void *cls,
2705 const struct GNUNET_CADET_Channel *channel) 2671 const struct GNUNET_CADET_Channel *channel)
2706{ 2672{
2707 struct ChannelCtx *channel_ctx = cls; // FIXME: free this context! 2673 struct GNUNET_PeerIdentity *peer = cls;
2708 struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
2709 uint32_t *channel_flag; 2674 uint32_t *channel_flag;
2710 struct PeerContext *peer_ctx; 2675 struct PeerContext *peer_ctx;
2711 2676
@@ -3198,8 +3163,7 @@ static void
3198handle_peer_check (void *cls, 3163handle_peer_check (void *cls,
3199 const struct GNUNET_MessageHeader *msg) 3164 const struct GNUNET_MessageHeader *msg)
3200{ 3165{
3201 const struct ChannelCtx *channel_ctx = cls; 3166 const struct GNUNET_PeerIdentity *peer = cls;
3202 const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
3203 LOG (GNUNET_ERROR_TYPE_DEBUG, 3167 LOG (GNUNET_ERROR_TYPE_DEBUG,
3204 "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer)); 3168 "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer));
3205 3169
@@ -3219,8 +3183,7 @@ static void
3219handle_peer_push (void *cls, 3183handle_peer_push (void *cls,
3220 const struct GNUNET_MessageHeader *msg) 3184 const struct GNUNET_MessageHeader *msg)
3221{ 3185{
3222 const struct ChannelCtx *channel_ctx = cls; 3186 const struct GNUNET_PeerIdentity *peer = cls;
3223 const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
3224 3187
3225 // (check the proof of work (?)) 3188 // (check the proof of work (?))
3226 3189
@@ -3281,8 +3244,7 @@ static void
3281handle_peer_pull_request (void *cls, 3244handle_peer_pull_request (void *cls,
3282 const struct GNUNET_MessageHeader *msg) 3245 const struct GNUNET_MessageHeader *msg)
3283{ 3246{
3284 const struct ChannelCtx *channel_ctx = cls; 3247 struct GNUNET_PeerIdentity *peer = cls;
3285 const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
3286 const struct GNUNET_PeerIdentity *view_array; 3248 const struct GNUNET_PeerIdentity *view_array;
3287 3249
3288 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer)); 3250 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer));
@@ -3362,9 +3324,8 @@ static void
3362handle_peer_pull_reply (void *cls, 3324handle_peer_pull_reply (void *cls,
3363 const struct GNUNET_RPS_P2P_PullReplyMessage *msg) 3325 const struct GNUNET_RPS_P2P_PullReplyMessage *msg)
3364{ 3326{
3365 const struct ChannelCtx *channel_ctx = cls;
3366 const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id;
3367 const struct GNUNET_PeerIdentity *peers; 3327 const struct GNUNET_PeerIdentity *peers;
3328 struct GNUNET_PeerIdentity *sender = cls;
3368 uint32_t i; 3329 uint32_t i;
3369#ifdef ENABLE_MALICIOUS 3330#ifdef ENABLE_MALICIOUS
3370 struct AttackedPeer *tmp_att_peer; 3331 struct AttackedPeer *tmp_att_peer;