blob: 7ab9f264313f09ba07e85a1e3dee4c3d8af7c77d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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
Chuck Levere6765b82008-12-11 17:56:14 -050017#define SM_MAXSTRLEN 1024
Chuck Lever7e44d3b2008-12-05 19:03:16 -050018#define SM_PRIV_SIZE 16
19
20struct nsm_private {
21 unsigned char data[SM_PRIV_SIZE];
22};
23
NeilBrownd343fce2006-10-17 00:10:18 -070024struct svc_rqst;
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define NLM_MAXCOOKIELEN 32
27#define NLM_MAXSTRLEN 1024
28
Harvey Harrison77f18f52009-02-11 17:16:58 -080029#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Harvey Harrison77f18f52009-02-11 17:16:58 -080035#define nlm_drop_reply cpu_to_be32(30000)
NeilBrownd343fce2006-10-17 00:10:18 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037/* Lock info passed via NLM */
38struct nlm_lock {
39 char * caller;
Chuck Lever48df020a2007-11-01 16:56:53 -040040 unsigned int len; /* length of "caller" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 struct nfs_fh fh;
42 struct xdr_netobj oh;
Trond Myklebust7bab3772006-03-20 13:44:06 -050043 u32 svid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 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
53struct 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 */
62struct 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
73typedef struct nlm_args nlm_args;
74
75/*
76 * Generic lockd result
77 */
78struct nlm_res {
79 struct nlm_cookie cookie;
Al Viroe8c5c042006-12-13 00:35:03 -080080 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 struct nlm_lock lock;
82};
83
84/*
85 * statd callback when client has rebooted
86 */
87struct nlm_reboot {
Chuck Lever576df462008-12-05 19:03:39 -050088 char *mon;
89 unsigned int len;
90 u32 state;
91 struct nsm_private priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
93
94/*
95 * Contents of statd callback when monitored host rebooted
96 */
97#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
98
Christoph Hellwig026fec72017-05-08 19:01:48 +020099int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200100int nlmsvc_encode_testres(struct svc_rqst *, __be32 *);
Christoph Hellwig026fec72017-05-08 19:01:48 +0200101int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *);
102int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *);
103int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200104int nlmsvc_encode_res(struct svc_rqst *, __be32 *);
Christoph Hellwig026fec72017-05-08 19:01:48 +0200105int nlmsvc_decode_res(struct svc_rqst *, __be32 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200106int nlmsvc_encode_void(struct svc_rqst *, __be32 *);
Christoph Hellwig026fec72017-05-08 19:01:48 +0200107int nlmsvc_decode_void(struct svc_rqst *, __be32 *);
108int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200109int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *);
Christoph Hellwig026fec72017-05-08 19:01:48 +0200110int nlmsvc_decode_notify(struct svc_rqst *, __be32 *);
111int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112/*
113int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
114int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
115int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
116int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
117 */
118
119#endif /* LOCKD_XDR_H */