cld.h revision 30692c65c4174412c90e79489e98ab85c1a7412f
130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/*
230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Upcall description for nfsdcld communication
330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (c) 2012 Red Hat, Inc.
530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Author(s): Jeff Layton <jlayton@redhat.com>
630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  This program is free software; you can redistribute it and/or modify
830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  it under the terms of the GNU General Public License as published by
930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  the Free Software Foundation; either version 2 of the License, or
1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  (at your option) any later version.
1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  This program is distributed in the hope that it will be useful,
1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  but WITHOUT ANY WARRANTY; without even the implied warranty of
1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  GNU General Public License for more details.
1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  You should have received a copy of the GNU General Public License
1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  along with this program; if not, write to the Free Software
1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */
2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef _NFSD_CLD_H
2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define _NFSD_CLD_H
2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* latest upcall version available */
2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define CLD_UPCALL_VERSION 1
2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* defined by RFC3530 */
2930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NFS4_OPAQUE_LIMIT 1024
3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3130692c65c4174412c90e79489e98ab85c1a7412fBen Chengenum cld_command {
3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	Cld_Create,		/* create a record for this cm_id */
3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	Cld_Remove,		/* remove record of this cm_id */
3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	Cld_Check,		/* is this cm_id allowed? */
3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	Cld_GraceDone,		/* grace period is complete */
3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* representation of long-form NFSv4 client ID */
3930692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct cld_name {
4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint16_t	cn_len;				/* length of cm_id */
4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	unsigned char	cn_id[NFS4_OPAQUE_LIMIT];	/* client-provided */
4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* message struct for communication with userspace */
4530692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct cld_msg {
4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint8_t		cm_vers;		/* upcall version */
4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint8_t		cm_cmd;			/* upcall command */
4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	int16_t		cm_status;		/* return code */
4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t	cm_xid;			/* transaction id */
5030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	union {
5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		int64_t		cm_gracetime;	/* grace period start time */
5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		struct cld_name	cm_name;
5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	} __attribute__((packed)) cm_u;
5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* !_NFSD_CLD_H */
57