GNUnet  0.11.x
Functions
gnunet-service-messenger_message_handle.h File Reference

GNUnet MESSENGER service. More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
#include "gnunet-service-messenger_message_kind.h"
#include "gnunet-service-messenger_member_session.h"
#include "gnunet-service-messenger_tunnel.h"
#include "messenger_api_message.h"
Include dependency graph for gnunet-service-messenger_message_handle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent join message to make changes of current member information. More...
 
void handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent leave message to make changes of current member information. More...
 
void handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent name message to rename a current member. More...
 
void handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly. More...
 
void handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent peer message to make changes of the basement in the room. More...
 
void handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent id message to change a members id. More...
 
void handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent miss message to drop a peer from the basement in the room. More...
 
void handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received or sent delete message to delete a specific message from the store. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_message_handle.h.

Function Documentation

◆ handle_message_join()

void handle_message_join ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent join message to make changes of current member information.

(add matching member and clear member info)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageJOIN-Message
[in]hashHash of the message

Definition at line 39 of file gnunet-service-messenger_message_handle.c.

41 {
42  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n",
43  GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
44 
45  if (GNUNET_OK != reset_member_session(session, hash))
46  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Resetting member session failed!\n");
47 
49  room,
50  &(message->body.join.key),
51  &(message->header.sender_id),
53  );
54 }
int reset_member_session(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash)
Resets a given member session which re-opens a member session for new usage.
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
void solve_room_member_collisions(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_PublicKey *public_key, const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp)
Checks for potential collisions with member ids and solves them changing active handles ids if they u...
#define GNUNET_log(kind,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
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_INFO
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:542
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, get_room_key(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_sh2s(), GNUNET_TIME_absolute_ntoh(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, reset_member_session(), GNUNET_MESSENGER_MessageHeader::sender_id, solve_room_member_collisions(), and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by callback_room_handle_message().

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

◆ handle_message_leave()

void handle_message_leave ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent leave message to make changes of current member information.

(remove matching member and clear member info)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageLEAVE-Message
[in]hashHash of the message

Definition at line 57 of file gnunet-service-messenger_message_handle.c.

59 {
60  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n",
61  GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
62 
63  close_member_session(session);
64 }
void close_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Closes a given member session which opens the request for completion of the given member session.

References close_member_session(), get_room_key(), GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_sh2s(), GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::sender_id.

Referenced by callback_room_handle_message().

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

◆ handle_message_name()

void handle_message_name ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent name message to rename a current member.

(change name of matching member)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageNAME-Message
[in]hashHash of the message

Definition at line 67 of file gnunet-service-messenger_message_handle.c.

69 {
70  struct GNUNET_MESSENGER_Contact *contact = get_member_session_contact(session);
71 
72  if (!contact)
73  return;
74 
75  set_contact_name (contact, message->body.name.name);
76 }
struct GNUNET_MESSENGER_Contact * get_member_session_contact(struct GNUNET_MESSENGER_MemberSession *session)
Returns the contact which is connected to a given member session.
void set_contact_name(struct GNUNET_MESSENGER_Contact *contact, const char *name)
Changes the current name of a given contact by copying it from the parameter name.
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, get_member_session_contact(), GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, and set_contact_name().

Referenced by callback_room_handle_message().

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

◆ handle_message_key()

void handle_message_key ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly.

(move the member in the contacts and change its key)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageKEY-Message
[in]hashHash of the message

Definition at line 79 of file gnunet-service-messenger_message_handle.c.

81 {
82  handle_session_switch (session, message, hash);
83 }
static void handle_session_switch(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)

References handle_session_switch().

Referenced by callback_room_handle_message().

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

◆ handle_message_peer()

void handle_message_peer ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent peer message to make changes of the basement in the room.

(add a new peer to the basement and restructure connections based on updated list of peers)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messagePEER-Message
[in]hashHash of the message

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

88 {
89  if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer)))
90  add_to_list_tunnels (&(room->basement), &(message->body.peer.peer));
91 
92  if (room->peer_message)
94 }
void rebuild_room_basement_structure(struct GNUNET_MESSENGER_SrvRoom *room)
Rebuilds the decentralized structure for a room by ensuring all required connections are made dependi...
@ GNUNET_NO
Definition: gnunet_common.h:94
void add_to_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
Adds a specific peer from a tunnel to the end of the list.
int contains_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
Tests linearly if the list of tunnels peer identities contains a specific peer identity and returns G...
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_HashCode * peer_message
struct GNUNET_MESSENGER_ListTunnels basement

References add_to_list_tunnels(), GNUNET_MESSENGER_SrvRoom::basement, GNUNET_MESSENGER_Message::body, contains_list_tunnels(), GNUNET_NO, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_SrvRoom::peer_message, and rebuild_room_basement_structure().

Referenced by callback_room_handle_message().

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

◆ handle_message_id()

void handle_message_id ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent id message to change a members id.

(change id of matching member)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageID-Message
[in]hashHash of the message

Definition at line 97 of file gnunet-service-messenger_message_handle.c.

99 {
100  handle_session_switch (session, message, hash);
101 
103  room,
105  &(message->body.id.id),
107  );
108 }
const struct GNUNET_IDENTITY_PublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the public key from an EGO of a given member session.
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.

References GNUNET_MESSENGER_Message::body, get_member_session_public_key(), GNUNET_TIME_absolute_ntoh(), handle_session_switch(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, solve_room_member_collisions(), and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by callback_room_handle_message().

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

◆ handle_message_miss()

void handle_message_miss ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent miss message to drop a peer from the basement in the room.

(remove a peer from the basement and restructure connections based on updated list of peers)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageMISS-Message
[in]hashHash of the message

Definition at line 111 of file gnunet-service-messenger_message_handle.c.

113 {
114  struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL);
115 
116  if (!element)
117  return;
118 
119  remove_from_list_tunnels (&(room->basement), element);
120 
121  if (room->peer_message)
123 }
struct GNUNET_MESSENGER_ListTunnel * remove_from_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
Removes a specific element from the list of tunnels peer identities and returns the next element in t...
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
Searches linearly through the list of tunnels peer identities for matching a specific peer identity a...

References GNUNET_MESSENGER_SrvRoom::basement, GNUNET_MESSENGER_Message::body, find_list_tunnels(), GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_SrvRoom::peer_message, rebuild_room_basement_structure(), and remove_from_list_tunnels().

Referenced by callback_room_handle_message().

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

◆ handle_message_delete()

void handle_message_delete ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_MemberSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received or sent delete message to delete a specific message from the store.

(remove a message from the store of a room under a given delay)

Parameters
[in/out]room Room of the message
[in/out]session Member session
[in]messageDELETE-Message
[in]hashHash of the message

Definition at line 126 of file gnunet-service-messenger_message_handle.c.

128 {
131 
134 
135  delete_room_message (room, session, &(message->body.deletion.hash), delay);
136 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
int delete_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Deletes a message from the room with a given hash in a specific delay if the provided member by its s...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:454
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:277
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:248
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

References consensus-simulation::action, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageDelete::delay, delay, delete_room_message(), GNUNET_MESSENGER_MessageBody::deletion, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_ntoh(), GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by callback_room_handle_message().

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