diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-05-30 16:06:00 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-05-30 16:06:00 +0000 |
commit | 95cdeb5c0bb1f14f3959863e6bf4675db48ea177 (patch) | |
tree | 545e2a910c0efdae9dc2e2af8da45efa007cdf32 /src/peerstore/peerstore_common.c | |
parent | 02f9d1e7389d0da0a475ae0035b67801c7ca2d06 (diff) | |
download | gnunet-95cdeb5c0bb1f14f3959863e6bf4675db48ea177.tar.gz gnunet-95cdeb5c0bb1f14f3959863e6bf4675db48ea177.zip |
peerstore: towards watch functionality
Diffstat (limited to 'src/peerstore/peerstore_common.c')
-rw-r--r-- | src/peerstore/peerstore_common.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c index 5783973b6..2b62abf19 100644 --- a/src/peerstore/peerstore_common.c +++ b/src/peerstore/peerstore_common.c | |||
@@ -26,6 +26,38 @@ | |||
26 | #include "peerstore_common.h" | 26 | #include "peerstore_common.h" |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Creates a hash of the given key combination | ||
30 | * | ||
31 | */ | ||
32 | void | ||
33 | PEERSTORE_hash_key(const char *sub_system, | ||
34 | const struct GNUNET_PeerIdentity *peer, | ||
35 | const char *key, | ||
36 | struct GNUNET_HashCode *ret) | ||
37 | { | ||
38 | size_t sssize; | ||
39 | size_t psize; | ||
40 | size_t ksize; | ||
41 | size_t totalsize; | ||
42 | void *block; | ||
43 | void *blockptr; | ||
44 | |||
45 | sssize = strlen(sub_system) + 1; | ||
46 | psize = sizeof(struct GNUNET_PeerIdentity); | ||
47 | ksize = strlen(sub_system) + 1; | ||
48 | totalsize = sssize + psize + ksize; | ||
49 | block = GNUNET_malloc(totalsize); | ||
50 | blockptr = block; | ||
51 | memcpy(blockptr, sub_system, sssize); | ||
52 | blockptr += sssize; | ||
53 | memcpy(blockptr, peer, psize); | ||
54 | blockptr += psize; | ||
55 | memcpy(blockptr, key, ksize); | ||
56 | GNUNET_CRYPTO_hash(block, totalsize, ret); | ||
57 | GNUNET_free(block); | ||
58 | } | ||
59 | |||
60 | /** | ||
29 | * Creates a record message ready to be sent | 61 | * Creates a record message ready to be sent |
30 | * | 62 | * |
31 | * @param sub_system sub system string | 63 | * @param sub_system sub system string |