2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2007-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2017-11-14 20:21:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
2017-04-19 12:04:45 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2008-11-24 20:17:36 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-22 02:40:55 +00:00
|
|
|
#include <optional>
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
#include "transmission.h"
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/** @addtogroup peers Peers
|
|
|
|
@{ */
|
|
|
|
|
2021-10-11 21:54:16 +00:00
|
|
|
class tr_peerIo;
|
2009-05-29 19:17:12 +00:00
|
|
|
|
|
|
|
/** @brief opaque struct holding hanshake state information.
|
|
|
|
freed when the handshake is completed. */
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_handshake;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2021-10-22 02:40:55 +00:00
|
|
|
struct tr_handshake_result
|
|
|
|
{
|
|
|
|
struct tr_handshake* handshake;
|
|
|
|
tr_peerIo* io;
|
|
|
|
bool readAnythingFromPeer;
|
|
|
|
bool isConnected;
|
|
|
|
void* userData;
|
|
|
|
std::optional<tr_peer_id_t> peer_id;
|
|
|
|
};
|
|
|
|
|
2008-09-19 17:03:25 +00:00
|
|
|
/* returns true on success, false on error */
|
2021-10-22 02:40:55 +00:00
|
|
|
using tr_handshake_done_func = bool (*)(tr_handshake_result const& result);
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2021-10-22 02:40:55 +00:00
|
|
|
/** @brief create a new handshake */
|
|
|
|
tr_handshake* tr_handshakeNew(
|
|
|
|
tr_peerIo* io,
|
|
|
|
tr_encryption_mode encryption_mode,
|
|
|
|
tr_handshake_done_func when_done,
|
|
|
|
void* when_done_user_data);
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_handshakeAbort(tr_handshake* handshake);
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2021-10-11 21:54:16 +00:00
|
|
|
tr_peerIo* tr_handshakeStealIO(tr_handshake* handshake);
|
2008-12-20 22:19:34 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/** @} */
|