Monero
Namespaces | Macros | Functions
levin_abstract_invoke2.h File Reference
#include "portable_storage_template_helper.h"
#include <boost/utility/string_ref.hpp>
#include <boost/utility/value_init.hpp>
#include <functional>
#include "byte_slice.h"
#include "span.h"
#include "net/levin_base.h"
Include dependency graph for levin_abstract_invoke2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 epee
 TODO: (mj-xmr) This will be reduced in an another PR.
 
 epee::net_utils
 

Macros

#define MONERO_DEFAULT_LOG_CATEGORY   "net"
 
#define CHAIN_LEVIN_INVOKE_MAP2(context_type)
 
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type)
 
#define CHAIN_LEVIN_INVOKE_MAP()
 
#define CHAIN_LEVIN_NOTIFY_MAP()
 
#define CHAIN_LEVIN_NOTIFY_STUB()
 
#define BEGIN_INVOKE_MAP2(owner_type)
 
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out)
 
#define HANDLE_INVOKE_T2(COMMAND, func)
 
#define HANDLE_NOTIFY2(command_id, func, type_name_in)
 
#define HANDLE_NOTIFY_T2(NOTIFY, func)
 
#define CHAIN_INVOKE_MAP2(func)
 
#define CHAIN_INVOKE_MAP_TO_OBJ2(obj)
 
#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type)
 
#define END_INVOKE_MAP2()
 

Functions

template<typename context_t >
void on_levin_traffic (const context_t &context, bool initiator, bool sent, bool error, size_t bytes, const char *category)
 
template<typename context_t >
void on_levin_traffic (const context_t &context, bool initiator, bool sent, bool error, size_t bytes, int command)
 
template<class t_arg , class t_result , class t_transport >
bool epee::net_utils::invoke_remote_command2 (const epee::net_utils::connection_context_base context, int command, const t_arg &out_struct, t_result &result_struct, t_transport &transport)
 
template<class t_result , class t_arg , class callback_t , class t_transport >
bool epee::net_utils::async_invoke_remote_command2 (const epee::net_utils::connection_context_base &context, int command, const t_arg &out_struct, t_transport &transport, const callback_t &cb, size_t inv_timeout=LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
 
template<class t_arg , class t_transport >
bool epee::net_utils::notify_remote_command2 (const typename t_transport::connection_context &context, int command, const t_arg &out_struct, t_transport &transport)
 
template<class t_owner , class t_in_type , class t_out_type , class t_context , class callback_t >
int epee::net_utils::buff_to_t_adapter (int command, const epee::span< const uint8_t > in_buff, byte_stream &buff_out, callback_t cb, t_context &context)
 
template<class t_owner , class t_in_type , class t_context , class callback_t >
int epee::net_utils::buff_to_t_adapter (t_owner *powner, int command, const epee::span< const uint8_t > in_buff, callback_t cb, t_context &context)
 

Macro Definition Documentation

◆ BEGIN_INVOKE_MAP2

#define BEGIN_INVOKE_MAP2 (   owner_type)
Value:
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, t_context& context, bool& handled) \
{ \
try { \
typedef owner_type internal_owner_type_name;
A partial drop-in replacement for std::ostream.
Definition: byte_stream.h:57
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_INVOKE_MAP2

#define CHAIN_INVOKE_MAP2 (   func)
Value:
{ \
int res = func(is_notify, command, in_buff, buff_out, context, handled); \
if(handled) \
return res; \
}
const char * res
Definition: hmac_keccak.cpp:42
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_INVOKE_MAP_TO_OBJ2

#define CHAIN_INVOKE_MAP_TO_OBJ2 (   obj)
Value:
{ \
int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, context, handled); \
if(handled) \
return res; \
}
const char * res
Definition: hmac_keccak.cpp:42
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT

#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT (   obj,
  context_type 
)
Value:
{ \
int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, static_cast<context_type>(context), handled); \
if(handled) return res; \
}
const char * res
Definition: hmac_keccak.cpp:42
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_LEVIN_INVOKE_MAP

#define CHAIN_LEVIN_INVOKE_MAP ( )
Value:
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
}
A partial drop-in replacement for std::ostream.
Definition: byte_stream.h:57
Definition: net_utils_base.h:366
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_LEVIN_INVOKE_MAP2

#define CHAIN_LEVIN_INVOKE_MAP2 (   context_type)
Value:
int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, context_type& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
}
A partial drop-in replacement for std::ostream.
Definition: byte_stream.h:57
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_LEVIN_NOTIFY_MAP

#define CHAIN_LEVIN_NOTIFY_MAP ( )
Value:
{ \
bool handled = false; std::string fake_str;\
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}
::std::string string
Definition: gtest-port.h:1097
Definition: net_utils_base.h:366
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_LEVIN_NOTIFY_MAP2

#define CHAIN_LEVIN_NOTIFY_MAP2 (   context_type)
Value:
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
{ \
bool handled = false; epee::byte_stream fake_str; \
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}
A partial drop-in replacement for std::ostream.
Definition: byte_stream.h:57
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ CHAIN_LEVIN_NOTIFY_STUB

#define CHAIN_LEVIN_NOTIFY_STUB ( )
Value:
{ \
return -1; \
}
Definition: net_utils_base.h:366
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ END_INVOKE_MAP2

#define END_INVOKE_MAP2 ( )
Value:
LOG_ERROR("Unknown command:" << command); \
on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \
} \
catch (const std::exception &e) { \
MERROR("Error in handle_invoke_map: " << e.what()); \
return LEVIN_ERROR_CONNECTION_TIMEDOUT; /* seems kinda appropriate */ \
} \
}
#define LEVIN_ERROR_CONNECTION_TIMEDOUT
Definition: levin_base.h:106
#define LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED
Definition: levin_base.h:108
e
Definition: pymoduletest.py:79
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ HANDLE_INVOKE2

#define HANDLE_INVOKE2 (   command_id,
  func,
  type_name_in,
  typename_out 
)
Value:
if(!is_notify && command_id == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in, typename_out>(this, command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ HANDLE_INVOKE_T2

#define HANDLE_INVOKE_T2 (   COMMAND,
  func 
)
Value:
if(!is_notify && COMMAND::ID == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename COMMAND::request, typename COMMAND::response>(command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ HANDLE_NOTIFY2

#define HANDLE_NOTIFY2 (   command_id,
  func,
  type_name_in 
)
Value:
if(is_notify && command_id == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ HANDLE_NOTIFY_T2

#define HANDLE_NOTIFY_T2 (   NOTIFY,
  func 
)
Value:
if(is_notify && NOTIFY::ID == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename NOTIFY::request>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105

◆ MONERO_DEFAULT_LOG_CATEGORY

#define MONERO_DEFAULT_LOG_CATEGORY   "net"

Function Documentation

◆ on_levin_traffic() [1/2]

template<typename context_t >
void on_levin_traffic ( const context_t &  context,
bool  initiator,
bool  sent,
bool  error,
size_t  bytes,
const char *  category 
)

◆ on_levin_traffic() [2/2]

template<typename context_t >
void on_levin_traffic ( const context_t &  context,
bool  initiator,
bool  sent,
bool  error,
size_t  bytes,
int  command 
)