mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-07 01:53:24 +09:00
[Feat] (P11 PAIR): the PairBind control message - the client's nonce and which of its two connections this is, the first frame on each - with the control revision 3 -> 4 and its pin
This commit is contained in:
@@ -50,6 +50,9 @@ struct WelcomeBuilder;
|
||||
struct DataBind;
|
||||
struct DataBindBuilder;
|
||||
|
||||
struct PairBind;
|
||||
struct PairBindBuilder;
|
||||
|
||||
struct CapsSnapshot;
|
||||
struct CapsSnapshotBuilder;
|
||||
|
||||
@@ -552,11 +555,12 @@ enum class CtrlMsg : uint8_t {
|
||||
LogFlush = 12,
|
||||
DataBind = 13,
|
||||
SurfaceProgress = 14,
|
||||
PairBind = 15,
|
||||
MIN = NONE,
|
||||
MAX = SurfaceProgress
|
||||
MAX = PairBind
|
||||
};
|
||||
|
||||
inline const CtrlMsg (&EnumValuesCtrlMsg())[15] {
|
||||
inline const CtrlMsg (&EnumValuesCtrlMsg())[16] {
|
||||
static const CtrlMsg values[] = {
|
||||
CtrlMsg::NONE,
|
||||
CtrlMsg::Hello,
|
||||
@@ -572,13 +576,14 @@ inline const CtrlMsg (&EnumValuesCtrlMsg())[15] {
|
||||
CtrlMsg::Refuse,
|
||||
CtrlMsg::LogFlush,
|
||||
CtrlMsg::DataBind,
|
||||
CtrlMsg::SurfaceProgress
|
||||
CtrlMsg::SurfaceProgress,
|
||||
CtrlMsg::PairBind
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesCtrlMsg() {
|
||||
static const char * const names[16] = {
|
||||
static const char * const names[17] = {
|
||||
"NONE",
|
||||
"Hello",
|
||||
"Welcome",
|
||||
@@ -594,13 +599,14 @@ inline const char * const *EnumNamesCtrlMsg() {
|
||||
"LogFlush",
|
||||
"DataBind",
|
||||
"SurfaceProgress",
|
||||
"PairBind",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameCtrlMsg(CtrlMsg e) {
|
||||
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::SurfaceProgress)) return "";
|
||||
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::PairBind)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesCtrlMsg()[index];
|
||||
}
|
||||
@@ -665,6 +671,10 @@ template<> struct CtrlMsgTraits<MobileGL::Wire::SurfaceProgress> {
|
||||
static const CtrlMsg enum_value = CtrlMsg::SurfaceProgress;
|
||||
};
|
||||
|
||||
template<> struct CtrlMsgTraits<MobileGL::Wire::PairBind> {
|
||||
static const CtrlMsg enum_value = CtrlMsg::PairBind;
|
||||
};
|
||||
|
||||
template <bool B = false>
|
||||
bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, CtrlMsg type);
|
||||
template <bool B = false>
|
||||
@@ -1478,6 +1488,76 @@ inline ::flatbuffers::Offset<DataBind> CreateDataBindDirect(
|
||||
nonce__);
|
||||
}
|
||||
|
||||
struct PairBind FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef PairBindBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NONCE = 4,
|
||||
VT_AUX = 6
|
||||
};
|
||||
const ::flatbuffers::Vector<uint8_t> *nonce() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_NONCE);
|
||||
}
|
||||
bool aux() const {
|
||||
return GetField<uint8_t>(VT_AUX, 0) != 0;
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_NONCE) &&
|
||||
verifier.VerifyVector(nonce()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_AUX, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct PairBindBuilder {
|
||||
typedef PairBind Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_nonce(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> nonce) {
|
||||
fbb_.AddOffset(PairBind::VT_NONCE, nonce);
|
||||
}
|
||||
void add_aux(bool aux) {
|
||||
fbb_.AddElement<uint8_t>(PairBind::VT_AUX, static_cast<uint8_t>(aux), 0);
|
||||
}
|
||||
explicit PairBindBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<PairBind> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<PairBind>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<PairBind> CreatePairBind(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> nonce = 0,
|
||||
bool aux = false) {
|
||||
PairBindBuilder builder_(_fbb);
|
||||
builder_.add_nonce(nonce);
|
||||
builder_.add_aux(aux);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct PairBind::Traits {
|
||||
using type = PairBind;
|
||||
static auto constexpr Create = CreatePairBind;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<PairBind> CreatePairBindDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<uint8_t> *nonce = nullptr,
|
||||
bool aux = false) {
|
||||
auto nonce__ = nonce ? _fbb.CreateVector<uint8_t>(*nonce) : 0;
|
||||
return MobileGL::Wire::CreatePairBind(
|
||||
_fbb,
|
||||
nonce__,
|
||||
aux);
|
||||
}
|
||||
|
||||
struct CapsSnapshot FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef CapsSnapshotBuilder Builder;
|
||||
struct Traits;
|
||||
@@ -2416,6 +2496,9 @@ struct CtrlEnvelope FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
const MobileGL::Wire::SurfaceProgress *msg_as_SurfaceProgress() const {
|
||||
return msg_type() == MobileGL::Wire::CtrlMsg::SurfaceProgress ? static_cast<const MobileGL::Wire::SurfaceProgress *>(msg()) : nullptr;
|
||||
}
|
||||
const MobileGL::Wire::PairBind *msg_as_PairBind() const {
|
||||
return msg_type() == MobileGL::Wire::CtrlMsg::PairBind ? static_cast<const MobileGL::Wire::PairBind *>(msg()) : nullptr;
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -2482,6 +2565,10 @@ template<> inline const MobileGL::Wire::SurfaceProgress *CtrlEnvelope::msg_as<Mo
|
||||
return msg_as_SurfaceProgress();
|
||||
}
|
||||
|
||||
template<> inline const MobileGL::Wire::PairBind *CtrlEnvelope::msg_as<MobileGL::Wire::PairBind>() const {
|
||||
return msg_as_PairBind();
|
||||
}
|
||||
|
||||
struct CtrlEnvelopeBuilder {
|
||||
typedef CtrlEnvelope Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
@@ -2580,6 +2667,10 @@ inline bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const vo
|
||||
auto ptr = reinterpret_cast<const MobileGL::Wire::SurfaceProgress *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case CtrlMsg::PairBind: {
|
||||
auto ptr = reinterpret_cast<const MobileGL::Wire::PairBind *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ extern "C" {
|
||||
// 2 P7 (p7/spawnhang): the SurfaceProgress message.
|
||||
// 3 P12 (on-screen server window): WindowKind.ServerOwned, the SurfaceRefusal enum and
|
||||
// SurfaceReply.width/height/refusal.
|
||||
#define MOBILEGL_PROTOCOL_CONTROL_REVISION 3
|
||||
// 4 P11 PAIR: the PairBind message - a socket client's control and aux connections pair by
|
||||
// the nonce each presents first, not by arrival order.
|
||||
#define MOBILEGL_PROTOCOL_CONTROL_REVISION 4
|
||||
|
||||
#define MOBILEGL_ABI_VERSION(major, minor) (((uint32_t)(major) << 16) | (uint32_t)(minor))
|
||||
#define MOBILEGL_ABI_MAJOR_OF(version) ((uint32_t)(version) >> 16)
|
||||
|
||||
@@ -142,6 +142,19 @@ table DataBind {
|
||||
nonce: [ubyte];
|
||||
}
|
||||
|
||||
// P11 PAIR. The FIRST frame on each of the two connections a socket client opens with
|
||||
// SocketTransport::ConnectTo - control, then aux (the SCM_RIGHTS socket; the data connection on a
|
||||
// tcp:// ConnectTo) - and on control the only frame before the Hello. `nonce` is 128 bits from the
|
||||
// client's CSPRNG, the same on both; `aux` says which of the two this connection is. The server
|
||||
// holds every accepted connection until it has presented this and pairs the two halves by the
|
||||
// nonce, never by arrival order (Server/PairAcceptor.h): a stray connection, or a second client
|
||||
// connecting at the same moment, cannot become half of this client's session. A control connection
|
||||
// whose first frame is a Hello is a peer from before this message and is refused by name.
|
||||
table PairBind {
|
||||
nonce: [ubyte];
|
||||
aux: bool;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Capabilities
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -401,6 +414,7 @@ union CtrlMsg {
|
||||
LogFlush,
|
||||
DataBind,
|
||||
SurfaceProgress,
|
||||
PairBind,
|
||||
}
|
||||
|
||||
table CtrlEnvelope {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"1": "7fc859f7fa756818401f4162e7d49a25d430b91e44d89c297321e3cb36c69638",
|
||||
"2": "b30928e6fc93ddc015fd86f634a6820f775a6f2f6de5a848d273981e706b2597",
|
||||
"3": "da09f0acb48cf245703f28556ef5a38bc9e25241ebbf7b6baa9ab1765b7ddd50"
|
||||
"3": "da09f0acb48cf245703f28556ef5a38bc9e25241ebbf7b6baa9ab1765b7ddd50",
|
||||
"4": "6357c3a07ae258d2825dc42bfd610712b15a38a3beb7a96b5f56ea2988705e7f"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user