00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 #ifndef _RPC_AUTH_H
00048 #define _RPC_AUTH_H
00049 #ifndef WIN32
00050         #include <sys/cdefs.h>
00051 #endif
00052 
00053 #define MAX_AUTH_BYTES  400
00054 #define MAXNETNAMELEN   255     
00055 
00056 
00057 
00058 
00059 enum auth_stat {
00060         AUTH_OK=0,
00061         
00062 
00063 
00064         AUTH_BADCRED=1,                 
00065         AUTH_REJECTEDCRED=2,            
00066         AUTH_BADVERF=3,                 
00067         AUTH_REJECTEDVERF=4,            
00068         AUTH_TOOWEAK=5,                 
00069         
00070 
00071 
00072         AUTH_INVALIDRESP=6,             
00073         AUTH_FAILED=7                   
00074 };
00075 
00076 #ifdef WIN32
00077     
00078                
00079     #include <stdint.h>
00080 #else
00081           
00082 #endif
00083 
00084 union des_block {
00085         struct {
00086                 u_int32 high;
00087                 u_int32 low;
00088         } key;
00089         char c[8];
00090 };
00091 typedef union des_block des_block;
00092 __BEGIN_DECLS
00093 extern bool_t xdr_des_block __P((XDR *, des_block *));
00094 __END_DECLS
00095 
00096 
00097 
00098 
00099 struct opaque_auth {
00100         enum_t  oa_flavor;              
00101         caddr_t oa_base;                
00102         u_int   oa_length;              
00103 };
00104 
00105 
00106 
00107 
00108 
00109 typedef struct __rpc_auth {
00110         struct  opaque_auth     ah_cred;
00111         struct  opaque_auth     ah_verf;
00112         union   des_block       ah_key;
00113         struct auth_ops {
00114                 void    (*ah_nextverf) __P((struct __rpc_auth *));
00115                 
00116                 int     (*ah_marshal) __P((struct __rpc_auth *, XDR *));
00117                 
00118                 int     (*ah_validate) __P((struct __rpc_auth *,
00119                             struct opaque_auth *));
00120                 
00121                 int     (*ah_refresh) __P((struct __rpc_auth *));
00122                 
00123                 void    (*ah_destroy) __P((struct __rpc_auth *));
00124         } *ah_ops;
00125         caddr_t ah_private;
00126 } AUTH;
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 #define AUTH_NEXTVERF(auth)             \
00138                 ((*((auth)->ah_ops->ah_nextverf))(auth))
00139 #define auth_nextverf(auth)             \
00140                 ((*((auth)->ah_ops->ah_nextverf))(auth))
00141 
00142 #define AUTH_MARSHALL(auth, xdrs)       \
00143                 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00144 #define auth_marshall(auth, xdrs)       \
00145                 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
00146 
00147 #define AUTH_VALIDATE(auth, verfp)      \
00148                 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00149 #define auth_validate(auth, verfp)      \
00150                 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
00151 
00152 #define AUTH_REFRESH(auth)              \
00153                 ((*((auth)->ah_ops->ah_refresh))(auth))
00154 #define auth_refresh(auth)              \
00155                 ((*((auth)->ah_ops->ah_refresh))(auth))
00156 
00157 #define AUTH_DESTROY(auth)              \
00158                 ((*((auth)->ah_ops->ah_destroy))(auth))
00159 #define auth_destroy(auth)              \
00160                 ((*((auth)->ah_ops->ah_destroy))(auth))
00161 
00162 
00163 extern struct opaque_auth _null_auth;
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 __BEGIN_DECLS
00180 struct sockaddr_in;
00181 extern AUTH *authunix_create            __P((char *, int, int, int, int *));
00182 extern AUTH *authunix_create_default    __P((void));
00183 extern AUTH *authnone_create            __P((void));
00184 extern AUTH *authdes_create             __P((char *, u_int,
00185                                             struct sockaddr_in *, des_block *));
00186 __END_DECLS
00187 
00188 #define AUTH_NONE       0               
00189 #define AUTH_NULL       0               
00190 #define AUTH_UNIX       1               
00191 #define AUTH_SHORT      2               
00192 #define AUTH_DES        3               
00193 
00194 #endif