Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * linux/include/linux/lockd/xdr.h | |
4 | * | |
5 | * XDR types for the NLM protocol | |
6 | * | |
7 | * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> | |
8 | */ | |
9 | ||
10 | #ifndef LOCKD_XDR_H | |
11 | #define LOCKD_XDR_H | |
12 | ||
13 | #include <linux/fs.h> | |
14 | #include <linux/nfs.h> | |
15 | #include <linux/sunrpc/xdr.h> | |
16 | ||
e6765b83 | 17 | #define SM_MAXSTRLEN 1024 |
7e44d3be CL |
18 | #define SM_PRIV_SIZE 16 |
19 | ||
20 | struct nsm_private { | |
21 | unsigned char data[SM_PRIV_SIZE]; | |
22 | }; | |
23 | ||
d343fce1 N |
24 | struct svc_rqst; |
25 | ||
1da177e4 LT |
26 | #define NLM_MAXCOOKIELEN 32 |
27 | #define NLM_MAXSTRLEN 1024 | |
28 | ||
77f18f5e HH |
29 | #define nlm_granted cpu_to_be32(NLM_LCK_GRANTED) |
30 | #define nlm_lck_denied cpu_to_be32(NLM_LCK_DENIED) | |
31 | #define nlm_lck_denied_nolocks cpu_to_be32(NLM_LCK_DENIED_NOLOCKS) | |
32 | #define nlm_lck_blocked cpu_to_be32(NLM_LCK_BLOCKED) | |
33 | #define nlm_lck_denied_grace_period cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD) | |
1da177e4 | 34 | |
77f18f5e | 35 | #define nlm_drop_reply cpu_to_be32(30000) |
d343fce1 | 36 | |
1da177e4 LT |
37 | /* Lock info passed via NLM */ |
38 | struct nlm_lock { | |
39 | char * caller; | |
48df020a | 40 | unsigned int len; /* length of "caller" */ |
1da177e4 LT |
41 | struct nfs_fh fh; |
42 | struct xdr_netobj oh; | |
7bab377f | 43 | u32 svid; |
1da177e4 LT |
44 | struct file_lock fl; |
45 | }; | |
46 | ||
47 | /* | |
48 | * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes. | |
49 | * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to | |
50 | * 32 bytes. | |
51 | */ | |
52 | ||
53 | struct nlm_cookie | |
54 | { | |
55 | unsigned char data[NLM_MAXCOOKIELEN]; | |
56 | unsigned int len; | |
57 | }; | |
58 | ||
59 | /* | |
60 | * Generic lockd arguments for all but sm_notify | |
61 | */ | |
62 | struct nlm_args { | |
63 | struct nlm_cookie cookie; | |
64 | struct nlm_lock lock; | |
65 | u32 block; | |
66 | u32 reclaim; | |
67 | u32 state; | |
68 | u32 monitor; | |
69 | u32 fsm_access; | |
70 | u32 fsm_mode; | |
71 | }; | |
72 | ||
73 | typedef struct nlm_args nlm_args; | |
74 | ||
75 | /* | |
76 | * Generic lockd result | |
77 | */ | |
78 | struct nlm_res { | |
79 | struct nlm_cookie cookie; | |
e8c5c045 | 80 | __be32 status; |
1da177e4 LT |
81 | struct nlm_lock lock; |
82 | }; | |
83 | ||
84 | /* | |
85 | * statd callback when client has rebooted | |
86 | */ | |
87 | struct nlm_reboot { | |
576df463 CL |
88 | char *mon; |
89 | unsigned int len; | |
90 | u32 state; | |
91 | struct nsm_private priv; | |
1da177e4 LT |
92 | }; |
93 | ||
94 | /* | |
95 | * Contents of statd callback when monitored host rebooted | |
96 | */ | |
97 | #define NLMSVC_XDRSIZE sizeof(struct nlm_args) | |
98 | ||
026fec7e | 99 | int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *); |
63f8de37 | 100 | int nlmsvc_encode_testres(struct svc_rqst *, __be32 *); |
026fec7e CH |
101 | int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *); |
102 | int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *); | |
103 | int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *); | |
63f8de37 | 104 | int nlmsvc_encode_res(struct svc_rqst *, __be32 *); |
026fec7e | 105 | int nlmsvc_decode_res(struct svc_rqst *, __be32 *); |
63f8de37 | 106 | int nlmsvc_encode_void(struct svc_rqst *, __be32 *); |
026fec7e CH |
107 | int nlmsvc_decode_void(struct svc_rqst *, __be32 *); |
108 | int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *); | |
63f8de37 | 109 | int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *); |
026fec7e CH |
110 | int nlmsvc_decode_notify(struct svc_rqst *, __be32 *); |
111 | int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *); | |
1da177e4 LT |
112 | /* |
113 | int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *); | |
114 | int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *); | |
115 | int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *); | |
116 | int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *); | |
117 | */ | |
118 | ||
119 | #endif /* LOCKD_XDR_H */ |