diff options
Diffstat (limited to 'src/include/gnunet_messenger_service.h')
-rw-r--r-- | src/include/gnunet_messenger_service.h | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index 5f4207d2f..475f8e32e 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -42,7 +42,6 @@ extern "C" { | |||
42 | #include "gnunet_common.h" | 42 | #include "gnunet_common.h" |
43 | #include "gnunet_configuration_lib.h" | 43 | #include "gnunet_configuration_lib.h" |
44 | #include "gnunet_identity_service.h" | 44 | #include "gnunet_identity_service.h" |
45 | #include "gnunet_protocols.h" | ||
46 | #include "gnunet_scheduler_lib.h" | 45 | #include "gnunet_scheduler_lib.h" |
47 | #include "gnunet_time_lib.h" | 46 | #include "gnunet_time_lib.h" |
48 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
@@ -50,9 +49,9 @@ extern "C" { | |||
50 | /** | 49 | /** |
51 | * Version number of GNUnet Messenger API. | 50 | * Version number of GNUnet Messenger API. |
52 | * | 51 | * |
53 | * Current version of the Messenger: 0.2 | 52 | * Current version of the Messenger: 0.3 |
54 | */ | 53 | */ |
55 | #define GNUNET_MESSENGER_VERSION 0x00000002 | 54 | #define GNUNET_MESSENGER_VERSION 0x00000003 |
56 | 55 | ||
57 | /** | 56 | /** |
58 | * Identifier of GNUnet MESSENGER Service. | 57 | * Identifier of GNUnet MESSENGER Service. |
@@ -256,11 +255,6 @@ struct GNUNET_MESSENGER_MessageHeader | |||
256 | struct GNUNET_MESSENGER_MessageInfo | 255 | struct GNUNET_MESSENGER_MessageInfo |
257 | { | 256 | { |
258 | /** | 257 | /** |
259 | * The senders key to verify its signatures. | ||
260 | */ | ||
261 | struct GNUNET_IDENTITY_PublicKey host_key; | ||
262 | |||
263 | /** | ||
264 | * The version of GNUnet Messenger API. | 258 | * The version of GNUnet Messenger API. |
265 | * | 259 | * |
266 | * The sixteen lower bits represent the lower version number while the sixteen higher bits | 260 | * The sixteen lower bits represent the lower version number while the sixteen higher bits |
@@ -462,6 +456,10 @@ struct GNUNET_MESSENGER_MessageFile | |||
462 | */ | 456 | */ |
463 | struct GNUNET_MESSENGER_MessagePrivate | 457 | struct GNUNET_MESSENGER_MessagePrivate |
464 | { | 458 | { |
459 | /** | ||
460 | * The ECDH key to decrypt the message. | ||
461 | */ | ||
462 | struct GNUNET_CRYPTO_EcdhePublicKey key; | ||
465 | 463 | ||
466 | /** | 464 | /** |
467 | * The length of the encrypted message. | 465 | * The length of the encrypted message. |
@@ -554,18 +552,12 @@ enum GNUNET_MESSENGER_MessageFlags | |||
554 | * The private flag. The flag indicates that the message was privately encrypted. | 552 | * The private flag. The flag indicates that the message was privately encrypted. |
555 | */ | 553 | */ |
556 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, | 554 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, |
557 | }; | ||
558 | 555 | ||
559 | /** | 556 | /** |
560 | * Method called whenever the EGO of a <i>handle</i> changes or if the first connection fails | 557 | * The peer flag. The flag indicates that the message was sent by a peer and not a member. |
561 | * to load a valid EGO and the anonymous key pair will be used instead. | 558 | */ |
562 | * | 559 | GNUNET_MESSENGER_FLAG_PEER = 4, |
563 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect | 560 | }; |
564 | * @param[in/out] handle Messenger handle | ||
565 | */ | ||
566 | typedef void | ||
567 | (*GNUNET_MESSENGER_IdentityCallback) (void *cls, | ||
568 | struct GNUNET_MESSENGER_Handle *handle); | ||
569 | 561 | ||
570 | /** | 562 | /** |
571 | * Method called whenever a message is sent or received from a <i>room</i>. | 563 | * Method called whenever a message is sent or received from a <i>room</i>. |
@@ -602,13 +594,12 @@ typedef int | |||
602 | const struct GNUNET_MESSENGER_Contact *contact); | 594 | const struct GNUNET_MESSENGER_Contact *contact); |
603 | 595 | ||
604 | /** | 596 | /** |
605 | * Set up a handle for the messenger related functions and connects to all necessary services. It will look up the ego | 597 | * Set up a handle for the messenger related functions and connects to all necessary services. It will use the |
606 | * key identified by its <i>name</i> and use it for signing all messages from the handle. | 598 | * a custom name in combination of a private key provided for signing all messages from the handle. |
607 | * | 599 | * |
608 | * @param[in] cfg Configuration to use | 600 | * @param[in] cfg Configuration to use |
609 | * @param[in] name Name to look up an ego or NULL to stay anonymous | 601 | * @param[in] name Name or NULL |
610 | * @param[in] identity_callback Function called when the EGO of the handle changes | 602 | * @param[in] key Private key or NULL to stay anonymous |
611 | * @param[in,out] identity_cls Closure for the <i>identity_callback</i> handler | ||
612 | * @param[in] msg_callback Function called when a new message is sent or received | 603 | * @param[in] msg_callback Function called when a new message is sent or received |
613 | * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler | 604 | * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler |
614 | * @return Messenger handle to use, NULL on error | 605 | * @return Messenger handle to use, NULL on error |
@@ -616,26 +607,11 @@ typedef int | |||
616 | struct GNUNET_MESSENGER_Handle* | 607 | struct GNUNET_MESSENGER_Handle* |
617 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 608 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
618 | const char *name, | 609 | const char *name, |
619 | GNUNET_MESSENGER_IdentityCallback identity_callback, | 610 | const struct GNUNET_IDENTITY_PrivateKey *key, |
620 | void *identity_cls, | ||
621 | GNUNET_MESSENGER_MessageCallback msg_callback, | 611 | GNUNET_MESSENGER_MessageCallback msg_callback, |
622 | void *msg_cls); | 612 | void *msg_cls); |
623 | 613 | ||
624 | /** | 614 | /** |
625 | * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All | ||
626 | * participated rooms get informed about the key renewal. The handle requires a set name for this function to work and | ||
627 | * it needs to be unused by other egos. | ||
628 | * | ||
629 | * Keep in mind that this will fully delete the old ego key (if any is used) even if any other service wants to use it | ||
630 | * as default. | ||
631 | * | ||
632 | * @param[in,out] handle Messenger handle to use | ||
633 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
634 | */ | ||
635 | int | ||
636 | GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle); | ||
637 | |||
638 | /** | ||
639 | * Disconnect all of the messengers used services and clears up its used memory. | 615 | * Disconnect all of the messengers used services and clears up its used memory. |
640 | * | 616 | * |
641 | * @param[in,out] handle Messenger handle to use | 617 | * @param[in,out] handle Messenger handle to use |
@@ -653,9 +629,8 @@ const char* | |||
653 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); | 629 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); |
654 | 630 | ||
655 | /** | 631 | /** |
656 | * Set the name for the messenger. This will rename the currently used ego and move all stored files related to the current | 632 | * Set the name for the messenger handle and sends messages renaming your contact in currently |
657 | * name to its new directory. If anything fails during this process the function returns #GNUNET_NO and the name for | 633 | * open rooms. |
658 | * the messenger won't change as specified. | ||
659 | * | 634 | * |
660 | * @param[in,out] handle Messenger handle to use | 635 | * @param[in,out] handle Messenger handle to use |
661 | * @param[in] name Name for the messenger to change to | 636 | * @param[in] name Name for the messenger to change to |
@@ -669,12 +644,25 @@ GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, | |||
669 | * Get the public key used by the messenger or NULL if the anonymous key was used. | 644 | * Get the public key used by the messenger or NULL if the anonymous key was used. |
670 | * | 645 | * |
671 | * @param[in] handle Messenger handle to use | 646 | * @param[in] handle Messenger handle to use |
672 | * @return Used ego's public key or NULL | 647 | * @return Used public key or NULL |
673 | */ | 648 | */ |
674 | const struct GNUNET_IDENTITY_PublicKey* | 649 | const struct GNUNET_IDENTITY_PublicKey* |
675 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | 650 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); |
676 | 651 | ||
677 | /** | 652 | /** |
653 | * Set the private key used by the messenger or NULL if the anonymous key should be | ||
654 | * used instead. The currently used key will be replaced and the change will get signed | ||
655 | * accordingly to be verified by all contacts. | ||
656 | * | ||
657 | * @param[in,out] handle Messenger handle to use | ||
658 | * @param[in] key Private key to change to or NULL | ||
659 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | ||
660 | */ | ||
661 | int | ||
662 | GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, | ||
663 | const struct GNUNET_IDENTITY_PrivateKey *key); | ||
664 | |||
665 | /** | ||
678 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet | 666 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet |
679 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. | 667 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. |
680 | * | 668 | * |
@@ -781,7 +769,7 @@ GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contac | |||
781 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. | 769 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. |
782 | * | 770 | * |
783 | * @param[in] contact Contact handle | 771 | * @param[in] contact Contact handle |
784 | * @return Public key of the ego used by <i>contact</i> or NULL | 772 | * @return Public key used by <i>contact</i> or NULL |
785 | */ | 773 | */ |
786 | const struct GNUNET_IDENTITY_PublicKey* | 774 | const struct GNUNET_IDENTITY_PublicKey* |
787 | GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact); | 775 | GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact); |
@@ -801,12 +789,12 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact | |||
801 | * Sending a message to all members in a given room can be done by providing NULL as contact. | 789 | * Sending a message to all members in a given room can be done by providing NULL as contact. |
802 | * | 790 | * |
803 | * @param[in,out] room Room handle | 791 | * @param[in,out] room Room handle |
804 | * @param[in] message New message to send | 792 | * @param[in,out] message New message to send |
805 | * @param[in] contact Contact or NULL | 793 | * @param[in] contact Contact or NULL |
806 | */ | 794 | */ |
807 | void | 795 | void |
808 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, | 796 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, |
809 | const struct GNUNET_MESSENGER_Message *message, | 797 | struct GNUNET_MESSENGER_Message *message, |
810 | const struct GNUNET_MESSENGER_Contact* contact); | 798 | const struct GNUNET_MESSENGER_Contact* contact); |
811 | 799 | ||
812 | /** | 800 | /** |