aboutsummaryrefslogtreecommitdiff
path: root/src/util/peer.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-06-22 08:39:54 +0000
committerBart Polot <bart@net.in.tum.de>2011-06-22 08:39:54 +0000
commita36de9cd81b02e4454ffcfa10c709419700c590d (patch)
tree79bee9b32e1ad06d86fe9c2ea23703dfab20a19e /src/util/peer.c
parent0b81657b642457b7e15414ded2f66b33ce6835c2 (diff)
downloadgnunet-a36de9cd81b02e4454ffcfa10c709419700c590d.tar.gz
gnunet-a36de9cd81b02e4454ffcfa10c709419700c590d.zip
Added search function for PEER_id given a PeerIdentity
Diffstat (limited to 'src/util/peer.c')
-rw-r--r--src/util/peer.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util/peer.c b/src/util/peer.c
index e013c22e9..96ac271c0 100644
--- a/src/util/peer.c
+++ b/src/util/peer.c
@@ -73,6 +73,35 @@ static unsigned int free_list_start;
73 73
74 74
75/** 75/**
76 * Search for a peer identity. The reference counter is not changed.
77 *
78 * @param pid identity to find
79 * @return the interned identity or 0.
80 */
81GNUNET_PEER_Id
82GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid)
83{
84 struct PeerEntry *e;
85 long off;
86
87 if (pid == NULL)
88 return 0;
89 if (NULL == map)
90 return 0;
91 off = (long) GNUNET_CONTAINER_multihashmap_get (map, &pid->hashPubKey);
92 e = (off == 0) ? NULL : &table[off];
93 if (e != NULL)
94 {
95 GNUNET_assert (e->rc > 0);
96 return e->pid;
97 }
98 else
99 {
100 return 0;
101 }
102}
103
104/**
76 * Intern an peer identity. If the identity is already known, its 105 * Intern an peer identity. If the identity is already known, its
77 * reference counter will be increased by one. 106 * reference counter will be increased by one.
78 * 107 *