* i.e. zdrmem_create() buffers.
* It aims to be compatible with normal rpcgen generated functions.
*/
+#ifdef WIN32
+#include "win32_compat.h"
+#endif
+
+#ifdef AROS
+#include "aros_compat.h"
+#endif
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "libnfs-zdr.h"
struct opaque_auth _null_auth;
}
-bool_t libnfs_zdr_enum(ZDR *zdrs, int32_t *e)
+bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e)
{
- return libnfs_zdr_u_int(zdrs, (uint32_t *)e);
+ bool_t ret;
+ int32_t i = *e;
+
+ ret = libnfs_zdr_u_int(zdrs, (uint32_t *)&i);
+ *e = i;
+
+ return ret;
}
bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b)
}
for (i = 0; i < *size; i++) {
- if (proc(zdrs, *arrp + i * elsize)) {
+ if (!proc(zdrs, *arrp + i * elsize)) {
return FALSE;
}
}
return FALSE;
}
- if (!libnfs_zdr_bytes(zdrs, &auth->oa_base, &auth->oa_length, &auth->oa_length)) {
+ if (!libnfs_zdr_bytes(zdrs, &auth->oa_base, &auth->oa_length, auth->oa_length)) {
return FALSE;
}
static bool_t libnfs_rpc_call_body(ZDR *zdrs, struct call_body *cmb)
{
- if (!libnfs_zdr_u_int(zdrs, &cmb->cb_rpcvers)) {
+ if (!libnfs_zdr_u_int(zdrs, &cmb->rpcvers)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &cmb->cb_prog)) {
+ if (!libnfs_zdr_u_int(zdrs, &cmb->prog)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &cmb->cb_vers)) {
+ if (!libnfs_zdr_u_int(zdrs, &cmb->vers)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &cmb->cb_proc)) {
+ if (!libnfs_zdr_u_int(zdrs, &cmb->proc)) {
return FALSE;
}
- if (!libnfs_opaque_auth(zdrs, &cmb->cb_cred)) {
+ if (!libnfs_opaque_auth(zdrs, &cmb->cred)) {
return FALSE;
}
- if (!libnfs_opaque_auth(zdrs, &cmb->cb_verf)) {
+ if (!libnfs_opaque_auth(zdrs, &cmb->verf)) {
return FALSE;
}
+
+ return TRUE;
}
static bool_t libnfs_accepted_reply(ZDR *zdrs, struct accepted_reply *ar)
{
- if (!libnfs_opaque_auth(zdrs, &ar->ar_verf)) {
+ if (!libnfs_opaque_auth(zdrs, &ar->verf)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &ar->ar_stat)) {
+ if (!libnfs_zdr_u_int(zdrs, &ar->stat)) {
return FALSE;
}
- switch (ar->ar_stat) {
+ switch (ar->stat) {
case SUCCESS:
- if (!ar->ar_results.proc(zdrs, ar->ar_results.where)) {
+ if (!ar->reply_data.results.proc(zdrs, ar->reply_data.results.where)) {
return FALSE;
}
return TRUE;
case PROG_MISMATCH:
- if (!libnfs_zdr_u_int(zdrs, &ar->ar_vers.low)) {
+ if (!libnfs_zdr_u_int(zdrs, &ar->reply_data.mismatch_info.low)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &ar->ar_vers.high)) {
+ if (!libnfs_zdr_u_int(zdrs, &ar->reply_data.mismatch_info.high)) {
return FALSE;
}
return TRUE;
return FALSE;
}
-static bool_t libnfs_rejected_reply(ZDR *zdrs, struct rejected_reply *RP_dr)
+static bool_t libnfs_rejected_reply(ZDR *zdrs, struct rejected_reply *rr)
{
-printf("rejected reply\n");
-exit(10);
+ if (!libnfs_zdr_u_int(zdrs, &rr->stat)) {
+ return FALSE;
+ }
+
+ switch (rr->stat) {
+ case RPC_MISMATCH:
+ if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.mismatch_info.low)) {
+ return FALSE;
+ }
+ if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.mismatch_info.high)) {
+ return FALSE;
+ }
+ return TRUE;
+ case AUTH_ERROR:
+ if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.stat)) {
+ return FALSE;
+ }
+ return TRUE;
+ default:
+ return TRUE;
+ }
+
+ return FALSE;
}
static bool_t libnfs_rpc_reply_body(ZDR *zdrs, struct reply_body *rmb)
{
- if (!libnfs_zdr_u_int(zdrs, &rmb->rp_stat)) {
+ if (!libnfs_zdr_u_int(zdrs, &rmb->stat)) {
return FALSE;
}
- switch (rmb->rp_stat) {
+ switch (rmb->stat) {
case MSG_ACCEPTED:
- if (!libnfs_accepted_reply(zdrs, &rmb->rp_acpt)) {
+ if (!libnfs_accepted_reply(zdrs, &rmb->reply.areply)) {
return FALSE;
}
return TRUE;
case MSG_DENIED:
- if (!libnfs_rejected_reply(zdrs, &rmb->rp_rjct)) {
+ if (!libnfs_rejected_reply(zdrs, &rmb->reply.rreply)) {
return FALSE;
}
return TRUE;
static bool_t libnfs_rpc_msg(ZDR *zdrs, struct rpc_msg *msg)
{
- if (!libnfs_zdr_u_int(zdrs, &msg->rm_xid)) {
+ if (!libnfs_zdr_u_int(zdrs, &msg->xid)) {
return FALSE;
}
- if (!libnfs_zdr_u_int(zdrs, &msg->rm_direction)) {
+ if (!libnfs_zdr_u_int(zdrs, &msg->direction)) {
return FALSE;
}
- switch (msg->rm_direction) {
+ switch (msg->direction) {
case CALL:
- return libnfs_rpc_call_body(zdrs, &msg->ru.RM_cmb);
+ return libnfs_rpc_call_body(zdrs, &msg->body.cbody);
break;
case REPLY:
- return libnfs_rpc_reply_body(zdrs, &msg->ru.RM_rmb);
+ return libnfs_rpc_reply_body(zdrs, &msg->body.rbody);
break;
default:
return FALSE;
return libnfs_rpc_msg(zdrs, msg);
}
-AUTH *authnone_create(void)
+struct AUTH *authnone_create(void)
{
- AUTH *auth;
+ struct AUTH *auth;
- auth = malloc(sizeof(AUTH));
+ auth = malloc(sizeof(struct AUTH));
auth->ah_cred.oa_flavor = AUTH_NONE;
auth->ah_cred.oa_length = 0;
return auth;
}
-AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups)
+struct AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups)
{
- AUTH *auth;
+ struct AUTH *auth;
int size;
uint32_t *buf;
int idx;
size = 4 + 4 + ((strlen(host) + 3) & ~3) + 4 + 4 + 4 + len * 4;
- auth = malloc(sizeof(AUTH));
+ auth = malloc(sizeof(struct AUTH));
auth->ah_cred.oa_flavor = AUTH_UNIX;
auth->ah_cred.oa_length = size;
auth->ah_cred.oa_base = malloc(size);
- buf = auth->ah_cred.oa_base;
+ buf = (uint32_t *)auth->ah_cred.oa_base;
idx = 0;
buf[idx++] = htonl(time(NULL));
buf[idx++] = htonl(strlen(host));
return auth;
}
-AUTH *libnfs_authunix_create_default(void)
+struct AUTH *libnfs_authunix_create_default(void)
{
- return libnfs_authunix_create("libnfs", getuid(), -1, 0, NULL);
+#ifdef WIN32
+ return libnfs_authunix_create("libnfs", 65535, 65535, 0, NULL);
+#else
+ return libnfs_authunix_create("libnfs", getuid(), getgid(), 0, NULL);
+#endif
}
-void libnfs_auth_destroy(AUTH *auth)
+void libnfs_auth_destroy(struct AUTH *auth)
{
if (auth->ah_cred.oa_base) {
free(auth->ah_cred.oa_base);