GNUnet 0.22.2
messenger_api_message_kind.h File Reference
Include dependency graph for messenger_api_message_kind.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct GNUNET_MESSENGER_Messagecreate_message_join (const struct GNUNET_CRYPTO_PrivateKey *key)
 Creates and allocates a new join message containing the clients public key. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_leave (void)
 Creates and allocates a new leave message. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_name (const char *name)
 Creates and allocates a new name message containing the name to change to. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_key (const struct GNUNET_CRYPTO_PrivateKey *key)
 Creates and allocates a new key message containing the public key to change to derived from its private counterpart. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_id (const struct GNUNET_ShortHashCode *unique_id)
 Creates and allocates a new id message containing the unique member id to change to. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_request (const struct GNUNET_HashCode *hash)
 Creates and allocates a new request message containing the hash of a missing message. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Creates and allocates a new delete message containing the hash of a message to delete after a specific delay. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_subscribe (const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Relative time, uint32_t flags)
 Creates and allocates a new subscribe message for a subscription of a given discourse with a specific time window and flags. More...
 

Function Documentation

◆ create_message_join()

struct GNUNET_MESSENGER_Message * create_message_join ( const struct GNUNET_CRYPTO_PrivateKey key)

Creates and allocates a new join message containing the clients public key.

(all values are stored as copy)

Parameters
[in]keyPrivate key
Returns
New message

Definition at line 31 of file messenger_api_message_kind.c.

32{
33 struct GNUNET_MESSENGER_Message *message;
34
35 if (! key)
36 return NULL;
37
39
40 if (! message)
41 return NULL;
42
44 return message;
45}
struct GNUNET_HashCode key
The key used in the DHT.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:430
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_CRYPTO_key_get_public(), GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_MessageBody::join, key, and GNUNET_MESSENGER_MessageJoin::key.

Referenced by handle_member_id().

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

◆ create_message_leave()

struct GNUNET_MESSENGER_Message * create_message_leave ( void  )

Creates and allocates a new leave message.

Returns
New message

Definition at line 49 of file messenger_api_message_kind.c.

50{
52}
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.

References create_message(), and GNUNET_MESSENGER_KIND_LEAVE.

Referenced by GNUNET_MESSENGER_close_room().

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

◆ create_message_name()

struct GNUNET_MESSENGER_Message * create_message_name ( const char *  name)

Creates and allocates a new name message containing the name to change to.

(all values are stored as copy)

Parameters
[in]nameNew name
Returns
New message

Definition at line 56 of file messenger_api_message_kind.c.

57{
58 struct GNUNET_MESSENGER_Message *message;
59
60 if (! name)
61 return NULL;
62
64
65 if (! message)
66 return NULL;
67
68 message->body.name.name = GNUNET_strdup (name);
69 return message;
70}
static char * name
Name (label) of the records to list.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_KIND_NAME, GNUNET_strdup, name, GNUNET_MESSENGER_MessageName::name, and GNUNET_MESSENGER_MessageBody::name.

Referenced by iterate_send_name_to_room().

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

◆ create_message_key()

struct GNUNET_MESSENGER_Message * create_message_key ( const struct GNUNET_CRYPTO_PrivateKey key)

Creates and allocates a new key message containing the public key to change to derived from its private counterpart.

(all values are stored as copy)

Parameters
[in]keyPrivate key
Returns
New message

Definition at line 74 of file messenger_api_message_kind.c.

75{
76 struct GNUNET_MESSENGER_Message *message;
77
78 if (! key)
79 return NULL;
80
82
83 if (! message)
84 return NULL;
85
87 return message;
88}
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_CRYPTO_PublicKey key
The new public key which replaces the current senders public key.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_CRYPTO_key_get_public(), GNUNET_MESSENGER_KIND_KEY, key, GNUNET_MESSENGER_MessageKey::key, and GNUNET_MESSENGER_MessageBody::key.

Referenced by iterate_send_key_to_room().

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

◆ create_message_id()

struct GNUNET_MESSENGER_Message * create_message_id ( const struct GNUNET_ShortHashCode unique_id)

Creates and allocates a new id message containing the unique member id to change to.

(all values are stored as copy)

Parameters
[in]unique_idUnique member id
Returns
New message

Definition at line 92 of file messenger_api_message_kind.c.

93{
94 struct GNUNET_MESSENGER_Message *message;
95
96 if (! unique_id)
97 return NULL;
98
100
101 if (! message)
102 return NULL;
103
104 GNUNET_memcpy (&(message->body.id.id), unique_id,
105 sizeof(struct GNUNET_ShortHashCode));
106
107 return message;
108}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
A 256-bit hashcode.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_MessageId::id, and GNUNET_MESSENGER_MessageBody::id.

Referenced by handle_member_id().

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

◆ create_message_request()

struct GNUNET_MESSENGER_Message * create_message_request ( const struct GNUNET_HashCode hash)

Creates and allocates a new request message containing the hash of a missing message.

(all values are stored as copy)

Parameters
[in]hashHash of message
Returns
New message

Definition at line 112 of file messenger_api_message_kind.c.

113{
114 struct GNUNET_MESSENGER_Message *message;
115
116 if (! hash)
117 return NULL;
118
119 {
120 struct GNUNET_HashCode zero;
121 memset (&zero, 0, sizeof(zero));
122
123 if (0 == GNUNET_CRYPTO_hash_cmp (hash, &zero))
124 return NULL;
125 }
126
128
129 if (! message)
130 return NULL;
131
132 GNUNET_memcpy (&(message->body.request.hash), hash, sizeof(struct
134
135 return message;
136}
static const struct GNUNET_CRYPTO_PrivateKey zero
Public key of all zeros.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:218
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_HashCode hash
The hash of the requested message.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_CRYPTO_hash_cmp(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageBody::request, and zero.

Referenced by handle_miss_message().

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

◆ create_message_delete()

struct GNUNET_MESSENGER_Message * create_message_delete ( const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Creates and allocates a new delete message containing the hash of a message to delete after a specific delay.

(all values are stored as copy)

Parameters
[in]hashHash of message
[in]delayDelay of deletion
Returns
New message

Definition at line 140 of file messenger_api_message_kind.c.

142{
143 struct GNUNET_MESSENGER_Message *message;
144
145 if (! hash)
146 return NULL;
147
149
150 if (! message)
151 return NULL;
152
153 GNUNET_memcpy (&(message->body.deletion.hash), hash, sizeof(struct
155 message->body.deletion.delay = GNUNET_TIME_relative_hton (delay);
156
157 return message;
158}
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:620
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_memcpy, GNUNET_MESSENGER_KIND_DELETE, GNUNET_TIME_relative_hton(), and GNUNET_MESSENGER_MessageDelete::hash.

Referenced by delete_room_message().

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

◆ create_message_subscribe()

struct GNUNET_MESSENGER_Message * create_message_subscribe ( const struct GNUNET_ShortHashCode discourse,
const struct GNUNET_TIME_Relative  time,
uint32_t  flags 
)

Creates and allocates a new subscribe message for a subscription of a given discourse with a specific time window and flags.

(all values are stored as copy)

Parameters
[in]discourseDiscourse
[in]timeTime of subscription
[in]flagsSubscription flags
Returns
New message

Definition at line 162 of file messenger_api_message_kind.c.

165{
166 struct GNUNET_MESSENGER_Message *message;
167
168 if (! discourse)
169 return NULL;
170
172
173 if (! message)
174 return NULL;
175
176 GNUNET_memcpy (&(message->body.subscribe.discourse), discourse,
177 sizeof (struct GNUNET_ShortHashCode));
178
180 message->body.subscribe.flags = flags;
181
182 return message;
183}
@ GNUNET_MESSENGER_KIND_SUBSCRIBE
The subscribe kind.
struct GNUNET_MESSENGER_MessageSubscribe subscribe
uint32_t flags
The flags about the subscription to a discourse.
struct GNUNET_TIME_RelativeNBO time
The time window of the subscription.
struct GNUNET_ShortHashCode discourse
The hash of the discourse to subscribe.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageSubscribe::flags, GNUNET_memcpy, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_TIME_relative_hton(), GNUNET_MESSENGER_MessageBody::subscribe, and GNUNET_MESSENGER_MessageSubscribe::time.

Referenced by handle_discourse_subscription().

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