GNUnet  0.19.3
messenger_api_message.c File Reference

messenger api: client and service implementation of GNUnet MESSENGER service More...

#include "platform.h"
#include "messenger_api_message.h"
Include dependency graph for messenger_api_message.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MessageSignature
 
struct  GNUNET_MESSENGER_ShortMessage
 

Macros

#define member_size(type, member)   sizeof(((type*) NULL)->member)
 
#define max(x, y)   (x > y? x : y)
 
#define min(x, y)   (x < y? x : y)
 
#define encode_step_ext(dst, offset, src, size)
 
#define encode_step(dst, offset, src)
 
#define encode_step_key(dst, offset, src, length)
 
#define encode_step_signature(dst, offset, src, length)
 
#define decode_step_ext(src, offset, dst, size)
 
#define decode_step(src, offset, dst)
 
#define decode_step_malloc(src, offset, dst, size, zero)
 
#define decode_step_key(src, offset, dst, length)
 

Typedefs

typedef uint32_t kind_t
 

Functions

struct GNUNET_MESSENGER_Messagecreate_message (enum GNUNET_MESSENGER_MessageKind kind)
 Creates and allocates a new message with a specific kind. More...
 
struct GNUNET_MESSENGER_Messagecopy_message (const struct GNUNET_MESSENGER_Message *message)
 Creates and allocates a copy of a given message. More...
 
static void destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body)
 
void cleanup_message (struct GNUNET_MESSENGER_Message *message)
 Frees the messages body memory. More...
 
void destroy_message (struct GNUNET_MESSENGER_Message *message)
 Destroys a message and frees its memory fully. More...
 
int is_message_session_bound (const struct GNUNET_MESSENGER_Message *message)
 Returns if the message should be bound to a member session. More...
 
static void fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened)
 
static void unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message)
 
static uint16_t get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
 
uint16_t get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, int include_header)
 Returns the minimal size in bytes to encode a message of a specific kind. More...
 
static uint16_t get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body)
 
uint16_t get_message_size (const struct GNUNET_MESSENGER_Message *message, int include_header)
 Returns the exact size in bytes to encode a given message. More...
 
static uint16_t get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, int include_body)
 
static uint16_t calc_usual_padding ()
 
static uint16_t calc_padded_length (uint16_t length)
 
static void encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, char *buffer, uint16_t offset)
 
void encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, int include_header)
 Encodes a given message into a buffer of a maximal length in bytes. More...
 
static void encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer)
 
static uint16_t decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, const char *buffer, uint16_t offset)
 
int decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_header, uint16_t *padding)
 Decodes a message from a given buffer of a maximal length in bytes. More...
 
static int decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer)
 
void hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
 Calculates a hash of a given buffer with a length in bytes from a message. More...
 
void sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego)
 Signs the hash of a message with a given ego and writes the signature into the buffer as well. More...
 
int verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_IDENTITY_PublicKey *key)
 Verifies the signature of a given message and its hash with a specific public key. More...
 
int encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PublicKey *key)
 Encrypts a message using a given public key and replaces its body and kind with the now private encrypted message. More...
 
int decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PrivateKey *key)
 Decrypts a private message using a given private key and replaces its body and kind with the inner encrypted message. More...
 
struct GNUNET_MQ_Envelopepack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego, int mode)
 Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_PACK_MODE_ENVELOPE. More...
 
int filter_message_sending (const struct GNUNET_MESSENGER_Message *message)
 Returns if a specific kind of message should be sent by a client. More...
 

Detailed Description

messenger api: client and service implementation of GNUnet MESSENGER service

Author
Tobias Frisch

Definition in file messenger_api_message.c.

Macro Definition Documentation

◆ member_size

#define member_size (   type,
  member 
)    sizeof(((type*) NULL)->member)

Definition at line 182 of file messenger_api_message.c.

◆ max

#define max (   x,
 
)    (x > y? x : y)

Definition at line 336 of file messenger_api_message.c.

◆ min

#define min (   x,
 
)    (x < y? x : y)

Definition at line 364 of file messenger_api_message.c.

◆ encode_step_ext

#define encode_step_ext (   dst,
  offset,
  src,
  size 
)
Value:
do { \
GNUNET_memcpy(dst + offset, src, size); \
offset += size; \
} while (0)
static unsigned int size
Size of the "table".
Definition: peer.c:68

Definition at line 366 of file messenger_api_message.c.

◆ encode_step

#define encode_step (   dst,
  offset,
  src 
)
Value:
do { \
encode_step_ext(dst, offset, src, sizeof(*src)); \
} while (0)

Definition at line 371 of file messenger_api_message.c.

◆ encode_step_key

#define encode_step_key (   dst,
  offset,
  src,
  length 
)
Value:
do { \
src, dst + offset, length - offset \
); \
if (result < 0) \
GNUNET_break (0); \
else \
offset += result; \
} while (0)
static int result
Global testing status.
ssize_t GNUNET_IDENTITY_write_public_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
Definition: identity_api.c:890

Definition at line 375 of file messenger_api_message.c.

◆ encode_step_signature

#define encode_step_signature (   dst,
  offset,
  src,
  length 
)
Value:
do { \
src, dst + offset, length - offset \
); \
if (result < 0) \
GNUNET_break (0); \
else \
offset += result; \
} while (0)
ssize_t GNUNET_IDENTITY_write_signature_to_buffer(const struct GNUNET_IDENTITY_Signature *sig, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_Signature to a compact buffer.

Definition at line 385 of file messenger_api_message.c.

◆ decode_step_ext

#define decode_step_ext (   src,
  offset,
  dst,
  size 
)
Value:
do { \
GNUNET_memcpy(dst, src + offset, size); \
offset += size; \
} while (0)

Definition at line 527 of file messenger_api_message.c.

◆ decode_step

#define decode_step (   src,
  offset,
  dst 
)
Value:
do { \
decode_step_ext(src, offset, dst, sizeof(*dst)); \
} while (0)

Definition at line 532 of file messenger_api_message.c.

◆ decode_step_malloc

#define decode_step_malloc (   src,
  offset,
  dst,
  size,
  zero 
)
Value:
do { \
dst = GNUNET_malloc(size + zero); \
if (zero) dst[size] = 0; \
decode_step_ext(src, offset, dst, size); \
} while (0)
static const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.
#define GNUNET_malloc(size)
Wrapper around malloc.

Definition at line 536 of file messenger_api_message.c.

◆ decode_step_key

#define decode_step_key (   src,
  offset,
  dst,
  length 
)
Value:
do { \
size_t read; \
src + offset, length - offset, dst, &read \
); \
GNUNET_break(0); \
else \
offset += read; \
} while (0)
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:865
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_SYSERR

Definition at line 542 of file messenger_api_message.c.

Typedef Documentation

◆ kind_t

typedef uint32_t kind_t

Definition at line 234 of file messenger_api_message.c.

Function Documentation

◆ create_message()

struct GNUNET_MESSENGER_Message* create_message ( enum GNUNET_MESSENGER_MessageKind  kind)

Creates and allocates a new message with a specific kind.

Parameters
[in]kindKind of message
Returns
New message

Definition at line 42 of file messenger_api_message.c.

43 {
45 
46  message->header.kind = kind;
47 
48  switch (message->header.kind)
49  {
51  message->body.name.name = NULL;
52  break;
54  message->body.text.text = NULL;
55  break;
57  message->body.file.uri = NULL;
58  break;
60  message->body.privacy.length = 0;
61  message->body.privacy.data = NULL;
62  break;
63  default:
64  break;
65  }
66 
67  return message;
68 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_FILE
The file kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
struct GNUNET_MESSENGER_MessagePrivate privacy
struct GNUNET_MESSENGER_MessageText text
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_MessageFile file
char * uri
The uri of the encrypted file.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
char * name
The new name which replaces the current senders name.
uint16_t length
The length of the encrypted message.
char * data
The data of the encrypted message.
char * text
The containing text.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TEXT, GNUNET_new, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by create_message_delete(), create_message_id(), create_message_info(), create_message_invite(), create_message_join(), create_message_key(), create_message_leave(), create_message_merge(), create_message_miss(), create_message_name(), create_message_peer(), create_message_request(), create_message_text(), and get_store_message().

Here is the caller graph for this function:

◆ copy_message()

struct GNUNET_MESSENGER_Message* copy_message ( const struct GNUNET_MESSENGER_Message message)

Creates and allocates a copy of a given message.

Parameters
[in]messageMessage
Returns
New message

Definition at line 71 of file messenger_api_message.c.

72 {
73  GNUNET_assert(message);
74 
76 
77  GNUNET_memcpy(copy, message, sizeof(struct GNUNET_MESSENGER_Message));
78 
79  switch (message->header.kind)
80  {
82  copy->body.name.name = GNUNET_strdup(message->body.name.name);
83  break;
85  copy->body.text.text = GNUNET_strdup(message->body.text.text);
86  break;
88  copy->body.file.uri = GNUNET_strdup(message->body.file.uri);
89  break;
91  copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc(copy->body.privacy.length) : NULL;
92 
93  if (copy->body.privacy.data)
94  {
95  GNUNET_memcpy(copy->body.privacy.data, message->body.privacy.data, copy->body.privacy.length);
96  }
97 
98  break;
99  default:
100  break;
101  }
102 
103  return copy;
104 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_assert, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TEXT, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by forward_tunnel_message(), handle_room_message(), handle_tunnel_message(), notify_srv_handle_message(), and send_srv_handle_message().

Here is the caller graph for this function:

◆ destroy_message_body()

static void destroy_message_body ( enum GNUNET_MESSENGER_MessageKind  kind,
struct GNUNET_MESSENGER_MessageBody body 
)
static

Definition at line 107 of file messenger_api_message.c.

109 {
110  switch (kind)
111  {
113  GNUNET_free(body->name.name);
114  break;
116  GNUNET_free(body->text.text);
117  break;
119  GNUNET_free(body->file.uri);
120  break;
122  GNUNET_free(body->privacy.data);
123  break;
124  default:
125  break;
126  }
127 }
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_free, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by cleanup_message(), destroy_message(), encrypt_message(), and unfold_short_message().

Here is the caller graph for this function:

◆ cleanup_message()

void cleanup_message ( struct GNUNET_MESSENGER_Message message)

Frees the messages body memory.

Parameters
[in,out]messageMessage

Definition at line 130 of file messenger_api_message.c.

131 {
132  GNUNET_assert(message);
133 
134  destroy_message_body (message->header.kind, &(message->body));
135 }
static void destroy_message_body(enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body)

References GNUNET_MESSENGER_Message::body, destroy_message_body(), GNUNET_assert, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.

Referenced by check_recv_message(), check_send_message(), handle_recv_message(), handle_send_message(), and handle_tunnel_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_message()

void destroy_message ( struct GNUNET_MESSENGER_Message message)

Destroys a message and frees its memory fully.

Parameters
[in,out]messageMessage

Definition at line 138 of file messenger_api_message.c.

139 {
140  GNUNET_assert(message);
141 
142  destroy_message_body (message->header.kind, &(message->body));
143 
144  GNUNET_free(message);
145 }

References GNUNET_MESSENGER_Message::body, destroy_message_body(), GNUNET_assert, GNUNET_free, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.

Referenced by callback_set_handle_name(), create_message_peer(), forward_tunnel_message(), get_store_message(), handle_delete_message(), handle_room_message(), iterate_destroy_message(), iterate_destroy_messages(), notify_srv_handle_message(), send_tunnel_message(), set_srv_handle_ego(), and update_room_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_message_session_bound()

int is_message_session_bound ( const struct GNUNET_MESSENGER_Message message)

Returns if the message should be bound to a member session.

Parameters
[in]messageMessage
Returns
GNUNET_YES or GNUNET_NO

Definition at line 148 of file messenger_api_message.c.

149 {
150  GNUNET_assert(message);
151 
152  if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) ||
153  (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind) ||
154  (GNUNET_MESSENGER_KIND_NAME == message->header.kind) ||
155  (GNUNET_MESSENGER_KIND_KEY == message->header.kind) ||
156  (GNUNET_MESSENGER_KIND_ID == message->header.kind))
157  return GNUNET_YES;
158  else
159  return GNUNET_NO;
160 }
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.

References GNUNET_assert, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_NAME, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.

Referenced by send_srv_room_message(), and update_member_session_history().

Here is the caller graph for this function:

◆ fold_short_message()

static void fold_short_message ( const struct GNUNET_MESSENGER_Message message,
struct GNUNET_MESSENGER_ShortMessage shortened 
)
static

Definition at line 163 of file messenger_api_message.c.

165 {
166  shortened->kind = message->header.kind;
167 
168  GNUNET_memcpy(&(shortened->body), &(message->body), sizeof(struct GNUNET_MESSENGER_MessageBody));
169 }
The unified body of a GNUNET_MESSENGER_Message.
struct GNUNET_MESSENGER_MessageBody body
enum GNUNET_MESSENGER_MessageKind kind

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, GNUNET_memcpy, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_ShortMessage::kind.

Referenced by encrypt_message().

Here is the caller graph for this function:

◆ unfold_short_message()

static void unfold_short_message ( struct GNUNET_MESSENGER_ShortMessage shortened,
struct GNUNET_MESSENGER_Message message 
)
static

Definition at line 172 of file messenger_api_message.c.

174 {
175  destroy_message_body (message->header.kind, &(message->body));
176 
177  message->header.kind = shortened->kind;
178 
179  GNUNET_memcpy(&(message->body), &(shortened->body), sizeof(struct GNUNET_MESSENGER_MessageBody));
180 }

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, destroy_message_body(), GNUNET_memcpy, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_ShortMessage::kind.

Referenced by decrypt_message(), and encrypt_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_message_body_kind_size()

static uint16_t get_message_body_kind_size ( enum GNUNET_MESSENGER_MessageKind  kind)
static

Definition at line 185 of file messenger_api_message.c.

186 {
187  uint16_t length = 0;
188 
189  switch (kind)
190  {
192  length += member_size(struct GNUNET_MESSENGER_Message, body.info.messenger_version);
193  break;
195  length += member_size(struct GNUNET_MESSENGER_Message, body.peer.peer);
196  break;
198  length += member_size(struct GNUNET_MESSENGER_Message, body.id.id);
199  break;
201  length += member_size(struct GNUNET_MESSENGER_Message, body.miss.peer);
202  break;
204  length += member_size(struct GNUNET_MESSENGER_Message, body.merge.previous);
205  break;
207  length += member_size(struct GNUNET_MESSENGER_Message, body.request.hash);
208  break;
210  length += member_size(struct GNUNET_MESSENGER_Message, body.invite.door);
211  length += member_size(struct GNUNET_MESSENGER_Message, body.invite.key);
212  break;
214  break;
216  length += member_size(struct GNUNET_MESSENGER_Message, body.file.key);
217  length += member_size(struct GNUNET_MESSENGER_Message, body.file.hash);
218  length += member_size(struct GNUNET_MESSENGER_Message, body.file.name);
219  break;
221  length += member_size(struct GNUNET_MESSENGER_Message, body.privacy.key);
222  break;
224  length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.hash);
225  length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.delay);
226  break;
227  default:
228  break;
229  }
230 
231  return length;
232 }
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
#define member_size(type, member)

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageInvite::door, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, member_size, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, and GNUNET_MESSENGER_MessageBody::request.

Referenced by get_message_kind_size(), and get_short_message_size().

Here is the caller graph for this function:

◆ get_message_kind_size()

uint16_t get_message_kind_size ( enum GNUNET_MESSENGER_MessageKind  kind,
int  include_header 
)

Returns the minimal size in bytes to encode a message of a specific kind.

Parameters
[in]kindKind of message
[in]include_headerFlag to include header
Returns
Minimal size to encode

Definition at line 237 of file messenger_api_message.c.

239 {
240  uint16_t length = 0;
241 
242  if (GNUNET_YES == include_header)
243  {
244  length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp);
245  length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id);
246  length += member_size(struct GNUNET_MESSENGER_Message, header.previous);
247  }
248 
249  length += sizeof(kind_t);
250 
251  return length + get_message_body_kind_size (kind);
252 }
static uint16_t get_message_body_kind_size(enum GNUNET_MESSENGER_MessageKind kind)
uint32_t kind_t

References get_message_body_kind_size(), GNUNET_YES, GNUNET_MESSENGER_Message::header, member_size, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by calc_usual_padding(), check_recv_message(), check_send_message(), check_tunnel_message(), decode_message(), get_message_size(), and get_store_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_message_body_size()

static uint16_t get_message_body_size ( enum GNUNET_MESSENGER_MessageKind  kind,
const struct GNUNET_MESSENGER_MessageBody body 
)
static

Definition at line 255 of file messenger_api_message.c.

257 {
258  uint16_t length = 0;
259 
260  switch (kind)
261  {
264  break;
266  length += GNUNET_IDENTITY_public_key_get_length(&(body->join.key));
267  break;
269  length += (body->name.name ? strlen (body->name.name) : 0);
270  break;
272  length += GNUNET_IDENTITY_public_key_get_length(&(body->key.key));
273  break;
275  length += strlen (body->text.text);
276  break;
278  length += strlen (body->file.uri);
279  break;
281  length += body->privacy.length;
282  break;
283  default:
284  break;
285  }
286 
287  return length;
288 }
ssize_t GNUNET_IDENTITY_public_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:830
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_MESSENGER_MessageInfo info
struct GNUNET_IDENTITY_PublicKey host_key
The senders key to verify its signatures.
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_IDENTITY_PublicKey key
The new public key which replaces the current senders public key.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageBody::file, GNUNET_IDENTITY_public_key_get_length(), GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_MessageInfo::host_key, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by get_message_size(), and get_short_message_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_message_size()

uint16_t get_message_size ( const struct GNUNET_MESSENGER_Message message,
int  include_header 
)

Returns the exact size in bytes to encode a given message.

Parameters
[in]messageMessage
[in]include_headerFlag to include header
Returns
Size to encode

Definition at line 291 of file messenger_api_message.c.

293 {
294  GNUNET_assert(message);
295 
296  uint16_t length = 0;
297 
298  if (GNUNET_YES == include_header)
300 
301  length += get_message_kind_size (message->header.kind, include_header);
302  length += get_message_body_size (message->header.kind, &(message->body));
303 
304  return length;
305 }
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
Definition: identity_api.c:951
static uint16_t get_message_body_size(enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body)
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, int include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
struct GNUNET_IDENTITY_Signature signature
The signature of the senders private key.

References GNUNET_MESSENGER_Message::body, get_message_body_size(), get_message_kind_size(), GNUNET_assert, GNUNET_IDENTITY_signature_get_length(), GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_MessageHeader::signature.

Referenced by GNUNET_MESSENGER_send_message(), iterate_save_messages(), notify_srv_handle_message(), and pack_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_short_message_size()

static uint16_t get_short_message_size ( const struct GNUNET_MESSENGER_ShortMessage message,
int  include_body 
)
static

Definition at line 308 of file messenger_api_message.c.

310 {
311  const uint16_t minimum_size = sizeof(struct GNUNET_HashCode) + sizeof(kind_t);
312 
313  if (message)
314  return minimum_size + get_message_body_kind_size (message->kind)
315  + (include_body == GNUNET_YES? get_message_body_size (message->kind, &(message->body)) : 0);
316  else
317  return minimum_size;
318 }
A 512-bit hashcode.

References GNUNET_MESSENGER_ShortMessage::body, get_message_body_kind_size(), get_message_body_size(), GNUNET_YES, and GNUNET_MESSENGER_ShortMessage::kind.

Referenced by decode_short_message(), and encrypt_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_usual_padding()

static uint16_t calc_usual_padding ( )
static

Definition at line 321 of file messenger_api_message.c.

322 {
323  uint16_t padding = 0;
324  uint16_t kind_size;
325 
326  for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) {
328 
329  if (kind_size > padding)
330  padding = kind_size;
331  }
332 
333  return padding + GNUNET_MESSENGER_PADDING_MIN;
334 }
GNUNET_MESSENGER_MessageKind
Enum for the different supported kinds of messages.
#define GNUNET_MESSENGER_KIND_MAX
#define GNUNET_MESSENGER_PADDING_MIN

References get_message_kind_size(), GNUNET_MESSENGER_KIND_MAX, GNUNET_MESSENGER_PADDING_MIN, and GNUNET_YES.

Referenced by calc_padded_length().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_padded_length()

static uint16_t calc_padded_length ( uint16_t  length)
static

Definition at line 339 of file messenger_api_message.c.

340 {
341  static uint16_t usual_padding = 0;
342 
343  if (!usual_padding)
344  usual_padding = calc_usual_padding();
345 
346  const uint16_t padded_length = max(
348  usual_padding
349  );
350 
351  if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0)
353 
354  if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL1)
356 
357  if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL2)
359 
361 
362 }
static uint16_t calc_usual_padding()
#define max(x, y)
#define GNUNET_MESSENGER_MAX_MESSAGE_SIZE
#define GNUNET_MESSENGER_PADDING_LEVEL0
#define GNUNET_MESSENGER_PADDING_LEVEL2
#define GNUNET_MESSENGER_PADDING_LEVEL1

References calc_usual_padding(), GNUNET_MESSENGER_MAX_MESSAGE_SIZE, GNUNET_MESSENGER_PADDING_LEVEL0, GNUNET_MESSENGER_PADDING_LEVEL1, GNUNET_MESSENGER_PADDING_LEVEL2, GNUNET_MESSENGER_PADDING_MIN, and max.

Referenced by encrypt_message(), and pack_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode_message_body()

static void encode_message_body ( enum GNUNET_MESSENGER_MessageKind  kind,
const struct GNUNET_MESSENGER_MessageBody body,
uint16_t  length,
char *  buffer,
uint16_t  offset 
)
static

Definition at line 396 of file messenger_api_message.c.

401 {
402  uint32_t version;
403  switch (kind)
404  {
406  version = GNUNET_htobe32(body->info.messenger_version);
407 
408  encode_step_key(buffer, offset, &(body->info.host_key), length);
409  encode_step(buffer, offset, &version);
410  break;
412  encode_step_key(buffer, offset, &(body->join.key), length);
413  break;
415  if (body->name.name)
416  encode_step_ext(buffer, offset, body->name.name, min(length - offset, strlen(body->name.name)));
417  break;
419  encode_step_key(buffer, offset, &(body->key.key), length);
420  break;
422  encode_step(buffer, offset, &(body->peer.peer));
423  break;
425  encode_step(buffer, offset, &(body->id.id));
426  break;
428  encode_step(buffer, offset, &(body->miss.peer));
429  break;
431  encode_step(buffer, offset, &(body->merge.previous));
432  break;
434  encode_step(buffer, offset, &(body->request.hash));
435  break;
437  encode_step(buffer, offset, &(body->invite.door));
438  encode_step(buffer, offset, &(body->invite.key));
439  break;
441  encode_step_ext(buffer, offset, body->text.text, min(length - offset, strlen(body->text.text)));
442  break;
444  encode_step(buffer, offset, &(body->file.key));
445  encode_step(buffer, offset, &(body->file.hash));
446  encode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name));
447  encode_step_ext(buffer, offset, body->file.uri, min(length - offset, strlen(body->file.uri)));
448  break;
450  encode_step(buffer, offset, &(body->privacy.key));
451  encode_step_ext(buffer, offset, body->privacy.data, min(length - offset, body->privacy.length));
452  break;
454  encode_step(buffer, offset, &(body->deletion.hash));
455  encode_step(buffer, offset, &(body->deletion.delay));
456  break;
457  default:
458  break;
459  }
460 
461  if (offset >= length)
462  return;
463 
464  const uint16_t padding = length - offset;
465  const uint16_t used_padding = sizeof(padding) + sizeof(char);
466 
467  GNUNET_assert(padding >= used_padding);
468 
469  buffer[offset++] = '\0';
470 
471  if (padding > used_padding)
472  GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, buffer + offset, padding - used_padding);
473 
474  GNUNET_memcpy(buffer + length - sizeof(padding), &padding, sizeof(padding));
475 }
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_htobe32(x)
#define encode_step_ext(dst, offset, src, size)
#define encode_step(dst, offset, src)
#define min(x, y)
#define encode_step_key(dst, offset, src, length)
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageInvite invite
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
struct GNUNET_HashCode hash
The hash of the original file.
struct GNUNET_CRYPTO_SymmetricSessionKey key
The symmetric key to decrypt the file.
char name[NAME_MAX]
The name of the original file.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
uint32_t messenger_version
The version of GNUnet Messenger API.
struct GNUNET_HashCode key
The hash identifying the port of the room.
struct GNUNET_PeerIdentity door
The peer identity of an open door to a room.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_CRYPTO_EcdhePublicKey key
The ECDH key to decrypt the message.
struct GNUNET_HashCode hash
The hash of the requested message.

References GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageInvite::door, encode_step, encode_step_ext, encode_step_key, GNUNET_MESSENGER_MessageBody::file, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_htobe32, GNUNET_memcpy, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageInfo::host_key, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, min, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by encode_message(), and encode_short_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode_message()

void encode_message ( const struct GNUNET_MESSENGER_Message message,
uint16_t  length,
char *  buffer,
int  include_header 
)

Encodes a given message into a buffer of a maximal length in bytes.

Parameters
[in]messageMessage
[in]lengthMaximal length to encode
[out]bufferBuffer
[in]include_headerFlag to include header

Definition at line 478 of file messenger_api_message.c.

482 {
483  GNUNET_assert((message) && (buffer));
484 
485  uint16_t offset = 0;
486 
487  if (GNUNET_YES == include_header)
488  encode_step_signature(buffer, offset, &(message->header.signature), length);
489 
490  const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind);
491 
492  if (GNUNET_YES == include_header)
493  {
494  encode_step(buffer, offset, &(message->header.timestamp));
495  encode_step(buffer, offset, &(message->header.sender_id));
496  encode_step(buffer, offset, &(message->header.previous));
497  }
498 
499  encode_step(buffer, offset, &kind);
500 
501  encode_message_body (message->header.kind, &(message->body), length, buffer, offset);
502 }
static void encode_message_body(enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, char *buffer, uint16_t offset)
#define encode_step_signature(dst, offset, src, length)
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.

References GNUNET_MESSENGER_Message::body, encode_message_body(), encode_step, encode_step_signature, GNUNET_assert, GNUNET_htobe32, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by GNUNET_MESSENGER_send_message(), iterate_save_messages(), notify_srv_handle_message(), and pack_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode_short_message()

static void encode_short_message ( const struct GNUNET_MESSENGER_ShortMessage message,
uint16_t  length,
char *  buffer 
)
static

Definition at line 505 of file messenger_api_message.c.

508 {
509  struct GNUNET_HashCode hash;
510  uint16_t offset = sizeof(hash);
511 
512  const kind_t kind = GNUNET_htobe32((kind_t) message->kind);
513 
514  encode_step(buffer, offset, &kind);
515 
516  encode_message_body (message->kind, &(message->body), length, buffer, offset);
517 
519  buffer + sizeof(hash),
520  length - sizeof(hash),
521  &hash
522  );
523 
524  GNUNET_memcpy(buffer, &hash, sizeof(hash));
525 }
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41

References GNUNET_MESSENGER_ShortMessage::body, encode_message_body(), encode_step, GNUNET_CRYPTO_hash(), GNUNET_htobe32, GNUNET_memcpy, and GNUNET_MESSENGER_ShortMessage::kind.

Referenced by encrypt_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_message_body()

static uint16_t decode_message_body ( enum GNUNET_MESSENGER_MessageKind kind,
struct GNUNET_MESSENGER_MessageBody body,
uint16_t  length,
const char *  buffer,
uint16_t  offset 
)
static

Definition at line 555 of file messenger_api_message.c.

560 {
561  uint16_t padding = 0;
562 
563  GNUNET_memcpy(&padding, buffer + length - sizeof(padding), sizeof(padding));
564 
565  if (padding > length - offset)
566  padding = 0;
567 
568  const uint16_t end_zero = length - padding;
569 
570  if ((padding) && (buffer[end_zero] != '\0'))
571  padding = 0;
572 
573  length -= padding;
574 
575  uint32_t version;
576  switch (*kind)
577  {
579  decode_step_key(buffer, offset, &(body->info.host_key), length);
580  decode_step(buffer, offset, &version);
581 
582  body->info.messenger_version = GNUNET_be32toh(version);
583  break;
585  decode_step_key(buffer, offset, &(body->join.key), length);
586  break;
588  if (length - offset > 0)
589  decode_step_malloc(buffer, offset, body->name.name, length - offset, 1);
590  else
591  body->name.name = NULL;
592  break;
594  decode_step_key(buffer, offset, &(body->key.key), length);
595  break;
597  decode_step(buffer, offset, &(body->peer.peer));
598  break;
600  decode_step(buffer, offset, &(body->id.id));
601  break;
603  decode_step(buffer, offset, &(body->miss.peer));
604  break;
606  decode_step(buffer, offset, &(body->merge.previous));
607  break;
609  decode_step(buffer, offset, &(body->request.hash));
610  break;
612  decode_step(buffer, offset, &(body->invite.door));
613  decode_step(buffer, offset, &(body->invite.key));
614  break;
616  decode_step_malloc(buffer, offset, body->text.text, length - offset, 1);
617  break;
619  decode_step(buffer, offset, &(body->file.key));
620  decode_step(buffer, offset, &(body->file.hash));
621  decode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name));
622  decode_step_malloc(buffer, offset, body->file.uri, length - offset, 1);
623  break;
625  decode_step(buffer, offset, &(body->privacy.key));
626 
627  body->privacy.length = (length - offset);
628  decode_step_malloc(buffer, offset, body->privacy.data, length - offset, 0);
629  break;
631  decode_step(buffer, offset, &(body->deletion.hash));
632  decode_step(buffer, offset, &(body->deletion.delay));
633  break;
634  default:
636  break;
637  }
638 
639  return padding;
640 }
#define GNUNET_be32toh(x)
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
#define decode_step(src, offset, dst)
#define decode_step_key(src, offset, dst, length)
#define decode_step_malloc(src, offset, dst, size, zero)
#define decode_step_ext(src, offset, dst, size)

References GNUNET_MESSENGER_MessagePrivate::data, decode_step, decode_step_ext, decode_step_key, decode_step_malloc, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageInvite::door, GNUNET_MESSENGER_MessageBody::file, GNUNET_be32toh, GNUNET_memcpy, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageInfo::host_key, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and GNUNET_MESSENGER_MessageFile::uri.

Referenced by decode_message(), and decode_short_message().

Here is the caller graph for this function:

◆ decode_message()

int decode_message ( struct GNUNET_MESSENGER_Message message,
uint16_t  length,
const char *  buffer,
int  include_header,
uint16_t *  padding 
)

Decodes a message from a given buffer of a maximal length in bytes.

If the buffer is too small for a message of its decoded kind the function fails with resulting GNUNET_NO after decoding only the messages header.

On success the function returns GNUNET_YES.

Parameters
[out]messageMessage
[in]lengthMaximal length to decode
[in]bufferBuffer
[in]include_headerFlag to include header
[out]paddingPadding
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 643 of file messenger_api_message.c.

648 {
650  (message) &&
651  (buffer) &&
652  (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
653  );
654 
655  uint16_t offset = 0;
656 
657  if (GNUNET_YES == include_header)
658  {
660  &(message->header.signature), buffer, length - offset
661  );
662 
663  if (result < 0)
664  return GNUNET_NO;
665  else
666  offset += result;
667  }
668 
669  const uint16_t count = length - offset;
670 
671  if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
672  return GNUNET_NO;
673 
674  kind_t kind;
675 
676  if (GNUNET_YES == include_header)
677  {
678  decode_step(buffer, offset, &(message->header.timestamp));
679  decode_step(buffer, offset, &(message->header.sender_id));
680  decode_step(buffer, offset, &(message->header.previous));
681  }
682 
683  decode_step(buffer, offset, &kind);
684 
685  message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind);
686 
687  if (count < get_message_kind_size (message->header.kind, include_header))
688  return GNUNET_NO;
689 
690  const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset);
691 
692  if (padding)
693  *padding = result;
694 
695  return GNUNET_YES;
696 }
ssize_t GNUNET_IDENTITY_read_signature_from_buffer(struct GNUNET_IDENTITY_Signature *sig, const void *buffer, size_t len)
Reads a GNUNET_IDENTITY_Signature from a compact buffer.
Definition: identity_api.c:988
static uint16_t decode_message_body(enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, const char *buffer, uint16_t offset)

References GNUNET_MESSENGER_Message::body, decode_message_body(), decode_step, get_message_kind_size(), GNUNET_assert, GNUNET_be32toh, GNUNET_IDENTITY_read_signature_from_buffer(), GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, result, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by check_recv_message(), check_send_message(), check_tunnel_message(), get_store_message(), handle_recv_message(), handle_send_message(), and handle_tunnel_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_short_message()

static int decode_short_message ( struct GNUNET_MESSENGER_ShortMessage message,
uint16_t  length,
const char *  buffer 
)
static

Definition at line 699 of file messenger_api_message.c.

702 {
703  struct GNUNET_HashCode expected, hash;
704  uint16_t offset = sizeof(hash);
705 
706  if (length < get_short_message_size (NULL, GNUNET_NO))
707  return GNUNET_NO;
708 
709  GNUNET_memcpy(&hash, buffer, sizeof(hash));
710 
712  buffer + sizeof(hash),
713  length - sizeof(hash),
714  &expected
715  );
716 
717  if (0 != GNUNET_CRYPTO_hash_cmp(&hash, &expected))
718  return GNUNET_NO;
719 
720  kind_t kind;
721 
722  decode_step(buffer, offset, &kind);
723 
724  message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind);
725 
726  if (length < get_short_message_size (message, GNUNET_NO))
727  return GNUNET_NO;
728 
729  decode_message_body (&(message->kind), &(message->body), length, buffer, offset);
730 
731  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind)
732  return GNUNET_NO;
733 
734  return GNUNET_YES;
735 }
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:220
static uint16_t get_short_message_size(const struct GNUNET_MESSENGER_ShortMessage *message, int include_body)

References GNUNET_MESSENGER_ShortMessage::body, decode_message_body(), decode_step, get_short_message_size(), GNUNET_be32toh, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_cmp(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_ShortMessage::kind.

Referenced by decrypt_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_message()

void hash_message ( const struct GNUNET_MESSENGER_Message message,
uint16_t  length,
const char *  buffer,
struct GNUNET_HashCode hash 
)

Calculates a hash of a given buffer with a length in bytes from a message.

Parameters
[in]messageMessage
[in]lengthLength of buffer
[in]bufferBuffer
[out]hashHash

Definition at line 738 of file messenger_api_message.c.

742 {
743  GNUNET_assert((message) && (buffer) && (hash));
744 
745  const ssize_t offset = GNUNET_IDENTITY_signature_get_length(
746  &(message->header.signature)
747  );
748 
749  GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash);
750 }

References GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_IDENTITY_signature_get_length(), GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::signature.

Referenced by check_tunnel_message(), get_store_message(), handle_tunnel_message(), and pack_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign_message()

void sign_message ( struct GNUNET_MESSENGER_Message message,
uint16_t  length,
char *  buffer,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_Ego ego 
)

Signs the hash of a message with a given ego and writes the signature into the buffer as well.

Parameters
[in,out]messageMessage
[in]lengthLength of buffer
[out]bufferBuffer
[in]hashHash of message
[in]egoEGO

Definition at line 753 of file messenger_api_message.c.

758 {
759  GNUNET_assert((message) && (buffer) && (hash) && (ego));
760 
761  struct GNUNET_MESSENGER_MessageSignature signature;
762 
764  signature.purpose.size = htonl (sizeof(signature));
765 
766  GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
767  GNUNET_IDENTITY_sign(&(ego->priv), &signature, &(message->header.signature));
768 
769  uint16_t offset = 0;
770  encode_step_signature(buffer, offset, &(message->header.signature), length);
771 }
#define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE
Signature of a chat message.
#define GNUNET_IDENTITY_sign(priv, ps, sig)
Sign a given block with GNUNET_IDENTITY_PrivateKey.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
struct GNUNET_IDENTITY_PrivateKey priv
struct GNUNET_CRYPTO_EccSignaturePurpose purpose

References encode_step_signature, GNUNET_assert, GNUNET_IDENTITY_sign, GNUNET_memcpy, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Ego::priv, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by pack_message().

Here is the caller graph for this function:

◆ verify_message()

int verify_message ( const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash,
const struct GNUNET_IDENTITY_PublicKey key 
)

Verifies the signature of a given message and its hash with a specific public key.

The function returns GNUNET_OK if the signature was valid, otherwise GNUNET_SYSERR.

Parameters
[in]messageMessage
[in]hashHash of message
[in]keyPublic key of EGO
Returns
GNUNET_OK on success, otherwise GNUNET_SYSERR

Definition at line 774 of file messenger_api_message.c.

777 {
778  GNUNET_assert((message) && (hash) && (key));
779 
780  if (ntohl (key->type) != ntohl (message->header.signature.type))
781  return GNUNET_SYSERR;
782 
783  struct GNUNET_MESSENGER_MessageSignature signature;
784 
786  signature.purpose.size = htonl (sizeof(signature));
787 
788  GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
789 
791  &(message->header.signature), key);
792 }
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_IDENTITY_signature_verify(purp, ps, sig, pub)
Verify a given signature with GNUNET_IDENTITY_PublicKey.
uint32_t type
Type of signature.

References GNUNET_assert, GNUNET_IDENTITY_signature_verify, GNUNET_memcpy, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_SYSERR, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_IDENTITY_Signature::type.

Referenced by verify_member_session_as_sender().

Here is the caller graph for this function:

◆ encrypt_message()

int encrypt_message ( struct GNUNET_MESSENGER_Message message,
const struct GNUNET_IDENTITY_PublicKey key 
)

Encrypts a message using a given public key and replaces its body and kind with the now private encrypted message.

The function returns GNUNET_YES if the operation succeeded, otherwise GNUNET_NO.

Parameters
[in,out]messageMessage
[in]keyPublic key of EGO
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 795 of file messenger_api_message.c.

797 {
798  GNUNET_assert((message) && (key));
799 
800  struct GNUNET_MESSENGER_ShortMessage shortened;
801 
802  fold_short_message (message, &shortened);
803 
804  const uint16_t length = get_short_message_size (&shortened, GNUNET_YES);
805  const uint16_t padded_length = calc_padded_length(length);
806 
808  message->body.privacy.data = GNUNET_malloc(padded_length);
809  message->body.privacy.length = padded_length;
810 
811  encode_short_message (&shortened, padded_length, message->body.privacy.data);
812 
813  if (padded_length == GNUNET_IDENTITY_encrypt (message->body.privacy.data, padded_length, key,
814  &(message->body.privacy.key),
815  message->body.privacy.data))
816  {
817  destroy_message_body (shortened.kind, &(shortened.body));
818  return GNUNET_YES;
819  }
820  else
821  {
822  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Encrypting message failed!\n");
823 
824  unfold_short_message (&shortened, message);
825  return GNUNET_NO;
826  }
827 }
ssize_t GNUNET_IDENTITY_encrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Encrypt a block with GNUNET_IDENTITY_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is re...
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
static void fold_short_message(const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened)
static uint16_t calc_padded_length(uint16_t length)
static void encode_short_message(const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer)
static void unfold_short_message(struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message)

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, calc_padded_length(), GNUNET_MESSENGER_MessagePrivate::data, destroy_message_body(), encode_short_message(), fold_short_message(), get_short_message_size(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_encrypt(), GNUNET_log, GNUNET_malloc, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ShortMessage::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::privacy, and unfold_short_message().

Referenced by handle_send_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt_message()

int decrypt_message ( struct GNUNET_MESSENGER_Message message,
const struct GNUNET_IDENTITY_PrivateKey key 
)

Decrypts a private message using a given private key and replaces its body and kind with the inner encrypted message.

The function returns GNUNET_YES if the operation succeeded, otherwise GNUNET_NO.

Parameters
[in,out]messageMessage
[in]keyPrivate key of EGO
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 830 of file messenger_api_message.c.

832 {
833  GNUNET_assert((message) && (key));
834 
835  if (message->body.privacy.length != GNUNET_IDENTITY_decrypt (message->body.privacy.data, message->body.privacy.length,
836  key, &(message->body.privacy.key),
837  message->body.privacy.data))
838  {
839  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decrypting message failed!\n");
840 
841  return GNUNET_NO;
842  }
843 
844  struct GNUNET_MESSENGER_ShortMessage shortened;
845 
846  if (GNUNET_YES != decode_short_message (&shortened, message->body.privacy.length, message->body.privacy.data))
847  {
848  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decoding decrypted message failed!\n");
849 
850  return GNUNET_NO;
851  }
852 
853  unfold_short_message (&shortened, message);
854 
855  return GNUNET_YES;
856 }
ssize_t GNUNET_IDENTITY_decrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Decrypt a given block with GNUNET_IDENTITY_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ...
static int decode_short_message(struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer)

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, decode_short_message(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_decrypt(), GNUNET_log, GNUNET_NO, GNUNET_YES, key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::privacy, and unfold_short_message().

Referenced by notify_srv_handle_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_message()

struct GNUNET_MQ_Envelope* pack_message ( struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_Ego ego,
int  mode 
)

Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_PACK_MODE_ENVELOPE.

Independent of the mode the message will be hashed if hash is not NULL and it will be signed if the ego is not NULL.

Parameters
[out]messageMessage
[out]hashHash of message
[in]egoEGO to sign
[in]modeMode of packing
Returns
Envelope or NULL

Definition at line 859 of file messenger_api_message.c.

863 {
864  GNUNET_assert(message);
865 
866  if (ego)
867  message->header.signature.type = ego->priv.type;
868 
869  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Packing message kind=%u and sender: %s\n",
870  message->header.kind, GNUNET_sh2s(&(message->header.sender_id)));
871 
872  struct GNUNET_MessageHeader *header;
873 
874  const uint16_t length = get_message_size (message, GNUNET_YES);
875  const uint16_t padded_length = calc_padded_length(length);
876 
877  struct GNUNET_MQ_Envelope *env;
878  char *buffer;
879 
881  {
882  env = GNUNET_MQ_msg_extra(header, padded_length, GNUNET_MESSAGE_TYPE_CADET_CLI);
883 
884  buffer = (char*) &(header[1]);
885  }
886  else
887  {
888  env = NULL;
889 
890  buffer = GNUNET_malloc(padded_length);
891  }
892 
893  encode_message (message, padded_length, buffer, GNUNET_YES);
894 
895  if (hash)
896  {
897  hash_message (message, length, buffer, hash);
898 
899  if (ego)
900  sign_message (message, length, buffer, hash, ego);
901  }
902 
904  GNUNET_free(buffer);
905 
906  return env;
907 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:62
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
void sign_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego)
Signs the hash of a message with a given ego and writes the signature into the buffer as well.
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, int include_header)
Encodes a given message into a buffer of a maximal length in bytes.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, int include_header)
Returns the exact size in bytes to encode a given message.
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE
uint32_t type
Type of public key.
Header for all communications.

References calc_padded_length(), encode_message(), env, get_message_size(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CADET_CLI, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, GNUNET_MQ_msg_extra, GNUNET_sh2s(), GNUNET_YES, hash_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, mode, GNUNET_MESSENGER_Ego::priv, GNUNET_MESSENGER_MessageHeader::sender_id, sign_message(), GNUNET_MESSENGER_MessageHeader::signature, GNUNET_IDENTITY_PrivateKey::type, and GNUNET_IDENTITY_Signature::type.

Referenced by forward_tunnel_message(), iterate_send_room_message(), and pack_srv_room_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_message_sending()

int filter_message_sending ( const struct GNUNET_MESSENGER_Message message)

Returns if a specific kind of message should be sent by a client.

The function returns GNUNET_YES or GNUNET_NO for recommendations and GNUNET_SYSERR for specific kinds of messages which should not be sent manually at all.

Parameters
[in]messageMessage

Definition at line 910 of file messenger_api_message.c.

911 {
912  switch (message->header.kind)
913  {
915  return GNUNET_SYSERR; // Reserved for connection handling only!
917  return GNUNET_NO; // Use #GNUNET_MESSENGER_enter_room(...) instead!
919  return GNUNET_NO; // Use #GNUNET_MESSENGER_close_room(...) instead!
921  return GNUNET_YES;
923  return GNUNET_NO; // Use #GNUNET_MESSENGER_update(...) instead!
925  return GNUNET_NO; // Use #GNUNET_MESSENGER_open_room(...) instead!
927  return GNUNET_SYSERR; // Reserved for member id handling only!
929  return GNUNET_SYSERR; // Reserved for connection handling only!
931  return GNUNET_YES;
933  return GNUNET_YES;
935  return GNUNET_YES;
937  return GNUNET_YES;
939  return GNUNET_YES;
941  return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead!
943  return GNUNET_YES;
944  default:
945  return GNUNET_SYSERR;
946  }
947 }

Referenced by check_send_message(), and GNUNET_MESSENGER_send_message().

Here is the caller graph for this function: