GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-service-messenger_message_recv.h File Reference
Include dependency graph for gnunet-service-messenger_message_recv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

enum GNUNET_GenericReturnValue 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 connected to.
 
enum GNUNET_GenericReturnValue 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.
 
enum GNUNET_GenericReturnValue recv_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Handles a received miss message to react to activity in the basement of a room.
 
enum GNUNET_GenericReturnValue 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 the message was found.
 

Function Documentation

◆ recv_message_info()

enum GNUNET_GenericReturnValue 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 connected to.

(all current tunnels will be informed about the id change)

Parameters
[in,out]roomRoom of the message
[in,out]tunnelReceiving connection
[in]messageINFO-Message
[in]hashHash of the message
Returns
GNUNET_NO to not forward the message

Definition at line 100 of file gnunet-service-messenger_message_recv.c.

104{
105 uint32_t version;
106 struct GNUNET_PeerIdentity peer;
107
108 version = get_tunnel_messenger_version (tunnel);
109
111 message->body.info.
112 messenger_version))
113 {
114 disconnect_tunnel (tunnel);
115 return GNUNET_NO;
116 }
117
118 if (version == get_tunnel_messenger_version (tunnel))
119 return GNUNET_NO;
120
121 if (room->host)
123 room->service));
124
125 get_tunnel_peer_identity (tunnel, &peer);
126
127 if (GNUNET_YES != contains_list_tunnels (&(room->basement), &peer))
128 {
129 struct GNUNET_MESSENGER_MessageStore *message_store;
130 struct GNUNET_MESSENGER_MemberStore *member_store;
131 struct GNUNET_MESSENGER_ListTunnel *element;
132
133 message_store = get_srv_room_message_store (room);
134 member_store = get_srv_room_member_store (room);
135
136 for (element = room->basement.head; element; element = element->next)
137 {
138 const struct GNUNET_MESSENGER_Message *msg;
139
140 if (! element->hash)
141 continue;
142
143 msg = get_store_message (message_store, element->hash);
144
145 if (! msg)
146 continue;
147
148 forward_tunnel_message (tunnel, msg, element->hash);
149 }
150
151 iterate_store_members (member_store, iterate_forward_members, tunnel);
152 }
153
154 check_srv_room_peer_status (room, tunnel);
155 return GNUNET_NO;
156}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
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 ...
struct GNUNET_MESSENGER_Message * create_message_info(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new info message containing the hosts service peer identity and version.
static enum GNUNET_GenericReturnValue iterate_forward_members(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
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.
void check_srv_room_peer_status(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Checks the current state of opening a given room from this peer and re-publishes it if necessary to a...
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
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.
enum GNUNET_GenericReturnValue 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 pee...
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 ...
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.
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
enum GNUNET_GenericReturnValue 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_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head
struct GNUNET_MESSENGER_MessageInfo info
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_Service * service
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, GNUNET_MESSENGER_Message::body, check_srv_room_peer_status(), contains_list_tunnels(), create_message_info(), disconnect_tunnel(), forward_tunnel_message(), get_srv_room_member_store(), get_srv_room_message_store(), get_store_message(), get_tunnel_messenger_version(), get_tunnel_peer_identity(), GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_ListTunnel::hash, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_MessageBody::info, iterate_forward_members(), iterate_store_members(), msg, GNUNET_MESSENGER_ListTunnel::next, send_tunnel_message(), GNUNET_MESSENGER_SrvRoom::service, and update_tunnel_messenger_version().

Referenced by handle_tunnel_message().

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

◆ recv_message_peer()

enum GNUNET_GenericReturnValue 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.

(the peer message and the member id can potentially be linked to the tunnel)

Parameters
[in,out]roomRoom of the message
[in,out]tunnelReceiving connection
[in]messagePEER-Message
[in]hashHash of the message
Returns
GNUNET_YES to forward the message

Definition at line 160 of file gnunet-service-messenger_message_recv.c.

164{
165 struct GNUNET_PeerIdentity peer;
166
167 GNUNET_PEER_resolve (tunnel->peer, &peer);
168
169 if (0 == GNUNET_memcmp (&peer, &(message->body.peer.peer)))
170 {
171 if (! tunnel->peer_message)
172 tunnel->peer_message = GNUNET_new (struct GNUNET_HashCode);
173
174 GNUNET_memcpy (tunnel->peer_message, &hash, sizeof(hash));
175 }
176
177 update_to_list_tunnels (&(room->basement), &(message->body.peer.peer), hash);
178 return GNUNET_YES;
179}
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#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_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition peer.c:220
void update_to_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HashCode *hash)
Updates a specific peer from a tunnel in the list.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.

References GNUNET_MESSENGER_SrvRoom::basement, GNUNET_MESSENGER_Message::body, GNUNET_memcmp, GNUNET_memcpy, GNUNET_new, GNUNET_PEER_resolve(), GNUNET_YES, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::peer_message, and update_to_list_tunnels().

Referenced by handle_tunnel_message().

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

◆ recv_message_miss()

enum GNUNET_GenericReturnValue recv_message_miss ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvTunnel tunnel,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Handles a received miss message to react to activity in the basement of a room.

(the miss message can cause automatic opening of the room)

Parameters
[in,out]roomRoom of the message
[in,out]tunnelReceiving connection
[in]messageMISS-Message
[in]hashHash of the message
Returns
GNUNET_YES to forward the message

Definition at line 183 of file gnunet-service-messenger_message_recv.c.

187{
189
190 service = room->service;
191
192 if ((GNUNET_YES == service->auto_routing) &&
193 (service->min_routers > count_of_tunnels (&(room->basement))))
194 open_srv_room (room, NULL);
195
196 return GNUNET_YES;
197}
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
size_t count_of_tunnels(const struct GNUNET_MESSENGER_ListTunnels *tunnels)
Returns the count of peers in a list (typically from the basement of a room).
enum GNUNET_GenericReturnValue open_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Tries to open a room for a given handle.

References GNUNET_MESSENGER_SrvRoom::basement, count_of_tunnels(), GNUNET_YES, open_srv_room(), service, and GNUNET_MESSENGER_SrvRoom::service.

Referenced by handle_tunnel_message().

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

◆ recv_message_request()

enum GNUNET_GenericReturnValue 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 the message was found.

(this can also cause this peer to send a new request instead of only forwarding the received one)

Parameters
[in,out]roomRoom of the message
[in,out]tunnelReceiving connection
[in]messageREQUEST-Message
[in]hashHash of the message
Returns
GNUNET_YES or GNUNET_NO depending on required forwarding

Definition at line 234 of file gnunet-service-messenger_message_recv.c.

238{
239 struct GNUNET_MESSENGER_MemberStore *member_store;
240 struct GNUNET_MESSENGER_Member *member;
241 struct GNUNET_MESSENGER_MemberSession *session;
242
243 member_store = get_srv_room_member_store (room);
244 member = get_store_member_of (member_store, message);
245
246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request for message (%s)\n",
247 GNUNET_h2s (hash));
248
249 if (! member)
250 return GNUNET_NO;
251
252 session = get_member_session_of (member, message, hash);
253
254 if ((! session) || (GNUNET_YES != check_member_session_history (session,
255 &(message->
256 body.request
257 .hash),
258 GNUNET_NO)))
259 return GNUNET_NO;
260
262 &(message->body.request.hash),
263 session, callback_found_message,
264 tunnel))
265 return GNUNET_YES;
266
267 return GNUNET_NO;
268}
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...
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
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.
static void callback_found_message(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
#define GNUNET_log(kind,...)
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_HashCode hash
The hash of the requested message.

References GNUNET_MESSENGER_Message::body, callback_found_message(), check_member_session_history(), get_member_session_of(), get_srv_room_member_store(), get_store_member_of(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_MessageBody::request, and request_srv_room_message().

Referenced by handle_tunnel_message().

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