Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

oncrpc.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef _IPXE_ONCRPC_H
  2. #define _IPXE_ONCRPC_H
  3. #include <stdint.h>
  4. #include <ipxe/interface.h>
  5. #include <ipxe/iobuf.h>
  6. /** @file
  7. *
  8. * SUN ONC RPC protocol.
  9. *
  10. */
  11. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  12. /** ONC RCP Version */
  13. #define ONCRPC_VERS 2
  14. /** ONC RPC Null Authentication */
  15. #define ONCRPC_AUTH_NONE 0
  16. /** ONC RPC System Authentication (also called UNIX Authentication) */
  17. #define ONCRPC_AUTH_SYS 1
  18. /** Size of an ONC RPC header */
  19. #define ONCRPC_HEADER_SIZE ( 11 * sizeof ( uint32_t ) )
  20. #define ONCRPC_FIELD( type, value ) { oncrpc_ ## type, { .type = value } }
  21. #define ONCRPC_SUBFIELD( type, args... ) \
  22. { oncrpc_ ## type, { .type = { args } } }
  23. #define ONCRPC_FIELD_END { oncrpc_none, { } }
  24. /** Enusure that size is a multiple of four */
  25. #define oncrpc_align( size ) ( ( (size) + 3 ) & ~3 )
  26. /**
  27. * Calculate the length of a string, including padding bytes.
  28. *
  29. * @v str String
  30. * @ret size Length of the padded string
  31. */
  32. #define oncrpc_strlen( str ) ( oncrpc_align ( strlen ( str ) ) + \
  33. sizeof ( uint32_t ) )
  34. struct oncrpc_cred {
  35. uint32_t flavor;
  36. uint32_t length;
  37. };
  38. struct oncrpc_cred_sys {
  39. struct oncrpc_cred credential;
  40. uint32_t stamp;
  41. char *hostname;
  42. uint32_t uid;
  43. uint32_t gid;
  44. uint32_t aux_gid_len;
  45. uint32_t aux_gid[16];
  46. };
  47. struct oncrpc_reply
  48. {
  49. struct oncrpc_cred *verifier;
  50. uint32_t rpc_id;
  51. uint32_t reply_state;
  52. uint32_t accept_state;
  53. uint32_t frame_size;
  54. struct io_buffer *data;
  55. };
  56. struct oncrpc_session {
  57. struct oncrpc_reply pending_reply;
  58. struct oncrpc_cred *credential;
  59. struct oncrpc_cred *verifier;
  60. uint32_t rpc_id;
  61. uint32_t prog_name;
  62. uint32_t prog_vers;
  63. };
  64. enum oncrpc_field_type {
  65. oncrpc_none = 0,
  66. oncrpc_int32,
  67. oncrpc_int64,
  68. oncrpc_str,
  69. oncrpc_array,
  70. oncrpc_intarray,
  71. oncrpc_cred,
  72. };
  73. union oncrpc_field_value {
  74. struct {
  75. size_t length;
  76. const void *ptr;
  77. } array;
  78. struct {
  79. size_t length;
  80. const uint32_t *ptr;
  81. } intarray;
  82. int64_t int64;
  83. int32_t int32;
  84. const char *str;
  85. const struct oncrpc_cred *cred;
  86. };
  87. struct oncrpc_field {
  88. enum oncrpc_field_type type;
  89. union oncrpc_field_value value;
  90. };
  91. extern struct oncrpc_cred oncrpc_auth_none;
  92. int oncrpc_init_cred_sys ( struct oncrpc_cred_sys *auth_sys );
  93. void oncrpc_init_session ( struct oncrpc_session *session,
  94. struct oncrpc_cred *credential,
  95. struct oncrpc_cred *verifier, uint32_t prog_name,
  96. uint32_t prog_vers );
  97. int oncrpc_call ( struct interface *intf, struct oncrpc_session *session,
  98. uint32_t proc_name, const struct oncrpc_field fields[] );
  99. size_t oncrpc_compute_size ( const struct oncrpc_field fields[] );
  100. int oncrpc_get_reply ( struct oncrpc_session *session,
  101. struct oncrpc_reply *reply, struct io_buffer *io_buf );
  102. #endif /* _IPXE_ONCRPC_H */