From d9dda7eda6b55b311982d99885aafd82448a057e Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Fri, 2 Apr 2010 15:16:18 +0000 Subject: [PATCH] hello api call, may be unnecessary --- src/hello/hello.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 */ -- 2.25.1