Skip to content
API Documentation
BastionGuard™
bsc::proto Namespace Reference

Namespaces

namespace  msg

Functions

std::string resolve_socket_path (std::string uri)
void frame_encode (std::string_view payload, std::vector< std::uint8_t > &out)
std::int64_t frame_peek_length (const std::uint8_t *buf, std::size_t len)

Variables

constexpr const char * kDefaultSocketPath = "/tmp/bsd-daemon.sock"
constexpr std::size_t kMaxFrameSize = 4u * 1024u * 1024u

Function Documentation

◆ frame_encode()

void bsc::proto::frame_encode ( std::string_view payload,
std::vector< std::uint8_t > & out )
inline

Definition at line 66 of file Wire.hpp.

66 {
67 const std::uint32_t len = static_cast<std::uint32_t>(payload.size());
68 out.resize(4 + payload.size());
69 out[0] = static_cast<std::uint8_t>(len & 0xff);
70 out[1] = static_cast<std::uint8_t>((len >> 8) & 0xff);
71 out[2] = static_cast<std::uint8_t>((len >> 16) & 0xff);
72 out[3] = static_cast<std::uint8_t>((len >> 24) & 0xff);
73 std::memcpy(out.data() + 4, payload.data(), payload.size());
74}

References frame_encode().

Referenced by frame_encode(), UIServer::Impl::send_frame(), and bsc::ui::UIClient::Impl::write_frame().

◆ frame_peek_length()

std::int64_t bsc::proto::frame_peek_length ( const std::uint8_t * buf,
std::size_t len )
inline

Definition at line 78 of file Wire.hpp.

78 {
79 if (len < 4) return -1;
80 return static_cast<std::uint32_t>(buf[0])
81 | (static_cast<std::uint32_t>(buf[1]) << 8)
82 | (static_cast<std::uint32_t>(buf[2]) << 16)
83 | (static_cast<std::uint32_t>(buf[3]) << 24);
84}

References frame_peek_length().

Referenced by UIServer::Impl::client_session(), frame_peek_length(), and bsc::ui::UIClient::Impl::read_until_eof().

◆ resolve_socket_path()

std::string bsc::proto::resolve_socket_path ( std::string uri)
inline

Definition at line 58 of file Wire.hpp.

58 {
59 static const std::string prefix = "unix://";
60 if (uri.rfind(prefix, 0) == 0) uri = uri.substr(prefix.size());
61 return uri;
62}

References resolve_socket_path().

Referenced by resolve_socket_path(), and UIServer::Impl::start().

Variable Documentation

◆ kDefaultSocketPath

const char* bsc::proto::kDefaultSocketPath = "/tmp/bsd-daemon.sock"
inlineconstexpr

Definition at line 44 of file Wire.hpp.

◆ kMaxFrameSize

std::size_t bsc::proto::kMaxFrameSize = 4u * 1024u * 1024u
inlineconstexpr