GNUnet 0.28.0-dev.3-20-gf1136b0b8
 
Loading...
Searching...
No Matches
gnunet-service-messenger.c File Reference
Include dependency graph for gnunet-service-messenger.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_Client
 

Functions

static void handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
 
static void handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
 
static enum GNUNET_GenericReturnValue check_room_initial_key (const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void initialize_handle_via_key (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static enum GNUNET_GenericReturnValue check_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static enum GNUNET_GenericReturnValue check_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_sync (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static enum GNUNET_GenericReturnValue check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
 
static void handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *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 void handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
 
static void * callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 
static void callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service)
 Setup MESSENGER internals.
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), GNUNET_MESSENGER_SERVICE_NAME, GNUNET_SERVICE_OPTION_NONE, &run, &callback_client_connect, &callback_client_disconnect, NULL, GNUNET_MQ_hd_fixed_size(create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL), GNUNET_MQ_hd_fixed_size(destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL), GNUNET_MQ_hd_var_size(room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_var_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_hd_fixed_size(room_sync, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro.
 

Variables

struct GNUNET_MESSENGER_Servicemessenger
 

Function Documentation

◆ handle_create()

static void handle_create ( void *  cls,
const struct GNUNET_MESSENGER_CreateMessage msg 
)
static

Definition at line 43 of file gnunet-service-messenger.c.

45{
46 struct GNUNET_MESSENGER_Client *msg_client;
47
48 GNUNET_assert (cls);
49
50 msg_client = cls;
51
52 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created\n");
53
55}
#define GNUNET_log(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2434
struct GNUNET_SERVICE_Client * client

References GNUNET_MESSENGER_Client::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and GNUNET_SERVICE_client_continue().

Here is the call graph for this function:

◆ handle_destroy()

static void handle_destroy ( void *  cls,
const struct GNUNET_MESSENGER_DestroyMessage msg 
)
static

Definition at line 59 of file gnunet-service-messenger.c.

61{
62 struct GNUNET_MESSENGER_Client *msg_client;
63
64 GNUNET_assert (cls);
65
66 msg_client = cls;
67
68 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle destroyed\n");
69
71}
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2463

References GNUNET_MESSENGER_Client::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and GNUNET_SERVICE_client_drop().

Here is the call graph for this function:

◆ check_room_initial_key()

static enum GNUNET_GenericReturnValue check_room_initial_key ( const struct GNUNET_MESSENGER_RoomMessage msg)
static

Definition at line 75 of file gnunet-service-messenger.c.

76{
77 uint16_t full_length;
78 uint16_t msg_length;
79 const char *msg_buffer;
80
82
83 full_length = ntohs (msg->header.size);
84
85 if (full_length < sizeof(*msg))
86 return GNUNET_NO;
87
88 msg_length = full_length - sizeof(*msg);
89 msg_buffer = ((const char*) msg) + sizeof(*msg);
90
91 if (0 == msg_length)
92 return GNUNET_OK;
93
94 {
96 size_t key_len;
97
99 msg_length,
100 &key, &key_len
101 ))
102 return GNUNET_NO;
103
104 return key_len == msg_length ? GNUNET_OK : GNUNET_NO;
105 }
106}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_HashCode key
The key used in the DHT.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_blindable_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_NO
An identity key as per LSD0001.

References GNUNET_assert, GNUNET_CRYPTO_read_blindable_pk_from_buffer(), GNUNET_NO, GNUNET_OK, key, msg, and GNUNET_MessageHeader::size.

Referenced by check_room_entry(), and check_room_open().

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

◆ initialize_handle_via_key()

static void initialize_handle_via_key ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 110 of file gnunet-service-messenger.c.

112{
113 uint16_t full_length;
114 uint16_t msg_length;
115 const char *msg_buffer;
116
117 GNUNET_assert ((handle) && (msg));
118
119 full_length = ntohs (msg->header.size);
120 msg_length = full_length - sizeof(*msg);
121 msg_buffer = ((const char*) msg) + sizeof(*msg);
122
123 if (msg_length > 0)
124 {
126 size_t key_len;
127
129 msg_length,
130 &key,
131 &key_len))
133 else
135 "Initialization failed while reading invalid key!\n");
136 }
137 else
138 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Initialization is missing key!\n");
139}
void set_srv_handle_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Sets the public key of a given handle.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_assert, GNUNET_CRYPTO_read_blindable_pk_from_buffer(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, handle, key, msg, set_srv_handle_key(), and GNUNET_MessageHeader::size.

Referenced by handle_room_entry(), and handle_room_open().

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

◆ check_room_open()

static enum GNUNET_GenericReturnValue check_room_open ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 143 of file gnunet-service-messenger.c.

145{
147}
static enum GNUNET_GenericReturnValue check_room_initial_key(const struct GNUNET_MESSENGER_RoomMessage *msg)

References check_room_initial_key(), and msg.

Here is the call graph for this function:

◆ handle_room_open()

static void handle_room_open ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 151 of file gnunet-service-messenger.c.

153{
154 struct GNUNET_MESSENGER_Client *msg_client;
155
156 GNUNET_assert ((cls) && (msg));
157
158 msg_client = cls;
159
160 initialize_handle_via_key (msg_client->handle, msg);
161
162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (
163 &(msg->key)));
164
165 if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key)))
166 {
167 sync_srv_handle_room (msg_client->handle,
169 &(msg->key), &(msg->previous), &(msg->epoch), NULL);
170 }
171 else
172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n",
173 GNUNET_h2s (&(msg->key)));
174
176}
static void initialize_handle_via_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_RoomMessage *msg)
void sync_srv_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, uint16_t response_type, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *previous, const struct GNUNET_HashCode *epoch, const struct GNUNET_PeerIdentity *door)
Starts merging message hashes until the state from a room of a given handle using a specific key is f...
enum GNUNET_GenericReturnValue 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...
@ GNUNET_YES
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
struct GNUNET_MESSENGER_SrvHandle * handle

References GNUNET_MESSENGER_Client::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, initialize_handle_via_key(), msg, open_srv_handle_room(), and sync_srv_handle_room().

Here is the call graph for this function:

◆ check_room_entry()

static enum GNUNET_GenericReturnValue check_room_entry ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 180 of file gnunet-service-messenger.c.

182{
184}

References check_room_initial_key(), and msg.

Here is the call graph for this function:

◆ handle_room_entry()

static void handle_room_entry ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 188 of file gnunet-service-messenger.c.

190{
191 struct GNUNET_MESSENGER_Client *msg_client;
192 struct GNUNET_PeerIdentity door;
193
194 GNUNET_assert ((cls) && (msg));
195
196 msg_client = cls;
197
198 initialize_handle_via_key (msg_client->handle, msg);
199 memset (&door, 0, sizeof (door));
200
201 if ((! GNUNET_is_zero (&(msg->door))) ||
203 GNUNET_memcpy (&door, &(msg->door), sizeof (door));
204
205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (
206 &(msg->key)), GNUNET_i2s (&door));
207
208 if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &door, &(msg->key
209 )))
210 {
211 sync_srv_handle_room (msg_client->handle,
213 &(msg->key), &(msg->previous), &(msg->epoch), &door);
214 }
215 else
216 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n",
217 GNUNET_h2s (&(msg->key)),
218 GNUNET_i2s (&door));
219
221}
struct GNUNET_MESSENGER_Service * messenger
enum GNUNET_GenericReturnValue 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...
enum GNUNET_GenericReturnValue get_service_peer_identity(struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
Tries to write the peer identity of the peer running a service on to the peer parameter.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
The identity of the host (wraps the signing key of the peer).

References GNUNET_MESSENGER_Client::client, entry_srv_handle_room(), get_service_peer_identity(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_i2s(), GNUNET_is_zero, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, initialize_handle_via_key(), messenger, msg, and sync_srv_handle_room().

Here is the call graph for this function:

◆ handle_room_close()

static void handle_room_close ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 225 of file gnunet-service-messenger.c.

227{
228 struct GNUNET_MESSENGER_Client *msg_client;
229
230 GNUNET_assert (cls);
231
232 msg_client = cls;
233
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (
235 &(msg->key)));
236
237 if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key)))
238 {
239 sync_srv_handle_room (msg_client->handle,
241 &(msg->key), &(msg->previous), &(msg->epoch), NULL);
242 }
243 else
244 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n",
245 GNUNET_h2s (&(msg->key)));
246
248}
enum GNUNET_GenericReturnValue 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...
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE

References GNUNET_MESSENGER_Client::client, close_srv_handle_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, msg, and sync_srv_handle_room().

Here is the call graph for this function:

◆ handle_room_sync()

static void handle_room_sync ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 252 of file gnunet-service-messenger.c.

254{
255 struct GNUNET_MESSENGER_Client *msg_client;
256
257 GNUNET_assert (cls);
258
259 msg_client = cls;
260
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Syncing room: %s\n",
262 GNUNET_h2s (&(msg->key)));
263
264 sync_srv_handle_room (msg_client->handle,
266 &(msg->key), &(msg->previous), &(msg->epoch), NULL);
267
269}
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC

References GNUNET_MESSENGER_Client::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_SERVICE_client_continue(), GNUNET_MESSENGER_Client::handle, msg, and sync_srv_handle_room().

Here is the call graph for this function:

◆ check_send_message()

static enum GNUNET_GenericReturnValue check_send_message ( void *  cls,
const struct GNUNET_MESSENGER_SendMessage msg 
)
static

Definition at line 273 of file gnunet-service-messenger.c.

275{
276 uint16_t full_length;
277 uint16_t msg_length;
278 const char *msg_buffer;
279 struct GNUNET_MESSENGER_Message message;
280
282
283 full_length = ntohs (msg->header.size);
284
285 if (full_length < sizeof(*msg))
286 return GNUNET_NO;
287
288 msg_length = full_length - sizeof(*msg);
289 msg_buffer = ((const char*) msg) + sizeof(*msg);
290
292 GNUNET_YES))
293 {
294 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Too short message: %s\n", GNUNET_h2s (
295 &(msg->key)));
296 return GNUNET_NO;
297 }
298
299 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer,
301 NULL))
302 {
303 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Decoding message failed: %s\n",
304 GNUNET_h2s (
305 &(msg->key)));
306 return GNUNET_NO;
307 }
308
309 {
310 enum GNUNET_GenericReturnValue allowed;
311 allowed = filter_message_sending (&message);
312
313 if (GNUNET_SYSERR == allowed)
315 "Sending message not allowed: %s to %s\n",
316 GNUNET_MESSENGER_name_of_kind (message.header.kind),
317 GNUNET_h2s (&(msg->key)));
318
319 cleanup_message (&message);
320 return GNUNET_SYSERR != allowed? GNUNET_OK : GNUNET_NO;
321 }
322}
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_SYSERR
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
enum GNUNET_GenericReturnValue filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message should be sent by a client.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
enum GNUNET_GenericReturnValue decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximum length in bytes.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.

References cleanup_message(), decode_message(), filter_message_sending(), get_message_kind_size(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, msg, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_send_message()

static void handle_send_message ( void *  cls,
const struct GNUNET_MESSENGER_SendMessage msg 
)
static

Definition at line 326 of file gnunet-service-messenger.c.

328{
329 struct GNUNET_MESSENGER_Client *msg_client;
330 const struct GNUNET_HashCode *key;
331 const char *msg_buffer;
332 uint16_t msg_length;
333
334 GNUNET_assert ((cls) && (msg));
335
336 msg_client = cls;
337
338 key = &(msg->key);
339 msg_buffer = ((const char*) msg) + sizeof(*msg);
340 msg_length = ntohs (msg->header.size) - sizeof(*msg);
341
342 {
343 struct GNUNET_MESSENGER_Message message;
344 decode_message (&message, msg_length, msg_buffer, GNUNET_YES, NULL);
345
346 if ((GNUNET_YES != msg_client->handle->service->group_keys) &&
347 (GNUNET_MESSENGER_KIND_GROUP == message.header.kind))
348 goto skip_message;
349
350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s (by %s)\n",
351 GNUNET_MESSENGER_name_of_kind (message.header.kind),
352 GNUNET_h2s (key),
353 GNUNET_sh2s (&(message.header.sender_id)));
354
355 if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message
356 ))
357 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
358 GNUNET_MESSENGER_name_of_kind (message.header.kind),
359 GNUNET_h2s (key));
360
361skip_message:
362 cleanup_message (&message);
363 }
364
366}
enum GNUNET_GenericReturnValue 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.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
@ GNUNET_MESSENGER_KIND_GROUP
The group kind.
A 512-bit hashcode.
enum GNUNET_GenericReturnValue group_keys
struct GNUNET_MESSENGER_Service * service

References cleanup_message(), GNUNET_MESSENGER_Client::client, decode_message(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_GROUP, GNUNET_MESSENGER_name_of_kind(), GNUNET_SERVICE_client_continue(), GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_Service::group_keys, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, msg, send_srv_handle_message(), GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_SrvHandle::service, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ callback_found_message()

static void callback_found_message ( void *  cls,
struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)
static

Definition at line 370 of file gnunet-service-messenger.c.

374{
375 struct GNUNET_MESSENGER_Client *msg_client;
376 struct GNUNET_MESSENGER_SenderSession session;
377
378 GNUNET_assert ((cls) && (room) && (hash));
379
380 msg_client = cls;
381
382 if (! message)
383 {
385 struct GNUNET_MQ_Envelope *env;
386
388 "Notifying client about missing message: %s\n",
389 GNUNET_h2s (hash));
390
393 GNUNET_memcpy (&(response->key), &(room->key), sizeof(room->key));
394 GNUNET_memcpy (&(response->hash), hash, sizeof(*hash));
395 GNUNET_MQ_send (msg_client->handle->mq, env);
396 return;
397 }
398
399 if (GNUNET_YES == is_peer_message (message))
400 {
401 struct GNUNET_MESSENGER_PeerStore *store;
402
403 store = get_srv_room_peer_store (room);
404 session.peer = get_store_peer_of (store, message, hash);
405
406 if (! session.peer)
407 {
409 "Peer session from sender of message (%s) unknown!\n",
410 GNUNET_h2s (hash));
411 return;
412 }
413 }
414 else
415 {
416 struct GNUNET_MESSENGER_MemberStore *store;
417 struct GNUNET_MESSENGER_Member *member;
418
420 member = get_store_member_of (store, message);
421
422 if (! member)
423 {
424 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n",
425 GNUNET_h2s (hash));
426 return;
427 }
428
429 session.member = get_member_session_of (member, message, hash);
430
431 if (! session.member)
432 {
434 "Member session from sender of message (%s) unknown!\n",
435 GNUNET_h2s (hash));
436 return;
437 }
438 }
439
440 {
441 const struct GNUNET_MESSENGER_MessageStore *message_store;
442 const struct GNUNET_HashCode *epoch;
443
444 message_store = get_srv_room_message_store (room);
445 epoch = get_store_message_epoch (message_store, hash);
446
447 if (GNUNET_NO == msg_client->handle->service->local_request)
448 notify_srv_handle_message (msg_client->handle, room, &session, message,
449 hash, epoch, GNUNET_NO);
450 else
451 handle_service_message (msg_client->handle->service, room, &session,
452 message, hash, epoch, GNUNET_NO);
453 }
454}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static struct MHD_Response * response
Our canonical response.
void notify_srv_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Notifies the handle that a new message was received or sent.
struct GNUNET_MESSENGER_SrvMemberSession * 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.
const struct GNUNET_HashCode * get_store_message_epoch(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the epoch hash of a message from a message store matching a given hash.
struct GNUNET_PeerIdentity * get_store_peer_of(struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the peer identity inside the store which verifies the signature of a given message as valid.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used peer store of a given room.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void handle_service_message(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Sends a received or sent message with a given hash to each handle of a service which is currently mem...
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:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
Message to request something from a room.
struct GNUNET_MESSENGER_MemberStore * store
enum GNUNET_GenericReturnValue local_request

References env, get_member_session_of(), get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_peer_store(), get_store_member_of(), get_store_message_epoch(), get_store_peer_of(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Client::handle, handle_service_message(), is_peer_message(), GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_Service::local_request, GNUNET_MESSENGER_SenderSession::member, GNUNET_MESSENGER_SrvHandle::mq, notify_srv_handle_message(), GNUNET_MESSENGER_SenderSession::peer, response, GNUNET_MESSENGER_SrvHandle::service, and GNUNET_MESSENGER_Member::store.

Referenced by handle_get_message().

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

◆ handle_get_message()

static void handle_get_message ( void *  cls,
const struct GNUNET_MESSENGER_GetMessage msg 
)
static

Definition at line 458 of file gnunet-service-messenger.c.

460{
461 struct GNUNET_MESSENGER_Client *msg_client;
462 struct GNUNET_MESSENGER_SrvRoom *room;
463 const struct GNUNET_ShortHashCode *member_id;
464 struct GNUNET_MESSENGER_Member *member;
466 struct GNUNET_MESSENGER_SrvMemberSession *session;
467
468 GNUNET_assert ((cls) && (msg));
469
470 msg_client = cls;
471
472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n",
473 GNUNET_h2s (&(msg->key)));
474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requested message: %s\n",
475 GNUNET_h2s (&(msg->hash)));
476
477 room = get_service_room (messenger, &(msg->key));
478
479 if (! room)
480 {
481 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (
482 &(msg->key)));
483 goto end_handling;
484 }
485
486 {
487 struct GNUNET_MESSENGER_MemberStore *member_store;
488 member_store = get_srv_room_member_store (room);
489
490 member_id = get_srv_handle_member_id (msg_client->handle,
491 &(msg->key));
492
493 member = get_store_member (member_store, member_id);
494 }
495
496 if (! member)
497 {
499 "Member not valid to request a message! (%s)\n",
500 GNUNET_sh2s (member_id));
501 goto end_handling;
502 }
503
504 pubkey = get_srv_handle_key (msg_client->handle);
505
506 if (! pubkey)
507 {
509 "Handle needs to have a public key to request a message! (%s)\n",
510 GNUNET_sh2s (member_id));
511 goto end_handling;
512 }
513
514 session = get_member_session (member, pubkey);
515
516 if (! session)
517 {
519 "Session not valid to request a message! (%s)\n",
520 GNUNET_sh2s (member_id));
521 goto end_handling;
522 }
523
525 msg_client);
526
527end_handling:
529}
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
static void callback_found_message(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
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.
struct GNUNET_MESSENGER_SrvMemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key)
Returns the member session of a member identified by a given public key.
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.
enum GNUNET_GenericReturnValue request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
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.
A 256-bit hashcode.

References callback_found_message(), GNUNET_MESSENGER_Client::client, get_member_session(), get_service_room(), get_srv_handle_key(), get_srv_handle_member_id(), get_srv_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_sh2s(), GNUNET_MESSENGER_Client::handle, messenger, msg, pubkey, request_srv_room_message(), and GNUNET_MESSENGER_MemberStore::room.

Here is the call graph for this function:

◆ callback_client_connect()

static void * callback_client_connect ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Definition at line 533 of file gnunet-service-messenger.c.

536{
537 struct GNUNET_MESSENGER_Client *msg_client;
538
539 GNUNET_assert ((client) && (mq));
540
541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New client connected to service!\n");
542
543 msg_client = GNUNET_new (struct GNUNET_MESSENGER_Client);
544
545 msg_client->client = client;
546 msg_client->handle = add_service_handle (messenger, mq);
547
548 return msg_client;
549}
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.

References add_service_handle(), GNUNET_MESSENGER_Client::client, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_MESSENGER_Client::handle, messenger, and mq.

Here is the call graph for this function:

◆ callback_client_disconnect()

static void callback_client_disconnect ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  internal_cls 
)
static

Definition at line 553 of file gnunet-service-messenger.c.

556{
557 struct GNUNET_MESSENGER_Client *msg_client;
558
559 GNUNET_assert (internal_cls);
560
561 msg_client = internal_cls;
562
564
565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected from service!\n");
566
567 GNUNET_free (msg_client);
568}
void remove_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes a handle from a service and destroys it.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSENGER_Client::handle, messenger, and remove_service_handle().

Here is the call graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle config,
struct GNUNET_SERVICE_Handle service 
)
static

Setup MESSENGER internals.

Parameters
[in/out]cls closure
[in]configconfiguration to use
[in/out]service the initialized service

Definition at line 579 of file gnunet-service-messenger.c.

582{
584
586
587 if (! messenger)
589}
const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572

References config, create_service(), GNUNET_assert, GNUNET_SCHEDULER_shutdown(), messenger, and service.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ messenger