GNUnet  0.20.0
gnunet-service-messenger_tunnel.c File Reference

GNUnet MESSENGER service. More...

Include dependency graph for gnunet-service-messenger_tunnel.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MessageSent
 

Functions

struct GNUNET_MESSENGER_SrvTunnelcreate_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_HashCodeget_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...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_tunnel.c.

Function Documentation

◆ create_tunnel()

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).

Parameters
[in,out]roomRoom
[in]doorPeer identity
Returns
New tunnel

Definition at line 37 of file gnunet-service-messenger_tunnel.c.

39 {
40  GNUNET_assert((room) && (door));
41 
43 
44  tunnel->room = room;
45  tunnel->channel = NULL;
46 
47  tunnel->peer = GNUNET_PEER_intern (door);
48 
49  tunnel->messenger_version = 0;
50 
51  tunnel->peer_message = NULL;
52 
53  init_message_state(&(tunnel->state));
54 
55  return tunnel;
56 }
void init_message_state(struct GNUNET_MESSENGER_MessageState *state)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_PEER_Id GNUNET_PEER_intern(const struct GNUNET_PeerIdentity *pid)
Intern an peer identity.
Definition: peer.c:108
struct GNUNET_CADET_Channel * channel
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_MESSENGER_SrvRoom * room

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().

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

◆ destroy_tunnel()

void destroy_tunnel ( struct GNUNET_MESSENGER_SrvTunnel tunnel)

Destroys a tunnel and frees its memory fully.

Parameters
[in,out]tunnel

Definition at line 59 of file gnunet-service-messenger_tunnel.c.

60 {
61  GNUNET_assert(tunnel);
62 
63  if (tunnel->channel)
65 
66  GNUNET_PEER_change_rc (tunnel->peer, -1);
67 
68  if (tunnel->peer_message)
69  GNUNET_free(tunnel->peer_message);
70 
71  clear_message_state(&(tunnel->state));
72 
73  GNUNET_free(tunnel);
74 }
void clear_message_state(struct GNUNET_MESSENGER_MessageState *state)
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:830
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_PEER_change_rc(GNUNET_PEER_Id id, int delta)
Change the reference counter of an interned PID.
Definition: peer.c:192

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.

Here is the call graph for this function:

◆ bind_tunnel()

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.

Parameters
[in,out]tunnelTunnel
[in,out]channelCADET channel

Definition at line 77 of file gnunet-service-messenger_tunnel.c.

79 {
80  GNUNET_assert(tunnel);
81 
82  if (tunnel->channel)
84 
85  tunnel->channel = channel;
86 }
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.

References GNUNET_MESSENGER_SrvTunnel::channel, delayed_disconnect_channel(), and GNUNET_assert.

Referenced by callback_room_connect().

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

◆ callback_room_disconnect()

void callback_room_disconnect ( struct GNUNET_MESSENGER_SrvRoom room,
void *  cls 
)

Definition at line 792 of file gnunet-service-messenger_room.c.

794 {
795  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
796 
797  if (!room->host)
798  return;
799 
802 
805  return;
806 
809 }
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
int send_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_YES
int contains_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
Tests linearly if the list of tunnels peer identities contains a specific peer identity and returns G...
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_MESSENGER_SrvHandle * host
The identity of the host (wraps the signing key of the peer).

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_srv_room_message(), and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by callback_tunnel_disconnect().

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

◆ callback_tunnel_disconnect()

void callback_tunnel_disconnect ( void *  cls,
const struct GNUNET_CADET_Channel channel 
)

Definition at line 93 of file gnunet-service-messenger_tunnel.c.

95 {
96  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
97 
98  if (tunnel)
99  {
100  tunnel->channel = NULL;
101 
102  callback_room_disconnect (tunnel->room, cls);
103  }
104 }
void callback_room_disconnect(struct GNUNET_MESSENGER_SrvRoom *room, void *cls)

References callback_room_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, and GNUNET_MESSENGER_SrvTunnel::room.

Referenced by connect_tunnel(), and open_srv_room().

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

◆ callback_verify_room_message()

int callback_verify_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
void *  cls,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash 
)

Definition at line 812 of file gnunet-service-messenger_room.c.

816 {
817  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
818  {
819  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Message error: Kind is unknown! (%d)\n", message->header.kind);
820  return GNUNET_SYSERR;
821  }
822 
823  struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
824 
825  const struct GNUNET_MESSENGER_Message *previous = get_store_message(message_store, &(message->header.previous));
826 
827  if (!previous)
828  goto skip_time_comparison;
829 
830  struct GNUNET_TIME_Absolute timestamp = GNUNET_TIME_absolute_ntoh(message->header.timestamp);
832 
833  if (GNUNET_TIME_relative_get_zero_().rel_value_us != GNUNET_TIME_absolute_get_difference(timestamp, last).rel_value_us)
834  {
835  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Message error: Timestamp does not check out!\n");
836  return GNUNET_SYSERR;
837  }
838 
839 skip_time_comparison:
840  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Receiving message of kind: %s!\n",
842 
843  return GNUNET_OK;
844 }
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:36
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:133
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:421
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
Time for absolute times used by GNUnet, in microseconds.

References get_srv_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().

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

◆ check_tunnel_message()

int check_tunnel_message ( void *  cls,
const struct GNUNET_MessageHeader header 
)

Definition at line 113 of file gnunet-service-messenger_tunnel.c.

115 {
116  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
117 
118  if (!tunnel)
119  return GNUNET_SYSERR;
120 
121  const uint16_t length = ntohs (header->size) - sizeof(*header);
122  const char *buffer = (const char*) &header[1];
123 
124  struct GNUNET_MESSENGER_Message message;
125 
127  {
128  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Message too short! (%d)\n", length);
129  return GNUNET_SYSERR;
130  }
131 
132  uint16_t padding = 0;
133 
134  if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, &padding))
135  {
136  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Decoding failed!\n");
137  return GNUNET_SYSERR;
138  }
139 
140  struct GNUNET_HashCode hash;
141  hash_message (&message, length - padding, buffer, &hash);
142 
143  return callback_verify_room_message (tunnel->room, cls, &message, &hash);
144 }
int callback_verify_room_message(struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
@ GNUNET_ERROR_TYPE_WARNING
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, int include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
A 512-bit hashcode.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

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.

Here is the call graph for this function:

◆ update_room_message()

int update_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Definition at line 994 of file gnunet-service-messenger_room.c.

997 {
998  GNUNET_assert((room) && (message) && (hash));
999 
1001 
1002  const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)?
1004  );
1005 
1006  if (GNUNET_YES == requested)
1007  cancel_store_operation(operation_store, hash);
1008 
1009  struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
1010 
1011  const struct GNUNET_MESSENGER_Message *old_message = get_store_message (message_store, hash);
1012 
1013  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n", GNUNET_h2s (get_srv_room_key(room)));
1014 
1015  if ((old_message) || (GNUNET_OK != put_store_message (message_store, hash, message)))
1016  {
1017  if (old_message != message)
1018  destroy_message(message);
1019 
1020  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
1021  return GNUNET_NO;
1022  }
1023 
1024  update_message_state(&(room->state), requested, message, hash);
1025 
1026  if ((GNUNET_YES == requested) ||
1027  (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
1029  return GNUNET_YES;
1030 
1031  if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
1032  (GNUNET_MESSENGER_OP_MERGE == get_store_operation_type(operation_store, &(message->body.merge.previous))))
1033  cancel_store_operation(operation_store, &(message->body.merge.previous));
1034 
1035  if (GNUNET_MESSENGER_OP_MERGE == get_store_operation_type(operation_store, &(message->header.previous)))
1036  cancel_store_operation(operation_store, &(message->header.previous));
1037 
1038  return GNUNET_YES;
1039 }
void update_message_state(struct GNUNET_MESSENGER_MessageState *state, int requested, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
int put_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message)
Stores a message into the message store.
void cancel_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Stops any active operation under a given hash in a specific operation store.
enum GNUNET_MESSENGER_OperationType get_store_operation_type(const struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Returns the type of the active operation under a given hash in a specific operation store.
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
@ GNUNET_NO
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageState state

References GNUNET_MESSENGER_Message::body, cancel_store_operation(), destroy_message(), get_srv_room_key(), get_srv_room_message_store(), get_srv_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_srv_room_message().

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

◆ callback_room_handle_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 1086 of file gnunet-service-messenger_room.c.

1090 {
1092  struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
1093 
1094  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n", GNUNET_h2s (hash));
1095 
1096  if (!member)
1097  {
1098  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Message handling dropped: Member is missing!\n");
1099  return;
1100  }
1101 
1102  struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
1103 
1104  if (!session)
1105  {
1106  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Message handling dropped: Session is missing!\n");
1107  return;
1108  }
1109 
1110  struct GNUNET_MESSENGER_MemberUpdate update;
1111  update.message = message;
1112  update.hash = hash;
1113 
1114  update.head = NULL;
1115  update.tail = NULL;
1116 
1117  iterate_store_members(member_store, iterate_update_member_sessions, &update);
1118 
1119  while (update.head)
1120  {
1121  struct GNUNET_MESSENGER_MemberSessionCompletion *element = update.head;
1122 
1123  remove_room_member_session (room, element->session);
1124 
1125  GNUNET_CONTAINER_DLL_remove(update.head, update.tail, element);
1126  GNUNET_free (element);
1127  }
1128 
1129  const int start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1130 
1131  add_to_list_messages (&(room->handling), hash);
1132 
1133  switch (message->header.kind)
1134  {
1136  handle_message_join (room, session, message, hash);
1137  break;
1139  handle_message_leave (room, session, message, hash);
1140  break;
1142  handle_message_name (room, session, message, hash);
1143  break;
1145  handle_message_key (room, session, message, hash);
1146  break;
1148  handle_message_peer (room, session, message, hash);
1149  break;
1151  handle_message_id (room, session, message, hash);
1152  break;
1154  handle_message_miss (room, session, message, hash);
1155  break;
1157  handle_message_delete (room, session, message, hash);
1158  break;
1159  default:
1160  break;
1161  }
1162 
1163  if (GNUNET_YES == start_handle)
1164  handle_room_messages (room);
1165 }
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
struct GNUNET_MESSENGER_MemberSession * get_member_session_of(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the member session of a member using a public key which can verify the signature of a given m...
struct GNUNET_MESSENGER_Member * get_store_member_of(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message)
Returns the member of a store using a sender id of a given message.
int iterate_store_members(struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
Iterate through all member sessions currently connected to the members of the given member store and ...
void handle_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent key message to change the key of a member and rearrange the contacts accor...
void handle_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent peer message to make changes of the basement in the room.
void handle_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent join message to make changes of current member information.
void handle_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent miss message to drop a peer from the basement in the room.
void handle_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent id message to change a members id.
void handle_message_name(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent name message to rename a current member.
void handle_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent leave message to make changes of current member information.
void handle_message_delete(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent delete message to delete a specific message from the store.
static void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
static void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
static int iterate_update_member_sessions(void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_MESSENGER_KIND_MISS
The miss 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_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_MemberSession * session
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_ListMessages handling

References add_to_list_messages(), get_member_session_of(), get_srv_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_srv_room_message().

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

◆ update_tunnel_last_message()

static void update_tunnel_last_message ( struct GNUNET_MESSENGER_SrvTunnel tunnel,
const struct GNUNET_HashCode hash 
)
static

Definition at line 158 of file gnunet-service-messenger_tunnel.c.

160 {
161  struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(tunnel->room);
162 
163  const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)?
165  );
166 
167  struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(tunnel->room);
168 
169  const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash);
170 
171  if (message)
172  update_message_state(&(tunnel->state), requested, message, hash);
173 }

References get_srv_room_message_store(), get_srv_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().

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

◆ handle_tunnel_message()

void handle_tunnel_message ( void *  cls,
const struct GNUNET_MessageHeader header 
)

Definition at line 176 of file gnunet-service-messenger_tunnel.c.

177 {
178  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
179 
180  if (!tunnel)
181  return;
182 
183  const uint16_t length = ntohs (header->size) - sizeof(*header);
184  const char *buffer = (const char*) &header[1];
185 
186  struct GNUNET_MESSENGER_Message message;
187  struct GNUNET_HashCode hash;
188 
189  uint16_t padding = 0;
190 
191  decode_message (&message, length, buffer, GNUNET_YES, &padding);
192  hash_message (&message, length - padding, buffer, &hash);
193 
194  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got message of kind: %s!\n",
195  GNUNET_MESSENGER_name_of_kind(message.header.kind));
196 
197  const int new_message = update_room_message (
198  tunnel->room, copy_message (&message), &hash
199  );
200 
201  if (GNUNET_YES != new_message)
202  goto receive_done;
203 
204  update_tunnel_last_message (tunnel, &hash);
205 
206  int forward_message = GNUNET_YES;
207 
208  switch (message.header.kind)
209  {
211  forward_message = recv_message_info (tunnel->room, tunnel, &message, &hash);
212  break;
214  forward_message = recv_message_peer (tunnel->room, tunnel, &message, &hash);
215  break;
217  forward_message = recv_message_request (tunnel->room, tunnel, &message, &hash);
218  break;
219  default:
220  break;
221  }
222 
223  if (GNUNET_YES == forward_message)
224  {
225  forward_srv_room_message (tunnel->room, tunnel, &message, &hash);
226  callback_room_handle_message (tunnel->room, NULL, &message, &hash);
227  }
228 
229 receive_done:
230  cleanup_message(&message);
231 
233 }
int recv_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received peer message to link it to its origin tunnel if the peer identity matches.
int recv_message_request(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received request message by checking for the requested message and forwarding it back if th...
int recv_message_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received info message to change the current member id to the one generated by the host conn...
void forward_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Forwards a message with a given hash to a specific tunnel inside of a room.
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)
int update_room_message(struct GNUNET_MESSENGER_SrvRoom *room, 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 GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:872
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.

References callback_room_handle_message(), GNUNET_MESSENGER_SrvTunnel::channel, cleanup_message(), copy_message(), decode_message(), forward_srv_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().

Here is the call graph for this function:

◆ connect_tunnel()

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.

Parameters
[in,out]tunnelTunnel
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 236 of file gnunet-service-messenger_tunnel.c.

237 {
238  GNUNET_assert(tunnel);
239 
240  if (tunnel->channel)
241  return GNUNET_NO;
242 
243  const struct GNUNET_PeerIdentity *door = GNUNET_PEER_resolve2 (tunnel->peer);
244 
245  struct GNUNET_CADET_Handle *cadet = get_srv_room_cadet (tunnel->room);
246  const struct GNUNET_HashCode *key = get_srv_room_key (tunnel->room);
247 
249  struct GNUNET_MessageHeader, NULL),
251 
252  struct GNUNET_HashCode port;
255 
256  return GNUNET_YES;
257 }
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1015
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
const struct GNUNET_PeerIdentity * GNUNET_PEER_resolve2(GNUNET_PEER_Id id)
Convert an interned PID to a normal peer identity.
Definition: peer.c:234
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
void convert_messenger_key_to_port(const struct GNUNET_HashCode *key, struct GNUNET_HashCode *port)
Converts a Messenger service key of a room to the specific port which gets used for the CADET channel...
Opaque handle to the service.
Definition: cadet_api.c:39
Message handler for a specific message type.
Header for all communications.

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().

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

◆ disconnect_tunnel()

void disconnect_tunnel ( struct GNUNET_MESSENGER_SrvTunnel tunnel)

Disconnects and unbinds a channel from a tunnel.

The actual disconnection will be asynchronous.

Parameters
[in,out]tunnelTunnel

Definition at line 260 of file gnunet-service-messenger_tunnel.c.

261 {
262  GNUNET_assert(tunnel);
263 
264  if (tunnel->channel)
265  {
267 
268  tunnel->channel = NULL;
269  }
270 }

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().

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

◆ is_tunnel_connected()

int is_tunnel_connected ( const struct GNUNET_MESSENGER_SrvTunnel tunnel)

Returns the status of a currently bound channel of a tunnel.

Parameters
[in]tunnelTunnel
Returns
GNUNET_YES or GNUNET_NO

Definition at line 273 of file gnunet-service-messenger_tunnel.c.

274 {
275  GNUNET_assert(tunnel);
276 
277  return (tunnel->channel ? GNUNET_YES : GNUNET_NO);
278 }

References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_assert, GNUNET_NO, and GNUNET_YES.

Referenced by iterate_send_room_message(), and send_room_info().

Here is the caller graph for this function:

◆ callback_tunnel_sent()

static void callback_tunnel_sent ( void *  cls)
static

Definition at line 287 of file gnunet-service-messenger_tunnel.c.

288 {
289  struct GNUNET_MESSENGER_MessageSent *sent = cls;
290 
291  if (sent->tunnel)
292  update_tunnel_last_message (sent->tunnel, &(sent->hash));
293 
294  GNUNET_free(sent);
295 }
struct GNUNET_MESSENGER_SrvTunnel * tunnel

References GNUNET_free, GNUNET_MESSENGER_MessageSent::hash, GNUNET_MESSENGER_MessageSent::tunnel, and update_tunnel_last_message().

Referenced by send_tunnel_envelope().

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

◆ 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.

Parameters
[in,out]tunnelTunnel
[in,out]envEnvelope
[in]hashHash of message

Definition at line 298 of file gnunet-service-messenger_tunnel.c.

301 {
302  GNUNET_assert((tunnel) && (env) && (hash));
303 
304  struct GNUNET_MQ_Handle *mq = GNUNET_CADET_get_mq (tunnel->channel);
305 
307 
308  GNUNET_memcpy(&(sent->hash), hash, sizeof(struct GNUNET_HashCode));
309 
310  sent->tunnel = tunnel;
311 
313  GNUNET_MQ_send (mq, env);
314 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void callback_tunnel_sent(void *cls)
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
Definition: cadet_api.c:1066
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:638
Handle to a message queue.
Definition: mq.c:87

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().

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

◆ 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.

Parameters
[in,out]tunnelTunnel
[in,out]handleHandle
[in,out]messageMessage
Returns
GNUNET_YES on success, GNUNET_NO otherwise

Definition at line 317 of file gnunet-service-messenger_tunnel.c.

320 {
321  GNUNET_assert((tunnel) && (handle));
322 
323  if (!message)
324  return GNUNET_NO;
325 
326  struct GNUNET_HashCode hash;
328  tunnel->room, (struct GNUNET_MESSENGER_SrvHandle*) handle,
330  );
331 
332  destroy_message(message);
333 
334  if (!env)
335  return GNUNET_NO;
336 
337  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending tunnel message: %s\n",
338  GNUNET_h2s(&hash));
339 
340  send_tunnel_envelope (tunnel, env, &hash);
341  return GNUNET_YES;
342 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MQ_Envelope * pack_srv_room_message(const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode)
Packs a message depending on the selected mode into a newly allocated 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.
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE

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().

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

◆ forward_tunnel_message()

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.

Parameters
[in,out]tunnelTunnel
[in]messageMessage
[in]hashHash of message

Definition at line 345 of file gnunet-service-messenger_tunnel.c.

348 {
349  GNUNET_assert((tunnel) && (message) && (hash));
350 
351  struct GNUNET_MESSENGER_Message *copy = copy_message(message);
353 
354  destroy_message(copy);
355 
356  if (!env)
357  return;
358 
359  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Forwarding tunnel message: %s\n",
360  GNUNET_h2s(hash));
361 
362  send_tunnel_envelope (tunnel, env, hash);
363 }
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego, int mode)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...

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().

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

◆ get_tunnel_peer_message()

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.

Parameters
[in]tunnelTunnel
Returns
Hash of peer message or NULL

Definition at line 366 of file gnunet-service-messenger_tunnel.c.

367 {
368  GNUNET_assert(tunnel);
369 
370  return tunnel->peer_message;
371 }

References GNUNET_assert, and GNUNET_MESSENGER_SrvTunnel::peer_message.

◆ get_tunnel_peer_identity()

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.

Parameters
[in]tunnelTunnel
[out]peerPeer identity

Definition at line 374 of file gnunet-service-messenger_tunnel.c.

376 {
377  GNUNET_assert(tunnel);
378 
379  GNUNET_PEER_resolve(tunnel->peer, peer);
380 }
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:220
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_assert, GNUNET_PEER_resolve(), GNUNET_MESSENGER_SrvTunnel::peer, and peer.

Referenced by callback_room_disconnect(), and recv_message_info().

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

◆ get_tunnel_messenger_version()

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.

See also
update_tunnel_messenger_version
Parameters
[in]tunnelTunnel
Returns
Version of messenger

Definition at line 383 of file gnunet-service-messenger_tunnel.c.

384 {
385  GNUNET_assert(tunnel);
386 
387  return tunnel->messenger_version;
388 }

References GNUNET_assert, and GNUNET_MESSENGER_SrvTunnel::messenger_version.

Referenced by iterate_send_room_message(), and recv_message_info().

Here is the caller graph for this function:

◆ update_tunnel_messenger_version()

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.

Parameters
[in,out]tunnelTunnel
[in]versionVersion of messenger

Definition at line 391 of file gnunet-service-messenger_tunnel.c.

393 {
394  GNUNET_assert(tunnel);
395 
396  if (version != GNUNET_MESSENGER_VERSION)
397  return GNUNET_SYSERR;
398 
399  if (version > tunnel->messenger_version)
400  tunnel->messenger_version = version;
401 
402  return GNUNET_OK;
403 }
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.

References GNUNET_assert, GNUNET_MESSENGER_VERSION, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MESSENGER_SrvTunnel::messenger_version.

Referenced by recv_message_info().

Here is the caller graph for this function: