GNUnet  0.11.x
Functions
gnunet-service-messenger_message_kind.c File Reference

GNUnet MESSENGER service. More...

#include "gnunet-service-messenger_message_kind.h"
#include "messenger_api_util.h"
Include dependency graph for gnunet-service-messenger_message_kind.c:

Go to the source code of this file.

Functions

struct GNUNET_MESSENGER_Messagecreate_message_info (const struct GNUNET_MESSENGER_Ego *ego)
 Creates and allocates a new info message containing the hosts EGO public key and a newly generated unique member id. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_join (const struct GNUNET_MESSENGER_Ego *ego)
 Creates and allocates a new join message containing the clients EGO 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_IDENTITY_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_peer (const struct GNUNET_MESSENGER_Service *service)
 Creates and allocates a new peer message containing a services peer identity. 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_miss (const struct GNUNET_PeerIdentity *peer)
 Creates and allocates a new miss message containing the missing peer identity. More...
 
struct GNUNET_MESSENGER_Messagecreate_message_merge (const struct GNUNET_HashCode *previous)
 Creates and allocates a new merge message containing the hash of a second previous message besides the regular previous message mentioned in a messages header. 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...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_message_kind.c.

Function Documentation

◆ create_message_info()

struct GNUNET_MESSENGER_Message* create_message_info ( const struct GNUNET_MESSENGER_Ego ego)

Creates and allocates a new info message containing the hosts EGO public key and a newly generated unique member id.

(all values are stored as copy)

Parameters
[in]egoEGO of the host
[in]membersMap of all assigned member ids
Returns
New message

Definition at line 31 of file gnunet-service-messenger_message_kind.c.

32 {
33  if (!ego)
34  return NULL;
35 
37 
38  if (!message)
39  return NULL;
40 
41  GNUNET_memcpy(&(message->body.info.host_key), &(ego->pub), sizeof(ego->pub));
42 
44 
45  return message;
46 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
struct GNUNET_IDENTITY_PublicKey pub
struct GNUNET_MESSENGER_MessageInfo info
uint32_t messenger_version
The version of GNUnet Messenger API.
struct GNUNET_IDENTITY_PublicKey host_key
The senders key to verify its signatures.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_VERSION, GNUNET_MESSENGER_MessageInfo::host_key, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageInfo::messenger_version, and GNUNET_MESSENGER_Ego::pub.

Referenced by recv_message_info(), and send_room_info().

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

◆ create_message_join()

struct GNUNET_MESSENGER_Message* create_message_join ( const struct GNUNET_MESSENGER_Ego ego)

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

(all values are stored as copy)

Parameters
[in]egoEGO of the client
Returns
New message

Definition at line 49 of file gnunet-service-messenger_message_kind.c.

50 {
51  if (!ego)
52  return NULL;
53 
55 
56  if (!message)
57  return NULL;
58 
59  GNUNET_memcpy(&(message->body.join.key), &(ego->pub), sizeof(ego->pub));
60 
61  return message;
62 }
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, and GNUNET_MESSENGER_Ego::pub.

Referenced by join_room().

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 65 of file gnunet-service-messenger_message_kind.c.

66 {
68 }
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.

References create_message(), and GNUNET_MESSENGER_KIND_LEAVE.

Referenced by close_service_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 71 of file gnunet-service-messenger_message_kind.c.

72 {
73  if (!name)
74  return NULL;
75 
77 
78  if (!message)
79  return NULL;
80 
81  message->body.name.name = GNUNET_strdup(name);
82  return message;
83 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
const char * name
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 callback_set_handle_name().

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_IDENTITY_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 of EGO
Returns
New message

Definition at line 86 of file gnunet-service-messenger_message_kind.c.

87 {
88  if (!key)
89  return NULL;
90 
92 
93  if (!message)
94  return NULL;
95 
97  return message;
98 }
struct GNUNET_HashCode key
The key used in the DHT.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_IDENTITY_PublicKey key
The new public key which replaces the current senders public key.

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

Referenced by set_handle_ego().

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

◆ create_message_peer()

struct GNUNET_MESSENGER_Message* create_message_peer ( const struct GNUNET_MESSENGER_Service service)

Creates and allocates a new peer message containing a services peer identity.

(all values are stored as copy)

Parameters
[in]serviceService
Returns
New message

Definition at line 101 of file gnunet-service-messenger_message_kind.c.

102 {
103  if (!service)
104  return NULL;
105 
107 
108  if (!message)
109  return NULL;
110 
112  return message;
113  else
114  {
115  destroy_message (message);
116  return NULL;
117  }
118 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
int get_service_peer_identity(const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
Tries to write the peer identity of the peer running a service on to the peer parameter.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.

References GNUNET_MESSENGER_Message::body, create_message(), destroy_message(), get_service_peer_identity(), GNUNET_MESSENGER_KIND_PEER, GNUNET_OK, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, and service.

Referenced by check_room_peer_status(), and open_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 121 of file gnunet-service-messenger_message_kind.c.

122 {
123  if (!unique_id)
124  return NULL;
125 
127 
128  if (!message)
129  return NULL;
130 
131  GNUNET_memcpy(&(message->body.id.id), unique_id, sizeof(struct GNUNET_ShortHashCode));
132 
133  return message;
134 }
@ 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 solve_room_member_collisions().

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

◆ create_message_miss()

struct GNUNET_MESSENGER_Message* create_message_miss ( const struct GNUNET_PeerIdentity peer)

Creates and allocates a new miss message containing the missing peer identity.

(all values are stored as copy)

Parameters
[in]peerMissing peer identity
Returns
New message

Definition at line 137 of file gnunet-service-messenger_message_kind.c.

138 {
139  if (!peer)
140  return NULL;
141 
143 
144  if (!message)
145  {
146  return NULL;
147  }
148 
149  GNUNET_memcpy(&(message->body.miss.peer), peer, sizeof(struct GNUNET_PeerIdentity));
150 
151  return message;
152 }
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageMiss::peer, and peer.

Referenced by callback_room_disconnect().

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

◆ create_message_merge()

struct GNUNET_MESSENGER_Message* create_message_merge ( const struct GNUNET_HashCode previous)

Creates and allocates a new merge message containing the hash of a second previous message besides the regular previous message mentioned in a messages header.

(all values are stored as copy)

Parameters
[in]previousHash of message
Returns
New message

Definition at line 155 of file gnunet-service-messenger_message_kind.c.

156 {
157  if (!previous)
158  return NULL;
159 
161 
162  if (!message)
163  return NULL;
164 
165  GNUNET_memcpy(&(message->body.merge.previous), previous, sizeof(struct GNUNET_HashCode));
166 
167  return message;
168 }
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode previous
The hash of a second previous message.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_MessageBody::merge, and GNUNET_MESSENGER_MessageMerge::previous.

Referenced by callback_room_merge(), and merge_room_last_messages().

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 171 of file gnunet-service-messenger_message_kind.c.

172 {
173  if (!hash)
174  return NULL;
175 
176  struct GNUNET_HashCode zero;
177  memset (&zero, 0, sizeof(zero));
178 
179  if (0 == GNUNET_CRYPTO_hash_cmp (hash, &zero))
180  return NULL;
181 
183 
184  if (!message)
185  return NULL;
186 
187  GNUNET_memcpy(&(message->body.request.hash), hash, sizeof(struct GNUNET_HashCode));
188 
189  return message;
190 }
static const struct GNUNET_IDENTITY_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:201
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
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 callback_found_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 193 of file gnunet-service-messenger_message_kind.c.

194 {
195  if ((!door) || (!key))
196  return NULL;
197 
199 
200  if (!message)
201  return NULL;
202 
203  GNUNET_memcpy(&(message->body.invite.door), door, sizeof(struct GNUNET_PeerIdentity));
204  GNUNET_memcpy(&(message->body.invite.key), key, sizeof(struct GNUNET_HashCode));
205 
206  return message;
207 }
@ 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.

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 210 of file gnunet-service-messenger_message_kind.c.

211 {
212  if (!text)
213  return NULL;
214 
216 
217  if (!message)
218  return NULL;
219 
220  message->body.text.text = GNUNET_strdup(text);
221  return message;
222 }
@ 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 225 of file gnunet-service-messenger_message_kind.c.

226 {
227  if (!hash)
228  return NULL;
229 
231 
232  if (!message)
233  return NULL;
234 
235  GNUNET_memcpy(&(message->body.deletion.hash), hash, sizeof(struct GNUNET_HashCode));
237 
238  return message;
239 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
@ 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:444
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, delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_memcpy, GNUNET_MESSENGER_KIND_DELETE, GNUNET_TIME_relative_hton(), and GNUNET_MESSENGER_MessageDelete::hash.

Here is the call graph for this function: