GNUnet 0.21.1
MESSENGER service

Instant messaging based on the CADET subsystem. More...

Data Structures

struct  GNUNET_MESSENGER_RoomEntryRecord
 A room entry record specifies which peer is hosting a given room and may also specify the key to enter it. More...
 
struct  GNUNET_MESSENGER_RoomDetailsRecord
 A room details record specifies a custom name for a given room and some additional space for flags. More...
 
struct  GNUNET_MESSENGER_MessageHeader
 The header of a GNUNET_MESSENGER_Message. More...
 
struct  GNUNET_MESSENGER_MessageInfo
 An info message body. More...
 
struct  GNUNET_MESSENGER_MessageJoin
 A join message body. More...
 
struct  GNUNET_MESSENGER_MessageLeave
 A leave message body. More...
 
struct  GNUNET_MESSENGER_MessageName
 A name message body. More...
 
struct  GNUNET_MESSENGER_MessageKey
 A key message body. More...
 
struct  GNUNET_MESSENGER_MessagePeer
 A peer message body. More...
 
struct  GNUNET_MESSENGER_MessageId
 An id message body. More...
 
struct  GNUNET_MESSENGER_MessageMiss
 A miss message body. More...
 
struct  GNUNET_MESSENGER_MessageMerge
 A merge message body. More...
 
struct  GNUNET_MESSENGER_MessageRequest
 A request message body. More...
 
struct  GNUNET_MESSENGER_MessageInvite
 An invite message body. More...
 
struct  GNUNET_MESSENGER_MessageText
 A text message body. More...
 
struct  GNUNET_MESSENGER_MessageFile
 A file message body. More...
 
struct  GNUNET_MESSENGER_MessagePrivate
 A private message body. More...
 
struct  GNUNET_MESSENGER_MessageDelete
 A delete message body This allows deletion of an own previous message with any custom automatic delay. More...
 
struct  GNUNET_MESSENGER_MessageConnection
 A connection message body This allows to tell others about connection information about a peer. More...
 
struct  GNUNET_MESSENGER_MessageTicket
 A ticket message body This allows to exchange ticket identifiers with an audience. More...
 
struct  GNUNET_MESSENGER_MessageTranscript
 A transcript message body This allows reading the content of a sent private message. More...
 
struct  GNUNET_MESSENGER_MessageTag
 A tag message body This allows tagging a message with a custom tag. More...
 
struct  GNUNET_MESSENGER_MessageBody
 The unified body of a GNUNET_MESSENGER_Message. More...
 
struct  GNUNET_MESSENGER_Message
 Struct to a message. More...
 

Macros

#define GNUNET_MESSENGER_VERSION   0x00000003
 Version number of GNUnet Messenger API. More...
 
#define GNUNET_MESSENGER_SERVICE_NAME   "messenger"
 Identifier of GNUnet MESSENGER Service. More...
 
#define GNUNET_MESSENGER_KIND_MAX   (GNUNET_MESSENGER_KIND_DELETE)
 

Typedefs

typedef void(* GNUNET_MESSENGER_MessageCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
 Method called whenever a message is sent or received from a room. More...
 
typedef enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_MemberCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 Method called for each member in a room during iteration. More...
 

Enumerations

enum  GNUNET_MESSENGER_MessageKind {
  GNUNET_MESSENGER_KIND_INFO = 1 , GNUNET_MESSENGER_KIND_JOIN = 2 , GNUNET_MESSENGER_KIND_LEAVE = 3 , GNUNET_MESSENGER_KIND_NAME = 4 ,
  GNUNET_MESSENGER_KIND_KEY = 5 , GNUNET_MESSENGER_KIND_PEER = 6 , GNUNET_MESSENGER_KIND_ID = 7 , GNUNET_MESSENGER_KIND_MISS = 8 ,
  GNUNET_MESSENGER_KIND_MERGE = 9 , GNUNET_MESSENGER_KIND_REQUEST = 10 , GNUNET_MESSENGER_KIND_INVITE = 11 , GNUNET_MESSENGER_KIND_TEXT = 12 ,
  GNUNET_MESSENGER_KIND_FILE = 13 , GNUNET_MESSENGER_KIND_PRIVATE = 14 , GNUNET_MESSENGER_KIND_DELETE = 15 , GNUNET_MESSENGER_KIND_CONNECTION = 16 ,
  GNUNET_MESSENGER_KIND_TICKET = 17 , GNUNET_MESSENGER_KIND_TRANSCRIPT = 18 , GNUNET_MESSENGER_KIND_TAG = 19 , GNUNET_MESSENGER_KIND_UNKNOWN = 0
}
 Enum for the different supported kinds of messages. More...
 
enum  GNUNET_MESSENGER_MessageFlags {
  GNUNET_MESSENGER_FLAG_NONE = 0 , GNUNET_MESSENGER_FLAG_SENT = 1 , GNUNET_MESSENGER_FLAG_PRIVATE = 2 , GNUNET_MESSENGER_FLAG_PEER = 4 ,
  GNUNET_MESSENGER_FLAG_RECENT = 8 , GNUNET_MESSENGER_FLAG_UPDATE = 16 , GNUNET_MESSENGER_FLAG_DELETE = 32
}
 Enum for the different supported flags used by message handling. More...
 
enum  GNUNET_MESSENGER_ConnectionFlags { GNUNET_MESSENGER_FLAG_CONNECTION_NONE = 0 , GNUNET_MESSENGER_FLAG_CONNECTION_AUTO = 1 }
 Enum for the different supported flags used to specify connection handling. More...
 

Functions

const char * GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
 Get the name of a message kind. More...
 
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...
 
const char * GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle)
 Get the name (if specified, otherwise NULL) used by the messenger. More...
 
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...
 
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...
 
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...
 
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...
 
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 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...
 
void GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_RECLAIM_Ticket *ticket)
 Send a ticket into a room. More...
 

Detailed Description

Instant messaging based on the CADET subsystem.

Macro Definition Documentation

◆ GNUNET_MESSENGER_VERSION

#define GNUNET_MESSENGER_VERSION   0x00000003

Version number of GNUnet Messenger API.

Current version of the Messenger: 0.3

Definition at line 56 of file gnunet_messenger_service.h.

◆ GNUNET_MESSENGER_SERVICE_NAME

#define GNUNET_MESSENGER_SERVICE_NAME   "messenger"

Identifier of GNUnet MESSENGER Service.

Definition at line 61 of file gnunet_messenger_service.h.

◆ GNUNET_MESSENGER_KIND_MAX

#define GNUNET_MESSENGER_KIND_MAX   (GNUNET_MESSENGER_KIND_DELETE)

Definition at line 226 of file gnunet_messenger_service.h.

Typedef Documentation

◆ GNUNET_MESSENGER_MessageCallback

typedef void(* GNUNET_MESSENGER_MessageCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)

Method called whenever a message is sent or received from a room.

The flags will indicate with a bitmask if a message was received privately or if the message was sent by the client.

Parameters
[in/out]cls Closure from GNUNET_MESSENGER_connect
[in]roomRoom handle
[in]senderSender of message
[in]recipientRecipient of message
[in]messageNewly received or sent message
[in]hashHash identifying the message
[in]flagsFlags of the message

Definition at line 715 of file gnunet_messenger_service.h.

◆ GNUNET_MESSENGER_MemberCallback

typedef enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_MemberCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)

Method called for each member in a room during iteration.

If the method returns GNUNET_YES the iteration continues, otherwise it will quit the iteration.

Parameters
[in/out]cls Closure from GNUNET_MESSENGER_iterate_members
[in]roomRoom handle
[in]contactContact handle

Definition at line 715 of file gnunet_messenger_service.h.

Enumeration Type Documentation

◆ GNUNET_MESSENGER_MessageKind

Enum for the different supported kinds of messages.

Enumerator
GNUNET_MESSENGER_KIND_INFO 

The info kind.

The message contains a GNUNET_MESSENGER_MessageInfo body.

GNUNET_MESSENGER_KIND_JOIN 

The join kind.

The message contains a GNUNET_MESSENGER_MessageJoin body.

GNUNET_MESSENGER_KIND_LEAVE 

The leave kind.

The message contains a GNUNET_MESSENGER_MessageLeave body.

GNUNET_MESSENGER_KIND_NAME 

The name kind.

The message contains a GNUNET_MESSENGER_MessageName body.

GNUNET_MESSENGER_KIND_KEY 

The key kind.

The message contains a GNUNET_MESSENGER_MessageKey body.

GNUNET_MESSENGER_KIND_PEER 

The peer kind.

The message contains a GNUNET_MESSENGER_MessagePeer body.

GNUNET_MESSENGER_KIND_ID 

The id kind.

The message contains a GNUNET_MESSENGER_MessageId body.

GNUNET_MESSENGER_KIND_MISS 

The miss kind.

The message contains a GNUNET_MESSENGER_MessageMiss body.

GNUNET_MESSENGER_KIND_MERGE 

The merge kind.

The message contains a GNUNET_MESSENGER_MessageMerge body.

GNUNET_MESSENGER_KIND_REQUEST 

The request kind.

The message contains a GNUNET_MESSENGER_MessageRequest body.

GNUNET_MESSENGER_KIND_INVITE 

The invite kind.

The message contains a GNUNET_MESSENGER_MessageInvite body.

GNUNET_MESSENGER_KIND_TEXT 

The text kind.

The message contains a GNUNET_MESSENGER_MessageText body.

GNUNET_MESSENGER_KIND_FILE 

The file kind.

The message contains a GNUNET_MESSENGER_MessageFile body.

GNUNET_MESSENGER_KIND_PRIVATE 

The private kind.

The message contains a GNUNET_MESSENGER_MessagePrivate body.

GNUNET_MESSENGER_KIND_DELETE 

The delete kind.

The message contains a GNUNET_MESSENGER_MessageDelete body.

GNUNET_MESSENGER_KIND_CONNECTION 

The connection kind.

The message contains a GNUNET_MESSENGER_MessageConnection body.

GNUNET_MESSENGER_KIND_TICKET 

The ticket kind.

The message contains a GNUNET_MESSENGER_MessageTicket body.

GNUNET_MESSENGER_KIND_TRANSCRIPT 

The transcript kind.

The message contains a GNUNET_MESSENGER_MessageTranscript body.

GNUNET_MESSENGER_KIND_TAG 

The tag kind.

The message contains a GNUNET_MESSENGER_MessageTag body.

GNUNET_MESSENGER_KIND_UNKNOWN 

The unknown kind.

The message contains an unknown body.

Definition at line 123 of file gnunet_messenger_service.h.

124{
129
134
139
144
149
154
159
164
169
174
179
184
189
194
199
204
209
214
219
224};
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_TAG
The tag kind.
@ GNUNET_MESSENGER_KIND_FILE
The file kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_KIND_TRANSCRIPT
The transcript kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_TICKET
The ticket kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.

◆ GNUNET_MESSENGER_MessageFlags

Enum for the different supported flags used by message handling.

Compatible flags can be OR'ed together.

Enumerator
GNUNET_MESSENGER_FLAG_NONE 

The none flag.

The flag indicates that the message is not affected by any special context.

GNUNET_MESSENGER_FLAG_SENT 

The sent flag.

The flag indicates that the message was sent by the client.

GNUNET_MESSENGER_FLAG_PRIVATE 

The private flag.

The flag indicates that the message was privately encrypted.

GNUNET_MESSENGER_FLAG_PEER 

The peer flag.

The flag indicates that the message was sent by a peer and not a member.

GNUNET_MESSENGER_FLAG_RECENT 

The recent flag.

The flag indicates that the message was recently handled by the service.

GNUNET_MESSENGER_FLAG_UPDATE 

The update flag.

The flag indicates that the message was updated by the client.

GNUNET_MESSENGER_FLAG_DELETE 

The delete flag.

The flag indicates that the message was deleted by the service.

Definition at line 646 of file gnunet_messenger_service.h.

647{
652
657
662
667
672
677
682};
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
@ GNUNET_MESSENGER_FLAG_DELETE
The delete flag.
@ GNUNET_MESSENGER_FLAG_PEER
The peer flag.
@ GNUNET_MESSENGER_FLAG_RECENT
The recent flag.

◆ GNUNET_MESSENGER_ConnectionFlags

Enum for the different supported flags used to specify connection handling.

Compatible flags can be OR'ed together.

Enumerator
GNUNET_MESSENGER_FLAG_CONNECTION_NONE 

The none flag.

The flag indicates that the connection is not affected by any modifications. GNUNET_MESSENGER_FLAG_CONNECTION_NONE

GNUNET_MESSENGER_FLAG_CONNECTION_AUTO 

The auto flag.

The flag indicates that a peer will automatically handle routing. GNUNET_MESSENGER_FLAG_CONNECTION_AUTO

Definition at line 688 of file gnunet_messenger_service.h.

689{
699};
@ GNUNET_MESSENGER_FLAG_CONNECTION_AUTO
The auto flag.
@ GNUNET_MESSENGER_FLAG_CONNECTION_NONE
The none flag.

Function Documentation

◆ GNUNET_MESSENGER_name_of_kind()

const char * GNUNET_MESSENGER_name_of_kind ( enum GNUNET_MESSENGER_MessageKind  kind)

Get the name of a message kind.

Parameters
kindKind of a message
Returns
Name of that kind

Definition at line 43 of file messenger_api.c.

44{
45 switch (kind)
46 {
48 return "INFO";
50 return "JOIN";
52 return "LEAVE";
54 return "NAME";
56 return "KEY";
58 return "PEER";
60 return "ID";
62 return "MISS";
64 return "MERGE";
66 return "REQUEST";
68 return "INVITE";
70 return "TEXT";
72 return "FILE";
74 return "PRIVATE";
76 return "DELETE";
78 return "CONNECTION";
80 return "TICKET";
82 return "TRANSCRIPT";
84 return "TAG";
85 default:
86 return "UNKNOWN";
87 }
88}

References GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, and GNUNET_MESSENGER_KIND_TRANSCRIPT.

Referenced by callback_verify_room_message(), handle_recv_message(), handle_send_message(), handle_tunnel_message(), notify_srv_handle_message(), on_message(), and send_srv_room_message().

Here is the caller graph for this function:

◆ GNUNET_MESSENGER_connect()

struct GNUNET_MESSENGER_Handle * GNUNET_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.

It will use the a custom name in combination of a private key provided for signing all messages from the handle.

Parameters
[in]cfgConfiguration to use
[in]nameName or NULL
[in]keyPrivate key or NULL to stay anonymous
[in]msg_callbackFunction called when a new message is sent or received
[in,out]msg_clsClosure for the msg_callback handler
Returns
Messenger handle to use, NULL on error

Definition at line 587 of file messenger_api.c.

592{
594 msg_cls);
595
597
598 if (handle->mq)
599 {
601
604
606 struct GNUNET_MQ_Envelope *env;
607
610 return handle;
611 }
612 else
613 {
615 return NULL;
616 }
617}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
struct GNUNET_HashCode key
The key used in the DHT.
static char * name
Name (label) of the records to list.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:47
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE
static void reconnect(struct GNUNET_MESSENGER_Handle *handle)
struct GNUNET_MESSENGER_Handle * create_handle(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Creates and allocates a new handle using a given configuration and a custom message callback with a g...
void destroy_handle(struct GNUNET_MESSENGER_Handle *handle)
Destroys a handle and frees its memory fully from the client API.
void set_handle_key(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_PrivateKey *key)
Sets the keypair of a given handle to the keypair of a specific private key.
void set_handle_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Sets the name of a handle to a specific name.
Message to create a handle for a client.
GNUNET_MESSENGER_MessageCallback msg_callback
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44

References cfg, create_handle(), destroy_handle(), env, GNUNET_CRYPTO_private_key_get_length(), GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, key, GNUNET_VPN_Handle::mq, msg, GNUNET_MESSENGER_Handle::msg_callback, GNUNET_MESSENGER_Handle::msg_cls, name, reconnect(), set_handle_key(), and set_handle_name().

Referenced by on_ego_lookup(), run(), and start_service_run().

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

◆ GNUNET_MESSENGER_disconnect()

void GNUNET_MESSENGER_disconnect ( struct GNUNET_MESSENGER_Handle handle)

Disconnect all of the messengers used services and clears up its used memory.

Parameters
[in,out]handleMessenger handle to use

Definition at line 621 of file messenger_api.c.

622{
623 if (! handle)
624 return;
625
627 struct GNUNET_MQ_Envelope *env;
628
631
633}
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
Message to destroy the handle for a client.

References destroy_handle(), env, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, GNUNET_VPN_Handle::mq, and msg.

Referenced by shutdown_hook(), and stop_service_run().

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

◆ GNUNET_MESSENGER_get_name()

const char * GNUNET_MESSENGER_get_name ( const struct GNUNET_MESSENGER_Handle handle)

Get the name (if specified, otherwise NULL) used by the messenger.

Parameters
[in]handleMessenger handle to use
Returns
Name used by the messenger or NULL

Definition at line 764 of file messenger_api.c.

765{
766 if (! handle)
767 return NULL;
768
769 return get_handle_name (handle);
770}
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.

References get_handle_name(), and handle.

Referenced by on_identity(), and on_message().

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

◆ GNUNET_MESSENGER_set_name()

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.

Parameters
[in,out]handleMessenger handle to use
[in]nameName for the messenger to change to
Returns
GNUNET_YES on success, GNUNET_NO on failure and GNUNET_SYSERR if handle is NULL

Definition at line 799 of file messenger_api.c.

801{
802 if (! handle)
803 return GNUNET_SYSERR;
804
805 set_handle_name (handle, strlen (name) > 0 ? name : NULL);
807 return GNUNET_YES;
808}
@ GNUNET_YES
@ GNUNET_SYSERR
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 fo...
static enum GNUNET_GenericReturnValue iterate_send_name_to_room(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)

References GNUNET_MESSENGER_find_rooms(), GNUNET_SYSERR, GNUNET_YES, handle, iterate_send_name_to_room(), name, and set_handle_name().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_get_key()

const struct GNUNET_CRYPTO_PublicKey * GNUNET_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.

Parameters
[in]handleMessenger handle to use
Returns
Used public key or NULL

Definition at line 822 of file messenger_api.c.

823{
824 if (! handle)
825 return NULL;
826
828}
static const struct GNUNET_CRYPTO_PublicKey * get_non_anonymous_key(const struct GNUNET_CRYPTO_PublicKey *public_key)
const struct GNUNET_CRYPTO_PublicKey * get_handle_pubkey(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.

References get_handle_pubkey(), get_non_anonymous_key(), and handle.

Here is the call graph for this function:

◆ GNUNET_MESSENGER_set_key()

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.

The currently used key will be replaced and the change will get signed accordingly to be verified by all contacts.

Parameters
[in,out]handleMessenger handle to use
[in]keyPrivate key to change to or NULL
Returns
GNUNET_YES on success, GNUNET_NO on failure and GNUNET_SYSERR if handle is NULL

Definition at line 849 of file messenger_api.c.

851{
852 if (! handle)
853 return GNUNET_SYSERR;
854
855 if (! key)
856 {
858 set_handle_key (handle, NULL);
859 return GNUNET_YES;
860 }
861
863 return GNUNET_SYSERR;
864
865 struct GNUNET_CRYPTO_PrivateKey priv;
866 GNUNET_memcpy (&priv, key, sizeof (priv));
867
869 set_handle_key (handle, &priv);
870 return GNUNET_YES;
871}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static enum GNUNET_GenericReturnValue iterate_send_key_to_room(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
A private key for an identity as per LSD0001.

References GNUNET_CRYPTO_private_key_get_length(), GNUNET_memcpy, GNUNET_MESSENGER_find_rooms(), GNUNET_SYSERR, GNUNET_YES, handle, iterate_send_key_to_room(), key, and set_handle_key().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_open_room()

struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_open_room ( struct GNUNET_MESSENGER_Handle handle,
const struct GNUNET_HashCode key 
)

Open a room to send and receive messages.

The room will use the specified key as port for the underlying cadet service. Opening a room results in opening the port for incoming connections as possible door.

Notice that there can only be one room related to a specific key. So trying to open two rooms with the same key will result in opening the room once but returning the handle both times because the room stays open.

You can also open a room after entering it through a door using GNUNET_MESSENGER_enter_room. This will notify all entered doors to list you as new door.

( All doors form a ring structured network to shorten the latency sending and receiving messages. )

Parameters
[in,out]handleMessenger handle to use
[in]keyHash identifying the port
Returns
Room handle, NULL on error

Definition at line 875 of file messenger_api.c.

877{
878 if ((! handle) || (! key))
879 return NULL;
880
882 handle->rooms, key);
883
884 if (! room)
885 {
886 room = create_room (handle, key);
887
889 room,
891 {
892 destroy_room (room);
893 return NULL;
894 }
895 }
896
897 send_open_room (handle, room);
898 return room;
899}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
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...
@ GNUNET_OK
static void send_open_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
void destroy_room(struct GNUNET_MESSENGER_Room *room)
Destroys a room and frees its memory fully from the client API.
struct GNUNET_MESSENGER_Room * create_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key for the client API.

References create_room(), destroy_room(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_OK, handle, key, and send_open_room().

Referenced by join_room_run(), and on_identity().

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

◆ GNUNET_MESSENGER_enter_room()

struct GNUNET_MESSENGER_Room * GNUNET_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.

Notice that there can only be one room related to a specific key. So trying to enter two rooms with the same key will result in entering the room once but returning the handle both times because the room stays entered. You can however enter a room through multiple doors in parallel which results in connecting both ends. But entering the room through the same door won't have any effect after the first time.

You can also enter a room through a door after opening it using GNUNET_MESSENGER_open_room. But the door may not be your own peer identity.

( All doors form a ring structured network to shorten the latency sending and receiving messages. )

Parameters
[in,out]handleMessenger handle to use
[in]doorPeer identity of an open door
[in]keyHash identifying the port
Returns
Room handle, NULL on error

Definition at line 903 of file messenger_api.c.

906{
907 if ((! handle) || (! door) || (! key))
908 return NULL;
909
911 handle->rooms, key);
912
913 if (! room)
914 {
915 room = create_room (handle, key);
916
918 room,
920 {
921 destroy_room (room);
922 return NULL;
923 }
924 }
925
926 send_enter_room (handle, room, door);
927 return room;
928}
static void send_enter_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)

References create_room(), destroy_room(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_OK, handle, key, and send_enter_room().

Referenced by join_room_run(), and on_identity().

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

◆ GNUNET_MESSENGER_close_room()

void GNUNET_MESSENGER_close_room ( struct GNUNET_MESSENGER_Room room)

Close a room which was entered, opened or both in various order and variety.

Closing a room will destroy all connections from your peer to another and the other way around.

( After a member closes a door, all members entered through that specific door have to use another one or open the room on their own. )

Parameters
[in,out]roomRoom handle

Definition at line 932 of file messenger_api.c.

933{
934 if (! room)
935 return;
936
938
939 if (message)
940 enqueue_message_to_room (room, message, NULL);
941}
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_leave()
Creates and allocates a new leave message.

References create_message_leave(), and enqueue_message_to_room().

Referenced by shutdown_hook().

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

◆ GNUNET_MESSENGER_find_rooms()

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.

The callback will receive a room matching the condition and the given contact. The function returns the amount of rooms iterated with the given callback.

Parameters
[in]handleMessenger handle to use
[in]contactContact handle
[in]callbackFunction called for each room
[in]clsClosure for the callback handler
Returns
Amount of rooms iterated

Definition at line 978 of file messenger_api.c.

982{
983 if (! handle)
984 return GNUNET_SYSERR;
985
986 struct GNUNET_MESSENGER_RoomFind find;
987
988 find.contact = contact;
989 find.callback = callback;
990 find.counter = (contact? contact->rc : SIZE_MAX);
991 find.cls = cls;
992
994 iterate_find_room, &find);
995}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static enum GNUNET_GenericReturnValue iterate_find_room(void *cls, const struct GNUNET_HashCode *key, void *value)
#define SIZE_MAX
Definition: platform.h:208
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, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_SYSERR, handle, iterate_find_room(), GNUNET_MESSENGER_Contact::rc, and SIZE_MAX.

Referenced by GNUNET_MESSENGER_set_key(), and GNUNET_MESSENGER_set_name().

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

◆ GNUNET_MESSENGER_room_get_key()

const struct GNUNET_HashCode * GNUNET_MESSENGER_room_get_key ( const struct GNUNET_MESSENGER_Room room)

Get the key of a given room.

Parameters
[in]roomRoom handle
Returns
Hash identifying the port or NULL on failure

Definition at line 999 of file messenger_api.c.

1000{
1001 if (! room)
1002 return NULL;
1003
1004 return &(room->key);
1005}
struct GNUNET_HashCode key

References GNUNET_MESSENGER_Room::key.

Referenced by on_message_cb().

Here is the caller graph for this function:

◆ GNUNET_MESSENGER_get_sender()

const struct GNUNET_MESSENGER_Contact * GNUNET_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.

Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.

Parameters
[in]roomRoom handle
[in]hashHash identifying a message
Returns
Contact handle, NULL otherwise

Definition at line 1009 of file messenger_api.c.

1011{
1012 if ((! room) || (! hash))
1013 return NULL;
1014
1015 return get_room_sender (room, hash);
1016}
struct GNUNET_MESSENGER_Contact * get_room_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages sender locally stored from a map for a given hash in a room.

References get_room_sender().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_get_recipient()

const struct GNUNET_MESSENGER_Contact * GNUNET_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.

Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.

Parameters
[in]roomRoom handle
[in]hashHash identifying a message
Returns
Contact handle, NULL otherwise

Definition at line 1020 of file messenger_api.c.

1022{
1023 if ((! room) || (! hash))
1024 return NULL;
1025
1026 return get_room_recipient (room, hash);
1027}
struct GNUNET_MESSENGER_Contact * get_room_recipient(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages recipient locally stored from a map for a given hash in a room.

References get_room_recipient().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_contact_get_name()

const char * GNUNET_MESSENGER_contact_get_name ( const struct GNUNET_MESSENGER_Contact contact)

Get the name used by the contact.

Parameters
[in]contactContact handle
Returns
Name of contact or NULL

Definition at line 1031 of file messenger_api.c.

1033{
1034 if (! contact)
1035 return NULL;
1036
1037 return get_contact_name (contact);
1038}
const char * get_contact_name(const struct GNUNET_MESSENGER_Contact *contact)
Returns the current name of a given contact or NULL if no valid name was assigned yet.

References get_contact_name().

Referenced by on_message().

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

◆ GNUNET_MESSENGER_contact_get_key()

const struct GNUNET_CRYPTO_PublicKey * GNUNET_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.

Parameters
[in]contactContact handle
Returns
Public key used by contact or NULL

Definition at line 1042 of file messenger_api.c.

1044{
1045 if (! contact)
1046 return NULL;
1047
1048 return get_non_anonymous_key (get_contact_key (contact));
1049}
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.

References get_contact_key(), and get_non_anonymous_key().

Referenced by iterate_send_private_message().

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

◆ GNUNET_MESSENGER_contact_get_id()

size_t GNUNET_MESSENGER_contact_get_id ( const struct GNUNET_MESSENGER_Contact contact)

Get the locally unique id of the contact.

Parameters
[in]contactContact handle
Returns
Locally unique contact id or zero

Definition at line 1053 of file messenger_api.c.

1055{
1056 if (! contact)
1057 return 0;
1058
1059 return get_contact_id (contact);
1060}
size_t get_contact_id(const struct GNUNET_MESSENGER_Contact *contact)
Returns the locally unique identifier of a given contact.

References get_contact_id().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_send_message()

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.

If you opened the room all entered members will receive the message. If you entered the room through a door all so entered doors will receive the message as well. All members receiving the message will also propagate this message recursively as long as the message is unknown to them.

Notice that all messages sent and received are also stored and can be propagated to new members entering the room.

If you provide a specific contact as receiver of the given message, the message will automatically be encrypted and sent as a private message (see GNUNET_MESSENGER_MessagePrivate). Therefore the selected contact will be the only member receiving the actual message.

Sending a message to all members in a given room can be done by providing NULL as contact.

Parameters
[in,out]roomRoom handle
[in,out]messageNew message to send
[in]contactContact or NULL

Definition at line 1119 of file messenger_api.c.

1122{
1123 if ((! room) || (! message))
1124 return;
1125
1126 switch (filter_message_sending (message))
1127 {
1128 case GNUNET_SYSERR:
1130 "Sending message aborted: This kind of message is reserved for the service!\n");
1131 return;
1132 case GNUNET_NO:
1134 "Sending message aborted: This kind of message could cause issues!\n");
1135 return;
1136 default:
1137 break;
1138 }
1139
1140 const struct GNUNET_CRYPTO_PublicKey *public_key;
1141
1142 if (contact)
1143 {
1144 public_key = get_non_anonymous_key (
1145 get_contact_key (contact)
1146 );
1147
1148 if (! public_key)
1149 {
1151 "Sending message aborted: Invalid key!\n");
1152 return;
1153 }
1154 }
1155 else
1156 public_key = NULL;
1157
1158 send_message_to_room_with_key (room, copy_message (message), public_key);
1159}
#define GNUNET_log(kind,...)
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
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 * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
enum GNUNET_GenericReturnValue filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message should be sent by a client.
An identity key as per LSD0001.

References copy_message(), filter_message_sending(), get_contact_key(), get_non_anonymous_key(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, and send_message_to_room_with_key().

Referenced by iterate_send_private_message(), on_message(), and read_stdio().

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

◆ GNUNET_MESSENGER_delete_message()

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.

A deletion will be propagated to all members of the room as with any other sent message. Notice that a deletion will only request other members of the room to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored.

Depending on the implementation other clients may also ignore your deletion request in other circumstances.

Parameters
[in,out]roomRoom handle
[in]messageMessage to delete
[in]delayDelay to delete the message

Definition at line 1182 of file messenger_api.c.

1185{
1186 if ((! room) || (! hash))
1187 return;
1188
1189 delete_message_in_room (room, hash, delay);
1190}
void delete_message_in_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)

References delete_message_in_room().

Here is the call graph for this function:

◆ GNUNET_MESSENGER_get_message()

const struct GNUNET_MESSENGER_Message * GNUNET_MESSENGER_get_message ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Get the message in a room identified by its hash.

Parameters
[in]roomRoom handle
[in]hashHash identifying a message
Returns
Message struct or NULL if no message with that hash is known

Definition at line 1194 of file messenger_api.c.

1196{
1197 if ((! room) || (! hash))
1198 return NULL;
1199
1200 const struct GNUNET_MESSENGER_Message *message = get_room_message (room,
1201 hash);
1202
1203 if (! message)
1204 {
1206 struct GNUNET_MQ_Envelope *env;
1207
1209 GNUNET_memcpy (&(msg->key), &(room->key), sizeof(msg->key));
1210 GNUNET_memcpy (&(msg->hash), hash, sizeof(*hash));
1211 GNUNET_MQ_send (room->handle->mq, env);
1212 }
1213
1214 return message;
1215}
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
Message to request something from a room.
struct GNUNET_MQ_Handle * mq
struct GNUNET_MESSENGER_Handle * handle

References env, get_room_message(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.

Here is the call graph for this function:

◆ GNUNET_MESSENGER_iterate_members()

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.

The callback will receive the contact of each member. The function returns the amount of members iterated with the given callback.

Parameters
[in]roomRoom handle
[in]callbackFunction called for each member
[in]clsClosure for the callback handler
Returns
Amount of members iterated

Definition at line 1219 of file messenger_api.c.

1222{
1223 if (! room)
1224 return GNUNET_SYSERR;
1225
1226 return iterate_room_members (room, callback, cls);
1227}
int iterate_room_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room to forward each of them to a selected callback with a cu...

References GNUNET_SYSERR, and iterate_room_members().

Referenced by read_stdio().

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

◆ GNUNET_MESSENGER_send_ticket()

void GNUNET_MESSENGER_send_ticket ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_RECLAIM_Ticket ticket 
)

Send a ticket into a room.

The ticket will automatically be converted into a message to be sent only to its audience as a private message.

A ticket can only be sent with this function if its issuer's public key is the one being used by the messenger. The audience's public key is not allowed to be the anonymous public key. The room needs to contain a member using the audience's public key.

Parameters
[in,out]roomRoom handle
[in]ticketTicket to send

Definition at line 1258 of file messenger_api.c.

1260{
1261 if ((! room) || (! ticket))
1262 return;
1263
1264 const struct GNUNET_CRYPTO_PublicKey *pubkey;
1266
1267 if (0 != GNUNET_memcmp (pubkey, &(ticket->identity)))
1268 {
1270 "Sending ticket aborted: Invalid identity!\n");
1271 return;
1272 }
1273
1274 struct GNUNET_MESSENGER_CheckTicket check;
1275 check.audience = &(ticket->audience);
1276 check.result = GNUNET_NO;
1277
1278 const int members = iterate_room_members (
1279 room,
1281 &check);
1282
1283 if ((! members) || (GNUNET_YES != check.result))
1284 {
1286 "Sending ticket aborted: Audience not found!\n");
1287 return;
1288 }
1289
1291 &(ticket->rnd)
1292 );
1293
1294 if (! message)
1295 {
1297 "Sending ticket aborted: Message creation failed!\n");
1298 return;
1299 }
1300
1301 send_message_to_room_with_key (room, message, &(ticket->audience));
1302}
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
static enum GNUNET_GenericReturnValue check_ticket_audience(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
struct GNUNET_MESSENGER_Message * create_message_ticket(const struct GNUNET_RECLAIM_Identifier *identifier)
Creates and allocates a new ticket message containing the identifier of a ticket to exchange it with ...
const struct GNUNET_CRYPTO_PublicKey * audience
struct GNUNET_CRYPTO_PublicKey audience
The ticket audience (= relying party)
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
struct GNUNET_CRYPTO_PublicKey identity
The ticket issuer (= the user)

References GNUNET_RECLAIM_Ticket::audience, GNUNET_MESSENGER_CheckTicket::audience, check_ticket_audience(), create_message_ticket(), get_handle_pubkey(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_RECLAIM_Ticket::identity, iterate_room_members(), pubkey, GNUNET_MESSENGER_CheckTicket::result, GNUNET_RECLAIM_Ticket::rnd, send_message_to_room_with_key(), and ticket.

Here is the call graph for this function: