home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / nfsd / src / rpc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-29  |  2.0 KB  |  101 lines

  1. /*  Headers for the handling of RPC
  2.  
  3.     ©1999 Joseph Walton
  4.  
  5.     This software is distributed under the terms of the GNU General Public
  6.     License; either version 2 of the License, or (at your option) any
  7.     later version.
  8. */
  9.  
  10. #ifndef NFSD_RPC_H
  11. #define NFSD_RPC_H
  12.  
  13. #include <exec/types.h>
  14. #include <sys/types.h>
  15.  
  16. #include <netinet/in.h>
  17.  
  18. /* The type that XDR takes on the wire */
  19. typedef LONG int32;
  20.  
  21. #define SINT32 (sizeof(int32))
  22.  
  23. #define INT32S(bytes) (((bytes) + 3) / SINT32)
  24.  
  25. #define G_INT(x) (int)ntohl(x)
  26. #define G_UINT(x) (unsigned int)ntohl(x)
  27.  
  28. #define G_ENUM(x) G_INT(x)
  29.  
  30. #define P_INT(x) (int32)htonl(x)
  31. #define P_UINT(x) (int32)htonl(x)
  32.  
  33. #define P_ENUM(x) G_INT(x)
  34. #define P_ENUM_FALSE P_ENUM(0)
  35. #define P_ENUM_TRUE P_ENUM(1)
  36.  
  37. /* What kind of RPC are we concerned with? */
  38. #define RPC_VERSION 2
  39.  
  40. // Kinds of message
  41. #define CALL 0
  42. #define REPLY 1
  43.  
  44. // Status of a reply
  45. #define MSG_ACCEPTED 0
  46. #define MSG_DENIED 1
  47.  
  48. // Reasons for rejecting message
  49. #define RPC_MISMATCH 0
  50. #define AUTH_ERROR 1
  51.  
  52. // Reasons for AUTH_ERROR
  53. #define AUTH_TOOWEAK 5
  54. #define AUTH_FAILED 7
  55.  
  56. // Status of an accepted message
  57. #define SUCCESS 0
  58. #define PROG_UNAVAIL 1
  59. #define PROG_MISMATCH 2
  60. #define PROC_UNAVAIL 3
  61. #define GARBAGE_ARGS 4
  62. #define SYSTEM_ERR 5
  63.  
  64. // Kinds of authorisation
  65. #define AUTH_NONE 0
  66. #define AUTH_SYS 1
  67. #define AUTH_SHORT 2
  68. // One day, perhaps...
  69. #define AUTH_DES 3
  70. #define AUTH_KERB 4
  71.  
  72. #define AUTH_SYS_MACHINENAMELEN 256
  73.  
  74. struct authunix {
  75.         BOOL isUnix;
  76.         char machineName[AUTH_SYS_MACHINENAMELEN];
  77.         u_int uid;
  78.         u_int gid;
  79.         u_int numGids;
  80.         u_int gids[16];
  81. };
  82.  
  83. struct Call {
  84.     int c_program;
  85.     int c_version;
  86.     int c_procedure;
  87.     struct authunix c_auth;
  88.     struct sockaddr_in c_from;
  89.     BOOL c_hasBeenPrinted; /* Has the source been identified on the console? */
  90. };
  91.  
  92. /* Prototypes */
  93. u_int getUnsignedInt(int32);
  94. int getInt(int32);
  95. int32 *getString(int32 *ptr, int32 *limit, char *buf, int bufchars);
  96. int32 *readAuth(int32 *ptr, int32 *limit, struct authunix *auth);
  97. int32 *PrepareAcceptedHeader(int32 id, int32 *ptr);
  98.  
  99. #endif
  100.  
  101.