gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_messenger_service.h (40481B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2020--2025 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  */
     20 /**
     21  * @author Tobias Frisch
     22  *
     23  * @file
     24  * MESSENGER service; manages decentralized chat groups
     25  *
     26  * @defgroup messenger  MESSENGER service
     27  * Instant messaging based on the CADET subsystem
     28  *
     29  * @{
     30  */
     31 
     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_util_lib.h"
     43 
     44 /**
     45  * Version number of GNUnet Messenger API.
     46  *
     47  * Current version of the Messenger: 0.6
     48  */
     49 #define GNUNET_MESSENGER_VERSION 0x00000006
     50 
     51 /**
     52  * Identifier of GNUnet MESSENGER Service.
     53  */
     54 #define GNUNET_MESSENGER_SERVICE_NAME "messenger"
     55 
     56 /**
     57  * Opaque handle to the messenger
     58  */
     59 struct GNUNET_MESSENGER_Handle;
     60 
     61 /**
     62  * Opaque handle to a room
     63  */
     64 struct GNUNET_MESSENGER_Room;
     65 
     66 /**
     67  * Opaque handle to a contact
     68  */
     69 struct GNUNET_MESSENGER_Contact;
     70 
     71 GNUNET_NETWORK_STRUCT_BEGIN
     72 
     73 /**
     74  * A room key code specifies an identifier of a room and
     75  * its individual properties.
     76  *
     77  * Size: 64 bytes
     78  */
     79 struct GNUNET_MESSENGER_RoomKeyCode
     80 {
     81   uint8_t public_bit : 1;
     82   uint8_t group_bit : 1;
     83   uint8_t feed_bit : 1;
     84   uint8_t unused_bits : 5;
     85   uint8_t bits[sizeof(struct GNUNET_HashCode) - 1];  /* = 63 */
     86 };
     87 
     88 /**
     89  * A room key unifies a room key code and its 512bit hash
     90  * representation.
     91  *
     92  * Size: 64 bytes
     93  */
     94 union GNUNET_MESSENGER_RoomKey
     95 {
     96   struct GNUNET_HashCode hash;
     97   struct GNUNET_MESSENGER_RoomKeyCode code;
     98 };
     99 
    100 /**
    101  * A room entry record specifies which peer is hosting a given room and
    102  * may also specify the key to enter it.
    103  *
    104  * Record-size: 96 bytes
    105  */
    106 struct GNUNET_MESSENGER_RoomEntryRecord
    107 {
    108   /**
    109    * The peer identity of an open door to a room.
    110    */
    111   struct GNUNET_PeerIdentity door;
    112 
    113   /**
    114    * The hash identifying the port of the room.
    115    */
    116   struct GNUNET_HashCode key GNUNET_PACKED;
    117 };
    118 
    119 /**
    120  * A room details record specifies a custom name for a given room and
    121  * some additional space for flags.
    122  *
    123  * Record-size: 260 bytes
    124  */
    125 struct GNUNET_MESSENGER_RoomDetailsRecord
    126 {
    127   /**
    128    * The custom name for the room.
    129    */
    130   char name[256];
    131 
    132   /**
    133    * The flags of the room.
    134    */
    135   uint32_t flags;
    136 };
    137 
    138 /**
    139  * An epoch identifier code specifies an epoch or group key inside
    140  * a room and it provides the information about its group size.
    141  *
    142  * Size: 32 bytes
    143  */
    144 struct GNUNET_MESSENGER_EpochIdentifierCode
    145 {
    146   uint8_t group_bit : 1;
    147   uint8_t level_bits : 7;
    148   uint8_t bits[sizeof(struct GNUNET_ShortHashCode) - 1];  /* = 31 */
    149 };
    150 
    151 /**
    152  * An epoch identifier unifies an epoch identifier code and its
    153  * 256bit hash representation.
    154  *
    155  * Size: 32 bytes
    156  */
    157 union GNUNET_MESSENGER_EpochIdentifier
    158 {
    159   struct GNUNET_ShortHashCode hash;
    160   struct GNUNET_MESSENGER_EpochIdentifierCode code;
    161 };
    162 
    163 /**
    164  * A room epoch key record specifies an epoch key for a given room
    165  * that can be identified via a given key to enter it and an epoch
    166  * identifier.
    167  *
    168  * Record-size: 228
    169  */
    170 struct GNUNET_MESSENGER_RoomEpochKeyRecord
    171 {
    172   /**
    173    * The hash identifying the port of the room.
    174    */
    175   struct GNUNET_HashCode key GNUNET_PACKED;
    176 
    177   /**
    178    * The hash identifying the epoch.
    179    */
    180   struct GNUNET_HashCode hash GNUNET_PACKED;
    181 
    182   /**
    183    * The short hash identifying the epoch or group key.
    184    */
    185   struct GNUNET_ShortHashCode identifier GNUNET_PACKED;
    186 
    187   /**
    188    * The shared epoch or group key in the room.
    189    */
    190   struct GNUNET_CRYPTO_SymmetricSessionKey shared_key;
    191 
    192   /**
    193    * The flags of the epoch or group key.
    194    */
    195   uint32_t flags;
    196 };
    197 
    198 #define GNUNET_MESSENGER_EPOCH_NONCE_BYTES \
    199         sizeof (struct GNUNET_ShortHashCode)
    200 
    201 /**
    202  * Struct to store a unique epoch nonce for message data encryption.
    203  *
    204  * Size: 32 bytes
    205  */
    206 struct GNUNET_MESSENGER_EpochNonceData
    207 {
    208   uint8_t nonce[GNUNET_MESSENGER_EPOCH_NONCE_BYTES];
    209 };
    210 
    211 /**
    212  * An epoch nonce unifies the epoch nonce data and its
    213  * 256bit hash representation.
    214  *
    215  * Size: 32 bytes
    216  */
    217 union GNUNET_MESSENGER_EpochNonce
    218 {
    219   struct GNUNET_ShortHashCode hash;
    220   struct GNUNET_MESSENGER_EpochNonceData data;
    221 };
    222 
    223 GNUNET_NETWORK_STRUCT_END
    224 
    225 /**
    226  * Enum for the different supported kinds of messages
    227  */
    228 enum GNUNET_MESSENGER_MessageKind
    229 {
    230   /**
    231    * The info kind. The message contains a #GNUNET_MESSENGER_MessageInfo body.
    232    */
    233   GNUNET_MESSENGER_KIND_INFO = 1,
    234 
    235   /**
    236      * The join kind. The message contains a #GNUNET_MESSENGER_MessageJoin body.
    237      */
    238   GNUNET_MESSENGER_KIND_JOIN = 2,
    239 
    240   /**
    241      * The leave kind. The message contains a #GNUNET_MESSENGER_MessageLeave body.
    242      */
    243   GNUNET_MESSENGER_KIND_LEAVE = 3,
    244 
    245   /**
    246    * The name kind. The message contains a #GNUNET_MESSENGER_MessageName body.
    247    */
    248   GNUNET_MESSENGER_KIND_NAME = 4,
    249 
    250   /**
    251    * The key kind. The message contains a #GNUNET_MESSENGER_MessageKey body.
    252    */
    253   GNUNET_MESSENGER_KIND_KEY = 5,
    254 
    255   /**
    256    * The peer kind. The message contains a #GNUNET_MESSENGER_MessagePeer body.
    257    */
    258   GNUNET_MESSENGER_KIND_PEER = 6,
    259 
    260   /**
    261    * The id kind. The message contains a #GNUNET_MESSENGER_MessageId body.
    262    */
    263   GNUNET_MESSENGER_KIND_ID = 7,
    264 
    265   /**
    266    * The miss kind. The message contains a #GNUNET_MESSENGER_MessageMiss body.
    267    */
    268   GNUNET_MESSENGER_KIND_MISS = 8,
    269 
    270   /**
    271    * The merge kind. The message contains a #GNUNET_MESSENGER_MessageMerge body.
    272    */
    273   GNUNET_MESSENGER_KIND_MERGE = 9,
    274 
    275   /**
    276    * The request kind. The message contains a #GNUNET_MESSENGER_MessageRequest body.
    277    */
    278   GNUNET_MESSENGER_KIND_REQUEST = 10,
    279 
    280   /**
    281    * The invite kind. The message contains a #GNUNET_MESSENGER_MessageInvite body.
    282    */
    283   GNUNET_MESSENGER_KIND_INVITE = 11,
    284 
    285   /**
    286    * The text kind. The message contains a #GNUNET_MESSENGER_MessageText body.
    287    */
    288   GNUNET_MESSENGER_KIND_TEXT = 12,
    289 
    290   /**
    291    * The file kind. The message contains a #GNUNET_MESSENGER_MessageFile body.
    292    */
    293   GNUNET_MESSENGER_KIND_FILE = 13,
    294 
    295   /**
    296    * The private kind. The message contains a #GNUNET_MESSENGER_MessagePrivate body.
    297    */
    298   GNUNET_MESSENGER_KIND_PRIVATE = 14,
    299 
    300   /**
    301    * The deletion kind. The message contains a #GNUNET_MESSENGER_MessageDeletion body.
    302    */
    303   GNUNET_MESSENGER_KIND_DELETION = 15,
    304 
    305   /**
    306    * The connection kind. The message contains a #GNUNET_MESSENGER_MessageConnection body.
    307    */
    308   GNUNET_MESSENGER_KIND_CONNECTION = 16,
    309 
    310   /**
    311    * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body.
    312    */
    313   GNUNET_MESSENGER_KIND_TICKET = 17,
    314 
    315   /**
    316    * The transcript kind. The message contains a #GNUNET_MESSENGER_MessageTranscript body.
    317    */
    318   GNUNET_MESSENGER_KIND_TRANSCRIPT = 18,
    319 
    320   /**
    321    * The tag kind. The message contains a #GNUNET_MESSENGER_MessageTag body.
    322    */
    323   GNUNET_MESSENGER_KIND_TAG = 19,
    324 
    325   /**
    326    * The subscription kind. The message contains a #GNUNET_MESSENGER_MessageSubscribtion body.
    327    */
    328   GNUNET_MESSENGER_KIND_SUBSCRIBTION = 20,
    329 
    330   /**
    331    * The talk kind. The message contains a #GNUNET_MESSENGER_MessageTalk body.
    332    */
    333   GNUNET_MESSENGER_KIND_TALK = 21,
    334 
    335   /**
    336    * The announcement kind. The message contains a #GNUNET_MESSENGER_MessageAnnouncement body.
    337    */
    338   GNUNET_MESSENGER_KIND_ANNOUNCEMENT = 22,
    339 
    340   /**
    341    * The secret kind. The message contains a #GNUNET_MESSENGER_MessageSecret body.
    342    */
    343   GNUNET_MESSENGER_KIND_SECRET = 23,
    344 
    345   /**
    346    * The appeal kind. The message contains a #GNUNET_MESSENGER_MessageAppeal body.
    347    */
    348   GNUNET_MESSENGER_KIND_APPEAL = 24,
    349 
    350   /**
    351    * The access kind. The message contains a #GNUNET_MESSENGER_MessageAccess body.
    352    */
    353   GNUNET_MESSENGER_KIND_ACCESS = 25,
    354 
    355   /**
    356    * The revolution kind. The message contains a #GNUNET_MESSENGER_MessageRevolution body.
    357    */
    358   GNUNET_MESSENGER_KIND_REVOLUTION = 26,
    359 
    360   /**
    361    * The group kind. The message contains a #GNUNET_MESSENGER_MessageGroup body.
    362    */
    363   GNUNET_MESSENGER_KIND_GROUP = 27,
    364 
    365   /**
    366    * The authorization kind. The message contains a #GNUNET_MESSENGER_MessageAuthorization body.
    367    */
    368   GNUNET_MESSENGER_KIND_AUTHORIZATION = 28,
    369 
    370   /**
    371    * The unknown kind. The message contains an unknown body.
    372    */
    373   GNUNET_MESSENGER_KIND_UNKNOWN = 0
    374 };
    375 
    376 #define GNUNET_MESSENGER_KIND_MAX (GNUNET_MESSENGER_KIND_TALK)
    377 
    378 /**
    379  * Get the name of a message <i>kind</i>.
    380  *
    381  * @param[in] kind Kind of a message
    382  * @return Name of that kind
    383  */
    384 const char*
    385 GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind);
    386 
    387 /**
    388  * Creates a room <i>key</i> from given optional <i>input</i> string using certain
    389  * properties for this targeted room.
    390  *
    391  * @param[out] key Room key
    392  * @param[in] input Input string or NULL
    393  * @param[in] is_public Public property
    394  * @param[in] is_group Group property
    395  * @param[in] is_feed Feed property
    396  */
    397 void
    398 GNUNET_MESSENGER_create_room_key (union GNUNET_MESSENGER_RoomKey *key,
    399                                   const char *input,
    400                                   enum GNUNET_GenericReturnValue is_public,
    401                                   enum GNUNET_GenericReturnValue is_group,
    402                                   enum GNUNET_GenericReturnValue is_feed);
    403 
    404 /**
    405  * The header of a #GNUNET_MESSENGER_Message.
    406  * This allows authentication of the sender, temporal ordering and finding potentially missed messages.
    407  *
    408  * Message-header-size: 140+ bytes
    409  */
    410 struct GNUNET_MESSENGER_MessageHeader
    411 {
    412   /**
    413    * The signature of the senders private key.
    414    */
    415   struct GNUNET_CRYPTO_BlindableKeySignature signature;
    416 
    417   /**
    418    * The timestamp of the message.
    419    */
    420   struct GNUNET_TIME_AbsoluteNBO timestamp;
    421 
    422   /**
    423    * The senders id inside of the room the message was sent in.
    424    */
    425   struct GNUNET_ShortHashCode sender_id;
    426 
    427   /**
    428    * The hash of the previous message from the senders perspective.
    429    */
    430   struct GNUNET_HashCode previous;
    431 
    432   /**
    433    * The kind of the message.
    434    */
    435   enum GNUNET_MESSENGER_MessageKind kind;
    436 };
    437 
    438 /**
    439  * An info message body.
    440  * This allows ensuring member ids are unique and this first message can be verified.
    441  *
    442  * Message-body-size: 4 bytes
    443  */
    444 struct GNUNET_MESSENGER_MessageInfo
    445 {
    446   /**
    447    * The version of GNUnet Messenger API.
    448    *
    449    * The sixteen lower bits represent the lower version number while the sixteen higher bits
    450    * represent the higher version number. A different higher version number implies incompatibility
    451    * to lower versions while differences in the lower version can still be supported potentially.
    452    */
    453   uint32_t messenger_version;
    454 };
    455 
    456 /**
    457  * A join message body.
    458  * This allows informing others about joining the room with a given key pair.
    459  *
    460  * Message-body-size: 68+ bytes
    461  */
    462 struct GNUNET_MESSENGER_MessageJoin
    463 {
    464   /**
    465    * The previous epoch the message was sent from.
    466    */
    467   struct GNUNET_HashCode epoch;
    468 
    469   /**
    470    * The senders public key to verify its signatures.
    471    */
    472   struct GNUNET_CRYPTO_BlindablePublicKey key;
    473 };
    474 
    475 /**
    476  * A leave message body.
    477  * This allows informing others about leaving the room.
    478  *
    479  * Message-body-size: 64 bytes
    480  */
    481 struct GNUNET_MESSENGER_MessageLeave
    482 {
    483   /**
    484    * The previous epoch the message was sent from.
    485    */
    486   struct GNUNET_HashCode epoch;
    487 };
    488 
    489 /**
    490  * A name message body.
    491  * This allows replacing the current name with another one.
    492  *
    493  * Message-body-size: 0+ bytes
    494  */
    495 struct GNUNET_MESSENGER_MessageName
    496 {
    497   /**
    498    * The new name which replaces the current senders name.
    499    */
    500   char *name;
    501 };
    502 
    503 /**
    504  * A key message body.
    505  * This allows replacing the current key pair with another one.
    506  *
    507  * Message-body-size: 4+ bytes
    508  */
    509 struct GNUNET_MESSENGER_MessageKey
    510 {
    511   /**
    512    * The new public key which replaces the current senders public key.
    513    */
    514   struct GNUNET_CRYPTO_BlindablePublicKey key;
    515 };
    516 
    517 /**
    518  * A peer message body.
    519  * This allows informing others to open a peer as a door to the current room.
    520  *
    521  * Message-body-size: 32 bytes
    522  */
    523 struct GNUNET_MESSENGER_MessagePeer
    524 {
    525   /**
    526    * The peer identity of the sender opening a room.
    527    */
    528   struct GNUNET_PeerIdentity peer;
    529 };
    530 
    531 /**
    532  * An id message body.
    533  * This allows replacing the member id with a newly unique generated one.
    534  *
    535  * Message-body-size: 32 bytes
    536  */
    537 struct GNUNET_MESSENGER_MessageId
    538 {
    539   /**
    540    * The new id which will replace the senders id in a room.
    541    */
    542   struct GNUNET_ShortHashCode id;
    543 };
    544 
    545 /**
    546  * A miss message body.
    547  * This allows informing others about a disconnection of any door.
    548  *
    549  * Message-body-size: 32 bytes
    550  */
    551 struct GNUNET_MESSENGER_MessageMiss
    552 {
    553   /**
    554    * The peer identity of a disconnected door to a room.
    555    */
    556   struct GNUNET_PeerIdentity peer;
    557 };
    558 
    559 /**
    560  * A merge message body.
    561  * This allows merging message history branches together.
    562  *
    563  * Message-body-size: 192 bytes
    564  */
    565 struct GNUNET_MESSENGER_MessageMerge
    566 {
    567   /**
    568    * The previous epochs the message was sent from.
    569    */
    570   struct GNUNET_HashCode epochs[2];
    571 
    572   /**
    573    * The hash of a second previous message.
    574    */
    575   struct GNUNET_HashCode previous;
    576 };
    577 
    578 /**
    579  * A request message body.
    580  * This allows requesting the content of a specific message which is currently missing.
    581  *
    582  * Message-body-size: 64 bytes
    583  */
    584 struct GNUNET_MESSENGER_MessageRequest
    585 {
    586   /**
    587    * The hash of the requested message.
    588    */
    589   struct GNUNET_HashCode hash;
    590 };
    591 
    592 /**
    593  * An invite message body.
    594  * This allows sharing information about other rooms in form of an invitation.
    595  *
    596  * Message-body-size: 96 bytes
    597  */
    598 struct GNUNET_MESSENGER_MessageInvite
    599 {
    600   /**
    601    * The peer identity of an open door to a room.
    602    */
    603   struct GNUNET_PeerIdentity door;
    604 
    605   /**
    606    * The hash identifying the port of the room.
    607    */
    608   union GNUNET_MESSENGER_RoomKey key;
    609 };
    610 
    611 /**
    612  * A text message body.
    613  * This allows general communication in text form.
    614  *
    615  * Message-body-size: 0+ bytes
    616  */
    617 struct GNUNET_MESSENGER_MessageText
    618 {
    619   /**
    620    * The containing text.
    621    */
    622   char *text;
    623 };
    624 
    625 /**
    626  * A file message body.
    627  * This allows sending necessary details about an uploaded encrypted file to allow access to it.
    628  *
    629  * Message-body-size: 383+ bytes
    630  */
    631 struct GNUNET_MESSENGER_MessageFile
    632 {
    633   /**
    634    * The symmetric key to decrypt the file.
    635    */
    636   struct GNUNET_CRYPTO_SymmetricSessionKey key;
    637 
    638   /**
    639    * The hash of the original file.
    640    */
    641   struct GNUNET_HashCode hash;
    642 
    643   /**
    644    * The name of the original file.
    645    */
    646   char name[NAME_MAX];
    647 
    648   /**
    649    * The uri of the encrypted file.
    650    */
    651   char *uri;
    652 };
    653 
    654 /**
    655  * A private message body.
    656  * This allows to encapsulate any message to be encrypted for only one specific member to receive in a room.
    657  *
    658  * Message-body-size: 0+ bytes
    659  */
    660 struct GNUNET_MESSENGER_MessagePrivate
    661 {
    662   /**
    663    * The length of the encrypted message.
    664    */
    665   uint16_t length;
    666 
    667   /**
    668    * The data of the encrypted message.
    669    */
    670   char *data;
    671 };
    672 
    673 /**
    674  * A deletion message body
    675  * This allows deletion of an own previous message with any custom automatic delay.
    676  *
    677  * Message-body-size: 72 bytes
    678  */
    679 struct GNUNET_MESSENGER_MessageDeletion
    680 {
    681   /**
    682    * The hash of the message to delete.
    683    */
    684   struct GNUNET_HashCode hash;
    685 
    686   /**
    687    * The delay of the delete operation to get processed.
    688    */
    689   struct GNUNET_TIME_RelativeNBO delay;
    690 };
    691 
    692 /**
    693  * A connection message body
    694  * This allows to tell others about connection information about a peer.
    695  *
    696  * Message-body-size: 8 bytes
    697  */
    698 struct GNUNET_MESSENGER_MessageConnection
    699 {
    700   /**
    701    * The amount of connections of a peer.
    702    */
    703   uint32_t amount;
    704 
    705   /**
    706    * The flags about the connections of a peer.
    707    */
    708   uint32_t flags;
    709 };
    710 
    711 /**
    712  * A ticket message body
    713  * This allows to exchange ticket identifiers with an audience.
    714  *
    715  * Message-body-size: 0+ bytes
    716  */
    717 struct GNUNET_MESSENGER_MessageTicket
    718 {
    719   /**
    720    * The identifier of a ticket.
    721    */
    722   char *identifier;
    723 };
    724 
    725 /**
    726  * A transcript message body
    727  * This allows reading the content of a sent private message.
    728  *
    729  * Message-body-size: 68+ bytes
    730  */
    731 struct GNUNET_MESSENGER_MessageTranscript
    732 {
    733   /**
    734    * The hash of the original message.
    735    */
    736   struct GNUNET_HashCode hash;
    737 
    738   /**
    739    * The key from the recipient of the original message.
    740    */
    741   struct GNUNET_CRYPTO_BlindablePublicKey key;
    742 
    743   /**
    744    * The length of the transcribed message.
    745    */
    746   uint16_t length;
    747 
    748   /**
    749    * The data of the transcribed message.
    750    */
    751   char *data;
    752 };
    753 
    754 /**
    755  * A tag message body
    756  * This allows tagging a message with a custom tag.
    757  *
    758  * Message-body-size: 64+ bytes
    759  */
    760 struct GNUNET_MESSENGER_MessageTag
    761 {
    762   /**
    763    * The hash of the message to tag.
    764    */
    765   struct GNUNET_HashCode hash;
    766 
    767   /**
    768    * The custom tag.
    769    */
    770   char *tag;
    771 };
    772 
    773 /**
    774  * A subscription message body
    775  * This allows subscribing to a discourse.
    776  *
    777  * Message-body-size: 44 bytes
    778  */
    779 struct GNUNET_MESSENGER_MessageSubscribtion
    780 {
    781   /**
    782    * The hash of the discourse to subscription.
    783    */
    784   struct GNUNET_ShortHashCode discourse;
    785 
    786   /**
    787    * The time window of the subscription.
    788    */
    789   struct GNUNET_TIME_RelativeNBO time;
    790 
    791   /**
    792    * The flags about the subscription to a discourse.
    793    */
    794   uint32_t flags;
    795 };
    796 
    797 /**
    798  * A talk message body
    799  * This allows talking in a discourse.
    800  *
    801  * Message-body-size: 32+ bytes
    802  */
    803 struct GNUNET_MESSENGER_MessageTalk
    804 {
    805   /**
    806    * The hash of the discourse to talk.
    807    */
    808   struct GNUNET_ShortHashCode discourse;
    809 
    810   /**
    811    * The length of the talk message data.
    812    */
    813   uint16_t length;
    814 
    815   /**
    816    * The data of the talk message.
    817    */
    818   char *data;
    819 };
    820 
    821 /**
    822  * An announcement message body
    823  * This allows announcing group and epoch keys.
    824  *
    825  * Message-body-size: 168 bytes
    826  */
    827 struct GNUNET_MESSENGER_MessageAnnouncement
    828 {
    829   /**
    830    * The identifier of the announcement in an epoch.
    831    */
    832   union GNUNET_MESSENGER_EpochIdentifier identifier;
    833 
    834   /**
    835    * The public key to appeal access.
    836    */
    837   struct GNUNET_CRYPTO_EcdhePublicKey key;
    838 
    839   /**
    840    * The nonce of the announcement.
    841    */
    842   union GNUNET_MESSENGER_EpochNonce nonce;
    843 
    844   /**
    845    * The timeout of the announcement.
    846    */
    847   struct GNUNET_TIME_RelativeNBO timeout;
    848 
    849   /**
    850    * The hmac of the announcement.
    851    */
    852   struct GNUNET_HashCode hmac;
    853 };
    854 
    855 #define GNUNET_MESSENGER_SECRET_IV_BYTES \
    856         sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector)
    857 
    858 /**
    859  * A secret message body
    860  * This allows exchanging encrypted messages.
    861  *
    862  * Message-body-size: 128+ bytes
    863  */
    864 struct GNUNET_MESSENGER_MessageSecret
    865 {
    866   /**
    867    * The identifier of the announcement in an epoch.
    868    */
    869   union GNUNET_MESSENGER_EpochIdentifier identifier;
    870 
    871   /**
    872    * The IV of the secret message.
    873    */
    874   uint8_t iv[GNUNET_MESSENGER_SECRET_IV_BYTES];
    875 
    876   /**
    877    * The hmac of the encrypted message.
    878    */
    879   struct GNUNET_HashCode hmac;
    880 
    881   /**
    882    * The length of the encrypted message.
    883    */
    884   uint16_t length;
    885 
    886   /**
    887    * The data of the encrypted message.
    888    */
    889   char *data;
    890 };
    891 
    892 /**
    893  * An appeal message body
    894  * This allows appealing to receive an epoch key.
    895  *
    896  * Message-body-size: 104 bytes
    897  */
    898 struct GNUNET_MESSENGER_MessageAppeal
    899 {
    900   /**
    901    * The hash of the linked announcement message event.
    902    */
    903   struct GNUNET_HashCode event;
    904 
    905   /**
    906    * The public key to receive access.
    907    */
    908   struct GNUNET_CRYPTO_EcdhePublicKey key;
    909 
    910   /**
    911    * The timeout of the appeal.
    912    */
    913   struct GNUNET_TIME_RelativeNBO timeout;
    914 };
    915 
    916 #define GNUNET_MESSENGER_ACCESS_KEY_BYTES \
    917         sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey) + \
    918         GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES
    919 
    920 /**
    921  * An access message body
    922  * This allows providing access to a group or an epoch key using a public key.
    923  *
    924  * Message-body-size: 240 bytes
    925  */
    926 struct GNUNET_MESSENGER_MessageAccess
    927 {
    928   /**
    929    * The hash of the linked announcement or group message event.
    930    */
    931   struct GNUNET_HashCode event;
    932 
    933   /**
    934    * The encrypted group or epoch key.
    935    */
    936   uint8_t key[GNUNET_MESSENGER_ACCESS_KEY_BYTES];
    937 
    938   /**
    939    * The hmac of the access.
    940    */
    941   struct GNUNET_HashCode hmac;
    942 };
    943 
    944 /**
    945  * A revolution message body
    946  * This allows revolutionizing a group or epoch.
    947  *
    948  * Message-body-size: 128 bytes
    949  */
    950 struct GNUNET_MESSENGER_MessageRevolution
    951 {
    952   /**
    953    * The identifier of the announcement in an epoch.
    954    */
    955   union GNUNET_MESSENGER_EpochIdentifier identifier;
    956 
    957   /**
    958    * The nonce of the revolution.
    959    */
    960   union GNUNET_MESSENGER_EpochNonce nonce;
    961 
    962   /**
    963    * The hmac of the revolution.
    964    */
    965   struct GNUNET_HashCode hmac;
    966 };
    967 
    968 /**
    969  * A group message body
    970  * This allows forming an epoch group.
    971  *
    972  * Message-body-size: 168 bytes
    973  */
    974 struct GNUNET_MESSENGER_MessageGroup
    975 {
    976   /**
    977    * The identifier of the group in an epoch.
    978    */
    979   union GNUNET_MESSENGER_EpochIdentifier identifier;
    980 
    981   /**
    982    * The hash of the initiator group announcement.
    983    */
    984   struct GNUNET_HashCode initiator;
    985 
    986   /**
    987    * The hash of the partner group announcement.
    988    */
    989   struct GNUNET_HashCode partner;
    990 
    991   /**
    992    * The timeout of the group formation.
    993    */
    994   struct GNUNET_TIME_RelativeNBO timeout;
    995 };
    996 
    997 #define GNUNET_MESSENGER_AUTHORIZATION_KEY_BYTES \
    998         sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey)
    999 
   1000 /**
   1001  * An authorization message body
   1002  * This allows providing access to a group or an epoch key using an established shared key.
   1003  *
   1004  * Message-body-size: 224 bytes
   1005  */
   1006 struct GNUNET_MESSENGER_MessageAuthorization
   1007 {
   1008   /**
   1009    * The identifier of the group in an epoch.
   1010    */
   1011   union GNUNET_MESSENGER_EpochIdentifier identifier;
   1012 
   1013   /**
   1014    * The hash of the linked group message event.
   1015    */
   1016   struct GNUNET_HashCode event;
   1017 
   1018   /**
   1019    * The encrypted group or epoch key.
   1020    */
   1021   uint8_t key[GNUNET_MESSENGER_AUTHORIZATION_KEY_BYTES];
   1022 
   1023   /**
   1024    * The hmac of the authorization.
   1025    */
   1026   struct GNUNET_HashCode hmac;
   1027 };
   1028 
   1029 /**
   1030  * The unified body of a #GNUNET_MESSENGER_Message.
   1031  */
   1032 struct GNUNET_MESSENGER_MessageBody
   1033 {
   1034   union
   1035   {
   1036     struct GNUNET_MESSENGER_MessageInfo info;
   1037     struct GNUNET_MESSENGER_MessageJoin join;
   1038     struct GNUNET_MESSENGER_MessageLeave leave;
   1039     struct GNUNET_MESSENGER_MessageName name;
   1040     struct GNUNET_MESSENGER_MessageKey key;
   1041     struct GNUNET_MESSENGER_MessagePeer peer;
   1042     struct GNUNET_MESSENGER_MessageId id;
   1043     struct GNUNET_MESSENGER_MessageMiss miss;
   1044     struct GNUNET_MESSENGER_MessageMerge merge;
   1045     struct GNUNET_MESSENGER_MessageRequest request;
   1046     struct GNUNET_MESSENGER_MessageInvite invite;
   1047     struct GNUNET_MESSENGER_MessageText text;
   1048     struct GNUNET_MESSENGER_MessageFile file;
   1049     struct GNUNET_MESSENGER_MessagePrivate privacy;
   1050     struct GNUNET_MESSENGER_MessageDeletion deletion;
   1051     struct GNUNET_MESSENGER_MessageConnection connection;
   1052     struct GNUNET_MESSENGER_MessageTicket ticket;
   1053     struct GNUNET_MESSENGER_MessageTranscript transcript;
   1054     struct GNUNET_MESSENGER_MessageTag tag;
   1055     struct GNUNET_MESSENGER_MessageSubscribtion subscription;
   1056     struct GNUNET_MESSENGER_MessageTalk talk;
   1057     struct GNUNET_MESSENGER_MessageAnnouncement announcement;
   1058     struct GNUNET_MESSENGER_MessageSecret secret;
   1059     struct GNUNET_MESSENGER_MessageAppeal appeal;
   1060     struct GNUNET_MESSENGER_MessageAccess access;
   1061     struct GNUNET_MESSENGER_MessageRevolution revolution;
   1062     struct GNUNET_MESSENGER_MessageGroup group;
   1063     struct GNUNET_MESSENGER_MessageAuthorization authorization;
   1064   };
   1065 };
   1066 
   1067 /**
   1068  * Struct to a message
   1069  */
   1070 struct GNUNET_MESSENGER_Message
   1071 {
   1072   /**
   1073    * Header.
   1074    */
   1075   struct GNUNET_MESSENGER_MessageHeader header;
   1076 
   1077   /**
   1078    * Body
   1079    */
   1080   struct GNUNET_MESSENGER_MessageBody body;
   1081 };
   1082 
   1083 /**
   1084  * Enum for the different supported flags used by message handling.
   1085  * Compatible flags can be OR'ed together.
   1086  */
   1087 enum GNUNET_MESSENGER_MessageFlags
   1088 {
   1089   /**
   1090    * The none flag. The flag indicates that the message is not affected by any special context.
   1091    */
   1092   GNUNET_MESSENGER_FLAG_NONE = 0,
   1093 
   1094   /**
   1095    * The sent flag. The flag indicates that the message was sent by the client.
   1096    */
   1097   GNUNET_MESSENGER_FLAG_SENT = 1,
   1098 
   1099   /**
   1100    * The private flag. The flag indicates that the message was privately encrypted.
   1101    */
   1102   GNUNET_MESSENGER_FLAG_PRIVATE = 2,
   1103 
   1104   /**
   1105    * The peer flag. The flag indicates that the message was sent by a peer and not a member.
   1106    */
   1107   GNUNET_MESSENGER_FLAG_PEER = 4,
   1108 
   1109   /**
   1110    * The recent flag. The flag indicates that the message was recently handled by the service.
   1111    */
   1112   GNUNET_MESSENGER_FLAG_RECENT = 8,
   1113 
   1114   /**
   1115    * The update flag. The flag indicates that the message was updated by the client.
   1116    */
   1117   GNUNET_MESSENGER_FLAG_UPDATE = 16,
   1118 
   1119   /**
   1120    * The delete flag. The flag indicates that the message was deleted by the service.
   1121    */
   1122   GNUNET_MESSENGER_FLAG_DELETE = 32,
   1123 
   1124   /**
   1125    * The secret flag. The flag indicates that the message was encrypted as epoch secret.
   1126    */
   1127   GNUNET_MESSENGER_FLAG_SECRET = 64,
   1128 
   1129   /**
   1130    * The member flag. The flag indicates that the message introduces a new member to the client.
   1131    */
   1132   GNUNET_MESSENGER_FLAG_MEMBER = 128,
   1133 };
   1134 
   1135 /**
   1136  * Enum for the different supported flags used to specify connection handling.
   1137  * Compatible flags can be OR'ed together.
   1138  */
   1139 enum GNUNET_MESSENGER_ConnectionFlags
   1140 {
   1141   /**
   1142    * The none flag. The flag indicates that the connection is not affected by any modifications.
   1143    */
   1144   GNUNET_MESSENGER_FLAG_CONNECTION_NONE = 0,/**< GNUNET_MESSENGER_FLAG_CONNECTION_NONE */
   1145 
   1146   /**
   1147    * The auto flag. The flag indicates that a peer will automatically handle routing.
   1148    */
   1149   GNUNET_MESSENGER_FLAG_CONNECTION_AUTO = 1,/**< GNUNET_MESSENGER_FLAG_CONNECTION_AUTO */
   1150 };
   1151 
   1152 /**
   1153  * Enum for the different supported flags used to specify subscription handling.
   1154  * Compatible flags can be OR'ed together.
   1155  */
   1156 enum GNUNET_MESSENGER_SubscriptionFlags
   1157 {
   1158   /**
   1159    * The none flag. The flag indicates that the subscription is not affected by any modifications.
   1160    */
   1161   GNUNET_MESSENGER_FLAG_SUBSCRIPTION_NONE = 0,
   1162 
   1163   /**
   1164    * The unsubscribe flag. The flag indicates that a member will unsubscribe a discourse.
   1165    */
   1166   GNUNET_MESSENGER_FLAG_SUBSCRIPTION_UNSUBSCRIBE = 1,
   1167 
   1168   /**
   1169    * The keep alive flag. The flag indicates that a member keeps a subscription alive implicitly.
   1170    */
   1171   GNUNET_MESSENGER_FLAG_SUBSCRIPTION_KEEP_ALIVE = 2,
   1172 };
   1173 
   1174 enum GNUNET_MESSENGER_EpochFlags
   1175 {
   1176   /**
   1177    * The none flag. This flag indicates that the epoch or group key is not affected by
   1178    * any modifications.
   1179    */
   1180   GNUNET_MESSENGER_FLAG_EPOCH_NONE = 0,
   1181 
   1182   /**
   1183    * The valid flag. This flag indicates whether an epoch or group key is still valid.
   1184    */
   1185   GNUNET_MESSENGER_FLAG_EPOCH_VALID = 1,
   1186 };
   1187 
   1188 /**
   1189  * Method called whenever a message is sent or received from a <i>room</i>.
   1190  *
   1191  * The <i>flags</i> will indicate with a bitmask if a message was
   1192  * received privately or if the message was sent by the client.
   1193  *
   1194  * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect
   1195  * @param[in] room Room handle
   1196  * @param[in] sender Sender of message
   1197  * @param[in] recipient Recipient of message
   1198  * @param[in] message Newly received or sent message
   1199  * @param[in] hash Hash identifying the message
   1200  * @param[in] flags Flags of the message
   1201  */
   1202 typedef void
   1203 (*GNUNET_MESSENGER_MessageCallback) (void *cls,
   1204                                      struct GNUNET_MESSENGER_Room *room,
   1205                                      const struct
   1206                                      GNUNET_MESSENGER_Contact *sender,
   1207                                      const struct
   1208                                      GNUNET_MESSENGER_Contact *recipient,
   1209                                      const struct
   1210                                      GNUNET_MESSENGER_Message *message,
   1211                                      const struct GNUNET_HashCode *hash,
   1212                                      enum GNUNET_MESSENGER_MessageFlags flags);
   1213 
   1214 /**
   1215  * Method called for each member in a <i>room</i> during iteration. If the method returns
   1216  * #GNUNET_YES the iteration continues, otherwise it will quit the iteration.
   1217  *
   1218  * @param[in/out] cls Closure from #GNUNET_MESSENGER_iterate_members
   1219  * @param[in] room Room handle
   1220  * @param[in] contact Contact handle
   1221  */
   1222 typedef enum GNUNET_GenericReturnValue
   1223 (*GNUNET_MESSENGER_MemberCallback) (void *cls,
   1224                                     struct GNUNET_MESSENGER_Room *room,
   1225                                     const struct
   1226                                     GNUNET_MESSENGER_Contact *contact);
   1227 
   1228 /**
   1229  * Set up a handle for the messenger related functions and connects to all necessary services. It will use the
   1230  * a custom name in combination of a private key provided for signing all messages from the handle.
   1231  *
   1232  * @param[in] cfg Configuration to use
   1233  * @param[in] name Name or NULL
   1234  * @param[in] key Private key or NULL to stay anonymous
   1235  * @param[in] msg_callback Function called when a new message is sent or received
   1236  * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler
   1237  * @return Messenger handle to use, NULL on error
   1238  */
   1239 struct GNUNET_MESSENGER_Handle*
   1240 GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
   1241                           const char *name,
   1242                           const struct GNUNET_CRYPTO_BlindablePrivateKey *key,
   1243                           GNUNET_MESSENGER_MessageCallback msg_callback,
   1244                           void *msg_cls);
   1245 
   1246 /**
   1247  * Disconnect all of the messengers used services and clears up its used memory.
   1248  *
   1249  * @param[in,out] handle Messenger handle to use
   1250  */
   1251 void
   1252 GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle);
   1253 
   1254 /**
   1255  * Get the name (if specified, otherwise NULL) used by the messenger.
   1256  *
   1257  * @param[in] handle Messenger handle to use
   1258  * @return Name used by the messenger or NULL
   1259  */
   1260 const char*
   1261 GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle);
   1262 
   1263 /**
   1264  * Set the name for the messenger handle and sends messages renaming your contact in currently
   1265  * open rooms.
   1266  *
   1267  * @param[in,out] handle Messenger handle to use
   1268  * @param[in] name Name for the messenger to change to
   1269  * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL
   1270  */
   1271 enum GNUNET_GenericReturnValue
   1272 GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
   1273                            const char *name);
   1274 
   1275 /**
   1276  * Get the public key used by the messenger or NULL if the anonymous key was used.
   1277  *
   1278  * @param[in] handle Messenger handle to use
   1279  * @return Used public key or NULL
   1280  */
   1281 const struct GNUNET_CRYPTO_BlindablePublicKey*
   1282 GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
   1283 
   1284 /**
   1285  * Set the private key used by the messenger or NULL if the anonymous key should be
   1286  * used instead. The currently used key will be replaced and the change will get signed
   1287  * accordingly to be verified by all contacts.
   1288  *
   1289  * @param[in,out] handle Messenger handle to use
   1290  * @param[in] key Private key to change to or NULL
   1291  * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL
   1292  */
   1293 enum GNUNET_GenericReturnValue
   1294 GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle,
   1295                           const struct GNUNET_CRYPTO_BlindablePrivateKey *key);
   1296 
   1297 /**
   1298  * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet
   1299  * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>.
   1300  *
   1301  * Notice that there can only be one room related to a specific <i>key</i>. So trying to open two rooms with the same
   1302  * <i>key</i> will result in opening the room once but returning the handle both times because the room stays open.
   1303  *
   1304  * You can also open a room after entering it through a <b>door</b> using #GNUNET_MESSENGER_enter_room. This
   1305  * will notify all entered <b>doors</b> to list you as new <b>door</b>.
   1306  *
   1307  * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. )
   1308  *
   1309  * @param[in,out] handle Messenger handle to use
   1310  * @param[in] key Hash identifying the port
   1311  * @return Room handle, NULL on error
   1312  */
   1313 struct GNUNET_MESSENGER_Room*
   1314 GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle,
   1315                             const union GNUNET_MESSENGER_RoomKey *key);
   1316 
   1317 /**
   1318  * Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room.
   1319  *
   1320  * Notice that there can only be one room related to a specific <i>key</i>. So trying to enter two rooms with the same
   1321  * <i>key</i> will result in entering the room once but returning the handle both times because the room stays entered.
   1322  * You can however enter a room through multiple <b>doors</b> in parallel which results in connecting both ends. But
   1323  * entering the room through the same <b>door</b> won't have any effect after the first time.
   1324  *
   1325  * You can also enter a room through a <b>door</b> after opening it using #GNUNET_MESSENGER_open_room. But the
   1326  * <b>door</b> may not be your own peer identity.
   1327  *
   1328  * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. )
   1329  *
   1330  * @param[in,out] handle Messenger handle to use
   1331  * @param[in] door Peer identity of an open <b>door</b>
   1332  * @param[in] key Hash identifying the port
   1333  * @return Room handle, NULL on error
   1334  */
   1335 struct GNUNET_MESSENGER_Room*
   1336 GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle,
   1337                              const struct GNUNET_PeerIdentity *door,
   1338                              const union GNUNET_MESSENGER_RoomKey *key);
   1339 
   1340 /**
   1341  * Close a <i>room</i> which was entered, opened or both in various order and variety. Closing a room will destroy all
   1342  * connections from your peer to another and the other way around.
   1343  *
   1344  * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one
   1345  * or open the room on their own. )
   1346  *
   1347  * @param[in,out] room Room handle
   1348  */
   1349 void
   1350 GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room);
   1351 
   1352 /**
   1353  * Searches for a specific <i>contact</i> in a given <i>room</i> and calls a selected <i>callback</i> with a given
   1354  * closure for each of them containing the contact as a member. The callback will receive a room matching the condition
   1355  * and the given contact. The function returns the amount of rooms iterated with the given callback.
   1356  *
   1357  * @param[in] handle Messenger handle to use
   1358  * @param[in] contact Contact handle
   1359  * @param[in] callback Function called for each room
   1360  * @param[in] cls Closure for the <i>callback</i> handler
   1361  * @return Amount of rooms iterated
   1362  */
   1363 int
   1364 GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle,
   1365                              const struct GNUNET_MESSENGER_Contact *contact,
   1366                              GNUNET_MESSENGER_MemberCallback callback,
   1367                              void *cls);
   1368 
   1369 /**
   1370  * Get the key of a given <i>room</i>.
   1371  *
   1372  * @param[in] room Room handle
   1373  * @return Hash identifying the port or NULL on failure
   1374  */
   1375 const struct GNUNET_HashCode*
   1376 GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room);
   1377 
   1378 /**
   1379  * Get the contact of a member in a <i>room</i> which sent a specific message identified with a given <i>hash</i>.
   1380  *
   1381  * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.
   1382  *
   1383  * @param[in] room Room handle
   1384  * @param[in] hash Hash identifying a message
   1385  * @return Contact handle, NULL otherwise
   1386  */
   1387 const struct GNUNET_MESSENGER_Contact*
   1388 GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room,
   1389                              const struct GNUNET_HashCode *hash);
   1390 
   1391 /**
   1392  * Get the contact of a member in a <i>room</i> which has been targeted as recipient of a specific message identified
   1393  * with a given <i>hash</i>.
   1394  *
   1395  * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.
   1396  *
   1397  * @param[in] room Room handle
   1398  * @param[in] hash Hash identifying a message
   1399  * @return Contact handle, NULL otherwise
   1400  */
   1401 const struct GNUNET_MESSENGER_Contact*
   1402 GNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room,
   1403                                 const struct GNUNET_HashCode *hash);
   1404 
   1405 /**
   1406  * Get the name used by the <i>contact</i>.
   1407  *
   1408  * @param[in] contact Contact handle
   1409  * @return Name of <i>contact</i> or NULL
   1410  */
   1411 const char*
   1412 GNUNET_MESSENGER_contact_get_name (const struct
   1413                                    GNUNET_MESSENGER_Contact *contact);
   1414 
   1415 /**
   1416  * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used.
   1417  *
   1418  * @param[in] contact Contact handle
   1419  * @return Public key used by <i>contact</i> or NULL
   1420  */
   1421 const struct GNUNET_CRYPTO_BlindablePublicKey*
   1422 GNUNET_MESSENGER_contact_get_key (const struct
   1423                                   GNUNET_MESSENGER_Contact *contact);
   1424 
   1425 /**
   1426  * Get the locally unique id of the <i>contact</i>.
   1427  *
   1428  * @param[in] contact Contact handle
   1429  * @return Locally unique contact id or zero
   1430  */
   1431 size_t
   1432 GNUNET_MESSENGER_contact_get_id (const struct
   1433                                  GNUNET_MESSENGER_Contact *contact);
   1434 
   1435 /**
   1436  * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the
   1437  * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the
   1438  * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively
   1439  * as long as the <i>message</i> is unknown to them.
   1440  *
   1441  * Notice that all messages sent and received are also stored and can be propagated to new members entering the room.
   1442  *
   1443  * If you provide a specific <i>contact</i> as receiver of the given message, the message will automatically be
   1444  * encrypted and sent as a private message (see #GNUNET_MESSENGER_MessagePrivate). Therefore the selected contact
   1445  * will be the only member receiving the actual message.
   1446  *
   1447  * Sending a message to all members in a given room can be done by providing NULL as contact.
   1448  *
   1449  * @param[in,out] room Room handle
   1450  * @param[in,out] message New message to send
   1451  * @param[in] contact Contact or NULL
   1452  */
   1453 void
   1454 GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
   1455                                const struct GNUNET_MESSENGER_Message *message,
   1456                                const struct GNUNET_MESSENGER_Contact *contact);
   1457 
   1458 /**
   1459  * Delete a message identified by its <i>hash</i> from a <i>room</i>. A deletion will be propagated to all members
   1460  * of the room as with any other sent message. Notice that a deletion will only request other members of the room
   1461  * to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored.
   1462  *
   1463  * Depending on the implementation other clients may also ignore your deletion request in other circumstances.
   1464  *
   1465  * @param[in,out] room Room handle
   1466  * @param[in] message Message to delete
   1467  * @param[in] delay Delay to delete the message
   1468  */
   1469 void
   1470 GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room,
   1471                                  const struct GNUNET_HashCode *hash,
   1472                                  const struct GNUNET_TIME_Relative delay);
   1473 
   1474 /**
   1475  * Get the message in a <i>room</i> identified by its <i>hash</i> and requests it if necessary.
   1476  *
   1477  * @param[in,out] room Room handle
   1478  * @param[in] hash Hash identifying a message
   1479  * @return Message struct or NULL if no message with that hash is known
   1480  */
   1481 const struct GNUNET_MESSENGER_Message*
   1482 GNUNET_MESSENGER_get_message (struct GNUNET_MESSENGER_Room *room,
   1483                               const struct GNUNET_HashCode *hash);
   1484 
   1485 /**
   1486  * Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i>
   1487  * for each of them with a provided closure. The callback will receive the contact of each
   1488  * member. The function returns the amount of members iterated with the given callback.
   1489  *
   1490  * @param[in] room Room handle
   1491  * @param[in] callback Function called for each member
   1492  * @param[in] cls Closure for the <i>callback</i> handler
   1493  * @return Amount of members iterated
   1494  */
   1495 int
   1496 GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
   1497                                   GNUNET_MESSENGER_MemberCallback callback,
   1498                                   void *cls);
   1499 
   1500 #if 0 /* keep Emacsens' auto-indent happy */
   1501 {
   1502 #endif
   1503 #ifdef __cplusplus
   1504 }
   1505 #endif
   1506 
   1507 #endif // GNUNET_MESSENGER_SERVICE_H
   1508 
   1509 /** @} *//* end of group */