GNUnet  0.19.4
gnunet_messenger_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2020--2022 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  */
32 #ifndef GNUNET_MESSENGER_SERVICE_H
33 #define GNUNET_MESSENGER_SERVICE_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #if 0 /* keep Emacsens' auto-indent happy */
38 }
39 #endif
40 #endif
41 
42 #include "gnunet_common.h"
45 #include "gnunet_protocols.h"
46 #include "gnunet_scheduler_lib.h"
47 #include "gnunet_time_lib.h"
48 #include "gnunet_util_lib.h"
49 
55 #define GNUNET_MESSENGER_VERSION 0x00000001
56 
60 #define GNUNET_MESSENGER_SERVICE_NAME "messenger"
61 
66 
71 
76 
78 
84 {
89 
93  struct GNUNET_HashCode key;
94 };
95 
97 
99 
105 {
109  char name [256];
110 
114  uint32_t flags;
115 };
116 
118 
123 {
128 
133 
138 
143 
148 
153 
158 
163 
168 
173 
178 
183 
188 
193 
198 
203 };
204 
205 #define GNUNET_MESSENGER_KIND_MAX (GNUNET_MESSENGER_KIND_DELETE)
206 
213 const char*
215 
223 {
228 
233 
238 
242  struct GNUNET_HashCode previous;
243 
248 };
249 
257 {
262 
271 };
272 
280 {
285 };
286 
294 {
295 };
296 
304 {
308  char *name;
309 };
310 
318 {
323 };
324 
332 {
336  struct GNUNET_PeerIdentity peer;
337 };
338 
346 {
350  struct GNUNET_ShortHashCode id;
351 };
352 
360 {
364  struct GNUNET_PeerIdentity peer;
365 };
366 
374 {
378  struct GNUNET_HashCode previous;
379 };
380 
388 {
392  struct GNUNET_HashCode hash;
393 };
394 
402 {
406  struct GNUNET_PeerIdentity door;
407 
411  struct GNUNET_HashCode key;
412 };
413 
421 {
425  char *text;
426 };
427 
435 {
440 
444  struct GNUNET_HashCode hash;
445 
449  char name[NAME_MAX];
450 
454  char *uri;
455 };
456 
464 {
469 
473  uint16_t length;
474 
478  char *data;
479 };
480 
488 {
492  struct GNUNET_HashCode hash;
493 
498 };
499 
504 {
505  union
506  {
522  };
523 };
524 
529 {
534 
539 };
540 
546 {
551 
556 
561 };
562 
570 typedef void
573 
587 typedef void
589  struct GNUNET_MESSENGER_Room *room,
590  const struct GNUNET_MESSENGER_Contact *sender,
591  const struct GNUNET_MESSENGER_Message *message,
592  const struct GNUNET_HashCode *hash,
593  enum GNUNET_MESSENGER_MessageFlags flags);
594 
603 typedef int
604 (*GNUNET_MESSENGER_MemberCallback) (void* cls,
605  struct GNUNET_MESSENGER_Room *room,
606  const struct GNUNET_MESSENGER_Contact *contact);
607 
622  const char *name,
624  void *identity_cls,
626  void *msg_cls);
627 
639 int
641 
647 void
649 
656 const char*
658 
668 int
670  const char *name);
671 
678 const struct GNUNET_IDENTITY_PublicKey*
680 
697 struct GNUNET_MESSENGER_Room*
699  const struct GNUNET_HashCode *key);
700 
719 struct GNUNET_MESSENGER_Room*
721  const struct GNUNET_PeerIdentity *door,
722  const struct GNUNET_HashCode *key);
723 
733 void
735 
747 int
749  const struct GNUNET_MESSENGER_Contact *contact,
751  void *cls);
752 
759 const struct GNUNET_HashCode*
761 
771 const struct GNUNET_MESSENGER_Contact*
773  const struct GNUNET_HashCode *hash);
774 
781 const char*
783 
790 const struct GNUNET_IDENTITY_PublicKey*
792 
811 void
813  const struct GNUNET_MESSENGER_Message *message,
814  const struct GNUNET_MESSENGER_Contact* contact);
815 
823 const struct GNUNET_MESSENGER_Message*
825  const struct GNUNET_HashCode *hash);
826 
837 int
840  void* cls);
841 
842 #if 0 /* keep Emacsens' auto-indent happy */
843 {
844 #endif
845 #ifdef __cplusplus
846 }
847 #endif
848 
849 #endif //GNUNET_MESSENGER_SERVICE_H
850 /* end of group */
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Configuration API.
Identity service; implements identity management for GNUnet.
Constants for network protocols.
API to schedule computations using continuation passing style.
Functions related to time.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
const char * GNUNET_MESSENGER_get_name(const struct GNUNET_MESSENGER_Handle *handle)
Get the name (if specified, otherwise NULL) used by the messenger.
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_enter_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Enter a room to send and receive messages through a door opened using GNUNET_MESSENGER_open_room.
void(* GNUNET_MESSENGER_IdentityCallback)(void *cls, struct GNUNET_MESSENGER_Handle *handle)
Method called whenever the EGO of a handle changes or if the first connection fails to load a valid E...
int GNUNET_MESSENGER_iterate_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room and calls a selected callback for each of them with a pr...
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_open_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Open a room to send and receive messages.
int GNUNET_MESSENGER_find_rooms(const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Searches for a specific contact in a given room and calls a selected callback with a given closure fo...
GNUNET_MESSENGER_MessageKind
Enum for the different supported kinds of messages.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling Compatible flags can be OR'ed togethe...
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_contact_get_key(const struct GNUNET_MESSENGER_Contact *contact)
Get the public key used by the contact or NULL if the anonymous key was used.
int(* GNUNET_MESSENGER_MemberCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Method called for each member in a room during iteration.
struct GNUNET_MESSENGER_Handle * GNUNET_MESSENGER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Set up a handle for the messenger related functions and connects to all necessary services.
int GNUNET_MESSENGER_update(struct GNUNET_MESSENGER_Handle *handle)
Update a handle of the messenger to use a different ego key and replace the old one with a newly gene...
const char * GNUNET_MESSENGER_contact_get_name(const struct GNUNET_MESSENGER_Contact *contact)
Get the name used by the contact.
const struct GNUNET_IDENTITY_PublicKey * GNUNET_MESSENGER_get_key(const struct GNUNET_MESSENGER_Handle *handle)
Get the public key used by the messenger or NULL if the anonymous key was used.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:36
const struct GNUNET_MESSENGER_Contact * GNUNET_MESSENGER_get_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Get the contact of a member in a room which sent a specific message identified with a given hash.
void GNUNET_MESSENGER_disconnect(struct GNUNET_MESSENGER_Handle *handle)
Disconnect all of the messengers used services and clears up its used memory.
const struct GNUNET_HashCode * GNUNET_MESSENGER_room_get_key(const struct GNUNET_MESSENGER_Room *room)
Get the key of a given room.
void GNUNET_MESSENGER_close_room(struct GNUNET_MESSENGER_Room *room)
Close a room which was entered, opened or both in various order and variety.
const struct GNUNET_MESSENGER_Message * GNUNET_MESSENGER_get_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Get the message in a room identified by its hash.
int GNUNET_MESSENGER_set_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Set the name for the messenger.
void GNUNET_MESSENGER_send_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_Contact *contact)
Send a message into a room.
void(* GNUNET_MESSENGER_MessageCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Method called whenever a message is sent or received from a room.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_FILE
The file kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
const char * name
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
A 512-bit hashcode.
An identity key as per LSD0001.
An identity signature as per LSD0001.
GNUNET_MESSENGER_MessageCallback msg_callback
GNUNET_MESSENGER_IdentityCallback identity_callback
The unified body of a GNUNET_MESSENGER_Message.
struct GNUNET_MESSENGER_MessagePrivate privacy
struct GNUNET_MESSENGER_MessageText text
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageFile file
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_MESSENGER_MessageInvite invite
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_MESSENGER_MessageInfo info
A delete message body This allows deletion of an own previous message with any custom automatic delay...
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.
char * uri
The uri of the encrypted file.
struct GNUNET_HashCode hash
The hash of the original file.
struct GNUNET_CRYPTO_SymmetricSessionKey key
The symmetric key to decrypt the file.
char name[NAME_MAX]
The name of the original file.
The header of a GNUNET_MESSENGER_Message.
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_IDENTITY_Signature signature
The signature of the senders private key.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
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_HashCode key
The hash identifying the port of the room.
struct GNUNET_PeerIdentity door
The peer identity of an open door to a room.
struct GNUNET_IDENTITY_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_IDENTITY_PublicKey key
The new public key which replaces the current senders public key.
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.
char * name
The new name which replaces the current senders name.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
uint16_t length
The length of the encrypted message.
struct GNUNET_CRYPTO_EcdhePublicKey key
The ECDH key to decrypt the message.
char * data
The data of the encrypted message.
struct GNUNET_HashCode hash
The hash of the requested message.
char * text
The containing text.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
A room details record specifies a custom name for a given room and some additional space for flags.
uint32_t flags
The flags of the room.
char name[256]
The custom name for the room.
A room entry record specifies which peer is hosting a given room and may also specify the key to ente...
struct GNUNET_PeerIdentity door
The peer identity of an open door to a room.
struct GNUNET_HashCode key
The hash identifying the port of the room.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds and in network byte order.