X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fhello%2Fhello.c;h=a7aaf7d54790330eec7ad6cb481f992848857999;hb=8de34260292a2e6f7bb980dcefd8d95f5763ad25;hp=79d0edf8dac6049265d8fab6d9c7315fbd97a39f;hpb=120afa6058ba579887a9b417ec86cf06926d765e;p=oweals%2Fgnunet.git diff --git a/src/hello/hello.c b/src/hello/hello.c index 79d0edf8d..a7aaf7d54 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -479,5 +479,27 @@ GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, } +/** + * Get the peer identity from a HELLO message. + * + * @param hello the hello message + * @param peer where to store the peer's identity + * @return GNUNET_SYSERR if the HELLO was malformed + */ +int +GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, + struct GNUNET_PeerIdentity *peer) +{ + uint16_t ret = ntohs (hello->header.size); + if ((ret < sizeof (struct GNUNET_HELLO_Message)) || + (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO)) + return GNUNET_SYSERR; + GNUNET_CRYPTO_hash (&hello->publicKey, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &peer->hashPubKey); + return GNUNET_OK; +} + + /* end of hello.c */