aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c98
1 files changed, 1 insertions, 97 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 555660c04..4d502713f 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -97,11 +97,6 @@ static struct GNUNET_HashCode port;
97#define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask)) 97#define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
98 98
99/** 99/**
100 * Set a channel flag of given channel context.
101 */
102#define set_channel_flag(channel_flags, mask) ((*channel_flags) |= (mask))
103
104/**
105 * Get channel flag of given channel context. 100 * Get channel flag of given channel context.
106 */ 101 */
107#define check_channel_flag_set(channel_flags, mask)\ 102#define check_channel_flag_set(channel_flags, mask)\
@@ -189,19 +184,9 @@ struct PeerContext
189 struct ChannelCtx *send_channel_ctx; 184 struct ChannelCtx *send_channel_ctx;
190 185
191 /** 186 /**
192 * Flags to the sending channel
193 */
194 uint32_t *send_channel_flags;
195
196 /**
197 * Channel open from client. 187 * Channel open from client.
198 */ 188 */
199 struct ChannelCtx *recv_channel_ctx; // unneeded? 189 struct ChannelCtx *recv_channel_ctx;
200
201 /**
202 * Flags to the receiving channel
203 */
204 uint32_t *recv_channel_flags;
205 190
206 /** 191 /**
207 * Array of pending operations on this peer. 192 * Array of pending operations on this peer.
@@ -375,8 +360,6 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
375 360
376 ctx = GNUNET_new (struct PeerContext); 361 ctx = GNUNET_new (struct PeerContext);
377 ctx->peer_id = *peer; 362 ctx->peer_id = *peer;
378 ctx->send_channel_flags = GNUNET_new (uint32_t);
379 ctx->recv_channel_flags = GNUNET_new (uint32_t);
380 ret = GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx, 363 ret = GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx,
381 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 364 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
382 GNUNET_assert (GNUNET_OK == ret); 365 GNUNET_assert (GNUNET_OK == ret);
@@ -1307,7 +1290,6 @@ int
1307Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) 1290Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1308{ 1291{
1309 struct PeerContext *peer_ctx; 1292 struct PeerContext *peer_ctx;
1310 uint32_t *channel_flag;
1311 1293
1312 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) 1294 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
1313 { 1295 {
@@ -1383,9 +1365,6 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1383 GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); 1365 GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task);
1384 } 1366 }
1385 1367
1386 GNUNET_free (peer_ctx->send_channel_flags);
1387 GNUNET_free (peer_ctx->recv_channel_flags);
1388
1389 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id)) 1368 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id))
1390 { 1369 {
1391 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); 1370 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n");
@@ -1459,77 +1438,6 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl
1459 return check_peer_flag_set (peer_ctx, flags); 1438 return check_peer_flag_set (peer_ctx, flags);
1460} 1439}
1461 1440
1462
1463/**
1464 * @brief set flags on a given channel.
1465 *
1466 * @param channel the channel to set flags on
1467 * @param flags the flags
1468 */
1469void
1470Peers_set_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags)
1471{
1472 set_channel_flag (channel_flags, flags);
1473}
1474
1475
1476/**
1477 * @brief unset flags on a given channel.
1478 *
1479 * @param channel the channel to unset flags on
1480 * @param flags the flags
1481 */
1482void
1483Peers_unset_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags)
1484{
1485 unset_channel_flag (channel_flags, flags);
1486}
1487
1488
1489/**
1490 * @brief Check whether flags on a channel are set.
1491 *
1492 * @param channel the channel to check the flag of
1493 * @param flags the flags to check
1494 *
1495 * @return #GNUNET_YES if all given flags are set
1496 * #GNUNET_NO otherwise
1497 */
1498int
1499Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags)
1500{
1501 return check_channel_flag_set (channel_flags, flags);
1502}
1503
1504/**
1505 * @brief Get the flags for the channel in @a role for @a peer.
1506 *
1507 * @param peer Peer to get the channel flags for.
1508 * @param role Role of channel to get flags for
1509 *
1510 * @return The flags.
1511 */
1512uint32_t *
1513Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer,
1514 enum Peers_ChannelRole role)
1515{
1516 const struct PeerContext *peer_ctx;
1517
1518 peer_ctx = get_peer_ctx (peer);
1519 if (Peers_CHANNEL_ROLE_SENDING == role)
1520 {
1521 return peer_ctx->send_channel_flags;
1522 }
1523 else if (Peers_CHANNEL_ROLE_RECEIVING == role)
1524 {
1525 return peer_ctx->recv_channel_flags;
1526 }
1527 else
1528 {
1529 GNUNET_assert (0);
1530 }
1531}
1532
1533/** 1441/**
1534 * @brief Check whether we have information about the given peer. 1442 * @brief Check whether we have information about the given peer.
1535 * 1443 *
@@ -1644,9 +1552,6 @@ Peers_handle_inbound_channel (void *cls,
1644 LOG (GNUNET_ERROR_TYPE_WARNING, 1552 LOG (GNUNET_ERROR_TYPE_WARNING,
1645 "Already got one receive channel. Destroying old one.\n"); 1553 "Already got one receive channel. Destroying old one.\n");
1646 GNUNET_break_op (0); 1554 GNUNET_break_op (0);
1647 set_channel_flag (peer_ctx->recv_channel_flags,
1648 Peers_CHANNEL_ESTABLISHED_TWICE);
1649 //GNUNET_CADET_channel_destroy (channel);
1650 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel); 1555 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel);
1651 remove_channel_ctx (peer_ctx->recv_channel_ctx); 1556 remove_channel_ctx (peer_ctx->recv_channel_ctx);
1652 peer_ctx->recv_channel_ctx = channel_ctx; 1557 peer_ctx->recv_channel_ctx = channel_ctx;
@@ -2824,7 +2729,6 @@ cleanup_destroyed_channel (void *cls,
2824{ 2729{
2825 struct ChannelCtx *channel_ctx = cls; 2730 struct ChannelCtx *channel_ctx = cls;
2826 struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; 2731 struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
2827 uint32_t *channel_flag;
2828 struct PeerContext *peer_ctx; 2732 struct PeerContext *peer_ctx;
2829 2733
2830 GNUNET_assert (NULL != peer); 2734 GNUNET_assert (NULL != peer);