![]() |
GNUnet
0.11.x
|
GNUnet MESSENGER service. More...
#include "gnunet-service-messenger_tunnel.h"
#include "gnunet-service-messenger_handle.h"
#include "gnunet-service-messenger_message_recv.h"
#include "gnunet-service-messenger_message_store.h"
#include "gnunet-service-messenger_operation_store.h"
#include "gnunet-service-messenger_operation.h"
#include "messenger_api_util.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MessageSent |
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... | |
void | callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls) |
void | callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel) |
int | callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash) |
int | check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header) |
int | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
void | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash) |
void | handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header) |
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... | |
static void | callback_tunnel_sent (void *cls) |
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.c.
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 36 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_room_at().
void destroy_tunnel | ( | struct GNUNET_MESSENGER_SrvTunnel * | tunnel | ) |
Destroys a tunnel and frees its memory fully.
[in/out] | tunnel |
Definition at line 58 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 76 of file gnunet-service-messenger_tunnel.c.
References GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), and GNUNET_assert.
Referenced by callback_room_connect().
void callback_room_disconnect | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
void * | cls | ||
) |
Definition at line 791 of file gnunet-service-messenger_room.c.
References GNUNET_MESSENGER_SrvRoom::basement, contains_list_tunnels(), create_message_miss(), get_tunnel_peer_identity(), GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, identity, GNUNET_MESSENGER_SrvTunnel::room, send_room_message(), and GNUNET_MESSENGER_SrvRoom::tunnels.
Referenced by callback_tunnel_disconnect().
void callback_tunnel_disconnect | ( | void * | cls, |
const struct GNUNET_CADET_Channel * | channel | ||
) |
Definition at line 92 of file gnunet-service-messenger_tunnel.c.
References callback_room_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, and GNUNET_MESSENGER_SrvTunnel::room.
Referenced by connect_tunnel(), and open_room().
int callback_verify_room_message | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
void * | cls, | ||
struct GNUNET_MESSENGER_Message * | message, | ||
struct GNUNET_HashCode * | hash | ||
) |
Definition at line 811 of file gnunet-service-messenger_room.c.
References get_room_message_store(), get_store_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_name_of_kind(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_get_zero_(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, and GNUNET_MESSENGER_MessageHeader::timestamp.
Referenced by check_tunnel_message().
int check_tunnel_message | ( | void * | cls, |
const struct GNUNET_MessageHeader * | header | ||
) |
Definition at line 112 of file gnunet-service-messenger_tunnel.c.
References callback_verify_room_message(), decode_message(), get_message_kind_size(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_SYSERR, GNUNET_YES, hash_message(), GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MessageHeader::size.
int update_room_message | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Definition at line 993 of file gnunet-service-messenger_room.c.
References GNUNET_MESSENGER_Message::body, cancel_store_operation(), destroy_message(), get_room_key(), get_room_message_store(), get_room_operation_store(), get_store_message(), get_store_operation_type(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_OP_MERGE, GNUNET_MESSENGER_OP_REQUEST, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, put_store_message(), GNUNET_MESSENGER_OperationStore::room, GNUNET_MESSENGER_SrvRoom::state, and update_message_state().
Referenced by handle_tunnel_message(), and send_room_message().
void callback_room_handle_message | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
struct GNUNET_MESSENGER_SrvHandle * | handle, | ||
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Definition at line 1085 of file gnunet-service-messenger_room.c.
References add_to_list_messages(), get_member_session_of(), get_room_member_store(), get_store_member_of(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_NO, GNUNET_YES, handle_message_delete(), handle_message_id(), handle_message_join(), handle_message_key(), handle_message_leave(), handle_message_miss(), handle_message_name(), handle_message_peer(), handle_room_messages(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_MemberUpdate::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_MemberUpdate::head, GNUNET_MESSENGER_Message::header, iterate_store_members(), iterate_update_member_sessions(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_MemberUpdate::message, remove_room_member_session(), GNUNET_MESSENGER_MemberStore::room, GNUNET_MESSENGER_MemberSessionCompletion::session, and GNUNET_MESSENGER_MemberUpdate::tail.
Referenced by handle_tunnel_message(), and send_room_message().
|
static |
Definition at line 157 of file gnunet-service-messenger_tunnel.c.
References get_room_message_store(), get_room_operation_store(), get_store_message(), get_store_operation_type(), GNUNET_MESSENGER_OP_REQUEST, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MESSENGER_SrvTunnel::state, and update_message_state().
Referenced by callback_tunnel_sent(), and handle_tunnel_message().
void handle_tunnel_message | ( | void * | cls, |
const struct GNUNET_MessageHeader * | header | ||
) |
Definition at line 175 of file gnunet-service-messenger_tunnel.c.
References callback_room_handle_message(), GNUNET_MESSENGER_SrvTunnel::channel, cleanup_message(), copy_message(), decode_message(), forward_room_message(), GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_name_of_kind(), GNUNET_YES, hash_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, recv_message_info(), recv_message_peer(), recv_message_request(), GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MessageHeader::size, update_room_message(), and update_tunnel_last_message().
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 235 of file gnunet-service-messenger_tunnel.c.
References cadet, callback_tunnel_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, convert_messenger_key_to_port(), 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, handlers, key, GNUNET_MESSENGER_SrvTunnel::peer, port, 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.
[in/out] | tunnel Tunnel |
Definition at line 259 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 272 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().
|
static |
Definition at line 286 of file gnunet-service-messenger_tunnel.c.
References GNUNET_free, GNUNET_MESSENGER_MessageSent::hash, GNUNET_MESSENGER_MessageSent::tunnel, and update_tunnel_last_message().
Referenced by send_tunnel_envelope().
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 297 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 316 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_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 344 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_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 365 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 373 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 382 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 390 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().