![]() |
GNUnet
0.11.x
|
GNUnet MESSENGER service. More...
#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_peer_lib.h"
#include "gnunet_crypto_lib.h"
#include "gnunet-service-messenger_room.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_SrvTunnel |
Functions | |
struct GNUNET_MESSENGER_SrvTunnel * | create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door) |
Creates and allocates a tunnel of a room to a specific peer identity (called door). More... | |
void | destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Destroys a tunnel and frees its memory fully. More... | |
void | bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel) |
Binds a CADET channel to a tunnel and replaces its channel the tunnel is currently bound to if necessary. More... | |
int | connect_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Tries to connect a tunnel by creating a new CADET channel and binding it. More... | |
void | disconnect_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Disconnects and unbinds a channel from a tunnel. More... | |
int | is_tunnel_connected (const struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Returns the status of a currently bound channel of a tunnel. More... | |
void | send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env, const struct GNUNET_HashCode *hash) |
Sends an envelope containing a message with a given hash through a tunnel. More... | |
int | send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message) |
Sends a message by packing it automatically into an envelope and passing it through the tunnel. More... | |
void | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Forwards a given message with a known hash through a tunnel. More... | |
const struct GNUNET_HashCode * | get_tunnel_peer_message (const struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Returns the hash of the latest peer message published through a given tunnel and matching the tunnels peer identity. More... | |
void | get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer) |
Writes the peer identity of the peer connected via tunnel to this peer into the peer parameter. More... | |
uint32_t | get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
Returns the current messenger version the peer connected via a given tunnel has reported to be using if it was compatible during updating. More... | |
int | update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, uint32_t version) |
Updates the messenger version of the tunnel to a given version if it is compatible to the running peer of the service. More... | |
GNUnet MESSENGER service.
Definition in file gnunet-service-messenger_tunnel.h.
struct GNUNET_MESSENGER_SrvTunnel* create_tunnel | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
const struct GNUNET_PeerIdentity * | door | ||
) |
Creates and allocates a tunnel of a room to a specific peer identity (called door).
Definition at line 33 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_new, GNUNET_PEER_intern(), GNUNET_MESSENGER_SrvTunnel::last_message, GNUNET_MESSENGER_SrvTunnel::messenger_version, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::peer_message, and GNUNET_MESSENGER_SrvTunnel::room.
Referenced by callback_room_connect(), and enter_room_at().
void destroy_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Destroys a tunnel and frees its memory fully.
Definition at line 53 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_free, GNUNET_PEER_change_rc(), GNUNET_MESSENGER_SrvTunnel::last_message, GNUNET_MESSENGER_SrvTunnel::peer, and GNUNET_MESSENGER_SrvTunnel::peer_message.
void bind_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
struct GNUNET_CADET_Channel * | channel | ||
) |
Binds a CADET channel to a tunnel and replaces its channel the tunnel is currently bound to if necessary.
Definition at line 72 of file gnunet-service-messenger_tunnel.c.
References callback_room_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), GNUNET_assert, and GNUNET_MESSENGER_SrvTunnel::room.
Referenced by callback_room_connect().
int connect_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Tries to connect a tunnel by creating a new CADET channel and binding it.
The function returns GNUNET_YES on success, otherwise GNUNET_NO.
Definition at line 209 of file gnunet-service-messenger_tunnel.c.
References cadet, callback_tunnel_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, get_room_cadet(), get_room_key(), GNUNET_assert, GNUNET_CADET_channel_create(), GNUNET_MESSAGE_TYPE_CADET_CLI, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_PEER_resolve2(), GNUNET_YES, key, GNUNET_MESSENGER_SrvTunnel::peer, and GNUNET_MESSENGER_SrvTunnel::room.
Referenced by enter_room_at(), and rebuild_room_basement_structure().
void disconnect_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Disconnects and unbinds a channel from a tunnel.
The actual disconnection will be asynchronous.
Definition at line 231 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), and GNUNET_assert.
Referenced by callback_room_connect(), rebuild_room_basement_structure(), and recv_message_info().
int is_tunnel_connected | ( | const struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Returns the status of a currently bound channel of a tunnel.
[in] | tunnel | Tunnel |
Definition at line 244 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_NO, and GNUNET_YES.
Referenced by iterate_send_room_message(), and send_room_info().
void send_tunnel_envelope | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
struct GNUNET_MQ_Envelope * | env, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Sends an envelope containing a message with a given hash through a tunnel.
Definition at line 269 of file gnunet-service-messenger_tunnel.c.
References callback_tunnel_sent(), GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_CADET_get_mq(), GNUNET_memcpy, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_MESSENGER_MessageSent::hash, mq, and GNUNET_MESSENGER_MessageSent::tunnel.
Referenced by forward_tunnel_message(), iterate_send_room_message(), and send_tunnel_message().
int send_tunnel_message | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
void * | handle, | ||
struct GNUNET_MESSENGER_Message * | message | ||
) |
Sends a message by packing it automatically into an envelope and passing it through the tunnel.
The used handle will sign the message and the hash will be calculated and stored.
Definition at line 287 of file gnunet-service-messenger_tunnel.c.
References destroy_message(), env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, GNUNET_NO, GNUNET_YES, pack_room_message(), GNUNET_MESSENGER_SrvTunnel::room, and send_tunnel_envelope().
Referenced by recv_message_info(), and send_room_info().
void forward_tunnel_message | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Forwards a given message with a known hash through a tunnel.
Definition at line 313 of file gnunet-service-messenger_tunnel.c.
References copy_message(), destroy_message(), env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, pack_message(), and send_tunnel_envelope().
Referenced by check_room_peer_status(), iterate_forward_members(), and recv_message_request().
const struct GNUNET_HashCode* get_tunnel_peer_message | ( | const struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Returns the hash of the latest peer message published through a given tunnel and matching the tunnels peer identity.
If no peer message has been linked to the tunnel yet, NULL gets returned.
[in] | tunnel | Tunnel |
Definition at line 336 of file gnunet-service-messenger_tunnel.c.
References GNUNET_assert, and GNUNET_MESSENGER_SrvTunnel::peer_message.
void get_tunnel_peer_identity | ( | const struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
struct GNUNET_PeerIdentity * | peer | ||
) |
Writes the peer identity of the peer connected via tunnel to this peer into the peer parameter.
[in] | tunnel | Tunnel |
[out] | peer | Peer identity |
Definition at line 344 of file gnunet-service-messenger_tunnel.c.
References GNUNET_assert, GNUNET_PEER_resolve(), and GNUNET_MESSENGER_SrvTunnel::peer.
Referenced by callback_room_disconnect(), and recv_message_info().
uint32_t get_tunnel_messenger_version | ( | const struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Returns the current messenger version the peer connected via a given tunnel has reported to be using if it was compatible during updating.
[in] | tunnel | Tunnel |
Definition at line 352 of file gnunet-service-messenger_tunnel.c.
References GNUNET_assert, and GNUNET_MESSENGER_SrvTunnel::messenger_version.
Referenced by iterate_send_room_message(), and recv_message_info().
int update_tunnel_messenger_version | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel, |
uint32_t | version | ||
) |
Updates the messenger version of the tunnel to a given version if it is compatible to the running peer of the service.
Depending on success it returns GNUNET_OK or GNUNET_SYSERR on failure.
Definition at line 360 of file gnunet-service-messenger_tunnel.c.
References GNUNET_assert, GNUNET_MESSENGER_VERSION, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MESSENGER_SrvTunnel::messenger_version.
Referenced by recv_message_info().