GNUnet 0.21.1
messenger_api.c File Reference
Include dependency graph for messenger_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_RoomFind
 
struct  GNUNET_MESSENGER_CheckTicket
 

Functions

const char * GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
 Get the name of a message kind. More...
 
static enum GNUNET_GenericReturnValue dequeue_messages_from_room (struct GNUNET_MESSENGER_Room *room)
 
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 void handle_room_sync (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void enqueue_message_to_room (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
 
static void handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
 
static enum GNUNET_GenericReturnValue check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void handle_miss_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
 
static void reconnect (struct GNUNET_MESSENGER_Handle *handle)
 
static void send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static void send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
 
static void send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static void send_sync_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static enum GNUNET_GenericReturnValue iterate_reset_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_reconnect (void *cls)
 
static enum GNUNET_GenericReturnValue iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_mq_error (void *cls, enum GNUNET_MQ_Error error)
 
struct GNUNET_MESSENGER_HandleGNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, const struct GNUNET_CRYPTO_PrivateKey *key, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
 Set up a handle for the messenger related functions and connects to all necessary services. More...
 
void GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle)
 Disconnect all of the messengers used services and clears up its used memory. More...
 
static void send_message_to_room (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_HashCode *hash)
 
const char * GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle)
 Get the name (if specified, otherwise NULL) used by the messenger. More...
 
static enum GNUNET_GenericReturnValue iterate_send_name_to_room (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 
enum GNUNET_GenericReturnValue GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name)
 Set the name for the messenger handle and sends messages renaming your contact in currently open rooms. More...
 
static const struct GNUNET_CRYPTO_PublicKeyget_non_anonymous_key (const struct GNUNET_CRYPTO_PublicKey *public_key)
 
const struct GNUNET_CRYPTO_PublicKeyGNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle)
 Get the public key used by the messenger or NULL if the anonymous key was used. More...
 
static enum GNUNET_GenericReturnValue iterate_send_key_to_room (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 
enum GNUNET_GenericReturnValue GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_PrivateKey *key)
 Set the private key used by the messenger or NULL if the anonymous key should be used instead. More...
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
 Open a room to send and receive messages. More...
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
 Enter a room to send and receive messages through a door opened using GNUNET_MESSENGER_open_room. More...
 
void GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room)
 Close a room which was entered, opened or both in various order and variety. More...
 
static enum GNUNET_GenericReturnValue iterate_find_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
int GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Searches for a specific contact in a given room and calls a selected callback with a given closure for each of them containing the contact as a member. More...
 
const struct GNUNET_HashCodeGNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room)
 Get the key of a given room. More...
 
const struct GNUNET_MESSENGER_ContactGNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the contact of a member in a room which sent a specific message identified with a given hash. More...
 
const struct GNUNET_MESSENGER_ContactGNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the contact of a member in a room which has been targeted as recipient of a specific message identified with a given hash. More...
 
const char * GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact)
 Get the name used by the contact. More...
 
const struct GNUNET_CRYPTO_PublicKeyGNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact)
 Get the public key used by the contact or NULL if the anonymous key was used. More...
 
size_t GNUNET_MESSENGER_contact_get_id (const struct GNUNET_MESSENGER_Contact *contact)
 Get the locally unique id of the contact. More...
 
static void send_message_to_room_with_key (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *public_key)
 
void GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_Contact *contact)
 Send a message into a room. More...
 
void delete_message_in_room (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 
void GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Delete a message identified by its hash from a room. More...
 
const struct GNUNET_MESSENGER_MessageGNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the message in a room identified by its hash. More...
 
int GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Iterates through all members of a given room and calls a selected callback for each of them with a provided closure. More...
 
static enum GNUNET_GenericReturnValue check_ticket_audience (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 
void GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_RECLAIM_Ticket *ticket)
 Send a ticket into a room. More...
 

Function Documentation

◆ dequeue_messages_from_room()

static enum GNUNET_GenericReturnValue dequeue_messages_from_room ( struct GNUNET_MESSENGER_Room room)
static

Definition at line 714 of file messenger_api.c.

715{
716 if (GNUNET_YES != is_room_available (room))
717 return room->queue.head ? GNUNET_NO : GNUNET_YES;
718
719 struct GNUNET_MESSENGER_Message *message = NULL;
720 struct GNUNET_MESSENGER_Message *transcript = NULL;
723 struct GNUNET_HashCode hash, other;
724
725 do {
726 if (message)
727 destroy_message (message);
728
729 message = dequeue_from_messages (&(room->queue), &key, &transcript);
730
731 if (! message)
732 {
733 message = transcript;
734 continue;
735 }
736
737 send_message_to_room (room, message, &key, &hash);
738
739 if (! transcript)
740 continue;
741
742 GNUNET_memcpy (&(transcript->body.transcript.hash), &hash, sizeof(hash));
744
745 if (GNUNET_YES == encrypt_message (transcript, &pubkey))
746 {
747 send_message_to_room (room, transcript, &key, &other);
748
749 link_room_message (room, &hash, &other);
750 link_room_message (room, &other, &hash);
751 }
752 else
754 "Sending transcript aborted: Encryption failed!\n");
755
756 destroy_message (transcript);
757 } while (message);
758
759 return GNUNET_YES;
760}
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:602
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_ERROR
static void send_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue encrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key)
Encrypts a message using a given public key and replaces its body and kind with the now private encry...
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_Message * dequeue_from_messages(struct GNUNET_MESSENGER_QueueMessages *messages, struct GNUNET_CRYPTO_PrivateKey *sender, struct GNUNET_MESSENGER_Message **transcript)
Remove the message from the front of the queue and returns it.
enum GNUNET_GenericReturnValue is_room_available(const struct GNUNET_MESSENGER_Room *room)
Checks whether a room is available to send messages.
void link_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
Links a message identified by its hash inside a given room with another message identified by its oth...
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageTranscript transcript
struct GNUNET_HashCode hash
The hash of the original message.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_QueueMessage * head
struct GNUNET_MESSENGER_QueueMessages queue

References GNUNET_MESSENGER_Message::body, dequeue_from_messages(), destroy_message(), encrypt_message(), GNUNET_CRYPTO_key_get_public(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_QueueMessages::head, is_room_available(), key, link_room_message(), pubkey, GNUNET_MESSENGER_Room::queue, send_message_to_room(), and GNUNET_MESSENGER_MessageBody::transcript.

Referenced by enqueue_message_to_room(), handle_room_entry(), handle_room_open(), and handle_room_sync().

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

◆ handle_room_open()

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

Definition at line 95 of file messenger_api.c.

97{
98 struct GNUNET_MESSENGER_Handle *handle = cls;
99
100 const struct GNUNET_HashCode *key = &(msg->key);
101 const struct GNUNET_HashCode *prev = &(msg->previous);
102
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opened room: %s\n", GNUNET_h2s (key));
104
106
108
109 if (! room)
110 return;
111
112 update_room_last_message (room, prev);
113
115}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
static enum GNUNET_GenericReturnValue dequeue_messages_from_room(struct GNUNET_MESSENGER_Room *room)
void open_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Marks a room known to a handle identified by a given key as open.
struct GNUNET_MESSENGER_Room * get_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Returns the room known to a handle identified by a given key.
void update_room_last_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Updates the last message hash of a room for the client API so that new messages can point to the late...

References dequeue_messages_from_room(), get_handle_room(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, msg, open_handle_room(), and update_room_last_message().

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 119 of file messenger_api.c.

121{
122 struct GNUNET_MESSENGER_Handle *handle = cls;
123
124 const struct GNUNET_PeerIdentity *door = &(msg->door);
125 const struct GNUNET_HashCode *key = &(msg->key);
126 const struct GNUNET_HashCode *prev = &(msg->previous);
127
128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered room: %s\n", GNUNET_h2s (key));
129
131
133
134 if (! room)
135 return;
136
137 update_room_last_message (room, prev);
138
140}
void entry_handle_room_at(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Adds a tunnel for a room known to a handle identified by a given key to a list of opened connections.
The identity of the host (wraps the signing key of the peer).

References dequeue_messages_from_room(), entry_handle_room_at(), get_handle_room(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, msg, and update_room_last_message().

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 144 of file messenger_api.c.

146{
147 struct GNUNET_MESSENGER_Handle *handle = cls;
148
149 const struct GNUNET_HashCode *key = &(msg->key);
150 const struct GNUNET_HashCode *prev = &(msg->previous);
151
153
154 if (room)
155 update_room_last_message (room, prev);
156
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closed room: %s\n", GNUNET_h2s (key));
158
160}
void close_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Destroys and so implicitly closes a room known to a handle identified by a given key.

References close_handle_room(), get_handle_room(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, msg, and update_room_last_message().

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 164 of file messenger_api.c.

166{
167 struct GNUNET_MESSENGER_Handle *handle = cls;
168
169 const struct GNUNET_HashCode *key = &(msg->key);
170 const struct GNUNET_HashCode *prev = &(msg->previous);
171
173
174 if (! room)
175 return;
176
177 update_room_last_message (room, prev);
178
179 room->wait_for_sync = GNUNET_NO;
180
182}
enum GNUNET_GenericReturnValue wait_for_sync

References dequeue_messages_from_room(), get_handle_room(), GNUNET_NO, handle, key, msg, update_room_last_message(), and GNUNET_MESSENGER_Room::wait_for_sync.

Here is the call graph for this function:

◆ enqueue_message_to_room()

static void enqueue_message_to_room ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_MESSENGER_Message transcript 
)
static

Definition at line 682 of file messenger_api.c.

685{
686 GNUNET_assert ((room) && (message));
687
688 const struct GNUNET_CRYPTO_PrivateKey *key = get_handle_key (room->handle);
689 enum GNUNET_GenericReturnValue priority;
690
691 switch (message->header.kind)
692 {
694 priority = GNUNET_YES;
695 break;
696 default:
697 priority = GNUNET_NO;
698 break;
699 }
700
701 enqueue_to_messages (&(room->queue), key, message, transcript, priority);
702
703 if (GNUNET_YES != is_room_available (room))
704 return;
705
706 if (GNUNET_YES == is_message_session_bound (message))
707 send_sync_room (room->handle, room);
708 else if (GNUNET_YES != room->wait_for_sync)
710}
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
static void send_sync_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
const struct GNUNET_CRYPTO_PrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
enum GNUNET_GenericReturnValue is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
void enqueue_to_messages(struct GNUNET_MESSENGER_QueueMessages *messages, const struct GNUNET_CRYPTO_PrivateKey *sender, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript, enum GNUNET_GenericReturnValue priority)
Adds a specific message to the end or the beginning of the queue depending on its priority.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_Handle * handle

References dequeue_messages_from_room(), enqueue_to_messages(), get_handle_key(), GNUNET_assert, GNUNET_MESSENGER_KIND_JOIN, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, is_message_session_bound(), is_room_available(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Room::queue, send_sync_room(), and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by GNUNET_MESSENGER_close_room(), handle_member_id(), handle_miss_message(), iterate_send_key_to_room(), iterate_send_name_to_room(), and send_message_to_room_with_key().

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

◆ handle_member_id()

static void handle_member_id ( void *  cls,
const struct GNUNET_MESSENGER_MemberMessage msg 
)
static

Definition at line 191 of file messenger_api.c.

193{
194 struct GNUNET_MESSENGER_Handle *handle = cls;
195
196 const struct GNUNET_HashCode *key = &(msg->key);
197 const struct GNUNET_ShortHashCode *id = &(msg->id);
198 const uint32_t reset = msg->reset;
199
200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Changed member id in room: %s\n",
201 GNUNET_h2s (key));
202
204
205 if (! room)
206 {
207 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Room is unknown to handle: %s\n",
208 GNUNET_h2s (key));
209 return;
210 }
211
212 struct GNUNET_MESSENGER_Message *message;
213 if ((! get_room_sender_id (room)) || (GNUNET_YES == reset))
214 {
215 set_room_sender_id (room, id);
217 }
218 else
219 message = create_message_id (id);
220
221 if (! message)
222 return;
223
224 enqueue_message_to_room (room, message, NULL);
225}
static int reset
Reset argument.
@ GNUNET_ERROR_TYPE_WARNING
static void enqueue_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
struct GNUNET_MESSENGER_Message * create_message_join(const struct GNUNET_CRYPTO_PrivateKey *key)
Creates and allocates a new join message containing the clients public key.
struct GNUNET_MESSENGER_Message * create_message_id(const struct GNUNET_ShortHashCode *unique_id)
Creates and allocates a new id message containing the unique member id to change to.
void set_room_sender_id(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
Sets the member id of the room's sender to a specific id or NULL.
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
A 256-bit hashcode.

References create_message_id(), create_message_join(), enqueue_message_to_room(), get_handle_key(), get_handle_room(), get_room_sender_id(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_YES, handle, key, msg, reset, and set_room_sender_id().

Here is the call graph for this function:

◆ check_recv_message()

static enum GNUNET_GenericReturnValue check_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 229 of file messenger_api.c.

231{
232 const uint16_t full_length = ntohs (msg->header.size);
233
234 if (full_length < sizeof(*msg))
235 {
237 "Receiving failed: Message invalid!\n");
238 return GNUNET_NO;
239 }
240
241 const uint16_t length = full_length - sizeof(*msg);
242 const char *buffer = ((const char*) msg) + sizeof(*msg);
243
244 struct GNUNET_MESSENGER_Message message;
245
247 GNUNET_YES))
248 {
250 "Receiving failed: Message too short!\n");
251 return GNUNET_NO;
252 }
253
254 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL))
255 {
257 "Receiving failed: Message decoding failed!\n");
258 return GNUNET_NO;
259 }
260
261 cleanup_message (&message);
262 return GNUNET_OK;
263}
@ GNUNET_OK
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
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 maximal length in bytes.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References cleanup_message(), decode_message(), get_message_kind_size(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_OK, GNUNET_YES, msg, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_recv_message()

static void handle_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 267 of file messenger_api.c.

269{
270 struct GNUNET_MESSENGER_Handle *handle = cls;
271
272 const struct GNUNET_HashCode *key = &(msg->key);
273 const struct GNUNET_HashCode *sender = &(msg->sender);
274 const struct GNUNET_HashCode *context = &(msg->context);
275 const struct GNUNET_HashCode *hash = &(msg->hash);
276
277 enum GNUNET_MESSENGER_MessageFlags flags = (
278 (enum GNUNET_MESSENGER_MessageFlags) (msg->flags));
279
280 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
281 const char *buffer = ((const char*) msg) + sizeof(*msg);
282
283 struct GNUNET_MESSENGER_Message message;
284 decode_message (&message, length, buffer, GNUNET_YES, NULL);
285
286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message: %s\n",
287 GNUNET_MESSENGER_name_of_kind (message.header.kind));
288
290
291 if (! room)
292 {
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unknown room for this client: %s\n",
294 GNUNET_h2s (key));
295
296 goto skip_message;
297 }
298
300 "Raw contact from sender and context: (%s : %s)\n",
302
304 sender,
305 context,
306 hash,
307 &message,
308 flags);
309
310skip_message:
311 cleanup_message (&message);
312}
static pa_context * context
Pulseaudio context.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:43
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling.
void process_message_control(struct GNUNET_MESSENGER_MessageControl *control, const struct GNUNET_HashCode *sender, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message, enum GNUNET_MESSENGER_MessageFlags flags)
Processes a new message with its hash and regarding information about sender, context and message fla...
struct GNUNET_MESSENGER_MessageControl * control

References cleanup_message(), context, GNUNET_MESSENGER_Room::control, decode_message(), get_handle_room(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, msg, process_message_control(), and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_miss_message()

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

Definition at line 316 of file messenger_api.c.

318{
319 struct GNUNET_MESSENGER_Handle *handle = cls;
320
321 const struct GNUNET_HashCode *key = &(msg->key);
322 const struct GNUNET_HashCode *hash = &(msg->hash);
323
324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Missing message in room: %s\n",
325 GNUNET_h2s (hash));
326
328
329 if (! room)
330 {
332 "Miss in unknown room for this client: %s\n", GNUNET_h2s (key));
333 return;
334 }
335
336 if (! get_room_sender_id (room))
337 return;
338
339 struct GNUNET_MESSENGER_Message *message = create_message_request (hash);
340 if (! message)
341 return;
342
343 enqueue_message_to_room (room, message, NULL);
344}
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.

References create_message_request(), enqueue_message_to_room(), get_handle_room(), get_room_sender_id(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, and msg.

Here is the call graph for this function:

◆ reconnect()

static void reconnect ( struct GNUNET_MESSENGER_Handle handle)
static

Definition at line 539 of file messenger_api.c.

540{
541 const struct GNUNET_MQ_MessageHandler handlers[] = {
543 member_id,
546 ),
548 room_open,
551 ),
553 room_entry,
556 ),
558 room_close,
561 ),
566 ),
568 miss_message,
571 ),
573 room_sync,
576 ),
578 };
579
583}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static enum GNUNET_GenericReturnValue recv_message(void *cls, const struct GNUNET_MessageHeader *msg)
We have received a full message, pass to the MQ dispatcher.
Definition: client.c:335
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
static void callback_mq_error(void *cls, enum GNUNET_MQ_Error error)
Message to request something from a room.
Message to receive the current member id of a handle in room.
Message to receive something from a room.
General message to confirm interaction with a room.
Message handler for a specific message type.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
Definition: vpn_api.c:39
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44

References callback_mq_error(), GNUNET_VPN_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, handle, handlers, GNUNET_VPN_Handle::mq, and recv_message().

Referenced by callback_reconnect(), and GNUNET_MESSENGER_connect().

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

◆ send_open_room()

static void send_open_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 351 of file messenger_api.c.

353{
355
357 struct GNUNET_MQ_Envelope *env;
358
360 "Open room (%s) by member using key: %s\n",
361 GNUNET_h2s (&(room->key)),
363
364 const ssize_t len = GNUNET_CRYPTO_public_key_get_length (key);
365
366 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
368 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
369 GNUNET_memcpy (&(msg->previous), &(room->last_message),
370 sizeof(msg->previous));
371
372 char *msg_buffer = ((char*) msg) + sizeof(*msg);
373
374 if (len > 0)
376
378}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:68
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:551
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
Definition: crypto_pkey.c:128
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_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
const struct GNUNET_CRYPTO_PublicKey * get_handle_pubkey(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
struct GNUNET_HashCode key
struct GNUNET_HashCode last_message

References env, get_handle_pubkey(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_CRYPTO_write_public_key_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::last_message, GNUNET_VPN_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_open_room(), and iterate_reset_room().

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

◆ send_enter_room()

static void send_enter_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_PeerIdentity door 
)
static

Definition at line 382 of file messenger_api.c.

385{
387
389 struct GNUNET_MQ_Envelope *env;
390
391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Enter room (%s) via door: %s (%s)\n",
392 GNUNET_h2s (&(room->key)),
393 GNUNET_i2s (door),
395
396 const ssize_t len = GNUNET_CRYPTO_public_key_get_length (key);
397
398 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
400 GNUNET_memcpy (&(msg->door), door, sizeof(*door));
401 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
402 GNUNET_memcpy (&(msg->previous), &(room->last_message),
403 sizeof(msg->previous));
404
405 char *msg_buffer = ((char*) msg) + sizeof(*msg);
406
407 if (len > 0)
409
411}
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).

References env, get_handle_pubkey(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_CRYPTO_write_public_key_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::last_message, GNUNET_VPN_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_enter_room(), and iterate_reset_room().

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

◆ send_close_room()

static void send_close_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 415 of file messenger_api.c.

417{
419 struct GNUNET_MQ_Envelope *env;
420
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Close room (%s)!\n",
422 GNUNET_h2s (&(room->key)));
423
425
426 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
427 GNUNET_memcpy (&(msg->previous), &(room->last_message),
428 sizeof(msg->previous));
429
431}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::last_message, GNUNET_VPN_Handle::mq, and msg.

Referenced by iterate_close_room(), and send_message_to_room().

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

◆ send_sync_room()

static void send_sync_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 435 of file messenger_api.c.

437{
439 struct GNUNET_MQ_Envelope *env;
440
442
443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sync room (%s)!\n",
444 GNUNET_h2s (&(room->key)));
445
447
448 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
449 GNUNET_memcpy (&(msg->previous), &(room->last_message),
450 sizeof(msg->previous));
451
453}

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::last_message, GNUNET_VPN_Handle::mq, msg, and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by enqueue_message_to_room().

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

◆ iterate_reset_room()

static enum GNUNET_GenericReturnValue iterate_reset_room ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 457 of file messenger_api.c.

460{
461 struct GNUNET_MESSENGER_Handle *handle = cls;
462 struct GNUNET_MESSENGER_Room *room = value;
463
464 if (GNUNET_YES == room->opened)
465 send_open_room (handle, room);
466
467 struct GNUNET_MESSENGER_ListTunnel *entry = room->entries.head;
468
469 struct GNUNET_PeerIdentity door;
470
471 while (entry)
472 {
473 GNUNET_PEER_resolve (entry->peer, &door);
474
475 send_enter_room (handle, room, &door);
476
477 entry = entry->next;
478 }
479
480 return GNUNET_YES;
481}
static char * value
Value of the record to add/remove.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:220
static void send_enter_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
static void send_open_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head
enum GNUNET_GenericReturnValue opened
struct GNUNET_MESSENGER_ListTunnels entries

References GNUNET_MESSENGER_Room::entries, GNUNET_PEER_resolve(), GNUNET_YES, handle, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_ListTunnel::next, GNUNET_MESSENGER_Room::opened, GNUNET_MESSENGER_ListTunnel::peer, send_enter_room(), send_open_room(), and value.

Referenced by callback_reconnect().

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

◆ callback_reconnect()

static void callback_reconnect ( void *  cls)
static

Definition at line 485 of file messenger_api.c.

486{
487 struct GNUNET_MESSENGER_Handle *handle = cls;
488
489 handle->reconnect_task = NULL;
490 handle->reconnect_time = GNUNET_TIME_STD_BACKOFF (handle->reconnect_time);
491
492 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnect messenger!\n");
493
495
497 handle);
498}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void reconnect(struct GNUNET_MESSENGER_Handle *handle)
static enum GNUNET_GenericReturnValue iterate_reset_room(void *cls, const struct GNUNET_HashCode *key, void *value)

References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_STD_BACKOFF, handle, iterate_reset_room(), and reconnect().

Referenced by callback_mq_error().

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

◆ iterate_close_room()

static enum GNUNET_GenericReturnValue iterate_close_room ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 502 of file messenger_api.c.

505{
506 struct GNUNET_MESSENGER_Handle *handle = cls;
507 struct GNUNET_MESSENGER_Room *room = value;
508
509 send_close_room (handle, room);
510
511 return GNUNET_YES;
512}
static void send_close_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)

References GNUNET_YES, handle, send_close_room(), and value.

Referenced by callback_mq_error().

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

◆ callback_mq_error()

static void callback_mq_error ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Definition at line 516 of file messenger_api.c.

518{
519 struct GNUNET_MESSENGER_Handle *handle = cls;
520
521 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MQ_Error: %u\n", error);
522
524 handle);
525
526 if (handle->mq)
527 {
529 handle->mq = NULL;
530 }
531
532 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_time,
534 handle);
535}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
static void callback_reconnect(void *cls)
static enum GNUNET_GenericReturnValue iterate_close_room(void *cls, const struct GNUNET_HashCode *key, void *value)

References callback_reconnect(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), handle, iterate_close_room(), and GNUNET_VPN_Handle::mq.

Referenced by reconnect().

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

◆ send_message_to_room()

static void send_message_to_room ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_CRYPTO_PrivateKey key,
struct GNUNET_HashCode hash 
)
static

Definition at line 637 of file messenger_api.c.

641{
642 const struct GNUNET_ShortHashCode *sender_id = get_room_sender_id (room);
643
646
647 GNUNET_memcpy (&(message->header.sender_id), sender_id,
648 sizeof(message->header.sender_id));
649 GNUNET_memcpy (&(message->header.previous), &(room->last_message),
650 sizeof(message->header.previous));
651
652 message->header.signature.type = key->type;
653
654 const uint16_t msg_length = get_message_size (message, GNUNET_YES);
655
657 struct GNUNET_MQ_Envelope *env;
658
660 msg, msg_length,
662 );
663
664 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
665
666 char *msg_buffer = ((char*) msg) + sizeof(*msg);
667 encode_message (message, msg_length, msg_buffer, GNUNET_YES);
668
669 hash_message (message, msg_length, msg_buffer, hash);
670 sign_message (message, msg_length, msg_buffer, hash, key);
671
672 update_room_last_message (room, hash);
673
674 GNUNET_MQ_send (room->handle->mq, env);
675
677 send_close_room (room->handle, room);
678}
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, enum GNUNET_GenericReturnValue include_header)
Encodes a given message into a buffer of a maximal length in bytes.
void sign_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PrivateKey *key)
Signs the hash of a message with a given private key and writes the signature into the buffer as well...
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, enum GNUNET_GenericReturnValue include_header)
Returns the exact size in bytes to encode a given message.
uint32_t type
Type of signature.
struct GNUNET_MQ_Handle * mq
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
struct GNUNET_CRYPTO_Signature signature
The signature of the senders private key.
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.
Message to send something into a room.

References encode_message(), env, get_message_size(), get_room_sender_id(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GNUNET_MESSENGER_Room::handle, hash_message(), GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Room::last_message, GNUNET_MESSENGER_Handle::mq, msg, GNUNET_MESSENGER_MessageHeader::previous, send_close_room(), GNUNET_MESSENGER_MessageHeader::sender_id, sign_message(), GNUNET_MESSENGER_MessageHeader::signature, GNUNET_MESSENGER_MessageHeader::timestamp, GNUNET_CRYPTO_Signature::type, and update_room_last_message().

Referenced by dequeue_messages_from_room().

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

◆ iterate_send_name_to_room()

static enum GNUNET_GenericReturnValue iterate_send_name_to_room ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 774 of file messenger_api.c.

777{
778 const struct GNUNET_MESSENGER_Handle *handle = cls;
779
780 if (GNUNET_YES != room->use_handle_name)
781 return GNUNET_YES;
782
783 const char *name = get_handle_name (handle);
784
785 if (! name)
786 return GNUNET_YES;
787
789
790 if (! message)
791 return GNUNET_NO;
792
793 enqueue_message_to_room (room, message, NULL);
794 return GNUNET_YES;
795}
static char * name
Name (label) of the records to list.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
struct GNUNET_MESSENGER_Message * create_message_name(const char *name)
Creates and allocates a new name message containing the name to change to.
enum GNUNET_GenericReturnValue use_handle_name

References create_message_name(), enqueue_message_to_room(), get_handle_name(), GNUNET_NO, GNUNET_YES, handle, name, and GNUNET_MESSENGER_Room::use_handle_name.

Referenced by GNUNET_MESSENGER_set_name().

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

◆ get_non_anonymous_key()

static const struct GNUNET_CRYPTO_PublicKey * get_non_anonymous_key ( const struct GNUNET_CRYPTO_PublicKey public_key)
static

Definition at line 812 of file messenger_api.c.

813{
814 if (0 == GNUNET_memcmp (public_key, get_anonymous_public_key ()))
815 return NULL;
816
817 return public_key;
818}
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const struct GNUNET_CRYPTO_PublicKey * get_anonymous_public_key()
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...

References get_anonymous_public_key(), and GNUNET_memcmp.

Referenced by check_ticket_audience(), GNUNET_MESSENGER_contact_get_key(), GNUNET_MESSENGER_get_key(), and GNUNET_MESSENGER_send_message().

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

◆ iterate_send_key_to_room()

static enum GNUNET_GenericReturnValue iterate_send_key_to_room ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 832 of file messenger_api.c.

835{
836 const struct GNUNET_CRYPTO_PrivateKey *key = cls;
837
839
840 if (! message)
841 return GNUNET_NO;
842
843 enqueue_message_to_room (room, message, NULL);
844 return GNUNET_YES;
845}
struct GNUNET_MESSENGER_Message * create_message_key(const struct GNUNET_CRYPTO_PrivateKey *key)
Creates and allocates a new key message containing the public key to change to derived from its priva...

References create_message_key(), enqueue_message_to_room(), GNUNET_NO, GNUNET_YES, and key.

Referenced by GNUNET_MESSENGER_set_key().

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

◆ iterate_find_room()

static enum GNUNET_GenericReturnValue iterate_find_room ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 953 of file messenger_api.c.

956{
957 struct GNUNET_MESSENGER_RoomFind *find = cls;
958 struct GNUNET_MESSENGER_Room *room = value;
959
960 if ((find->counter > 0) && ((! find->contact) || (GNUNET_YES ==
961 find_room_member (room,
962 find->
963 contact))))
964 {
965 find->counter--;
966
967 if (! find->callback)
968 return GNUNET_YES;
969
970 return find->callback (find->cls, room, find->contact);
971 }
972 else
973 return GNUNET_NO;
974}
enum GNUNET_GenericReturnValue find_room_member(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Checks through all members of a given room if a specific contact is found and returns a result depend...
GNUNET_MESSENGER_MemberCallback callback
const struct GNUNET_MESSENGER_Contact * contact

References GNUNET_MESSENGER_RoomFind::callback, GNUNET_MESSENGER_RoomFind::cls, GNUNET_MESSENGER_RoomFind::contact, GNUNET_MESSENGER_RoomFind::counter, find_room_member(), GNUNET_NO, GNUNET_YES, and value.

Referenced by GNUNET_MESSENGER_find_rooms().

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

◆ send_message_to_room_with_key()

static void send_message_to_room_with_key ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_CRYPTO_PublicKey public_key 
)
static

Definition at line 1064 of file messenger_api.c.

1067{
1068 struct GNUNET_MESSENGER_Message *transcript = NULL;
1069 const struct GNUNET_CRYPTO_PublicKey *pubkey;
1070
1071 char *original_name;
1072
1073 if (GNUNET_MESSENGER_KIND_NAME != message->header.kind)
1074 goto skip_naming;
1075
1076 original_name = message->body.name.name;
1078 "Apply rule for using handle name in room: %s\n", GNUNET_h2s (
1079 &(room->key)));
1080
1081 const char *handle_name = get_handle_name (room->handle);
1082
1083 if ((handle_name) && (GNUNET_YES == room->use_handle_name) &&
1084 ((! original_name) || (0 == strlen (original_name))))
1085 {
1086 if (original_name)
1087 GNUNET_free (original_name);
1088
1089 message->body.name.name = GNUNET_strdup (handle_name);
1090 }
1091
1092skip_naming:
1093 if (! public_key)
1094 goto skip_encryption;
1095
1097
1098 if (0 != GNUNET_memcmp (pubkey, public_key))
1099 transcript = transcribe_message (message, public_key);
1100
1101 if (GNUNET_YES != encrypt_message (message, public_key))
1102 {
1104 "Sending message aborted: Encryption failed!\n");
1105
1106 if (transcript)
1107 destroy_message (transcript);
1108
1109 destroy_message (message);
1110 return;
1111 }
1112
1113skip_encryption:
1114 enqueue_message_to_room (room, message, transcript);
1115}
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_free(ptr)
Wrapper around free.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
struct GNUNET_MESSENGER_Message * transcribe_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key)
Transcribes a message as a new transcript message using a given public key from the recipient of the ...
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, destroy_message(), encrypt_message(), enqueue_message_to_room(), get_handle_name(), get_handle_pubkey(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_MESSENGER_KIND_NAME, GNUNET_strdup, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, pubkey, transcribe_message(), and GNUNET_MESSENGER_Room::use_handle_name.

Referenced by delete_message_in_room(), GNUNET_MESSENGER_send_message(), and GNUNET_MESSENGER_send_ticket().

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

◆ delete_message_in_room()

void delete_message_in_room ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Definition at line 1163 of file messenger_api.c.

1166{
1167 struct GNUNET_MESSENGER_Message *message = create_message_delete (hash,
1168 delay);
1169
1170 if (! message)
1171 {
1173 "Sending deletion aborted: Message creation failed!\n");
1174 return;
1175 }
1176
1177 send_message_to_room_with_key (room, message, NULL);
1178}
static void send_message_to_room_with_key(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *public_key)
struct GNUNET_MESSENGER_Message * create_message_delete(const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Creates and allocates a new delete message containing the hash of a message to delete after a specifi...

References create_message_delete(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, and send_message_to_room_with_key().

Referenced by GNUNET_MESSENGER_delete_message(), and handle_delete_message().

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

◆ check_ticket_audience()

static enum GNUNET_GenericReturnValue check_ticket_audience ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 1238 of file messenger_api.c.

1241{
1242 struct GNUNET_MESSENGER_CheckTicket *check = cls;
1243
1244 const struct GNUNET_CRYPTO_PublicKey *key;
1246
1247 if ((key) && (0 == GNUNET_memcmp (key, check->audience)))
1248 {
1249 check->result = GNUNET_YES;
1250 return GNUNET_NO;
1251 }
1252
1253 return GNUNET_YES;
1254}
static const struct GNUNET_CRYPTO_PublicKey * get_non_anonymous_key(const struct GNUNET_CRYPTO_PublicKey *public_key)
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.
const struct GNUNET_CRYPTO_PublicKey * audience
enum GNUNET_GenericReturnValue result

References GNUNET_MESSENGER_CheckTicket::audience, get_contact_key(), get_non_anonymous_key(), GNUNET_memcmp, GNUNET_NO, GNUNET_YES, key, and GNUNET_MESSENGER_CheckTicket::result.

Referenced by GNUNET_MESSENGER_send_ticket().

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