GNUnet  0.20.0
gnunet-service-messenger.c File Reference

GNUnet MESSENGER service. More...

Include dependency graph for gnunet-service-messenger.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_Client
 

Functions

static int check_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
 
static void handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
 
static void handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg)
 
static void handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
 
static int check_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
 
static void handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *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_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static int 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. More...
 
 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. More...
 

Variables

struct GNUNET_MESSENGER_Servicemessenger
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger.c.

Function Documentation

◆ check_create()

static int check_create ( void *  cls,
const struct GNUNET_MESSENGER_CreateMessage msg 
)
static

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

45 {
47  return GNUNET_OK;
48 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
@ GNUNET_OK
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

References GNUNET_MQ_check_zero_termination, GNUNET_OK, and msg.

◆ handle_create()

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

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

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 }
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.
#define GNUNET_log(kind,...)
@ 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:2249
const char * name
struct GNUNET_SERVICE_Client * client
struct GNUNET_MESSENGER_SrvHandle * handle

References GNUNET_MESSENGER_Client::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_MESSENGER_Client::handle, msg, name, and setup_srv_handle_name().

Here is the call graph for this function:

◆ handle_update()

static void handle_update ( void *  cls,
const struct GNUNET_MESSENGER_UpdateMessage msg 
)
static

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

68 {
69  struct GNUNET_MESSENGER_Client *msg_client = cls;
70 
71  update_srv_handle (msg_client->handle);
72 
74 }
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...

References GNUNET_MESSENGER_Client::client, GNUNET_SERVICE_client_continue(), GNUNET_MESSENGER_Client::handle, and update_srv_handle().

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 77 of file gnunet-service-messenger.c.

79 {
80  struct GNUNET_MESSENGER_Client *msg_client = cls;
81 
82  GNUNET_SERVICE_client_drop (msg_client->client);
83 }
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330

References GNUNET_MESSENGER_Client::client, and GNUNET_SERVICE_client_drop().

Here is the call graph for this function:

◆ check_set_name()

static int check_set_name ( void *  cls,
const struct GNUNET_MESSENGER_NameMessage msg 
)
static

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

88 {
90  return GNUNET_OK;
91 }

References GNUNET_MQ_check_zero_termination, GNUNET_OK, and msg.

◆ handle_set_name()

static void handle_set_name ( void *  cls,
const struct GNUNET_MESSENGER_NameMessage msg 
)
static

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

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 }
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 ...

References GNUNET_MESSENGER_Client::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_MESSENGER_Client::handle, msg, name, and set_srv_handle_name().

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 109 of file gnunet-service-messenger.c.

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 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct MHD_Response * response
Our canonical response.
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...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
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
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_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
General message to confirm interaction with a room.
A 256-bit hashcode.

References GNUNET_MESSENGER_Client::client, env, get_srv_handle_member_id(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_SrvHandle::mq, msg, open_srv_handle_room(), and response.

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 140 of file gnunet-service-messenger.c.

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 }
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...
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

References GNUNET_MESSENGER_Client::client, entry_srv_handle_room(), env, get_srv_handle_member_id(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_SrvHandle::mq, msg, and response.

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 174 of file gnunet-service-messenger.c.

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 }
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...
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE

References GNUNET_MESSENGER_Client::client, close_srv_handle_room(), env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_SrvHandle::mq, msg, and response.

Here is the call graph for this function:

◆ check_send_message()

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

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

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 }
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_NO
@ GNUNET_SYSERR
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling Compatible flags can be OR'ed togethe...
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
int filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns if a specific kind of message should be sent by a client.
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.
An identity key as per LSD0001.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References cleanup_message(), decode_message(), filter_message_sending(), get_message_kind_size(), GNUNET_IDENTITY_read_public_key_from_buffer(), GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, 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 247 of file gnunet-service-messenger.c.

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",
288  GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (
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",
293  GNUNET_MESSENGER_name_of_kind (message.header.kind),
294  GNUNET_h2s (key));
295 
296  end_handling:
297  cleanup_message (&message);
298 
300 }
struct GNUNET_HashCode key
The key used in the DHT.
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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:36
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...
A 512-bit hashcode.

References cleanup_message(), GNUNET_MESSENGER_Client::client, decode_message(), encrypt_message(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_IDENTITY_read_public_key_from_buffer(), GNUNET_log, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, msg, send_srv_handle_message(), 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 303 of file gnunet-service-messenger.c.

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 }
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.
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_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.
struct GNUNET_MESSENGER_MemberStore * store

References create_message_request(), get_member_session_of(), get_srv_room_member_store(), get_store_member_of(), GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_Client::handle, GNUNET_MESSENGER_MemberSession::member, notify_srv_handle_message(), GNUNET_MESSENGER_MemberStore::room, send_srv_room_message(), 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 337 of file gnunet-service-messenger.c.

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 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
struct GNUNET_MESSENGER_Service * messenger
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_MESSENGER_Ego * get_srv_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
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_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.
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.
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.

References callback_found_message(), GNUNET_MESSENGER_Client::client, get_member_session(), get_service_room(), get_srv_handle_ego(), get_srv_handle_member_id(), get_srv_room_member_store(), get_store_member(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), handle, GNUNET_MESSENGER_MemberSession::member, messenger, msg, pub, 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 395 of file gnunet-service-messenger.c.

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 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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.

References add_service_handle(), GNUNET_MESSENGER_Client::client, 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 409 of file gnunet-service-messenger.c.

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 }
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_free, 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 428 of file gnunet-service-messenger.c.

431 {
433 
434  if (! messenger)
436 }
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.
static const struct GNUNET_CONFIGURATION_Handle * config
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562

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

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ messenger