2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2017-2022 Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2017-06-28 15:46:06 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "net.h"
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2017-06-28 15:46:06 +00:00
|
|
|
enum tr_peer_socket_type
|
|
|
|
{
|
|
|
|
TR_PEER_SOCKET_TYPE_NONE,
|
|
|
|
TR_PEER_SOCKET_TYPE_TCP,
|
|
|
|
TR_PEER_SOCKET_TYPE_UTP
|
|
|
|
};
|
|
|
|
|
|
|
|
union tr_peer_socket_handle
|
|
|
|
{
|
|
|
|
tr_socket_t tcp;
|
|
|
|
struct UTPSocket* utp;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tr_peer_socket
|
|
|
|
{
|
2022-05-25 23:16:15 +00:00
|
|
|
enum tr_peer_socket_type type = TR_PEER_SOCKET_TYPE_NONE;
|
2017-06-28 15:46:06 +00:00
|
|
|
union tr_peer_socket_handle handle;
|
|
|
|
};
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
struct tr_peer_socket tr_peer_socket_tcp_create(tr_socket_t const handle);
|
2017-06-28 15:46:06 +00:00
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
struct tr_peer_socket tr_peer_socket_utp_create(struct UTPSocket* const handle);
|
|
|
|
|
|
|
|
struct tr_session;
|
2022-07-09 23:44:20 +00:00
|
|
|
struct tr_address;
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
struct tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_address const* addr, tr_port port, bool client_is_seed);
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
struct tr_peer_socket tr_netOpenPeerUTPSocket(tr_session* session, tr_address const* addr, tr_port port, bool client_is_seed);
|
2022-02-19 18:10:43 +00:00
|
|
|
|
|
|
|
void tr_netClosePeerSocket(tr_session* session, tr_peer_socket socket);
|