Home | History | Annotate | Line # | Download | only in librpcsvc
      1  1.1     jtc /*
      2  1.1     jtc  * Network lock manager protocol definition
      3  1.1     jtc  * Copyright (C) 1986 Sun Microsystems, Inc.
      4  1.1     jtc  *
      5  1.1     jtc  * protocol used between local lock manager and remote lock manager
      6  1.1     jtc  */
      7  1.1     jtc 
      8  1.1     jtc #ifdef RPC_HDR
      9  1.1     jtc %#define LM_MAXSTRLEN	1024
     10  1.1     jtc %#define MAXNAMELEN	LM_MAXSTRLEN+1
     11  1.1     jtc #else
     12  1.3   lukem %#include <sys/cdefs.h>
     13  1.7  kleink %#ifndef __lint__
     14  1.1     jtc %/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
     15  1.1     jtc %/*static char sccsid[] = "from: * @(#)nlm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
     16  1.7  kleink %__RCSID("$NetBSD: nlm_prot.x,v 1.7 2004/07/01 22:52:34 kleink Exp $");
     17  1.7  kleink %#endif /* not __lint__ */
     18  1.1     jtc #endif
     19  1.1     jtc 
     20  1.1     jtc /*
     21  1.1     jtc  * status of a call to the lock manager
     22  1.1     jtc  */
     23  1.1     jtc enum nlm_stats {
     24  1.1     jtc 	nlm_granted = 0,
     25  1.1     jtc 	nlm_denied = 1,
     26  1.1     jtc 	nlm_denied_nolocks = 2,
     27  1.1     jtc 	nlm_blocked = 3,
     28  1.1     jtc 	nlm_denied_grace_period = 4
     29  1.1     jtc };
     30  1.1     jtc 
     31  1.1     jtc struct nlm_holder {
     32  1.1     jtc 	bool exclusive;
     33  1.1     jtc 	int svid;
     34  1.1     jtc 	netobj oh;
     35  1.1     jtc 	unsigned l_offset;
     36  1.1     jtc 	unsigned l_len;
     37  1.1     jtc };
     38  1.1     jtc 
     39  1.1     jtc union nlm_testrply switch (nlm_stats stat) {
     40  1.1     jtc 	case nlm_denied:
     41  1.1     jtc 		struct nlm_holder holder;
     42  1.1     jtc 	default:
     43  1.1     jtc 		void;
     44  1.1     jtc };
     45  1.1     jtc 
     46  1.1     jtc struct nlm_stat {
     47  1.1     jtc 	nlm_stats stat;
     48  1.1     jtc };
     49  1.1     jtc 
     50  1.1     jtc struct nlm_res {
     51  1.1     jtc 	netobj cookie;
     52  1.1     jtc 	nlm_stat stat;
     53  1.1     jtc };
     54  1.1     jtc 
     55  1.1     jtc struct nlm_testres {
     56  1.1     jtc 	netobj cookie;
     57  1.1     jtc 	nlm_testrply stat;
     58  1.1     jtc };
     59  1.1     jtc 
     60  1.1     jtc struct nlm_lock {
     61  1.1     jtc 	string caller_name<LM_MAXSTRLEN>;
     62  1.1     jtc 	netobj fh;		/* identify a file */
     63  1.1     jtc 	netobj oh;		/* identify owner of a lock */
     64  1.1     jtc 	int svid;		/* generated from pid for svid */
     65  1.1     jtc 	unsigned l_offset;
     66  1.1     jtc 	unsigned l_len;
     67  1.1     jtc };
     68  1.1     jtc 
     69  1.1     jtc struct nlm_lockargs {
     70  1.1     jtc 	netobj cookie;
     71  1.1     jtc 	bool block;
     72  1.1     jtc 	bool exclusive;
     73  1.1     jtc 	struct nlm_lock alock;
     74  1.1     jtc 	bool reclaim;		/* used for recovering locks */
     75  1.1     jtc 	int state;		/* specify local status monitor state */
     76  1.1     jtc };
     77  1.1     jtc 
     78  1.1     jtc struct nlm_cancargs {
     79  1.4  simonb 	netobj cookie;
     80  1.1     jtc 	bool block;
     81  1.1     jtc 	bool exclusive;
     82  1.1     jtc 	struct nlm_lock alock;
     83  1.1     jtc };
     84  1.1     jtc 
     85  1.1     jtc struct nlm_testargs {
     86  1.4  simonb 	netobj cookie;
     87  1.1     jtc 	bool exclusive;
     88  1.1     jtc 	struct nlm_lock alock;
     89  1.1     jtc };
     90  1.1     jtc 
     91  1.1     jtc struct nlm_unlockargs {
     92  1.4  simonb 	netobj cookie;
     93  1.1     jtc 	struct nlm_lock alock;
     94  1.1     jtc };
     95  1.1     jtc 
     96  1.1     jtc 
     97  1.1     jtc #ifdef RPC_HDR
     98  1.1     jtc %/*
     99  1.1     jtc % * The following enums are actually bit encoded for efficient
    100  1.1     jtc % * boolean algebra.... DON'T change them.....
    101  1.1     jtc % */
    102  1.1     jtc #endif
    103  1.1     jtc enum	fsh_mode {
    104  1.1     jtc 	fsm_DN  = 0,	/* deny none */
    105  1.1     jtc 	fsm_DR  = 1,	/* deny read */
    106  1.1     jtc 	fsm_DW  = 2,	/* deny write */
    107  1.1     jtc 	fsm_DRW = 3	/* deny read/write */
    108  1.1     jtc };
    109  1.1     jtc 
    110  1.1     jtc enum	fsh_access {
    111  1.1     jtc 	fsa_NONE = 0,	/* for completeness */
    112  1.1     jtc 	fsa_R    = 1,	/* read only */
    113  1.1     jtc 	fsa_W    = 2,	/* write only */
    114  1.1     jtc 	fsa_RW   = 3	/* read/write */
    115  1.1     jtc };
    116  1.1     jtc 
    117  1.1     jtc struct	nlm_share {
    118  1.1     jtc 	string caller_name<LM_MAXSTRLEN>;
    119  1.1     jtc 	netobj	fh;
    120  1.1     jtc 	netobj	oh;
    121  1.1     jtc 	fsh_mode	mode;
    122  1.1     jtc 	fsh_access	access;
    123  1.1     jtc };
    124  1.1     jtc 
    125  1.1     jtc struct	nlm_shareargs {
    126  1.1     jtc 	netobj	cookie;
    127  1.1     jtc 	nlm_share	share;
    128  1.1     jtc 	bool	reclaim;
    129  1.1     jtc };
    130  1.1     jtc 
    131  1.1     jtc struct	nlm_shareres {
    132  1.1     jtc 	netobj	cookie;
    133  1.1     jtc 	nlm_stats	stat;
    134  1.1     jtc 	int	sequence;
    135  1.1     jtc };
    136  1.1     jtc 
    137  1.1     jtc struct	nlm_notify {
    138  1.1     jtc 	string name<MAXNAMELEN>;
    139  1.1     jtc 	long state;
    140  1.1     jtc };
    141  1.1     jtc 
    142  1.5  bouyer #ifdef RPC_HDR
    143  1.5  bouyer %/* definitions for NLM version 4 */
    144  1.5  bouyer #endif
    145  1.5  bouyer enum nlm4_stats {
    146  1.5  bouyer 	nlm4_granted			= 0,
    147  1.5  bouyer 	nlm4_denied			= 1,
    148  1.5  bouyer 	nlm4_denied_nolock		= 2,
    149  1.5  bouyer 	nlm4_blocked			= 3,
    150  1.5  bouyer 	nlm4_denied_grace_period	= 4,
    151  1.5  bouyer 	nlm4_deadlck			= 5,
    152  1.5  bouyer 	nlm4_rofs			= 6,
    153  1.5  bouyer 	nlm4_stale_fh			= 7,
    154  1.5  bouyer 	nlm4_fbig			= 8,
    155  1.5  bouyer 	nlm4_failed			= 9
    156  1.5  bouyer };
    157  1.5  bouyer 
    158  1.5  bouyer struct nlm4_stat {
    159  1.5  bouyer 	nlm4_stats stat;
    160  1.5  bouyer };
    161  1.5  bouyer 
    162  1.5  bouyer struct nlm4_holder {
    163  1.5  bouyer 	bool exclusive;
    164  1.5  bouyer 	u_int32_t svid;
    165  1.5  bouyer 	netobj oh;
    166  1.5  bouyer 	u_int64_t l_offset;
    167  1.5  bouyer 	u_int64_t l_len;
    168  1.5  bouyer };
    169  1.5  bouyer 
    170  1.5  bouyer struct nlm4_lock {
    171  1.5  bouyer 	string caller_name<MAXNAMELEN>;
    172  1.5  bouyer 	netobj fh;
    173  1.5  bouyer 	netobj oh;
    174  1.5  bouyer 	u_int32_t svid;
    175  1.5  bouyer 	u_int64_t l_offset;
    176  1.5  bouyer 	u_int64_t l_len;
    177  1.5  bouyer };
    178  1.5  bouyer 
    179  1.5  bouyer struct nlm4_share {
    180  1.5  bouyer 	string caller_name<MAXNAMELEN>;
    181  1.5  bouyer 	netobj fh;
    182  1.5  bouyer 	netobj oh;
    183  1.5  bouyer 	fsh_mode mode;
    184  1.5  bouyer 	fsh_access access;
    185  1.5  bouyer };
    186  1.5  bouyer 
    187  1.5  bouyer union nlm4_testrply switch (nlm4_stats stat) {
    188  1.5  bouyer 	case nlm_denied:
    189  1.5  bouyer 		struct nlm4_holder holder;
    190  1.5  bouyer 	default:
    191  1.5  bouyer 		void;
    192  1.5  bouyer };
    193  1.5  bouyer 
    194  1.5  bouyer struct nlm4_testres {
    195  1.5  bouyer 	netobj cookie;
    196  1.5  bouyer 	nlm4_testrply stat;
    197  1.5  bouyer };
    198  1.5  bouyer 
    199  1.5  bouyer struct nlm4_testargs {
    200  1.5  bouyer 	netobj cookie;
    201  1.5  bouyer 	bool exclusive;
    202  1.5  bouyer 	struct nlm4_lock alock;
    203  1.5  bouyer };
    204  1.5  bouyer 
    205  1.5  bouyer struct nlm4_res {
    206  1.5  bouyer 	netobj cookie;
    207  1.5  bouyer 	nlm4_stat stat;
    208  1.5  bouyer };
    209  1.5  bouyer 
    210  1.5  bouyer struct nlm4_lockargs {
    211  1.5  bouyer 	netobj cookie;
    212  1.5  bouyer 	bool block;
    213  1.5  bouyer 	bool exclusive;
    214  1.5  bouyer 	struct nlm4_lock alock;
    215  1.5  bouyer 	bool reclaim;		/* used for recovering locks */
    216  1.5  bouyer 	int state;		/* specify local status monitor state */
    217  1.5  bouyer };
    218  1.5  bouyer 
    219  1.5  bouyer struct nlm4_cancargs {
    220  1.5  bouyer 	netobj cookie;
    221  1.5  bouyer 	bool block;
    222  1.5  bouyer 	bool exclusive;
    223  1.5  bouyer 	struct nlm4_lock alock;
    224  1.5  bouyer };
    225  1.5  bouyer 
    226  1.5  bouyer struct nlm4_unlockargs {
    227  1.5  bouyer 	netobj cookie;
    228  1.5  bouyer 	struct nlm4_lock alock;
    229  1.5  bouyer };
    230  1.5  bouyer 
    231  1.5  bouyer struct	nlm4_shareargs {
    232  1.5  bouyer 	netobj	cookie;
    233  1.5  bouyer 	nlm4_share	share;
    234  1.5  bouyer 	bool	reclaim;
    235  1.5  bouyer };
    236  1.5  bouyer 
    237  1.5  bouyer struct	nlm4_shareres {
    238  1.5  bouyer 	netobj	cookie;
    239  1.5  bouyer 	nlm4_stats	stat;
    240  1.5  bouyer 	int	sequence;
    241  1.5  bouyer };
    242  1.5  bouyer 
    243  1.1     jtc /*
    244  1.6  bouyer  * argument for the procedure called by rpc.statd when a monitored host
    245  1.6  bouyer  * status change.
    246  1.6  bouyer  * XXX assumes LM_MAXSTRLEN == SM_MAXSTRLEN
    247  1.6  bouyer  */
    248  1.6  bouyer struct nlm_sm_status {
    249  1.6  bouyer 	string mon_name<LM_MAXSTRLEN>; /* name of host */
    250  1.6  bouyer 	int state;			/* new state */
    251  1.6  bouyer 	opaque priv[16];		/* private data */
    252  1.6  bouyer };
    253  1.6  bouyer 
    254  1.6  bouyer /*
    255  1.1     jtc  * Over-the-wire protocol used between the network lock managers
    256  1.1     jtc  */
    257  1.1     jtc 
    258  1.1     jtc program NLM_PROG {
    259  1.6  bouyer 	version NLM_SM {
    260  1.6  bouyer 		void NLM_SM_NOTIFY(struct nlm_sm_status) = 1;
    261  1.6  bouyer 	} = 0;
    262  1.6  bouyer 
    263  1.1     jtc 	version NLM_VERS {
    264  1.1     jtc 
    265  1.1     jtc 		nlm_testres	NLM_TEST(struct nlm_testargs) =	1;
    266  1.1     jtc 
    267  1.1     jtc 		nlm_res		NLM_LOCK(struct nlm_lockargs) =	2;
    268  1.1     jtc 
    269  1.1     jtc 		nlm_res		NLM_CANCEL(struct nlm_cancargs) = 3;
    270  1.1     jtc 		nlm_res		NLM_UNLOCK(struct nlm_unlockargs) =	4;
    271  1.1     jtc 
    272  1.1     jtc 		/*
    273  1.1     jtc 		 * remote lock manager call-back to grant lock
    274  1.1     jtc 		 */
    275  1.1     jtc 		nlm_res		NLM_GRANTED(struct nlm_testargs)= 5;
    276  1.1     jtc 		/*
    277  1.1     jtc 		 * message passing style of requesting lock
    278  1.1     jtc 		 */
    279  1.1     jtc 		void		NLM_TEST_MSG(struct nlm_testargs) = 6;
    280  1.1     jtc 		void		NLM_LOCK_MSG(struct nlm_lockargs) = 7;
    281  1.1     jtc 		void		NLM_CANCEL_MSG(struct nlm_cancargs) =8;
    282  1.1     jtc 		void		NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9;
    283  1.1     jtc 		void		NLM_GRANTED_MSG(struct nlm_testargs) = 10;
    284  1.1     jtc 		void		NLM_TEST_RES(nlm_testres) = 11;
    285  1.1     jtc 		void		NLM_LOCK_RES(nlm_res) = 12;
    286  1.1     jtc 		void		NLM_CANCEL_RES(nlm_res) = 13;
    287  1.1     jtc 		void		NLM_UNLOCK_RES(nlm_res) = 14;
    288  1.1     jtc 		void		NLM_GRANTED_RES(nlm_res) = 15;
    289  1.1     jtc 	} = 1;
    290  1.1     jtc 
    291  1.1     jtc 	version NLM_VERSX {
    292  1.1     jtc 		nlm_shareres	NLM_SHARE(nlm_shareargs) = 20;
    293  1.1     jtc 		nlm_shareres	NLM_UNSHARE(nlm_shareargs) = 21;
    294  1.1     jtc 		nlm_res		NLM_NM_LOCK(nlm_lockargs) = 22;
    295  1.1     jtc 		void		NLM_FREE_ALL(nlm_notify) = 23;
    296  1.1     jtc 	} = 3;
    297  1.1     jtc 
    298  1.5  bouyer 	version NLM_VERS4 {
    299  1.5  bouyer 		nlm4_testres NLM4_TEST(nlm4_testargs) = 1;
    300  1.5  bouyer 		nlm4_res NLM4_LOCK(nlm4_lockargs) = 2;
    301  1.5  bouyer 		nlm4_res NLM4_CANCEL(nlm4_cancargs) = 3;
    302  1.5  bouyer 		nlm4_res NLM4_UNLOCK(nlm4_unlockargs) = 4;
    303  1.5  bouyer 		nlm4_res NLM4_GRANTED(nlm4_testargs) = 5;
    304  1.5  bouyer 		void NLM4_TEST_MSG(nlm4_testargs) = 6;
    305  1.5  bouyer 		void NLM4_LOCK_MSG(nlm4_lockargs) = 7;
    306  1.5  bouyer 		void NLM4_CANCEL_MSG(nlm4_cancargs) = 8;
    307  1.5  bouyer 		void NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9;
    308  1.5  bouyer 		void NLM4_GRANTED_MSG(nlm4_testargs) = 10;
    309  1.5  bouyer 		void NLM4_TEST_RES(nlm4_testres) = 11;
    310  1.5  bouyer 		void NLM4_LOCK_RES(nlm4_res) = 12;
    311  1.5  bouyer 		void NLM4_CANCEL_RES(nlm4_res) = 13;
    312  1.5  bouyer 		void NLM4_UNLOCK_RES(nlm4_res) = 14;
    313  1.5  bouyer 		void NLM4_GRANTED_RES(nlm4_res) = 15;
    314  1.5  bouyer 		nlm4_shareres NLM4_SHARE(nlm4_shareargs) = 20;
    315  1.5  bouyer 		nlm4_shareres NLM4_UNSHARE(nlm4_shareargs) = 21;
    316  1.5  bouyer 		nlm4_res NLM4_NM_LOCK(nlm4_lockargs) = 22;
    317  1.5  bouyer 		void NLM4_FREE_ALL(nlm_notify) = 23;
    318  1.5  bouyer 	} = 4;
    319  1.1     jtc } = 100021;
    320