51 const char *
name = ((
const char*) msg) +
sizeof(*msg);
91 const char *
name = ((
const char*) msg) +
sizeof(*msg);
190 const uint16_t full_length = ntohs (msg->
header.
size) -
sizeof(msg->
header);
192 if (full_length <
sizeof(msg->
key))
195 const uint16_t length = full_length -
sizeof(msg->
key);
196 const char *buffer = ((
const char*) msg) +
sizeof(*msg);
212 const char *buffer = ((
const char*) msg) +
sizeof(*msg);
214 const uint16_t length = ntohs (msg->
header.
size) -
sizeof(*msg);
283 if ((!messenger) || (!messenger->
cadet) || (!messenger->
identity))
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.
struct GNUNET_MESSENGER_MessageHeader header
Header.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_MessageHeader * msg
static void callback_client_disconnect(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
struct GNUNET_CADET_Handle * cadet
GNUnet MESSENGER service.
static void handle_room_entry(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE
void setup_handle_name(struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
Tries to set the name and EGO key of a handle initially by looking up a specific name.
static void handle_room_open(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
struct GNUNET_SERVICE_Client * client
struct GNUNET_PeerIdentity door
static int check_set_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
#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
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service)
Setup MESSENGER internals.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static int check_create(void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_MESSENGER_SrvHandle * add_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
Creates and adds a new handle to a service using a given message queue.
struct GNUNET_MESSENGER_Service * messenger
static void handle_destroy(void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
Handle to a client that is connected to a service.
int send_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle to the room using a specific key.
Message to send something into a room.
struct GNUNET_MessageHeader header
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
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 int check_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void handle_update(void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg)
Message to create a handle for a client.
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...
#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 const struct GNUNET_CONFIGURATION_Handle * config
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
static void handle_create(void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
struct GNUNET_HashCode key
static void handle_get_message(void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
struct GNUNET_MESSENGER_SrvRoom * get_service_room(struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key)
Returns the room identified by a given key for a service.
struct GNUNET_MQ_Handle * mq
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
static void handle_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
struct GNUNET_HashCode key
The key used in the DHT.
static const char * get_message(void **buf, int *len, void *cls)
void remove_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes a handle from a service and destroys it.
struct GNUNET_MQ_Envelope * env
Message to update the handle (its EGO key) for a client.
Message to destroy the handle for a client.
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
#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.
Handle to a message queue.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
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 ...
int update_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Tries to change the keypair of an EGO of a handle under the same name and informs all rooms about the...
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
struct GNUNET_HashCode key
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
Message to receive the current name of a handle.
struct GNUNET_HashCode key
GNUNET_SERVICE_MAIN(GNUNET_MESSENGER_SERVICE_NAME, GNUNET_SERVICE_OPTION_NONE, &run, &callback_client_connect, &callback_client_disconnect, NULL, GNUNET_MQ_hd_var_size(create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL), GNUNET_MQ_hd_fixed_size(update, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, struct GNUNET_MESSENGER_UpdateMessage, NULL), GNUNET_MQ_hd_fixed_size(destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL), GNUNET_MQ_hd_var_size(set_name, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, struct GNUNET_MESSENGER_NameMessage, NULL), GNUNET_MQ_hd_fixed_size(room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_fixed_size(room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_fixed_size(room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_var_size(send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL), GNUNET_MQ_hd_fixed_size(get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_RecvMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
struct GNUNET_MQ_Handle * mq
#define GNUNET_log(kind,...)
static struct MHD_Response * response
Our canonical response.
static void send_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Send a message to another peer.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
const struct GNUNET_ShortHashCode * get_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
struct GNUNET_MESSENGER_Service * create_service(const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle)
Creates and allocates a new service using a given config and a GNUnet service handle.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
static void handle_room_close(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void destroy(void *cls)
static void handle_set_name(void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
int entry_handle_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Makes a given handle a member of the room using a specific key and enters the room through a tunnel t...
Message to receive something from a room.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
General message to confirm interaction with a room.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_IDENTITY_Handle * identity
GNUnet MESSENGER service.
#define GNUNET_free(ptr)
Wrapper around free.
messenger api: client and service implementation of GNUnet MESSENGER service
static void * callback_client_connect(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)