2014-02-10 12:43:13 +00:00
|
|
|
#pragma once
|
2023-04-01 03:18:41 +00:00
|
|
|
///@file
|
2014-02-10 12:43:13 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
#define SERVE_MAGIC_1 0x390c9deb
|
|
|
|
#define SERVE_MAGIC_2 0x5452eecb
|
|
|
|
|
2021-08-23 21:47:29 +00:00
|
|
|
#define SERVE_PROTOCOL_VERSION (2 << 8 | 7)
|
2014-02-10 12:43:13 +00:00
|
|
|
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
|
|
|
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
|
|
|
|
2023-05-26 15:22:24 +00:00
|
|
|
/**
|
|
|
|
* The "serve protocol", used by ssh:// stores.
|
|
|
|
*
|
|
|
|
* This `struct` is basically just a `namespace`; We use a type rather
|
|
|
|
* than a namespace just so we can use it as a template argument.
|
|
|
|
*/
|
|
|
|
struct ServeProto
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Enumeration of all the request types for the protocol.
|
|
|
|
*/
|
|
|
|
enum struct Command : uint64_t;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum struct ServeProto::Command : uint64_t
|
|
|
|
{
|
|
|
|
QueryValidPaths = 1,
|
|
|
|
QueryPathInfos = 2,
|
|
|
|
DumpStorePath = 3,
|
|
|
|
ImportPaths = 4,
|
|
|
|
ExportPaths = 5,
|
|
|
|
BuildPaths = 6,
|
|
|
|
QueryClosure = 7,
|
|
|
|
BuildDerivation = 8,
|
|
|
|
AddToStoreNar = 9,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience for sending operation codes.
|
|
|
|
*
|
|
|
|
* @todo Switch to using `ServeProto::Serialize` instead probably. But
|
|
|
|
* this was not done at this time so there would be less churn.
|
|
|
|
*/
|
|
|
|
inline Sink & operator << (Sink & sink, ServeProto::Command op)
|
|
|
|
{
|
|
|
|
return sink << (uint64_t) op;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience for debugging.
|
|
|
|
*
|
|
|
|
* @todo Perhaps render known opcodes more nicely.
|
|
|
|
*/
|
|
|
|
inline std::ostream & operator << (std::ostream & s, ServeProto::Command op)
|
|
|
|
{
|
|
|
|
return s << (uint64_t) op;
|
|
|
|
}
|
2014-02-10 12:43:13 +00:00
|
|
|
|
|
|
|
}
|