Comms CCF
This is a simple communication layer based on COBS, CBOR and FNV-1A
Loading...
Searching...
No Matches
rpc.hpp File Reference

Remote procedure support. More...

#include "cbor.hpp"
#include "comptime_str.hpp"
#include "ndebug.hpp"
#include <stddef.h>
#include <stdint.h>
#include <array>
#include <functional>
#include <span>
#include <string_view>
#include <tuple>
#include <utility>
#include "debug_end.hpp"

Go to the source code of this file.

Classes

struct  Type< T >
struct  Type< I >
struct  Type< std::string_view >
struct  Type< std::span< uint8_t, extent > >
struct  Type< std::tuple<> >
struct  Type< std::tuple< Ts... > >
class  NonTemplatedCall
class  Call< Ret, Args >
class  Rpc< Calls >

Macros

#define self   (*this)
#define self_arg(type)
#define self_app(value)
#define prototype(ret, name, args)
#define definition(ret, name, args)
#define LITERAL_COMPTIME_STRING(name, value)

Detailed Description

Remote procedure support.

Remote Procedure Call (RPC)

We can have remote code execution very simply: read a function pointer, then a list of arguments (e.g. CBOR encoded), and jump to that pointer with the arguments on the stack. This is tedious and fragile, however.

The tedium we can help by using e.g. Python to do some of the sending data, and the fragility we can help by defining at compile-time which functions we want to be exposed, and also doing type checking on those argumets.

We can further help the tedium and safety by transmitting a schema that the endpoint supports. This way we can do checking at the Python level even before we send data out.

Using template metaprogramming, we can also have type safety in C++.

Macro Definition Documentation

◆ definition

#define definition ( ret,
name,
args )
Value:
ret name args const override

◆ LITERAL_COMPTIME_STRING

#define LITERAL_COMPTIME_STRING ( name,
value )
Value:
const decltype(CompTimeString{value}) name{value}
Definition comptime_str.hpp:23

◆ prototype

#define prototype ( ret,
name,
args )
Value:
virtual ret name args const = 0

◆ self_app

#define self_app ( value)
Value:
/* implicit */

◆ self_arg

#define self_arg ( type)
Value:
/* implicit */