![]() |
GNUnet
0.11.x
|
Instant messaging based on the CADET subsystem. More...
Macros | |
#define | GNUNET_MESSENGER_SERVICE_NAME "messenger" |
Typedefs | |
typedef void(* | GNUNET_MESSENGER_IdentityCallback) (void *cls, struct GNUNET_MESSENGER_Handle *handle) |
Method called whenever the EGO of a handle changes or if the first connection fails to load a valid EGO and the anonymous key pair will be used instead. More... | |
typedef void(* | GNUNET_MESSENGER_MessageCallback) (void *cls, const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Method called whenever a message is sent or received from a room. 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_UNKNOWN = 0 } |
Enum for the different supported kinds of messages. 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_Handle * | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls) |
Set up a handle for the messenger related functions and connects to all necessary services. More... | |
int | GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle) |
Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. 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... | |
int | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name) |
Set the name for the messenger. More... | |
const struct GNUNET_IDENTITY_PublicKey * | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle) |
Get the public key used by the messenger. More... | |
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. More... | |
struct GNUNET_MESSENGER_Room * | GNUNET_MESSENGER_entry_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... | |
struct GNUNET_MESSENGER_Contact * | GNUNET_MESSENGER_get_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id) |
Get the contact of a member in a room identified by their id. 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_IDENTITY_PublicKey * | GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact) |
Get the public key used by the contact. More... | |
void | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message) |
Send a message into a room. More... | |
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. More... | |
Instant messaging based on the CADET subsystem.
#define GNUNET_MESSENGER_SERVICE_NAME "messenger" |
Definition at line 51 of file gnunet_messenger_service.h.
Referenced by create_service(), reconnect(), and run().
typedef void(* GNUNET_MESSENGER_IdentityCallback) (void *cls, struct GNUNET_MESSENGER_Handle *handle) |
Method called whenever the EGO of a handle changes or if the first connection fails to load a valid EGO and the anonymous key pair will be used instead.
cls | Closure from GNUNET_MESSENGER_connect |
handle | Messenger handle |
Definition at line 422 of file gnunet_messenger_service.h.
typedef void(* GNUNET_MESSENGER_MessageCallback) (void *cls, const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Method called whenever a message is sent or received from a room.
cls | Closure from GNUNET_MESSENGER_connect |
room | Room handle |
message | Newly received or sent message |
hash | Hash identifying the message |
Definition at line 433 of file gnunet_messenger_service.h.
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_UNKNOWN | The unknown kind. The message contains an unknown body. |
Definition at line 71 of file gnunet_messenger_service.h.
const char* GNUNET_MESSENGER_name_of_kind | ( | enum GNUNET_MESSENGER_MessageKind | kind | ) |
Get the name of a message kind.
kind | Kind of a message |
Definition at line 34 of file messenger_api.c.
References 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_REQUEST, and GNUNET_MESSENGER_KIND_TEXT.
Referenced by handle_recv_message(), and handle_send_message().
struct GNUNET_MESSENGER_Handle* GNUNET_MESSENGER_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | name, | ||
GNUNET_MESSENGER_IdentityCallback | identity_callback, | ||
void * | identity_cls, | ||
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 look up the ego key identified by its name and use it for signing all messages from the handle.
cfg | Configuration to use |
name | Name to look up an ego or NULL to stay anonymous |
identity_callback | Function called when the EGO of the handle changes |
identity_cls | Closure for the identity_callback handler |
msg_callback | Function called when a new message is sent or received |
msg_cls | Closure for the msg_callback handler |
Definition at line 355 of file messenger_api.c.
References create_handle(), destroy_handle(), env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, GNUNET_MESSENGER_Handle::mq, msg, and reconnect().
Referenced by run().
int GNUNET_MESSENGER_update | ( | struct GNUNET_MESSENGER_Handle * | handle | ) |
Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one.
All participated rooms get informed about the key renewal. The handle requires a set name for this function to work and it needs to be unused by other egos.
Keep in mind that this will fully delete the old ego key (if any is used) even if any other service wants to use it as default.
handle | Messenger handle to use |
Definition at line 390 of file messenger_api.c.
References env, get_handle_name(), GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_MESSENGER_Handle::mq, and msg.
void GNUNET_MESSENGER_disconnect | ( | struct GNUNET_MESSENGER_Handle * | handle | ) |
Disconnect all of the messengers used services and clears up its used memory.
handle | Messenger handle to use |
Definition at line 404 of file messenger_api.c.
References destroy_handle(), env, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_Handle::mq, and msg.
Referenced by shutdown_hook().
const char* GNUNET_MESSENGER_get_name | ( | const struct GNUNET_MESSENGER_Handle * | handle | ) |
Get the name (if specified, otherwise NULL) used by the messenger.
handle | Messenger handle to use |
Definition at line 419 of file messenger_api.c.
References get_handle_name().
Referenced by on_identity().
int GNUNET_MESSENGER_set_name | ( | struct GNUNET_MESSENGER_Handle * | handle, |
const char * | name | ||
) |
Set the name for the messenger.
This will rename the currently used ego and move all stored files related to the current name to its new directory. If anything fails during this process the function returns GNUNET_NO and the name for the messenger won't change as specified.
handle | Messenger handle to use |
name | Name for the messenger to change to |
Definition at line 428 of file messenger_api.c.
References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Handle::mq, and msg.
const struct GNUNET_IDENTITY_PublicKey* GNUNET_MESSENGER_get_key | ( | const struct GNUNET_MESSENGER_Handle * | handle | ) |
Get the public key used by the messenger.
handle | Messenger handle to use |
Definition at line 452 of file messenger_api.c.
References get_handle_key().
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_entry_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. )
handle | Messenger handle to use |
key | Hash identifying the port |
Definition at line 461 of file messenger_api.c.
References create_room(), destroy_room(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_OK, GNUNET_MESSENGER_Handle::rooms, and send_open_room().
Referenced by on_identity().
struct GNUNET_MESSENGER_Room* GNUNET_MESSENGER_entry_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. )
handle | Messenger handle to use |
door | Peer identity of an open door |
key | Hash identifying the port |
Definition at line 482 of file messenger_api.c.
References create_room(), destroy_room(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_OK, GNUNET_MESSENGER_Handle::rooms, and send_entry_room().
Referenced by on_identity().
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. )
room | Room handle |
Definition at line 504 of file messenger_api.c.
References GNUNET_MESSENGER_Room::handle, and send_close_room().
Referenced by shutdown_hook().
struct GNUNET_MESSENGER_Contact* GNUNET_MESSENGER_get_member | ( | const struct GNUNET_MESSENGER_Room * | room, |
const struct GNUNET_ShortHashCode * | id | ||
) |
Get the contact of a member in a room identified by their id.
Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.
room | Room handle |
id | Hash identifying a member |
Definition at line 510 of file messenger_api.c.
References GNUNET_CONTAINER_multishortmap_get(), and GNUNET_MESSENGER_Room::members.
Referenced by on_message().
const char* GNUNET_MESSENGER_contact_get_name | ( | const struct GNUNET_MESSENGER_Contact * | contact | ) |
Get the name used by the contact.
contact | Contact handle |
Definition at line 516 of file messenger_api.c.
References get_contact_name().
Referenced by on_message().
const struct GNUNET_IDENTITY_PublicKey* GNUNET_MESSENGER_contact_get_key | ( | const struct GNUNET_MESSENGER_Contact * | contact | ) |
Get the public key used by the contact.
contact | Contact handle |
Definition at line 525 of file messenger_api.c.
References get_contact_key().
void GNUNET_MESSENGER_send_message | ( | struct GNUNET_MESSENGER_Room * | room, |
const struct GNUNET_MESSENGER_Message * | message | ||
) |
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.
room | Room handle |
message | New message to send |
Definition at line 534 of file messenger_api.c.
References encode_message(), env, get_message_size(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_SendMessage::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.
Referenced by read_stdio().
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.
room | Room handle |
hash | Hash identifying a message |
Definition at line 552 of file messenger_api.c.
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_RecvMessage::hash, GNUNET_MESSENGER_RecvMessage::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.