Select Git revision
testutils.c
Forked from
Nettle / nettle
Source project has a limited visibility.
api.h 10.36 KiB
#ifndef API_H
#define API_H
#include <sys/types.h>
#include <msgpack.hpp>
#include <cstdint>
#include <string>
#define MSG_HDR(name, def_op) \
struct name : public rpc_msg {\
name() : rpc_msg{def_op} {}
#define SERIALISE(...) \
MSGPACK_DEFINE(op, __VA_ARGS__)
namespace blue
{
constexpr size_t MAX_RPC_MSG_SIZE = 4096;
/*
* This enum class listst all the RPC messages available for
* communication between the daemon and the client.
*
* Messages are grouped by OP_OPERATION_MSG, where OPERATION is a task
* to perform and MSG represents a message used to accomplish
* OPERATION. An example is the scan operation whose messages are
* named OP_SCAN_REQUEST, OP_SCAN_START, etc.
*
* After each message, a comment is present that describes what
* message type should be used to serialise and deserialise the
* message for that operation.
*
* An example is the OP_SCAN_ITEM message with type
* blue::msg_scan_item, which the client could deserialise as
*
* msgpack::object deserialised = oh.get();
* blue::msg_scan_item item;
* deserialised.convert(item);
* std::cout << item.name << std::endl;
*
* See bluecontrol/src/bluecontrol.cpp as reference.
*/
enum class rpc_op : uint32_t
{
OP_UNUSED = 0x0000,
/* Normal scan flow
* ================
*
* CLIENT DAEMON
* ----------------------
* -- OP_SCAN_REQUEST ->
* <- OP_SCAN_START --
* <- OP_SCAN_ITEM --
* .
* .
* .
* <- OP_SCAN_DONE --
*
* The client sends the daemon a OP_SCAN_REQUEST request and the
* daemon responds with OP_SCAN_START followed by zero or more
* OP_SCAN_ITEM messages followed by OP_SCAN_DONE.
*/
OP_SCAN_REQUEST, // blue::rpc_msg
OP_SCAN_START, // blue::rpc_msg
OP_SCAN_ITEM, // blue::msg_scan_item
OP_SCAN_DONE, // blue::rpc_msg
/*
* Normal pairing flow