GNUnet 0.21.1
gnunet-service-messenger_message_send.c File Reference
Include dependency graph for gnunet-service-messenger_message_send.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MemberNotify
 

Functions

static void notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map, enum GNUNET_GenericReturnValue check_permission)
 
static enum GNUNET_GenericReturnValue iterate_notify_about_members (void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
 
void send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a sent join message to ensure growth of the decentralized room structure. More...
 
void send_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a sent key message to ensure changes to the public key of the sending handle. More...
 
void send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a sent peer message to update the rooms peer message of this service. More...
 
void send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a sent id message to update the handles member id in the room. More...
 
void send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a sent request message to trigger the request operation for this service. More...
 

Function Documentation

◆ notify_about_members()

static void notify_about_members ( struct GNUNET_MESSENGER_MemberNotify notify,
struct GNUNET_MESSENGER_MemberSession session,
struct GNUNET_CONTAINER_MultiHashMap map,
enum GNUNET_GenericReturnValue  check_permission 
)
static

Definition at line 44 of file gnunet-service-messenger_message_send.c.

48{
49 if (session->prev)
50 notify_about_members (notify, session->prev, map, GNUNET_YES);
51
52 struct GNUNET_MESSENGER_MessageStore *message_store =
54 struct GNUNET_MESSENGER_ListMessage *element;
55
57 "Notify through all of member session: %s\n",
59
60 for (element = session->messages.head; element; element = element->next)
61 {
63 &(element->hash)))
64 continue;
65
66 if ((GNUNET_YES == check_permission) &&
68 &(element->hash),
69 GNUNET_NO)))
70 {
72 "Permission for notification of session message denied!\n");
73 continue;
74 }
75
77 NULL,
80 "Notification of session message could be duplicated!\n");
81
82 const struct GNUNET_MESSENGER_Message *message = get_store_message (
83 message_store, &(element->hash));
84
85 if ((! message) || (GNUNET_YES == is_peer_message (message)))
86 {
88 "Session message for notification is invalid!\n");
89 continue;
90 }
91
93 sender.member = session;
94
95 notify_srv_handle_message (notify->handle, notify->room, &sender, message,
96 &(element->hash), GNUNET_NO);
97 }
98}
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, enum GNUNET_GenericReturnValue recent)
Notifies the handle that a new message was received or sent.
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
static void notify_about_members(struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map, enum GNUNET_GenericReturnValue check_permission)
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
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...
static struct GNUNET_CONTAINER_MultiPeerMap * map
Peermap of PeerIdentities to "struct PeerEntry" (for fast lookup).
Definition: peer.c:63
struct GNUNET_MESSENGER_ListMessage * next
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_MemberSession * session
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_MemberSession * prev
struct GNUNET_MESSENGER_ListMessages messages
struct GNUNET_MESSENGER_MemberSession * member

References check_member_session_history(), get_member_session_id(), get_srv_room_message_store(), get_store_message(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_MemberNotify::handle, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, is_peer_message(), map, GNUNET_MESSENGER_SenderSession::member, GNUNET_MESSENGER_MemberSession::messages, GNUNET_MESSENGER_ListMessage::next, notify_about_members(), notify_srv_handle_message(), GNUNET_MESSENGER_MemberSession::prev, GNUNET_MESSENGER_MemberNotify::room, and GNUNET_MESSENGER_MemberNotify::session.

Referenced by iterate_notify_about_members(), and notify_about_members().

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

◆ iterate_notify_about_members()

static enum GNUNET_GenericReturnValue iterate_notify_about_members ( void *  cls,
const struct GNUNET_CRYPTO_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

Definition at line 102 of file gnunet-service-messenger_message_send.c.

106{
107 struct GNUNET_MESSENGER_MemberNotify *notify = cls;
108
109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Notify about member session: %s\n",
111
112 if ((notify->session == session) || (GNUNET_YES ==
114 return GNUNET_YES;
115
118
119 notify_about_members (notify, session, map, GNUNET_NO);
120
122 return GNUNET_YES;
123}
enum GNUNET_GenericReturnValue is_member_session_completed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been completed.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
Internal representation of the hash map.

References get_member_session_id(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, is_member_session_completed(), map, notify_about_members(), and GNUNET_MESSENGER_MemberNotify::session.

Referenced by send_message_join().

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

◆ send_message_join()

void send_message_join ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a sent join message to ensure growth of the decentralized room structure.

(if the service provides a peer message for this room currently, it will be forwarded)

Parameters
[in,out]roomRoom of the message
[in,out]handleSending handle
[in]messageJOIN-Message
[in]hashHash of the message

Definition at line 127 of file gnunet-service-messenger_message_send.c.

131{
132 set_srv_handle_key (handle, &(message->body.join.key));
133
134 struct GNUNET_MESSENGER_MemberStore *member_store =
136 struct GNUNET_MESSENGER_Member *member = add_store_member (member_store,
137 &(message->header.
138 sender_id));
139
141 member, message, hash);
142
143 if (! session)
144 {
146 "A valid session is required to join a room!\n");
147 goto skip_member_notification;
148 }
149
150 struct GNUNET_MESSENGER_MemberNotify notify;
151
152 notify.room = room;
153 notify.handle = handle;
154 notify.session = session;
155
157 "Notify about all member sessions except: %s\n",
159
162
163skip_member_notification:
165}
void set_srv_handle_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_PublicKey *key)
Sets the public key of a given handle.
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...
int iterate_store_members(struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
Iterate through all member sessions currently connected to the members of the given member store and ...
struct GNUNET_MESSENGER_Member * add_store_member(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Adds a member to a store under a specific id and returns it on success.
static enum GNUNET_GenericReturnValue iterate_notify_about_members(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
void check_srv_room_peer_status(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Checks the current state of opening a given room from this peer and re-publishes it if necessary to a...
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References add_store_member(), GNUNET_MESSENGER_Message::body, check_srv_room_peer_status(), get_member_session_id(), get_member_session_of(), get_srv_room_member_store(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_sh2s(), handle, GNUNET_MESSENGER_MemberNotify::handle, GNUNET_MESSENGER_Message::header, iterate_notify_about_members(), iterate_store_members(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_MemberStore::room, GNUNET_MESSENGER_MemberNotify::room, GNUNET_MESSENGER_MemberNotify::session, and set_srv_handle_key().

Referenced by send_srv_room_message().

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

◆ send_message_key()

void send_message_key ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a sent key message to ensure changes to the public key of the sending handle.

Parameters
[in,out]roomRoom of the message
[in,out]handleSending handle
[in]messageKEY-Message
[in]hashHash of the message

Definition at line 169 of file gnunet-service-messenger_message_send.c.

173{
174 set_srv_handle_key (handle, &(message->body.key.key));
175}
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_CRYPTO_PublicKey key
The new public key which replaces the current senders public key.

References GNUNET_MESSENGER_Message::body, handle, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, and set_srv_handle_key().

Referenced by send_srv_room_message().

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

◆ send_message_peer()

void send_message_peer ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a sent peer message to update the rooms peer message of this service.

(a set peer message indicates this service being a part of the decentralized room structure)

Parameters
[in,out]roomRoom of the message
[in,out]handleSending handle
[in]messagePEER-Message
[in]hashHash of the message

Definition at line 179 of file gnunet-service-messenger_message_send.c.

183{
184 if (! room->peer_message)
185 room->peer_message = GNUNET_new (struct GNUNET_HashCode);
186
187 GNUNET_memcpy (room->peer_message, hash, sizeof(struct GNUNET_HashCode));
188
190}
struct GNUNET_MESSENGER_Message * create_message_connection(const struct GNUNET_MESSENGER_SrvRoom *room)
Creates and allocates a new connection message containing the amount of the peer's connections in a g...
enum GNUNET_GenericReturnValue 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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A 512-bit hashcode.
struct GNUNET_HashCode * peer_message
struct GNUNET_MESSENGER_SrvHandle * host

References create_message_connection(), GNUNET_memcpy, GNUNET_new, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_SrvRoom::peer_message, GNUNET_MESSENGER_MemberNotify::room, and send_srv_room_message().

Referenced by send_srv_room_message().

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

◆ send_message_id()

void send_message_id ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a sent id message to update the handles member id in the room.

(changing member id is useful to prevent collisions)

Parameters
[in,out]roomRoom of the message
[in,out]handleSending handle
[in]messageID-Message
[in]hashHash of the message

Definition at line 194 of file gnunet-service-messenger_message_send.c.

198{
200 &(message->body.id.id));
201}
enum GNUNET_GenericReturnValue change_srv_handle_member_id(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id)
Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK...
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
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, change_srv_handle_member_id(), get_srv_room_key(), handle, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, and GNUNET_MESSENGER_MemberNotify::room.

Referenced by send_srv_room_message().

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

◆ send_message_request()

void send_message_request ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a sent request message to trigger the request operation for this service.

(the request operation will deactivate the possibility of spamming requests)

Parameters
[in,out]roomRoom of the message
[in,out]handleSending handle
[in]messageREQUEST-Message
[in]hashHash of the message

Definition at line 205 of file gnunet-service-messenger_message_send.c.

209{
210 struct GNUNET_MESSENGER_OperationStore *operation_store =
212
214 operation_store,
215 &(message->body.request.hash),
218 );
219}
enum GNUNET_GenericReturnValue use_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_OperationType type, struct GNUNET_TIME_Relative delay)
Tries to use an operation under a given hash in a specific operation store.
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
#define GNUNET_MESSENGER_REQUEST_DELAY
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_HashCode hash
The hash of the requested message.

References GNUNET_MESSENGER_Message::body, get_srv_room_operation_store(), GNUNET_MESSENGER_OP_REQUEST, GNUNET_MESSENGER_REQUEST_DELAY, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_OperationStore::room, and use_store_operation().

Referenced by send_srv_room_message().

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