Skip to content
Snippets Groups Projects
Select Git revision
  • c30ac57a4f70e285e9fdd7925cc2ce9480ea8827
  • master default protected
  • streebog
  • gost28147
  • master-updates
  • ed448
  • shake256
  • curve448
  • ecc-sqrt
  • gosthash94cp
  • cmac64
  • block16-refactor
  • siv-mode
  • cmac-layout
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
41 results

testutils.c

Blame
  • 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