GNUnet 0.22.2
gnunet-service-messenger_message_kind.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27
29
31
34{
35 struct GNUNET_MESSENGER_Message *message;
36
37 if (! service)
38 return NULL;
39
41
42 if (! message)
43 return NULL;
44
46
47 return message;
48}
49
50
53{
54 struct GNUNET_MESSENGER_Message *message;
55
56 if (! service)
57 return NULL;
58
60
61 if (! message)
62 return NULL;
63
65 &(message->body.peer.peer)))
66 return message;
67 else
68 {
69 destroy_message (message);
70 return NULL;
71 }
72}
73
74
77{
78 struct GNUNET_MESSENGER_Message *message;
79
80 if (! peer)
81 return NULL;
82
84
85 if (! message)
86 {
87 return NULL;
88 }
89
90 GNUNET_memcpy (&(message->body.miss.peer), peer, sizeof(struct
92
93 return message;
94}
95
96
98create_message_merge (const struct GNUNET_HashCode *previous)
99{
100 struct GNUNET_MESSENGER_Message *message;
101
102 if (! previous)
103 return NULL;
104
106
107 if (! message)
108 return NULL;
109
110 GNUNET_memcpy (&(message->body.merge.previous), previous, sizeof(struct
112
113 return message;
114}
115
116
119{
120 struct GNUNET_MESSENGER_Message *message;
121
122 if (! room)
123 return NULL;
124
126
127 if (! message)
128 return NULL;
129
132
133 return message;
134}
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_MESSENGER_Message * create_message_connection(const struct GNUNET_MESSENGER_SrvRoom *room)
Creates and allocates a new connection message containing the amount of the peer's connections in a g...
struct GNUNET_MESSENGER_Message * create_message_info(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new info message containing the hosts service peer identity and version.
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
struct GNUNET_MESSENGER_Message * create_message_peer(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
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 th...
uint32_t get_srv_room_amount_of_tunnels(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the amount of active tunnels of a given room.
uint32_t get_srv_room_connection_flags(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns connection flags about connection information of a given room and the service managing it.
enum GNUNET_GenericReturnValue get_service_peer_identity(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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageConnection connection
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_MESSENGER_MessageInfo info
uint32_t amount
The amount of connections of a peer.
uint32_t flags
The flags about the connections of a peer.
uint32_t messenger_version
The version of GNUnet Messenger API.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_MESSENGER_MessageBody body
Body.
The identity of the host (wraps the signing key of the peer).