GNUnet  0.11.x
Functions
messenger_api.c File Reference

messenger api: client implementation of GNUnet MESSENGER service More...

#include "gnunet_messenger_service.h"
#include "gnunet-service-messenger.h"
#include "messenger_api_handle.h"
#include "messenger_api_message.h"
Include dependency graph for messenger_api.c:

Go to the source code of this file.

Functions

const char * GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
 Get the name of a message kind. More...
 
static int check_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
 
static void handle_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
 
static void handle_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
 
static void handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
 
static void handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static int check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void reconnect (struct GNUNET_MESSENGER_Handle *handle)
 
static void send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static void send_entry_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
 
static void send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static int iterate_reset_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_reconnect (void *cls)
 
static int iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_mq_error (void *cls, enum GNUNET_MQ_Error error)
 
struct GNUNET_MESSENGER_HandleGNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
 Set up a handle for the messenger related functions and connects to all necessary services. More...
 
int GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle)
 Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. More...
 
void GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle)
 Disconnect all of the messengers used services and clears up its used memory. More...
 
const char * GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle)
 Get the name (if specified, otherwise NULL) used by the messenger. More...
 
int GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name)
 Set the name for the messenger. More...
 
const struct GNUNET_IDENTITY_PublicKeyGNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle)
 Get the public key used by the messenger. More...
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
 Open a room to send and receive messages. More...
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_entry_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
 Enter a room to send and receive messages through a door opened using GNUNET_MESSENGER_open_room(...). More...
 
void GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room)
 Close a room which was entered, opened or both in various order and variety. More...
 
struct GNUNET_MESSENGER_ContactGNUNET_MESSENGER_get_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
 Get the contact of a member in a room identified by their id. More...
 
const char * GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact)
 Get the name used by the contact. More...
 
const struct GNUNET_IDENTITY_PublicKeyGNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact)
 Get the public key used by the contact. More...
 
void GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message)
 Send a message into a room. More...
 
const struct GNUNET_MESSENGER_MessageGNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the message in a room identified by its hash. More...
 

Detailed Description

messenger api: client implementation of GNUnet MESSENGER service

Author
Tobias Frisch

Definition in file messenger_api.c.

Function Documentation

◆ check_get_name()

static int check_get_name ( void *  cls,
const struct GNUNET_MESSENGER_NameMessage msg 
)
static

Definition at line 70 of file messenger_api.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

71 {
73  return GNUNET_OK;
74 }
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_get_name()

static void handle_get_name ( void *  cls,
const struct GNUNET_MESSENGER_NameMessage msg 
)
static

Definition at line 77 of file messenger_api.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, handle, name, and set_handle_name().

78 {
79  struct GNUNET_MESSENGER_Handle *handle = cls;
80 
81  const char *name = ((const char*) msg) + sizeof(*msg);
82 
83  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Set name of handle: %s\n", name);
84 
85  set_handle_name (handle, strlen(name) > 0? name : NULL);
86 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int set_handle_name(struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
Tries to rename the handle which implies renaming the EGO its using and moving all related data into ...
const char * name
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ handle_get_key()

static void handle_get_key ( void *  cls,
const struct GNUNET_MESSENGER_KeyMessage msg 
)
static

Definition at line 89 of file messenger_api.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_public_key_to_string(), GNUNET_log, handle, GNUNET_MESSENGER_Handle::identity_callback, GNUNET_MESSENGER_Handle::identity_cls, GNUNET_MESSENGER_KeyMessage::pubkey, pubkey, and set_handle_key().

90 {
91  struct GNUNET_MESSENGER_Handle *handle = cls;
92 
93  const struct GNUNET_IDENTITY_PublicKey *pubkey = &(msg->pubkey);
94 
95  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Set key of handle: %s\n", GNUNET_IDENTITY_public_key_to_string (pubkey));
96 
97  set_handle_key (handle, pubkey);
98 
99  if (handle->identity_callback)
100  handle->identity_callback (handle->identity_cls, handle);
101 }
struct GNUNET_IDENTITY_PublicKey pubkey
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
An identity key as per LSD0001.
#define GNUNET_log(kind,...)
void set_handle_key(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *pubkey)
Sets the public key of a given handle to a specific public key.
GNUNET_MESSENGER_IdentityCallback identity_callback
Here is the call graph for this function:

◆ handle_member_id()

static void handle_member_id ( void *  cls,
const struct GNUNET_MESSENGER_MemberMessage msg 
)
static

Definition at line 104 of file messenger_api.c.

References GNUNET_MESSENGER_Room::contact_id, GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, handle, GNUNET_MESSENGER_MemberMessage::id, key, GNUNET_MESSENGER_MemberMessage::key, and GNUNET_MESSENGER_Handle::rooms.

105 {
106  struct GNUNET_MESSENGER_Handle *handle = cls;
107 
108  const struct GNUNET_HashCode *key = &(msg->key);
109  const struct GNUNET_ShortHashCode *id = &(msg->id);
110 
111  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Set id of handle in room: %s\n", GNUNET_h2s (key));
112 
113  struct GNUNET_MESSENGER_Room *room = GNUNET_CONTAINER_multihashmap_get (handle->rooms, key);
114 
115  if (room)
116  {
117  if (!room->contact_id)
119 
120  GNUNET_memcpy(room->contact_id, id, sizeof(*id));
121  }
122 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A 256-bit hashcode.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_ShortHashCode * contact_id
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CONTAINER_MultiHashMap * rooms
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_ShortHashCode id
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ handle_room_open()

static void handle_room_open ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 125 of file messenger_api.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, GNUNET_MESSENGER_RoomMessage::key, and open_handle_room().

126 {
127  struct GNUNET_MESSENGER_Handle *handle = cls;
128 
129  const struct GNUNET_HashCode *key = &(msg->key);
130 
131  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opened room: %s\n", GNUNET_h2s (key));
132 
133  open_handle_room (handle, key);
134 }
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int open_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Makes a given handle a member of the room using a specific key and opens the room from the handles se...
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ handle_room_entry()

static void handle_room_entry ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 137 of file messenger_api.c.

References GNUNET_MESSENGER_RoomMessage::door, entry_handle_room_at(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, and GNUNET_MESSENGER_RoomMessage::key.

138 {
139  struct GNUNET_MESSENGER_Handle *handle = cls;
140 
141  const struct GNUNET_PeerIdentity *door = &(msg->door);
142  const struct GNUNET_HashCode *key = &(msg->key);
143 
144  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entered room: %s\n", GNUNET_h2s (key));
145 
146  entry_handle_room_at (handle, door, key);
147 }
void entry_handle_room_at(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Adds a tunnel for a room known to a handle identified by a given key to a list of opened connections...
struct GNUNET_PeerIdentity door
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ handle_room_close()

static void handle_room_close ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 150 of file messenger_api.c.

References close_handle_room(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, handle, key, and GNUNET_MESSENGER_RoomMessage::key.

151 {
152  struct GNUNET_MESSENGER_Handle *handle = cls;
153 
154  const struct GNUNET_HashCode *key = &(msg->key);
155 
156  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closed room: %s\n", GNUNET_h2s (key));
157 
158  close_handle_room (handle, key);
159 }
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int close_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Removes the membership of the room using a specific key and closes it if no other handle from this se...
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ check_recv_message()

static int check_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 162 of file messenger_api.c.

References decode_message(), GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_RecvMessage::hash, GNUNET_MESSENGER_RecvMessage::header, GNUNET_MESSENGER_Message::header, and GNUNET_MessageHeader::size.

163 {
164  const uint16_t full_length = ntohs (msg->header.size) - sizeof(msg->header);
165 
166  if (full_length < sizeof(msg->hash))
167  return GNUNET_NO;
168 
169  const uint16_t length = full_length - sizeof(msg->hash);
170  const char *buffer = ((const char*) msg) + sizeof(*msg);
171 
172  struct GNUNET_MESSENGER_Message message;
173 
174  if (length < sizeof(message.header))
175  return GNUNET_NO;
176 
177  if (GNUNET_YES != decode_message (&message, length, buffer))
178  return GNUNET_NO;
179 
180  return GNUNET_OK;
181 }
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_MessageHeader header
Here is the call graph for this function:

◆ handle_recv_message()

static void handle_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 184 of file messenger_api.c.

References decode_message(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_name_of_kind(), handle, handle_room_message(), GNUNET_MESSENGER_RecvMessage::hash, GNUNET_MESSENGER_RecvMessage::header, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_RecvMessage::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Handle::msg_callback, GNUNET_MESSENGER_Handle::msg_cls, reconnect(), GNUNET_MESSENGER_Handle::rooms, and GNUNET_MessageHeader::size.

185 {
186  struct GNUNET_MESSENGER_Handle *handle = cls;
187 
188  const struct GNUNET_HashCode *key = &(msg->key);
189  const struct GNUNET_HashCode *hash = &(msg->hash);
190 
191  const char *buffer = ((const char*) msg) + sizeof(*msg);
192 
193  const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
194 
195  struct GNUNET_MESSENGER_Message message;
196  decode_message (&message, length, buffer);
197 
198  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Receiving message: %s\n", GNUNET_MESSENGER_name_of_kind (message.header.kind));
199 
200  struct GNUNET_MESSENGER_Room *room = GNUNET_CONTAINER_multihashmap_get (handle->rooms, key);
201 
202  if (room)
203  {
204  handle_room_message (room, &message, hash);
205 
206  if (handle->msg_callback)
207  handle->msg_callback (handle->msg_cls, room, &message, hash);
208  }
209  else
210  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESSENGER ERROR: Room not found\n");
211 }
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
GNUNET_MESSENGER_MessageCallback msg_callback
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:34
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CONTAINER_MultiHashMap * rooms
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
void handle_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a message with a given hash in a room for the client API to update members and its informatio...
#define GNUNET_log(kind,...)
struct GNUNET_MessageHeader header
Here is the call graph for this function:

◆ reconnect()

static void reconnect ( struct GNUNET_MESSENGER_Handle handle)
static

Definition at line 320 of file messenger_api.c.

References callback_mq_error(), GNUNET_MESSENGER_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MESSENGER_Handle::mq, and recv_message().

Referenced by callback_reconnect(), GNUNET_MESSENGER_connect(), and handle_recv_message().

321 {
326  struct GNUNET_MESSENGER_KeyMessage, handle),
328  member_id,
330  struct GNUNET_MESSENGER_MemberMessage, handle),
331  GNUNET_MQ_hd_fixed_size(room_open,
334  handle),
335  GNUNET_MQ_hd_fixed_size(room_entry,
338  handle),
339  GNUNET_MQ_hd_fixed_size(room_close,
342  handle),
344  recv_message,
346  struct GNUNET_MESSENGER_RecvMessage, handle),
348 
349  handle->mq = GNUNET_CLIENT_connect (handle->cfg,
351  handlers, &callback_mq_error, handle);
352 }
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY
Message to receive the current member id of a handle in room.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1063
static void callback_mq_error(void *cls, enum GNUNET_MQ_Error error)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_MQ_Handle * mq
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static int recv_message(void *cls, const struct GNUNET_MessageHeader *msg)
We have received a full message, pass to the MQ dispatcher.
Definition: client.c:332
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME
Message handler for a specific message type.
const struct GNUNET_CONFIGURATION_Handle * cfg
#define GNUNET_MESSENGER_SERVICE_NAME
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
Message to receive the current name of a handle.
Message to receive the current public key of a handle.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
Message to receive something from a room.
General message to confirm interaction with a room.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_open_room()

static void send_open_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 217 of file messenger_api.c.

References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_RoomMessage::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_open_room(), and iterate_reset_room().

218 {
220  struct GNUNET_MQ_Envelope *env;
221 
223  GNUNET_memcpy(&(msg->key), &(room->key), sizeof(room->key));
224  GNUNET_MQ_send (handle->mq, env);
225 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_HashCode key
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
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
General message to confirm interaction with a room.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_entry_room()

static void send_entry_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_PeerIdentity door 
)
static

Definition at line 228 of file messenger_api.c.

References GNUNET_MESSENGER_RoomMessage::door, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_RoomMessage::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_entry_room(), and iterate_reset_room().

230 {
232  struct GNUNET_MQ_Envelope *env;
233 
235  GNUNET_memcpy(&(msg->door), door, sizeof(*door));
236  GNUNET_memcpy(&(msg->key), &(room->key), sizeof(room->key));
237  GNUNET_MQ_send (handle->mq, env);
238 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_HashCode key
struct GNUNET_PeerIdentity door
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
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
General message to confirm interaction with a room.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_close_room()

static void send_close_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 241 of file messenger_api.c.

References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_RoomMessage::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_close_room(), and iterate_close_room().

242 {
244  struct GNUNET_MQ_Envelope *env;
245 
247  GNUNET_memcpy(&(msg->key), &(room->key), sizeof(room->key));
248  GNUNET_MQ_send (handle->mq, env);
249 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_HashCode key
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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
General message to confirm interaction with a room.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_reset_room()

static int iterate_reset_room ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 252 of file messenger_api.c.

References GNUNET_MESSENGER_Room::entries, GNUNET_PEER_resolve(), GNUNET_YES, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_ListTunnel::next, GNUNET_MESSENGER_Room::opened, GNUNET_MESSENGER_ListTunnel::peer, send_entry_room(), send_open_room(), and value.

Referenced by callback_reconnect().

253 {
254  struct GNUNET_MESSENGER_Handle *handle = cls;
255  struct GNUNET_MESSENGER_Room *room = value;
256 
257  if (GNUNET_YES == room->opened)
258  send_open_room (handle, room);
259 
260  struct GNUNET_MESSENGER_ListTunnel *entry = room->entries.head;
261 
262  struct GNUNET_PeerIdentity door;
263 
264  while (entry)
265  {
266  GNUNET_PEER_resolve (entry->peer, &door);
267 
268  send_entry_room (handle, room, &door);
269 
270  entry = entry->next;
271  }
272 
273  return GNUNET_YES;
274 }
struct GNUNET_MESSENGER_ListTunnel * head
struct GNUNET_MESSENGER_ListTunnel * next
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
struct GNUNET_MESSENGER_ListTunnels entries
static char * value
Value of the record to add/remove.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void send_open_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
static void send_entry_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
The identity of the host (wraps the signing key of the peer).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_reconnect()

static void callback_reconnect ( void *  cls)
static

Definition at line 277 of file messenger_api.c.

References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_TIME_STD_BACKOFF, iterate_reset_room(), reconnect(), GNUNET_MESSENGER_Handle::reconnect_task, GNUNET_MESSENGER_Handle::reconnect_time, and GNUNET_MESSENGER_Handle::rooms.

Referenced by callback_mq_error().

278 {
279  struct GNUNET_MESSENGER_Handle *handle = cls;
280 
281  handle->reconnect_task = NULL;
283  ;
284 
285  reconnect (handle);
286 
288 }
static int iterate_reset_room(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_SCHEDULER_Task * reconnect_task
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CONTAINER_MultiHashMap * rooms
struct GNUNET_TIME_Relative reconnect_time
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void reconnect(struct GNUNET_MESSENGER_Handle *handle)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_close_room()

static int iterate_close_room ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 291 of file messenger_api.c.

References GNUNET_YES, send_close_room(), and value.

Referenced by callback_mq_error().

292 {
293  struct GNUNET_MESSENGER_Handle *handle = cls;
294  struct GNUNET_MESSENGER_Room *room = value;
295 
296  send_close_room (handle, room);
297 
298  return GNUNET_YES;
299 }
static char * value
Value of the record to add/remove.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void send_close_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_mq_error()

static void callback_mq_error ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Definition at line 302 of file messenger_api.c.

References callback_reconnect(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), iterate_close_room(), GNUNET_MESSENGER_Handle::mq, GNUNET_MESSENGER_Handle::reconnect_task, GNUNET_MESSENGER_Handle::reconnect_time, and GNUNET_MESSENGER_Handle::rooms.

Referenced by reconnect().

303 {
304  struct GNUNET_MESSENGER_Handle *handle = cls;
305 
306  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MQ ERROR: %u\n", error);
307 
309 
310  if (handle->mq)
311  {
312  GNUNET_MQ_destroy (handle->mq);
313  handle->mq = NULL;
314  }
315 
317 }
static void callback_reconnect(void *cls)
static int iterate_close_room(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_SCHEDULER_Task * reconnect_task
struct GNUNET_MQ_Handle * mq
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CONTAINER_MultiHashMap * rooms
struct GNUNET_TIME_Relative reconnect_time
#define GNUNET_log(kind,...)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function: