summaryrefslogtreecommitdiff
path: root/include/linux/sunrpc/xdrgen/_defs.h
blob: d767206feea4756ec901c2e313f65742353bf47e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2024 Oracle and/or its affiliates.
 *
 * This header defines XDR data type primitives specified in
 * Section 4 of RFC 4506, used by RPC programs implemented
 * in the Linux kernel.
 *
 * A generated definition can also embed a struct xdr_buf, which
 * carries a page-resident payload captured by reference, so this
 * header pulls in the kernel's XDR types as well.
 */

#ifndef _SUNRPC_XDRGEN__DEFS_H_
#define _SUNRPC_XDRGEN__DEFS_H_

#include <linux/sunrpc/xdr.h>

#define TRUE	(true)
#define FALSE	(false)

typedef struct {
	u32 len;
	unsigned char *data;
} string;

typedef struct {
	u32 len;
	u8 *data;
} opaque;

/*
 * Cursor a hook-driven aggregate codec hands to its begin/item/end
 * hooks, one element at a time, in place of a materialized C array.
 * The generated framing owns it. @xdr is the RPC layer's stream and
 * @ctx its xdrgen_ctx, the svc_rqst on the server. @index is the
 * current element; @member_id selects among a type's marked members.
 * For a counted array @count is the wire length: a decoder fills it
 * before the begin hook runs, an encoder's begin hook sets it. The
 * hook contract is under "Pragma aggregate" in
 * tools/net/sunrpc/xdrgen/README.
 *
 * An optional-data list ("type *name") carries no count. Its encoder
 * pulls elements until the item hook returns false. False ends the
 * list rather than failing the encode: the framing writes the
 * value-follows terminator, so a producer that stops early leaves a
 * valid truncated list on the wire. A producer that stops for a
 * mid-list error records it in the application state @ctx reaches,
 * and either returns false from the end hook, which fails the
 * encode, or reports it in the procedure status.
 */
struct xdrgen_aggregate_cursor {
	struct xdr_stream	*xdr;
	u32			index;
	u32			count;
	unsigned int		member_id;
	void			*ctx;
};

#define XDR_void		(0)
#define XDR_bool		(1)
#define XDR_short		(1)
#define XDR_unsigned_short	(1)
#define XDR_int			(1)
#define XDR_unsigned_int	(1)
#define XDR_long		(1)
#define XDR_unsigned_long	(1)
#define XDR_hyper		(2)
#define XDR_unsigned_hyper	(2)

#endif /* _SUNRPC_XDRGEN__DEFS_H_ */