-
Notifications
You must be signed in to change notification settings - Fork 10
/
Protocol.hxx
99 lines (77 loc) · 2.22 KB
/
Protocol.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: BSD-2-Clause
// Copyright CM4all GmbH
// author: Max Kellermann <mk@cm4all.com>
#pragma once
#include <stdint.h>
/*
Definitions for the Spawn daemon protocol
(https://github.com/CM4all/spawn).
The Spawn daemon listens on a local seqpacket socket for commands.
Each datagram begins with the 32 bit "magic", followed by a CRC32 of
all command packets, followed by one or more command packets.
Each command packet begins with a header and a variable-length
payload. The payloads are padded to the next multiple of 4 bytes.
These command packets belong together; they construct a larger
request; for example, the first command may specify the namespace
name, and the following packets specify the types of namespaces.
All integers are native endian. This protocol is designed for
communication over local sockets (AF_LOCAL), and thus has no need
for conversion to network byte order.
*/
namespace SpawnAccessory {
/**
* This magic number precedes every datagram.
*/
static const uint32_t MAGIC = 0x63046173;
struct DatagramHeader {
uint32_t magic;
uint32_t crc;
};
enum class RequestCommand : uint16_t {
NOP = 0,
/**
* Set the name of namespaces requested by this datagram. Payload
* is a non-empty variable-length name (7 bit ASCII, no null
* bytes).
*/
NAME = 1,
/**
* Create a new IPC namespace. No payload.
*
* Response may be #ResponseCommand::NAMESPACE_HANDLES or
* #ResponseCommand::ERROR.
*/
IPC_NAMESPACE = 2,
/**
* Create a new PID namespace. No payload.
*
* Response may be #ResponseCommand::NAMESPACE_HANDLES or
* #ResponseCommand::ERROR.
*/
PID_NAMESPACE = 3,
};
struct RequestHeader {
uint16_t size;
RequestCommand command;
};
enum class ResponseCommand : uint16_t {
/**
* The request has failed.
*
* Payload is a human-readable error message.
*/
ERROR = 0,
/**
* Successful response to #RequestCommand::*_NAMESPACE.
*
* Payload is a list of "uint32_t" values, each of them denoting a
* single "CLONE_*" flag. This defines the order in which the
* namespace file handles are being transmitted as ancillary data.
*/
NAMESPACE_HANDLES = 1,
};
struct ResponseHeader {
uint16_t size;
ResponseCommand command;
};
}