2 Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #include "win32_compat.h"
24 #include "libnfs-zdr.h"
26 #include "libnfs-raw.h"
27 #include "libnfs-private.h"
28 #include "libnfs-raw-nsm.h"
30 int rpc_nsm1_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
34 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_NULL
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
36 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/null call");
40 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
41 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/null call");
42 rpc_free_pdu(rpc
, pdu
);
49 int rpc_nsm1_stat_async(struct rpc_context
*rpc
, rpc_cb cb
, struct NSM1_STATargs
*args
, void *private_data
)
53 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_STAT
, cb
, private_data
, (zdrproc_t
)zdr_NSM1_STATres
, sizeof(NSM1_STATres
));
55 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/stat call");
59 if (zdr_NSM1_STATargs(&pdu
->zdr
, args
) == 0) {
60 rpc_set_error(rpc
, "ZDR error: Failed to encode NSM1_STATargs");
61 rpc_free_pdu(rpc
, pdu
);
65 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
66 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/stat call");
67 rpc_free_pdu(rpc
, pdu
);
74 int rpc_nsm1_mon_async(struct rpc_context
*rpc
, rpc_cb cb
, struct NSM1_MONargs
*args
, void *private_data
)
78 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_MON
, cb
, private_data
, (zdrproc_t
)zdr_NSM1_MONres
, sizeof(NSM1_MONres
));
80 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/mon call");
84 if (zdr_NSM1_MONargs(&pdu
->zdr
, args
) == 0) {
85 rpc_set_error(rpc
, "ZDR error: Failed to encode NSM1_MONargs");
86 rpc_free_pdu(rpc
, pdu
);
90 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
91 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/mon call");
92 rpc_free_pdu(rpc
, pdu
);
99 int rpc_nsm1_unmon_async(struct rpc_context
*rpc
, rpc_cb cb
, struct NSM1_UNMONargs
*args
, void *private_data
)
103 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_UNMON
, cb
, private_data
, (zdrproc_t
)zdr_NSM1_UNMONres
, sizeof(NSM1_UNMONres
));
105 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/unmon call");
109 if (zdr_NSM1_UNMONargs(&pdu
->zdr
, args
) == 0) {
110 rpc_set_error(rpc
, "ZDR error: Failed to encode NSM1_UNMONargs");
111 rpc_free_pdu(rpc
, pdu
);
115 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
116 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/unmon call");
117 rpc_free_pdu(rpc
, pdu
);
124 int rpc_nsm1_unmonall_async(struct rpc_context
*rpc
, rpc_cb cb
, struct NSM1_UNMONALLargs
*args
, void *private_data
)
128 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_UNMON_ALL
, cb
, private_data
, (zdrproc_t
)zdr_NSM1_UNMONALLres
, sizeof(NSM1_UNMONALLres
));
130 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/unmonall call");
134 if (zdr_NSM1_UNMONALLargs(&pdu
->zdr
, args
) == 0) {
135 rpc_set_error(rpc
, "ZDR error: Failed to encode NSM1_UNMONALLargs");
136 rpc_free_pdu(rpc
, pdu
);
140 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
141 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/unmonall call");
142 rpc_free_pdu(rpc
, pdu
);
149 int rpc_nsm1_simucrash_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
153 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_SIMU_CRASH
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
155 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/simucrash call");
159 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
160 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/simucrash call");
161 rpc_free_pdu(rpc
, pdu
);
168 int rpc_nsm1_notify_async(struct rpc_context
*rpc
, rpc_cb cb
, struct NSM1_NOTIFYargs
*args
, void *private_data
)
172 pdu
= rpc_allocate_pdu(rpc
, NSM_PROGRAM
, NSM_V1
, NSM1_NOTIFY
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
174 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nsm/notify call");
178 if (zdr_NSM1_NOTIFYargs(&pdu
->zdr
, args
) == 0) {
179 rpc_set_error(rpc
, "ZDR error: Failed to encode NSM1_NOTIFYargs");
180 rpc_free_pdu(rpc
, pdu
);
184 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
185 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nsm/notify call");
186 rpc_free_pdu(rpc
, pdu
);
193 char *nsmstat1_to_str(int st
)
195 enum nsmstat1 stat
= st
;
197 char *str
= "unknown n1m stat";
199 case NSM_STAT_SUCC
: str
="NSM_STAT_SUCC";break;
200 case NSM_STAT_FAIL
: str
="NSM_STAT_FAIL";break;