xdrpp
RFC4506 XDR compiler and message library
Classes | Typedefs | Enumerations | Functions | Variables
xdr Namespace Reference

Most of the xdrpp library is encapsulated in the xdr namespace. More...

Classes

struct  accepted_reply
 
struct  archive_adapter
 This is used to apply an archive to a field. More...
 
struct  archive_adapter< detail::Printer >
 
class  arpc_server
 
class  arpc_service
 
class  asynchronous_client_base
 
struct  call_args
 
struct  call_body
 
struct  call_result
 A unique_ptr to a call result, or NULL if the call failed (in which case message returns an error message). More...
 
struct  call_result< void >
 
struct  delete_addrinfo
 A deleter to use std::unique_ptr with addrinfo structures (which must be freed recursively). More...
 
struct  field_archiver_t
 
struct  field_assigner_t
 
struct  field_constructor_t
 
struct  field_destructor_t
 
struct  field_ptr
 Type-level representation of a pointer-to-member value. More...
 
struct  field_size_t
 
struct  generator_t
 
class  generic_rpc_tcp_listener
 
struct  indices
 Placeholder type used to contain a parameter pack of tuple indices, so as to unpack a tuple in function call arguments. More...
 
struct  IniGroup
 Set of callbacks to run when parsing properties within a particular group. More...
 
class  IniLine
 Contents of a specific property. More...
 
struct  mapping
 
struct  marshal_base
 Common utility types and functions for all the marshaling classes. More...
 
struct  marshal_noswap
 Numeric marshaling mixin that does not byteswap any numeric values (which will produce RFC4506 output on a big-endian machine). More...
 
struct  marshal_swap
 Numeric marshaling mixin that byteswaps all numeric values (thus producing RFC4506 output on a little-endian machine). More...
 
class  message_t
 Message buffer, with room at beginning for 4-byte length. More...
 
class  msg_sock
 Send and receive a series of delimited messages on a stream socket. More...
 
struct  netbuf
 
struct  opaque_array
 XDR opaque is represented as std::uint8_t;. More...
 
struct  opaque_auth
 
struct  PMAP_VERS
 
struct  pmaplist_entry
 
struct  pointer
 Optional data (represented with pointer notation in XDR source). More...
 
class  pollset
 Structure to poll for a set of file descriptors and timeouts. More...
 
class  pollset_plus
 Adds support for signal handlers, asynchonous events, and callbacks injected from other threads to the basic functionality in pollset_light. More...
 
struct  rejected_reply
 
struct  reply_body
 
class  reply_cb
 
class  reply_cb< void >
 
struct  rp__list
 
struct  rpc_call_stat
 Structure encoding all the various reasons a server can decline to process an RPC call it received. More...
 
struct  rpc_msg
 
class  rpc_server_base
 
class  rpc_sock
 A wrapper around xdr::msg_sock that separates calls from replies. More...
 
struct  rpc_sock_reply_t
 Functor wrapper around rpc_sock::send_reply. More...
 
struct  rpc_success_hdr
 Structure that gets marshalled as an RPC success header. More...
 
class  rpc_tcp_listener_common
 Listens for connections on a TCP socket (optionally registering the socket with rpcbind), and then serves one or more program/version interfaces to accepted connections. More...
 
struct  rpcb
 
struct  rpcb_entry
 
struct  rpcb_entry_list
 
struct  rpcb_rmtcallargs
 
struct  rpcb_rmtcallres
 
struct  rpcb_stat
 
struct  rpcbs_addrlist
 
struct  rpcbs_rmtcalllist
 
struct  RPCBVERS
 
struct  RPCBVERS4
 
struct  service_base
 
struct  session_allocator
 Trivial session allocator that just calls new and delete. More...
 
struct  session_allocator< void >
 
struct  sock_t
 Abstract away the type of a socket (for windows). More...
 
class  srpc_server
 Attach RPC services to a single, connected stream socket. More...
 
class  srpc_service
 
class  synchronous_client_base
 Synchronous file descriptor demultiplexer. More...
 
struct  transparent_ptr
 A pointer, but that gets marshalled as the underlying object and can convert to the underlying type. More...
 
class  unique_sock
 Self-closing socket. More...
 
struct  xarray
 XDR arrays are implemented using std::array as a supertype. More...
 
struct  xdr_bad_discriminant
 Attempt to set invalid value for a union discriminant. More...
 
struct  xdr_bad_message_size
 Message not multiple of 4 bytes, or cannot fully be parsed. More...
 
struct  xdr_call_error
 This is the exception raised in an RPC client when it reaches the server and transmits a call, with no connection or communication errors, but the server replies with an RPC-level message header refusing to execute the call. More...
 
struct  xdr_fp_base
 Default traits for use as supertype of specializations of xdr_traits for floating-point types. More...
 
struct  xdr_generic_get
 Archive type for unmarshaling from a buffer. More...
 
struct  xdr_generic_put
 Archive type for marshaling to a buffer. More...
 
struct  xdr_integral_base
 Default traits for use as supertype of specializations of xdr_traits for integral types. More...
 
struct  xdr_invariant_failed
 Exception for use by xdr::xdr_validate. More...
 
struct  xdr_overflow
 Attempt to exceed the bounds of a variable-length array or string. More...
 
struct  xdr_runtime_error
 Generic class of XDR unmarshaling errors. More...
 
struct  xdr_should_be_zero
 Padding bytes that should have contained zero don't. More...
 
struct  xdr_struct_base
 
struct  xdr_struct_base< FP, Rest... >
 
struct  xdr_struct_base<>
 Supertype to construct XDR traits of structure objects, used in output of the xdrc compiler. More...
 
struct  xdr_system_error
 This exception represents a system error encountered while attempting to send RPC messages over a socket. More...
 
struct  xdr_traits
 Metadata for all marshalable XDR types. More...
 
struct  xdr_traits< bool >
 
struct  xdr_traits< double >
 
struct  xdr_traits< float >
 
struct  xdr_traits< opaque_array< N > >
 
struct  xdr_traits< pointer< T > >
 
struct  xdr_traits< rpc_success_hdr >
 
struct  xdr_traits< std::int32_t >
 
struct  xdr_traits< std::int64_t >
 
struct  xdr_traits< std::tuple< T... > >
 
struct  xdr_traits< std::uint32_t >
 
struct  xdr_traits< std::uint64_t >
 
struct  xdr_traits< transparent_ptr< T > >
 
struct  xdr_traits< xarray< T, N > >
 
struct  xdr_traits< xstring< N > >
 
struct  xdr_traits< xvector< std::uint8_t, N > >
 
struct  xdr_traits< xvector< T, N > >
 
struct  xdr_traits<::xdr::accept_stat >
 
struct  xdr_traits<::xdr::accepted_reply >
 
struct  xdr_traits<::xdr::accepted_reply::_reply_data_t >
 
struct  xdr_traits<::xdr::accepted_reply::_reply_data_t::_mismatch_info_t >
 
struct  xdr_traits<::xdr::auth_flavor >
 
struct  xdr_traits<::xdr::auth_stat >
 
struct  xdr_traits<::xdr::call_args >
 
struct  xdr_traits<::xdr::call_body >
 
struct  xdr_traits<::xdr::call_result >
 
struct  xdr_traits<::xdr::mapping >
 
struct  xdr_traits<::xdr::msg_type >
 
struct  xdr_traits<::xdr::netbuf >
 
struct  xdr_traits<::xdr::opaque_auth >
 
struct  xdr_traits<::xdr::pmaplist_entry >
 
struct  xdr_traits<::xdr::reject_stat >
 
struct  xdr_traits<::xdr::rejected_reply >
 
struct  xdr_traits<::xdr::rejected_reply::_mismatch_info_t >
 
struct  xdr_traits<::xdr::reply_body >
 
struct  xdr_traits<::xdr::reply_stat >
 
struct  xdr_traits<::xdr::rp__list >
 
struct  xdr_traits<::xdr::rpc_msg >
 
struct  xdr_traits<::xdr::rpc_msg::_body_t >
 
struct  xdr_traits<::xdr::rpcb >
 
struct  xdr_traits<::xdr::rpcb_entry >
 
struct  xdr_traits<::xdr::rpcb_entry_list >
 
struct  xdr_traits<::xdr::rpcb_rmtcallargs >
 
struct  xdr_traits<::xdr::rpcb_rmtcallres >
 
struct  xdr_traits<::xdr::rpcb_stat >
 
struct  xdr_traits<::xdr::rpcbs_addrlist >
 
struct  xdr_traits<::xdr::rpcbs_rmtcalllist >
 
struct  xdr_traits_base
 Default xdr_traits values for actual XDR types, used as a supertype for most xdr::xdr_traits specializations. More...
 
struct  xdr_wrong_union
 Attempt to access wrong field of a union. More...
 
struct  xstring
 A string with a maximum length (returned by xstring::max_size()). More...
 
struct  xvector
 A vector with a maximum size (returned by xvector::max_size()). More...
 

Typedefs

template<typename T >
using arpc_client = typename T::template _xdr_client< asynchronous_client_base >
 
template<typename Session = void, typename SessionAllocator = session_allocator<Session>>
using arpc_tcp_listener = generic_rpc_tcp_listener< arpc_service, Session, SessionAllocator >
 
using IniActions = std::unordered_map< string, IniGroup >
 Holds the actions to execute on various properties in the ini file.
 
using xdr_put = xdr_generic_put< marshal_swap >
 Archive for marshaling in RFC4506 big-endian order.
 
using xdr_get = xdr_generic_get< marshal_swap >
 Archive for unmarshaling in RFC4506 big-endian order.
 
using msg_ptr = std::unique_ptr< message_t >
 
using rpcblist_ptr = xdr::pointer< rp__list >
 
using rpcb_entry_list_ptr = xdr::pointer< rpcb_entry_list >
 
using rpcbs_proc = xdr::xarray< std::int32_t, RPCBSTAT_HIGHPROC >
 
using rpcbs_addrlist_ptr = xdr::pointer< rpcbs_addrlist >
 
using rpcbs_rmtcalllist_ptr = xdr::pointer< rpcbs_rmtcalllist >
 
using rpcb_stat_byvers = xdr::xarray< rpcb_stat, RPCBVERS_STAT >
 
using rpcb_string = xdr::xstring<>
 
using pmaplist = xdr::pointer< pmaplist_entry >
 
template<typename T >
using wrap_transparent_ptr = typename detail::wrap_transparent_ptr_helper< T >::type
 Wrap xdr::transparent_ptr around each type in a tuple to generate a new tuple type. More...
 
using unique_addrinfo = std::unique_ptr< addrinfo, delete_addrinfo >
 Automatically garbage-collected addrinfo pointer.
 
template<typename T >
using srpc_client = typename T::template _xdr_client< synchronous_client_base >
 Create an RPC client from an interface type and connected stream socket. More...
 
template<typename Session = void, typename SessionAllocator = session_allocator<Session>>
using srpc_tcp_listener = generic_rpc_tcp_listener< srpc_service, Session, SessionAllocator >
 
template<uint32_t N = XDR_MAX_LEN>
using opaque_vec = xvector< std::uint8_t, N >
 Variable-length opaque data is just a vector of std::uint8_t.
 
template<typename T >
using all_indices_of = typename detail::all_indices< std::tuple_size< typename std::remove_reference< T >::type >::value >
 A type representing all the indices of a particuar tuple.
 
using xdr_void = std::tuple<>
 Placehoder type representing void values marshaled as 0 bytes.
 

Enumerations

enum  auth_flavor : std::int32_t {
  AUTH_NONE = 0, AUTH_SYS = 1, AUTH_SHORT = 2, AUTH_DH = 3,
  RPCSEC_GSS = 6
}
 
enum  msg_type : std::int32_t { CALL = 0, REPLY = 1 }
 
enum  reply_stat : std::int32_t { MSG_ACCEPTED = 0, MSG_DENIED = 1 }
 
enum  accept_stat : std::int32_t {
  SUCCESS = 0, PROG_UNAVAIL = 1, PROG_MISMATCH = 2, PROC_UNAVAIL = 3,
  GARBAGE_ARGS = 4, SYSTEM_ERR = 5
}
 
enum  reject_stat : std::int32_t { RPC_MISMATCH = 0, AUTH_ERROR = 1 }
 
enum  auth_stat : std::int32_t {
  AUTH_OK = 0, AUTH_BADCRED = 1, AUTH_REJECTEDCRED = 2, AUTH_BADVERF = 3,
  AUTH_REJECTEDVERF = 4, AUTH_TOOWEAK = 5, AUTH_INVALIDRESP = 6, AUTH_FAILED = 7,
  AUTH_KERB_GENERIC = 8, AUTH_TIMEEXPIRE = 9, AUTH_TKT_FILE = 10, AUTH_DECODE = 11,
  AUTH_NET_ADDR = 12, RPCSEC_GSS_CREDPROBLEM = 13, RPCSEC_GSS_CTXPROBLEM = 14
}
 

Functions

template<typename T >
void xdr_clear (T &t)
 Reset XDR data structure to its default contents. More...
 
Constexpr std::uint32_t swap32 (std::uint32_t v)
 Byteswap 32-bit number.
 
Constexpr std::uint64_t swap64 (std::uint64_t v)
 Byteswap 64-bit number.
 
Constexpr std::uint32_t swap32le (std::uint32_t v)
 Byteswap 32-bit value only on little-endian machines, identity function on big-endian machines. More...
 
Constexpr std::uint32_t swap32be (std::uint32_t v)
 Byteswap 32-bit value only on big-endian machines.
 
Constexpr std::uint64_t swap64le (std::uint64_t v)
 Byteswap 64-bit value only on little-endian machines.
 
Constexpr std::uint64_t swap64be (std::uint64_t v)
 Byteswap 64-bit value only on big-endian machines.
 
const char * rpc_errmsg (accept_stat ev)
 Translate one of the conditions in RFC5531 for an unexecuted call into a string. More...
 
const char * rpc_errmsg (auth_stat ev)
 Translate one of the conditions in RFC5531 for an unexecuted call into a string. More...
 
void check_call_hdr (const rpc_msg &hdr)
 Check that an RPC header precedes a result. More...
 
bool ini_unescape (string::const_iterator, string::const_iterator, string *)
 
void from_string (const string &s, string *sp)
 
void from_string (const string &s, bool *bp)
 
template<class T >
add_base (T(&conv)(const string &, size_t *, int), const string &s, size_t *pos)
 
template<class T >
add_base (T(&conv)(const string &, size_t *), const string &s, size_t *pos)
 
template<typename T , typename U , typename ... Base>
void from_string_with (U(&conv)(const string &, size_t *, Base...), const string &s, T *rp)
 
void ini_runparse (IniActions &a, IniLine &st, std::istream &s)
 Run the ini parser. More...
 
bool ini_parse (IniActions &a, string file)
 Run the parser on a file. More...
 
std::size_t xdr_argpack_size ()
 
template<typename T , typename... Args>
std::size_t xdr_argpack_size (const T &t, const Args &...a)
 Returns the sum of bytes required to marshal all of the argument values. More...
 
template<typename Archive >
void xdr_argpack_archive (Archive &)
 
template<typename Archive , typename T , typename... Args>
void xdr_argpack_archive (Archive &ar, T &&t, Args &&...args)
 Applies an archive to each argument.
 
template<typename... Args>
msg_ptr xdr_to_msg (const Args &...args)
 Marshal one or a series of XDR types into a newly allocated buffer referenced xdr::msg_ptr. More...
 
template<typename... Args>
opaque_vec xdr_to_opaque (const Args &...args)
 Marshal one or a series of XDR types into a newly allocated opaque structure for embedding in other XDR types. More...
 
template<typename... Args>
void xdr_from_msg (const msg_ptr &m, Args &...args)
 This does the reverse of xdr::xdr_to_msg, unmarshalling one or more types from a message. More...
 
template<typename Bytes , typename... Args>
auto xdr_from_opaque (const Bytes &m, Args &...args) -> decltype(detail::bytes_to_void(m.data()))
 The reverse of xdr::xdr_to_opaque. More...
 
std::string escape_string (const std::string &s)
 Use hex escapes for non-printable characters, and prefix backslashes and quotes with backslash. More...
 
std::string hexdump (const void *data, size_t len)
 Turn a string into a double-length sequence of hex nibbles.
 
template<typename T >
std::string xdr_to_string (const T &t, const char *name=nullptr, int indent=0)
 Return a std::string containing a pretty-printed version an XDR data type. More...
 
template<typename T >
std::enable_if< xdr_traits< T >::valid, std::ostream & >::type operator<< (std::ostream &os, const T &t)
 Print an arbitrary XDR structure to a std::ostream. More...
 
unique_sock tcp_connect_rpc (const char *host, std::uint32_t prog, std::uint32_t vers, int family=AF_UNSPEC)
 Create a TCP connection to an RPC server on host, first querying rpcbind on host to determine the port. More...
 
int parse_uaddr_port (const string &uaddr)
 Extract the port number from an RFC1833 / RFC5665 universal network address (uaddr). More...
 
string make_uaddr (const sockaddr *sa, socklen_t salen)
 Create a uaddr for a local address or file descriptor.
 
string make_uaddr (sock_t s)
 
void rpcbind_register (const sockaddr *sa, socklen_t salen, std::uint32_t prog, std::uint32_t vers)
 Register a service listening on sa with rpcbind.
 
void rpcbind_register (sock_t s, std::uint32_t prog, std::uint32_t vers)
 
int parse_uaddr_port (const std::string &uaddr)
 Extract the port number from an RFC1833 / RFC5665 universal network address (uaddr). More...
 
msg_ptr rpc_accepted_error_msg (uint32_t xid, accept_stat stat)
 
msg_ptr rpc_prog_mismatch_msg (uint32_t xid, uint32_t low, uint32_t high)
 
msg_ptr rpc_auth_error_msg (uint32_t xid, auth_stat stat)
 
msg_ptr rpc_rpc_mismatch_msg (uint32_t xid)
 
template<typename Archive , typename T >
void archive (Archive &ar, const transparent_ptr< T > &t, const char *name=nullptr)
 
template<typename P , typename C , typename S , typename T , typename... Rest>
auto dispatch_with_session (C &&c, S *s, T &&t, Rest &&...rest) -> decltype(detail::dispatch_session_helper< P, C, T >::dispatch(c, s, std::forward< T >(t), std::forward< Rest >(rest)...))
 Call P::dispatch with a session pointer (unless the session type S is void, in which case the argument is omitted) and with a tuple that should be unpacked into multiple arguments. More...
 
const std::error_category & gai_category ()
 Category for system errors dealing with DNS (getaddrinfo, etc.).
 
unique_addrinfo get_addrinfo (const char *host, int socktype=SOCK_STREAM, const char *service=nullptr, int family=AF_UNSPEC)
 Wrapper around getaddrinfo that returns a garbage-collected xdr::unique_addrinfo. More...
 
void get_numinfo (const sockaddr *sa, socklen_t salen, string *host, string *serv)
 Return printable versions of numeric host and port number.
 
unique_sock tcp_connect1 (const addrinfo *ai, bool ndelay=false)
 Try connecting to the first addrinfo in a linked list.
 
unique_sock tcp_connect (const addrinfo *ai)
 Try connecting to every addrinfo in a list until one succeeds.
 
unique_sock tcp_connect (const char *host, const char *service, int family)
 
unique_sock tcp_listen (const char *service="0", int family=AF_UNSPEC, int backlog=5)
 Create bind a listening TCP socket.
 
bool sock_eagain ()
 Returns true if the most recent (socket) error is a temporary error, such as EAGAIN, EWOULDBLOCK, or EINTR. More...
 
const char * sock_errmsg ()
 Last socket error message (strerror(errno) on POSIX).
 
void throw_sockerr (const char *)
 Throw a system_error exception for the last socket error.
 
ssize_t read (sock_t s, void *buf, std::size_t count)
 
ssize_t write (sock_t s, const void *buf, std::size_t count)
 
ssize_t readv (sock_t s, const struct iovec *iov, int iovcnt)
 
ssize_t writev (sock_t s, const struct iovec *iov, int iovcnt)
 
void close (sock_t s)
 
void set_nonblock (sock_t s)
 Set the O_NONBLOCK flag on a socket. More...
 
void set_close_on_exec (sock_t s)
 Set the close-on-exec flag of a file descriptor. More...
 
sock_t accept (sock_t s, sockaddr *addr, socklen_t *addrlen)
 Wrapper around accept for sock_t.
 
void create_selfpipe (sock_t ss[2])
 Create a socket (or pipe on unix, where both are file descriptors) that is connected to itself. More...
 
void get_numinfo (const sockaddr *sa, socklen_t salen, std::string *host, std::string *serv)
 Return printable versions of numeric host and port number.
 
unique_sock tcp_connect (const unique_addrinfo &ai)
 
bool sock_eof ()
 
msg_ptr read_message (sock_t s)
 
void write_message (sock_t s, const msg_ptr &m)
 
void prepare_call (uint32_t prog, uint32_t vers, uint32_t proc, rpc_msg &hdr)
 
template<typename P >
void prepare_call (rpc_msg &hdr)
 
uint32_t size32 (std::size_t s)
 
template<typename T >
void validate (const T &t)
 If this function template is specialized, it provides a means of placing extra restrictions on XDR data structures (beyond those of the XDR specification). More...
 
template<typename Archive , typename T >
void archive (Archive &ar, T &&t, const char *name=nullptr)
 By default, this function simply applies ar (which must be a function object) to t. More...
 
template<typename T >
std::size_t xdr_size (const T &t)
 Return the marshaled size of an XDR data type.
 
template<typename To , typename From >
To xdr_reinterpret (From f)
 A reinterpret-cast like function that works between types such as floating-point and integers of the same size. More...
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator== (const T &a, const T &b)
 Equality for XDR structures. More...
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator!= (const T &a, const T &b)
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator< (const T &a, const T &b)
 Ordering of XDR structures. See note at xdr::operator==.
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator> (const T &a, const T &b)
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator<= (const T &a, const T &b)
 
template<typename T >
std::enable_if< xdr_traits< T >::is_struct &&xdr_traits< T >::xdr_defined, bool >::type operator>= (const T &a, const T &b)
 
template<typename T >
std::enable_if< xdr_traits< T >::is_union, bool >::type operator== (const T &a, const T &b)
 Equality of XDR unions. More...
 
template<typename T >
std::enable_if< xdr_traits< T >::is_union, bool >::type operator< (const T &a, const T &b)
 Ordering of XDR unions. See note at xdr::operator==.
 

Variables

Constexpr const bool is_big_endian = false
 True on big endian machines, false on little endian machines.
 
Constexpr const std::uint32_t RPCB_PORT = 111
 
Constexpr const std::uint32_t rpcb_highproc_2 = 5
 
Constexpr const std::uint32_t rpcb_highproc_3 = 8
 
Constexpr const std::uint32_t rpcb_highproc_4 = 12
 
Constexpr const std::uint32_t RPCBSTAT_HIGHPROC = 13
 
Constexpr const std::uint32_t RPCBVERS_STAT = 3
 
Constexpr const std::uint32_t RPCBVERS_4_STAT = 2
 
Constexpr const std::uint32_t RPCBVERS_3_STAT = 1
 
Constexpr const std::uint32_t RPCBVERS_2_STAT = 0
 
Constexpr const std::uint32_t PMAP_PORT = 111
 
bool xdr_trace_server = std::getenv("XDR_TRACE_SERVER")
 
constexpr sock_t invalid_sock {}
 
bool xdr_trace_client = std::getenv("XDR_TRACE_CLIENT")
 
uint32_t xid_counter
 
Constexpr const field_constructor_t field_constructor {}
 Passed to the auto-generated _xdr_with_mem_ptr static method to construct the active union field (or at least the union field corresponding to the second argument to _xdr_with_mem_ptr, which should be the active union field). More...
 
Constexpr const field_destructor_t field_destructor {}
 Passed to _xdr_with_mem_ptr to destroy the active union field.
 
Constexpr const field_assigner_t field_assigner {}
 Passed to _xdr_with_mem_ptr to assign to the active union field.
 
Constexpr const field_archiver_t field_archiver {}
 Passed to _xdr_with_mem_ptr to archive the active union field.
 
Constexpr const field_size_t field_size {}
 Passed to _xdr_with_mem_ptr to compute the size of the active union field. More...
 

Detailed Description

Most of the xdrpp library is encapsulated in the xdr namespace.

Typedef Documentation

◆ wrap_transparent_ptr

template<typename T >
using xdr::wrap_transparent_ptr = typedef typename detail::wrap_transparent_ptr_helper<T>::type

Wrap xdr::transparent_ptr around each type in a tuple to generate a new tuple type.

Definition at line 118 of file server.h.

◆ srpc_client

template<typename T >
using xdr::srpc_client = typedef typename T::template _xdr_client<synchronous_client_base>

Create an RPC client from an interface type and connected stream socket.

Note that the file descriptor is not closed afterwards (as you may wish to use different interfaces over the same file descriptor). A simple example looks like this:

unique_fd fd = tcp_connect_rpc(argc > 2 ? argv[2] : nullptr,
MyProg1::program, MyProg1::version);
srpc_client<MyProg1> c{fd.get()};
unique_ptr<big_string> result = c.hello(5);

Definition at line 95 of file srpc.h.

Function Documentation

◆ xdr_clear()

template<typename T >
void xdr::xdr_clear ( T &  t)

Reset XDR data structure to its default contents.

All vectors and strings are set to length 0, all fixed-size opaque arrays zeroed out, and all numeric and enum types sent to their default values (generally 0).

Definition at line 55 of file clear.h.

◆ swap32le()

Constexpr std::uint32_t xdr::swap32le ( std::uint32_t  v)
inline

Byteswap 32-bit value only on little-endian machines, identity function on big-endian machines.

Definition at line 78 of file endian.h.

◆ rpc_errmsg() [1/2]

const char * xdr::rpc_errmsg ( accept_stat  ev)

Translate one of the conditions in RFC5531 for an unexecuted call into a string.

Definition at line 10 of file rpc_msg.cc.

◆ rpc_errmsg() [2/2]

const char * xdr::rpc_errmsg ( auth_stat  ev)

Translate one of the conditions in RFC5531 for an unexecuted call into a string.

Definition at line 31 of file rpc_msg.cc.

◆ check_call_hdr()

void xdr::check_call_hdr ( const rpc_msg hdr)

Check that an RPC header precedes a result.

Exceptions
xdr_call_errorif the reply does not contain a response.

Definition at line 115 of file rpc_msg.cc.

◆ ini_runparse()

void xdr::ini_runparse ( IniActions a,
IniLine st,
std::istream &  s 
)

Run the ini parser.

Afterwards a.error() will tell you if there was an error.

Definition at line 171 of file iniparse.cc.

◆ ini_parse()

bool xdr::ini_parse ( IniActions a,
string  file 
)

Run the parser on a file.

A simple wrapper around fba::ini_runparse that opens the file.

Definition at line 207 of file iniparse.cc.

◆ xdr_argpack_size()

template<typename T , typename... Args>
std::size_t xdr::xdr_argpack_size ( const T &  t,
const Args &...  a 
)
inline

Returns the sum of bytes required to marshal all of the argument values.

Definition at line 209 of file marshal.h.

◆ xdr_to_msg()

template<typename... Args>
msg_ptr xdr::xdr_to_msg ( const Args &...  args)

Marshal one or a series of XDR types into a newly allocated buffer referenced xdr::msg_ptr.

If more than one argument is given, each XDR value is marshaled in turn. (In particular, this allows one to marshal a header followed by a message body.)

Definition at line 231 of file marshal.h.

◆ xdr_to_opaque()

template<typename... Args>
opaque_vec xdr::xdr_to_opaque ( const Args &...  args)

Marshal one or a series of XDR types into a newly allocated opaque structure for embedding in other XDR types.

Definition at line 243 of file marshal.h.

◆ xdr_from_msg()

template<typename... Args>
void xdr::xdr_from_msg ( const msg_ptr &  m,
Args &...  args 
)

This does the reverse of xdr::xdr_to_msg, unmarshalling one or more types from a message.

Note that it throws an exception if the entire buffer is not consumed.

Definition at line 257 of file marshal.h.

◆ xdr_from_opaque()

template<typename Bytes , typename... Args>
auto xdr::xdr_from_opaque ( const Bytes &  m,
Args &...  args 
) -> decltype(detail::bytes_to_void(m.data()))

The reverse of xdr::xdr_to_opaque.

For convenience, accepts the data in std::string and std::vector (of byte types) in addition to xdr::xdr_opaque<>.

Definition at line 276 of file marshal.h.

◆ escape_string()

std::string xdr::escape_string ( const std::string &  s)

Use hex escapes for non-printable characters, and prefix backslashes and quotes with backslash.

Definition at line 8 of file printer.cc.

◆ xdr_to_string()

template<typename T >
std::string xdr::xdr_to_string ( const T &  t,
const char *  name = nullptr,
int  indent = 0 
)

Return a std::string containing a pretty-printed version an XDR data type.

The string will contain multiple lines and end with a newline.

  • name if non-NULL, the string begins with the name and an equals sign.
  • indent specifies a non-zero minimum indentation.

Definition at line 162 of file printer.h.

◆ operator<<()

template<typename T >
std::enable_if<xdr_traits<T>::valid, std::ostream &>::type xdr::operator<< ( std::ostream &  os,
const T &  t 
)
inline

Print an arbitrary XDR structure to a std::ostream.

To use this function, you will have to say using xdr::operator<< within the namespace of your XDR file. As per the C++ standard, a using directive (i.e., using namespace xdr) will not allow argument-dependent lookup.

Definition at line 177 of file printer.h.

◆ tcp_connect_rpc()

unique_sock xdr::tcp_connect_rpc ( const char *  host,
std::uint32_t  prog,
std::uint32_t  vers,
int  family = AF_UNSPEC 
)

Create a TCP connection to an RPC server on host, first querying rpcbind on host to determine the port.

Definition at line 38 of file rpcbind.cc.

◆ parse_uaddr_port() [1/2]

int xdr::parse_uaddr_port ( const std::string &  uaddr)

Extract the port number from an RFC1833 / RFC5665 universal network address (uaddr).

Definition at line 78 of file rpcbind.cc.

◆ parse_uaddr_port() [2/2]

int xdr::parse_uaddr_port ( const std::string &  uaddr)

Extract the port number from an RFC1833 / RFC5665 universal network address (uaddr).

Definition at line 78 of file rpcbind.cc.

◆ dispatch_with_session()

template<typename P , typename C , typename S , typename T , typename... Rest>
auto xdr::dispatch_with_session ( C &&  c,
S *  s,
T &&  t,
Rest &&...  rest 
) -> decltype(detail::dispatch_session_helper<P, C, T>::dispatch( c, s, std::forward<T>(t), std::forward<Rest>(rest)...))
inline

Call P::dispatch with a session pointer (unless the session type S is void, in which case the argument is omitted) and with a tuple that should be unpacked into multiple arguments.

For example,

dispatch_with_session<P>(c, (void *) 0, make_tuple(1, //! 2), 3, 4);

is equivalent to

P::dispatch(c, 1, 2, 3, 4);

Definition at line 165 of file server.h.

◆ get_addrinfo()

unique_addrinfo xdr::get_addrinfo ( const char *  host,
int  socktype = SOCK_STREAM,
const char *  service = nullptr,
int  family = AF_UNSPEC 
)

Wrapper around getaddrinfo that returns a garbage-collected xdr::unique_addrinfo.

Exceptions
std::system_errorwith xdr::gai_category on failure.

Definition at line 70 of file socket.cc.

◆ sock_eagain()

bool xdr::sock_eagain ( )

Returns true if the most recent (socket) error is a temporary error, such as EAGAIN, EWOULDBLOCK, or EINTR.

Definition at line 18 of file socket_unix.cc.

◆ set_nonblock()

void xdr::set_nonblock ( sock_t  s)

Set the O_NONBLOCK flag on a socket.

Exceptions
std::system_erroron failure.

Definition at line 70 of file socket_unix.cc.

◆ set_close_on_exec()

void xdr::set_close_on_exec ( sock_t  s)

Set the close-on-exec flag of a file descriptor.

Exceptions
std::system_erroron failure.

Definition at line 79 of file socket_unix.cc.

◆ create_selfpipe()

void xdr::create_selfpipe ( sock_t  ss[2])

Create a socket (or pipe on unix, where both are file descriptors) that is connected to itself.

Definition at line 89 of file socket_unix.cc.

◆ validate()

template<typename T >
void xdr::validate ( const T &  t)
inline

If this function template is specialized, it provides a means of placing extra restrictions on XDR data structures (beyond those of the XDR specification).

When a specialized xdr::validate function detects a bad data argument, it should throw an exception of type xdr::xdr_invariant_failed. Note this mechanism only works for user-defined XDR structs and unions. It does not work for enums, typedef aliases, or built-in types (int, hyper, string, vectors, etc.).

Definition at line 113 of file types.h.

◆ archive()

template<typename Archive , typename T >
void xdr::archive ( Archive &  ar,
T &&  t,
const char *  name = nullptr 
)
inline

By default, this function simply applies ar (which must be a function object) to t.

However, it does so via the xdr::archive_adapter template class, which can be specialized to capture the field name as well. Never specialize or overload this function on Archive (specialize xdr::archive_adapter instead). However, in special cases (such as xdr::transparent_ptr) it is reasonable to specialize this function template on T.

Definition at line 140 of file types.h.

◆ xdr_reinterpret()

template<typename To , typename From >
To xdr::xdr_reinterpret ( From  f)
inline

A reinterpret-cast like function that works between types such as floating-point and integers of the same size.

Used in marshaling, so that a single set of byteswap routines can be used on all numeric types including floating point. Uses a union to avoid strict pointer aliasing problems.

Definition at line 215 of file types.h.

◆ operator==() [1/2]

template<typename T >
std::enable_if<xdr_traits<T>::is_struct && xdr_traits<T>::xdr_defined, bool>::type xdr::operator== ( const T &  a,
const T &  b 
)
inline

Equality for XDR structures.

To use this operator, you will have to include using declaration using xdr::operator== in the namespace of your XDR file. Note that a using namespace xdr using directive (as opposed to declaration) is insufficient, because the C++ standard explicitly prevents using directives from impacting argument-dependent lookup. A using namespace xdr directive at global scope is also insufficient, though more subtly, because standard library functions for comparing vectors will fail.

Definition at line 947 of file types.h.

◆ operator==() [2/2]

template<typename T >
std::enable_if<xdr_traits<T>::is_union, bool>::type xdr::operator== ( const T &  a,
const T &  b 
)
inline

Equality of XDR unions.

See note at xdr::operator== for XDR structs.

Definition at line 1017 of file types.h.

Variable Documentation

◆ field_constructor

Constexpr const field_constructor_t xdr::field_constructor {}

Passed to the auto-generated _xdr_with_mem_ptr static method to construct the active union field (or at least the union field corresponding to the second argument to _xdr_with_mem_ptr, which should be the active union field).

Definition at line 855 of file types.h.

◆ field_size

Constexpr const field_size_t xdr::field_size {}

Passed to _xdr_with_mem_ptr to compute the size of the active union field.

Definition at line 899 of file types.h.