#include <transport.hpp>
Definition at line 124 of file transport.hpp.
◆ ProtocolV1()
| hw::trezor::ProtocolV1::ProtocolV1 |
( |
| ) |
|
|
default |
◆ ~ProtocolV1()
| virtual hw::trezor::ProtocolV1::~ProtocolV1 |
( |
| ) |
|
|
virtualdefault |
◆ read()
| void hw::trezor::ProtocolV1::read |
( |
Transport & |
transport, |
|
|
std::shared_ptr< google::protobuf::Message > & |
msg, |
|
|
messages::MessageType * |
msg_type = nullptr |
|
) |
| |
|
overridevirtual |
Implements hw::trezor::Protocol.
Definition at line 223 of file transport.cpp.
229 throw exc::CommunicationException(
"Read chunk has invalid size");
232 if (strncmp(chunk,
"?##", 3) != 0){
233 throw exc::CommunicationException(
"Malformed chunk");
239 deserialize_message_header(chunk + 3, tag, len);
242 data_acc.reserve(len);
246 if (chunk[0] !=
'?'){
247 throw exc::CommunicationException(
"Chunk malformed");
250 data_acc.append(chunk + 1, cur - 1);
255 *msg_type =
static_cast<messages::MessageType
>(tag);
259 throw exc::CommunicationException(
"Response incomplete");
263 if (!msg_wrap->ParseFromArray(data_acc.c_str(), len)){
264 throw exc::CommunicationException(
"Message could not be parsed");
::google::protobuf::Message * get_message(int wire_number)
std::shared_ptr< Transport > transport(const std::string &path)
◆ write()
| void hw::trezor::ProtocolV1::write |
( |
Transport & |
transport, |
|
|
const google::protobuf::Message & |
req |
|
) |
| |
|
overridevirtual |
Implements hw::trezor::Protocol.
Definition at line 192 of file transport.cpp.
193 const auto msg_size = message_size(req);
194 const auto buff_size = serialize_message_buffer_size(msg_size) + 2;
196 std::unique_ptr<uint8_t[]> req_buff(
new uint8_t[buff_size]);
197 uint8_t * req_buff_raw = req_buff.get();
198 req_buff_raw[0] =
'#';
199 req_buff_raw[1] =
'#';
201 serialize_message(req, msg_size, req_buff_raw + 2, buff_size - 2);
207 while(offset < buff_size){
208 auto to_copy = std::min((
size_t)(buff_size - offset), (
size_t)(
REPLEN - 1));
211 memcpy(chunk_buff + 1, req_buff_raw + offset, to_copy);
214 if (to_copy <
REPLEN - 1){
215 memset(chunk_buff + 1 + to_copy, 0,
REPLEN - 1 - to_copy);
void * memcpy(void *a, const void *b, size_t c)
std::shared_ptr< Transport > transport(const std::string &path)
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