From: Nathan S. Evans Date: Fri, 2 Apr 2010 15:16:18 +0000 (+0000) Subject: hello api call, may be unnecessary X-Git-Tag: initial-import-from-subversion-38251~22315 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d9dda7eda6b55b311982d99885aafd82448a057e;p=oweals%2Fgnunet.git hello api call, may be unnecessary --- diff --git a/src/hello/hello.c b/src/hello/hello.c index dfcc31dc2..4ddeebd03 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -510,4 +510,23 @@ GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, return GNUNET_OK; } +/** + * Get the header from a HELLO message, used so other code + * can correctly send HELLO messages. + * + * @param hello the hello message + * + * @return header or NULL if the HELLO was malformed + */ +struct GNUNET_MessageHeader * +GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello) +{ + uint16_t ret = ntohs (hello->header.size); + if ((ret < sizeof (struct GNUNET_HELLO_Message)) || + (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO)) + return NULL; + + return &hello->header; +} + /* end of hello.c */