GNUnet  0.11.x
Data Structures | Functions
gnunet-service-messenger_tunnel.c File Reference

GNUnet MESSENGER service. More...

#include "gnunet-service-messenger_tunnel.h"
#include "gnunet-service-messenger_handle.h"
#include "gnunet-service-messenger_util.h"
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. More...
 
void destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel)
 Destroys a tunnel and frees its memory fully. More...
 
int bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel)
 Binds a CADET channel to a tunnel on returns GNUNET_YES only if the bounds channel was replaced successfully, otherwise GNUNET_NO gets returned. 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)
 
void callback_room_recv (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, 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...
 
void callback_room_sent (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, void *cls, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 
static void callback_tunnel_sent (void *cls)
 
void send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MQ_Envelope *env, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Sends an envelope containing a message with a given hash through a tunnel by a given handle. More...
 
void send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
 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...
 

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.

Parameters
roomRoom
doorPeer identity
Returns
New tunnel

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

References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_MESSENGER_SrvTunnel::contact_id, GNUNET_assert, GNUNET_new, GNUNET_PEER_intern(), GNUNET_MESSENGER_SrvTunnel::last_message, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::peer_message, and GNUNET_MESSENGER_SrvTunnel::room.

Referenced by callback_room_connect(), and entry_room_at().

33 {
34  GNUNET_assert((room) && (door));
35 
37 
38  tunnel->room = room;
39  tunnel->channel = NULL;
40 
41  tunnel->peer = GNUNET_PEER_intern (door);
42  tunnel->contact_id = NULL;
43 
44  tunnel->peer_message = NULL;
45  tunnel->last_message = NULL;
46 
47  return tunnel;
48 }
#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.
struct GNUNET_MESSENGER_SrvRoom * room
struct GNUNET_CADET_Channel * channel
struct GNUNET_ShortHashCode * contact_id
GNUNET_PEER_Id GNUNET_PEER_intern(const struct GNUNET_PeerIdentity *pid)
Intern an peer identity.
Definition: peer.c:107
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
tunnel

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

References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_MESSENGER_SrvTunnel::contact_id, 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.

52 {
53  GNUNET_assert(tunnel);
54 
55  if (tunnel->channel)
57 
58  GNUNET_PEER_change_rc (tunnel->peer, -1);
59 
60  if (tunnel->contact_id)
61  GNUNET_free(tunnel->contact_id);
62 
63  if (tunnel->peer_message)
64  GNUNET_free(tunnel->peer_message);
65 
66  if (tunnel->last_message)
67  GNUNET_free(tunnel->last_message);
68 
69  GNUNET_free(tunnel);
70 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CADET_Channel * channel
void GNUNET_PEER_change_rc(GNUNET_PEER_Id id, int delta)
Change the reference counter of an interned PID.
Definition: peer.c:197
struct GNUNET_ShortHashCode * contact_id
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:837
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ bind_tunnel()

int bind_tunnel ( struct GNUNET_MESSENGER_SrvTunnel tunnel,
struct GNUNET_CADET_Channel channel 
)

Binds a CADET channel to a tunnel on returns GNUNET_YES only if the bounds channel was replaced successfully, otherwise GNUNET_NO gets returned.

Parameters
tunnelTunnel
channelCADET channel
Returns
GNUNET_YES on success, otherwise GNUNET_NO

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

References callback_room_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_MESSENGER_SrvTunnel::contact_id, delayed_disconnect_channel(), GNUNET_assert, GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_SrvTunnel::room.

Referenced by callback_room_connect().

74 {
75  GNUNET_assert(tunnel);
76 
77  if (tunnel->channel)
78  {
79  if (tunnel->contact_id)
80  return GNUNET_NO;
81 
83  }
84 
85  tunnel->channel = channel;
86 
87  return GNUNET_YES;
88 }
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CADET_Channel * channel
struct GNUNET_ShortHashCode * contact_id
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 706 of file gnunet-service-messenger_room.c.

References GNUNET_MESSENGER_SrvRoom::basement, contains_list_tunnels(), create_message_miss(), destroy_message(), GNUNET_PEER_resolve(), GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_SrvTunnel::peer, send_room_message(), and GNUNET_MESSENGER_SrvTunnelFinder::tunnel.

Referenced by bind_tunnel(), and callback_tunnel_disconnect().

707 {
708  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
709 
710  if (!room->host)
711  return;
712 
714 
715  GNUNET_PEER_resolve (tunnel->peer, &identity);
716 
718  {
720 
721  if (message)
722  {
723  struct GNUNET_HashCode hash;
724 
725  send_room_message (room, room->host, message, &hash);
726  destroy_message (message);
727  }
728  }
729 }
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...
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
A 512-bit hashcode.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_MESSENGER_SrvHandle * host
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
void send_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
Sends a message from a given handle into a room.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MESSENGER_ListTunnels basement
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 94 of file gnunet-service-messenger_tunnel.c.

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

Referenced by connect_tunnel(), join_room_locally(), and open_room().

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 }
struct GNUNET_MESSENGER_SrvRoom * room
void callback_room_disconnect(struct GNUNET_MESSENGER_SrvRoom *room, void *cls)
struct GNUNET_CADET_Channel * channel
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 732 of file gnunet-service-messenger_room.c.

References GNUNET_MESSENGER_MemberInfo::access, GNUNET_MESSENGER_Message::body, contains_store_message(), get_contact_key(), get_service_contact_by_pubkey(), GNUNET_CONTAINER_multishortmap_get(), GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_MEMBER_BLOCKED, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageInfo::host_key, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SrvRoom::member_infos, GNUNET_MESSENGER_SrvRoom::members, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::store, GNUNET_MESSENGER_SrvRoom::strict_access, and verify_message().

Referenced by callback_tunnel_disconnect(), and check_tunnel_message().

734 {
735  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
736  return GNUNET_SYSERR;
737 
739  &(message->header.sender_id));
740 
741  if (!contact)
742  {
743  if (GNUNET_MESSENGER_KIND_INFO == message->header.kind)
744  contact = get_service_contact_by_pubkey (room->service, &(message->body.info.host_key));
745  else if (GNUNET_MESSENGER_KIND_JOIN == message->header.kind)
746  contact = get_service_contact_by_pubkey (room->service, &(message->body.join.key));
747  }
748 
749  if ((!contact) || (GNUNET_SYSERR == verify_message (message, hash, get_contact_key (contact))))
750  return GNUNET_SYSERR;
751 
752  if (GNUNET_YES == room->strict_access)
753  {
755  &(message->header.sender_id));
756 
757  if ((info) && (GNUNET_MESSENGER_MEMBER_BLOCKED == info->access))
758  return GNUNET_SYSERR;
759  }
760 
761  if (GNUNET_YES == contains_store_message (&(room->store), hash))
762  return GNUNET_NO;
763 
764  return GNUNET_YES;
765 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_IDENTITY_PublicKey host_key
The senders key to verify its signatures.
struct GNUNET_CONTAINER_MultiShortmap * member_infos
struct GNUNET_MESSENGER_Service * service
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageBody body
Body.
int contains_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Checks if a message matching a given hash is stored in a message store.
const struct GNUNET_IDENTITY_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_SrvContact *contact)
Returns the public key of a given contact.
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageInfo info
struct GNUNET_MESSENGER_SrvContact * get_service_contact_by_pubkey(struct GNUNET_MESSENGER_Service *service, const struct GNUNET_IDENTITY_PublicKey *pubkey)
Returns a contact of a service identified by a given public key.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_MESSENGER_MemberAccess access
struct GNUNET_MESSENGER_MessageJoin join
int verify_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_IDENTITY_PublicKey *key)
Verifies the signature of a given message and its hash with a specific public key.
struct GNUNET_MESSENGER_MessageStore store
enum GNUNET_MESSENGER_MessageKind kind
The kind of the 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 111 of file gnunet-service-messenger_tunnel.c.

References GNUNET_MESSENGER_Message::body, callback_room_recv(), callback_verify_room_message(), GNUNET_MESSENGER_SrvTunnel::contact_id, decode_message(), GNUNET_memcmp, GNUNET_memcpy, GNUNET_MESSENGER_KIND_PEER, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_SYSERR, GNUNET_YES, hash_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, result, GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MessageHeader::size.

Referenced by join_room_locally().

112 {
113  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
114 
115  if (!tunnel)
116  return GNUNET_NO;
117 
118  const uint16_t length = ntohs (header->size) - sizeof(*header);
119  const char *buffer = (const char*) &header[1];
120 
121  struct GNUNET_MESSENGER_Message message;
122 
123  if (length < sizeof(message.header))
124  return GNUNET_NO;
125 
126  if (GNUNET_YES != decode_message (&message, length, buffer))
127  return GNUNET_NO;
128 
129  struct GNUNET_HashCode hash;
130  hash_message (length, buffer, &hash);
131 
132  int result = callback_verify_room_message (tunnel->room, cls, &message, &hash);
133 
134  if (GNUNET_MESSENGER_KIND_PEER == message.header.kind)
135  {
137 
138  GNUNET_PEER_resolve (tunnel->peer, &identity);
139 
140  if (0 == GNUNET_memcmp(&(message.body.peer.peer), &(identity)))
141  {
142  if (tunnel->contact_id)
143  {
144  if (0 != GNUNET_memcmp(tunnel->contact_id, &(message.header.sender_id)))
145  result = GNUNET_SYSERR;
146  }
147  else
148  {
149  tunnel->contact_id = GNUNET_new(struct GNUNET_ShortHashCode);
150 
151  GNUNET_memcpy(tunnel->contact_id, &(message.header.sender_id), sizeof(struct GNUNET_ShortHashCode));
152  }
153  }
154  }
155 
156  return (result == GNUNET_YES ? GNUNET_OK : GNUNET_NO);
157 }
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer)
Decodes a message from a given buffer of a maximal length in bytes.
void hash_message(uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer of a length in bytes.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
A 256-bit hashcode.
int callback_verify_room_message(struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
struct GNUNET_MESSENGER_SrvRoom * room
static int result
Global testing status.
A 512-bit hashcode.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_ShortHashCode * contact_id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_room_recv()

void callback_room_recv ( struct GNUNET_MESSENGER_SrvRoom room,
void *  cls,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

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

References add_to_list_messages(), forward_room_message(), GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, 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_MESSENGER_KIND_REQUEST, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle_room_messages(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, put_store_message(), recv_message_id(), recv_message_info(), recv_message_join(), recv_message_key(), recv_message_leave(), recv_message_miss(), recv_message_name(), recv_message_peer(), recv_message_request(), GNUNET_MESSENGER_SrvRoom::store, GNUNET_MESSENGER_SrvTunnelFinder::tunnel, and update_room_last_messages().

Referenced by check_tunnel_message(), and handle_tunnel_message().

943 {
944  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
945 
946  if (GNUNET_OK != put_store_message (&(room->store), hash, message))
947  return;
948 
949  update_room_last_messages (room, message, hash);
950 
951  if (GNUNET_MESSENGER_KIND_INFO != message->header.kind)
952  forward_room_message (room, tunnel, message, hash);
953 
954  const int start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
955 
956  add_to_list_messages (&(room->handling), hash);
957 
958  switch (message->header.kind)
959  {
961  recv_message_info (room, tunnel, message, hash);
962  break;
964  recv_message_join (room, tunnel, message, hash);
965  break;
967  recv_message_leave (room, tunnel, message, hash);
968  break;
970  recv_message_name (room, tunnel, message, hash);
971  break;
973  recv_message_key (room, tunnel, message, hash);
974  break;
976  recv_message_peer (room, tunnel, message, hash);
977  break;
979  recv_message_id (room, tunnel, message, hash);
980  break;
982  recv_message_miss (room, tunnel, message, hash);
983  break;
985  recv_message_request (room, tunnel, message, hash);
986  break;
987  default:
988  break;
989  }
990 
991  if (GNUNET_YES == start_handle)
992  handle_room_messages (room);
993 }
void recv_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received miss message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
void recv_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received key message.
void recv_message_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, 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...
struct GNUNET_MESSENGER_ListMessage * head
void forward_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const 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 recv_message_name(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received name message.
void recv_message_request(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, 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...
void update_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Updates the last messages of a room by replacing them if the previous hash of a given message matches...
void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
Handles all queued up messages of a room to handle in correct order.
void recv_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received join message to forward all member information to the new member if the message wa...
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_ListMessages handling
void recv_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received id message to change the tunnels linked member id if necessary.
void recv_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received leave message.
void recv_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, 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 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.
struct GNUNET_MESSENGER_MessageStore store
enum GNUNET_MESSENGER_MessageKind kind
The kind of the 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 164 of file gnunet-service-messenger_tunnel.c.

References callback_room_recv(), GNUNET_MESSENGER_SrvTunnel::channel, copy_message(), decode_message(), GNUNET_CADET_receive_done(), GNUNET_memcpy, GNUNET_new, hash_message(), GNUNET_MESSENGER_SrvTunnel::last_message, GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MessageHeader::size.

Referenced by join_room_locally().

165 {
166  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
167 
168  const uint16_t length = ntohs (header->size) - sizeof(*header);
169  const char *buffer = (const char*) &header[1];
170 
171  struct GNUNET_MESSENGER_Message message;
172  struct GNUNET_HashCode hash;
173 
174  decode_message (&message, length, buffer);
175  hash_message (length, buffer, &hash);
176 
177  if (tunnel)
178  {
179  if (!tunnel->last_message)
180  tunnel->last_message = GNUNET_new(struct GNUNET_HashCode);
181 
182  GNUNET_memcpy(tunnel->last_message, &hash, sizeof(struct GNUNET_HashCode));
183 
184  callback_room_recv (tunnel->room, cls, copy_message (&message), &hash);
185  }
186 
188 }
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer)
Decodes a message from a given buffer of a maximal length in bytes.
void hash_message(uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer of a length in bytes.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_MESSENGER_SrvRoom * room
void callback_room_recv(struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
A 512-bit hashcode.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
struct GNUNET_CADET_Channel * channel
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:888
Here is the call graph for this function:
Here is the caller 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
tunnelTunnel
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 191 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 entry_room_at(), and rebuild_room_basement_structure().

192 {
193  GNUNET_assert(tunnel);
194 
195  if (tunnel->channel)
196  return GNUNET_NO;
197 
198  const struct GNUNET_PeerIdentity *door = GNUNET_PEER_resolve2 (tunnel->peer);
199 
200  struct GNUNET_CADET_Handle *cadet = get_room_cadet (tunnel->room);
201  struct GNUNET_HashCode *key = get_room_key (tunnel->room);
202 
204  struct GNUNET_MessageHeader, NULL),
206 
207  tunnel->channel = GNUNET_CADET_channel_create (cadet, tunnel, door, key, NULL, callback_tunnel_disconnect, handlers);
208 
209  return GNUNET_YES;
210 }
const struct GNUNET_PeerIdentity * GNUNET_PEER_resolve2(GNUNET_PEER_Id id)
Convert an interned PID to a normal peer identity.
Definition: peer.c:245
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
struct GNUNET_HashCode * get_room_key(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
Opaque handle to the service.
Definition: cadet_api.c:38
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
struct GNUNET_CADET_Handle * get_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_MESSENGER_SrvRoom * room
A 512-bit hashcode.
Message handler for a specific message type.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_CADET_Channel * channel
The identity of the host (wraps the signing key of the peer).
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:1031
Header for all communications.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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
tunnelTunnel

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

References GNUNET_MESSENGER_SrvTunnel::channel, and delayed_disconnect_channel().

Referenced by callback_room_connect(), rebuild_room_basement_structure(), and send_message_info().

214 {
215  if (tunnel->channel)
216  {
218 
219  tunnel->channel = NULL;
220  }
221 }
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.
struct GNUNET_CADET_Channel * channel
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
tunnelTunnel
Returns
GNUNET_YES or GNUNET_NO

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

References GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_NO, and GNUNET_YES.

Referenced by iterate_send_room_message(), and send_room_info().

225 {
226  return (tunnel->channel ? GNUNET_YES : GNUNET_NO);
227 }
struct GNUNET_CADET_Channel * channel
Here is the caller graph for this function:

◆ callback_room_sent()

void callback_room_sent ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
void *  cls,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

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

References add_to_list_messages(), get_room_message(), GNUNET_free, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, 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_OK, GNUNET_YES, handle_room_messages(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, put_store_message(), send_message_id(), send_message_info(), send_message_join(), send_message_key(), send_message_leave(), send_message_miss(), send_message_name(), send_message_peer(), GNUNET_MESSENGER_SrvRoom::store, GNUNET_MESSENGER_SrvTunnelFinder::tunnel, and update_room_last_messages().

Referenced by iterate_send_room_message(), send_room_message(), send_room_message_ext(), and send_tunnel_envelope().

1000 {
1001  const struct GNUNET_MESSENGER_Message *old_message = get_room_message (room, handle, hash, GNUNET_NO);
1002 
1003  if ((old_message) || (GNUNET_OK != put_store_message (&(room->store), hash, message)))
1004  {
1005  if (old_message != message)
1006  GNUNET_free(message);
1007  }
1008  else
1009  {
1010  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; // may be NULL
1011 
1012  update_room_last_messages (room, message, hash);
1013 
1014  const int start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1015 
1016  add_to_list_messages (&(room->handling), hash);
1017 
1018  switch (message->header.kind)
1019  {
1021  send_message_info (room, handle, tunnel, message, hash);
1022  break;
1024  send_message_join (room, handle, tunnel, message, hash);
1025  break;
1027  send_message_leave (room, handle, tunnel, message, hash);
1028  break;
1030  send_message_name (room, handle, tunnel, message, hash);
1031  break;
1033  send_message_key (room, handle, tunnel, message, hash);
1034  break;
1036  send_message_peer (room, handle, tunnel, message, hash);
1037  break;
1039  send_message_id (room, handle, tunnel, message, hash);
1040  break;
1042  send_message_miss (room, handle, tunnel, message, hash);
1043  break;
1044  default:
1045  break;
1046  }
1047 
1048  if (GNUNET_YES == start_handle)
1049  handle_room_messages (room);
1050  }
1051 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_ListMessage * head
void send_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent leave message.
void send_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent join message to ensure growth of the decentralized room structure. ...
void update_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Updates the last messages of a room by replacing them if the previous hash of a given message matches...
void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
Handles all queued up messages of a room to handle in correct order.
void send_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent miss message.
void send_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent id message.
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.
void send_message_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent info message to setup a tunnels linked member id.
struct GNUNET_MESSENGER_ListMessages handling
const struct GNUNET_MESSENGER_Message * get_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *hash, int request)
Returns a message from a room identified by a given hash.
void send_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent peer message to update the rooms peer message of this service.
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 send_message_name(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent name message.
void send_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent key message.
struct GNUNET_MESSENGER_MessageStore store
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_tunnel_sent()

static void callback_tunnel_sent ( void *  cls)
static

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

References GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_MESSENGER_MessageSent::hash, GNUNET_MESSENGER_SrvTunnel::last_message, and GNUNET_MESSENGER_MessageSent::tunnel.

Referenced by send_tunnel_envelope().

241 {
242  struct GNUNET_MESSENGER_MessageSent *sent = cls;
243 
244  if (sent->tunnel)
245  {
246  if (!sent->tunnel->last_message)
248 
249  GNUNET_memcpy(sent->tunnel->last_message, &(sent->hash), sizeof(struct GNUNET_HashCode));
250  }
251 
252  GNUNET_free(sent);
253 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A 512-bit hashcode.
struct GNUNET_MESSENGER_SrvTunnel * tunnel
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ send_tunnel_envelope()

void send_tunnel_envelope ( struct GNUNET_MESSENGER_SrvTunnel tunnel,
void *  handle,
struct GNUNET_MQ_Envelope env,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Sends an envelope containing a message with a given hash through a tunnel by a given handle.

Parameters
tunnelTunnel
handleHandle
envEnvelope
messageMessage
hashHash of message

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

References callback_room_sent(), callback_tunnel_sent(), GNUNET_MESSENGER_SrvTunnel::channel, GNUNET_CADET_get_mq(), GNUNET_memcpy, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_MESSENGER_MessageSent::hash, mq, GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MESSENGER_MessageSent::tunnel.

Referenced by forward_tunnel_message(), iterate_send_room_message(), and send_tunnel_message().

258 {
259  struct GNUNET_MQ_Handle *mq = GNUNET_CADET_get_mq (tunnel->channel);
260 
262 
263  GNUNET_memcpy(&(sent->hash), hash, sizeof(struct GNUNET_HashCode));
264 
265  sent->tunnel = tunnel;
266 
268  GNUNET_MQ_send (mq, env);
269 
270  callback_room_sent (tunnel->room, (struct GNUNET_MESSENGER_SrvHandle*) handle, tunnel, message, hash);
271 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:787
struct GNUNET_MESSENGER_SrvRoom * room
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
A 512-bit hashcode.
struct GNUNET_MESSENGER_SrvTunnel * tunnel
struct GNUNET_CADET_Channel * channel
Handle to a message queue.
Definition: mq.c:85
void callback_room_sent(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, void *cls, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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:355
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:1082
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_tunnel_message()

void send_tunnel_message ( struct GNUNET_MESSENGER_SrvTunnel tunnel,
void *  handle,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash 
)

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
tunnelTunnel
handleHandle
[out]messageMessage
[out]hashHash of message

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

References copy_message(), env, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, pack_room_message(), GNUNET_MESSENGER_SrvTunnel::room, and send_tunnel_envelope().

Referenced by recv_message_info(), and send_room_info().

276 {
278  message, hash,
280 
281  if (env)
282  send_tunnel_envelope (tunnel, handle, env, copy_message (message), hash);
283 }
void send_tunnel_envelope(struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MQ_Envelope *env, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Sends an envelope containing a message with a given hash through a tunnel by a given handle...
struct GNUNET_MESSENGER_SrvRoom * room
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Envelope * pack_room_message(struct GNUNET_MESSENGER_SrvRoom *room, 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.
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
tunnelTunnel
messageMessage
hashHash of message

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

References copy_message(), env, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, pack_message(), and send_tunnel_envelope().

Referenced by iterate_send_member_infos(), recv_message_request(), and send_message_join().

288 {
289  struct GNUNET_MESSENGER_Message *clone = copy_message (message);
291 
292  if (env)
293  send_tunnel_envelope (tunnel, NULL, env, clone, hash);
294 }
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...
void send_tunnel_envelope(struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MQ_Envelope *env, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Sends an envelope containing a message with a given hash through a tunnel by a given handle...
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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
tunnelTunnel
Returns
Hash of peer message or NULL

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

References GNUNET_MESSENGER_SrvTunnel::peer_message.

298 {
299  return tunnel->peer_message;
300 }