xdrpp
RFC4506 XDR compiler and message library
rpc_msg.hh
1 // -*- C++ -*-
2 // Automatically generated from xdrpp/rpc_msg.x.
3 // DO NOT EDIT or your changes may be overwritten
4 
5 #ifndef __XDR_XDRPP_RPC_MSG_HH_INCLUDED__
6 #define __XDR_XDRPP_RPC_MSG_HH_INCLUDED__ 1
7 
8 #include <xdrpp/types.h>
9 
10 namespace xdr {
11 
12 enum auth_flavor : std::int32_t {
13  AUTH_NONE = 0,
14  AUTH_SYS = 1,
15  AUTH_SHORT = 2,
16  AUTH_DH = 3,
17  RPCSEC_GSS = 6,
18 };
19 } namespace xdr {
20 template<> struct xdr_traits<::xdr::auth_flavor>
21  : xdr_integral_base<::xdr::auth_flavor, std::uint32_t> {
22  using case_type = std::int32_t;
23  static Constexpr const bool is_enum = true;
24  static Constexpr const bool is_numeric = false;
25  static const char *enum_name(::xdr::auth_flavor val) {
26  switch (val) {
27  case ::xdr::AUTH_NONE:
28  return "AUTH_NONE";
29  case ::xdr::AUTH_SYS:
30  return "AUTH_SYS";
31  case ::xdr::AUTH_SHORT:
32  return "AUTH_SHORT";
33  case ::xdr::AUTH_DH:
34  return "AUTH_DH";
35  case ::xdr::RPCSEC_GSS:
36  return "RPCSEC_GSS";
37  default:
38  return nullptr;
39  }
40  }
41  static const std::vector<int32_t> &enum_values() {
42  static const std::vector<int32_t> _xdr_enum_vec = {
43  ::xdr::AUTH_NONE,
44  ::xdr::AUTH_SYS,
45  ::xdr::AUTH_SHORT,
46  ::xdr::AUTH_DH,
47  ::xdr::RPCSEC_GSS
48  };
49  return _xdr_enum_vec;
50  }
51 };
52 } namespace xdr {
53 
54 struct opaque_auth {
55  auth_flavor flavor{};
56  xdr::opaque_vec<400> body{};
57 
58  opaque_auth() = default;
59  template<typename _flavor_T,
60  typename _body_T,
61  typename = typename
62  std::enable_if<std::is_constructible<auth_flavor, _flavor_T>::value
63  && std::is_constructible<xdr::opaque_vec<400>, _body_T>::value
64  >::type>
65  explicit opaque_auth(_flavor_T &&_flavor,
66  _body_T &&_body)
67  : flavor(std::forward<_flavor_T>(_flavor)),
68  body(std::forward<_body_T>(_body)) {}
69 };
70 } namespace xdr {
71 template<> struct xdr_traits<::xdr::opaque_auth>
72  : xdr_struct_base<field_ptr<::xdr::opaque_auth,
73  decltype(::xdr::opaque_auth::flavor),
74  &::xdr::opaque_auth::flavor>,
75  field_ptr<::xdr::opaque_auth,
76  decltype(::xdr::opaque_auth::body),
77  &::xdr::opaque_auth::body>> {
78  template<typename Archive> static void
79  save(Archive &ar, const ::xdr::opaque_auth &obj) {
80  archive(ar, obj.flavor, "flavor");
81  archive(ar, obj.body, "body");
82  }
83  template<typename Archive> static void
84  load(Archive &ar, ::xdr::opaque_auth &obj) {
85  archive(ar, obj.flavor, "flavor");
86  archive(ar, obj.body, "body");
87  xdr::validate(obj);
88  }
89 };
90 } namespace xdr {
91 
92 enum msg_type : std::int32_t {
93  CALL = 0,
94  REPLY = 1,
95 };
96 } namespace xdr {
97 template<> struct xdr_traits<::xdr::msg_type>
98  : xdr_integral_base<::xdr::msg_type, std::uint32_t> {
99  using case_type = std::int32_t;
100  static Constexpr const bool is_enum = true;
101  static Constexpr const bool is_numeric = false;
102  static const char *enum_name(::xdr::msg_type val) {
103  switch (val) {
104  case ::xdr::CALL:
105  return "CALL";
106  case ::xdr::REPLY:
107  return "REPLY";
108  default:
109  return nullptr;
110  }
111  }
112  static const std::vector<int32_t> &enum_values() {
113  static const std::vector<int32_t> _xdr_enum_vec = {
114  ::xdr::CALL,
115  ::xdr::REPLY
116  };
117  return _xdr_enum_vec;
118  }
119 };
120 } namespace xdr {
121 
122 enum reply_stat : std::int32_t {
123  MSG_ACCEPTED = 0,
124  MSG_DENIED = 1,
125 };
126 } namespace xdr {
127 template<> struct xdr_traits<::xdr::reply_stat>
128  : xdr_integral_base<::xdr::reply_stat, std::uint32_t> {
129  using case_type = std::int32_t;
130  static Constexpr const bool is_enum = true;
131  static Constexpr const bool is_numeric = false;
132  static const char *enum_name(::xdr::reply_stat val) {
133  switch (val) {
134  case ::xdr::MSG_ACCEPTED:
135  return "MSG_ACCEPTED";
136  case ::xdr::MSG_DENIED:
137  return "MSG_DENIED";
138  default:
139  return nullptr;
140  }
141  }
142  static const std::vector<int32_t> &enum_values() {
143  static const std::vector<int32_t> _xdr_enum_vec = {
144  ::xdr::MSG_ACCEPTED,
145  ::xdr::MSG_DENIED
146  };
147  return _xdr_enum_vec;
148  }
149 };
150 } namespace xdr {
151 
152 enum accept_stat : std::int32_t {
153  SUCCESS = 0,
154  PROG_UNAVAIL = 1,
155  PROG_MISMATCH = 2,
156  PROC_UNAVAIL = 3,
157  GARBAGE_ARGS = 4,
158  SYSTEM_ERR = 5,
159 };
160 } namespace xdr {
161 template<> struct xdr_traits<::xdr::accept_stat>
162  : xdr_integral_base<::xdr::accept_stat, std::uint32_t> {
163  using case_type = std::int32_t;
164  static Constexpr const bool is_enum = true;
165  static Constexpr const bool is_numeric = false;
166  static const char *enum_name(::xdr::accept_stat val) {
167  switch (val) {
168  case ::xdr::SUCCESS:
169  return "SUCCESS";
170  case ::xdr::PROG_UNAVAIL:
171  return "PROG_UNAVAIL";
172  case ::xdr::PROG_MISMATCH:
173  return "PROG_MISMATCH";
174  case ::xdr::PROC_UNAVAIL:
175  return "PROC_UNAVAIL";
176  case ::xdr::GARBAGE_ARGS:
177  return "GARBAGE_ARGS";
178  case ::xdr::SYSTEM_ERR:
179  return "SYSTEM_ERR";
180  default:
181  return nullptr;
182  }
183  }
184  static const std::vector<int32_t> &enum_values() {
185  static const std::vector<int32_t> _xdr_enum_vec = {
186  ::xdr::SUCCESS,
187  ::xdr::PROG_UNAVAIL,
188  ::xdr::PROG_MISMATCH,
189  ::xdr::PROC_UNAVAIL,
190  ::xdr::GARBAGE_ARGS,
191  ::xdr::SYSTEM_ERR
192  };
193  return _xdr_enum_vec;
194  }
195 };
196 } namespace xdr {
197 
198 enum reject_stat : std::int32_t {
199  RPC_MISMATCH = 0,
200  AUTH_ERROR = 1,
201 };
202 } namespace xdr {
203 template<> struct xdr_traits<::xdr::reject_stat>
204  : xdr_integral_base<::xdr::reject_stat, std::uint32_t> {
205  using case_type = std::int32_t;
206  static Constexpr const bool is_enum = true;
207  static Constexpr const bool is_numeric = false;
208  static const char *enum_name(::xdr::reject_stat val) {
209  switch (val) {
210  case ::xdr::RPC_MISMATCH:
211  return "RPC_MISMATCH";
212  case ::xdr::AUTH_ERROR:
213  return "AUTH_ERROR";
214  default:
215  return nullptr;
216  }
217  }
218  static const std::vector<int32_t> &enum_values() {
219  static const std::vector<int32_t> _xdr_enum_vec = {
220  ::xdr::RPC_MISMATCH,
221  ::xdr::AUTH_ERROR
222  };
223  return _xdr_enum_vec;
224  }
225 };
226 } namespace xdr {
227 
228 enum auth_stat : std::int32_t {
229  AUTH_OK = 0,
230  AUTH_BADCRED = 1,
231  AUTH_REJECTEDCRED = 2,
232  AUTH_BADVERF = 3,
233  AUTH_REJECTEDVERF = 4,
234  AUTH_TOOWEAK = 5,
235  AUTH_INVALIDRESP = 6,
236  AUTH_FAILED = 7,
237  AUTH_KERB_GENERIC = 8,
238  AUTH_TIMEEXPIRE = 9,
239  AUTH_TKT_FILE = 10,
240  AUTH_DECODE = 11,
241  AUTH_NET_ADDR = 12,
242  RPCSEC_GSS_CREDPROBLEM = 13,
243  RPCSEC_GSS_CTXPROBLEM = 14,
244 };
245 } namespace xdr {
246 template<> struct xdr_traits<::xdr::auth_stat>
247  : xdr_integral_base<::xdr::auth_stat, std::uint32_t> {
248  using case_type = std::int32_t;
249  static Constexpr const bool is_enum = true;
250  static Constexpr const bool is_numeric = false;
251  static const char *enum_name(::xdr::auth_stat val) {
252  switch (val) {
253  case ::xdr::AUTH_OK:
254  return "AUTH_OK";
255  case ::xdr::AUTH_BADCRED:
256  return "AUTH_BADCRED";
257  case ::xdr::AUTH_REJECTEDCRED:
258  return "AUTH_REJECTEDCRED";
259  case ::xdr::AUTH_BADVERF:
260  return "AUTH_BADVERF";
261  case ::xdr::AUTH_REJECTEDVERF:
262  return "AUTH_REJECTEDVERF";
263  case ::xdr::AUTH_TOOWEAK:
264  return "AUTH_TOOWEAK";
265  case ::xdr::AUTH_INVALIDRESP:
266  return "AUTH_INVALIDRESP";
267  case ::xdr::AUTH_FAILED:
268  return "AUTH_FAILED";
269  case ::xdr::AUTH_KERB_GENERIC:
270  return "AUTH_KERB_GENERIC";
271  case ::xdr::AUTH_TIMEEXPIRE:
272  return "AUTH_TIMEEXPIRE";
273  case ::xdr::AUTH_TKT_FILE:
274  return "AUTH_TKT_FILE";
275  case ::xdr::AUTH_DECODE:
276  return "AUTH_DECODE";
277  case ::xdr::AUTH_NET_ADDR:
278  return "AUTH_NET_ADDR";
279  case ::xdr::RPCSEC_GSS_CREDPROBLEM:
280  return "RPCSEC_GSS_CREDPROBLEM";
281  case ::xdr::RPCSEC_GSS_CTXPROBLEM:
282  return "RPCSEC_GSS_CTXPROBLEM";
283  default:
284  return nullptr;
285  }
286  }
287  static const std::vector<int32_t> &enum_values() {
288  static const std::vector<int32_t> _xdr_enum_vec = {
289  ::xdr::AUTH_OK,
290  ::xdr::AUTH_BADCRED,
291  ::xdr::AUTH_REJECTEDCRED,
292  ::xdr::AUTH_BADVERF,
293  ::xdr::AUTH_REJECTEDVERF,
294  ::xdr::AUTH_TOOWEAK,
295  ::xdr::AUTH_INVALIDRESP,
296  ::xdr::AUTH_FAILED,
297  ::xdr::AUTH_KERB_GENERIC,
298  ::xdr::AUTH_TIMEEXPIRE,
299  ::xdr::AUTH_TKT_FILE,
300  ::xdr::AUTH_DECODE,
301  ::xdr::AUTH_NET_ADDR,
302  ::xdr::RPCSEC_GSS_CREDPROBLEM,
303  ::xdr::RPCSEC_GSS_CTXPROBLEM
304  };
305  return _xdr_enum_vec;
306  }
307 };
308 } namespace xdr {
309 
310 struct call_body {
311  std::uint32_t rpcvers{};
312  std::uint32_t prog{};
313  std::uint32_t vers{};
314  std::uint32_t proc{};
315  opaque_auth cred{};
316  opaque_auth verf{};
317 
318  call_body() = default;
319  template<typename _rpcvers_T,
320  typename _prog_T,
321  typename _vers_T,
322  typename _proc_T,
323  typename _cred_T,
324  typename _verf_T,
325  typename = typename
326  std::enable_if<std::is_constructible<std::uint32_t, _rpcvers_T>::value
327  && std::is_constructible<std::uint32_t, _prog_T>::value
328  && std::is_constructible<std::uint32_t, _vers_T>::value
329  && std::is_constructible<std::uint32_t, _proc_T>::value
330  && std::is_constructible<opaque_auth, _cred_T>::value
331  && std::is_constructible<opaque_auth, _verf_T>::value
332  >::type>
333  explicit call_body(_rpcvers_T &&_rpcvers,
334  _prog_T &&_prog,
335  _vers_T &&_vers,
336  _proc_T &&_proc,
337  _cred_T &&_cred,
338  _verf_T &&_verf)
339  : rpcvers(std::forward<_rpcvers_T>(_rpcvers)),
340  prog(std::forward<_prog_T>(_prog)),
341  vers(std::forward<_vers_T>(_vers)),
342  proc(std::forward<_proc_T>(_proc)),
343  cred(std::forward<_cred_T>(_cred)),
344  verf(std::forward<_verf_T>(_verf)) {}
345 };
346 } namespace xdr {
347 template<> struct xdr_traits<::xdr::call_body>
348  : xdr_struct_base<field_ptr<::xdr::call_body,
349  decltype(::xdr::call_body::rpcvers),
350  &::xdr::call_body::rpcvers>,
351  field_ptr<::xdr::call_body,
352  decltype(::xdr::call_body::prog),
353  &::xdr::call_body::prog>,
354  field_ptr<::xdr::call_body,
355  decltype(::xdr::call_body::vers),
356  &::xdr::call_body::vers>,
357  field_ptr<::xdr::call_body,
358  decltype(::xdr::call_body::proc),
359  &::xdr::call_body::proc>,
360  field_ptr<::xdr::call_body,
361  decltype(::xdr::call_body::cred),
362  &::xdr::call_body::cred>,
363  field_ptr<::xdr::call_body,
364  decltype(::xdr::call_body::verf),
365  &::xdr::call_body::verf>> {
366  template<typename Archive> static void
367  save(Archive &ar, const ::xdr::call_body &obj) {
368  archive(ar, obj.rpcvers, "rpcvers");
369  archive(ar, obj.prog, "prog");
370  archive(ar, obj.vers, "vers");
371  archive(ar, obj.proc, "proc");
372  archive(ar, obj.cred, "cred");
373  archive(ar, obj.verf, "verf");
374  }
375  template<typename Archive> static void
376  load(Archive &ar, ::xdr::call_body &obj) {
377  archive(ar, obj.rpcvers, "rpcvers");
378  archive(ar, obj.prog, "prog");
379  archive(ar, obj.vers, "vers");
380  archive(ar, obj.proc, "proc");
381  archive(ar, obj.cred, "cred");
382  archive(ar, obj.verf, "verf");
383  xdr::validate(obj);
384  }
385 };
386 } namespace xdr {
387 
389  struct _reply_data_t {
391  std::uint32_t low{};
392  std::uint32_t high{};
393 
394  _mismatch_info_t() = default;
395  template<typename _low_T,
396  typename _high_T,
397  typename = typename
398  std::enable_if<std::is_constructible<std::uint32_t, _low_T>::value
399  && std::is_constructible<std::uint32_t, _high_T>::value
400  >::type>
401  explicit _mismatch_info_t(_low_T &&_low,
402  _high_T &&_high)
403  : low(std::forward<_low_T>(_low)),
404  high(std::forward<_high_T>(_high)) {}
405  };
406 
407  using _xdr_case_type = xdr::xdr_traits<accept_stat>::case_type;
408  private:
409  _xdr_case_type stat_;
410  union {
411  xdr::opaque_array<0> results_;
412  _mismatch_info_t mismatch_info_;
413  };
414 
415  public:
416  static const std::vector<accept_stat> &_xdr_discriminant_values() {
417  static const std::vector<accept_stat> _xdr_disc_vec {};
418  return _xdr_disc_vec;
419  }
420  static Constexpr int _xdr_field_number(_xdr_case_type which) {
421  return which == SUCCESS ? 1
422  : which == PROG_MISMATCH ? 2
423  : 0;
424  }
425  template<typename _F, typename..._A> static bool
426  _xdr_with_mem_ptr(_F &_f, _xdr_case_type _which, _A&&..._a) {
427  switch (_which) {
428  case SUCCESS:
429  _f(&_reply_data_t::results_, std::forward<_A>(_a)...);
430  return true;
431  case PROG_MISMATCH:
432  _f(&_reply_data_t::mismatch_info_, std::forward<_A>(_a)...);
433  return true;
434  default:
435  return true;
436  }
437  }
438 
439  _xdr_case_type _xdr_discriminant() const { return stat_; }
440  void _xdr_discriminant(_xdr_case_type which, bool validate = true) {
441  int fnum = _xdr_field_number(which);
442  if (fnum < 0 && validate)
443  throw xdr::xdr_bad_discriminant("bad value of stat in _reply_data_t");
444  if (fnum != _xdr_field_number(stat_)) {
445  this->~_reply_data_t();
446  stat_ = which;
447  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
448  }
449  else
450  stat_ = which;
451  }
452  explicit _reply_data_t(accept_stat which = accept_stat{}) : stat_(which) {
453  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
454  }
455  _reply_data_t(const _reply_data_t &source) : stat_(source.stat_) {
456  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this, source);
457  }
458  _reply_data_t(_reply_data_t &&source) : stat_(source.stat_) {
459  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this,
460  std::move(source));
461  }
462  ~_reply_data_t() { _xdr_with_mem_ptr(xdr::field_destructor, stat_, *this); }
463  _reply_data_t &operator=(const _reply_data_t &source) {
464  if (_xdr_field_number(stat_)
465  == _xdr_field_number(source.stat_))
466  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this, source);
467  else {
468  this->~_reply_data_t();
469  stat_ = std::numeric_limits<_xdr_case_type>::max();
470  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this, source);
471  }
472  stat_ = source.stat_;
473  return *this;
474  }
475  _reply_data_t &operator=(_reply_data_t &&source) {
476  if (_xdr_field_number(stat_)
477  == _xdr_field_number(source.stat_))
478  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this,
479  std::move(source));
480  else {
481  this->~_reply_data_t();
482  stat_ = std::numeric_limits<_xdr_case_type>::max();
483  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this,
484  std::move(source));
485  }
486  stat_ = source.stat_;
487  return *this;
488  }
489 
490  accept_stat stat() const { return accept_stat(stat_); }
491  _reply_data_t &stat(accept_stat _xdr_d, bool _xdr_validate = true) {
492  _xdr_discriminant(_xdr_d, _xdr_validate);
493  return *this;
494  }
495 
496  xdr::opaque_array<0> &results() {
497  if (_xdr_field_number(stat_) == 1)
498  return results_;
499  throw xdr::xdr_wrong_union("_reply_data_t: results accessed when not selected");
500  }
501  const xdr::opaque_array<0> &results() const {
502  if (_xdr_field_number(stat_) == 1)
503  return results_;
504  throw xdr::xdr_wrong_union("_reply_data_t: results accessed when not selected");
505  }
506  _mismatch_info_t &mismatch_info() {
507  if (_xdr_field_number(stat_) == 2)
508  return mismatch_info_;
509  throw xdr::xdr_wrong_union("_reply_data_t: mismatch_info accessed when not selected");
510  }
511  const _mismatch_info_t &mismatch_info() const {
512  if (_xdr_field_number(stat_) == 2)
513  return mismatch_info_;
514  throw xdr::xdr_wrong_union("_reply_data_t: mismatch_info accessed when not selected");
515  }
516  };
517 
518  opaque_auth verf{};
519  _reply_data_t reply_data{};
520 
521  accepted_reply() = default;
522  template<typename _verf_T,
523  typename _reply_data_T,
524  typename = typename
525  std::enable_if<std::is_constructible<opaque_auth, _verf_T>::value
526  && std::is_constructible<_reply_data_t, _reply_data_T>::value
527  >::type>
528  explicit accepted_reply(_verf_T &&_verf,
529  _reply_data_T &&_reply_data)
530  : verf(std::forward<_verf_T>(_verf)),
531  reply_data(std::forward<_reply_data_T>(_reply_data)) {}
532 };
533 } namespace xdr {
535  : xdr_struct_base<field_ptr<::xdr::accepted_reply::_reply_data_t::_mismatch_info_t,
536  decltype(::xdr::accepted_reply::_reply_data_t::_mismatch_info_t::low),
537  &::xdr::accepted_reply::_reply_data_t::_mismatch_info_t::low>,
538  field_ptr<::xdr::accepted_reply::_reply_data_t::_mismatch_info_t,
539  decltype(::xdr::accepted_reply::_reply_data_t::_mismatch_info_t::high),
540  &::xdr::accepted_reply::_reply_data_t::_mismatch_info_t::high>> {
541  template<typename Archive> static void
542  save(Archive &ar, const ::xdr::accepted_reply::_reply_data_t::_mismatch_info_t &obj) {
543  archive(ar, obj.low, "low");
544  archive(ar, obj.high, "high");
545  }
546  template<typename Archive> static void
547  load(Archive &ar, ::xdr::accepted_reply::_reply_data_t::_mismatch_info_t &obj) {
548  archive(ar, obj.low, "low");
549  archive(ar, obj.high, "high");
550  xdr::validate(obj);
551  }
552 };
554  static Constexpr const bool is_class = true;
555  static Constexpr const bool is_union = true;
556  static Constexpr const bool has_fixed_size = false;
557 
559  using case_type = ::xdr::accepted_reply::_reply_data_t::_xdr_case_type;
560  using discriminant_type = decltype(std::declval<union_type>().stat());
561 
562  static const char *union_field_name(case_type which) {
563  switch (union_type::_xdr_field_number(which)) {
564  case 1:
565  return "results";
566  case 2:
567  return "mismatch_info";
568  }
569  return nullptr;
570  }
571  static const char *union_field_name(const union_type &u) {
572  return union_field_name(u._xdr_discriminant());
573  }
574 
575  static std::size_t serial_size(const ::xdr::accepted_reply::_reply_data_t &obj) {
576  std::size_t size = 0;
577  if (!obj._xdr_with_mem_ptr(field_size, obj._xdr_discriminant(), obj, size))
578  throw xdr_bad_discriminant("bad value of stat in _reply_data_t");
579  return size + 4;
580  }
581  template<typename Archive> static void
582  save(Archive &ar, const ::xdr::accepted_reply::_reply_data_t &obj) {
583  xdr::archive(ar, obj.stat(), "stat");
584  if (!obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
585  union_field_name(obj)))
586  throw xdr_bad_discriminant("bad value of stat in _reply_data_t");
587  }
588  template<typename Archive> static void
589  load(Archive &ar, ::xdr::accepted_reply::_reply_data_t &obj) {
590  discriminant_type which;
591  xdr::archive(ar, which, "stat");
592  obj.stat(which);
593  obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
594  union_field_name(which));
595  xdr::validate(obj);
596  }
597 };
598 template<> struct xdr_traits<::xdr::accepted_reply>
599  : xdr_struct_base<field_ptr<::xdr::accepted_reply,
600  decltype(::xdr::accepted_reply::verf),
601  &::xdr::accepted_reply::verf>,
602  field_ptr<::xdr::accepted_reply,
603  decltype(::xdr::accepted_reply::reply_data),
604  &::xdr::accepted_reply::reply_data>> {
605  template<typename Archive> static void
606  save(Archive &ar, const ::xdr::accepted_reply &obj) {
607  archive(ar, obj.verf, "verf");
608  archive(ar, obj.reply_data, "reply_data");
609  }
610  template<typename Archive> static void
611  load(Archive &ar, ::xdr::accepted_reply &obj) {
612  archive(ar, obj.verf, "verf");
613  archive(ar, obj.reply_data, "reply_data");
614  xdr::validate(obj);
615  }
616 };
617 } namespace xdr {
618 
621  std::uint32_t low{};
622  std::uint32_t high{};
623 
624  _mismatch_info_t() = default;
625  template<typename _low_T,
626  typename _high_T,
627  typename = typename
628  std::enable_if<std::is_constructible<std::uint32_t, _low_T>::value
629  && std::is_constructible<std::uint32_t, _high_T>::value
630  >::type>
631  explicit _mismatch_info_t(_low_T &&_low,
632  _high_T &&_high)
633  : low(std::forward<_low_T>(_low)),
634  high(std::forward<_high_T>(_high)) {}
635  };
636 
637  using _xdr_case_type = xdr::xdr_traits<reject_stat>::case_type;
638 private:
639  _xdr_case_type stat_;
640  union {
641  _mismatch_info_t mismatch_info_;
642  auth_stat rj_why_;
643  };
644 
645 public:
646  static const std::vector<reject_stat> &_xdr_discriminant_values() {
647  static const std::vector<reject_stat> _xdr_disc_vec {
648  RPC_MISMATCH,
649  AUTH_ERROR
650  };
651  return _xdr_disc_vec;
652  }
653  static Constexpr int _xdr_field_number(_xdr_case_type which) {
654  return which == RPC_MISMATCH ? 1
655  : which == AUTH_ERROR ? 2
656  : -1;
657  }
658  template<typename _F, typename..._A> static bool
659  _xdr_with_mem_ptr(_F &_f, _xdr_case_type _which, _A&&..._a) {
660  switch (_which) {
661  case RPC_MISMATCH:
662  _f(&rejected_reply::mismatch_info_, std::forward<_A>(_a)...);
663  return true;
664  case AUTH_ERROR:
665  _f(&rejected_reply::rj_why_, std::forward<_A>(_a)...);
666  return true;
667  }
668  return false;
669  }
670 
671  _xdr_case_type _xdr_discriminant() const { return stat_; }
672  void _xdr_discriminant(_xdr_case_type which, bool validate = true) {
673  int fnum = _xdr_field_number(which);
674  if (fnum < 0 && validate)
675  throw xdr::xdr_bad_discriminant("bad value of stat in rejected_reply");
676  if (fnum != _xdr_field_number(stat_)) {
677  this->~rejected_reply();
678  stat_ = which;
679  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
680  }
681  else
682  stat_ = which;
683  }
684  explicit rejected_reply(reject_stat which = reject_stat{}) : stat_(which) {
685  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
686  }
687  rejected_reply(const rejected_reply &source) : stat_(source.stat_) {
688  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this, source);
689  }
690  rejected_reply(rejected_reply &&source) : stat_(source.stat_) {
691  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this,
692  std::move(source));
693  }
694  ~rejected_reply() { _xdr_with_mem_ptr(xdr::field_destructor, stat_, *this); }
695  rejected_reply &operator=(const rejected_reply &source) {
696  if (_xdr_field_number(stat_)
697  == _xdr_field_number(source.stat_))
698  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this, source);
699  else {
700  this->~rejected_reply();
701  stat_ = std::numeric_limits<_xdr_case_type>::max();
702  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this, source);
703  }
704  stat_ = source.stat_;
705  return *this;
706  }
707  rejected_reply &operator=(rejected_reply &&source) {
708  if (_xdr_field_number(stat_)
709  == _xdr_field_number(source.stat_))
710  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this,
711  std::move(source));
712  else {
713  this->~rejected_reply();
714  stat_ = std::numeric_limits<_xdr_case_type>::max();
715  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this,
716  std::move(source));
717  }
718  stat_ = source.stat_;
719  return *this;
720  }
721 
722  reject_stat stat() const { return reject_stat(stat_); }
723  rejected_reply &stat(reject_stat _xdr_d, bool _xdr_validate = true) {
724  _xdr_discriminant(_xdr_d, _xdr_validate);
725  return *this;
726  }
727 
728  _mismatch_info_t &mismatch_info() {
729  if (_xdr_field_number(stat_) == 1)
730  return mismatch_info_;
731  throw xdr::xdr_wrong_union("rejected_reply: mismatch_info accessed when not selected");
732  }
733  const _mismatch_info_t &mismatch_info() const {
734  if (_xdr_field_number(stat_) == 1)
735  return mismatch_info_;
736  throw xdr::xdr_wrong_union("rejected_reply: mismatch_info accessed when not selected");
737  }
738  auth_stat &rj_why() {
739  if (_xdr_field_number(stat_) == 2)
740  return rj_why_;
741  throw xdr::xdr_wrong_union("rejected_reply: rj_why accessed when not selected");
742  }
743  const auth_stat &rj_why() const {
744  if (_xdr_field_number(stat_) == 2)
745  return rj_why_;
746  throw xdr::xdr_wrong_union("rejected_reply: rj_why accessed when not selected");
747  }
748 };
749 } namespace xdr {
751  : xdr_struct_base<field_ptr<::xdr::rejected_reply::_mismatch_info_t,
752  decltype(::xdr::rejected_reply::_mismatch_info_t::low),
753  &::xdr::rejected_reply::_mismatch_info_t::low>,
754  field_ptr<::xdr::rejected_reply::_mismatch_info_t,
755  decltype(::xdr::rejected_reply::_mismatch_info_t::high),
756  &::xdr::rejected_reply::_mismatch_info_t::high>> {
757  template<typename Archive> static void
758  save(Archive &ar, const ::xdr::rejected_reply::_mismatch_info_t &obj) {
759  archive(ar, obj.low, "low");
760  archive(ar, obj.high, "high");
761  }
762  template<typename Archive> static void
763  load(Archive &ar, ::xdr::rejected_reply::_mismatch_info_t &obj) {
764  archive(ar, obj.low, "low");
765  archive(ar, obj.high, "high");
766  xdr::validate(obj);
767  }
768 };
770  static Constexpr const bool is_class = true;
771  static Constexpr const bool is_union = true;
772  static Constexpr const bool has_fixed_size = false;
773 
775  using case_type = ::xdr::rejected_reply::_xdr_case_type;
776  using discriminant_type = decltype(std::declval<union_type>().stat());
777 
778  static const char *union_field_name(case_type which) {
779  switch (union_type::_xdr_field_number(which)) {
780  case 1:
781  return "mismatch_info";
782  case 2:
783  return "rj_why";
784  }
785  return nullptr;
786  }
787  static const char *union_field_name(const union_type &u) {
788  return union_field_name(u._xdr_discriminant());
789  }
790 
791  static std::size_t serial_size(const ::xdr::rejected_reply &obj) {
792  std::size_t size = 0;
793  if (!obj._xdr_with_mem_ptr(field_size, obj._xdr_discriminant(), obj, size))
794  throw xdr_bad_discriminant("bad value of stat in rejected_reply");
795  return size + 4;
796  }
797  template<typename Archive> static void
798  save(Archive &ar, const ::xdr::rejected_reply &obj) {
799  xdr::archive(ar, obj.stat(), "stat");
800  if (!obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
801  union_field_name(obj)))
802  throw xdr_bad_discriminant("bad value of stat in rejected_reply");
803  }
804  template<typename Archive> static void
805  load(Archive &ar, ::xdr::rejected_reply &obj) {
806  discriminant_type which;
807  xdr::archive(ar, which, "stat");
808  obj.stat(which);
809  obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
810  union_field_name(which));
811  xdr::validate(obj);
812  }
813 };
814 } namespace xdr {
815 
816 struct reply_body {
817  using _xdr_case_type = xdr::xdr_traits<reply_stat>::case_type;
818 private:
819  _xdr_case_type stat_;
820  union {
821  accepted_reply areply_;
822  rejected_reply rreply_;
823  };
824 
825 public:
826  static const std::vector<reply_stat> &_xdr_discriminant_values() {
827  static const std::vector<reply_stat> _xdr_disc_vec {
828  MSG_ACCEPTED,
829  MSG_DENIED
830  };
831  return _xdr_disc_vec;
832  }
833  static Constexpr int _xdr_field_number(_xdr_case_type which) {
834  return which == MSG_ACCEPTED ? 1
835  : which == MSG_DENIED ? 2
836  : -1;
837  }
838  template<typename _F, typename..._A> static bool
839  _xdr_with_mem_ptr(_F &_f, _xdr_case_type _which, _A&&..._a) {
840  switch (_which) {
841  case MSG_ACCEPTED:
842  _f(&reply_body::areply_, std::forward<_A>(_a)...);
843  return true;
844  case MSG_DENIED:
845  _f(&reply_body::rreply_, std::forward<_A>(_a)...);
846  return true;
847  }
848  return false;
849  }
850 
851  _xdr_case_type _xdr_discriminant() const { return stat_; }
852  void _xdr_discriminant(_xdr_case_type which, bool validate = true) {
853  int fnum = _xdr_field_number(which);
854  if (fnum < 0 && validate)
855  throw xdr::xdr_bad_discriminant("bad value of stat in reply_body");
856  if (fnum != _xdr_field_number(stat_)) {
857  this->~reply_body();
858  stat_ = which;
859  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
860  }
861  else
862  stat_ = which;
863  }
864  explicit reply_body(reply_stat which = reply_stat{}) : stat_(which) {
865  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this);
866  }
867  reply_body(const reply_body &source) : stat_(source.stat_) {
868  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this, source);
869  }
870  reply_body(reply_body &&source) : stat_(source.stat_) {
871  _xdr_with_mem_ptr(xdr::field_constructor, stat_, *this,
872  std::move(source));
873  }
874  ~reply_body() { _xdr_with_mem_ptr(xdr::field_destructor, stat_, *this); }
875  reply_body &operator=(const reply_body &source) {
876  if (_xdr_field_number(stat_)
877  == _xdr_field_number(source.stat_))
878  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this, source);
879  else {
880  this->~reply_body();
881  stat_ = std::numeric_limits<_xdr_case_type>::max();
882  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this, source);
883  }
884  stat_ = source.stat_;
885  return *this;
886  }
887  reply_body &operator=(reply_body &&source) {
888  if (_xdr_field_number(stat_)
889  == _xdr_field_number(source.stat_))
890  _xdr_with_mem_ptr(xdr::field_assigner, stat_, *this,
891  std::move(source));
892  else {
893  this->~reply_body();
894  stat_ = std::numeric_limits<_xdr_case_type>::max();
895  _xdr_with_mem_ptr(xdr::field_constructor, source.stat_, *this,
896  std::move(source));
897  }
898  stat_ = source.stat_;
899  return *this;
900  }
901 
902  reply_stat stat() const { return reply_stat(stat_); }
903  reply_body &stat(reply_stat _xdr_d, bool _xdr_validate = true) {
904  _xdr_discriminant(_xdr_d, _xdr_validate);
905  return *this;
906  }
907 
908  accepted_reply &areply() {
909  if (_xdr_field_number(stat_) == 1)
910  return areply_;
911  throw xdr::xdr_wrong_union("reply_body: areply accessed when not selected");
912  }
913  const accepted_reply &areply() const {
914  if (_xdr_field_number(stat_) == 1)
915  return areply_;
916  throw xdr::xdr_wrong_union("reply_body: areply accessed when not selected");
917  }
918  rejected_reply &rreply() {
919  if (_xdr_field_number(stat_) == 2)
920  return rreply_;
921  throw xdr::xdr_wrong_union("reply_body: rreply accessed when not selected");
922  }
923  const rejected_reply &rreply() const {
924  if (_xdr_field_number(stat_) == 2)
925  return rreply_;
926  throw xdr::xdr_wrong_union("reply_body: rreply accessed when not selected");
927  }
928 };
929 } namespace xdr {
931  static Constexpr const bool is_class = true;
932  static Constexpr const bool is_union = true;
933  static Constexpr const bool has_fixed_size = false;
934 
936  using case_type = ::xdr::reply_body::_xdr_case_type;
937  using discriminant_type = decltype(std::declval<union_type>().stat());
938 
939  static const char *union_field_name(case_type which) {
940  switch (union_type::_xdr_field_number(which)) {
941  case 1:
942  return "areply";
943  case 2:
944  return "rreply";
945  }
946  return nullptr;
947  }
948  static const char *union_field_name(const union_type &u) {
949  return union_field_name(u._xdr_discriminant());
950  }
951 
952  static std::size_t serial_size(const ::xdr::reply_body &obj) {
953  std::size_t size = 0;
954  if (!obj._xdr_with_mem_ptr(field_size, obj._xdr_discriminant(), obj, size))
955  throw xdr_bad_discriminant("bad value of stat in reply_body");
956  return size + 4;
957  }
958  template<typename Archive> static void
959  save(Archive &ar, const ::xdr::reply_body &obj) {
960  xdr::archive(ar, obj.stat(), "stat");
961  if (!obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
962  union_field_name(obj)))
963  throw xdr_bad_discriminant("bad value of stat in reply_body");
964  }
965  template<typename Archive> static void
966  load(Archive &ar, ::xdr::reply_body &obj) {
967  discriminant_type which;
968  xdr::archive(ar, which, "stat");
969  obj.stat(which);
970  obj._xdr_with_mem_ptr(field_archiver, obj.stat(), ar, obj,
971  union_field_name(which));
972  xdr::validate(obj);
973  }
974 };
975 } namespace xdr {
976 
977 struct rpc_msg {
978  struct _body_t {
979  using _xdr_case_type = xdr::xdr_traits<msg_type>::case_type;
980  private:
981  _xdr_case_type mtype_;
982  union {
983  call_body cbody_;
984  reply_body rbody_;
985  };
986 
987  public:
988  static const std::vector<msg_type> &_xdr_discriminant_values() {
989  static const std::vector<msg_type> _xdr_disc_vec {
990  CALL,
991  REPLY
992  };
993  return _xdr_disc_vec;
994  }
995  static Constexpr int _xdr_field_number(_xdr_case_type which) {
996  return which == CALL ? 1
997  : which == REPLY ? 2
998  : -1;
999  }
1000  template<typename _F, typename..._A> static bool
1001  _xdr_with_mem_ptr(_F &_f, _xdr_case_type _which, _A&&..._a) {
1002  switch (_which) {
1003  case CALL:
1004  _f(&_body_t::cbody_, std::forward<_A>(_a)...);
1005  return true;
1006  case REPLY:
1007  _f(&_body_t::rbody_, std::forward<_A>(_a)...);
1008  return true;
1009  }
1010  return false;
1011  }
1012 
1013  _xdr_case_type _xdr_discriminant() const { return mtype_; }
1014  void _xdr_discriminant(_xdr_case_type which, bool validate = true) {
1015  int fnum = _xdr_field_number(which);
1016  if (fnum < 0 && validate)
1017  throw xdr::xdr_bad_discriminant("bad value of mtype in _body_t");
1018  if (fnum != _xdr_field_number(mtype_)) {
1019  this->~_body_t();
1020  mtype_ = which;
1021  _xdr_with_mem_ptr(xdr::field_constructor, mtype_, *this);
1022  }
1023  else
1024  mtype_ = which;
1025  }
1026  explicit _body_t(msg_type which = msg_type{}) : mtype_(which) {
1027  _xdr_with_mem_ptr(xdr::field_constructor, mtype_, *this);
1028  }
1029  _body_t(const _body_t &source) : mtype_(source.mtype_) {
1030  _xdr_with_mem_ptr(xdr::field_constructor, mtype_, *this, source);
1031  }
1032  _body_t(_body_t &&source) : mtype_(source.mtype_) {
1033  _xdr_with_mem_ptr(xdr::field_constructor, mtype_, *this,
1034  std::move(source));
1035  }
1036  ~_body_t() { _xdr_with_mem_ptr(xdr::field_destructor, mtype_, *this); }
1037  _body_t &operator=(const _body_t &source) {
1038  if (_xdr_field_number(mtype_)
1039  == _xdr_field_number(source.mtype_))
1040  _xdr_with_mem_ptr(xdr::field_assigner, mtype_, *this, source);
1041  else {
1042  this->~_body_t();
1043  mtype_ = std::numeric_limits<_xdr_case_type>::max();
1044  _xdr_with_mem_ptr(xdr::field_constructor, source.mtype_, *this, source);
1045  }
1046  mtype_ = source.mtype_;
1047  return *this;
1048  }
1049  _body_t &operator=(_body_t &&source) {
1050  if (_xdr_field_number(mtype_)
1051  == _xdr_field_number(source.mtype_))
1052  _xdr_with_mem_ptr(xdr::field_assigner, mtype_, *this,
1053  std::move(source));
1054  else {
1055  this->~_body_t();
1056  mtype_ = std::numeric_limits<_xdr_case_type>::max();
1057  _xdr_with_mem_ptr(xdr::field_constructor, source.mtype_, *this,
1058  std::move(source));
1059  }
1060  mtype_ = source.mtype_;
1061  return *this;
1062  }
1063 
1064  msg_type mtype() const { return msg_type(mtype_); }
1065  _body_t &mtype(msg_type _xdr_d, bool _xdr_validate = true) {
1066  _xdr_discriminant(_xdr_d, _xdr_validate);
1067  return *this;
1068  }
1069 
1070  call_body &cbody() {
1071  if (_xdr_field_number(mtype_) == 1)
1072  return cbody_;
1073  throw xdr::xdr_wrong_union("_body_t: cbody accessed when not selected");
1074  }
1075  const call_body &cbody() const {
1076  if (_xdr_field_number(mtype_) == 1)
1077  return cbody_;
1078  throw xdr::xdr_wrong_union("_body_t: cbody accessed when not selected");
1079  }
1080  reply_body &rbody() {
1081  if (_xdr_field_number(mtype_) == 2)
1082  return rbody_;
1083  throw xdr::xdr_wrong_union("_body_t: rbody accessed when not selected");
1084  }
1085  const reply_body &rbody() const {
1086  if (_xdr_field_number(mtype_) == 2)
1087  return rbody_;
1088  throw xdr::xdr_wrong_union("_body_t: rbody accessed when not selected");
1089  }
1090  };
1091 
1092  std::uint32_t xid{};
1093  _body_t body{};
1094 
1095  rpc_msg() = default;
1096  template<typename _xid_T,
1097  typename _body_T,
1098  typename = typename
1099  std::enable_if<std::is_constructible<std::uint32_t, _xid_T>::value
1100  && std::is_constructible<_body_t, _body_T>::value
1101  >::type>
1102  explicit rpc_msg(_xid_T &&_xid,
1103  _body_T &&_body)
1104  : xid(std::forward<_xid_T>(_xid)),
1105  body(std::forward<_body_T>(_body)) {}
1106 };
1107 } namespace xdr {
1109  static Constexpr const bool is_class = true;
1110  static Constexpr const bool is_union = true;
1111  static Constexpr const bool has_fixed_size = false;
1112 
1114  using case_type = ::xdr::rpc_msg::_body_t::_xdr_case_type;
1115  using discriminant_type = decltype(std::declval<union_type>().mtype());
1116 
1117  static const char *union_field_name(case_type which) {
1118  switch (union_type::_xdr_field_number(which)) {
1119  case 1:
1120  return "cbody";
1121  case 2:
1122  return "rbody";
1123  }
1124  return nullptr;
1125  }
1126  static const char *union_field_name(const union_type &u) {
1127  return union_field_name(u._xdr_discriminant());
1128  }
1129 
1130  static std::size_t serial_size(const ::xdr::rpc_msg::_body_t &obj) {
1131  std::size_t size = 0;
1132  if (!obj._xdr_with_mem_ptr(field_size, obj._xdr_discriminant(), obj, size))
1133  throw xdr_bad_discriminant("bad value of mtype in _body_t");
1134  return size + 4;
1135  }
1136  template<typename Archive> static void
1137  save(Archive &ar, const ::xdr::rpc_msg::_body_t &obj) {
1138  xdr::archive(ar, obj.mtype(), "mtype");
1139  if (!obj._xdr_with_mem_ptr(field_archiver, obj.mtype(), ar, obj,
1140  union_field_name(obj)))
1141  throw xdr_bad_discriminant("bad value of mtype in _body_t");
1142  }
1143  template<typename Archive> static void
1144  load(Archive &ar, ::xdr::rpc_msg::_body_t &obj) {
1145  discriminant_type which;
1146  xdr::archive(ar, which, "mtype");
1147  obj.mtype(which);
1148  obj._xdr_with_mem_ptr(field_archiver, obj.mtype(), ar, obj,
1149  union_field_name(which));
1150  xdr::validate(obj);
1151  }
1152 };
1153 template<> struct xdr_traits<::xdr::rpc_msg>
1154  : xdr_struct_base<field_ptr<::xdr::rpc_msg,
1155  decltype(::xdr::rpc_msg::xid),
1156  &::xdr::rpc_msg::xid>,
1157  field_ptr<::xdr::rpc_msg,
1158  decltype(::xdr::rpc_msg::body),
1159  &::xdr::rpc_msg::body>> {
1160  template<typename Archive> static void
1161  save(Archive &ar, const ::xdr::rpc_msg &obj) {
1162  archive(ar, obj.xid, "xid");
1163  archive(ar, obj.body, "body");
1164  }
1165  template<typename Archive> static void
1166  load(Archive &ar, ::xdr::rpc_msg &obj) {
1167  archive(ar, obj.xid, "xid");
1168  archive(ar, obj.body, "body");
1169  xdr::validate(obj);
1170  }
1171 };
1172 } namespace xdr {
1173 
1174 }
1175 
1176 #endif // !__XDR_XDRPP_RPC_MSG_HH_INCLUDED__
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 ...
Definition: types.h:855
Type definitions for xdrc compiler output.
static Constexpr const bool is_class
T is an XDR struct or union.
Definition: types.h:158
Constexpr const field_size_t field_size
Passed to _xdr_with_mem_ptr to compute the size of the active union field.
Definition: types.h:899
Attempt to access wrong field of a union.
Definition: types.h:75
Constexpr const field_destructor_t field_destructor
Passed to _xdr_with_mem_ptr to destroy the active union field.
Definition: types.h:863
Most of the xdrpp library is encapsulated in the xdr namespace.
Definition: arpc.cc:4
static Constexpr const bool is_union
T is an XDR union.
Definition: types.h:156
Constexpr const field_assigner_t field_assigner
Passed to _xdr_with_mem_ptr to assign to the active union field.
Definition: types.h:873
Default traits for use as supertype of specializations of xdr_traits for integral types...
Definition: types.h:229
static Constexpr const bool is_enum
T is an XDR enum or bool (traits have enum_name).
Definition: types.h:160
Attempt to set invalid value for a union discriminant.
Definition: types.h:56
Default xdr_traits values for actual XDR types, used as a supertype for most xdr::xdr_traits speciali...
Definition: types.h:191
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.
Definition: types.h:140
Metadata for all marshalable XDR types.
Definition: types.h:146
void validate(const T &t)
If this function template is specialized, it provides a means of placing extra restrictions on XDR da...
Definition: types.h:113
static Constexpr const bool is_numeric
T is one of [u]int{32,64}_t, float, or double.
Definition: types.h:164
static Constexpr const bool has_fixed_size
T has a fixed size.
Definition: types.h:166
Constexpr const field_archiver_t field_archiver
Passed to _xdr_with_mem_ptr to archive the active union field.
Definition: types.h:888