#include <transport.hpp>
Definition at line 196 of file transport.hpp.
◆ UdpTransport()
| hw::trezor::UdpTransport::UdpTransport |
( |
boost::optional< std::string > |
device_path = boost::none, |
|
|
boost::optional< std::shared_ptr< Protocol >> |
proto = boost::none |
|
) |
| |
|
explicit |
Definition at line 510 of file transport.cpp.
512 m_io_service(), m_deadline(m_io_service)
516 const char *env_trezor_path =
nullptr;
519 parse_udp_path(m_device_host, m_device_port, device_path.get());
520 }
else if ((env_trezor_path = getenv(
"TREZOR_PATH")) !=
nullptr && boost::starts_with(env_trezor_path,
UdpTransport::PATH_PREFIX)){
521 parse_udp_path(m_device_host, m_device_port,
std::string(env_trezor_path));
522 MDEBUG(
"Applied TREZOR_PATH: " << m_device_host <<
":" << m_device_port);
527 assert_port_number((
uint32_t)m_device_port);
528 if (m_device_host !=
"localhost" && m_device_host !=
DEFAULT_HOST){
529 throw std::invalid_argument(
"Local endpoint allowed only");
532 m_proto = proto ? proto.get() : std::make_shared<ProtocolV1>();
static const int DEFAULT_PORT
static const char * PATH_PREFIX
static const char * DEFAULT_HOST
◆ ~UdpTransport()
| virtual hw::trezor::UdpTransport::~UdpTransport |
( |
| ) |
|
|
virtualdefault |
◆ close()
| void hw::trezor::UdpTransport::close |
( |
| ) |
|
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 601 of file transport.cpp.
606 MTRACE(
"Closing Trezor:UdpTransport");
608 throw exc::CommunicationException(
"Socket is already closed");
611 m_proto->session_end(*
this);
◆ dump()
| std::ostream & hw::trezor::UdpTransport::dump |
( |
std::ostream & |
o | ) |
const |
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 766 of file transport.cpp.
767 return o <<
"UdpTransport<path=" <<
get_path()
768 <<
", socket_alive=" << (m_socket ?
"true" :
"false")
std::string get_path() const override
◆ enumerate()
Reimplemented from hw::trezor::Transport.
Definition at line 566 of file transport.cpp.
567 std::shared_ptr<UdpTransport> t = std::make_shared<UdpTransport>();
568 bool t_works =
false;
◆ find_debug()
| std::shared_ptr< Transport > hw::trezor::UdpTransport::find_debug |
( |
| ) |
|
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 616 of file transport.cpp.
617 #ifdef WITH_TREZOR_DEBUGGING 618 std::shared_ptr<UdpTransport> t = std::make_shared<UdpTransport>();
619 t->m_proto = std::make_shared<ProtocolV1>();
620 t->m_device_host = m_device_host;
621 t->m_device_port = m_device_port + 1;
624 MINFO(
"Debug link is disabled in production");
◆ get_path()
| std::string hw::trezor::UdpTransport::get_path |
( |
| ) |
const |
|
overridevirtual |
◆ open()
| void hw::trezor::UdpTransport::open |
( |
| ) |
|
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 582 of file transport.cpp.
587 udp::resolver resolver(m_io_service);
588 udp::resolver::query query(udp::v4(), m_device_host,
std::to_string(m_device_port));
589 m_endpoint = *resolver.resolve(query);
592 m_socket->open(udp::v4());
594 m_deadline.expires_at(boost::posix_time::pos_infin);
597 m_proto->session_begin(*
this);
std::unique_ptr< void, close > socket
Unique ZMQ socket handle, calls zmq_close on destruction.
std::string to_string(t_connection_type type)
◆ ping()
| bool hw::trezor::UdpTransport::ping |
( |
| ) |
|
|
overridevirtual |
◆ read()
| void hw::trezor::UdpTransport::read |
( |
std::shared_ptr< google::protobuf::Message > & |
msg, |
|
|
messages::MessageType * |
msg_type = nullptr |
|
) |
| |
|
overridevirtual |
◆ read_chunk()
| size_t hw::trezor::UdpTransport::read_chunk |
( |
void * |
buff, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 642 of file transport.cpp.
645 throw std::invalid_argument(
"Buffer too small");
651 boost::system::error_code ec;
652 len =
receive(buff, size, &ec,
true);
653 if (ec == boost::asio::error::operation_aborted) {
656 throw exc::CommunicationException(
std::string(
"Comm error: ") + ec.message());
660 throw exc::CommunicationException(
"Invalid chunk size");
665 }
catch(exc::CommunicationException
const& e){
667 }
catch(std::exception
const& e){
668 MWARNING(
"Error reading chunk, reason: " << e.what());
673 return static_cast<size_t>(len);
expect< std::string > receive(void *const socket, const int flags)
◆ write()
| void hw::trezor::UdpTransport::write |
( |
const google::protobuf::Message & |
req | ) |
|
|
overridevirtual |
◆ write_chunk()
| void hw::trezor::UdpTransport::write_chunk |
( |
const void * |
buff, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Reimplemented from hw::trezor::Transport.
Definition at line 629 of file transport.cpp.
633 throw exc::CommunicationException(
"Invalid chunk size");
636 auto written = m_socket->send_to(boost::asio::buffer(buff, size), m_endpoint);
637 if (size != written){
638 throw exc::CommunicationException(
"Could not send the whole chunk");
◆ DEFAULT_HOST
| const char * hw::trezor::UdpTransport::DEFAULT_HOST = "127.0.0.1" |
|
static |
◆ DEFAULT_PORT
| const int hw::trezor::UdpTransport::DEFAULT_PORT = 21324 |
|
static |
◆ PATH_PREFIX
| const char * hw::trezor::UdpTransport::PATH_PREFIX = "udp:" |
|
static |
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.0.0.4/src/device_trezor/trezor/transport.hpp
- /home/abuild/rpmbuild/BUILD/electroneum-5.0.0.4/src/device_trezor/trezor/transport.cpp