GNUnet 0.21.1
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 if (! service)
36 return NULL;
37
40
41 if (! message)
42 return NULL;
43
45
46 return message;
47}
48
49
52{
53 if (! service)
54 return NULL;
55
58
59 if (! message)
60 return NULL;
61
63 &(message->body.peer.peer)))
64 return message;
65 else
66 {
67 destroy_message (message);
68 return NULL;
69 }
70}
71
72
75{
76 if (! peer)
77 return NULL;
78
81
82 if (! message)
83 {
84 return NULL;
85 }
86
87 GNUNET_memcpy (&(message->body.miss.peer), peer, sizeof(struct
89
90 return message;
91}
92
93
95create_message_merge (const struct GNUNET_HashCode *previous)
96{
97 if (! previous)
98 return NULL;
99
100 struct GNUNET_MESSENGER_Message *message = create_message (
102
103 if (! message)
104 return NULL;
105
106 GNUNET_memcpy (&(message->body.merge.previous), previous, sizeof(struct
108
109 return message;
110}
111
112
115{
116 if (! room)
117 return NULL;
118
119 struct GNUNET_MESSENGER_Message *message = create_message (
121
122 if (! message)
123 return NULL;
124
127
128 return message;
129}
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).