GNUnet MESSENGER service. More...
#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_room.h"
#include "gnunet-service-messenger_message_state.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).
[in,out] | room | Room |
[in] | door | Peer identity |
Definition at line 37 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_new, GNUNET_PEER_intern(), init_message_state(), GNUNET_MESSENGER_SrvTunnel::messenger_version, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::peer_message, GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MESSENGER_SrvTunnel::state.
Referenced by callback_room_connect(), and enter_srv_room_at().
void destroy_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Destroys a tunnel and frees its memory fully.
[in,out] | tunnel |
Definition at line 59 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, clear_message_state(), GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_free, GNUNET_PEER_change_rc(), GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::peer_message, and GNUNET_MESSENGER_SrvTunnel::state.
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.
[in,out] | tunnel | Tunnel |
[in,out] | channel | CADET channel |
Definition at line 77 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), and GNUNET_assert.
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.
[in,out] | tunnel | Tunnel |
Definition at line 236 of file gnunet-service-messenger_tunnel.c.
References cadet, callback_tunnel_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, convert_messenger_key_to_port(), get_srv_room_cadet(), get_srv_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, handlers, key, GNUNET_MESSENGER_SrvTunnel::peer, port, and GNUNET_MESSENGER_SrvTunnel::room.
Referenced by enter_srv_room_at(), and rebuild_srv_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.
[in,out] | tunnel | Tunnel |
Definition at line 260 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), and GNUNET_assert.
Referenced by callback_room_connect(), rebuild_srv_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 273 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.
[in,out] | tunnel | Tunnel |
[in,out] | env | Envelope |
[in] | hash | Hash of message |
Definition at line 298 of file gnunet-service-messenger_tunnel.c.
References callback_tunnel_sent(), GNUNET_MESSENGER_SrvTunnel::channel, env, 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.
[in,out] | tunnel | Tunnel |
[in,out] | handle | Handle |
[in,out] | message | Message |
Definition at line 317 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, handle, pack_srv_room_message(), GNUNET_MESSENGER_SrvTunnel::room, send_tunnel_envelope(), and GNUNET_MESSENGER_MessageSent::tunnel.
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.
[in,out] | tunnel | Tunnel |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 345 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 callback_found_message(), check_srv_room_peer_status(), and forward_about_members().
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 366 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 374 of file gnunet-service-messenger_tunnel.c.
References GNUNET_assert, GNUNET_PEER_resolve(), GNUNET_MESSENGER_SrvTunnel::peer, and 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 383 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.
[in,out] | tunnel | Tunnel |
[in] | version | Version of messenger |
Definition at line 391 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().