GNUnet  0.11.x
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  */
27 
31 #include "messenger_api_message.h"
32 
34 {
37 };
38 
40 
41 static int
42 check_create (void *cls,
43  const struct GNUNET_MESSENGER_CreateMessage *msg)
44 {
46  return GNUNET_OK;
47 }
48 
49 static void
50 handle_create (void *cls,
51  const struct GNUNET_MESSENGER_CreateMessage *msg)
52 {
53  struct GNUNET_MESSENGER_Client *msg_client = cls;
54 
55  const char *name = ((const char*) msg) + sizeof(*msg);
56 
57  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name);
58 
59  setup_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL);
60 
62 }
63 
64 static void
65 handle_update (void *cls,
66  const struct GNUNET_MESSENGER_UpdateMessage *msg)
67 {
68  struct GNUNET_MESSENGER_Client *msg_client = cls;
69 
70  update_handle (msg_client->handle);
71 
73 }
74 
75 static void
76 handle_destroy (void *cls,
78 {
79  struct GNUNET_MESSENGER_Client *msg_client = cls;
80 
81  GNUNET_SERVICE_client_drop (msg_client->client);
82 }
83 
84 static int
85 check_set_name (void *cls,
86  const struct GNUNET_MESSENGER_NameMessage *msg)
87 {
89  return GNUNET_OK;
90 }
91 
92 static void
93 handle_set_name (void *cls,
94  const struct GNUNET_MESSENGER_NameMessage *msg)
95 {
96  struct GNUNET_MESSENGER_Client *msg_client = cls;
97 
98  const char *name = ((const char*) msg) + sizeof(*msg);
99 
100  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name);
101 
102  set_handle_name (msg_client->handle, name);
103 
105 }
106 
107 static void
108 handle_room_open (void *cls,
109  const struct GNUNET_MESSENGER_RoomMessage *msg)
110 {
111  struct GNUNET_MESSENGER_Client *msg_client = cls;
112 
113  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (&(msg->key)));
114 
115  if (GNUNET_YES == open_handle_room (msg_client->handle, &(msg->key)))
116  {
117  const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
118 
119  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n", GNUNET_sh2s (member_id));
120 
122  struct GNUNET_MQ_Envelope *env;
123 
125  GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
126  GNUNET_MQ_send (msg_client->handle->mq, env);
127  }
128  else
129  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n", GNUNET_h2s (&(msg->key)));
130 
132 }
133 
134 static void
135 handle_room_entry (void *cls,
136  const struct GNUNET_MESSENGER_RoomMessage *msg)
137 {
138  struct GNUNET_MESSENGER_Client *msg_client = cls;
139 
140  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (&(msg->key)), GNUNET_i2s (&(msg->door)));
141 
142  if (GNUNET_YES == entry_handle_room (msg_client->handle, &(msg->door), &(msg->key)))
143  {
144  const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
145 
146  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n", GNUNET_sh2s (member_id));
147 
149  struct GNUNET_MQ_Envelope *env;
150 
152  GNUNET_memcpy(&(response->door), &(msg->door), sizeof(msg->door));
153  GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
154  GNUNET_MQ_send (msg_client->handle->mq, env);
155  }
156  else
157  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n", GNUNET_h2s (&(msg->key)),
158  GNUNET_i2s (&(msg->door)));
159 
161 }
162 
163 static void
164 handle_room_close (void *cls,
165  const struct GNUNET_MESSENGER_RoomMessage *msg)
166 {
167  struct GNUNET_MESSENGER_Client *msg_client = cls;
168 
169  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (&(msg->key)));
170 
171  if (GNUNET_YES == close_handle_room (msg_client->handle, &(msg->key)))
172  {
173  const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
174 
175  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room with member id: %s\n", GNUNET_sh2s (member_id));
176 
178  struct GNUNET_MQ_Envelope *env;
179 
181  GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
182  GNUNET_MQ_send (msg_client->handle->mq, env);
183  }
184  else
185  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n", GNUNET_h2s (&(msg->key)));
186 
188 }
189 
190 static int
192  const struct GNUNET_MESSENGER_SendMessage *msg)
193 {
194  const uint16_t full_length = ntohs (msg->header.size);
195 
196  if (full_length < sizeof(*msg))
197  return GNUNET_NO;
198 
199  const enum GNUNET_MESSENGER_MessageFlags flags = (
200  (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
201  );
202 
203  const uint16_t length = full_length - sizeof(*msg);
204  const char *buffer = ((const char*) msg) + sizeof(*msg);
205 
206  ssize_t key_length = 0;
207 
208  if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE))
209  goto check_for_message;
210 
211  struct GNUNET_IDENTITY_PublicKey public_key;
212 
213  key_length = GNUNET_IDENTITY_read_key_from_buffer(&public_key, buffer, length);
214 
215 check_for_message:
216  if (key_length < 0)
217  return GNUNET_NO;
218 
219  const uint16_t msg_length = length - key_length;
220  const char* msg_buffer = buffer + key_length;
221 
222  struct GNUNET_MESSENGER_Message message;
223 
225  return GNUNET_NO;
226 
227  if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL))
228  return GNUNET_NO;
229 
230  if (GNUNET_YES != filter_message_sending(&message))
231  return GNUNET_NO;
232 
233  return GNUNET_OK;
234 }
235 
236 static void
238  const struct GNUNET_MESSENGER_SendMessage *msg)
239 {
240  struct GNUNET_MESSENGER_Client *msg_client = cls;
241 
242  const enum GNUNET_MESSENGER_MessageFlags flags = (
243  (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
244  );
245 
246  const struct GNUNET_HashCode *key = &(msg->key);
247  const char *buffer = ((const char*) msg) + sizeof(*msg);
248 
249  const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
250  ssize_t key_length = 0;
251 
252  struct GNUNET_IDENTITY_PublicKey public_key;
253 
254  if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
256  &public_key, buffer, length
257  );
258 
259  const uint16_t msg_length = length - key_length;
260  const char* msg_buffer = buffer + key_length;
261 
262  struct GNUNET_MESSENGER_Message message;
263  decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL);
264 
265  if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) &&
266  (GNUNET_YES != encrypt_message(&message, &public_key)))
267  {
268  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Encrypting message failed: Message got dropped!\n");
269 
270  goto end_handling;
271  }
272 
273  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n",
275 
276  if (GNUNET_YES != send_handle_message (msg_client->handle, key, &message))
277  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
279 
280 end_handling:
282 }
283 
284 static void
286  struct GNUNET_MESSENGER_SrvRoom *room,
287  const struct GNUNET_MESSENGER_Message *message,
288  const struct GNUNET_HashCode *hash)
289 {
290  struct GNUNET_MESSENGER_Client *msg_client = cls;
291 
292  if (!message)
293  {
294  send_room_message(room, msg_client->handle, create_message_request(hash));
295  return;
296  }
297 
299 
300  struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message);
301 
302  if (!member)
303  {
304  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (hash));
305  return;
306  }
307 
308  struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
309 
310  if (session)
311  notify_handle_message (msg_client->handle, get_room_key(room), session, message, hash);
312 }
313 
314 static void
316  const struct GNUNET_MESSENGER_GetMessage *msg)
317 {
318  struct GNUNET_MESSENGER_Client *msg_client = cls;
319 
320  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n", GNUNET_h2s (&(msg->key)));
321 
322  struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger, &(msg->key));
323 
324  if (!room)
325  {
326  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (&(msg->key)));
327  goto end_handling;
328  }
329 
331 
332  struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, get_handle_member_id(
333  msg_client->handle, &(msg->key)
334  ));
335 
336  if (!member)
337  {
338  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Member not valid to request a message!\n");
339  goto end_handling;
340  }
341 
343 
344  if (!session)
345  {
346  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Session not valid to request a message!\n");
347  goto end_handling;
348  }
349 
350  request_room_message (room, &(msg->hash), session, callback_found_message, msg_client);
351 
352 end_handling:
354 }
355 
356 static void*
358  struct GNUNET_SERVICE_Client *client,
359  struct GNUNET_MQ_Handle *mq)
360 {
361  struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client);
362 
363  msg_client->client = client;
364  msg_client->handle = add_service_handle (messenger, mq);
365 
366  return msg_client;
367 }
368 
369 static void
372  void *internal_cls)
373 {
374  struct GNUNET_MESSENGER_Client *msg_client = internal_cls;
375 
376  remove_service_handle (messenger, msg_client->handle);
377 
378  GNUNET_free(msg_client);
379 }
380 
388 static void
389 run (void *cls,
390  const struct GNUNET_CONFIGURATION_Handle *config,
392 {
394 
395  if (!messenger)
397 }
398 
405  &run,
408  NULL,
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 const int key_length
Fixed size of the public/private keys.
Definition: gnunet-abd.c:211
static void destroy(void *cls)
static struct MHD_Response * response
Our canonical response.
struct GNUNET_HashCode key
The key used in the DHT.
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_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, 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.
void set_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 ...
int open_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_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.
const struct GNUNET_ShortHashCode * get_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.
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
int close_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...
int entry_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_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 update_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_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.
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
int request_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.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
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
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
ssize_t GNUNET_IDENTITY_read_key_from_buffer(struct GNUNET_IDENTITY_PublicKey *key, const void *buffer, size_t len)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:994
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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:35
#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:355
#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:67
#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:531
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2325
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2244
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_signature, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
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...
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind)
Returns the minimal size in bytes to encode a message of a specific kind.
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.
struct GNUNET_IDENTITY_PublicKey pub
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:86
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:251
Handle to a service.
Definition: service.c:117
A 256-bit hashcode.