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

GNUnet MESSENGER service. More...

#include "gnunet-service-messenger_message_handle.h"
Include dependency graph for gnunet-service-messenger_message_handle.c:

Go to the source code of this file.

Functions

void handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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_SrvTunnel *tunnel, 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...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_message_handle.c.

Function Documentation

◆ handle_message_join()

void handle_message_join ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageJOIN-Message
hashHash of the message

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

References GNUNET_MESSENGER_MemberInfo::access, add_room_contact(), add_to_list_messages(), GNUNET_MESSENGER_Message::body, clear_list_messages(), get_room_contact(), get_room_member_info(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_put(), GNUNET_MESSENGER_MEMBER_UNKNOWN, GNUNET_new, GNUNET_YES, GNUNET_MESSENGER_Message::header, init_list_messages(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_SrvRoom::member_infos, GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MESSENGER_MemberInfo::session_messages.

Referenced by recv_message_join(), and send_message_join().

31 {
32  struct GNUNET_MESSENGER_SrvContact *contact = get_room_contact (room, &(message->header.sender_id));
33 
34  if (!contact)
35  add_room_contact (room, &(message->header.sender_id), &(message->body.join.key));
36 
37  struct GNUNET_MESSENGER_MemberInfo *info = get_room_member_info (room, &(message->header.sender_id));
38 
39  if (!info)
40  {
42 
45  }
46  else
48 
51  add_to_list_messages (&(info->session_messages), hash);
52 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_MultiShortmap * member_infos
struct GNUNET_MESSENGER_MemberInfo * get_room_member_info(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the member information of a member in a room identified by a given id.
struct GNUNET_MESSENGER_SrvContact * get_room_contact(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the contact of a member in a room identified by a given id.
void init_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Initializes list of message hashes as empty list.
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
struct GNUNET_MESSENGER_MessageBody body
Body.
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void add_room_contact(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id, const struct GNUNET_IDENTITY_PublicKey *pubkey)
Adds a contact from the service to a room under a specific id with a given public key...
void clear_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Clears the list of message hashes.
struct GNUNET_MESSENGER_ListMessages session_messages
enum GNUNET_MESSENGER_MemberAccess access
struct GNUNET_MESSENGER_MessageJoin join
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageLEAVE-Message
hashHash of the message

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

References clear_list_messages(), get_room_member_info(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MESSENGER_MemberInfo::session_messages.

Referenced by recv_message_leave(), and send_message_leave().

57 {
58  struct GNUNET_MESSENGER_MemberInfo *info = get_room_member_info (room, &(message->header.sender_id));
59 
60  if (info)
62 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MemberInfo * get_room_member_info(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the member information of a member in a room identified by a given id.
void clear_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Clears the list of message hashes.
struct GNUNET_MESSENGER_ListMessages session_messages
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageNAME-Message
hashHash of the message

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

References add_to_list_messages(), GNUNET_MESSENGER_Message::body, get_room_contact(), get_room_member_info(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MemberInfo::session_messages, and set_contact_name().

Referenced by recv_message_name(), and send_message_name().

67 {
68  struct GNUNET_MESSENGER_SrvContact *contact = get_room_contact (room, &(message->header.sender_id));
69 
70  if (contact)
71  set_contact_name (contact, message->body.name.name);
72 
73  struct GNUNET_MESSENGER_MemberInfo *info = get_room_member_info (room, &(message->header.sender_id));
74 
75  if (info)
76  add_to_list_messages (&(info->session_messages), hash);
77 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MemberInfo * get_room_member_info(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the member information of a member in a room identified by a given id.
struct GNUNET_MESSENGER_SrvContact * get_room_contact(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the contact of a member in a room identified by a given id.
void set_contact_name(struct GNUNET_MESSENGER_SrvContact *contact, const char *name)
Changes the current name of a given contact by copying it from the parameter name.
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_ListMessages session_messages
char * name
The new name which replaces the current senders name.
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageKEY-Message
hashHash of the message

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

References add_to_list_messages(), GNUNET_MESSENGER_Message::body, get_room_contact(), get_room_member_info(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_MemberInfo::session_messages, and swap_service_contact_by_pubkey().

Referenced by recv_message_key(), and send_message_key().

82 {
83  struct GNUNET_MESSENGER_SrvContact *contact = get_room_contact (room, &(message->header.sender_id));
84 
85  if (contact)
86  swap_service_contact_by_pubkey (room->service, contact, &(message->body.key.key));
87 
88  struct GNUNET_MESSENGER_MemberInfo *info = get_room_member_info (room, &(message->header.sender_id));
89 
90  if (info)
91  add_to_list_messages (&(info->session_messages), hash);
92 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MessageKey key
void swap_service_contact_by_pubkey(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvContact *contact, const struct GNUNET_IDENTITY_PublicKey *pubkey)
Changes the public key for a contact known to a service to a specific public key and updates local ma...
struct GNUNET_MESSENGER_MemberInfo * get_room_member_info(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the member information of a member in a room identified by a given id.
struct GNUNET_MESSENGER_SrvContact * get_room_contact(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the contact of a member in a room identified by a given id.
struct GNUNET_MESSENGER_Service * service
struct GNUNET_IDENTITY_PublicKey key
The new public key which replaces the current senders public key.
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_ListMessages session_messages
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messagePEER-Message
hashHash of the message

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

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 recv_message_peer(), and send_message_peer().

97 {
98  if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer)))
99  add_to_list_tunnels (&(room->basement), &(message->body.peer.peer));
100 
101  if (room->peer_message)
103 }
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
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...
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.
struct GNUNET_HashCode * peer_message
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessagePeer peer
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...
struct GNUNET_MESSENGER_ListTunnels basement
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageID-Message
hashHash of the message

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

References add_to_list_messages(), GNUNET_MESSENGER_Message::body, get_room_member_info(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MemberInfo::session_messages, and switch_room_member_id().

Referenced by recv_message_id(), and send_message_id().

108 {
109  struct GNUNET_MESSENGER_MemberInfo *info = get_room_member_info (room, &(message->header.sender_id));
110 
111  if (info)
112  add_to_list_messages (&(info->session_messages), hash);
113 
114  switch_room_member_id (room, &(message->header.sender_id), &(message->body.id.id), hash);
115 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
struct GNUNET_MESSENGER_MemberInfo * get_room_member_info(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id)
Returns the member information of a member in a room identified by a given id.
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
struct GNUNET_MESSENGER_MessageBody body
Body.
void switch_room_member_id(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *old_id, const struct GNUNET_ShortHashCode *new_id, const struct GNUNET_HashCode *hash)
Changes an id of a current member from an old id to a new one and adds optionally the hash of an id m...
struct GNUNET_MESSENGER_ListMessages session_messages
struct GNUNET_MESSENGER_MessageId id
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_SrvTunnel tunnel,
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
roomRoom of the message
tunnelReceiving/sending connection (may be NULL)
messageMISS-Message
hashHash of the message

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

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 recv_message_miss(), and send_message_miss().

120 {
121  struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL);
122 
123  if (!element)
124  return;
125 
126  remove_from_list_tunnels (&(room->basement), element);
127 
128  if (room->peer_message)
130 }
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_HashCode * peer_message
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessagePeer peer
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...
struct GNUNET_MESSENGER_ListTunnels basement
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...
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...
Here is the call graph for this function:
Here is the caller graph for this function: