Skip to content
Snippets Groups Projects
Select Git revision
  • 0ce1de9e529e34d5e38f7b7f4e5fcc27b02c44b5
  • master default protected
  • master-updates
  • rename-data-symbols
  • x86_64-sha_ni-sha256
  • ecc-params-tweak
  • delete-old-aes
  • cmac-support
  • x86_64-sha_ni-sha1
  • gcm-ctr-opt
  • ctr-opt
  • skein
  • api-opaque-fix
  • curve448
  • hkdf-support
  • openssl-benchmark-update
  • merge-pss
  • rsa-crt-hardening
  • chacha96
  • fat-library
  • versioned-symbols
  • 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
  • converted-master-branch-to-git
  • nettle_2.4_release_20110903
  • nettle_2.3_release_20110902
  • nettle_2.2_release_20110711
  • nettle_2.1_release_20100725
41 results

install-sh

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    api.h 1.72 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
    {
    // API result codes
    constexpr uint32_t OP_SUCCESS = 0x0000;
    constexpr uint32_t OP_FAIL    = 0x0001;
    constexpr uint32_t OP_BUSY    = 0x0002;
    
    constexpr size_t MAX_RPC_MSG_SIZE = 4096;
    
    // Header for all messages to easily extract the op field.
    struct rpc_msg
    {
    	uint32_t op;
    	MSGPACK_DEFINE(op);
    };
    
    // Scanning
    constexpr uint32_t OP_SCAN_START = 0x0001;
    MSG_HDR(msg_scan_reply, OP_SCAN_START)
    	uint32_t result;
    	SERIALISE(result);
    };
    constexpr uint32_t OP_SCAN_ITEM = 0x0002;
    MSG_HDR(msg_scan_item, OP_SCAN_ITEM)
    	std::string name;
    	SERIALISE(name);
    };
    constexpr uint32_t OP_SCAN_DONE = 0x0003;
    
    // Pairing
    constexpr uint32_t OP_PAIR_REQUEST = 0x0004;
    MSG_HDR(msg_pair_request, OP_PAIR_REQUEST)
    	std::string name;
    	SERIALISE(name);
    };
    constexpr uint32_t OP_PAIR_START = 0x0005;
    constexpr uint32_t OP_PAIR_UNKNOWN = 0x0006;
    constexpr uint32_t OP_PAIR_ERROR = 0x0007;
    
    // Listing paired devices
    constexpr uint32_t OP_LIST_PAIRS_REQUEST = 0x0008;
    constexpr uint32_t OP_LIST_PAIRS_ITEM = 0x0009;
    MSG_HDR(msg_pair_item, OP_LIST_PAIRS_ITEM)
    	std::string name;
    	SERIALISE(name);
    };
    constexpr uint32_t OP_LIST_PAIRS_DONE = 0x000A;
    constexpr uint32_t OP_LIST_PAIRS_ERROR = 0x000B;
    
    // Set device PIN
    constexpr uint32_t OP_SET_DEVICE_PIN = 0x000C;
    MSG_HDR(msg_set_pin_request, OP_SET_DEVICE_PIN)
    	std::string name;
    	std::string pin;
    	SERIALISE(name, pin);
    };
    constexpr uint32_t OP_SET_DEVICE_PIN_UNKNOWN = 0x000D;
    constexpr uint32_t OP_SET_DEVICE_PIN_TOO_LONG = 0x000E;
    }
    
    #endif // API_H