GNUnet  0.19.4
gnunet-service-messenger.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2020--2021 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
28 
32 #include "messenger_api_message.h"
33 
35 {
38 };
39 
41 
42 static int
43 check_create (void *cls,
44  const struct GNUNET_MESSENGER_CreateMessage *msg)
45 {
47  return GNUNET_OK;
48 }
49 
50 static void
51 handle_create (void *cls,
52  const struct GNUNET_MESSENGER_CreateMessage *msg)
53 {
54  struct GNUNET_MESSENGER_Client *msg_client = cls;
55 
56  const char *name = ((const char*) msg) + sizeof(*msg);
57 
58  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name);
59 
60  setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL);
61 
63 }
64 
65 static void
66 handle_update (void *cls,
67  const struct GNUNET_MESSENGER_UpdateMessage *msg)
68 {
69  struct GNUNET_MESSENGER_Client *msg_client = cls;
70 
71  update_srv_handle (msg_client->handle);
72 
74 }
75 
76 static void
77 handle_destroy (void *cls,
79 {
80  struct GNUNET_MESSENGER_Client *msg_client = cls;
81 
82  GNUNET_SERVICE_client_drop (msg_client->client);
83 }
84 
85 static int
86 check_set_name (void *cls,
87  const struct GNUNET_MESSENGER_NameMessage *msg)
88 {
90  return GNUNET_OK;
91 }
92 
93 static void
94 handle_set_name (void *cls,
95  const struct GNUNET_MESSENGER_NameMessage *msg)
96 {
97  struct GNUNET_MESSENGER_Client *msg_client = cls;
98 
99  const char *name = ((const char*) msg) + sizeof(*msg);
100 
101  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name);
102 
103  set_srv_handle_name (msg_client->handle, name);
104 
106 }
107 
108 static void
109 handle_room_open (void *cls,
110  const struct GNUNET_MESSENGER_RoomMessage *msg)
111 {
112  struct GNUNET_MESSENGER_Client *msg_client = cls;
113 
114  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (
115  &(msg->key)));
116 
117  if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key)))
118  {
119  const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
120  msg_client->handle, &(msg->key));
121 
122  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n",
123  GNUNET_sh2s (member_id));
124 
126  struct GNUNET_MQ_Envelope *env;
127 
129  GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
130  GNUNET_MQ_send (msg_client->handle->mq, env);
131  }
132  else
133  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n",
134  GNUNET_h2s (&(msg->key)));
135 
137 }
138 
139 static void
140 handle_room_entry (void *cls,
141  const struct GNUNET_MESSENGER_RoomMessage *msg)
142 {
143  struct GNUNET_MESSENGER_Client *msg_client = cls;
144 
145  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (
146  &(msg->key)), GNUNET_i2s (&(msg->door)));
147 
148  if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door),
149  &(msg->key)))
150  {
151  const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
152  msg_client->handle, &(msg->key));
153 
154  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n",
155  GNUNET_sh2s (member_id));
156 
158  struct GNUNET_MQ_Envelope *env;
159 
161  GNUNET_memcpy (&(response->door), &(msg->door), sizeof(msg->door));
162  GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
163  GNUNET_MQ_send (msg_client->handle->mq, env);
164  }
165  else
166  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n",
167  GNUNET_h2s (&(msg->key)),
168  GNUNET_i2s (&(msg->door)));
169 
171 }
172 
173 static void
174 handle_room_close (void *cls,
175  const struct GNUNET_MESSENGER_RoomMessage *msg)
176 {
177  struct GNUNET_MESSENGER_Client *msg_client = cls;
178 
179  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (
180  &(msg->key)));
181 
182  if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key)))
183  {
184  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n",
185  GNUNET_h2s (&(msg->key)));
186 
188  struct GNUNET_MQ_Envelope *env;
189 
191  GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
192  GNUNET_MQ_send (msg_client->handle->mq, env);
193  }
194  else
195  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n",
196  GNUNET_h2s (&(msg->key)));
197 
199 }
200 
201 static int
203  const struct GNUNET_MESSENGER_SendMessage *msg)
204 {
205  const uint16_t full_length = ntohs (msg->header.size);
206 
207  if (full_length < sizeof(*msg))
208  return GNUNET_NO;
209 
210  const enum GNUNET_MESSENGER_MessageFlags flags = (
211  (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
212  );
213 
214  const uint16_t length = full_length - sizeof(*msg);
215  const char *buffer = ((const char*) msg) + sizeof(*msg);
216  struct GNUNET_IDENTITY_PublicKey public_key;
217 
218 
219  size_t key_length = 0;
220 
221  if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE))
222  if (GNUNET_SYSERR ==
224  &public_key,
225  &key_length))
226  return GNUNET_NO;
227 
228  const uint16_t msg_length = length - key_length;
229  const char *msg_buffer = buffer + key_length;
230 
231  struct GNUNET_MESSENGER_Message message;
232 
234  return GNUNET_NO;
235 
236  if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO,
237  NULL))
238  return GNUNET_NO;
239 
240  const int allowed = filter_message_sending (&message);
241 
242  cleanup_message (&message);
243  return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO;
244 }
245 
246 static void
248  const struct GNUNET_MESSENGER_SendMessage *msg)
249 {
250  struct GNUNET_MESSENGER_Client *msg_client = cls;
251 
252  const enum GNUNET_MESSENGER_MessageFlags flags = (
253  (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
254  );
255 
256  const struct GNUNET_HashCode *key = &(msg->key);
257  const char *buffer = ((const char*) msg) + sizeof(*msg);
258 
259  const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
260  size_t key_length = 0;
261 
262  struct GNUNET_IDENTITY_PublicKey public_key;
263 
264  if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
265  {
268  length,
269  &public_key,
270  &key_length));
271  }
272  const uint16_t msg_length = length - key_length;
273  const char*msg_buffer = buffer + key_length;
274 
275  struct GNUNET_MESSENGER_Message message;
276  decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL);
277 
278  if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) &&
279  (GNUNET_YES != encrypt_message (&message, &public_key)))
280  {
282  "Encrypting message failed: Message got dropped!\n");
283 
284  goto end_handling;
285  }
286 
287  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n",
289  key));
290 
291  if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message))
292  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
294  GNUNET_h2s (key));
295 
296  end_handling:
297  cleanup_message (&message);
298 
300 }
301 
302 static void
304  struct GNUNET_MESSENGER_SrvRoom *room,
305  const struct GNUNET_MESSENGER_Message *message,
306  const struct GNUNET_HashCode *hash)
307 {
308  struct GNUNET_MESSENGER_Client *msg_client = cls;
309 
310  if (! message)
311  {
313  hash));
314  return;
315  }
316 
318 
319  struct GNUNET_MESSENGER_Member *member = get_store_member_of (store, message);
320 
321  if (! member)
322  {
323  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n",
324  GNUNET_h2s (hash));
325  return;
326  }
327 
329  member, message, hash);
330 
331  if (session)
332  notify_srv_handle_message (msg_client->handle, room, session, message,
333  hash);
334 }
335 
336 static void
338  const struct GNUNET_MESSENGER_GetMessage *msg)
339 {
340  struct GNUNET_MESSENGER_Client *msg_client = cls;
341 
342  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n",
343  GNUNET_h2s (&(msg->key)));
344 
346  &(msg->key));
347 
348  if (! room)
349  {
350  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (
351  &(msg->key)));
352  goto end_handling;
353  }
354 
355  struct GNUNET_MESSENGER_MemberStore *member_store =
357 
358  struct GNUNET_MESSENGER_Member *member = get_store_member (member_store,
360  msg_client->
361  handle,
362  &(msg->key)
363  ));
364 
365  if (! member)
366  {
368  "Member not valid to request a message!\n");
369  goto end_handling;
370  }
371 
373  &(
375  msg_client
376  ->
377  handle)
378  ->pub));
379 
380  if (! session)
381  {
383  "Session not valid to request a message!\n");
384  goto end_handling;
385  }
386 
387  request_srv_room_message (room, &(msg->hash), session, callback_found_message,
388  msg_client);
389 
390  end_handling:
392 }
393 
394 static void*
396  struct GNUNET_SERVICE_Client *client,
397  struct GNUNET_MQ_Handle *mq)
398 {
399  struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new (struct
401 
402  msg_client->client = client;
403  msg_client->handle = add_service_handle (messenger, mq);
404 
405  return msg_client;
406 }
407 
408 static void
411  void *internal_cls)
412 {
413  struct GNUNET_MESSENGER_Client *msg_client = internal_cls;
414 
415  remove_service_handle (messenger, msg_client->handle);
416 
417  GNUNET_free (msg_client);
418 }
419 
427 static void
428 run (void *cls,
429  const struct GNUNET_CONFIGURATION_Handle *config,
431 {
433 
434  if (! messenger)
436 }
437 
444  &run,
447  NULL,
451  GNUNET_MQ_hd_fixed_size (update,
453  struct
457  struct
459  GNUNET_MQ_hd_var_size (set_name,
461  struct
464  struct GNUNET_MESSENGER_RoomMessage, NULL),
466  struct GNUNET_MESSENGER_RoomMessage, NULL),
468  struct GNUNET_MESSENGER_RoomMessage, NULL),
474  struct
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void destroy(void *cls)
static struct MHD_Response * response
Our canonical response.
struct GNUNET_HashCode key
The key used in the DHT.
static int create
Create DID Document Flag.
Definition: gnunet-did.c:71
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void handle_create(void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
GNUNET_SERVICE_MAIN(GNUNET_MESSENGER_SERVICE_NAME, GNUNET_SERVICE_OPTION_NONE, &run, &callback_client_connect, &callback_client_disconnect, NULL, GNUNET_MQ_hd_var_size(create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL), GNUNET_MQ_hd_fixed_size(update, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, struct GNUNET_MESSENGER_UpdateMessage, NULL), GNUNET_MQ_hd_fixed_size(destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL), GNUNET_MQ_hd_var_size(set_name, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, struct GNUNET_MESSENGER_NameMessage, NULL), GNUNET_MQ_hd_fixed_size(room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_fixed_size(room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_fixed_size(room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_var_size(send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL), GNUNET_MQ_hd_fixed_size(get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_GetMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void handle_destroy(void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service)
Setup MESSENGER internals.
static void handle_room_close(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
static void handle_room_open(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_room_entry(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_set_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
static void callback_client_disconnect(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
static void handle_update(void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg)
static int check_create(void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
static int check_set_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
struct GNUNET_MESSENGER_Service * messenger
static void handle_get_message(void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
static void callback_found_message(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
static int check_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
static void * callback_client_connect(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
GNUnet MESSENGER service.
void notify_srv_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Notifies the handle that a new message was received or sent.
int close_srv_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Removes the membership of the room using a specific key and closes it if no other handle from this se...
const struct GNUNET_ShortHashCode * get_srv_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
int open_srv_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Makes a given handle a member of the room using a specific key and opens the room from the handles se...
void setup_srv_handle_name(struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
Tries to set the name and EGO key of a handle initially by looking up a specific name.
int entry_srv_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Makes a given handle a member of the room using a specific key and enters the room through a tunnel t...
int send_srv_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle to the room using a specific key.
void set_srv_handle_name(struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
Tries to rename the handle which implies renaming the EGO its using and moving all related data into ...
const struct GNUNET_MESSENGER_Ego * get_srv_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
void update_srv_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Tries to change the key pair of an EGO of a handle under the same name and informs all rooms about th...
GNUnet MESSENGER service.
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_MESSENGER_MemberSession * get_member_session_of(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the member session of a member using a public key which can verify the signature of a given m...
struct GNUNET_MESSENGER_Member * get_store_member_of(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message)
Returns the member of a store using a sender id of a given message.
struct GNUNET_MESSENGER_Member * get_store_member(const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Returns the member in a store identified by a given id.
struct GNUNET_MESSENGER_Message * create_message_request(const struct GNUNET_HashCode *hash)
Creates and allocates a new request message containing the hash of a missing message.
int send_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
int request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
void remove_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes a handle from a service and destroys it.
struct GNUNET_MESSENGER_SrvHandle * add_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
Creates and adds a new handle to a service using a given message queue.
struct GNUNET_MESSENGER_SrvRoom * get_service_room(const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key)
Returns the room identified by a given key for a service.
struct GNUNET_MESSENGER_Service * create_service(const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle)
Creates and allocates a new service using a given config and a GNUnet service handle.
GNUnet MESSENGER service.
static void send_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Send a message to another peer.
static const struct GNUNET_CONFIGURATION_Handle * config
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
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling Compatible flags can be OR'ed togethe...
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:36
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
int filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns if a specific kind of message should be sent by a client.
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 encry...
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.
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.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.
messenger api: client and service implementation of GNUnet MESSENGER service
const char * name
static const char * get_message(void **buf, int *len, void *cls)
A 512-bit hashcode.
An identity key as per LSD0001.
struct GNUNET_SERVICE_Client * client
struct GNUNET_MESSENGER_SrvHandle * handle
Message to create a handle for a client.
Message to destroy the handle for a client.
Message to request something from a room.
struct GNUNET_MESSENGER_MemberStore * store
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
Message to receive the current name of a handle.
General message to confirm interaction with a room.
Message to send something into a room.
Message to update the handle (its EGO key) for a client.
Handle to a message queue.
Definition: mq.c:87
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Handle to a client that is connected to a service.
Definition: service.c:252
Handle to a service.
Definition: service.c:118
A 256-bit hashcode.