mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

TracyProtocol.hpp (2281B)


      1 #ifndef __TRACYPROTOCOL_HPP__
      2 #define __TRACYPROTOCOL_HPP__
      3 
      4 #include <limits>
      5 #include <stdint.h>
      6 
      7 namespace tracy
      8 {
      9 
     10 constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
     11 
     12 enum : uint32_t { ProtocolVersion = 24 };
     13 enum : uint32_t { BroadcastVersion = 0 };
     14 
     15 using lz4sz_t = uint32_t;
     16 
     17 enum { TargetFrameSize = 256 * 1024 };
     18 enum { LZ4Size = Lz4CompressBound( TargetFrameSize ) };
     19 static_assert( LZ4Size <= std::numeric_limits<lz4sz_t>::max(), "LZ4Size greater than lz4sz_t" );
     20 static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" );
     21 
     22 enum { HandshakeShibbolethSize = 8 };
     23 static const char HandshakeShibboleth[HandshakeShibbolethSize] = { 'T', 'r', 'a', 'c', 'y', 'P', 'r', 'f' };
     24 
     25 enum HandshakeStatus : uint8_t
     26 {
     27     HandshakePending,
     28     HandshakeWelcome,
     29     HandshakeProtocolMismatch,
     30     HandshakeNotAvailable,
     31     HandshakeDropped
     32 };
     33 
     34 enum { WelcomeMessageProgramNameSize = 64 };
     35 enum { WelcomeMessageHostInfoSize = 1024 };
     36 
     37 #pragma pack( 1 )
     38 
     39 enum ServerQuery : uint8_t
     40 {
     41     ServerQueryTerminate,
     42     ServerQueryString,
     43     ServerQueryThreadString,
     44     ServerQuerySourceLocation,
     45     ServerQueryPlotName,
     46     ServerQueryCallstackFrame,
     47     ServerQueryFrameName,
     48     ServerQueryDisconnect,
     49     ServerQueryExternalName,
     50     ServerQueryParameter
     51 };
     52 
     53 struct ServerQueryPacket
     54 {
     55     ServerQuery type;
     56     uint64_t ptr;
     57 };
     58 
     59 enum { ServerQueryPacketSize = sizeof( ServerQueryPacket ) };
     60 
     61 
     62 struct WelcomeMessage
     63 {
     64     double timerMul;
     65     int64_t initBegin;
     66     int64_t initEnd;
     67     uint64_t delay;
     68     uint64_t resolution;
     69     uint64_t epoch;
     70     uint64_t pid;
     71     uint8_t onDemand;
     72     uint8_t isApple;
     73     char programName[WelcomeMessageProgramNameSize];
     74     char hostInfo[WelcomeMessageHostInfoSize];
     75 };
     76 
     77 enum { WelcomeMessageSize = sizeof( WelcomeMessage ) };
     78 
     79 
     80 struct OnDemandPayloadMessage
     81 {
     82     uint64_t frames;
     83     uint64_t currentTime;
     84 };
     85 
     86 enum { OnDemandPayloadMessageSize = sizeof( OnDemandPayloadMessage ) };
     87 
     88 
     89 struct BroadcastMessage
     90 {
     91     uint32_t broadcastVersion;
     92     uint32_t protocolVersion;
     93     uint32_t activeTime;        // in seconds
     94     char programName[WelcomeMessageProgramNameSize];
     95 };
     96 
     97 enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
     98 
     99 #pragma pack()
    100 
    101 }
    102 
    103 #endif