2 Copyright (C) 2012 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/>.
18 * This file contains definitions for the built in ZDR implementation.
19 * This is a very limited ZDR subset that can only marshal to/from a momory buffer,
20 * i.e. zdrmem_create() buffers.
21 * It aims to be compatible with normal rpcgen generated functions.
24 /************************************************************
25 * Definitions copied from RFC 5531
26 * and slightly modified.
27 ************************************************************/
29 #ifndef _LIBNFS_ZDR_H_
30 #define _LIBNFS_ZDR_H_
33 #ifndef CADDR_T_DEFINED
34 #define CADDR_T_DEFINED
35 typedef char *caddr_t
;
42 #include <sys/types.h>
52 /* we dont need these */
63 #define ZDR_INLINE(...) NULL
64 #define IZDR_PUT_U_LONG(...) assert(0)
65 #define IZDR_GET_U_LONG(...) (assert(0), 0)
66 #define IZDR_PUT_LONG(...) assert(0)
67 #define IZDR_GET_LONG(...) (assert(0), 0)
68 #define IZDR_PUT_BOOL(...) assert(0)
69 #define IZDR_GET_BOOL(...) (assert(0), 0)
96 typedef struct ZDR ZDR
;
99 typedef uint32_t u_int
;
100 typedef uint32_t enum_t
;
101 typedef uint32_t bool_t
;
103 typedef int (*zdrproc_t
) (ZDR
*, void *,...);
114 extern struct opaque_auth _null_auth
;
117 struct opaque_auth ah_cred
;
118 struct opaque_auth ah_verf
;
122 #define RPC_MSG_VERSION 2
151 * failed at remote end
153 AUTH_BADCRED
= 1, /* bogus credentials (seal broken) */
154 AUTH_REJECTEDCRED
= 2, /* client should begin new session */
155 AUTH_BADVERF
= 3, /* bogus verifier (seal broken) */
156 AUTH_REJECTEDVERF
= 4, /* verifier expired or was replayed */
157 AUTH_TOOWEAK
= 5, /* rejected due to security reasons */
161 AUTH_INVALIDRESP
= 6, /* bogus response verifier */
162 AUTH_FAILED
= 7 /* some unknown reason */
170 struct opaque_auth cred
;
171 struct opaque_auth verf
;
174 struct accepted_reply
{
175 struct opaque_auth verf
;
189 struct rejected_reply
{
190 enum reject_stat stat
;
203 struct accepted_reply areply
;
204 struct rejected_reply rreply
;
213 struct call_body cbody
;
214 struct reply_body rbody
;
218 #define zdrmem_create libnfs_zdrmem_create
219 void libnfs_zdrmem_create(ZDR
*zdrs
, const caddr_t addr
, uint32_t size
, enum zdr_op xop
);
221 #define zdr_destroy libnfs_zdr_destroy
222 void libnfs_zdr_destroy(ZDR
*zdrs
);
224 #define zdr_bytes libnfs_zdr_bytes
225 bool_t
libnfs_zdr_bytes(ZDR
*zdrs
, char **bufp
, uint32_t *size
, uint32_t maxsize
);
227 #define zdr_u_int libnfs_zdr_u_int
228 bool_t
libnfs_zdr_u_int(ZDR
*zdrs
, uint32_t *u
);
230 #define zdr_int libnfs_zdr_int
231 bool_t
libnfs_zdr_int(ZDR
*zdrs
, int32_t *i
);
233 #define zdr_u_quad_t libnfs_zdr_u_quad_t
234 bool_t
libnfs_zdr_u_quad_t(ZDR
*zdrs
, uint64_t *u
);
236 #define zdr_quad_t libnfs_zdr_quad_t
237 bool_t
libnfs_zdr_quad_t(ZDR
*zdrs
, int64_t *i
);
239 #define zdr_enum libnfs_zdr_enum
240 bool_t
libnfs_zdr_enum(ZDR
*zdrs
, enum_t
*e
);
242 #define zdr_bool libnfs_zdr_bool
243 bool_t
libnfs_zdr_bool(ZDR
*zdrs
, bool_t
*b
);
245 #define zdr_void libnfs_zdr_void
246 bool_t
libnfs_zdr_void(void);
248 #define zdr_pointer libnfs_zdr_pointer
249 bool_t
libnfs_zdr_pointer(ZDR
*zdrs
, char **objp
, uint32_t size
, zdrproc_t proc
);
251 #define zdr_opaque libnfs_zdr_opaque
252 bool_t
libnfs_zdr_opaque(ZDR
*zdrs
, char *objp
, uint32_t size
);
254 #define zdr_string libnfs_zdr_string
255 bool_t
libnfs_zdr_string(ZDR
*zdrs
, char **strp
, uint32_t maxsize
);
257 #define zdr_array libnfs_zdr_array
258 bool_t
libnfs_zdr_array(ZDR
*zdrs
, char **arrp
, uint32_t *size
, uint32_t maxsize
, uint32_t elsize
, zdrproc_t proc
);
260 #define zdr_setpos libnfs_zdr_setpos
261 bool_t
libnfs_zdr_setpos(ZDR
*zdrs
, uint32_t pos
);
263 #define zdr_getpos libnfs_zdr_getpos
264 uint32_t libnfs_zdr_getpos(ZDR
*zdrs
);
266 #define zdr_free libnfs_zdr_free
267 void libnfs_zdr_free(zdrproc_t proc
, char *objp
);
269 #define zdr_callmsg libnfs_zdr_callmsg
270 bool_t
libnfs_zdr_callmsg(ZDR
*zdrs
, struct rpc_msg
*msg
);
272 #define zdr_replymsg libnfs_zdr_replymsg
273 bool_t
libnfs_zdr_replymsg(ZDR
*zdrs
, struct rpc_msg
*msg
);
275 #define authnone_create libnfs_authnone_create
276 struct AUTH
*libnfs_authnone_create(void);
278 #define authunix_create libnfs_authunix_create
279 struct AUTH
*libnfs_authunix_create(char *host
, uint32_t uid
, uint32_t gid
, uint32_t len
, uint32_t *groups
);
281 #define authunix_create_default libnfs_authunix_create_default
282 struct AUTH
*libnfs_authunix_create_default(void);
284 #define auth_destroy libnfs_auth_destroy
285 void libnfs_auth_destroy(struct AUTH
*auth
);