81 const char *
name = ((
const char*) msg) +
sizeof(*msg);
164 const uint16_t full_length = ntohs (msg->
header.
size) -
sizeof(msg->
header);
166 if (full_length <
sizeof(msg->
hash))
169 const uint16_t length = full_length -
sizeof(msg->
hash);
170 const char *buffer = ((
const char*) msg) +
sizeof(*msg);
174 if (length <
sizeof(message.
header))
191 const char *buffer = ((
const char*) msg) +
sizeof(*msg);
193 const uint16_t length = ntohs (msg->
header.
size) -
sizeof(*msg);
365 const uint16_t name_len = name ? strlen (name) : 0;
372 char *extra = ((
char*) msg) +
sizeof(*msg);
377 extra[name_len] =
'\0';
433 const uint16_t name_len = name ? strlen (name) : 0;
440 char *extra = ((
char*) msg) +
sizeof(*msg);
445 extra[name_len] =
'\0';
545 char *buffer = ((
char*) msg) +
sizeof(*msg);
const struct GNUNET_MESSENGER_Message * GNUNET_MESSENGER_get_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Get the message in a room identified by its hash.
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.
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_get_key(const struct GNUNET_MESSENGER_Handle *handle)
Get the public key used by the messenger.
void GNUNET_MESSENGER_send_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message)
Send a message into a room.
struct GNUNET_MESSENGER_MessageHeader header
Header.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY
struct GNUNET_MessageHeader * msg
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_open_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Open a room to send and receive messages.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
struct GNUNET_HashCode key
void GNUNET_MESSENGER_close_room(struct GNUNET_MESSENGER_Room *room)
Close a room which was entered, opened or both in various order and variety.
static void handle_get_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
struct GNUNET_IDENTITY_PublicKey pubkey
const struct GNUNET_IDENTITY_PublicKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
Message to receive the current member id of a handle in room.
GNUnet MESSENGER service.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE
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.
struct GNUNET_HashCode key
static void callback_reconnect(void *cls)
GNUNET_MQ_Error
Error codes for the queue.
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...
const char * GNUNET_MESSENGER_contact_get_name(const struct GNUNET_MESSENGER_Contact *contact)
Get the name used by the contact.
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
void destroy_room(struct GNUNET_MESSENGER_SrvRoom *room)
Destroys a room and frees its memory fully.
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_PeerIdentity door
struct GNUNET_MESSENGER_ListTunnel * head
static void callback_mq_error(void *cls, enum GNUNET_MQ_Error error)
static void handle_recv_message(void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
int GNUNET_MESSENGER_set_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Set the name for the messenger.
static int iterate_close_room(void *cls, const struct GNUNET_HashCode *key, void *value)
static int iterate_reset_room(void *cls, const struct GNUNET_HashCode *key, void *value)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_HashCode hash
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message)
Returns the exact size in bytes to encode a given message.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer)
Encodes a given message into a buffer of a maximal length in bytes.
struct GNUNET_SCHEDULER_Task * reconnect_task
struct GNUNET_MESSENGER_ListTunnel * next
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void handle_room_open(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_member_id(void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
static void handle_get_key(void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
struct GNUNET_MQ_Handle * mq
struct GNUNET_MESSENGER_ListTunnels entries
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.
Message to send something into a room.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
static int check_recv_message(void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
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.
struct GNUNET_ShortHashCode * contact_id
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
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 char * value
Value of the record to add/remove.
void(* GNUNET_MESSENGER_MessageCallback)(void *cls, const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Method called whenever a message is sent or received from a room.
static int check_get_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
#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.
Message to create a handle for a client.
GNUNET_MESSENGER_MessageCallback msg_callback
struct GNUNET_MESSENGER_Room * GNUNET_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(...).
static void handle_room_close(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
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_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
struct GNUNET_HashCode key
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 gene...
struct GNUNET_CONTAINER_MultiHashMap * rooms
messenger api: client implementation of GNUnet MESSENGER service
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME
Message handler for a specific message type.
struct GNUNET_MESSENGER_Handle * handle
struct GNUNET_TIME_Relative reconnect_time
struct GNUNET_HashCode key
The key used in the DHT.
void(* GNUNET_MESSENGER_IdentityCallback)(void *cls, struct GNUNET_MESSENGER_Handle *handle)
Method called whenever the EGO of a handle changes or if the first connection fails to load a valid E...
static void send_open_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
struct GNUNET_MQ_Envelope * env
Message to update the handle (its EGO key) for a client.
Message to destroy the handle for a client.
void destroy_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Destroys a handle and frees its memory fully.
#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 send_entry_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
const struct GNUNET_CONFIGURATION_Handle * cfg
#define GNUNET_MESSENGER_SERVICE_NAME
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 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_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
struct GNUNET_MESSENGER_SrvRoom * create_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key.
The identity of the host (wraps the signing key of the peer).
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 ...
struct GNUNET_MESSENGER_Handle * GNUNET_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...
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
struct GNUNET_MESSENGER_SrvHandle * create_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
Creates and allocates a new handle related to a service and using a given mq (message queue)...
An identity key as per LSD0001.
struct GNUNET_ShortHashCode id
struct GNUNET_HashCode key
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
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.
Message to receive the current name of a handle.
struct GNUNET_HashCode key
Message to receive the current public key of a handle.
void GNUNET_MESSENGER_disconnect(struct GNUNET_MESSENGER_Handle *handle)
Disconnect all of the messengers used services and clears up its used memory.
#define GNUNET_log(kind,...)
const char * GNUNET_MESSENGER_get_name(const struct GNUNET_MESSENGER_Handle *handle)
Get the name (if specified, otherwise NULL) used by the messenger.
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_contact_get_key(const struct GNUNET_MESSENGER_Contact *contact)
Get the public key used by the contact.
static void send_close_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
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.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
GNUNET_MESSENGER_MessageKind
Enum for the different supported kinds of messages.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
static void reconnect(struct GNUNET_MESSENGER_Handle *handle)
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
GNUNET_MESSENGER_IdentityCallback identity_callback
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Message to receive something from a room.
struct GNUNET_MESSENGER_Contact * GNUNET_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.
General message to confirm interaction with a room.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void handle_room_entry(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
messenger api: client and service implementation of GNUnet MESSENGER service
struct GNUNET_MessageHeader header