89 const char *
name = ((
const char*)
msg) +
sizeof(*msg);
100 const uint16_t full_length = ntohs (
msg->header.
size);
102 if (full_length <
sizeof(*
msg))
105 const uint16_t length = full_length -
sizeof(*msg);
106 const char *buffer = ((
const char*)
msg) +
sizeof(*msg);
124 const uint16_t length = ntohs (
msg->header.
size) -
sizeof(*msg);
125 const char *buffer = ((
const char*)
msg) +
sizeof(*msg);
140 if (
handle->identity_callback)
210 const uint16_t full_length = ntohs (
msg->header.
size);
212 if (full_length <
sizeof(*
msg))
215 const uint16_t length = full_length -
sizeof(*msg);
216 const char *buffer = ((
const char*)
msg) +
sizeof(*msg);
244 const uint16_t length = ntohs (
msg->header.
size) -
sizeof(*msg);
245 const char *buffer = ((
const char*)
msg) +
sizeof(*msg);
270 handle->msg_callback (
handle->msg_cls, room, contact, stored_message, hash, flags);
450 const uint16_t name_len =
name ? strlen (
name) : 0;
457 char *extra = ((
char*)
msg) +
sizeof(*msg);
462 extra[name_len] =
'\0';
519 const uint16_t name_len =
name ? strlen (
name) : 0;
526 char *extra = ((
char*)
msg) +
sizeof(*msg);
531 extra[name_len] =
'\0';
676 if ((!room) || (!hash))
705 if ((!room) || (!message))
720 ssize_t key_length = 0;
745 const uint16_t length = (uint16_t) key_length + msg_length;
754 msg->flags = (uint32_t) (
758 char *buffer = ((
char*)
msg) +
sizeof(*msg);
759 char *msg_buffer = buffer + key_length;
773 if ((!room) || (!hash))
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static enum GNUNET_GenericReturnValue recv_message(void *cls, const struct GNUNET_MessageHeader *msg)
We have received a full message, pass to the MQ dispatcher.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static pa_context * context
Pulseaudio context.
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static char * value
Value of the record to add/remove.
GNUnet MESSENGER service.
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.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue 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.
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_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
ssize_t GNUNET_IDENTITY_write_public_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
ssize_t GNUNET_IDENTITY_public_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
#define GNUNET_log(kind,...)
#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.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
const char * GNUNET_MESSENGER_get_name(const struct GNUNET_MESSENGER_Handle *handle)
Get the name (if specified, otherwise NULL) used by the messenger.
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_enter_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.
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...
int GNUNET_MESSENGER_iterate_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room and calls a selected callback for each of them with a pr...
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.
int GNUNET_MESSENGER_find_rooms(const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Searches for a specific contact in a given room and calls a selected callback with a given closure fo...
GNUNET_MESSENGER_MessageKind
Enum for the different supported kinds of messages.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling Compatible flags can be OR'ed togethe...
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_contact_get_key(const struct GNUNET_MESSENGER_Contact *contact)
Get the public key used by the contact or NULL if the anonymous key was used.
int(* GNUNET_MESSENGER_MemberCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Method called for each member in a room during iteration.
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.
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...
const char * GNUNET_MESSENGER_contact_get_name(const struct GNUNET_MESSENGER_Contact *contact)
Get the name used by the contact.
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_get_key(const struct GNUNET_MESSENGER_Handle *handle)
Get the public key used by the messenger or NULL if the anonymous key was used.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
const struct GNUNET_MESSENGER_Contact * GNUNET_MESSENGER_get_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Get the contact of a member in a room which sent a specific message identified with a given hash.
void GNUNET_MESSENGER_disconnect(struct GNUNET_MESSENGER_Handle *handle)
Disconnect all of the messengers used services and clears up its used memory.
const struct GNUNET_HashCode * GNUNET_MESSENGER_room_get_key(const struct GNUNET_MESSENGER_Room *room)
Get the key of a given room.
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
void GNUNET_MESSENGER_close_room(struct GNUNET_MESSENGER_Room *room)
Close a room which was entered, opened or both in various order and variety.
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 GNUNET_MESSENGER_set_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Set the name for the messenger.
void GNUNET_MESSENGER_send_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_Contact *contact)
Send a message into a room.
void(* GNUNET_MESSENGER_MessageCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Method called whenever a message is sent or received from a room.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_FILE
The file kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
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.
#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 int iterate_reset_room(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_recv_message(void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
static void callback_reconnect(void *cls)
static void handle_room_close(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static const struct GNUNET_IDENTITY_PublicKey * get_non_anonymous_key(const struct GNUNET_IDENTITY_PublicKey *public_key)
static int iterate_find_room(void *cls, const struct GNUNET_HashCode *key, void *value)
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 send_enter_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 void callback_mq_error(void *cls, enum GNUNET_MQ_Error error)
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 int iterate_close_room(void *cls, const struct GNUNET_HashCode *key, void *value)
static int check_get_key(void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
static void handle_get_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
static int check_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 int check_get_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
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 * 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.
struct GNUNET_MESSENGER_Handle * create_handle(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Creates and allocates a new handle using a given configuration and a custom message callback with a g...
void open_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Marks a room known to a handle identified by a given key as open.
void destroy_handle(struct GNUNET_MESSENGER_Handle *handle)
Destroys a handle and frees its memory fully from the client API.
struct GNUNET_MESSENGER_ContactStore * get_handle_contact_store(struct GNUNET_MESSENGER_Handle *handle)
Returns the used contact store of a given handle.
void close_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Destroys and so implicitly closes a room known to a handle identified by a given key.
void set_handle_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Sets the name of a handle to a specific name.
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.
const struct GNUNET_IDENTITY_PublicKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
messenger api: client implementation of GNUnet MESSENGER service
int filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns if a specific kind of message should be sent by a client.
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, int include_header)
Encodes a given message into a buffer of a maximal length in bytes.
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, int include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, int include_header)
Returns the exact size in bytes to encode a given message.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.
messenger api: client and service implementation of GNUnet MESSENGER service
struct GNUNET_MESSENGER_Contact * handle_room_message(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 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...
struct GNUNET_MESSENGER_Contact * get_room_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages sender locally stored from a map for a given hash in a room.
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
int find_room_member(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Checks through all members of a given room if a specific contact is found and returns a result depend...
struct GNUNET_MESSENGER_Room * create_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key for the client API.
int iterate_room_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room to forward each of them to a selected callback with a cu...
void destroy_room(struct GNUNET_MESSENGER_Room *room)
Destroys a room and frees its memory fully from the client API.
const struct GNUNET_IDENTITY_PublicKey * get_anonymous_public_key()
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...
messenger api: client implementation of GNUnet MESSENGER service
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
An identity key as per LSD0001.
Message to create a handle for a client.
Message to destroy the handle for a client.
Message to request something from a room.
struct GNUNET_MQ_Handle * mq
GNUNET_MESSENGER_MessageCallback msg_callback
GNUNET_MESSENGER_IdentityCallback identity_callback
Message to receive the current public key of a handle.
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head
Message to receive the current member id of a handle in room.
struct GNUNET_MESSENGER_MessageHeader header
Header.
Message to receive the current name of a handle.
Message to receive something from a room.
GNUNET_MESSENGER_MemberCallback callback
const struct GNUNET_MESSENGER_Contact * contact
General message to confirm interaction with a room.
struct GNUNET_MESSENGER_Handle * handle
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_ShortHashCode * contact_id
struct GNUNET_HashCode key
Message to send something into a room.
Message to update the handle (its EGO key) for a client.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
static char * get_key(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...