GNUnet 0.21.1
messenger_api_message_kind.c File Reference
Include dependency graph for messenger_api_message_kind.c:

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 ()
 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_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
 Creates and allocates a new invite message containing the peer identity of an entrance peer to a room using a given key as shared secret for communication. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_text (const char *text)
 Creates and allocates a new text message containing a string representing text. 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_ticket (const struct GNUNET_RECLAIM_Identifier *identifier)
 Creates and allocates a new ticket message containing the identifier of a ticket to exchange it with a given audience. 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 if (! key)
34 return NULL;
35
38
39 if (! message)
40 return NULL;
41
43 return message;
44}
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:602
@ 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 ( )

Creates and allocates a new leave message.

Returns
New message

Definition at line 48 of file messenger_api_message_kind.c.

49{
51}
@ 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 55 of file messenger_api_message_kind.c.

56{
57 if (! name)
58 return NULL;
59
62
63 if (! message)
64 return NULL;
65
66 message->body.name.name = GNUNET_strdup (name);
67 return message;
68}
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 72 of file messenger_api_message_kind.c.

73{
74 if (! key)
75 return NULL;
76
79
80 if (! message)
81 return NULL;
82
84 return message;
85}
@ 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 89 of file messenger_api_message_kind.c.

90{
91 if (! unique_id)
92 return NULL;
93
96
97 if (! message)
98 return NULL;
99
100 GNUNET_memcpy (&(message->body.id.id), unique_id, sizeof(struct
102
103 return message;
104}
#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 108 of file messenger_api_message_kind.c.

109{
110 if (! hash)
111 return NULL;
112
113 struct GNUNET_HashCode zero;
114 memset (&zero, 0, sizeof(zero));
115
116 if (0 == GNUNET_CRYPTO_hash_cmp (hash, &zero))
117 return NULL;
118
119 struct GNUNET_MESSENGER_Message *message = create_message (
121
122 if (! message)
123 return NULL;
124
125 GNUNET_memcpy (&(message->body.request.hash), hash, sizeof(struct
127
128 return message;
129}
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:221
@ 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_invite()

struct GNUNET_MESSENGER_Message * create_message_invite ( const struct GNUNET_PeerIdentity door,
const struct GNUNET_HashCode key 
)

Creates and allocates a new invite message containing the peer identity of an entrance peer to a room using a given key as shared secret for communication.

(all values are stored as copy)

Parameters
[in]doorPeer identity
[in]keyShared secret of a room
Returns
New message

Definition at line 133 of file messenger_api_message_kind.c.

135{
136 if ((! door) || (! key))
137 return NULL;
138
139 struct GNUNET_MESSENGER_Message *message = create_message (
141
142 if (! message)
143 return NULL;
144
145 GNUNET_memcpy (&(message->body.invite.door), door, sizeof(struct
147 GNUNET_memcpy (&(message->body.invite.key), key, sizeof(struct
149
150 return message;
151}
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
struct GNUNET_MESSENGER_MessageInvite invite
struct GNUNET_HashCode key
The hash identifying the port of the room.
struct GNUNET_PeerIdentity door
The peer identity of an open door to a room.
The identity of the host (wraps the signing key of the peer).

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageInvite::door, GNUNET_memcpy, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_MessageBody::invite, key, and GNUNET_MESSENGER_MessageInvite::key.

Here is the call graph for this function:

◆ create_message_text()

struct GNUNET_MESSENGER_Message * create_message_text ( const char *  text)

Creates and allocates a new text message containing a string representing text.

(all values are stored as copy)

Parameters
[in]textText
Returns
New message

Definition at line 155 of file messenger_api_message_kind.c.

156{
157 if (! text)
158 return NULL;
159
160 struct GNUNET_MESSENGER_Message *message = create_message (
162
163 if (! message)
164 return NULL;
165
166 message->body.text.text = GNUNET_strdup (text);
167 return message;
168}
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
struct GNUNET_MESSENGER_MessageText text
char * text
The containing text.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_KIND_TEXT, GNUNET_strdup, GNUNET_MESSENGER_MessageText::text, and GNUNET_MESSENGER_MessageBody::text.

Here is the call 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 172 of file messenger_api_message_kind.c.

174{
175 if (! hash)
176 return NULL;
177
178 struct GNUNET_MESSENGER_Message *message = create_message (
180
181 if (! message)
182 return NULL;
183
184 GNUNET_memcpy (&(message->body.deletion.hash), hash, sizeof(struct
186 message->body.deletion.delay = GNUNET_TIME_relative_hton (delay);
187
188 return message;
189}
@ 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:618
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_message_in_room().

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

◆ create_message_ticket()

struct GNUNET_MESSENGER_Message * create_message_ticket ( const struct GNUNET_RECLAIM_Identifier identifier)

Creates and allocates a new ticket message containing the identifier of a ticket to exchange it with a given audience.

(all values are stored as copy)

Parameters
[in]identifierIdentifier of ticket
Returns
New message

Definition at line 193 of file messenger_api_message_kind.c.

194{
195 if (! identifier)
196 return NULL;
197
198 struct GNUNET_MESSENGER_Message *message = create_message (
200
201 if (! message)
202 return NULL;
203
204 GNUNET_memcpy (&(message->body.ticket.identifier), identifier,
205 sizeof(struct GNUNET_RECLAIM_Identifier));
206
207 return message;
208}
@ GNUNET_MESSENGER_KIND_TICKET
The ticket kind.
struct GNUNET_MESSENGER_MessageTicket ticket
struct GNUNET_RECLAIM_Identifier identifier
The identifier of a RECLAIM ticket.
A reclaim identifier FIXME maybe put this in a different namespace.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_MessageTicket::identifier, and GNUNET_MESSENGER_MessageBody::ticket.

Referenced by GNUNET_MESSENGER_send_ticket().

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